ATEST-633
This commit is contained in:
@ -81,6 +81,8 @@ public class JSONTableResponseStreamWriter implements ResponseStreamWriter {
|
|||||||
@Resource(name = QueryRestConfig.BEAN_NAME_DEFAULT_RESPONSE_AGGREGATIONS)
|
@Resource(name = QueryRestConfig.BEAN_NAME_DEFAULT_RESPONSE_AGGREGATIONS)
|
||||||
private Set<Aggregation> defaultResponseAggregations;
|
private Set<Aggregation> defaultResponseAggregations;
|
||||||
|
|
||||||
|
// In case ArchiverAppliance had several events within the 10ms mapping interval, return these
|
||||||
|
// aggregations
|
||||||
private Set<String> defaultResponseAggregationsStr;
|
private Set<String> defaultResponseAggregationsStr;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
@ -116,7 +118,9 @@ public class JSONTableResponseStreamWriter implements ResponseStreamWriter {
|
|||||||
/* make sure identifiers are available */
|
/* make sure identifiers are available */
|
||||||
includedFields.add(QueryField.channel.name());
|
includedFields.add(QueryField.channel.name());
|
||||||
includedFields.add(QueryField.backend.name());
|
includedFields.add(QueryField.backend.name());
|
||||||
includedFields.addAll(defaultResponseAggregationsStr);
|
if (!containsAggregation(includedFields)) {
|
||||||
|
includedFields.addAll(defaultResponseAggregationsStr);
|
||||||
|
}
|
||||||
|
|
||||||
ObjectWriter writer = JSONResponseStreamWriter.configureWriter(includedFields, mapper);
|
ObjectWriter writer = JSONResponseStreamWriter.configureWriter(includedFields, mapper);
|
||||||
|
|
||||||
@ -211,4 +215,13 @@ public class JSONTableResponseStreamWriter implements ResponseStreamWriter {
|
|||||||
throw exception.get();
|
throw exception.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean containsAggregation(Set<String> includedFields) {
|
||||||
|
for (Aggregation aggregation : Aggregation.values()) {
|
||||||
|
if (includedFields.contains(aggregation.name())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,6 +145,72 @@ public class JsonQueryRestControllerTableTest extends AbstractDaqRestTest {
|
|||||||
.andExpect(MockMvcResultMatchers.jsonPath("$.data[1][1].iocMillis").value(1010));
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[1][1].iocMillis").value(1010));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPulseRangeQuery_NrOfBins() throws Exception {
|
||||||
|
DAQQuery request = new DAQQuery(
|
||||||
|
new RequestRangePulseId(
|
||||||
|
100,
|
||||||
|
101),
|
||||||
|
TEST_CHANNEL_NAMES);
|
||||||
|
request.setMapping(new Mapping());
|
||||||
|
request.addField(QueryField.pulseId);
|
||||||
|
request.addField(QueryField.globalSeconds);
|
||||||
|
request.addField(QueryField.globalMillis);
|
||||||
|
request.addField(QueryField.iocSeconds);
|
||||||
|
request.addField(QueryField.iocMillis);
|
||||||
|
request.addField(QueryField.value);
|
||||||
|
|
||||||
|
AggregationDescriptor aggregation = new AggregationDescriptor(AggregationType.value);
|
||||||
|
aggregation.setNrOfBins(1);
|
||||||
|
aggregation.setAggregations(Arrays.asList(Aggregation.mean));
|
||||||
|
request.setAggregation(aggregation);
|
||||||
|
|
||||||
|
String content = mapper.writeValueAsString(request);
|
||||||
|
System.out.println(content);
|
||||||
|
|
||||||
|
this.mockMvc
|
||||||
|
.perform(MockMvcRequestBuilders
|
||||||
|
.post(DomainConfig.PATH_QUERY)
|
||||||
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
|
.content(content))
|
||||||
|
|
||||||
|
.andDo(MockMvcResultHandlers.print())
|
||||||
|
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data").isArray())
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0]").exists())
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0]").isArray())
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0][0]").exists())
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0][0]").isMap())
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0][0].channel").value(TEST_CHANNEL_01))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0][0].backend").value(Backend.SF_DATABUFFER.getKey()))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0][0].pulseId").value(100))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0][0].globalSeconds").value(
|
||||||
|
TestTimeUtils.getTimeStr(1, 0)))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0][0].globalMillis").value(1000))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0][0].iocSeconds").value(
|
||||||
|
TestTimeUtils.getTimeStr(1, 0)))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0][0].iocMillis").value(1000))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0][0].value.mean").value(100.5))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0][0].value.min").doesNotExist())
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0][0].value.max").doesNotExist())
|
||||||
|
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0][1]").exists())
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0][1]").isMap())
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0][1].channel").value(TEST_CHANNEL_02))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0][1].backend").value(Backend.SF_DATABUFFER.getKey()))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0][1].pulseId").value(100))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0][1].globalSeconds").value(
|
||||||
|
TestTimeUtils.getTimeStr(1, 0)))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0][1].globalMillis").value(1000))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0][1].iocSeconds").value(
|
||||||
|
TestTimeUtils.getTimeStr(1, 0)))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0][1].iocMillis").value(1000))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0][1].value.mean").value(100.5))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0][1].value.min").doesNotExist())
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0][1].value.max").doesNotExist());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPulseRangeQuery_ChannelOrder() throws Exception {
|
public void testPulseRangeQuery_ChannelOrder() throws Exception {
|
||||||
DAQQuery request = new DAQQuery(
|
DAQQuery request = new DAQQuery(
|
||||||
@ -369,7 +435,8 @@ public class JsonQueryRestControllerTableTest extends AbstractDaqRestTest {
|
|||||||
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0][1]").exists())
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0][1]").exists())
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0][1]").isMap())
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0][1]").isMap())
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0][1].channel").value(TEST_CHANNEL_02))
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0][1].channel").value(TEST_CHANNEL_02))
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0][1].backend").value(Backend.SF_ARCHIVERAPPLIANCE.getKey()))
|
.andExpect(
|
||||||
|
MockMvcResultMatchers.jsonPath("$.data[0][1].backend").value(Backend.SF_ARCHIVERAPPLIANCE.getKey()))
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0][1].pulseId").value(100))
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0][1].pulseId").value(100))
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0][1].globalSeconds").value(
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0][1].globalSeconds").value(
|
||||||
TestTimeUtils.getTimeStr(1, 0)))
|
TestTimeUtils.getTimeStr(1, 0)))
|
||||||
@ -385,7 +452,8 @@ public class JsonQueryRestControllerTableTest extends AbstractDaqRestTest {
|
|||||||
.andExpect(MockMvcResultMatchers.jsonPath("$.data[1][1]").exists())
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[1][1]").exists())
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$.data[1][1]").isMap())
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[1][1]").isMap())
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$.data[1][1].channel").value(TEST_CHANNEL_02))
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[1][1].channel").value(TEST_CHANNEL_02))
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$.data[1][1].backend").value(Backend.SF_ARCHIVERAPPLIANCE.getKey()))
|
.andExpect(
|
||||||
|
MockMvcResultMatchers.jsonPath("$.data[1][1].backend").value(Backend.SF_ARCHIVERAPPLIANCE.getKey()))
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$.data[1][1].pulseId").value(101))
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[1][1].pulseId").value(101))
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$.data[1][1].globalSeconds").value(
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[1][1].globalSeconds").value(
|
||||||
TestTimeUtils.getTimeStr(1, 10000000)));
|
TestTimeUtils.getTimeStr(1, 10000000)));
|
||||||
@ -2159,9 +2227,9 @@ public class JsonQueryRestControllerTableTest extends AbstractDaqRestTest {
|
|||||||
request.setValueTransformation(
|
request.setValueTransformation(
|
||||||
new ValueTransformationSequence(
|
new ValueTransformationSequence(
|
||||||
new ImageDownScaleValueTransformation(8, Color.BLUE, Color.RED),
|
new ImageDownScaleValueTransformation(8, Color.BLUE, Color.RED),
|
||||||
new ImageEncodingValueTransformation(
|
new ImageEncodingValueTransformation(
|
||||||
ImageFormat.PNG,
|
ImageFormat.PNG,
|
||||||
new Base64ImageEncoder(StandardCharsets.UTF_8, true, false))));
|
new Base64ImageEncoder(StandardCharsets.UTF_8, true, false))));
|
||||||
|
|
||||||
String content = mapper.writeValueAsString(request);
|
String content = mapper.writeValueAsString(request);
|
||||||
System.out.println(content);
|
System.out.println(content);
|
||||||
|
Reference in New Issue
Block a user