parent
27cec7ec31
commit
58d7aa93c3
|
@ -114,7 +114,7 @@ public class ContextUtility {
|
|||
contexts.put(securityContext.getUUID(), securityContext);
|
||||
}
|
||||
|
||||
private synchronized SecurityContext getSecurityContextByFullName(String fullName) throws ContextException {
|
||||
public synchronized SecurityContext getSecurityContextByFullName(String fullName) throws ContextException {
|
||||
try {
|
||||
SecurityContext securityContext = null;
|
||||
|
||||
|
|
|
@ -780,7 +780,7 @@ public abstract class ElementManagement<El extends OElement> {
|
|||
|
||||
return affectedInstances;
|
||||
} catch(ResourceRegistryException e) {
|
||||
logger.error("Unable to add {} with UUID {} to Context with UUID {} - Cause is {}", elementType, uuid, contextUUID, e.getMessage());
|
||||
logger.error("Unable to add {} with UUID {} to Context with UUID {} - Reason is {}", elementType, uuid, contextUUID, e.getMessage());
|
||||
if(oDatabaseDocument != null) {
|
||||
oDatabaseDocument.rollback();
|
||||
}
|
||||
|
|
|
@ -111,12 +111,12 @@ public class ElementManagementUtility {
|
|||
}
|
||||
}
|
||||
|
||||
private static OElement getAnyElementByUUID(ODatabaseDocument orientGraph, UUID uuid)
|
||||
public static OElement getAnyElementByUUID(ODatabaseDocument oDatabaseDocument, UUID uuid)
|
||||
throws NotFoundException, ResourceRegistryException {
|
||||
try {
|
||||
return Utility.getElementByUUID(orientGraph, null, uuid, OVertex.class);
|
||||
return Utility.getElementByUUID(oDatabaseDocument, null, uuid, OVertex.class);
|
||||
} catch(NotFoundException e) {
|
||||
return Utility.getElementByUUID(orientGraph, null, uuid, OEdge.class);
|
||||
return Utility.getElementByUUID(oDatabaseDocument, null, uuid, OEdge.class);
|
||||
} catch(ResourceRegistryException e) {
|
||||
throw e;
|
||||
} catch(Exception e) {
|
||||
|
|
|
@ -298,14 +298,14 @@ public abstract class EntityManagement<E extends EntityElement> extends EntityEl
|
|||
}
|
||||
|
||||
public String reallyQuery(String relationType, String referenceType, UUID referenceUUID, ODirection direction,
|
||||
boolean polymorphic, Map<String,String> constraint) throws ResourceRegistryException {
|
||||
boolean polymorphic, Map<String,String> constraint, boolean includeRelationInResult) throws ResourceRegistryException {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
ArrayNode arrayNode = objectMapper.createArrayNode();
|
||||
|
||||
Iterable<?> references = null;
|
||||
|
||||
if(referenceUUID != null) {
|
||||
OElement element = ElementManagementUtility.getAnyElementByUUID(referenceUUID);
|
||||
OElement element = ElementManagementUtility.getAnyElementByUUID(oDatabaseDocument, referenceUUID);
|
||||
if(element instanceof OVertex) {
|
||||
@SuppressWarnings("unchecked")
|
||||
EntityManagement<Entity> entityManagement = ElementManagementUtility.getEntityManagement(getWorkingContext(),
|
||||
|
@ -415,14 +415,27 @@ public abstract class EntityManagement<E extends EntityElement> extends EntityEl
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
EntityManagement entityManagement = ElementManagementUtility.getEntityManagement(getWorkingContext(),
|
||||
oDatabaseDocument, vertex);
|
||||
|
||||
try {
|
||||
if(referenceUUID!=null && entityManagement.getUUID().compareTo(referenceUUID) == 0) {
|
||||
continue;
|
||||
}
|
||||
JsonNode jsonNode = entityManagement.serializeAsJson();
|
||||
|
||||
JsonNode jsonNode;
|
||||
if(includeRelationInResult) {
|
||||
@SuppressWarnings("rawtypes")
|
||||
RelationManagement relationManagement = ElementManagementUtility.getRelationManagement(getWorkingContext(),
|
||||
oDatabaseDocument, edge);
|
||||
jsonNode = relationManagement.serializeAsJson();
|
||||
}else {
|
||||
jsonNode = entityManagement.serializeAsJson();
|
||||
}
|
||||
|
||||
arrayNode.add(jsonNode);
|
||||
} catch(ResourceRegistryException e) {
|
||||
logger.error("Unable to correctly serialize {}. It will be excluded from results. {}",
|
||||
|
@ -547,7 +560,7 @@ public abstract class EntityManagement<E extends EntityElement> extends EntityEl
|
|||
}
|
||||
|
||||
public String query(String relationType, String referenceType, UUID referenceUUID, ODirection direction,
|
||||
boolean polymorphic, Map<String,String> constraint) throws ResourceRegistryException {
|
||||
boolean polymorphic, Map<String,String> constraint, boolean includeRelationInResult) throws ResourceRegistryException {
|
||||
try {
|
||||
oDatabaseDocument = getWorkingContext().getDatabaseDocument(PermissionMode.READER);
|
||||
|
||||
|
@ -601,7 +614,7 @@ public abstract class EntityManagement<E extends EntityElement> extends EntityEl
|
|||
break;
|
||||
}
|
||||
|
||||
return reallyQuery(relationType, referenceType, referenceUUID, direction, polymorphic, constraint);
|
||||
return reallyQuery(relationType, referenceType, referenceUUID, direction, polymorphic, constraint, includeRelationInResult);
|
||||
|
||||
} catch(ResourceRegistryException e) {
|
||||
throw e;
|
||||
|
|
|
@ -333,7 +333,7 @@ public class Access extends BaseRest {
|
|||
* All the EService identified By a SoftwareFacet :
|
||||
* GET /access/query/EService/isIdentifiedBy/SoftwareFacet?polymorphic=true&direction=out
|
||||
*
|
||||
* The Eservice identified By the SoftwareFacet with UUID 7bc997c3-d005-40ff-b9ed-c4b6a35851f1 :
|
||||
* All the EService identified By the SoftwareFacet with UUID 7bc997c3-d005-40ff-b9ed-c4b6a35851f1 :
|
||||
* GET /access/query/EService/isIdentifiedBy/SoftwareFacet?reference=7bc997c3-d005-40ff-b9ed-c4b6a35851f1&polymorphic=true&direction=out
|
||||
*
|
||||
* All the Resources identified By a ContactFacet :
|
||||
|
@ -362,6 +362,7 @@ public class Access extends BaseRest {
|
|||
@QueryParam(AccessPath.REFERENCE_PARAM) String reference,
|
||||
@QueryParam(AccessPath.POLYMORPHIC_PARAM) @DefaultValue("false") Boolean polymorphic,
|
||||
@QueryParam(AccessPath.DIRECTION_PARAM) @DefaultValue("out") String direction,
|
||||
@QueryParam(AccessPath.INCLUDE_RELATION_PARAM) @DefaultValue("false") Boolean includeRelation,
|
||||
@Context UriInfo uriInfo) throws ResourceRegistryException {
|
||||
|
||||
logger.info("Requested {} instances having a(n) {} ({}={}} with {} ({}={})", resourcetype, relationType,
|
||||
|
@ -417,7 +418,7 @@ public class Access extends BaseRest {
|
|||
}
|
||||
|
||||
return ((ResourceManagement) erManagement).query(relationType, referenceType, refereceUUID, directionEnum,
|
||||
polymorphic, constraint);
|
||||
polymorphic, constraint, includeRelation);
|
||||
}
|
||||
|
||||
String error = String.format("%s is not a %s type", resourcetype, Resource.NAME);
|
||||
|
|
|
@ -65,7 +65,11 @@ public class ContextTest {
|
|||
}
|
||||
}
|
||||
|
||||
public static String getCurrentScope(String token) throws ObjectNotFound, Exception {
|
||||
public static String getCurrentContextFullName() throws ObjectNotFound, Exception {
|
||||
return getContextFullNameByToken(SecurityTokenProvider.instance.get());
|
||||
}
|
||||
|
||||
public static String getContextFullNameByToken(String token) throws ObjectNotFound, Exception {
|
||||
AuthorizationEntry authorizationEntry = Constants.authorizationService().get(token);
|
||||
String context = authorizationEntry.getContext();
|
||||
logger.info("Context of token {} is {}", token, context);
|
||||
|
@ -85,7 +89,7 @@ public class ContextTest {
|
|||
String qualifier = authorizationEntry.getQualifier();
|
||||
Caller caller = new Caller(clientInfo, qualifier);
|
||||
AuthorizationProvider.instance.set(caller);
|
||||
ScopeProvider.instance.set(getCurrentScope(token));
|
||||
ScopeProvider.instance.set(getContextFullNameByToken(token));
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
|
|
|
@ -711,32 +711,34 @@ public class ERManagementTest extends ContextTest {
|
|||
ResourceManagement resourceManagement = new ResourceManagement();
|
||||
resourceManagement.setElementType(Service.NAME);
|
||||
|
||||
boolean includeRelation = false;
|
||||
|
||||
/* Getting Hosting Node */
|
||||
String json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.BOTH, true, null);
|
||||
String json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.BOTH, true, null, includeRelation);
|
||||
List<Resource> resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
||||
Assert.assertTrue(resourceList.size()==1);
|
||||
Resource resource = resourceList.get(0);
|
||||
Assert.assertTrue(resource.getHeader().getUUID().compareTo(hostingNodeUUID)==0);
|
||||
|
||||
json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.OUT, true, null);
|
||||
json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.OUT, true, null, includeRelation);
|
||||
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
||||
Assert.assertTrue(resourceList.size()==1);
|
||||
resource = resourceList.get(0);
|
||||
Assert.assertTrue(resource.getHeader().getUUID().compareTo(hostingNodeUUID)==0);
|
||||
|
||||
json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.IN, true, null);
|
||||
json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.IN, true, null, includeRelation);
|
||||
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
||||
Assert.assertTrue(resourceList.size()==0);
|
||||
|
||||
|
||||
|
||||
json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.BOTH, false, null);
|
||||
json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.BOTH, false, null, includeRelation);
|
||||
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
||||
Assert.assertTrue(resourceList.size()==0);
|
||||
json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.OUT, false, null);
|
||||
json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.OUT, false, null, includeRelation);
|
||||
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
||||
Assert.assertTrue(resourceList.size()==0);
|
||||
json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.IN, false, null);
|
||||
json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.IN, false, null, includeRelation);
|
||||
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
||||
Assert.assertTrue(resourceList.size()==0);
|
||||
/* END Getting Hosting Node */
|
||||
|
@ -744,29 +746,29 @@ public class ERManagementTest extends ContextTest {
|
|||
|
||||
|
||||
/* Getting EService */
|
||||
json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.BOTH, true, null);
|
||||
json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.BOTH, true, null, includeRelation);
|
||||
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
||||
Assert.assertTrue(resourceList.size()==1);
|
||||
Assert.assertTrue(resourceList.get(0).getHeader().getUUID().compareTo(eServiceUUID)==0);
|
||||
|
||||
json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.OUT, true, null);
|
||||
json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.OUT, true, null, includeRelation);
|
||||
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
||||
Assert.assertTrue(resourceList.size()==0);
|
||||
|
||||
json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.IN, true, null);
|
||||
json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.IN, true, null, includeRelation);
|
||||
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
||||
Assert.assertTrue(resourceList.size()==1);
|
||||
Assert.assertTrue(resourceList.get(0).getHeader().getUUID().compareTo(eServiceUUID)==0);
|
||||
|
||||
json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.BOTH, false, null);
|
||||
json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.BOTH, false, null, includeRelation);
|
||||
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
||||
Assert.assertTrue(resourceList.size()==0);
|
||||
|
||||
json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.OUT, false, null);
|
||||
json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.OUT, false, null, includeRelation);
|
||||
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
||||
Assert.assertTrue(resourceList.size()==0);
|
||||
|
||||
json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.IN, false, null);
|
||||
json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.IN, false, null, includeRelation);
|
||||
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
||||
Assert.assertTrue(resourceList.size()==0);
|
||||
/* END Getting HostingNode */
|
||||
|
@ -777,12 +779,12 @@ public class ERManagementTest extends ContextTest {
|
|||
|
||||
/* EService --ConsistsOf--> SoftwareFacet*/
|
||||
try {
|
||||
json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, ODirection.BOTH, true, null);
|
||||
json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, ODirection.BOTH, true, null, includeRelation);
|
||||
}catch(InvalidQueryException e) {
|
||||
// Ok expected
|
||||
}
|
||||
|
||||
json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, ODirection.OUT, true, null);
|
||||
json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, ODirection.OUT, true, null, includeRelation);
|
||||
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
||||
Assert.assertTrue(resourceList.size()==1);
|
||||
resource = resourceList.get(0);
|
||||
|
@ -791,24 +793,24 @@ public class ERManagementTest extends ContextTest {
|
|||
Assert.assertTrue(targetIdentificationFacet.getHeader().getUUID().compareTo(identificationFacetUUID)==0);
|
||||
|
||||
try {
|
||||
json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, ODirection.IN, true, null);
|
||||
json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, ODirection.IN, true, null, includeRelation);
|
||||
}catch(InvalidQueryException e) {
|
||||
// Ok expected
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, ODirection.BOTH, false, null);
|
||||
json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, ODirection.BOTH, false, null, includeRelation);
|
||||
}catch(InvalidQueryException e) {
|
||||
// Ok expected
|
||||
}
|
||||
|
||||
json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, ODirection.OUT, false, null);
|
||||
json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, ODirection.OUT, false, null, includeRelation);
|
||||
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
||||
Assert.assertTrue(resourceList.size()==0);
|
||||
|
||||
try {
|
||||
json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, ODirection.IN, false, null);
|
||||
json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, ODirection.IN, false, null, includeRelation);
|
||||
}catch(InvalidQueryException e) {
|
||||
// Ok expected
|
||||
}
|
||||
|
|
|
@ -117,10 +117,12 @@ public class ResourceManagementTest extends ContextTest {
|
|||
@SuppressWarnings("rawtypes")
|
||||
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
|
||||
|
||||
boolean includeRelation = false;
|
||||
|
||||
if (erManagement instanceof ResourceManagement) {
|
||||
boolean[] booleans = new boolean[] {true, false};
|
||||
for(boolean bool : booleans) {
|
||||
String ret = ((ResourceManagement) erManagement).query(relationType, facetType, null, ODirection.OUT, bool, constraint);
|
||||
String ret = ((ResourceManagement) erManagement).query(relationType, facetType, null, ODirection.OUT, bool, constraint, includeRelation);
|
||||
logger.debug("Result of query for {}polymorphic {} --{}--> {} with constaint {} is {}", bool ? "" : "NOT ",
|
||||
type, relationType, facetType, constraint, ret);
|
||||
}
|
||||
|
@ -199,7 +201,9 @@ public class ResourceManagementTest extends ContextTest {
|
|||
|
||||
Configuration expected = createdConfigurations.get(i);
|
||||
UUID expectedUUID = expected.getHeader().getUUID();
|
||||
|
||||
|
||||
boolean includeRelation = false;
|
||||
|
||||
for(Boolean polymorphic : polymorphics) {
|
||||
|
||||
|
||||
|
@ -213,7 +217,7 @@ public class ResourceManagementTest extends ContextTest {
|
|||
resourceType, relationType, referenceType, constraint);
|
||||
|
||||
String ret = resourceManagement.query(relationType, referenceType, refereceUUID, directionEnum,
|
||||
polymorphic, constraint);
|
||||
polymorphic, constraint, includeRelation);
|
||||
|
||||
List<Configuration> list = ElementMapper.unmarshalList(Configuration.class, ret);
|
||||
Assert.assertTrue(list.size()==expectedSize);
|
||||
|
@ -239,7 +243,7 @@ public class ResourceManagementTest extends ContextTest {
|
|||
parentResourceType, relationType, referenceType, constraint);
|
||||
|
||||
String retPolimorphic = parentResourceManagement.query(relationType, referenceType, refereceUUID, directionEnum,
|
||||
polymorphic, constraint);
|
||||
polymorphic, constraint, includeRelation);
|
||||
List<ConfigurationTemplate> listPolimorphic = ElementMapper.unmarshalList(ConfigurationTemplate.class, retPolimorphic);
|
||||
Assert.assertTrue(listPolimorphic.size()==expectedSize);
|
||||
|
||||
|
|
|
@ -220,11 +220,8 @@ public class BasicTest extends ContextTest {
|
|||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
logger.debug("Switching to another context");
|
||||
ContextTest.setContextByName(ALTERNATIVE_TEST_SCOPE);
|
||||
|
||||
try {
|
||||
addToContextThenTestIfBehaveProperly(eService, true);
|
||||
addToContextThenTestIfBehaveProperly(eService, true, ALTERNATIVE_TEST_SCOPE);
|
||||
}finally {
|
||||
UUID eServiceUUID = eService.getHeader().getUUID();
|
||||
resourceManagement = new ResourceManagement();
|
||||
|
@ -307,15 +304,19 @@ public class BasicTest extends ContextTest {
|
|||
|
||||
public boolean mustBeAdded(Relation<Resource, Entity> r);
|
||||
|
||||
public boolean mustBeRemoved(Relation<Resource, Entity> r);
|
||||
|
||||
}
|
||||
|
||||
protected Resource getAndAddIsRelatedTo(Resource r, RelationConstraint relationConstraint) throws ResourceRegistryException, Exception {
|
||||
ResourceManagement resourceManagement = new ResourceManagement();
|
||||
resourceManagement.setElementType(Resource.NAME);
|
||||
|
||||
String resourceType = TypeMapper.getType(r);
|
||||
// resourceManagement.setElementType(resourceType);
|
||||
UUID resourceUUID = r.getHeader().getUUID();
|
||||
|
||||
// resourceManagement.setUUID(resourceUUID);
|
||||
String ret = resourceManagement.query(IsRelatedTo.NAME, resourceType, resourceUUID, ODirection.OUT, true, new HashMap<>());
|
||||
String ret = resourceManagement.query(IsRelatedTo.NAME, resourceType, resourceUUID, ODirection.IN, true, new HashMap<>(), true);
|
||||
@SuppressWarnings("rawtypes")
|
||||
List<IsRelatedTo> isRelatedToList = ElementMapper.unmarshalList(IsRelatedTo.class, ret);
|
||||
for(@SuppressWarnings("rawtypes") IsRelatedTo isRelatedTo : isRelatedToList) {
|
||||
|
@ -342,6 +343,11 @@ public class BasicTest extends ContextTest {
|
|||
public boolean mustBeAdded(Relation<Resource, Entity> r) {
|
||||
return r.getPropagationConstraint().getAddConstraint() == AddConstraint.propagate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mustBeRemoved(Relation<Resource, Entity> r) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
@ -363,14 +369,15 @@ public class BasicTest extends ContextTest {
|
|||
return expected;
|
||||
}
|
||||
|
||||
protected void addToContextThenTestIfBehaveProperly(Resource r, boolean dryRun) throws ResourceRegistryException, Exception {
|
||||
protected void addToContextThenTestIfBehaveProperly(Resource r, boolean dryRun, String targetContextFullName) throws ResourceRegistryException, Exception {
|
||||
|
||||
Map<UUID, Element> expectedInstances = getAddedExpectedInstances(r);
|
||||
|
||||
ResourceManagement resourceManagement = new ResourceManagement();
|
||||
resourceManagement.setElementType(TypeMapper.getType(r));
|
||||
resourceManagement.setUUID(r.getHeader().getUUID());
|
||||
resourceManagement.setDryRunContextSharing(dryRun);
|
||||
UUID contextUUID = ContextUtility.getCurrentSecurityContext().getUUID();
|
||||
UUID contextUUID = ContextUtility.getInstance().getSecurityContextByFullName(targetContextFullName).getUUID();
|
||||
Map<UUID, JsonNode> affectedInstances = resourceManagement.addToContext(contextUUID);
|
||||
|
||||
SortedSet<UUID> expectedInstancesUUID = new TreeSet<>(expectedInstances.keySet());
|
||||
|
@ -490,8 +497,11 @@ public class BasicTest extends ContextTest {
|
|||
hostingNode, disk, null);
|
||||
hostingNode.addFacet(hasPersistentMemory);
|
||||
|
||||
PropagationConstraint propagationConstraint = new PropagationConstraintImpl();
|
||||
propagationConstraint.setAddConstraint(AddConstraint.unpropagate);
|
||||
propagationConstraint.setRemoveConstraint(RemoveConstraint.cascade);
|
||||
Activates<HostingNode, EService> activates = new ActivatesImpl<HostingNode, EService>(
|
||||
hostingNode, eService, null);
|
||||
hostingNode, eService, propagationConstraint);
|
||||
UUID activatedUUID = UUID.randomUUID();
|
||||
activates.setHeader(new HeaderImpl(activatedUUID));
|
||||
hostingNode.attachResource(activates);
|
||||
|
@ -515,27 +525,16 @@ public class BasicTest extends ContextTest {
|
|||
hostingNodeInstances.put(consistsOf.getTarget().getHeader().getUUID(), consistsOf.getTarget());
|
||||
}
|
||||
|
||||
/*
|
||||
IsRelatedToManagement isRelatedToManagement = new IsRelatedToManagement();
|
||||
isRelatedToManagement.setElementType(Activates.NAME);
|
||||
isRelatedToManagement.setUUID(activatedUUID);
|
||||
String activatesString = isRelatedToManagement.read();
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Activates<HostingNode, EService> unmarshalledActivates = ElementMapper.unmarshal(Activates.class, activatesString);
|
||||
// An intermediate variable has been used to suppress warning here and not to the whole test function
|
||||
activates = unmarshalledActivates;
|
||||
|
||||
hostingNode.attachResource(activates);
|
||||
*/
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
logger.debug("Switching to another context");
|
||||
ContextTest.setContextByName(ALTERNATIVE_TEST_SCOPE);
|
||||
String currentContextFulName = ContextTest.getCurrentContextFullName();
|
||||
String targetContextFullName = ALTERNATIVE_TEST_SCOPE;
|
||||
|
||||
addToContextThenTestIfBehaveProperly(hostingNode, true, targetContextFullName);
|
||||
|
||||
logger.debug("Switching to the target context");
|
||||
ContextTest.setContextByName(targetContextFullName);
|
||||
|
||||
addToContextThenTestIfBehaveProperly(hostingNode, true);
|
||||
|
||||
UUID contextUUID = ContextUtility.getCurrentSecurityContext().getUUID();
|
||||
try {
|
||||
|
@ -548,7 +547,10 @@ public class BasicTest extends ContextTest {
|
|||
// OK
|
||||
}
|
||||
|
||||
addToContextThenTestIfBehaveProperly(hostingNode, false);
|
||||
logger.debug("Switching back to the target context");
|
||||
ContextTest.setContextByName(currentContextFulName);
|
||||
|
||||
addToContextThenTestIfBehaveProperly(hostingNode, false, targetContextFullName);
|
||||
|
||||
resourceManagement = new ResourceManagement();
|
||||
resourceManagement.setUUID(hostingNodeUUID);
|
||||
|
|
Loading…
Reference in New Issue