Skip to content

Commit

Permalink
feat(impl):[#488] new datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
ds-ext-kmassalski committed Mar 28, 2024
1 parent 59db4a6 commit 7d3f25f
Show file tree
Hide file tree
Showing 23 changed files with 273,443 additions and 235,137 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,11 @@ public String getModelJsonSchema(final String urn) {
@Override
public List<AspectModel> getAllAspectModels() {
return List.of(
new AspectModel("urn:bamm:io.catenax.serial_part:1.0.1#SerialPart", "1.0.1",
new AspectModel("urn:samm:io.catenax.serial_part:3.0.0#SerialPart", "3.0.0",
"SerialPart", MODEL_TYPE, MODEL_STATUS),
new AspectModel("urn:bamm:io.catenax.esr_certificates.esr_certificate:1.0.0#EsrCertificate", "1.0.0",
"EsrCertificate", MODEL_TYPE, MODEL_STATUS),
new AspectModel("urn:bamm:io.catenax.single_level_bom_as_built:2.0.0#SingleLevelBomAsBuilt",
"2.0.0", "SingleLevelBomAsBuilt", MODEL_TYPE, MODEL_STATUS),
new AspectModel("urn:bamm:io.catenax.part_as_specified:2.0.0#PartAsSpecified",
new AspectModel("urn:samm:io.catenax.single_level_bom_as_built:3.0.0#SingleLevelBomAsBuilt",
"3.0.0", "SingleLevelBomAsBuilt", MODEL_TYPE, MODEL_STATUS),
new AspectModel("urn:samm:io.catenax.part_as_specified:2.0.0#PartAsSpecified",
"2.0.0", "PartAsSpecified", MODEL_TYPE, MODEL_STATUS),
new AspectModel("urn:bamm:io.catenax.part_as_planned:1.0.1#PartAsPlanned",
"1.0.1", "PartAsPlanned", MODEL_TYPE, MODEL_STATUS));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import static org.eclipse.tractusx.irs.testing.wiremock.SubmodelFacadeWiremockSupport.PATH_NEGOTIATE;
import static org.eclipse.tractusx.irs.testing.wiremock.SubmodelFacadeWiremockSupport.PATH_STATE;
import static org.eclipse.tractusx.irs.testing.wiremock.SubmodelFacadeWiremockSupport.PATH_TRANSFER;
import static org.eclipse.tractusx.irs.util.TestMother.batchAspectName;
import static org.eclipse.tractusx.irs.util.TestMother.singleLevelBomAsBuiltAspectName;

import java.time.Duration;
Expand Down Expand Up @@ -153,7 +154,7 @@ void shouldStartApplicationAndCollectSemanticModels() throws SchemaNotFoundExcep
final AspectModels allAspectModels = semanticHubService.getAllAspectModels();

// Assert
assertThat(allAspectModels.models()).hasSize(79);
assertThat(allAspectModels.models()).hasSize(99);
}

@Test
Expand Down Expand Up @@ -288,7 +289,7 @@ private void successfulRegistryAndDataRequest(final String globalAssetId, final

final String edcAssetId = WiremockSupport.randomUUIDwithPrefix();
final String batch = WiremockSupport.submodelRequest(edcAssetId, "Batch",
"urn:samm:io.catenax.batch:2.0.0#Batch", batchFileName);
batchAspectName, batchFileName);

final String singleLevelBomAsBuilt = WiremockSupport.submodelRequest(edcAssetId, "SingleLevelBomAsBuilt",
singleLevelBomAsBuiltAspectName, sbomFileName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
* WireMock configurations and requests used for testing Semantic Hub fLow.
*/
public final class SemanticHubWireMockSupport {
public static final String BATCH_URN = "urn:samm:io.catenax.batch:2.0.0%23Batch";
private static final String SINGLE_LEVEL_BOM_AS_BUILT_URN = "urn:bamm:io.catenax.single_level_bom_as_built:2.0.0%23SingleLevelBomAsBuilt";
public static final String BATCH_URN = "urn:samm:io.catenax.batch:3.0.0%23Batch";
private static final String SINGLE_LEVEL_BOM_AS_BUILT_URN = "urn:samm:io.catenax.single_level_bom_as_built:3.0.0%23SingleLevelBomAsBuilt";
public static final String SCHEMA_PATH_PLACEHOLDER = "/models/%s/json-schema";
public static final String SEMANTIC_HUB_SCHEMA_URL =
"http://semantic.hub" + SCHEMA_PATH_PLACEHOLDER.formatted("{urn}");
Expand All @@ -44,12 +44,12 @@ private SemanticHubWireMockSupport() {
}

public static void semanticHubWillReturnBatchSchema() {
schemaResponse200(SCHEMA_PATH_PLACEHOLDER.formatted(BATCH_URN), "semantichub/batch-2.0.0-schema.json");
schemaResponse200(SCHEMA_PATH_PLACEHOLDER.formatted(BATCH_URN), "semantichub/batch-3.0.0-schema.json");
}

public static void semanticHubWillReturnSingleLevelBomAsBuiltSchema() {
schemaResponse200(SCHEMA_PATH_PLACEHOLDER.formatted(SINGLE_LEVEL_BOM_AS_BUILT_URN),
"semantichub/singleLevelBomAsBuilt-2.0.0-schema.json");
"semantichub/singleLevelBomAsBuilt-3.0.0-schema.json");
}

private static void schemaResponse200(final String urlRegex, final String fileName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ void shouldReturnJsonSchema() throws SchemaNotFoundException {
semanticHubWillReturnBatchSchema();

// Act
final String modelJsonSchema = semanticsHubFacade.getModelJsonSchema("urn:samm:io.catenax.batch:2.0.0#Batch");
final String modelJsonSchema = semanticsHubFacade.getModelJsonSchema("urn:samm:io.catenax.batch:3.0.0#Batch");

// Assert
assertThat(modelJsonSchema).contains("urn_samm_io.catenax.batch_2.0.0_CatenaXIdTrait")
.contains("A batch is a quantity of (semi-) finished products or (raw) material");
SemanticHubWireMockSupport.verifySemanticHubWasCalledForModel("urn:samm:io.catenax.batch:2.0.0%23Batch", 1);
assertThat(modelJsonSchema).contains("urn_samm_io.catenax.shared.uuid_2.0.0_UuidV4Trait")
.contains("A batch is a quantity of(semi-)finished products or(raw)material");
SemanticHubWireMockSupport.verifySemanticHubWasCalledForModel("urn:samm:io.catenax.batch:3.0.0%23Batch", 1);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ void registerJobWithCollectAspectsShouldIncludeSubmodels() throws InvalidSchemaE
when(jsonValidatorService.validate(any(), any())).thenReturn(ValidationResult.builder().valid(true).build());
when(connectorEndpointsService.fetchConnectorEndpoints(any())).thenReturn(
List.of("https://connector.endpoint.nl"));
final RegisterJob registerJob = registerJob("urn:uuid:8ddd8fe0-1b4f-44b4-90f3-a8f68e551ac7", 100,
final RegisterJob registerJob = registerJob("urn:uuid:1398cd56-682b-4c94-93ac-4807f9bfca41", 100,
List.of(serialPartAspectName, productDescriptionAspectName, singleLevelBomAsBuiltAspectName),
true, false, Direction.DOWNWARD);
when(connectorEndpointsService.fetchConnectorEndpoints(registerJob.getKey().getBpn())).thenReturn(
Expand All @@ -146,7 +146,7 @@ void registerJobWithCollectAspectsShouldIncludeSubmodels() throws InvalidSchemaE
// then
given().ignoreException(ResponseStatusException.class)
.await()
.atMost(10, TimeUnit.SECONDS)
.atMost(10, TimeUnit.MINUTES)
.until(() -> getSubmodelsSize(registeredJob.getId()), greaterThan(0));
}

Expand Down Expand Up @@ -192,7 +192,7 @@ void registerJobWithDepthShouldBuildTreeUntilGivenDepth() {
@Test
void registerJobWithUpwardDirectionShouldBuildRelationships() {
// given
final RegisterJob registerJob = registerJobWithDirection("urn:uuid:819816fe-7346-49a5-b528-cec5b5367a71",
final RegisterJob registerJob = registerJobWithDirection("urn:uuid:1398cd56-682b-4c94-93ac-4807f9bfca41",
Direction.UPWARD);
when(connectorEndpointsService.fetchConnectorEndpoints(any())).thenReturn(
List.of("http://localhost/discovery"));
Expand Down
20 changes: 10 additions & 10 deletions irs-api/src/test/java/org/eclipse/tractusx/irs/util/TestMother.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@
*/
public class TestMother {

public static final String singleLevelBomAsBuiltAspectName = "urn:bamm:io.catenax.single_level_bom_as_built:2.0.0#SingleLevelBomAsBuilt";
public static final String singleLevelUsageAsBuiltAspectName = "urn:bamm:io.catenax.single_level_usage_as_built:2.0.0#SingleLevelUsageAsBuilt";
public static final String serialPartAspectName = "urn:bamm:io.catenax.serial_part:1.0.1#SerialPart";
public static final String batchAspectName = "urn:samm:io.catenax.batch:2.0.0#Batch";
public static final String materialForRecyclingAspectName = "urn:bamm:io.catenax.material_for_recycling:1.1.0#MaterialForRecycling";
public static final String productDescriptionAspectName = "urn:bamm:io.catenax.vehicle.product_description:2.0.0#ProductDescription";
public static final String singleLevelBomAsBuiltAspectName = "urn:samm:io.catenax.single_level_bom_as_built:3.0.0#SingleLevelBomAsBuilt";
public static final String singleLevelUsageAsBuiltAspectName = "urn:samm:io.catenax.single_level_usage_as_built:2.0.0#SingleLevelUsageAsBuilt";
public static final String serialPartAspectName = "urn:samm:io.catenax.serial_part:3.0.0#SerialPart";
public static final String batchAspectName = "urn:samm:io.catenax.batch:3.0.0#Batch";
public static final String materialForRecyclingAspectName = "urn:samm:io.catenax.material_for_recycling:1.1.0#MaterialForRecycling";
public static final String productDescriptionAspectName = "urn:samm:io.catenax.battery.product_description:1.0.1#ProductDescription";

Faker faker = new Faker();

Expand All @@ -89,7 +89,7 @@ public static RegisterJob registerJobWithoutDepth() {
}

public static RegisterJob registerJobWithDepthAndAspect(final Integer depth, final List<String> aspectTypes) {
return registerJob("urn:uuid:8ddd8fe0-1b4f-44b4-90f3-a8f68e551ac7", depth, aspectTypes, false, false,
return registerJob("urn:uuid:1398cd56-682b-4c94-93ac-4807f9bfca41", depth, aspectTypes, false, false,
Direction.DOWNWARD);
}

Expand All @@ -98,20 +98,20 @@ public static RegisterJob registerJobWithDirection(final String globalAssetId, f
}

public static RegisterJob registerJobWithUrl(final String callbackUrl) {
final RegisterJob registerJob = registerJob("urn:uuid:8ddd8fe0-1b4f-44b4-90f3-a8f68e551ac7", 100, List.of(),
final RegisterJob registerJob = registerJob("urn:uuid:1398cd56-682b-4c94-93ac-4807f9bfca41", 100, List.of(),
false, false, Direction.DOWNWARD);
registerJob.setCallbackUrl(callbackUrl);
return registerJob;
}

public static RegisterJob registerJobWithDepthAndAspectAndCollectAspects(final Integer depth,
final List<String> aspectTypes) {
return registerJob("urn:uuid:8ddd8fe0-1b4f-44b4-90f3-a8f68e551ac7", depth, aspectTypes, true, false,
return registerJob("urn:uuid:1398cd56-682b-4c94-93ac-4807f9bfca41", depth, aspectTypes, true, false,
Direction.DOWNWARD);
}

public static RegisterJob registerJobWithLookupBPNs() {
return registerJob("urn:uuid:8ddd8fe0-1b4f-44b4-90f3-a8f68e551ac7", null,
return registerJob("urn:uuid:1398cd56-682b-4c94-93ac-4807f9bfca41", null,
List.of(singleLevelBomAsBuiltAspectName), false, true, Direction.DOWNWARD);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
{
"catenaXId": "urn:uuid:7e4541ea-bb0f-464c-8cb3-021abccbfaf5",
"quantity": {
"quantityNumber": 0.2014,
"measurementUnit": "unit:kilogram"
"value": 0.2014,
"unit": "unit:kilogram"
},
"hasAlternatives": true,
"businessPartner": "BPNL00000000TEST",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"catenaXId": "urn:uuid:a314ad6b-77ea-417e-ae2d-193b3e249e99",
"quantity": {
"quantityNumber": 0.2014,
"quantityNumber": 0.4014,
"measurementUnit": "unit:kilogram"
},
"hasAlternatives": true,
Expand Down
Loading

0 comments on commit 7d3f25f

Please sign in to comment.