ChecklistPlanner { public List<InitStage> getInitStages() { return getSelectedChecklists().map(Checklist::asInitStage).collect(Collectors.toList()); } ChecklistPlanner(final List<String> activeChecklistIds); void provideChecklists(final List<Checklist> constructed); void discoverChecklists(); void discoverChecklists(final ClassLoader classLoader); void discoverChecklists(final List<File> files); List<InitStage> getInitStages(); List<CheckSpec> getEffectiveCheckSpecs(final List<CheckSpec> checkOverrides); static List<Checklist> constructChecklists(final Map<URL, List<JsonObject>> parsed); static Map<URL, List<JsonObject>> parseChecklists(final URL manifestUrl); static Map<URL, List<JsonObject>> parseChecklists(final ClassLoader classLoader); static Map<URL, List<JsonObject>> parseChecklists(final List<File> files); static final String OAKPAL_CHECKLIST; static final String OAKPAL_MODULENAME; static final String BUNDLE_SYMBOLICNAME; static final String AUTOMATIC_MODULE_NAME; }
@Test public void testGetInitStages() throws Exception { List<Checklist> checklists = this.constructIndivChecklists(); ChecklistPlanner planner = new ChecklistPlanner(ALL_CKL_IDS); planner.provideChecklists(checklists); List<InitStage> initStages = planner.getInitStages(); assertEquals("init stages count should be ", 4, initStages.size()); new OakMachine.Builder().withInitStages(initStages).build().initAndInspect(session -> { assertTrue("/ChecklistPlannerTest/alpha node should exist", session.nodeExists("/ChecklistPlannerTest/alpha")); assertTrue("/ChecklistPlannerTest/bravo-1 node should exist", session.nodeExists("/ChecklistPlannerTest/bravo-1")); assertTrue("/ChecklistPlannerTest/bravo-2 node should exist", session.nodeExists("/ChecklistPlannerTest/bravo-2")); assertTrue("/ChecklistPlannerTest/charlie node should exist", session.nodeExists("/ChecklistPlannerTest/charlie")); }); ChecklistPlanner selectivePlanner = new ChecklistPlanner(Collections.singletonList(CKL_NAME_BRAVO_2)); selectivePlanner.provideChecklists(checklists); List<InitStage> selectiveStages = selectivePlanner.getInitStages(); assertEquals("selective init stages count should be ", 1, selectiveStages.size()); new OakMachine.Builder().withInitStages(selectiveStages).build().initAndInspect(session -> { assertFalse("/ChecklistPlannerTest/alpha node should not exist", session.nodeExists("/ChecklistPlannerTest/alpha")); assertFalse("/ChecklistPlannerTest/bravo-1 node should not exist", session.nodeExists("/ChecklistPlannerTest/bravo-1")); assertTrue("/ChecklistPlannerTest/bravo-2 node should exist", session.nodeExists("/ChecklistPlannerTest/bravo-2")); assertFalse("/ChecklistPlannerTest/charlie node should not exist", session.nodeExists("/ChecklistPlannerTest/charlie")); }); }