Permalink
Browse files

Fixed attribute event timestamps check

  • Loading branch information...
christianbauer committed Oct 11, 2017
1 parent 6f3cfa2 commit 25fb204535298bc687d202f88bea23763926de9a
@@ -154,10 +154,12 @@ public void start(Container container) throws Exception {
@Override
public void stop(Container container) throws Exception {
/* TODO Accessing the database while shutting down is not a good thing, it will hang if the JDBC pool is shutting down
synchronized (protocolConfigurations) {
new ArrayList<>(protocolConfigurations.values())
.forEach(protocolConfigAndConsumer -> unlinkProtocolConfiguration(protocolConfigAndConsumer.key));
}
*/
}
@Override
@@ -236,7 +236,7 @@ public static Processor buildAssetState(TimerService timerService) {
// Check the last update timestamp of the attribute, ignoring any event that is older than last update
// TODO This means we drop out-of-sequence events but accept events with the same source timestamp
// TODO Several attribute events can occur in the same millisecond, then order of application is undefined
lastStateEvent.map(Event::getTimestamp).filter(t -> t > 0 && eventTime <= t).ifPresent(
lastStateEvent.map(Event::getTimestamp).filter(t -> t >= 0 && eventTime < t).ifPresent(
lastStateTime -> {
throw new AssetProcessingException(
Reason.EVENT_OUTDATED,
@@ -150,12 +150,22 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
then: "no rule engines should have fired after a few seconds"
new PollingConditions(initialDelay: 3).eventually assertNoRulesFired
when: "an old (stale) attribute event is pushed into the system"
when: "the same attribute event is pushed into the system (same timestamp as last asset state)"
resetRulesExecutionListeners()
assetProcessingService.sendAttributeEvent(apartment2LivingRoomPresenceDetectedChange)
then: "no rule engines should have fired after a few seconds"
new PollingConditions(initialDelay: 3).eventually assertNoRulesFired
then: "the rule engines in scope should fire the 'All' rule but not the 'All changed' rule"
conditions.eventually {
assert globalEngineFiredRules.size() == 1
assert globalEngineFiredRules[0] == "All"
assert masterEngineFiredRules.size() == 0
assert customerAEngineFiredRules.size() == 1
assert customerAEngineFiredRules[0] == "All"
assert smartHomeEngineFiredRules.size() == 0
assert apartment2EngineFiredRules.size() == 1
assert apartment2EngineFiredRules[0] == "All"
assert apartment3EngineFiredRules.size() == 0
}
when: "an attribute event with the same value as current value is pushed into the system"
resetRulesExecutionListeners()

0 comments on commit 25fb204

Please sign in to comment.