Skip to content

Commit d5af790

Browse files
committed
test: verify immutability of views on the context
1 parent be0aaeb commit d5af790

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

src/test/java/edu/kit/datamanager/ro_crate/context/ContextTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,8 @@ void testReadKeys() {
261261
for (String key : expected) {
262262
assertTrue(given.contains(key), "Key " + key + " not found in the context");
263263
}
264+
// prove immutability
265+
assertThrows(UnsupportedOperationException.class, () -> given.add("newKey"));
264266
}
265267

266268
@Test
@@ -273,5 +275,7 @@ void testReadPairs() {
273275
assertTrue(keys.contains(key), "Key " + key + " not found in the context");
274276
values.forEach(s -> assertFalse(s.isEmpty(), "Value for key " + key + " is empty"));
275277
}
278+
// prove immutability
279+
assertThrows(UnsupportedOperationException.class, () -> given.put("newKey", "newValue"));
276280
}
277281
}

src/test/java/edu/kit/datamanager/ro_crate/crate/TestRemoveAddContext.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ void testReadContextKeys() {
6262
for (String key : expected) {
6363
assertTrue(given.contains(key), "Key " + key + " not found in the context");
6464
}
65+
// prove immutability
66+
assertThrows(UnsupportedOperationException.class, () -> given.add("newKey"));
6567
}
6668

6769
@Test
@@ -74,5 +76,7 @@ void testReadContextPairs() {
7476
assertTrue(keys.contains(key), "Key " + key + " not found in the context");
7577
values.forEach(s -> assertFalse(s.isEmpty(), "Value for key " + key + " is empty"));
7678
}
79+
// prove immutability
80+
assertThrows(UnsupportedOperationException.class, () -> given.put("newKey", "newValue"));
7781
}
7882
}

0 commit comments

Comments
 (0)