@Test public void testCustomRunnable() throws Exception { ActivityHint activityHint = new ActivityHint(DatasourceActivity.class); controller.startOrResume(activityHint); CountDownLatch latch = new CountDownLatch(1); Runnable runner = () -> { try { latch.await(60, TimeUnit.SECONDS); } catch (InterruptedException e) { // } }; assertFalse(store.loadingProperty().get()); store.executeCustomRunnable(runner); FXPlatform.waitForFX(); assertTrue(store.loadingProperty().get()); latch.countDown(); controller.waitForDataSource(); FXPlatform.waitForFX(); assertFalse(store.loadingProperty().get()); }
@Test public void testDatasourceHint() throws Exception { ActivityHint activityHint = new ActivityHint(DatasourceActivity.class); controller.startOrResume(activityHint); TestDataSource initialDS = (TestDataSource) store.getDatasource(); assertNull(initialDS.getDataSourceHint()); ActivityHint nextActivity = new ActivityHint(DatasourceActivity.class); nextActivity.setNextActivityId("other"); nextActivity.setDataSourceHint(() -> "Hallo sauerland!"); nextActivity.setReturnToActivity(activityHint.getNextActivityId()); nextActivity.setReturnToDatasourceHint(() -> "back"); controller.startOrResume(nextActivity); TestDataSource datasource = (TestDataSource) store.getDatasource(); assertEquals("Hallo sauerland!", datasource.getDataSourceHint()); controller.stopCurrent(); assertEquals("back", initialDS.getDataSourceHint()); }
@Test public void testResume() throws Exception { ActivityHint activityHint = new ActivityHint(DatasourceActivity.class); controller.startOrResume(activityHint); ActivityHint nextActivity = new ActivityHint(DatasourceActivity.class); nextActivity.setNextActivityId("other"); controller.startOrResume(nextActivity); ActivityHint returnToInitial = new ActivityHint(DatasourceActivity.class); returnToInitial.setDataSourceHint(() -> "PCT"); returnToInitial.setReturnToActivity("other"); returnToInitial.setReturnToDatasourceHint(() -> "I'll be back"); controller.startOrResume(returnToInitial); TestDataSource datasource = (TestDataSource) store.getDatasource(); assertEquals("PCT", datasource.getDataSourceHint()); controller.stopCurrent(); datasource = (TestDataSource) store.getDatasource(); assertEquals("I'll be back", datasource.getDataSourceHint()); }
@After public void tearDown() throws Exception { controller.stopAll(); }