Skip to content

Commit

Permalink
Merge pull request #233 from catenax-ng/main
Browse files Browse the repository at this point in the history
feature: TRACEFOSS-2235 update test data to asBuilt 1.5.3 and asPlanned 1.5.1
  • Loading branch information
ds-jhartmann authored Aug 4, 2023
2 parents 6adf13a + f180121 commit 764cb8c
Show file tree
Hide file tree
Showing 9 changed files with 5,069 additions and 31 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
## [Unreleased]
### Added

- Configuration for left and right policies to use registry client library

### Changed

- Update asBuild test data to 1.5.3 and asPlanned to 1.5.1

### Removed

## [6.0.0 - 2023-07-21]
Expand Down
2 changes: 1 addition & 1 deletion DEPENDENCIES_BACKEND
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ maven/mavencentral/org.eclipse.edc/transfer-spi/0.1.3, Apache-2.0, approved, tec
maven/mavencentral/org.eclipse.edc/transform-spi/0.1.3, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/validator-spi/0.1.3, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/web-spi/0.1.3, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.tractusx.irs/irs-registry-client/1.0.0-20230724.103139-7, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.irs/irs-registry-client/1.0.0-20230731.142230-8, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.traceability/tx-backend/0.0.1-SNAPSHOT, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.traceability/tx-models/0.0.1-SNAPSHOT, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.flywaydb/flyway-core/9.5.1, Apache-2.0, approved, #7296
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,12 @@ mvn clean test
Product Traceability FOSS Backend relies on [Testcontainers library](https://www.testcontainers.org/) in order to provide
persistence layer, thus [Docker Engine](https://docs.docker.com/engine/) is required to be running.

To run integration tests invoke following command:
If you want to execute the integration tests with IntelliJ you must mark the src/integration/groovy folder as "Test Sources Root".

To run integration tests via command line, invoke following command:

```sh
mvn clean verify
mvn -pl tx-models,tx-backend,tx-coverage -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B verify
```

#### Running all tests
Expand Down
10 changes: 6 additions & 4 deletions dev/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,30 @@ Repeat those steps for registry, submodelserver, trace-x-provider-edcs, tracex-i

In order to upload data to EDC Provider, please use [IRS project script](https://github.com/catenax-ng/tx-item-relationship-service/blob/main/local/testing/testdata/transform-and-upload.py)

Keep in mind to always update DEV and TEST since they are dependend on each other.

Sample invocation (DEV)

```
python transform-and-upload.py -f CX_Testdata_MessagingTest_v0.0.6.json -s https://tracex-submodel-server.dev.demo.catena-x.net -edc https://trace-x-edc.dev.demo.catena-x.net -a https://trace-x-registry.dev.demo.catena-x.net/semantics/registry/api/v3.0 -p id-3.0-trace -k <apiKey> --aas3
python transform-and-upload.py -f CX_Testdata_MessagingTest_v0.0.7.json -s https://tracex-submodel-server.dev.demo.catena-x.net -edc https://trace-x-edc.dev.demo.catena-x.net -a https://trace-x-registry.dev.demo.catena-x.net/semantics/registry/api/v3.0 -p id-3.0-trace -k <apiKey> --aas3
```

Sample invocation (TEST)

```
python transform-and-upload.py -f CX_Testdata_MessagingTest_v0.0.6.json -s https://tracex-submodel-server-test.dev.demo.catena-x.net -edc https://trace-x-test-edc.dev.demo.catena-x.net -a https://trace-x-registry-test.dev.demo.catena-x.net/semantics/registry/api/v3.0 -p id-3.0-trace -k <apiKey> --aas3
python transform-and-upload.py -f CX_Testdata_MessagingTest_v0.0.7.json -s https://tracex-submodel-server-test.dev.demo.catena-x.net -edc https://trace-x-test-edc.dev.demo.catena-x.net -a https://trace-x-registry-test.dev.demo.catena-x.net/semantics/registry/api/v3.0 -p id-3.0-trace -k <apiKey> --aas3
```

Sample invocation (E2E A)

```
python transform-and-upload.py -f CX_Testdata_MessagingTest_v0.0.6.json -s https://tracex-submodel-server-e2e-a.dev.demo.catena-x.net -edc https://trace-x-edc-e2e-a.dev.demo.catena-x.net -a https://trace-x-registry-e2e-a.dev.demo.catena-x.net/semantics/registry/api/v3.0 -p id-3.0-trace -k <apiKey> --aas3
python transform-and-upload.py -f CX_Testdata_MessagingTest_v0.0.7.json -s https://tracex-submodel-server-e2e-a.dev.demo.catena-x.net -edc https://trace-x-edc-e2e-a.dev.demo.catena-x.net -a https://trace-x-registry-e2e-a.dev.demo.catena-x.net/semantics/registry/api/v3.0 -p id-3.0-trace -k <apiKey> --aas3
```

Sample invocation (E2E B)

```
python transform-and-upload.py -f CX_Testdata_MessagingTest_v0.0.6.json -s https://tracex-submodel-server-e2e-b.dev.demo.catena-x.net -edc https://trace-x-edc-e2e-b.dev.demo.catena-x.net -a https://trace-x-registry-e2e-b.dev.demo.catena-x.net/semantics/registry/api/v3.0 -p id-3.0-trace -k <apiKey> --aas3
python transform-and-upload.py -f CX_Testdata_MessagingTest_v0.0.7.json -s https://tracex-submodel-server-e2e-b.dev.demo.catena-x.net -edc https://trace-x-edc-e2e-b.dev.demo.catena-x.net -a https://trace-x-registry-e2e-b.dev.demo.catena-x.net/semantics/registry/api/v3.0 -p id-3.0-trace -k <apiKey> --aas3
```

where:
Expand Down
3,863 changes: 3,862 additions & 1 deletion tx-backend/openapi/traceability-foss-backend.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.eclipse.tractusx.traceability.assets.infrastructure.base.irs.model.response.semanticdatamodel.SemanticDataModel;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
Expand All @@ -57,11 +58,17 @@ public record JobDetailResponse(
private static final String AS_PLANNED_MAPPING_ASPECT_1 = "urn:bamm:io.catenax.part_as_planned:1.0.1#PartAsPlanned";
private static final String AS_PLANNED_MAPPING_ASPECT_2 = "urn:bamm:io.catenax.part_as_planned:1.0.0#PartAsPlanned";

private static final String AS_BUILT_MAPPING_ASPECT_SERIALPART_1 = "urn:bamm:io.catenax.serial_part:1.0.0#SerialPart";
private static final String AS_BUILT_MAPPING_ASPECT_SERIALPART_2 = "urn:samm:io.catenax.serial_part:1.0.0#SerialPart";
private static final String AS_BUILT_MAPPING_ASPECT_SERIALPART_3 = "urn:bamm:io.catenax.serial_part:1.1.0#SerialPart";
private static final String[] AS_BUILT_MAPPING_ASPECT_SERIALPART_LIST = {
"urn:bamm:io.catenax.serial_part:1.0.0#SerialPart",
"urn:samm:io.catenax.serial_part:1.0.0#SerialPart",
"urn:bamm:io.catenax.serial_part:1.1.0#SerialPart",
"urn:bamm:io.catenax.serial_part:1.0.1#SerialPart"
};

private static final String AS_BUILT_MAPPING_ASPECT_BATCH = "urn:bamm:io.catenax.batch:1.0.0#Batch";
private static final String[] AS_BUILT_MAPPING_ASPECT_BATCH = {
"urn:bamm:io.catenax.batch:1.0.0#Batch",
"urn:bamm:io.catenax.batch:1.0.2#Batch"
};

@JsonCreator
static JobDetailResponse of(
Expand Down Expand Up @@ -146,9 +153,9 @@ private boolean isSupplierDirection() {
private List<Asset> mapToOtherPartsAsBuilt(Map<String, String> shortIds, Owner owner, Map<String, String> bpnMapping) {
List<SemanticDataModel> otherParts = semanticDataModels().stream().filter(semanticDataModel -> isAsBuiltAndOtherPart(semanticDataModel, jobStatus)).toList();

log.info(":: mapToOtherPartsAsBuilt()" );
log.info(":: mapToOtherPartsAsBuilt()");
log.info(":: otherParts: {}", otherParts);
final List<Asset> assets = otherParts
final List<Asset> assets = otherParts
.stream()
.map(semanticDataModel -> semanticDataModel.toDomain(semanticDataModel.localIdentifiers(), shortIds, owner, bpnMapping,
Collections.emptyList(),
Expand All @@ -160,9 +167,9 @@ private List<Asset> mapToOtherPartsAsBuilt(Map<String, String> shortIds, Owner o

private List<Asset> mapToOtherPartsAsPlanned(Map<String, String> shortIds, Owner owner, Map<String, String> bpnMapping) {
List<SemanticDataModel> otherParts = semanticDataModels().stream().filter(semanticDataModel -> isAsPlannedAndOtherPart(semanticDataModel, jobStatus)).toList();
log.info(":: mapToOtherPartsAsPlanned()" );
log.info(":: mapToOtherPartsAsPlanned()");
log.info(":: otherParts: {}", otherParts);
final List<Asset> assets = otherParts
final List<Asset> assets = otherParts
.stream()
.map(semanticDataModel -> semanticDataModel.toDomainAsPlanned(shortIds, owner, bpnMapping,
Collections.emptyList(),
Expand All @@ -178,15 +185,15 @@ private List<Asset> mapToOwnPartsAsPlanned(Map<String, String> shortIds, Map<Str
semanticDataModels().stream()
.filter(semanticDataModel -> isAsPlannedAndOwnPart(semanticDataModel, jobStatus)).toList();

log.info(":: mapToOwnPartsAsPlanned()" );
log.info(":: mapToOwnPartsAsPlanned()");
log.info(":: ownPartsAsPlanned: {}", ownPartsAsPlanned);

Map<String, List<Relationship>> singleLevelBomRelationship = relationships().stream()
.filter(relationship -> SINGLE_LEVEL_BOM_AS_PLANNED.equals(relationship.aspectType().getAspectName()))
.collect(Collectors.groupingBy(Relationship::catenaXId, Collectors.toList()));


final List<Asset> assets = ownPartsAsPlanned
final List<Asset> assets = ownPartsAsPlanned
.stream()
.map(semanticDataModel -> semanticDataModel.toDomainAsPlanned(shortIds, Owner.OWN, bpnMapping,
Collections.emptyList(),
Expand All @@ -198,7 +205,7 @@ private List<Asset> mapToOwnPartsAsPlanned(Map<String, String> shortIds, Map<Str

private List<Asset> mapToOwnPartsAsBuilt(Map<String, String> shortIds, Map<String, String> bpnMapping) {
List<SemanticDataModel> ownParts = semanticDataModels().stream().filter(semanticDataModel -> isAsBuiltAndOwnPart(semanticDataModel, jobStatus)).toList();
log.info(":: mapToOwnPartsAsBuilt()" );
log.info(":: mapToOwnPartsAsBuilt()");
log.info(":: ownParts: {}", ownParts);
// The Relationship on supplierPart catenaXId contains the id of the asset which has a relationship
Map<String, List<Relationship>> supplierPartsMap = relationships().stream()
Expand Down Expand Up @@ -239,22 +246,18 @@ private List<Descriptions> getParentParts(Map<String, List<Relationship>> relati

private boolean isAsBuiltAndOwnPart(SemanticDataModel semanticDataModel, JobStatus jobStatus) {
final boolean result = semanticDataModel.getCatenaXId().equals(jobStatus.globalAssetId()) &&
(semanticDataModel.aspectType().equals(AS_BUILT_MAPPING_ASPECT_SERIALPART_1)
|| semanticDataModel.aspectType().equals(AS_BUILT_MAPPING_ASPECT_SERIALPART_2)
|| semanticDataModel.aspectType().equals(AS_BUILT_MAPPING_ASPECT_SERIALPART_3)
|| semanticDataModel.aspectType().equals(AS_BUILT_MAPPING_ASPECT_BATCH));
(Arrays.asList(AS_BUILT_MAPPING_ASPECT_SERIALPART_LIST).contains(semanticDataModel.aspectType())
|| Arrays.asList(AS_BUILT_MAPPING_ASPECT_BATCH).contains(semanticDataModel.aspectType()));
log.info(":: isAsBuildAndOwnPart() {}", semanticDataModel);
log.info(":: result: {}", result);
return result;
}

private boolean isAsBuiltAndOtherPart(SemanticDataModel semanticDataModel, JobStatus jobStatus) {
final boolean result =!semanticDataModel.getCatenaXId()
final boolean result = !semanticDataModel.getCatenaXId()
.equals(jobStatus.globalAssetId()) &&
(semanticDataModel.aspectType().equals(AS_BUILT_MAPPING_ASPECT_SERIALPART_1)
|| semanticDataModel.aspectType().equals(AS_BUILT_MAPPING_ASPECT_SERIALPART_2)
|| semanticDataModel.aspectType().equals(AS_BUILT_MAPPING_ASPECT_SERIALPART_3)
|| semanticDataModel.aspectType().equals(AS_BUILT_MAPPING_ASPECT_BATCH));
(Arrays.asList(AS_BUILT_MAPPING_ASPECT_SERIALPART_LIST).contains(semanticDataModel.aspectType())
|| Arrays.asList(AS_BUILT_MAPPING_ASPECT_BATCH).contains(semanticDataModel.aspectType()));
log.info(":: isAsBuiltAndOtherPart() {}", semanticDataModel);
log.info(":: result: {}", result);
return result;
Expand All @@ -270,7 +273,7 @@ private boolean isAsPlannedAndOwnPart(SemanticDataModel semanticDataModel, JobSt

private boolean isAsPlannedAndOtherPart(SemanticDataModel semanticDataModel, JobStatus jobStatus) {
final boolean result = !semanticDataModel.getCatenaXId().equals(jobStatus.globalAssetId())
&& (semanticDataModel.aspectType().equals(AS_PLANNED_MAPPING_ASPECT_1) ||semanticDataModel.aspectType().equals(AS_PLANNED_MAPPING_ASPECT_2) );
&& (semanticDataModel.aspectType().equals(AS_PLANNED_MAPPING_ASPECT_1) || semanticDataModel.aspectType().equals(AS_PLANNED_MAPPING_ASPECT_2));
log.info(":: isAsPlannedAndOtherPart() {}", semanticDataModel);
log.info(":: result: {}", result);
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ class Submodel {
@Type(value = SemanticDataModel.class, names = {
"urn:samm:io.catenax.serial_part:1.0.0#SerialPart",
"urn:bamm:io.catenax.serial_part:1.0.0#SerialPart",
"urn:bamm:io.catenax.serial_part:1.1.0#SerialPart"
"urn:bamm:io.catenax.serial_part:1.1.0#SerialPart",
"urn:bamm:io.catenax.serial_part:1.0.1#SerialPart"

}),
@Type(value = SemanticDataModel.class, names = {
"urn:bamm:com.catenax.batch:1.0.0#Batch",
"urn:bamm:io.catenax.batch:1.0.0#Batch"
"urn:bamm:io.catenax.batch:1.0.0#Batch",
"urn:bamm:io.catenax.batch:1.0.2#Batch"
}),
@Type(value = SemanticDataModel.class, names = {
"urn:bamm:io.catenax.part_as_planned:1.0.1#PartAsPlanned",
Expand Down
4 changes: 4 additions & 0 deletions tx-backend/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ irs-edc-client:
read: PT90S # HTTP read timeout for the submodel client
connect: PT90S # HTTP connect timeout for the submodel client

catalog:
policies:
acceptedRightOperands: active # List of comma separated names of the rightOperands to accept.
acceptedLeftOperands: idsc:PURPOSE # List of comma separated names of the leftOperands to accept.

server:
servlet:
Expand Down
Loading

0 comments on commit 764cb8c

Please sign in to comment.