Skip to content

Update datastore test #242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ public void testAddAndGetByKeyOneDataStream() throws Exception
public void testGetWrongKey() throws Exception
{
testGetNumRecordsOneDataStream();
assertNull(cmdStore.get(bigId(11)));
assertNull(cmdStore.get(bigId(110)));
}


Expand Down Expand Up @@ -556,7 +556,6 @@ public void testSelectCommandsByDataStreamIDAndTime() throws Exception
checkSelectedEntries(resultStream, Collections.emptyMap(), filter);
}


@Test
public void testSelectCommandsByDataStreamIDAndPredicates() throws Exception
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,33 @@ protected CommandStreamKey addSimpleCommandStream(SystemId sysID, String outputN

return addCommandStream(sysID, dataStruct, validTime);
}



protected CommandStreamKey addSimpleCommandStream(SystemId sysID, String outputName, String description, TimeExtent validTime, String definition) throws DataStoreException
{
SWEHelper fac = new SWEHelper();
var dataStruct = fac.createRecord()
.name(outputName)
.description(description)
.addField("t1", fac.createTime().asSamplingTimeIsoUTC().build())
.addField("q2", fac.createQuantity().build())
.addField("c3", fac.createCount().build())
.addField("b4", fac.createVector().definition(definition).build())
.addField("txt5", fac.createText().build())
.build();

return addCommandStream(sysID, dataStruct, validTime);
}

protected CommandStreamKey addSimpleCommandStream(BigId sysID, String outputName, TimeExtent validTime) throws DataStoreException
{
return addSimpleCommandStream(new SystemId(sysID, PROC_UID_PREFIX+sysID), outputName, "command stream description", validTime);
}



protected CommandStreamKey addSimpleCommandStreamWithDefinition(BigId sysID, String outputName, TimeExtent validTime, String definition) throws DataStoreException
{
return addSimpleCommandStream(new SystemId(sysID, PROC_UID_PREFIX+sysID), outputName, "command stream description", validTime, definition);
}

protected CommandStreamKey addSimpleCommandStream(BigId sysID, String outputName, String description, TimeExtent validTime) throws DataStoreException
{
return addSimpleCommandStream(new SystemId(sysID, PROC_UID_PREFIX+sysID), outputName, description, validTime);
Expand Down Expand Up @@ -620,13 +639,46 @@ public void testAddAndSelectBySystemID() throws Exception
testAddAndSelectBySystemID_ExpectedResults();
checkSelectedEntries(resultStream, expectedResults, filter);
}




@Test
@SuppressWarnings("unused")
public void testAddAndSelectByTaskableProperty() throws Exception
{
Stream<Entry<CommandStreamKey, ICommandStreamInfo>> resultStream;

var now = Instant.now().truncatedTo(ChronoUnit.SECONDS);
var sysID1 = bigId(1);
var sysID2 = bigId(2);
var sysID3 = bigId(3);
var ds1v0 = addSimpleCommandStreamWithDefinition(sysID1, "out1",
TimeExtent.endNow(now.minus(365, ChronoUnit.DAYS)),"someDefinition1");
var ds2v0 = addSimpleCommandStream(sysID1, "out2", TimeExtent.endNow(now.minus(60, ChronoUnit.DAYS)));
var ds4v0 = addSimpleCommandStreamWithDefinition(sysID3, "temp",
TimeExtent.beginAt(now.plus(1, ChronoUnit.DAYS)),"someDefinition2");
var ds5v0 = addSimpleCommandStream(sysID3, "out3", TimeExtent.endNow(now.minus(60, ChronoUnit.DAYS)));
var ds6v0 = addSimpleCommandStream(sysID3, "out4", TimeExtent.endNow(now.minus(60, ChronoUnit.DAYS)));
cmdStreamStore.commit();

// select from t0 to now
CommandStreamFilter filter = new CommandStreamFilter.Builder()
.withTaskableProperties("someDefinition1","someDefinition2")
.build();
resultStream = cmdStreamStore.selectEntries(filter);

testAddAndSelectByTaskableProperty_ExpectedResults();
checkSelectedEntries(resultStream, expectedResults, filter);
}

protected void testAddAndSelectBySystemID_ExpectedResults()
{
addToExpectedResults(3, 4, 5);
}


protected void testAddAndSelectByTaskableProperty_ExpectedResults()
{
addToExpectedResults(0, 2);
}

@Test
@SuppressWarnings("unused")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,23 @@ protected void addToExpectedResults(int... entryIdxList)
}


protected DataStreamKey addSimpleDataStreamWithDefinition(SystemId sysID, String outputName, String description, TimeExtent validTime, String definition) throws DataStoreException
{
SWEHelper fac = new SWEHelper();
var dataStruct = fac.createRecord()
.name(outputName)
.description(description)
.addField("t1", fac.createTime().asSamplingTimeIsoUTC().build())
.addField("q2", fac.createQuantity().build())
.addField("c3", fac.createCount().build())
.addField("b4", fac.createBoolean().build())
.addField("def", fac.createVector().definition(definition))
.addField("txt5", fac.createText().build())
.build();

return addDataStream(sysID, dataStruct, validTime);
}

