use of org.motechproject.mots.domain.AssignedModules in project mots by motech-implementations.
the class ModuleAssignmentServiceTest method assignModulesShouldThrowIfIvrIdIsNotSet.
@Test(expected = ModuleAssignmentException.class)
public void assignModulesShouldThrowIfIvrIdIsNotSet() {
final CommunityHealthWorker chw = new CommunityHealthWorkerDataBuilder().withIvrId(null).build();
final AssignedModules assignedModules = new AssignedModulesDataBuilder().withChw(chw).build();
when(assignedModulesRepository.findByHealthWorkerId(eq(chw.getId()))).thenReturn(Optional.of(assignedModules));
moduleAssignmentService.assignModules(assignedModules);
}
use of org.motechproject.mots.domain.AssignedModules in project mots by motech-implementations.
the class AssignedModulesDataBuilder method buildAsNew.
/**
* Builds instance of {@link AssignedModules} without id.
*/
public AssignedModules buildAsNew() {
AssignedModules assignedModules = new AssignedModules();
assignedModules.setHealthWorker(chw);
assignedModules.setModules(modules);
return assignedModules;
}
use of org.motechproject.mots.domain.AssignedModules in project mots by motech-implementations.
the class AssignedModulesDataBuilder method build.
/**
* Builds instance of {@link AssignedModules}.
*/
public AssignedModules build() {
AssignedModules assignedModules = buildAsNew();
assignedModules.setId(id);
return assignedModules;
}
use of org.motechproject.mots.domain.AssignedModules in project mots by motech-implementations.
the class ModuleAssignmentController method assignModules.
/**
* Assign modules for CHW.
* @param moduleAssignmentDto dto with chw id and list of modules assigned to it
*/
@RequestMapping(value = "/module/assign", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.OK)
public void assignModules(@RequestBody ModuleAssignmentDto moduleAssignmentDto) {
AssignedModules assignedModules = moduleAssignmentMapper.fromDto(moduleAssignmentDto);
moduleAssignmentService.assignModules(assignedModules);
}
use of org.motechproject.mots.domain.AssignedModules in project mots by motech-implementations.
the class ModuleAssignmentServiceTest method shouldReturnAssignedModules.
@Test
public void shouldReturnAssignedModules() {
AssignedModules actual = moduleAssignmentService.getAssignedModules(CHW.getId());
assertEquals(existingAssignedModules, actual);
}
Aggregations