Skip to content

Commit

Permalink
Merge pull request #785 from eclipse-tractusx/main
Browse files Browse the repository at this point in the history
Sync with upstream
  • Loading branch information
dsmf authored Feb 26, 2024
2 parents 282c692 + 7b3a60b commit 98d7086
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 26 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed Log4J configuration
- Fix tavern and cucumber tests

## [4.5.2] - 2024-02-22
## Changed
- Updated IRS OpenAPI version to 4.5.2

## [4.5.1] - 2024-02-20
### Changed
- Moved Docker notice to separate file #425


## [4.5.0] - 2024-02-07
### Added
- Added helper script for building documentation locally.
Expand Down Expand Up @@ -538,6 +541,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

[Unreleased]: https://github.com/eclipse-tractusx/item-relationship-service/compare/4.6.0...HEAD
[4.6.0]: https://github.com/eclipse-tractusx/item-relationship-service/compare/4.5.1...4.6.0
[4.5.2]: https://github.com/eclipse-tractusx/item-relationship-service/compare/4.5.1...4.5.2
[4.5.1]: https://github.com/eclipse-tractusx/item-relationship-service/compare/4.5.0...4.5.1
[4.5.1]: https://github.com/eclipse-tractusx/item-relationship-service/compare/4.5.0...4.5.1
[4.5.0]: https://github.com/eclipse-tractusx/item-relationship-service/compare/4.4.0...4.5.0
Expand Down
8 changes: 8 additions & 0 deletions charts/irs-helm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Update IRS version to 4.6.0

## [6.14.2] - 2024-02-22
### Changed
- Update IRS version to 4.5.2

## [6.14.1] - 2024-02-20
### Changed
- Update IRS version to 4.5.1

