@Test(expected = JsonParseException.class) public void testStartTransactionStatusIsObject() throws UserIdentityUnauthorizedException { JsonObject command = gson.fromJson("{evseId:'1',identifyingToken:{token:'1',status:{status:'ACCEPTED'}}}", JsonObject.class); handler.handle(CHARGING_STATION_ID_STRING, command, ROOT_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(), RequestStartTransactionCommand.class)) { throw new UserIdentityUnauthorizedException(chargingStationId, identityContext.getUserIdentity(), RequestStartTransactionCommand.class); } try { ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation != null && chargingStation.communicationAllowed()) { RequestStartTransactionApiCommand command = gson.fromJson(commandObject, RequestStartTransactionApiCommand.class); commandGateway.send(new RequestStartTransactionCommand(csId, command.getIdentifyingToken(), command.getEvseId(), identityContext), new CorrelationToken()); } else { throw new IllegalStateException("It is not possible to request a start transaction on a charging station that is not registered"); } } catch (JsonSyntaxException ex) { throw new IllegalArgumentException("Start transaction command is not able to parse the payload, is your json correctly formatted?", ex); } }
RequestStartTransactionJsonCommandHandler 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(), RequestStartTransactionCommand.class)) { throw new UserIdentityUnauthorizedException(chargingStationId, identityContext.getUserIdentity(), RequestStartTransactionCommand.class); } try { ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation != null && chargingStation.communicationAllowed()) { RequestStartTransactionApiCommand command = gson.fromJson(commandObject, RequestStartTransactionApiCommand.class); commandGateway.send(new RequestStartTransactionCommand(csId, command.getIdentifyingToken(), command.getEvseId(), identityContext), new CorrelationToken()); } else { throw new IllegalStateException("It is not possible to request a start transaction on a charging station that is not registered"); } } catch (JsonSyntaxException ex) { throw new IllegalArgumentException("Start transaction command is not able to parse the payload, is your json correctly formatted?", ex); } } }
RequestStartTransactionJsonCommandHandler 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(), RequestStartTransactionCommand.class)) { throw new UserIdentityUnauthorizedException(chargingStationId, identityContext.getUserIdentity(), RequestStartTransactionCommand.class); } try { ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation != null && chargingStation.communicationAllowed()) { RequestStartTransactionApiCommand command = gson.fromJson(commandObject, RequestStartTransactionApiCommand.class); commandGateway.send(new RequestStartTransactionCommand(csId, command.getIdentifyingToken(), command.getEvseId(), identityContext), new CorrelationToken()); } else { throw new IllegalStateException("It is not possible to request a start transaction on a charging station that is not registered"); } } catch (JsonSyntaxException ex) { throw new IllegalArgumentException("Start transaction command is not able to parse the payload, is your json correctly formatted?", ex); } }  }
RequestStartTransactionJsonCommandHandler 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(), RequestStartTransactionCommand.class)) { throw new UserIdentityUnauthorizedException(chargingStationId, identityContext.getUserIdentity(), RequestStartTransactionCommand.class); } try { ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation != null && chargingStation.communicationAllowed()) { RequestStartTransactionApiCommand command = gson.fromJson(commandObject, RequestStartTransactionApiCommand.class); commandGateway.send(new RequestStartTransactionCommand(csId, command.getIdentifyingToken(), command.getEvseId(), identityContext), new CorrelationToken()); } else { throw new IllegalStateException("It is not possible to request a start transaction on a charging station that is not registered"); } } catch (JsonSyntaxException ex) { throw new IllegalArgumentException("Start transaction command is not able to parse the payload, is your json correctly formatted?", ex); } }  @Override String getCommandName(); @Override void handle(String chargingStationId, JsonObject commandObject, IdentityContext identityContext); }
RequestStartTransactionJsonCommandHandler 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(), RequestStartTransactionCommand.class)) { throw new UserIdentityUnauthorizedException(chargingStationId, identityContext.getUserIdentity(), RequestStartTransactionCommand.class); } try { ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation != null && chargingStation.communicationAllowed()) { RequestStartTransactionApiCommand command = gson.fromJson(commandObject, RequestStartTransactionApiCommand.class); commandGateway.send(new RequestStartTransactionCommand(csId, command.getIdentifyingToken(), command.getEvseId(), identityContext), new CorrelationToken()); } else { throw new IllegalStateException("It is not possible to request a start transaction on a charging station that is not registered"); } } catch (JsonSyntaxException ex) { throw new IllegalArgumentException("Start transaction command is not able to parse the payload, is your json correctly formatted?", ex); } }  @Override String getCommandName(); @Override void handle(String chargingStationId, JsonObject commandObject, IdentityContext identityContext);  }