Skip to content

Commit

Permalink
fix: IDEV-4037 handle empty value for change configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
vdufau committed Apr 24, 2024
1 parent ed85bf4 commit cd5c47d
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.izivia.ocpp.json15

import com.fasterxml.jackson.annotation.JsonInclude
import com.fasterxml.jackson.annotation.JsonValue
import com.fasterxml.jackson.databind.ObjectMapper
import com.izivia.ocpp.core15.model.changeconfiguration.ChangeConfigurationReq
import com.izivia.ocpp.core15.model.common.enumeration.Measurand
import com.izivia.ocpp.core15.model.common.enumeration.ReadingContext
import com.izivia.ocpp.json.OcppJsonMapper
Expand All @@ -10,8 +12,14 @@ internal object Ocpp15JsonObjectMapper : ObjectMapper(
OcppJsonMapper()
.addMixIn(Measurand::class.java, EnumMixin::class.java)
.addMixIn(ReadingContext::class.java, EnumMixin::class.java)
.addMixIn(ChangeConfigurationReq::class.java, ChangeConfigurationReqMixin::class.java)
)

private abstract class EnumMixin(
@JsonValue val value: String
)

private abstract class ChangeConfigurationReqMixin {
@get:JsonInclude(JsonInclude.Include.ALWAYS)
abstract val value: String
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.izivia.ocpp.soap15

import com.fasterxml.jackson.annotation.JsonInclude
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.annotation.JsonRootName
import com.fasterxml.jackson.databind.MapperFeature
Expand Down Expand Up @@ -242,6 +243,7 @@ private abstract class ChangeConfigurationReqMixin(
@JacksonXmlProperty(localName = "o:key")
val key: String,
@JacksonXmlProperty(localName = "o:value")
@JsonInclude(JsonInclude.Include.ALWAYS)
val value: String
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.izivia.ocpp.json16

import com.fasterxml.jackson.annotation.JsonInclude
import com.fasterxml.jackson.annotation.JsonValue
import com.fasterxml.jackson.databind.ObjectMapper
import com.izivia.ocpp.core16.model.changeconfiguration.ChangeConfigurationReq
import com.izivia.ocpp.core16.model.common.enumeration.Measurand
import com.izivia.ocpp.core16.model.common.enumeration.Phase
import com.izivia.ocpp.core16.model.common.enumeration.ReadingContext
Expand All @@ -12,8 +14,14 @@ internal object Ocpp16JsonObjectMapper : ObjectMapper(
.addMixIn(Measurand::class.java, EnumMixin::class.java)
.addMixIn(ReadingContext::class.java, EnumMixin::class.java)
.addMixIn(Phase::class.java, EnumMixin::class.java)
.addMixIn(ChangeConfigurationReq::class.java, ChangeConfigurationReqMixin::class.java)
)

private abstract class EnumMixin(
@JsonValue val value: String
)

private abstract class ChangeConfigurationReqMixin {
@get:JsonInclude(JsonInclude.Include.ALWAYS)
abstract val value: String
}
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ private abstract class ChangeConfigurationReqMixin(
@JacksonXmlProperty(localName = "o:key")
val key: String,
@JacksonXmlProperty(localName = "o:value")
@JsonInclude(JsonInclude.Include.ALWAYS)
val value: String
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.izivia.ocpp.json20

import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import com.fasterxml.jackson.annotation.JsonInclude
import com.fasterxml.jackson.annotation.JsonValue
import com.fasterxml.jackson.databind.ObjectMapper
import com.izivia.ocpp.core20.model.common.enumeration.MeasurandEnumType
Expand All @@ -10,6 +11,8 @@ import com.izivia.ocpp.core20.model.notifyevent.NotifyEventReq
import com.izivia.ocpp.core20.model.notifymonitoringreport.NotifyMonitoringReportReq
import com.izivia.ocpp.core20.model.notifyreport.NotifyReportReq
import com.izivia.ocpp.core20.model.notifyreport.enumeration.DataEnumType
import com.izivia.ocpp.core20.model.setvariables.SetVariableDataType
import com.izivia.ocpp.core20.model.setvariables.SetVariablesReq
import com.izivia.ocpp.json.OcppJsonMapper

internal object Ocpp20JsonObjectMapper : ObjectMapper(
Expand All @@ -21,11 +24,17 @@ internal object Ocpp20JsonObjectMapper : ObjectMapper(
.addMixIn(NotifyEventReq::class.java, HasActionTimestampMixin::class.java)
.addMixIn(NotifyReportReq::class.java, HasActionTimestampMixin::class.java)
.addMixIn(NotifyMonitoringReportReq::class.java, HasActionTimestampMixin::class.java)
.addMixIn(SetVariableDataType::class.java, SetVariableDataTypeMixin::class.java)
)

private abstract class EnumMixin(
@JsonValue val value: String
)

@JsonIgnoreProperties(value = ["timestamp"])
private abstract class HasActionTimestampMixin
private abstract class HasActionTimestampMixin

private abstract class SetVariableDataTypeMixin {
@get:JsonInclude(JsonInclude.Include.ALWAYS)
abstract val attributeValue: String
}

0 comments on commit cd5c47d

Please sign in to comment.