/** * {@inheritDoc} */ @Override public String[] getStringValues(InvocationSequenceData invocSequence, ICachedDataService cachedDataService) { PlatformIdent pIdent = cachedDataService.getPlatformIdentForId(invocSequence.getPlatformIdent()); if (null != pIdent) { List<String> ipList = pIdent.getDefinedIPs(); String[] result = new String[ipList.size()]; ipList.toArray(result); return result; } else { return new String[0]; } }
/** * {@inheritDoc} */ @Override public String[] getStringValues(InvocationSequenceData invocSequence, ICachedDataService cachedDataService) { PlatformIdent pIdent = cachedDataService.getPlatformIdentForId(invocSequence.getPlatformIdent()); if (null != pIdent) { return new String[] { pIdent.getAgentName() }; } else { return new String[0]; } }
/** * Reloads the data from the service. */ private void loadDataFromService() { List<InvocationSequenceData> invocData; if (!autoUpdate) { if (template.getMethodIdent() != IdDefinition.ID_NOT_USED) { invocData = dataAccessService.getInvocationSequenceOverview(template.getPlatformIdent(), template.getMethodIdent(), limit, fromDate, toDate, resultComparator); } else { invocData = dataAccessService.getInvocationSequenceOverview(template.getPlatformIdent(), limit, fromDate, toDate, resultComparator); } } else { if (template.getMethodIdent() != IdDefinition.ID_NOT_USED) { invocData = dataAccessService.getInvocationSequenceOverview(template.getPlatformIdent(), template.getMethodIdent(), limit, resultComparator); } else { invocData = dataAccessService.getInvocationSequenceOverview(template.getPlatformIdent(), limit, resultComparator); } } // why this? so only update with new data if returned collection is not empty, i would say // with every update, if it is empty, then there is nothing to display // then i also done need the clearInvocationFlag // I changed here, .clear() is now out of if clause invocationSequenceData.clear(); if (!invocData.isEmpty()) { invocationSequenceData.addAll(invocData); } }
@Test public void platformIdentIsNull() { when(cachedDataService.getPlatformIdentForId(1L)).thenReturn(null); when(invocationSequenceData.getPlatformIdent()).thenReturn(1L); String[] values = valueSource.getStringValues(invocationSequenceData, cachedDataService); assertThat(values, is(emptyArray())); } }
@Test public void retrieveAgentName() { when(cachedDataService.getPlatformIdentForId(1L)).thenReturn(platformIdent); when(invocationSequenceData.getPlatformIdent()).thenReturn(1L); when(platformIdent.getAgentName()).thenReturn("agentName"); String[] values = valueSource.getStringValues(invocationSequenceData, cachedDataService); assertThat(values, is(arrayContaining("agentName"))); }
@Test public void retrieveURI() { List<String> ips = new ArrayList<>(); ips.add(IP_1); ips.add(IP_2); Mockito.doReturn(PLATFORM_IDENT_ID).when(invocationSeuence).getPlatformIdent(); Mockito.doReturn(platformIdent).when(cachedDataService).getPlatformIdentForId(PLATFORM_IDENT_ID); Mockito.doReturn(ips).when(platformIdent).getDefinedIPs(); String[] values = valueSource.getStringValues(invocationSeuence, cachedDataService); assertThat(values, hasItemInArray(IP_1)); assertThat(values, hasItemInArray(IP_2)); }
/** * {@inheritDoc} */ @Override public InvocationSequenceData getInvocationSequenceDetail(InvocationSequenceData template) { // here we need to create new query since this one does not exist in factory StorageIndexQuery query = invocationDataQueryFactory.getIndexQueryProvider().getIndexQuery(); ArrayList<Class<?>> searchedClasses = new ArrayList<>(); searchedClasses.add(InvocationSequenceData.class); query.setObjectClasses(searchedClasses); query.setPlatformIdent(template.getPlatformIdent()); query.setMethodIdent(template.getMethodIdent()); query.setSensorTypeIdent(template.getSensorTypeIdent()); query.setOnlyInvocationsWithoutChildren(false); ArrayList<Long> includeIds = new ArrayList<>(); includeIds.add(template.getId()); query.setIncludeIds(includeIds); List<InvocationSequenceData> results = super.executeQuery(query); if (results.size() == 1) { return results.get(0); } return null; }
@Test public void noBusinessContext() throws Exception { when(cachedDataService.getPlatformIdentForId(PLATFORM_ID)).thenReturn(platformIdent); when(cachedDataService.getBusinessTransactionForId(APP_ID, BT_ID)).thenReturn(null); double duration = RandomUtils.nextDouble(); long time = RandomUtils.nextLong(); when(data.getPlatformIdent()).thenReturn(PLATFORM_ID); when(data.getApplicationId()).thenReturn(APP_ID); when(data.getBusinessTransactionId()).thenReturn(BT_ID); when(data.getTimeStamp()).thenReturn(new Timestamp(time)); when(data.getDuration()).thenReturn(duration); Collection<Builder> pointBuilderCol = builder.createBuilders(data); assertThat(pointBuilderCol.size(), is(1)); Builder pointBuilder = pointBuilderCol.iterator().next(); assertThat(getMeasurement(pointBuilder), is(Series.BusinessTransaction.NAME)); assertThat(getTime(pointBuilder), is(time)); assertThat(getPrecision(pointBuilder), is(TimeUnit.MILLISECONDS)); assertThat(getTags(pointBuilder), hasEntry(Series.TAG_AGENT_ID, String.valueOf(PLATFORM_ID))); assertThat(getTags(pointBuilder), hasEntry(Series.TAG_AGENT_NAME, String.valueOf(AGENT_NAME))); assertThat(getTags(pointBuilder), hasEntry(Series.BusinessTransaction.TAG_APPLICATION_NAME, String.valueOf(ApplicationDefinition.UNKNOWN_APP))); assertThat(getTags(pointBuilder), hasEntry(Series.BusinessTransaction.TAG_BUSINESS_TRANSACTION_NAME, String.valueOf(BusinessTransactionDefinition.UNKNOWN_BUSINESS_TX))); assertThat(getFields(pointBuilder), hasEntry(Series.BusinessTransaction.FIELD_DURATION, (Object) duration)); }
@Test public void noPlatform() throws Exception { when(cachedDataService.getPlatformIdentForId(PLATFORM_ID)).thenReturn(null); when(cachedDataService.getBusinessTransactionForId(APP_ID, BT_ID)).thenReturn(businessTransactionData); when(businessTransactionData.getApplication()).thenReturn(applicationData); double duration = RandomUtils.nextDouble(); long time = RandomUtils.nextLong(); when(data.getPlatformIdent()).thenReturn(PLATFORM_ID); when(data.getApplicationId()).thenReturn(APP_ID); when(data.getBusinessTransactionId()).thenReturn(BT_ID); when(data.getTimeStamp()).thenReturn(new Timestamp(time)); when(data.getDuration()).thenReturn(duration); Collection<Builder> pointBuilderCol = builder.createBuilders(data); assertThat(pointBuilderCol.size(), is(1)); Builder pointBuilder = pointBuilderCol.iterator().next(); assertThat(getMeasurement(pointBuilder), is(Series.BusinessTransaction.NAME)); assertThat(getTime(pointBuilder), is(time)); assertThat(getPrecision(pointBuilder), is(TimeUnit.MILLISECONDS)); assertThat(getTags(pointBuilder), hasEntry(Series.TAG_AGENT_ID, String.valueOf(PLATFORM_ID))); assertThat(getTags(pointBuilder), not(hasKey(Series.TAG_AGENT_NAME))); assertThat(getTags(pointBuilder), hasEntry(Series.BusinessTransaction.TAG_APPLICATION_NAME, String.valueOf(APP_NAME))); assertThat(getTags(pointBuilder), hasEntry(Series.BusinessTransaction.TAG_BUSINESS_TRANSACTION_NAME, String.valueOf(BT_NAME))); assertThat(getFields(pointBuilder), hasEntry(Series.BusinessTransaction.FIELD_DURATION, (Object) duration)); }
assertThat(invocation.getPlatformIdent(), is(platformId)); assertThat(invocation.getMethodIdent(), is(methodId)); assertThat(invocation.getSensorTypeIdent(), is(sensorTypeId));
@Test public void happyPath() throws Exception { when(cachedDataService.getPlatformIdentForId(PLATFORM_ID)).thenReturn(platformIdent); when(cachedDataService.getBusinessTransactionForId(APP_ID, BT_ID)).thenReturn(businessTransactionData); when(businessTransactionData.getApplication()).thenReturn(applicationData); double duration = RandomUtils.nextDouble(); long time = RandomUtils.nextLong(); when(data.getPlatformIdent()).thenReturn(PLATFORM_ID); when(data.getApplicationId()).thenReturn(APP_ID); when(data.getBusinessTransactionId()).thenReturn(BT_ID); when(data.getTimeStamp()).thenReturn(new Timestamp(time)); when(data.getDuration()).thenReturn(duration); when(data.getId()).thenReturn(Long.MAX_VALUE); Collection<Builder> pointBuilderCol = builder.createBuilders(data); assertThat(pointBuilderCol.size(), is(1)); Builder pointBuilder = pointBuilderCol.iterator().next(); assertThat(getMeasurement(pointBuilder), is(Series.BusinessTransaction.NAME)); assertThat(getTime(pointBuilder), is(time)); assertThat(getPrecision(pointBuilder), is(TimeUnit.MILLISECONDS)); assertThat(getTags(pointBuilder), hasEntry(Series.TAG_AGENT_ID, String.valueOf(PLATFORM_ID))); assertThat(getTags(pointBuilder), hasEntry(Series.TAG_AGENT_NAME, String.valueOf(AGENT_NAME))); assertThat(getTags(pointBuilder), hasEntry(Series.BusinessTransaction.TAG_APPLICATION_NAME, String.valueOf(APP_NAME))); assertThat(getTags(pointBuilder), hasEntry(Series.BusinessTransaction.TAG_BUSINESS_TRANSACTION_NAME, String.valueOf(BT_NAME))); assertThat(getFields(pointBuilder), hasEntry(Series.BusinessTransaction.FIELD_DURATION, (Object) duration)); assertThat(getFields(pointBuilder), hasEntry(Series.BusinessTransaction.FIELD_TRACE_ID, (Object) Long.MAX_VALUE)); }
assertThat(invocation.getPlatformIdent(), is(platformId)); assertThat(invocation.getMethodIdent(), is(methodId)); assertThat(invocation.getSensorTypeIdent(), is(sensorTypeId));
assertThat(invocation.getPlatformIdent(), is(platformId)); assertThat(invocation.getMethodIdent(), is(methodId1)); assertThat(invocation.getSensorTypeIdent(), is(sensorTypeId));
assertThat(invocation.getPlatformIdent(), is(platformId)); assertThat(invocation.getMethodIdent(), is(methodId1)); assertThat(invocation.getSensorTypeIdent(), is(sensorTypeId));
assertThat(invocation.getPlatformIdent(), is(platformId)); assertThat(invocation.getMethodIdent(), is(methodId)); assertThat(invocation.getSensorTypeIdent(), is(sensorTypeId));
assertThat(invocation.getPlatformIdent(), is(platformId)); assertThat(invocation.getMethodIdent(), is(methodId)); assertThat(invocation.getSensorTypeIdent(), is(sensorTypeId));
assertThat(invocation.getPlatformIdent(), is(platformId)); assertThat(invocation.getMethodIdent(), is(methodId1)); assertThat(invocation.getSensorTypeIdent(), is(sensorTypeId)); assertThat(invocation.getChildCount(), is(1L)); InvocationSequenceData child = invocation.getNestedSequences().iterator().next(); assertThat(child.getPlatformIdent(), is(platformId)); assertThat(child.getMethodIdent(), is(methodId2)); assertThat(child.getSensorTypeIdent(), is(sensorTypeId));
assertThat(invocation.getPlatformIdent(), is(platformId)); assertThat(invocation.getMethodIdent(), is(methodId1)); assertThat(invocation.getSensorTypeIdent(), is(sensorTypeId)); assertThat(invocation.getChildCount(), is(1L)); InvocationSequenceData child = invocation.getNestedSequences().iterator().next(); assertThat(child.getPlatformIdent(), is(platformId)); assertThat(child.getMethodIdent(), is(methodId2)); assertThat(child.getSensorTypeIdent(), is(sensorTypeId));
/** * 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; }
idDefinition.setPlatformId(invocationSequenceData.getPlatformIdent()); idDefinition.setMethodId(invocationSequenceData.getMethodIdent()); idDefinition.setSensorTypeId(invocationSequenceData.getSensorTypeIdent());