Search in sources :

Example 1 with RevisionData

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

the class RevisionCompareTest method compareBranchWithNewComponent_BaseWithNewComponent.

@Test
public void compareBranchWithNewComponent_BaseWithNewComponent() throws Exception {
    indexRevision(MAIN, new RevisionData(STORAGE_KEY1, "field1", "field2"));
    final String branch = createBranch(MAIN, "a");
    indexRevision(branch, new RevisionData(STORAGE_KEY2, "field1", "field2"));
    final RevisionCompare compare = index().compare(MAIN, branch);
    assertThat(compare.getDetails()).hasSize(1);
    final RevisionCompareDetail detail = compare.getDetails().iterator().next();
    assertThat(detail.getOp()).isEqualTo(Operation.ADD);
    assertThat(detail.getObject()).isEqualTo(ROOT);
    assertThat(detail.getComponent()).isEqualTo(ObjectId.of(DOC_TYPE, STORAGE_KEY2));
}
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 2 with RevisionData

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

the class RevisionCompareTest method compareBranchWithStringArrayPropertyChange.

@Test
public void compareBranchWithStringArrayPropertyChange() throws Exception {
    RevisionData data = new RevisionData(STORAGE_KEY1, null, null, List.of(), null);
    indexRevision(MAIN, data);
    String branch = createBranch(MAIN, "a");
    RevisionData updatedData = new RevisionData(STORAGE_KEY1, null, null, List.of("1", "2"), null);
    indexChange(branch, data, updatedData);
    RevisionCompare compare = index().compare(MAIN, branch);
    assertThat(compare.getDetails()).containsOnly(RevisionCompareDetail.componentChange(Operation.CHANGE, data.getContainerId(), data.getObjectId()), RevisionCompareDetail.propertyChange(Operation.CHANGE, data.getObjectId(), "terms", "[]", "[\"1\",\"2\"]"));
}
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 3 with RevisionData

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

the class RevisionRangePathQueryTest method readRange.

@Test
public void readRange() throws Exception {
    final String branchA = createBranch(MAIN, "a");
    final RevisionData data1 = new RevisionData(STORAGE_KEY1, "field1", "field2");
    final RevisionData data2 = new RevisionData(STORAGE_KEY2, "field1", "field2Changed");
    indexRevision(MAIN, data1);
    indexRevision(branchA, data2);
    final Iterable<RevisionData> hits = search(RevisionIndex.toRevisionRange(MAIN, branchA), Query.select(RevisionData.class).where(Expressions.matchAll()).build());
    assertThat(hits).containsOnly(data2);
}
Also used : RevisionData(com.b2international.index.revision.RevisionFixtures.RevisionData) Test(org.junit.Test)

Example 4 with RevisionData

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

the class SingleDocumentRevisionIndexSearchTest method searchWithFilter.

@Test
public void searchWithFilter() 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 Expression expression = Expressions.builder().filter(Expressions.exactMatch("field1", "field1")).build();
    final Query<RevisionData> query = Query.select(RevisionData.class).where(expression).build();
    final Iterable<RevisionData> matches = search(MAIN, query);
    assertThat(matches).hasSize(2);
    assertThat(matches).containsAll(Lists.newArrayList(first, second));
}
Also used : Expression(com.b2international.index.query.Expression) RevisionData(com.b2international.index.revision.RevisionFixtures.RevisionData) Test(org.junit.Test)

Example 5 with RevisionData

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

the class SingleDocumentRevisionIndexSearchTest method searchMatchBooleanPrefixQuery.

@Test
public void searchMatchBooleanPrefixQuery() {
    final RevisionData first = new RevisionData(STORAGE_KEY1, "Long field value", "field2");
    final RevisionData second = new RevisionData(STORAGE_KEY2, "Verbose field value", "field2");
    indexRevision(MAIN, first, second);
    final Query<RevisionData> query = Query.select(RevisionData.class).where(Expressions.matchBooleanPrefix("field1", "Verbose f")).build();
    final Iterable<RevisionData> matches = search(MAIN, query);
    assertThat(matches).hasSize(1);
    assertThat(matches).containsOnly(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