@Test public void testDomainServiceReturningNull() { String unknownManufacturer = "UNKNOWN"; String unknownModel = "MODEL"; when(domainService.getEvses(unknownManufacturer, unknownModel)).thenReturn(null); eventListener.onEvent(new UnconfiguredChargingStationBootedEvent(CHARGING_STATION_ID, PROTOCOL, getAttributes(unknownManufacturer, unknownModel), IDENTITY_CONTEXT)); verify(domainService).getEvses(unknownManufacturer, unknownModel); verify(gateway, never()).send(any(ConfigureChargingStationCommand.class)); }
@EventHandler protected void onEvent(UnconfiguredChargingStationBootedEvent event) { LOG.info("Handling UnconfiguredChargingStationBootedEvent"); Map<String, String> attributes = event.getAttributes(); Set<Evse> evses = domainService.getEvses(attributes.get(AttributeMapKeys.VENDOR_ID), attributes.get(AttributeMapKeys.MODEL)); if (evses != null && !evses.isEmpty()) { IdentityContext identityContext = new IdentityContext(addOnIdentity, new NullUserIdentity()); ConfigureChargingStationCommand command = new ConfigureChargingStationCommand(event.getChargingStationId(), evses, identityContext); LOG.info("Sending configure charging station command for charging station: {}", event.getChargingStationId()); commandGateway.send(command); } else { LOG.info("No Evses found for vendor {} and model {}", attributes.get(AttributeMapKeys.VENDOR_ID), attributes.get(AttributeMapKeys.MODEL)); } }
ConfigurationEventListener { @EventHandler protected void onEvent(UnconfiguredChargingStationBootedEvent event) { LOG.info("Handling UnconfiguredChargingStationBootedEvent"); Map<String, String> attributes = event.getAttributes(); Set<Evse> evses = domainService.getEvses(attributes.get(AttributeMapKeys.VENDOR_ID), attributes.get(AttributeMapKeys.MODEL)); if (evses != null && !evses.isEmpty()) { IdentityContext identityContext = new IdentityContext(addOnIdentity, new NullUserIdentity()); ConfigureChargingStationCommand command = new ConfigureChargingStationCommand(event.getChargingStationId(), evses, identityContext); LOG.info("Sending configure charging station command for charging station: {}", event.getChargingStationId()); commandGateway.send(command); } else { LOG.info("No Evses found for vendor {} and model {}", attributes.get(AttributeMapKeys.VENDOR_ID), attributes.get(AttributeMapKeys.MODEL)); } } }
ConfigurationEventListener { @EventHandler protected void onEvent(UnconfiguredChargingStationBootedEvent event) { LOG.info("Handling UnconfiguredChargingStationBootedEvent"); Map<String, String> attributes = event.getAttributes(); Set<Evse> evses = domainService.getEvses(attributes.get(AttributeMapKeys.VENDOR_ID), attributes.get(AttributeMapKeys.MODEL)); if (evses != null && !evses.isEmpty()) { IdentityContext identityContext = new IdentityContext(addOnIdentity, new NullUserIdentity()); ConfigureChargingStationCommand command = new ConfigureChargingStationCommand(event.getChargingStationId(), evses, identityContext); LOG.info("Sending configure charging station command for charging station: {}", event.getChargingStationId()); commandGateway.send(command); } else { LOG.info("No Evses found for vendor {} and model {}", attributes.get(AttributeMapKeys.VENDOR_ID), attributes.get(AttributeMapKeys.MODEL)); } }  }
ConfigurationEventListener { @EventHandler protected void onEvent(UnconfiguredChargingStationBootedEvent event) { LOG.info("Handling UnconfiguredChargingStationBootedEvent"); Map<String, String> attributes = event.getAttributes(); Set<Evse> evses = domainService.getEvses(attributes.get(AttributeMapKeys.VENDOR_ID), attributes.get(AttributeMapKeys.MODEL)); if (evses != null && !evses.isEmpty()) { IdentityContext identityContext = new IdentityContext(addOnIdentity, new NullUserIdentity()); ConfigureChargingStationCommand command = new ConfigureChargingStationCommand(event.getChargingStationId(), evses, identityContext); LOG.info("Sending configure charging station command for charging station: {}", event.getChargingStationId()); commandGateway.send(command); } else { LOG.info("No Evses found for vendor {} and model {}", attributes.get(AttributeMapKeys.VENDOR_ID), attributes.get(AttributeMapKeys.MODEL)); } }  void setCommandGateway(ConfigurationCommandGateway commandGateway); void setDomainService(DomainService domainService); void setAddOnId(String id); }
ConfigurationEventListener { @EventHandler protected void onEvent(UnconfiguredChargingStationBootedEvent event) { LOG.info("Handling UnconfiguredChargingStationBootedEvent"); Map<String, String> attributes = event.getAttributes(); Set<Evse> evses = domainService.getEvses(attributes.get(AttributeMapKeys.VENDOR_ID), attributes.get(AttributeMapKeys.MODEL)); if (evses != null && !evses.isEmpty()) { IdentityContext identityContext = new IdentityContext(addOnIdentity, new NullUserIdentity()); ConfigureChargingStationCommand command = new ConfigureChargingStationCommand(event.getChargingStationId(), evses, identityContext); LOG.info("Sending configure charging station command for charging station: {}", event.getChargingStationId()); commandGateway.send(command); } else { LOG.info("No Evses found for vendor {} and model {}", attributes.get(AttributeMapKeys.VENDOR_ID), attributes.get(AttributeMapKeys.MODEL)); } }  void setCommandGateway(ConfigurationCommandGateway commandGateway); void setDomainService(DomainService domainService); void setAddOnId(String id); static final String ADD_ON_TYPE; }