Loading vessels-lib/src/main/java/es/redmic/vesselslib/dto/tracking/VesselTrackingPropertiesDTO.java +58 −4 Original line number Diff line number Diff line Loading @@ -7,8 +7,10 @@ import org.joda.time.DateTime; import org.joda.time.DateTimeZone; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.kjetland.jackson.jsonSchema.annotations.JsonSchemaDefault; import com.kjetland.jackson.jsonSchema.annotations.JsonSchemaNotNull; import com.kjetland.jackson.jsonSchema.annotations.JsonSchemaUrl; Loading Loading @@ -52,6 +54,8 @@ public class VesselTrackingPropertiesDTO extends PropertiesDTO { + "{\"name\":\"navStat\",\"type\":[\"int\", \"null\"]}," + "{\"name\":\"dest\",\"type\":[\"string\", \"null\"]}," + "{\"name\":\"eta\",\"type\":[\"string\", \"null\"]}," + "{\"name\":\"qFlag\",\"type\":\"string\"}," + "{\"name\":\"vFlag\",\"type\":\"string\"}," + "{\"name\":\"activity\",\"type\":\"string\"}," + "{\"name\":\"inserted\",\"type\":[\"null\",{\"type\":\"long\",\"logicalType\":\"timestamp-millis\"}]," + "\"default\": null}," Loading Loading @@ -83,6 +87,10 @@ public class VesselTrackingPropertiesDTO extends PropertiesDTO { private String eta; private String qFlag; private String vFlag; public VesselDTO getVessel() { return vessel; } Loading Loading @@ -147,6 +155,30 @@ public class VesselTrackingPropertiesDTO extends PropertiesDTO { this.eta = eta; } @NotNull @JsonSchemaDefault(value = "0") @JsonProperty(value = "qFlag") public String getQFlag() { return qFlag; } @JsonProperty(value = "qFlag") public void setQFlag(String qFlag) { this.qFlag = qFlag; } @NotNull @JsonSchemaDefault(value = "N") @JsonProperty(value = "vFlag") public String getVFlag() { return vFlag; } @JsonProperty(value = "vFlag") public void setVFlag(String vFlag) { this.vFlag = vFlag; } @JsonIgnore @Override public Schema getSchema() { Loading Loading @@ -174,10 +206,14 @@ public class VesselTrackingPropertiesDTO extends PropertiesDTO { case 7: return eta; case 8: return getActivity(); return qFlag; case 9: return getInserted() != null ? getInserted().getMillis() : null; return vFlag; case 10: return getActivity(); case 11: return getInserted() != null ? getInserted().getMillis() : null; case 12: return getUpdated() != null ? getUpdated().getMillis() : null; default: throw new org.apache.avro.AvroRuntimeException("Bad index"); Loading Loading @@ -213,12 +249,18 @@ public class VesselTrackingPropertiesDTO extends PropertiesDTO { eta = value != null ? value.toString() : null; break; case 8: setActivity(value.toString()); qFlag = value != null ? value.toString() : null; break; case 9: setInserted(value != null ? new DateTime(value, DateTimeZone.UTC).toDateTime() : null); vFlag = value != null ? value.toString() : null; break; case 10: setActivity(value.toString()); break; case 11: setInserted(value != null ? new DateTime(value, DateTimeZone.UTC).toDateTime() : null); break; case 12: setUpdated(value != null ? new DateTime(value, DateTimeZone.UTC).toDateTime() : null); break; default: Loading @@ -236,7 +278,9 @@ public class VesselTrackingPropertiesDTO extends PropertiesDTO { result = prime * result + ((eta == null) ? 0 : eta.hashCode()); result = prime * result + ((heading == null) ? 0 : heading.hashCode()); result = prime * result + ((navStat == null) ? 0 : navStat.hashCode()); result = prime * result + ((qFlag == null) ? 0 : qFlag.hashCode()); result = prime * result + ((sog == null) ? 0 : sog.hashCode()); result = prime * result + ((vFlag == null) ? 0 : vFlag.hashCode()); result = prime * result + ((vessel == null) ? 0 : vessel.hashCode()); return result; } Loading Loading @@ -280,11 +324,21 @@ public class VesselTrackingPropertiesDTO extends PropertiesDTO { return false; } else if (!navStat.equals(other.navStat)) return false; if (qFlag == null) { if (other.qFlag != null) return false; } else if (!qFlag.equals(other.qFlag)) return false; if (sog == null) { if (other.sog != null) return false; } else if (!sog.equals(other.sog)) return false; if (vFlag == null) { if (other.vFlag != null) return false; } else if (!vFlag.equals(other.vFlag)) return false; if (vessel == null) { if (other.vessel != null) return false; Loading vessels-lib/src/test/java/es/redmic/vesselslib/unit/dto/vesseltracking/VesselTrackingCheckDTOValidationTest.java +16 −2 Original line number Diff line number Diff line Loading @@ -43,7 +43,6 @@ public class VesselTrackingCheckDTOValidationTest extends DTOBaseTest<VesselTrac public void validationDTO_ReturnNotNullError_IfVesselIsNull() { dto.getProperties().setVessel(null); ; checkDTOHasError(dto, NOT_NULL_MESSAGE_TEMPLATE); } Loading @@ -52,7 +51,22 @@ public class VesselTrackingCheckDTOValidationTest extends DTOBaseTest<VesselTrac public void validationDTO_ReturnNotNullError_IfDateIsNull() { dto.getProperties().setDate(null); ; checkDTOHasError(dto, NOT_NULL_MESSAGE_TEMPLATE); } @Test public void validationDTO_ReturnNotNullError_IfQFlagIsNull() { dto.getProperties().setQFlag(null); checkDTOHasError(dto, NOT_NULL_MESSAGE_TEMPLATE); } @Test public void validationDTO_ReturnNotNullError_IfVFlagIsNull() { dto.getProperties().setVFlag(null); checkDTOHasError(dto, NOT_NULL_MESSAGE_TEMPLATE); } Loading vessels-lib/src/test/java/es/redmic/vesselslib/unit/utils/VesselTrackingDataUtil.java +2 −0 Original line number Diff line number Diff line Loading @@ -291,6 +291,8 @@ public abstract class VesselTrackingDataUtil { properties.setNavStat(33); properties.setDest("Santa Cruz de Tenerife"); properties.setEta("00:00 00:00"); properties.setQFlag("0"); properties.setVFlag("N"); return vesselTracking; } Loading Loading
vessels-lib/src/main/java/es/redmic/vesselslib/dto/tracking/VesselTrackingPropertiesDTO.java +58 −4 Original line number Diff line number Diff line Loading @@ -7,8 +7,10 @@ import org.joda.time.DateTime; import org.joda.time.DateTimeZone; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.kjetland.jackson.jsonSchema.annotations.JsonSchemaDefault; import com.kjetland.jackson.jsonSchema.annotations.JsonSchemaNotNull; import com.kjetland.jackson.jsonSchema.annotations.JsonSchemaUrl; Loading Loading @@ -52,6 +54,8 @@ public class VesselTrackingPropertiesDTO extends PropertiesDTO { + "{\"name\":\"navStat\",\"type\":[\"int\", \"null\"]}," + "{\"name\":\"dest\",\"type\":[\"string\", \"null\"]}," + "{\"name\":\"eta\",\"type\":[\"string\", \"null\"]}," + "{\"name\":\"qFlag\",\"type\":\"string\"}," + "{\"name\":\"vFlag\",\"type\":\"string\"}," + "{\"name\":\"activity\",\"type\":\"string\"}," + "{\"name\":\"inserted\",\"type\":[\"null\",{\"type\":\"long\",\"logicalType\":\"timestamp-millis\"}]," + "\"default\": null}," Loading Loading @@ -83,6 +87,10 @@ public class VesselTrackingPropertiesDTO extends PropertiesDTO { private String eta; private String qFlag; private String vFlag; public VesselDTO getVessel() { return vessel; } Loading Loading @@ -147,6 +155,30 @@ public class VesselTrackingPropertiesDTO extends PropertiesDTO { this.eta = eta; } @NotNull @JsonSchemaDefault(value = "0") @JsonProperty(value = "qFlag") public String getQFlag() { return qFlag; } @JsonProperty(value = "qFlag") public void setQFlag(String qFlag) { this.qFlag = qFlag; } @NotNull @JsonSchemaDefault(value = "N") @JsonProperty(value = "vFlag") public String getVFlag() { return vFlag; } @JsonProperty(value = "vFlag") public void setVFlag(String vFlag) { this.vFlag = vFlag; } @JsonIgnore @Override public Schema getSchema() { Loading Loading @@ -174,10 +206,14 @@ public class VesselTrackingPropertiesDTO extends PropertiesDTO { case 7: return eta; case 8: return getActivity(); return qFlag; case 9: return getInserted() != null ? getInserted().getMillis() : null; return vFlag; case 10: return getActivity(); case 11: return getInserted() != null ? getInserted().getMillis() : null; case 12: return getUpdated() != null ? getUpdated().getMillis() : null; default: throw new org.apache.avro.AvroRuntimeException("Bad index"); Loading Loading @@ -213,12 +249,18 @@ public class VesselTrackingPropertiesDTO extends PropertiesDTO { eta = value != null ? value.toString() : null; break; case 8: setActivity(value.toString()); qFlag = value != null ? value.toString() : null; break; case 9: setInserted(value != null ? new DateTime(value, DateTimeZone.UTC).toDateTime() : null); vFlag = value != null ? value.toString() : null; break; case 10: setActivity(value.toString()); break; case 11: setInserted(value != null ? new DateTime(value, DateTimeZone.UTC).toDateTime() : null); break; case 12: setUpdated(value != null ? new DateTime(value, DateTimeZone.UTC).toDateTime() : null); break; default: Loading @@ -236,7 +278,9 @@ public class VesselTrackingPropertiesDTO extends PropertiesDTO { result = prime * result + ((eta == null) ? 0 : eta.hashCode()); result = prime * result + ((heading == null) ? 0 : heading.hashCode()); result = prime * result + ((navStat == null) ? 0 : navStat.hashCode()); result = prime * result + ((qFlag == null) ? 0 : qFlag.hashCode()); result = prime * result + ((sog == null) ? 0 : sog.hashCode()); result = prime * result + ((vFlag == null) ? 0 : vFlag.hashCode()); result = prime * result + ((vessel == null) ? 0 : vessel.hashCode()); return result; } Loading Loading @@ -280,11 +324,21 @@ public class VesselTrackingPropertiesDTO extends PropertiesDTO { return false; } else if (!navStat.equals(other.navStat)) return false; if (qFlag == null) { if (other.qFlag != null) return false; } else if (!qFlag.equals(other.qFlag)) return false; if (sog == null) { if (other.sog != null) return false; } else if (!sog.equals(other.sog)) return false; if (vFlag == null) { if (other.vFlag != null) return false; } else if (!vFlag.equals(other.vFlag)) return false; if (vessel == null) { if (other.vessel != null) return false; Loading
vessels-lib/src/test/java/es/redmic/vesselslib/unit/dto/vesseltracking/VesselTrackingCheckDTOValidationTest.java +16 −2 Original line number Diff line number Diff line Loading @@ -43,7 +43,6 @@ public class VesselTrackingCheckDTOValidationTest extends DTOBaseTest<VesselTrac public void validationDTO_ReturnNotNullError_IfVesselIsNull() { dto.getProperties().setVessel(null); ; checkDTOHasError(dto, NOT_NULL_MESSAGE_TEMPLATE); } Loading @@ -52,7 +51,22 @@ public class VesselTrackingCheckDTOValidationTest extends DTOBaseTest<VesselTrac public void validationDTO_ReturnNotNullError_IfDateIsNull() { dto.getProperties().setDate(null); ; checkDTOHasError(dto, NOT_NULL_MESSAGE_TEMPLATE); } @Test public void validationDTO_ReturnNotNullError_IfQFlagIsNull() { dto.getProperties().setQFlag(null); checkDTOHasError(dto, NOT_NULL_MESSAGE_TEMPLATE); } @Test public void validationDTO_ReturnNotNullError_IfVFlagIsNull() { dto.getProperties().setVFlag(null); checkDTOHasError(dto, NOT_NULL_MESSAGE_TEMPLATE); } Loading
vessels-lib/src/test/java/es/redmic/vesselslib/unit/utils/VesselTrackingDataUtil.java +2 −0 Original line number Diff line number Diff line Loading @@ -291,6 +291,8 @@ public abstract class VesselTrackingDataUtil { properties.setNavStat(33); properties.setDest("Santa Cruz de Tenerife"); properties.setEta("00:00 00:00"); properties.setQFlag("0"); properties.setVFlag("N"); return vesselTracking; } Loading