Skip to content

Commit b10f948

Browse files
fix: cosmos tests
1 parent 017f10e commit b10f948

File tree

7 files changed

+42
-53
lines changed

7 files changed

+42
-53
lines changed

DEPENDENCIES

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ maven/mavencentral/org.junit.platform/junit-platform-engine/1.10.0, EPL-2.0, app
532532
maven/mavencentral/org.junit.platform/junit-platform-engine/1.9.2, EPL-2.0, approved, #3128
533533
maven/mavencentral/org.junit.platform/junit-platform-engine/1.9.3, EPL-2.0, approved, #3128
534534
maven/mavencentral/org.junit.platform/junit-platform-launcher/1.10.0, EPL-2.0, approved, #9704
535-
maven/mavencentral/org.junit/junit-bom/5.10.0, , restricted, clearlydefined
535+
maven/mavencentral/org.junit/junit-bom/5.10.0, EPL-2.0, approved, #9844
536536
maven/mavencentral/org.junit/junit-bom/5.9.2, EPL-2.0, approved, #4711
537537
maven/mavencentral/org.junit/junit-bom/5.9.3, EPL-2.0, approved, #4711
538538
maven/mavencentral/org.jvnet.mimepull/mimepull/1.9.15, CDDL-1.1 OR GPL-2.0-only WITH Classpath-exception-2.0, approved, CQ21484

extensions/control-plane/store/contract-definition-store-cosmos/src/test/java/org/eclipse/edc/connector/store/azure/cosmos/contractdefinition/PostgresContractDefinitionStoreTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import java.util.List;
4242

4343
import static java.util.stream.IntStream.range;
44+
import static org.assertj.core.api.Assertions.assertThat;
4445
import static org.assertj.core.api.Assertions.assertThatThrownBy;
4546
import static org.eclipse.edc.azure.testfixtures.CosmosPostgresTestExtension.DEFAULT_DATASOURCE_NAME;
4647
import static org.eclipse.edc.junit.testfixtures.TestUtils.getResourceFileContentAsString;
@@ -83,10 +84,7 @@ void findAll_queryByInvalidKey() {
8384
.filter(List.of(new Criterion("notexist", "=", "somevalue")))
8485
.build();
8586

86-
assertThatThrownBy(() -> getContractDefinitionStore().findAll(spec))
87-
.isInstanceOf(IllegalArgumentException.class)
88-
.hasMessageStartingWith("Translation failed for Model");
89-
87+
assertThat(getContractDefinitionStore().findAll(spec)).isEmpty();
9088
}
9189

9290
// Override in PG since it does not have the field mapping

extensions/control-plane/store/contract-negotiation-store-cosmos/src/test/java/org/eclipse/edc/connector/store/azure/cosmos/contractnegotiation/CosmosContractNegotiationStoreTest.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252

5353
import static java.util.stream.IntStream.range;
5454
import static org.assertj.core.api.Assertions.assertThat;
55-
import static org.assertj.core.api.Assertions.assertThatThrownBy;
5655
import static org.eclipse.edc.azure.testfixtures.CosmosPostgresTestExtension.DEFAULT_DATASOURCE_NAME;
5756
import static org.eclipse.edc.connector.contract.spi.testfixtures.negotiation.store.TestFunctions.createContract;
5857
import static org.eclipse.edc.connector.contract.spi.testfixtures.negotiation.store.TestFunctions.createContractBuilder;
@@ -168,9 +167,7 @@ void query_invalidKey_shouldThrowException() {
168167

169168
var expression = criterion("contractAgreement.notexist", "=", contractId.toString());
170169
var query = QuerySpec.Builder.newInstance().filter(expression).build();
171-
assertThatThrownBy(() -> store.queryNegotiations(query))
172-
.isInstanceOf(IllegalArgumentException.class)
173-
.hasMessageStartingWith("Translation failed for Model");
170+
assertThat(store.queryNegotiations(query)).isEmpty();
174171
}
175172

176173
@Test
@@ -212,7 +209,7 @@ void queryAgreements_withQuerySpec_invalidOperand() {
212209
});
213210

