@Test public void testHandleStopTransactionOnRegisteredStation() throws UserIdentityUnauthorizedException { JsonObject commandObject = gson.fromJson("{'id' : '" + OperatorApiJsonTestUtils.NUMBERED_TRANSACTION_ID.getId() + "'}", JsonObject.class); handler.handle(CHARGING_STATION_ID_STRING, commandObject, ChargingStationTestUtils.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(), RequestStopTransactionCommand.class)) { throw new UserIdentityUnauthorizedException(chargingStationId, identityContext.getUserIdentity(), RequestStopTransactionCommand.class); } try { RequestStopTransactionApiCommand command = gson.fromJson(commandObject, RequestStopTransactionApiCommand.class); ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation != null && chargingStation.communicationAllowed()) { TransactionId transactionId = new NumberedTransactionId(csId, chargingStation.getProtocol(), command.getId()); commandGateway.send(new RequestStopTransactionCommand(csId, transactionId, identityContext), new CorrelationToken()); } } catch (JsonSyntaxException ex) { throw new IllegalArgumentException("Configure command not able to parse the payload, is your json correctly formatted?", ex); } }
RequestStopTransactionJsonCommandHandler 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(), RequestStopTransactionCommand.class)) { throw new UserIdentityUnauthorizedException(chargingStationId, identityContext.getUserIdentity(), RequestStopTransactionCommand.class); } try { RequestStopTransactionApiCommand command = gson.fromJson(commandObject, RequestStopTransactionApiCommand.class); ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation != null && chargingStation.communicationAllowed()) { TransactionId transactionId = new NumberedTransactionId(csId, chargingStation.getProtocol(), command.getId()); commandGateway.send(new RequestStopTransactionCommand(csId, transactionId, identityContext), new CorrelationToken()); } } catch (JsonSyntaxException ex) { throw new IllegalArgumentException("Configure command not able to parse the payload, is your json correctly formatted?", ex); } } }
RequestStopTransactionJsonCommandHandler 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(), RequestStopTransactionCommand.class)) { throw new UserIdentityUnauthorizedException(chargingStationId, identityContext.getUserIdentity(), RequestStopTransactionCommand.class); } try { RequestStopTransactionApiCommand command = gson.fromJson(commandObject, RequestStopTransactionApiCommand.class); ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation != null && chargingStation.communicationAllowed()) { TransactionId transactionId = new NumberedTransactionId(csId, chargingStation.getProtocol(), command.getId()); commandGateway.send(new RequestStopTransactionCommand(csId, transactionId, identityContext), new CorrelationToken()); } } catch (JsonSyntaxException ex) { throw new IllegalArgumentException("Configure command not able to parse the payload, is your json correctly formatted?", ex); } }  }
RequestStopTransactionJsonCommandHandler 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(), RequestStopTransactionCommand.class)) { throw new UserIdentityUnauthorizedException(chargingStationId, identityContext.getUserIdentity(), RequestStopTransactionCommand.class); } try { RequestStopTransactionApiCommand command = gson.fromJson(commandObject, RequestStopTransactionApiCommand.class); ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation != null && chargingStation.communicationAllowed()) { TransactionId transactionId = new NumberedTransactionId(csId, chargingStation.getProtocol(), command.getId()); commandGateway.send(new RequestStopTransactionCommand(csId, transactionId, identityContext), new CorrelationToken()); } } catch (JsonSyntaxException ex) { throw new IllegalArgumentException("Configure 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); }
RequestStopTransactionJsonCommandHandler 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(), RequestStopTransactionCommand.class)) { throw new UserIdentityUnauthorizedException(chargingStationId, identityContext.getUserIdentity(), RequestStopTransactionCommand.class); } try { RequestStopTransactionApiCommand command = gson.fromJson(commandObject, RequestStopTransactionApiCommand.class); ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation != null && chargingStation.communicationAllowed()) { TransactionId transactionId = new NumberedTransactionId(csId, chargingStation.getProtocol(), command.getId()); commandGateway.send(new RequestStopTransactionCommand(csId, transactionId, identityContext), new CorrelationToken()); } } catch (JsonSyntaxException ex) { throw new IllegalArgumentException("Configure 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);  }