OakpalPlan implements JsonObjectConvertible { public OakMachine.Builder toOakMachineBuilder(final @Nullable ErrorListener errorListener, final @NotNull ClassLoader classLoader) throws Exception { final ChecklistPlanner checklistPlanner = new ChecklistPlanner(checklists); checklistPlanner.discoverChecklists(classLoader); final List<ProgressCheck> allChecks; try { allChecks = new ArrayList<>(Locator.loadFromCheckSpecs( checklistPlanner.getEffectiveCheckSpecs(checks), classLoader)); } catch (final Exception e) { throw new Exception("Error while loading progress checks.", e); } final Locale locale = Locale.getDefault(); for (final ProgressCheck progressCheck : allChecks) { initResourceBundle(progressCheck, locale, classLoader); } return new OakMachine.Builder() .withErrorListener(errorListener) .withProgressChecks(allChecks) .withInitStages(checklistPlanner.getInitStages()) .withInitStage(toInitStage()) .withPreInstallUrls(preInstallUrls) .withInstallHookPolicy(installHookPolicy) .withInstallHookClassLoader(classLoader) .withRunModes(new HashSet<>(getRunModes())) .withSlingSimulator(DefaultSlingSimulator.instance()) .withEnablePreInstallHooks(enablePreInstallHooks); } private  OakpalPlan(final @Nullable URL base,
                       final @Nullable JsonObject originalJson,
                       final @NotNull String name,
                       final @NotNull List<String> runModes,
                       final @NotNull List<String> checklists,
                       final @NotNull List<URL> preInstallUrls,
                       final @NotNull List<JcrNs> jcrNamespaces,
                       final @NotNull List<QNodeTypeDefinition> jcrNodetypes,
                       final @NotNull List<PrivilegeDefinition> jcrPrivileges,
                       final @NotNull List<ForcedRoot> forcedRoots,
                       final @NotNull List<CheckSpec> checks,
                       final boolean enablePreInstallHooks,
                       final @Nullable InstallHookPolicy installHookPolicy,
                       final @NotNull List<URL> repoInitUrls,
                       final @NotNull List<String> repoInits); @NotNull static JsonKeys keys(); URL getBase(); String getName(); JsonObject getOriginalJson(); List<String> getRunModes(); List<String> getChecklists(); List<URL> getPreInstallUrls(); List<JcrNs> getJcrNamespaces(); List<QNodeTypeDefinition> getJcrNodetypes(); List<PrivilegeDefinition> getJcrPrivileges(); List<ForcedRoot> getForcedRoots(); List<CheckSpec> getChecks(); boolean isEnablePreInstallHooks(); InstallHookPolicy getInstallHookPolicy(); List<URL> getRepoInitUrls(); List<String> getRepoInits(); @Override JsonObject toJson(); @Override String toString(); OakMachine.Builder toOakMachineBuilder(final @Nullable ErrorListener errorListener,
                                                  final @NotNull ClassLoader classLoader); static OakpalPlan fromJson(final @NotNull JsonObject json); static Result<OakpalPlan> fromJson(final @NotNull URL jsonUrl); static final URL EMPTY_PLAN_URL; static final URL BASIC_PLAN_URL; static final String DEFAULT_PLAN_NAME; }
@Test public void testToOakMachineBuilder() throws Exception { final URL expectBaseUrl = new URL(baseUrl, "fullPlan.json"); final Result<OakpalPlan> fullPlan = OakpalPlan.fromJson(expectBaseUrl); assertTrue("full plan is successful", fullPlan.isSuccess()); final OakpalPlan derived = fullPlan.getOrDefault(null); assertNotNull("not null full plan", derived); final ErrorListener errorListener = mock(ErrorListener.class); final OakMachine machine = derived.toOakMachineBuilder(errorListener, Util.getDefaultClassLoader()).build(); final URL url1 = new URL("http: final URL url2 = new URL("http: final List<URL> expectPreInstallUrls = Arrays.asList(url1, url2); assertEquals("expect preInstallUrls", expectPreInstallUrls, machine.getPreInstallUrls()); }