Search in sources :

Example 31 with SMSCommand

use of org.hisp.dhis.sms.command.SMSCommand in project dhis2-core by dhis2.

the class SMSCommandServiceTest method createTeiCommand.

private void createTeiCommand() {
    trackedEntityAttributeA = createTrackedEntityAttribute('A');
    trackedEntityAttributeB = createTrackedEntityAttribute('B');
    trackedEntityAttributeService.addTrackedEntityAttribute(trackedEntityAttributeA);
    trackedEntityAttributeService.addTrackedEntityAttribute(trackedEntityAttributeB);
    programA = createProgram('A');
    programService.addProgram(programA);
    smsCodeTeiA = new SMSCode();
    smsCodeTeiA.setCode("a");
    smsCodeTeiA.setTrackedEntityAttribute(trackedEntityAttributeA);
    smsCodeTeiB = new SMSCode();
    smsCodeTeiB.setCode("b");
    smsCodeTeiB.setTrackedEntityAttribute(trackedEntityAttributeB);
    teiRegistrationCommand = new SMSCommand();
    teiRegistrationCommand.setName(teiCommandName);
    teiRegistrationCommand.setProgram(programA);
    teiRegistrationCommand.setParserType(ParserType.TRACKED_ENTITY_REGISTRATION_PARSER);
    teiRegistrationCommand.setCodes(Sets.newHashSet(smsCodeTeiA, smsCodeTeiB));
    teiRegistrationCommand.setSuccessMessage(success);
    teiRegistrationCommand.setNoUserMessage(noUserMessage);
    defaultMessagesC.put(SUCCESS_MESSAGE, success);
    defaultMessagesC.put(NO_USER_MESSAGE, noUserMessage);
}
Also used : SMSCommand(org.hisp.dhis.sms.command.SMSCommand) SMSCode(org.hisp.dhis.sms.command.code.SMSCode)

Example 32 with SMSCommand

use of org.hisp.dhis.sms.command.SMSCommand in project dhis2-core by dhis2.

the class SMSCommandServiceTest method testSaveKeyValueParser.

// -------------------------------------------------------------------------
// SAVE
// -------------------------------------------------------------------------
@Test
void testSaveKeyValueParser() {
    smsCommandService.save(keyValueCommandA);
    SMSCommand keyValueCmd = smsCommandService.getSMSCommand(keyValueCommandName);
    assertEquals(keyValueCommandName, keyValueCmd.getName());
    assertTrue(keyValueCmd.getCodes().contains(smsCodeA1));
    assertTrue(keyValueCmd.getCodes().contains(smsCodeA2));
    assertTrue(CompletenessMethod.AT_LEAST_ONE_DATAVALUE.equals(keyValueCmd.getCompletenessMethod()));
}
Also used : SMSCommand(org.hisp.dhis.sms.command.SMSCommand) Test(org.junit.jupiter.api.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 33 with SMSCommand

use of org.hisp.dhis.sms.command.SMSCommand in project dhis2-core by dhis2.

the class SMSCommandServiceTest method testSaveAlertParser.

@Test
void testSaveAlertParser() {
    smsCommandService.save(alertParserCommand);
    SMSCommand alertCommand = smsCommandService.getSMSCommand(alertMessageCommandName);
    assertEquals(alertMessageCommandName, alertCommand.getName());
    assertEquals(0, alertCommand.getCodes().size());
    assertTrue(CompletenessMethod.AT_LEAST_ONE_DATAVALUE.equals(alertCommand.getCompletenessMethod()));
    assertEquals(success, alertCommand.getSuccessMessage());
    testDefaults(alertCommand, defaultMessagesB);
}
Also used : SMSCommand(org.hisp.dhis.sms.command.SMSCommand) Test(org.junit.jupiter.api.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 34 with SMSCommand

use of org.hisp.dhis.sms.command.SMSCommand in project dhis2-core by dhis2.

the class SMSCommandServiceTest method testSaveUnregistrationParser.

@Test
void testSaveUnregistrationParser() {
    smsCommandService.save(unregisteredParserCommand);
    SMSCommand unregCommand = smsCommandService.getSMSCommand(unregistrationCommandName);
    assertNotNull(unregCommand);
    assertEquals(unregistrationCommandName, unregCommand.getName());
    assertEquals(userGroupA, unregCommand.getUserGroup());
    testDefaults(unregCommand, defaultMessagesD);
    Set<User> users = unregCommand.getUserGroup().getMembers();
    assertTrue(users.contains(userA));
    assertTrue(users.contains(userB));
}
Also used : User(org.hisp.dhis.user.User) SMSCommand(org.hisp.dhis.sms.command.SMSCommand) Test(org.junit.jupiter.api.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 35 with SMSCommand

use of org.hisp.dhis.sms.command.SMSCommand in project dhis2-core by dhis2.

the class SMSCommandServiceTest method createUnregisteredParserCommand.

private void createUnregisteredParserCommand() {
    userA = createUser('A');
    userB = createUser('B');
    userService.addUser(userA);
    userService.addUser(userB);
    userGroupA = createUserGroup('G', Sets.newHashSet(userA, userB));
    userGroupService.addUserGroup(userGroupA);
    unregisteredParserCommand = new SMSCommand();
    unregisteredParserCommand.setName(unregistrationCommandName);
    unregisteredParserCommand.setParserType(ParserType.UNREGISTERED_PARSER);
    unregisteredParserCommand.setUserGroup(userGroupA);
}
Also used : SMSCommand(org.hisp.dhis.sms.command.SMSCommand)

Aggregations

SMSCommand (org.hisp.dhis.sms.command.SMSCommand)41 Test (org.junit.jupiter.api.Test)17 DhisSpringTest (org.hisp.dhis.DhisSpringTest)14 SMSCode (org.hisp.dhis.sms.command.code.SMSCode)14 User (org.hisp.dhis.user.User)9 Transactional (org.springframework.transaction.annotation.Transactional)8 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)7 SMSParserException (org.hisp.dhis.sms.parse.SMSParserException)7 SMSSpecialCharacter (org.hisp.dhis.sms.command.SMSSpecialCharacter)6 UserGroup (org.hisp.dhis.user.UserGroup)6 List (java.util.List)5 Set (java.util.Set)5 DataSet (org.hisp.dhis.dataset.DataSet)5 Program (org.hisp.dhis.program.Program)5 ParserType (org.hisp.dhis.sms.parse.ParserType)5 HashSet (java.util.HashSet)4 Map (java.util.Map)4 ProgramService (org.hisp.dhis.program.ProgramService)4 SMSCommandService (org.hisp.dhis.sms.command.SMSCommandService)4 TrackedEntityAttribute (org.hisp.dhis.trackedentity.TrackedEntityAttribute)4