@Override public void afterTick(TimeLapse timeLapse) { assertThat(leh.getEventTypeHistory()).containsExactly( ClockEventType.STARTED); } });
@Override public void tick(TimeLapse timeLapse) { intervals.add(Range.openClosed(timeLapse.getStartTime(), timeLapse.getEndTime())); assertThat(leh.getEventTypeHistory()).containsExactly( ClockEventType.STARTED); }
assertEquals(asList(), l1.getEventTypeHistory()); assertEquals(asList(EVENT2), l2.getEventTypeHistory()); assertEquals(asList(EVENT2), l3.getEventTypeHistory()); assertEquals(asList(), l1.getEventTypeHistory()); assertEquals(asList(EVENT2), l2.getEventTypeHistory()); assertEquals(asList(EVENT2, EVENT3), l3.getEventTypeHistory()); assertEquals(asList(EVENT1), l1.getEventTypeHistory()); assertEquals(asList(EVENT2, EVENT1), l2.getEventTypeHistory()); assertEquals(asList(EVENT2, EVENT3, EVENT1), l3.getEventTypeHistory()); assertEquals(asList(EVENT1), l1.getEventTypeHistory()); assertEquals(asList(EVENT2, EVENT1), l2.getEventTypeHistory()); assertEquals(asList(EVENT2, EVENT3, EVENT1, EVENT3), l3.getEventTypeHistory());
verify(clock, times(1)).switchToSimulatedTime(); assertThat(eventHistory.getEventTypeHistory()) .containsExactly(EventType.NEW_SCHEDULE); assertThat(solvers.get(0).isScheduleUpdated()).isTrue();
assertEquals(asList(ADD_CONNECTION), history.getEventTypeHistory()); history.getEventTypeHistory()); assertEquals( asList(ADD_CONNECTION, ADD_CONNECTION, ADD_CONNECTION, ADD_CONNECTION), history.getEventTypeHistory()); asList(ADD_CONNECTION, ADD_CONNECTION, ADD_CONNECTION, ADD_CONNECTION, REMOVE_CONNECTION), history.getEventTypeHistory()); asList(ADD_CONNECTION, ADD_CONNECTION, ADD_CONNECTION, ADD_CONNECTION, REMOVE_CONNECTION, CHANGE_CONNECTION_DATA), history.getEventTypeHistory()); REMOVE_CONNECTION, CHANGE_CONNECTION_DATA, REMOVE_CONNECTION, REMOVE_CONNECTION, REMOVE_CONNECTION), history.getEventTypeHistory());
/** * Tests that the same device is used again upon re-registering. */ @Test public void testRegisterUnregistered() { final ListenerEventHistory leh = new ListenerEventHistory(); model.getEventAPI().addListener(leh, EventTypes.ADD_COMM_USER, EventTypes.REMOVE_COMM_USER); final CommDevice originalDevice = agent1.device(); assertThat(model.contains(agent1)).isTrue(); model.unregister(agent1); assertThat(model.contains(agent1)).isFalse(); assertThat(leh.getEventTypeHistory()).containsExactly(REMOVE_COMM_USER) .inOrder(); model.register(agent1); assertThat(model.contains(agent1)).isTrue(); final CommDevice newDevice = agent1.device(); assertThat(originalDevice).isSameAs(newDevice); assertThat(leh.getEventTypeHistory()).containsExactly(REMOVE_COMM_USER, ADD_COMM_USER) .inOrder(); newDevice.broadcast(Contents.HELLO_WORLD); }
/** * Tests that STOPPED event is dispatched when an exception occurs. */ @Test public void testStoppedEventOnException() { final ListenerEventHistory history = new ListenerEventHistory(); getModel().getEventAPI().addListener(history, Clock.ClockEventType.STOPPED); getModel().register(new TickListener() { @Override public void tick(TimeLapse timeLapse) { if (timeLapse.getStartTime() >= 300) { throw new IllegalStateException("Test"); } } @Override public void afterTick(TimeLapse timeLapse) {} }); boolean failure = false; try { getModel().start(); } catch (final IllegalStateException e) { assertThat(e.getMessage()).isEqualTo("Test"); assertThat(history.getEventTypeHistory()).containsExactly( ClockEventType.STOPPED); failure = true; } assertThat(failure).isTrue(); }
assertThat(history.getEventTypeHistory()).containsExactly( ClockEventType.STARTED, RtClockEventType.SWITCH_TO_SIM_TIME); assertThat(history.getEventTypeHistory()).containsExactly( ClockEventType.STARTED, RtClockEventType.SWITCH_TO_SIM_TIME); } else { assertThat(history.getEventTypeHistory()).containsExactly( ClockEventType.STARTED, RtClockEventType.SWITCH_TO_SIM_TIME, assertThat(getModel().getClockMode()).isEqualTo(ClockMode.SIMULATED); if (timeLapse.getTime() == 100000) { assertThat(history.getEventTypeHistory()).containsExactly( ClockEventType.STARTED, RtClockEventType.SWITCH_TO_SIM_TIME); } else { assertThat(history.getEventTypeHistory()).containsExactly( ClockEventType.STARTED, RtClockEventType.SWITCH_TO_SIM_TIME, assertThat(getModel().getClockMode()).isEqualTo(ClockMode.REAL_TIME); if (timeLapse.getTime() == 100100) { assertThat(history.getEventTypeHistory()).containsExactly( ClockEventType.STARTED, RtClockEventType.SWITCH_TO_SIM_TIME, RtClockEventType.SWITCH_TO_REAL_TIME); } else { assertThat(history.getEventTypeHistory()).containsExactly( ClockEventType.STARTED, RtClockEventType.SWITCH_TO_SIM_TIME,
assertThat(history.getEventTypeHistory()).containsExactly( ClockEventType.STARTED, RtClockEventType.SWITCH_TO_SIM_TIME,
assertThat(leh.getEventTypeHistory()).isEmpty(); getModel().start(); assertThat(intervals).hasSize(2); Range.openClosed(model.getTickLength(), model.getTickLength() * 2)) .inOrder(); assertThat(leh.getEventTypeHistory()).containsExactly( ClockEventType.STARTED, ClockEventType.STOPPED);
history.getEventTypeHistory());
EventB.create(0L)); assertThat(cHandler.getEvents()).isEmpty(); assertThat(leh.getEventTypeHistory()).containsExactly( EventType.SCENARIO_STARTED, EventType.SCENARIO_EVENT,
/** * Test starting and stopping time. */ @Test public void testStartStop() { final LimitingTickListener ltl = new LimitingTickListener(getModel(), 3); final ListenerEventHistory leh = new ListenerEventHistory(); getModel().getEventAPI().addListener(leh, ClockEventType.values()); getModel().register(ltl); getModel().start(); assertEquals(3 * getModel().getTickLength(), getModel().getCurrentTime()); getModel().start(); assertEquals(6 * getModel().getTickLength(), getModel().getCurrentTime()); assertThat(leh.getEventTypeHistory()).isEqualTo( asList( ClockEventType.STARTED, ClockEventType.STOPPED, ClockEventType.STARTED, ClockEventType.STOPPED)); }
EventC.create(100)).inOrder(); assertThat(leh.getEventTypeHistory()) .containsAllOf(SCENARIO_STARTED, SCENARIO_FINISHED) .inOrder();
EventA.create(0)).inOrder(); assertThat(leh.getEventTypeHistory()) .containsExactly(SCENARIO_EVENT, SCENARIO_EVENT, SCENARIO_STARTED, SCENARIO_EVENT)