return (HttpInfo) httpInfoList.get(0); } else { return new HttpInfo(uri, requestMethod, tag);
@Test public void retrieveURI() { HttpInfo httpInfo = new HttpInfo("/test/uri", "POST", null); doReturn(httpTimerData).when(invocationSequenceData).getTimerData(); doReturn(httpInfo).when(httpTimerData).getHttpInfo(); String[] values = valueSource.getStringValues(invocationSequenceData, cachedDataService); assertThat(values, hasItemInArray("/test/uri")); }
@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 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 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 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 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())); }
@Test public void retrieveURL() { HttpInfo httpInfo = new HttpInfo(); httpInfo.setScheme("http"); httpInfo.setServerName("localhost"); httpInfo.setServerPort(8080); httpInfo.setUri("/test/uri"); httpInfo.setQueryString("test=true"); doReturn(httpTimerData).when(invocationSequenceData).getTimerData(); doReturn(httpInfo).when(httpTimerData).getHttpInfo(); String[] values = valueSource.getStringValues(invocationSequenceData, cachedDataService); assertThat(values, hasItemInArray("http://localhost:8080/test/uri?test=true")); }
@Test private void ifTheAggregatedObjectHasHttpTimerDataAndIsDefinedInTheMapItMustBeAggregatedToTheDiagnosisAggregator() { InvocationSequenceData invocationSequenceData = new InvocationSequenceData(new Timestamp(10L), 10L, 20L, 2L); diagnosisDataAggregationPerformer = new DiagnosisDataAggregationPerformer(); HttpTimerData timerData = new HttpTimerData(new Timestamp(10), 10, 10, 108L); HttpInfo httpInfo = new HttpInfo("URI", "requestMethod", "headerValue"); timerData.setHttpInfo(httpInfo); invocationSequenceData.setTimerData(timerData); Object key = new Pair<Long, String>(invocationSequenceData.getMethodIdent(), ((HttpTimerData) invocationSequenceData.getTimerData()).getHttpInfo().getUri()); diagnosisDataAggregationPerformer.diagnosisDataAggregationMap.put(key, alreadyAggregatedObject); diagnosisDataAggregationPerformer.aggregateInvocationSequenceData(invocationSequenceData); verify(alreadyAggregatedObject, times(1)).aggregate(invocationSequenceData); } }