Add test cases for parent context and marshaling/unmarshaling of a simple context.
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/resource-management/resource-manager@158882 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
047ed63b59
commit
a4e32dd47a
|
@ -2,6 +2,8 @@ package org.gcube.resourcemanagement.manager.webapp.rs;
|
|||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.ws.rs.client.Entity;
|
||||
import javax.ws.rs.core.Application;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
@ -20,6 +22,8 @@ import org.junit.runners.MethodSorters;
|
|||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
/**
|
||||
* Test cases for the Context methods.
|
||||
*
|
||||
|
@ -36,6 +40,24 @@ public class ContextTest extends JerseyTest {
|
|||
return new ResourceConfig(Context.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.gcube.resourcemanagement.manager.webapp.rs.Context#create(java.lang.String)}.
|
||||
*/
|
||||
@Test
|
||||
public void step0_Context() {
|
||||
org.gcube.informationsystem.model.entity.Context newContext = new ContextImpl(contextName);
|
||||
//newContext.setParent(new ContextImpl("parent"));
|
||||
try {
|
||||
ISMapper.unmarshal(org.gcube.informationsystem.model.entity.Context.class, ISMapper.marshal(newContext));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
assertFalse("Failed to unmarshal the context.", false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.gcube.resourcemanagement.manager.webapp.rs.Context#create(java.lang.String)}.
|
||||
|
@ -56,5 +78,22 @@ public class ContextTest extends JerseyTest {
|
|||
assertFalse("Failed to marshal the context.", false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.gcube.resourcemanagement.manager.webapp.rs.Context#create(java.lang.String)} when the parent does not exist.
|
||||
*/
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void step1_CreateNoParent() {
|
||||
org.gcube.informationsystem.model.entity.Context newContext = new ContextImpl(contextName);
|
||||
newContext.setParent(new ContextImpl("DoNotExist"));
|
||||
try {
|
||||
target("context").request()
|
||||
.post(Entity.entity(ISMapper.marshal(newContext), MediaType.APPLICATION_JSON + ";charset=UTF-8"));
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
assertFalse("Failed to marshal the context.", false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue