diff --git a/src/controllers/management-controllers/dataplane-controller.ts b/src/controllers/management-controllers/dataplane-controller.ts index 107d8e31..e47eb38d 100644 --- a/src/controllers/management-controllers/dataplane-controller.ts +++ b/src/controllers/management-controllers/dataplane-controller.ts @@ -1,8 +1,10 @@ import { EdcConnectorClientContext } from "../../context"; import { + expand, expandArray, Dataplane, DataplaneInput, + IdResponse, EDC_CONTEXT, } from "../../entities"; import { Inner } from "../../inner"; @@ -22,7 +24,7 @@ export class DataplaneController { async register( input: DataplaneInput, context?: EdcConnectorClientContext, - ): Promise { + ): Promise { const actualContext = context || this.#context!; return this.#inner.request(actualContext.management, { @@ -33,12 +35,13 @@ export class DataplaneController { ...input, "@context": this.defaultContextValues, }, - }); + }) + .then((body) => expand(body, () => new IdResponse())); } async list(context?: EdcConnectorClientContext): Promise { const actualContext = context || this.#context!; - + return this.#inner .request(actualContext.management, { path: "/v2/dataplanes", diff --git a/tests/controllers/management-tests/dataplanes.test.ts b/tests/controllers/management-tests/dataplanes.test.ts index 37b6d1de..dd98ec24 100644 --- a/tests/controllers/management-tests/dataplanes.test.ts +++ b/tests/controllers/management-tests/dataplanes.test.ts @@ -1,3 +1,4 @@ +import * as crypto from "node:crypto"; import { EdcConnectorClient } from "../../../src"; describe("DataplaneController", () => { @@ -12,8 +13,9 @@ describe("DataplaneController", () => { describe("register", () => { it("succesfully register a dataplane", async () => { + const id = crypto.randomUUID(); const input = { - id: "consumer-dataplane", + "@id": id, url: "http://provider-connector:9192/control/transfer", allowedSourceTypes: ["HttpData"], allowedDestTypes: ["HttpProxy", "HttpData"], @@ -22,9 +24,10 @@ describe("DataplaneController", () => { }, }; - const registration = await dataplanes.register(input); + const idResponse = await dataplanes.register(input); - expect(registration).toBeUndefined(); + expect(idResponse.id).toBe(id); + expect(idResponse.createdAt).toBeGreaterThan(0); }); });