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

fix: Address update #1029

Merged
merged 5 commits into from
Aug 19, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ please see [changelog_updates.md](docs/dev/changelog_updates.md).
#### Patch Changes

- Improve database performance by removing duplicate indexes
- The data address is now correctly updated when editing an asset.

### Deployment Migration Notes

Expand Down
4 changes: 2 additions & 2 deletions docs/api/sovity-edc-api-wrapper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -603,11 +603,11 @@ components:
DataSourceType:
type: string
description: Supported Data Source Types by UiDataSource
default: CUSTOM
enum:
- HTTP_DATA
- ON_REQUEST
- CUSTOM
default: CUSTOM
SecretValue:
type: object
properties:
Expand Down Expand Up @@ -815,14 +815,14 @@ components:
UiDataSourceHttpDataMethod:
type: string
description: Supported HTTP Methods by UiDataSource
default: GET
enum:
- GET
- POST
- PUT
- PATCH
- DELETE
- OPTIONS
default: GET
UiDataSourceOnRequest:
required:
- contactEmail
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public IdResponseDto editAsset(String assetId, UiAssetEditRequest request) {
Objects.requireNonNull(foundAsset, "Asset with ID %s not found".formatted(assetId));
val editedAsset = assetMapper.editAsset(foundAsset, request);
val updatedAsset = assetService.update(editedAsset).orElseThrow(ServiceException::new);
assetService.update(editedAsset.getId(), editedAsset.getDataAddress());
return new IdResponseDto(updatedAsset.getId());
}

Expand Down
44 changes: 44 additions & 0 deletions tests/src/test/java/de/sovity/edc/e2e/UiApiWrapperTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import de.sovity.edc.client.gen.model.ContractDefinitionRequest;
import de.sovity.edc.client.gen.model.ContractNegotiationRequest;
import de.sovity.edc.client.gen.model.ContractNegotiationSimplifiedState;
import de.sovity.edc.client.gen.model.DataSourceAvailability;
import de.sovity.edc.client.gen.model.DataSourceType;
import de.sovity.edc.client.gen.model.InitiateCustomTransferRequest;
import de.sovity.edc.client.gen.model.InitiateTransferRequest;
Expand All @@ -35,6 +36,8 @@
import de.sovity.edc.client.gen.model.UiDataOffer;
import de.sovity.edc.client.gen.model.UiDataSource;
import de.sovity.edc.client.gen.model.UiDataSourceHttpData;
import de.sovity.edc.client.gen.model.UiDataSourceHttpDataMethod;
import de.sovity.edc.client.gen.model.UiDataSourceOnRequest;
import de.sovity.edc.client.gen.model.UiPolicyConstraint;
import de.sovity.edc.client.gen.model.UiPolicyExpression;
import de.sovity.edc.client.gen.model.UiPolicyExpressionType;
Expand Down Expand Up @@ -591,6 +594,7 @@ void checkIdAvailability(E2eScenario scenario, @Provider EdcClient providerClien
assertThat(posContractDefinitionResponse.getAvailable()).isTrue();
}

@DisabledOnGithub
ununhexium marked this conversation as resolved.
Show resolved Hide resolved
@Test
void retrieveSingleContractAgreement(
E2eScenario scenario,
Expand Down Expand Up @@ -632,6 +636,46 @@ void retrieveSingleContractAgreement(
.isEqualTo(alternativePolicy.getPolicyJsonLd());
}

@Test
void canMakeAnOnDemandDataSourceAvailable(
E2eScenario scenario,
@Provider EdcClient providerClient
) {
// arrange
val assetId = scenario.createAsset(UiAssetCreateRequest.builder()
.dataSource(UiDataSource.builder()
.type(DataSourceType.ON_REQUEST)
.onRequest(UiDataSourceOnRequest.builder()
.contactEmail("whatever@example.com")
.contactPreferredEmailSubject("Subject")
.build())
.build())
.id("asset")
.title("foo")
.build());

// act

providerClient.uiApi().editAsset(assetId, UiAssetEditRequest.builder()
.dataSourceOverrideOrNull(UiDataSource.builder()
.type(DataSourceType.HTTP_DATA)
.httpData(UiDataSourceHttpData.builder()
.method(UiDataSourceHttpDataMethod.GET)
.baseUrl("http://example.com/baseUrl")
.build())
.build())
.build());

val asset =
providerClient.uiApi().getAssetPage().getAssets().stream().filter(it -> it.getAssetId().equals(assetId)).findFirst().get();

// assert
assertThat(asset.getDataSourceAvailability()).isEqualTo(DataSourceAvailability.LIVE);
assertThatJson(asset.getAssetJsonLd())
.inPath("$.[\"https://w3id.org/edc/v0.0.1/ns/dataAddress\"][\"https://w3id.org/edc/v0.0.1/ns/baseUrl\"]")
.isEqualTo("\"http://example.com/baseUrl\"");
}

private UiContractNegotiation negotiate(
EdcClient consumerClient,
ConnectorRemote consumerConnector,
Expand Down
Loading