public File getIndexDir(IndexDefinition definition, String indexPath, String dirName) throws IOException { String uid = definition.getUniqueId();
public File getIndexDir(IndexDefinition definition, String indexPath, String dirName) throws IOException { String uid = definition.getUniqueId();
@Test public void uniqueIdForFreshIndex() throws Exception{ IndexDefinition defn = IndexDefinition.newBuilder(root, builder.getNodeState(), "/foo").build(); assertEquals("0", defn.getUniqueId()); builder.child(":status"); defn = IndexDefinition.newBuilder(root, builder.getNodeState(),"/foo").build(); assertNull(defn.getUniqueId()); }
@Test public void uniqueIdForFreshIndex() throws Exception{ IndexDefinition defn = IndexDefinition.newBuilder(root, builder.getNodeState(), "/foo").build(); assertEquals("0", defn.getUniqueId()); builder.child(":status"); defn = IndexDefinition.newBuilder(root, builder.getNodeState(),"/foo").build(); assertNull(defn.getUniqueId()); }
@Test public void uniqueIdInitializedInIndexing() throws Exception{ Tree idx = createIndex("test1", of("propa", "propb")); Tree props = TestUtil.newRulePropTree(idx, "nt:base"); Tree prop1 = props.addChild(TestUtil.unique("prop")); prop1.setProperty(FulltextIndexConstants.PROP_NAME, "jcr:title"); prop1.setProperty(FulltextIndexConstants.PROP_PROPERTY_INDEX, true); root.commit(); //Make some changes such incremental indexing happens root.getTree("/").addChild("a").setProperty("jcr:title", "foo"); root.commit(); NodeState idxState = NodeStateUtils.getNode(nodeStore.getRoot(), idx.getPath()); IndexDefinition defn = new IndexDefinition(INITIAL_CONTENT, idxState, "/foo"); //Check that with normal indexing uid gets initialized String uid = defn.getUniqueId(); assertNotNull(defn.getUniqueId()); //Now trigger a reindex idx.setProperty(IndexConstants.REINDEX_PROPERTY_NAME, true); root.commit(); //Refetch the NodeState idxState = NodeStateUtils.getNode(nodeStore.getRoot(), idx.getPath()); defn = new IndexDefinition(INITIAL_CONTENT, idxState, "/foo"); //Check that uid is also initialized in reindexing String uid2 = defn.getUniqueId(); assertNotNull(defn.getUniqueId()); assertNotEquals(uid, uid2); }