You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
2.1 KiB
60 lines
2.1 KiB
package hs.fulda.de.ci.exam.project;
|
|
|
|
import org.junit.Test;
|
|
|
|
import static hs.fulda.de.ci.exam.project.ReservationStatus.Confirmed;
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
public class NotificationTest {
|
|
|
|
EmailNotification email = new EmailNotification("test@gmail.com", "HelloWorld");
|
|
EmailNotification emailInvalid = new EmailNotification("testgmail.com", "HelloWorld");
|
|
FlightReservation reservation = new FlightReservation();
|
|
SmsNotification sms = new SmsNotification("01788370107", "Reservation confirmed");
|
|
SmsNotification smsInvalid = new SmsNotification("123", "Some Wrong Number");
|
|
|
|
|
|
@Test
|
|
public void emailValidiationShouldReturnTrueForValidEmail() {
|
|
boolean result = email.sendNotification();
|
|
boolean expected = true;
|
|
assertThat(expected).isEqualTo(result);
|
|
}
|
|
|
|
@Test
|
|
public void emailValidiationShouldReturnFalseForInValidEmail() {
|
|
boolean result = emailInvalid.sendNotification();
|
|
boolean expected = false;
|
|
assertThat(expected).isEqualTo(result);
|
|
}
|
|
|
|
@Test
|
|
public void emailNotificationShouldBeSentWhenFlighReservationCompleted() {
|
|
reservation.setStatus(Confirmed);
|
|
boolean result = reservation.notifyUser("email", "test@gmail.com", "Reservation is Confirmed!");
|
|
boolean expected = true;
|
|
assertThat(expected).isEqualTo(result);
|
|
}
|
|
|
|
@Test
|
|
public void smsNotificationShouldBeSentWhenSmsTypeIsChosen() {
|
|
reservation.setStatus(Confirmed);
|
|
boolean result = reservation.notifyUser("sms", "01788370107", "Reservation is successfull");
|
|
boolean expected = true;
|
|
assertThat(expected).isEqualTo(result);
|
|
}
|
|
|
|
@Test
|
|
public void smsIsSentWhenNumberIsValid() {
|
|
boolean result = sms.sendNotification();
|
|
boolean expected = true;
|
|
assertThat(expected).isEqualTo(result);
|
|
}
|
|
|
|
@Test
|
|
public void smsShouldNotBeSentWhenNumberIsInvalid() {
|
|
boolean result = smsInvalid.sendNotification();
|
|
boolean expected = false;
|
|
assertThat(expected).isEqualTo(result);
|
|
}
|
|
}
|