ATEST-827: adding test case

This commit is contained in:
Christof Zellweger
2017-10-09 10:09:10 +02:00
parent 73863224b1
commit cbecaa7198

View File

@@ -19,8 +19,11 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import ch.psi.daq.domain.backend.Backend;
import ch.psi.daq.domain.config.DomainConfig;
import ch.psi.daq.domain.query.DAQQuery;
import ch.psi.daq.domain.query.operation.Aggregation;
import ch.psi.daq.domain.query.operation.AggregationDescriptor;
import ch.psi.daq.domain.query.operation.Compression;
import ch.psi.daq.domain.query.response.Response;
import ch.psi.daq.domain.request.range.RequestRangeDate;
import ch.psi.daq.domain.request.range.RequestRangePulseId;
import ch.psi.daq.queryrest.response.csv.CSVHTTPResponse;
import ch.psi.daq.queryrest.response.json.JSONHTTPResponse;
@@ -71,6 +74,26 @@ public class ResponseQueryTest extends AbstractDaqRestTest{
assertEquals(query.getResponse().getCompression().getFileSuffix(), deserial.getResponse().getFileSuffix());
}
@Test
public void test_JSON_02_01() throws JsonParseException, JsonMappingException, IOException {
DAQQuery query = new DAQQuery(
new RequestRangeDate(
"2017-09-25T19:00:05.319+02:00",
"2017-09-25T19:03:05.319+02:00"),
new AggregationDescriptor().setDurationPerBin(100),
"TestChannel_01");
query.setResponse(new CSVHTTPResponse(Compression.GZIP));
// String value = mapper.writeValueAsString(query);
String value = "{\"channels\":[{\"backend\":\"queryrest-1\",\"name\":\"TestChannel_01\"}],\"fields\":[\"globalMillis\",\"globalDate\",\"value\",\"shape\",\"eventCount\"],\"range\":{\"startDate\":\"2017-09-25T19:02:57.318+02:00\",\"endDate\":\"2017-09-25T19:03:05.319+02:00\"},\"aggregation\":{\"durationPerBin\":\"PT15M\"},\"response\":{\"format\":\"csv\",\"compression\":\"none\"}}";
// System.out.println(value);
DAQQuery deserial = mapper.readValue(value, DAQQuery.class);
assertNotNull(deserial.getResponse());
assertEquals(query.getResponse().getClass(), deserial.getResponse().getClass());
assertEquals(query.getResponse().getCompression(), deserial.getResponse().getCompression());
}
@Test
public void test_JSON_03() throws JsonParseException, JsonMappingException, IOException {
DAQQuery query = new DAQQuery(
@@ -112,4 +135,6 @@ public class ResponseQueryTest extends AbstractDaqRestTest{
assertNull(deserial.getResponse());
}
}