@Test public void testNullCorrelationId() { eventListener.onEvent(new AuthorizationRequestedEvent(CHARGING_STATION_ID, IDENTIFYING_TOKEN, identityContext), null); verify(service).validate(IDENTIFYING_TOKEN, CHARGING_STATION_ID); verify(gateway).send(argThat(new ArgumentMatcher<CommandMessage>() { @Override public boolean matches(Object o) { if (!(o instanceof GenericCommandMessage)) { return false; } return ((GenericCommandMessage) o).getMetaData().size() == 0; } })); }
@EventHandler protected void onEvent(AuthorizationRequestedEvent event, @MetaData(value = CorrelationToken.KEY, required = false) CorrelationToken correlationToken) { IdentifyingToken identifyingToken = event.getIdentifyingToken(); identifyingToken = identificationAuthorizationService.validate(identifyingToken, event.getChargingStationId()); CommandMessage commandMessage; IdentityContext identityContext = new IdentityContext(addOnIdentity, new NullUserIdentity()); if (identifyingToken.isValid()) { commandMessage = asCommandMessage(new GrantAuthorizationCommand(event.getChargingStationId(), identifyingToken, identityContext)); } else { commandMessage = asCommandMessage(new DenyAuthorizationCommand(event.getChargingStationId(), identifyingToken, identityContext)); } if (correlationToken != null) { commandMessage = commandMessage.andMetaData(Collections.singletonMap(CorrelationToken.KEY, correlationToken)); } commandGateway.send(commandMessage); }
AuthorizationEventListener { @EventHandler protected void onEvent(AuthorizationRequestedEvent event, @MetaData(value = CorrelationToken.KEY, required = false) CorrelationToken correlationToken) { IdentifyingToken identifyingToken = event.getIdentifyingToken(); identifyingToken = identificationAuthorizationService.validate(identifyingToken, event.getChargingStationId()); CommandMessage commandMessage; IdentityContext identityContext = new IdentityContext(addOnIdentity, new NullUserIdentity()); if (identifyingToken.isValid()) { commandMessage = asCommandMessage(new GrantAuthorizationCommand(event.getChargingStationId(), identifyingToken, identityContext)); } else { commandMessage = asCommandMessage(new DenyAuthorizationCommand(event.getChargingStationId(), identifyingToken, identityContext)); } if (correlationToken != null) { commandMessage = commandMessage.andMetaData(Collections.singletonMap(CorrelationToken.KEY, correlationToken)); } commandGateway.send(commandMessage); } }
AuthorizationEventListener { @EventHandler protected void onEvent(AuthorizationRequestedEvent event, @MetaData(value = CorrelationToken.KEY, required = false) CorrelationToken correlationToken) { IdentifyingToken identifyingToken = event.getIdentifyingToken(); identifyingToken = identificationAuthorizationService.validate(identifyingToken, event.getChargingStationId()); CommandMessage commandMessage; IdentityContext identityContext = new IdentityContext(addOnIdentity, new NullUserIdentity()); if (identifyingToken.isValid()) { commandMessage = asCommandMessage(new GrantAuthorizationCommand(event.getChargingStationId(), identifyingToken, identityContext)); } else { commandMessage = asCommandMessage(new DenyAuthorizationCommand(event.getChargingStationId(), identifyingToken, identityContext)); } if (correlationToken != null) { commandMessage = commandMessage.andMetaData(Collections.singletonMap(CorrelationToken.KEY, correlationToken)); } commandGateway.send(commandMessage); }  }
AuthorizationEventListener { @EventHandler protected void onEvent(AuthorizationRequestedEvent event, @MetaData(value = CorrelationToken.KEY, required = false) CorrelationToken correlationToken) { IdentifyingToken identifyingToken = event.getIdentifyingToken(); identifyingToken = identificationAuthorizationService.validate(identifyingToken, event.getChargingStationId()); CommandMessage commandMessage; IdentityContext identityContext = new IdentityContext(addOnIdentity, new NullUserIdentity()); if (identifyingToken.isValid()) { commandMessage = asCommandMessage(new GrantAuthorizationCommand(event.getChargingStationId(), identifyingToken, identityContext)); } else { commandMessage = asCommandMessage(new DenyAuthorizationCommand(event.getChargingStationId(), identifyingToken, identityContext)); } if (correlationToken != null) { commandMessage = commandMessage.andMetaData(Collections.singletonMap(CorrelationToken.KEY, correlationToken)); } commandGateway.send(commandMessage); }  void setIdentificationAuthorizationService(IdentificationAuthorizationService identificationAuthorizationService); void setCommandGateway(AuthorizationCommandGateway commandGateway); void setAddOnIdentity(String addOnIdentity); }
AuthorizationEventListener { @EventHandler protected void onEvent(AuthorizationRequestedEvent event, @MetaData(value = CorrelationToken.KEY, required = false) CorrelationToken correlationToken) { IdentifyingToken identifyingToken = event.getIdentifyingToken(); identifyingToken = identificationAuthorizationService.validate(identifyingToken, event.getChargingStationId()); CommandMessage commandMessage; IdentityContext identityContext = new IdentityContext(addOnIdentity, new NullUserIdentity()); if (identifyingToken.isValid()) { commandMessage = asCommandMessage(new GrantAuthorizationCommand(event.getChargingStationId(), identifyingToken, identityContext)); } else { commandMessage = asCommandMessage(new DenyAuthorizationCommand(event.getChargingStationId(), identifyingToken, identityContext)); } if (correlationToken != null) { commandMessage = commandMessage.andMetaData(Collections.singletonMap(CorrelationToken.KEY, correlationToken)); } commandGateway.send(commandMessage); }  void setIdentificationAuthorizationService(IdentificationAuthorizationService identificationAuthorizationService); void setCommandGateway(AuthorizationCommandGateway commandGateway); void setAddOnIdentity(String addOnIdentity);  }