Loading src/main/java/org/etsi/osl/tmf/ri639/model/PhysicalResource.java +4 −15 Viewed Changes for src/main/java/org/etsi/osl/tmf/ri639/model/PhysicalResource.java: 4 added lines, 15 removed lines. Original line number Diff line number Diff line Loading @@ -142,21 +142,10 @@ public class PhysicalResource extends Resource { return this; } /** * A date time( DateTime). The date from which the resource is operating * * @return startOperatingDate **/ @Schema(description = "A date time( DateTime). The date from which the resource is operating") @Valid public OffsetDateTime getStartOperatingDate() { return startOperatingDate; } public void setStartOperatingDate(OffsetDateTime startOperatingDate) { this.startOperatingDate = startOperatingDate; } // getStartOperatingDate()/setStartOperatingDate(OffsetDateTime) are inherited from Resource. // Do not re-declare them here: Jackson prefers a setter declared in the subclass over the // parent's String setter, so a plain ObjectMapper (e.g. Camel's) could no longer deserialize // "startOperatingDate" for a PhysicalResource. public PhysicalResource versionNumber(String versionNumber) { this.versionNumber = versionNumber; Loading src/test/java/org/etsi/osl/tmf/ri639/model/PhysicalResourceJsonDatesTest.java +62 Viewed Changes for src/test/java/org/etsi/osl/tmf/ri639/model/PhysicalResourceJsonDatesTest.java: 62 added lines, 0 removed lines. Original line number Diff line number Diff line package org.etsi.osl.tmf.ri639.model; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertInstanceOf; import static org.junit.jupiter.api.Assertions.assertTrue; import java.time.OffsetDateTime; import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.jupiter.api.Test; /** * PhysicalResource dates must read and write with a plain {@link ObjectMapper} (no JavaTimeModule), * which is what Camel's Jackson data format uses. * * <p>Regression: PhysicalResource used to re-declare {@code setStartOperatingDate(OffsetDateTime)}. * Jackson prefers a setter declared in the subclass over Resource's String setter, so * EVENT.RESOURCE.ATTRCHANGED failed with "Java 8 date/time type OffsetDateTime not supported by default". */ public class PhysicalResourceJsonDatesTest { private static final String START = "2026-11-01T10:00:00Z"; private static final String END = "2027-11-01T10:00:00Z"; private static final String MANUFACTURE = "2025-01-15T08:30:00+02:00"; private final ObjectMapper mapper = new ObjectMapper(); @Test public void attrChangedNotificationWithPhysicalResourceDatesReads() throws Exception { String json = "{\"event\":{\"event\":{\"resource\":{" + "\"@type\":\"PhysicalResource\",\"name\":\"aPhysical\"," + "\"startOperatingDate\":\"" + START + "\"," + "\"endOperatingDate\":\"" + END + "\"," + "\"manufactureDate\":\"" + MANUFACTURE + "\"}}}}"; ResourceAttributeValueChangeNotification n = mapper.readValue(json, ResourceAttributeValueChangeNotification.class); Resource r = n.getEvent().getEvent().getResource(); PhysicalResource pr = assertInstanceOf(PhysicalResource.class, r); assertEquals(OffsetDateTime.parse(START), pr.getStartOperatingDate()); assertEquals(OffsetDateTime.parse(END), pr.getEndOperatingDate()); assertEquals(OffsetDateTime.parse(MANUFACTURE), pr.getManufactureDate()); } @Test public void physicalResourceDatesRoundTripAsIsoStrings() throws Exception { PhysicalResource pr = new PhysicalResource(); pr.setName("aPhysical"); pr.setType("PhysicalResource"); pr.setStartOperatingDate(OffsetDateTime.parse(START)); pr.setEndOperatingDate(OffsetDateTime.parse(END)); pr.setManufactureDate(OffsetDateTime.parse(MANUFACTURE)); String json = mapper.writeValueAsString(pr); assertTrue(json.contains("\"startOperatingDate\":\"" + OffsetDateTime.parse(START) + "\""), json); PhysicalResource back = mapper.readValue(json, PhysicalResource.class); assertEquals(OffsetDateTime.parse(START), back.getStartOperatingDate()); assertEquals(OffsetDateTime.parse(END), back.getEndOperatingDate()); assertEquals(OffsetDateTime.parse(MANUFACTURE), back.getManufactureDate()); } } Loading
src/main/java/org/etsi/osl/tmf/ri639/model/PhysicalResource.java +4 −15 Viewed Changes for src/main/java/org/etsi/osl/tmf/ri639/model/PhysicalResource.java: 4 added lines, 15 removed lines. Original line number Diff line number Diff line Loading @@ -142,21 +142,10 @@ public class PhysicalResource extends Resource { return this; } /** * A date time( DateTime). The date from which the resource is operating * * @return startOperatingDate **/ @Schema(description = "A date time( DateTime). The date from which the resource is operating") @Valid public OffsetDateTime getStartOperatingDate() { return startOperatingDate; } public void setStartOperatingDate(OffsetDateTime startOperatingDate) { this.startOperatingDate = startOperatingDate; } // getStartOperatingDate()/setStartOperatingDate(OffsetDateTime) are inherited from Resource. // Do not re-declare them here: Jackson prefers a setter declared in the subclass over the // parent's String setter, so a plain ObjectMapper (e.g. Camel's) could no longer deserialize // "startOperatingDate" for a PhysicalResource. public PhysicalResource versionNumber(String versionNumber) { this.versionNumber = versionNumber; Loading
src/test/java/org/etsi/osl/tmf/ri639/model/PhysicalResourceJsonDatesTest.java +62 Viewed Changes for src/test/java/org/etsi/osl/tmf/ri639/model/PhysicalResourceJsonDatesTest.java: 62 added lines, 0 removed lines. Original line number Diff line number Diff line package org.etsi.osl.tmf.ri639.model; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertInstanceOf; import static org.junit.jupiter.api.Assertions.assertTrue; import java.time.OffsetDateTime; import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.jupiter.api.Test; /** * PhysicalResource dates must read and write with a plain {@link ObjectMapper} (no JavaTimeModule), * which is what Camel's Jackson data format uses. * * <p>Regression: PhysicalResource used to re-declare {@code setStartOperatingDate(OffsetDateTime)}. * Jackson prefers a setter declared in the subclass over Resource's String setter, so * EVENT.RESOURCE.ATTRCHANGED failed with "Java 8 date/time type OffsetDateTime not supported by default". */ public class PhysicalResourceJsonDatesTest { private static final String START = "2026-11-01T10:00:00Z"; private static final String END = "2027-11-01T10:00:00Z"; private static final String MANUFACTURE = "2025-01-15T08:30:00+02:00"; private final ObjectMapper mapper = new ObjectMapper(); @Test public void attrChangedNotificationWithPhysicalResourceDatesReads() throws Exception { String json = "{\"event\":{\"event\":{\"resource\":{" + "\"@type\":\"PhysicalResource\",\"name\":\"aPhysical\"," + "\"startOperatingDate\":\"" + START + "\"," + "\"endOperatingDate\":\"" + END + "\"," + "\"manufactureDate\":\"" + MANUFACTURE + "\"}}}}"; ResourceAttributeValueChangeNotification n = mapper.readValue(json, ResourceAttributeValueChangeNotification.class); Resource r = n.getEvent().getEvent().getResource(); PhysicalResource pr = assertInstanceOf(PhysicalResource.class, r); assertEquals(OffsetDateTime.parse(START), pr.getStartOperatingDate()); assertEquals(OffsetDateTime.parse(END), pr.getEndOperatingDate()); assertEquals(OffsetDateTime.parse(MANUFACTURE), pr.getManufactureDate()); } @Test public void physicalResourceDatesRoundTripAsIsoStrings() throws Exception { PhysicalResource pr = new PhysicalResource(); pr.setName("aPhysical"); pr.setType("PhysicalResource"); pr.setStartOperatingDate(OffsetDateTime.parse(START)); pr.setEndOperatingDate(OffsetDateTime.parse(END)); pr.setManufactureDate(OffsetDateTime.parse(MANUFACTURE)); String json = mapper.writeValueAsString(pr); assertTrue(json.contains("\"startOperatingDate\":\"" + OffsetDateTime.parse(START) + "\""), json); PhysicalResource back = mapper.readValue(json, PhysicalResource.class); assertEquals(OffsetDateTime.parse(START), back.getStartOperatingDate()); assertEquals(OffsetDateTime.parse(END), back.getEndOperatingDate()); assertEquals(OffsetDateTime.parse(MANUFACTURE), back.getManufactureDate()); } }