package org.gcube.gcat.persistence.ckan; import java.net.URL; import java.util.UUID; import org.gcube.gcat.ContextTest; import org.gcube.gcat.persistence.ckan.CKANResource; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; public class CKANResourceTest extends ContextTest { private static final Logger logger = LoggerFactory.getLogger(CKANResourceTest.class); /* * PROD * Workspace(luca.frosini) > RESTful Transaction Model.pdf * https://data.d4science.org/shub/ab4daec8-2ce4-43d7-9d37-00b2051e3530 * URL url = new URL("https://goo.gl/bFME6Q"); */ /* * DEV * Workspace(luca.frosini) > RESTful Transaction Model.pdf * https://data-d.d4science.org/shub/e03355cd-058a-4e3a-8d5b-cf3676a46840 * URL url = new URL("https://goo.gl/fSZH1o"); * * * Workspace(luca.frosini) > RESTful Transaction Model v 1.0.pdf * https://data-d.d4science.org/shub/5df695ea-986a-437d-abaf-ed1542a7f5af * URL url = new URL("https://goo.gl/7ofQwn"); * * * Workspace(luca.frosini) > RESTful Transaction Model v 1.1.pdf * https://data-d.d4science.org/shub/7b6628e4-b397-4df9-b387-2d643ae0095c * URL url = new URL("https://goo.gl/jvXMcd"); * */ @Test public void testCopyStorageResource() throws Exception { URL url = new URL("https://goo.gl/fSZH1o"); String itemID = UUID.randomUUID().toString(); CKANResource ckanResource = new CKANResource(itemID); ckanResource.resourceID = UUID.randomUUID().toString(); URL finalURL = ckanResource.copyStorageResource(url); logger.debug("Initial URL is {} - Final URL is {}", url, finalURL); ckanResource.deleteStorageResource(finalURL); } // @Test public void testCreate() throws Exception { ObjectMapper objectMapper = new ObjectMapper(); ObjectNode objectNode = objectMapper.createObjectNode(); objectNode.put(CKANResource.URL_KEY, "https://data.d4science.org/shub/ab4daec8-2ce4-43d7-9d37-00b2051e3530"); objectNode.put(CKANResource.ID_KEY, "8422b5d4-626b-46f2-9121-bbc6d443071d"); CKANResource ckanResource = new CKANResource("f9221556-4b1f-49f2-8951-a4c30d71cd37"); String json = ckanResource.getAsString(objectNode); logger.debug("Going to create Resource {}", json); ckanResource.create(json); } }