diff --git a/io/src/main/java/org/gcube/resourcemanagement/manager/io/extendedmodel/package-info.java b/io/src/main/java/org/gcube/resourcemanagement/manager/io/extendedmodel/package-info.java new file mode 100644 index 0000000..51fe6ae --- /dev/null +++ b/io/src/main/java/org/gcube/resourcemanagement/manager/io/extendedmodel/package-info.java @@ -0,0 +1,7 @@ +/** + * Extensions/abstraction over the gCube resource model. + * + * @author Manuele Simi (ISTI - CNR) + * + */ +package org.gcube.resourcemanagement.manager.io.extendedmodel; \ No newline at end of file diff --git a/webapp/pom.xml b/webapp/pom.xml index 6ed76b6..c95c241 100644 --- a/webapp/pom.xml +++ b/webapp/pom.xml @@ -130,10 +130,14 @@ 0.0.1-SNAPSHOT + + + - org.gcube.information-system - resource-registry-context-client - 1.0.0-SNAPSHOT + org.glassfish.jersey.media + jersey-media-json-jackson + 2.26 + runtime @@ -147,7 +151,7 @@ org.glassfish.jersey.test-framework.providers jersey-test-framework-provider-simple - 2.17 + 2.26 test diff --git a/webapp/src/main/java/org/gcube/resourcemanagement/manager/webapp/rs/Context.java b/webapp/src/main/java/org/gcube/resourcemanagement/manager/webapp/rs/Context.java index ac45d97..10f641d 100644 --- a/webapp/src/main/java/org/gcube/resourcemanagement/manager/webapp/rs/Context.java +++ b/webapp/src/main/java/org/gcube/resourcemanagement/manager/webapp/rs/Context.java @@ -31,7 +31,7 @@ public class Context { { logger.info("Requested to create context {} with json {}", org.gcube.informationsystem.model.entity.Context.NAME, json); - String response = ""; + String response = "All good"; //TODO return Response.status(Status.CREATED).entity(response). type(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8).build(); diff --git a/webapp/src/main/java/org/gcube/resourcemanagement/manager/webapp/rs/package-info.java b/webapp/src/main/java/org/gcube/resourcemanagement/manager/webapp/rs/package-info.java index 3d1f019..592d5ef 100644 --- a/webapp/src/main/java/org/gcube/resourcemanagement/manager/webapp/rs/package-info.java +++ b/webapp/src/main/java/org/gcube/resourcemanagement/manager/webapp/rs/package-info.java @@ -1,4 +1,6 @@ /** + * Signatures of the REST methods for the Resource Manager webapp. + * * @author Manuele Simi (ISTI - CNR) * */ diff --git a/webapp/src/test/java/org/gcube/resourcemanagement/manager/webapp/rs/ContextTest.java b/webapp/src/test/java/org/gcube/resourcemanagement/manager/webapp/rs/ContextTest.java new file mode 100644 index 0000000..12fbcd2 --- /dev/null +++ b/webapp/src/test/java/org/gcube/resourcemanagement/manager/webapp/rs/ContextTest.java @@ -0,0 +1,59 @@ +package org.gcube.resourcemanagement.manager.webapp.rs; + +import static org.junit.Assert.*; + +import javax.ws.rs.client.Entity; +import javax.ws.rs.core.Application; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; + +import org.gcube.informationsystem.impl.entity.ContextImpl; +import org.gcube.informationsystem.impl.utils.ISMapper; +import org.glassfish.jersey.server.ResourceConfig; +import org.glassfish.jersey.test.JerseyTest; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.BlockJUnit4ClassRunner; +import org.junit.runners.MethodSorters; + +import com.fasterxml.jackson.core.JsonProcessingException; + +/** + * Test cases for the Context methods. + * + * @author Manuele Simi (ISTI-CNR)* + */ +@RunWith(BlockJUnit4ClassRunner.class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class ContextTest extends JerseyTest { + + private final static String contextName = "firstContext"; + + @Override + protected Application configure() { + return new ResourceConfig(Context.class); + } + + /** + * Test method for + * {@link org.gcube.resourcemanagement.manager.webapp.rs.Context#create(java.lang.String)}. + */ + @Test + public void step1_Create() { + org.gcube.informationsystem.model.entity.Context newContext = new ContextImpl(); + newContext.setName(contextName); + Response create; + try { + create = target("context").request() + .post(Entity.entity(ISMapper.marshal(newContext), MediaType.APPLICATION_JSON + ";charset=UTF-8")); + assertEquals("Unexpected returned code. Reason: " + create.getStatusInfo().getReasonPhrase(), + Status.CREATED.getStatusCode(), create.getStatus()); + assertEquals("All good", (String) create.readEntity(String.class)); + } catch (JsonProcessingException e) { + assertFalse("Failed to marshal the context.", false); + } + } + +}