### Question:
PendingResultHandler { public void offerValue(final String pendingResultId, final Object value) { offerResult(pendingResultId, new SimpleResult(value)); } @Autowired  PendingResultHandler(final PendingResultsHolder pendingResultsHolder,
            @Value("${server.application.name}") final String applicationName); String createPendingResult(); void removePendingResult(final String pendingResultId); Object pollValue(final String pendingResultId); void offerValue(final String pendingResultId, final Object value); void offerException(final String pendingResultId, final Exception exception);  }### Answer:
@Test public void shouldPublishEvent_onOfferValue() throws Exception { final TestValue testValue = new TestValue(randomString(), randomInt(100)); final String pendingResultId = randomId(); pendingResultHandler.offerValue(pendingResultId, testValue); final ArgumentCaptor<PendingResultOfferedEvent> captor = ArgumentCaptor.forClass(PendingResultOfferedEvent.class); verify(mockSystemEventPublisher).publishEvent(captor.capture()); final PendingResultOfferedEvent event = captor.getValue(); assertEquals(applicationName, event.getTargetApplicationName()); assertNull(event.getTargetApplicationVersion()); assertEquals(pendingResultId, event.getPendingResultId()); final Object actualResult = new XStream().fromXML(event.getResultXml()); assertTrue(actualResult instanceof Result); assertEquals(((Result) actualResult).getValue(), testValue); }
@Test public void shouldPublishEvent_onOfferNullValue() throws Exception { final Object value = null; final String pendingResultId = randomId(); pendingResultHandler.offerValue(pendingResultId, value); final ArgumentCaptor<PendingResultOfferedEvent> captor = ArgumentCaptor.forClass(PendingResultOfferedEvent.class); verify(mockSystemEventPublisher).publishEvent(captor.capture()); final PendingResultOfferedEvent event = captor.getValue(); assertEquals(applicationName, event.getTargetApplicationName()); assertNull(event.getTargetApplicationVersion()); assertEquals(pendingResultId, event.getPendingResultId()); final Object actualResult = new XStream().fromXML(event.getResultXml()); assertTrue(actualResult instanceof Result); assertNull(((Result) actualResult).getValue()); }