Skip to content

Commit 3c980f1

Browse files
committed
Increase test coverage for ProxyNode
1 parent 62ac116 commit 3c980f1

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

core/src/test/java/io/lionweb/model/impl/ProxyNodeTest.java

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package io.lionweb.model.impl;
22

3-
import static org.junit.Assert.assertEquals;
4-
import static org.junit.Assert.assertThrows;
3+
import static org.junit.Assert.*;
54

65
import io.lionweb.language.*;
76
import org.junit.Test;
@@ -18,13 +17,39 @@ public void operationsCannotBePerformed() {
1817
ProxyNode proxyNode = new ProxyNode("id-123");
1918

2019
Property p = new Property();
20+
Containment c = new Containment();
21+
ProxyNode anotherProxyNode = new ProxyNode("id-124");
2122

2223
assertThrows(ProxyNode.CannotDoBecauseProxyException.class, proxyNode::getAnnotations);
2324
assertThrows(ProxyNode.CannotDoBecauseProxyException.class, proxyNode::getClassifier);
2425
assertThrows(ProxyNode.CannotDoBecauseProxyException.class, proxyNode::getParent);
26+
assertThrows(ProxyNode.CannotDoBecauseProxyException.class, proxyNode::getContainmentFeature);
2527
assertThrows(
2628
ProxyNode.CannotDoBecauseProxyException.class, () -> proxyNode.getPropertyValue(p));
2729
assertThrows(
2830
ProxyNode.CannotDoBecauseProxyException.class, () -> proxyNode.setPropertyValue(p, "foo"));
31+
assertThrows(ProxyNode.CannotDoBecauseProxyException.class, () -> proxyNode.getChildren(c));
32+
assertThrows(
33+
ProxyNode.CannotDoBecauseProxyException.class,
34+
() -> proxyNode.addChild(c, anotherProxyNode));
35+
assertThrows(
36+
ProxyNode.CannotDoBecauseProxyException.class,
37+
() -> proxyNode.removeChild(anotherProxyNode));
38+
assertThrows(ProxyNode.CannotDoBecauseProxyException.class, () -> proxyNode.removeChild(c, 0));
39+
}
40+
41+
@Test
42+
public void auxiliaryMethods() {
43+
ProxyNode proxyNode1 = new ProxyNode("id-123");
44+
ProxyNode proxyNode2 = new ProxyNode("id-123");
45+
ProxyNode proxyNode3 = new ProxyNode("id-124");
46+
47+
assertEquals(proxyNode1, proxyNode2);
48+
assertNotEquals(proxyNode1, proxyNode3);
49+
50+
assertEquals(proxyNode1.hashCode(), proxyNode2.hashCode());
51+
assertNotEquals(proxyNode1.hashCode(), proxyNode3.hashCode());
52+
53+
assertEquals("ProxyNode(id-123)", proxyNode1.toString());
2954
}
3055
}

0 commit comments

Comments
 (0)