Search in sources :

Example 91 with Request

use of com.runwaysdk.session.Request in project geoprism-registry by terraframe.

the class BusinessTypeTest method testRemove.

@Test
@Request
public void testRemove() {
    String code = "TEST_PROG";
    String orgCode = FastTestDataset.ORG_CGOV.getCode();
    String label = "Test Prog";
    JsonObject object = new JsonObject();
    object.addProperty(BusinessType.CODE, code);
    object.addProperty(BusinessType.ORGANIZATION, orgCode);
    object.add(BusinessType.DISPLAYLABEL, new LocalizedValue(label).toJSON());
    BusinessType type = BusinessType.apply(object);
    type.delete();
    Assert.assertNull(BusinessType.getByCode(type.getCode()));
}
Also used : LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) BusinessType(net.geoprism.registry.BusinessType) JsonObject(com.google.gson.JsonObject) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 92 with Request

use of com.runwaysdk.session.Request in project geoprism-registry by terraframe.

the class BusinessTypeTest method testToJson.

@Test
@Request
public void testToJson() {
    String code = "TEST_PROG";
    String orgCode = FastTestDataset.ORG_CGOV.getCode();
    String label = "Test Prog";
    JsonObject object = new JsonObject();
    object.addProperty(BusinessType.CODE, code);
    object.addProperty(BusinessType.ORGANIZATION, orgCode);
    object.add(BusinessType.DISPLAYLABEL, new LocalizedValue(label).toJSON());
    BusinessType type = BusinessType.apply(object);
    try {
        JsonObject json = type.toJSON();
        Assert.assertEquals(type.getCode(), json.get("code").getAsString());
        Assert.assertFalse(json.has("attributes"));
    } finally {
        type.delete();
    }
}
Also used : LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) BusinessType(net.geoprism.registry.BusinessType) JsonObject(com.google.gson.JsonObject) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 93 with Request

use of com.runwaysdk.session.Request in project geoprism-registry by terraframe.

the class BusinessTypeTest method testCreate.

@Test
@Request
public void testCreate() {
    String code = "TEST_PROG";
    String orgCode = FastTestDataset.ORG_CGOV.getCode();
    String label = "Test Prog";
    JsonObject object = new JsonObject();
    object.addProperty(BusinessType.CODE, code);
    object.addProperty(BusinessType.ORGANIZATION, orgCode);
    object.add(BusinessType.DISPLAYLABEL, new LocalizedValue(label).toJSON());
    BusinessType type = BusinessType.apply(object);
    try {
        Assert.assertEquals(code, type.getCode());
        Assert.assertEquals(orgCode, type.getOrganization().getCode());
        Assert.assertEquals(label, type.getDisplayLabel().getValue());
        Assert.assertNotNull(type.getMdVertex());
    } finally {
        type.delete();
    }
}
Also used : LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) BusinessType(net.geoprism.registry.BusinessType) JsonObject(com.google.gson.JsonObject) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 94 with Request

use of com.runwaysdk.session.Request in project geoprism-registry by terraframe.

the class ClassificationTest method testAddGetChildApplyWithParent.

@Test
@Request
public void testAddGetChildApplyWithParent() {
    Classification parent = Classification.newInstance(type);
    parent.setCode(PARENT_CODE);
    parent.apply(null);
    try {
        Classification child = Classification.newInstance(type);
        child.setCode(CHILD_CODE);
        child.apply(parent);
        try {
            Page<Classification> children = parent.getChildren(20, 1);
            Assert.assertEquals(Long.valueOf(1), children.getCount());
            Classification result = children.getResults().get(0);
            Assert.assertEquals(child.getOid(), result.getOid());
        } finally {
            child.delete();
        }
    } finally {
        parent.delete();
    }
}
Also used : Classification(net.geoprism.registry.model.Classification) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 95 with Request

use of com.runwaysdk.session.Request in project geoprism-registry by terraframe.

the class ClassificationTest method testGetAncestor.

@Test
@Request
public void testGetAncestor() {
    Classification grandParent = Classification.newInstance(type);
    grandParent.setCode(GRANDPARENT_CODE);
    grandParent.apply(null);
    try {
        Classification parent = Classification.newInstance(type);
        parent.setCode(PARENT_CODE);
        parent.apply(grandParent);
        try {
            Classification child = Classification.newInstance(type);
            child.setCode(CHILD_CODE);
            child.apply(parent);
            try {
                List<Classification> ancestors = child.getAncestors(null);
                Assert.assertEquals(3, ancestors.size());
            } finally {
                child.delete();
            }
        } finally {
            parent.delete();
        }
    } finally {
        grandParent.delete();
    }
}
Also used : Classification(net.geoprism.registry.model.Classification) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Aggregations

Request (com.runwaysdk.session.Request)340 Test (org.junit.Test)145 JsonObject (com.google.gson.JsonObject)85 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)73 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)73 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)53 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)40 JsonArray (com.google.gson.JsonArray)36 Date (java.util.Date)33 ChangeRequest (net.geoprism.registry.action.ChangeRequest)32 OAuthClientRequest (org.apache.oltu.oauth2.client.request.OAuthClientRequest)31 QueryFactory (com.runwaysdk.query.QueryFactory)30 ValueOverTime (com.runwaysdk.dataaccess.graph.attributes.ValueOverTime)26 ValueOverTimeCollection (com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection)22 ListType (net.geoprism.registry.ListType)21 SimpleDateFormat (java.text.SimpleDateFormat)19 Classification (net.geoprism.registry.model.Classification)19 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)19 ClassificationTypeTest (net.geoprism.registry.classification.ClassificationTypeTest)17 TransitionEvent (net.geoprism.registry.graph.transition.TransitionEvent)17