For readme.

This commit is contained in:
Fabian Märki
2015-07-24 17:51:12 +02:00
parent 689622be07
commit ea7ebbabbe
3 changed files with 168 additions and 23 deletions

View File

@ -111,7 +111,7 @@ public class ResponseStreamWriter {
try {
generator.writeStartObject();
generator.writeStringField(QueryField.channel.name(), entry.getKey());
generator.writeArrayFieldStart("values");
generator.writeArrayFieldStart("data");
entry.getValue()
/* ensure elements are sequentially written to the stream */
.sequential()

View File

@ -10,6 +10,7 @@ import ch.psi.daq.query.model.PulseRangeQuery;
import ch.psi.daq.query.model.TimeRangeQuery;
import ch.psi.daq.query.model.TimeRangeQueryDate;
import ch.psi.daq.test.queryrest.AbstractDaqRestTest;
import ch.psi.daq.test.queryrest.query.DummyQueryProcessor;
/**
* Tests the {@link DaqController} implementation.
@ -20,8 +21,8 @@ public class DaqRestControllerTest extends AbstractDaqRestTest {
public void testPulseRangeQuery() throws Exception {
PulseRangeQuery request = new PulseRangeQuery(
100,
101
);
101,
DummyQueryProcessor.TEST_CHANNEL_NAMES);
String content = mapper.writeValueAsString(request);
@ -35,21 +36,22 @@ public class DaqRestControllerTest extends AbstractDaqRestTest {
.andExpect(MockMvcResultMatchers.jsonPath("$").isArray())
.andExpect(MockMvcResultMatchers.jsonPath("$[0]").exists())
.andExpect(MockMvcResultMatchers.jsonPath("$[0].channel").value("testChannel1"))
.andExpect(MockMvcResultMatchers.jsonPath("$[0].values").isArray())
.andExpect(MockMvcResultMatchers.jsonPath("$[0].values[0].pulseId").value(100))
.andExpect(MockMvcResultMatchers.jsonPath("$[0].values[1].pulseId").value(101))
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data").isArray())
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[0].pulseId").value(100))
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[1].pulseId").value(101))
.andExpect(MockMvcResultMatchers.jsonPath("$[1]").exists())
.andExpect(MockMvcResultMatchers.jsonPath("$[1].channel").value("testChannel2"))
.andExpect(MockMvcResultMatchers.jsonPath("$[1].values").isArray())
.andExpect(MockMvcResultMatchers.jsonPath("$[1].values[0].pulseId").value(100))
.andExpect(MockMvcResultMatchers.jsonPath("$[1].values[1].pulseId").value(101));
.andExpect(MockMvcResultMatchers.jsonPath("$[1].data").isArray())
.andExpect(MockMvcResultMatchers.jsonPath("$[1].data[0].pulseId").value(100))
.andExpect(MockMvcResultMatchers.jsonPath("$[1].data[1].pulseId").value(101));
}
@Test
public void testTimeRangeQuery() throws Exception {
TimeRangeQuery request = new TimeRangeQuery(
100,
101);
101,
DummyQueryProcessor.TEST_CHANNEL_NAMES);
String content = mapper.writeValueAsString(request);
@ -63,14 +65,14 @@ public class DaqRestControllerTest extends AbstractDaqRestTest {
.andExpect(MockMvcResultMatchers.jsonPath("$").isArray())
.andExpect(MockMvcResultMatchers.jsonPath("$[0]").exists())
.andExpect(MockMvcResultMatchers.jsonPath("$[0].channel").value("testChannel1"))
.andExpect(MockMvcResultMatchers.jsonPath("$[0].values").isArray())
.andExpect(MockMvcResultMatchers.jsonPath("$[0].values[0].pulseId").value(100))
.andExpect(MockMvcResultMatchers.jsonPath("$[0].values[1].pulseId").value(101))
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data").isArray())
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[0].pulseId").value(100))
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[1].pulseId").value(101))
.andExpect(MockMvcResultMatchers.jsonPath("$[1]").exists())
.andExpect(MockMvcResultMatchers.jsonPath("$[1].channel").value("testChannel2"))
.andExpect(MockMvcResultMatchers.jsonPath("$[1].values").isArray())
.andExpect(MockMvcResultMatchers.jsonPath("$[1].values[0].pulseId").value(100))
.andExpect(MockMvcResultMatchers.jsonPath("$[1].values[1].pulseId").value(101));
.andExpect(MockMvcResultMatchers.jsonPath("$[1].data").isArray())
.andExpect(MockMvcResultMatchers.jsonPath("$[1].data[0].pulseId").value(100))
.andExpect(MockMvcResultMatchers.jsonPath("$[1].data[1].pulseId").value(101));
}
@Test
@ -79,7 +81,8 @@ public class DaqRestControllerTest extends AbstractDaqRestTest {
String endDate = TimeRangeQueryDate.format(101);
TimeRangeQueryDate request = new TimeRangeQueryDate(
startDate,
endDate);
endDate,
DummyQueryProcessor.TEST_CHANNEL_NAMES);
String content = mapper.writeValueAsString(request);
@ -93,13 +96,13 @@ public class DaqRestControllerTest extends AbstractDaqRestTest {
.andExpect(MockMvcResultMatchers.jsonPath("$").isArray())
.andExpect(MockMvcResultMatchers.jsonPath("$[0]").exists())
.andExpect(MockMvcResultMatchers.jsonPath("$[0].channel").value("testChannel1"))
.andExpect(MockMvcResultMatchers.jsonPath("$[0].values").isArray())
.andExpect(MockMvcResultMatchers.jsonPath("$[0].values[0].pulseId").value(100))
.andExpect(MockMvcResultMatchers.jsonPath("$[0].values[1].pulseId").value(101))
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data").isArray())
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[0].pulseId").value(100))
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[1].pulseId").value(101))
.andExpect(MockMvcResultMatchers.jsonPath("$[1]").exists())
.andExpect(MockMvcResultMatchers.jsonPath("$[1].channel").value("testChannel2"))
.andExpect(MockMvcResultMatchers.jsonPath("$[1].values").isArray())
.andExpect(MockMvcResultMatchers.jsonPath("$[1].values[0].pulseId").value(100))
.andExpect(MockMvcResultMatchers.jsonPath("$[1].values[1].pulseId").value(101));
.andExpect(MockMvcResultMatchers.jsonPath("$[1].data").isArray())
.andExpect(MockMvcResultMatchers.jsonPath("$[1].data[0].pulseId").value(100))
.andExpect(MockMvcResultMatchers.jsonPath("$[1].data[1].pulseId").value(101));
}
}