@Test public void testUnlockCommand() throws UserIdentityUnauthorizedException { JsonObject commandObject = gson.fromJson("{evseId:'1'}", JsonObject.class); handler.handle(CHARGING_STATION_ID_STRING, commandObject, 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(), RequestUnlockEvseCommand.class)) { throw new UserIdentityUnauthorizedException(chargingStationId, identityContext.getUserIdentity(), RequestUnlockEvseCommand.class); } try { ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation != null && chargingStation.communicationAllowed()) { UnlockEvseApiCommand command = gson.fromJson(commandObject, UnlockEvseApiCommand.class); commandGateway.send(new RequestUnlockEvseCommand(csId, command.getEvseId(), identityContext), new CorrelationToken()); } } catch (JsonSyntaxException e) { throw new IllegalArgumentException("Unlock evse command not able to parse the payload, is your JSON correctly formatted?", e); } }
RequestUnlockEvseJsonCommandHandler 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(), RequestUnlockEvseCommand.class)) { throw new UserIdentityUnauthorizedException(chargingStationId, identityContext.getUserIdentity(), RequestUnlockEvseCommand.class); } try { ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation != null && chargingStation.communicationAllowed()) { UnlockEvseApiCommand command = gson.fromJson(commandObject, UnlockEvseApiCommand.class); commandGateway.send(new RequestUnlockEvseCommand(csId, command.getEvseId(), identityContext), new CorrelationToken()); } } catch (JsonSyntaxException e) { throw new IllegalArgumentException("Unlock evse command not able to parse the payload, is your JSON correctly formatted?", e); } } }
RequestUnlockEvseJsonCommandHandler 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(), RequestUnlockEvseCommand.class)) { throw new UserIdentityUnauthorizedException(chargingStationId, identityContext.getUserIdentity(), RequestUnlockEvseCommand.class); } try { ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation != null && chargingStation.communicationAllowed()) { UnlockEvseApiCommand command = gson.fromJson(commandObject, UnlockEvseApiCommand.class); commandGateway.send(new RequestUnlockEvseCommand(csId, command.getEvseId(), identityContext), new CorrelationToken()); } } catch (JsonSyntaxException e) { throw new IllegalArgumentException("Unlock evse command not able to parse the payload, is your JSON correctly formatted?", e); } }  }
RequestUnlockEvseJsonCommandHandler 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(), RequestUnlockEvseCommand.class)) { throw new UserIdentityUnauthorizedException(chargingStationId, identityContext.getUserIdentity(), RequestUnlockEvseCommand.class); } try { ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation != null && chargingStation.communicationAllowed()) { UnlockEvseApiCommand command = gson.fromJson(commandObject, UnlockEvseApiCommand.class); commandGateway.send(new RequestUnlockEvseCommand(csId, command.getEvseId(), identityContext), new CorrelationToken()); } } catch (JsonSyntaxException e) { throw new IllegalArgumentException("Unlock evse command not able to parse the payload, is your JSON correctly formatted?", e); } }  @Override String getCommandName(); @Override void handle(String chargingStationId, JsonObject commandObject, IdentityContext identityContext); }
RequestUnlockEvseJsonCommandHandler 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(), RequestUnlockEvseCommand.class)) { throw new UserIdentityUnauthorizedException(chargingStationId, identityContext.getUserIdentity(), RequestUnlockEvseCommand.class); } try { ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation != null && chargingStation.communicationAllowed()) { UnlockEvseApiCommand command = gson.fromJson(commandObject, UnlockEvseApiCommand.class); commandGateway.send(new RequestUnlockEvseCommand(csId, command.getEvseId(), identityContext), new CorrelationToken()); } } catch (JsonSyntaxException e) { throw new IllegalArgumentException("Unlock evse command not able to parse the payload, is your JSON correctly formatted?", e); } }  @Override String getCommandName(); @Override void handle(String chargingStationId, JsonObject commandObject, IdentityContext identityContext);  }