protected DataStreamKey addSimpleDataStream(SystemId sysID, String outputName, String description, TimeExtent validTime) throws DataStoreException
{
SWEHelper fac = new SWEHelper();
Expand All @@ -126,17 +143,21 @@ protected DataStreamKey addSimpleDataStream(SystemId sysID, String outputName, S

return addDataStream(sysID, dataStruct, validTime);
}


protected DataStreamKey addSimpleDataStreamWithDefinition(BigId sysID, String outputName, TimeExtent validTime, String definition) throws DataStoreException
{
return addSimpleDataStreamWithDefinition(new SystemId(sysID, PROC_UID_PREFIX+sysID.getIdAsLong()), outputName, "datastream description", validTime, definition);
}

protected DataStreamKey addSimpleDataStream(BigId sysID, String outputName, TimeExtent validTime) throws DataStoreException
{
return addSimpleDataStream(new SystemId(sysID, PROC_UID_PREFIX+sysID), outputName, "datastream description", validTime);
return addSimpleDataStream(new SystemId(sysID, PROC_UID_PREFIX+sysID.getScope()+sysID.getIdAsLong()), outputName, "datastream description", validTime);
}


protected DataStreamKey addSimpleDataStream(BigId sysID, String outputName, String description, TimeExtent validTime) throws DataStoreException
{
return addSimpleDataStream(new SystemId(sysID, PROC_UID_PREFIX+sysID), outputName, description, validTime);
return addSimpleDataStream(new SystemId(sysID, PROC_UID_PREFIX+sysID.getScope()+sysID.getIdAsLong()), outputName, description, validTime);
}


Expand Down Expand Up @@ -633,13 +654,43 @@ public void testAddAndSelectBySystemID() throws Exception
testAddAndSelectBySystemID_ExpectedResults();
checkSelectedEntries(resultStream, expectedResults, filter);
}



@Test
@SuppressWarnings("unused")
public void testAddAndSelectByObservedProperty() throws Exception
{
Stream<Entry<DataStreamKey, IDataStreamInfo>> resultStream;

var now = Instant.now().truncatedTo(ChronoUnit.SECONDS);
var sysID1 = bigId(1);
var sysID2 = bigId(2);
var sysID3 = bigId(3);
var ds1v0 = addSimpleDataStreamWithDefinition(sysID1, "out1", TimeExtent.endNow(now.minus(365, ChronoUnit.DAYS)),"http://sensorml.com/ont/swe/property/Location");
var ds2v0 = addSimpleDataStream(sysID1, "out2", TimeExtent.endNow(now.minus(60, ChronoUnit.DAYS)));
var ds4v0 = addSimpleDataStreamWithDefinition(sysID3, "temp", TimeExtent.beginAt(now.plus(1, ChronoUnit.DAYS)), "http://sensorml.com/ont/swe/property/GeodeticLatitude");
var ds6v0 = addSimpleDataStream(sysID3, "out3", TimeExtent.endNow(now.minus(60, ChronoUnit.DAYS)));
var ds7v0 = addSimpleDataStream(sysID3, "out4", TimeExtent.endNow(now.minus(60, ChronoUnit.DAYS)));
dataStreamStore.commit();

// select from t0 to now
DataStreamFilter filter = new DataStreamFilter.Builder()
.withObservedProperties("http://sensorml.com/ont/swe/property/Location","http://sensorml.com/ont/swe/property/GeodeticLatitude")
.build();
resultStream = dataStreamStore.selectEntries(filter);

testAddAndSelectByObservedProperty_ExpectedResults();
checkSelectedEntries(resultStream, expectedResults, filter);
}

protected void testAddAndSelectBySystemID_ExpectedResults()
{
addToExpectedResults(3, 4, 5);
}


protected void testAddAndSelectByObservedProperty_ExpectedResults()
{
addToExpectedResults(0, 2);
}

@Test
@SuppressWarnings("unused")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,9 @@ public void testSpatialFilterThroughput() throws Exception

int numFeatures = 100000;
addSamplingPoints2D(0, numFeatures);


featureStore.commit();

// spatial filter with all features
FeatureFilter filter = new FeatureFilter.Builder()
.withLocationWithin(featureStore.getFeaturesBbox())
Expand Down Expand Up @@ -1388,7 +1390,8 @@ public void testErrorAddWithExistingUID() throws Exception
public void testErrorAddWithInvalidParent() throws Exception
{
useAdd = true;
addNonGeoFeatures(bigId(10L), 1, 2);
addNonGeoFeatures(bigId(11000L), 1, 2);
featureStore.commit();
}


Expand Down
Loading