@Test public void shouldThrowErrorIfSupervisoryNodeIsNotTheParentNode() { when(supervisoryNodeRepository.getSupervisoryNodeParentId(supplyLine.getSupervisoryNode().getId())).thenThrow(new DataException("Supervising Node is not the Top node")); expectedEx.expect(DataException.class); expectedEx.expectMessage("Supervising Node is not the Top node"); service.save(supplyLine); }
public void save(SupplyLine supplyLine) { validateIfSupervisoryNodeIsTopmostNode(supplyLine); if (supplyLine.getId() == null) { repository.insert(supplyLine); return; } repository.update(supplyLine); }
SupplyLineService { public void save(SupplyLine supplyLine) { validateIfSupervisoryNodeIsTopmostNode(supplyLine); if (supplyLine.getId() == null) { repository.insert(supplyLine); return; } repository.update(supplyLine); } }
SupplyLineService { public void save(SupplyLine supplyLine) { validateIfSupervisoryNodeIsTopmostNode(supplyLine); if (supplyLine.getId() == null) { repository.insert(supplyLine); return; } repository.update(supplyLine); }  }
SupplyLineService { public void save(SupplyLine supplyLine) { validateIfSupervisoryNodeIsTopmostNode(supplyLine); if (supplyLine.getId() == null) { repository.insert(supplyLine); return; } repository.update(supplyLine); }  SupplyLine getSupplyLineBy(SupervisoryNode supervisoryNode, Program program); void save(SupplyLine supplyLine); SupplyLine getExisting(SupplyLine supplyLine); List<Facility> getSupplyingFacilities(Long userId); SupplyLine getById(Long id); List<SupplyLine> search(String searchParam, String column, Pagination pagination); Integer getTotalSearchResultCount(String searchParam, String column); SupplyLine getByFacilityProgram(Long facilityId, Long programId); }
SupplyLineService { public void save(SupplyLine supplyLine) { validateIfSupervisoryNodeIsTopmostNode(supplyLine); if (supplyLine.getId() == null) { repository.insert(supplyLine); return; } repository.update(supplyLine); }  SupplyLine getSupplyLineBy(SupervisoryNode supervisoryNode, Program program); void save(SupplyLine supplyLine); SupplyLine getExisting(SupplyLine supplyLine); List<Facility> getSupplyingFacilities(Long userId); SupplyLine getById(Long id); List<SupplyLine> search(String searchParam, String column, Pagination pagination); Integer getTotalSearchResultCount(String searchParam, String column); SupplyLine getByFacilityProgram(Long facilityId, Long programId);  }