@Test public void newChargingStationCreatedShouldCreateChargingStation() { when(chargingStationRepository.findOne(CHARGING_STATION_ID.getId())).thenReturn(null); localAuthorization.onEvent(new ChargingStationCreatedEvent(CHARGING_STATION_ID, ImmutableSet.<UserIdentity>builder().add(USER_IDENTITY).build(), IDENTITY_CONTEXT)); verify(chargingStationRepository).createOrUpdate(new LocalAuthChargingStation(CHARGING_STATION_ID.getId())); }
@EventHandler void onEvent(ChargingStationCreatedEvent event) { String chargingStationId = event.getChargingStationId().getId(); LocalAuthChargingStation chargingStation = chargingStationRepository.findOne(chargingStationId); if (chargingStation == null) { chargingStationRepository.createOrUpdate(new LocalAuthChargingStation(chargingStationId)); } }
LocalAuthorization implements AuthorizationProvider { @EventHandler void onEvent(ChargingStationCreatedEvent event) { String chargingStationId = event.getChargingStationId().getId(); LocalAuthChargingStation chargingStation = chargingStationRepository.findOne(chargingStationId); if (chargingStation == null) { chargingStationRepository.createOrUpdate(new LocalAuthChargingStation(chargingStationId)); } } }
LocalAuthorization implements AuthorizationProvider { @EventHandler void onEvent(ChargingStationCreatedEvent event) { String chargingStationId = event.getChargingStationId().getId(); LocalAuthChargingStation chargingStation = chargingStationRepository.findOne(chargingStationId); if (chargingStation == null) { chargingStationRepository.createOrUpdate(new LocalAuthChargingStation(chargingStationId)); } }  }
LocalAuthorization implements AuthorizationProvider { @EventHandler void onEvent(ChargingStationCreatedEvent event) { String chargingStationId = event.getChargingStationId().getId(); LocalAuthChargingStation chargingStation = chargingStationRepository.findOne(chargingStationId); if (chargingStation == null) { chargingStationRepository.createOrUpdate(new LocalAuthChargingStation(chargingStationId)); } }  @Override IdentifyingToken validate(IdentifyingToken identifyingToken, @Nullable ChargingStationId chargingStationId); void setTokenRepository(TokenRepository tokenRepository); void setChargingStationRepository(ChargingStationRepository chargingStationRepository); }
LocalAuthorization implements AuthorizationProvider { @EventHandler void onEvent(ChargingStationCreatedEvent event) { String chargingStationId = event.getChargingStationId().getId(); LocalAuthChargingStation chargingStation = chargingStationRepository.findOne(chargingStationId); if (chargingStation == null) { chargingStationRepository.createOrUpdate(new LocalAuthChargingStation(chargingStationId)); } }  @Override IdentifyingToken validate(IdentifyingToken identifyingToken, @Nullable ChargingStationId chargingStationId); void setTokenRepository(TokenRepository tokenRepository); void setChargingStationRepository(ChargingStationRepository chargingStationRepository);  }