@Test public void testNoAjaxCorrelation() throws InterruptedException { when(frontEndSpan.getDetails()).thenReturn(mock(AjaxRequest.class)); processor.process(Collections.singleton(frontEndSpan), mock(EntityManager.class)); verify(spanDao, never()).get(any()); } }
@Test public void testBackEndSpanFirst() throws InterruptedException { when(spanDao.get(Matchers.eq(backEndIdent))).thenReturn(backEndSpan); processor.process(Collections.singleton(frontEndSpan), mock(EntityManager.class)); verify(backEndSpan, times(1)).setParentSpanId(eq(frontEndIdent.getId())); }
@Test public void testEUMSpanFirst() throws InterruptedException { // span initially not available MutableInt counter = new MutableInt(0); doAnswer(new Answer<AbstractSpan>() { @Override public AbstractSpan answer(InvocationOnMock invocation) throws Throwable { counter.increment(); if (counter.longValue() >= 5) { // make it available on the fifth attempt return backEndSpan; } else { return null; } } }).when(spanDao).get(Matchers.eq(backEndIdent)); processor.process(Collections.singleton(frontEndSpan), mock(EntityManager.class)); verify(backEndSpan, times(1)).setParentSpanId(eq(frontEndIdent.getId())); }