Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
GitHub Actions Bot committed Jan 11, 2024
2 parents c776e1d + db05a43 commit 82bdd0b
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.3.23
### Added

## fixed
- Fixed idShort null pointer exception.

## 0.3.22
### Added

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.util.stream.Stream;

import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.tractusx.semantics.RegistryProperties;
import org.eclipse.tractusx.semantics.aas.registry.model.GetAllAssetAdministrationShellIdsByAssetLink200Response;
import org.eclipse.tractusx.semantics.aas.registry.model.PagedResultPagingMetadata;
Expand Down Expand Up @@ -109,8 +110,10 @@ public Shell save(Shell shell) {
*/
private void validateIdShort( Shell shell ) {
//Check uniqueness of IdShort in shell level
Optional.of( shell.getIdShort() ).map( shellRepository::existsByIdShort ).filter( BooleanUtils::isFalse )
.orElseThrow( () -> new DuplicateKeyException( "An AssetAdministrationShell for the given IdShort already exists." ) );
Optional.ofNullable( shell.getIdShort() ).map( shellRepository::existsByIdShort ).filter( BooleanUtils::isTrue )
.ifPresent( aBoolean -> {
throw new DuplicateKeyException( "An AssetAdministrationShell for the given IdShort already exists." );
} );

checkForDuplicateIdShortWithInSubModels( shell );
}
Expand All @@ -121,6 +124,7 @@ private void checkForDuplicateIdShortWithInSubModels( Shell shell ) {
.map( Collection::stream )
.orElseGet( Stream::empty )
.map( Submodel::getIdShort )
.filter( StringUtils::isNotBlank )
.map( String::toLowerCase )
.toList();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,6 @@ components:
AssetAdministrationShellDescriptor:
required:
- id
- idShort
type: object
example: {"description":[{"language":"de","text":"hello text"},{"language":"en","text":"hello s"}],"displayName":[{"language":"de","text":"this is an example description1"}],"endpoints":[{"interface":"interfaceNameExample","protocolInformation":{"href":"endpointAddressExample","endpointProtocol":"endpointProtocolExample","endpointProtocolVersion":["e"],"subprotocol":"subprotocolExample","subprotocolBody":"subprotocolBodyExample","subprotocolBodyEncoding":"subprotocolBodyExample","securityAttributes":[{"type":"NONE","key": "Security Attribute key","value": "Security Attribute value"}]}}],"idShort":"idShortExample","id":"e1eba3d7-91f0-4dac-a730-eaa1d35e035c","specificAssetIds":[{"supplementalSemanticIds":[{"type":"ExternalReference","keys":[{"type":"Submodel","value":"semanticIdExample"}]}],"name":"identifier1KeyExample","value":"identifier1ValueExample"},{"supplementalSemanticIds":[{"type":"ExternalReference","keys":[{"type":"Submodel","value":"semanticIdExample"}]}],"name":"identifier2KeyExample","value":"identifier2ValueExample"}],"submodelDescriptors":[{"endpoints":[{"interface":"interfaceNameExample","protocolInformation":{"href":"endpointAddressExample","endpointProtocol":"endpointProtocolExample","endpointProtocolVersion":["e"],"subprotocol":"subprotocolExample","subprotocolBody":"subprotocolBodyExample","subprotocolBodyEncoding":"subprotocolBodyExample","securityAttributes":[{"type":"NONE","key": "Security Attribute key","value": "Security Attribute value"}]}}],"idShort":"idShortExample","id":"cd47615b-daf3-4036-8670-d2f89349d388","semanticId":{"type":"ExternalReference","keys":[{"type":"Submodel","value":"semanticIdExample"}]},"description":[{"language":"de","text":"hello text"},{"language":"en","text":"hello s"}]}]}
allOf:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,7 @@ public void testFetchShellsByMultipleIdentificationsExpectSuccessExpectSuccess()
@DisplayName( "Test creating a new Asset Administration Shell Descriptor with unique IdShort in shell and submodelDescriptor level" )
public void test_Creating_a_new_Asset_Administration_Shell_Descriptor_with_unique_IdShort_in_shell_and_submodelDescriptor_level() throws Exception {
//Given
removedAllShells();
AssetAdministrationShellDescriptor shellPayload = TestUtil.createCompleteAasDescriptor();
//When & Then
mvc.perform(
Expand All @@ -947,10 +948,71 @@ public void test_Creating_a_new_Asset_Administration_Shell_Descriptor_with_uniqu
.andExpect( status().isCreated());
}

@Test
@DisplayName( "Test creating a new Asset Administration Shell Descriptor with empty IdShort in shell and submodelDescriptor level" )
public void test_Creating_a_new_Asset_Administration_Shell_Descriptor_with_empty_IdShort_in_shell_and_submodelDescriptor_level() throws Exception {
//Given
removedAllShells();
AssetAdministrationShellDescriptor shellPayload = TestUtil.createCompleteAasDescriptor();
shellPayload.setIdShort( null );
shellPayload.getSubmodelDescriptors().get( 0 ).setIdShort( null );
//When & Then
mvc.perform(
MockMvcRequestBuilders
.post( SHELL_BASE_PATH )
.accept( MediaType.APPLICATION_JSON )
.contentType( MediaType.APPLICATION_JSON )
.content( mapper.writeValueAsString( shellPayload ) )
.with( jwtTokenFactory.allRoles() )
)
.andDo( MockMvcResultHandlers.print() )
.andExpect( status().isCreated());
}

@Test
@DisplayName( "Test creating a new Asset Administration Shell Descriptor with empty IdShort in shell and valid IdShort in submodelDescriptor level" )
public void test_Creating_a_new_Asset_Administration_Shell_Descriptor_with_empty_IdShort_in_shell_and_valid_IdShort_in_submodelDescriptor_level() throws Exception {
//Given
removedAllShells();
AssetAdministrationShellDescriptor shellPayload = TestUtil.createCompleteAasDescriptor();
shellPayload.setIdShort( null );
//When & Then
mvc.perform(
MockMvcRequestBuilders
.post( SHELL_BASE_PATH )
.accept( MediaType.APPLICATION_JSON )
.contentType( MediaType.APPLICATION_JSON )
.content( mapper.writeValueAsString( shellPayload ) )
.with( jwtTokenFactory.allRoles() )
)
.andDo( MockMvcResultHandlers.print() )
.andExpect( status().isCreated());
}

@Test
@DisplayName( "Test creating a new Asset Administration Shell Descriptor with valid IdShort in shell and empty IdShort in submodelDescriptor level" )
public void test_Creating_a_new_Asset_Administration_Shell_Descriptor_with_valid_IdShort_in_shell_and_empty_IdShort_in_submodelDescriptor_level() throws Exception {
//Given
AssetAdministrationShellDescriptor shellPayload = TestUtil.createCompleteAasDescriptor();
shellPayload.getSubmodelDescriptors().get( 0 ).setIdShort( null );
//When & Then
mvc.perform(
MockMvcRequestBuilders
.post( SHELL_BASE_PATH )
.accept( MediaType.APPLICATION_JSON )
.contentType( MediaType.APPLICATION_JSON )
.content( mapper.writeValueAsString( shellPayload ) )
.with( jwtTokenFactory.allRoles() )
)
.andDo( MockMvcResultHandlers.print() )
.andExpect( status().isCreated());
}

@Test
@DisplayName( "Test creating a new Asset Administration Shell Descriptor with dupilcate IdShort in shell level" )
public void test_Creating_a_new_Asset_Administration_Shell_Descriptor_with_Dupilcate_IdShort_in_shell_level() throws Exception {
//Given
removedAllShells();
//Creates a shell using test data
AssetAdministrationShellDescriptor shellPayload = TestUtil.createCompleteAasDescriptor();
shellPayload.setId( UUID.randomUUID().toString() );
Expand All @@ -976,10 +1038,15 @@ public void test_Creating_a_new_Asset_Administration_Shell_Descriptor_with_Dupil
.andExpect( jsonPath( "$.messages[0].text", is( "An AssetAdministrationShell for the given IdShort already exists." ) ) );
}

private void removedAllShells() {
shellRepository.deleteAll();
}

@Test
@DisplayName( "Test Creating a new Asset Administration Shell Descriptor with unique IdShort in shell level and duplicate IdShort in submodelDescriptor level" )
public void test_Creating_a_new_Asset_Administration_Shell_Descriptor_with_unique_IdShort_in_shell_level_and_duplicate_submodelDescriptor_level() throws Exception {
//Given
removedAllShells();
AssetAdministrationShellDescriptor shellPayload = TestUtil.createCompleteAasDescriptor();

SubmodelDescriptor submodelDescriptor = new SubmodelDescriptor();
Expand Down
4 changes: 2 additions & 2 deletions charts/registry/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ sources:
- https://github.com/eclipse-tractusx/sldt-digital-twin-registry

type: application
version: 0.3.29
appVersion: 0.3.21
version: 0.3.30
appVersion: 0.3.22

dependencies:
- repository: https://charts.bitnami.com/bitnami
Expand Down

0 comments on commit 82bdd0b

Please sign in to comment.