Skip to content

Commit

Permalink
chore: switched to v4alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
wolf4ood committed Nov 25, 2024
1 parent 29bf34a commit cf82267
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ public interface ManagementApi {

String MANAGEMENT_API_CONTEXT = "management-api";

String MANAGEMENT_API_V_3_1_ALPHA = "v3.1-alpha";
String MANAGEMENT_API_V_4_ALPHA = "v4alpha";
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
import static java.lang.String.format;
import static java.util.Optional.ofNullable;
import static org.eclipse.edc.api.management.ManagementApi.MANAGEMENT_API_CONTEXT;
import static org.eclipse.edc.api.management.ManagementApi.MANAGEMENT_API_V_3_1_ALPHA;
import static org.eclipse.edc.api.management.ManagementApi.MANAGEMENT_API_V_4_ALPHA;
import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.VOCAB;
import static org.eclipse.edc.policy.model.OdrlNamespace.ODRL_PREFIX;
import static org.eclipse.edc.policy.model.OdrlNamespace.ODRL_SCHEMA;
Expand Down Expand Up @@ -166,9 +166,9 @@ public void initialize(ServiceExtensionContext context) {
managementApiTransformerRegistry.register(new JsonObjectToAssetTransformer());
managementApiTransformerRegistry.register(new JsonValueToGenericTypeTransformer(jsonLdMapper));

var managementApiTransformerRegistryV31Alpha = managementApiTransformerRegistry.forContext(MANAGEMENT_API_V_3_1_ALPHA);
var managementApiTransformerRegistryV4Alpha = managementApiTransformerRegistry.forContext(MANAGEMENT_API_V_4_ALPHA);

managementApiTransformerRegistryV31Alpha.register(new JsonObjectFromPolicyTransformer(factory, participantIdMapper, true));
managementApiTransformerRegistryV4Alpha.register(new JsonObjectFromPolicyTransformer(factory, participantIdMapper, true));

registerVersionInfo(getClass().getClassLoader());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
{
"version": "3.1.0-alpha",
"urlPath": "/v3.1alpha",
"lastUpdated": "2024-09-04T10:17:00Z",
"maturity": "alpha"
},
{
"version": "4.0.0-alpha",
"urlPath": "/v4alpha",
"lastUpdated": "2024-11-21T14:24:00Z",
"maturity": "alpha"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import org.eclipse.edc.connector.controlplane.api.management.contractagreement.v2.ContractAgreementApiV2Controller;
import org.eclipse.edc.connector.controlplane.api.management.contractagreement.v3.ContractAgreementApiV3Controller;
import org.eclipse.edc.connector.controlplane.api.management.contractagreement.v31alpha.ContractAgreementApiV31AlphaController;
import org.eclipse.edc.connector.controlplane.api.management.contractagreement.v4alpha.ContractAgreementApiV4AlphaController;
import org.eclipse.edc.connector.controlplane.services.spi.contractagreement.ContractAgreementService;
import org.eclipse.edc.runtime.metamodel.annotation.Extension;
import org.eclipse.edc.runtime.metamodel.annotation.Inject;
Expand All @@ -29,7 +29,7 @@
import org.eclipse.edc.web.spi.configuration.ApiContext;

import static org.eclipse.edc.api.management.ManagementApi.MANAGEMENT_API_CONTEXT;
import static org.eclipse.edc.api.management.ManagementApi.MANAGEMENT_API_V_3_1_ALPHA;
import static org.eclipse.edc.api.management.ManagementApi.MANAGEMENT_API_V_4_ALPHA;

@Extension(value = ContractAgreementApiExtension.NAME)
public class ContractAgreementApiExtension implements ServiceExtension {
Expand Down Expand Up @@ -57,11 +57,11 @@ public void initialize(ServiceExtensionContext context) {
var monitor = context.getMonitor();

var managementApiTransformerRegistry = transformerRegistry.forContext(MANAGEMENT_API_CONTEXT);
var managementApiTransformerRegistryV31Alpha = managementApiTransformerRegistry.forContext(MANAGEMENT_API_V_3_1_ALPHA);
var managementApiTransformerRegistryV31Alpha = managementApiTransformerRegistry.forContext(MANAGEMENT_API_V_4_ALPHA);


webService.registerResource(ApiContext.MANAGEMENT, new ContractAgreementApiV2Controller(service, managementApiTransformerRegistry, monitor, validatorRegistry));
webService.registerResource(ApiContext.MANAGEMENT, new ContractAgreementApiV3Controller(service, managementApiTransformerRegistry, monitor, validatorRegistry));
webService.registerResource(ApiContext.MANAGEMENT, new ContractAgreementApiV31AlphaController(service, managementApiTransformerRegistryV31Alpha, monitor, validatorRegistry));
webService.registerResource(ApiContext.MANAGEMENT, new ContractAgreementApiV4AlphaController(service, managementApiTransformerRegistryV31Alpha, monitor, validatorRegistry));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.connector.controlplane.api.management.contractagreement.v31alpha;
package org.eclipse.edc.connector.controlplane.api.management.contractagreement.v4alpha;

import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.Operation;
Expand All @@ -28,9 +28,9 @@
import org.eclipse.edc.api.management.schema.ManagementApiSchema;
import org.eclipse.edc.api.model.ApiCoreSchema;

@OpenAPIDefinition(info = @Info(version = "v3.1-alpha"))
@Tag(name = "Contract Agreement v3.1-alpha")
public interface ContractAgreementApiV3Alpha {
@OpenAPIDefinition(info = @Info(version = "v4alpha"))
@Tag(name = "Contract Agreement v4alpha")
public interface ContractAgreementApiV4Alpha {

@Operation(description = "Gets all contract agreements according to a particular query",
requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = ApiCoreSchema.QuerySpecSchema.class))),
Expand All @@ -41,7 +41,7 @@ public interface ContractAgreementApiV3Alpha {
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class))))
}
)
JsonArray queryAgreementsV31Alpha(JsonObject querySpecJson);
JsonArray queryAgreementsV4Alpha(JsonObject querySpecJson);

