Skip to content

Commit ea0b480

Browse files
authored
add some test cases re flatgraph compat mode (ShiftLeftSecurity#427)
* add some test cases re flatgraph compat mode * add comment to clarify/warn the reader
1 parent 439314c commit ea0b480

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

core-tests/src/test/java/overflowdb/ElementTest.java

+11-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ public void overviewTest() {
3838
TestNode.LABEL,
3939
TestNode.STRING_PROPERTY, "node 2",
4040
TestNode.INT_PROPERTY, 52,
41-
TestNode.STRING_LIST_PROPERTY, Arrays.asList("stringThree", "stringFour"),
4241
TestNode.INT_LIST_PROPERTY, Arrays.asList(52, 53));
4342

4443
builder.addEdge(n1D, n2D,TestEdge.LABEL, TestEdge.LONG_PROPERTY, 99L);
@@ -49,13 +48,23 @@ public void overviewTest() {
4948
Node n2 = (Node)n2D.getRefOrId();
5049
Edge e = n1.outE().next();
5150

52-
// verify that we can cast to our domain-specific nodes/edges
51+
// verify that we can cast to our domain-specific nodes/edges
52+
// n.b. the results of `property` and `propertyOption` accessors depend on the domain class implementations
53+
// and might therefor be misleading - see e.g. https://github.com/joernio/joern/pull/4382: our codegen generates domain
54+
// classes that return `Some(Seq.empty)` for an undefined list property...
5355
TestNode node1 = (TestNode) n1;
56+
TestNode node2 = (TestNode) n2;
5457
assertEquals("node 1", node1.stringProperty());
5558
assertEquals("node 1", node1.property(TestNode.STRING_PROPERTY));
5659
assertEquals("node 1", node1.property(new PropertyKey<>(TestNode.STRING_PROPERTY)));
5760
assertEquals(Optional.of("node 1"), node1.propertyOption(TestNode.STRING_PROPERTY));
5861
assertEquals(Optional.of("node 1"), node1.propertyOption(new PropertyKey<>(TestNode.STRING_PROPERTY)));
62+
assertEquals(Optional.of(Arrays.asList("stringOne", "stringTwo")), node1.propertyOption(TestNode.STRING_LIST_PROPERTY));
63+
assertEquals(Optional.of(Arrays.asList("stringOne", "stringTwo")), node1.propertyOption(new PropertyKey<>(TestNode.STRING_LIST_PROPERTY)));
64+
assertEquals(Optional.empty(), node1.propertyOption("UNKNOWN_PROPERTY"));
65+
assertEquals(Optional.empty(), node1.propertyOption(new PropertyKey<>("UNKNOWN_PROPERTY")));
66+
assertEquals(Optional.empty(), node2.propertyOption(TestNode.STRING_LIST_PROPERTY));
67+
assertEquals(Optional.empty(), node2.propertyOption(new PropertyKey<>(TestNode.STRING_LIST_PROPERTY)));
5968
assertEquals(Integer.valueOf(42), node1.intProperty());
6069
assertEquals(Arrays.asList("stringOne", "stringTwo"), node1.stringListProperty());
6170
assertEquals(Arrays.asList(42, 43), node1.intListProperty());

0 commit comments

Comments
 (0)