@Test(expected = NullPointerException.class) public void testInvalidAddress() throws UserIdentityUnauthorizedException { JsonObject commandObject = gson.fromJson("{address:{addressLine:'Teststraat 1',city:'Deurne',country:'NL'},accessibility:'PUBLIC'}", JsonObject.class); handler.handle(OperatorApiJsonTestUtils.CHARGING_STATION_ID_STRING, commandObject, IDENTITY_CONTEXT); }
@Override public void handle(String chargingStationId, JsonObject commandObject, IdentityContext identityContext) throws UserIdentityUnauthorizedException { ChargingStationId csId = new ChargingStationId(chargingStationId); if (!commandAuthorizationService.isAuthorized(csId, identityContext.getUserIdentity(), PlaceChargingStationCommand.class)) { throw new UserIdentityUnauthorizedException(chargingStationId, identityContext.getUserIdentity(), PlaceChargingStationCommand.class); } try { ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation != null && chargingStation.isAccepted()) { PlaceChargingStationApiCommand command = gson.fromJson(commandObject, PlaceChargingStationApiCommand.class); commandGateway.send(new PlaceChargingStationCommand(csId, command.getCoordinates(), command.getAddress(), command.getAccessibility(), identityContext)); } } catch (JsonSyntaxException ex) { throw new IllegalArgumentException("Place charging station command not able to parse the payload, is your JSON correctly formatted?", ex); } }
PlaceChargingStationJsonCommandHandler extends JsonCommandHandler { @Override public void handle(String chargingStationId, JsonObject commandObject, IdentityContext identityContext) throws UserIdentityUnauthorizedException { ChargingStationId csId = new ChargingStationId(chargingStationId); if (!commandAuthorizationService.isAuthorized(csId, identityContext.getUserIdentity(), PlaceChargingStationCommand.class)) { throw new UserIdentityUnauthorizedException(chargingStationId, identityContext.getUserIdentity(), PlaceChargingStationCommand.class); } try { ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation != null && chargingStation.isAccepted()) { PlaceChargingStationApiCommand command = gson.fromJson(commandObject, PlaceChargingStationApiCommand.class); commandGateway.send(new PlaceChargingStationCommand(csId, command.getCoordinates(), command.getAddress(), command.getAccessibility(), identityContext)); } } catch (JsonSyntaxException ex) { throw new IllegalArgumentException("Place charging station command not able to parse the payload, is your JSON correctly formatted?", ex); } } }
PlaceChargingStationJsonCommandHandler extends JsonCommandHandler { @Override public void handle(String chargingStationId, JsonObject commandObject, IdentityContext identityContext) throws UserIdentityUnauthorizedException { ChargingStationId csId = new ChargingStationId(chargingStationId); if (!commandAuthorizationService.isAuthorized(csId, identityContext.getUserIdentity(), PlaceChargingStationCommand.class)) { throw new UserIdentityUnauthorizedException(chargingStationId, identityContext.getUserIdentity(), PlaceChargingStationCommand.class); } try { ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation != null && chargingStation.isAccepted()) { PlaceChargingStationApiCommand command = gson.fromJson(commandObject, PlaceChargingStationApiCommand.class); commandGateway.send(new PlaceChargingStationCommand(csId, command.getCoordinates(), command.getAddress(), command.getAccessibility(), identityContext)); } } catch (JsonSyntaxException ex) { throw new IllegalArgumentException("Place charging station command not able to parse the payload, is your JSON correctly formatted?", ex); } }  }
PlaceChargingStationJsonCommandHandler extends JsonCommandHandler { @Override public void handle(String chargingStationId, JsonObject commandObject, IdentityContext identityContext) throws UserIdentityUnauthorizedException { ChargingStationId csId = new ChargingStationId(chargingStationId); if (!commandAuthorizationService.isAuthorized(csId, identityContext.getUserIdentity(), PlaceChargingStationCommand.class)) { throw new UserIdentityUnauthorizedException(chargingStationId, identityContext.getUserIdentity(), PlaceChargingStationCommand.class); } try { ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation != null && chargingStation.isAccepted()) { PlaceChargingStationApiCommand command = gson.fromJson(commandObject, PlaceChargingStationApiCommand.class); commandGateway.send(new PlaceChargingStationCommand(csId, command.getCoordinates(), command.getAddress(), command.getAccessibility(), identityContext)); } } catch (JsonSyntaxException ex) { throw new IllegalArgumentException("Place charging station command not able to parse the payload, is your JSON correctly formatted?", ex); } }  @Override String getCommandName(); @Override void handle(String chargingStationId, JsonObject commandObject, IdentityContext identityContext); }
PlaceChargingStationJsonCommandHandler extends JsonCommandHandler { @Override public void handle(String chargingStationId, JsonObject commandObject, IdentityContext identityContext) throws UserIdentityUnauthorizedException { ChargingStationId csId = new ChargingStationId(chargingStationId); if (!commandAuthorizationService.isAuthorized(csId, identityContext.getUserIdentity(), PlaceChargingStationCommand.class)) { throw new UserIdentityUnauthorizedException(chargingStationId, identityContext.getUserIdentity(), PlaceChargingStationCommand.class); } try { ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation != null && chargingStation.isAccepted()) { PlaceChargingStationApiCommand command = gson.fromJson(commandObject, PlaceChargingStationApiCommand.class); commandGateway.send(new PlaceChargingStationCommand(csId, command.getCoordinates(), command.getAddress(), command.getAccessibility(), identityContext)); } } catch (JsonSyntaxException ex) { throw new IllegalArgumentException("Place charging station command not able to parse the payload, is your JSON correctly formatted?", ex); } }  @Override String getCommandName(); @Override void handle(String chargingStationId, JsonObject commandObject, IdentityContext identityContext);  }