Browse Source

sms validation

feature-pr-notification
Imron 3 years ago
parent
commit
f4c587cf42
  1. 13
      src/main/java/hs/fulda/de/ci/exam/project/SmsNotification.java
  2. 7
      src/test/java/hs/fulda/de/ci/exam/project/NotificationTest.java

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

@ -1,12 +1,25 @@
package hs.fulda.de.ci.exam.project;
public class SmsNotification extends Notification {
String to;
String content;
public SmsNotification(String to, String content) {
super();
this.to = to;
this.content = content;
}
@Override
public boolean sendNotification() {
if (isValidEmail(to)) {
System.out.println("SMS is sent to " + to);
return true;
}
System.out.println("Invalid Number");
return false;
}
private boolean isValidEmail(String to) {
return true;
}
}

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

@ -35,4 +35,11 @@ public class NotificationTest {
boolean result = reservation.notifyUser("sms", "01788370107", "Reservation is successfull");
assertTrue(result);
}
@Test
public void smsIsSentWhenNumberIsValid(){
SmsNotification sms = new SmsNotification("01788370107", "Reservation confirmed");
boolean result = sms.sendNotification();
assertTrue(result);
}
}
Loading…
Cancel
Save