Search in sources :

Example 36 with RevisionData

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);
}
Also used : Expression(com.b2international.index.query.Expression) RevisionData(com.b2international.index.revision.RevisionFixtures.RevisionData) Test(org.junit.Test)

Example 37 with RevisionData

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);
}
Also used : RevisionData(com.b2international.index.revision.RevisionFixtures.RevisionData) Test(org.junit.Test)

Example 38 with RevisionData

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);
}
Also used : RevisionData(com.b2international.index.revision.RevisionFixtures.RevisionData) Test(org.junit.Test)

Example 39 with RevisionData

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);
}
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 40 with RevisionData

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));
}
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)

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