use of org.hisp.dhis.outboundmessage.OutboundMessage in project dhis2-core by dhis2.
the class BulkSmsGatewayTest method initTest.
@BeforeEach
public void initTest() {
smsGatewayConfig = new BulkSmsGatewayConfig();
smsGatewayConfig.setDefault(true);
smsGatewayConfig.setUsername("username");
smsGatewayConfig.setPassword("password");
recipients.add(PHONE_NUMBER);
outboundMessageList.add(new OutboundMessage(SUBJECT, MESSAGE, recipients));
outboundMessageList.add(new OutboundMessage(SUBJECT, MESSAGE, recipients));
outboundMessageList.add(new OutboundMessage(SUBJECT, MESSAGE, recipients));
batch = new OutboundMessageBatch(outboundMessageList, DeliveryChannel.SMS);
when(pbeStringEncryptor.decrypt(anyString())).thenReturn(smsGatewayConfig.getPassword());
}
use of org.hisp.dhis.outboundmessage.OutboundMessage in project dhis2-core by dhis2.
the class SMPPGatewayTest method testBulkMessage.
@Test
void testBulkMessage() {
List<OutboundMessage> messages = new ArrayList<>();
messages.add(new OutboundMessage(SUBJECT, TEXT, Sets.newHashSet(RECIPIENT)));
messages.add(new OutboundMessage(SUBJECT, TEXT, Sets.newHashSet(RECIPIENT)));
messages.add(new OutboundMessage(SUBJECT, TEXT, Sets.newHashSet(RECIPIENT)));
messages.add(new OutboundMessage(SUBJECT, TEXT, Sets.newHashSet(RECIPIENT)));
messages.add(new OutboundMessage(SUBJECT, TEXT, Sets.newHashSet(RECIPIENT)));
messages.add(new OutboundMessage(SUBJECT, TEXT, Sets.newHashSet(RECIPIENT)));
messages.add(new OutboundMessage(SUBJECT, TEXT, Sets.newHashSet(RECIPIENT)));
messages.add(new OutboundMessage(SUBJECT, TEXT, Sets.newHashSet(RECIPIENT)));
OutboundMessageBatch batch = new OutboundMessageBatch(messages, DeliveryChannel.SMS);
List<OutboundMessageResponse> responses = gateway.sendBatch(batch, config);
assertNotNull(responses);
assertEquals(8, responses.size());
responses.forEach(r -> assertTrue(r.isOk()));
}
use of org.hisp.dhis.outboundmessage.OutboundMessage in project dhis2-core by dhis2.
the class FakeMessageSender method sendMessageBatch.
@Override
public OutboundMessageResponseSummary sendMessageBatch(OutboundMessageBatch batch) {
for (OutboundMessage msg : batch.getMessages()) {
sendMessage(msg.getSubject(), msg.getText(), msg.getRecipients());
}
OutboundMessageResponseSummary summary = new OutboundMessageResponseSummary();
int n = batch.getMessages().size();
summary.setSent(n);
summary.setTotal(n);
summary.setBatchStatus(OutboundMessageBatchStatus.COMPLETED);
summary.setChannel(batch.getDeliveryChannel());
return summary;
}
use of org.hisp.dhis.outboundmessage.OutboundMessage in project dhis2-core by dhis2.
the class FakeMessageSender method sendMessage.
@Override
public OutboundMessageResponse sendMessage(String subject, String text, Set<String> recipients) {
OutboundMessage message = new OutboundMessage(subject, text, recipients);
for (String recipient : recipients) {
sendMessagesByRecipient.computeIfAbsent(recipient, key -> new ArrayList<>()).add(message);
}
OutboundMessageResponse response = new OutboundMessageResponse();
response.setOk(true);
response.setAsync(false);
response.setDescription(subject + ":" + text);
response.setResponseObject(EmailResponse.SENT);
return response;
}
use of org.hisp.dhis.outboundmessage.OutboundMessage in project dhis2-core by dhis2.
the class UserControllerTest method testResetToInvite.
@Test
void testResetToInvite() {
assertStatus(HttpStatus.NO_CONTENT, POST("/users/" + peter.getUid() + "/reset"));
OutboundMessage email = assertMessageSendTo("peter@pan.net");
assertValidToken(extractTokenFromEmailText(email.getText()));
}
Aggregations