ScenarioConverters { public static Function<Scenario, Scenario> toRealtime() { return TimeModelConverter.TO_RT; } private  ScenarioConverters(); static Function<Scenario, Scenario> useTimeModel(
      final TimeModel.AbstractBuilder<?> timeModel); static Function<Scenario, Scenario> toRealtime(); static Function<Scenario, Scenario> toSimulatedtime(); static Function<Scenario, Scenario> eventConverter(
      final Function<TimedEvent, TimedEvent> converter);  }
@Test public void testEmpty() { final Scenario empty = Scenario.builder().build(); assertThat(empty.getModelBuilders()).isEmpty(); final Scenario convertedEmpty = verifyNotNull(ScenarioConverters.toRealtime().apply(empty)); assertThat(convertedEmpty.getModelBuilders()) .contains(TimeModel.builder() .withRealTime() .withStartInClockMode(ClockMode.SIMULATED)); }
@Test public void testCopyProperties() { final Scenario s = Scenario.builder() .addModel(TimeModel.builder() .withTickLength(754L) .withTimeUnit(NonSI.DAY)) .addModel(CommModel.builder()) .build(); final Scenario converted = verifyNotNull(ScenarioConverters.toRealtime().apply(s)); assertThat(converted.getModelBuilders()) .contains(TimeModel.builder() .withRealTime() .withStartInClockMode(ClockMode.SIMULATED) .withTickLength(754L) .withTimeUnit(NonSI.DAY)); }
@Test public void testTooManyTimeModels() { final Scenario s = Scenario.builder() .addModel(TimeModel.builder()) .addModel(TimeModel.builder().withRealTime()) .build(); boolean fail = false; try { ScenarioConverters.toRealtime().apply(s); } catch (final IllegalArgumentException e) { fail = true; assertThat(e.getMessage()) .isEqualTo("More than one time model is not supported."); } assertThat(fail).isTrue(); }