You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@causeway.apache.org by da...@apache.org on 2026/04/24 07:49:26 UTC
(causeway) 16/28: CAUSEWAY-3989: [v2] adds test to demo bug
This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a commit to branch CAUSEWAY-3989
in repository https://gitbox.apache.org/repos/asf/causeway.git
commit fbfd6048e8f63ab0d498d139a807a94bcf5d6388
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Wed Apr 22 11:28:32 2026 +0100
CAUSEWAY-3989: [v2] adds test to demo bug
---
.../CommandDtoUtils_toYaml_fromYaml_Test.java | 97 ++++++++++++++++++++++
1 file changed, 97 insertions(+)
diff --git a/api/applib/src/test/java/org/apache/causeway/applib/util/schema/CommandDtoUtils_toYaml_fromYaml_Test.java b/api/applib/src/test/java/org/apache/causeway/applib/util/schema/CommandDtoUtils_toYaml_fromYaml_Test.java
new file mode 100644
index 00000000000..43ef012b482
--- /dev/null
+++ b/api/applib/src/test/java/org/apache/causeway/applib/util/schema/CommandDtoUtils_toYaml_fromYaml_Test.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.causeway.applib.util.schema;
+
+import java.util.List;
+import java.util.TimeZone;
+
+import javax.xml.datatype.DatatypeConstants;
+import javax.xml.datatype.DatatypeFactory;
+import javax.xml.datatype.XMLGregorianCalendar;
+
+import org.assertj.core.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import org.apache.causeway.commons.io.DataSource;
+import org.apache.causeway.schema.cmd.v2.ActionDto;
+import org.apache.causeway.schema.cmd.v2.CommandDto;
+import org.apache.causeway.schema.cmd.v2.ParamDto;
+import org.apache.causeway.schema.cmd.v2.ParamsDto;
+import org.apache.causeway.schema.common.v2.InteractionType;
+import org.apache.causeway.schema.common.v2.OidDto;
+import org.apache.causeway.schema.common.v2.OidsDto;
+import org.apache.causeway.schema.common.v2.ValueType;
+
+class CommandDtoUtils_toYaml_fromYaml_Test {
+
+ @Test
+ void localDate_roundtrip_is_broken_due_to_timezone_marshalling() throws Exception {
+ TimeZone originalDefault = TimeZone.getDefault();
+ TimeZone.setDefault(TimeZone.getTimeZone("Europe/Amsterdam"));
+ try {
+ XMLGregorianCalendar originalDate = DatatypeFactory.newInstance()
+ .newXMLGregorianCalendarDate(2026, 7, 1, DatatypeConstants.FIELD_UNDEFINED);
+
+ CommandDto command = new CommandDto();
+ command.setMajorVersion("2");
+ command.setMinorVersion("0");
+ command.setInteractionId("localdate-roundtrip-bug");
+ command.setUsername("sven");
+
+ OidDto oid = new OidDto();
+ oid.setType("demo.Customer");
+ oid.setId("123");
+ OidsDto targets = new OidsDto();
+ targets.getOid().add(oid);
+ command.setTargets(targets);
+
+ ParamDto localDateParam = new ParamDto();
+ localDateParam.setName("Invoice Date");
+ localDateParam.setType(ValueType.LOCAL_DATE);
+ localDateParam.setLocalDate(originalDate);
+
+ ParamsDto params = new ParamsDto();
+ params.getParameter().add(localDateParam);
+
+ ActionDto action = new ActionDto();
+ action.setLogicalMemberIdentifier("demo.Customer#invoice");
+ action.setInteractionType(InteractionType.ACTION_INVOCATION);
+ action.setParameters(params);
+ command.setMember(action);
+
+ String yaml = CommandDtoUtils.toYaml(List.of(command));
+ List<CommandDto> roundtripped = CommandDtoUtils.fromYaml(DataSource.ofStringUtf8(yaml));
+
+ XMLGregorianCalendar roundtrippedDate = ((ActionDto) roundtripped.get(0).getMember())
+ .getParameters()
+ .getParameter()
+ .get(0)
+ .getLocalDate();
+
+ // Demonstrates the current bug: localDate gets marshalled as date-time with timezone.
+ Assertions.assertThat(yaml)
+ .containsPattern("localDate:\\s+\"\\d{4}-\\d{2}-\\d{2}T.*(Z|[+-]\\d{2}:\\d{2})\"");
+ Assertions.assertThat(roundtrippedDate.toXMLFormat())
+ .isNotEqualTo(originalDate.toXMLFormat());
+ } finally {
+ TimeZone.setDefault(originalDefault);
+ }
+ }
+}
+