Search in sources :

Example 6 with RevisionData

use of com.b2international.index.revision.RevisionFixtures.RevisionData in project snow-owl by b2ihealthcare.

the class SingleDocumentRevisionIndexSearchTest method searchWithMatchTextFuzzy.

@Test
public void searchWithMatchTextFuzzy() {
    final RevisionData data = new RevisionData(STORAGE_KEY1, "abcd", "efgh");
    indexRevision(MAIN, data);
    final Query<RevisionData> query = Query.select(RevisionData.class).where(Expressions.matchTextFuzzy("field1.text", "aacd")).build();
    final Iterable<RevisionData> matches = search(MAIN, query);
    assertThat(matches).hasSize(1);
    assertThat(matches).containsOnly(data);
}
Also used : RevisionData(com.b2international.index.revision.RevisionFixtures.RevisionData) Test(org.junit.Test)

Example 7 with RevisionData

use of com.b2international.index.revision.RevisionFixtures.RevisionData in project snow-owl by b2ihealthcare.

the class SingleDocumentRevisionIndexSearchTest method searchDifferentRevisions.

@Test
public void searchDifferentRevisions() throws Exception {
    final RevisionData first = new RevisionData(STORAGE_KEY1, "field1", "field2");
    final RevisionData second = new RevisionData(STORAGE_KEY2, "field1Changed", "field2");
    indexRevision(MAIN, first, second);
    final Query<RevisionData> query = Query.select(RevisionData.class).where(Expressions.exactMatch("field1", "field1")).build();
    final Iterable<RevisionData> matches = search(MAIN, query);
    assertThat(matches).hasSize(1);
    assertThat(matches).containsOnly(first);
}
Also used : RevisionData(com.b2international.index.revision.RevisionFixtures.RevisionData) Test(org.junit.Test)

Example 8 with RevisionData

use of com.b2international.index.revision.RevisionFixtures.RevisionData in project snow-owl by b2ihealthcare.

the class SingleDocumentRevisionIndexSearchTest method searchMultipleRevisions.

@Test
public void searchMultipleRevisions() throws Exception {
    final RevisionData first = new RevisionData(STORAGE_KEY1, "field1", "field2");
    final RevisionData second = new RevisionData(STORAGE_KEY1, "field1", "field2Changed");
    indexRevision(MAIN, first, second);
    final Query<RevisionData> query = Query.select(RevisionData.class).where(Expressions.exactMatch("field1", "field1")).build();
    final Iterable<RevisionData> matches = search(MAIN, query);
    // only second version should match, the first revision should be unaccessible without timestamp
    assertThat(matches).hasSize(1);
    assertThat(matches).containsOnly(second);
}
Also used : RevisionData(com.b2international.index.revision.RevisionFixtures.RevisionData) Test(org.junit.Test)

Example 9 with RevisionData

use of com.b2international.index.revision.RevisionFixtures.RevisionData in project snow-owl by b2ihealthcare.

the class RevisionPurgeTest method purgeBranchWithSingleRevision.

@Test
@Ignore
public void purgeBranchWithSingleRevision() throws Exception {
    indexRevision(MAIN, new RevisionData(STORAGE_KEY1, "field1", "field2"));
    index().purge(MAIN, Purge.ALL);
    // the revision should be still there
    assertNotNull(getRevision(MAIN, RevisionData.class, STORAGE_KEY1));
}
Also used : RevisionData(com.b2international.index.revision.RevisionFixtures.RevisionData) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 10 with RevisionData

use of com.b2international.index.revision.RevisionFixtures.RevisionData in project snow-owl by b2ihealthcare.

the class RevisionPurgeTest method purgeBranchWithTwoRevisionsOfDocument.

@Test
@Ignore
public void purgeBranchWithTwoRevisionsOfDocument() throws Exception {
    indexRevision(MAIN, new RevisionData(STORAGE_KEY1, "field1", "field2"));
    indexRevision(MAIN, new RevisionData(STORAGE_KEY1, "field1Changed", "field2"));
    index().purge(MAIN, Purge.ALL);
    // only the most recent revision should be available
    final Iterable<RevisionData> revisions = searchRaw(Query.select(RevisionData.class).where(Expressions.exactMatch(Revision.Fields.ID, STORAGE_KEY1)).limit(Integer.MAX_VALUE).build());
    assertEquals(1, Iterables.size(revisions));
    final RevisionData actual = Iterables.getOnlyElement(revisions);
    assertDocEquals(new RevisionData(STORAGE_KEY1, "field1Changed", "field2"), actual);
}
Also used : RevisionData(com.b2international.index.revision.RevisionFixtures.RevisionData) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

RevisionData (com.b2international.index.revision.RevisionFixtures.RevisionData)52 Test (org.junit.Test)52 ComponentRevisionData (com.b2international.index.revision.RevisionFixtures.ComponentRevisionData)13 ContainerRevisionData (com.b2international.index.revision.RevisionFixtures.ContainerRevisionData)13 Ignore (org.junit.Ignore)6 Expression (com.b2international.index.query.Expression)2 ImmutableList (com.google.common.collect.ImmutableList)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 TimeUnit (java.util.concurrent.TimeUnit)2 Assert.assertEquals (org.junit.Assert.assertEquals)2 Assert.assertTrue (org.junit.Assert.assertTrue)2