Skip to content

Commit 1dcdd98

Browse files
committed
Refine new Henshin rule set with graph constraints
1 parent f0660e0 commit 1dcdd98

File tree

2 files changed

+2041
-4
lines changed

2 files changed

+2041
-4
lines changed

org.cobolt.ngctoac/src/org/cobolt/ngctoac/TopologyControlRuleTests.java

+24-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
import static org.junit.Assert.assertFalse;
55
import static org.junit.Assert.assertTrue;
66

7+
import java.io.IOException;
78
import java.util.Arrays;
89

910
import org.eclipse.emf.ecore.EObject;
1011
import org.eclipse.emf.ecore.resource.Resource;
12+
import org.eclipse.emf.ecore.util.EcoreUtil;
1113
import org.eclipse.emf.henshin.interpreter.Engine;
1214
import org.eclipse.emf.henshin.interpreter.impl.EGraphImpl;
1315
import org.eclipse.emf.henshin.interpreter.impl.EngineImpl;
@@ -17,7 +19,10 @@
1719
import org.junit.Test;
1820

1921
public class TopologyControlRuleTests {
20-
private static final String TOPOLOGY_INSTANCE_TWO_NODES = "../../../../instance/Topology.xmi";
22+
private static final String PROJECT_ROOT_RELATIVE_PATH = "../../../..";
23+
24+
private static final String TOPOLOGY_INSTANCE_TWO_NODES = PROJECT_ROOT_RELATIVE_PATH + "/instance/Topology.xmi";
25+
private static final String TOPOLOGY_INSTANCE_TEMP = PROJECT_ROOT_RELATIVE_PATH + "/output/Topology.xmi";
2126

2227
private HenshinResourceSet resourceSet;
2328

@@ -105,6 +110,8 @@ public void testCreateTriangleForbiddenByApplicationCondition1() {
105110
assertTrue(setLinkState("1->2", LinkState.ACTIVE));
106111
assertTrue(addLink_Refined("1->3", 1));
107112

113+
saveCurrentTopology();
114+
108115
assertFalse(addLink_Refined("3->2", 6));
109116
}
110117

@@ -176,4 +183,20 @@ private boolean setLinkState_Refined(final String linkId, final int newState) {
176183
private EObject getTopology() {
177184
return this.graph.getRoots().get(0);
178185
}
186+
187+
@SuppressWarnings("unused")
188+
/**
189+
* Utility function for saving the current state of the topology
190+
*/
191+
private void saveCurrentTopology() {
192+
final Resource topologyResource = this.resourceSet.getResource(TOPOLOGY_INSTANCE_TWO_NODES);
193+
final Resource tempResource = this.resourceSet.createResource(TOPOLOGY_INSTANCE_TEMP);
194+
final EObject copiedTopology = EcoreUtil.copy(topologyResource.getContents().get(0));
195+
tempResource.getContents().add(copiedTopology);
196+
try {
197+
tempResource.save(null);
198+
} catch (final IOException e) {
199+
e.printStackTrace();
200+
}
201+
}
179202
}

0 commit comments

Comments
 (0)