use of org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime in project geoprism-registry by terraframe.
the class GeoObjectOverTimeServiceTest method testCreateGeoObjectOverTimeBadGeometry.
@Test
public void testCreateGeoObjectOverTimeBadGeometry() {
GeometryBuilder builder = new GeometryBuilder(new GeometryFactory());
Point point = builder.point(48.44, -123.37);
GeoObjectOverTime geoObj = TEST_GO.newGeoObjectOverTime(testData.adapter);
geoObj.setGeometry(point, TestDataSet.DEFAULT_OVER_TIME_DATE, TestDataSet.DEFAULT_OVER_TIME_DATE);
try {
testData.adapter.createGeoObjectOverTime(geoObj.toJSON().toString());
Assert.fail("Able to create a GeoObject with a wrong geometry type");
} catch (SmartExceptionDTO e) {
// This is expected
Assert.assertEquals(GeometryTypeException.CLASS, e.getType());
}
}
use of org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime in project geoprism-registry by terraframe.
the class GeoObjectOverTimeServiceTest method testGetGeoObjectOverTime.
@Test
public void testGetGeoObjectOverTime() {
// Allowed Users
TestUserInfo[] allowedUsers = new TestUserInfo[] { FastTestDataset.USER_CGOV_RA, FastTestDataset.USER_CGOV_RM, FastTestDataset.USER_CGOV_RC, FastTestDataset.USER_CGOV_AC };
for (TestUserInfo user : allowedUsers) {
FastTestDataset.runAsUser(user, (request, adapter) -> {
GeoObjectOverTime geoObj = adapter.getGeoObjectOverTime(FastTestDataset.CAMBODIA.getRegistryId(), FastTestDataset.CAMBODIA.getGeoObjectType().getCode());
FastTestDataset.CAMBODIA.assertEquals(geoObj);
});
}
}
use of org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime in project geoprism-registry by terraframe.
the class GovernanceTest method testActionSerialization.
/**
* Tests serialization on the DTOs and also conversion to/from DTO
*/
@Test
public void testActionSerialization() {
TestGeoObjectInfo testGo = FastTestDataset.CAMBODIA;
// GeoObjectOverTime go = testGo.asGeoObject();
GeoObjectOverTime goTime = testData.adapter.getGeoObjectOverTimeByCode(FastTestDataset.CAMBODIA.getCode(), FastTestDataset.CAMBODIA.getGeoObjectType().getCode());
testGo.setRegistryId(goTime.getUid());
/*
* UpdateGeoObject
*/
UpdateGeoObjectActionDTO updateDTO = new UpdateGeoObjectActionDTO();
updateDTO.setGeoObject(goTime.toJSON());
updateDTO.setCreateActionDate(Date.from(Instant.now().minus(6, ChronoUnit.HOURS)));
updateDTO.setContributorNotes("UPDATE_CONTRIB_NOTES");
updateDTO.setMaintainerNotes("UPDATE_MAINTAIN_NOTES");
String updateJson = updateDTO.toJSON().toString();
String updateJson2 = AbstractActionDTO.parseAction(updateJson).toJSON().toString();
Assert.assertEquals(updateJson, updateJson2);
UpdateGeoObjectAction updateRA = (UpdateGeoObjectAction) AbstractAction.dtoToRegistry(updateDTO);
GeoObjectOverTime updateRAGO = GeoObjectOverTime.fromJSON(testData.adapter, updateRA.getGeoObjectJson());
// testGo.assertEquals(updateRAGO);
Assert.assertEquals(updateDTO.getContributorNotes(), updateRA.getContributorNotes());
Assert.assertEquals(updateDTO.getMaintainerNotes(), updateRA.getMaintainerNotes());
Assert.assertEquals(updateDTO.getApiVersion(), updateRA.getApiVersion());
// Assert.assertEquals(updateDTO.getCreateActionDate().getTime(),
// updateRA.getCreateActionDate().getTime()); // TODO : Runway dates are
// accurate to the second, but epoch is accurate to the milisecond.
/*
* TODO : The rest of the supported actions
*/
}
use of org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime in project geoprism-registry by terraframe.
the class GovernanceTest method testUpdateAction.
@Test
public void testUpdateAction() {
Date startDate = new Date();
Date endDate = new Date();
GeoObjectOverTime goTime = testData.adapter.getGeoObjectOverTimeByCode(FastTestDataset.CAMBODIA.getCode(), FastTestDataset.CAMBODIA.getGeoObjectType().getCode());
goTime.setDisplayLabel(new LocalizedValue("test 123"), startDate, endDate);
UpdateGeoObjectActionDTO updateDTO = new UpdateGeoObjectActionDTO();
updateDTO.setGeoObject(goTime.toJSON());
updateDTO.setCreateActionDate(Date.from(Instant.now().minus(6, ChronoUnit.HOURS)));
updateDTO.setContributorNotes("UPDATE_CONTRIB_NOTES");
updateDTO.setMaintainerNotes("UPDATE_MAINTAIN_NOTES");
UpdateGeoObjectAction updateRA = (UpdateGeoObjectAction) AbstractAction.dtoToRegistry(updateDTO);
execute(updateRA);
GeoObjectOverTime goTime2 = testData.adapter.getGeoObjectOverTimeByCode(FastTestDataset.CAMBODIA.getCode(), FastTestDataset.CAMBODIA.getGeoObjectType().getCode());
Assert.assertEquals("test 123", goTime2.getDisplayLabel(startDate).getValue());
}
use of org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime in project geoprism-registry by terraframe.
the class RegistryVersionTest method genericDuplicateDatatypeTest.
private void genericDuplicateDatatypeTest(String attributeName, Object value) throws ParseException {
final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
dateFormat.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
// Initial Setup : Create a VOT with a large date range
VertexServerGeoObject serverObj = (VertexServerGeoObject) FastTestDataset.PROV_CENTRAL.getServerObject();
serverObj.getValuesOverTime(attributeName).clear();
serverObj.setValue(attributeName, value, dateFormat.parse("1990-01-01"), dateFormat.parse("1990-02-01"));
serverObj.apply(false);
Assert.assertEquals(1, FastTestDataset.PROV_CENTRAL.getServerObject().getValuesOverTime(attributeName).size());
// Set a value inside that date range with the same value
VertexServerGeoObject serverObj2 = (VertexServerGeoObject) FastTestDataset.PROV_CENTRAL.getServerObject();
serverObj2.setValue(attributeName, value, dateFormat.parse("1990-01-05"), dateFormat.parse("1990-01-10"));
serverObj2.apply(false);
// Fetch the object and assert values on it
Assert.assertEquals(1, FastTestDataset.PROV_CENTRAL.getServerObject().getValuesOverTime(attributeName).size());
GeoObjectOverTime goTime = testData.adapter.getGeoObjectOverTimeByCode(FastTestDataset.PROV_CENTRAL.getCode(), FastTestDataset.PROV_CENTRAL.getGeoObjectType().getCode());
Assert.assertEquals(1, goTime.getAllValues(attributeName).size());
ValueOverTimeCollectionDTO all = goTime.getAllValues(attributeName);
Assert.assertEquals("1990-01-01", dateFormat.format(all.get(0).getStartDate()));
Assert.assertEquals("1990-02-01", dateFormat.format(all.get(0).getEndDate()));
Assert.assertTrue(value.equals(all.get(0).getValue()));
}
Aggregations