Browse Source

sms notification

feature-pr-notification
Imron 3 years ago
parent
commit
7abce6392e
  1. 1
      src/main/java/hs/fulda/de/ci/exam/project/EmailNotification.java
  2. 9
      src/main/java/hs/fulda/de/ci/exam/project/FlightReservation.java
  3. 12
      src/main/java/hs/fulda/de/ci/exam/project/SmsNotification.java
  4. 8
      src/test/java/hs/fulda/de/ci/exam/project/NotificationTest.java

1
src/main/java/hs/fulda/de/ci/exam/project/EmailNotification.java

@ -5,6 +5,7 @@ import java.util.regex.Pattern;
public class EmailNotification extends Notification {
String email;
String content;
public EmailNotification(String email, String content) {
super();
this.email = email;

9
src/main/java/hs/fulda/de/ci/exam/project/FlightReservation.java

@ -61,10 +61,15 @@ public class FlightReservation {
status = Confirmed;
}
public boolean notifyUser(String type, String email, String content) {
public boolean notifyUser(String type, String to, String content) {
Notification notification = null;
switch (type) {
case "email": notification = new EmailNotification(email, content);
case "email":
notification = new EmailNotification(to, content);
break;
case "sms":
notification = new SmsNotification(to, content);
break;
}
return notification.sendNotification();
}

12
src/main/java/hs/fulda/de/ci/exam/project/SmsNotification.java

@ -0,0 +1,12 @@
package hs.fulda.de.ci.exam.project;
public class SmsNotification extends Notification {
public SmsNotification(String to, String content) {
super();
}
@Override
public boolean sendNotification() {
return true;
}
}

8
src/test/java/hs/fulda/de/ci/exam/project/NotificationTest.java

@ -27,4 +27,12 @@ public class NotificationTest {
boolean result = reservation.notifyUser("email", "test@gmail.com", "Reservation is Confirmed!");
assertTrue(result);
}
@Test
public void smsNotificationShouldBeSentWhenSmsTypeIsChosen(){
FlightReservation reservation = new FlightReservation();
reservation.setStatus(Confirmed);
boolean result = reservation.notifyUser("sms", "01788370107", "Reservation is successfull");
assertTrue(result);
}
}
Loading…
Cancel
Save