@Test public void testHandleChangeConfigurationOnRegisteredStation() throws UserIdentityUnauthorizedException { JsonObject commandObject = gson.fromJson("{'key' : 'foo', 'value': 'bar'}", JsonObject.class); handler.handle(OperatorApiJsonTestUtils.CHARGING_STATION_ID.getId(), commandObject, ROOT_IDENTITY_CONTEXT); RequestChangeConfigurationItemCommand command = new RequestChangeConfigurationItemCommand(OperatorApiJsonTestUtils.CHARGING_STATION_ID, new ConfigurationItem("foo", "bar"), ROOT_IDENTITY_CONTEXT); verify(this.gateway).send(eq(command), any(CorrelationToken.class)); }
@Override public void handle(String chargingStationId, JsonObject commandObject, IdentityContext identityContext) throws UserIdentityUnauthorizedException { ChargingStationId csId = new ChargingStationId(chargingStationId); if (!commandAuthorizationService.isAuthorized(csId, identityContext.getUserIdentity(), RequestChangeConfigurationItemCommand.class)) { throw new UserIdentityUnauthorizedException(chargingStationId, identityContext.getUserIdentity(), RequestChangeConfigurationItemCommand.class); } try { ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation != null && chargingStation.communicationAllowed()) { ChangeConfigurationApiCommand command = gson.fromJson(commandObject, ChangeConfigurationApiCommand.class); commandGateway.send(new RequestChangeConfigurationItemCommand(csId, new ConfigurationItem(command.getKey(), command.getValue()), identityContext), new CorrelationToken()); } } catch (JsonSyntaxException ex) { throw new IllegalArgumentException("Change configuration command not able to parse the payload, is your json correctly formatted?", ex); } }
RequestChangeConfigurationItemJsonCommandHandler 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(), RequestChangeConfigurationItemCommand.class)) { throw new UserIdentityUnauthorizedException(chargingStationId, identityContext.getUserIdentity(), RequestChangeConfigurationItemCommand.class); } try { ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation != null && chargingStation.communicationAllowed()) { ChangeConfigurationApiCommand command = gson.fromJson(commandObject, ChangeConfigurationApiCommand.class); commandGateway.send(new RequestChangeConfigurationItemCommand(csId, new ConfigurationItem(command.getKey(), command.getValue()), identityContext), new CorrelationToken()); } } catch (JsonSyntaxException ex) { throw new IllegalArgumentException("Change configuration command not able to parse the payload, is your json correctly formatted?", ex); } } }
RequestChangeConfigurationItemJsonCommandHandler 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(), RequestChangeConfigurationItemCommand.class)) { throw new UserIdentityUnauthorizedException(chargingStationId, identityContext.getUserIdentity(), RequestChangeConfigurationItemCommand.class); } try { ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation != null && chargingStation.communicationAllowed()) { ChangeConfigurationApiCommand command = gson.fromJson(commandObject, ChangeConfigurationApiCommand.class); commandGateway.send(new RequestChangeConfigurationItemCommand(csId, new ConfigurationItem(command.getKey(), command.getValue()), identityContext), new CorrelationToken()); } } catch (JsonSyntaxException ex) { throw new IllegalArgumentException("Change configuration command not able to parse the payload, is your json correctly formatted?", ex); } }  }
RequestChangeConfigurationItemJsonCommandHandler 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(), RequestChangeConfigurationItemCommand.class)) { throw new UserIdentityUnauthorizedException(chargingStationId, identityContext.getUserIdentity(), RequestChangeConfigurationItemCommand.class); } try { ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation != null && chargingStation.communicationAllowed()) { ChangeConfigurationApiCommand command = gson.fromJson(commandObject, ChangeConfigurationApiCommand.class); commandGateway.send(new RequestChangeConfigurationItemCommand(csId, new ConfigurationItem(command.getKey(), command.getValue()), identityContext), new CorrelationToken()); } } catch (JsonSyntaxException ex) { throw new IllegalArgumentException("Change configuration 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); }
RequestChangeConfigurationItemJsonCommandHandler 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(), RequestChangeConfigurationItemCommand.class)) { throw new UserIdentityUnauthorizedException(chargingStationId, identityContext.getUserIdentity(), RequestChangeConfigurationItemCommand.class); } try { ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation != null && chargingStation.communicationAllowed()) { ChangeConfigurationApiCommand command = gson.fromJson(commandObject, ChangeConfigurationApiCommand.class); commandGateway.send(new RequestChangeConfigurationItemCommand(csId, new ConfigurationItem(command.getKey(), command.getValue()), identityContext), new CorrelationToken()); } } catch (JsonSyntaxException ex) { throw new IllegalArgumentException("Change configuration 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);  }