@Test public void shouldSaveAnUpdate() throws Exception { MaintenanceRequest request = new MaintenanceRequest(); request.setId(3L); service.save(request); verify(repository, never()).insert(request); verify(repository).update(request); }
public void save(MaintenanceRequest request) { if (!request.hasId()) { repository.insert(request); notifyVendor(request); } else { repository.update(request); } }
MaintenanceRequestService { public void save(MaintenanceRequest request) { if (!request.hasId()) { repository.insert(request); notifyVendor(request); } else { repository.update(request); } } }
MaintenanceRequestService { public void save(MaintenanceRequest request) { if (!request.hasId()) { repository.insert(request); notifyVendor(request); } else { repository.update(request); } }  }
MaintenanceRequestService { public void save(MaintenanceRequest request) { if (!request.hasId()) { repository.insert(request); notifyVendor(request); } else { repository.update(request); } }  List<MaintenanceRequest> getAll(); List<MaintenanceRequest> getAllForFacility(Long facilityId); List<MaintenanceRequest> getAllForVendor(Long vendorId); List<MaintenanceRequest> getOutstandingForVendor(Long vendorId); List<MaintenanceRequest> getOutstandingForUser(Long userId); MaintenanceRequest getById(Long id); void save(MaintenanceRequest request); List<Log> getFullHistory(Long inventoryId); }
MaintenanceRequestService { public void save(MaintenanceRequest request) { if (!request.hasId()) { repository.insert(request); notifyVendor(request); } else { repository.update(request); } }  List<MaintenanceRequest> getAll(); List<MaintenanceRequest> getAllForFacility(Long facilityId); List<MaintenanceRequest> getAllForVendor(Long vendorId); List<MaintenanceRequest> getOutstandingForVendor(Long vendorId); List<MaintenanceRequest> getOutstandingForUser(Long userId); MaintenanceRequest getById(Long id); void save(MaintenanceRequest request); List<Log> getFullHistory(Long inventoryId);  }