From 8915a348995ee356bc0ae8ea7edbeee63ac60895 Mon Sep 17 00:00:00 2001 From: Tim Dahlmanns Date: Wed, 19 Jun 2024 16:29:21 +0200 Subject: [PATCH] fix(data-plane-selector-control-api): getAllDataPlaneInstances endpoint --- .../api/DataplaneSelectorControlApiExtension.java | 10 ++++++++++ .../api/DataplaneSelectorControlApiExtensionTest.java | 3 +++ 2 files changed, 13 insertions(+) diff --git a/extensions/data-plane-selector/data-plane-selector-control-api/src/main/java/org/eclipse/edc/connector/dataplane/selector/control/api/DataplaneSelectorControlApiExtension.java b/extensions/data-plane-selector/data-plane-selector-control-api/src/main/java/org/eclipse/edc/connector/dataplane/selector/control/api/DataplaneSelectorControlApiExtension.java index f53450af5bb..b7b2c8de597 100644 --- a/extensions/data-plane-selector/data-plane-selector-control-api/src/main/java/org/eclipse/edc/connector/dataplane/selector/control/api/DataplaneSelectorControlApiExtension.java +++ b/extensions/data-plane-selector/data-plane-selector-control-api/src/main/java/org/eclipse/edc/connector/dataplane/selector/control/api/DataplaneSelectorControlApiExtension.java @@ -9,6 +9,7 @@ * * Contributors: * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation + * Fraunhofer Institute for Software and Systems Engineering - Bugfix * */ @@ -19,16 +20,21 @@ import org.eclipse.edc.runtime.metamodel.annotation.Inject; import org.eclipse.edc.spi.system.ServiceExtension; import org.eclipse.edc.spi.system.ServiceExtensionContext; +import org.eclipse.edc.spi.types.TypeManager; import org.eclipse.edc.transform.spi.TypeTransformerRegistry; +import org.eclipse.edc.transform.transformer.edc.from.JsonObjectFromDataPlaneInstanceTransformer; import org.eclipse.edc.transform.transformer.edc.to.JsonObjectToDataPlaneInstanceTransformer; import org.eclipse.edc.validator.spi.JsonObjectValidatorRegistry; import org.eclipse.edc.web.spi.WebService; import org.eclipse.edc.web.spi.configuration.ApiContext; import java.time.Clock; +import java.util.Map; +import static jakarta.json.Json.createBuilderFactory; import static org.eclipse.edc.connector.dataplane.selector.control.api.DataplaneSelectorControlApiExtension.NAME; import static org.eclipse.edc.connector.dataplane.selector.spi.instance.DataPlaneInstance.DATAPLANE_INSTANCE_TYPE; +import static org.eclipse.edc.spi.constants.CoreConstants.JSON_LD; @Extension(NAME) public class DataplaneSelectorControlApiExtension implements ServiceExtension { @@ -41,6 +47,9 @@ public class DataplaneSelectorControlApiExtension implements ServiceExtension { @Inject private JsonObjectValidatorRegistry validatorRegistry; + @Inject + private TypeManager typeManager; + @Inject private TypeTransformerRegistry typeTransformerRegistry; @@ -60,6 +69,7 @@ public void initialize(ServiceExtensionContext context) { validatorRegistry.register(DATAPLANE_INSTANCE_TYPE, DataPlaneInstanceValidator.instance()); typeTransformerRegistry.register(new JsonObjectToDataPlaneInstanceTransformer()); + typeTransformerRegistry.register(new JsonObjectFromDataPlaneInstanceTransformer(createBuilderFactory(Map.of()), typeManager.getMapper(JSON_LD))); var controller = new DataplaneSelectorControlApiController(validatorRegistry, typeTransformerRegistry, dataPlaneSelectorService, clock); webService.registerResource(ApiContext.CONTROL, controller); diff --git a/extensions/data-plane-selector/data-plane-selector-control-api/src/test/java/org/eclipse/edc/connector/dataplane/selector/control/api/DataplaneSelectorControlApiExtensionTest.java b/extensions/data-plane-selector/data-plane-selector-control-api/src/test/java/org/eclipse/edc/connector/dataplane/selector/control/api/DataplaneSelectorControlApiExtensionTest.java index 40c60ac2604..e732867e947 100644 --- a/extensions/data-plane-selector/data-plane-selector-control-api/src/test/java/org/eclipse/edc/connector/dataplane/selector/control/api/DataplaneSelectorControlApiExtensionTest.java +++ b/extensions/data-plane-selector/data-plane-selector-control-api/src/test/java/org/eclipse/edc/connector/dataplane/selector/control/api/DataplaneSelectorControlApiExtensionTest.java @@ -9,6 +9,7 @@ * * Contributors: * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation + * Fraunhofer Institute for Software and Systems Engineering - Bugfix * */ @@ -18,6 +19,7 @@ import org.eclipse.edc.junit.extensions.DependencyInjectionExtension; import org.eclipse.edc.spi.system.ServiceExtensionContext; import org.eclipse.edc.transform.spi.TypeTransformerRegistry; +import org.eclipse.edc.transform.transformer.edc.from.JsonObjectFromDataPlaneInstanceTransformer; import org.eclipse.edc.transform.transformer.edc.to.JsonObjectToDataPlaneInstanceTransformer; import org.eclipse.edc.validator.jsonobject.JsonObjectValidator; import org.eclipse.edc.validator.spi.JsonObjectValidatorRegistry; @@ -65,5 +67,6 @@ void shouldRegisterTransformers(DataplaneSelectorControlApiExtension extension, extension.initialize(context); verify(typeTransformerRegistry).register(isA(JsonObjectToDataPlaneInstanceTransformer.class)); + verify(typeTransformerRegistry).register(isA(JsonObjectFromDataPlaneInstanceTransformer.class)); } }