|
|
|
@ -3,6 +3,7 @@ package org.gcube.resourcemanagement.manager.webapp.context;
|
|
|
|
|
import static org.junit.Assert.*;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
|
|
import javax.ws.rs.client.Entity;
|
|
|
|
|
import javax.ws.rs.core.Application;
|
|
|
|
@ -44,12 +45,14 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
|
|
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
|
|
|
|
public class RMContextTest extends JerseyTest {
|
|
|
|
|
|
|
|
|
|
private final static String contextName = "firstContext4";
|
|
|
|
|
private final static String contextName = "firstContext7";
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
@BeforeClass
|
|
|
|
@ -107,20 +110,24 @@ public class RMContextTest extends JerseyTest {
|
|
|
|
|
public void step1_Create() {
|
|
|
|
|
if (skipTest)
|
|
|
|
|
return;
|
|
|
|
|
Context newContext = new ContextImpl(contextName);
|
|
|
|
|
Context newContext = new ContextImpl(contextName, uuid);
|
|
|
|
|
System.out.println(newContext.getHeader().getUUID().toString());
|
|
|
|
|
try {
|
|
|
|
|
System.out.print(ISMapper.marshal(newContext));
|
|
|
|
|
Response create = target("context").queryParam(RMContextPath.FORCE_RRURL_PARAM, RR).request()
|
|
|
|
|
.post(Entity.entity(ISMapper.marshal(newContext), MediaType.APPLICATION_JSON + ";charset=UTF-8"));
|
|
|
|
|
|
|
|
|
|
SerializableErrorCode code = create.readEntity(SerializableErrorCode.class);
|
|
|
|
|
RMCode realCode = CodeFinder.findAndConvert(code, RMCode.values());
|
|
|
|
|
assertNotNull(create);
|
|
|
|
|
// TODO: to restore an expected success when create is fully
|
|
|
|
|
// functional
|
|
|
|
|
assertEquals("Unexpected returned code. Reason: " + create.getStatusInfo().getReasonPhrase(),
|
|
|
|
|
Status.NOT_ACCEPTABLE.getStatusCode(), create.getStatus());
|
|
|
|
|
assertEquals(RMCode.CONTEXT_ALREADY_EXISTS, realCode);
|
|
|
|
|
if (create.getStatusInfo() == Status.OK) {
|
|
|
|
|
String message = create.readEntity(String.class);
|
|
|
|
|
System.out.println("RM says: " + message);
|
|
|
|
|
}else {
|
|
|
|
|
assertEquals("Unexpected returned code. Reason: " + create.getStatusInfo().getReasonPhrase(),
|
|
|
|
|
Status.NOT_ACCEPTABLE.getStatusCode(), create.getStatus());
|
|
|
|
|
SerializableErrorCode code = create.readEntity(SerializableErrorCode.class);
|
|
|
|
|
RMCode realCode = CodeFinder.findAndConvert(code, RMCode.values());
|
|
|
|
|
assertEquals(RMCode.CONTEXT_ALREADY_EXISTS, realCode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (JsonProcessingException e) {
|
|
|
|
|
assertFalse("Failed to marshal the context.", false);
|
|
|
|
|
}
|
|
|
|
|