Refine search
@Override @Nullable public NodeState retrieve(@NotNull String checkpoint) { checkNotNull(checkpoint); NodeState cp = scheduler.getHeadNodeState() .getChildNode("checkpoints") .getChildNode(checkpoint) .getChildNode(ROOT); if (cp.exists()) { return cp; } return null; }
private void mergeSubtree(NodeBuilder builder, NodeState state, String name, int depth) { NodeState subtree = state.getChildNode(name); if (subtree.exists()) { if (!builder.hasChildNode(name)) { builder.setChildNode(name, subtree); } else if (depth > 0) { NodeBuilder subbuilder = builder.child(name); for (String subname : subtree.getChildNodeNames()) { mergeSubtree(subbuilder, subtree, subname, depth - 1); } } } }
@Test public void testGetChildNode() { assertTrue(state.getChildNode("x").exists()); assertTrue(state.getChildNode("y").exists()); assertTrue(state.getChildNode("z").exists()); assertFalse(state.getChildNode("a").exists()); }
@Test public void testNonExistingPath() throws Exception { NodeState idxDef = store.getRoot().getChildNode("oak:index").getChildNode("a"); try { new OakSolrNodeStateConfiguration(idxDef); } catch (IllegalArgumentException e) { // expected to fail as the NodeState doesn't exist } }
@Test public void childrenUnderMountAreFound() { assertThat("root.tmp(childCount)", store.getRoot().getChildNode("tmp").getChildNodeCount(10), equalTo(2l)); }
@Test public void noVersionStoragePrePopulated() throws Exception { // default initial content does not have intermediate nodes // pre-populated NodeState system = INITIAL_CONTENT.getChildNode(JCR_SYSTEM); assertTrue(system.exists()); NodeState vs = system.getChildNode(JCR_VERSIONSTORAGE); assertTrue(vs.exists()); assertTrue(vs.getChildNodeCount(Integer.MAX_VALUE) == 0); }
@Test public void getRoot() { assertEquals(root, store.getRoot()); assertEquals(root.getChildNode("test"), store.getRoot().getChildNode("test")); assertEquals(root.getChildNode("test").getChildNode("x"), store.getRoot().getChildNode("test").getChildNode("x")); assertEquals(root.getChildNode("test").getChildNode("any"), store.getRoot().getChildNode("test").getChildNode("any")); assertEquals(root.getChildNode("test").getProperty("a"), store.getRoot().getChildNode("test").getProperty("a")); assertEquals(root.getChildNode("test").getProperty("any"), store.getRoot().getChildNode("test").getProperty("any")); }
@Test public void testGetChildNode() { assertTrue(state.getChildNode("x0").exists()); assertTrue(state.getChildNode("x1").exists()); assertTrue(state.getChildNode("x" + N).exists()); assertFalse(state.getChildNode("x" + (N + 1)).exists()); }
@Test public void mergeExisting_Aggregates() throws Exception{ builder.aggregateRule("foo").include("/path1"); builder.aggregateRule("foo").include("/path2"); nodeBuilder = builder.build().builder(); builder = new IndexDefinitionBuilder(nodeBuilder); builder.aggregateRule("foo").include("/path1"); builder.aggregateRule("foo").include("/path3"); NodeState state = builder.build(); assertEquals(3, state.getChildNode(AGGREGATES).getChildNode("foo").getChildNodeCount(100)); }
protected static NodeState getIndexDefinitionState(NodeState defn) { if (isDisableStoredIndexDefinition()){ return defn; } NodeState storedState = defn.getChildNode(INDEX_DEFINITION_NODE); return storedState.exists() ? storedState : defn; }
private void mergeSubtree(NodeBuilder builder, NodeState state, String name, int depth) { NodeState subtree = state.getChildNode(name); if (subtree.exists()) { if (!builder.hasChildNode(name)) { builder.setChildNode(name, subtree); } else if (depth > 0) { NodeBuilder subbuilder = builder.child(name); for (String subname : subtree.getChildNodeNames()) { mergeSubtree(subbuilder, subtree, subname, depth - 1); } } } }
@Test public void shouldRespectPathBoundariesForExcludes() { final NodeState decorated = wrap("/", rootNodeState, null, of("/content/foo"), null, null); assertExistingChildNodeName(decorated, "content"); assertMissingChildNodeName(decorated.getChildNode("content"), "foo"); assertExistingChildNodeName(decorated.getChildNode("content"), "football"); }
@Test public void bundlingConfig() throws Exception { NodeState system = INITIAL_CONTENT.getChildNode(JCR_SYSTEM); assertFalse(system.getChildNode(DOCUMENT_NODE_STORE).exists()); }
@Test public void mergeExisting_Aggregates() throws Exception{ builder.aggregateRule("foo").include("/path1"); builder.aggregateRule("foo").include("/path2"); nodeBuilder = builder.build().builder(); builder = new IndexDefinitionBuilder(nodeBuilder); builder.aggregateRule("foo").include("/path1"); builder.aggregateRule("foo").include("/path3"); NodeState state = builder.build(); assertEquals(3, state.getChildNode(AGGREGATES).getChildNode("foo").getChildNodeCount(100)); }
/** * Assumes that given state is of type nt:file and then reads * the jcr:content/@jcr:data property to get the binary content */ @Nullable public static Blob getBlob(NodeState state, String resourceName){ NodeState contentNode = state.getChildNode(JcrConstants.JCR_CONTENT); checkArgument(contentNode.exists(), "Was expecting to find jcr:content node to read resource %s", resourceName); PropertyState property = contentNode.getProperty(JcrConstants.JCR_DATA); return property != null ? property.getValue(Type.BINARY) : null; } }
@Test public void shouldRespectPathBoundariesForIncludes() { final NodeState decorated = wrap("/", rootNodeState, of("/content/foo"), null, null, null); assertExistingChildNodeName(decorated, "content"); assertExistingChildNodeName(decorated.getChildNode("content"), "foo"); assertMissingChildNodeName(decorated.getChildNode("content"), "football"); }
@Test public void aggregates() throws Exception{ builder.aggregateRule("cq:Page").include("jcr:content").relativeNode(); builder.aggregateRule("dam:Asset", "*", "*/*"); NodeState state = builder.build(); assertTrue(state.getChildNode("aggregates").exists()); assertTrue(state.getChildNode("aggregates").getChildNode("dam:Asset").exists()); assertTrue(state.getChildNode("aggregates").getChildNode("cq:Page").exists()); }
@NotNull @Override public ReadOnlyBuilder child(@NotNull String name) { NodeState child = state.getChildNode(name); if (child.exists()) { return new ReadOnlyBuilder(child); } else { throw unsupported(); } }
@Test public void testExistingPath() throws Exception { NodeState idxDef = store.getRoot().getChildNode("oak:index").getChildNode("solrIdx"); OakSolrNodeStateConfiguration nodeStateConfiguration = new OakSolrNodeStateConfiguration(idxDef); assertNotNull(nodeStateConfiguration.getCatchAllField()); }
@Test public void aggregates() throws Exception{ builder.aggregateRule("cq:Page").include("jcr:content").relativeNode(); builder.aggregateRule("dam:Asset", "*", "*/*"); NodeState state = builder.build(); assertTrue(state.getChildNode("aggregates").exists()); assertTrue(state.getChildNode("aggregates").getChildNode("dam:Asset").exists()); assertTrue(state.getChildNode("aggregates").getChildNode("cq:Page").exists()); }