use of net.geoprism.registry.IncrementalListType in project geoprism-registry by terraframe.
the class ListTypeTest method testGetAnnualFrequencyDates.
// @Test
// public void testCreatePublishedVersionsFromOtherOrg()
// {
// JsonObject listJson = getJson(USATestData.ORG_NPS.getServerObject(),
// USATestData.HIER_ADMIN, USATestData.STATE, USATestData.COUNTRY);
//
// ListTypeService service = new ListTypeService();
// JsonObject result = service.apply(testData.clientRequest.getSessionId(),
// listJson);
// String oid = result.get(ComponentInfo.OID).getAsString();
//
// try
// {
// TestUserInfo[] users = new TestUserInfo[] { USATestData.USER_PPP_RA };
//
// for (TestUserInfo user : users)
// {
// try
// {
// USATestData.runAsUser(user, (request, adapter) -> {
//
// service.createPublishedVersions(request.getSessionId(), oid);
//
// Assert.fail("Able to publish a master list as a user with bad roles");
// });
// }
// catch (SmartExceptionDTO e)
// {
// // This is expected
// }
// }
// }
// finally
// {
// service.remove(testData.clientRequest.getSessionId(), oid);
// }
//
// }
//
// @Test
// public void testGetTile() throws IOException
// {
// JsonObject listJson = getJson(USATestData.ORG_NPS.getServerObject(),
// USATestData.HIER_ADMIN, USATestData.STATE, ListType.PUBLIC, false,
// USATestData.COUNTRY);
//
// ListTypeService service = new ListTypeService();
// JsonObject result = service.apply(testData.clientRequest.getSessionId(),
// listJson);
// String oid = result.get(ComponentInfo.OID).getAsString();
//
// try
// {
// service.applyPublishedVersions(testData.clientRequest.getSessionId(),
// oid);
//
// final JsonObject object =
// service.getVersions(testData.clientRequest.getSessionId(), oid,
// ListTypeVersion.PUBLISHED);
// final JsonArray json = object.get(ListType.VERSIONS).getAsJsonArray();
//
// Assert.assertEquals(USATestData.DEFAULT_TIME_YEAR_DIFF, json.size());
//
// String versionId = json.get(0).getAsJsonObject().get("oid").getAsString();
//
// JSONObject tileObj = new JSONObject();
// tileObj.put("oid", versionId);
// tileObj.put("x", 1);
// tileObj.put("y", 1);
// tileObj.put("z", 1);
//
// try (InputStream tile =
// service.getTile(testData.clientRequest.getSessionId(), tileObj))
// {
// Assert.assertNotNull(tile);
//
// byte[] ctile = getCachedTile(versionId);
//
// Assert.assertNotNull(ctile);
// Assert.assertTrue(ctile.length > 0);
// }
// }
// finally
// {
// service.remove(testData.clientRequest.getSessionId(), oid);
// }
// }
//
// @Request
// private byte[] getCachedTile(String versionId)
// {
// return TileCache.getCachedTile(versionId, 1, 1, 1);
// }
@Test
@Request
public void testGetAnnualFrequencyDates() {
final IncrementalListType list = new IncrementalListType();
list.addFrequency(ChangeFrequency.ANNUAL);
Calendar calendar = Calendar.getInstance(GeoRegistryUtil.SYSTEM_TIMEZONE);
calendar.clear();
calendar.set(2012, Calendar.MARCH, 3);
final Date startDate = calendar.getTime();
calendar.set(2017, Calendar.OCTOBER, 21);
final Date endDate = calendar.getTime();
List<Date> dates = list.getFrequencyDates(startDate, endDate);
Assert.assertEquals(6, dates.size());
for (int i = 0; i < dates.size(); i++) {
calendar.clear();
calendar.set((2012 + i), Calendar.DECEMBER, 31);
Assert.assertEquals(calendar.getTime(), dates.get(i));
}
}
use of net.geoprism.registry.IncrementalListType in project geoprism-registry by terraframe.
the class ListTypeTest method testGetBiannualFrequencyDates.
@Test
@Request
public void testGetBiannualFrequencyDates() {
final IncrementalListType list = new IncrementalListType();
list.addFrequency(ChangeFrequency.BIANNUAL);
Calendar calendar = Calendar.getInstance(GeoRegistryUtil.SYSTEM_TIMEZONE);
calendar.clear();
calendar.set(2012, Calendar.MARCH, 3);
final Date startDate = calendar.getTime();
calendar.set(2013, Calendar.JANUARY, 2);
final Date endDate = calendar.getTime();
List<Date> dates = list.getFrequencyDates(startDate, endDate);
Assert.assertEquals(3, dates.size());
}
use of net.geoprism.registry.IncrementalListType in project geoprism-registry by terraframe.
the class ListTypeTest method testGetQuarterFrequencyDates.
@Test
@Request
public void testGetQuarterFrequencyDates() {
final IncrementalListType list = new IncrementalListType();
list.addFrequency(ChangeFrequency.QUARTER);
Calendar calendar = Calendar.getInstance(GeoRegistryUtil.SYSTEM_TIMEZONE);
calendar.clear();
calendar.set(2012, Calendar.MARCH, 3);
final Date startDate = calendar.getTime();
calendar.set(2013, Calendar.JANUARY, 2);
final Date endDate = calendar.getTime();
List<Date> dates = list.getFrequencyDates(startDate, endDate);
Assert.assertEquals(5, dates.size());
}
use of net.geoprism.registry.IncrementalListType in project geoprism-registry by terraframe.
the class ListTypeTest method testGetMonthFrequencyDates.
@Test
@Request
public void testGetMonthFrequencyDates() {
final IncrementalListType list = new IncrementalListType();
list.addFrequency(ChangeFrequency.MONTHLY);
Calendar calendar = Calendar.getInstance(GeoRegistryUtil.SYSTEM_TIMEZONE);
calendar.clear();
calendar.set(2012, Calendar.MARCH, 3);
final Date startDate = calendar.getTime();
calendar.set(2013, Calendar.JANUARY, 2);
final Date endDate = calendar.getTime();
List<Date> dates = list.getFrequencyDates(startDate, endDate);
Assert.assertEquals(11, dates.size());
}
use of net.geoprism.registry.IncrementalListType in project geoprism-registry by terraframe.
the class ListTypeTest method testIncrementListTypeSerialization.
@Test
@Request
public void testIncrementListTypeSerialization() {
IncrementalListType list = new IncrementalListType();
list.setUniversal(USATestData.STATE.getUniversal());
list.getDisplayLabel().setValue("Test List");
list.setCode("TEST_CODE");
list.setOrganization(USATestData.ORG_NPS.getServerObject());
list.getDescription().setValue("My Overal Description");
list.setPublishingStartDate(USATestData.DEFAULT_OVER_TIME_DATE);
list.addFrequency(ChangeFrequency.ANNUAL);
JsonObject json = list.toJSON();
IncrementalListType test = (IncrementalListType) ListType.fromJSON(json);
Assert.assertEquals(list.getUniversalOid(), test.getUniversalOid());
Assert.assertEquals(list.getDisplayLabel().getValue(), test.getDisplayLabel().getValue());
Assert.assertEquals(list.getDescription().getValue(), test.getDescription().getValue());
Assert.assertEquals(list.getOrganization(), test.getOrganization());
Assert.assertEquals(list.getCode(), test.getCode());
Assert.assertEquals(list.getHierarchiesAsJson().toString(), test.getHierarchiesAsJson().toString());
Assert.assertEquals(list.getFrequency().get(0), test.getFrequency().get(0));
Assert.assertEquals(list.getPublishingStartDate(), test.getPublishingStartDate());
}
Aggregations