use of com.b2international.index.revision.RevisionFixtures.RevisionData in project snow-owl by b2ihealthcare.
the class SingleDocumentRevisionIndexSearchTest method searchWithMinimumShouldMatch.
@Test
public void searchWithMinimumShouldMatch() throws Exception {
final RevisionData first = new RevisionData(STORAGE_KEY1, "field1", "field1");
final RevisionData second = new RevisionData(STORAGE_KEY2, "field1", "field2");
indexRevision(MAIN, first, second);
final Expression expression = Expressions.builder().should(Expressions.exactMatch("field1", "field1")).should(Expressions.exactMatch("field2", "field2")).setMinimumNumberShouldMatch(2).build();
final Query<RevisionData> query = Query.select(RevisionData.class).where(expression).build();
final Iterable<RevisionData> matches = search(MAIN, query);
assertThat(matches).hasSize(1);
assertThat(matches).containsOnly(second);
}
use of com.b2international.index.revision.RevisionFixtures.RevisionData in project snow-owl by b2ihealthcare.
the class RevisionBranchMergeTest method rebaseDivergedThenMerge.
@Test
public void rebaseDivergedThenMerge() throws Exception {
final String branchA = createBranch(MAIN, "a");
indexRevision(branchA, NEW_DATA);
indexRevision(MAIN, NEW_DATA2);
// rebase, revision should be visible from task
branching().prepareMerge(MAIN, branchA).merge();
RevisionData branchARev = getRevision(branchA, RevisionData.class, NEW_DATA.getId());
assertNotNull(branchARev);
assertState(branchA, MAIN, BranchState.FORWARD);
assertState(MAIN, branchA, BranchState.BEHIND);
// merge, revision should be visible from MAIN
branching().prepareMerge(branchA, MAIN).squash(true).merge();
RevisionData mainRev = getRevision(MAIN, RevisionData.class, NEW_DATA.getId());
assertNotNull(mainRev);
assertState(branchA, MAIN, BranchState.BEHIND);
assertState(MAIN, branchA, BranchState.FORWARD);
}
use of com.b2international.index.revision.RevisionFixtures.RevisionData in project snow-owl by b2ihealthcare.
the class RevisionBranchMergeTest method rebaseBranchOnParentWithChangedRevision.
@Test
public void rebaseBranchOnParentWithChangedRevision() throws Exception {
indexRevision(MAIN, NEW_DATA);
String child = createBranch(MAIN, "a");
// create a revision on child branch
indexChange(MAIN, NEW_DATA, CHANGED_DATA);
branching().prepareMerge(MAIN, child).merge();
// after merge revision should be visible from MAIN branch
RevisionData afterRebase = getRevision(child, RevisionData.class, STORAGE_KEY1);
assertDocEquals(CHANGED_DATA, afterRebase);
}
use of com.b2international.index.revision.RevisionFixtures.RevisionData in project snow-owl by b2ihealthcare.
the class RevisionCompareTest method compareBranchWithNewAndChanged.
@Test
public void compareBranchWithNewAndChanged() throws Exception {
final String branch = createBranch(MAIN, "a");
// new revision
RevisionData rev1 = new RevisionData(STORAGE_KEY1, "field1", "field2");
indexRevision(branch, rev1);
// change storageKey1 component
RevisionData changed = new RevisionData(STORAGE_KEY1, "field1", "field2Changed");
indexChange(branch, rev1, changed);
final RevisionCompare compare = index().compare(MAIN, branch);
assertThat(compare.getDetails()).hasSize(1);
assertThat(compare.getTotalAdded()).isEqualTo(1);
assertThat(compare.getTotalChanged()).isEqualTo(0);
assertThat(compare.getTotalRemoved()).isEqualTo(0);
}
use of com.b2international.index.revision.RevisionFixtures.RevisionData in project snow-owl by b2ihealthcare.
the class RevisionCompareTest method compareBranchWithNewComponent.
@Test
public void compareBranchWithNewComponent() throws Exception {
final String branch = createBranch(MAIN, "a");
indexRevision(branch, new RevisionData(STORAGE_KEY1, "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_KEY1));
}
Aggregations