@Test public void createEvse() throws ResourceAlreadyExistsException { ChargingStationType chargingStationType = getChargingStationTypeNonTransient(entityManagerFactory); io.motown.chargingstationconfiguration.viewmodel.persistence.entities.Evse evse = getEvse(9); evse.setConnectors(TestUtils.getConnectors(3)); io.motown.chargingstationconfiguration.viewmodel.persistence.entities.Evse createdEvse = domainService.createEvse(chargingStationType.getId(), evse); ChargingStationType chargingStationTypeUpdated = chargingStationTypeRepository.findOne(chargingStationType.getId()); assertEquals(evse.getIdentifier(), createdEvse.getIdentifier()); assertEquals(chargingStationTypeUpdated.getEvses().size(), chargingStationType.getEvses().size() + 1); }
public Evse createEvse(Long chargingStationTypeId, Evse evse) throws ResourceAlreadyExistsException { ChargingStationType chargingStationType = chargingStationTypeRepository.findOne(chargingStationTypeId); if (getEvseByIdentifier(chargingStationType, evse.getIdentifier()) != null) { throw new ResourceAlreadyExistsException(String.format("Evse with identifier '%s' already exists.", evse.getIdentifier())); } chargingStationType.getEvses().add(evse); chargingStationType = chargingStationTypeRepository.createOrUpdate(chargingStationType); return getEvseByIdentifier(chargingStationType, evse.getIdentifier()); }
DomainService { public Evse createEvse(Long chargingStationTypeId, Evse evse) throws ResourceAlreadyExistsException { ChargingStationType chargingStationType = chargingStationTypeRepository.findOne(chargingStationTypeId); if (getEvseByIdentifier(chargingStationType, evse.getIdentifier()) != null) { throw new ResourceAlreadyExistsException(String.format("Evse with identifier '%s' already exists.", evse.getIdentifier())); } chargingStationType.getEvses().add(evse); chargingStationType = chargingStationTypeRepository.createOrUpdate(chargingStationType); return getEvseByIdentifier(chargingStationType, evse.getIdentifier()); } }
DomainService { public Evse createEvse(Long chargingStationTypeId, Evse evse) throws ResourceAlreadyExistsException { ChargingStationType chargingStationType = chargingStationTypeRepository.findOne(chargingStationTypeId); if (getEvseByIdentifier(chargingStationType, evse.getIdentifier()) != null) { throw new ResourceAlreadyExistsException(String.format("Evse with identifier '%s' already exists.", evse.getIdentifier())); } chargingStationType.getEvses().add(evse); chargingStationType = chargingStationTypeRepository.createOrUpdate(chargingStationType); return getEvseByIdentifier(chargingStationType, evse.getIdentifier()); }  }
DomainService { public Evse createEvse(Long chargingStationTypeId, Evse evse) throws ResourceAlreadyExistsException { ChargingStationType chargingStationType = chargingStationTypeRepository.findOne(chargingStationTypeId); if (getEvseByIdentifier(chargingStationType, evse.getIdentifier()) != null) { throw new ResourceAlreadyExistsException(String.format("Evse with identifier '%s' already exists.", evse.getIdentifier())); } chargingStationType.getEvses().add(evse); chargingStationType = chargingStationTypeRepository.createOrUpdate(chargingStationType); return getEvseByIdentifier(chargingStationType, evse.getIdentifier()); }  Set<io.motown.domain.api.chargingstation.Evse> getEvses(String vendor, String model); Evse createEvse(Long chargingStationTypeId, Evse evse); Set<Evse> getEvses(Long chargingStationTypeId); ChargingStationType createChargingStationType(ChargingStationType chargingStationType); ChargingStationType updateChargingStationType(Long id, ChargingStationType chargingStationType); List<ChargingStationType> getChargingStationTypes(int offset, int limit); Long getTotalNumberOfChargingStationTypes(); ChargingStationType getChargingStationType(Long id); void deleteChargingStationType(Long id); Set<Connector> getConnectors(Long chargingStationTypeId, Long evseId); Connector createConnector(Long chargingStationTypeId, Long evseId, Connector connector); Connector updateConnector(Long chargingStationTypeId, Long evseId, Connector connector); Connector getConnector(Long chargingStationTypeId, Long evseId, Long id); void deleteConnector(Long chargingStationTypeId, Long evseId, Long id); Evse updateEvse(Long chargingStationTypeId, Evse evse); Evse getEvse(Long chargingStationTypeId, Long id); void deleteEvse(Long chargingStationTypeId, Long id); Manufacturer createManufacturer(Manufacturer manufacturer); Manufacturer updateManufacturer(Long id, Manufacturer manufacturer); List<Manufacturer> getManufacturers(int offset, int limit); Long getTotalNumberOfManufacturers(); Manufacturer getManufacturer(Long id); void deleteManufacturer(Long id); void setChargingStationTypeRepository(ChargingStationTypeRepository chargingStationTypeRepository); void setManufacturerRepository(ManufacturerRepository manufacturerRepository); }
DomainService { public Evse createEvse(Long chargingStationTypeId, Evse evse) throws ResourceAlreadyExistsException { ChargingStationType chargingStationType = chargingStationTypeRepository.findOne(chargingStationTypeId); if (getEvseByIdentifier(chargingStationType, evse.getIdentifier()) != null) { throw new ResourceAlreadyExistsException(String.format("Evse with identifier '%s' already exists.", evse.getIdentifier())); } chargingStationType.getEvses().add(evse); chargingStationType = chargingStationTypeRepository.createOrUpdate(chargingStationType); return getEvseByIdentifier(chargingStationType, evse.getIdentifier()); }  Set<io.motown.domain.api.chargingstation.Evse> getEvses(String vendor, String model); Evse createEvse(Long chargingStationTypeId, Evse evse); Set<Evse> getEvses(Long chargingStationTypeId); ChargingStationType createChargingStationType(ChargingStationType chargingStationType); ChargingStationType updateChargingStationType(Long id, ChargingStationType chargingStationType); List<ChargingStationType> getChargingStationTypes(int offset, int limit); Long getTotalNumberOfChargingStationTypes(); ChargingStationType getChargingStationType(Long id); void deleteChargingStationType(Long id); Set<Connector> getConnectors(Long chargingStationTypeId, Long evseId); Connector createConnector(Long chargingStationTypeId, Long evseId, Connector connector); Connector updateConnector(Long chargingStationTypeId, Long evseId, Connector connector); Connector getConnector(Long chargingStationTypeId, Long evseId, Long id); void deleteConnector(Long chargingStationTypeId, Long evseId, Long id); Evse updateEvse(Long chargingStationTypeId, Evse evse); Evse getEvse(Long chargingStationTypeId, Long id); void deleteEvse(Long chargingStationTypeId, Long id); Manufacturer createManufacturer(Manufacturer manufacturer); Manufacturer updateManufacturer(Long id, Manufacturer manufacturer); List<Manufacturer> getManufacturers(int offset, int limit); Long getTotalNumberOfManufacturers(); Manufacturer getManufacturer(Long id); void deleteManufacturer(Long id); void setChargingStationTypeRepository(ChargingStationTypeRepository chargingStationTypeRepository); void setManufacturerRepository(ManufacturerRepository manufacturerRepository);  }