@Test(expected = IllegalArgumentException.class) public void testOpeningTimesTimeStartEqualToTimeStop() throws UserIdentityUnauthorizedException { JsonObject commandObject = gson.fromJson("{openingTimes:[{day:'tuesday',timeStart:'12:00',timeStop:'12:00'}]}", JsonObject.class); handler.handle(OperatorApiJsonTestUtils.CHARGING_STATION_ID_STRING, commandObject, 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(), SetChargingStationOpeningTimesCommand.class)) { throw new UserIdentityUnauthorizedException(chargingStationId, identityContext.getUserIdentity(), SetChargingStationOpeningTimesCommand.class); } try { ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation != null && chargingStation.isAccepted()) { SetChargingStationOpeningTimesApiCommand command = gson.fromJson(commandObject, SetChargingStationOpeningTimesApiCommand.class); commandGateway.send(new SetChargingStationOpeningTimesCommand(csId, command.getOpeningTimes(), identityContext)); } } catch (JsonSyntaxException e) { throw new IllegalArgumentException("Set charging station opening times command not able to parse the payload, is your JSON correctly formatted?", e); } }
SetChargingStationOpeningTimesJsonCommandHandler 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(), SetChargingStationOpeningTimesCommand.class)) { throw new UserIdentityUnauthorizedException(chargingStationId, identityContext.getUserIdentity(), SetChargingStationOpeningTimesCommand.class); } try { ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation != null && chargingStation.isAccepted()) { SetChargingStationOpeningTimesApiCommand command = gson.fromJson(commandObject, SetChargingStationOpeningTimesApiCommand.class); commandGateway.send(new SetChargingStationOpeningTimesCommand(csId, command.getOpeningTimes(), identityContext)); } } catch (JsonSyntaxException e) { throw new IllegalArgumentException("Set charging station opening times command not able to parse the payload, is your JSON correctly formatted?", e); } } }
SetChargingStationOpeningTimesJsonCommandHandler 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(), SetChargingStationOpeningTimesCommand.class)) { throw new UserIdentityUnauthorizedException(chargingStationId, identityContext.getUserIdentity(), SetChargingStationOpeningTimesCommand.class); } try { ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation != null && chargingStation.isAccepted()) { SetChargingStationOpeningTimesApiCommand command = gson.fromJson(commandObject, SetChargingStationOpeningTimesApiCommand.class); commandGateway.send(new SetChargingStationOpeningTimesCommand(csId, command.getOpeningTimes(), identityContext)); } } catch (JsonSyntaxException e) { throw new IllegalArgumentException("Set charging station opening times command not able to parse the payload, is your JSON correctly formatted?", e); } }  }
SetChargingStationOpeningTimesJsonCommandHandler 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(), SetChargingStationOpeningTimesCommand.class)) { throw new UserIdentityUnauthorizedException(chargingStationId, identityContext.getUserIdentity(), SetChargingStationOpeningTimesCommand.class); } try { ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation != null && chargingStation.isAccepted()) { SetChargingStationOpeningTimesApiCommand command = gson.fromJson(commandObject, SetChargingStationOpeningTimesApiCommand.class); commandGateway.send(new SetChargingStationOpeningTimesCommand(csId, command.getOpeningTimes(), identityContext)); } } catch (JsonSyntaxException e) { throw new IllegalArgumentException("Set charging station opening times 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); }
SetChargingStationOpeningTimesJsonCommandHandler 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(), SetChargingStationOpeningTimesCommand.class)) { throw new UserIdentityUnauthorizedException(chargingStationId, identityContext.getUserIdentity(), SetChargingStationOpeningTimesCommand.class); } try { ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation != null && chargingStation.isAccepted()) { SetChargingStationOpeningTimesApiCommand command = gson.fromJson(commandObject, SetChargingStationOpeningTimesApiCommand.class); commandGateway.send(new SetChargingStationOpeningTimesCommand(csId, command.getOpeningTimes(), identityContext)); } } catch (JsonSyntaxException e) { throw new IllegalArgumentException("Set charging station opening times 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);  }