Remove renamed test.
This commit is contained in:
@ -1,210 +0,0 @@
|
|||||||
package ch.psi.daq.test.queryrest.controller;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
|
||||||
import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
|
|
||||||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
|
|
||||||
|
|
||||||
import ch.psi.daq.cassandra.request.range.RequestRangeDate;
|
|
||||||
import ch.psi.daq.cassandra.request.range.RequestRangePulseId;
|
|
||||||
import ch.psi.daq.cassandra.request.range.RequestRangeTime;
|
|
||||||
import ch.psi.daq.cassandra.util.test.CassandraDataGen;
|
|
||||||
import ch.psi.daq.common.ordering.Ordering;
|
|
||||||
import ch.psi.daq.query.model.AggregationType;
|
|
||||||
import ch.psi.daq.query.model.Query;
|
|
||||||
import ch.psi.daq.query.model.impl.DAQQuery;
|
|
||||||
import ch.psi.daq.queryrest.controller.QueryRestController;
|
|
||||||
import ch.psi.daq.test.cassandra.admin.CassandraTestAdmin;
|
|
||||||
import ch.psi.daq.test.queryrest.AbstractDaqRestTest;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests the {@link DaqController} implementation.
|
|
||||||
*/
|
|
||||||
public class DaqRestControllerTest extends AbstractDaqRestTest {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private CassandraTestAdmin cassandraTestAdmin;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private CassandraDataGen dataGen;
|
|
||||||
|
|
||||||
private static final boolean initialized = false;
|
|
||||||
|
|
||||||
private static final int DATA_KEYSPACE = 1;
|
|
||||||
public static final String[] TEST_CHANNEL_NAMES = new String[] {"testChannel1", "testChannel2"};
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() throws Exception {
|
|
||||||
if (!initialized) {
|
|
||||||
cassandraTestAdmin.truncateAll();
|
|
||||||
|
|
||||||
dataGen.writeData(DATA_KEYSPACE, 100, 2, TEST_CHANNEL_NAMES);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@After
|
|
||||||
public void tearDown() throws Exception {}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testChannelNameQuery() throws Exception {
|
|
||||||
|
|
||||||
this.mockMvc.perform(
|
|
||||||
MockMvcRequestBuilders
|
|
||||||
.get(QueryRestController.CHANNELS)
|
|
||||||
.contentType(MediaType.APPLICATION_JSON))
|
|
||||||
.andDo(MockMvcResultHandlers.print())
|
|
||||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$").isArray())
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0]").exists())
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0]").value("testChannel1"))
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[1]").exists())
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[1]").value("testChannel2"))
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[2]").doesNotExist());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testPulseRangeQuery() throws Exception {
|
|
||||||
Query request = new DAQQuery(
|
|
||||||
new RequestRangePulseId(
|
|
||||||
100,
|
|
||||||
101),
|
|
||||||
TEST_CHANNEL_NAMES);
|
|
||||||
|
|
||||||
String content = mapper.writeValueAsString(request);
|
|
||||||
System.out.println(content);
|
|
||||||
|
|
||||||
content = "{\"channels\":[\"testChannel1\",\"testChannel2\"],\"startPulseId\":100,\"endPulseId\":101}";
|
|
||||||
|
|
||||||
this.mockMvc
|
|
||||||
.perform(MockMvcRequestBuilders
|
|
||||||
.post(QueryRestController.QUERY)
|
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
|
||||||
.content(content))
|
|
||||||
|
|
||||||
.andDo(MockMvcResultHandlers.print())
|
|
||||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$").isArray())
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0]").exists())
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].channel").value("testChannel1"))
|
|
||||||
.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].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 {
|
|
||||||
Query request = new DAQQuery(
|
|
||||||
new RequestRangeTime(
|
|
||||||
100,
|
|
||||||
101),
|
|
||||||
TEST_CHANNEL_NAMES);
|
|
||||||
|
|
||||||
String content = mapper.writeValueAsString(request);
|
|
||||||
|
|
||||||
this.mockMvc.perform(MockMvcRequestBuilders
|
|
||||||
.post(QueryRestController.QUERY)
|
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
|
||||||
.content(content))
|
|
||||||
|
|
||||||
.andDo(MockMvcResultHandlers.print())
|
|
||||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$").isArray())
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0]").exists())
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].channel").value("testChannel1"))
|
|
||||||
.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].data").isArray())
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[1].data[0].pulseId").value(100))
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[1].data[1].pulseId").value(101));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDateRangeQuery() throws Exception {
|
|
||||||
String startDate = RequestRangeDate.format(100);
|
|
||||||
String endDate = RequestRangeDate.format(101);
|
|
||||||
Query request = new DAQQuery(
|
|
||||||
new RequestRangeDate(
|
|
||||||
startDate,
|
|
||||||
endDate),
|
|
||||||
TEST_CHANNEL_NAMES);
|
|
||||||
|
|
||||||
String content = mapper.writeValueAsString(request);
|
|
||||||
System.out.println(content);
|
|
||||||
|
|
||||||
this.mockMvc
|
|
||||||
.perform(
|
|
||||||
MockMvcRequestBuilders
|
|
||||||
.post(QueryRestController.QUERY)
|
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
|
||||||
.content(content)
|
|
||||||
)
|
|
||||||
.andDo(MockMvcResultHandlers.print())
|
|
||||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$").isArray())
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0]").exists())
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].channel").value("testChannel1"))
|
|
||||||
.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].data").isArray())
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[1].data[0].pulseId").value(100))
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[1].data[1].pulseId").value(101));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testExtremaAggregation() throws Exception {
|
|
||||||
Query request = new DAQQuery(
|
|
||||||
new RequestRangePulseId(
|
|
||||||
100,
|
|
||||||
101),
|
|
||||||
false,
|
|
||||||
Ordering.asc,
|
|
||||||
AggregationType.extrema,
|
|
||||||
TEST_CHANNEL_NAMES[0]);
|
|
||||||
|
|
||||||
String content = mapper.writeValueAsString(request);
|
|
||||||
|
|
||||||
this.mockMvc
|
|
||||||
.perform(MockMvcRequestBuilders.post(QueryRestController.QUERY)
|
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
|
||||||
.content(content))
|
|
||||||
|
|
||||||
.andDo(MockMvcResultHandlers.print())
|
|
||||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
|
||||||
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$").exists())
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$.minima").exists())
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$.minima.min").exists())
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$.minima.min.value").exists())
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$.minima.min.value").value(100))
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$.minima.min.event").exists())
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$.minima.min.event.channel").exists())
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$.minima.min.event.channel").value(TEST_CHANNEL_NAMES[0]))
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$.minima.min.event.pulseId").exists())
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$.minima.min.event.pulseId").value(100))
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$.maxima").exists())
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$.minima.max").exists())
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$.minima.max.value").exists())
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$.minima.max.value").value(101))
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$.minima.max.event").exists())
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$.minima.max.event.channel").exists())
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$.minima.max.event.channel").value(TEST_CHANNEL_NAMES[0]))
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$.minima.max.event.pulseId").exists())
|
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$.minima.max.event.pulseId").value(101));
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user