use of org.commongeoregistry.adapter.dataaccess.AttributeGeometry in project geoprism-registry by terraframe.
the class RegistryVersionTest method testInsertDuplicateBetween.
/**
* Tests to make sure if we set a value which is encompassed by a larger surrounding date range
* that the operation is ignored.
*/
@Test
public void testInsertDuplicateBetween() throws ParseException {
final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
dateFormat.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
this.addVersionData(FastTestDataset.PROV_CENTRAL);
Assert.assertEquals(3, FastTestDataset.PROV_CENTRAL.getServerObject().getValuesOverTime(DefaultAttribute.EXISTS.getName()).size());
FastTestDataset.PROV_CENTRAL.getServerObject().setExists(Boolean.TRUE, dateFormat.parse("02-10-1990"), dateFormat.parse("02-15-1990"));
Assert.assertEquals(3, FastTestDataset.PROV_CENTRAL.getServerObject().getValuesOverTime(DefaultAttribute.EXISTS.getName()).size());
GeoObjectOverTime goTime = testData.adapter.getGeoObjectOverTimeByCode(FastTestDataset.PROV_CENTRAL.getCode(), FastTestDataset.PROV_CENTRAL.getGeoObjectType().getCode());
Assert.assertEquals(3, goTime.getAllValues(DefaultAttribute.EXISTS.getName()).size());
Assert.assertEquals(FastTestDataset.PROV_CENTRAL.getCode(), goTime.getCode());
Assert.assertEquals(Boolean.FALSE, goTime.getExists(dateFormat.parse("1990-01-01")));
Assert.assertEquals(Boolean.TRUE, goTime.getExists(dateFormat.parse("1990-02-01")));
Assert.assertEquals(Boolean.FALSE, goTime.getExists(dateFormat.parse("1990-03-01")));
ValueOverTimeCollectionDTO allStatus = goTime.getAllValues(DefaultAttribute.EXISTS.getName());
Assert.assertEquals("1990-01-01", dateFormat.format(allStatus.get(0).getStartDate()));
Assert.assertEquals("1990-01-31", dateFormat.format(allStatus.get(0).getEndDate()));
Assert.assertEquals("1990-02-01", dateFormat.format(allStatus.get(1).getStartDate()));
Assert.assertEquals("1990-02-28", dateFormat.format(allStatus.get(1).getEndDate()));
Assert.assertEquals("1990-03-01", dateFormat.format(allStatus.get(2).getStartDate()));
Assert.assertEquals("1990-03-31", dateFormat.format(allStatus.get(2).getEndDate()));
Geometry expectedGeom = FastTestDataset.PROV_CENTRAL.fetchGeoObject().getGeometry();
Geometry actualGeom = ((AttributeGeometry) goTime.getAttributeOnDate(DefaultAttribute.GEOMETRY.getName(), FastTestDataset.DEFAULT_OVER_TIME_DATE)).getValue();
Assert.assertTrue(expectedGeom.equalsTopo(actualGeom));
}
use of org.commongeoregistry.adapter.dataaccess.AttributeGeometry in project geoprism-registry by terraframe.
the class RegistryVersionTest method testGetGeoObjectOverTimeByCode.
@Test
public void testGetGeoObjectOverTimeByCode() throws ParseException {
this.addVersionData(FastTestDataset.PROV_CENTRAL);
GeoObjectOverTime goTime = testData.adapter.getGeoObjectOverTimeByCode(FastTestDataset.PROV_CENTRAL.getCode(), FastTestDataset.PROV_CENTRAL.getGeoObjectType().getCode());
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
dateFormat.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
Assert.assertEquals(FastTestDataset.PROV_CENTRAL.getCode(), goTime.getCode());
Assert.assertEquals(Boolean.FALSE, goTime.getExists(dateFormat.parse("1990-01-01")));
Assert.assertEquals(Boolean.TRUE, goTime.getExists(dateFormat.parse("1990-02-01")));
Assert.assertEquals(Boolean.FALSE, goTime.getExists(dateFormat.parse("1990-03-01")));
ValueOverTimeCollectionDTO allStatus = goTime.getAllValues(DefaultAttribute.EXISTS.getName());
Assert.assertEquals("1990-01-01", dateFormat.format(allStatus.get(0).getStartDate()));
Assert.assertEquals("1990-01-31", dateFormat.format(allStatus.get(0).getEndDate()));
Assert.assertEquals("1990-02-01", dateFormat.format(allStatus.get(1).getStartDate()));
Assert.assertEquals("1990-02-28", dateFormat.format(allStatus.get(1).getEndDate()));
Assert.assertEquals("1990-03-01", dateFormat.format(allStatus.get(2).getStartDate()));
Assert.assertEquals("1990-03-31", dateFormat.format(allStatus.get(2).getEndDate()));
Geometry expectedGeom = FastTestDataset.PROV_CENTRAL.fetchGeoObject().getGeometry();
Geometry actualGeom = ((AttributeGeometry) goTime.getAttributeOnDate(DefaultAttribute.GEOMETRY.getName(), FastTestDataset.DEFAULT_OVER_TIME_DATE)).getValue();
Assert.assertTrue(expectedGeom.equalsTopo(actualGeom));
}
Aggregations