Skip to content

Commit

Permalink
fix(data-plane-selector-control-api): getAllDataPlaneInstances endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
timdah committed Jun 20, 2024
1 parent 8c47051 commit f1880cf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*
* Contributors:
* Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation
* Fraunhofer Institute for Software and Systems Engineering - register missing transformer
*
*/

Expand All @@ -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 {
Expand All @@ -41,6 +47,9 @@ public class DataplaneSelectorControlApiExtension implements ServiceExtension {
@Inject
private JsonObjectValidatorRegistry validatorRegistry;

@Inject
private TypeManager typeManager;

@Inject
private TypeTransformerRegistry typeTransformerRegistry;

Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*
* Contributors:
* Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation
* Fraunhofer Institute for Software and Systems Engineering - register missing transformer
*
*/

Expand All @@ -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;
Expand Down Expand Up @@ -65,5 +67,6 @@ void shouldRegisterTransformers(DataplaneSelectorControlApiExtension extension,
extension.initialize(context);

verify(typeTransformerRegistry).register(isA(JsonObjectToDataPlaneInstanceTransformer.class));
verify(typeTransformerRegistry).register(isA(JsonObjectFromDataPlaneInstanceTransformer.class));
}
}

0 comments on commit f1880cf

Please sign in to comment.