Search in sources :

Example 1 with DistrictAssignmentDtoDataBuilder

use of org.motechproject.mots.testbuilder.DistrictAssignmentDtoDataBuilder in project mots by motech-implementations.

the class ModuleAssignmentServiceTest method setUp.

/**
 * Prepare the test environment.
 */
@Before
public void setUp() {
    user = TestUtils.createNewUserAndAddToSecurityContext();
    existingAssignedModules = new AssignedModulesDataBuilder().withChw(CHW).withModule(MODULE_1).withModule(MODULE_2).build();
    newAssignedModules = new AssignedModulesDataBuilder().withChw(CHW).withModule(MODULE_2).withModule(MODULE_3).build();
    districtAssignmentDto = new DistrictAssignmentDtoDataBuilder().withModule(MODULE_2.getId().toString()).withModule(MODULE_3.getId().toString()).withDistrictId(DISTRICT.getId().toString()).build();
    when(assignedModulesRepository.findByHealthWorkerId(eq(CHW.getId()))).thenReturn(Optional.of(existingAssignedModules));
    when(districtRepository.findOne(eq((DISTRICT.getId())))).thenReturn(DISTRICT);
    mockModuleInModuleRepository(MODULE_2);
    mockModuleInModuleRepository(MODULE_3);
}
Also used : AssignedModulesDataBuilder(org.motechproject.mots.testbuilder.AssignedModulesDataBuilder) DistrictAssignmentDtoDataBuilder(org.motechproject.mots.testbuilder.DistrictAssignmentDtoDataBuilder) Before(org.junit.Before)

Example 2 with DistrictAssignmentDtoDataBuilder

use of org.motechproject.mots.testbuilder.DistrictAssignmentDtoDataBuilder in project mots by motech-implementations.

the class ModuleAssignmentServiceTest method shouldThrowIfModulesWithDoesNotExists.

@Test(expected = EntityNotFoundException.class)
public void shouldThrowIfModulesWithDoesNotExists() {
    UUID moduleId = UUID.randomUUID();
    DistrictAssignmentDto customDistrictAssignmentDto = new DistrictAssignmentDtoDataBuilder().withModule(moduleId.toString()).withDistrictId(DISTRICT.getId().toString()).build();
    when(moduleRepository.findById(moduleId)).thenReturn(Optional.empty());
    moduleAssignmentService.assignModulesToDistrict(customDistrictAssignmentDto);
}
Also used : DistrictAssignmentDto(org.motechproject.mots.dto.DistrictAssignmentDto) UUID(java.util.UUID) DistrictAssignmentDtoDataBuilder(org.motechproject.mots.testbuilder.DistrictAssignmentDtoDataBuilder) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

DistrictAssignmentDtoDataBuilder (org.motechproject.mots.testbuilder.DistrictAssignmentDtoDataBuilder)2 UUID (java.util.UUID)1 Before (org.junit.Before)1 Test (org.junit.Test)1 DistrictAssignmentDto (org.motechproject.mots.dto.DistrictAssignmentDto)1 AssignedModulesDataBuilder (org.motechproject.mots.testbuilder.AssignedModulesDataBuilder)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1