Skip to content

Commit

Permalink
fix(recursion): Add unit tests for BPN check
Browse files Browse the repository at this point in the history
  • Loading branch information
ds-jkreutzfeld committed Jul 20, 2023
1 parent ee74c8a commit 7319bf0
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,25 @@ void shouldFillItemContainerWithRelationshipAndAddChildIdsToProcess()
assertThat(aasTransferProcess.getIdsToProcess()).isNotEmpty();
}

@Test
void shouldPutTombstoneForMissingBpn() throws EdcClientException {
final ItemContainer.ItemContainerBuilder itemContainerWithShell = ItemContainer.builder()
.shell(shellDescriptor(
List.of(submodelDescriptor(
singleLevelBomAsBuiltAspectName,
"address"))));
// when
final ItemContainer result = relationshipDelegate.process(itemContainerWithShell, jobParameter(),
new AASTransferProcess(), PartChainIdentificationKey.builder().globalAssetId("testId").build());

// then
assertThat(result).isNotNull();
assertThat(result.getTombstones()).hasSize(1);
assertThat(result.getTombstones().get(0).getCatenaXId()).isEqualTo("testId");
assertThat(result.getTombstones().get(0).getProcessingError().getProcessStep()).isEqualTo(
ProcessStep.SUBMODEL_REQUEST);
}

@Test
void shouldCatchRestClientExceptionAndPutTombstone() throws EdcClientException {
// given
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,29 @@ void shouldCatchJsonParseExceptionAndPutTombstone() throws SchemaNotFoundExcepti
ProcessStep.SCHEMA_VALIDATION);
}


@Test
void shouldPutTombstoneForMissingBpn() {
final ItemContainer.ItemContainerBuilder itemContainerShellWithTwoSubmodels = ItemContainer.builder()
.shell(shellDescriptor(
List.of(submodelDescriptor(
"urn:bamm:com.catenax.serial_part:1.0.0#SerialPart",
"testSerialPartEndpoint"),
submodelDescriptor(
"urn:bamm:com.catenax.single_level_bom_as_built:1.0.0#SingleLevelBomAsBuilt",
"testSingleLevelBomAsBuiltEndpoint"))));

// when
final ItemContainer result = submodelDelegate.process(itemContainerShellWithTwoSubmodels, jobParameterCollectAspects(),
new AASTransferProcess(), PartChainIdentificationKey.builder().globalAssetId("testId").build());

// then
assertThat(result).isNotNull();
assertThat(result.getTombstones()).hasSize(2);
assertThat(result.getTombstones().get(0).getCatenaXId()).isEqualTo("testId");
assertThat(result.getTombstones().get(0).getProcessingError().getProcessStep()).isEqualTo(
ProcessStep.SUBMODEL_REQUEST);
}
@Test
void shouldCatchUsagePolicyExceptionAndPutTombstone() throws EdcClientException {
// given
Expand Down

0 comments on commit 7319bf0

Please sign in to comment.