Search in sources :

Example 31 with RevisionData

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

the class RevisionCompareTest method compareBranchWithRevertedChanges.

@Test
public void compareBranchWithRevertedChanges() throws Exception {
    RevisionData rev1 = new RevisionData(STORAGE_KEY1, "field1", "field2");
    indexRevision(MAIN, rev1);
    final String branch = createBranch(MAIN, "a");
    // change storageKey1 component then revert the change
    RevisionData changed = new RevisionData(STORAGE_KEY1, "field1", "field2Changed");
    indexChange(branch, rev1, changed);
    // this actually reverts the prev. change, via a new revision
    indexChange(branch, changed, rev1);
    final RevisionCompare compare = index().compare(MAIN, branch);
    assertThat(compare.getDetails()).containsOnly(RevisionCompareDetail.componentChange(Operation.CHANGE, rev1.getContainerId(), rev1.getObjectId()));
}
Also used : ComponentRevisionData(com.b2international.index.revision.RevisionFixtures.ComponentRevisionData) ContainerRevisionData(com.b2international.index.revision.RevisionFixtures.ContainerRevisionData) RevisionData(com.b2international.index.revision.RevisionFixtures.RevisionData) Test(org.junit.Test)

Example 32 with RevisionData

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

the class SingleDocumentRevisionIndexSearchTest method searchWithPrefix.

@Test
public void searchWithPrefix() throws Exception {
    final RevisionData first = new RevisionData(STORAGE_KEY1, "pref1Field1", "field2");
    final RevisionData second = new RevisionData(STORAGE_KEY2, "pref2Field1", "field2");
    indexRevision(MAIN, first, second);
    final Query<RevisionData> query = Query.select(RevisionData.class).where(Expressions.prefixMatch("field1", "pref1")).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 33 with RevisionData

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

the class SingleDocumentRevisionIndexSearchTest method searchMatchNone.

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

Example 34 with RevisionData

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

the class SingleDocumentRevisionIndexSearchTest method searchWithMatchTextAny.

@Test
public void searchWithMatchTextAny() {
    final RevisionData first = new RevisionData(STORAGE_KEY1, "a", "field2");
    final RevisionData second = new RevisionData(STORAGE_KEY2, "b", "field2");
    indexRevision(MAIN, first, second);
    final Query<RevisionData> query = Query.select(RevisionData.class).where(Expressions.matchTextAny("field1.text", "a b")).build();
    final Iterable<RevisionData> matches = search(MAIN, query);
    assertThat(matches).hasSize(2);
    assertThat(matches).containsAll(Lists.newArrayList(first, second));
}
Also used : RevisionData(com.b2international.index.revision.RevisionFixtures.RevisionData) Test(org.junit.Test)

Example 35 with RevisionData

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

the class SingleDocumentRevisionIndexSearchTest method searchMatchAll.

@Test
public void searchMatchAll() throws Exception {
    final RevisionData first = new RevisionData(STORAGE_KEY1, "field1", "field2");
    final RevisionData second = new RevisionData(STORAGE_KEY2, "field1", "field2");
    indexRevision(MAIN, first, second);
    final Query<RevisionData> query = Query.select(RevisionData.class).where(Expressions.matchAll()).build();
    final Iterable<RevisionData> matches = search(MAIN, query);
    assertThat(matches).hasSize(2);
    assertThat(matches).containsOnly(first, second);
}
Also used : RevisionData(com.b2international.index.revision.RevisionFixtures.RevisionData) 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