@Test public void shouldGetInventoryCountForSupervisedFacilities() throws Exception { long userId = 1L; long typeId = 1L; long programId = 1L; long equipmentTypeId = 1L; long facilityId = 1L; Facility facility = new Facility(facilityId); List<Facility> facilities = new ArrayList<>(); facilities.add(facility); long[] facilityIds = {facilityId}; when(facilityService.getUserSupervisedFacilities(userId, programId, MANAGE_EQUIPMENT_INVENTORY)).thenReturn(facilities); when(repository.getInventoryCount(programId, equipmentTypeId, facilityIds)).thenReturn(1); int count = service.getInventoryCount(userId, typeId, programId, equipmentTypeId); verify(facilityService).getUserSupervisedFacilities(userId, programId, MANAGE_EQUIPMENT_INVENTORY); verify(repository).getInventoryCount(programId, equipmentTypeId, facilityIds); assertEquals(count, 1); }
public Integer getInventoryCount(Long userId, Long typeId, Long programId, Long equipmentTypeId) { long[] facilityIds = getFacilityIds(userId, typeId, programId); return repository.getInventoryCount(programId, equipmentTypeId, facilityIds); }
EquipmentInventoryService { public Integer getInventoryCount(Long userId, Long typeId, Long programId, Long equipmentTypeId) { long[] facilityIds = getFacilityIds(userId, typeId, programId); return repository.getInventoryCount(programId, equipmentTypeId, facilityIds); } }
EquipmentInventoryService { public Integer getInventoryCount(Long userId, Long typeId, Long programId, Long equipmentTypeId) { long[] facilityIds = getFacilityIds(userId, typeId, programId); return repository.getInventoryCount(programId, equipmentTypeId, facilityIds); }  }
EquipmentInventoryService { public Integer getInventoryCount(Long userId, Long typeId, Long programId, Long equipmentTypeId) { long[] facilityIds = getFacilityIds(userId, typeId, programId); return repository.getInventoryCount(programId, equipmentTypeId, facilityIds); }  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 Integer getInventoryCount(Long userId, Long typeId, Long programId, Long equipmentTypeId) { long[] facilityIds = getFacilityIds(userId, typeId, programId); return repository.getInventoryCount(programId, equipmentTypeId, facilityIds); }  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();  }