Skip to content

Commit

Permalink
feat(impl):[#370] add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
ds-ext-kmassalski committed Jan 31, 2024
1 parent eb69da9 commit dceda1f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.eclipse.tractusx.irs.util.TestMother.jobParameter;
import static org.eclipse.tractusx.irs.util.TestMother.jobParameterAuditContractNegotiation;
import static org.eclipse.tractusx.irs.util.TestMother.shell;
import static org.eclipse.tractusx.irs.util.TestMother.shellDescriptor;
import static org.eclipse.tractusx.irs.util.TestMother.submodelDescriptorWithoutHref;
Expand Down Expand Up @@ -64,6 +65,24 @@ void shouldFillItemContainerWithShell() throws RegistryServiceException {
assertThat(result).isNotNull();
assertThat(result.getShells()).isNotEmpty();
assertThat(result.getShells().get(0).payload().getSubmodelDescriptors()).isNotEmpty();
assertThat(result.getShells().get(0).contractAgreementId()).isNull();
}

@Test
void shouldFillItemContainerWithShellAndContractAgreementIdWhenAuditFlag() throws RegistryServiceException {
// given
when(digitalTwinRegistryService.fetchShells(any())).thenReturn(
List.of(shell("", shellDescriptor(List.of(submodelDescriptorWithoutHref("any"))))));

// when
final ItemContainer result = digitalTwinDelegate.process(ItemContainer.builder(), jobParameterAuditContractNegotiation(),
new AASTransferProcess("id", 0), createKey());

// then
assertThat(result).isNotNull();
assertThat(result.getShells()).isNotEmpty();
assertThat(result.getShells().get(0).payload().getSubmodelDescriptors()).isNotEmpty();
assertThat(result.getShells().get(0).contractAgreementId()).isNotNull();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public static JobParameter jobParameter() {
.direction(Direction.DOWNWARD)
.aspects(List.of(AspectType.SERIAL_PART.toString(),
AspectType.SINGLE_LEVEL_BOM_AS_BUILT.toString()))
.auditContractNegotiation(false)
.build();
}

Expand Down Expand Up @@ -197,6 +198,17 @@ public static JobParameter jobParameterCollectBpns() {
.build();
}

public static JobParameter jobParameterAuditContractNegotiation() {
return JobParameter.builder()
.depth(5)
.bomLifecycle(BomLifecycle.AS_BUILT)
.direction(Direction.DOWNWARD)
.aspects(List.of(AspectType.SERIAL_PART.toString(),
AspectType.SINGLE_LEVEL_BOM_AS_BUILT.toString()))
.auditContractNegotiation(true)
.build();
}

public static MeterRegistryService simpleMeterRegistryService() {
return new MeterRegistryService(new SimpleMeterRegistry());
}
Expand Down

0 comments on commit dceda1f

Please sign in to comment.