@Test public void shouldReturnCornerCaseMaximumTimeConfidence() { J2735TimeConfidence expectedValue = J2735TimeConfidence.TIME_000_000_000_000_02; JsonNode testFPV = null; try { testFPV = (JsonNode) XmlUtils.fromXmlS( "<initialPosition>" + "<long>0</long>" + "<lat>0</lat>" + "<elevation>0</elevation>" + "<heading>0</heading>" + "<posAccuracy><semiMajor>0</semiMajor><semiMinor>0</semiMinor><orientation>0</orientation></posAccuracy>" + "<posConfidence><pos>unavailable</pos><elevation>unavailable</elevation></posConfidence>" + "<speed><transmission>forwardGears</transmission><speed>0</speed></speed>" + "<speedConfidence><heading>unavailable</heading><speed>unavailable</speed><throttle>unavailable</throttle></speedConfidence>" + "<timeConfidence>TIME_000_000_000_000_02</timeConfidence>" + "<utcTime><year>0</year><month>0</month><day>0</day><hour>31</hour><minute>60</minute><second>65535</second><offset>0</offset></utcTime>" + "</initialPosition>", JsonNode.class); } catch (XmlUtilsException e) { fail("XML parsing error:" + e); } J2735TimeConfidence actualValue = FullPositionVectorBuilder.genericFullPositionVector(testFPV).getTimeConfidence(); assertEquals(expectedValue, actualValue); }
public static J2735FullPositionVector genericFullPositionVector(JsonNode initialPosition) { long longitude = initialPosition.get("long").asLong(); long latitude = initialPosition.get("lat").asLong(); Long elevation = null; if (initialPosition.get("elevation") != null) { elevation = initialPosition.get("elevation").asLong(); } Long timeConfidence = null; if (initialPosition.get(TIME_CONFIDENCE) != null) { timeConfidence = initialPosition.get(TIME_CONFIDENCE).asLong(); } if (longitude < LONG_LOWER_BOUND || longitude > LONG_UPPER_BOUND) { throw new IllegalArgumentException("Longitude value out of bounds [-1799999999..1800000001]"); } if (latitude < LAT_LOWER_BOUND || latitude > LAT_UPPER_BOUND) { throw new IllegalArgumentException("Latitude value out of bounds [-900000000..900000001]"); } if (null == elevation || elevation.longValue() < ELEV_LOWER_BOUND || elevation.longValue() > ELEV_UPPER_BOUND) { throw new IllegalArgumentException("Elevation value out of bounds [-4096..61439]"); } if (null == timeConfidence) { throw new IllegalArgumentException("Time confidence value out of bounds [0..39]"); } J2735FullPositionVector fpv = new J2735FullPositionVector(); fpv.setPosition(Position3DBuilder.odePosition3D( new DsrcPosition3D(latitude, longitude, elevation))); if (initialPosition.get(HEADING) != null) { fpv.setHeading(HeadingBuilder.genericHeading(initialPosition.get(HEADING))); } if (initialPosition.get(POS_ACCURACY) != null) { fpv.setPosAccuracy(PositionalAccuracyBuilder.genericPositionalAccuracy(initialPosition.get(POS_ACCURACY))); } if (initialPosition.get(POS_CONFIDENCE) != null) { fpv.setPosConfidence(PositionConfidenceSetBuilder.genericPositionConfidenceSet(initialPosition.get(POS_CONFIDENCE))); } if (initialPosition.get(SPEED) != null) { fpv.setSpeed(TransmissionAndSpeedBuilder.genericTransmissionAndSpeed(initialPosition.get(SPEED))); } if (initialPosition.get(SPEED_CONFIDENCE) != null) { fpv.setSpeedConfidence(SpeedandHeadingandThrottleConfidenceBuilder .genericSpeedandHeadingandThrottleConfidence(initialPosition.get(SPEED_CONFIDENCE))); } if (initialPosition.get(TIME_CONFIDENCE) != null) { fpv.setTimeConfidence(J2735TimeConfidence.valueOf(initialPosition.get(TIME_CONFIDENCE).asText().replaceAll("-", "_").toUpperCase())); } if (initialPosition.get(UTC_TIME) != null) { fpv.setUtcTime(DDateTimeBuilder.genericDDateTime(initialPosition.get(UTC_TIME))); } return fpv; }
FullPositionVectorBuilder { public static J2735FullPositionVector genericFullPositionVector(JsonNode initialPosition) { long longitude = initialPosition.get("long").asLong(); long latitude = initialPosition.get("lat").asLong(); Long elevation = null; if (initialPosition.get("elevation") != null) { elevation = initialPosition.get("elevation").asLong(); } Long timeConfidence = null; if (initialPosition.get(TIME_CONFIDENCE) != null) { timeConfidence = initialPosition.get(TIME_CONFIDENCE).asLong(); } if (longitude < LONG_LOWER_BOUND || longitude > LONG_UPPER_BOUND) { throw new IllegalArgumentException("Longitude value out of bounds [-1799999999..1800000001]"); } if (latitude < LAT_LOWER_BOUND || latitude > LAT_UPPER_BOUND) { throw new IllegalArgumentException("Latitude value out of bounds [-900000000..900000001]"); } if (null == elevation || elevation.longValue() < ELEV_LOWER_BOUND || elevation.longValue() > ELEV_UPPER_BOUND) { throw new IllegalArgumentException("Elevation value out of bounds [-4096..61439]"); } if (null == timeConfidence) { throw new IllegalArgumentException("Time confidence value out of bounds [0..39]"); } J2735FullPositionVector fpv = new J2735FullPositionVector(); fpv.setPosition(Position3DBuilder.odePosition3D( new DsrcPosition3D(latitude, longitude, elevation))); if (initialPosition.get(HEADING) != null) { fpv.setHeading(HeadingBuilder.genericHeading(initialPosition.get(HEADING))); } if (initialPosition.get(POS_ACCURACY) != null) { fpv.setPosAccuracy(PositionalAccuracyBuilder.genericPositionalAccuracy(initialPosition.get(POS_ACCURACY))); } if (initialPosition.get(POS_CONFIDENCE) != null) { fpv.setPosConfidence(PositionConfidenceSetBuilder.genericPositionConfidenceSet(initialPosition.get(POS_CONFIDENCE))); } if (initialPosition.get(SPEED) != null) { fpv.setSpeed(TransmissionAndSpeedBuilder.genericTransmissionAndSpeed(initialPosition.get(SPEED))); } if (initialPosition.get(SPEED_CONFIDENCE) != null) { fpv.setSpeedConfidence(SpeedandHeadingandThrottleConfidenceBuilder .genericSpeedandHeadingandThrottleConfidence(initialPosition.get(SPEED_CONFIDENCE))); } if (initialPosition.get(TIME_CONFIDENCE) != null) { fpv.setTimeConfidence(J2735TimeConfidence.valueOf(initialPosition.get(TIME_CONFIDENCE).asText().replaceAll("-", "_").toUpperCase())); } if (initialPosition.get(UTC_TIME) != null) { fpv.setUtcTime(DDateTimeBuilder.genericDDateTime(initialPosition.get(UTC_TIME))); } return fpv; } }
FullPositionVectorBuilder { public static J2735FullPositionVector genericFullPositionVector(JsonNode initialPosition) { long longitude = initialPosition.get("long").asLong(); long latitude = initialPosition.get("lat").asLong(); Long elevation = null; if (initialPosition.get("elevation") != null) { elevation = initialPosition.get("elevation").asLong(); } Long timeConfidence = null; if (initialPosition.get(TIME_CONFIDENCE) != null) { timeConfidence = initialPosition.get(TIME_CONFIDENCE).asLong(); } if (longitude < LONG_LOWER_BOUND || longitude > LONG_UPPER_BOUND) { throw new IllegalArgumentException("Longitude value out of bounds [-1799999999..1800000001]"); } if (latitude < LAT_LOWER_BOUND || latitude > LAT_UPPER_BOUND) { throw new IllegalArgumentException("Latitude value out of bounds [-900000000..900000001]"); } if (null == elevation || elevation.longValue() < ELEV_LOWER_BOUND || elevation.longValue() > ELEV_UPPER_BOUND) { throw new IllegalArgumentException("Elevation value out of bounds [-4096..61439]"); } if (null == timeConfidence) { throw new IllegalArgumentException("Time confidence value out of bounds [0..39]"); } J2735FullPositionVector fpv = new J2735FullPositionVector(); fpv.setPosition(Position3DBuilder.odePosition3D( new DsrcPosition3D(latitude, longitude, elevation))); if (initialPosition.get(HEADING) != null) { fpv.setHeading(HeadingBuilder.genericHeading(initialPosition.get(HEADING))); } if (initialPosition.get(POS_ACCURACY) != null) { fpv.setPosAccuracy(PositionalAccuracyBuilder.genericPositionalAccuracy(initialPosition.get(POS_ACCURACY))); } if (initialPosition.get(POS_CONFIDENCE) != null) { fpv.setPosConfidence(PositionConfidenceSetBuilder.genericPositionConfidenceSet(initialPosition.get(POS_CONFIDENCE))); } if (initialPosition.get(SPEED) != null) { fpv.setSpeed(TransmissionAndSpeedBuilder.genericTransmissionAndSpeed(initialPosition.get(SPEED))); } if (initialPosition.get(SPEED_CONFIDENCE) != null) { fpv.setSpeedConfidence(SpeedandHeadingandThrottleConfidenceBuilder .genericSpeedandHeadingandThrottleConfidence(initialPosition.get(SPEED_CONFIDENCE))); } if (initialPosition.get(TIME_CONFIDENCE) != null) { fpv.setTimeConfidence(J2735TimeConfidence.valueOf(initialPosition.get(TIME_CONFIDENCE).asText().replaceAll("-", "_").toUpperCase())); } if (initialPosition.get(UTC_TIME) != null) { fpv.setUtcTime(DDateTimeBuilder.genericDDateTime(initialPosition.get(UTC_TIME))); } return fpv; } private  FullPositionVectorBuilder(); }
FullPositionVectorBuilder { public static J2735FullPositionVector genericFullPositionVector(JsonNode initialPosition) { long longitude = initialPosition.get("long").asLong(); long latitude = initialPosition.get("lat").asLong(); Long elevation = null; if (initialPosition.get("elevation") != null) { elevation = initialPosition.get("elevation").asLong(); } Long timeConfidence = null; if (initialPosition.get(TIME_CONFIDENCE) != null) { timeConfidence = initialPosition.get(TIME_CONFIDENCE).asLong(); } if (longitude < LONG_LOWER_BOUND || longitude > LONG_UPPER_BOUND) { throw new IllegalArgumentException("Longitude value out of bounds [-1799999999..1800000001]"); } if (latitude < LAT_LOWER_BOUND || latitude > LAT_UPPER_BOUND) { throw new IllegalArgumentException("Latitude value out of bounds [-900000000..900000001]"); } if (null == elevation || elevation.longValue() < ELEV_LOWER_BOUND || elevation.longValue() > ELEV_UPPER_BOUND) { throw new IllegalArgumentException("Elevation value out of bounds [-4096..61439]"); } if (null == timeConfidence) { throw new IllegalArgumentException("Time confidence value out of bounds [0..39]"); } J2735FullPositionVector fpv = new J2735FullPositionVector(); fpv.setPosition(Position3DBuilder.odePosition3D( new DsrcPosition3D(latitude, longitude, elevation))); if (initialPosition.get(HEADING) != null) { fpv.setHeading(HeadingBuilder.genericHeading(initialPosition.get(HEADING))); } if (initialPosition.get(POS_ACCURACY) != null) { fpv.setPosAccuracy(PositionalAccuracyBuilder.genericPositionalAccuracy(initialPosition.get(POS_ACCURACY))); } if (initialPosition.get(POS_CONFIDENCE) != null) { fpv.setPosConfidence(PositionConfidenceSetBuilder.genericPositionConfidenceSet(initialPosition.get(POS_CONFIDENCE))); } if (initialPosition.get(SPEED) != null) { fpv.setSpeed(TransmissionAndSpeedBuilder.genericTransmissionAndSpeed(initialPosition.get(SPEED))); } if (initialPosition.get(SPEED_CONFIDENCE) != null) { fpv.setSpeedConfidence(SpeedandHeadingandThrottleConfidenceBuilder .genericSpeedandHeadingandThrottleConfidence(initialPosition.get(SPEED_CONFIDENCE))); } if (initialPosition.get(TIME_CONFIDENCE) != null) { fpv.setTimeConfidence(J2735TimeConfidence.valueOf(initialPosition.get(TIME_CONFIDENCE).asText().replaceAll("-", "_").toUpperCase())); } if (initialPosition.get(UTC_TIME) != null) { fpv.setUtcTime(DDateTimeBuilder.genericDDateTime(initialPosition.get(UTC_TIME))); } return fpv; } private  FullPositionVectorBuilder(); static J2735FullPositionVector genericFullPositionVector(JsonNode initialPosition); }
FullPositionVectorBuilder { public static J2735FullPositionVector genericFullPositionVector(JsonNode initialPosition) { long longitude = initialPosition.get("long").asLong(); long latitude = initialPosition.get("lat").asLong(); Long elevation = null; if (initialPosition.get("elevation") != null) { elevation = initialPosition.get("elevation").asLong(); } Long timeConfidence = null; if (initialPosition.get(TIME_CONFIDENCE) != null) { timeConfidence = initialPosition.get(TIME_CONFIDENCE).asLong(); } if (longitude < LONG_LOWER_BOUND || longitude > LONG_UPPER_BOUND) { throw new IllegalArgumentException("Longitude value out of bounds [-1799999999..1800000001]"); } if (latitude < LAT_LOWER_BOUND || latitude > LAT_UPPER_BOUND) { throw new IllegalArgumentException("Latitude value out of bounds [-900000000..900000001]"); } if (null == elevation || elevation.longValue() < ELEV_LOWER_BOUND || elevation.longValue() > ELEV_UPPER_BOUND) { throw new IllegalArgumentException("Elevation value out of bounds [-4096..61439]"); } if (null == timeConfidence) { throw new IllegalArgumentException("Time confidence value out of bounds [0..39]"); } J2735FullPositionVector fpv = new J2735FullPositionVector(); fpv.setPosition(Position3DBuilder.odePosition3D( new DsrcPosition3D(latitude, longitude, elevation))); if (initialPosition.get(HEADING) != null) { fpv.setHeading(HeadingBuilder.genericHeading(initialPosition.get(HEADING))); } if (initialPosition.get(POS_ACCURACY) != null) { fpv.setPosAccuracy(PositionalAccuracyBuilder.genericPositionalAccuracy(initialPosition.get(POS_ACCURACY))); } if (initialPosition.get(POS_CONFIDENCE) != null) { fpv.setPosConfidence(PositionConfidenceSetBuilder.genericPositionConfidenceSet(initialPosition.get(POS_CONFIDENCE))); } if (initialPosition.get(SPEED) != null) { fpv.setSpeed(TransmissionAndSpeedBuilder.genericTransmissionAndSpeed(initialPosition.get(SPEED))); } if (initialPosition.get(SPEED_CONFIDENCE) != null) { fpv.setSpeedConfidence(SpeedandHeadingandThrottleConfidenceBuilder .genericSpeedandHeadingandThrottleConfidence(initialPosition.get(SPEED_CONFIDENCE))); } if (initialPosition.get(TIME_CONFIDENCE) != null) { fpv.setTimeConfidence(J2735TimeConfidence.valueOf(initialPosition.get(TIME_CONFIDENCE).asText().replaceAll("-", "_").toUpperCase())); } if (initialPosition.get(UTC_TIME) != null) { fpv.setUtcTime(DDateTimeBuilder.genericDDateTime(initialPosition.get(UTC_TIME))); } return fpv; } private  FullPositionVectorBuilder(); static J2735FullPositionVector genericFullPositionVector(JsonNode initialPosition);  }