Skip to content

Commit c2e994b

Browse files
core: trace object properties handles null properly (#1367)
1 parent 60fed04 commit c2e994b

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

webtau-core/src/main/java/org/testingisdocumenting/webtau/data/converters/ObjectProperties.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ private List<Object> unwrapCollectionProperties(Collection<?> properties) {
6464
}
6565

6666
private Object unwrappedProperties(Object v) {
67-
if (v instanceof Collection) {
67+
if (v == null) {
68+
return null;
69+
} if (v instanceof Collection) {
6870
return unwrapCollectionProperties((Collection<?>)v);
6971
} else if (v instanceof Map) {
7072
return unwrapMapProperties((Map<?, ?>) v);

webtau-core/src/test/groovy/org/testingisdocumenting/webtau/data/converters/ObjectPropertiesTest.groovy

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,18 @@ class ObjectPropertiesTest {
108108
}
109109
}
110110

111+
@Test
112+
void "table of objects with nulls"() {
113+
def game1 = new GameConfig(null, Paths.get("/games/superA"))
114+
def game2 = new GameConfig("duper game", null)
115+
116+
game1.registerAchievement("id1", "name", null)
117+
118+
runAndValidateOutput('[tracing] games\n' +
119+
' achievements │ gameName │ location \n' +
120+
' [{"description": null, "id": "id1", "name": "name"}] │ null │ /games/superA\n' +
121+
' [] │ "duper game" │ null ') {
122+
trace("games", propertiesTable([game1, game2]))
123+
}
124+
}
111125
}

0 commit comments

Comments
 (0)