@Test public void shouldSaveNewType() throws Exception { EquipmentEnergyType type = new EquipmentEnergyType(); type.setName("Test"); service.save(type); verify(repository).insert(type); verify(repository, never()).update(type); }
public void save(EquipmentEnergyType energyType){ if(energyType.getId() == null){ repository.insert(energyType); } else { repository.update(energyType); } }
EquipmentEnergyTypeService { public void save(EquipmentEnergyType energyType){ if(energyType.getId() == null){ repository.insert(energyType); } else { repository.update(energyType); } } }
EquipmentEnergyTypeService { public void save(EquipmentEnergyType energyType){ if(energyType.getId() == null){ repository.insert(energyType); } else { repository.update(energyType); } }  }
EquipmentEnergyTypeService { public void save(EquipmentEnergyType energyType){ if(energyType.getId() == null){ repository.insert(energyType); } else { repository.update(energyType); } }  List<EquipmentEnergyType> getAll(); EquipmentEnergyType getById(Long id); void save(EquipmentEnergyType energyType); }
EquipmentEnergyTypeService { public void save(EquipmentEnergyType energyType){ if(energyType.getId() == null){ repository.insert(energyType); } else { repository.update(energyType); } }  List<EquipmentEnergyType> getAll(); EquipmentEnergyType getById(Long id); void save(EquipmentEnergyType energyType);  }