Rename Context to RMContext to avoid to fully qualify the Context in the model.

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/resource-management/resource-manager@158933 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Manuele Simi 2017-11-30 04:10:26 +00:00
parent f841ccffa6
commit da7841fd0f
3 changed files with 19 additions and 17 deletions

View File

@ -3,7 +3,7 @@ package org.gcube.resourcemanagement.manager.webapp;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.MediaType;
import org.gcube.resourcemanagement.manager.webapp.rs.Context;
import org.gcube.resourcemanagement.manager.webapp.rs.RMContext;
import org.glassfish.jersey.server.ResourceConfig;
/**
@ -16,7 +16,7 @@ public class ResourceInitializer extends ResourceConfig {
public ResourceInitializer(){
//where jersey will find the operation's handler
packages(Context.class.getPackage().toString());
packages(RMContext.class.getPackage().toString());
}
}

View File

@ -10,6 +10,7 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import org.gcube.informationsystem.impl.utils.ISMapper;
import org.gcube.informationsystem.model.entity.Context;
import org.gcube.resourcemanagement.manager.io.rs.ContextPath;
import org.gcube.resourcemanagement.manager.webapp.ResourceInitializer;
import org.slf4j.Logger;
@ -19,15 +20,15 @@ import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
/**
* Methods for manipulating {@link org.gcube.informationsystem.model.entity.Context}s.
* Methods for manipulating {@link Context}s.
*
* @author Manuele Simi (ISTI-CNR)
* @author Manuele Simi (ISTI-CNR)
*
*/
@Path(ContextPath.CONTEXT_ROOT)
public class Context {
public class RMContext {
private static Logger logger = LoggerFactory.getLogger(Context.class);
private static Logger logger = LoggerFactory.getLogger(RMContext.class);
/*
* e.g. POST /resource-manager/context/
@ -37,8 +38,8 @@ public class Context {
public Response create(String json) throws JsonParseException, JsonMappingException, IOException, IllegalArgumentException
{
logger.info("Requested to create context {} with json {}",
org.gcube.informationsystem.model.entity.Context.NAME, json);
org.gcube.informationsystem.model.entity.Context inputContext = ISMapper.unmarshal(org.gcube.informationsystem.model.entity.Context.class, json);
Context.NAME, json);
Context inputContext = ISMapper.unmarshal(Context.class, json);
if (Objects.nonNull(inputContext.getParent()))
return Response.status(Status.BAD_REQUEST).build();
String response = "All good";

View File

@ -12,6 +12,7 @@ import javax.ws.rs.core.Response.Status;
import org.gcube.informationsystem.impl.entity.ContextImpl;
import org.gcube.informationsystem.impl.utils.ISMapper;
import org.gcube.informationsystem.model.entity.Context;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
import org.junit.FixMethodOrder;
@ -30,26 +31,26 @@ import com.fasterxml.jackson.core.JsonProcessingException;
*/
@RunWith(BlockJUnit4ClassRunner.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class ContextTest extends JerseyTest {
public class RMContextTest extends JerseyTest {
private final static String contextName = "firstContext";
@Override
protected Application configure() {
return new ResourceConfig(Context.class);
return new ResourceConfig(RMContext.class);
}
/**
* Test method for
* {@link org.gcube.resourcemanagement.manager.webapp.rs.Context#create(java.lang.String)}.
* {@link org.gcube.resourcemanagement.manager.webapp.rs.RMContext#create(java.lang.String)}.
*/
@Test
public void step0_Context() {
org.gcube.informationsystem.model.entity.Context newContext = new ContextImpl(contextName);
Context newContext = new ContextImpl(contextName);
//newContext.setParent(new ContextImpl("parent"));
try {
ISMapper.unmarshal(org.gcube.informationsystem.model.entity.Context.class, ISMapper.marshal(newContext));
ISMapper.unmarshal(Context.class, ISMapper.marshal(newContext));
} catch (IOException e) {
e.printStackTrace();
assertFalse("Failed to unmarshal the context.", false);
@ -59,11 +60,11 @@ public class ContextTest extends JerseyTest {
/**
* Test method for
* {@link org.gcube.resourcemanagement.manager.webapp.rs.Context#create(java.lang.String)}.
* {@link org.gcube.resourcemanagement.manager.webapp.rs.RMContext#create(java.lang.String)}.
*/
@Test
public void step1_Create() {
org.gcube.informationsystem.model.entity.Context newContext = new ContextImpl(contextName);
Context newContext = new ContextImpl(contextName);
try {
Response create = target("context").request()
.post(Entity.entity(ISMapper.marshal(newContext), MediaType.APPLICATION_JSON + ";charset=UTF-8"));
@ -79,11 +80,11 @@ public class ContextTest extends JerseyTest {
/**
* Test method for
* {@link org.gcube.resourcemanagement.manager.webapp.rs.Context#create(java.lang.String)} when the parent does not exist.
* {@link org.gcube.resourcemanagement.manager.webapp.rs.RMContext#create(java.lang.String)} when the parent does not exist.
*/
@Test
public void step1_CreateWithInvalidParent() {
org.gcube.informationsystem.model.entity.Context newContext = new ContextImpl(contextName);
Context newContext = new ContextImpl(contextName);
newContext.setParent(new ContextImpl("DoNotExist"));
try {
Response create = target("context").request()