@Test public void triggerPush_WhenCallTimeoutIsReached_ShouldNotTriggerPush() { final BingRule bingRule = Mockito.mock(BingRule.class); Mockito.when(bingRule.shouldNotify()).thenReturn(true); Mockito.when(mBingRulesManager.fulfilledBingRule(Mockito.any(Event.class))).thenReturn(bingRule); final Event event = new Event(); event.type = Event.EVENT_TYPE_CALL_INVITE; event.originServerTs = System.currentTimeMillis() - 124000; final RoomState roomState = new RoomState(); mTimelinePushWorker.triggerPush(roomState, event); Mockito.verify(mDataHandler, Mockito.never()).onBingEvent(event, roomState, bingRule); }
public void triggerPush(@NonNull final RoomState state, @NonNull final Event event) { BingRule bingRule; boolean outOfTimeEvent = false; long maxLifetime = 0; long eventLifetime = 0; final JsonObject eventContent = event.getContentAsJsonObject(); if (eventContent != null && eventContent.has("lifetime")) { maxLifetime = eventContent.get("lifetime").getAsLong(); eventLifetime = System.currentTimeMillis() - event.getOriginServerTs(); outOfTimeEvent = eventLifetime > maxLifetime; } final BingRulesManager bingRulesManager = mDataHandler.getBingRulesManager(); if (!outOfTimeEvent && bingRulesManager != null && (bingRule = bingRulesManager.fulfilledBingRule(event)) != null) { if (bingRule.shouldNotify()) { if (Event.EVENT_TYPE_CALL_INVITE.equals(event.getType())) { long lifeTime = event.getAge(); if (Long.MAX_VALUE == lifeTime) { lifeTime = System.currentTimeMillis() - event.getOriginServerTs(); } if (lifeTime > MXCall.CALL_TIMEOUT_MS) { Log.d(LOG_TAG, "IGNORED onBingEvent rule id " + bingRule.ruleId + " event id " + event.eventId + " in " + event.roomId); return; } } Log.d(LOG_TAG, "onBingEvent rule id " + bingRule.ruleId + " event id " + event.eventId + " in " + event.roomId); mDataHandler.onBingEvent(event, state, bingRule); } else { Log.d(LOG_TAG, "rule id " + bingRule.ruleId + " event id " + event.eventId + " in " + event.roomId + " has a mute notify rule"); } } else if (outOfTimeEvent) { Log.e(LOG_TAG, "outOfTimeEvent for " + event.eventId + " in " + event.roomId); Log.e(LOG_TAG, "outOfTimeEvent maxlifetime " + maxLifetime + " eventLifeTime " + eventLifetime); } }
TimelinePushWorker { public void triggerPush(@NonNull final RoomState state, @NonNull final Event event) { BingRule bingRule; boolean outOfTimeEvent = false; long maxLifetime = 0; long eventLifetime = 0; final JsonObject eventContent = event.getContentAsJsonObject(); if (eventContent != null && eventContent.has("lifetime")) { maxLifetime = eventContent.get("lifetime").getAsLong(); eventLifetime = System.currentTimeMillis() - event.getOriginServerTs(); outOfTimeEvent = eventLifetime > maxLifetime; } final BingRulesManager bingRulesManager = mDataHandler.getBingRulesManager(); if (!outOfTimeEvent && bingRulesManager != null && (bingRule = bingRulesManager.fulfilledBingRule(event)) != null) { if (bingRule.shouldNotify()) { if (Event.EVENT_TYPE_CALL_INVITE.equals(event.getType())) { long lifeTime = event.getAge(); if (Long.MAX_VALUE == lifeTime) { lifeTime = System.currentTimeMillis() - event.getOriginServerTs(); } if (lifeTime > MXCall.CALL_TIMEOUT_MS) { Log.d(LOG_TAG, "IGNORED onBingEvent rule id " + bingRule.ruleId + " event id " + event.eventId + " in " + event.roomId); return; } } Log.d(LOG_TAG, "onBingEvent rule id " + bingRule.ruleId + " event id " + event.eventId + " in " + event.roomId); mDataHandler.onBingEvent(event, state, bingRule); } else { Log.d(LOG_TAG, "rule id " + bingRule.ruleId + " event id " + event.eventId + " in " + event.roomId + " has a mute notify rule"); } } else if (outOfTimeEvent) { Log.e(LOG_TAG, "outOfTimeEvent for " + event.eventId + " in " + event.roomId); Log.e(LOG_TAG, "outOfTimeEvent maxlifetime " + maxLifetime + " eventLifeTime " + eventLifetime); } } }
TimelinePushWorker { public void triggerPush(@NonNull final RoomState state, @NonNull final Event event) { BingRule bingRule; boolean outOfTimeEvent = false; long maxLifetime = 0; long eventLifetime = 0; final JsonObject eventContent = event.getContentAsJsonObject(); if (eventContent != null && eventContent.has("lifetime")) { maxLifetime = eventContent.get("lifetime").getAsLong(); eventLifetime = System.currentTimeMillis() - event.getOriginServerTs(); outOfTimeEvent = eventLifetime > maxLifetime; } final BingRulesManager bingRulesManager = mDataHandler.getBingRulesManager(); if (!outOfTimeEvent && bingRulesManager != null && (bingRule = bingRulesManager.fulfilledBingRule(event)) != null) { if (bingRule.shouldNotify()) { if (Event.EVENT_TYPE_CALL_INVITE.equals(event.getType())) { long lifeTime = event.getAge(); if (Long.MAX_VALUE == lifeTime) { lifeTime = System.currentTimeMillis() - event.getOriginServerTs(); } if (lifeTime > MXCall.CALL_TIMEOUT_MS) { Log.d(LOG_TAG, "IGNORED onBingEvent rule id " + bingRule.ruleId + " event id " + event.eventId + " in " + event.roomId); return; } } Log.d(LOG_TAG, "onBingEvent rule id " + bingRule.ruleId + " event id " + event.eventId + " in " + event.roomId); mDataHandler.onBingEvent(event, state, bingRule); } else { Log.d(LOG_TAG, "rule id " + bingRule.ruleId + " event id " + event.eventId + " in " + event.roomId + " has a mute notify rule"); } } else if (outOfTimeEvent) { Log.e(LOG_TAG, "outOfTimeEvent for " + event.eventId + " in " + event.roomId); Log.e(LOG_TAG, "outOfTimeEvent maxlifetime " + maxLifetime + " eventLifeTime " + eventLifetime); } } TimelinePushWorker(@NonNull final MXDataHandler dataHandler); }
TimelinePushWorker { public void triggerPush(@NonNull final RoomState state, @NonNull final Event event) { BingRule bingRule; boolean outOfTimeEvent = false; long maxLifetime = 0; long eventLifetime = 0; final JsonObject eventContent = event.getContentAsJsonObject(); if (eventContent != null && eventContent.has("lifetime")) { maxLifetime = eventContent.get("lifetime").getAsLong(); eventLifetime = System.currentTimeMillis() - event.getOriginServerTs(); outOfTimeEvent = eventLifetime > maxLifetime; } final BingRulesManager bingRulesManager = mDataHandler.getBingRulesManager(); if (!outOfTimeEvent && bingRulesManager != null && (bingRule = bingRulesManager.fulfilledBingRule(event)) != null) { if (bingRule.shouldNotify()) { if (Event.EVENT_TYPE_CALL_INVITE.equals(event.getType())) { long lifeTime = event.getAge(); if (Long.MAX_VALUE == lifeTime) { lifeTime = System.currentTimeMillis() - event.getOriginServerTs(); } if (lifeTime > MXCall.CALL_TIMEOUT_MS) { Log.d(LOG_TAG, "IGNORED onBingEvent rule id " + bingRule.ruleId + " event id " + event.eventId + " in " + event.roomId); return; } } Log.d(LOG_TAG, "onBingEvent rule id " + bingRule.ruleId + " event id " + event.eventId + " in " + event.roomId); mDataHandler.onBingEvent(event, state, bingRule); } else { Log.d(LOG_TAG, "rule id " + bingRule.ruleId + " event id " + event.eventId + " in " + event.roomId + " has a mute notify rule"); } } else if (outOfTimeEvent) { Log.e(LOG_TAG, "outOfTimeEvent for " + event.eventId + " in " + event.roomId); Log.e(LOG_TAG, "outOfTimeEvent maxlifetime " + maxLifetime + " eventLifeTime " + eventLifetime); } } TimelinePushWorker(@NonNull final MXDataHandler dataHandler); void triggerPush(@NonNull final RoomState state,
                            @NonNull final Event event); }
