From 23d787e86ec0d9fbd83c99066dc724d6821b17a9 Mon Sep 17 00:00:00 2001 From: Daniel <d.hornung@indiscale.com> Date: Fri, 4 Mar 2022 19:07:05 +0100 Subject: [PATCH] TEST: Unit test to guard against the server not updating list props. This is an additional safeguard against issue #217, in addition to the existing Python integration test. --- .../caosdb/server/transaction/UpdateTest.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/test/java/org/caosdb/server/transaction/UpdateTest.java b/src/test/java/org/caosdb/server/transaction/UpdateTest.java index 36cce88a..f8cd30f6 100644 --- a/src/test/java/org/caosdb/server/transaction/UpdateTest.java +++ b/src/test/java/org/caosdb/server/transaction/UpdateTest.java @@ -256,4 +256,36 @@ public class UpdateTest { assertEquals(newEntity.getEntityStatus(), QUALIFIED); assertEquals(newProperty.getEntityStatus(), QUALIFIED); } + + /** + * For issue #217: Server gets list property datatype wrong if description is updated. + */ + @Test + public void testDeriveUpdate_UpdateList() + throws NoSuchAlgorithmException, CaosDBException, IOException { + final Property oldProperty = new Property(1); + final Property newProperty = new Property(1); + oldProperty.setDatatype("List<Person>"); + newProperty.setDatatype("List<Person>"); + final Entity oldEntity = new Entity(); + final Entity newEntity = new Entity(); + + oldProperty.setRole("Record"); + newProperty.setRole("Property"); + oldEntity.addProperty(oldProperty); + newEntity.addProperty(newProperty); + + // The only difference between old and new + newEntity.setDescription("New description."); + + new WriteTransaction(null).deriveUpdate(newEntity, oldEntity); + // check if newEntity's Property is QUALIFIED. + assertEquals(QUALIFIED, newEntity.getProperties().get(0).getEntityStatus()); + + // CheckPropValid checkJob = new CheckPropValid(); + // checkJob.init(null, newEntity, null); + // checkJob.run(); + // assertTrue(newEntity.getProperties().get(0).isDatatypeOverride()); + + } } -- GitLab