Search in sources :

Example 1 with SupervisoryNodeDto

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());
}
Also used : RightDto(org.openlmis.stockmanagement.dto.referencedata.RightDto) SupervisoryNodeDto(org.openlmis.stockmanagement.dto.referencedata.SupervisoryNodeDto)

Example 2 with SupervisoryNodeDto

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);
}
Also used : SupervisoryNodeDto(org.openlmis.stockmanagement.dto.referencedata.SupervisoryNodeDto) Test(org.junit.Test)

Example 3 with SupervisoryNodeDto

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);
}
Also used : SupervisoryNodeDto(org.openlmis.stockmanagement.dto.referencedata.SupervisoryNodeDto) Test(org.junit.Test)

Aggregations

SupervisoryNodeDto (org.openlmis.stockmanagement.dto.referencedata.SupervisoryNodeDto)3 Test (org.junit.Test)2 RightDto (org.openlmis.stockmanagement.dto.referencedata.RightDto)1