214211
var query = QuerySpec.Builder.newInstance().filter(criterion("notexistprop", "=", "asset-2")).build();
215-
assertThatThrownBy(() -> store.queryAgreements(query));
212+
assertThat(store.queryAgreements(query)).isEmpty();
216213
}
217214

218215
@Test

extensions/control-plane/store/contract-negotiation-store-cosmos/src/test/resources/schema.sql

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,17 @@ CREATE TABLE IF NOT EXISTS edc_contract_agreement
3737

3838
CREATE TABLE IF NOT EXISTS edc_contract_negotiation
3939
(
40-
id VARCHAR NOT NULL
40+
id VARCHAR NOT NULL
4141
CONSTRAINT contract_negotiation_pk
4242
PRIMARY KEY,
43-
created_at BIGINT NOT NULL,
44-
updated_at BIGINT NOT NULL,
43+
created_at BIGINT NOT NULL,
44+
updated_at BIGINT NOT NULL,
4545
correlation_id VARCHAR,
46-
counterparty_id VARCHAR NOT NULL,
47-
counterparty_address VARCHAR NOT NULL,
48-
protocol VARCHAR NOT NULL,
49-
type VARCHAR NOT NULL,
50-
state INTEGER DEFAULT 0 NOT NULL,
46+
counterparty_id VARCHAR NOT NULL,
47+
counterparty_address VARCHAR NOT NULL,
48+
protocol VARCHAR NOT NULL,
49+
type VARCHAR NOT NULL,
50+
state INTEGER DEFAULT 0 NOT NULL,
5151
state_count INTEGER DEFAULT 0,
5252
state_timestamp BIGINT,
5353
error_detail VARCHAR,
@@ -57,6 +57,7 @@ CREATE TABLE IF NOT EXISTS edc_contract_negotiation
5757
contract_offers JSON,
5858
callback_addresses JSON,
5959
trace_context JSON,
60+
pending BOOLEAN DEFAULT FALSE,
6061
lease_id VARCHAR
6162
CONSTRAINT contract_negotiation_lease_lease_id_fk
6263
REFERENCES edc_lease

extensions/control-plane/store/policy-definition-store-cosmos/src/test/java/org/eclipse/edc/connector/store/azure/cosmos/policydefinition/CosmosPolicyDefinitionStoreTest.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import java.util.stream.IntStream;
3737
import javax.sql.DataSource;
3838

39+
import static org.assertj.core.api.Assertions.assertThat;
3940
import static org.assertj.core.api.Assertions.assertThatThrownBy;
4041
import static org.eclipse.edc.azure.testfixtures.CosmosPostgresTestExtension.DEFAULT_DATASOURCE_NAME;
4142
import static org.eclipse.edc.connector.policy.spi.testfixtures.TestFunctions.createPolicy;
@@ -85,9 +86,7 @@ void find_queryByProperty_notExist() {
8586

8687
// query by prohibition assignee
8788
var querySpec = QuerySpec.Builder.newInstance().filter(criterion("notexist", "=", "foobar")).build();
88-
assertThatThrownBy(() -> getPolicyDefinitionStore().findAll(querySpec))
89-
.isInstanceOf(IllegalArgumentException.class)
90-
.hasMessageStartingWith("Translation failed for Model");
89+
assertThat(getPolicyDefinitionStore().findAll(querySpec)).isEmpty();
9190
}
9291

9392
@Test
@@ -96,8 +95,7 @@ void findAll_sorting_nonExistentProperty() {
9695
IntStream.range(0, 10).mapToObj(i -> createPolicy("test-policy")).forEach((d) -> getPolicyDefinitionStore().create(d));
9796
var query = QuerySpec.Builder.newInstance().sortField("notexist").sortOrder(SortOrder.DESC).build();
9897
assertThatThrownBy(() -> getPolicyDefinitionStore().findAll(query))
99-
.isInstanceOf(IllegalArgumentException.class)
100-
.hasMessageStartingWith("Translation failed for Model");
98+
.isInstanceOf(IllegalArgumentException.class);
10199

102100
}
103101

extensions/control-plane/store/transfer-process-store-cosmos/src/test/java/org/eclipse/edc/connector/store/azure/cosmos/transferprocess/CosmosTransferProcessStoreTest.java

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@
1616

1717
import org.awaitility.Awaitility;
1818
import org.eclipse.edc.azure.testfixtures.CosmosPostgresTestExtension;
19-
import org.eclipse.edc.azure.testfixtures.annotations.ParallelPostgresCosmosTest;
19+
import org.eclipse.edc.azure.testfixtures.annotations.PostgresCosmosTest;
2020
import org.eclipse.edc.connector.store.sql.transferprocess.store.SqlTransferProcessStore;
2121
import org.eclipse.edc.connector.store.sql.transferprocess.store.schema.postgres.PostgresDialectStatements;
2222
import org.eclipse.edc.connector.transfer.spi.testfixtures.store.TestFunctions;
2323
import org.eclipse.edc.connector.transfer.spi.testfixtures.store.TransferProcessStoreTestBase;
2424
import org.eclipse.edc.connector.transfer.spi.types.ProvisionedResourceSet;
2525
import org.eclipse.edc.connector.transfer.spi.types.ResourceManifest;
2626
import org.eclipse.edc.policy.model.PolicyRegistrationTypes;
27+
import org.eclipse.edc.spi.persistence.EdcPersistenceException;
2728
import org.eclipse.edc.spi.query.Criterion;
2829
import org.eclipse.edc.spi.query.QuerySpec;
2930
import org.eclipse.edc.spi.query.SortOrder;
@@ -46,7 +47,6 @@
4647

4748
import static java.util.stream.IntStream.range;
4849
import static org.assertj.core.api.Assertions.assertThat;
49-
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
5050
import static org.assertj.core.api.Assertions.assertThatThrownBy;
5151
import static org.eclipse.edc.azure.testfixtures.CosmosPostgresTestExtension.DEFAULT_DATASOURCE_NAME;
5252
import static org.eclipse.edc.connector.transfer.spi.testfixtures.store.TestFunctions.createDataRequest;
@@ -57,7 +57,7 @@
5757
import static org.eclipse.edc.spi.persistence.StateEntityStore.hasState;
5858
import static org.hamcrest.Matchers.hasSize;
5959

60-
@ParallelPostgresCosmosTest
60+
@PostgresCosmosTest
6161
@ExtendWith(CosmosPostgresTestExtension.class)
6262
class CosmosTransferProcessStoreTest extends TransferProcessStoreTestBase {
6363

@@ -114,8 +114,7 @@ void find_queryByDataRequest_propNotExist() {
114114
.filter(List.of(new Criterion("dataRequest.notexist", "=", "somevalue")))
115115
.build();
116116

117-
assertThatThrownBy(() -> store.findAll(query)).isInstanceOf(IllegalArgumentException.class)
118-
.hasMessageStartingWith("Translation failed");
117+
assertThat(store.findAll(query)).isEmpty();
119118
}
120119

121120

@@ -134,8 +133,7 @@ void find_queryByResourceManifest_propNotExist() {
134133
.filter(List.of(new Criterion("resourceManifest.foobar", "=", "someval")))
135134
.build();
136135

137-
assertThatThrownBy(() -> store.findAll(query)).isInstanceOf(IllegalArgumentException.class)
138-
.hasMessageStartingWith("Translation failed for Model");
136+
assertThat(store.findAll(query)).isEmpty();
139137

140138
// returns empty when the invalid value is embedded in JSON
141139
var query2 = QuerySpec.Builder.newInstance()
@@ -166,8 +164,7 @@ void find_queryByProvisionedResourceSet_propNotExist() {
166164
var query = QuerySpec.Builder.newInstance()
167165
.filter(List.of(new Criterion("provisionedResourceSet.foobar.transferProcessId", "=", "testprocess1")))
168166
.build();
169-
assertThatThrownBy(() -> store.findAll(query)).isInstanceOf(IllegalArgumentException.class)
170-
.hasMessageStartingWith("Translation failed for Model");
167+
assertThat(store.findAll(query)).isEmpty();
171168

172169
// returns empty when the invalid value is embedded in JSON
173170
var query2 = QuerySpec.Builder.newInstance()
@@ -186,8 +183,7 @@ void find_queryByLease() {
186183
.filter(List.of(new Criterion("lease.leasedBy", "=", "foobar")))
187184
.build();
188185

189-
assertThatThrownBy(() -> store.findAll(query)).isInstanceOf(IllegalArgumentException.class)
190-
.hasMessageStartingWith("Translation failed for Model");
186+
assertThat(store.findAll(query)).isEmpty();
191187

192188
}
193189

@@ -196,7 +192,7 @@ void create_withoutDataRequest_throwsException() {
196192
var t1 = TestFunctions.createTransferProcessBuilder("id1")
197193
.dataRequest(null)
198194
.build();
199-
assertThatIllegalArgumentException().isThrownBy(() -> getTransferProcessStore().save(t1));
195+
assertThatThrownBy(() -> getTransferProcessStore().save(t1)).isInstanceOf(EdcPersistenceException.class);
200196
}
201197

202198

@@ -219,8 +215,7 @@ protected void findAll_verifySorting_invalidProperty() {
219215
var query = QuerySpec.Builder.newInstance().sortField("notexist").sortOrder(SortOrder.DESC).build();
220216

221217
assertThatThrownBy(() -> getTransferProcessStore().findAll(query))
222-
.isInstanceOf(IllegalArgumentException.class)
223-
.hasMessageStartingWith("Translation failed for Model");
218+
.isInstanceOf(IllegalArgumentException.class);
224219
}
225220

226221
@Override

extensions/control-plane/store/transfer-process-store-cosmos/src/test/resources/schema.sql

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,22 @@ CREATE TABLE IF NOT EXISTS edc_transfer_process
1919
transferprocess_id VARCHAR NOT NULL
2020
CONSTRAINT transfer_process_pk
2121
PRIMARY KEY,
22-
type VARCHAR NOT NULL,
23-
state INTEGER NOT NULL,
24-
state_count INTEGER DEFAULT 0 NOT NULL,
25-
state_time_stamp BIGINT,
26-
created_at BIGINT NOT NULL,
27-
updated_at BIGINT NOT NULL,
28-
trace_context JSON,
29-
error_detail VARCHAR,
30-
resource_manifest JSON,
31-
provisioned_resource_set JSON,
32-
content_data_address JSON,
33-
deprovisioned_resources JSON,
34-
private_properties JSON,
35-
callback_addresses JSON,
36-
lease_id VARCHAR
22+
type VARCHAR NOT NULL,
23+
state INTEGER NOT NULL,
24+
state_count INTEGER DEFAULT 0 NOT NULL,
25+
state_time_stamp BIGINT,
26+
created_at BIGINT NOT NULL,
27+
updated_at BIGINT NOT NULL,
28+
trace_context JSON,
29+
error_detail VARCHAR,
30+
resource_manifest JSON,
31+
provisioned_resource_set JSON,
32+
content_data_address JSON,
33+
deprovisioned_resources JSON,
34+
private_properties JSON,
35+
callback_addresses JSON,
36+
pending BOOLEAN DEFAULT FALSE,
37+
lease_id VARCHAR
3738
CONSTRAINT transfer_process_lease_lease_id_fk
3839
REFERENCES edc_lease
3940
ON DELETE SET NULL
@@ -65,7 +66,6 @@ CREATE TABLE IF NOT EXISTS edc_data_request
6566
asset_id VARCHAR NOT NULL,
6667
contract_id VARCHAR NOT NULL,
6768
data_destination JSON NOT NULL,
68-
managed_resources BOOLEAN DEFAULT TRUE,
6969
transfer_process_id VARCHAR NOT NULL
7070
CONSTRAINT data_request_transfer_process_id_fk
7171
REFERENCES edc_transfer_process

0 commit comments

Comments
 (0)