/** * {@inheritDoc} */ @Override public void accept(ProblemOccurrence problemOccurrence) { Builder builder = problemOccurrencePointBuilder.getBuilder(problemOccurrence); influxDBDao.insert(builder.build()); } }
@Test public void mustToCallToInsertDBDao() { Builder builder = Point.measurement("test").addField("test", 1).time(1, TimeUnit.MILLISECONDS); when(diagnosisCmrConfiguration.problemOccurrencePointBuilder.getBuilder(problemOccurrence)).thenReturn(builder); diagnosisCmrConfiguration.accept(problemOccurrence); ArgumentCaptor<Point> pointCaptor = ArgumentCaptor.forClass(Point.class); verify(diagnosisCmrConfiguration.influxDBDao).insert(pointCaptor.capture()); assertThat(pointCaptor.getValue().lineProtocol(), is(builder.build().lineProtocol())); } }
@Test public void noApplicationData() throws Exception { when(cachedDataService.getApplicationForId(problemOccurrence.getApplicationNameIdent())).thenReturn(null); when(cachedDataService.getPlatformIdentForId(APP_ID)).thenReturn(null); when(cachedDataService.getBusinessTransactionForId(APP_ID, BUSINESS_TX_ID)).thenReturn(businessTransactionData); when(cachedDataService.getMethodIdentForId(invocationIdentifier.getMethodIdent())).thenReturn(methodIdent); Builder pointBuilder = builder.getBuilder(problemOccurrence); assertThat(getMeasurement(pointBuilder), is(Series.ProblemOccurrenceInformation.NAME)); assertThat(getPrecision(pointBuilder), is(TimeUnit.MILLISECONDS)); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_APPLICATION_NAME, String.valueOf(ApplicationDefinition.UNKNOWN_APP))); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_BUSINESS_TRANSACTION_NAME, String.valueOf(BUSINESS_TX))); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_PROBLEM_CONTEXT_METHOD_NAME, FQN + "." + METHOD)); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_ROOTCAUSE_METHOD_NAME, FQN + "." + METHOD)); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_CAUSESTRUCTURE_CAUSE_TYPE, String.valueOf(causeType))); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_CAUSESTRUCTURE_SOURCE_TYPE, String.valueOf(sourceType))); assertThat(getFields(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.FIELD_INVOCATION_ROOT_DURATION, DURATION)); assertThat(getFields(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.FIELD_GLOBAL_CONTEXT_METHOD_EXCLUSIVE_TIME, EXCLUSIVE_DURATION)); assertThat(getFields(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.FIELD_ROOTCAUSE_METHOD_EXCLUSIVE_TIME, EXCLUSIVE_DURATION)); }
@Test public void noPlatform() throws Exception { when(cachedDataService.getApplicationForId(problemOccurrence.getApplicationNameIdent())).thenReturn(applicationData); when(cachedDataService.getPlatformIdentForId(APP_ID)).thenReturn(null); when(cachedDataService.getBusinessTransactionForId(APP_ID, BUSINESS_TX_ID)).thenReturn(businessTransactionData); when(cachedDataService.getMethodIdentForId(invocationIdentifier.getMethodIdent())).thenReturn(methodIdent); Builder pointBuilder = builder.getBuilder(problemOccurrence); assertThat(getMeasurement(pointBuilder), is(Series.ProblemOccurrenceInformation.NAME)); assertThat(getPrecision(pointBuilder), is(TimeUnit.MILLISECONDS)); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_APPLICATION_NAME, String.valueOf(APPLICATION_NAME))); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_BUSINESS_TRANSACTION_NAME, String.valueOf(BUSINESS_TX))); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_PROBLEM_CONTEXT_METHOD_NAME, FQN + "." + METHOD)); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_ROOTCAUSE_METHOD_NAME, FQN + "." + METHOD)); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_CAUSESTRUCTURE_CAUSE_TYPE, String.valueOf(causeType))); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_CAUSESTRUCTURE_SOURCE_TYPE, String.valueOf(sourceType))); assertThat(getFields(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.FIELD_INVOCATION_ROOT_DURATION, DURATION)); assertThat(getFields(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.FIELD_GLOBAL_CONTEXT_METHOD_EXCLUSIVE_TIME, EXCLUSIVE_DURATION)); assertThat(getFields(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.FIELD_ROOTCAUSE_METHOD_EXCLUSIVE_TIME, EXCLUSIVE_DURATION)); }
@Test public void happyPath() throws Exception { when(cachedDataService.getApplicationForId(problemOccurrence.getApplicationNameIdent())).thenReturn(applicationData); when(cachedDataService.getPlatformIdentForId(APP_ID)).thenReturn(platformIdent); when(cachedDataService.getBusinessTransactionForId(APP_ID, BUSINESS_TX_ID)).thenReturn(businessTransactionData); when(cachedDataService.getMethodIdentForId(invocationIdentifier.getMethodIdent())).thenReturn(methodIdent); Builder pointBuilder = builder.getBuilder(problemOccurrence); assertThat(getMeasurement(pointBuilder), is(Series.ProblemOccurrenceInformation.NAME)); assertThat(getPrecision(pointBuilder), is(TimeUnit.MILLISECONDS)); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_APPLICATION_NAME, String.valueOf(APPLICATION_NAME))); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_BUSINESS_TRANSACTION_NAME, String.valueOf(BUSINESS_TX))); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_PROBLEM_CONTEXT_METHOD_NAME, FQN + "." + METHOD)); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_ROOTCAUSE_METHOD_NAME, FQN + "." + METHOD)); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_CAUSESTRUCTURE_CAUSE_TYPE, String.valueOf(causeType))); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_CAUSESTRUCTURE_SOURCE_TYPE, String.valueOf(sourceType))); assertThat(getFields(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.FIELD_INVOCATION_ROOT_DURATION, DURATION)); assertThat(getFields(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.FIELD_GLOBAL_CONTEXT_METHOD_EXCLUSIVE_TIME, EXCLUSIVE_DURATION)); assertThat(getFields(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.FIELD_ROOTCAUSE_METHOD_EXCLUSIVE_TIME, EXCLUSIVE_DURATION)); }
@Test public void noBusinessContext() throws Exception { when(cachedDataService.getApplicationForId(problemOccurrence.getApplicationNameIdent())).thenReturn(applicationData); when(cachedDataService.getPlatformIdentForId(APP_ID)).thenReturn(platformIdent); when(cachedDataService.getBusinessTransactionForId(APP_ID, BUSINESS_TX_ID)).thenReturn(null); when(cachedDataService.getMethodIdentForId(invocationIdentifier.getMethodIdent())).thenReturn(methodIdent); Builder pointBuilder = builder.getBuilder(problemOccurrence); assertThat(getMeasurement(pointBuilder), is(Series.ProblemOccurrenceInformation.NAME)); assertThat(getPrecision(pointBuilder), is(TimeUnit.MILLISECONDS)); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_APPLICATION_NAME, String.valueOf(APPLICATION_NAME))); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_BUSINESS_TRANSACTION_NAME, BusinessTransactionDefinition.UNKNOWN_BUSINESS_TX)); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_PROBLEM_CONTEXT_METHOD_NAME, FQN + "." + METHOD)); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_ROOTCAUSE_METHOD_NAME, FQN + "." + METHOD)); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_CAUSESTRUCTURE_CAUSE_TYPE, String.valueOf(causeType))); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_CAUSESTRUCTURE_SOURCE_TYPE, String.valueOf(sourceType))); assertThat(getFields(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.FIELD_INVOCATION_ROOT_DURATION, DURATION)); assertThat(getFields(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.FIELD_GLOBAL_CONTEXT_METHOD_EXCLUSIVE_TIME, EXCLUSIVE_DURATION)); assertThat(getFields(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.FIELD_ROOTCAUSE_METHOD_EXCLUSIVE_TIME, EXCLUSIVE_DURATION)); }
@Test public void noMethodIdentifier() throws Exception { when(cachedDataService.getApplicationForId(problemOccurrence.getApplicationNameIdent())).thenReturn(applicationData); when(cachedDataService.getPlatformIdentForId(APP_ID)).thenReturn(platformIdent); when(cachedDataService.getBusinessTransactionForId(APP_ID, BUSINESS_TX_ID)).thenReturn(businessTransactionData); when(cachedDataService.getMethodIdentForId(invocationIdentifier.getMethodIdent())).thenReturn(null); Builder pointBuilder = builder.getBuilder(problemOccurrence); assertThat(getMeasurement(pointBuilder), is(Series.ProblemOccurrenceInformation.NAME)); assertThat(getPrecision(pointBuilder), is(TimeUnit.MILLISECONDS)); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_APPLICATION_NAME, String.valueOf(APPLICATION_NAME))); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_BUSINESS_TRANSACTION_NAME, String.valueOf(BUSINESS_TX))); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_PROBLEM_CONTEXT_METHOD_NAME, UNKNOWN_METHOD_FQN)); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_ROOTCAUSE_METHOD_NAME, UNKNOWN_METHOD_FQN)); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_CAUSESTRUCTURE_CAUSE_TYPE, String.valueOf(causeType))); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_CAUSESTRUCTURE_SOURCE_TYPE, String.valueOf(sourceType))); assertThat(getFields(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.FIELD_INVOCATION_ROOT_DURATION, DURATION)); assertThat(getFields(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.FIELD_GLOBAL_CONTEXT_METHOD_EXCLUSIVE_TIME, EXCLUSIVE_DURATION)); assertThat(getFields(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.FIELD_ROOTCAUSE_METHOD_EXCLUSIVE_TIME, EXCLUSIVE_DURATION)); } }