Search in sources :

Example 16 with RevisionData

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

the class CommitWatermarkTest method commitWatermarkHigh.

@Test
public void commitWatermarkHigh() throws Exception {
    StagingArea staging = index().prepareCommit(MAIN);
    for (int i = 0; i < 21; i++) {
        staging.stageNew(new RevisionData(UUID.randomUUID().toString(), "1", "2"));
    }
    staging.commit(currentTime(), "test", "commitWatermarkHigh");
    Assertions.assertThat(appender.list).extracting(ILoggingEvent::getFormattedMessage).contains("high commit watermark [20] exceeded in commit [MAIN - test - commitWatermarkHigh] number of changes: 21");
}
Also used : RevisionData(com.b2international.index.revision.RevisionFixtures.RevisionData) Test(org.junit.Test)

Example 17 with RevisionData

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

the class CommitWatermarkTest method commitWatermarkLow.

@Test
public void commitWatermarkLow() throws Exception {
    StagingArea staging = index().prepareCommit(MAIN);
    for (int i = 0; i < 11; i++) {
        staging.stageNew(new RevisionData(UUID.randomUUID().toString(), "1", "2"));
    }
    staging.commit(currentTime(), "test", "commitWatermarkLow");
    Assertions.assertThat(appender.list).extracting(ILoggingEvent::getFormattedMessage).contains("low commit watermark [10] exceeded in commit [MAIN - test - commitWatermarkLow] number of changes: 11");
}
Also used : RevisionData(com.b2international.index.revision.RevisionFixtures.RevisionData) Test(org.junit.Test)

Example 18 with RevisionData

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

the class HookTest method preCommitHook.

@Test
public void preCommitHook() throws Exception {
    CountDownLatch latch = new CountDownLatch(1);
    withHook((Hooks.PreCommitHook) staging -> {
        assertEquals(1L, staging.getNewObjects().count());
        latch.countDown();
    });
    commit(MAIN, Collections.singleton(new RevisionData(STORAGE_KEY1, "field1", "field2")));
    assertTrue(latch.await(1, TimeUnit.SECONDS));
}
Also used : TimeUnit(java.util.concurrent.TimeUnit) CountDownLatch(java.util.concurrent.CountDownLatch) ImmutableList(com.google.common.collect.ImmutableList) Collection(java.util.Collection) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) RevisionData(com.b2international.index.revision.RevisionFixtures.RevisionData) CountDownLatch(java.util.concurrent.CountDownLatch) RevisionData(com.b2international.index.revision.RevisionFixtures.RevisionData) Test(org.junit.Test)

Example 19 with RevisionData

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

the class RevisionBranchMergeTest method fastForwardMergeBranchWithChangedRevisionToParent.

@Test
public void fastForwardMergeBranchWithChangedRevisionToParent() throws Exception {
    indexRevision(MAIN, NEW_DATA);
    String child = createBranch(MAIN, "a");
    // create a revision on child branch
    indexChange(child, NEW_DATA, CHANGED_DATA);
    branching().prepareMerge(child, MAIN).merge();
    // after merge revision should be visible from MAIN branch
    RevisionData afterMerge = getRevision(MAIN, RevisionData.class, STORAGE_KEY1);
    assertDocEquals(CHANGED_DATA, afterMerge);
}
Also used : RevisionData(com.b2international.index.revision.RevisionFixtures.RevisionData) Test(org.junit.Test)

Example 20 with RevisionData

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

the class RevisionBranchMergeTest method mergeOlderTagBranchToNewerBranch.

@Test
public void mergeOlderTagBranchToNewerBranch() throws Exception {
    // create tagged/versioned data
    final String oldParent = createBranch(MAIN, "oldParent");
    indexRevision(oldParent, NEW_DATA);
    final String tag = createBranch(oldParent, "tag");
    RevisionData updatedAfterTag = NEW_DATA.toBuilder().terms(List.of("term")).build();
    indexChange(oldParent, NEW_DATA, updatedAfterTag);
    // index new change on MAIN
    indexRevision(MAIN, NEW_DATA2);
    final String target = createBranch(MAIN, "target");
    assertNotNull("Failed to merge tag to target", branching().prepareMerge(tag, target).squash(false).merge());
    RevisionData afterMerge = getRevision(target, RevisionData.class, STORAGE_KEY1);
    assertDocEquals(NEW_DATA, afterMerge);
    RevisionData existingDoc = getRevision(target, RevisionData.class, STORAGE_KEY2);
    assertDocEquals(NEW_DATA2, existingDoc);
}
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