@Test public void shouldSaveAnUpdate() throws Exception{ EquipmentType type = new EquipmentType(); type.setId(1L); type.setName("Test"); type.setCode("Test"); service.save(type); verify(repository, never()).insert(type); verify(repository).update(type); }
public void save(EquipmentType type){ if(type.getId() == null){ repository.insert(type); } else { repository.update(type); } }
EquipmentTypeService { public void save(EquipmentType type){ if(type.getId() == null){ repository.insert(type); } else { repository.update(type); } } }
EquipmentTypeService { public void save(EquipmentType type){ if(type.getId() == null){ repository.insert(type); } else { repository.update(type); } }  }
EquipmentTypeService { public void save(EquipmentType type){ if(type.getId() == null){ repository.insert(type); } else { repository.update(type); } }  List<EquipmentType> getAll(); EquipmentType getTypeById(Long id); void save(EquipmentType type); }
EquipmentTypeService { public void save(EquipmentType type){ if(type.getId() == null){ repository.insert(type); } else { repository.update(type); } }  List<EquipmentType> getAll(); EquipmentType getTypeById(Long id); void save(EquipmentType type);  }