/** * Test that {@link InvocationExtractorDataProcessor} will extract all children of an * invocation. */ @Test public void testInvocationExtractor() { AbstractDataProcessor chainedProcessor = mock(AbstractDataProcessor.class); List<AbstractDataProcessor> chainedList = new ArrayList<>(); chainedList.add(chainedProcessor); InvocationExtractorDataProcessor invocationExtractorDataProcessor = new InvocationExtractorDataProcessor(chainedList); invocationExtractorDataProcessor.setStorageWriter(storageWriter); InvocationSequenceData invocationSequenceData = new InvocationSequenceData(); List<InvocationSequenceData> children = new ArrayList<>(); InvocationSequenceData child1 = new InvocationSequenceData(new Timestamp(new Date().getTime()), 10, 10, 10); TimerData timerData = new TimerData(); child1.setTimerData(timerData); InvocationSequenceData child2 = new InvocationSequenceData(new Timestamp(new Date().getTime()), 20, 20, 20); SqlStatementData sqlStatementData = new SqlStatementData(); child2.setSqlStatementData(sqlStatementData); children.add(child1); children.add(child2); invocationSequenceData.setNestedSequences(children); assertThat(invocationExtractorDataProcessor.canBeProcessed(invocationSequenceData), is(true)); invocationExtractorDataProcessor.process(invocationSequenceData); verify(chainedProcessor, times(1)).process(timerData); verify(chainedProcessor, times(1)).process(timerData); verify(chainedProcessor, times(0)).process(child1); verify(chainedProcessor, times(0)).process(child2); }
child.setParentSequence(parent); parent.setNestedSequences(Collections.singletonList(child));
child.setParentSequence(parent); parent.setNestedSequences(Collections.singletonList(child));
invData.setNestedSequences(children); return invData;
/** * Builds an invocation sequence data tree. * */ @BeforeMethod public void init() { List<InvocationSequenceData> nestedSequences1 = new ArrayList<>(); List<InvocationSequenceData> nestedSequences2 = new ArrayList<>(); rootInvocationSequence = new InvocationSequenceData(); rootInvocationSequence.setNestedSequences(nestedSequences1); firstChildSequence = new InvocationSequenceData(DEF_DATE, PLATFORM_IDENT, SENSOR_TYPE_IDENT, 1L); firstChildSequence.setDuration(200d); firstChildSequence.setParentSequence(rootInvocationSequence); secondChildSequence = new InvocationSequenceData(DEF_DATE, PLATFORM_IDENT, SENSOR_TYPE_IDENT, 2L); secondChildSequence.setDuration(4000d); secondChildSequence.setParentSequence(rootInvocationSequence); thirdChildSequence = new InvocationSequenceData(DEF_DATE, PLATFORM_IDENT, SENSOR_TYPE_IDENT, 3L); thirdChildSequence.setDuration(500d); thirdChildSequence.setParentSequence(secondChildSequence); fourthChildSequence = new InvocationSequenceData(DEF_DATE, PLATFORM_IDENT, SENSOR_TYPE_IDENT, 4L); fourthChildSequence.setDuration(500d); fourthChildSequence.setParentSequence(rootInvocationSequence); nestedSequences1.add(firstChildSequence); nestedSequences1.add(secondChildSequence); nestedSequences1.add(fourthChildSequence); nestedSequences2.add(thirdChildSequence); rootInvocationSequence = new InvocationSequenceData(); rootInvocationSequence.setNestedSequences(nestedSequences1); secondChildSequence.setNestedSequences(nestedSequences2); }
child.setParentSequence(parent); parent.setNestedSequences(Collections.singletonList(child));
child.setParentSequence(parent); parent.setNestedSequences(Collections.singletonList(child));
/** * Clones invocation sequence. This method returns new object exactly same as the original * object, but with out nested sequences set. * * @return Cloned invocation sequence. */ public InvocationSequenceData getClonedInvocationSequence() { InvocationSequenceData clone = new InvocationSequenceData(this.getTimeStamp(), this.getPlatformIdent(), this.getSensorTypeIdent(), this.getMethodIdent()); clone.setId(this.getId()); clone.setSpanIdent(this.getSpanIdent()); clone.setChildCount(this.getChildCount()); clone.setDuration(this.getDuration()); clone.setEnd(this.getEnd()); clone.setNestedSequences(Collections.<InvocationSequenceData> emptyList()); clone.setParameterContentData(this.getParameterContentData()); clone.setParentSequence(this.getParentSequence()); clone.setPosition(this.getPosition()); clone.setSqlStatementData(this.getSqlStatementData()); clone.setTimerData(this.getTimerData()); clone.setExceptionSensorDataObjects(this.getExceptionSensorDataObjects()); clone.setStart(this.getStart()); clone.setNestedSqlStatements(this.isNestedSqlStatements()); clone.setNestedExceptions(this.isNestedExceptions()); clone.setLoggingData(this.getLoggingData()); clone.setApplicationId(this.getApplicationId()); clone.setBusinessTransactionId(this.getBusinessTransactionId()); return clone; }