@Test public void testHandleChargingStationSentKiloWattMeterValuesEvent() { Transaction transaction = new Transaction(CHARGING_STATION_ID.getId(), TRANSACTION_ID.getId()); transaction.setEvseId(EVSE_ID); repository.createOrUpdate(transaction); assertTrue(transaction.getMeterValues().isEmpty()); List<MeterValue> meterValuesWithKiloWattHour = ImmutableList.<MeterValue>builder() .add(new MeterValue(new Date(), "1.5", ReadingContext.PERIODIC_SAMPLE, ValueFormat.RAW, Measurand.IMPORTED_ACTIVE_ENERGY_REGISTER, Location.OUTLET, UnitOfMeasure.KILOWATT_HOUR)) .build(); listener.handle(new ChargingStationSentMeterValuesEvent(CHARGING_STATION_ID, TRANSACTION_ID, EVSE_ID, meterValuesWithKiloWattHour, IDENTITY_CONTEXT)); transaction = repository.findByTransactionId(TRANSACTION_ID.getId()); assertFalse(transaction.getMeterValues().isEmpty()); assertEquals(1, transaction.getMeterValues().size()); assertEquals("1500.0", transaction.getMeterValues().iterator().next().getWattHour()); }
@EventHandler public void handle(TransactionStartedEvent event) { LOG.debug("TransactionStartedEvent for [{}] received!", event.getChargingStationId()); StartTransactionInfo startTransactionInfo = event.getStartTransactionInfo(); IdentifyingToken identifyingToken = startTransactionInfo.getIdentifyingToken(); Transaction transaction = new Transaction(event.getChargingStationId().getId(), event.getTransactionId().getId(), startTransactionInfo.getEvseId(), identifyingToken.getToken(), startTransactionInfo.getMeterStart(), startTransactionInfo.getTimestamp(), identifyingToken.getMobilityServiceProvider(), identifyingToken.getVisibleId()); repository.createOrUpdate(transaction); }
TransactionEventListener { @EventHandler public void handle(TransactionStartedEvent event) { LOG.debug("TransactionStartedEvent for [{}] received!", event.getChargingStationId()); StartTransactionInfo startTransactionInfo = event.getStartTransactionInfo(); IdentifyingToken identifyingToken = startTransactionInfo.getIdentifyingToken(); Transaction transaction = new Transaction(event.getChargingStationId().getId(), event.getTransactionId().getId(), startTransactionInfo.getEvseId(), identifyingToken.getToken(), startTransactionInfo.getMeterStart(), startTransactionInfo.getTimestamp(), identifyingToken.getMobilityServiceProvider(), identifyingToken.getVisibleId()); repository.createOrUpdate(transaction); } }
TransactionEventListener { @EventHandler public void handle(TransactionStartedEvent event) { LOG.debug("TransactionStartedEvent for [{}] received!", event.getChargingStationId()); StartTransactionInfo startTransactionInfo = event.getStartTransactionInfo(); IdentifyingToken identifyingToken = startTransactionInfo.getIdentifyingToken(); Transaction transaction = new Transaction(event.getChargingStationId().getId(), event.getTransactionId().getId(), startTransactionInfo.getEvseId(), identifyingToken.getToken(), startTransactionInfo.getMeterStart(), startTransactionInfo.getTimestamp(), identifyingToken.getMobilityServiceProvider(), identifyingToken.getVisibleId()); repository.createOrUpdate(transaction); }  }
TransactionEventListener { @EventHandler public void handle(TransactionStartedEvent event) { LOG.debug("TransactionStartedEvent for [{}] received!", event.getChargingStationId()); StartTransactionInfo startTransactionInfo = event.getStartTransactionInfo(); IdentifyingToken identifyingToken = startTransactionInfo.getIdentifyingToken(); Transaction transaction = new Transaction(event.getChargingStationId().getId(), event.getTransactionId().getId(), startTransactionInfo.getEvseId(), identifyingToken.getToken(), startTransactionInfo.getMeterStart(), startTransactionInfo.getTimestamp(), identifyingToken.getMobilityServiceProvider(), identifyingToken.getVisibleId()); repository.createOrUpdate(transaction); }  void setRepository(TransactionRepository repository); @EventHandler void handle(TransactionStartedEvent event); @EventHandler void handle(TransactionStoppedEvent event); @EventHandler void handle(ChargingStationSentMeterValuesEvent event); }
TransactionEventListener { @EventHandler public void handle(TransactionStartedEvent event) { LOG.debug("TransactionStartedEvent for [{}] received!", event.getChargingStationId()); StartTransactionInfo startTransactionInfo = event.getStartTransactionInfo(); IdentifyingToken identifyingToken = startTransactionInfo.getIdentifyingToken(); Transaction transaction = new Transaction(event.getChargingStationId().getId(), event.getTransactionId().getId(), startTransactionInfo.getEvseId(), identifyingToken.getToken(), startTransactionInfo.getMeterStart(), startTransactionInfo.getTimestamp(), identifyingToken.getMobilityServiceProvider(), identifyingToken.getVisibleId()); repository.createOrUpdate(transaction); }  void setRepository(TransactionRepository repository); @EventHandler void handle(TransactionStartedEvent event); @EventHandler void handle(TransactionStoppedEvent event); @EventHandler void handle(ChargingStationSentMeterValuesEvent event);  }