ChecklistPlanner { static CheckSpec applyOverrides(final List<CheckSpec> checkOverrides, final CheckSpec base) { CheckSpec merged = base; LOGGER.trace("[applyOverrides] base: {}", base); List<CheckSpec> applicable = checkOverrides.stream().filter(base::isOverriddenBy) .collect(Collectors.toList()); for (CheckSpec spec : applicable) { merged = spec.overlay(merged); LOGGER.trace("[applyOverrides] spec: {}, merged: {}", spec, merged); } return merged; } 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 testApplyOverrides() { final CheckSpec base = new CheckSpec(); base.setName(CKL_ID_ALPHA + "/" + "foo"); base.setImpl("base_impl"); base.setConfig(key("zero", "orez").key("shared", "zero").get()); final CheckSpec implicitSkipOverride = new CheckSpec(); implicitSkipOverride.setName("foo"); implicitSkipOverride.setSkip(true); final CheckSpec implicitConfigOverride1 = new CheckSpec(); implicitConfigOverride1.setName("foo"); implicitConfigOverride1.setConfig(key("one", "eno").key("shared", "one").get()); final CheckSpec implicitConfigOverride2 = new CheckSpec(); implicitConfigOverride2.setName("foo"); implicitConfigOverride2.setConfig(key("two", "owt").key("shared", "two").get()); final CheckSpec result = ChecklistPlanner.applyOverrides(Arrays.asList( implicitSkipOverride, implicitConfigOverride1, implicitConfigOverride2 ), base); assertTrue("skipped", result.isSkip()); assertEquals("shared should be", "two", result.getConfig().getString("shared")); assertEquals("zero should be", "orez", result.getConfig().getString("zero")); assertEquals("one should be", "eno", result.getConfig().getString("one")); assertEquals("two should be", "owt", result.getConfig().getString("two")); }