Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…-core into OH2-396_add_lock_mechanism
  • Loading branch information
SilverD3 committed Oct 23, 2024
2 parents c49e219 + a7252ae commit a9d9334
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions src/test/java/org/isf/sms/Tests.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ void testToString() throws Exception {
Sms foundSms = smsIoOperation.getByID(code);
assertThat(foundSms).isNotNull();
assertThat(foundSms.toString())
.isEqualTo("Sms [smsId=1, smsDate=2010-09-08T00:00, smsDateSched=2011-09-08T00:00, smsNumber=***, smsText=***, smsDateSent=null, smsUser=TestUser, module=TestModule, moduleID=TestModId, hashCode=0]");
.isEqualTo(
"Sms [smsId=1, smsDate=2010-09-08T00:00, smsDateSched=2011-09-08T00:00, smsNumber=***, smsText=***, smsDateSent=null, smsUser=TestUser, module=TestModule, moduleID=TestModId, hashCode=0]");
}

@Test
Expand All @@ -233,7 +234,7 @@ void testGetAll() throws Exception {
assertThat(allSms).isEmpty();

allSms = smsManager.getAll(LocalDateTime.of(2011, 8, 8, 0, 0, 0),
LocalDateTime.of(2011, 9, 15, 0, 0, 0));
LocalDateTime.of(2011, 9, 15, 0, 0, 0));
assertThat(allSms).hasSize(1);
}

Expand All @@ -257,7 +258,7 @@ void testSaveSplitFalse() throws Exception {
sms.setSmsNumber("+1320241494");
smsManager.saveOrUpdate(sms, false);
List<Sms> allSms = smsManager.getAll(LocalDateTime.of(2011, 8, 8, 0, 0, 0),
LocalDateTime.of(2011, 9, 15, 0, 0, 0));
LocalDateTime.of(2011, 9, 15, 0, 0, 0));
assertThat(allSms).hasSize(1);
assertThat(smsIoOperation.getByID(1)).isNotNull();
}
Expand All @@ -268,7 +269,7 @@ void testSaveSplitTrue() throws Exception {
sms.setSmsNumber("+1320241494");
smsManager.saveOrUpdate(sms, true);
List<Sms> allSms = smsManager.getAll(LocalDateTime.of(2011, 8, 8, 0, 0, 0),
LocalDateTime.of(2011, 9, 15, 0, 0, 0));
LocalDateTime.of(2011, 9, 15, 0, 0, 0));
assertThat(allSms).hasSize(1);
assertThat(smsIoOperation.getByID(1)).isNotNull();
}
Expand All @@ -283,7 +284,7 @@ void testSaveSplitTrueTextGreaterThanMax() throws Exception {
UserSession.setUser(user);
smsManager.saveOrUpdate(sms, true);
List<Sms> allSms = smsManager.getAll(LocalDateTime.of(2011, 8, 8, 0, 0, 0),
LocalDateTime.of(2011, 9, 15, 0, 0, 0));
LocalDateTime.of(2011, 9, 15, 0, 0, 0));
assertThat(allSms).hasSize(3);
}

Expand All @@ -296,7 +297,7 @@ void testSaveSplitFalseTextGreaterThanMax() throws Exception {
User user = new User("admin", userGroup, "password", "description");
UserSession.setUser(user);
assertThatThrownBy(() -> smsManager.saveOrUpdate(sms, false))
.isInstanceOf(OHDataValidationException.class);
.isInstanceOf(OHDataValidationException.class);
}

@Test
Expand All @@ -307,10 +308,10 @@ void testSaveValidationSmsNumberBad() throws Exception {
User user = new User("admin", userGroup, "password", "description");
UserSession.setUser(user);
assertThatThrownBy(() -> smsManager.saveOrUpdate(sms, false))
.isInstanceOf(OHDataValidationException.class)
.has(
new Condition<Throwable>(
e -> ((OHServiceException) e).getMessages().size() == 1, "Expecting single validation error"));
.isInstanceOf(OHDataValidationException.class)
.has(
new Condition<Throwable>(
e -> ((OHServiceException) e).getMessages().size() == 1, "Expecting single validation error"));
}

@Test
Expand All @@ -322,10 +323,10 @@ void testSaveValidationSmsTextEmpty() throws Exception {
User user = new User("admin", userGroup, "password", "description");
UserSession.setUser(user);
assertThatThrownBy(() -> smsManager.saveOrUpdate(sms, false))
.isInstanceOf(OHDataValidationException.class)
.has(
new Condition<Throwable>(
e -> ((OHServiceException) e).getMessages().size() == 1, "Expecting single validation error"));
.isInstanceOf(OHDataValidationException.class)
.has(
new Condition<Throwable>(
e -> ((OHServiceException) e).getMessages().size() == 1, "Expecting single validation error"));
}

@Test
Expand Down Expand Up @@ -370,15 +371,16 @@ void testSmsSenderOperationsSendSMSNoGateway() throws Exception {
assertThat(dummySmsSenderOperatinos.sendSMS(sms)).isFalse();
}

@Test
void testSmsSenderOperationsSendSMSFailure() throws Exception {
Sms sms = testSms.setup(true);
sms.setSmsNumber("+1320241494");
sms.setSmsText("SomeText");
assertThat(smsSenderOperations.initialize()).isTrue();
smsSenderOperations.preSMSSending(sms);
assertThat(smsSenderOperations.sendSMS(sms)).isFalse();
}
// Waiting for OP-1354 fix
// @Test
// void testSmsSenderOperationsSendSMSFailure() throws Exception {
// Sms sms = testSms.setup(true);
// sms.setSmsNumber("+1320241494");
// sms.setSmsText("SomeText");
// assertThat(smsSenderOperations.initialize()).isTrue();
// smsSenderOperations.preSMSSending(sms);
// assertThat(smsSenderOperations.sendSMS(sms)).isFalse();
// }

@Test
void testSmsSenderOperationsTerminate() throws Exception {
Expand Down

0 comments on commit a9d9334

Please sign in to comment.