TimelinePushWorker { public void triggerPush(@NonNull final RoomState state, @NonNull final Event event) { BingRule bingRule; boolean outOfTimeEvent = false; long maxLifetime = 0; long eventLifetime = 0; final JsonObject eventContent = event.getContentAsJsonObject(); if (eventContent != null && eventContent.has("lifetime")) { maxLifetime = eventContent.get("lifetime").getAsLong(); eventLifetime = System.currentTimeMillis() - event.getOriginServerTs(); outOfTimeEvent = eventLifetime > maxLifetime; } final BingRulesManager bingRulesManager = mDataHandler.getBingRulesManager(); if (!outOfTimeEvent && bingRulesManager != null && (bingRule = bingRulesManager.fulfilledBingRule(event)) != null) { if (bingRule.shouldNotify()) { if (Event.EVENT_TYPE_CALL_INVITE.equals(event.getType())) { long lifeTime = event.getAge(); if (Long.MAX_VALUE == lifeTime) { lifeTime = System.currentTimeMillis() - event.getOriginServerTs(); } if (lifeTime > MXCall.CALL_TIMEOUT_MS) { Log.d(LOG_TAG, "IGNORED onBingEvent rule id " + bingRule.ruleId + " event id " + event.eventId + " in " + event.roomId); return; } } Log.d(LOG_TAG, "onBingEvent rule id " + bingRule.ruleId + " event id " + event.eventId + " in " + event.roomId); mDataHandler.onBingEvent(event, state, bingRule); } else { Log.d(LOG_TAG, "rule id " + bingRule.ruleId + " event id " + event.eventId + " in " + event.roomId + " has a mute notify rule"); } } else if (outOfTimeEvent) { Log.e(LOG_TAG, "outOfTimeEvent for " + event.eventId + " in " + event.roomId); Log.e(LOG_TAG, "outOfTimeEvent maxlifetime " + maxLifetime + " eventLifeTime " + eventLifetime); } } TimelinePushWorker(@NonNull final MXDataHandler dataHandler); void triggerPush(@NonNull final RoomState state,
                            @NonNull final Event event);  }