@Test public void testHandleTransactionStoppedEvent() { ChargingStation cs = new ChargingStation(CHARGING_STATION_ID.getId()); cs.setEvses(ImmutableSet.<Evse>builder().add(new Evse("1", ComponentStatus.AVAILABLE)).build()); chargingStationRepository.createOrUpdate(cs); listener.handle(new TransactionStartedEvent(CHARGING_STATION_ID, TRANSACTION_ID, START_TRANSACTION_INFO, IDENTITY_CONTEXT)); Transaction transaction = repository.findByTransactionId(TRANSACTION_ID.getId()); assertNotNull(transaction); assertEquals(0, transaction.getMeterStop()); assertNull(transaction.getStoppedTimestamp()); listener.handle(new TransactionStoppedEvent(CHARGING_STATION_ID, TRANSACTION_ID, IDENTIFYING_TOKEN_ACCEPTED, METER_STOP, new Date(), IDENTITY_CONTEXT)); transaction = repository.findByTransactionId(TRANSACTION_ID.getId()); assertTrue(transaction.getMeterStop() > 0 && transaction.getMeterStop() > transaction.getMeterStart()); assertNotNull(transaction.getStoppedTimestamp()); assertTrue(transaction.getStoppedTimestamp().after(transaction.getStartedTimestamp())); }
@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);  }