use of org.openlmis.stockmanagement.dto.referencedata.SupervisoryNodeDto in project openlmis-stockmanagement by OpenLMIS.
the class StockoutNotifier method getEditors.
private Collection<UserDto> getEditors(StockCard stockCard) {
RightDto right = rightReferenceDataService.findRight(STOCK_INVENTORIES_EDIT);
SupervisoryNodeDto supervisoryNode = supervisoryNodeReferenceDataService.findSupervisoryNode(stockCard.getProgramId(), stockCard.getFacilityId());
if (supervisoryNode == null) {
throw new IllegalArgumentException(String.format("There is no supervisory node for program %s and facility %s", stockCard.getProgramId(), stockCard.getFacilityId()));
}
return supervisingUsersReferenceDataService.findAll(supervisoryNode.getId(), right.getId(), stockCard.getProgramId());
}
use of org.openlmis.stockmanagement.dto.referencedata.SupervisoryNodeDto in project openlmis-stockmanagement by OpenLMIS.
the class SupervisoryNodeReferenceDataServiceTest method shouldReturnFirstElementIfMoreThanOneFound.
@Test
public void shouldReturnFirstElementIfMoreThanOneFound() {
SupervisoryNodeReferenceDataService spy = spy(new SupervisoryNodeReferenceDataService());
SupervisoryNodeDto secondNode = new SupervisoryNodeDto();
List<SupervisoryNodeDto> found = Arrays.asList(supervisoryNode, secondNode);
doReturn(new DummyPage<>(found)).when(spy).getPage(RequestParameters.init().set(PROGRAM_ID, program).set(FACILITY_ID, facility));
SupervisoryNodeDto foundNode = spy.findSupervisoryNode(program, facility);
assertEquals(supervisoryNode, foundNode);
assertNotEquals(secondNode, foundNode);
}
use of org.openlmis.stockmanagement.dto.referencedata.SupervisoryNodeDto in project openlmis-stockmanagement by OpenLMIS.
the class SupervisoryNodeReferenceDataServiceTest method shouldReturnFirstElementFoundElementIfOneFound.
@Test
public void shouldReturnFirstElementFoundElementIfOneFound() {
SupervisoryNodeReferenceDataService spy = spy(new SupervisoryNodeReferenceDataService());
doReturn(new DummyPage<>(Collections.singletonList(supervisoryNode))).when(spy).getPage(RequestParameters.init().set(PROGRAM_ID, program).set(FACILITY_ID, facility));
SupervisoryNodeDto foundNode = spy.findSupervisoryNode(program, facility);
assertEquals(supervisoryNode, foundNode);
}
Aggregations