Fixed test to properly support delete PropagationConstraint

This commit is contained in:
Luca Frosini 2023-02-07 16:58:13 +01:00
parent 6784426862
commit ea77168e2a
2 changed files with 6 additions and 3 deletions

View File

@ -23,6 +23,7 @@ import org.gcube.informationsystem.model.reference.properties.Encrypted;
import org.gcube.informationsystem.model.reference.properties.Header; import org.gcube.informationsystem.model.reference.properties.Header;
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint; import org.gcube.informationsystem.model.reference.properties.PropagationConstraint;
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint.AddConstraint; import org.gcube.informationsystem.model.reference.properties.PropagationConstraint.AddConstraint;
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint.DeleteConstraint;
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint.RemoveConstraint; import org.gcube.informationsystem.model.reference.properties.PropagationConstraint.RemoveConstraint;
import org.gcube.informationsystem.model.reference.relations.ConsistsOf; import org.gcube.informationsystem.model.reference.relations.ConsistsOf;
import org.gcube.informationsystem.model.reference.relations.IsRelatedTo; import org.gcube.informationsystem.model.reference.relations.IsRelatedTo;
@ -367,14 +368,15 @@ public class ERManagementTest extends ContextTest {
} }
public static HostingNode createHostingNode(EService eService) throws Exception { public static HostingNode createHostingNode(EService eService) throws Exception {
return createHostingNode(eService, RemoveConstraint.cascade); return createHostingNode(eService, RemoveConstraint.cascade, DeleteConstraint.cascade);
} }
public static HostingNode createHostingNode(EService eService, RemoveConstraint removeConstraint) throws Exception { public static HostingNode createHostingNode(EService eService, RemoveConstraint removeConstraint, DeleteConstraint deleteConstraint) throws Exception {
HostingNode hostingNode = ERManagementTest.instantiateValidHostingNode(); HostingNode hostingNode = ERManagementTest.instantiateValidHostingNode();
if(eService!=null) { if(eService!=null) {
PropagationConstraint propagationConstraint = new PropagationConstraintImpl(); PropagationConstraint propagationConstraint = new PropagationConstraintImpl();
propagationConstraint.setRemoveConstraint(removeConstraint); propagationConstraint.setRemoveConstraint(removeConstraint);
propagationConstraint.setDeleteConstraint(deleteConstraint);
Activates<HostingNode, EService> activates = new ActivatesImpl<HostingNode, EService>(hostingNode, eService, Activates<HostingNode, EService> activates = new ActivatesImpl<HostingNode, EService>(hostingNode, eService,
propagationConstraint); propagationConstraint);
hostingNode.attachResource(activates); hostingNode.attachResource(activates);

View File

@ -10,6 +10,7 @@ import java.util.UUID;
import org.gcube.informationsystem.base.reference.IdentifiableElement; import org.gcube.informationsystem.base.reference.IdentifiableElement;
import org.gcube.informationsystem.model.reference.entities.Resource; import org.gcube.informationsystem.model.reference.entities.Resource;
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint.DeleteConstraint;
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint.RemoveConstraint; import org.gcube.informationsystem.model.reference.properties.PropagationConstraint.RemoveConstraint;
import org.gcube.informationsystem.model.reference.relations.ConsistsOf; import org.gcube.informationsystem.model.reference.relations.ConsistsOf;
import org.gcube.informationsystem.resourceregistry.ContextTest; import org.gcube.informationsystem.resourceregistry.ContextTest;
@ -205,7 +206,7 @@ public class BasicTest extends MultiContextTest {
EService eService = ERManagementTest.createEService(); EService eService = ERManagementTest.createEService();
/* Creating HostingNode */ /* Creating HostingNode */
HostingNode hostingNode = ERManagementTest.createHostingNode(eService, removeConstraint); HostingNode hostingNode = ERManagementTest.createHostingNode(eService, removeConstraint, DeleteConstraint.cascade);
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Activates<HostingNode, EService> activates = (Activates<HostingNode, EService>) getOutcomingIsRelatedTo(hostingNode).get(0); Activates<HostingNode, EService> activates = (Activates<HostingNode, EService>) getOutcomingIsRelatedTo(hostingNode).get(0);