@Test public void shouldUpdateRefrigeratorIfAlreadyExists() { Refrigerator refrigerator = mock(Refrigerator.class); when(refrigerator.getId()).thenReturn(1L); service.save(refrigerator); verify(repository).update(refrigerator); }
public void save(Refrigerator refrigerator) { if (refrigerator.getId() == null) { repository.insert(refrigerator); } else { repository.update(refrigerator); } }
RefrigeratorService { public void save(Refrigerator refrigerator) { if (refrigerator.getId() == null) { repository.insert(refrigerator); } else { repository.update(refrigerator); } } }
RefrigeratorService { public void save(Refrigerator refrigerator) { if (refrigerator.getId() == null) { repository.insert(refrigerator); } else { repository.update(refrigerator); } }  }
RefrigeratorService { public void save(Refrigerator refrigerator) { if (refrigerator.getId() == null) { repository.insert(refrigerator); } else { repository.update(refrigerator); } }  List<Refrigerator> getRefrigeratorsForADeliveryZoneAndProgram(Long deliveryZoneId, Long programId); void disableAllFor(Long facilityId); List<Refrigerator> getAllBy(Long facilityId); void save(Refrigerator refrigerator); }
RefrigeratorService { public void save(Refrigerator refrigerator) { if (refrigerator.getId() == null) { repository.insert(refrigerator); } else { repository.update(refrigerator); } }  List<Refrigerator> getRefrigeratorsForADeliveryZoneAndProgram(Long deliveryZoneId, Long programId); void disableAllFor(Long facilityId); List<Refrigerator> getAllBy(Long facilityId); void save(Refrigerator refrigerator);  }