Skip to content

Commit

Permalink
Add a unit test to ensure that it's possible to create a data offer w…
Browse files Browse the repository at this point in the history
…ith an empty (not null) policy definition
  • Loading branch information
ununhexium committed Oct 2, 2024
1 parent de076b0 commit 0d4d517
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 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 @@ -786,6 +786,55 @@ void canCreateDataOfferWithNewPolicy(
.isEqualTo(assetId);
}

@Test
void canCreateDataOfferWithNewEmptyPolicyAndRestrictedPublishing(
@Provider EdcClient providerClient
) {
// arrange
val dataSource = UiDataSource.builder()
.httpData(UiDataSourceHttpData.builder()
.baseUrl("http://example.com")
.method(UiDataSourceHttpDataMethod.GET)
.build())
.type(DataSourceType.HTTP_DATA)
.build();

val assetId = "asset";
val asset = UiAssetCreateRequest.builder()
.dataSource(dataSource)
.id(assetId)
.title("My asset")
.build();

val dataOfferCreateRequest = new DataOfferCreationRequest(
asset,
DataOfferCreationRequest.PolicyEnum.PUBLISH_RESTRICTED,
UiPolicyExpression.builder().build()
);

// act
val returnedId = providerClient.uiApi().createDataOffer(dataOfferCreateRequest).getId();

// assert
assertThat(returnedId).isEqualTo(assetId);

assertThat(providerClient.uiApi().getAssetPage().getAssets())
.extracting(UiAsset::getAssetId)
.first()
.isEqualTo(assetId);

assertThat(getAllPoliciesExceptTheAlwaysTruePolicy(providerClient))
.hasSize(1)
.extracting(PolicyDefinitionDto::getPolicyDefinitionId)
.first()
.isEqualTo(assetId);

assertThat(providerClient.uiApi().getContractDefinitionPage().getContractDefinitions())
.extracting(ContractDefinitionEntry::getContractDefinitionId)
.first()
.isEqualTo(assetId);
}

@Test
void dontCreateAnythingIfTheAssetAlreadyExists(
E2eScenario scenario,
Expand Down

0 comments on commit 0d4d517

Please sign in to comment.