Browse Source

get frequent flying number of a Customer

feature-pr-CustomerClass
Sona Markosyan 3 years ago
parent
commit
e6465af3d1
  1. 19
      src/main/java/hs/fulda/de/ci/exam/project/Customer.java
  2. 38
      src/test/java/hs/fulda/de/ci/exam/project/CustomerTest.java

19
src/main/java/hs/fulda/de/ci/exam/project/Customer.java

@ -0,0 +1,19 @@
package hs.fulda.de.ci.exam.project;
public class Customer extends Person{
private String frequentFlyerNumber;
public Customer(String name, Address address, String email, String phone) {
super(name, address, email, phone);
}
public void setFrequentFlyerNumber(String frequentFlyerNumber) {
this.frequentFlyerNumber = frequentFlyerNumber;
}
public String getFrequentFlyerNumber() {
return frequentFlyerNumber;
}
}

38
src/test/java/hs/fulda/de/ci/exam/project/CustomerTest.java

@ -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");
}
}
Loading…
Cancel
Save