@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()); }
incrementalProducer.addAllCycleMetadata(cycleMetadata); Assert.assertTrue(incrementalProducer.hasMetadata());