Browse Source

getOptions from CDPlayer tested on ArrayContainsInterfaceMethods.

feature-pr-cdPlayerGetOptions
JPANZO 3 years ago
parent
commit
63db5393e8
  1. 22
      src/test/java/device/cdPlayer/CDPlayerTest.java

22
src/test/java/device/cdPlayer/CDPlayerTest.java

@ -1,5 +1,6 @@
package device.cdPlayer;
import device.Device;
import device.cdPlayer.exceptions.*;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
@ -7,6 +8,10 @@ import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.mockito.junit.jupiter.MockitoExtension;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;
import static org.assertj.core.api.Assertions.assertThat;
@ -231,19 +236,30 @@ class CDPlayerTest {
@ParameterizedTest
@MethodSource("getOptionsTestData")
void getOptionsTest(String testName,String testDirection, CDPlayer _cdPlayer, String expectedResult){
void getOptionsTest(String testName,String testDirection, CDPlayer _cdPlayer){
if(testDirection.equals("ReturnValueNotNull")) {
assertThat(_cdPlayer.getOptions()).describedAs(testName).isNotEqualTo(null);
}
if(testDirection.equals("ArrayLengthGreaterThen0")) {
assertThat(_cdPlayer.getOptions().length).describedAs(testName).isNotEqualTo(0);
}
if(testDirection.equals("ArrayContainsInterfaceMethods")) {
Method[]interfaceMethods=Device.class.getDeclaredMethods();
List<String> deviceMethods = new ArrayList<String>(Arrays.asList(_cdPlayer.getOptions()));
for (int i = 0; i < interfaceMethods.length; i++) {
assertThat(deviceMethods.contains(interfaceMethods[i].getName())).describedAs(testName).isEqualTo(true);
}
}
}
static Stream<Arguments> getOptionsTestData () {
CDPlayer cdPlayer1 = new CDPlayer();
return Stream.of(
Arguments.of("[getOptions(): shouldNotReturnNull] => ReturnValueNotNull", "ReturnValueNotNull", cdPlayer1,null),
Arguments.of("[getOptions(): shouldReturnAnArrayWithLengthGreaterThen0] => ArrayLengthGreaterThen0", "ArrayLengthGreaterThen0", cdPlayer1,null)
Arguments.of("[getOptions(): shouldNotReturnNull] => ReturnValueNotNull", "ReturnValueNotNull", cdPlayer1),
Arguments.of("[getOptions(): shouldReturnAnArrayWithLengthGreaterThen0] => ArrayLengthGreaterThen0", "ArrayLengthGreaterThen0", cdPlayer1),
Arguments.of("[getOptions(): shouldReturnAnArrayWithInAllInterfaceMethods] => ArrayContainsInterfaceMethods", "ArrayContainsInterfaceMethods", cdPlayer1)
);
}

Loading…
Cancel
Save