From c4cad1ea24d2b78a271a2695ceb8c2b549d25f93 Mon Sep 17 00:00:00 2001 From: Gertjan Assies Date: Mon, 16 Oct 2017 08:16:49 +0200 Subject: [PATCH 1/3] TNM-4930 Added tests to validate serialized messages against 1.6 json schema --- build.sbt | 4 +- .../src/test/resources/schemas/Authorize.json | 15 ++ .../resources/schemas/AuthorizeResponse.json | 37 ++++ .../resources/schemas/BootNotification.json | 48 +++++ .../schemas/BootNotificationResponse.json | 28 +++ .../resources/schemas/CancelReservation.json | 14 ++ .../schemas/CancelReservationResponse.json | 18 ++ .../resources/schemas/ChangeAvailability.json | 22 +++ .../schemas/ChangeAvailabilityResponse.json | 19 ++ .../schemas/ChangeConfiguration.json | 20 +++ .../schemas/ChangeConfigurationResponse.json | 20 +++ .../test/resources/schemas/ClearCache.json | 7 + .../resources/schemas/ClearCacheResponse.json | 18 ++ .../schemas/ClearChargingProfile.json | 25 +++ .../schemas/ClearChargingProfileResponse.json | 18 ++ .../test/resources/schemas/DataTransfer.json | 22 +++ .../schemas/DataTransferResponse.json | 23 +++ .../DiagnosticsStatusNotification.json | 20 +++ ...DiagnosticsStatusNotificationResponse.json | 7 + .../schemas/FirmwareStatusNotification.json | 23 +++ .../FirmwareStatusNotificationResponse.json | 7 + .../schemas/GetCompositeSchedule.json | 25 +++ .../schemas/GetCompositeScheduleResponse.json | 74 ++++++++ .../resources/schemas/GetConfiguration.json | 15 ++ .../schemas/GetConfigurationResponse.json | 38 ++++ .../resources/schemas/GetDiagnostics.json | 29 +++ .../schemas/GetDiagnosticsResponse.json | 12 ++ .../schemas/GetLocalListVersion.json | 7 + .../schemas/GetLocalListVersionResponse.json | 14 ++ .../src/test/resources/schemas/Heartbeat.json | 7 + .../resources/schemas/HeartbeatResponse.json | 15 ++ .../test/resources/schemas/MeterValues.json | 141 +++++++++++++++ .../schemas/MeterValuesResponse.json | 7 + .../schemas/RemoteStartTransaction.json | 119 +++++++++++++ .../RemoteStartTransactionResponse.json | 18 ++ .../schemas/RemoteStopTransaction.json | 14 ++ .../RemoteStopTransactionResponse.json | 18 ++ .../test/resources/schemas/ReserveNow.json | 32 ++++ .../resources/schemas/ReserveNowResponse.json | 21 +++ .../src/test/resources/schemas/Reset.json | 18 ++ .../test/resources/schemas/ResetResponse.json | 18 ++ .../test/resources/schemas/SendLocalList.json | 63 +++++++ .../schemas/SendLocalListResponse.json | 20 +++ .../resources/schemas/SetChargingProfile.json | 116 ++++++++++++ .../schemas/SetChargingProfileResponse.json | 19 ++ .../resources/schemas/StartTransaction.json | 31 ++++ .../schemas/StartTransactionResponse.json | 41 +++++ .../resources/schemas/StatusNotification.json | 67 +++++++ .../schemas/StatusNotificationResponse.json | 7 + .../resources/schemas/StopTransaction.json | 166 ++++++++++++++++++ .../schemas/StopTransactionResponse.json | 34 ++++ .../resources/schemas/TriggerMessage.json | 25 +++ .../schemas/TriggerMessageResponse.json | 19 ++ .../resources/schemas/UnlockConnector.json | 14 ++ .../schemas/UnlockConnectorResponse.json | 19 ++ .../resources/schemas/UpdateFirmware.json | 26 +++ .../schemas/UpdateFirmwareResponse.json | 7 + .../json/v16/JsonSchemaValidationSpec.scala | 100 +++++++++++ .../ocpp/json/v16/SerializationV16Spec.scala | 2 + .../ocpp/json/v16/scalacheck/Helpers.scala | 6 +- .../v16/scalacheck/MessageGenerators.scala | 35 ++-- .../ocpp/messages/meter/Meter.scala | 4 +- .../ocpp/soap/CentralSystemClient.scala | 2 +- .../ocpp/soap/CentralSystemDispatcher.scala | 2 +- 64 files changed, 1858 insertions(+), 24 deletions(-) create mode 100755 ocpp-json/src/test/resources/schemas/Authorize.json create mode 100755 ocpp-json/src/test/resources/schemas/AuthorizeResponse.json create mode 100755 ocpp-json/src/test/resources/schemas/BootNotification.json create mode 100755 ocpp-json/src/test/resources/schemas/BootNotificationResponse.json create mode 100755 ocpp-json/src/test/resources/schemas/CancelReservation.json create mode 100755 ocpp-json/src/test/resources/schemas/CancelReservationResponse.json create mode 100755 ocpp-json/src/test/resources/schemas/ChangeAvailability.json create mode 100755 ocpp-json/src/test/resources/schemas/ChangeAvailabilityResponse.json create mode 100755 ocpp-json/src/test/resources/schemas/ChangeConfiguration.json create mode 100755 ocpp-json/src/test/resources/schemas/ChangeConfigurationResponse.json create mode 100755 ocpp-json/src/test/resources/schemas/ClearCache.json create mode 100755 ocpp-json/src/test/resources/schemas/ClearCacheResponse.json create mode 100755 ocpp-json/src/test/resources/schemas/ClearChargingProfile.json create mode 100755 ocpp-json/src/test/resources/schemas/ClearChargingProfileResponse.json create mode 100755 ocpp-json/src/test/resources/schemas/DataTransfer.json create mode 100755 ocpp-json/src/test/resources/schemas/DataTransferResponse.json create mode 100755 ocpp-json/src/test/resources/schemas/DiagnosticsStatusNotification.json create mode 100755 ocpp-json/src/test/resources/schemas/DiagnosticsStatusNotificationResponse.json create mode 100755 ocpp-json/src/test/resources/schemas/FirmwareStatusNotification.json create mode 100755 ocpp-json/src/test/resources/schemas/FirmwareStatusNotificationResponse.json create mode 100755 ocpp-json/src/test/resources/schemas/GetCompositeSchedule.json create mode 100755 ocpp-json/src/test/resources/schemas/GetCompositeScheduleResponse.json create mode 100755 ocpp-json/src/test/resources/schemas/GetConfiguration.json create mode 100755 ocpp-json/src/test/resources/schemas/GetConfigurationResponse.json create mode 100755 ocpp-json/src/test/resources/schemas/GetDiagnostics.json create mode 100755 ocpp-json/src/test/resources/schemas/GetDiagnosticsResponse.json create mode 100755 ocpp-json/src/test/resources/schemas/GetLocalListVersion.json create mode 100755 ocpp-json/src/test/resources/schemas/GetLocalListVersionResponse.json create mode 100755 ocpp-json/src/test/resources/schemas/Heartbeat.json create mode 100755 ocpp-json/src/test/resources/schemas/HeartbeatResponse.json create mode 100755 ocpp-json/src/test/resources/schemas/MeterValues.json create mode 100755 ocpp-json/src/test/resources/schemas/MeterValuesResponse.json create mode 100755 ocpp-json/src/test/resources/schemas/RemoteStartTransaction.json create mode 100755 ocpp-json/src/test/resources/schemas/RemoteStartTransactionResponse.json create mode 100755 ocpp-json/src/test/resources/schemas/RemoteStopTransaction.json create mode 100755 ocpp-json/src/test/resources/schemas/RemoteStopTransactionResponse.json create mode 100755 ocpp-json/src/test/resources/schemas/ReserveNow.json create mode 100755 ocpp-json/src/test/resources/schemas/ReserveNowResponse.json create mode 100755 ocpp-json/src/test/resources/schemas/Reset.json create mode 100755 ocpp-json/src/test/resources/schemas/ResetResponse.json create mode 100755 ocpp-json/src/test/resources/schemas/SendLocalList.json create mode 100755 ocpp-json/src/test/resources/schemas/SendLocalListResponse.json create mode 100755 ocpp-json/src/test/resources/schemas/SetChargingProfile.json create mode 100755 ocpp-json/src/test/resources/schemas/SetChargingProfileResponse.json create mode 100755 ocpp-json/src/test/resources/schemas/StartTransaction.json create mode 100755 ocpp-json/src/test/resources/schemas/StartTransactionResponse.json create mode 100755 ocpp-json/src/test/resources/schemas/StatusNotification.json create mode 100755 ocpp-json/src/test/resources/schemas/StatusNotificationResponse.json create mode 100755 ocpp-json/src/test/resources/schemas/StopTransaction.json create mode 100755 ocpp-json/src/test/resources/schemas/StopTransactionResponse.json create mode 100755 ocpp-json/src/test/resources/schemas/TriggerMessage.json create mode 100755 ocpp-json/src/test/resources/schemas/TriggerMessageResponse.json create mode 100755 ocpp-json/src/test/resources/schemas/UnlockConnector.json create mode 100755 ocpp-json/src/test/resources/schemas/UnlockConnectorResponse.json create mode 100755 ocpp-json/src/test/resources/schemas/UpdateFirmware.json create mode 100755 ocpp-json/src/test/resources/schemas/UpdateFirmwareResponse.json create mode 100644 ocpp-json/src/test/scala/com/thenewmotion/ocpp/json/v16/JsonSchemaValidationSpec.scala diff --git a/build.sbt b/build.sbt index c410273..2c7de1c 100644 --- a/build.sbt +++ b/build.sbt @@ -5,6 +5,7 @@ val specs2V = "3.9.1" val slf4jV = "1.7.12" val json4sNative = "org.json4s" %% "json4s-native" % json4sV +val json4sjackson = "org.json4s" %% "json4s-jackson" % json4sV val javaWebSocket = "org.java-websocket" % "Java-WebSocket" % "1.3.0" val slf4jApi = "org.slf4j" % "slf4j-api" % slf4jV val slf4jSimpleLogger = "org.slf4j" % "slf4j-simple" % slf4jV @@ -21,6 +22,7 @@ val commonsCodec = "commons-codec" % "commons-codec" % "1.10" val enumUtils = "com.thenewmotion" %% "enum-utils" % "0.2.1" val scalaCheck = "org.scalacheck" %% "scalacheck" % "1.13.4" % "test" val specs2ScalaCheck = "org.specs2" %% "specs2-scalacheck" % specs2V % "test" +val jsonSchemaValidator = "com.github.java-json-tools" % "json-schema-validator" % "2.2.8" % "test" def module(name: String) = Project(name, file(name)) .enablePlugins(OssLibPlugin) @@ -59,7 +61,7 @@ val json = module("ocpp-json") .dependsOn(messages) .settings( libraryDependencies ++= Seq( - json4sNative, slf4jApi, scalaCheck, specs2ScalaCheck + json4sNative, slf4jApi, scalaCheck, specs2ScalaCheck, jsonSchemaValidator, json4sjackson ) ) diff --git a/ocpp-json/src/test/resources/schemas/Authorize.json b/ocpp-json/src/test/resources/schemas/Authorize.json new file mode 100755 index 0000000..7c4fda5 --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/Authorize.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "AuthorizeRequest", + "type": "object", + "properties": { + "idTag": { + "type": "string", + "maxLength": 20 + } + }, + "additionalProperties": false, + "required": [ + "idTag" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/AuthorizeResponse.json b/ocpp-json/src/test/resources/schemas/AuthorizeResponse.json new file mode 100755 index 0000000..c914a71 --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/AuthorizeResponse.json @@ -0,0 +1,37 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "AuthorizeResponse", + "type": "object", + "properties": { + "idTagInfo": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "Accepted", + "Blocked", + "Expired", + "Invalid", + "ConcurrentTx" + ] + }, + "expiryDate": { + "type": "string", + "format": "date-time" + }, + "parentIdTag": { + "type": "string", + "maxLength": 20 + } + }, + "required": [ + "status" + ] + } + }, + "additionalProperties": false, + "required": [ + "idTagInfo" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/BootNotification.json b/ocpp-json/src/test/resources/schemas/BootNotification.json new file mode 100755 index 0000000..8515558 --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/BootNotification.json @@ -0,0 +1,48 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "BootNotificationRequest", + "type": "object", + "properties": { + "chargePointVendor": { + "type": "string", + "maxLength": 20 + }, + "chargePointModel": { + "type": "string", + "maxLength": 20 + }, + "chargePointSerialNumber": { + "type": "string", + "maxLength": 25 + }, + "chargeBoxSerialNumber": { + "type": "string", + "maxLength": 25 + }, + "firmwareVersion": { + "type": "string", + "maxLength": 50 + }, + "iccid": { + "type": "string", + "maxLength": 20 + }, + "imsi": { + "type": "string", + "maxLength": 20 + }, + "meterType": { + "type": "string", + "maxLength": 25 + }, + "meterSerialNumber": { + "type": "string", + "maxLength": 25 + } + }, + "additionalProperties": false, + "required": [ + "chargePointVendor", + "chargePointModel" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/BootNotificationResponse.json b/ocpp-json/src/test/resources/schemas/BootNotificationResponse.json new file mode 100755 index 0000000..10e42eb --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/BootNotificationResponse.json @@ -0,0 +1,28 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "BootNotificationResponse", + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "Accepted", + "Pending", + "Rejected" + ] + }, + "currentTime": { + "type": "string", + "format": "date-time" + }, + "interval": { + "type": "number" + } + }, + "additionalProperties": false, + "required": [ + "status", + "currentTime", + "interval" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/CancelReservation.json b/ocpp-json/src/test/resources/schemas/CancelReservation.json new file mode 100755 index 0000000..c09db45 --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/CancelReservation.json @@ -0,0 +1,14 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "CancelReservationRequest", + "type": "object", + "properties": { + "reservationId": { + "type": "integer" + } + }, + "additionalProperties": false, + "required": [ + "reservationId" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/CancelReservationResponse.json b/ocpp-json/src/test/resources/schemas/CancelReservationResponse.json new file mode 100755 index 0000000..ce4d656 --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/CancelReservationResponse.json @@ -0,0 +1,18 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "CancelReservationResponse", + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "Accepted", + "Rejected" + ] + } + }, + "additionalProperties": false, + "required": [ + "status" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/ChangeAvailability.json b/ocpp-json/src/test/resources/schemas/ChangeAvailability.json new file mode 100755 index 0000000..c35733e --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/ChangeAvailability.json @@ -0,0 +1,22 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "ChangeAvailabilityRequest", + "type": "object", + "properties": { + "connectorId": { + "type": "integer" + }, + "type": { + "type": "string", + "enum": [ + "Inoperative", + "Operative" + ] + } + }, + "additionalProperties": false, + "required": [ + "connectorId", + "type" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/ChangeAvailabilityResponse.json b/ocpp-json/src/test/resources/schemas/ChangeAvailabilityResponse.json new file mode 100755 index 0000000..ec5e7e2 --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/ChangeAvailabilityResponse.json @@ -0,0 +1,19 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "ChangeAvailabilityResponse", + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "Accepted", + "Rejected", + "Scheduled" + ] + } + }, + "additionalProperties": false, + "required": [ + "status" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/ChangeConfiguration.json b/ocpp-json/src/test/resources/schemas/ChangeConfiguration.json new file mode 100755 index 0000000..890f2e2 --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/ChangeConfiguration.json @@ -0,0 +1,20 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "ChangeConfigurationRequest", + "type": "object", + "properties": { + "key": { + "type": "string", + "maxLength": 50 + }, + "value": { + "type": "string", + "maxLength": 500 + } + }, + "additionalProperties": false, + "required": [ + "key", + "value" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/ChangeConfigurationResponse.json b/ocpp-json/src/test/resources/schemas/ChangeConfigurationResponse.json new file mode 100755 index 0000000..e94fd0f --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/ChangeConfigurationResponse.json @@ -0,0 +1,20 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "ChangeConfigurationResponse", + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "Accepted", + "Rejected", + "RebootRequired", + "NotSupported" + ] + } + }, + "additionalProperties": false, + "required": [ + "status" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/ClearCache.json b/ocpp-json/src/test/resources/schemas/ClearCache.json new file mode 100755 index 0000000..bcf8051 --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/ClearCache.json @@ -0,0 +1,7 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "ClearCacheRequest", + "type": "object", + "properties": {}, + "additionalProperties": false +} diff --git a/ocpp-json/src/test/resources/schemas/ClearCacheResponse.json b/ocpp-json/src/test/resources/schemas/ClearCacheResponse.json new file mode 100755 index 0000000..f69d0d0 --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/ClearCacheResponse.json @@ -0,0 +1,18 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "ClearCacheResponse", + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "Accepted", + "Rejected" + ] + } + }, + "additionalProperties": false, + "required": [ + "status" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/ClearChargingProfile.json b/ocpp-json/src/test/resources/schemas/ClearChargingProfile.json new file mode 100755 index 0000000..f456ae4 --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/ClearChargingProfile.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "ClearChargingProfileRequest", + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "connectorId": { + "type": "integer" + }, + "chargingProfilePurpose": { + "type": "string", + "enum": [ + "ChargePointMaxProfile", + "TxDefaultProfile", + "TxProfile" + ] + }, + "stackLevel": { + "type": "integer" + } + }, + "additionalProperties": false +} diff --git a/ocpp-json/src/test/resources/schemas/ClearChargingProfileResponse.json b/ocpp-json/src/test/resources/schemas/ClearChargingProfileResponse.json new file mode 100755 index 0000000..6fc3584 --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/ClearChargingProfileResponse.json @@ -0,0 +1,18 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "ClearChargingProfileResponse", + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "Accepted", + "Unknown" + ] + } + }, + "additionalProperties": false, + "required": [ + "status" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/DataTransfer.json b/ocpp-json/src/test/resources/schemas/DataTransfer.json new file mode 100755 index 0000000..8181221 --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/DataTransfer.json @@ -0,0 +1,22 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "DataTransferRequest", + "type": "object", + "properties": { + "vendorId": { + "type": "string", + "maxLength": 255 + }, + "messageId": { + "type": "string", + "maxLength": 50 + }, + "data": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "vendorId" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/DataTransferResponse.json b/ocpp-json/src/test/resources/schemas/DataTransferResponse.json new file mode 100755 index 0000000..4fe121e --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/DataTransferResponse.json @@ -0,0 +1,23 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "DataTransferResponse", + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "Accepted", + "Rejected", + "UnknownMessageId", + "UnknownVendorId" + ] + }, + "data": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "status" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/DiagnosticsStatusNotification.json b/ocpp-json/src/test/resources/schemas/DiagnosticsStatusNotification.json new file mode 100755 index 0000000..6b2a66a --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/DiagnosticsStatusNotification.json @@ -0,0 +1,20 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "DiagnosticsStatusNotificationRequest", + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "Idle", + "Uploaded", + "UploadFailed", + "Uploading" + ] + } + }, + "additionalProperties": false, + "required": [ + "status" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/DiagnosticsStatusNotificationResponse.json b/ocpp-json/src/test/resources/schemas/DiagnosticsStatusNotificationResponse.json new file mode 100755 index 0000000..fe2a39f --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/DiagnosticsStatusNotificationResponse.json @@ -0,0 +1,7 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "DiagnosticsStatusNotificationResponse", + "type": "object", + "properties": {}, + "additionalProperties": false +} diff --git a/ocpp-json/src/test/resources/schemas/FirmwareStatusNotification.json b/ocpp-json/src/test/resources/schemas/FirmwareStatusNotification.json new file mode 100755 index 0000000..70d295b --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/FirmwareStatusNotification.json @@ -0,0 +1,23 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "FirmwareStatusNotificationRequest", + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "Downloaded", + "DownloadFailed", + "Downloading", + "Idle", + "InstallationFailed", + "Installing", + "Installed" + ] + } + }, + "additionalProperties": false, + "required": [ + "status" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/FirmwareStatusNotificationResponse.json b/ocpp-json/src/test/resources/schemas/FirmwareStatusNotificationResponse.json new file mode 100755 index 0000000..2ba1f89 --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/FirmwareStatusNotificationResponse.json @@ -0,0 +1,7 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "FirmwareStatusNotificationResponse", + "type": "object", + "properties": {}, + "additionalProperties": false +} diff --git a/ocpp-json/src/test/resources/schemas/GetCompositeSchedule.json b/ocpp-json/src/test/resources/schemas/GetCompositeSchedule.json new file mode 100755 index 0000000..8726942 --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/GetCompositeSchedule.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "GetCompositeScheduleRequest", + "type": "object", + "properties": { + "connectorId": { + "type": "integer" + }, + "duration": { + "type": "integer" + }, + "chargingRateUnit": { + "type": "string", + "enum": [ + "A", + "W" + ] + } + }, + "additionalProperties": false, + "required": [ + "connectorId", + "duration" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/GetCompositeScheduleResponse.json b/ocpp-json/src/test/resources/schemas/GetCompositeScheduleResponse.json new file mode 100755 index 0000000..9a17df6 --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/GetCompositeScheduleResponse.json @@ -0,0 +1,74 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "GetCompositeScheduleResponse", + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "Accepted", + "Rejected" + ] + }, + "connectorId": { + "type": "integer" + }, + "scheduleStart": { + "type": "string", + "format": "date-time" + }, + "chargingSchedule": { + "type": "object", + "properties": { + "duration": { + "type": "integer" + }, + "startSchedule": { + "type": "string", + "format": "date-time" + }, + "chargingRateUnit": { + "type": "string", + "enum": [ + "A", + "W" + ] + }, + "chargingSchedulePeriod": { + "type": "array", + "items": { + "type": "object", + "properties": { + "startPeriod": { + "type": "integer" + }, + "limit": { + "type": "number", + "multipleOf" : 0.1 + }, + "numberPhases": { + "type": "integer" + } + }, + "required": [ + "startPeriod", + "limit" + ] + } + }, + "minChargingRate": { + "type": "number", + "multipleOf" : 0.1 + } + }, + "required": [ + "chargingRateUnit", + "chargingSchedulePeriod" + ] + } + }, + "additionalProperties": false, + "required": [ + "status" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/GetConfiguration.json b/ocpp-json/src/test/resources/schemas/GetConfiguration.json new file mode 100755 index 0000000..2322d0e --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/GetConfiguration.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "GetConfigurationRequest", + "type": "object", + "properties": { + "key": { + "type": "array", + "items": { + "type": "string", + "maxLength": 50 + } + } + }, + "additionalProperties": false +} diff --git a/ocpp-json/src/test/resources/schemas/GetConfigurationResponse.json b/ocpp-json/src/test/resources/schemas/GetConfigurationResponse.json new file mode 100755 index 0000000..c8a2c13 --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/GetConfigurationResponse.json @@ -0,0 +1,38 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "GetConfigurationResponse", + "type": "object", + "properties": { + "configurationKey": { + "type": "array", + "items": { + "type": "object", + "properties": { + "key": { + "type": "string", + "maxLength": 50 + }, + "readonly": { + "type": "boolean" + }, + "value": { + "type": "string", + "maxLength": 500 + } + }, + "required": [ + "key", + "readonly" + ] + } + }, + "unknownKey": { + "type": "array", + "items": { + "type": "string", + "maxLength": 50 + } + } + }, + "additionalProperties": false +} diff --git a/ocpp-json/src/test/resources/schemas/GetDiagnostics.json b/ocpp-json/src/test/resources/schemas/GetDiagnostics.json new file mode 100755 index 0000000..0b1c56b --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/GetDiagnostics.json @@ -0,0 +1,29 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "GetDiagnosticsRequest", + "type": "object", + "properties": { + "location": { + "type": "string", + "format": "uri" + }, + "retries": { + "type": "integer" + }, + "retryInterval": { + "type": "integer" + }, + "startTime": { + "type": "string", + "format": "date-time" + }, + "stopTime": { + "type": "string", + "format": "date-time" + } + }, + "additionalProperties": false, + "required": [ + "location" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/GetDiagnosticsResponse.json b/ocpp-json/src/test/resources/schemas/GetDiagnosticsResponse.json new file mode 100755 index 0000000..80892f5 --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/GetDiagnosticsResponse.json @@ -0,0 +1,12 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "GetDiagnosticsResponse", + "type": "object", + "properties": { + "fileName": { + "type": "string", + "maxLength": 255 + } + }, + "additionalProperties": false +} diff --git a/ocpp-json/src/test/resources/schemas/GetLocalListVersion.json b/ocpp-json/src/test/resources/schemas/GetLocalListVersion.json new file mode 100755 index 0000000..2a58446 --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/GetLocalListVersion.json @@ -0,0 +1,7 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "GetLocalListVersionRequest", + "type": "object", + "properties": {}, + "additionalProperties": false +} diff --git a/ocpp-json/src/test/resources/schemas/GetLocalListVersionResponse.json b/ocpp-json/src/test/resources/schemas/GetLocalListVersionResponse.json new file mode 100755 index 0000000..14bd186 --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/GetLocalListVersionResponse.json @@ -0,0 +1,14 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "GetLocalListVersionResponse", + "type": "object", + "properties": { + "listVersion": { + "type": "integer" + } + }, + "additionalProperties": false, + "required": [ + "listVersion" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/Heartbeat.json b/ocpp-json/src/test/resources/schemas/Heartbeat.json new file mode 100755 index 0000000..2d5701c --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/Heartbeat.json @@ -0,0 +1,7 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "HeartbeatRequest", + "type": "object", + "properties": {}, + "additionalProperties": false +} diff --git a/ocpp-json/src/test/resources/schemas/HeartbeatResponse.json b/ocpp-json/src/test/resources/schemas/HeartbeatResponse.json new file mode 100755 index 0000000..39f09f4 --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/HeartbeatResponse.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "HeartbeatResponse", + "type": "object", + "properties": { + "currentTime": { + "type": "string", + "format": "date-time" + } + }, + "additionalProperties": false, + "required": [ + "currentTime" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/MeterValues.json b/ocpp-json/src/test/resources/schemas/MeterValues.json new file mode 100755 index 0000000..e0e61e2 --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/MeterValues.json @@ -0,0 +1,141 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "MeterValuesRequest", + "type": "object", + "properties": { + "connectorId": { + "type": "integer" + }, + "transactionId": { + "type": "integer" + }, + "meterValue": { + "type": "array", + "items": { + "type": "object", + "properties": { + "timestamp": { + "type": "string", + "format": "date-time" + }, + "sampledValue": { + "type": "array", + "items": { + "type": "object", + "properties": { + "value": { + "type": "string" + }, + "context": { + "type": "string", + "enum": [ + "Interruption.Begin", + "Interruption.End", + "Sample.Clock", + "Sample.Periodic", + "Transaction.Begin", + "Transaction.End", + "Trigger", + "Other" + ] + }, + "format": { + "type": "string", + "enum": [ + "Raw", + "SignedData" + ] + }, + "measurand": { + "type": "string", + "enum": [ + "Energy.Active.Export.Register", + "Energy.Active.Import.Register", + "Energy.Reactive.Export.Register", + "Energy.Reactive.Import.Register", + "Energy.Active.Export.Interval", + "Energy.Active.Import.Interval", + "Energy.Reactive.Export.Interval", + "Energy.Reactive.Import.Interval", + "Power.Active.Export", + "Power.Active.Import", + "Power.Offered", + "Power.Reactive.Export", + "Power.Reactive.Import", + "Power.Factor", + "Current.Import", + "Current.Export", + "Current.Offered", + "Voltage", + "Frequency", + "Temperature", + "SoC", + "RPM" + ] + }, + "phase": { + "type": "string", + "enum": [ + "L1", + "L2", + "L3", + "N", + "L1-N", + "L2-N", + "L3-N", + "L1-L2", + "L2-L3", + "L3-L1" + ] + }, + "location": { + "type": "string", + "enum": [ + "Cable", + "EV", + "Inlet", + "Outlet", + "Body" + ] + }, + "unit": { + "type": "string", + "enum": [ + "Wh", + "kWh", + "varh", + "kvarh", + "W", + "kW", + "VA", + "kVA", + "var", + "kvar", + "A", + "V", + "K", + "Celsius", + "Fahrenheit", + "Percent" + ] + } + }, + "required": [ + "value" + ] + } + } + }, + "required": [ + "timestamp", + "sampledValue" + ] + } + } + }, + "additionalProperties": false, + "required": [ + "connectorId", + "meterValue" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/MeterValuesResponse.json b/ocpp-json/src/test/resources/schemas/MeterValuesResponse.json new file mode 100755 index 0000000..3b8d9fc --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/MeterValuesResponse.json @@ -0,0 +1,7 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "MeterValuesResponse", + "type": "object", + "properties": {}, + "additionalProperties": false +} diff --git a/ocpp-json/src/test/resources/schemas/RemoteStartTransaction.json b/ocpp-json/src/test/resources/schemas/RemoteStartTransaction.json new file mode 100755 index 0000000..a29bdd2 --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/RemoteStartTransaction.json @@ -0,0 +1,119 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "RemoteStartTransactionRequest", + "type": "object", + "properties": { + "connectorId": { + "type": "integer" + }, + "idTag": { + "type": "string", + "maxLength": 20 + }, + "chargingProfile": { + "type": "object", + "properties": { + "chargingProfileId": { + "type": "integer" + }, + "transactionId": { + "type": "integer" + }, + "stackLevel": { + "type": "integer" + }, + "chargingProfilePurpose": { + "type": "string", + "enum": [ + "ChargePointMaxProfile", + "TxDefaultProfile", + "TxProfile" + ] + }, + "chargingProfileKind": { + "type": "string", + "enum": [ + "Absolute", + "Recurring", + "Relative" + ] + }, + "recurrencyKind": { + "type": "string", + "enum": [ + "Daily", + "Weekly" + ] + }, + "validFrom": { + "type": "string", + "format": "date-time" + }, + "validTo": { + "type": "string", + "format": "date-time" + }, + "chargingSchedule": { + "type": "object", + "properties": { + "duration": { + "type": "integer" + }, + "startSchedule": { + "type": "string", + "format": "date-time" + }, + "chargingRateUnit": { + "type": "string", + "enum": [ + "A", + "W" + ] + }, + "chargingSchedulePeriod": { + "type": "array", + "items": { + "type": "object", + "properties": { + "startPeriod": { + "type": "integer" + }, + "limit": { + "type": "number", + "multipleOf" : 0.1 + }, + "numberPhases": { + "type": "integer" + } + }, + "required": [ + "startPeriod", + "limit" + ] + } + }, + "minChargingRate": { + "type": "number", + "multipleOf" : 0.1 + } + }, + "required": [ + "chargingRateUnit", + "chargingSchedulePeriod" + ] + } + }, + "required": [ + "chargingProfileId", + "stackLevel", + "chargingProfilePurpose", + "chargingProfileKind", + "chargingSchedule" + ] + } + }, + "additionalProperties": false, + "required": [ + "idTag" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/RemoteStartTransactionResponse.json b/ocpp-json/src/test/resources/schemas/RemoteStartTransactionResponse.json new file mode 100755 index 0000000..e68893b --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/RemoteStartTransactionResponse.json @@ -0,0 +1,18 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "RemoteStartTransactionResponse", + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "Accepted", + "Rejected" + ] + } + }, + "additionalProperties": false, + "required": [ + "status" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/RemoteStopTransaction.json b/ocpp-json/src/test/resources/schemas/RemoteStopTransaction.json new file mode 100755 index 0000000..f8c7c51 --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/RemoteStopTransaction.json @@ -0,0 +1,14 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "RemoteStopTransactionRequest", + "type": "object", + "properties": { + "transactionId": { + "type": "integer" + } + }, + "additionalProperties": false, + "required": [ + "transactionId" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/RemoteStopTransactionResponse.json b/ocpp-json/src/test/resources/schemas/RemoteStopTransactionResponse.json new file mode 100755 index 0000000..af4f50b --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/RemoteStopTransactionResponse.json @@ -0,0 +1,18 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "RemoteStopTransactionResponse", + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "Accepted", + "Rejected" + ] + } + }, + "additionalProperties": false, + "required": [ + "status" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/ReserveNow.json b/ocpp-json/src/test/resources/schemas/ReserveNow.json new file mode 100755 index 0000000..baa39d2 --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/ReserveNow.json @@ -0,0 +1,32 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "ReserveNowRequest", + "type": "object", + "properties": { + "connectorId": { + "type": "integer" + }, + "expiryDate": { + "type": "string", + "format": "date-time" + }, + "idTag": { + "type": "string", + "maxLength": 20 + }, + "parentIdTag": { + "type": "string", + "maxLength": 20 + }, + "reservationId": { + "type": "integer" + } + }, + "additionalProperties": false, + "required": [ + "connectorId", + "expiryDate", + "idTag", + "reservationId" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/ReserveNowResponse.json b/ocpp-json/src/test/resources/schemas/ReserveNowResponse.json new file mode 100755 index 0000000..542cbca --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/ReserveNowResponse.json @@ -0,0 +1,21 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "ReserveNowResponse", + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "Accepted", + "Faulted", + "Occupied", + "Rejected", + "Unavailable" + ] + } + }, + "additionalProperties": false, + "required": [ + "status" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/Reset.json b/ocpp-json/src/test/resources/schemas/Reset.json new file mode 100755 index 0000000..ecc7180 --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/Reset.json @@ -0,0 +1,18 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "ResetRequest", + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "Hard", + "Soft" + ] + } + }, + "additionalProperties": false, + "required": [ + "type" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/ResetResponse.json b/ocpp-json/src/test/resources/schemas/ResetResponse.json new file mode 100755 index 0000000..c5b1b66 --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/ResetResponse.json @@ -0,0 +1,18 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "ResetResponse", + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "Accepted", + "Rejected" + ] + } + }, + "additionalProperties": false, + "required": [ + "status" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/SendLocalList.json b/ocpp-json/src/test/resources/schemas/SendLocalList.json new file mode 100755 index 0000000..0465615 --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/SendLocalList.json @@ -0,0 +1,63 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "SendLocalListRequest", + "type": "object", + "properties": { + "listVersion": { + "type": "integer" + }, + "localAuthorizationList": { + "type": "array", + "items": { + "type": "object", + "properties": { + "idTag": { + "type": "string", + "maxLength": 20 + }, + "idTagInfo": { + "type": "object", + "expiryDate": { + "type": "string", + "format": "date-time" + }, + "parentIdTag": { + "type": "string", + "maxLength": 20 + }, + "properties": { + "status": { + "type": "string", + "enum": [ + "Accepted", + "Blocked", + "Expired", + "Invalid", + "ConcurrentTx" + ] + } + }, + "required": [ + "status" + ] + } + }, + "required": [ + "idTag" + ] + } + }, + "updateType": { + "type": "string", + "enum": [ + "Differential", + "Full" + ] + } + }, + "additionalProperties": false, + "required": [ + "listVersion", + "updateType" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/SendLocalListResponse.json b/ocpp-json/src/test/resources/schemas/SendLocalListResponse.json new file mode 100755 index 0000000..988ee1e --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/SendLocalListResponse.json @@ -0,0 +1,20 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "SendLocalListResponse", + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "Accepted", + "Failed", + "NotSupported", + "VersionMismatch" + ] + } + }, + "additionalProperties": false, + "required": [ + "status" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/SetChargingProfile.json b/ocpp-json/src/test/resources/schemas/SetChargingProfile.json new file mode 100755 index 0000000..a832949 --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/SetChargingProfile.json @@ -0,0 +1,116 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "SetChargingProfileRequest", + "type": "object", + "properties": { + "connectorId": { + "type": "integer" + }, + "csChargingProfiles": { + "type": "object", + "properties": { + "chargingProfileId": { + "type": "integer" + }, + "transactionId": { + "type": "integer" + }, + "stackLevel": { + "type": "integer" + }, + "chargingProfilePurpose": { + "type": "string", + "enum": [ + "ChargePointMaxProfile", + "TxDefaultProfile", + "TxProfile" + ] + }, + "chargingProfileKind": { + "type": "string", + "enum": [ + "Absolute", + "Recurring", + "Relative" + ] + }, + "recurrencyKind": { + "type": "string", + "enum": [ + "Daily", + "Weekly" + ] + }, + "validFrom": { + "type": "string", + "format": "date-time" + }, + "validTo": { + "type": "string", + "format": "date-time" + }, + "chargingSchedule": { + "type": "object", + "properties": { + "duration": { + "type": "integer" + }, + "startSchedule": { + "type": "string", + "format": "date-time" + }, + "chargingRateUnit": { + "type": "string", + "enum": [ + "A", + "W" + ] + }, + "chargingSchedulePeriod": { + "type": "array", + "items": { + "type": "object", + "properties": { + "startPeriod": { + "type": "integer" + }, + "limit": { + "type": "number", + "multipleOf" : 0.1 + }, + "numberPhases": { + "type": "integer" + } + }, + "required": [ + "startPeriod", + "limit" + ] + } + }, + "minChargingRate": { + "type": "number", + "multipleOf" : 0.1 + } + }, + "required": [ + "chargingRateUnit", + "chargingSchedulePeriod" + ] + } + }, + "required": [ + "chargingProfileId", + "stackLevel", + "chargingProfilePurpose", + "chargingProfileKind", + "chargingSchedule" + ] + } + }, + "additionalProperties": false, + "required": [ + "connectorId", + "csChargingProfiles" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/SetChargingProfileResponse.json b/ocpp-json/src/test/resources/schemas/SetChargingProfileResponse.json new file mode 100755 index 0000000..bfa3628 --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/SetChargingProfileResponse.json @@ -0,0 +1,19 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "SetChargingProfileResponse", + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "Accepted", + "Rejected", + "NotSupported" + ] + } + }, + "additionalProperties": false, + "required": [ + "status" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/StartTransaction.json b/ocpp-json/src/test/resources/schemas/StartTransaction.json new file mode 100755 index 0000000..aebe5fc --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/StartTransaction.json @@ -0,0 +1,31 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "StartTransactionRequest", + "type": "object", + "properties": { + "connectorId": { + "type": "integer" + }, + "idTag": { + "type": "string", + "maxLength": 20 + }, + "meterStart": { + "type": "integer" + }, + "reservationId": { + "type": "integer" + }, + "timestamp": { + "type": "string", + "format": "date-time" + } + }, + "additionalProperties": false, + "required": [ + "connectorId", + "idTag", + "meterStart", + "timestamp" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/StartTransactionResponse.json b/ocpp-json/src/test/resources/schemas/StartTransactionResponse.json new file mode 100755 index 0000000..b4d46d7 --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/StartTransactionResponse.json @@ -0,0 +1,41 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "StartTransactionResponse", + "type": "object", + "properties": { + "idTagInfo": { + "type": "object", + "properties": { + "expiryDate": { + "type": "string", + "format": "date-time" + }, + "parentIdTag": { + "type": "string", + "maxLength": 20 + }, + "status": { + "type": "string", + "enum": [ + "Accepted", + "Blocked", + "Expired", + "Invalid", + "ConcurrentTx" + ] + } + }, + "required": [ + "status" + ] + }, + "transactionId": { + "type": "integer" + } + }, + "additionalProperties": false, + "required": [ + "idTagInfo", + "transactionId" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/StatusNotification.json b/ocpp-json/src/test/resources/schemas/StatusNotification.json new file mode 100755 index 0000000..44542c3 --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/StatusNotification.json @@ -0,0 +1,67 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "StatusNotificationRequest", + "type": "object", + "properties": { + "connectorId": { + "type": "integer" + }, + "errorCode": { + "type": "string", + "enum": [ + "ConnectorLockFailure", + "EVCommunicationError", + "GroundFailure", + "HighTemperature", + "InternalError", + "LocalListConflict", + "NoError", + "OtherError", + "OverCurrentFailure", + "PowerMeterFailure", + "PowerSwitchFailure", + "ReaderFailure", + "ResetFailure", + "UnderVoltage", + "OverVoltage", + "WeakSignal" + ] + }, + "info": { + "type": "string", + "maxLength": 50 + }, + "status": { + "type": "string", + "enum": [ + "Available", + "Preparing", + "Charging", + "SuspendedEVSE", + "SuspendedEV", + "Finishing", + "Reserved", + "Unavailable", + "Faulted" + ] + }, + "timestamp": { + "type": "string", + "format": "date-time" + }, + "vendorId": { + "type": "string", + "maxLength": 255 + }, + "vendorErrorCode": { + "type": "string", + "maxLength": 50 + } + }, + "additionalProperties": false, + "required": [ + "connectorId", + "errorCode", + "status" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/StatusNotificationResponse.json b/ocpp-json/src/test/resources/schemas/StatusNotificationResponse.json new file mode 100755 index 0000000..78a7423 --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/StatusNotificationResponse.json @@ -0,0 +1,7 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "StatusNotificationResponse", + "type": "object", + "properties": {}, + "additionalProperties": false +} diff --git a/ocpp-json/src/test/resources/schemas/StopTransaction.json b/ocpp-json/src/test/resources/schemas/StopTransaction.json new file mode 100755 index 0000000..924663d --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/StopTransaction.json @@ -0,0 +1,166 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "StopTransactionRequest", + "type": "object", + "properties": { + "idTag": { + "type": "string", + "maxLength": 20 + }, + "meterStop": { + "type": "integer" + }, + "timestamp": { + "type": "string", + "format": "date-time" + }, + "transactionId": { + "type": "integer" + }, + "reason": { + "type": "string", + "enum": [ + "EmergencyStop", + "EVDisconnected", + "HardReset", + "Local", + "Other", + "PowerLoss", + "Reboot", + "Remote", + "SoftReset", + "UnlockCommand", + "DeAuthorized" + ] + }, + "transactionData": { + "type": "array", + "items": { + "type": "object", + "properties": { + "timestamp": { + "type": "string", + "format": "date-time" + }, + "sampledValue": { + "type": "array", + "items": { + "type": "object", + "properties": { + "value": { + "type": "string" + }, + "context": { + "type": "string", + "enum": [ + "Interruption.Begin", + "Interruption.End", + "Sample.Clock", + "Sample.Periodic", + "Transaction.Begin", + "Transaction.End", + "Trigger", + "Other" + ] + }, + "format": { + "type": "string", + "enum": [ + "Raw", + "SignedData" + ] + }, + "measurand": { + "type": "string", + "enum": [ + "Energy.Active.Export.Register", + "Energy.Active.Import.Register", + "Energy.Reactive.Export.Register", + "Energy.Reactive.Import.Register", + "Energy.Active.Export.Interval", + "Energy.Active.Import.Interval", + "Energy.Reactive.Export.Interval", + "Energy.Reactive.Import.Interval", + "Power.Active.Export", + "Power.Active.Import", + "Power.Offered", + "Power.Reactive.Export", + "Power.Reactive.Import", + "Power.Factor", + "Current.Import", + "Current.Export", + "Current.Offered", + "Voltage", + "Frequency", + "Temperature", + "SoC", + "RPM" + ] + }, + "phase": { + "type": "string", + "enum": [ + "L1", + "L2", + "L3", + "N", + "L1-N", + "L2-N", + "L3-N", + "L1-L2", + "L2-L3", + "L3-L1" + ] + }, + "location": { + "type": "string", + "enum": [ + "Cable", + "EV", + "Inlet", + "Outlet", + "Body" + ] + }, + "unit": { + "type": "string", + "enum": [ + "Wh", + "kWh", + "varh", + "kvarh", + "W", + "kW", + "VA", + "kVA", + "var", + "kvar", + "A", + "V", + "K", + "Celsius", + "Fahrenheit", + "Percent" + ] + } + }, + "required": [ + "value" + ] + } + } + }, + "required": [ + "timestamp", + "sampledValue" + ] + } + } + }, + "additionalProperties": false, + "required": [ + "transactionId", + "timestamp", + "meterStop" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/StopTransactionResponse.json b/ocpp-json/src/test/resources/schemas/StopTransactionResponse.json new file mode 100755 index 0000000..c50bdaa --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/StopTransactionResponse.json @@ -0,0 +1,34 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "StopTransactionResponse", + "type": "object", + "properties": { + "idTagInfo": { + "type": "object", + "properties": { + "expiryDate": { + "type": "string", + "format": "date-time" + }, + "parentIdTag": { + "type": "string", + "maxLength": 20 + }, + "status": { + "type": "string", + "enum": [ + "Accepted", + "Blocked", + "Expired", + "Invalid", + "ConcurrentTx" + ] + } + }, + "required": [ + "status" + ] + } + }, + "additionalProperties": false +} diff --git a/ocpp-json/src/test/resources/schemas/TriggerMessage.json b/ocpp-json/src/test/resources/schemas/TriggerMessage.json new file mode 100755 index 0000000..ef9d5a4 --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/TriggerMessage.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "TriggerMessageRequest", + "type": "object", + "properties": { + "requestedMessage": { + "type": "string", + "enum": [ + "BootNotification", + "DiagnosticsStatusNotification", + "FirmwareStatusNotification", + "Heartbeat", + "MeterValues", + "StatusNotification" + ] + }, + "connectorId": { + "type": "integer" + } + }, + "additionalProperties": false, + "required": [ + "requestedMessage" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/TriggerMessageResponse.json b/ocpp-json/src/test/resources/schemas/TriggerMessageResponse.json new file mode 100755 index 0000000..54695be --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/TriggerMessageResponse.json @@ -0,0 +1,19 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "TriggerMessageResponse", + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "Accepted", + "Rejected", + "NotImplemented" + ] + } + }, + "additionalProperties": false, + "required": [ + "status" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/UnlockConnector.json b/ocpp-json/src/test/resources/schemas/UnlockConnector.json new file mode 100755 index 0000000..15686d0 --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/UnlockConnector.json @@ -0,0 +1,14 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "UnlockConnectorRequest", + "type": "object", + "properties": { + "connectorId": { + "type": "integer" + } + }, + "additionalProperties": false, + "required": [ + "connectorId" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/UnlockConnectorResponse.json b/ocpp-json/src/test/resources/schemas/UnlockConnectorResponse.json new file mode 100755 index 0000000..05ca975 --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/UnlockConnectorResponse.json @@ -0,0 +1,19 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "UnlockConnectorResponse", + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "Unlocked", + "UnlockFailed", + "NotSupported" + ] + } + }, + "additionalProperties": false, + "required": [ + "status" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/UpdateFirmware.json b/ocpp-json/src/test/resources/schemas/UpdateFirmware.json new file mode 100755 index 0000000..119184f --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/UpdateFirmware.json @@ -0,0 +1,26 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "UpdateFirmwareRequest", + "type": "object", + "properties": { + "location": { + "type": "string", + "format": "uri" + }, + "retries": { + "type": "number" + }, + "retrieveDate": { + "type": "string", + "format": "date-time" + }, + "retryInterval": { + "type": "number" + } + }, + "additionalProperties": false, + "required": [ + "location", + "retrieveDate" + ] +} diff --git a/ocpp-json/src/test/resources/schemas/UpdateFirmwareResponse.json b/ocpp-json/src/test/resources/schemas/UpdateFirmwareResponse.json new file mode 100755 index 0000000..370600f --- /dev/null +++ b/ocpp-json/src/test/resources/schemas/UpdateFirmwareResponse.json @@ -0,0 +1,7 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "UpdateFirmwareResponse", + "type": "object", + "properties": {}, + "additionalProperties": false +} diff --git a/ocpp-json/src/test/scala/com/thenewmotion/ocpp/json/v16/JsonSchemaValidationSpec.scala b/ocpp-json/src/test/scala/com/thenewmotion/ocpp/json/v16/JsonSchemaValidationSpec.scala new file mode 100644 index 0000000..fce2e79 --- /dev/null +++ b/ocpp-json/src/test/scala/com/thenewmotion/ocpp/json/v16/JsonSchemaValidationSpec.scala @@ -0,0 +1,100 @@ +package com.thenewmotion.ocpp +package json +package v16 + +import com.fasterxml.jackson.databind.JsonNode +import com.github.fge.jsonschema.main.{JsonSchemaFactory, JsonValidator} +import org.scalacheck.Gen +import org.scalacheck.Prop.forAll +import org.specs2.ScalaCheck +import org.specs2.mutable.Specification +import org.json4s.jackson.JsonMethods._ + +import scala.collection.JavaConversions._ +import scala.reflect.{ClassTag, classTag} + +object JsonSchemaValidationSpec extends Specification with ScalaCheck { + + import SerializationV16._ + import scalacheck.MessageGenerators._ + + val validator: JsonValidator = JsonSchemaFactory.byDefault().getValidator + + "Validating serialized OCPP 1.6 messages against the schema" should { + validateJson(bootNotificationReq)(BootNotificationReqV16Variant, "BootNotification.json") + validateJson(bootNotificationRes)(BootNotificationResV16Variant, "BootNotificationResponse.json") + validateJson(authorizeReq)(AuthorizeReqV16Variant, "Authorize.json") + validateJson(authorizeRes)(AuthorizeResV16Variant, "AuthorizeResponse.json") + validateJson(startTransactionReq)(StartTransactionReqV16Variant, "StartTransaction.json") +// validateJson(startTransactionRes)(StartTransactionResV16Variant, "StartTransactionResponse.json") + validateJson(stopTransactionReq)(StopTransactionReqV16Variant, "StopTransaction.json") +// validateJson(stopTransactionRes)(StopTransactionResV16Variant, "StopTransactionResponse.json") + validateJson(unlockConnectorReq)(UnlockConnectorReqV16Variant, "UnlockConnector.json") + validateJson(unlockConnectorRes)(UnlockConnectorResV16Variant, "UnlockConnectorResponse.json") + validateJson(resetReq)(ResetReqV16Variant, "Reset.json") + validateJson(resetRes)(ResetResV16Variant, "ResetResponse.json") + validateJson(changeAvailabilityReq)(ChangeAvailabilityReqV16Variant, "ChangeAvailability.json") + validateJson(changeAvailabilityRes)(ChangeAvailabilityResV16Variant, "ChangeAvailabilityResponse.json") + validateJson(statusNotificationReq)(StatusNotificationReqV16Variant, "StatusNotification.json") + validateJson(statusNotificationRes)(StatusNotificationResV16Variant, "StatusNotificationResponse.json") + validateJson(remoteStartTransactionReq)(RemoteStartTransactionReqV16Variant, "RemoteStartTransaction.json") + validateJson(remoteStartTransactionRes)(RemoteStartTransactionResV16Variant, "RemoteStartTransactionResponse.json") + validateJson(remoteStopTransactionReq)(RemoteStopTransactionReqV16Variant, "RemoteStopTransaction.json") + validateJson(remoteStopTransactionRes)(RemoteStopTransactionResV16Variant, "RemoteStopTransactionResponse.json") + validateJson(heartbeatReq)(HeartbeatReqV16Variant, "Heartbeat.json") + validateJson(heartbeatRes)(HeartbeatResV16Variant, "HeartbeatResponse.json") + validateJson(updateFirmwareReq)(UpdateFirmwareReqV16Variant, "UpdateFirmware.json") + validateJson(updateFirmwareRes)(UpdateFirmwareResV16Variant, "UpdateFirmwareResponse.json") + validateJson(firmwareStatusNotificationReq)(FirmwareStatusNotificationReqV16Variant, "FirmwareStatusNotification.json") + validateJson(firmwareStatusNotificationRes)(FirmwareStatusNotificationResV16Variant, "FirmwareStatusNotificationResponse.json") + validateJson(getDiagnosticsReq)(GetDiagnosticsReqV16Variant, "GetDiagnostics.json") + validateJson(getDiagnosticsRes)(GetDiagnosticsResV16Variant, "GetDiagnosticsResponse.json") + validateJson(diagnosticsStatusNotificationReq)(DiagnosticsStatusNotificationReqV16Variant, "DiagnosticsStatusNotification.json") + validateJson(diagnosticsStatusNotificationRes)(DiagnosticsStatusNotificationResV16Variant, "DiagnosticsStatusNotificationResponse.json") + validateJson(meterValuesReq)(MeterValuesReqV16Variant, "MeterValues.json") + validateJson(meterValuesRes)(MeterValuesResV16Variant, "MeterValuesResponse.json") + validateJson(changeConfigurationReq)(ChangeConfigurationReqV16Variant, "ChangeConfiguration.json") + validateJson(changeConfigurationRes)(ChangeConfigurationResV16Variant, "ChangeConfigurationResponse.json") + validateJson(clearCacheReq)(ClearCacheReqV16Variant, "ClearCache.json") + validateJson(clearCacheRes)(ClearCacheResV16Variant, "ClearCacheResponse.json") + validateJson(getConfigurationReq)(GetConfigurationReqV16Variant, "GetConfiguration.json") + validateJson(getConfigurationRes)(GetConfigurationResV16Variant, "GetConfigurationResponse.json") + validateJson(getLocalListVersionReq)(GetLocalListVersionReqV16Variant, "GetLocalListVersion.json") + validateJson(getLocalListVersionRes)(GetLocalListVersionResV16Variant, "GetLocalListVersionResponse.json") + validateJson(reserveNowReq)(ReserveNowReqV16Variant, "ReserveNow.json") + validateJson(reserveNowRes)(ReserveNowResV16Variant, "ReserveNowResponse.json") + validateJson(cancelReservationReq)(CancelReservationReqV16Variant, "CancelReservation.json") + validateJson(cancelReservationRes)(CancelReservationResV16Variant, "CancelReservationResponse.json") + validateJson(clearChargingProfileReq)(ClearChargingProfileReqV16Variant, "ClearChargingProfile.json") + validateJson(clearChargingProfileRes)(ClearChargingProfileResV16Variant, "ClearChargingProfileResponse.json") + validateJson(getCompositeScheduleReq)(GetCompositeScheduleReqV16Variant, "GetCompositeSchedule.json") + validateJson(getCompositeScheduleRes)(GetCompositeScheduleResV16Variant, "GetCompositeScheduleResponse.json") + validateJson(setChargingProfileReq)(SetChargingProfileReqV16Variant, "SetChargingProfile.json") + validateJson(setChargingProfileRes)(SetChargingProfileResV16Variant, "SetChargingProfileResponse.json") + validateJson(triggerMessageReq)(TriggerMessageReqV16Variant, "TriggerMessage.json") + validateJson(triggerMessageRes)(TriggerMessageResV16Variant, "TriggerMessageResponse.json") + } + + private def validateJson[T <: v16.Message : ClassTag, M <: messages.Message] + (messageGen: Gen[T]) + (ser: OcppMessageSerializer[M, Version.V16.type], schema:String) = { + + val schemaFile:String = scala.io.Source.fromInputStream(getClass.getResourceAsStream(s"/schemas/${schema}")).getLines.mkString("\n") + val jsonSchema: JsonNode = asJsonNode(parse(schemaFile)) + + val className = classTag[T].runtimeClass.getSimpleName + + s"result in succesfull validation of $className" in { + forAll(messageGen) { msg => + val json:JsonNode = asJsonNode(ser.serialize(ser.from(msg.asInstanceOf[ser.VersionSpecific]))) + val validationReport = validator.validate(jsonSchema, json) + if (validationReport.isSuccess) { + success + } else { + failure(validationReport.map(_.getMessage).mkString("\n")) + } + } + } + } +} + diff --git a/ocpp-json/src/test/scala/com/thenewmotion/ocpp/json/v16/SerializationV16Spec.scala b/ocpp-json/src/test/scala/com/thenewmotion/ocpp/json/v16/SerializationV16Spec.scala index 715a1de..e6dfab4 100644 --- a/ocpp-json/src/test/scala/com/thenewmotion/ocpp/json/v16/SerializationV16Spec.scala +++ b/ocpp-json/src/test/scala/com/thenewmotion/ocpp/json/v16/SerializationV16Spec.scala @@ -21,7 +21,9 @@ object SerializationV16Spec extends Specification with ScalaCheck { testMessageClass(authorizeReq)(AuthorizeReqV16Variant) testMessageClass(authorizeRes)(AuthorizeResV16Variant) testMessageClass(startTransactionReq)(StartTransactionReqV16Variant) +// testMessageClass(startTransactionRes)(StartTransactionResV16Variant) testMessageClass(stopTransactionReq)(StopTransactionReqV16Variant) +// testMessageClass(stopTransactionRes)(StopTransactionResV16Variant) testMessageClass(unlockConnectorReq)(UnlockConnectorReqV16Variant) testMessageClass(unlockConnectorRes)(UnlockConnectorResV16Variant) testMessageClass(resetReq)(ResetReqV16Variant) diff --git a/ocpp-json/src/test/scala/com/thenewmotion/ocpp/json/v16/scalacheck/Helpers.scala b/ocpp-json/src/test/scala/com/thenewmotion/ocpp/json/v16/scalacheck/Helpers.scala index a4d3773..ecae75e 100644 --- a/ocpp-json/src/test/scala/com/thenewmotion/ocpp/json/v16/scalacheck/Helpers.scala +++ b/ocpp-json/src/test/scala/com/thenewmotion/ocpp/json/v16/scalacheck/Helpers.scala @@ -16,7 +16,7 @@ object Helpers { def connectorIdGen: Gen[Int] = chooseNum(1, 4) def connectorIdIncludingChargePointGen: Gen[Int] = chooseNum(0, 4) - def idTagGen: Gen[String] = alphaNumStr.filter(_.nonEmpty) + def idTagGen: Gen[String] = Gen.resize(20, alphaNumStr.filter(_.nonEmpty)) def idTagInfoGen: Gen[IdTagInfo] = for { @@ -108,9 +108,9 @@ object Helpers { def configurationEntryGen: Gen[ConfigurationEntry] = for { - key <- alphaNumStr + key <- Gen.resize(50,alphaNumStr) readOnly <- oneOf(true, false) - value <- option(words) + value <- option(Gen.resize(500, words)) } yield ConfigurationEntry(key, readOnly, value) def enumerableGen[T <: Nameable](e: Enumerable[T]): Gen[T] = diff --git a/ocpp-json/src/test/scala/com/thenewmotion/ocpp/json/v16/scalacheck/MessageGenerators.scala b/ocpp-json/src/test/scala/com/thenewmotion/ocpp/json/v16/scalacheck/MessageGenerators.scala index 0adf865..22750ea 100644 --- a/ocpp-json/src/test/scala/com/thenewmotion/ocpp/json/v16/scalacheck/MessageGenerators.scala +++ b/ocpp-json/src/test/scala/com/thenewmotion/ocpp/json/v16/scalacheck/MessageGenerators.scala @@ -10,15 +10,15 @@ object MessageGenerators { def bootNotificationReq: Gen[BootNotificationReq] = for { - chargePointVendor <- alphaNumStr - chargePointModel <- words - chargePointSerialNumber <- option(alphaNumStr) - chargeBoxSerialNumber <- option(alphaNumStr) - firmwareVersion <- option(alphaNumStr) - iccid <- option(numStr) - imsi <- option(numStr) - meterType <- option(alphaNumStr) - meterSerialNumber <- option(alphaNumStr) + chargePointVendor <- Gen.resize(20, alphaNumStr) + chargePointModel <- Gen.resize(20, words) + chargePointSerialNumber <- option(Gen.resize(25, alphaNumStr)) + chargeBoxSerialNumber <- option(Gen.resize(25, alphaNumStr)) + firmwareVersion <- option(Gen.resize(50, alphaNumStr)) + iccid <- option(Gen.resize(20, numStr)) + imsi <- option(Gen.resize(20, numStr)) + meterType <- option(Gen.resize(25, alphaNumStr)) + meterSerialNumber <- option(Gen.resize(25, alphaNumStr)) } yield BootNotificationReq( chargePointVendor, chargePointModel, @@ -60,6 +60,7 @@ object MessageGenerators { reservationId ) } + def startTransactionRes: Gen[StartTransactionRes] = ??? def stopTransactionReq: Gen[StopTransactionReq] = for { @@ -80,6 +81,8 @@ object MessageGenerators { ) } + def stopTransactionRes: Gen[StopTransactionRes] = ??? + def unlockConnectorReq: Gen[UnlockConnectorReq] = connectorIdGen.map(UnlockConnectorReq) @@ -110,13 +113,13 @@ object MessageGenerators { else const("NoError") info <- if (status == "Faulted") - option(words) + option(Gen.resize(50, words)) else const(None) timestamp <- option(dateTimeGen) - vendorId <- option(alphaNumStr) + vendorId <- option(Gen.resize(255, alphaNumStr)) vendorErrorCode <- if (status == "Faulted") - option(alphaNumStr) + option(Gen.resize(50, alphaNumStr)) else const(None) } yield StatusNotificationReq(connectorId, status, errorCode, info, timestamp, vendorId, vendorErrorCode) @@ -190,8 +193,8 @@ object MessageGenerators { def changeConfigurationReq: Gen[ChangeConfigurationReq] = for { - key <- alphaNumStr - value <- words + key <- Gen.resize(50, alphaNumStr) + value <- Gen.resize(500, words) } yield ChangeConfigurationReq(key, value) def changeConfigurationRes: Gen[ChangeConfigurationRes] = @@ -204,13 +207,13 @@ object MessageGenerators { def getConfigurationReq: Gen[GetConfigurationReq] = for { - keys <- optionalNonEmptyList(alphaNumStr) + keys <- optionalNonEmptyList(Gen.resize(50, alphaNumStr)) } yield GetConfigurationReq(keys) def getConfigurationRes: Gen[GetConfigurationRes] = for { entries <- optionalNonEmptyList(configurationEntryGen) - unknownKeys <- optionalNonEmptyList(alphaNumStr) + unknownKeys <- optionalNonEmptyList(Gen.resize(50,alphaNumStr)) } yield GetConfigurationRes(entries, unknownKeys) def getLocalListVersionReq: Gen[GetLocalListVersionReq] = const(GetLocalListVersionReq()) diff --git a/ocpp-messages/src/main/scala/com/thenewmotion/ocpp/messages/meter/Meter.scala b/ocpp-messages/src/main/scala/com/thenewmotion/ocpp/messages/meter/Meter.scala index 1e7be56..39dfd96 100644 --- a/ocpp-messages/src/main/scala/com/thenewmotion/ocpp/messages/meter/Meter.scala +++ b/ocpp-messages/src/main/scala/com/thenewmotion/ocpp/messages/meter/Meter.scala @@ -89,9 +89,9 @@ object Measurand extends EnumerableWithDefault[Measurand] { sealed trait ValueFormat extends Nameable object ValueFormat extends EnumerableWithDefault[ValueFormat] { case object Raw extends ValueFormat - case object Signed extends ValueFormat + case object SignedData extends ValueFormat - val values = Set(Raw, Signed) + val values = Set(Raw, SignedData) val default = Raw } diff --git a/ocpp-soap/src/main/scala/com/thenewmotion/ocpp/soap/CentralSystemClient.scala b/ocpp-soap/src/main/scala/com/thenewmotion/ocpp/soap/CentralSystemClient.scala index b630b09..7706831 100644 --- a/ocpp-soap/src/main/scala/com/thenewmotion/ocpp/soap/CentralSystemClient.scala +++ b/ocpp-soap/src/main/scala/com/thenewmotion/ocpp/soap/CentralSystemClient.scala @@ -342,7 +342,7 @@ class CentralSystemClientV15(val chargeBoxIdentity: String, uri: Uri, http: Http import messages.meter.{ValueFormat => ocpp} x match { case ocpp.Raw => Raw - case ocpp.Signed => SignedData + case ocpp.SignedData => SignedData } } diff --git a/ocpp-soap/src/main/scala/com/thenewmotion/ocpp/soap/CentralSystemDispatcher.scala b/ocpp-soap/src/main/scala/com/thenewmotion/ocpp/soap/CentralSystemDispatcher.scala index 7f15563..835e9a1 100644 --- a/ocpp-soap/src/main/scala/com/thenewmotion/ocpp/soap/CentralSystemDispatcher.scala +++ b/ocpp-soap/src/main/scala/com/thenewmotion/ocpp/soap/CentralSystemDispatcher.scala @@ -317,7 +317,7 @@ object CentralSystemDispatcherV15 extends AbstractDispatcher[CentralSystemReq, C import meter.{ValueFormat => ocpp} x match { case Raw => ocpp.Raw - case SignedData => ocpp.Signed + case SignedData => ocpp.SignedData } } From 0c8a4b130a2618e7bfa2eb050e95f17b3741320e Mon Sep 17 00:00:00 2001 From: Gertjan Assies Date: Mon, 16 Oct 2017 09:48:02 +0200 Subject: [PATCH 2/3] TNM-4930 Added missing generators --- .../json/v16/JsonSchemaValidationSpec.scala | 4 ++-- .../ocpp/json/v16/SerializationV16Spec.scala | 4 ++-- .../v16/scalacheck/MessageGenerators.scala | 21 ++++++++++++++++--- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/ocpp-json/src/test/scala/com/thenewmotion/ocpp/json/v16/JsonSchemaValidationSpec.scala b/ocpp-json/src/test/scala/com/thenewmotion/ocpp/json/v16/JsonSchemaValidationSpec.scala index fce2e79..1d7f173 100644 --- a/ocpp-json/src/test/scala/com/thenewmotion/ocpp/json/v16/JsonSchemaValidationSpec.scala +++ b/ocpp-json/src/test/scala/com/thenewmotion/ocpp/json/v16/JsonSchemaValidationSpec.scala @@ -26,9 +26,9 @@ object JsonSchemaValidationSpec extends Specification with ScalaCheck { validateJson(authorizeReq)(AuthorizeReqV16Variant, "Authorize.json") validateJson(authorizeRes)(AuthorizeResV16Variant, "AuthorizeResponse.json") validateJson(startTransactionReq)(StartTransactionReqV16Variant, "StartTransaction.json") -// validateJson(startTransactionRes)(StartTransactionResV16Variant, "StartTransactionResponse.json") + validateJson(startTransactionRes)(StartTransactionResV16Variant, "StartTransactionResponse.json") validateJson(stopTransactionReq)(StopTransactionReqV16Variant, "StopTransaction.json") -// validateJson(stopTransactionRes)(StopTransactionResV16Variant, "StopTransactionResponse.json") + validateJson(stopTransactionRes)(StopTransactionResV16Variant, "StopTransactionResponse.json") validateJson(unlockConnectorReq)(UnlockConnectorReqV16Variant, "UnlockConnector.json") validateJson(unlockConnectorRes)(UnlockConnectorResV16Variant, "UnlockConnectorResponse.json") validateJson(resetReq)(ResetReqV16Variant, "Reset.json") diff --git a/ocpp-json/src/test/scala/com/thenewmotion/ocpp/json/v16/SerializationV16Spec.scala b/ocpp-json/src/test/scala/com/thenewmotion/ocpp/json/v16/SerializationV16Spec.scala index e6dfab4..136b70a 100644 --- a/ocpp-json/src/test/scala/com/thenewmotion/ocpp/json/v16/SerializationV16Spec.scala +++ b/ocpp-json/src/test/scala/com/thenewmotion/ocpp/json/v16/SerializationV16Spec.scala @@ -21,9 +21,9 @@ object SerializationV16Spec extends Specification with ScalaCheck { testMessageClass(authorizeReq)(AuthorizeReqV16Variant) testMessageClass(authorizeRes)(AuthorizeResV16Variant) testMessageClass(startTransactionReq)(StartTransactionReqV16Variant) -// testMessageClass(startTransactionRes)(StartTransactionResV16Variant) + testMessageClass(startTransactionRes)(StartTransactionResV16Variant) testMessageClass(stopTransactionReq)(StopTransactionReqV16Variant) -// testMessageClass(stopTransactionRes)(StopTransactionResV16Variant) + testMessageClass(stopTransactionRes)(StopTransactionResV16Variant) testMessageClass(unlockConnectorReq)(UnlockConnectorReqV16Variant) testMessageClass(unlockConnectorRes)(UnlockConnectorResV16Variant) testMessageClass(resetReq)(ResetReqV16Variant) diff --git a/ocpp-json/src/test/scala/com/thenewmotion/ocpp/json/v16/scalacheck/MessageGenerators.scala b/ocpp-json/src/test/scala/com/thenewmotion/ocpp/json/v16/scalacheck/MessageGenerators.scala index 22750ea..9bc3018 100644 --- a/ocpp-json/src/test/scala/com/thenewmotion/ocpp/json/v16/scalacheck/MessageGenerators.scala +++ b/ocpp-json/src/test/scala/com/thenewmotion/ocpp/json/v16/scalacheck/MessageGenerators.scala @@ -2,7 +2,9 @@ package com.thenewmotion.ocpp package json.v16 package scalacheck -import org.scalacheck.Gen, Gen._ +import org.scalacheck.Gen +import Gen._ +import com.thenewmotion.ocpp.json.v16.scalacheck.Helpers.idTagInfoGen object MessageGenerators { @@ -60,7 +62,13 @@ object MessageGenerators { reservationId ) } - def startTransactionRes: Gen[StartTransactionRes] = ??? + def startTransactionRes: Gen[StartTransactionRes] = + for { + transactionId <- transactionIdGen + idTagInfo <- idTagInfoGen + } yield { + StartTransactionRes(transactionId, idTagInfo) + } def stopTransactionReq: Gen[StopTransactionReq] = for { @@ -81,7 +89,14 @@ object MessageGenerators { ) } - def stopTransactionRes: Gen[StopTransactionRes] = ??? + def stopTransactionRes: Gen[StopTransactionRes] = + for { + idTagInfo <- option(idTagInfoGen) + } yield { + StopTransactionRes( + idTagInfo + ) + } def unlockConnectorReq: Gen[UnlockConnectorReq] = connectorIdGen.map(UnlockConnectorReq) From 98e0dbc33dd515019a7813b5ffd070c3b0032189 Mon Sep 17 00:00:00 2001 From: Reinier Lamers Date: Mon, 16 Oct 2017 16:15:29 +0200 Subject: [PATCH 3/3] TNM-4930 depend on Jackson only for test --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 2c7de1c..f882d35 100644 --- a/build.sbt +++ b/build.sbt @@ -5,7 +5,6 @@ val specs2V = "3.9.1" val slf4jV = "1.7.12" val json4sNative = "org.json4s" %% "json4s-native" % json4sV -val json4sjackson = "org.json4s" %% "json4s-jackson" % json4sV val javaWebSocket = "org.java-websocket" % "Java-WebSocket" % "1.3.0" val slf4jApi = "org.slf4j" % "slf4j-api" % slf4jV val slf4jSimpleLogger = "org.slf4j" % "slf4j-simple" % slf4jV @@ -22,6 +21,7 @@ val commonsCodec = "commons-codec" % "commons-codec" % "1.10" val enumUtils = "com.thenewmotion" %% "enum-utils" % "0.2.1" val scalaCheck = "org.scalacheck" %% "scalacheck" % "1.13.4" % "test" val specs2ScalaCheck = "org.specs2" %% "specs2-scalacheck" % specs2V % "test" +val json4sjackson = "org.json4s" %% "json4s-jackson" % json4sV % "test" val jsonSchemaValidator = "com.github.java-json-tools" % "json-schema-validator" % "2.2.8" % "test" def module(name: String) = Project(name, file(name))