Search in sources :

Example 11 with SMSCommand

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

the class SMSCommandServiceTest method testGetCommandByName.

@Test
void testGetCommandByName() {
    smsCommandService.save(keyValueCommandA);
    SMSCommand created = smsCommandService.getSMSCommand(keyValueCommandName);
    assertNotNull(created);
    assertEquals(keyValueCommandName, created.getName());
    testDefaults(created, defaultMessagesA);
}
Also used : SMSCommand(org.hisp.dhis.sms.command.SMSCommand) Test(org.junit.jupiter.api.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 12 with SMSCommand

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

the class SMSCommandServiceTest method testSaveEventRegistrationParser.

@Test
void testSaveEventRegistrationParser() {
    smsCommandService.save(eventRegistrationCommand);
    SMSCommand eventRegistrationCommand = smsCommandService.getSMSCommand(eventRegistrationCommandName);
    assertEquals(eventRegistrationCommandName, eventRegistrationCommand.getName());
    assertEquals(programD, eventRegistrationCommand.getProgram());
    assertEquals(programStageD, eventRegistrationCommand.getProgramStage());
    testDefaults(eventRegistrationCommand, defaultMessagesE);
    Set<DataElement> dataElements = eventRegistrationCommand.getCodes().stream().map(c -> c.getDataElement()).collect(Collectors.toSet());
    assertTrue(dataElements.contains(dataElementD));
    assertFalse(dataElements.contains(dataElementC));
}
Also used : Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) Arrays(java.util.Arrays) DataElementService(org.hisp.dhis.dataelement.DataElementService) DataSet(org.hisp.dhis.dataset.DataSet) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) Program(org.hisp.dhis.program.Program) CompletenessMethod(org.hisp.dhis.sms.command.CompletenessMethod) TrackedEntityAttributeService(org.hisp.dhis.trackedentity.TrackedEntityAttributeService) DataElement(org.hisp.dhis.dataelement.DataElement) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Map(java.util.Map) User(org.hisp.dhis.user.User) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) ParserType(org.hisp.dhis.sms.parse.ParserType) UserService(org.hisp.dhis.user.UserService) Function(com.google.common.base.Function) SMSSpecialCharacter(org.hisp.dhis.sms.command.SMSSpecialCharacter) ImmutableMap(com.google.common.collect.ImmutableMap) UserGroup(org.hisp.dhis.user.UserGroup) Set(java.util.Set) ProgramStageService(org.hisp.dhis.program.ProgramStageService) Collectors(java.util.stream.Collectors) ProgramStage(org.hisp.dhis.program.ProgramStage) Sets(com.google.common.collect.Sets) Test(org.junit.jupiter.api.Test) List(java.util.List) DhisSpringTest(org.hisp.dhis.DhisSpringTest) SMSCommandService(org.hisp.dhis.sms.command.SMSCommandService) UserGroupService(org.hisp.dhis.user.UserGroupService) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) SMSCode(org.hisp.dhis.sms.command.code.SMSCode) DataSetService(org.hisp.dhis.dataset.DataSetService) ProgramService(org.hisp.dhis.program.ProgramService) SMSCommand(org.hisp.dhis.sms.command.SMSCommand) TrackedEntityAttribute(org.hisp.dhis.trackedentity.TrackedEntityAttribute) DataElement(org.hisp.dhis.dataelement.DataElement) SMSCommand(org.hisp.dhis.sms.command.SMSCommand) Test(org.junit.jupiter.api.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 13 with SMSCommand

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

the class SMSCommandServiceTest method testAddSmsCodes.

// -------------------------------------------------------------------------
// UPDATE
// -------------------------------------------------------------------------
@Test
void testAddSmsCodes() {
    smsCommandService.save(keyValueCommandA);
    SMSCommand createdCommand = smsCommandService.getSMSCommand(keyValueCommandName);
    assertEquals(2, createdCommand.getCodes().size());
    smsCommandService.addSmsCodes(Sets.newHashSet(smsCodeC), createdCommand.getId());
    SMSCommand updatedCommand = smsCommandService.getSMSCommand(keyValueCommandName);
    assertEquals(3, updatedCommand.getCodes().size());
}
Also used : SMSCommand(org.hisp.dhis.sms.command.SMSCommand) Test(org.junit.jupiter.api.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 14 with SMSCommand

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

the class SMSCommandServiceTest method testDelete.

// -------------------------------------------------------------------------
// DELETE
// -------------------------------------------------------------------------
@Test
void testDelete() {
    smsCommandService.save(keyValueCommandA);
    SMSCommand createdCommand = smsCommandService.getSMSCommand(keyValueCommandName);
    assertNotNull(createdCommand);
    assertEquals(keyValueCommandName, createdCommand.getName());
    smsCommandService.delete(createdCommand);
    SMSCommand deleteCommand = smsCommandService.getSMSCommand(keyValueCommandName);
    assertNull(deleteCommand);
}
Also used : SMSCommand(org.hisp.dhis.sms.command.SMSCommand) Test(org.junit.jupiter.api.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 15 with SMSCommand

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

the class SMSCommandServiceTest method testGetSMSCommandByNameAndParser.

// -------------------------------------------------------------------------
// GET
// -------------------------------------------------------------------------
@Test
void testGetSMSCommandByNameAndParser() {
    smsCommandService.save(keyValueCommandA);
    SMSCommand keyValueCmd = smsCommandService.getSMSCommand(keyValueCommandName, ParserType.KEY_VALUE_PARSER);
    assertNotNull(keyValueCmd);
    SMSCommand noCommand = smsCommandService.getSMSCommand(keyValueCommandName, ParserType.ALERT_PARSER);
    assertNull(noCommand);
}
Also used : SMSCommand(org.hisp.dhis.sms.command.SMSCommand) Test(org.junit.jupiter.api.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

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