use of org.hisp.dhis.sms.command.SMSCommand in project dhis2-core by dhis2.
the class SMSCommandServiceTest method createEventRegistrationParserCommand.
private void createEventRegistrationParserCommand() {
dataElementD = createDataElement('D');
dataElementService.addDataElement(dataElementD);
programD = createProgram('D');
programService.addProgram(programD);
programStageD = createProgramStage('S', programD);
programStageService.saveProgramStage(programStageD);
eventRegistrationCommand = new SMSCommand();
eventRegistrationCommand.setName(eventRegistrationCommandName);
eventRegistrationCommand.setProgram(programD);
eventRegistrationCommand.setProgramStage(programStageD);
smsCodeEvent = new SMSCode();
smsCodeEvent.setCode("E");
smsCodeEvent.setDataElement(dataElementD);
eventRegistrationCommand.setCodes(Sets.newHashSet(smsCodeEvent));
}
use of org.hisp.dhis.sms.command.SMSCommand in project dhis2-core by dhis2.
the class SMSCommandServiceTest method createAlertParserCommand.
private void createAlertParserCommand() {
alertParserCommand = new SMSCommand();
alertParserCommand.setName(alertMessageCommandName);
alertParserCommand.setParserType(ParserType.ALERT_PARSER);
alertParserCommand.setSuccessMessage(success);
alertParserCommand.setWrongFormatMessage(wrongFormat);
defaultMessagesB.put(SUCCESS_MESSAGE, success);
defaultMessagesB.put(WRONG_FORMAT_MESSAGE, wrongFormat);
}
use of org.hisp.dhis.sms.command.SMSCommand in project dhis2-core by dhis2.
the class SMSCommandServiceTest method createKeyValueCommands.
// -------------------------------------------------------------------------
// Supportive Methods
// -------------------------------------------------------------------------
private void createKeyValueCommands() {
dataElementA = createDataElement('A');
dataElementB = createDataElement('B');
dataElementC = createDataElement('C');
dataElementService.addDataElement(dataElementA);
dataElementService.addDataElement(dataElementB);
dataElementService.addDataElement(dataElementC);
dataSetA = createDataSet('A');
dataSetA.addDataSetElement(dataElementA);
dataSetA.addDataSetElement(dataElementB);
dataSetService.addDataSet(dataSetA);
smsCodeA1 = new SMSCode();
smsCodeA1.setCode("a1");
smsCodeA1.setDataElement(dataElementA);
smsCodeA2 = new SMSCode();
smsCodeA2.setCode("a2");
smsCodeA2.setDataElement(dataElementB);
smsCodeB1 = new SMSCode();
smsCodeB1.setCode("b1");
smsCodeB1.setDataElement(dataElementA);
smsCodeB2 = new SMSCode();
smsCodeB2.setCode("b2");
smsCodeB2.setDataElement(dataElementB);
smsCodeC = new SMSCode();
smsCodeC.setCode("c");
smsCodeC.setDataElement(dataElementC);
characterA = new SMSSpecialCharacter();
characterA.setName("charA");
characterA.setValue("vCharA");
characterB = new SMSSpecialCharacter();
characterB.setName("charB");
characterB.setValue("vCharB");
keyValueCommandA = new SMSCommand();
keyValueCommandA.setName(keyValueCommandName);
keyValueCommandA.setParserType(ParserType.KEY_VALUE_PARSER);
keyValueCommandA.setDataset(dataSetA);
keyValueCommandA.setCodes(Sets.newHashSet(smsCodeA1, smsCodeA2));
keyValueCommandA.setSpecialCharacters(Sets.newHashSet(characterA));
keyValueCommandA.setSuccessMessage(success);
defaultMessagesA.put(SUCCESS_MESSAGE, success);
keyValueCommandB = new SMSCommand();
keyValueCommandB.setName(keyValueCommandNameB);
keyValueCommandB.setParserType(ParserType.KEY_VALUE_PARSER);
keyValueCommandB.setDataset(dataSetA);
keyValueCommandB.setCodes(Sets.newHashSet(smsCodeB1, smsCodeB2));
}
use of org.hisp.dhis.sms.command.SMSCommand in project dhis2-core by dhis2.
the class SmsUtilsTest method testSelectOrganisationUnit.
@Test
void testSelectOrganisationUnit() {
OrganisationUnit expected = organisationUnitA;
Map<String, String> parsedMessage = Maps.newHashMap(ImmutableMap.of("ORG", "TESTORGA"));
SMSCommand smsCommand = new SMSCommand();
assertEquals(expected, SmsUtils.selectOrganisationUnit(Lists.newArrayList(organisationUnitA), parsedMessage, smsCommand));
assertThrows(SMSParserException.class, () -> SmsUtils.selectOrganisationUnit(Lists.newArrayList(organisationUnitB, organisationUnitC), parsedMessage, smsCommand));
}
use of org.hisp.dhis.sms.command.SMSCommand in project dhis2-core by dhis2.
the class SmsUtilsTest method testGetUser.
@Test
void testGetUser() {
User returnedUser = SmsUtils.getUser("", new SMSCommand(), Lists.newArrayList(userA));
assertEquals(userA, returnedUser);
assertThrows(SMSParserException.class, () -> SmsUtils.getUser("", new SMSCommand(), Lists.newArrayList(userA, userB)));
}
Aggregations