/** * Rule execution. * * @return DIAGNOSIS_TAG_CAUSE_STRUCTURE */ @Action(resultTag = RuleConstants.DIAGNOSIS_TAG_CAUSE_STRUCTURE) public CauseStructure action() { // In case there is just one Root Cause method. if (rootCause.size() == 1) { return new CauseStructure(CauseType.SINGLE, rootCause.getSourceType()); } // The Root Causes are called either recursive if (calculateMaxRecursionDepth() > 1) { return new CauseStructure(CauseType.RECURSIVE, rootCause.getSourceType()); // or iterative. } else { return new CauseStructure(CauseType.ITERATIVE, rootCause.getSourceType()); } }
@Test private void musteReturnAnInstanceWithHttpSourceTypeDataIfTheTimerDataIsHttpTimerData() { InvocationSequenceData invocationSequenceData = new InvocationSequenceData(new Timestamp(10L), 10L, 20L, 108L); HttpTimerData timerData = new HttpTimerData(); invocationSequenceData.setTimerData(timerData); AggregatedDiagnosisData aggregatedDiagnosisData = DiagnosisDataAggregator.getInstance().getAggregatedDiagnosisData(invocationSequenceData); assertThat("The object must have HTTP as source type", aggregatedDiagnosisData.getSourceType(), is(SourceType.HTTP)); }
@Test private void musteReturnAnInstanceWithTimerDataSourceTypeDataIfTheTimerDataIsTimerData() { InvocationSequenceData invocationSequenceData = new InvocationSequenceData(new Timestamp(10L), 10L, 20L, 108L); TimerData timerData = new TimerData(); invocationSequenceData.setTimerData(timerData); AggregatedDiagnosisData aggregatedDiagnosisData = DiagnosisDataAggregator.getInstance().getAggregatedDiagnosisData(invocationSequenceData); assertThat("The object must have TIMERDATA as source type", aggregatedDiagnosisData.getSourceType(), is(SourceType.TIMERDATA)); }
@Test private void musteReturnAnInstanceWithDataBaseSourceTypeDataIfHasSqlData() { InvocationSequenceData invocationSequenceData = new InvocationSequenceData(new Timestamp(10L), 10L, 20L, 108L); SqlStatementData sqlStatementData = new SqlStatementData(new Timestamp(10), 10, 10, 108L); sqlStatementData.setCount(1); sqlStatementData.setSql("blahblahblah"); invocationSequenceData.setSqlStatementData(sqlStatementData); AggregatedDiagnosisData aggregatedDiagnosisData = DiagnosisDataAggregator.getInstance().getAggregatedDiagnosisData(invocationSequenceData); assertThat("The object must have DATABASE as source type", aggregatedDiagnosisData.getSourceType(), is(SourceType.DATABASE)); }
@Test private void mustReturnAnInstanceWithDataBaseSourceTypeDataIfHasSqlDataAndTimerData() { InvocationSequenceData invocationSequenceData = new InvocationSequenceData(new Timestamp(10L), 10L, 20L, 108L); SqlStatementData sqlStatementData = new SqlStatementData(new Timestamp(10), 10, 10, 108L); sqlStatementData.setCount(1); sqlStatementData.setSql("blahblahblah"); invocationSequenceData.setSqlStatementData(sqlStatementData); TimerData timerData = new TimerData(new Timestamp(10), 10L, 20, 108L); invocationSequenceData.setTimerData(timerData); AggregatedDiagnosisData aggregatedDiagnosisData = DiagnosisDataAggregator.getInstance().getAggregatedDiagnosisData(invocationSequenceData); assertThat("The object must have DATABASE as source type", aggregatedDiagnosisData.getSourceType(), is(SourceType.DATABASE)); } }