diff --git a/.github/workflows/automate-projects.yml b/.github/workflows/automate-projects.yml
index 3c61af07..ec3166d7 100644
--- a/.github/workflows/automate-projects.yml
+++ b/.github/workflows/automate-projects.yml
@@ -14,14 +14,14 @@ jobs:
steps:
- name: add-new-issues-to-organization-based-project-column
if: github.event_name == 'issues' && github.event.action == 'opened'
- uses: alex-page/github-project-automation-plus@v0.8.1
+ uses: alex-page/github-project-automation-plus@v0.8.2
with:
project: CoMPAS Issues Overview Board
column: To do
repo-token: ${{ secrets.ORG_GITHUB_ACTION_SECRET }}
- name: add-new-pull-request-to-organization-based-project-column
if: (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && github.event.action == 'opened'
- uses: alex-page/github-project-automation-plus@v0.8.1
+ uses: alex-page/github-project-automation-plus@v0.8.2
with:
project: CoMPAS Pull Request Overview Board
column: To do
diff --git a/.github/workflows/build-project.yml b/.github/workflows/build-project.yml
index 8bba8114..95370327 100644
--- a/.github/workflows/build-project.yml
+++ b/.github/workflows/build-project.yml
@@ -45,13 +45,13 @@ jobs:
java-version: '17'
- name: Create custom Maven Settings.xml
- uses: whelk-io/maven-settings-xml-action@v20
+ uses: whelk-io/maven-settings-xml-action@v21
with:
output_file: custom_maven_settings.xml
servers: '[{ "id": "github-packages-compas", "username": "OWNER", "password": "${{ secrets.GITHUB_TOKEN }}" }]'
- name: Build with Maven (Pull Request)
if: ${{ github.event_name == 'pull_request' }}
- run: ./mvnw -s custom_maven_settings.xml -B -Pnative-image clean verify
+ run: ./mvnw -s custom_maven_settings.xml -B -Pjvm-image clean verify
- name: Build with Maven (Push)
if: ${{ github.event_name == 'push' }}
run: ./mvnw -s custom_maven_settings.xml -B clean verify
diff --git a/.github/workflows/release-project.yml b/.github/workflows/release-project.yml
index 0ff955af..20a4fd38 100644
--- a/.github/workflows/release-project.yml
+++ b/.github/workflows/release-project.yml
@@ -51,7 +51,7 @@ jobs:
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Create custom Maven Settings.xml
- uses: whelk-io/maven-settings-xml-action@v20
+ uses: whelk-io/maven-settings-xml-action@v21
with:
output_file: custom_maven_settings.xml
servers: '[{ "id": "github-packages-compas", "username": "OWNER", "password": "${{ secrets.GITHUB_TOKEN }}" }]'
@@ -60,6 +60,6 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy with Maven to GitHub Packages and Docker Hub
- run: ./mvnw -B -s custom_maven_settings.xml -Pnative-image,release clean deploy
+ run: ./mvnw -B -s custom_maven_settings.xml -Pjvm-image,release clean deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/sonarcloud-analysis.yml b/.github/workflows/sonarcloud-analysis.yml
index 77fa1f30..13c4eb5d 100644
--- a/.github/workflows/sonarcloud-analysis.yml
+++ b/.github/workflows/sonarcloud-analysis.yml
@@ -56,7 +56,7 @@ jobs:
-Dsonar.projectKey=com-pas_compas-scl-data-service \
-Dsonar.organization=com-pas )"
- name: Create custom Maven Settings.xml
- uses: whelk-io/maven-settings-xml-action@v20
+ uses: whelk-io/maven-settings-xml-action@v21
with:
output_file: custom_maven_settings.xml
servers: '[{ "id": "github-packages-compas", "username": "OWNER", "password": "${{ secrets.GITHUB_TOKEN }}" }]'
diff --git a/app/pom.xml b/app/pom.xml
index 0926733c..5166dab1 100644
--- a/app/pom.xml
+++ b/app/pom.xml
@@ -50,7 +50,11 @@ SPDX-License-Identifier: Apache-2.0
org.lfenergy.compas.core
- jaxrs-commons
+ rest-commons
+
+
+ org.lfenergy.compas.core
+ websocket-commons
@@ -59,16 +63,17 @@ SPDX-License-Identifier: Apache-2.0
io.quarkus
- quarkus-resteasy
+ quarkus-resteasy-reactive
io.quarkus
- quarkus-resteasy-jaxb
+ quarkus-resteasy-reactive-jaxb
io.quarkus
- quarkus-hibernate-validator
+ quarkus-websockets
+
io.quarkus
quarkus-smallrye-jwt
@@ -81,6 +86,11 @@ SPDX-License-Identifier: Apache-2.0
io.quarkus
quarkus-smallrye-health
+
+
+ io.quarkus
+ quarkus-hibernate-validator
+
io.quarkus
quarkus-agroal
diff --git a/app/src/main/docker/Dockerfile-basex.jvm b/app/src/main/docker/Dockerfile-basex.jvm
index 0e014d4f..e64be699 100644
--- a/app/src/main/docker/Dockerfile-basex.jvm
+++ b/app/src/main/docker/Dockerfile-basex.jvm
@@ -21,7 +21,7 @@
# docker run -i --rm -p 8080:8080 -p 5005:5005 -e JAVA_ENABLE_DEBUG="true" quarkus/app-jvm
#
###
-FROM registry.access.redhat.com/ubi8/ubi-minimal:8.6
+FROM registry.access.redhat.com/ubi8/ubi-minimal:8.7
ARG JAVA_PACKAGE=java-17-openjdk-headless
ARG RUN_JAVA_VERSION=1.3.8
diff --git a/app/src/main/docker/Dockerfile-basex.native b/app/src/main/docker/Dockerfile-basex.native
index 51548a10..6f39b21f 100644
--- a/app/src/main/docker/Dockerfile-basex.native
+++ b/app/src/main/docker/Dockerfile-basex.native
@@ -14,7 +14,7 @@
# docker run -i --rm -p 8080:8080 quarkus/app
#
###
-FROM registry.access.redhat.com/ubi8/ubi-minimal:8.6
+FROM registry.access.redhat.com/ubi8/ubi-minimal:8.7
WORKDIR /work/
RUN chown 1001 /work \
&& chmod "g+rwX" /work \
diff --git a/app/src/main/docker/Dockerfile-postgresql.jvm b/app/src/main/docker/Dockerfile-postgresql.jvm
index 2781babf..6f53f4eb 100644
--- a/app/src/main/docker/Dockerfile-postgresql.jvm
+++ b/app/src/main/docker/Dockerfile-postgresql.jvm
@@ -21,7 +21,7 @@
# docker run -i --rm -p 8080:8080 -p 5005:5005 -e JAVA_ENABLE_DEBUG="true" quarkus/app-jvm
#
###
-FROM registry.access.redhat.com/ubi8/ubi-minimal:8.6
+FROM registry.access.redhat.com/ubi8/ubi-minimal:8.7
ARG JAVA_PACKAGE=java-17-openjdk-headless
ARG RUN_JAVA_VERSION=1.3.8
diff --git a/app/src/main/docker/Dockerfile-postgresql.native b/app/src/main/docker/Dockerfile-postgresql.native
index 4853d8c1..89b835e6 100644
--- a/app/src/main/docker/Dockerfile-postgresql.native
+++ b/app/src/main/docker/Dockerfile-postgresql.native
@@ -14,7 +14,7 @@
# docker run -i --rm -p 8080:8080 quarkus/app
#
###
-FROM registry.access.redhat.com/ubi8/ubi-minimal:8.6
+FROM registry.access.redhat.com/ubi8/ubi-minimal:8.7
WORKDIR /work/
RUN chown 1001 /work \
&& chmod "g+rwX" /work \
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/rest/CompasSclDataServiceConfiguration.java b/app/src/main/java/org/lfenergy/compas/scl/data/rest/CompasSclDataServiceConfiguration.java
index 26f426b2..2054f037 100644
--- a/app/src/main/java/org/lfenergy/compas/scl/data/rest/CompasSclDataServiceConfiguration.java
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/rest/CompasSclDataServiceConfiguration.java
@@ -14,8 +14,8 @@
* Create Beans from other dependencies that are used in the application.
*/
@RegisterForReflection(targets = {
- org.lfenergy.compas.core.jaxrs.model.ErrorResponse.class,
- org.lfenergy.compas.core.jaxrs.model.ErrorMessage.class
+ org.lfenergy.compas.core.commons.model.ErrorResponse.class,
+ org.lfenergy.compas.core.commons.model.ErrorMessage.class
})
public class CompasSclDataServiceConfiguration {
@Produces
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/rest/exception/CompasNoDataFoundExceptionHandler.java b/app/src/main/java/org/lfenergy/compas/scl/data/rest/exception/CompasNoDataFoundExceptionHandler.java
index 3b7974e3..efee3683 100644
--- a/app/src/main/java/org/lfenergy/compas/scl/data/rest/exception/CompasNoDataFoundExceptionHandler.java
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/rest/exception/CompasNoDataFoundExceptionHandler.java
@@ -3,7 +3,7 @@
// SPDX-License-Identifier: Apache-2.0
package org.lfenergy.compas.scl.data.rest.exception;
-import org.lfenergy.compas.core.jaxrs.model.ErrorResponse;
+import org.lfenergy.compas.core.commons.model.ErrorResponse;
import org.lfenergy.compas.scl.data.exception.CompasNoDataFoundException;
import javax.ws.rs.core.Response;
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/rest/v1/CompasCommonResource.java b/app/src/main/java/org/lfenergy/compas/scl/data/rest/v1/CompasCommonResource.java
index 79c5d6ef..4bec038e 100644
--- a/app/src/main/java/org/lfenergy/compas/scl/data/rest/v1/CompasCommonResource.java
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/rest/v1/CompasCommonResource.java
@@ -4,6 +4,7 @@
package org.lfenergy.compas.scl.data.rest.v1;
import io.quarkus.security.Authenticated;
+import io.smallrye.mutiny.Uni;
import org.eclipse.microprofile.jwt.JsonWebToken;
import org.lfenergy.compas.scl.data.rest.UserInfoProperties;
import org.lfenergy.compas.scl.data.rest.v1.model.Type;
@@ -40,10 +41,10 @@ public class CompasCommonResource {
@GET
@Path("/type/list")
@Produces(MediaType.APPLICATION_XML)
- public TypeListResponse list(@HeaderParam("Authorization") String authHeader) {
+ public Uni list(@HeaderParam("Authorization") String authHeader) {
LOGGER.trace("Authorization Header '{}'", authHeader);
- // Retrieve the roles the logged in user has.
+ // Retrieve the roles the logged-in user has.
var roles = jsonWebToken.getGroups();
var response = new TypeListResponse();
@@ -54,19 +55,19 @@ public TypeListResponse list(@HeaderParam("Authorization") String authHeader) {
.map(sclFileType -> new Type(sclFileType.name(), sclFileType.getDescription()))
.sorted(Comparator.comparing(Type::getDescription))
.toList());
- return response;
+ return Uni.createFrom().item(response);
}
@GET
@Path("/userinfo")
@Produces(MediaType.APPLICATION_XML)
- public UserInfoResponse getUserInfo(@HeaderParam("Authorization") String authHeader) {
+ public Uni getUserInfo(@HeaderParam("Authorization") String authHeader) {
LOGGER.trace("Authorization Header '{}'", authHeader);
var response = new UserInfoResponse();
response.setName(jsonWebToken.getClaim(userInfoProperties.name()));
response.setSessionWarning(userInfoProperties.sessionWarning());
response.setSessionExpires(userInfoProperties.sessionExpires());
- return response;
+ return Uni.createFrom().item(response);
}
}
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/rest/v1/CompasSclDataResource.java b/app/src/main/java/org/lfenergy/compas/scl/data/rest/v1/CompasSclDataResource.java
index 1cf3c31e..4d13bbc1 100644
--- a/app/src/main/java/org/lfenergy/compas/scl/data/rest/v1/CompasSclDataResource.java
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/rest/v1/CompasSclDataResource.java
@@ -4,6 +4,8 @@
package org.lfenergy.compas.scl.data.rest.v1;
import io.quarkus.security.Authenticated;
+import io.smallrye.common.annotation.Blocking;
+import io.smallrye.mutiny.Uni;
import org.eclipse.microprofile.jwt.JsonWebToken;
import org.lfenergy.compas.scl.data.model.Version;
import org.lfenergy.compas.scl.data.rest.UserInfoProperties;
@@ -42,89 +44,95 @@ public CompasSclDataResource(CompasSclDataService compasSclDataService) {
}
@POST
+ @Blocking
@Consumes(MediaType.APPLICATION_XML)
@Produces(MediaType.APPLICATION_XML)
- public CreateResponse create(@PathParam(TYPE_PATH_PARAM) SclFileType type,
- @Valid CreateRequest request) {
+ public Uni create(@PathParam(TYPE_PATH_PARAM) SclFileType type,
+ @Valid CreateRequest request) {
String who = jsonWebToken.getClaim(userInfoProperties.who());
LOGGER.trace("Username used for Who {}", who);
var response = new CreateResponse();
response.setSclData(compasSclDataService.create(type, request.getName(), who, request.getComment(),
request.getSclData()));
- return response;
+ return Uni.createFrom().item(response);
}
@GET
@Path("/list")
@Produces(MediaType.APPLICATION_XML)
- public ListResponse list(@PathParam(TYPE_PATH_PARAM) SclFileType type) {
+ public Uni list(@PathParam(TYPE_PATH_PARAM) SclFileType type) {
var response = new ListResponse();
response.setItems(compasSclDataService.list(type));
- return response;
+ return Uni.createFrom().item(response);
}
@GET
@Path("/{" + ID_PATH_PARAM + "}/versions")
@Produces(MediaType.APPLICATION_XML)
- public VersionsResponse listVersionsByUUID(@PathParam(TYPE_PATH_PARAM) SclFileType type,
- @PathParam(ID_PATH_PARAM) UUID id) {
+ public Uni listVersionsByUUID(@PathParam(TYPE_PATH_PARAM) SclFileType type,
+ @PathParam(ID_PATH_PARAM) UUID id) {
var response = new VersionsResponse();
response.setItems(compasSclDataService.listVersionsByUUID(type, id));
- return response;
+ return Uni.createFrom().item(response);
}
@GET
@Path("/{" + ID_PATH_PARAM + "}")
@Produces(MediaType.APPLICATION_XML)
- public GetResponse findByUUID(@PathParam(TYPE_PATH_PARAM) SclFileType type,
- @PathParam(ID_PATH_PARAM) UUID id) {
+ public Uni findByUUID(@PathParam(TYPE_PATH_PARAM) SclFileType type,
+ @PathParam(ID_PATH_PARAM) UUID id) {
var response = new GetResponse();
response.setSclData(compasSclDataService.findByUUID(type, id));
- return response;
+ return Uni.createFrom().item(response);
}
@GET
@Path("/{" + ID_PATH_PARAM + "}/{" + VERSION_PATH_PARAM + "}")
@Produces(MediaType.APPLICATION_XML)
- public GetResponse findByUUIDAndVersion(@PathParam(TYPE_PATH_PARAM) SclFileType type,
- @PathParam(ID_PATH_PARAM) UUID id,
- @PathParam(VERSION_PATH_PARAM) Version version) {
+ public Uni findByUUIDAndVersion(@PathParam(TYPE_PATH_PARAM) SclFileType type,
+ @PathParam(ID_PATH_PARAM) UUID id,
+ @PathParam(VERSION_PATH_PARAM) Version version) {
var response = new GetResponse();
response.setSclData(compasSclDataService.findByUUID(type, id, version));
- return response;
+ return Uni.createFrom().item(response);
}
@PUT
+ @Blocking
@Path("/{" + ID_PATH_PARAM + "}")
@Consumes(MediaType.APPLICATION_XML)
@Produces(MediaType.APPLICATION_XML)
- public UpdateResponse update(@PathParam(TYPE_PATH_PARAM) SclFileType type,
- @PathParam(ID_PATH_PARAM) UUID id,
- @Valid UpdateRequest request) {
+ public Uni update(@PathParam(TYPE_PATH_PARAM) SclFileType type,
+ @PathParam(ID_PATH_PARAM) UUID id,
+ @Valid UpdateRequest request) {
String who = jsonWebToken.getClaim(userInfoProperties.who());
LOGGER.trace("Username used for Who {}", who);
var response = new UpdateResponse();
response.setSclData(compasSclDataService.update(type, id, request.getChangeSetType(), who, request.getComment(),
request.getSclData()));
- return response;
+ return Uni.createFrom().item(response);
}
@DELETE
+ @Blocking
@Path("/{" + ID_PATH_PARAM + "}")
@Produces(MediaType.APPLICATION_XML)
- public void deleteAll(@PathParam(TYPE_PATH_PARAM) SclFileType type,
- @PathParam(ID_PATH_PARAM) UUID id) {
+ public Uni deleteAll(@PathParam(TYPE_PATH_PARAM) SclFileType type,
+ @PathParam(ID_PATH_PARAM) UUID id) {
compasSclDataService.delete(type, id);
+ return Uni.createFrom().nullItem();
}
@DELETE
+ @Blocking
@Path("/{" + ID_PATH_PARAM + "}/{" + VERSION_PATH_PARAM + "}")
@Produces(MediaType.APPLICATION_XML)
- public void deleteVersion(@PathParam(TYPE_PATH_PARAM) SclFileType type,
- @PathParam(ID_PATH_PARAM) UUID id,
- @PathParam(VERSION_PATH_PARAM) Version version) {
+ public Uni deleteVersion(@PathParam(TYPE_PATH_PARAM) SclFileType type,
+ @PathParam(ID_PATH_PARAM) UUID id,
+ @PathParam(VERSION_PATH_PARAM) Version version) {
compasSclDataService.delete(type, id, version);
+ return Uni.createFrom().nullItem();
}
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/rest/v1/model/CreateRequest.java b/app/src/main/java/org/lfenergy/compas/scl/data/rest/v1/model/CreateRequest.java
index 7b7889cb..117b35d5 100644
--- a/app/src/main/java/org/lfenergy/compas/scl/data/rest/v1/model/CreateRequest.java
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/rest/v1/model/CreateRequest.java
@@ -7,6 +7,7 @@
import org.eclipse.microprofile.openapi.annotations.media.Schema;
import org.lfenergy.compas.core.commons.constraint.FilenameValid;
+import javax.validation.constraints.NotBlank;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
@@ -30,6 +31,7 @@ public class CreateRequest {
@Schema(description = "The XML Content of the SCL added as CDATA. The content should contain a XML according to the IEC 61850 standard.",
example = "....]]")
+ @NotBlank
@XmlElement(name = "SclData", namespace = SCL_DATA_SERVICE_V1_NS_URI)
private String sclData;
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/rest/v1/model/UpdateRequest.java b/app/src/main/java/org/lfenergy/compas/scl/data/rest/v1/model/UpdateRequest.java
index c34016ee..f64bc37c 100644
--- a/app/src/main/java/org/lfenergy/compas/scl/data/rest/v1/model/UpdateRequest.java
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/rest/v1/model/UpdateRequest.java
@@ -7,6 +7,7 @@
import org.eclipse.microprofile.openapi.annotations.media.Schema;
import org.lfenergy.compas.scl.data.model.ChangeSetType;
+import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
@@ -32,6 +33,7 @@ public class UpdateRequest {
@Schema(description = "The XML Content of the SCL added as CDATA. The content should contain a XML according to the IEC 61850 standard.",
example = "....]]")
+ @NotBlank
@XmlElement(name = "SclData", namespace = SCL_DATA_SERVICE_V1_NS_URI)
private String sclData;
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/websocket/event/CompasSclDataEventHandler.java b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/event/CompasSclDataEventHandler.java
new file mode 100644
index 00000000..2528e203
--- /dev/null
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/event/CompasSclDataEventHandler.java
@@ -0,0 +1,69 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.event;
+
+import io.quarkus.vertx.ConsumeEvent;
+import org.lfenergy.compas.core.websocket.WebsocketHandler;
+import org.lfenergy.compas.scl.data.service.CompasSclDataService;
+import org.lfenergy.compas.scl.data.websocket.event.model.CreateEventRequest;
+import org.lfenergy.compas.scl.data.websocket.event.model.GetEventRequest;
+import org.lfenergy.compas.scl.data.websocket.event.model.GetVersionEventRequest;
+import org.lfenergy.compas.scl.data.websocket.event.model.UpdateEventRequest;
+import org.lfenergy.compas.scl.data.websocket.v1.model.CreateWsResponse;
+import org.lfenergy.compas.scl.data.websocket.v1.model.GetWsResponse;
+import org.lfenergy.compas.scl.data.websocket.v1.model.UpdateWsResponse;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+
+/**
+ * Event Handler used to execute the validation asynchronized.
+ */
+@ApplicationScoped
+public class CompasSclDataEventHandler {
+ private final CompasSclDataService compasSclDataService;
+
+ @Inject
+ public CompasSclDataEventHandler(CompasSclDataService compasSclDataService) {
+ this.compasSclDataService = compasSclDataService;
+ }
+
+ @ConsumeEvent(value = "create-ws", blocking = true)
+ public void createWebsocketsEvent(CreateEventRequest request) {
+ new WebsocketHandler().execute(request.getSession(), () -> {
+ var response = new CreateWsResponse();
+ response.setSclData(compasSclDataService.create(request.getType(), request.getName(), request.getWho(),
+ request.getComment(), request.getSclData()));
+ return response;
+ });
+ }
+
+ @ConsumeEvent(value = "get-ws")
+ public void getWebsocketsEvent(GetEventRequest request) {
+ new WebsocketHandler().execute(request.getSession(), () -> {
+ var response = new GetWsResponse();
+ response.setSclData(compasSclDataService.findByUUID(request.getType(), request.getId()));
+ return response;
+ });
+ }
+
+ @ConsumeEvent(value = "get-version-ws")
+ public void getVersionWebsocketsEvent(GetVersionEventRequest request) {
+ new WebsocketHandler().execute(request.getSession(), () -> {
+ var response = new GetWsResponse();
+ response.setSclData(compasSclDataService.findByUUID(request.getType(), request.getId(), request.getVersion()));
+ return response;
+ });
+ }
+
+ @ConsumeEvent(value = "update-ws", blocking = true)
+ public void updateWebsocketsEvent(UpdateEventRequest request) {
+ new WebsocketHandler().execute(request.getSession(), () -> {
+ var response = new UpdateWsResponse();
+ response.setSclData(compasSclDataService.update(request.getType(), request.getId(), request.getChangeSetType(),
+ request.getWho(), request.getComment(), request.getSclData()));
+ return response;
+ });
+ }
+}
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/websocket/event/model/CreateEventRequest.java b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/event/model/CreateEventRequest.java
new file mode 100644
index 00000000..2582a2ee
--- /dev/null
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/event/model/CreateEventRequest.java
@@ -0,0 +1,50 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.event.model;
+
+import org.lfenergy.compas.scl.extensions.model.SclFileType;
+
+import javax.websocket.Session;
+
+public class CreateEventRequest {
+ private final Session session;
+ private final SclFileType type;
+ private final String name;
+ private final String who;
+ private final String comment;
+ private final String sclData;
+
+ public CreateEventRequest(Session session, SclFileType type, String name, String who, String comment, String sclData) {
+ this.session = session;
+ this.type = type;
+ this.name = name;
+ this.who = who;
+ this.comment = comment;
+ this.sclData = sclData;
+ }
+
+ public Session getSession() {
+ return session;
+ }
+
+ public SclFileType getType() {
+ return type;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getWho() {
+ return who;
+ }
+
+ public String getComment() {
+ return comment;
+ }
+
+ public String getSclData() {
+ return sclData;
+ }
+}
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/websocket/event/model/GetEventRequest.java b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/event/model/GetEventRequest.java
new file mode 100644
index 00000000..ea3d4e8b
--- /dev/null
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/event/model/GetEventRequest.java
@@ -0,0 +1,33 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.event.model;
+
+import org.lfenergy.compas.scl.extensions.model.SclFileType;
+
+import javax.websocket.Session;
+import java.util.UUID;
+
+public class GetEventRequest {
+ private final Session session;
+ private final SclFileType type;
+ private final UUID id;
+
+ public GetEventRequest(Session session, SclFileType type, UUID id) {
+ this.session = session;
+ this.type = type;
+ this.id = id;
+ }
+
+ public Session getSession() {
+ return session;
+ }
+
+ public SclFileType getType() {
+ return type;
+ }
+
+ public UUID getId() {
+ return id;
+ }
+}
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/websocket/event/model/GetVersionEventRequest.java b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/event/model/GetVersionEventRequest.java
new file mode 100644
index 00000000..1675f37a
--- /dev/null
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/event/model/GetVersionEventRequest.java
@@ -0,0 +1,40 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.event.model;
+
+import org.lfenergy.compas.scl.data.model.Version;
+import org.lfenergy.compas.scl.extensions.model.SclFileType;
+
+import javax.websocket.Session;
+import java.util.UUID;
+
+public class GetVersionEventRequest {
+ private final Session session;
+ private final SclFileType type;
+ private final UUID id;
+ private final Version version;
+
+ public GetVersionEventRequest(Session session, SclFileType type, UUID id, Version version) {
+ this.session = session;
+ this.type = type;
+ this.id = id;
+ this.version = version;
+ }
+
+ public Session getSession() {
+ return session;
+ }
+
+ public SclFileType getType() {
+ return type;
+ }
+
+ public UUID getId() {
+ return id;
+ }
+
+ public Version getVersion() {
+ return version;
+ }
+}
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/websocket/event/model/UpdateEventRequest.java b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/event/model/UpdateEventRequest.java
new file mode 100644
index 00000000..7442950a
--- /dev/null
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/event/model/UpdateEventRequest.java
@@ -0,0 +1,58 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.event.model;
+
+import org.lfenergy.compas.scl.data.model.ChangeSetType;
+import org.lfenergy.compas.scl.extensions.model.SclFileType;
+
+import javax.websocket.Session;
+import java.util.UUID;
+
+public class UpdateEventRequest {
+ private final Session session;
+ private final SclFileType type;
+ private final UUID id;
+ private final ChangeSetType changeSetType;
+ private final String who;
+ private final String comment;
+ private final String sclData;
+
+ public UpdateEventRequest(Session session, SclFileType type, UUID id, ChangeSetType changeSetType, String who, String comment, String sclData) {
+ this.session = session;
+ this.type = type;
+ this.id = id;
+ this.changeSetType = changeSetType;
+ this.who = who;
+ this.comment = comment;
+ this.sclData = sclData;
+ }
+
+ public Session getSession() {
+ return session;
+ }
+
+ public SclFileType getType() {
+ return type;
+ }
+
+ public UUID getId() {
+ return id;
+ }
+
+ public ChangeSetType getChangeSetType() {
+ return changeSetType;
+ }
+
+ public String getWho() {
+ return who;
+ }
+
+ public String getComment() {
+ return comment;
+ }
+
+ public String getSclData() {
+ return sclData;
+ }
+}
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclCreateServerEndpoint.java b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclCreateServerEndpoint.java
new file mode 100644
index 00000000..3f520550
--- /dev/null
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclCreateServerEndpoint.java
@@ -0,0 +1,75 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1;
+
+import io.quarkus.security.Authenticated;
+import io.vertx.mutiny.core.eventbus.EventBus;
+import org.eclipse.microprofile.jwt.JsonWebToken;
+import org.lfenergy.compas.core.websocket.ErrorResponseEncoder;
+import org.lfenergy.compas.scl.data.rest.UserInfoProperties;
+import org.lfenergy.compas.scl.data.websocket.event.model.CreateEventRequest;
+import org.lfenergy.compas.scl.data.websocket.v1.decoder.CreateWsRequestDecoder;
+import org.lfenergy.compas.scl.data.websocket.v1.encoder.CreateWsResponseEncoder;
+import org.lfenergy.compas.scl.data.websocket.v1.model.CreateWsRequest;
+import org.lfenergy.compas.scl.extensions.model.SclFileType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.websocket.*;
+import javax.websocket.server.PathParam;
+import javax.websocket.server.ServerEndpoint;
+
+import static org.lfenergy.compas.core.websocket.WebsocketSupport.handleException;
+import static org.lfenergy.compas.scl.data.rest.Constants.TYPE_PATH_PARAM;
+
+@Authenticated
+@ApplicationScoped
+@ServerEndpoint(value = "/scl-ws/v1/{" + TYPE_PATH_PARAM + "}/create",
+ decoders = {CreateWsRequestDecoder.class},
+ encoders = {CreateWsResponseEncoder.class, ErrorResponseEncoder.class})
+public class CompasSclCreateServerEndpoint {
+ private static final Logger LOGGER = LoggerFactory.getLogger(CompasSclCreateServerEndpoint.class);
+
+ private final EventBus eventBus;
+ private final JsonWebToken jsonWebToken;
+ private final UserInfoProperties userInfoProperties;
+
+ @Inject
+ public CompasSclCreateServerEndpoint(EventBus eventBus,
+ JsonWebToken jsonWebToken,
+ UserInfoProperties userInfoProperties) {
+ this.eventBus = eventBus;
+ this.jsonWebToken = jsonWebToken;
+ this.userInfoProperties = userInfoProperties;
+ }
+
+ @OnOpen
+ public void onOpen(Session session, @PathParam(TYPE_PATH_PARAM) String type) {
+ LOGGER.debug("Starting (create) session {} for type {}.", session.getId(), type);
+ }
+
+ @OnMessage
+ public void onCreateMessage(Session session, CreateWsRequest request, @PathParam(TYPE_PATH_PARAM) String type) {
+ LOGGER.info("Message (create) from session {} for type {}.", session.getId(), type);
+
+ String who = jsonWebToken.getClaim(userInfoProperties.who());
+ LOGGER.trace("Username used for Who {}", who);
+
+ eventBus.send("create-ws", new CreateEventRequest(
+ session, SclFileType.valueOf(type), request.getName(), who, request.getComment(), request.getSclData()));
+ }
+
+ @OnError
+ public void onError(Session session, @PathParam(TYPE_PATH_PARAM) String type, Throwable throwable) {
+ LOGGER.warn("Error (create) with session {} for type {}.", session.getId(), type, throwable);
+ handleException(session, throwable);
+ }
+
+ @OnClose
+ public void onClose(Session session, @PathParam(TYPE_PATH_PARAM) String type) {
+ LOGGER.debug("Closing (create) session {} for type {}.", session.getId(), type);
+ }
+}
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclGetServerEndpoint.java b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclGetServerEndpoint.java
new file mode 100644
index 00000000..1f5fa11a
--- /dev/null
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclGetServerEndpoint.java
@@ -0,0 +1,65 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1;
+
+import io.quarkus.security.Authenticated;
+import io.vertx.mutiny.core.eventbus.EventBus;
+import org.lfenergy.compas.core.websocket.ErrorResponseEncoder;
+import org.lfenergy.compas.scl.data.websocket.event.model.GetEventRequest;
+import org.lfenergy.compas.scl.data.websocket.v1.decoder.GetWsRequestDecoder;
+import org.lfenergy.compas.scl.data.websocket.v1.encoder.GetWsResponseEncoder;
+import org.lfenergy.compas.scl.data.websocket.v1.model.GetWsRequest;
+import org.lfenergy.compas.scl.extensions.model.SclFileType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.websocket.*;
+import javax.websocket.server.PathParam;
+import javax.websocket.server.ServerEndpoint;
+
+import static org.lfenergy.compas.core.websocket.WebsocketSupport.handleException;
+import static org.lfenergy.compas.scl.data.rest.Constants.TYPE_PATH_PARAM;
+
+@Authenticated
+@ApplicationScoped
+@ServerEndpoint(value = "/scl-ws/v1/{" + TYPE_PATH_PARAM + "}/get",
+ decoders = {GetWsRequestDecoder.class},
+ encoders = {GetWsResponseEncoder.class, ErrorResponseEncoder.class})
+public class CompasSclGetServerEndpoint {
+ private static final Logger LOGGER = LoggerFactory.getLogger(CompasSclGetServerEndpoint.class);
+
+ private final EventBus eventBus;
+
+ @Inject
+ public CompasSclGetServerEndpoint(EventBus eventBus) {
+ this.eventBus = eventBus;
+ }
+
+ @OnOpen
+ public void onOpen(Session session, @PathParam(TYPE_PATH_PARAM) String type) {
+ LOGGER.debug("Starting (get) session {} for type {}.", session.getId(), type);
+ }
+
+ @OnMessage
+ public void onGetMessage(Session session,
+ GetWsRequest request,
+ @PathParam(TYPE_PATH_PARAM) String type) {
+ LOGGER.info("Message (get) from session {} for type {}.", session.getId(), type);
+
+ eventBus.send("get-ws", new GetEventRequest(session, SclFileType.valueOf(type), request.getId()));
+ }
+
+ @OnError
+ public void onError(Session session, @PathParam(TYPE_PATH_PARAM) String type, Throwable throwable) {
+ LOGGER.warn("Error (get) with session {} for type {}.", session.getId(), type, throwable);
+ handleException(session, throwable);
+ }
+
+ @OnClose
+ public void onClose(Session session, @PathParam(TYPE_PATH_PARAM) String type) {
+ LOGGER.debug("Closing (get) session {} for type {}.", session.getId(), type);
+ }
+}
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclGetVersionServerEndpoint.java b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclGetVersionServerEndpoint.java
new file mode 100644
index 00000000..7d7b361a
--- /dev/null
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclGetVersionServerEndpoint.java
@@ -0,0 +1,67 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1;
+
+import io.quarkus.security.Authenticated;
+import io.vertx.mutiny.core.eventbus.EventBus;
+import org.lfenergy.compas.core.websocket.ErrorResponseEncoder;
+import org.lfenergy.compas.scl.data.model.Version;
+import org.lfenergy.compas.scl.data.websocket.event.model.GetVersionEventRequest;
+import org.lfenergy.compas.scl.data.websocket.v1.decoder.GetVersionWsRequestDecoder;
+import org.lfenergy.compas.scl.data.websocket.v1.encoder.GetWsResponseEncoder;
+import org.lfenergy.compas.scl.data.websocket.v1.model.GetVersionWsRequest;
+import org.lfenergy.compas.scl.extensions.model.SclFileType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.websocket.*;
+import javax.websocket.server.PathParam;
+import javax.websocket.server.ServerEndpoint;
+
+import static org.lfenergy.compas.core.websocket.WebsocketSupport.handleException;
+import static org.lfenergy.compas.scl.data.rest.Constants.TYPE_PATH_PARAM;
+
+@Authenticated
+@ApplicationScoped
+@ServerEndpoint(value = "/scl-ws/v1/{" + TYPE_PATH_PARAM + "}/get-version",
+ decoders = {GetVersionWsRequestDecoder.class},
+ encoders = {GetWsResponseEncoder.class, ErrorResponseEncoder.class})
+public class CompasSclGetVersionServerEndpoint {
+ private static final Logger LOGGER = LoggerFactory.getLogger(CompasSclGetVersionServerEndpoint.class);
+
+ private final EventBus eventBus;
+
+ @Inject
+ public CompasSclGetVersionServerEndpoint(EventBus eventBus) {
+ this.eventBus = eventBus;
+ }
+
+ @OnOpen
+ public void onOpen(Session session, @PathParam(TYPE_PATH_PARAM) String type) {
+ LOGGER.debug("Starting session {} for type {}.", session.getId(), type);
+ }
+
+ @OnMessage
+ public void onGetVersionMessage(Session session,
+ GetVersionWsRequest request,
+ @PathParam(TYPE_PATH_PARAM) String type) {
+ LOGGER.info("Message from session {} for type {}.", session.getId(), type);
+
+ eventBus.send("get-version-ws", new GetVersionEventRequest(session, SclFileType.valueOf(type),
+ request.getId(), new Version(request.getVersion())));
+ }
+
+ @OnError
+ public void onError(Session session, @PathParam(TYPE_PATH_PARAM) String type, Throwable throwable) {
+ LOGGER.warn("Error with session {} for type {}.", session.getId(), type, throwable);
+ handleException(session, throwable);
+ }
+
+ @OnClose
+ public void onClose(Session session, @PathParam(TYPE_PATH_PARAM) String type) {
+ LOGGER.debug("Closing session {} for type {}.", session.getId(), type);
+ }
+}
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclUpdateServerEndpoint.java b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclUpdateServerEndpoint.java
new file mode 100644
index 00000000..d0db47bc
--- /dev/null
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclUpdateServerEndpoint.java
@@ -0,0 +1,77 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1;
+
+import io.quarkus.security.Authenticated;
+import io.vertx.mutiny.core.eventbus.EventBus;
+import org.eclipse.microprofile.jwt.JsonWebToken;
+import org.lfenergy.compas.core.websocket.ErrorResponseEncoder;
+import org.lfenergy.compas.scl.data.rest.UserInfoProperties;
+import org.lfenergy.compas.scl.data.websocket.event.model.UpdateEventRequest;
+import org.lfenergy.compas.scl.data.websocket.v1.decoder.UpdateWsRequestDecoder;
+import org.lfenergy.compas.scl.data.websocket.v1.encoder.UpdateWsResponseEncoder;
+import org.lfenergy.compas.scl.data.websocket.v1.model.UpdateWsRequest;
+import org.lfenergy.compas.scl.extensions.model.SclFileType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.websocket.*;
+import javax.websocket.server.PathParam;
+import javax.websocket.server.ServerEndpoint;
+
+import static org.lfenergy.compas.core.websocket.WebsocketSupport.handleException;
+import static org.lfenergy.compas.scl.data.rest.Constants.TYPE_PATH_PARAM;
+
+@Authenticated
+@ApplicationScoped
+@ServerEndpoint(value = "/scl-ws/v1/{" + TYPE_PATH_PARAM + "}/update",
+ decoders = {UpdateWsRequestDecoder.class},
+ encoders = {UpdateWsResponseEncoder.class, ErrorResponseEncoder.class})
+public class CompasSclUpdateServerEndpoint {
+ private static final Logger LOGGER = LoggerFactory.getLogger(CompasSclUpdateServerEndpoint.class);
+
+ private final EventBus eventBus;
+ private final JsonWebToken jsonWebToken;
+ private final UserInfoProperties userInfoProperties;
+
+ @Inject
+ public CompasSclUpdateServerEndpoint(EventBus eventBus,
+ JsonWebToken jsonWebToken,
+ UserInfoProperties userInfoProperties) {
+ this.eventBus = eventBus;
+ this.jsonWebToken = jsonWebToken;
+ this.userInfoProperties = userInfoProperties;
+ }
+
+ @OnOpen
+ public void onOpen(Session session, @PathParam(TYPE_PATH_PARAM) String type) {
+ LOGGER.debug("Starting (update) session {} for type {}.", session.getId(), type);
+ }
+
+ @OnMessage
+ public void onUpdateMessage(Session session, UpdateWsRequest request,
+ @PathParam(TYPE_PATH_PARAM) String type) {
+ LOGGER.info("Message (update) from session {} for type {}.", session.getId(), type);
+
+ String who = jsonWebToken.getClaim(userInfoProperties.who());
+ LOGGER.trace("Username used for Who {}", who);
+
+ eventBus.send("update-ws", new UpdateEventRequest(
+ session, SclFileType.valueOf(type), request.getId(), request.getChangeSetType(),
+ who, request.getComment(), request.getSclData()));
+ }
+
+ @OnError
+ public void onError(Session session, @PathParam(TYPE_PATH_PARAM) String type, Throwable throwable) {
+ LOGGER.warn("Error (update) with session {} for type {}.", session.getId(), type, throwable);
+ handleException(session, throwable);
+ }
+
+ @OnClose
+ public void onClose(Session session, @PathParam(TYPE_PATH_PARAM) String type) {
+ LOGGER.debug("Closing (update) session {} for type {}.", session.getId(), type);
+ }
+}
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/CreateWsRequestDecoder.java b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/CreateWsRequestDecoder.java
new file mode 100644
index 00000000..c0af36cb
--- /dev/null
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/CreateWsRequestDecoder.java
@@ -0,0 +1,20 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.decoder;
+
+import org.lfenergy.compas.core.websocket.AbstractDecoder;
+import org.lfenergy.compas.core.websocket.WebsocketSupport;
+import org.lfenergy.compas.scl.data.websocket.v1.model.CreateWsRequest;
+
+public class CreateWsRequestDecoder extends AbstractDecoder {
+ @Override
+ public boolean willDecode(String message) {
+ return (message != null);
+ }
+
+ @Override
+ public CreateWsRequest decode(String message) {
+ return WebsocketSupport.decode(message, CreateWsRequest.class);
+ }
+}
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/CreateWsResponseDecoder.java b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/CreateWsResponseDecoder.java
new file mode 100644
index 00000000..980a85d9
--- /dev/null
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/CreateWsResponseDecoder.java
@@ -0,0 +1,20 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.decoder;
+
+import org.lfenergy.compas.core.websocket.AbstractDecoder;
+import org.lfenergy.compas.core.websocket.WebsocketSupport;
+import org.lfenergy.compas.scl.data.websocket.v1.model.CreateWsResponse;
+
+public class CreateWsResponseDecoder extends AbstractDecoder {
+ @Override
+ public boolean willDecode(String message) {
+ return (message != null);
+ }
+
+ @Override
+ public CreateWsResponse decode(String message) {
+ return WebsocketSupport.decode(message, CreateWsResponse.class);
+ }
+}
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/GetVersionWsRequestDecoder.java b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/GetVersionWsRequestDecoder.java
new file mode 100644
index 00000000..91359c57
--- /dev/null
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/GetVersionWsRequestDecoder.java
@@ -0,0 +1,20 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.decoder;
+
+import org.lfenergy.compas.core.websocket.AbstractDecoder;
+import org.lfenergy.compas.core.websocket.WebsocketSupport;
+import org.lfenergy.compas.scl.data.websocket.v1.model.GetVersionWsRequest;
+
+public class GetVersionWsRequestDecoder extends AbstractDecoder {
+ @Override
+ public boolean willDecode(String message) {
+ return (message != null);
+ }
+
+ @Override
+ public GetVersionWsRequest decode(String message) {
+ return WebsocketSupport.decode(message, GetVersionWsRequest.class);
+ }
+}
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/GetWsRequestDecoder.java b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/GetWsRequestDecoder.java
new file mode 100644
index 00000000..6972d5ec
--- /dev/null
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/GetWsRequestDecoder.java
@@ -0,0 +1,20 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.decoder;
+
+import org.lfenergy.compas.core.websocket.AbstractDecoder;
+import org.lfenergy.compas.core.websocket.WebsocketSupport;
+import org.lfenergy.compas.scl.data.websocket.v1.model.GetWsRequest;
+
+public class GetWsRequestDecoder extends AbstractDecoder {
+ @Override
+ public boolean willDecode(String message) {
+ return (message != null);
+ }
+
+ @Override
+ public GetWsRequest decode(String message) {
+ return WebsocketSupport.decode(message, GetWsRequest.class);
+ }
+}
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/GetWsResponseDecoder.java b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/GetWsResponseDecoder.java
new file mode 100644
index 00000000..b591ace2
--- /dev/null
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/GetWsResponseDecoder.java
@@ -0,0 +1,20 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.decoder;
+
+import org.lfenergy.compas.core.websocket.AbstractDecoder;
+import org.lfenergy.compas.core.websocket.WebsocketSupport;
+import org.lfenergy.compas.scl.data.websocket.v1.model.GetWsResponse;
+
+public class GetWsResponseDecoder extends AbstractDecoder {
+ @Override
+ public boolean willDecode(String message) {
+ return (message != null);
+ }
+
+ @Override
+ public GetWsResponse decode(String message) {
+ return WebsocketSupport.decode(message, GetWsResponse.class);
+ }
+}
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/UpdateWsRequestDecoder.java b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/UpdateWsRequestDecoder.java
new file mode 100644
index 00000000..1a922e85
--- /dev/null
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/UpdateWsRequestDecoder.java
@@ -0,0 +1,20 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.decoder;
+
+import org.lfenergy.compas.core.websocket.AbstractDecoder;
+import org.lfenergy.compas.core.websocket.WebsocketSupport;
+import org.lfenergy.compas.scl.data.websocket.v1.model.UpdateWsRequest;
+
+public class UpdateWsRequestDecoder extends AbstractDecoder {
+ @Override
+ public boolean willDecode(String message) {
+ return (message != null);
+ }
+
+ @Override
+ public UpdateWsRequest decode(String message) {
+ return WebsocketSupport.decode(message, UpdateWsRequest.class);
+ }
+}
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/UpdateWsResponseDecoder.java b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/UpdateWsResponseDecoder.java
new file mode 100644
index 00000000..32f2b754
--- /dev/null
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/UpdateWsResponseDecoder.java
@@ -0,0 +1,20 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.decoder;
+
+import org.lfenergy.compas.core.websocket.AbstractDecoder;
+import org.lfenergy.compas.core.websocket.WebsocketSupport;
+import org.lfenergy.compas.scl.data.websocket.v1.model.UpdateWsResponse;
+
+public class UpdateWsResponseDecoder extends AbstractDecoder {
+ @Override
+ public boolean willDecode(String message) {
+ return (message != null);
+ }
+
+ @Override
+ public UpdateWsResponse decode(String message) {
+ return WebsocketSupport.decode(message, UpdateWsResponse.class);
+ }
+}
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/CreateWsRequestEncoder.java b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/CreateWsRequestEncoder.java
new file mode 100644
index 00000000..ba68c56a
--- /dev/null
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/CreateWsRequestEncoder.java
@@ -0,0 +1,15 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.encoder;
+
+import org.lfenergy.compas.core.websocket.AbstractEncoder;
+import org.lfenergy.compas.core.websocket.WebsocketSupport;
+import org.lfenergy.compas.scl.data.websocket.v1.model.CreateWsRequest;
+
+public class CreateWsRequestEncoder extends AbstractEncoder {
+ @Override
+ public String encode(CreateWsRequest jaxbObject) {
+ return WebsocketSupport.encode(jaxbObject, CreateWsRequest.class);
+ }
+}
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/CreateWsResponseEncoder.java b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/CreateWsResponseEncoder.java
new file mode 100644
index 00000000..ed87efde
--- /dev/null
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/CreateWsResponseEncoder.java
@@ -0,0 +1,15 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.encoder;
+
+import org.lfenergy.compas.core.websocket.AbstractEncoder;
+import org.lfenergy.compas.core.websocket.WebsocketSupport;
+import org.lfenergy.compas.scl.data.websocket.v1.model.CreateWsResponse;
+
+public class CreateWsResponseEncoder extends AbstractEncoder {
+ @Override
+ public String encode(CreateWsResponse jaxbObject) {
+ return WebsocketSupport.encode(jaxbObject, CreateWsResponse.class);
+ }
+}
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/GetVersionWsRequestEncoder.java b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/GetVersionWsRequestEncoder.java
new file mode 100644
index 00000000..22809767
--- /dev/null
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/GetVersionWsRequestEncoder.java
@@ -0,0 +1,15 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.encoder;
+
+import org.lfenergy.compas.core.websocket.AbstractEncoder;
+import org.lfenergy.compas.core.websocket.WebsocketSupport;
+import org.lfenergy.compas.scl.data.websocket.v1.model.GetVersionWsRequest;
+
+public class GetVersionWsRequestEncoder extends AbstractEncoder {
+ @Override
+ public String encode(GetVersionWsRequest jaxbObject) {
+ return WebsocketSupport.encode(jaxbObject, GetVersionWsRequest.class);
+ }
+}
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/GetWsRequestEncoder.java b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/GetWsRequestEncoder.java
new file mode 100644
index 00000000..80bf74ef
--- /dev/null
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/GetWsRequestEncoder.java
@@ -0,0 +1,15 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.encoder;
+
+import org.lfenergy.compas.core.websocket.AbstractEncoder;
+import org.lfenergy.compas.core.websocket.WebsocketSupport;
+import org.lfenergy.compas.scl.data.websocket.v1.model.GetWsRequest;
+
+public class GetWsRequestEncoder extends AbstractEncoder {
+ @Override
+ public String encode(GetWsRequest jaxbObject) {
+ return WebsocketSupport.encode(jaxbObject, GetWsRequest.class);
+ }
+}
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/GetWsResponseEncoder.java b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/GetWsResponseEncoder.java
new file mode 100644
index 00000000..2803cf5d
--- /dev/null
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/GetWsResponseEncoder.java
@@ -0,0 +1,15 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.encoder;
+
+import org.lfenergy.compas.core.websocket.AbstractEncoder;
+import org.lfenergy.compas.core.websocket.WebsocketSupport;
+import org.lfenergy.compas.scl.data.websocket.v1.model.GetWsResponse;
+
+public class GetWsResponseEncoder extends AbstractEncoder {
+ @Override
+ public String encode(GetWsResponse jaxbObject) {
+ return WebsocketSupport.encode(jaxbObject, GetWsResponse.class);
+ }
+}
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/UpdateWsRequestEncoder.java b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/UpdateWsRequestEncoder.java
new file mode 100644
index 00000000..b3b8b710
--- /dev/null
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/UpdateWsRequestEncoder.java
@@ -0,0 +1,15 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.encoder;
+
+import org.lfenergy.compas.core.websocket.AbstractEncoder;
+import org.lfenergy.compas.core.websocket.WebsocketSupport;
+import org.lfenergy.compas.scl.data.websocket.v1.model.UpdateWsRequest;
+
+public class UpdateWsRequestEncoder extends AbstractEncoder {
+ @Override
+ public String encode(UpdateWsRequest jaxbObject) {
+ return WebsocketSupport.encode(jaxbObject, UpdateWsRequest.class);
+ }
+}
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/UpdateWsResponseEncoder.java b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/UpdateWsResponseEncoder.java
new file mode 100644
index 00000000..4c5cbfdc
--- /dev/null
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/UpdateWsResponseEncoder.java
@@ -0,0 +1,15 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.encoder;
+
+import org.lfenergy.compas.core.websocket.AbstractEncoder;
+import org.lfenergy.compas.core.websocket.WebsocketSupport;
+import org.lfenergy.compas.scl.data.websocket.v1.model.UpdateWsResponse;
+
+public class UpdateWsResponseEncoder extends AbstractEncoder {
+ @Override
+ public String encode(UpdateWsResponse jaxbObject) {
+ return WebsocketSupport.encode(jaxbObject, UpdateWsResponse.class);
+ }
+}
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/model/CreateWsRequest.java b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/model/CreateWsRequest.java
new file mode 100644
index 00000000..3748261b
--- /dev/null
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/model/CreateWsRequest.java
@@ -0,0 +1,22 @@
+// SPDX-FileCopyrightText: 2021 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+
+package org.lfenergy.compas.scl.data.websocket.v1.model;
+
+import org.eclipse.microprofile.openapi.annotations.media.Schema;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_DATA_SERVICE_V1_NS_URI;
+
+@Schema(description = "Request to create a new entry in the database containing the SCL Element content.")
+@XmlType(name = "CreateWsRequest", namespace = SCL_DATA_SERVICE_V1_NS_URI)
+@XmlRootElement(name = "CreateWsRequest", namespace = SCL_DATA_SERVICE_V1_NS_URI)
+@XmlAccessorType(XmlAccessType.FIELD)
+public class CreateWsRequest extends org.lfenergy.compas.scl.data.rest.v1.model.CreateRequest {
+}
+
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/model/CreateWsResponse.java b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/model/CreateWsResponse.java
new file mode 100644
index 00000000..7a330bc3
--- /dev/null
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/model/CreateWsResponse.java
@@ -0,0 +1,20 @@
+// SPDX-FileCopyrightText: 2021 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.model;
+
+import org.eclipse.microprofile.openapi.annotations.media.Schema;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_DATA_SERVICE_V1_NS_URI;
+
+@Schema(description = "Response from creating a new entry in the database containing the SCL Element content.")
+@XmlType(name = "CreateWsResponse", namespace = SCL_DATA_SERVICE_V1_NS_URI)
+@XmlRootElement(name = "CreateWsResponse", namespace = SCL_DATA_SERVICE_V1_NS_URI)
+@XmlAccessorType(XmlAccessType.FIELD)
+public class CreateWsResponse extends org.lfenergy.compas.scl.data.rest.v1.model.CreateResponse {
+}
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/model/GetVersionWsRequest.java b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/model/GetVersionWsRequest.java
new file mode 100644
index 00000000..e050ce6f
--- /dev/null
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/model/GetVersionWsRequest.java
@@ -0,0 +1,48 @@
+// SPDX-FileCopyrightText: 2021 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+
+package org.lfenergy.compas.scl.data.websocket.v1.model;
+
+import org.eclipse.microprofile.openapi.annotations.media.Schema;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import javax.xml.bind.annotation.*;
+import java.util.UUID;
+
+import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_DATA_SERVICE_V1_NS_URI;
+
+@Schema(description = "Request for retrieving a SCL from the database.")
+@XmlType(name = "GetVersionWsRequest", namespace = SCL_DATA_SERVICE_V1_NS_URI)
+@XmlRootElement(name = "GetVersionWsRequest", namespace = SCL_DATA_SERVICE_V1_NS_URI)
+@XmlAccessorType(XmlAccessType.FIELD)
+public class GetVersionWsRequest {
+ @Schema(description = "The ID of the SCL File.",
+ example = "f7b98f4d-3fe4-4df2-8533-d7f0c1800344")
+ @NotNull
+ @XmlElement(name = "Id", namespace = SCL_DATA_SERVICE_V1_NS_URI, required = true)
+ private UUID id;
+
+ @Schema(description = "The version of the SCL File.",
+ example = "1.2.3")
+ @NotBlank
+ @XmlElement(name = "Version", namespace = SCL_DATA_SERVICE_V1_NS_URI, required = true)
+ private String version;
+
+ public UUID getId() {
+ return id;
+ }
+
+ public void setId(UUID id) {
+ this.id = id;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+}
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/model/GetWsRequest.java b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/model/GetWsRequest.java
new file mode 100644
index 00000000..764807e4
--- /dev/null
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/model/GetWsRequest.java
@@ -0,0 +1,33 @@
+// SPDX-FileCopyrightText: 2021 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+
+package org.lfenergy.compas.scl.data.websocket.v1.model;
+
+import org.eclipse.microprofile.openapi.annotations.media.Schema;
+
+import javax.validation.constraints.NotNull;
+import javax.xml.bind.annotation.*;
+import java.util.UUID;
+
+import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_DATA_SERVICE_V1_NS_URI;
+
+@Schema(description = "Request for retrieving a SCL from the database.")
+@XmlType(name = "GetWsRequest", namespace = SCL_DATA_SERVICE_V1_NS_URI)
+@XmlRootElement(name = "GetWsRequest", namespace = SCL_DATA_SERVICE_V1_NS_URI)
+@XmlAccessorType(XmlAccessType.FIELD)
+public class GetWsRequest {
+ @Schema(description = "The ID of the SCL File.",
+ example = "f7b98f4d-3fe4-4df2-8533-d7f0c1800344")
+ @NotNull
+ @XmlElement(name = "Id", namespace = SCL_DATA_SERVICE_V1_NS_URI, required = true)
+ private UUID id;
+
+ public UUID getId() {
+ return id;
+ }
+
+ public void setId(UUID id) {
+ this.id = id;
+ }
+}
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/model/GetWsResponse.java b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/model/GetWsResponse.java
new file mode 100644
index 00000000..50c51a4d
--- /dev/null
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/model/GetWsResponse.java
@@ -0,0 +1,21 @@
+// SPDX-FileCopyrightText: 2021 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+
+package org.lfenergy.compas.scl.data.websocket.v1.model;
+
+import org.eclipse.microprofile.openapi.annotations.media.Schema;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_DATA_SERVICE_V1_NS_URI;
+
+@Schema(description = "Response from retrieving a SCL from the database containing the SCL Content.")
+@XmlType(name = "GetWsResponse", namespace = SCL_DATA_SERVICE_V1_NS_URI)
+@XmlRootElement(name = "GetWsResponse", namespace = SCL_DATA_SERVICE_V1_NS_URI)
+@XmlAccessorType(XmlAccessType.FIELD)
+public class GetWsResponse extends org.lfenergy.compas.scl.data.rest.v1.model.GetResponse {
+}
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/model/UpdateWsRequest.java b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/model/UpdateWsRequest.java
new file mode 100644
index 00000000..b3b42769
--- /dev/null
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/model/UpdateWsRequest.java
@@ -0,0 +1,34 @@
+// SPDX-FileCopyrightText: 2021 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+
+package org.lfenergy.compas.scl.data.websocket.v1.model;
+
+import org.eclipse.microprofile.openapi.annotations.media.Schema;
+
+import javax.validation.constraints.NotNull;
+import javax.xml.bind.annotation.*;
+import java.util.UUID;
+
+import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_DATA_SERVICE_V1_NS_URI;
+
+@Schema(description = "Request to update an existing entry in the database containing the SCL Element content. " +
+ "A new version is created and the old version is also kept.")
+@XmlType(name = "UpdateWsRequest", namespace = SCL_DATA_SERVICE_V1_NS_URI)
+@XmlRootElement(name = "UpdateWsRequest", namespace = SCL_DATA_SERVICE_V1_NS_URI)
+@XmlAccessorType(XmlAccessType.FIELD)
+public class UpdateWsRequest extends org.lfenergy.compas.scl.data.rest.v1.model.UpdateRequest {
+ @Schema(description = "The ID of the SCL File.",
+ example = "f7b98f4d-3fe4-4df2-8533-d7f0c1800344")
+ @NotNull
+ @XmlElement(name = "Id", namespace = SCL_DATA_SERVICE_V1_NS_URI, required = true)
+ private UUID id;
+
+ public UUID getId() {
+ return id;
+ }
+
+ public void setId(UUID id) {
+ this.id = id;
+ }
+}
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/model/UpdateWsResponse.java b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/model/UpdateWsResponse.java
new file mode 100644
index 00000000..8e67b561
--- /dev/null
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/model/UpdateWsResponse.java
@@ -0,0 +1,21 @@
+// SPDX-FileCopyrightText: 2021 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+
+package org.lfenergy.compas.scl.data.websocket.v1.model;
+
+import org.eclipse.microprofile.openapi.annotations.media.Schema;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_DATA_SERVICE_V1_NS_URI;
+
+@Schema(description = "Response from updating a new entry in the database containing the SCL Element content.")
+@XmlType(name = "UpdateWsResponse", namespace = SCL_DATA_SERVICE_V1_NS_URI)
+@XmlRootElement(name = "UpdateWsResponse", namespace = SCL_DATA_SERVICE_V1_NS_URI)
+@XmlAccessorType(XmlAccessType.FIELD)
+public class UpdateWsResponse extends org.lfenergy.compas.scl.data.rest.v1.model.UpdateResponse {
+}
diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/model/package-info.java b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/model/package-info.java
new file mode 100644
index 00000000..68f35f72
--- /dev/null
+++ b/app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/model/package-info.java
@@ -0,0 +1,10 @@
+// SPDX-FileCopyrightText: 2021 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+@XmlSchema(xmlns = {@XmlNs(prefix = "sds", namespaceURI = SCL_DATA_SERVICE_V1_NS_URI)})
+package org.lfenergy.compas.scl.data.websocket.v1.model;
+
+import javax.xml.bind.annotation.XmlNs;
+import javax.xml.bind.annotation.XmlSchema;
+
+import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_DATA_SERVICE_V1_NS_URI;
diff --git a/app/src/main/resources/application.properties b/app/src/main/resources/application.properties
index bfdaef62..e4ee87b5 100644
--- a/app/src/main/resources/application.properties
+++ b/app/src/main/resources/application.properties
@@ -15,8 +15,14 @@ quarkus.log.level = INFO
quarkus.log.category."org.lfenergy.compas.scl.data".level = INFO
# Add scanning these dependencies for scanning, also used by native compilation.
-quarkus.index-dependency.jaxrs-commons.group-id = org.lfenergy.compas.core
-quarkus.index-dependency.jaxrs-commons.artifact-id = jaxrs-commons
+quarkus.index-dependency.hibernate-validator.group-id=org.hibernate.validator
+quarkus.index-dependency.hibernate-validator.artifact-id=hibernate-validator
+
+quarkus.index-dependency.websocket-commons.group-id = org.lfenergy.compas.core
+quarkus.index-dependency.websocket-commons.artifact-id = websocket-commons
+
+quarkus.index-dependency.rest-commons.group-id = org.lfenergy.compas.core
+quarkus.index-dependency.rest-commons.artifact-id = rest-commons
quarkus.index-dependency.scl-data-service.group-id = org.lfenergy.compas.scl.data
quarkus.index-dependency.scl-data-service.artifact-id = service
@@ -56,6 +62,15 @@ quarkus.http.auth.permission.SSD_DELETE_DELETE.paths=/compas-scl-data-service/sc
quarkus.http.auth.permission.SSD_DELETE_DELETE.policy=SSD_DELETE
quarkus.http.auth.permission.SSD_DELETE_DELETE.methods=DELETE
+quarkus.http.auth.permission.SSD_READ_GET_WS.paths=/compas-scl-data-service/scl-ws/v1/SSD/get
+quarkus.http.auth.permission.SSD_READ_GET_WS.policy=SSD_READ
+quarkus.http.auth.permission.SSD_READ_GET_VERSION_WS.paths=/compas-scl-data-service/scl-ws/v1/SSD/get-version
+quarkus.http.auth.permission.SSD_READ_GET_VERSION_WS.policy=SSD_READ
+quarkus.http.auth.permission.SSD_CREATE_POST_WS.paths=/compas-scl-data-service/scl-ws/v1/SSD/create
+quarkus.http.auth.permission.SSD_CREATE_POST_WS.policy=SSD_CREATE
+quarkus.http.auth.permission.SSD_UPDATE_PUT_WS.paths=/compas-scl-data-service/scl-ws/v1/SSD/update
+quarkus.http.auth.permission.SSD_UPDATE_PUT_WS.policy=SSD_UPDATE
+
quarkus.http.auth.policy.IID_READ.roles-allowed=IID_READ
quarkus.http.auth.permission.IID_READ_GET.paths=/compas-scl-data-service/scl/v1/IID/*
quarkus.http.auth.permission.IID_READ_GET.policy=IID_READ
@@ -73,6 +88,15 @@ quarkus.http.auth.permission.IID_DELETE_DELETE.paths=/compas-scl-data-service/sc
quarkus.http.auth.permission.IID_DELETE_DELETE.policy=IID_DELETE
quarkus.http.auth.permission.IID_DELETE_DELETE.methods=DELETE
+quarkus.http.auth.permission.IID_READ_GET_WS.paths=/compas-scl-data-service/scl-ws/v1/IID/get
+quarkus.http.auth.permission.IID_READ_GET_WS.policy=IID_READ
+quarkus.http.auth.permission.IID_READ_GET_VERSION_WS.paths=/compas-scl-data-service/scl-ws/v1/IID/get-version
+quarkus.http.auth.permission.IID_READ_GET_VERSION_WS.policy=IID_READ
+quarkus.http.auth.permission.IID_CREATE_POST_WS.paths=/compas-scl-data-service/scl-ws/v1/IID/create
+quarkus.http.auth.permission.IID_CREATE_POST_WS.policy=IID_CREATE
+quarkus.http.auth.permission.IID_UPDATE_PUT_WS.paths=/compas-scl-data-service/scl-ws/v1/IID/update
+quarkus.http.auth.permission.IID_UPDATE_PUT_WS.policy=IID_UPDATE
+
quarkus.http.auth.policy.ICD_READ.roles-allowed=ICD_READ
quarkus.http.auth.permission.ICD_READ_GET.paths=/compas-scl-data-service/scl/v1/ICD/*
quarkus.http.auth.permission.ICD_READ_GET.policy=ICD_READ
@@ -90,6 +114,15 @@ quarkus.http.auth.permission.ICD_DELETE_DELETE.paths=/compas-scl-data-service/sc
quarkus.http.auth.permission.ICD_DELETE_DELETE.policy=ICD_DELETE
quarkus.http.auth.permission.ICD_DELETE_DELETE.methods=DELETE
+quarkus.http.auth.permission.ICD_READ_GET_WS.paths=/compas-scl-data-service/scl-ws/v1/ICD/get
+quarkus.http.auth.permission.ICD_READ_GET_WS.policy=ICD_READ
+quarkus.http.auth.permission.ICD_READ_GET_VERSION_WS.paths=/compas-scl-data-service/scl-ws/v1/ICD/get-version
+quarkus.http.auth.permission.ICD_READ_GET_VERSION_WS.policy=ICD_READ
+quarkus.http.auth.permission.ICD_CREATE_POST_WS.paths=/compas-scl-data-service/scl-ws/v1/ICD/create
+quarkus.http.auth.permission.ICD_CREATE_POST_WS.policy=ICD_CREATE
+quarkus.http.auth.permission.ICD_UPDATE_PUT_WS.paths=/compas-scl-data-service/scl-ws/v1/ICD/update
+quarkus.http.auth.permission.ICD_UPDATE_PUT_WS.policy=ICD_UPDATE
+
quarkus.http.auth.policy.SCD_READ.roles-allowed=SCD_READ
quarkus.http.auth.permission.SCD_READ_GET.paths=/compas-scl-data-service/scl/v1/SCD/*
quarkus.http.auth.permission.SCD_READ_GET.policy=SCD_READ
@@ -107,6 +140,15 @@ quarkus.http.auth.permission.SCD_DELETE_DELETE.paths=/compas-scl-data-service/sc
quarkus.http.auth.permission.SCD_DELETE_DELETE.policy=SCD_DELETE
quarkus.http.auth.permission.SCD_DELETE_DELETE.methods=DELETE
+quarkus.http.auth.permission.SCD_READ_GET_WS.paths=/compas-scl-data-service/scl-ws/v1/SCD/get
+quarkus.http.auth.permission.SCD_READ_GET_WS.policy=SCD_READ
+quarkus.http.auth.permission.SCD_READ_GET_VERSION_WS.paths=/compas-scl-data-service/scl-ws/v1/SCD/get-version
+quarkus.http.auth.permission.SCD_READ_GET_VERSION_WS.policy=SCD_READ
+quarkus.http.auth.permission.SCD_CREATE_POST_WS.paths=/compas-scl-data-service/scl-ws/v1/SCD/create
+quarkus.http.auth.permission.SCD_CREATE_POST_WS.policy=SCD_CREATE
+quarkus.http.auth.permission.SCD_UPDATE_PUT_WS.paths=/compas-scl-data-service/scl-ws/v1/SCD/update
+quarkus.http.auth.permission.SCD_UPDATE_PUT_WS.policy=SCD_UPDATE
+
quarkus.http.auth.policy.CID_READ.roles-allowed=CID_READ
quarkus.http.auth.permission.CID_READ_GET.paths=/compas-scl-data-service/scl/v1/CID/*
quarkus.http.auth.permission.CID_READ_GET.policy=CID_READ
@@ -124,6 +166,15 @@ quarkus.http.auth.permission.CID_DELETE_DELETE.paths=/compas-scl-data-service/sc
quarkus.http.auth.permission.CID_DELETE_DELETE.policy=CID_DELETE
quarkus.http.auth.permission.CID_DELETE_DELETE.methods=DELETE
+quarkus.http.auth.permission.CID_READ_GET_WS.paths=/compas-scl-data-service/scl-ws/v1/CID/get
+quarkus.http.auth.permission.CID_READ_GET_WS.policy=CID_READ
+quarkus.http.auth.permission.CID_READ_GET_VERSION_WS.paths=/compas-scl-data-service/scl-ws/v1/CID/get-version
+quarkus.http.auth.permission.CID_READ_GET_VERSION_WS.policy=CID_READ
+quarkus.http.auth.permission.CID_CREATE_POST_WS.paths=/compas-scl-data-service/scl-ws/v1/CID/create
+quarkus.http.auth.permission.CID_CREATE_POST_WS.policy=CID_CREATE
+quarkus.http.auth.permission.CID_UPDATE_PUT_WS.paths=/compas-scl-data-service/scl-ws/v1/CID/update
+quarkus.http.auth.permission.CID_UPDATE_PUT_WS.policy=CID_UPDATE
+
quarkus.http.auth.policy.SED_READ.roles-allowed=SED_READ
quarkus.http.auth.permission.SED_READ_GET.paths=/compas-scl-data-service/scl/v1/SED/*
quarkus.http.auth.permission.SED_READ_GET.policy=SED_READ
@@ -141,6 +192,15 @@ quarkus.http.auth.permission.SED_DELETE_DELETE.paths=/compas-scl-data-service/sc
quarkus.http.auth.permission.SED_DELETE_DELETE.policy=SED_DELETE
quarkus.http.auth.permission.SED_DELETE_DELETE.methods=DELETE
+quarkus.http.auth.permission.SED_READ_GET_WS.paths=/compas-scl-data-service/scl-ws/v1/SED/get
+quarkus.http.auth.permission.SED_READ_GET_WS.policy=SED_READ
+quarkus.http.auth.permission.SED_READ_GET_VERSION_WS.paths=/compas-scl-data-service/scl-ws/v1/SED/get-version
+quarkus.http.auth.permission.SED_READ_GET_VERSION_WS.policy=SED_READ
+quarkus.http.auth.permission.SED_CREATE_POST_WS.paths=/compas-scl-data-service/scl-ws/v1/SED/create
+quarkus.http.auth.permission.SED_CREATE_POST_WS.policy=SED_CREATE
+quarkus.http.auth.permission.SED_UPDATE_PUT_WS.paths=/compas-scl-data-service/scl-ws/v1/SED/update
+quarkus.http.auth.permission.SED_UPDATE_PUT_WS.policy=SED_UPDATE
+
quarkus.http.auth.policy.ISD_READ.roles-allowed=ISD_READ
quarkus.http.auth.permission.ISD_READ_GET.paths=/compas-scl-data-service/scl/v1/ISD/*
quarkus.http.auth.permission.ISD_READ_GET.policy=ISD_READ
@@ -158,6 +218,15 @@ quarkus.http.auth.permission.ISD_DELETE_DELETE.paths=/compas-scl-data-service/sc
quarkus.http.auth.permission.ISD_DELETE_DELETE.policy=ISD_DELETE
quarkus.http.auth.permission.ISD_DELETE_DELETE.methods=DELETE
+quarkus.http.auth.permission.ISD_READ_GET_WS.paths=/compas-scl-data-service/scl-ws/v1/ISD/get
+quarkus.http.auth.permission.ISD_READ_GET_WS.policy=ISD_READ
+quarkus.http.auth.permission.ISD_READ_GET_VERSION_WS.paths=/compas-scl-data-service/scl-ws/v1/ISD/get-version
+quarkus.http.auth.permission.ISD_READ_GET_VERSION_WS.policy=ISD_READ
+quarkus.http.auth.permission.ISD_CREATE_POST_WS.paths=/compas-scl-data-service/scl-ws/v1/ISD/create
+quarkus.http.auth.permission.ISD_CREATE_POST_WS.policy=ISD_CREATE
+quarkus.http.auth.permission.ISD_UPDATE_PUT_WS.paths=/compas-scl-data-service/scl-ws/v1/ISD/update
+quarkus.http.auth.permission.ISD_UPDATE_PUT_WS.policy=ISD_UPDATE
+
quarkus.http.auth.policy.STD_READ.roles-allowed=STD_READ
quarkus.http.auth.permission.STD_READ_GET.paths=/compas-scl-data-service/scl/v1/STD/*
quarkus.http.auth.permission.STD_READ_GET.policy=STD_READ
@@ -174,3 +243,12 @@ quarkus.http.auth.policy.STD_DELETE.roles-allowed=STD_DELETE
quarkus.http.auth.permission.STD_DELETE_DELETE.paths=/compas-scl-data-service/scl/v1/STD/*
quarkus.http.auth.permission.STD_DELETE_DELETE.policy=STD_DELETE
quarkus.http.auth.permission.STD_DELETE_DELETE.methods=DELETE
+
+quarkus.http.auth.permission.STD_READ_GET_WS.paths=/compas-scl-data-service/scl-ws/v1/STD/get
+quarkus.http.auth.permission.STD_READ_GET_WS.policy=STD_READ
+quarkus.http.auth.permission.STD_READ_GET_VERSION_WS.paths=/compas-scl-data-service/scl-ws/v1/STD/get-version
+quarkus.http.auth.permission.STD_READ_GET_VERSION_WS.policy=STD_READ
+quarkus.http.auth.permission.STD_CREATE_POST_WS.paths=/compas-scl-data-service/scl-ws/v1/STD/create
+quarkus.http.auth.permission.STD_CREATE_POST_WS.policy=STD_CREATE
+quarkus.http.auth.permission.STD_UPDATE_PUT_WS.paths=/compas-scl-data-service/scl-ws/v1/STD/update
+quarkus.http.auth.permission.STD_UPDATE_PUT_WS.policy=STD_UPDATE
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/rest/exception/CompasNoDataFoundExceptionHandlerTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/rest/exception/CompasNoDataFoundExceptionHandlerTest.java
index 80402ad1..40179946 100644
--- a/app/src/test/java/org/lfenergy/compas/scl/data/rest/exception/CompasNoDataFoundExceptionHandlerTest.java
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/rest/exception/CompasNoDataFoundExceptionHandlerTest.java
@@ -4,7 +4,7 @@
package org.lfenergy.compas.scl.data.rest.exception;
import org.junit.jupiter.api.Test;
-import org.lfenergy.compas.core.jaxrs.model.ErrorResponse;
+import org.lfenergy.compas.core.commons.model.ErrorResponse;
import org.lfenergy.compas.scl.data.exception.CompasNoDataFoundException;
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/rest/v1/CompasSclDataResourceAsEditorTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/rest/v1/CompasSclDataResourceAsEditorTest.java
index a50fb5df..34dc5252 100644
--- a/app/src/test/java/org/lfenergy/compas/scl/data/rest/v1/CompasSclDataResourceAsEditorTest.java
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/rest/v1/CompasSclDataResourceAsEditorTest.java
@@ -69,7 +69,7 @@ void list_WhenCalled_ThenItemResponseRetrieved() {
assertEquals(name, xmlPath.get("ListResponse.Item[0].Name"));
assertEquals(version, xmlPath.get("ListResponse.Item[0].Version"));
assertEquals(labels.get(0), xmlPath.get("ListResponse.Item[0].Label"));
- verify(compasSclDataService, times(1)).list(type);
+ verify(compasSclDataService).list(type);
}
@Test
@@ -95,7 +95,7 @@ void listVersionsByUUID_WhenCalled_ThenItemResponseRetrieved() {
assertEquals(uuid.toString(), xmlPath.get("VersionsResponse.HistoryItem[0].Id"));
assertEquals(name, xmlPath.get("VersionsResponse.HistoryItem[0].Name"));
assertEquals(version, xmlPath.get("VersionsResponse.HistoryItem[0].Version"));
- verify(compasSclDataService, times(1)).listVersionsByUUID(type, uuid);
+ verify(compasSclDataService).listVersionsByUUID(type, uuid);
}
@Test
@@ -117,8 +117,8 @@ void findByUUID_WhenCalled_ThenSCLResponseRetrieved() throws IOException {
var xmlPath = response.xmlPath()
.using(xmlPathConfig().declaredNamespace("scl", SCL_NS_URI));
- assertEquals(scl, xmlPath.get("GetResponse.SclData"));
- verify(compasSclDataService, times(1)).findByUUID(type, uuid);
+ assertEquals(scl, xmlPath.get("GetWsResponse.SclData"));
+ verify(compasSclDataService).findByUUID(type, uuid);
}
@Test
@@ -142,8 +142,8 @@ void findByUUIDAndVersion_WhenCalled_ThenSCLResponseRetrieved() throws IOExcepti
var xmlPath = response.xmlPath()
.using(xmlPathConfig().declaredNamespace("scl", SCL_NS_URI));
- assertEquals(scl, xmlPath.get("GetResponse.SclData"));
- verify(compasSclDataService, times(1)).findByUUID(type, uuid, version);
+ assertEquals(scl, xmlPath.get("GetWsResponse.SclData"));
+ verify(compasSclDataService).findByUUID(type, uuid, version);
}
@Test
@@ -170,8 +170,8 @@ void create_WhenCalled_ThenServiceCalledAndUUIDRetrieved() throws IOException {
.extract()
.response();
- assertEquals(scl, response.xmlPath().getString("CreateResponse.SclData"));
- verify(compasSclDataService, times(1)).create(type, name, USERNAME, comment, scl);
+ assertEquals(scl, response.xmlPath().getString("CreateWsResponse.SclData"));
+ verify(compasSclDataService).create(type, name, USERNAME, comment, scl);
}
@Test
@@ -227,8 +227,8 @@ void update_WhenCalled_ThenServiceCalledAndNewUUIDRetrieved() throws IOException
.extract()
.response();
- assertEquals(scl, response.xmlPath().getString("CreateResponse.SclData"));
- verify(compasSclDataService, times(1)).update(type, uuid, changeSetType, USERNAME, comment, scl);
+ assertEquals(scl, response.xmlPath().getString("CreateWsResponse.SclData"));
+ verify(compasSclDataService).update(type, uuid, changeSetType, USERNAME, comment, scl);
}
@Test
@@ -245,7 +245,7 @@ void deleteAll_WhenCalled_ThenServiceCalled() {
.then()
.statusCode(204);
- verify(compasSclDataService, times(1)).delete(type, uuid);
+ verify(compasSclDataService).delete(type, uuid);
}
@Test
@@ -264,13 +264,14 @@ void deleteVersion_WhenCalled_ThenServiceCalled() {
.then()
.statusCode(204);
- verify(compasSclDataService, times(1)).delete(type, uuid, version);
+ verify(compasSclDataService).delete(type, uuid, version);
}
private String readSCL() throws IOException {
- var inputStream = getClass().getResourceAsStream("/scl/icd_import_ied_test.scd");
- assert inputStream != null;
+ try (var inputStream = getClass().getResourceAsStream("/scl/icd_import_ied_test.scd")) {
+ assert inputStream != null;
- return new String(inputStream.readAllBytes());
+ return new String(inputStream.readAllBytes());
+ }
}
}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/rest/v1/CompasSclDataResourceAsReaderTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/rest/v1/CompasSclDataResourceAsReaderTest.java
index 73cf38fd..3a4a86b4 100644
--- a/app/src/test/java/org/lfenergy/compas/scl/data/rest/v1/CompasSclDataResourceAsReaderTest.java
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/rest/v1/CompasSclDataResourceAsReaderTest.java
@@ -61,7 +61,7 @@ void list_WhenCalled_ThenItemResponseRetrieved() {
assertEquals(name, xmlPath.get("ListResponse.Item[0].Name"));
assertEquals(version, xmlPath.get("ListResponse.Item[0].Version"));
assertEquals(labels.get(0), xmlPath.get("ListResponse.Item[0].Label"));
- verify(compasSclDataService, times(1)).list(type);
+ verify(compasSclDataService).list(type);
}
@Test
@@ -87,7 +87,7 @@ void listVersionsByUUID_WhenCalled_ThenItemResponseRetrieved() {
assertEquals(uuid.toString(), xmlPath.get("VersionsResponse.HistoryItem[0].Id"));
assertEquals(name, xmlPath.get("VersionsResponse.HistoryItem[0].Name"));
assertEquals(version, xmlPath.get("VersionsResponse.HistoryItem[0].Version"));
- verify(compasSclDataService, times(1)).listVersionsByUUID(type, uuid);
+ verify(compasSclDataService).listVersionsByUUID(type, uuid);
}
@Test
@@ -109,8 +109,8 @@ void findByUUID_WhenCalled_ThenSCLResponseRetrieved() throws IOException {
var xmlPath = response.xmlPath()
.using(xmlPathConfig().declaredNamespace("scl", SCL_NS_URI));
- assertEquals(scl, xmlPath.get("GetResponse.SclData"));
- verify(compasSclDataService, times(1)).findByUUID(type, uuid);
+ assertEquals(scl, xmlPath.get("GetWsResponse.SclData"));
+ verify(compasSclDataService).findByUUID(type, uuid);
}
@Test
@@ -134,8 +134,8 @@ void findByUUIDAndVersion_WhenCalled_ThenSCLResponseRetrieved() throws IOExcepti
var xmlPath = response.xmlPath()
.using(xmlPathConfig().declaredNamespace("scl", SCL_NS_URI));
- assertEquals(scl, xmlPath.get("GetResponse.SclData"));
- verify(compasSclDataService, times(1)).findByUUID(type, uuid, version);
+ assertEquals(scl, xmlPath.get("GetWsResponse.SclData"));
+ verify(compasSclDataService).findByUUID(type, uuid, version);
}
@Test
@@ -223,9 +223,10 @@ void deleteVersion_WhenCalled_ThenServiceCalled() {
}
private String readSCL() throws IOException {
- var inputStream = getClass().getResourceAsStream("/scl/icd_import_ied_test.scd");
- assert inputStream != null;
+ try (var inputStream = getClass().getResourceAsStream("/scl/icd_import_ied_test.scd")) {
+ assert inputStream != null;
- return new String(inputStream.readAllBytes());
+ return new String(inputStream.readAllBytes());
+ }
}
}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/rest/v1/model/AbstractPojoTester.java b/app/src/test/java/org/lfenergy/compas/scl/data/rest/v1/model/AbstractPojoTester.java
index 13d6824c..52639a40 100644
--- a/app/src/test/java/org/lfenergy/compas/scl/data/rest/v1/model/AbstractPojoTester.java
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/rest/v1/model/AbstractPojoTester.java
@@ -16,10 +16,10 @@ abstract class AbstractPojoTester {
void validateSettersAndGetters() {
var personPojo = PojoClassFactory.getPojoClass(getClassToBeTested());
var validator = ValidatorBuilder.create()
- // Lets make sure that we have a getter and a setter for every field defined.
+ // Let's make sure that we have a getter and a setter for every field defined.
.with(new GetterMustExistRule())
.with(new SetterMustExistRule())
- // Lets also validate that they are behaving as expected
+ // Let's also validate that they are behaving as expected
.with(new SetterTester())
.with(new GetterTester())
.build();
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/event/CompasSclDataEventHandlerTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/event/CompasSclDataEventHandlerTest.java
new file mode 100644
index 00000000..39f9192d
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/event/CompasSclDataEventHandlerTest.java
@@ -0,0 +1,291 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.event;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.lfenergy.compas.core.commons.exception.CompasException;
+import org.lfenergy.compas.core.commons.model.ErrorResponse;
+import org.lfenergy.compas.scl.data.model.ChangeSetType;
+import org.lfenergy.compas.scl.data.model.Version;
+import org.lfenergy.compas.scl.data.service.CompasSclDataService;
+import org.lfenergy.compas.scl.data.websocket.event.model.CreateEventRequest;
+import org.lfenergy.compas.scl.data.websocket.event.model.GetEventRequest;
+import org.lfenergy.compas.scl.data.websocket.event.model.GetVersionEventRequest;
+import org.lfenergy.compas.scl.data.websocket.event.model.UpdateEventRequest;
+import org.lfenergy.compas.scl.data.websocket.v1.model.CreateWsResponse;
+import org.lfenergy.compas.scl.data.websocket.v1.model.GetWsResponse;
+import org.lfenergy.compas.scl.data.websocket.v1.model.UpdateWsResponse;
+import org.lfenergy.compas.scl.extensions.model.SclFileType;
+import org.mockito.ArgumentCaptor;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import javax.websocket.RemoteEndpoint;
+import javax.websocket.Session;
+import java.util.UUID;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.lfenergy.compas.core.commons.exception.CompasErrorCode.WEBSOCKET_GENERAL_ERROR_CODE;
+import static org.lfenergy.compas.scl.data.exception.CompasSclDataServiceErrorCode.DUPLICATE_SCL_NAME_ERROR_CODE;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@ExtendWith(MockitoExtension.class)
+class CompasSclDataEventHandlerTest {
+ @Mock
+ private CompasSclDataService service;
+
+ @InjectMocks
+ private CompasSclDataEventHandler eventHandler;
+
+ @Test
+ void createWebsocketsEvent_WhenCalled_ThenCreateResponseReturned() {
+ var type = SclFileType.CID;
+ var name = "Some name";
+ var who = "Who executed it";
+ var comment = "Some comment";
+ var sclData = "Some SCL Data";
+
+ var session = mockSession();
+ var request = new CreateEventRequest(session, type, name, who, comment, sclData);
+ when(service.create(type, name, who, comment, sclData)).thenReturn(sclData);
+
+ eventHandler.createWebsocketsEvent(request);
+
+ var response = verifyResponse(session, CreateWsResponse.class);
+ assertEquals(sclData, response.getSclData());
+ verify(service).create(type, name, who, comment, sclData);
+ }
+
+ @Test
+ void createWebsocketsEvent_WhenCalledAndCompasExceptionThrownByService_ThenErrorResponseReturned() {
+ var type = SclFileType.CID;
+ var name = "Some name";
+ var who = "Who executed it";
+ var comment = "Some comment";
+ var sclData = "Some SCL Data";
+ var errorMessage = "Some Error";
+
+ var session = mockSession();
+ var request = new CreateEventRequest(session, type, name, who, comment, sclData);
+ when(service.create(type, name, who, comment, sclData))
+ .thenThrow(new CompasException(DUPLICATE_SCL_NAME_ERROR_CODE, errorMessage));
+
+ eventHandler.createWebsocketsEvent(request);
+
+ verifyErrorResponse(session, DUPLICATE_SCL_NAME_ERROR_CODE, errorMessage);
+ verify(service).create(type, name, who, comment, sclData);
+ }
+
+ @Test
+ void createWebsocketsEvent_WhenCalledAndRuntimeExceptionThrownByService_ThenErrorResponseReturned() {
+ var type = SclFileType.CID;
+ var name = "Some name";
+ var who = "Who executed it";
+ var comment = "Some comment";
+ var sclData = "Some SCL Data";
+ var errorMessage = "Some Error";
+
+ var session = mockSession();
+ var request = new CreateEventRequest(session, type, name, who, comment, sclData);
+ when(service.create(type, name, who, comment, sclData)).thenThrow(new RuntimeException(errorMessage));
+
+ eventHandler.createWebsocketsEvent(request);
+
+ verifyErrorResponse(session, WEBSOCKET_GENERAL_ERROR_CODE, errorMessage);
+ verify(service).create(type, name, who, comment, sclData);
+ }
+
+ @Test
+ void getWebsocketsEvent_WhenCalled_ThenGetResponseReturned() {
+ var type = SclFileType.CID;
+ var id = UUID.randomUUID();
+ var sclData = "Some SCL Data";
+
+ var session = mockSession();
+ var request = new GetEventRequest(session, type, id);
+ when(service.findByUUID(type, id)).thenReturn(sclData);
+
+ eventHandler.getWebsocketsEvent(request);
+
+ var response = verifyResponse(session, GetWsResponse.class);
+ assertEquals(sclData, response.getSclData());
+ verify(service).findByUUID(type, id);
+ }
+
+ @Test
+ void getWebsocketsEvent_WhenCalledAndCompasExceptionThrownByService_ThenErrorResponseReturned() {
+ var type = SclFileType.CID;
+ var id = UUID.randomUUID();
+ var errorMessage = "Some Error";
+
+ var session = mockSession();
+ var request = new GetEventRequest(session, type, id);
+ when(service.findByUUID(type, id))
+ .thenThrow(new CompasException(DUPLICATE_SCL_NAME_ERROR_CODE, errorMessage));
+
+ eventHandler.getWebsocketsEvent(request);
+
+ verifyErrorResponse(session, DUPLICATE_SCL_NAME_ERROR_CODE, errorMessage);
+ verify(service).findByUUID(type, id);
+ }
+
+ @Test
+ void getWebsocketsEvent_WhenCalledAndRuntimeExceptionThrownByService_ThenErrorResponseReturned() {
+ var type = SclFileType.CID;
+ var id = UUID.randomUUID();
+ var errorMessage = "Some Error";
+
+ var session = mockSession();
+ var request = new GetEventRequest(session, type, id);
+ when(service.findByUUID(type, id)).thenThrow(new RuntimeException(errorMessage));
+
+ eventHandler.getWebsocketsEvent(request);
+
+ verifyErrorResponse(session, WEBSOCKET_GENERAL_ERROR_CODE, errorMessage);
+ verify(service).findByUUID(type, id);
+ }
+
+ @Test
+ void getVersionWebsocketsEvent_WhenCalled_ThenGetResponseReturned() {
+ var type = SclFileType.CID;
+ var id = UUID.randomUUID();
+ var sclData = "Some SCL Data";
+ var version = new Version("1.2.3");
+
+ var session = mockSession();
+ var request = new GetVersionEventRequest(session, type, id, version);
+ when(service.findByUUID(type, id, version)).thenReturn(sclData);
+
+ eventHandler.getVersionWebsocketsEvent(request);
+
+ var response = verifyResponse(session, GetWsResponse.class);
+ assertEquals(sclData, response.getSclData());
+ verify(service).findByUUID(type, id, version);
+ }
+
+ @Test
+ void getVersionWebsocketsEvent_WhenCalledAndCompasExceptionThrownByService_ThenErrorResponseReturned() {
+ var type = SclFileType.CID;
+ var id = UUID.randomUUID();
+ var version = new Version("1.2.3");
+ var errorMessage = "Some Error";
+
+ var session = mockSession();
+ var request = new GetVersionEventRequest(session, type, id, version);
+ when(service.findByUUID(type, id, version))
+ .thenThrow(new CompasException(DUPLICATE_SCL_NAME_ERROR_CODE, errorMessage));
+
+ eventHandler.getVersionWebsocketsEvent(request);
+
+ verifyErrorResponse(session, DUPLICATE_SCL_NAME_ERROR_CODE, errorMessage);
+ verify(service).findByUUID(type, id, version);
+ }
+
+ @Test
+ void getVersionWebsocketsEvent_WhenCalledAndRuntimeExceptionThrownByService_ThenErrorResponseReturned() {
+ var type = SclFileType.CID;
+ var id = UUID.randomUUID();
+ var version = new Version("1.2.3");
+ var errorMessage = "Some Error";
+
+ var session = mockSession();
+ var request = new GetVersionEventRequest(session, type, id, version);
+ when(service.findByUUID(type, id, version)).thenThrow(new RuntimeException(errorMessage));
+
+ eventHandler.getVersionWebsocketsEvent(request);
+
+ verifyErrorResponse(session, WEBSOCKET_GENERAL_ERROR_CODE, errorMessage);
+ verify(service).findByUUID(type, id, version);
+ }
+
+ @Test
+ void updateWebsocketsEvent_WhenCalled_ThenUpdateResponseReturned() {
+ var type = SclFileType.CID;
+ var id = UUID.randomUUID();
+ var cst = ChangeSetType.MINOR;
+ var who = "Who executed it";
+ var comment = "Some comment";
+ var sclData = "Some SCL Data";
+
+ var session = mockSession();
+ var request = new UpdateEventRequest(session, type, id, cst, who, comment, sclData);
+ when(service.update(type, id, cst, who, comment, sclData)).thenReturn(sclData);
+
+ eventHandler.updateWebsocketsEvent(request);
+
+ var response = verifyResponse(session, UpdateWsResponse.class);
+ assertEquals(sclData, response.getSclData());
+ verify(service).update(type, id, cst, who, comment, sclData);
+ }
+
+ @Test
+ void updateWebsocketsEvent_WhenCalledAndCompasExceptionThrownByService_ThenErrorResponseReturned() {
+ var type = SclFileType.CID;
+ var id = UUID.randomUUID();
+ var cst = ChangeSetType.MINOR;
+ var who = "Who executed it";
+ var comment = "Some comment";
+ var sclData = "Some SCL Data";
+ var errorMessage = "Some Error";
+
+ var session = mockSession();
+ var request = new UpdateEventRequest(session, type, id, cst, who, comment, sclData);
+ when(service.update(type, id, cst, who, comment, sclData))
+ .thenThrow(new CompasException(DUPLICATE_SCL_NAME_ERROR_CODE, errorMessage));
+
+ eventHandler.updateWebsocketsEvent(request);
+
+ verifyErrorResponse(session, DUPLICATE_SCL_NAME_ERROR_CODE, errorMessage);
+ verify(service).update(type, id, cst, who, comment, sclData);
+ }
+
+ @Test
+ void updateWebsocketsEvent_WhenCalledAndRuntimeExceptionThrownByService_ThenErrorResponseReturned() {
+ var type = SclFileType.CID;
+ var id = UUID.randomUUID();
+ var cst = ChangeSetType.MINOR;
+ var who = "Who executed it";
+ var comment = "Some comment";
+ var sclData = "Some SCL Data";
+ var errorMessage = "Some Error";
+
+ var session = mockSession();
+ var request = new UpdateEventRequest(session, type, id, cst, who, comment, sclData);
+ when(service.update(type, id, cst, who, comment, sclData)).thenThrow(new RuntimeException(errorMessage));
+
+ eventHandler.updateWebsocketsEvent(request);
+
+ verifyErrorResponse(session, WEBSOCKET_GENERAL_ERROR_CODE, errorMessage);
+ verify(service).update(type, id, cst, who, comment, sclData);
+ }
+
+ private Session mockSession() {
+ var session = Mockito.mock(Session.class);
+ var async = Mockito.mock(RemoteEndpoint.Async.class);
+ when(session.getAsyncRemote()).thenReturn(async);
+ return session;
+ }
+
+ private T verifyResponse(Session session, Class responseClass) {
+ verify(session).getAsyncRemote();
+ ArgumentCaptor captor = ArgumentCaptor.forClass(responseClass);
+ verify(session.getAsyncRemote()).sendObject(captor.capture());
+ return captor.getValue();
+ }
+
+ private void verifyErrorResponse(Session session, String errorCode, String errorMessage) {
+ verify(session).getAsyncRemote();
+ ArgumentCaptor captor = ArgumentCaptor.forClass(ErrorResponse.class);
+ verify(session.getAsyncRemote()).sendObject(captor.capture());
+ var response = captor.getValue();
+ assertEquals(1, response.getErrorMessages().size());
+ var message = response.getErrorMessages().get(0);
+ assertEquals(errorCode, message.getCode());
+ assertEquals(errorMessage, message.getMessage());
+ }
+}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/event/model/CreateEventRequestTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/event/model/CreateEventRequestTest.java
new file mode 100644
index 00000000..0c250f5c
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/event/model/CreateEventRequestTest.java
@@ -0,0 +1,51 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.event.model;
+
+import com.openpojo.reflection.impl.PojoClassFactory;
+import com.openpojo.validation.ValidatorBuilder;
+import com.openpojo.validation.rule.impl.GetterMustExistRule;
+import com.openpojo.validation.test.impl.GetterTester;
+import org.junit.jupiter.api.Test;
+import org.lfenergy.compas.scl.extensions.model.SclFileType;
+import org.mockito.Mockito;
+
+import javax.websocket.Session;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class CreateEventRequestTest {
+ @Test
+ void constructor_WhenCalledWith3Arguments_ThenValuesSet() {
+ var session = Mockito.mock(Session.class);
+ var type = SclFileType.CID;
+ var name = "Some name";
+ var who = "Who executed it";
+ var comment = "Some comment";
+ var sclData = "Some SCL Data";
+
+ var result = new CreateEventRequest(session, type, name, who, comment, sclData);
+
+ assertEquals(session, result.getSession());
+ assertEquals(type, result.getType());
+ assertEquals(name, result.getName());
+ assertEquals(who, result.getWho());
+ assertEquals(comment, result.getComment());
+ assertEquals(sclData, result.getSclData());
+ }
+
+ @Test
+ void validateSettersAndGetters() {
+ var personPojo = PojoClassFactory.getPojoClass(CreateEventRequest.class);
+ var validator = ValidatorBuilder.create()
+ // Let's make sure that we have a getter for every field defined.
+ .with(new GetterMustExistRule())
+ // Let's also validate that they are behaving as expected
+ .with(new GetterTester())
+ .build();
+
+ // Start the Test
+ validator.validate(personPojo);
+ }
+}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/event/model/GetEventRequestTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/event/model/GetEventRequestTest.java
new file mode 100644
index 00000000..e9240bcd
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/event/model/GetEventRequestTest.java
@@ -0,0 +1,46 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.event.model;
+
+import com.openpojo.reflection.impl.PojoClassFactory;
+import com.openpojo.validation.ValidatorBuilder;
+import com.openpojo.validation.rule.impl.GetterMustExistRule;
+import com.openpojo.validation.test.impl.GetterTester;
+import org.junit.jupiter.api.Test;
+import org.lfenergy.compas.scl.extensions.model.SclFileType;
+import org.mockito.Mockito;
+
+import javax.websocket.Session;
+import java.util.UUID;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class GetEventRequestTest {
+ @Test
+ void constructor_WhenCalledWith3Arguments_ThenValuesSet() {
+ var session = Mockito.mock(Session.class);
+ var type = SclFileType.CID;
+ var id = UUID.randomUUID();
+
+ var result = new GetEventRequest(session, type, id);
+
+ assertEquals(session, result.getSession());
+ assertEquals(type, result.getType());
+ assertEquals(id, result.getId());
+ }
+
+ @Test
+ void validateSettersAndGetters() {
+ var personPojo = PojoClassFactory.getPojoClass(UpdateEventRequest.class);
+ var validator = ValidatorBuilder.create()
+ // Let's make sure that we have a getter for every field defined.
+ .with(new GetterMustExistRule())
+ // Let's also validate that they are behaving as expected
+ .with(new GetterTester())
+ .build();
+
+ // Start the Test
+ validator.validate(personPojo);
+ }
+}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/event/model/GetVersionEventRequestTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/event/model/GetVersionEventRequestTest.java
new file mode 100644
index 00000000..1e2a9a29
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/event/model/GetVersionEventRequestTest.java
@@ -0,0 +1,49 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.event.model;
+
+import com.openpojo.reflection.impl.PojoClassFactory;
+import com.openpojo.validation.ValidatorBuilder;
+import com.openpojo.validation.rule.impl.GetterMustExistRule;
+import com.openpojo.validation.test.impl.GetterTester;
+import org.junit.jupiter.api.Test;
+import org.lfenergy.compas.scl.data.model.Version;
+import org.lfenergy.compas.scl.extensions.model.SclFileType;
+import org.mockito.Mockito;
+
+import javax.websocket.Session;
+import java.util.UUID;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class GetVersionEventRequestTest {
+ @Test
+ void constructor_WhenCalledWith3Arguments_ThenValuesSet() {
+ var session = Mockito.mock(Session.class);
+ var type = SclFileType.CID;
+ var id = UUID.randomUUID();
+ var version = new Version("1.2.3");
+
+ var result = new GetVersionEventRequest(session, type, id, version);
+
+ assertEquals(session, result.getSession());
+ assertEquals(type, result.getType());
+ assertEquals(id, result.getId());
+ assertEquals(version, result.getVersion());
+ }
+
+ @Test
+ void validateSettersAndGetters() {
+ var personPojo = PojoClassFactory.getPojoClass(UpdateEventRequest.class);
+ var validator = ValidatorBuilder.create()
+ // Let's make sure that we have a getter for every field defined.
+ .with(new GetterMustExistRule())
+ // Let's also validate that they are behaving as expected
+ .with(new GetterTester())
+ .build();
+
+ // Start the Test
+ validator.validate(personPojo);
+ }
+}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/event/model/UpdateEventRequestTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/event/model/UpdateEventRequestTest.java
new file mode 100644
index 00000000..ada45ffc
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/event/model/UpdateEventRequestTest.java
@@ -0,0 +1,55 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.event.model;
+
+import com.openpojo.reflection.impl.PojoClassFactory;
+import com.openpojo.validation.ValidatorBuilder;
+import com.openpojo.validation.rule.impl.GetterMustExistRule;
+import com.openpojo.validation.test.impl.GetterTester;
+import org.junit.jupiter.api.Test;
+import org.lfenergy.compas.scl.data.model.ChangeSetType;
+import org.lfenergy.compas.scl.extensions.model.SclFileType;
+import org.mockito.Mockito;
+
+import javax.websocket.Session;
+import java.util.UUID;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class UpdateEventRequestTest {
+ @Test
+ void constructor_WhenCalledWith3Arguments_ThenValuesSet() {
+ var session = Mockito.mock(Session.class);
+ var type = SclFileType.CID;
+ var id = UUID.randomUUID();
+ var changeSetType = ChangeSetType.MAJOR;
+ var who = "Who executed it";
+ var comment = "Some comment";
+ var sclData = "Some SCL Data";
+
+ var result = new UpdateEventRequest(session, type, id, changeSetType, who, comment, sclData);
+
+ assertEquals(session, result.getSession());
+ assertEquals(type, result.getType());
+ assertEquals(id, result.getId());
+ assertEquals(changeSetType, result.getChangeSetType());
+ assertEquals(who, result.getWho());
+ assertEquals(comment, result.getComment());
+ assertEquals(sclData, result.getSclData());
+ }
+
+ @Test
+ void validateSettersAndGetters() {
+ var personPojo = PojoClassFactory.getPojoClass(UpdateEventRequest.class);
+ var validator = ValidatorBuilder.create()
+ // Let's make sure that we have a getter for every field defined.
+ .with(new GetterMustExistRule())
+ // Let's also validate that they are behaving as expected
+ .with(new GetterTester())
+ .build();
+
+ // Start the Test
+ validator.validate(personPojo);
+ }
+}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/AbstractServerEndpointAsEditorTestSupport.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/AbstractServerEndpointAsEditorTestSupport.java
new file mode 100644
index 00000000..22d0f38a
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/AbstractServerEndpointAsEditorTestSupport.java
@@ -0,0 +1,20 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1;
+
+import io.quarkus.test.security.TestSecurity;
+import io.quarkus.test.security.jwt.Claim;
+import io.quarkus.test.security.jwt.JwtSecurity;
+
+import static org.lfenergy.compas.scl.data.rest.Constants.*;
+
+@TestSecurity(user = "test-editor", roles = {"SCD_" + READ_ROLE, "SCD_" + CREATE_ROLE, "SCD_" + UPDATE_ROLE})
+@JwtSecurity(claims = {
+ // Default the claim "name" is configured for Who, so we will set this claim for the test.
+ @Claim(key = "name", value = AbstractServerEndpointAsEditorTestSupport.USERNAME)
+})
+public abstract class AbstractServerEndpointAsEditorTestSupport extends AbstractServerEndpointTestSupport {
+ public static final String USERNAME = "Test Editor";
+
+}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/AbstractServerEndpointAsReaderTestSupport.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/AbstractServerEndpointAsReaderTestSupport.java
new file mode 100644
index 00000000..58722723
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/AbstractServerEndpointAsReaderTestSupport.java
@@ -0,0 +1,36 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1;
+
+import io.netty.handler.codec.http.HttpResponseStatus;
+import io.netty.handler.codec.http.websocketx.WebSocketClientHandshakeException;
+import io.quarkus.test.security.TestSecurity;
+
+import javax.websocket.ClientEndpoint;
+import javax.websocket.ContainerProvider;
+import java.io.InterruptedIOException;
+import java.net.URI;
+import java.util.concurrent.ExecutionException;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.lfenergy.compas.scl.data.rest.Constants.READ_ROLE;
+
+@TestSecurity(user = "test-editor", roles = {"SCD_" + READ_ROLE})
+public abstract class AbstractServerEndpointAsReaderTestSupport extends AbstractServerEndpointTestSupport {
+ protected void testWhenForbiddenToExecute(URI uri) {
+ var container = ContainerProvider.getWebSocketContainer();
+ var exception = assertThrows(InterruptedIOException.class, () -> container.connectToServer(Client.class, uri));
+
+ assertEquals(1, exception.getSuppressed().length);
+ assertEquals(ExecutionException.class, exception.getSuppressed()[0].getClass());
+ assertEquals(WebSocketClientHandshakeException.class, (exception.getSuppressed()[0]).getCause().getClass());
+ var wschExp = (WebSocketClientHandshakeException) (exception.getSuppressed()[0]).getCause();
+ assertEquals(HttpResponseStatus.FORBIDDEN, wschExp.response().status());
+ }
+
+ @ClientEndpoint()
+ static class Client {
+ }
+}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/AbstractServerEndpointTestSupport.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/AbstractServerEndpointTestSupport.java
new file mode 100644
index 00000000..6a4ad521
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/AbstractServerEndpointTestSupport.java
@@ -0,0 +1,63 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1;
+
+import org.lfenergy.compas.core.commons.model.ErrorMessage;
+import org.lfenergy.compas.core.commons.model.ErrorResponse;
+import org.lfenergy.compas.core.websocket.ErrorResponseDecoder;
+
+import javax.websocket.ClientEndpoint;
+import javax.websocket.ContainerProvider;
+import javax.websocket.OnMessage;
+import javax.websocket.Session;
+import java.io.IOException;
+import java.net.URI;
+import java.util.concurrent.LinkedBlockingDeque;
+import java.util.concurrent.TimeUnit;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.lfenergy.compas.core.commons.exception.CompasErrorCode.WEBSOCKET_DECODER_ERROR_CODE;
+
+public class AbstractServerEndpointTestSupport {
+ protected static final LinkedBlockingDeque sclDataQueue = new LinkedBlockingDeque<>();
+ protected static final LinkedBlockingDeque errorQueue = new LinkedBlockingDeque<>();
+
+ void testWhenCalledWithInvalidTextThenExceptionThrown(URI uri) throws Exception {
+ try (Session session = ContainerProvider.getWebSocketContainer().connectToServer(ErrorClient.class, uri)) {
+ session.getAsyncRemote().sendText("Invalid Message");
+
+ assertErrorResponse(WEBSOCKET_DECODER_ERROR_CODE);
+ }
+ }
+
+ protected void assertErrorResponse(String expectedErrorCode) throws InterruptedException {
+ var errorMessage = errorQueue.poll(10, TimeUnit.SECONDS);
+ assertEquals(expectedErrorCode, errorMessage.getCode());
+ assertEquals(0, errorQueue.size());
+ }
+
+ protected void assertSclData(String expectedSclData) throws InterruptedException {
+ var returnedSclData = sclDataQueue.poll(10, TimeUnit.SECONDS);
+ assertEquals(expectedSclData, returnedSclData);
+ assertEquals(0, sclDataQueue.size());
+ }
+
+ protected String readSCL() throws IOException {
+ try (var inputStream = getClass().getResourceAsStream("/scl/icd_import_ied_test.scd")) {
+ assert inputStream != null;
+
+ return new String(inputStream.readAllBytes());
+ }
+ }
+
+ @ClientEndpoint(decoders = ErrorResponseDecoder.class)
+ static class ErrorClient {
+ @OnMessage
+ public void onMessage(ErrorResponse response) {
+ if (response.getErrorMessages().size() > 0) {
+ errorQueue.addAll(response.getErrorMessages());
+ }
+ }
+ }
+}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclCreateServerEndpointAsEditorTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclCreateServerEndpointAsEditorTest.java
new file mode 100644
index 00000000..eabfa8e1
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclCreateServerEndpointAsEditorTest.java
@@ -0,0 +1,70 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1;
+
+import io.quarkus.test.common.http.TestHTTPResource;
+import io.quarkus.test.junit.QuarkusTest;
+import io.quarkus.test.junit.mockito.InjectMock;
+import org.junit.jupiter.api.Test;
+import org.lfenergy.compas.scl.data.service.CompasSclDataService;
+import org.lfenergy.compas.scl.data.websocket.v1.decoder.CreateWsResponseDecoder;
+import org.lfenergy.compas.scl.data.websocket.v1.encoder.CreateWsRequestEncoder;
+import org.lfenergy.compas.scl.data.websocket.v1.model.CreateWsRequest;
+import org.lfenergy.compas.scl.data.websocket.v1.model.CreateWsResponse;
+import org.lfenergy.compas.scl.extensions.model.SclFileType;
+
+import javax.websocket.ClientEndpoint;
+import javax.websocket.ContainerProvider;
+import javax.websocket.OnMessage;
+import javax.websocket.Session;
+import java.net.URI;
+
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@QuarkusTest
+class CompasSclCreateServerEndpointAsEditorTest extends AbstractServerEndpointAsEditorTestSupport {
+ @InjectMock
+ private CompasSclDataService service;
+
+ @TestHTTPResource("/scl-ws/v1/SCD/create")
+ private URI uri;
+
+ @Test
+ void createSCL_WhenCalled_ThenExpectedResponseIsRetrieved() throws Exception {
+ var encoder = new CreateWsRequestEncoder();
+ var sclFileTye = SclFileType.SCD;
+ var name = "Some name";
+ var comment = "Some comment";
+ var sclData = readSCL();
+
+ var request = new CreateWsRequest();
+ request.setName(name);
+ request.setComment(comment);
+ request.setSclData(sclData);
+
+ when(service.create(sclFileTye, name, USERNAME, comment, sclData))
+ .thenReturn(sclData);
+
+ try (Session session = ContainerProvider.getWebSocketContainer().connectToServer(Client.class, uri)) {
+ session.getAsyncRemote().sendText(encoder.encode(request));
+
+ assertSclData(sclData);
+ verify(service).create(sclFileTye, name, USERNAME, comment, sclData);
+ }
+ }
+
+ @Test
+ void createSCL_WhenCalledWithInvalidText_ThenExceptionThrown() throws Exception {
+ testWhenCalledWithInvalidTextThenExceptionThrown(uri);
+ }
+
+ @ClientEndpoint(decoders = CreateWsResponseDecoder.class)
+ static class Client {
+ @OnMessage
+ public void onMessage(CreateWsResponse response) {
+ sclDataQueue.add(response.getSclData());
+ }
+ }
+}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclCreateServerEndpointAsReaderTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclCreateServerEndpointAsReaderTest.java
new file mode 100644
index 00000000..5074709d
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclCreateServerEndpointAsReaderTest.java
@@ -0,0 +1,21 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1;
+
+import io.quarkus.test.common.http.TestHTTPResource;
+import io.quarkus.test.junit.QuarkusTest;
+import org.junit.jupiter.api.Test;
+
+import java.net.URI;
+
+@QuarkusTest
+class CompasSclCreateServerEndpointAsReaderTest extends AbstractServerEndpointAsReaderTestSupport {
+ @TestHTTPResource("/scl-ws/v1/SCD/create")
+ private URI uri;
+
+ @Test
+ void createSCL_WhenCalled_ThenExpectedResponseIsRetrieved() {
+ testWhenForbiddenToExecute(uri);
+ }
+}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclGetServerEndpointAsEditorTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclGetServerEndpointAsEditorTest.java
new file mode 100644
index 00000000..101d3ff1
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclGetServerEndpointAsEditorTest.java
@@ -0,0 +1,67 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1;
+
+import io.quarkus.test.common.http.TestHTTPResource;
+import io.quarkus.test.junit.QuarkusTest;
+import io.quarkus.test.junit.mockito.InjectMock;
+import org.junit.jupiter.api.Test;
+import org.lfenergy.compas.scl.data.service.CompasSclDataService;
+import org.lfenergy.compas.scl.data.websocket.v1.decoder.GetWsResponseDecoder;
+import org.lfenergy.compas.scl.data.websocket.v1.encoder.GetWsRequestEncoder;
+import org.lfenergy.compas.scl.data.websocket.v1.model.GetWsRequest;
+import org.lfenergy.compas.scl.data.websocket.v1.model.GetWsResponse;
+import org.lfenergy.compas.scl.extensions.model.SclFileType;
+
+import javax.websocket.ClientEndpoint;
+import javax.websocket.ContainerProvider;
+import javax.websocket.OnMessage;
+import javax.websocket.Session;
+import java.net.URI;
+import java.util.UUID;
+
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@QuarkusTest
+class CompasSclGetServerEndpointAsEditorTest extends AbstractServerEndpointAsEditorTestSupport {
+ @InjectMock
+ private CompasSclDataService service;
+
+ @TestHTTPResource("/scl-ws/v1/SCD/get")
+ private URI uri;
+
+ @Test
+ void getSCL_WhenCalled_ThenExpectedResponseIsRetrieved() throws Exception {
+ var encoder = new GetWsRequestEncoder();
+ var sclFileTye = SclFileType.SCD;
+ var id = UUID.randomUUID();
+ var sclData = readSCL();
+
+ var request = new GetWsRequest();
+ request.setId(id);
+
+ when(service.findByUUID(sclFileTye, id)).thenReturn(sclData);
+
+ try (Session session = ContainerProvider.getWebSocketContainer().connectToServer(Client.class, uri)) {
+ session.getAsyncRemote().sendText(encoder.encode(request));
+
+ assertSclData(sclData);
+ verify(service).findByUUID(sclFileTye, id);
+ }
+ }
+
+ @Test
+ void getSCL_WhenCalledWithInvalidText_ThenExceptionThrown() throws Exception {
+ testWhenCalledWithInvalidTextThenExceptionThrown(uri);
+ }
+
+ @ClientEndpoint(decoders = GetWsResponseDecoder.class)
+ static class Client {
+ @OnMessage
+ public void onMessage(GetWsResponse response) {
+ sclDataQueue.add(response.getSclData());
+ }
+ }
+}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclGetServerEndpointAsReaderTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclGetServerEndpointAsReaderTest.java
new file mode 100644
index 00000000..fa63b88a
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclGetServerEndpointAsReaderTest.java
@@ -0,0 +1,67 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1;
+
+import io.quarkus.test.common.http.TestHTTPResource;
+import io.quarkus.test.junit.QuarkusTest;
+import io.quarkus.test.junit.mockito.InjectMock;
+import org.junit.jupiter.api.Test;
+import org.lfenergy.compas.scl.data.service.CompasSclDataService;
+import org.lfenergy.compas.scl.data.websocket.v1.decoder.GetWsResponseDecoder;
+import org.lfenergy.compas.scl.data.websocket.v1.encoder.GetWsRequestEncoder;
+import org.lfenergy.compas.scl.data.websocket.v1.model.GetWsRequest;
+import org.lfenergy.compas.scl.data.websocket.v1.model.GetWsResponse;
+import org.lfenergy.compas.scl.extensions.model.SclFileType;
+
+import javax.websocket.ClientEndpoint;
+import javax.websocket.ContainerProvider;
+import javax.websocket.OnMessage;
+import javax.websocket.Session;
+import java.net.URI;
+import java.util.UUID;
+
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@QuarkusTest
+class CompasSclGetServerEndpointAsReaderTest extends AbstractServerEndpointAsReaderTestSupport {
+ @InjectMock
+ private CompasSclDataService service;
+
+ @TestHTTPResource("/scl-ws/v1/SCD/get")
+ private URI uri;
+
+ @Test
+ void getSCL_WhenCalled_ThenExpectedResponseIsRetrieved() throws Exception {
+ var encoder = new GetWsRequestEncoder();
+ var sclFileTye = SclFileType.SCD;
+ var id = UUID.randomUUID();
+ var sclData = readSCL();
+
+ var request = new GetWsRequest();
+ request.setId(id);
+
+ when(service.findByUUID(sclFileTye, id)).thenReturn(sclData);
+
+ try (Session session = ContainerProvider.getWebSocketContainer().connectToServer(Client.class, uri)) {
+ session.getAsyncRemote().sendText(encoder.encode(request));
+
+ assertSclData(sclData);
+ verify(service).findByUUID(sclFileTye, id);
+ }
+ }
+
+ @Test
+ void getSCL_WhenCalledWithInvalidText_ThenExceptionThrown() throws Exception {
+ testWhenCalledWithInvalidTextThenExceptionThrown(uri);
+ }
+
+ @ClientEndpoint(decoders = GetWsResponseDecoder.class)
+ static class Client {
+ @OnMessage
+ public void onMessage(GetWsResponse response) {
+ sclDataQueue.add(response.getSclData());
+ }
+ }
+}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclGetVersionServerEndpointAsEditorTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclGetVersionServerEndpointAsEditorTest.java
new file mode 100644
index 00000000..41da1179
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclGetVersionServerEndpointAsEditorTest.java
@@ -0,0 +1,70 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1;
+
+import io.quarkus.test.common.http.TestHTTPResource;
+import io.quarkus.test.junit.QuarkusTest;
+import io.quarkus.test.junit.mockito.InjectMock;
+import org.junit.jupiter.api.Test;
+import org.lfenergy.compas.scl.data.model.Version;
+import org.lfenergy.compas.scl.data.service.CompasSclDataService;
+import org.lfenergy.compas.scl.data.websocket.v1.decoder.GetWsResponseDecoder;
+import org.lfenergy.compas.scl.data.websocket.v1.encoder.GetVersionWsRequestEncoder;
+import org.lfenergy.compas.scl.data.websocket.v1.model.GetVersionWsRequest;
+import org.lfenergy.compas.scl.data.websocket.v1.model.GetWsResponse;
+import org.lfenergy.compas.scl.extensions.model.SclFileType;
+
+import javax.websocket.ClientEndpoint;
+import javax.websocket.ContainerProvider;
+import javax.websocket.OnMessage;
+import javax.websocket.Session;
+import java.net.URI;
+import java.util.UUID;
+
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@QuarkusTest
+class CompasSclGetVersionServerEndpointAsEditorTest extends AbstractServerEndpointAsEditorTestSupport {
+ @InjectMock
+ private CompasSclDataService service;
+
+ @TestHTTPResource("/scl-ws/v1/SCD/get-version")
+ private URI uri;
+
+ @Test
+ void getVersionSCL_WhenCalled_ThenExpectedResponseIsRetrieved() throws Exception {
+ var encoder = new GetVersionWsRequestEncoder();
+ var sclFileTye = SclFileType.SCD;
+ var id = UUID.randomUUID();
+ var version = new Version("1.2.3");
+ var sclData = readSCL();
+
+ var request = new GetVersionWsRequest();
+ request.setId(id);
+ request.setVersion(version.toString());
+
+ when(service.findByUUID(sclFileTye, id, version)).thenReturn(sclData);
+
+ try (Session session = ContainerProvider.getWebSocketContainer().connectToServer(Client.class, uri)) {
+ session.getAsyncRemote().sendText(encoder.encode(request));
+
+ assertSclData(sclData);
+ verify(service).findByUUID(sclFileTye, id, version);
+ }
+ }
+
+ @Test
+ void getSCL_WhenCalledWithInvalidText_ThenExceptionThrown() throws Exception {
+ testWhenCalledWithInvalidTextThenExceptionThrown(uri);
+ }
+
+ @ClientEndpoint(decoders = GetWsResponseDecoder.class)
+ static class Client {
+ @OnMessage
+ public void onMessage(GetWsResponse response) {
+ sclDataQueue.add(response.getSclData());
+ }
+ }
+}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclGetVersionServerEndpointAsReaderTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclGetVersionServerEndpointAsReaderTest.java
new file mode 100644
index 00000000..23037003
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclGetVersionServerEndpointAsReaderTest.java
@@ -0,0 +1,70 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1;
+
+import io.quarkus.test.common.http.TestHTTPResource;
+import io.quarkus.test.junit.QuarkusTest;
+import io.quarkus.test.junit.mockito.InjectMock;
+import org.junit.jupiter.api.Test;
+import org.lfenergy.compas.scl.data.model.Version;
+import org.lfenergy.compas.scl.data.service.CompasSclDataService;
+import org.lfenergy.compas.scl.data.websocket.v1.decoder.GetWsResponseDecoder;
+import org.lfenergy.compas.scl.data.websocket.v1.encoder.GetVersionWsRequestEncoder;
+import org.lfenergy.compas.scl.data.websocket.v1.model.GetVersionWsRequest;
+import org.lfenergy.compas.scl.data.websocket.v1.model.GetWsResponse;
+import org.lfenergy.compas.scl.extensions.model.SclFileType;
+
+import javax.websocket.ClientEndpoint;
+import javax.websocket.ContainerProvider;
+import javax.websocket.OnMessage;
+import javax.websocket.Session;
+import java.net.URI;
+import java.util.UUID;
+
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@QuarkusTest
+class CompasSclGetVersionServerEndpointAsReaderTest extends AbstractServerEndpointAsReaderTestSupport {
+ @InjectMock
+ private CompasSclDataService service;
+
+ @TestHTTPResource("/scl-ws/v1/SCD/get-version")
+ private URI uri;
+
+ @Test
+ void getVersionSCL_WhenCalled_ThenExpectedResponseIsRetrieved() throws Exception {
+ var encoder = new GetVersionWsRequestEncoder();
+ var sclFileTye = SclFileType.SCD;
+ var id = UUID.randomUUID();
+ var version = new Version("1.2.3");
+ var sclData = readSCL();
+
+ var request = new GetVersionWsRequest();
+ request.setId(id);
+ request.setVersion(version.toString());
+
+ when(service.findByUUID(sclFileTye, id, version)).thenReturn(sclData);
+
+ try (Session session = ContainerProvider.getWebSocketContainer().connectToServer(Client.class, uri)) {
+ session.getAsyncRemote().sendText(encoder.encode(request));
+
+ assertSclData(sclData);
+ verify(service).findByUUID(sclFileTye, id, version);
+ }
+ }
+
+ @Test
+ void getSCL_WhenCalledWithInvalidText_ThenExceptionThrown() throws Exception {
+ testWhenCalledWithInvalidTextThenExceptionThrown(uri);
+ }
+
+ @ClientEndpoint(decoders = GetWsResponseDecoder.class)
+ static class Client {
+ @OnMessage
+ public void onMessage(GetWsResponse response) {
+ sclDataQueue.add(response.getSclData());
+ }
+ }
+}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclUpdateServerEndpointAsEditorTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclUpdateServerEndpointAsEditorTest.java
new file mode 100644
index 00000000..04c397f1
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclUpdateServerEndpointAsEditorTest.java
@@ -0,0 +1,74 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1;
+
+import io.quarkus.test.common.http.TestHTTPResource;
+import io.quarkus.test.junit.QuarkusTest;
+import io.quarkus.test.junit.mockito.InjectMock;
+import org.junit.jupiter.api.Test;
+import org.lfenergy.compas.scl.data.model.ChangeSetType;
+import org.lfenergy.compas.scl.data.service.CompasSclDataService;
+import org.lfenergy.compas.scl.data.websocket.v1.decoder.UpdateWsResponseDecoder;
+import org.lfenergy.compas.scl.data.websocket.v1.encoder.UpdateWsRequestEncoder;
+import org.lfenergy.compas.scl.data.websocket.v1.model.UpdateWsRequest;
+import org.lfenergy.compas.scl.data.websocket.v1.model.UpdateWsResponse;
+import org.lfenergy.compas.scl.extensions.model.SclFileType;
+
+import javax.websocket.ClientEndpoint;
+import javax.websocket.ContainerProvider;
+import javax.websocket.OnMessage;
+import javax.websocket.Session;
+import java.net.URI;
+import java.util.UUID;
+
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@QuarkusTest
+class CompasSclUpdateServerEndpointAsEditorTest extends AbstractServerEndpointAsEditorTestSupport {
+ @InjectMock
+ private CompasSclDataService service;
+
+ @TestHTTPResource("/scl-ws/v1/SCD/update")
+ private URI uri;
+
+ @Test
+ void updateSCL_WhenCalled_ThenExpectedResponseIsRetrieved() throws Exception {
+ var encoder = new UpdateWsRequestEncoder();
+ var sclFileTye = SclFileType.SCD;
+ var id = UUID.randomUUID();
+ var cst = ChangeSetType.PATCH;
+ var comment = "Some comment";
+ var sclData = readSCL();
+
+ var request = new UpdateWsRequest();
+ request.setId(id);
+ request.setChangeSetType(cst);
+ request.setComment(comment);
+ request.setSclData(sclData);
+
+ when(service.update(sclFileTye, id, cst, USERNAME, comment, sclData))
+ .thenReturn(sclData);
+
+ try (Session session = ContainerProvider.getWebSocketContainer().connectToServer(Client.class, uri)) {
+ session.getAsyncRemote().sendText(encoder.encode(request));
+
+ assertSclData(sclData);
+ verify(service).update(sclFileTye, id, cst, USERNAME, comment, sclData);
+ }
+ }
+
+ @Test
+ void createSCL_WhenCalledWithInvalidText_ThenExceptionThrown() throws Exception {
+ testWhenCalledWithInvalidTextThenExceptionThrown(uri);
+ }
+
+ @ClientEndpoint(decoders = UpdateWsResponseDecoder.class)
+ static class Client {
+ @OnMessage
+ public void onMessage(UpdateWsResponse response) {
+ sclDataQueue.add(response.getSclData());
+ }
+ }
+}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclUpdateServerEndpointAsReaderTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclUpdateServerEndpointAsReaderTest.java
new file mode 100644
index 00000000..d0829e9c
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclUpdateServerEndpointAsReaderTest.java
@@ -0,0 +1,21 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1;
+
+import io.quarkus.test.common.http.TestHTTPResource;
+import io.quarkus.test.junit.QuarkusTest;
+import org.junit.jupiter.api.Test;
+
+import java.net.URI;
+
+@QuarkusTest
+class CompasSclUpdateServerEndpointAsReaderTest extends AbstractServerEndpointAsReaderTestSupport {
+ @TestHTTPResource("/scl-ws/v1/SCD/update")
+ private URI uri;
+
+ @Test
+ void createSCL_WhenCalled_ThenExpectedResponseIsRetrieved() {
+ testWhenForbiddenToExecute(uri);
+ }
+}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/CreateWsRequestDecoderTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/CreateWsRequestDecoderTest.java
new file mode 100644
index 00000000..f0253a10
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/CreateWsRequestDecoderTest.java
@@ -0,0 +1,72 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.decoder;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.lfenergy.compas.core.commons.exception.CompasException;
+
+import javax.xml.bind.UnmarshalException;
+
+import static org.junit.jupiter.api.Assertions.*;
+import static org.lfenergy.compas.core.commons.exception.CompasErrorCode.WEBSOCKET_DECODER_ERROR_CODE;
+import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_DATA_SERVICE_V1_NS_URI;
+
+class CreateWsRequestDecoderTest {
+ private CreateWsRequestDecoder decoder;
+
+ @BeforeEach
+ void init() {
+ decoder = new CreateWsRequestDecoder();
+ decoder.init(null);
+ }
+
+ @Test
+ void willDecode_WhenCalledWithString_ThenTrueReturned() {
+ assertTrue(decoder.willDecode(""));
+ assertTrue(decoder.willDecode("Some text"));
+ }
+
+ @Test
+ void willDecode_WhenCalledWithNull_ThenFalseReturned() {
+ assertFalse(decoder.willDecode(null));
+ }
+
+ @Test
+ void decode_WhenCalledWithCorrectRequestXML_ThenStringConvertedToObject() {
+ var sclData = "Some SCL Data";
+ var name = "Some name";
+ var comment = "Some comment";
+ var message = ""
+ + ""
+ + "" + name + ""
+ + "" + comment + ""
+ + ""
+ + "";
+
+ var result = decoder.decode(message);
+
+ assertNotNull(result);
+ assertEquals(name, result.getName());
+ assertEquals(comment, result.getComment());
+ assertEquals(sclData, result.getSclData());
+ }
+
+ @Test
+ void decode_WhenCalledWithWrongXMLType_ThenExceptionThrown() {
+ var message = ""
+ + ""
+ + "";
+
+ var exception = assertThrows(CompasException.class, () -> decoder.decode(message));
+ assertEquals(WEBSOCKET_DECODER_ERROR_CODE, exception.getErrorCode());
+ assertEquals(UnmarshalException.class, exception.getCause().getClass());
+ }
+
+ @AfterEach
+ void destroy() {
+ decoder.destroy();
+ }
+}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/CreateWsResponseDecoderTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/CreateWsResponseDecoderTest.java
new file mode 100644
index 00000000..3d2e26d5
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/CreateWsResponseDecoderTest.java
@@ -0,0 +1,66 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.decoder;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.lfenergy.compas.core.commons.exception.CompasException;
+
+import javax.xml.bind.UnmarshalException;
+
+import static org.junit.jupiter.api.Assertions.*;
+import static org.lfenergy.compas.core.commons.exception.CompasErrorCode.WEBSOCKET_DECODER_ERROR_CODE;
+import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_DATA_SERVICE_V1_NS_URI;
+
+class CreateWsResponseDecoderTest {
+ private CreateWsResponseDecoder decoder;
+
+ @BeforeEach
+ void init() {
+ decoder = new CreateWsResponseDecoder();
+ decoder.init(null);
+ }
+
+ @Test
+ void willDecode_WhenCalledWithString_ThenTrueReturned() {
+ assertTrue(decoder.willDecode(""));
+ assertTrue(decoder.willDecode("Some text"));
+ }
+
+ @Test
+ void willDecode_WhenCalledWithNull_ThenFalseReturned() {
+ assertFalse(decoder.willDecode(null));
+ }
+
+ @Test
+ void decode_WhenCalledWithCorrectRequestXML_ThenStringConvertedToObject() {
+ var sclData = "Some SCL Data";
+ var message = ""
+ + ""
+ + ""
+ + "";
+
+ var result = decoder.decode(message);
+
+ assertNotNull(result);
+ assertEquals(sclData, result.getSclData());
+ }
+
+ @Test
+ void decode_WhenCalledWithWrongXMLType_ThenExceptionThrown() {
+ var message = ""
+ + ""
+ + "";
+
+ var exception = assertThrows(CompasException.class, () -> decoder.decode(message));
+ assertEquals(WEBSOCKET_DECODER_ERROR_CODE, exception.getErrorCode());
+ assertEquals(UnmarshalException.class, exception.getCause().getClass());
+ }
+
+ @AfterEach
+ void destroy() {
+ decoder.destroy();
+ }
+}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/GetVersionWsRequestDecoderTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/GetVersionWsRequestDecoderTest.java
new file mode 100644
index 00000000..11d957d8
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/GetVersionWsRequestDecoderTest.java
@@ -0,0 +1,71 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.decoder;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.lfenergy.compas.core.commons.exception.CompasException;
+import org.lfenergy.compas.scl.data.model.Version;
+
+import javax.xml.bind.UnmarshalException;
+import java.util.UUID;
+
+import static org.junit.jupiter.api.Assertions.*;
+import static org.lfenergy.compas.core.commons.exception.CompasErrorCode.WEBSOCKET_DECODER_ERROR_CODE;
+import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_DATA_SERVICE_V1_NS_URI;
+
+class GetVersionWsRequestDecoderTest {
+ private GetVersionWsRequestDecoder decoder;
+
+ @BeforeEach
+ void init() {
+ decoder = new GetVersionWsRequestDecoder();
+ decoder.init(null);
+ }
+
+ @Test
+ void willDecode_WhenCalledWithString_ThenTrueReturned() {
+ assertTrue(decoder.willDecode(""));
+ assertTrue(decoder.willDecode("Some text"));
+ }
+
+ @Test
+ void willDecode_WhenCalledWithNull_ThenFalseReturned() {
+ assertFalse(decoder.willDecode(null));
+ }
+
+ @Test
+ void decode_WhenCalledWithCorrectRequestXML_ThenStringConvertedToObject() {
+ var id = UUID.randomUUID();
+ var version = new Version("1.2.3");
+ var message = ""
+ + ""
+ + "" + id + ""
+ + "" + version + ""
+ + "";
+
+ var result = decoder.decode(message);
+
+ assertNotNull(result);
+ assertEquals(id, result.getId());
+ assertEquals(version.toString(), result.getVersion());
+ }
+
+ @Test
+ void decode_WhenCalledWithWrongXMLType_ThenExceptionThrown() {
+ var message = ""
+ + ""
+ + "";
+
+ var exception = assertThrows(CompasException.class, () -> decoder.decode(message));
+ assertEquals(WEBSOCKET_DECODER_ERROR_CODE, exception.getErrorCode());
+ assertEquals(UnmarshalException.class, exception.getCause().getClass());
+ }
+
+ @AfterEach
+ void destroy() {
+ decoder.destroy();
+ }
+}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/GetWsRequestDecoderTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/GetWsRequestDecoderTest.java
new file mode 100644
index 00000000..58fcd263
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/GetWsRequestDecoderTest.java
@@ -0,0 +1,67 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.decoder;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.lfenergy.compas.core.commons.exception.CompasException;
+
+import javax.xml.bind.UnmarshalException;
+import java.util.UUID;
+
+import static org.junit.jupiter.api.Assertions.*;
+import static org.lfenergy.compas.core.commons.exception.CompasErrorCode.WEBSOCKET_DECODER_ERROR_CODE;
+import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_DATA_SERVICE_V1_NS_URI;
+
+class GetWsRequestDecoderTest {
+ private GetWsRequestDecoder decoder;
+
+ @BeforeEach
+ void init() {
+ decoder = new GetWsRequestDecoder();
+ decoder.init(null);
+ }
+
+ @Test
+ void willDecode_WhenCalledWithString_ThenTrueReturned() {
+ assertTrue(decoder.willDecode(""));
+ assertTrue(decoder.willDecode("Some text"));
+ }
+
+ @Test
+ void willDecode_WhenCalledWithNull_ThenFalseReturned() {
+ assertFalse(decoder.willDecode(null));
+ }
+
+ @Test
+ void decode_WhenCalledWithCorrectRequestXML_ThenStringConvertedToObject() {
+ var id = UUID.randomUUID();
+ var message = ""
+ + ""
+ + "" + id + ""
+ + "";
+
+ var result = decoder.decode(message);
+
+ assertNotNull(result);
+ assertEquals(id, result.getId());
+ }
+
+ @Test
+ void decode_WhenCalledWithWrongXMLType_ThenExceptionThrown() {
+ var message = ""
+ + ""
+ + "";
+
+ var exception = assertThrows(CompasException.class, () -> decoder.decode(message));
+ assertEquals(WEBSOCKET_DECODER_ERROR_CODE, exception.getErrorCode());
+ assertEquals(UnmarshalException.class, exception.getCause().getClass());
+ }
+
+ @AfterEach
+ void destroy() {
+ decoder.destroy();
+ }
+}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/GetWsResponseDecoderTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/GetWsResponseDecoderTest.java
new file mode 100644
index 00000000..fe1deb4d
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/GetWsResponseDecoderTest.java
@@ -0,0 +1,66 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.decoder;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.lfenergy.compas.core.commons.exception.CompasException;
+
+import javax.xml.bind.UnmarshalException;
+
+import static org.junit.jupiter.api.Assertions.*;
+import static org.lfenergy.compas.core.commons.exception.CompasErrorCode.WEBSOCKET_DECODER_ERROR_CODE;
+import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_DATA_SERVICE_V1_NS_URI;
+
+class GetWsResponseDecoderTest {
+ private GetWsResponseDecoder decoder;
+
+ @BeforeEach
+ void init() {
+ decoder = new GetWsResponseDecoder();
+ decoder.init(null);
+ }
+
+ @Test
+ void willDecode_WhenCalledWithString_ThenTrueReturned() {
+ assertTrue(decoder.willDecode(""));
+ assertTrue(decoder.willDecode("Some text"));
+ }
+
+ @Test
+ void willDecode_WhenCalledWithNull_ThenFalseReturned() {
+ assertFalse(decoder.willDecode(null));
+ }
+
+ @Test
+ void decode_WhenCalledWithCorrectRequestXML_ThenStringConvertedToObject() {
+ var sclData = "Some SCL Data";
+ var message = ""
+ + ""
+ + ""
+ + "";
+
+ var result = decoder.decode(message);
+
+ assertNotNull(result);
+ assertEquals(sclData, result.getSclData());
+ }
+
+ @Test
+ void decode_WhenCalledWithWrongXMLType_ThenExceptionThrown() {
+ var message = ""
+ + ""
+ + "";
+
+ var exception = assertThrows(CompasException.class, () -> decoder.decode(message));
+ assertEquals(WEBSOCKET_DECODER_ERROR_CODE, exception.getErrorCode());
+ assertEquals(UnmarshalException.class, exception.getCause().getClass());
+ }
+
+ @AfterEach
+ void destroy() {
+ decoder.destroy();
+ }
+}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/UpdateWsRequestDecoderTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/UpdateWsRequestDecoderTest.java
new file mode 100644
index 00000000..4beb9d89
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/UpdateWsRequestDecoderTest.java
@@ -0,0 +1,77 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.decoder;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.lfenergy.compas.core.commons.exception.CompasException;
+import org.lfenergy.compas.scl.data.model.ChangeSetType;
+
+import javax.xml.bind.UnmarshalException;
+import java.util.UUID;
+
+import static org.junit.jupiter.api.Assertions.*;
+import static org.lfenergy.compas.core.commons.exception.CompasErrorCode.WEBSOCKET_DECODER_ERROR_CODE;
+import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_DATA_SERVICE_V1_NS_URI;
+
+class UpdateWsRequestDecoderTest {
+ private UpdateWsRequestDecoder decoder;
+
+ @BeforeEach
+ void init() {
+ decoder = new UpdateWsRequestDecoder();
+ decoder.init(null);
+ }
+
+ @Test
+ void willDecode_WhenCalledWithString_ThenTrueReturned() {
+ assertTrue(decoder.willDecode(""));
+ assertTrue(decoder.willDecode("Some text"));
+ }
+
+ @Test
+ void willDecode_WhenCalledWithNull_ThenFalseReturned() {
+ assertFalse(decoder.willDecode(null));
+ }
+
+ @Test
+ void decode_WhenCalledWithCorrectRequestXML_ThenStringConvertedToObject() {
+ var sclData = "Some SCL Data";
+ var id = UUID.randomUUID();
+ var cst = ChangeSetType.MAJOR;
+ var comment = "Some comment";
+ var message = ""
+ + ""
+ + "" + id + ""
+ + "" + cst + ""
+ + "" + comment + ""
+ + ""
+ + "";
+
+ var result = decoder.decode(message);
+
+ assertNotNull(result);
+ assertEquals(id, result.getId());
+ assertEquals(cst, result.getChangeSetType());
+ assertEquals(comment, result.getComment());
+ assertEquals(sclData, result.getSclData());
+ }
+
+ @Test
+ void decode_WhenCalledWithWrongXMLType_ThenExceptionThrown() {
+ var message = ""
+ + ""
+ + "";
+
+ var exception = assertThrows(CompasException.class, () -> decoder.decode(message));
+ assertEquals(WEBSOCKET_DECODER_ERROR_CODE, exception.getErrorCode());
+ assertEquals(UnmarshalException.class, exception.getCause().getClass());
+ }
+
+ @AfterEach
+ void destroy() {
+ decoder.destroy();
+ }
+}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/UpdateWsResponseDecoderTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/UpdateWsResponseDecoderTest.java
new file mode 100644
index 00000000..55ca2a67
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/decoder/UpdateWsResponseDecoderTest.java
@@ -0,0 +1,66 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.decoder;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.lfenergy.compas.core.commons.exception.CompasException;
+
+import javax.xml.bind.UnmarshalException;
+
+import static org.junit.jupiter.api.Assertions.*;
+import static org.lfenergy.compas.core.commons.exception.CompasErrorCode.WEBSOCKET_DECODER_ERROR_CODE;
+import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_DATA_SERVICE_V1_NS_URI;
+
+class UpdateWsResponseDecoderTest {
+ private UpdateWsResponseDecoder decoder;
+
+ @BeforeEach
+ void init() {
+ decoder = new UpdateWsResponseDecoder();
+ decoder.init(null);
+ }
+
+ @Test
+ void willDecode_WhenCalledWithString_ThenTrueReturned() {
+ assertTrue(decoder.willDecode(""));
+ assertTrue(decoder.willDecode("Some text"));
+ }
+
+ @Test
+ void willDecode_WhenCalledWithNull_ThenFalseReturned() {
+ assertFalse(decoder.willDecode(null));
+ }
+
+ @Test
+ void decode_WhenCalledWithCorrectRequestXML_ThenStringConvertedToObject() {
+ var sclData = "Some SCL Data";
+ var message = ""
+ + ""
+ + ""
+ + "";
+
+ var result = decoder.decode(message);
+
+ assertNotNull(result);
+ assertEquals(sclData, result.getSclData());
+ }
+
+ @Test
+ void decode_WhenCalledWithWrongXMLType_ThenExceptionThrown() {
+ var message = ""
+ + ""
+ + "";
+
+ var exception = assertThrows(CompasException.class, () -> decoder.decode(message));
+ assertEquals(WEBSOCKET_DECODER_ERROR_CODE, exception.getErrorCode());
+ assertEquals(UnmarshalException.class, exception.getCause().getClass());
+ }
+
+ @AfterEach
+ void destroy() {
+ decoder.destroy();
+ }
+}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/CreateWsRequestEncoderTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/CreateWsRequestEncoderTest.java
new file mode 100644
index 00000000..e9085761
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/CreateWsRequestEncoderTest.java
@@ -0,0 +1,51 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.encoder;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.lfenergy.compas.scl.data.websocket.v1.model.CreateWsRequest;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_DATA_SERVICE_V1_NS_URI;
+
+class CreateWsRequestEncoderTest {
+ private CreateWsRequestEncoder encoder;
+
+ @BeforeEach
+ void init() {
+ encoder = new CreateWsRequestEncoder();
+ encoder.init(null);
+ }
+
+ @Test
+ void encode_WhenCalledWithRequest_ThenRequestConvertedToString() {
+ var sclData = "Some SCL Data";
+ var name = "Some name";
+ var comment = "Some comment";
+
+ var request = new CreateWsRequest();
+ request.setName(name);
+ request.setComment(comment);
+ request.setSclData(sclData);
+
+ var result = encoder.encode(request);
+
+ var expectedResult = "" +
+ "" +
+ "" + name + "" +
+ "" + comment + "" +
+ "" + sclData + "" +
+ "";
+ assertNotNull(result);
+ assertEquals(expectedResult, result);
+ }
+
+ @AfterEach
+ void destroy() {
+ encoder.destroy();
+ }
+}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/CreateWsResponseEncoderTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/CreateWsResponseEncoderTest.java
new file mode 100644
index 00000000..4e312084
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/CreateWsResponseEncoderTest.java
@@ -0,0 +1,45 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.encoder;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.lfenergy.compas.scl.data.websocket.v1.model.CreateWsResponse;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_DATA_SERVICE_V1_NS_URI;
+
+class CreateWsResponseEncoderTest {
+ private CreateWsResponseEncoder encoder;
+
+ @BeforeEach
+ void init() {
+ encoder = new CreateWsResponseEncoder();
+ encoder.init(null);
+ }
+
+ @Test
+ void encode_WhenCalledWithRequest_ThenRequestConvertedToString() {
+ var sclData = "Some SCL Data";
+
+ var request = new CreateWsResponse();
+ request.setSclData(sclData);
+
+ var result = encoder.encode(request);
+
+ var expectedResult = "" +
+ "" +
+ "" + sclData + "" +
+ "";
+ assertNotNull(result);
+ assertEquals(expectedResult, result);
+ }
+
+ @AfterEach
+ void destroy() {
+ encoder.destroy();
+ }
+}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/GetVersionWsRequestEncoderTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/GetVersionWsRequestEncoderTest.java
new file mode 100644
index 00000000..df8e8ddf
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/GetVersionWsRequestEncoderTest.java
@@ -0,0 +1,51 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.encoder;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.lfenergy.compas.scl.data.model.Version;
+import org.lfenergy.compas.scl.data.websocket.v1.model.GetVersionWsRequest;
+
+import java.util.UUID;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_DATA_SERVICE_V1_NS_URI;
+
+class GetVersionWsRequestEncoderTest {
+ private GetVersionWsRequestEncoder encoder;
+
+ @BeforeEach
+ void init() {
+ encoder = new GetVersionWsRequestEncoder();
+ encoder.init(null);
+ }
+
+ @Test
+ void encode_WhenCalledWithRequest_ThenRequestConvertedToString() {
+ var id = UUID.randomUUID();
+ var version = new Version("1.2.3");
+
+ var request = new GetVersionWsRequest();
+ request.setId(id);
+ request.setVersion(version.toString());
+
+ var result = encoder.encode(request);
+
+ var expectedResult = "" +
+ "" +
+ "" + id + "" +
+ "" + version + "" +
+ "";
+ assertNotNull(result);
+ assertEquals(expectedResult, result);
+ }
+
+ @AfterEach
+ void destroy() {
+ encoder.destroy();
+ }
+}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/GetWsRequestEncoderTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/GetWsRequestEncoderTest.java
new file mode 100644
index 00000000..eafe034f
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/GetWsRequestEncoderTest.java
@@ -0,0 +1,47 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.encoder;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.lfenergy.compas.scl.data.websocket.v1.model.GetWsRequest;
+
+import java.util.UUID;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_DATA_SERVICE_V1_NS_URI;
+
+class GetWsRequestEncoderTest {
+ private GetWsRequestEncoder encoder;
+
+ @BeforeEach
+ void init() {
+ encoder = new GetWsRequestEncoder();
+ encoder.init(null);
+ }
+
+ @Test
+ void encode_WhenCalledWithRequest_ThenRequestConvertedToString() {
+ var id = UUID.randomUUID();
+
+ var request = new GetWsRequest();
+ request.setId(id);
+
+ var result = encoder.encode(request);
+
+ var expectedResult = "" +
+ "" +
+ "" + id + "" +
+ "";
+ assertNotNull(result);
+ assertEquals(expectedResult, result);
+ }
+
+ @AfterEach
+ void destroy() {
+ encoder.destroy();
+ }
+}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/GetWsResponseEncoderTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/GetWsResponseEncoderTest.java
new file mode 100644
index 00000000..1770a984
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/GetWsResponseEncoderTest.java
@@ -0,0 +1,45 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.encoder;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.lfenergy.compas.scl.data.websocket.v1.model.GetWsResponse;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_DATA_SERVICE_V1_NS_URI;
+
+class GetWsResponseEncoderTest {
+ private GetWsResponseEncoder encoder;
+
+ @BeforeEach
+ void init() {
+ encoder = new GetWsResponseEncoder();
+ encoder.init(null);
+ }
+
+ @Test
+ void encode_WhenCalledWithRequest_ThenRequestConvertedToString() {
+ var sclData = "Some SCL Data";
+
+ var request = new GetWsResponse();
+ request.setSclData(sclData);
+
+ var result = encoder.encode(request);
+
+ var expectedResult = "" +
+ "" +
+ "" + sclData + "" +
+ "";
+ assertNotNull(result);
+ assertEquals(expectedResult, result);
+ }
+
+ @AfterEach
+ void destroy() {
+ encoder.destroy();
+ }
+}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/UpdateWsRequestEncoderTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/UpdateWsRequestEncoderTest.java
new file mode 100644
index 00000000..5e2a3e30
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/UpdateWsRequestEncoderTest.java
@@ -0,0 +1,57 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.encoder;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.lfenergy.compas.scl.data.model.ChangeSetType;
+import org.lfenergy.compas.scl.data.websocket.v1.model.UpdateWsRequest;
+
+import java.util.UUID;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_DATA_SERVICE_V1_NS_URI;
+
+class UpdateWsRequestEncoderTest {
+ private UpdateWsRequestEncoder encoder;
+
+ @BeforeEach
+ void init() {
+ encoder = new UpdateWsRequestEncoder();
+ encoder.init(null);
+ }
+
+ @Test
+ void encode_WhenCalledWithRequest_ThenRequestConvertedToString() {
+ var sclData = "Some SCL Data";
+ var id = UUID.randomUUID();
+ var cst = ChangeSetType.MAJOR;
+ var comment = "Some comment";
+
+ var request = new UpdateWsRequest();
+ request.setId(id);
+ request.setChangeSetType(cst);
+ request.setComment(comment);
+ request.setSclData(sclData);
+
+ var result = encoder.encode(request);
+
+ var expectedResult = "" +
+ "" +
+ "" + cst + "" +
+ "" + comment + "" +
+ "" + sclData + "" +
+ "" + id + "" +
+ "";
+ assertNotNull(result);
+ assertEquals(expectedResult, result);
+ }
+
+ @AfterEach
+ void destroy() {
+ encoder.destroy();
+ }
+}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/UpdateWsResponseEncoderTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/UpdateWsResponseEncoderTest.java
new file mode 100644
index 00000000..ce703078
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/encoder/UpdateWsResponseEncoderTest.java
@@ -0,0 +1,45 @@
+// SPDX-FileCopyrightText: 2022 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.encoder;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.lfenergy.compas.scl.data.websocket.v1.model.UpdateWsResponse;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_DATA_SERVICE_V1_NS_URI;
+
+class UpdateWsResponseEncoderTest {
+ private UpdateWsResponseEncoder encoder;
+
+ @BeforeEach
+ void init() {
+ encoder = new UpdateWsResponseEncoder();
+ encoder.init(null);
+ }
+
+ @Test
+ void encode_WhenCalledWithRequest_ThenRequestConvertedToString() {
+ var sclData = "Some SCL Data";
+
+ var request = new UpdateWsResponse();
+ request.setSclData(sclData);
+
+ var result = encoder.encode(request);
+
+ var expectedResult = "" +
+ "" +
+ "" + sclData + "" +
+ "";
+ assertNotNull(result);
+ assertEquals(expectedResult, result);
+ }
+
+ @AfterEach
+ void destroy() {
+ encoder.destroy();
+ }
+}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/model/AbstractPojoTester.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/model/AbstractPojoTester.java
new file mode 100644
index 00000000..8165a364
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/model/AbstractPojoTester.java
@@ -0,0 +1,32 @@
+// SPDX-FileCopyrightText: 2021 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.model;
+
+import com.openpojo.reflection.impl.PojoClassFactory;
+import com.openpojo.validation.ValidatorBuilder;
+import com.openpojo.validation.rule.impl.GetterMustExistRule;
+import com.openpojo.validation.rule.impl.SetterMustExistRule;
+import com.openpojo.validation.test.impl.GetterTester;
+import com.openpojo.validation.test.impl.SetterTester;
+import org.junit.jupiter.api.Test;
+
+abstract class AbstractPojoTester {
+ @Test
+ void validateSettersAndGetters() {
+ var personPojo = PojoClassFactory.getPojoClass(getClassToBeTested());
+ var validator = ValidatorBuilder.create()
+ // Let's make sure that we have a getter and a setter for every field defined.
+ .with(new GetterMustExistRule())
+ .with(new SetterMustExistRule())
+ // Let's also validate that they are behaving as expected
+ .with(new SetterTester())
+ .with(new GetterTester())
+ .build();
+
+ // Start the Test
+ validator.validate(personPojo);
+ }
+
+ protected abstract Class> getClassToBeTested();
+}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/model/CreateWsRequestTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/model/CreateWsRequestTest.java
new file mode 100644
index 00000000..77e4a130
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/model/CreateWsRequestTest.java
@@ -0,0 +1,11 @@
+// SPDX-FileCopyrightText: 2021 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.model;
+
+class CreateWsRequestTest extends AbstractPojoTester {
+ @Override
+ protected Class> getClassToBeTested() {
+ return CreateWsRequest.class;
+ }
+}
\ No newline at end of file
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/model/CreateWsResponseTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/model/CreateWsResponseTest.java
new file mode 100644
index 00000000..3ae73849
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/model/CreateWsResponseTest.java
@@ -0,0 +1,11 @@
+// SPDX-FileCopyrightText: 2021 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.model;
+
+class CreateWsResponseTest extends AbstractPojoTester {
+ @Override
+ protected Class> getClassToBeTested() {
+ return CreateWsResponse.class;
+ }
+}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/model/GetVersionWsRequestTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/model/GetVersionWsRequestTest.java
new file mode 100644
index 00000000..8f7c493d
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/model/GetVersionWsRequestTest.java
@@ -0,0 +1,11 @@
+// SPDX-FileCopyrightText: 2021 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.model;
+
+class GetVersionWsRequestTest extends AbstractPojoTester {
+ @Override
+ protected Class> getClassToBeTested() {
+ return GetVersionWsRequest.class;
+ }
+}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/model/GetWsRequestTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/model/GetWsRequestTest.java
new file mode 100644
index 00000000..a78ca3f2
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/model/GetWsRequestTest.java
@@ -0,0 +1,11 @@
+// SPDX-FileCopyrightText: 2021 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.model;
+
+class GetWsRequestTest extends AbstractPojoTester {
+ @Override
+ protected Class> getClassToBeTested() {
+ return GetWsRequest.class;
+ }
+}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/model/GetWsResponseTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/model/GetWsResponseTest.java
new file mode 100644
index 00000000..1ae4eb93
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/model/GetWsResponseTest.java
@@ -0,0 +1,11 @@
+// SPDX-FileCopyrightText: 2021 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.model;
+
+class GetWsResponseTest extends AbstractPojoTester {
+ @Override
+ protected Class> getClassToBeTested() {
+ return GetWsResponse.class;
+ }
+}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/model/UpdateWsRequestTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/model/UpdateWsRequestTest.java
new file mode 100644
index 00000000..3eb59399
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/model/UpdateWsRequestTest.java
@@ -0,0 +1,11 @@
+// SPDX-FileCopyrightText: 2021 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.model;
+
+class UpdateWsRequestTest extends AbstractPojoTester {
+ @Override
+ protected Class> getClassToBeTested() {
+ return UpdateWsRequest.class;
+ }
+}
diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/model/UpdateWsResponseTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/model/UpdateWsResponseTest.java
new file mode 100644
index 00000000..5ab6d28b
--- /dev/null
+++ b/app/src/test/java/org/lfenergy/compas/scl/data/websocket/v1/model/UpdateWsResponseTest.java
@@ -0,0 +1,11 @@
+// SPDX-FileCopyrightText: 2021 Alliander N.V.
+//
+// SPDX-License-Identifier: Apache-2.0
+package org.lfenergy.compas.scl.data.websocket.v1.model;
+
+class UpdateWsResponseTest extends AbstractPojoTester {
+ @Override
+ protected Class> getClassToBeTested() {
+ return UpdateWsResponse.class;
+ }
+}
diff --git a/pom.xml b/pom.xml
index 6f1823af..ae730342 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,10 +23,10 @@ SPDX-License-Identifier: Apache-2.0
3.0.0-M7
3.2.0
- 0.9.3
+ 0.10.2
- 2.13.0.Final
- 2.3.6
+ 2.14.0.Final
+ 2.3.7
3.0
2.0.3
0.9.1
@@ -99,7 +99,12 @@ SPDX-License-Identifier: Apache-2.0
org.lfenergy.compas.core
- jaxrs-commons
+ rest-commons
+ ${compas.core.version}
+
+
+ org.lfenergy.compas.core
+ websocket-commons
${compas.core.version}
diff --git a/repository/src/test/java/org/lfenergy/compas/scl/data/util/SclElementProcessorTest.java b/repository/src/test/java/org/lfenergy/compas/scl/data/util/SclElementProcessorTest.java
index d5930ffc..0191a302 100644
--- a/repository/src/test/java/org/lfenergy/compas/scl/data/util/SclElementProcessorTest.java
+++ b/repository/src/test/java/org/lfenergy/compas/scl/data/util/SclElementProcessorTest.java
@@ -202,40 +202,39 @@ void cleanupHistoryItem_WhenCalledWithVersion_ThenSameAndNewerVersionsAreRemoved
@Test
void shouldRemoveHItem_WhenCalledWithInvalidVersion_ThenFalseReturned() {
- var scl = readSCL("scl_cleanup_history.scd");
- var hItem = getHItem(scl, "Siemens");
-
- assertFalse(processor.shouldRemoveHItem(hItem, new Version("1.0.2")));
+ executeShouldRemoveHItemWhenCalledThenFalseReturned("Siemens");
}
@Test
void shouldRemoveHItem_WhenCalledWithEmptyVersion_ThenFalseReturned() {
- var scl = readSCL("scl_cleanup_history.scd");
- var hItem = getHItem(scl, "Empty");
-
- assertFalse(processor.shouldRemoveHItem(hItem, new Version("1.0.2")));
+ executeShouldRemoveHItemWhenCalledThenFalseReturned("Empty");
}
@Test
void shouldRemoveHItem_WhenCalledWithOlderVersion_ThenFalseReturned() {
+ executeShouldRemoveHItemWhenCalledThenFalseReturned("Created");
+ }
+
+ private void executeShouldRemoveHItemWhenCalledThenFalseReturned(String what) {
var scl = readSCL("scl_cleanup_history.scd");
- var hItem = getHItem(scl, "Created");
+ var hItem = getHItem(scl, what);
assertFalse(processor.shouldRemoveHItem(hItem, new Version("1.0.2")));
}
@Test
void shouldRemoveHItem_WhenCalledWithSameVersion_ThenTrueReturned() {
- var scl = readSCL("scl_cleanup_history.scd");
- var hItem = getHItem(scl, "Updated 1");
-
- assertTrue(processor.shouldRemoveHItem(hItem, new Version("1.0.2")));
+ executeShouldRemoveHItemWhenCalledThenTrueReturned("Updated 1");
}
@Test
void shouldRemoveHItem_WhenCalledWithNewerVersion_ThenTrueReturned() {
+ executeShouldRemoveHItemWhenCalledThenTrueReturned("Updated 2");
+ }
+
+ private void executeShouldRemoveHItemWhenCalledThenTrueReturned(String what) {
var scl = readSCL("scl_cleanup_history.scd");
- var hItem = getHItem(scl, "Updated 2");
+ var hItem = getHItem(scl, what);
assertTrue(processor.shouldRemoveHItem(hItem, new Version("1.0.2")));
}
diff --git a/service/src/test/java/org/lfenergy/compas/scl/data/service/CompasSclDataServiceTest.java b/service/src/test/java/org/lfenergy/compas/scl/data/service/CompasSclDataServiceTest.java
index 926d487d..919bc92b 100644
--- a/service/src/test/java/org/lfenergy/compas/scl/data/service/CompasSclDataServiceTest.java
+++ b/service/src/test/java/org/lfenergy/compas/scl/data/service/CompasSclDataServiceTest.java
@@ -60,7 +60,7 @@ void list_WhenCalled_ThenRepositoryIsCalled() {
var result = compasSclDataService.list(SCL_TYPE);
assertNotNull(result);
- verify(compasSclDataRepository, times(1)).list(SCL_TYPE);
+ verify(compasSclDataRepository).list(SCL_TYPE);
}
@Test
@@ -74,7 +74,7 @@ void listVersionsByUUID_WhenCalledAndRepositoryReturnItemList_ThenListIsReturned
assertNotNull(result);
assertEquals(expectedResult.size(), result.size());
assertEquals(expectedResult.get(0), result.get(0));
- verify(compasSclDataRepository, times(1)).listVersionsByUUID(SCL_TYPE, uuid);
+ verify(compasSclDataRepository).listVersionsByUUID(SCL_TYPE, uuid);
}
@Test
@@ -86,7 +86,7 @@ void listVersionsByUUID_WhenCalledAndRepositoryReturnsEmptyList_ThenExceptionIsT
compasSclDataService.listVersionsByUUID(SCL_TYPE, uuid);
});
assertEquals(NO_DATA_FOUND_ERROR_CODE, exception.getErrorCode());
- verify(compasSclDataRepository, times(1)).listVersionsByUUID(SCL_TYPE, uuid);
+ verify(compasSclDataRepository).listVersionsByUUID(SCL_TYPE, uuid);
}
@Test
@@ -97,7 +97,7 @@ void findByUUID_WhenCalledWithoutVersion_ThenRepositoryIsCalled() throws IOExcep
var result = compasSclDataService.findByUUID(SCL_TYPE, uuid);
assertNotNull(result);
- verify(compasSclDataRepository, times(1)).findByUUID(SCL_TYPE, uuid);
+ verify(compasSclDataRepository).findByUUID(SCL_TYPE, uuid);
}
@Test
@@ -109,7 +109,7 @@ void findByUUID_WhenCalledWithVersion_ThenRepositoryIsCalled() throws IOExceptio
var result = compasSclDataService.findByUUID(SCL_TYPE, uuid, version);
assertNotNull(result);
- verify(compasSclDataRepository, times(1)).findByUUID(SCL_TYPE, uuid, version);
+ verify(compasSclDataRepository).findByUUID(SCL_TYPE, uuid, version);
}
@Test
@@ -128,8 +128,8 @@ void create_WhenCalledWithOutCompasExtension_ThenSCLReturnedWithCorrectCompasExt
assertNotNull(scl);
assertCompasExtension(scl, name);
assertHistoryItem(scl, 2, INITIAL_VERSION, comment);
- verify(compasSclDataRepository, times(1)).create(eq(SCL_TYPE), any(UUID.class), eq(name), anyString(), eq(INITIAL_VERSION), eq(who), eq(emptyList()));
- verify(compasSclDataRepository, times(1)).hasDuplicateSclName(SCL_TYPE, name);
+ verify(compasSclDataRepository).create(eq(SCL_TYPE), any(UUID.class), eq(name), anyString(), eq(INITIAL_VERSION), eq(who), eq(emptyList()));
+ verify(compasSclDataRepository).hasDuplicateSclName(SCL_TYPE, name);
}
@Test
@@ -149,8 +149,8 @@ void create_WhenCalledWithCompasExtension_ThenSCLReturnedWithCorrectCompasExtens
assertNotNull(scl);
assertCompasExtension(scl, name);
assertHistoryItem(scl, 2, INITIAL_VERSION, comment);
- verify(compasSclDataRepository, times(1)).create(eq(SCL_TYPE), any(UUID.class), eq(name), anyString(), eq(INITIAL_VERSION), eq(who), eq(emptyList()));
- verify(compasSclDataRepository, times(1)).hasDuplicateSclName(SCL_TYPE, name);
+ verify(compasSclDataRepository).create(eq(SCL_TYPE), any(UUID.class), eq(name), anyString(), eq(INITIAL_VERSION), eq(who), eq(emptyList()));
+ verify(compasSclDataRepository).hasDuplicateSclName(SCL_TYPE, name);
}
@Test
@@ -166,7 +166,7 @@ void create_WhenCalledWithDuplicateSclName_ThenCompasExceptionThrown() throws IO
compasSclDataService.create(SCL_TYPE, name, who, comment, scl);
});
assertEquals(DUPLICATE_SCL_NAME_ERROR_CODE, exception.getErrorCode());
- verify(compasSclDataRepository, times(1)).hasDuplicateSclName(SCL_TYPE, name);
+ verify(compasSclDataRepository).hasDuplicateSclName(SCL_TYPE, name);
}
@Test
@@ -202,8 +202,8 @@ void update_WhenCalledWithoutCompasElements_ThenSCLReturnedWithCorrectCompasExte
assertNotNull(scl);
assertCompasExtension(scl, previousName);
assertHistoryItem(scl, 4, nextVersion, null);
- verify(compasSclDataRepository, times(1)).create(eq(SCL_TYPE), eq(uuid), eq(previousName), anyString(), eq(nextVersion), eq(who), eq(emptyList()));
- verify(compasSclDataRepository, times(1)).findMetaInfoByUUID(SCL_TYPE, uuid);
+ verify(compasSclDataRepository).create(eq(SCL_TYPE), eq(uuid), eq(previousName), anyString(), eq(nextVersion), eq(who), eq(emptyList()));
+ verify(compasSclDataRepository).findMetaInfoByUUID(SCL_TYPE, uuid);
verify(compasSclDataRepository, never()).hasDuplicateSclName(SCL_TYPE, previousName);
}
@@ -229,9 +229,9 @@ void update_WhenCalledWithCompasElementsAndNewName_ThenSCLReturnedWithCorrectCom
assertNotNull(scl);
assertCompasExtension(scl, newName);
assertHistoryItem(scl, 4, nextVersion, null);
- verify(compasSclDataRepository, times(1)).create(eq(SCL_TYPE), eq(uuid), eq(newName), anyString(), eq(nextVersion), eq(who), eq(emptyList()));
- verify(compasSclDataRepository, times(1)).findMetaInfoByUUID(SCL_TYPE, uuid);
- verify(compasSclDataRepository, times(1)).hasDuplicateSclName(SCL_TYPE, newName);
+ verify(compasSclDataRepository).create(eq(SCL_TYPE), eq(uuid), eq(newName), anyString(), eq(nextVersion), eq(who), eq(emptyList()));
+ verify(compasSclDataRepository).findMetaInfoByUUID(SCL_TYPE, uuid);
+ verify(compasSclDataRepository).hasDuplicateSclName(SCL_TYPE, newName);
}
@Test
@@ -252,8 +252,8 @@ void update_WhenCalledWithCompasElementsAndDuplicateNewName_ThenCompasExceptionT
compasSclDataService.update(SCL_TYPE, uuid, changeSet, who, null, scl);
});
assertEquals(DUPLICATE_SCL_NAME_ERROR_CODE, exception.getErrorCode());
- verify(compasSclDataRepository, times(1)).findMetaInfoByUUID(SCL_TYPE, uuid);
- verify(compasSclDataRepository, times(1)).hasDuplicateSclName(SCL_TYPE, newName);
+ verify(compasSclDataRepository).findMetaInfoByUUID(SCL_TYPE, uuid);
+ verify(compasSclDataRepository).hasDuplicateSclName(SCL_TYPE, newName);
}
@Test
@@ -276,8 +276,8 @@ void update_WhenCalledWithCompasElementsAndSameName_ThenSCLReturnedWithCorrectCo
assertNotNull(scl);
assertCompasExtension(scl, previousName);
assertHistoryItem(scl, 4, nextVersion, null);
- verify(compasSclDataRepository, times(1)).create(eq(SCL_TYPE), eq(uuid), eq(previousName), anyString(), eq(nextVersion), eq(who), eq(emptyList()));
- verify(compasSclDataRepository, times(1)).findMetaInfoByUUID(SCL_TYPE, uuid);
+ verify(compasSclDataRepository).create(eq(SCL_TYPE), eq(uuid), eq(previousName), anyString(), eq(nextVersion), eq(who), eq(emptyList()));
+ verify(compasSclDataRepository).findMetaInfoByUUID(SCL_TYPE, uuid);
verify(compasSclDataRepository, never()).hasDuplicateSclName(SCL_TYPE, previousName);
}
@@ -303,7 +303,7 @@ void delete_WhenCalledWithoutVersion_ThenRepositoryIsCalled() {
compasSclDataService.delete(SCL_TYPE, uuid);
- verify(compasSclDataRepository, times(1)).delete(SCL_TYPE, uuid);
+ verify(compasSclDataRepository).delete(SCL_TYPE, uuid);
}
@Test
@@ -315,7 +315,7 @@ void delete_WhenCalledWithVersion_ThenRepositoryIsCalled() {
compasSclDataService.delete(SCL_TYPE, uuid, version);
- verify(compasSclDataRepository, times(1)).delete(SCL_TYPE, uuid, version);
+ verify(compasSclDataRepository).delete(SCL_TYPE, uuid, version);
}
@Test