Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type-safe UiAsset #512

Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
82dc775
chore: Refactoring of Asset Dto
SaadEGI Sep 5, 2023
fe98859
chore: Asset Deserializer
SaadEGI Sep 8, 2023
87e7692
chore: Asset Deserializer + Asset Mapper Test + Test Cases
SaadEGI Sep 12, 2023
6e96d18
fix: Refactor AssetMapperTest + minor fixes
SaadEGI Sep 13, 2023
2ef5b4a
fix: Pipeline (Unused Imports)
SaadEGI Sep 13, 2023
3de17dc
Merge branch 'main' of https://github.com/sovity/edc-extensions into …
SaadEGI Sep 13, 2023
ef56352
fix: remove dead code
SaadEGI Sep 13, 2023
1292bb7
chore: refactor CreateAsset Endpoint
SaadEGI Sep 13, 2023
50c6d12
fix: newLines
SaadEGI Sep 13, 2023
f616982
chore: ContractAgreementPageCardBuilder UiAsset Refactoring
SaadEGI Sep 13, 2023
bd1667e
chore: Asset e2e Test
SaadEGI Sep 14, 2023
d8fa49d
chore: AssetMapper
SaadEGI Sep 14, 2023
b819c8a
ci: try fix test parallelity issues (4)
richardtreier Sep 14, 2023
3187376
Merge branch 'main' of https://github.com/sovity/edc-extensions into …
SaadEGI Sep 15, 2023
c6ec76a
chore: AssetMapper
SaadEGI Sep 15, 2023
212e363
fix: UiWrapperTest
SaadEGI Sep 15, 2023
6e8238a
fix: PR Revision
SaadEGI Sep 15, 2023
a7dedd3
fix: PR Revision
SaadEGI Sep 15, 2023
77af54a
fix: PR Revision (Asset Mapper + Asset Mapper Test)
SaadEGI Sep 18, 2023
43189c0
fix: PR Revision (Asset Mapper + Asset Mapper Test)
SaadEGI Sep 18, 2023
1eb6d57
Merge branch '459-backend-ui-api-wrapper-refactor-assetdto-to-be-a-ty…
richardtreier Sep 18, 2023
83190bc
test: fix AssetApiServiceTest#testAssetCreation
richardtreier Sep 18, 2023
b518efc
fix: PR Revision (Asset Mapper + Asset Mapper Test)
SaadEGI Sep 18, 2023
90ef84f
Merge branch '459-backend-ui-api-wrapper-refactor-assetdto-to-be-a-ty…
SaadEGI Sep 18, 2023
b93c368
fix: PR Revision (Asset Mapper + Asset Mapper Test+ UiApiWrapperTest)
SaadEGI Sep 18, 2023
7b17731
fix: layout
SaadEGI Sep 18, 2023
5036d44
fix: Naming
SaadEGI Sep 18, 2023
e01b930
fix: Naming
SaadEGI Sep 18, 2023
daa0097
fix: Naming
SaadEGI Sep 18, 2023
8c7f156
fix: Naming + Creator And Publisher Mapping
SaadEGI Sep 19, 2023
10759a0
fix: Failing tests
SaadEGI Sep 19, 2023
03b0a54
fix: Undo changes
SaadEGI Sep 19, 2023
65baad2
fix: (Temporary) Pipeline
SaadEGI Sep 19, 2023
82db764
fix: (Temporary) Pipeline
SaadEGI Sep 19, 2023
dfb94e3
fix: Style
SaadEGI Sep 19, 2023
8efed62
fix: contract definition operator mapping
richardtreier Sep 19, 2023
f37b8cc
Merge branch '459-backend-ui-api-wrapper-refactor-assetdto-to-be-a-ty…
richardtreier Sep 19, 2023
fb7c92e
fix: contract definition literal mapping
richardtreier Sep 19, 2023
5e51ebc
fix: asset json-ld handling
richardtreier Sep 19, 2023
a72cd04
docs: fix wording
richardtreier Sep 19, 2023
c92359f
chore: improve code quality
richardtreier Sep 19, 2023
541e865
chore: update CHANGELOG.md
richardtreier Sep 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
package de.sovity.edc.client;


import de.sovity.edc.client.gen.model.AssetCreateRequest;
import de.sovity.edc.client.gen.model.UiAssetCreateRequest;
import de.sovity.edc.ext.wrapper.utils.EdcPropertyUtils;
import lombok.SneakyThrows;
import org.eclipse.edc.connector.spi.asset.AssetService;
Expand All @@ -28,6 +28,7 @@
import org.junit.jupiter.api.extension.ExtendWith;

import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Map;

