@Before public void setUp() { MockitoAnnotations.initMocks(this); this.producer = new HollowProducer.Builder() .withListeners(listener).withSingleProducerEnforcer(singleProducerEnforcer).build(); }
AtomicInteger counter = new AtomicInteger(); HollowProducer producer = HollowProducer.withPublisher(blobStore) .withBlobStager(new HollowInMemoryBlobStager()) .withListener(new ValidatorListener() { @Override public String getName() { .withListener(new ValidationStatusListener() { @Override public void onValidationStatusStart(long version) { .build();
FakeAnnouncer fakeAnnouncerSpy = Mockito.spy(fakeAnnouncer); HollowProducer producer = HollowProducer.withPublisher(blobStore) .withBlobStager(new HollowInMemoryBlobStager()) .withAnnouncer(fakeAnnouncerSpy) .withVersionMinter(new HollowProducer.VersionMinter() { long counter = 0; public long mint() { .withNumStatesBetweenSnapshots(5) .build();
@Test public void snapshotUpdates() { HollowProducer producer = HollowProducer.withPublisher(blobStore) .withBlobStager(new HollowInMemoryBlobStager()) .withNumStatesBetweenSnapshots(2) /// do not produce snapshots for v2 or v3 .build();
@Test public void deltaSnapshotUpdates() { HollowProducer producer = HollowProducer.withPublisher(blobStore) .withBlobStager(new HollowInMemoryBlobStager()) .withNumStatesBetweenSnapshots(2) /// do not produce snapshots for v2 or v3 .build();
void updates(boolean doubleSnapshot) { HollowProducer producer = HollowProducer.withPublisher(blobStore) .withBlobStager(new HollowInMemoryBlobStager()) .build();
@Test public void deltaUpdates() { HollowProducer producer = HollowProducer.withPublisher(blobStore) .withBlobStager(new HollowInMemoryBlobStager()) .withNumStatesBetweenSnapshots(2) /// do not produce snapshots for v2 or v3 .build();
@Test public void snapshotDeltaUpdates() { HollowProducer producer = HollowProducer.withPublisher(blobStore) .withBlobStager(new HollowInMemoryBlobStager()) .withNumStatesBetweenSnapshots(2) /// do not produce snapshots for v2 or v3 .build();
@Test public void deltaUpdates() { HollowProducer producer = HollowProducer.withPublisher(blobStore) .withBlobStager(new HollowInMemoryBlobStager()) .withNumStatesBetweenSnapshots(2) /// do not produce snapshots for v2 or v3 .build();
@Test public void producerValidatesWithFailure() { HollowProducer producer = HollowProducer.withPublisher(blobStore) .withBlobStager(new HollowInMemoryBlobStager()) .withListener(new ValidatorListener() { @Override public String getName() { return "Test validator"; .withListener(new ValidationStatusListener() { boolean isStartCalled; .build();
.withBlobStager(new HollowInMemoryBlobStager()) .build();
.withBlobStager(new HollowInMemoryBlobStager()) .build();
@Test public void producerValidatesWithError() { HollowProducer producer = HollowProducer.withPublisher(blobStore) .withBlobStager(new HollowInMemoryBlobStager()) .withListener(new ValidatorListener() { @Override public String getName() { return "Test validator"; .withListener(new ValidationStatusListener() { boolean isStartCalled; .build();
@Test public void producerCompacts() { HollowProducer producer = HollowProducer.withPublisher(blobStore) .withBlobStager(new HollowInMemoryBlobStager()) .build();
void updates(boolean doubleSnapshot) { HollowProducer producer = HollowProducer.withPublisher(blobStore) .withBlobStager(new HollowInMemoryBlobStager()) .build();
FakeSingleProducerEnforcer fakeSingleProducerEnforcer = new FakeSingleProducerEnforcer(); HollowProducer producer = HollowProducer.withPublisher(blobStore) .withBlobStager(new HollowInMemoryBlobStager()) .withVersionMinter(new TestVersionMinter()) .withSingleProducerEnforcer(fakeSingleProducerEnforcer) .build();
HollowProducer.BlobStorageCleaner blobStorageCleaner = new HollowFilesystemBlobStorageCleaner(publishDir); HollowProducer producer = HollowProducer.withPublisher(publisher) .withBlobStorageCleaner(blobStorageCleaner) .withVersionMinter(new TestVersionMinter()) .build();
@Test public void fireFailureListener() { HollowProducer producer = createInMemoryProducer(); /// initialize the data -- classic producer creates the first state in the delta chain. initializeData(producer); FakeIncrementalCycleListener listener = new FakeIncrementalCycleListener(); HollowProducer fakeHollowProducer = FakeHollowProducer.withPublisher(blobStore) .withBlobStager(new HollowInMemoryBlobStager()) .withVersionMinter(new TestVersionMinter()) .build(); HollowProducer fakeHollowProducerSpy = Mockito.spy(fakeHollowProducer); /// now we'll be incrementally updating the state by mutating individual records HollowIncrementalProducer incrementalProducer = HollowIncrementalProducer .withProducer(fakeHollowProducerSpy) .withListener(listener) .build(); incrementalProducer.addOrModify(new TypeA(1, "one", 100)); incrementalProducer.addOrModify(new TypeA(2, "two", 2)); incrementalProducer.addOrModify(new TypeA(3, "three", 300)); incrementalProducer.addOrModify(new TypeA(3, "three", 3)); incrementalProducer.addOrModify(new TypeA(4, "five", 6)); incrementalProducer.delete(new TypeA(5, "five", 5)); Mockito.doThrow(new RuntimeException("oops")).when(fakeHollowProducerSpy).runCycle(any(HollowProducer.Populator.class)); long nextVersion = incrementalProducer.runCycle(); Assert.assertEquals(nextVersion, listener.getVersion()); Assert.assertEquals(IncrementalCycleListener.Status.FAIL, listener.getStatus()); Assert.assertEquals(4L, listener.getRecordsAddedOrModified()); Assert.assertEquals(1L, listener.getRecordsRemoved()); Assert.assertNotNull(listener.getCause()); }
try { HollowProducer producer = HollowProducer.withPublisher(blobStore) .withBlobStager(new HollowInMemoryBlobStager()) .withListener(new RecordCountVarianceValidator("TypeWithPrimaryKey", 1f)).build();
@Test public void fireFailureListenerWithMetadata() { HollowProducer producer = createInMemoryProducer(); /// initialize the data -- classic producer creates the first state in the delta chain. initializeData(producer); FakeIncrementalCycleListener listener = new FakeIncrementalCycleListener(); HollowProducer fakeHollowProducer = FakeHollowProducer.withPublisher(blobStore) .withBlobStager(new HollowInMemoryBlobStager()) .withVersionMinter(new TestVersionMinter()) .build(); HollowProducer fakeHollowProducerSpy = Mockito.spy(fakeHollowProducer); /// now we'll be incrementally updating the state by mutating individual records HollowIncrementalProducer incrementalProducer = HollowIncrementalProducer .withProducer(fakeHollowProducerSpy) .withListener(listener) .build(); HashMap<String, Object> cycleMetadata = new HashMap<>(); cycleMetadata.put("foo", "bar"); incrementalProducer.addAllCycleMetadata(cycleMetadata); Assert.assertTrue(incrementalProducer.hasMetadata()); incrementalProducer.addOrModify(new TypeA(1, "one", 100)); Mockito.doThrow(new RuntimeException("oops")).when(fakeHollowProducerSpy).runCycle(any(HollowProducer.Populator.class)); incrementalProducer.runCycle(); Assert.assertEquals(IncrementalCycleListener.Status.FAIL, listener.getStatus()); Assert.assertEquals(cycleMetadata, listener.getCycleMetadata()); Assert.assertFalse(incrementalProducer.hasMetadata()); }