/** * {@inheritDoc} */ @Override public String[] getStringValues(InvocationSequenceData invocSequence, ICachedDataService cachedDataService) { if (!InvocationSequenceDataHelper.hasHttpTimerData(invocSequence)) { return new String[0]; } HttpTimerData httpData = (HttpTimerData) invocSequence.getTimerData(); return new String[] { String.valueOf(httpData.getHttpInfo().getServerPort()) }; } }
/** * {@inheritDoc} */ @Override public String[] getStringValues(InvocationSequenceData invocSequence, ICachedDataService cachedDataService) { if (!InvocationSequenceDataHelper.hasHttpTimerData(invocSequence)) { return new String[0]; } HttpTimerData httpData = (HttpTimerData) invocSequence.getTimerData(); return new String[] { httpData.getHttpInfo().getServerName() }; } }
/** * {@inheritDoc} */ @Override public String[] getStringValues(InvocationSequenceData invocSequence, ICachedDataService cachedDataService) { if (!InvocationSequenceDataHelper.hasHttpTimerData(invocSequence)) { return new String[0]; } HttpTimerData httpData = (HttpTimerData) invocSequence.getTimerData(); return new String[] { httpData.getHttpInfo().getQueryString() }; } }
/** * {@inheritDoc} */ @Override public String[] getStringValues(InvocationSequenceData invocSequence, ICachedDataService cachedDataService) { if (!InvocationSequenceDataHelper.hasHttpTimerData(invocSequence)) { return new String[0]; } HttpTimerData httpData = (HttpTimerData) invocSequence.getTimerData(); return new String[] { httpData.getHttpInfo().getUrl() }; } }
/** * {@inheritDoc} */ @Override public String[] getStringValues(InvocationSequenceData invocSequence, ICachedDataService cachedDataService) { if (!InvocationSequenceDataHelper.hasHttpTimerData(invocSequence)) { return new String[0]; } HttpTimerData httpData = (HttpTimerData) invocSequence.getTimerData(); return new String[] { httpData.getHttpInfo().getScheme() }; } }
/** * Test is not null restriction with field navigation. */ @Test public void isNotNullNavigation() { HttpTimerData httpData = new HttpTimerData(); httpData.getHttpInfo().setId(1L); List<IIndexQueryRestriction> restrictions = Collections.singletonList(IndexQueryRestrictionFactory.isNotNull("httpInfo.id")); boolean result = processor.areAllRestrictionsFulfilled(httpData, restrictions); assertThat(result, is(true)); }
/** * Test greater or equal restriction with field navigation. */ @Test public void greaterEqualOneNavigation() { HttpTimerData httpData = new HttpTimerData(); httpData.getHttpInfo().setId(1L); List<IIndexQueryRestriction> restrictions = Collections.singletonList(IndexQueryRestrictionFactory.greaterEqual("httpInfo.id", 1L)); boolean result = processor.areAllRestrictionsFulfilled(httpData, restrictions); assertThat(result, is(true)); }
@Test public void retrieveServerPort() { HttpInfo httpInfo = new HttpInfo(); httpInfo.setServerPort(8080); doReturn(httpTimerData).when(invocationSequenceData).getTimerData(); doReturn(httpInfo).when(httpTimerData).getHttpInfo(); String[] values = valueSource.getStringValues(invocationSequenceData, cachedDataService); assertThat(values, hasItemInArray("8080")); }
@Test public void retrieveServerName() { HttpInfo httpInfo = new HttpInfo(); httpInfo.setServerName("localhost"); doReturn(httpTimerData).when(invocationSequenceData).getTimerData(); doReturn(httpInfo).when(httpTimerData).getHttpInfo(); String[] values = valueSource.getStringValues(invocationSequenceData, cachedDataService); assertThat(values, hasItemInArray("localhost")); }
@Test public void retrieveQueryString() { HttpInfo httpInfo = new HttpInfo(); httpInfo.setQueryString("test=true"); doReturn(httpTimerData).when(invocationSequenceData).getTimerData(); doReturn(httpInfo).when(httpTimerData).getHttpInfo(); String[] values = valueSource.getStringValues(invocationSequenceData, cachedDataService); assertThat(values, hasItemInArray("test=true")); }
/** * Test equal restriction with field navigation. */ @Test public void equalsTrueNavigation() { HttpTimerData httpData = new HttpTimerData(); httpData.getHttpInfo().setId(1L); List<IIndexQueryRestriction> restrictions = Collections.singletonList(IndexQueryRestrictionFactory.equal("httpInfo.id", 1L)); boolean result = processor.areAllRestrictionsFulfilled(httpData, restrictions); assertThat(result, is(true)); }
/** * Test not equal restriction with field navigation. */ @Test public void notEqualsFalseNavigation() { HttpTimerData httpData = new HttpTimerData(); httpData.getHttpInfo().setId(1L); List<IIndexQueryRestriction> restrictions = Collections.singletonList(IndexQueryRestrictionFactory.notEqual("httpInfo.id", 1L)); boolean result = processor.areAllRestrictionsFulfilled(httpData, restrictions); assertThat(result, is(false)); }
/** * Test less than restriction with field navigation. */ @Test public void lessThanZeroNavigation() { HttpTimerData httpData = new HttpTimerData(); httpData.getHttpInfo().setId(1L); List<IIndexQueryRestriction> restrictions = Collections.singletonList(IndexQueryRestrictionFactory.lessThan("httpInfo.id", 0L)); boolean result = processor.areAllRestrictionsFulfilled(httpData, restrictions); assertThat(result, is(false)); }
/** * Test equal restriction with field navigation. */ @Test public void equalsFalseNavigation() { HttpTimerData httpData = new HttpTimerData(); httpData.getHttpInfo().setId(1L); List<IIndexQueryRestriction> restrictions = Collections.singletonList(IndexQueryRestrictionFactory.equal("httpInfo.id", 0L)); boolean result = processor.areAllRestrictionsFulfilled(httpData, restrictions); assertThat(result, is(false)); }
/** * Test greater than restriction with field navigation. */ @Test public void greaterThanOneNavigation() { HttpTimerData httpData = new HttpTimerData(); httpData.getHttpInfo().setId(1L); List<IIndexQueryRestriction> restrictions = Collections.singletonList(IndexQueryRestrictionFactory.greaterThan("httpInfo.id", 1L)); boolean result = processor.areAllRestrictionsFulfilled(httpData, restrictions); assertThat(result, is(false)); }
/** * Test greater than restriction with field navigation. */ @Test public void greaterThanZeroNavigation() { HttpTimerData httpData = new HttpTimerData(); httpData.getHttpInfo().setId(1L); List<IIndexQueryRestriction> restrictions = Collections.singletonList(IndexQueryRestrictionFactory.greaterThan("httpInfo.id", 0L)); boolean result = processor.areAllRestrictionsFulfilled(httpData, restrictions); assertThat(result, is(true)); }
/** * Test less or equal restriction with field navigation. */ @Test public void lessEqualTwoNavigation() { HttpTimerData httpData = new HttpTimerData(); httpData.getHttpInfo().setId(1L); List<IIndexQueryRestriction> restrictions = Collections.singletonList(IndexQueryRestrictionFactory.lessEqual("httpInfo.id", 2L)); boolean result = processor.areAllRestrictionsFulfilled(httpData, restrictions); assertThat(result, is(true)); }
@Test public void retrieveRequestMethod() { HttpInfo httpInfo = new HttpInfo(); httpInfo.setRequestMethod("POST"); doReturn(httpTimerData).when(invocationSequenceData).getTimerData(); doReturn(httpInfo).when(httpTimerData).getHttpInfo(); String[] values = valueSource.getStringValues(invocationSequenceData, cachedDataService); assertThat(values, hasItemInArray("POST")); }
@Test public void retrieveScheme() { HttpInfo httpInfo = new HttpInfo(); httpInfo.setScheme("https"); doReturn(httpTimerData).when(invocationSequenceData).getTimerData(); doReturn(httpInfo).when(httpTimerData).getHttpInfo(); String[] values = valueSource.getStringValues(invocationSequenceData, cachedDataService); assertThat(values, hasItemInArray("https")); }
@Test private void musteReturnAnObjectWithAPairLongStringIfTheTimerDataHasHttpTimerData() { InvocationSequenceData invocationSequenceData = new InvocationSequenceData(new Timestamp(10L), 10L, 20L, 108L); HttpTimerData timerData = new HttpTimerData(new Timestamp(10), 10, 10, 108L); HttpInfo httpInfo = new HttpInfo("URI", "requestMethod", "headerValue"); timerData.setHttpInfo(httpInfo); invocationSequenceData.setTimerData(timerData); Pair<Long, String> aggregationKey = (Pair<Long, String>) DiagnosisDataAggregator.getInstance().getAggregationKey(invocationSequenceData); assertThat("The string of the pair must be the sql data", aggregationKey.getSecond(), is(timerData.getHttpInfo().getUri())); }