Loading src/main/java/org/etsi/osl/tmf/stm653/model/EntitySpecification.java −16 Viewed Changes for src/main/java/org/etsi/osl/tmf/stm653/model/EntitySpecification.java: 0 added lines, 16 removed lines. Original line number Diff line number Diff line Loading @@ -168,22 +168,6 @@ public class EntitySpecification extends BaseEntity { return this; } /** * Date and time of the last update of this REST resource * * @return lastUpdate **/ @Schema(description = "Date and time of the last update of this REST resource") @Valid public OffsetDateTime getLastUpdate() { return lastUpdate; } public void setLastUpdate(OffsetDateTime lastUpdate) { this.lastUpdate = lastUpdate; } public EntitySpecification lifecycleStatus(String lifecycleStatus) { this.lifecycleStatus = lifecycleStatus; return this; Loading src/test/java/org/etsi/osl/tmf/stm653/model/EntitySpecificationJsonDatesTest.java +45 Viewed Changes for src/test/java/org/etsi/osl/tmf/stm653/model/EntitySpecificationJsonDatesTest.java: 45 added lines, 0 removed lines. Original line number Diff line number Diff line package org.etsi.osl.tmf.stm653.model; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import java.time.OffsetDateTime; import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.jupiter.api.Test; /** * EntitySpecification.lastUpdate must read and write with a plain {@link ObjectMapper} (no JavaTimeModule), * which is what Camel's Jackson data format uses. * * <p>Regression: EntitySpecification used to re-declare {@code setLastUpdate(OffsetDateTime)}. * Jackson prefers a setter declared in the subclass over BaseEntity's String setter, so reading * "lastUpdate" failed with "Java 8 date/time type OffsetDateTime not supported by default". */ public class EntitySpecificationJsonDatesTest { private static final String LAST_UPDATE = "2026-11-01T10:00:00+02:00"; private final ObjectMapper mapper = new ObjectMapper(); @Test public void entitySpecificationLastUpdateReads() throws Exception { String json = "{\"name\":\"aSpec\",\"lastUpdate\":\"" + LAST_UPDATE + "\"}"; EntitySpecification es = mapper.readValue(json, EntitySpecification.class); assertEquals(OffsetDateTime.parse(LAST_UPDATE), es.getLastUpdate()); } @Test public void entitySpecificationLastUpdateRoundTripsAsIsoString() throws Exception { EntitySpecification es = new EntitySpecification(); es.setName("aSpec"); es.setLastUpdate(OffsetDateTime.parse(LAST_UPDATE)); String json = mapper.writeValueAsString(es); assertTrue(json.contains("\"lastUpdate\":\"" + OffsetDateTime.parse(LAST_UPDATE) + "\""), json); EntitySpecification back = mapper.readValue(json, EntitySpecification.class); assertEquals(OffsetDateTime.parse(LAST_UPDATE), back.getLastUpdate()); } } Loading
src/main/java/org/etsi/osl/tmf/stm653/model/EntitySpecification.java −16 Viewed Changes for src/main/java/org/etsi/osl/tmf/stm653/model/EntitySpecification.java: 0 added lines, 16 removed lines. Original line number Diff line number Diff line Loading @@ -168,22 +168,6 @@ public class EntitySpecification extends BaseEntity { return this; } /** * Date and time of the last update of this REST resource * * @return lastUpdate **/ @Schema(description = "Date and time of the last update of this REST resource") @Valid public OffsetDateTime getLastUpdate() { return lastUpdate; } public void setLastUpdate(OffsetDateTime lastUpdate) { this.lastUpdate = lastUpdate; } public EntitySpecification lifecycleStatus(String lifecycleStatus) { this.lifecycleStatus = lifecycleStatus; return this; Loading
src/test/java/org/etsi/osl/tmf/stm653/model/EntitySpecificationJsonDatesTest.java +45 Viewed Changes for src/test/java/org/etsi/osl/tmf/stm653/model/EntitySpecificationJsonDatesTest.java: 45 added lines, 0 removed lines. Original line number Diff line number Diff line package org.etsi.osl.tmf.stm653.model; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import java.time.OffsetDateTime; import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.jupiter.api.Test; /** * EntitySpecification.lastUpdate must read and write with a plain {@link ObjectMapper} (no JavaTimeModule), * which is what Camel's Jackson data format uses. * * <p>Regression: EntitySpecification used to re-declare {@code setLastUpdate(OffsetDateTime)}. * Jackson prefers a setter declared in the subclass over BaseEntity's String setter, so reading * "lastUpdate" failed with "Java 8 date/time type OffsetDateTime not supported by default". */ public class EntitySpecificationJsonDatesTest { private static final String LAST_UPDATE = "2026-11-01T10:00:00+02:00"; private final ObjectMapper mapper = new ObjectMapper(); @Test public void entitySpecificationLastUpdateReads() throws Exception { String json = "{\"name\":\"aSpec\",\"lastUpdate\":\"" + LAST_UPDATE + "\"}"; EntitySpecification es = mapper.readValue(json, EntitySpecification.class); assertEquals(OffsetDateTime.parse(LAST_UPDATE), es.getLastUpdate()); } @Test public void entitySpecificationLastUpdateRoundTripsAsIsoString() throws Exception { EntitySpecification es = new EntitySpecification(); es.setName("aSpec"); es.setLastUpdate(OffsetDateTime.parse(LAST_UPDATE)); String json = mapper.writeValueAsString(es); assertTrue(json.contains("\"lastUpdate\":\"" + OffsetDateTime.parse(LAST_UPDATE) + "\""), json); EntitySpecification back = mapper.readValue(json, EntitySpecification.class); assertEquals(OffsetDateTime.parse(LAST_UPDATE), back.getLastUpdate()); } }