Fixes #13180: Migrate OrientDB from version 2.2.X to 3.0.X
Task-Url: https://support.d4science.org/issues/13180 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@177123 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
1e14003aa8
commit
e7e7cc588e
|
@ -156,7 +156,7 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
||||||
if(oClass == null) {
|
if(oClass == null) {
|
||||||
if(element != null) {
|
if(element != null) {
|
||||||
OrientElement orientElement = (OrientElement) element;
|
OrientElement orientElement = (OrientElement) element;
|
||||||
OMetadata oMetadata = orientElement.getGraph().getRawGraph().getMetadata();
|
OMetadata oMetadata = orientElement.getRecord().getDatabase().getMetadata();
|
||||||
OSchema oSchema = oMetadata.getSchema();
|
OSchema oSchema = oMetadata.getSchema();
|
||||||
String type = orientElement.getRecord().getClassName();
|
String type = orientElement.getRecord().getClassName();
|
||||||
oClass = oSchema.getClass(type);
|
oClass = oSchema.getClass(type);
|
||||||
|
|
|
@ -31,7 +31,6 @@ import org.gcube.informationsystem.resourceregistry.utils.PropagationConstraintO
|
||||||
import org.gcube.informationsystem.resourceregistry.utils.Utility;
|
import org.gcube.informationsystem.resourceregistry.utils.Utility;
|
||||||
import org.gcube.informationsystem.utils.ISMapper;
|
import org.gcube.informationsystem.utils.ISMapper;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||||
|
|
|
@ -25,45 +25,45 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.orientechnologies.orient.core.db.ODatabaseSession;
|
||||||
import com.orientechnologies.orient.core.metadata.security.ORole;
|
import com.orientechnologies.orient.core.metadata.security.ORole;
|
||||||
import com.orientechnologies.orient.core.metadata.security.OSecurity;
|
import com.orientechnologies.orient.core.metadata.security.OSecurity;
|
||||||
import com.orientechnologies.orient.core.metadata.security.OUser;
|
import com.orientechnologies.orient.core.metadata.security.OUser;
|
||||||
import com.tinkerpop.blueprints.impls.orient.OrientGraph;
|
|
||||||
|
|
||||||
public class ContextManagementTest extends ScopedTest {
|
public class ContextManagementTest extends ScopedTest {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(ContextManagementTest.class);
|
private static Logger logger = LoggerFactory.getLogger(ContextManagementTest.class);
|
||||||
|
|
||||||
public static final String CTX_NAME_A = "A";
|
public static final String CTX_NAME_A = "A";
|
||||||
public static final String CTX_NAME_B = "B";
|
public static final String CTX_NAME_B = "B";
|
||||||
public static final String CTX_NAME_C = "C";
|
public static final String CTX_NAME_C = "C";
|
||||||
|
|
||||||
protected void assertions(Context pre, Context post, boolean checkParent, boolean create)
|
protected void assertions(Context pre, Context post, boolean checkParent, boolean create)
|
||||||
throws ResourceRegistryException {
|
throws ResourceRegistryException {
|
||||||
if (checkParent) {
|
if(checkParent) {
|
||||||
if (pre.getHeader() != null) {
|
if(pre.getHeader() != null) {
|
||||||
FacetManagementTest.checkHeader(post, pre.getHeader().getUUID(), create);
|
FacetManagementTest.checkHeader(post, pre.getHeader().getUUID(), create);
|
||||||
} else {
|
} else {
|
||||||
FacetManagementTest.checkHeader(post, null, create);
|
FacetManagementTest.checkHeader(post, null, create);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.assertTrue(pre.getName().compareTo(post.getName()) == 0);
|
Assert.assertTrue(pre.getName().compareTo(post.getName()) == 0);
|
||||||
if (checkParent && pre.getParent() != null && post.getParent() != null) {
|
if(checkParent && pre.getParent() != null && post.getParent() != null) {
|
||||||
Context preParent = pre.getParent().getSource();
|
Context preParent = pre.getParent().getSource();
|
||||||
Context postParent = post.getParent().getSource();
|
Context postParent = post.getParent().getSource();
|
||||||
assertions(preParent, postParent, false, false);
|
assertions(preParent, postParent, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void roleUserAssertions(UUID uuid, UUID oldParentUUID, boolean deleted) throws ResourceRegistryException {
|
protected void roleUserAssertions(UUID uuid, UUID oldParentUUID, boolean deleted) throws ResourceRegistryException {
|
||||||
ContextSecurityContext contextSecurityContext = new ContextSecurityContext();
|
ContextSecurityContext contextSecurityContext = new ContextSecurityContext();
|
||||||
ContextUtility.getInstance().addSecurityContext(contextSecurityContext.getUUID().toString(),
|
ContextUtility.getInstance().addSecurityContext(contextSecurityContext.getUUID().toString(),
|
||||||
contextSecurityContext);
|
contextSecurityContext);
|
||||||
|
|
||||||
OrientGraph orientGraph = contextSecurityContext.getGraph(PermissionMode.READER);
|
ODatabaseSession oDatabaseSession = contextSecurityContext.getDatabaseSession(PermissionMode.READER);
|
||||||
OSecurity oSecurity = orientGraph.getRawGraph().getMetadata().getSecurity();
|
OSecurity oSecurity = oDatabaseSession.getMetadata().getSecurity();
|
||||||
|
|
||||||
SecurityContext securityContext = null;
|
SecurityContext securityContext = null;
|
||||||
if(deleted) {
|
if(deleted) {
|
||||||
|
@ -71,31 +71,32 @@ public class ContextManagementTest extends ScopedTest {
|
||||||
} else {
|
} else {
|
||||||
securityContext = ContextUtility.getInstance().getSecurityContextByUUID(uuid);
|
securityContext = ContextUtility.getInstance().getSecurityContextByUUID(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean[] booleanArray = new boolean[] { false, true };
|
boolean[] booleanArray = new boolean[] {false, true};
|
||||||
for (boolean hierarchic : booleanArray) {
|
for(boolean hierarchic : booleanArray) {
|
||||||
for (PermissionMode permissionMode : PermissionMode.values()) {
|
for(PermissionMode permissionMode : PermissionMode.values()) {
|
||||||
String role = securityContext.getSecurityRoleOrUserName(permissionMode, SecurityType.ROLE, hierarchic);
|
String role = securityContext.getSecurityRoleOrUserName(permissionMode, SecurityType.ROLE, hierarchic);
|
||||||
ORole oRole = oSecurity.getRole(role);
|
ORole oRole = oSecurity.getRole(role);
|
||||||
Assert.assertEquals(oRole == null, deleted);
|
Assert.assertEquals(oRole == null, deleted);
|
||||||
|
|
||||||
String user = securityContext.getSecurityRoleOrUserName(permissionMode, SecurityType.USER, hierarchic);
|
String user = securityContext.getSecurityRoleOrUserName(permissionMode, SecurityType.USER, hierarchic);
|
||||||
OUser oUser = oSecurity.getUser(user);
|
OUser oUser = oSecurity.getUser(user);
|
||||||
Assert.assertEquals(oUser == null, deleted);
|
Assert.assertEquals(oUser == null, deleted);
|
||||||
if(oUser!=null) {
|
if(oUser != null) {
|
||||||
Assert.assertTrue(oUser.hasRole(oRole.getName(), false));
|
Assert.assertTrue(oUser.hasRole(oRole.getName(), false));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hierarchic) {
|
if(hierarchic) {
|
||||||
SecurityContext parent = null;
|
SecurityContext parent = null;
|
||||||
if(deleted){
|
if(deleted) {
|
||||||
if(oldParentUUID!=null) {
|
if(oldParentUUID != null) {
|
||||||
parent = ContextUtility.getInstance().getSecurityContextByUUID(oldParentUUID);
|
parent = ContextUtility.getInstance().getSecurityContextByUUID(oldParentUUID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parent = securityContext.getParentSecurityContext();
|
parent = securityContext.getParentSecurityContext();
|
||||||
while(parent!=null) {
|
while(parent != null) {
|
||||||
String parentUser = parent.getSecurityRoleOrUserName(permissionMode, SecurityType.USER, hierarchic);
|
String parentUser = parent.getSecurityRoleOrUserName(permissionMode, SecurityType.USER,
|
||||||
|
hierarchic);
|
||||||
OUser parentOUser = oSecurity.getUser(parentUser);
|
OUser parentOUser = oSecurity.getUser(parentUser);
|
||||||
Assert.assertTrue(parentOUser != null);
|
Assert.assertTrue(parentOUser != null);
|
||||||
Assert.assertEquals(parentOUser.hasRole(oRole.getName(), false), !deleted);
|
Assert.assertEquals(parentOUser.hasRole(oRole.getName(), false), !deleted);
|
||||||
|
@ -106,7 +107,7 @@ public class ContextManagementTest extends ScopedTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Context read(UUID uuid) throws ResourceRegistryException, IOException {
|
protected Context read(UUID uuid) throws ResourceRegistryException, IOException {
|
||||||
ContextManagement contextManagement = new ContextManagement();
|
ContextManagement contextManagement = new ContextManagement();
|
||||||
contextManagement.setUUID(uuid);
|
contextManagement.setUUID(uuid);
|
||||||
|
@ -115,7 +116,7 @@ public class ContextManagementTest extends ScopedTest {
|
||||||
roleUserAssertions(uuid, null, false);
|
roleUserAssertions(uuid, null, false);
|
||||||
return ISMapper.unmarshal(Context.class, contextString);
|
return ISMapper.unmarshal(Context.class, contextString);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Context create(Context context) throws ResourceRegistryException, IOException {
|
protected Context create(Context context) throws ResourceRegistryException, IOException {
|
||||||
ContextManagement contextManagement = new ContextManagement();
|
ContextManagement contextManagement = new ContextManagement();
|
||||||
contextManagement.setJson(ISMapper.marshal(context));
|
contextManagement.setJson(ISMapper.marshal(context));
|
||||||
|
@ -126,7 +127,7 @@ public class ContextManagementTest extends ScopedTest {
|
||||||
roleUserAssertions(c.getHeader().getUUID(), null, false);
|
roleUserAssertions(c.getHeader().getUUID(), null, false);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Context update(Context context) throws ResourceRegistryException, IOException {
|
protected Context update(Context context) throws ResourceRegistryException, IOException {
|
||||||
ContextManagement contextManagement = new ContextManagement();
|
ContextManagement contextManagement = new ContextManagement();
|
||||||
contextManagement.setJson(ISMapper.marshal(context));
|
contextManagement.setJson(ISMapper.marshal(context));
|
||||||
|
@ -137,7 +138,7 @@ public class ContextManagementTest extends ScopedTest {
|
||||||
roleUserAssertions(c.getHeader().getUUID(), null, false);
|
roleUserAssertions(c.getHeader().getUUID(), null, false);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean delete(UUID uuid) throws ResourceRegistryException {
|
protected boolean delete(UUID uuid) throws ResourceRegistryException {
|
||||||
ContextManagement contextManagement = new ContextManagement();
|
ContextManagement contextManagement = new ContextManagement();
|
||||||
contextManagement.setUUID(uuid);
|
contextManagement.setUUID(uuid);
|
||||||
|
@ -145,7 +146,7 @@ public class ContextManagementTest extends ScopedTest {
|
||||||
SecurityContext securityContext = ContextUtility.getInstance().getSecurityContextByUUID(uuid);
|
SecurityContext securityContext = ContextUtility.getInstance().getSecurityContextByUUID(uuid);
|
||||||
|
|
||||||
UUID oldParentUUID = null;
|
UUID oldParentUUID = null;
|
||||||
if(securityContext.getParentSecurityContext()!=null) {
|
if(securityContext.getParentSecurityContext() != null) {
|
||||||
oldParentUUID = securityContext.getParentSecurityContext().getUUID();
|
oldParentUUID = securityContext.getParentSecurityContext().getUUID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,35 +156,35 @@ public class ContextManagementTest extends ScopedTest {
|
||||||
logger.debug("Deleted {} with UUID {}", Context.NAME, uuid);
|
logger.debug("Deleted {} with UUID {}", Context.NAME, uuid);
|
||||||
return deleted;
|
return deleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean delete(Context context) throws ResourceRegistryException {
|
protected boolean delete(Context context) throws ResourceRegistryException {
|
||||||
return delete(context.getHeader().getUUID());
|
return delete(context.getHeader().getUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void invalidCreate(Context context) throws ResourceRegistryException, IOException {
|
protected void invalidCreate(Context context) throws ResourceRegistryException, IOException {
|
||||||
try {
|
try {
|
||||||
Context c = create(context);
|
Context c = create(context);
|
||||||
throw new RuntimeException(ISMapper.marshal(c) + " was created successfully. This is not what we expected");
|
throw new RuntimeException(ISMapper.marshal(c) + " was created successfully. This is not what we expected");
|
||||||
} catch (ContextAlreadyPresentException e) {
|
} catch(ContextAlreadyPresentException e) {
|
||||||
logger.debug("As expected {} cannot be created.", ISMapper.marshal(context));
|
logger.debug("As expected {} cannot be created.", ISMapper.marshal(context));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void invalidUpdate(Context context) throws ResourceRegistryException, IOException {
|
protected void invalidUpdate(Context context) throws ResourceRegistryException, IOException {
|
||||||
try {
|
try {
|
||||||
Context c = update(context);
|
Context c = update(context);
|
||||||
throw new RuntimeException(ISMapper.marshal(c) + " was updated successfully. This is not what we expected");
|
throw new RuntimeException(ISMapper.marshal(c) + " was updated successfully. This is not what we expected");
|
||||||
} catch (ContextAlreadyPresentException e) {
|
} catch(ContextAlreadyPresentException e) {
|
||||||
logger.debug("As expected {} cannot be updated.", ISMapper.marshal(context));
|
logger.debug("As expected {} cannot be updated.", ISMapper.marshal(context));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void invalidDelete(Context context) throws ResourceRegistryException, JsonProcessingException {
|
protected void invalidDelete(Context context) throws ResourceRegistryException, JsonProcessingException {
|
||||||
String contextString = ISMapper.marshal(context);
|
String contextString = ISMapper.marshal(context);
|
||||||
try {
|
try {
|
||||||
delete(context);
|
delete(context);
|
||||||
throw new RuntimeException(contextString + " was deleted successfully. This is not what we expected");
|
throw new RuntimeException(contextString + " was deleted successfully. This is not what we expected");
|
||||||
} catch (ContextException e) {
|
} catch(ContextException e) {
|
||||||
logger.debug("As expected {} cannot be deleted.", contextString);
|
logger.debug("As expected {} cannot be deleted.", contextString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -193,34 +194,34 @@ public class ContextManagementTest extends ScopedTest {
|
||||||
Context contextA1 = new ContextImpl(CTX_NAME_A);
|
Context contextA1 = new ContextImpl(CTX_NAME_A);
|
||||||
contextA1 = create(contextA1);
|
contextA1 = create(contextA1);
|
||||||
// ________A1________
|
// ________A1________
|
||||||
|
|
||||||
Context contextA2 = new ContextImpl(CTX_NAME_A);
|
Context contextA2 = new ContextImpl(CTX_NAME_A);
|
||||||
contextA2.setParent(contextA1);
|
contextA2.setParent(contextA1);
|
||||||
contextA2 = create(contextA2);
|
contextA2 = create(contextA2);
|
||||||
// ________A1________
|
// ________A1________
|
||||||
// ___A2
|
// ___A2
|
||||||
|
|
||||||
Context contextB3 = new ContextImpl(CTX_NAME_B);
|
Context contextB3 = new ContextImpl(CTX_NAME_B);
|
||||||
contextB3.setParent(contextA2);
|
contextB3.setParent(contextA2);
|
||||||
contextB3 = create(contextB3);
|
contextB3 = create(contextB3);
|
||||||
// ________A1________
|
// ________A1________
|
||||||
// ___A2
|
// ___A2
|
||||||
// B3
|
// B3
|
||||||
|
|
||||||
Context contextB4 = new ContextImpl(CTX_NAME_B);
|
Context contextB4 = new ContextImpl(CTX_NAME_B);
|
||||||
contextB4.setParent(contextA1);
|
contextB4.setParent(contextA1);
|
||||||
contextB4 = create(contextB4);
|
contextB4 = create(contextB4);
|
||||||
// ________A1________
|
// ________A1________
|
||||||
// ___A2_______B4____
|
// ___A2_______B4____
|
||||||
// B3
|
// B3
|
||||||
|
|
||||||
Context contextA5 = new ContextImpl(CTX_NAME_A);
|
Context contextA5 = new ContextImpl(CTX_NAME_A);
|
||||||
contextA5.setParent(contextB4);
|
contextA5.setParent(contextB4);
|
||||||
contextA5 = create(contextA5);
|
contextA5 = create(contextA5);
|
||||||
// ________A1________
|
// ________A1________
|
||||||
// ___A2_______B4____
|
// ___A2_______B4____
|
||||||
// B3______________A5
|
// B3______________A5
|
||||||
|
|
||||||
invalidCreate(contextA1); // Trying to recreate A1. Fails
|
invalidCreate(contextA1); // Trying to recreate A1. Fails
|
||||||
invalidCreate(contextA2); // Trying to recreate A2. Fails
|
invalidCreate(contextA2); // Trying to recreate A2. Fails
|
||||||
invalidCreate(contextB3); // Trying to recreate B3. Fails
|
invalidCreate(contextB3); // Trying to recreate B3. Fails
|
||||||
|
@ -242,20 +243,20 @@ public class ContextManagementTest extends ScopedTest {
|
||||||
// _____A1____B4_____
|
// _____A1____B4_____
|
||||||
// __A2__________A5__
|
// __A2__________A5__
|
||||||
// B3
|
// B3
|
||||||
|
|
||||||
contextB4.setParent(contextA1);
|
contextB4.setParent(contextA1);
|
||||||
update(contextB4);
|
update(contextB4);
|
||||||
// ________A1________
|
// ________A1________
|
||||||
// ___A2_______B4____
|
// ___A2_______B4____
|
||||||
// B3______________A5
|
// B3______________A5
|
||||||
|
|
||||||
// Trying to rename with the new name A. It fails due to A5.
|
// Trying to rename with the new name A. It fails due to A5.
|
||||||
contextB3.setName(CTX_NAME_A);
|
contextB3.setName(CTX_NAME_A);
|
||||||
update(contextB3);
|
update(contextB3);
|
||||||
// ________A1________
|
// ________A1________
|
||||||
// ___A2_______B4____
|
// ___A2_______B4____
|
||||||
// A3______________A5
|
// A3______________A5
|
||||||
|
|
||||||
// After Restoring name B, trying to move B3 as child of A1. It fails due to B4.
|
// After Restoring name B, trying to move B3 as child of A1. It fails due to B4.
|
||||||
contextB3.setName(CTX_NAME_B);
|
contextB3.setName(CTX_NAME_B);
|
||||||
contextB3.setParent(contextA1);
|
contextB3.setParent(contextA1);
|
||||||
|
@ -263,7 +264,7 @@ public class ContextManagementTest extends ScopedTest {
|
||||||
// ________A1________
|
// ________A1________
|
||||||
// ___A2_______B4____
|
// ___A2_______B4____
|
||||||
// A3______________A5
|
// A3______________A5
|
||||||
|
|
||||||
// Restoring A3 (was B3) as B3 and with parent A2.OK.
|
// Restoring A3 (was B3) as B3 and with parent A2.OK.
|
||||||
contextB3.setName(CTX_NAME_B);
|
contextB3.setName(CTX_NAME_B);
|
||||||
contextB3.setParent(contextA2);
|
contextB3.setParent(contextA2);
|
||||||
|
@ -271,12 +272,12 @@ public class ContextManagementTest extends ScopedTest {
|
||||||
// ________A1________
|
// ________A1________
|
||||||
// ___A2_______B4____
|
// ___A2_______B4____
|
||||||
// B3______________A5
|
// B3______________A5
|
||||||
|
|
||||||
// This update should not has eny effects except updating the lastUpdateTime.
|
// This update should not has eny effects except updating the lastUpdateTime.
|
||||||
contextB3.setName(CTX_NAME_B);
|
contextB3.setName(CTX_NAME_B);
|
||||||
contextB3.setParent(contextA2);
|
contextB3.setParent(contextA2);
|
||||||
update(contextB3);
|
update(contextB3);
|
||||||
|
|
||||||
// Trying to move A5 as child of A1. It fails due to A2.
|
// Trying to move A5 as child of A1. It fails due to A2.
|
||||||
contextA5.setParent(contextA1);
|
contextA5.setParent(contextA1);
|
||||||
invalidUpdate(contextA5);
|
invalidUpdate(contextA5);
|
||||||
|
@ -285,49 +286,49 @@ public class ContextManagementTest extends ScopedTest {
|
||||||
// ________A1________
|
// ________A1________
|
||||||
// ___A2_______B4____
|
// ___A2_______B4____
|
||||||
// B3______________A5
|
// B3______________A5
|
||||||
|
|
||||||
// Moving B3 as child of B4. OK.
|
// Moving B3 as child of B4. OK.
|
||||||
contextB3.setParent(contextB4);
|
contextB3.setParent(contextB4);
|
||||||
update(contextB3);
|
update(contextB3);
|
||||||
// ________A1________
|
// ________A1________
|
||||||
// ___A2_______B4____
|
// ___A2_______B4____
|
||||||
// ________B3______A5
|
// ________B3______A5
|
||||||
|
|
||||||
// Restoring the initial situation by moving B3 as child of A2. OK.
|
// Restoring the initial situation by moving B3 as child of A2. OK.
|
||||||
contextB3.setParent(contextA2);
|
contextB3.setParent(contextA2);
|
||||||
update(contextB3);
|
update(contextB3);
|
||||||
// ________A1________
|
// ________A1________
|
||||||
// ___A2_______B4____
|
// ___A2_______B4____
|
||||||
// B3______________A5
|
// B3______________A5
|
||||||
|
|
||||||
// Renaming B3 as C3. OK.
|
// Renaming B3 as C3. OK.
|
||||||
contextB3.setName(CTX_NAME_C);
|
contextB3.setName(CTX_NAME_C);
|
||||||
update(contextB3);
|
update(contextB3);
|
||||||
// ________A1________
|
// ________A1________
|
||||||
// ___A2_______B4____
|
// ___A2_______B4____
|
||||||
// C3______________A5
|
// C3______________A5
|
||||||
|
|
||||||
// Moving C3 (was B3) as child of A1. Now it is possible. OK.
|
// Moving C3 (was B3) as child of A1. Now it is possible. OK.
|
||||||
contextB3.setParent(contextA1);
|
contextB3.setParent(contextA1);
|
||||||
update(contextB3);
|
update(contextB3);
|
||||||
// ________A1________
|
// ________A1________
|
||||||
// ___A2___C3___B4___
|
// ___A2___C3___B4___
|
||||||
// ________________A5
|
// ________________A5
|
||||||
|
|
||||||
// Trying to rename C3 (was B3) newly to B3. Fails due to B4.
|
// Trying to rename C3 (was B3) newly to B3. Fails due to B4.
|
||||||
contextB3.setName(CTX_NAME_B);
|
contextB3.setName(CTX_NAME_B);
|
||||||
invalidUpdate(contextB3);
|
invalidUpdate(contextB3);
|
||||||
// ________A1________
|
// ________A1________
|
||||||
// ___A2___C3___B4___
|
// ___A2___C3___B4___
|
||||||
// ________________A5
|
// ________________A5
|
||||||
|
|
||||||
// Moving back C3 (was B3) as child of A2. OK.
|
// Moving back C3 (was B3) as child of A2. OK.
|
||||||
contextB3.setParent(contextA2);
|
contextB3.setParent(contextA2);
|
||||||
update(contextB3);
|
update(contextB3);
|
||||||
// ________A1________
|
// ________A1________
|
||||||
// ___A2_______B4____
|
// ___A2_______B4____
|
||||||
// C3______________A5
|
// C3______________A5
|
||||||
|
|
||||||
// Renaming C3 (was B3) to B3. OK.
|
// Renaming C3 (was B3) to B3. OK.
|
||||||
contextB3.setName(CTX_NAME_B);
|
contextB3.setName(CTX_NAME_B);
|
||||||
update(contextB3);
|
update(contextB3);
|
||||||
|
@ -372,7 +373,6 @@ public class ContextManagementTest extends ScopedTest {
|
||||||
// B3______________A5
|
// B3______________A5
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
// The following delete are not allowed because they are not child contexts
|
// The following delete are not allowed because they are not child contexts
|
||||||
invalidDelete(contextA1);
|
invalidDelete(contextA1);
|
||||||
invalidDelete(contextA2);
|
invalidDelete(contextA2);
|
||||||
|
@ -382,34 +382,34 @@ public class ContextManagementTest extends ScopedTest {
|
||||||
// ________A1________
|
// ________A1________
|
||||||
// ___A2_______B4____
|
// ___A2_______B4____
|
||||||
// B3
|
// B3
|
||||||
|
|
||||||
try {
|
try {
|
||||||
delete(contextA5);
|
delete(contextA5);
|
||||||
} catch (ContextNotFoundException e) {
|
} catch(ContextNotFoundException e) {
|
||||||
logger.debug("The context with uuid {} was not found. (Was already deleted)",
|
logger.debug("The context with uuid {} was not found. (Was already deleted)",
|
||||||
contextA5.getHeader().getUUID());
|
contextA5.getHeader().getUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
delete(contextB3);
|
delete(contextB3);
|
||||||
// ________A1________
|
// ________A1________
|
||||||
// ___A2_______B4____
|
// ___A2_______B4____
|
||||||
|
|
||||||
delete(contextB4);
|
delete(contextB4);
|
||||||
// ________A1________
|
// ________A1________
|
||||||
// ___A2
|
// ___A2
|
||||||
|
|
||||||
delete(contextA2);
|
delete(contextA2);
|
||||||
// ________A1________
|
// ________A1________
|
||||||
|
|
||||||
Context contextC = new ContextImpl(CTX_NAME_C);
|
Context contextC = new ContextImpl(CTX_NAME_C);
|
||||||
contextC.setHeader(new HeaderImpl(contextA1.getHeader().getUUID()));
|
contextC.setHeader(new HeaderImpl(contextA1.getHeader().getUUID()));
|
||||||
invalidCreate(contextC);
|
invalidCreate(contextC);
|
||||||
|
|
||||||
delete(contextA1);
|
delete(contextA1);
|
||||||
logger.debug("The DB should be now clean");
|
logger.debug("The DB should be now clean");
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Context> getAll() throws Exception{
|
private List<Context> getAll() throws Exception {
|
||||||
ContextManagement contextManagement = new ContextManagement();
|
ContextManagement contextManagement = new ContextManagement();
|
||||||
String allString = contextManagement.all(false);
|
String allString = contextManagement.all(false);
|
||||||
logger.trace(allString);
|
logger.trace(allString);
|
||||||
|
@ -437,10 +437,10 @@ public class ContextManagementTest extends ScopedTest {
|
||||||
@Test
|
@Test
|
||||||
public void testGetAll() throws Exception {
|
public void testGetAll() throws Exception {
|
||||||
List<Context> contexts = getAll();
|
List<Context> contexts = getAll();
|
||||||
for (Context context : contexts) {
|
for(Context context : contexts) {
|
||||||
logger.trace(ISMapper.marshal(context));
|
logger.trace(ISMapper.marshal(context));
|
||||||
List<IsParentOf<Context, Context>> children = context.getChildren();
|
List<IsParentOf<Context,Context>> children = context.getChildren();
|
||||||
for (IsParentOf<Context, Context> child : children) {
|
for(IsParentOf<Context,Context> child : children) {
|
||||||
Assert.assertTrue(child.getSource() == context);
|
Assert.assertTrue(child.getSource() == context);
|
||||||
Context childContext = child.getTarget();
|
Context childContext = child.getTarget();
|
||||||
Assert.assertTrue(childContext.getParent().getSource() == context);
|
Assert.assertTrue(childContext.getParent().getSource() == context);
|
||||||
|
@ -448,18 +448,17 @@ public class ContextManagementTest extends ScopedTest {
|
||||||
roleUserAssertions(context.getHeader().getUUID(), null, false);
|
roleUserAssertions(context.getHeader().getUUID(), null, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Test
|
// @Test
|
||||||
public void readContext() throws ResourceRegistryException, IOException {
|
public void readContext() throws ResourceRegistryException, IOException {
|
||||||
Context context = read(UUID.fromString(""));
|
Context context = read(UUID.fromString(""));
|
||||||
logger.debug("{}", context);
|
logger.debug("{}", context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// @Test
|
// @Test
|
||||||
public void deleteContext() throws ResourceRegistryException, IOException {
|
public void deleteContext() throws ResourceRegistryException, IOException {
|
||||||
Context context = read(UUID.fromString(""));
|
Context context = read(UUID.fromString(""));
|
||||||
delete(context);
|
delete(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue