Search in sources :

Example 26 with RevisionData

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

the class RevisionCompareTest method compareBranchWithChangedComponent.

@Test
public void compareBranchWithChangedComponent() throws Exception {
    RevisionData rev1 = new RevisionData(STORAGE_KEY1, "field1", "field2");
    indexRevision(MAIN, rev1);
    final String branch = createBranch(MAIN, "a");
    RevisionData rev2 = new RevisionData(STORAGE_KEY1, "field1Changed", "field2");
    indexChange(branch, rev1, rev2);
    final RevisionCompare compare = index().compare(MAIN, branch);
    assertThat(compare.getDetails()).containsOnly(RevisionCompareDetail.componentChange(Operation.CHANGE, rev2.getContainerId(), rev2.getObjectId()), RevisionCompareDetail.propertyChange(Operation.CHANGE, rev2.getObjectId(), "field1", "field1", "field1Changed"));
}
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 27 with RevisionData

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

the class RevisionCompareTest method compareBranchWithDeletedComponent.

@Test
public void compareBranchWithDeletedComponent() throws Exception {
    indexRevision(MAIN, new RevisionData(STORAGE_KEY1, "field1", "field2"));
    final String branch = createBranch(MAIN, "a");
    deleteRevision(branch, RevisionData.class, STORAGE_KEY1);
    final RevisionCompare compare = index().compare(MAIN, branch);
    assertThat(compare.getDetails()).hasSize(1);
    final RevisionCompareDetail detail = compare.getDetails().iterator().next();
    assertThat(detail.getOp()).isEqualTo(Operation.REMOVE);
    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)

Example 28 with RevisionData

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

the class BranchBaseQueryTest method readBaseOfBranchWithNewComponents.

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

Example 29 with RevisionData

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

the class BranchBaseQueryTest method readBaseOfBranchWithDeletedComponents.

@Test
public void readBaseOfBranchWithDeletedComponents() throws Exception {
    final RevisionData data = new RevisionData(STORAGE_KEY1, "field1", "field2");
    indexRevision(MAIN, data);
    final String branch = createBranch(MAIN, "a");
    deleteRevision(MAIN, RevisionData.class, STORAGE_KEY1);
    final Iterable<RevisionData> hits = search(branch + RevisionIndex.BASE_REF_CHAR, Query.select(RevisionData.class).where(Expressions.matchAll()).build());
    assertThat(hits).containsOnly(data);
}
Also used : RevisionData(com.b2international.index.revision.RevisionFixtures.RevisionData) Test(org.junit.Test)

Example 30 with RevisionData

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

the class BranchBaseQueryTest method readBaseOfBranch.

@Test
public void readBaseOfBranch() throws Exception {
    final RevisionData data = new RevisionData(STORAGE_KEY1, "field1", "field2");
    indexRevision(MAIN, data);
    final String branch = createBranch(MAIN, "a");
    final Iterable<RevisionData> hits = search(branch + RevisionIndex.BASE_REF_CHAR, Query.select(RevisionData.class).where(Expressions.matchAll()).build());
    assertThat(hits).containsOnly(data);
}
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