RMContextTest: extend step0 to check the validity of UUID and name.
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/resource-management/resource-manager@162339 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
f08c550f1d
commit
53f07d6d61
|
@ -45,13 +45,14 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
|||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
public class RMContextTest extends JerseyTest {
|
||||
|
||||
private final static String contextName = "firstContext7";
|
||||
private final static String context1Name = "AContext";
|
||||
|
||||
public static final UUID context1UUID = UUID.fromString("5f86dc81-2f59-486b-8aa9-3ab5486313c4");
|
||||
|
||||
private final static String RR = "http://manuele-registry.dev.d4science.org/resource-registry";
|
||||
|
||||
public static final String DEFAULT_TEST_SCOPE ="";
|
||||
|
||||
public static final UUID uuid = UUID.fromString("5f86dc81-2f59-486b-8aa9-3ab5486313c4");
|
||||
|
||||
private static boolean skipTest = false;
|
||||
|
||||
|
@ -91,10 +92,13 @@ public class RMContextTest extends JerseyTest {
|
|||
*/
|
||||
@Test
|
||||
public void step0_Context() {
|
||||
Context newContext = new ContextImpl(contextName);
|
||||
// newContext.setParent(new ContextImpl("parent"));
|
||||
Context newContext = new ContextImpl(context1Name);
|
||||
newContext.getHeader().setUUID(context1UUID);
|
||||
try {
|
||||
ISMapper.unmarshal(Context.class, ISMapper.marshal(newContext));
|
||||
Context uContext = ISMapper.unmarshal(Context.class, ISMapper.marshal(newContext));
|
||||
assertNotNull(uContext);
|
||||
assertEquals("Invalid context name", context1Name, uContext.getName());
|
||||
assertEquals("Invalid context UUID", context1UUID, uContext.getHeader().getUUID());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
assertFalse("Failed to unmarshal the context.", false);
|
||||
|
@ -104,13 +108,13 @@ public class RMContextTest extends JerseyTest {
|
|||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.gcube.resourcemanagement.manager.webapp.rs.RMContext#create(java.lang.String)}.
|
||||
* {@link org.gcube.resourcemanagement.manager.webapp.rs.RMContext#create(String)}.
|
||||
*/
|
||||
@Test
|
||||
public void step1_Create() {
|
||||
if (skipTest)
|
||||
return;
|
||||
Context newContext = new ContextImpl(contextName, uuid);
|
||||
Context newContext = new ContextImpl(context1Name, context1UUID);
|
||||
System.out.println(newContext.getHeader().getUUID().toString());
|
||||
try {
|
||||
System.out.print(ISMapper.marshal(newContext));
|
||||
|
@ -133,16 +137,35 @@ public class RMContextTest extends JerseyTest {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.gcube.resourcemanagement.manager.webapp.rs.RMContext#delete(String, String)}
|
||||
*/
|
||||
@Test
|
||||
public void step2_Delete() {
|
||||
if (skipTest)
|
||||
return;
|
||||
Context newContext = new ContextImpl(context1Name);
|
||||
try {
|
||||
Response 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.BAD_REQUEST.getStatusCode(), create.getStatus());
|
||||
} catch (JsonProcessingException e) {
|
||||
assertFalse("Failed to marshal the context.", false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.gcube.resourcemanagement.manager.webapp.rs.RMContext#create(java.lang.String)}
|
||||
* when the parent does not exist.
|
||||
*/
|
||||
@Test
|
||||
public void step1_CreateWithInvalidParent() {
|
||||
public void step2_CreateWithInvalidParent() {
|
||||
if (skipTest)
|
||||
return;
|
||||
Context newContext = new ContextImpl(contextName);
|
||||
Context newContext = new ContextImpl(context1Name);
|
||||
newContext.setParent(new ContextImpl("DoNotExist"));
|
||||
try {
|
||||
Response create = target("context").request()
|
||||
|
|
Loading…
Reference in New Issue