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));
}
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\"]"));
}
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);
}
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));
}
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);
}
Aggregations