Search in sources :

Example 1 with LuceneIndexWriter

use of org.neo4j.kernel.api.impl.schema.writer.LuceneIndexWriter in project neo4j by neo4j.

the class NonUniqueDatabaseIndexPopulatingUpdaterTest method additionsDeliveredToIndexWriter.

@Test
public void additionsDeliveredToIndexWriter() throws Exception {
    LuceneIndexWriter writer = mock(LuceneIndexWriter.class);
    NonUniqueLuceneIndexPopulatingUpdater updater = newUpdater(writer);
    String expectedString1 = LuceneDocumentStructure.documentRepresentingProperties((long) 1, "foo").toString();
    String expectedString2 = LuceneDocumentStructure.documentRepresentingProperties((long) 2, "bar").toString();
    String expectedString3 = LuceneDocumentStructure.documentRepresentingProperties((long) 3, "qux").toString();
    String expectedString4 = LuceneDocumentStructure.documentRepresentingProperties((long) 4, "git", "bit").toString();
    updater.process(add(1, SCHEMA_DESCRIPTOR, "foo"));
    verifydocument(writer, newTermForChangeOrRemove(1), expectedString1);
    updater.process(add(2, SCHEMA_DESCRIPTOR, "bar"));
    verifydocument(writer, newTermForChangeOrRemove(2), expectedString2);
    updater.process(add(3, SCHEMA_DESCRIPTOR, "qux"));
    verifydocument(writer, newTermForChangeOrRemove(3), expectedString3);
    updater.process(add(4, COMPOSITE_SCHEMA_DESCRIPTOR, "git", "bit"));
    verifydocument(writer, newTermForChangeOrRemove(4), expectedString4);
}
Also used : LuceneIndexWriter(org.neo4j.kernel.api.impl.schema.writer.LuceneIndexWriter) Matchers.hasToString(org.hamcrest.Matchers.hasToString) Test(org.junit.Test)

Example 2 with LuceneIndexWriter

use of org.neo4j.kernel.api.impl.schema.writer.LuceneIndexWriter in project neo4j by neo4j.

the class NonUniqueDatabaseIndexPopulatingUpdaterTest method removalsDeliveredToIndexWriter.

@Test
public void removalsDeliveredToIndexWriter() throws Exception {
    LuceneIndexWriter writer = mock(LuceneIndexWriter.class);
    NonUniqueLuceneIndexPopulatingUpdater updater = newUpdater(writer);
    updater.process(remove(1, SCHEMA_DESCRIPTOR, "foo"));
    verify(writer).deleteDocuments(newTermForChangeOrRemove(1));
    updater.process(remove(2, SCHEMA_DESCRIPTOR, "bar"));
    verify(writer).deleteDocuments(newTermForChangeOrRemove(2));
    updater.process(remove(3, SCHEMA_DESCRIPTOR, "baz"));
    verify(writer).deleteDocuments(newTermForChangeOrRemove(3));
    updater.process(remove(4, COMPOSITE_SCHEMA_DESCRIPTOR, "bit", "baz"));
    verify(writer).deleteDocuments(newTermForChangeOrRemove(4));
}
Also used : LuceneIndexWriter(org.neo4j.kernel.api.impl.schema.writer.LuceneIndexWriter) Test(org.junit.Test)

Example 3 with LuceneIndexWriter

use of org.neo4j.kernel.api.impl.schema.writer.LuceneIndexWriter in project neo4j by neo4j.

the class NonUniqueDatabaseIndexPopulatingUpdaterTest method changesDeliveredToIndexWriter.

@Test
public void changesDeliveredToIndexWriter() throws Exception {
    LuceneIndexWriter writer = mock(LuceneIndexWriter.class);
    NonUniqueLuceneIndexPopulatingUpdater updater = newUpdater(writer);
    String expectedString1 = LuceneDocumentStructure.documentRepresentingProperties((long) 1, "after1").toString();
    String expectedString2 = LuceneDocumentStructure.documentRepresentingProperties((long) 2, "after2").toString();
    String expectedString3 = LuceneDocumentStructure.documentRepresentingProperties((long) 3, "bit", "after2").toString();
    updater.process(change(1, SCHEMA_DESCRIPTOR, "before1", "after1"));
    verifydocument(writer, newTermForChangeOrRemove(1), expectedString1);
    updater.process(change(2, SCHEMA_DESCRIPTOR, "before2", "after2"));
    verifydocument(writer, newTermForChangeOrRemove(2), expectedString2);
    updater.process(change(3, COMPOSITE_SCHEMA_DESCRIPTOR, new Object[] { "bit", "before2" }, new Object[] { "bit", "after2" }));
    verifydocument(writer, newTermForChangeOrRemove(3), expectedString3);
}
Also used : LuceneIndexWriter(org.neo4j.kernel.api.impl.schema.writer.LuceneIndexWriter) Matchers.hasToString(org.hamcrest.Matchers.hasToString) Test(org.junit.Test)

Example 4 with LuceneIndexWriter

use of org.neo4j.kernel.api.impl.schema.writer.LuceneIndexWriter in project neo4j by neo4j.

the class UniqueDatabaseIndexPopulatingUpdaterTest method changesDeliveredToIndexWriter.

@Test
public void changesDeliveredToIndexWriter() throws Exception {
    LuceneIndexWriter writer = mock(LuceneIndexWriter.class);
    UniqueLuceneIndexPopulatingUpdater updater = newUpdater(writer);
    updater.process(change(1, descriptor, "before1", "after1"));
    updater.process(change(2, descriptor, "before2", "after2"));
    verify(writer).updateDocument(newTermForChangeOrRemove(1), LuceneDocumentStructure.documentRepresentingProperties((long) 1, "after1"));
    verify(writer).updateDocument(newTermForChangeOrRemove(2), LuceneDocumentStructure.documentRepresentingProperties((long) 2, "after2"));
}
Also used : LuceneIndexWriter(org.neo4j.kernel.api.impl.schema.writer.LuceneIndexWriter) Test(org.junit.Test)

Example 5 with LuceneIndexWriter

use of org.neo4j.kernel.api.impl.schema.writer.LuceneIndexWriter in project neo4j by neo4j.

the class UniqueDatabaseIndexPopulatingUpdaterTest method removalsDeliveredToIndexWriter.

@Test
public void removalsDeliveredToIndexWriter() throws Exception {
    LuceneIndexWriter writer = mock(LuceneIndexWriter.class);
    UniqueLuceneIndexPopulatingUpdater updater = newUpdater(writer);
    updater.process(remove(1, descriptor, "foo"));
    updater.process(remove(2, descriptor, "bar"));
    updater.process(remove(3, descriptor, "baz"));
    verify(writer).deleteDocuments(newTermForChangeOrRemove(1));
    verify(writer).deleteDocuments(newTermForChangeOrRemove(2));
    verify(writer).deleteDocuments(newTermForChangeOrRemove(3));
}
Also used : LuceneIndexWriter(org.neo4j.kernel.api.impl.schema.writer.LuceneIndexWriter) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 LuceneIndexWriter (org.neo4j.kernel.api.impl.schema.writer.LuceneIndexWriter)6 Matchers.hasToString (org.hamcrest.Matchers.hasToString)2