@Operation(description = "Gets an contract agreement with the given ID",
responses = {
Expand All @@ -53,7 +53,7 @@ public interface ContractAgreementApiV3Alpha {
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class))))
}
)
JsonObject getAgreementByIdV31Alpha(String id);
JsonObject getAgreementByIdV4Alpha(String id);


@Operation(description = "Gets a contract negotiation with the given contract agreement ID",
Expand All @@ -66,6 +66,6 @@ public interface ContractAgreementApiV3Alpha {
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class))))
}
)
JsonObject getNegotiationByAgreementIdV31Alpha(String id);
JsonObject getNegotiationByAgreementIdV4Alpha(String id);

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.connector.controlplane.api.management.contractagreement.v31alpha;
package org.eclipse.edc.connector.controlplane.api.management.contractagreement.v4alpha;

import jakarta.json.JsonArray;
import jakarta.json.JsonObject;
Expand All @@ -32,30 +32,30 @@

@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("/v3.1alpha/contractagreements")
public class ContractAgreementApiV31AlphaController extends BaseContractAgreementApiController implements ContractAgreementApiV3Alpha {
public ContractAgreementApiV31AlphaController(ContractAgreementService service, TypeTransformerRegistry transformerRegistry, Monitor monitor, JsonObjectValidatorRegistry validatorRegistry) {
@Path("/v4alpha/contractagreements")
public class ContractAgreementApiV4AlphaController extends BaseContractAgreementApiController implements ContractAgreementApiV4Alpha {
public ContractAgreementApiV4AlphaController(ContractAgreementService service, TypeTransformerRegistry transformerRegistry, Monitor monitor, JsonObjectValidatorRegistry validatorRegistry) {
super(service, transformerRegistry, monitor, validatorRegistry);
}

@POST
@Path("/request")
@Override
public JsonArray queryAgreementsV31Alpha(JsonObject querySpecJson) {
public JsonArray queryAgreementsV4Alpha(JsonObject querySpecJson) {
return queryAgreements(querySpecJson);
}

@GET
@Path("{id}")
@Override
public JsonObject getAgreementByIdV31Alpha(@PathParam("id") String id) {
public JsonObject getAgreementByIdV4Alpha(@PathParam("id") String id) {
return getAgreementById(id);
}

@GET
@Path("{id}/negotiation")
@Override
public JsonObject getNegotiationByAgreementIdV31Alpha(@PathParam("id") String id) {
public JsonObject getNegotiationByAgreementIdV4Alpha(@PathParam("id") String id) {
return getNegotiationByAgreementId(id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@

import io.restassured.specification.RequestSpecification;
import org.eclipse.edc.connector.controlplane.api.management.contractagreement.BaseContractAgreementApiControllerTest;
import org.eclipse.edc.connector.controlplane.api.management.contractagreement.v4alpha.ContractAgreementApiV4AlphaController;

import static io.restassured.RestAssured.given;

class ContractAgreementApiV31AlphaControllerTest extends BaseContractAgreementApiControllerTest {
class ContractAgreementApiV4AlphaControllerTest extends BaseContractAgreementApiControllerTest {
@Override
protected Object controller() {
return new ContractAgreementApiV31AlphaController(service, transformerRegistry, monitor, validatorRegistry);
return new ContractAgreementApiV4AlphaController(service, transformerRegistry, monitor, validatorRegistry);
}

protected RequestSpecification baseRequest() {
return given()
.baseUri("http://localhost:" + port + "/v3.1alpha/contractagreements")
.baseUri("http://localhost:" + port + "/v4alpha/contractagreements")
.when();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void getById(ManagementEndToEndTestContext context, ContractNegotiationStore sto
var agreement = createContractAgreement("cn1");
store.save(createContractNegotiationBuilder("cn1").contractAgreement(agreement).build());

var json = context.baseRequest()
context.baseRequest()
.contentType(JSON)
.get("/v3/contractagreements/cn1")
.then()
Expand All @@ -81,13 +81,13 @@ void getById(ManagementEndToEndTestContext context, ContractNegotiationStore sto
}

@Test
void getByIdV31Alpha(ManagementEndToEndTestContext context, ContractNegotiationStore store) {
void getByIdV4Alpha(ManagementEndToEndTestContext context, ContractNegotiationStore store) {
var agreement = createContractAgreement("cn1");
store.save(createContractNegotiationBuilder("cn1").contractAgreement(agreement).build());

context.baseRequest()
.contentType(JSON)
.get("/v3.1alpha/contractagreements/cn1")
.get("/v4alpha/contractagreements/cn1")
.then()
.statusCode(200)
.contentType(JSON)
Expand Down

0 comments on commit cf82267

Please sign in to comment.