@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()); }