Search in sources :

Example 1 with IncrementalListType

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));
    }
}
Also used : IncrementalListType(net.geoprism.registry.IncrementalListType) Calendar(java.util.Calendar) Date(java.util.Date) ClassificationTypeTest(net.geoprism.registry.classification.ClassificationTypeTest) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 2 with IncrementalListType

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());
}
Also used : IncrementalListType(net.geoprism.registry.IncrementalListType) Calendar(java.util.Calendar) Date(java.util.Date) ClassificationTypeTest(net.geoprism.registry.classification.ClassificationTypeTest) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 3 with IncrementalListType

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());
}
Also used : IncrementalListType(net.geoprism.registry.IncrementalListType) Calendar(java.util.Calendar) Date(java.util.Date) ClassificationTypeTest(net.geoprism.registry.classification.ClassificationTypeTest) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 4 with IncrementalListType

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());
}
Also used : IncrementalListType(net.geoprism.registry.IncrementalListType) Calendar(java.util.Calendar) Date(java.util.Date) ClassificationTypeTest(net.geoprism.registry.classification.ClassificationTypeTest) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 5 with IncrementalListType

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());
}
Also used : IncrementalListType(net.geoprism.registry.IncrementalListType) JsonObject(com.google.gson.JsonObject) ClassificationTypeTest(net.geoprism.registry.classification.ClassificationTypeTest) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Aggregations

Request (com.runwaysdk.session.Request)5 IncrementalListType (net.geoprism.registry.IncrementalListType)5 ClassificationTypeTest (net.geoprism.registry.classification.ClassificationTypeTest)5 Test (org.junit.Test)5 Calendar (java.util.Calendar)4 Date (java.util.Date)4 JsonObject (com.google.gson.JsonObject)1