@Test
public void testEnsureNamespaces() throws Exception {

    final NamespaceMapping mapping = JsonCnd.toNamespaceMapping(Arrays.asList(
            JcrNs.create("", ""),
            JcrNs.create("foo", "http://foo.com"),
            JcrNs.create("bar", "http://bar.com")));
    new OakMachine.Builder()
            .withInitStage(
                    new InitStage.Builder()
                            .withNs("bar", "http://bar.com")
                            .build())
            .build()
            .adminInitAndInspect(session -> {
                final NamespaceRegistry registry = session.getWorkspace()
                        .getNamespaceRegistry();
                assertEquals("bar already registered", "bar", registry.getPrefix("http://bar.com"));
                assertFalse("foo not registered", Arrays.asList(registry.getPrefixes()).contains("foo"));
                ChecklistExporter.ensureNamespaces(session, mapping);
                assertTrue("foo registered now", Arrays.asList(registry.getPrefixes()).contains("foo"));
                assertEquals("bar still registered", "bar", registry.getPrefix("http://bar.com"));
                assertEquals("foo uri is", "http://foo.com", registry.getURI("foo"));
            });
}