## [6.14.0] - 2024-02-07
### Added
- Added configuration parameters `oauth2.semantics.clientId`,`oauth2.semantics.clientSecret`, `oauth2.discovery.clientId`,`oauth2.discovery.clientSecret`, `oauth2.bpdm.clientId`,`oauth2.bpdm.clientSecret`
Expand Down
2 changes: 1 addition & 1 deletion docs/src/api/irs-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ info:
description: The API of the Item Relationship Service (IRS) for retrieving item
graphs along the value chain of CATENA-X partners.
title: IRS API
version: "2.1.0"
version: "4.5.2"
servers:
- url: http://localhost:8080
security:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class IrsApplication {
/**
* The IRS API version.
*/
public static final String API_VERSION = "2.1.0";
public static final String API_VERSION = "4.5.2";

/**
* The URL prefix for IRS API URLs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ public class EdcAssetService {
private static final String ASSET_CREATION_DATA_ADDRESS_PROXY_PATH = "https://w3id.org/edc/v0.0.1/ns/proxyPath";
private static final String ASSET_CREATION_DATA_ADDRESS_PROXY_QUERY_PARAMS = "https://w3id.org/edc/v0.0.1/ns/proxyQueryParams";
private static final String ASSET_CREATION_DATA_ADDRESS_METHOD = "https://w3id.org/edc/v0.0.1/ns/method";
private static final String ASSET_CREATION_PROPERTY_DESCRIPTION = "https://w3id.org/edc/v0.0.1/ns/description";
private static final String ASSET_CREATION_PROPERTY_CONTENT_TYPE = "https://w3id.org/edc/v0.0.1/ns/contenttype";
private static final String ASSET_CREATION_PROPERTY_POLICY_ID = "https://w3id.org/edc/v0.0.1/ns/policy-id";
private static final String ASSET_CREATION_PROPERTY_TYPE = "https://w3id.org/edc/v0.0.1/ns/type";
private static final String ASSET_CREATION_PROPERTY_NOTIFICATION_TYPE = "https://w3id.org/edc/v0.0.1/ns/notificationtype";
private static final String ASSET_CREATION_PROPERTY_NOTIFICATION_METHOD = "https://w3id.org/edc/v0.0.1/ns/notificationmethod";

private final EdcTransformer edcTransformer;
private final EdcConfiguration config;
Expand All @@ -81,7 +87,7 @@ private String sendRequest(final Asset request) throws CreateEdcAssetException {
final ResponseEntity<String> createEdcDataAssetResponse;
try {
createEdcDataAssetResponse = restTemplate.postForEntity(config.getControlplane().getEndpoint().getAsset(),
transformedPayload, String.class);
transformedPayload.toString(), String.class);
final HttpStatusCode responseCode = createEdcDataAssetResponse.getStatusCode();

if (responseCode.value() == HttpStatus.CONFLICT.value()) {
Expand All @@ -98,7 +104,7 @@ private String sendRequest(final Asset request) throws CreateEdcAssetException {
throw new CreateEdcAssetException("Failed to create asset %s".formatted(request.getId()));
}

public void deleteAsset(final String assetId, final RestTemplate restTemplate) throws DeleteEdcAssetException {
public void deleteAsset(final String assetId) throws DeleteEdcAssetException {
final String deleteUri = UriComponentsBuilder.fromPath(config.getControlplane().getEndpoint().getAsset())
.pathSegment("{notificationAssetId}")
.buildAndExpand(assetId)
Expand All @@ -115,9 +121,12 @@ public void deleteAsset(final String assetId, final RestTemplate restTemplate) t
private Asset createNotificationAssetRequest(final String assetName, final String baseUrl,
final NotificationMethod notificationMethod, final NotificationType notificationType) {
final String assetId = UUID.randomUUID().toString();
final Map<String, Object> properties = Map.of("description", assetName, "contenttype", DEFAULT_CONTENT_TYPE,
"policy-id", DEFAULT_POLICY_ID, "type", notificationType.getValue(), "notificationtype",
notificationType.getValue(), "notificationmethod", notificationMethod.getValue());
final Map<String, Object> properties = Map.of(ASSET_CREATION_PROPERTY_DESCRIPTION, assetName,
ASSET_CREATION_PROPERTY_CONTENT_TYPE, DEFAULT_CONTENT_TYPE,
ASSET_CREATION_PROPERTY_POLICY_ID, DEFAULT_POLICY_ID, ASSET_CREATION_PROPERTY_TYPE,
notificationType.getValue(), ASSET_CREATION_PROPERTY_NOTIFICATION_TYPE,
notificationType.getValue(), ASSET_CREATION_PROPERTY_NOTIFICATION_METHOD,
notificationMethod.getValue());

final DataAddress dataAddress = DataAddress.Builder.newInstance()
.type(HTTP_DATA)
Expand All @@ -139,7 +148,7 @@ private Asset createNotificationAssetRequest(final String assetName, final Strin

private Asset createDtrAssetRequest(final String assetName, final String baseUrl) {
final String assetId = UUID.randomUUID().toString();
final Map<String, Object> properties = Map.of("description", assetName, "type",
final Map<String, Object> properties = Map.of(ASSET_CREATION_PROPERTY_DESCRIPTION, assetName, ASSET_CREATION_PROPERTY_TYPE,
"data.core.digitalTwinRegistry");

final DataAddress dataAddress = DataAddress.Builder.newInstance()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public EdcCreatePolicyDefinitionRequest createPolicyDefinition(final String poli
.build();
}

public void deleteAccessPolicy(final String accessPolicyId, final RestTemplate restTemplate)
public void deleteAccessPolicy(final String accessPolicyId)
throws DeleteEdcPolicyDefinitionException {
final String deleteUri = UriComponentsBuilder.fromPath(
config.getControlplane().getEndpoint().getPolicyDefinition())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ void setUp() {
@Test
void testAssetCreateRequestStructure() throws JSONException, JsonProcessingException {

Map<String, Object> properties = Map.of("description", "endpoint to qualityinvestigation receive",
"contenttype", "application/json", "policy-id", "use-eu", "type", "receive", "notificationtype",
"qualityinvestigation", "notificationmethod", "receive");
Map<String, Object> properties = Map.of("https://w3id.org/edc/v0.0.1/ns/description", "endpoint to qualityinvestigation receive",
"https://w3id.org/edc/v0.0.1/ns/contenttype", "application/json", "https://w3id.org/edc/v0.0.1/ns/policy-id", "use-eu", "https://w3id.org/edc/v0.0.1/ns/type", "receive", "https://w3id.org/edc/v0.0.1/ns/notificationtype",
"qualityinvestigation", "https://w3id.org/edc/v0.0.1/ns/notificationmethod", "receive");

DataAddress dataAddress = DataAddress.Builder.newInstance()
.type(HTTP_DATA)
Expand Down Expand Up @@ -124,23 +124,28 @@ void testAssetCreateRequestStructure() throws JSONException, JsonProcessingExcep
"@id": "Asset1",
"@type": "edc:Asset",
"edc:properties": {
"edc:type": "receive",
"edc:notificationtype": "qualityinvestigation",
"edc:policy-id": "use-eu",
"edc:description": "endpoint to qualityinvestigation receive",
"edc:id": "Asset1",
"edc:contenttype": "Asset"
"edc:contenttype": "application/json",
"edc:notificationmethod": "receive"
},
"edc:dataAddress": {
"@type": "edc:DataAddress",
"edc:method": "POST",
"edc:type": "HttpData",
"edc:proxyMethod": "true",
"edc:proxyBody": "true",
"edc:baseUrl": "https://traceability.dev.demo.catena-x.net/api/qualitynotifications/receive",
"edc:method": "POST",
"edc:proxyMethod": "true"
"edc:baseUrl": "https://traceability.dev.demo.catena-x.net/api/qualitynotifications/receive"
},
"@context": {
"dct": "https://purl.org/dc/terms/",
"tx": "https://w3id.org/tractusx/v0.0.1/ns/",
"edc": "https://w3id.org/edc/v0.0.1/ns/",
"dcat": "https://www.w3.org/ns/dcat/",
"odrl": "http://www.w3.org/ns/odrl/2/",
"dcat": "https://www.w3.org/ns/dcat/",
"dspace": "https://w3id.org/dspace/v0.8/"
}
}
Expand All @@ -157,7 +162,7 @@ void givenCreateNotificationAsset_whenOk_ThenReturnCreatedAssetId() throws Creat
String assetName = "asset1";
NotificationMethod notificationMethod = NotificationMethod.RECEIVE;
NotificationType notificationType = NotificationType.QUALITY_ALERT;
when(restTemplate.postForEntity(any(String.class), any(JsonObject.class), any())).thenReturn(
when(restTemplate.postForEntity(any(String.class), any(String.class), any())).thenReturn(
ResponseEntity.ok("test"));

// when
Expand All @@ -175,7 +180,7 @@ void givenCreateDtrAsset_whenOk_ThenReturnCreatedAssetId() throws CreateEdcAsset
when(endpointConfig.getAsset()).thenReturn("/management/v2/assets");
String baseUrl = "http://test.test";
String assetName = "asset1";
when(restTemplate.postForEntity(any(String.class), any(JsonObject.class), any())).thenReturn(
when(restTemplate.postForEntity(any(String.class), any(String.class), any())).thenReturn(
ResponseEntity.ok("test"));

// when
Expand All @@ -194,7 +199,7 @@ void givenDeleteAsset_whenOk_ThenReturnCreatedAssetId() throws DeleteEdcAssetExc
String assetId = "id";

// when
service.deleteAsset(assetId, restTemplate);
service.deleteAsset(assetId);

// then
verify(restTemplate).delete(any(String.class));
Expand All @@ -209,7 +214,7 @@ void givenCreateDtrAsset_whenOK_ThenThrowException() {
String baseUrl = "http://test.test";
String assetName = "asset1";
doThrow(new RestClientException("Surprise")).when(restTemplate)
.postForEntity(any(String.class), any(JsonObject.class), any());
.postForEntity(any(String.class), any(String.class), any());

// when/then
assertThrows(CreateEdcAssetException.class, () -> service.createDtrAsset(baseUrl, assetName));
Expand All @@ -224,7 +229,7 @@ void givenCreateDtrAsset_whenTemplateException_ThenThrowException() {
String baseUrl = "http://test.test";
String assetName = "asset1";
doThrow(new RestClientException("Surprise")).when(restTemplate)
.postForEntity(any(String.class), any(JsonObject.class), any());
.postForEntity(any(String.class), any(String.class), any());

// when/then
assertThrows(CreateEdcAssetException.class, () -> service.createDtrAsset(baseUrl, assetName));
Expand All @@ -240,7 +245,7 @@ void givenDeleteAsset_whenTemplateException_ThenThrowException() {
doThrow(new RestClientException("Surprise")).when(restTemplate).delete(any(String.class));

// when/then
assertThrows(DeleteEdcAssetException.class, () -> service.deleteAsset(assetId, restTemplate));
assertThrows(DeleteEdcAssetException.class, () -> service.deleteAsset(assetId));
}

ObjectMapper objectMapper() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ void givenDeletePolicy_whenRestClientException_thenThrowException() {

// when/then
assertThrows(DeleteEdcPolicyDefinitionException.class,
() -> service.deleteAccessPolicy(policyName, restTemplate));
() -> service.deleteAccessPolicy(policyName));
}

@Test
Expand All @@ -187,7 +187,7 @@ void givenDeletePolicy_whenOk_thenCallRestTemplate() throws DeleteEdcPolicyDefin
String policyName = "policyName";

// when
service.deleteAccessPolicy(policyName, restTemplate);
service.deleteAccessPolicy(policyName);

// then
verify(restTemplate, times(1)).delete(any(String.class));
Expand Down

0 comments on commit 98d7086

Please sign in to comment.