Checklist implements JsonObjectConvertible { public InitStage asInitStage() { InitStage.Builder builder = new InitStage.Builder() .withRepoInits(getRepoInits()) .withOrderedCndUrls(getCndUrls()) .withForcedRoots(getForcedRoots()) .withPrivileges(getJcrPrivilegeNames()) .withQNodeTypes(getJcrNodetypes()) .withNs(getJcrNamespaces()); return builder.build(); } Checklist(final @Nullable JsonObject originalJson,
              final @Nullable String moduleName,
              final @Nullable String name,
              final @NotNull List<URL> cndUrls,
              final @NotNull List<JcrNs> jcrNamespaces,
              final @NotNull List<QNodeTypeDefinition> jcrNodetypes,
              final @NotNull List<PrivilegeDefinition> jcrPrivileges,
              final @NotNull List<ForcedRoot> forcedRoots,
              final @NotNull List<CheckSpec.ImmutableSpec> checks,
              final @NotNull List<String> repoInits); @NotNull static Checklist.JsonKeys keys(); static Comparator<T> comparingJsonKeys(final @NotNull Function<T, String> jsonKeyExtractor); String getModuleName(); String getName(); List<URL> getCndUrls(); List<QNodeTypeDefinition> getJcrNodetypes(); List<JcrNs> getJcrNamespaces(); List<String> getJcrPrivilegeNames(); List<PrivilegeDefinition> getJcrPrivileges(); List<ForcedRoot> getForcedRoots(); List<CheckSpec> getChecks(); List<String> getRepoInits(); InitStage asInitStage(); @Override String toString(); @Override JsonObject toJson(); static Checklist fromJson(final @NotNull String moduleName,
                                     final @Nullable URL manifestUrl,
                                     final @NotNull JsonObject json);  }
@Test public void testAsInitStage() throws Exception { Checklist.Builder builder = new Checklist.Builder("test"); final URL cndA = cndAUrl; final URL cndB = cndBUrl; builder.withCndUrls(Arrays.asList(cndA, cndB)); final String NS_PREFIX_FOO = "foo"; final String NS_URI_FOO = "http: final String NS_PREFIX_BAR = "bar"; final String NS_URI_BAR = "http: final List<JcrNs> jcrNamespaces = Arrays.asList( JcrNs.create(NS_PREFIX_FOO, NS_URI_FOO), JcrNs.create(NS_PREFIX_BAR, NS_URI_BAR)); builder.withJcrNamespaces(jcrNamespaces); final NamespaceMapping mapping = JsonCnd.toNamespaceMapping(jcrNamespaces); final List<QNodeTypeDefinition> nodetypes = JsonCnd.getQTypesFromJson(obj() .key("foo:primaryType").val(key("extends", arr().val("nt:base"))) .key("foo:mixinType").val(key("@", arr().val("mixin"))) .key("bar:primaryType").val(key("extends", arr().val("nt:base"))) .key("bar:mixinType").val(key("@", arr().val("mixin"))).get(), mapping); builder.withJcrNodetypes(nodetypes); final List<PrivilegeDefinition> privileges = JsonCnd.getPrivilegesFromJson(arr("foo:canDo", "bar:canBe").get(), mapping); builder.withJcrPrivileges(privileges); final List<ForcedRoot> forcedRoots = Arrays.asList( ForcedRoot.fromJson(obj() .key(ForcedRoot.keys().path(), "/test/foo") .key(ForcedRoot.keys().primaryType(), "foo:primaryType") .key(ForcedRoot.keys().mixinTypes(), arr().val("foo:mixinType")) .get()), ForcedRoot.fromJson(obj() .key(ForcedRoot.keys().path(), "/test/bar") .key(ForcedRoot.keys().primaryType(), "bar:primaryType") .key(ForcedRoot.keys().mixinTypes(), arr().val("bar:mixinType")) .get())); builder.withForcedRoots(forcedRoots); final List<String> repoInits = Arrays.asList( "create service user testAsInitStage1", "create service user testAsInitStage2" ); builder.withRepoInits(repoInits); InitStage initStage = builder.build().asInitStage(); final OakMachine machine = new OakMachine.Builder().withInitStage(initStage).build(); machine.adminInitAndInspect(session -> { assertEquals("foo namespace should be registered", NS_URI_FOO, session.getNamespaceURI(NS_PREFIX_FOO)); assertEquals("bar namespace should be registered", NS_URI_BAR, session.getNamespaceURI(NS_PREFIX_BAR)); assertTrue("/test/foo path exists", session.nodeExists("/test/foo")); assertTrue("/test/foo is a foo:primaryType", session.getNode("/test/foo").isNodeType("foo:primaryType")); assertTrue("/test/foo is a foo:mixinType", session.getNode("/test/foo").isNodeType("foo:mixinType")); assertTrue("/test/bar path exists", session.nodeExists("/test/bar")); assertTrue("/test/bar is a bar:primaryType", session.getNode("/test/bar").isNodeType("bar:primaryType")); assertTrue("/test/bar is a bar:mixinType", session.getNode("/test/bar").isNodeType("bar:mixinType")); UserManager userManager = ((JackrabbitSession) session).getUserManager(); assertNotNull("has principal testAsInitStage1", userManager.getAuthorizable("testAsInitStage1")); assertNotNull("has principal testAsInitStage2", userManager.getAuthorizable("testAsInitStage2")); }); }