Skip to content

Commit

Permalink
update to TimData class to allow for Tim payload serialization to wor…
Browse files Browse the repository at this point in the history
…k properly. Updates to affected unit tests
  • Loading branch information
Michael7371 committed Dec 10, 2024
1 parent 7dccf75 commit 9e48c45
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
******************************************************************************/
package us.dot.its.jpo.ode.model;

import com.fasterxml.jackson.annotation.JsonTypeInfo;
import static com.fasterxml.jackson.annotation.JsonTypeInfo.*;

public class OdeTimData extends OdeData {

private static final long serialVersionUID = 2057040404896561615L;
Expand All @@ -29,4 +32,16 @@ public OdeTimData(OdeMsgMetadata metadata, OdeMsgPayload payload) {
super(metadata, payload);
}

@Override
@JsonTypeInfo(use = Id.CLASS, include = As.EXISTING_PROPERTY, defaultImpl = OdeTimMetadata.class)
public void setMetadata(OdeMsgMetadata metadata) {
super.setMetadata(metadata);
}

@Override
@JsonTypeInfo(use = Id.CLASS, include = As.EXISTING_PROPERTY, defaultImpl = OdeTimPayload.class)
public void setPayload(OdeMsgPayload payload) {
super.setPayload(payload);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

package us.dot.its.jpo.ode.model;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

import us.dot.its.jpo.ode.plugin.j2735.OdeTravelerInformationMessage;
import us.dot.its.jpo.ode.plugin.j2735.travelerinformation.TravelerInformation;

Expand All @@ -36,7 +39,8 @@ public OdeTimPayload(OdeTravelerInformationMessage tim) {
this.setData(tim);
}

public OdeTimPayload(TravelerInformation tim) {
@JsonCreator
public OdeTimPayload(@JsonProperty("data") TravelerInformation tim) {
super(tim);
this.setData(tim);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ void testConvertToXMLMessageFrame()
staticOdeMsgMetadata.setSchemaVersion(Integer.parseInt(schemaVersion));

String actualXML = TimTransmogrifier.convertToXml(null, encodableTID, staticOdeMsgMetadata, staticSerialId);
var expected = String.format("<OdeAsn1Data><metadata><payloadType>us.dot.its.jpo.ode.model.OdeTimPayload</payloadType><serialId><streamId>6c33f802-418d-4b67-89d1-326b4fc8b1e3</streamId><bundleSize>1</bundleSize><bundleId>0</bundleId><recordId>0</recordId><serialNumber>0</serialNumber></serialId><odeReceivedAt>%s</odeReceivedAt><schemaVersion>%s</schemaVersion><maxDurationTime>0</maxDurationTime><sanitized>false</sanitized><request><sdw><serviceRegion><nwCorner><latitude>42.537903</latitude><longitude>-83.477903</longitude></nwCorner><seCorner><latitude>42.305753</latitude><longitude>-82.842753</longitude></seCorner></serviceRegion><ttl>thirtyminutes</ttl><deliverystart>2017-06-01T17:47:11-05:00</deliverystart><deliverystop>2018-03-01T17:47:11-05:15</deliverystop></sdw><rsus/></request><encodings><encodings><elementName>MessageFrame</elementName><elementType>MessageFrame</elementType><encodingRule>UPER</encodingRule></encodings></encodings></metadata><payload><dataType>MessageFrame</dataType><data><MessageFrame><messageId>31</messageId><value><TravelerInformation/></value></MessageFrame></data></payload></OdeAsn1Data>", DateTimeUtils.now(), schemaVersion);
var expected = String.format("<OdeAsn1Data><metadata><payloadType>us.dot.its.jpo.ode.model.OdeTimPayload</payloadType><serialId><streamId>6c33f802-418d-4b67-89d1-326b4fc8b1e3</streamId><bundleSize>1</bundleSize><bundleId>0</bundleId><recordId>0</recordId><serialNumber>0</serialNumber></serialId><odeReceivedAt>%s</odeReceivedAt><schemaVersion>%s</schemaVersion><maxDurationTime>0</maxDurationTime><sanitized>false</sanitized><request><sdw><serviceRegion><nwCorner><latitude>42.537903</latitude><longitude>-83.477903</longitude></nwCorner><seCorner><latitude>42.305753</latitude><longitude>-82.842753</longitude></seCorner></serviceRegion><ttl>thirtyminutes</ttl><deliverystart>2017-06-01T17:47:11-05:00</deliverystart><deliverystop>2018-03-01T17:47:11-05:15</deliverystop></sdw><rsus/></request><encodings><encodings><elementName>MessageFrame</elementName><elementType>MessageFrame</elementType><encodingRule>UPER</encodingRule></encodings></encodings></metadata><payload><data><MessageFrame><messageId>31</messageId><value><TravelerInformation/></value></MessageFrame></data><dataType>MessageFrame</dataType></payload></OdeAsn1Data>", DateTimeUtils.now(), schemaVersion);
assertEquals(expected, actualXML);
}

Expand Down
Loading

0 comments on commit 9e48c45

Please sign in to comment.