Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ununhexium committed Oct 25, 2024
1 parent cc67e34 commit fd56d96
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions tests/src/test/java/de/sovity/edc/e2e/UseCaseApiWrapper2Test.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 sovity GmbH
* Copyright (c) 2024 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
Expand All @@ -12,7 +12,7 @@
*
*/

package de.sovity.edc.ext.wrapper.api.usecase;
package de.sovity.edc.e2e;

import de.sovity.edc.client.EdcClient;
import de.sovity.edc.client.gen.model.CatalogFilterExpression;
Expand Down Expand Up @@ -45,7 +45,7 @@

import static org.assertj.core.api.Assertions.assertThat;

class UseCaseApiWrapperTest {
class UseCaseApiWrapper2Test {
String protocolApiUrl;

@RegisterExtension
Expand Down Expand Up @@ -81,6 +81,7 @@ void shouldFetchFilteredDataOffersWithEq(
assertThat(dataOffers.get(0).getAsset().getAssetId()).isEqualTo(assetId1);
assertThat(dataOffers.get(0).getAsset().getTitle()).isEqualTo("Test Asset 1");

cleanup(client);
}

@Test
Expand All @@ -102,6 +103,16 @@ void shouldFetchFilteredDataOffersWithIn(
assertThat(dataOffers)
.extracting(it -> it.getAsset().getAssetId())
.containsExactlyInAnyOrder(assetId1, assetId2);

cleanup(client);
}

private static void cleanup(EdcClient client) {
client.uiApi().deleteAsset(assetId1);
client.uiApi().deleteAsset(assetId2);
client.uiApi().deleteContractDefinition("cd-1");
client.uiApi().deleteContractDefinition("cd-2");
client.uiApi().deletePolicyDefinition(policyId);
}

@Test
Expand All @@ -123,6 +134,8 @@ void shouldFetchWithoutFilterButWithLimit(
assertThat(dataOffers)
.extracting(it -> it.getAsset().getAssetId())
.containsAnyOf(assetId1, assetId2);

cleanup(client);
}

private CatalogQuery criterion(
Expand Down Expand Up @@ -194,22 +207,25 @@ private void setupAssets(EdcClient client) {
.build())
.build();

int offset = 0;
int firstIndex = offset + 1;
assetId1 = client.uiApi().createAsset(UiAssetCreateRequest.builder()
.id("test-asset-1")
.title("Test Asset 1")
.id("test-asset-" + firstIndex)
.title("Test Asset " + firstIndex)
.dataSource(dataSource)
.mediaType("application/json")
.build()).getId();

int secondIndex = offset + 2;
assetId2 = client.uiApi().createAsset(UiAssetCreateRequest.builder()
.id("test-asset-2")
.title("Test Asset 2")
.id("test-asset-" + secondIndex)
.title("Test Asset " + secondIndex)
.dataSource(dataSource)
.mediaType("application/json")
.build()).getId();

policyId = client.uiApi().createPolicyDefinitionV2(PolicyDefinitionCreateDto.builder()
.policyDefinitionId("policy-1")
.policyDefinitionId("policy-" + offset)
.expression(UiPolicyExpression.builder()
.type(UiPolicyExpressionType.EMPTY)
.build())
Expand Down

0 comments on commit fd56d96

Please sign in to comment.