@Test public void shouldGetInventoryForUserFacility() throws Exception { long userId = 1L; long typeId = 0L; long programId = 1L; long equipmentTypeId = 1L; long facilityId = 1L; List<EquipmentInventory> expectedEquipments = new ArrayList<>(); expectedEquipments.add(new EquipmentInventory()); Facility facility = new Facility(facilityId); long[] facilityIds = {facilityId}; Pagination page = new Pagination(1, 2); when(facilityService.getHomeFacility(userId)).thenReturn(facility); when(repository.getInventory(programId, equipmentTypeId, facilityIds, page)).thenReturn(expectedEquipments); List<EquipmentInventory> equipments = service.getInventory(userId, typeId, programId, equipmentTypeId, page); verify(facilityService).getHomeFacility(userId); verify(repository).getInventory(programId, equipmentTypeId, facilityIds, page); assertEquals(equipments, expectedEquipments); }
public List<EquipmentInventory> getInventory(Long userId, Long typeId, Long programId, Long equipmentTypeId, Pagination pagination) { long[] facilityIds = getFacilityIds(userId, typeId, programId); return repository.getInventory(programId, equipmentTypeId, facilityIds, pagination); }
EquipmentInventoryService { public List<EquipmentInventory> getInventory(Long userId, Long typeId, Long programId, Long equipmentTypeId, Pagination pagination) { long[] facilityIds = getFacilityIds(userId, typeId, programId); return repository.getInventory(programId, equipmentTypeId, facilityIds, pagination); } }
EquipmentInventoryService { public List<EquipmentInventory> getInventory(Long userId, Long typeId, Long programId, Long equipmentTypeId, Pagination pagination) { long[] facilityIds = getFacilityIds(userId, typeId, programId); return repository.getInventory(programId, equipmentTypeId, facilityIds, pagination); }  }
EquipmentInventoryService { public List<EquipmentInventory> getInventory(Long userId, Long typeId, Long programId, Long equipmentTypeId, Pagination pagination) { long[] facilityIds = getFacilityIds(userId, typeId, programId); return repository.getInventory(programId, equipmentTypeId, facilityIds, pagination); }  List<EquipmentInventory> getInventoryForFacility(Long facilityId, Long programId); List<EquipmentInventory> getInventory(Long userId, Long typeId, Long programId, Long equipmentTypeId, Pagination pagination); Integer getInventoryCount(Long userId, Long typeId, Long programId, Long equipmentTypeId); EquipmentInventory getInventoryById(Long id); void save(EquipmentInventory inventory); void updateStatus(EquipmentInventory inventory); void updateNonFunctionalEquipments(); }
EquipmentInventoryService { public List<EquipmentInventory> getInventory(Long userId, Long typeId, Long programId, Long equipmentTypeId, Pagination pagination) { long[] facilityIds = getFacilityIds(userId, typeId, programId); return repository.getInventory(programId, equipmentTypeId, facilityIds, pagination); }  List<EquipmentInventory> getInventoryForFacility(Long facilityId, Long programId); List<EquipmentInventory> getInventory(Long userId, Long typeId, Long programId, Long equipmentTypeId, Pagination pagination); Integer getInventoryCount(Long userId, Long typeId, Long programId, Long equipmentTypeId); EquipmentInventory getInventoryById(Long id); void save(EquipmentInventory inventory); void updateStatus(EquipmentInventory inventory); void updateNonFunctionalEquipments();  }