### Question:
PendingResultOfferedEventHandler extends AbstractSystemEventHandler { @Override protected void handleSystemEvent(final SystemEvent systemEvent) { final PendingResultOfferedEvent event = (PendingResultOfferedEvent) systemEvent; final PendingResult pendingResult = pendingResultsHolder.get(event.getPendingResultId()); if (pendingResult != null) { final Result result = (Result) xStream.fromXML(event.getResultXml()); pendingResult.offerResult(result); } } @Autowired  PendingResultOfferedEventHandler(@Value("${server.application.name}") final String applicationName,
            @Value("${server.application.version}") final String applicationVersion,
            final PendingResultsHolder pendingResultsHolder); @Override Class<? extends SystemEvent> getEventClass();  }### Answer:
@Test public void shouldOfferResult_onHandleEvent() throws Exception { final String value = randomString(); final Result result = new SimpleResult(value); final String resultXml = new XStream().toXML(result); final String pendingResultId = randomId(); final PendingResultOfferedEvent event = mock(PendingResultOfferedEvent.class); when(event.getPendingResultId()).thenReturn(pendingResultId); when(event.getResultXml()).thenReturn(resultXml); final PendingResult mockPendingResult = mock(PendingResult.class); when(mockPendingResultsHolder.get(pendingResultId)).thenReturn(mockPendingResult); pendingResultOfferedEventHandler.handleSystemEvent(event); final ArgumentCaptor<Result> captor = ArgumentCaptor.forClass(Result.class); verify(mockPendingResult).offerResult(captor.capture()); assertTrue(captor.getValue() instanceof SimpleResult); final SimpleResult actualResult = (SimpleResult) captor.getValue(); assertEquals(value, actualResult.getValue()); }
@Test public void shouldDoNothing_onHandleEventForUnknownPendingResult() { final String pendingResultId = randomId(); final PendingResultOfferedEvent event = mock(PendingResultOfferedEvent.class); when(event.getPendingResultId()).thenReturn(pendingResultId); Exception thrownException = null; try { pendingResultOfferedEventHandler.handleSystemEvent(event); } catch (final Exception e) { thrownException = e; } assertNull(thrownException); }