Intermediate...
This commit is contained in:
@ -27,7 +27,7 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
|||||||
import com.fasterxml.jackson.core.JsonFactory;
|
import com.fasterxml.jackson.core.JsonFactory;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
import ch.psi.daq.common.statistic.StorelessStatistics;
|
import ch.psi.daq.common.statistic.Statistics;
|
||||||
import ch.psi.daq.domain.DataEvent;
|
import ch.psi.daq.domain.DataEvent;
|
||||||
import ch.psi.daq.domain.query.operation.Aggregation;
|
import ch.psi.daq.domain.query.operation.Aggregation;
|
||||||
import ch.psi.daq.domain.query.operation.QueryField;
|
import ch.psi.daq.domain.query.operation.QueryField;
|
||||||
@ -85,7 +85,7 @@ public class QueryRestConfig extends WebMvcConfigurerAdapter {
|
|||||||
// Mixin which is used dynamically to filter out which properties get serialised and which
|
// Mixin which is used dynamically to filter out which properties get serialised and which
|
||||||
// won't. This way, the user can specify which columns are to be received.
|
// won't. This way, the user can specify which columns are to be received.
|
||||||
objectMapper.addMixIn(DataEvent.class, PropertyFilterMixin.class);
|
objectMapper.addMixIn(DataEvent.class, PropertyFilterMixin.class);
|
||||||
objectMapper.addMixIn(StorelessStatistics.class, PropertyFilterMixin.class);
|
objectMapper.addMixIn(Statistics.class, PropertyFilterMixin.class);
|
||||||
objectMapper.addMixIn(EnumMap.class, PropertyFilterMixin.class);
|
objectMapper.addMixIn(EnumMap.class, PropertyFilterMixin.class);
|
||||||
|
|
||||||
objectMapper.addMixIn(Response.class, PolymorphicResponseMixIn.class);
|
objectMapper.addMixIn(Response.class, PolymorphicResponseMixIn.class);
|
||||||
|
@ -582,10 +582,17 @@ public class QueryRestControllerJsonTest extends AbstractDaqRestTest {
|
|||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[0].globalSeconds").value(
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[0].globalSeconds").value(
|
||||||
TestTimeUtils.getTimeStr(1, 0)))
|
TestTimeUtils.getTimeStr(1, 0)))
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[0].eventCount").value(5))
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[0].eventCount").value(5))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[0].value.min").value(100.0))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[0].value.mean").value(102.0))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[0].value.max").value(104.0))
|
||||||
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[1].pulseId").value(105))
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[1].pulseId").value(105))
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[1].globalSeconds").value(
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[1].globalSeconds").value(
|
||||||
TestTimeUtils.getTimeStr(1, 50000000)))
|
TestTimeUtils.getTimeStr(1, 50000000)))
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[1].eventCount").value(5));
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[1].eventCount").value(5))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[1].value.min").value(105.0))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[1].value.mean").value(107.0))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[1].value.max").value(109.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -623,42 +630,81 @@ public class QueryRestControllerJsonTest extends AbstractDaqRestTest {
|
|||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[0].globalSeconds").value(
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[0].globalSeconds").value(
|
||||||
TestTimeUtils.getTimeStr(10, 0)))
|
TestTimeUtils.getTimeStr(10, 0)))
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[0].eventCount").value(10))
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[0].eventCount").value(10))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[0].value.min").value(1000.0))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[0].value.mean").value(1004.5))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[0].value.max").value(1009.0))
|
||||||
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[1].pulseId").value(1010))
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[1].pulseId").value(1010))
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[1].globalSeconds").value(
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[1].globalSeconds").value(
|
||||||
TestTimeUtils.getTimeStr(10, 100000000)))
|
TestTimeUtils.getTimeStr(10, 100000000)))
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[1].eventCount").value(10))
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[1].eventCount").value(10))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[1].value.min").value(1010.0))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[1].value.mean").value(1014.5))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[1].value.max").value(1019.0))
|
||||||
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[2].pulseId").value(1020))
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[2].pulseId").value(1020))
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[2].globalSeconds").value(
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[2].globalSeconds").value(
|
||||||
TestTimeUtils.getTimeStr(10, 200000000)))
|
TestTimeUtils.getTimeStr(10, 200000000)))
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[2].eventCount").value(10))
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[2].eventCount").value(10))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[2].value.min").value(1020.0))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[2].value.mean").value(1024.5))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[2].value.max").value(1029.0))
|
||||||
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[3].pulseId").value(1030))
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[3].pulseId").value(1030))
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[3].globalSeconds").value(
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[3].globalSeconds").value(
|
||||||
TestTimeUtils.getTimeStr(10, 300000000)))
|
TestTimeUtils.getTimeStr(10, 300000000)))
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[3].eventCount").value(10))
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[3].eventCount").value(10))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[3].value.min").value(1030.0))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[3].value.mean").value(1034.5))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[3].value.max").value(1039.0))
|
||||||
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[4].pulseId").value(1040))
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[4].pulseId").value(1040))
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[4].globalSeconds").value(
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[4].globalSeconds").value(
|
||||||
TestTimeUtils.getTimeStr(10, 400000000)))
|
TestTimeUtils.getTimeStr(10, 400000000)))
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[4].eventCount").value(10))
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[4].eventCount").value(10))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[4].value.min").value(1040.0))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[4].value.mean").value(1044.5))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[4].value.max").value(1049.0))
|
||||||
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[5].pulseId").value(1050))
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[5].pulseId").value(1050))
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[5].globalSeconds").value(
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[5].globalSeconds").value(
|
||||||
TestTimeUtils.getTimeStr(10, 500000000)))
|
TestTimeUtils.getTimeStr(10, 500000000)))
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[5].eventCount").value(10))
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[5].eventCount").value(10))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[5].value.min").value(1050.0))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[5].value.mean").value(1054.5))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[5].value.max").value(1059.0))
|
||||||
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[6].pulseId").value(1060))
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[6].pulseId").value(1060))
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[6].globalSeconds").value(
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[6].globalSeconds").value(
|
||||||
TestTimeUtils.getTimeStr(10, 600000000)))
|
TestTimeUtils.getTimeStr(10, 600000000)))
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[6].eventCount").value(10))
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[6].eventCount").value(10))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[6].value.min").value(1060.0))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[6].value.mean").value(1064.5))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[6].value.max").value(1069.0))
|
||||||
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[7].pulseId").value(1070))
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[7].pulseId").value(1070))
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[7].globalSeconds").value(
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[7].globalSeconds").value(
|
||||||
TestTimeUtils.getTimeStr(10, 700000000)))
|
TestTimeUtils.getTimeStr(10, 700000000)))
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[7].eventCount").value(10))
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[7].eventCount").value(10))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[7].value.min").value(1070.0))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[7].value.mean").value(1074.5))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[7].value.max").value(1079.0))
|
||||||
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[8].pulseId").value(1080))
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[8].pulseId").value(1080))
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[8].globalSeconds").value(
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[8].globalSeconds").value(
|
||||||
TestTimeUtils.getTimeStr(10, 800000000)))
|
TestTimeUtils.getTimeStr(10, 800000000)))
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[8].eventCount").value(10))
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[8].eventCount").value(10))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[8].value.min").value(1080.0))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[8].value.mean").value(1084.5))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[8].value.max").value(1089.0))
|
||||||
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[9].pulseId").value(1090))
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[9].pulseId").value(1090))
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[9].globalSeconds").value(
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[9].globalSeconds").value(
|
||||||
TestTimeUtils.getTimeStr(10, 900000000)))
|
TestTimeUtils.getTimeStr(10, 900000000)))
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[9].eventCount").value(10));
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[9].eventCount").value(10))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[9].value.min").value(1090.0))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[9].value.mean").value(1094.5))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[9].value.max").value(1099.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -704,14 +750,14 @@ public class QueryRestControllerJsonTest extends AbstractDaqRestTest {
|
|||||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||||
.andExpect(MockMvcResultMatchers.header().string("Content-Disposition", "attachment; filename=data.json"));
|
.andExpect(MockMvcResultMatchers.header().string("Content-Disposition", "attachment; filename=data.json"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBadAggregation_01() throws Exception {
|
public void testBadAggregation_01() throws Exception {
|
||||||
DAQQuery request = new DAQQuery(
|
DAQQuery request = new DAQQuery(
|
||||||
new RequestRangePulseId(
|
new RequestRangePulseId(
|
||||||
10,
|
10,
|
||||||
11),
|
11),
|
||||||
new AggregationDescriptor().setDurationPerBin(1000),
|
new AggregationDescriptor().setDurationPerBin(1000),
|
||||||
TEST_CHANNEL_NAMES);
|
TEST_CHANNEL_NAMES);
|
||||||
|
|
||||||
String content = mapper.writeValueAsString(request);
|
String content = mapper.writeValueAsString(request);
|
||||||
@ -726,14 +772,14 @@ public class QueryRestControllerJsonTest extends AbstractDaqRestTest {
|
|||||||
.andDo(MockMvcResultHandlers.print())
|
.andDo(MockMvcResultHandlers.print())
|
||||||
.andExpect(MockMvcResultMatchers.status().isBadRequest());
|
.andExpect(MockMvcResultMatchers.status().isBadRequest());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBadAggregation_02() throws Exception {
|
public void testBadAggregation_02() throws Exception {
|
||||||
DAQQuery request = new DAQQuery(
|
DAQQuery request = new DAQQuery(
|
||||||
new RequestRangeTime(
|
new RequestRangeTime(
|
||||||
TimeUtils.getTimeFromMillis(0, 0),
|
TimeUtils.getTimeFromMillis(0, 0),
|
||||||
TimeUtils.getTimeFromMillis(10, 0)),
|
TimeUtils.getTimeFromMillis(10, 0)),
|
||||||
new AggregationDescriptor().setPulsesPerBin(100),
|
new AggregationDescriptor().setPulsesPerBin(100),
|
||||||
TEST_CHANNEL_NAMES);
|
TEST_CHANNEL_NAMES);
|
||||||
|
|
||||||
String content = mapper.writeValueAsString(request);
|
String content = mapper.writeValueAsString(request);
|
||||||
@ -748,14 +794,14 @@ public class QueryRestControllerJsonTest extends AbstractDaqRestTest {
|
|||||||
.andDo(MockMvcResultHandlers.print())
|
.andDo(MockMvcResultHandlers.print())
|
||||||
.andExpect(MockMvcResultMatchers.status().isBadRequest());
|
.andExpect(MockMvcResultMatchers.status().isBadRequest());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBadAggregation_03() throws Exception {
|
public void testBadAggregation_03() throws Exception {
|
||||||
DAQQuery request = new DAQQuery(
|
DAQQuery request = new DAQQuery(
|
||||||
new RequestRangePulseId(
|
new RequestRangePulseId(
|
||||||
10,
|
10,
|
||||||
11),
|
11),
|
||||||
new AggregationDescriptor().setDurationPerBin(1000).setNrOfBins(100),
|
new AggregationDescriptor().setDurationPerBin(1000).setNrOfBins(100),
|
||||||
TEST_CHANNEL_NAMES);
|
TEST_CHANNEL_NAMES);
|
||||||
|
|
||||||
String content = mapper.writeValueAsString(request);
|
String content = mapper.writeValueAsString(request);
|
||||||
|
Reference in New Issue
Block a user