|
@ -0,0 +1,38 @@ |
|
|
|
|
|
package hs.fulda.de.ci.exam.project; |
|
|
|
|
|
|
|
|
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
|
|
|
|
|
|
|
|
import java.lang.reflect.Field; |
|
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat; |
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals; |
|
|
|
|
|
|
|
|
|
|
|
public class CustomerTest { |
|
|
|
|
|
|
|
|
|
|
|
final Address address1 = new Address("Fuldaer str", "Fulda", "Hessen", "36037", "Germany"); |
|
|
|
|
|
final Customer person1 = new Customer("Max Mustermann", address1, "max.mustermann@gmail.com", "015147890206"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
public void test_setFlyingNumber() throws NoSuchFieldException, IllegalAccessException{ |
|
|
|
|
|
|
|
|
|
|
|
person1.setFrequentFlyerNumber("5"); |
|
|
|
|
|
|
|
|
|
|
|
final Field field = person1.getClass().getDeclaredField("frequentFlyerNumber"); |
|
|
|
|
|
field.setAccessible(true); |
|
|
|
|
|
assertEquals(field.get(person1), "5","set frequent flying number of the customer"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
public void test_getFlyingNumber() throws NoSuchFieldException, IllegalAccessException { |
|
|
|
|
|
|
|
|
|
|
|
final Field field = person1.getClass().getDeclaredField("frequentFlyerNumber"); |
|
|
|
|
|
field.setAccessible(true); |
|
|
|
|
|
field.set(person1, "10"); |
|
|
|
|
|
|
|
|
|
|
|
final String result = person1.getFrequentFlyerNumber(); |
|
|
|
|
|
|
|
|
|
|
|
assertEquals(result, "10","get frequent flying number of the customer"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |