@Test public void shouldNotUpdateStatusWhenSame() throws Exception { when(equipmentInventoryStatusMapper.getCurrentStatus(inventoryId)).thenReturn(status); repository.updateStatus(inventory); verify(equipmentInventoryStatusMapper).getCurrentStatus(inventoryId); }
public void updateStatus(EquipmentInventory inventory){ EquipmentInventoryStatus existingStatus = equipmentInventoryStatusMapper.getCurrentStatus(inventory.getId()); EquipmentInventoryStatus status = getStatusFromInventory(inventory); if (!status.equals(existingStatus)) { status.setCreatedBy(inventory.getCreatedBy()); status.setModifiedBy(inventory.getModifiedBy()); if (!equipmentOperationalStatusMapper.getById(status.getStatusId()).getIsBad()) { status.setNotFunctionalStatusId(null); } equipmentInventoryStatusMapper.insert(status); } }
EquipmentInventoryRepository { public void updateStatus(EquipmentInventory inventory){ EquipmentInventoryStatus existingStatus = equipmentInventoryStatusMapper.getCurrentStatus(inventory.getId()); EquipmentInventoryStatus status = getStatusFromInventory(inventory); if (!status.equals(existingStatus)) { status.setCreatedBy(inventory.getCreatedBy()); status.setModifiedBy(inventory.getModifiedBy()); if (!equipmentOperationalStatusMapper.getById(status.getStatusId()).getIsBad()) { status.setNotFunctionalStatusId(null); } equipmentInventoryStatusMapper.insert(status); } } }
EquipmentInventoryRepository { public void updateStatus(EquipmentInventory inventory){ EquipmentInventoryStatus existingStatus = equipmentInventoryStatusMapper.getCurrentStatus(inventory.getId()); EquipmentInventoryStatus status = getStatusFromInventory(inventory); if (!status.equals(existingStatus)) { status.setCreatedBy(inventory.getCreatedBy()); status.setModifiedBy(inventory.getModifiedBy()); if (!equipmentOperationalStatusMapper.getById(status.getStatusId()).getIsBad()) { status.setNotFunctionalStatusId(null); } equipmentInventoryStatusMapper.insert(status); } }  }
EquipmentInventoryRepository { public void updateStatus(EquipmentInventory inventory){ EquipmentInventoryStatus existingStatus = equipmentInventoryStatusMapper.getCurrentStatus(inventory.getId()); EquipmentInventoryStatus status = getStatusFromInventory(inventory); if (!status.equals(existingStatus)) { status.setCreatedBy(inventory.getCreatedBy()); status.setModifiedBy(inventory.getModifiedBy()); if (!equipmentOperationalStatusMapper.getById(status.getStatusId()).getIsBad()) { status.setNotFunctionalStatusId(null); } equipmentInventoryStatusMapper.insert(status); } }  List<EquipmentInventory> getFacilityInventory(Long facilityId, Long programId); List<EquipmentInventory> getInventory(Long programId, Long equipmentTypeId, long[] facilityIds, Pagination pagination); Integer getInventoryCount(Long programId, Long equipmentTypeId, long[] facilityIds); EquipmentInventory getInventoryById(Long id); void insert(EquipmentInventory inventory); void update(EquipmentInventory inventory); void updateStatus(EquipmentInventory inventory); String updateNonFunctionalEquipments(); }
EquipmentInventoryRepository { public void updateStatus(EquipmentInventory inventory){ EquipmentInventoryStatus existingStatus = equipmentInventoryStatusMapper.getCurrentStatus(inventory.getId()); EquipmentInventoryStatus status = getStatusFromInventory(inventory); if (!status.equals(existingStatus)) { status.setCreatedBy(inventory.getCreatedBy()); status.setModifiedBy(inventory.getModifiedBy()); if (!equipmentOperationalStatusMapper.getById(status.getStatusId()).getIsBad()) { status.setNotFunctionalStatusId(null); } equipmentInventoryStatusMapper.insert(status); } }  List<EquipmentInventory> getFacilityInventory(Long facilityId, Long programId); List<EquipmentInventory> getInventory(Long programId, Long equipmentTypeId, long[] facilityIds, Pagination pagination); Integer getInventoryCount(Long programId, Long equipmentTypeId, long[] facilityIds); EquipmentInventory getInventoryById(Long id); void insert(EquipmentInventory inventory); void update(EquipmentInventory inventory); void updateStatus(EquipmentInventory inventory); String updateNonFunctionalEquipments(); static Logger logger; }