@Test public void testInoperativeCommand() throws UserIdentityUnauthorizedException { JsonObject commandObject = gson.fromJson("{evseId:'1',availability:'inoperative'}", JsonObject.class); handler.handle(OperatorApiJsonTestUtils.CHARGING_STATION_ID_STRING, commandObject, ROOT_IDENTITY_CONTEXT); }
@Override public void handle(String chargingStationId, JsonObject commandObject, IdentityContext identityContext) throws UserIdentityUnauthorizedException { ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation == null || !chargingStation.communicationAllowed()) { return; } RequestChangeChargingStationAvailabilityApiCommand command; try { command = gson.fromJson(commandObject, RequestChangeChargingStationAvailabilityApiCommand.class); } catch (JsonSyntaxException ex) { throw new IllegalArgumentException("Configure command not able to parse the payload, is your json correctly formatted?", ex); } ChargingStationId csId = new ChargingStationId(chargingStationId); UserIdentity userIdentity = identityContext.getUserIdentity(); if (AVAILABILITY_INOPERATIVE.equalsIgnoreCase(command.getAvailability())) { if (command.getEvseId().getNumberedId() == 0) { checkAuthorization(csId, userIdentity, RequestChangeChargingStationAvailabilityToInoperativeCommand.class); commandGateway.send(new RequestChangeChargingStationAvailabilityToInoperativeCommand(new ChargingStationId(chargingStationId), identityContext), new CorrelationToken()); } else { checkAuthorization(csId, userIdentity, RequestChangeComponentAvailabilityToInoperativeCommand.class); commandGateway.send(new RequestChangeComponentAvailabilityToInoperativeCommand(new ChargingStationId(chargingStationId), command.getEvseId(), ChargingStationComponent.EVSE, identityContext), new CorrelationToken()); } } else { if (command.getEvseId().getNumberedId() == 0) { checkAuthorization(csId, userIdentity, RequestChangeChargingStationAvailabilityToOperativeCommand.class); commandGateway.send(new RequestChangeChargingStationAvailabilityToOperativeCommand(new ChargingStationId(chargingStationId), identityContext), new CorrelationToken()); } else { checkAuthorization(csId, userIdentity, RequestChangeComponentAvailabilityToOperativeCommand.class); commandGateway.send(new RequestChangeComponentAvailabilityToOperativeCommand(new ChargingStationId(chargingStationId), command.getEvseId(), ChargingStationComponent.EVSE, identityContext), new CorrelationToken()); } } }
RequestChangeAvailabilityJsonCommandHandler extends JsonCommandHandler { @Override public void handle(String chargingStationId, JsonObject commandObject, IdentityContext identityContext) throws UserIdentityUnauthorizedException { ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation == null || !chargingStation.communicationAllowed()) { return; } RequestChangeChargingStationAvailabilityApiCommand command; try { command = gson.fromJson(commandObject, RequestChangeChargingStationAvailabilityApiCommand.class); } catch (JsonSyntaxException ex) { throw new IllegalArgumentException("Configure command not able to parse the payload, is your json correctly formatted?", ex); } ChargingStationId csId = new ChargingStationId(chargingStationId); UserIdentity userIdentity = identityContext.getUserIdentity(); if (AVAILABILITY_INOPERATIVE.equalsIgnoreCase(command.getAvailability())) { if (command.getEvseId().getNumberedId() == 0) { checkAuthorization(csId, userIdentity, RequestChangeChargingStationAvailabilityToInoperativeCommand.class); commandGateway.send(new RequestChangeChargingStationAvailabilityToInoperativeCommand(new ChargingStationId(chargingStationId), identityContext), new CorrelationToken()); } else { checkAuthorization(csId, userIdentity, RequestChangeComponentAvailabilityToInoperativeCommand.class); commandGateway.send(new RequestChangeComponentAvailabilityToInoperativeCommand(new ChargingStationId(chargingStationId), command.getEvseId(), ChargingStationComponent.EVSE, identityContext), new CorrelationToken()); } } else { if (command.getEvseId().getNumberedId() == 0) { checkAuthorization(csId, userIdentity, RequestChangeChargingStationAvailabilityToOperativeCommand.class); commandGateway.send(new RequestChangeChargingStationAvailabilityToOperativeCommand(new ChargingStationId(chargingStationId), identityContext), new CorrelationToken()); } else { checkAuthorization(csId, userIdentity, RequestChangeComponentAvailabilityToOperativeCommand.class); commandGateway.send(new RequestChangeComponentAvailabilityToOperativeCommand(new ChargingStationId(chargingStationId), command.getEvseId(), ChargingStationComponent.EVSE, identityContext), new CorrelationToken()); } } } }
RequestChangeAvailabilityJsonCommandHandler extends JsonCommandHandler { @Override public void handle(String chargingStationId, JsonObject commandObject, IdentityContext identityContext) throws UserIdentityUnauthorizedException { ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation == null || !chargingStation.communicationAllowed()) { return; } RequestChangeChargingStationAvailabilityApiCommand command; try { command = gson.fromJson(commandObject, RequestChangeChargingStationAvailabilityApiCommand.class); } catch (JsonSyntaxException ex) { throw new IllegalArgumentException("Configure command not able to parse the payload, is your json correctly formatted?", ex); } ChargingStationId csId = new ChargingStationId(chargingStationId); UserIdentity userIdentity = identityContext.getUserIdentity(); if (AVAILABILITY_INOPERATIVE.equalsIgnoreCase(command.getAvailability())) { if (command.getEvseId().getNumberedId() == 0) { checkAuthorization(csId, userIdentity, RequestChangeChargingStationAvailabilityToInoperativeCommand.class); commandGateway.send(new RequestChangeChargingStationAvailabilityToInoperativeCommand(new ChargingStationId(chargingStationId), identityContext), new CorrelationToken()); } else { checkAuthorization(csId, userIdentity, RequestChangeComponentAvailabilityToInoperativeCommand.class); commandGateway.send(new RequestChangeComponentAvailabilityToInoperativeCommand(new ChargingStationId(chargingStationId), command.getEvseId(), ChargingStationComponent.EVSE, identityContext), new CorrelationToken()); } } else { if (command.getEvseId().getNumberedId() == 0) { checkAuthorization(csId, userIdentity, RequestChangeChargingStationAvailabilityToOperativeCommand.class); commandGateway.send(new RequestChangeChargingStationAvailabilityToOperativeCommand(new ChargingStationId(chargingStationId), identityContext), new CorrelationToken()); } else { checkAuthorization(csId, userIdentity, RequestChangeComponentAvailabilityToOperativeCommand.class); commandGateway.send(new RequestChangeComponentAvailabilityToOperativeCommand(new ChargingStationId(chargingStationId), command.getEvseId(), ChargingStationComponent.EVSE, identityContext), new CorrelationToken()); } } }  }
RequestChangeAvailabilityJsonCommandHandler extends JsonCommandHandler { @Override public void handle(String chargingStationId, JsonObject commandObject, IdentityContext identityContext) throws UserIdentityUnauthorizedException { ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation == null || !chargingStation.communicationAllowed()) { return; } RequestChangeChargingStationAvailabilityApiCommand command; try { command = gson.fromJson(commandObject, RequestChangeChargingStationAvailabilityApiCommand.class); } catch (JsonSyntaxException ex) { throw new IllegalArgumentException("Configure command not able to parse the payload, is your json correctly formatted?", ex); } ChargingStationId csId = new ChargingStationId(chargingStationId); UserIdentity userIdentity = identityContext.getUserIdentity(); if (AVAILABILITY_INOPERATIVE.equalsIgnoreCase(command.getAvailability())) { if (command.getEvseId().getNumberedId() == 0) { checkAuthorization(csId, userIdentity, RequestChangeChargingStationAvailabilityToInoperativeCommand.class); commandGateway.send(new RequestChangeChargingStationAvailabilityToInoperativeCommand(new ChargingStationId(chargingStationId), identityContext), new CorrelationToken()); } else { checkAuthorization(csId, userIdentity, RequestChangeComponentAvailabilityToInoperativeCommand.class); commandGateway.send(new RequestChangeComponentAvailabilityToInoperativeCommand(new ChargingStationId(chargingStationId), command.getEvseId(), ChargingStationComponent.EVSE, identityContext), new CorrelationToken()); } } else { if (command.getEvseId().getNumberedId() == 0) { checkAuthorization(csId, userIdentity, RequestChangeChargingStationAvailabilityToOperativeCommand.class); commandGateway.send(new RequestChangeChargingStationAvailabilityToOperativeCommand(new ChargingStationId(chargingStationId), identityContext), new CorrelationToken()); } else { checkAuthorization(csId, userIdentity, RequestChangeComponentAvailabilityToOperativeCommand.class); commandGateway.send(new RequestChangeComponentAvailabilityToOperativeCommand(new ChargingStationId(chargingStationId), command.getEvseId(), ChargingStationComponent.EVSE, identityContext), new CorrelationToken()); } } }  @Override String getCommandName(); @Override void handle(String chargingStationId, JsonObject commandObject, IdentityContext identityContext); }
RequestChangeAvailabilityJsonCommandHandler extends JsonCommandHandler { @Override public void handle(String chargingStationId, JsonObject commandObject, IdentityContext identityContext) throws UserIdentityUnauthorizedException { ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation == null || !chargingStation.communicationAllowed()) { return; } RequestChangeChargingStationAvailabilityApiCommand command; try { command = gson.fromJson(commandObject, RequestChangeChargingStationAvailabilityApiCommand.class); } catch (JsonSyntaxException ex) { throw new IllegalArgumentException("Configure command not able to parse the payload, is your json correctly formatted?", ex); } ChargingStationId csId = new ChargingStationId(chargingStationId); UserIdentity userIdentity = identityContext.getUserIdentity(); if (AVAILABILITY_INOPERATIVE.equalsIgnoreCase(command.getAvailability())) { if (command.getEvseId().getNumberedId() == 0) { checkAuthorization(csId, userIdentity, RequestChangeChargingStationAvailabilityToInoperativeCommand.class); commandGateway.send(new RequestChangeChargingStationAvailabilityToInoperativeCommand(new ChargingStationId(chargingStationId), identityContext), new CorrelationToken()); } else { checkAuthorization(csId, userIdentity, RequestChangeComponentAvailabilityToInoperativeCommand.class); commandGateway.send(new RequestChangeComponentAvailabilityToInoperativeCommand(new ChargingStationId(chargingStationId), command.getEvseId(), ChargingStationComponent.EVSE, identityContext), new CorrelationToken()); } } else { if (command.getEvseId().getNumberedId() == 0) { checkAuthorization(csId, userIdentity, RequestChangeChargingStationAvailabilityToOperativeCommand.class); commandGateway.send(new RequestChangeChargingStationAvailabilityToOperativeCommand(new ChargingStationId(chargingStationId), identityContext), new CorrelationToken()); } else { checkAuthorization(csId, userIdentity, RequestChangeComponentAvailabilityToOperativeCommand.class); commandGateway.send(new RequestChangeComponentAvailabilityToOperativeCommand(new ChargingStationId(chargingStationId), command.getEvseId(), ChargingStationComponent.EVSE, identityContext), new CorrelationToken()); } } }  @Override String getCommandName(); @Override void handle(String chargingStationId, JsonObject commandObject, IdentityContext identityContext);  }