import static org.assertj.core.api.Assertions.assertThat;
Expand All @@ -54,7 +55,7 @@ void assetPage(AssetService assetStore) {
var privateProperties = Map.of("random-private-prop", "456");
var properties = Map.of(
Asset.PROPERTY_ID, "asset-1",
"random-prop", "123"
"landingPage", "https://data-source.my-org/docs"
);
createAsset(assetStore, "2023-06-01", properties, privateProperties);

Expand All @@ -65,11 +66,11 @@ void assetPage(AssetService assetStore) {
var assets = result.getAssets();
assertThat(assets).hasSize(1);
var asset = assets.get(0);
assertThat(asset.getProperties()).isEqualTo(properties);
assertThat(asset.getId()).isEqualTo(properties.get(Asset.PROPERTY_ID));
assertThat(asset.getLandingPageUrl()).isEqualTo(properties.get("landingPage"));
assertThat(asset.getPrivateProperties()).isEqualTo(privateProperties);
}


@Test
void assetPageSorting(AssetService assetService) {
// arrange
Expand All @@ -83,39 +84,35 @@ void assetPageSorting(AssetService assetService) {

// assert
assertThat(result.getAssets())
.extracting(asset -> asset.getProperties().get(Asset.PROPERTY_ID))
.extracting(asset -> asset.getId())
.containsExactly("asset-3", "asset-2", "asset-1");
}

@Test
void testAssetCreation(AssetService assetService) {
// arrange
var client = TestUtils.edcClient();
var properties = Map.of(
Asset.PROPERTY_ID, "asset-1",
"random-prop", "123"
);
var privateProperties = Map.of("random-private-prop", "456");
var dataAddressProperties = Map.of(
EDC_DATA_ADDRESS_TYPE_PROPERTY, DATA_ADDRESS_TYPE,
"baseUrl", DATA_SINK
);
var assetRequest = AssetCreateRequest.builder()
.properties(properties)
.privateProperties(privateProperties)
var uiAssetRequest = UiAssetCreateRequest.builder()
.id("asset-1")
.name("AssetName")
.keywords(List.of("keyword1", "keyword2"))
.dataAddressProperties(dataAddressProperties)
.build();

// act
var response = client.uiApi().createAsset(assetRequest);
var response = client.uiApi().createAsset(uiAssetRequest);

// assert
assertThat(response.getId()).isEqualTo(properties.get(Asset.PROPERTY_ID));
assertThat(response.getId()).isEqualTo("asset-1");
var assets = assetService.query(QuerySpec.max()).getContent().toList();
assertThat(assets).hasSize(1);
var asset = assets.get(0);
assertThat(asset.getProperties()).isEqualTo(properties);
assertThat(asset.getPrivateProperties()).isEqualTo(privateProperties);
assertThat(asset.getName()).isEqualTo("AssetName");
assertThat(asset.getProperties().get("keywords")).isEqualTo(List.of("keyword1", "keyword2"));
assertThat(asset.getDataAddress().getProperties()).isEqualTo(dataAddressProperties);
}

Expand Down Expand Up @@ -161,6 +158,5 @@ private static long dateFormatterToLong(String date) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
return formatter.parse(date).getTime();
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ void testContractAgreementPage(
assertThat(agreement.getCounterPartyAddress()).isEqualTo("http://other-connector");
assertThat(agreement.getCounterPartyId()).isEqualTo("urn:connector:other-connector");
assertThat(agreement.getContractSigningDate()).isEqualTo(todayPlusDays(0));
assertThat(agreement.getAsset().getProperties()).containsEntry("https://w3id.org/edc/v0.0.1/ns/id", ASSET_ID);
assertThat(agreement.getAsset().getProperties()).containsEntry("some-property", "X");
assertThat(agreement.getAsset().getId()).isEqualTo(ASSET_ID);
assertThat(agreement.getAsset().getLandingPageUrl()).isEqualTo("X");
assertThat(agreement.getTransferProcesses()).hasSize(1);

var transfer = agreement.getTransferProcesses().get(0);
Expand Down Expand Up @@ -178,7 +178,7 @@ private ContractNegotiation contractDefinition(int contract) {
private Asset asset(String assetId) {
return Asset.Builder.newInstance()
.id(assetId)
.property("some-property", "X")
.property("http://www.w3.org/ns/dcat#landingPage", "X")
SaadEGI marked this conversation as resolved.
Show resolved Hide resolved
.createdAt(todayEpochMillis)
.dataAddress(dataAddress())
.build();
Expand Down
1 change: 1 addition & 0 deletions extensions/wrapper/wrapper-common-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies {
annotationProcessor("org.projectlombok:lombok:${lombokVersion}")
compileOnly("org.projectlombok:lombok:${lombokVersion}")


api("jakarta.ws.rs:jakarta.ws.rs-api:3.1.0")
api("jakarta.validation:jakarta.validation-api:3.0.2")
api("io.swagger.core.v3:swagger-annotations-jakarta:2.2.15")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,94 @@
import lombok.Setter;
import lombok.ToString;

import java.util.List;
import java.util.Map;

@Getter
@Setter

@ToString
@AllArgsConstructor
@Builder(toBuilder = true)
@RequiredArgsConstructor
@Schema(description = "Type-Safe Asset Metadata as needed by our UI")
public class UiAsset {
@Schema(description = "Asset ID", requiredMode = Schema.RequiredMode.REQUIRED)
private String assetId;

@Schema(description = "Asset name")
@Schema(description = "Asset Id", requiredMode = Schema.RequiredMode.REQUIRED)
private String id;

@Schema(description = "Asset Name", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String name;
SaadEGI marked this conversation as resolved.
Show resolved Hide resolved

@Schema(description = "Asset Title", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String title;
SaadEGI marked this conversation as resolved.
Show resolved Hide resolved

@Schema(description = "Asset Language", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String language;

@Schema(description = "Asset Description", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String description;

@Schema(description = "Asset Organization Name", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String creator;
SaadEGI marked this conversation as resolved.
Show resolved Hide resolved

@Schema(description = "Asset Homepage", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String publisher;
SaadEGI marked this conversation as resolved.
Show resolved Hide resolved

@Schema(description = "License URL", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String licenseUrl;

@Schema(description = "Version", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String version;

@Schema(description = "Asset Keywords", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private List<String> keywords;

@Schema(description = "Asset MediaType", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String distribution;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mismatch: docs vs field

what does this field even do?


@Schema(description = "Landing Page URL", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String landingPageUrl;

@Schema(description = "HTTP Datasource Hints Proxy Method", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private Boolean httpDatasourceHintsProxyMethod;

@Schema(description = "HTTP Datasource Hints Proxy Path", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private Boolean httpDatasourceHintsProxyPath;

@Schema(description = "HTTP Datasource Hints Proxy Query Params", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private Boolean httpDatasourceHintsProxyQueryParams;

@Schema(description = "HTTP Datasource Hints Proxy Body", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private Boolean httpDatasourceHintsProxyBody;

@Schema(description = "Data Category", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String dataCategory;

@Schema(description = "Data Subcategory", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String dataSubcategory;

@Schema(description = "Data Model", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String dataModel;

@Schema(description = "Geo-Reference Method", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String geoReferenceMethod;

@Schema(description = "Transport Mode", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String transportMode;

@Schema(description = "Asset additional Properties", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private Map<String, String> additionalProperties;

@Schema(description = "Asset Private Properties", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private Map<String, Object> privateProperties;

@Schema(description = "Asset Json Properties", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private Map<String, String> additionalJsonProperties;

@Schema(description = "Asset DataAddress Properties", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private Map<String, String> dataAddressProperties;
SaadEGI marked this conversation as resolved.
Show resolved Hide resolved

@Schema(description = "Contains the entire asset in its original expanded JSON-LD format", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String assetJsonLd;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* Copyright (c) 2022 sovity GmbH
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* sovity GmbH - initial API and implementation
*
*/

package de.sovity.edc.ext.wrapper.api.common.model;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.List;
import java.util.Map;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Schema(description = "Type-Safe OpenAPI generator friendly Asset Create DTO that supports an opinionated subset of the original EDC Asset Entity.")
public class UiAssetCreateRequest {
@Schema(description = "Asset Id", requiredMode = Schema.RequiredMode.REQUIRED)
private String id;

@Schema(description = "Asset Name", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String name;

@Schema(description = "Asset Title", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String title;
SaadEGI marked this conversation as resolved.
Show resolved Hide resolved

@Schema(description = "Asset Language", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String language;

@Schema(description = "Asset Description", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String description;

@Schema(description = "Asset Organization Name", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String creator;

@Schema(description = "Asset Homepage", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String publisher;

@Schema(description = "License URL", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String licenseUrl;

@Schema(description = "Version", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String version;

@Schema(description = "Asset Keywords", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private List<String> keywords;

@Schema(description = "Asset MediaType", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String distribution;

@Schema(description = "Landing Page URL", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String landingPageUrl;

@Schema(description = "Data Category", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String dataCategory;

@Schema(description = "Data Subcategory", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String dataSubcategory;

@Schema(description = "Data Model", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String dataModel;

@Schema(description = "Geo-Reference Method", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String geoReferenceMethod;

@Schema(description = "Transport Mode", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String transportMode;

@Schema(description = "Data Address", requiredMode = Schema.RequiredMode.REQUIRED)
private Map<String, String> dataAddressProperties;

@Schema(description = "Asset additional Properties", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private Map<String, String> additionalProperties;

@Schema(description = "Asset Private Properties", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private Map<String, Object> privateProperties;

@Schema(description = "Asset Json Properties", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private Map<String, String> additionalJsonProperties;

@Schema(description = "Contains the entire asset in its original expanded JSON-LD format", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String assetJsonLd;
}
SaadEGI marked this conversation as resolved.
Show resolved Hide resolved
Loading
Loading