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

feature(irs-edc-client): #412 fix asset creation in irs lib #445

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -81,7 +81,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 +98,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 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 @@ -157,7 +157,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 +175,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 +194,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 +209,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 +224,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 +240,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
Loading