Simulator implements SimulatorAPI { @SuppressWarnings("static-method") @Deprecated public boolean register(Model<?> m) { throw new UnsupportedOperationException( "Models can be added via Simulator.builder()."); } Simulator(Builder b); @SuppressWarnings("static-method") @Deprecated boolean register(Model<?> m); @Override void register(Object obj); @Override void unregister(Object o); ImmutableSet<Model<?>> getModels(); ModelProvider getModelProvider(); long getCurrentTime(); long getTimeStep(); void addTickListener(TickListener listener); void removeTickListener(TickListener listener); void start(); void togglePlayPause(); void stop(); void tick(); boolean isPlaying(); @Override RandomGenerator getRandomGenerator(); Unit<Duration> getTimeUnit(); static Builder builder();  }
@SuppressWarnings("deprecation") @Test(expected = UnsupportedOperationException.class) public void testRegisterModel() { simulator.register(new DummyModel()); }
@Test(expected = IllegalArgumentException.class) public void testRegisterModel2() { simulator.register((Object) new DummyModel()); }
@Test public void testRegister() { final Simulator sim = Simulator.builder() .addModel(DummyModel.builder()) .addModel(DummyModel.builder()) .addModel(DummyModelAsTickListener.builderAsTickListener()) .build(); assertThat(sim.getModels().asList().get(0)).isInstanceOf(DummyModel.class); assertThat(sim.getModels().asList().get(1)).isInstanceOf(DummyModel.class); assertThat(sim.getModels().asList().get(2)).isInstanceOf( DummyModelAsTickListener.class); sim.register(new DummyObject()); final DummyObjectTickListener dotl = new DummyObjectTickListener(); sim.register(dotl); final DummyObjectSimulationUser dosu = new DummyObjectSimulationUser(); sim.register(dosu); assertEquals(sim, dosu.getAPI()); sim.unregister(new DummyObject()); sim.unregister(new DummyObjectTickListener()); }