Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
Expand Down Expand Up @@ -454,7 +455,7 @@ private record LoaderContext(
Deque<AspectModelFile> unresolvedFiles
) {
private LoaderContext() {
this( new HashSet<>(), new HashSet<>(), new HashSet<>(), new ArrayDeque<>(), new ArrayDeque<>() );
this( new HashSet<>(), new LinkedHashSet<>(), new HashSet<>(), new ArrayDeque<>(), new ArrayDeque<>() );
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 Robert Bosch Manufacturing Solutions GmbH
* Copyright (c) 2025 Robert Bosch Manufacturing Solutions GmbH
*
* See the AUTHORS file(s) distributed with this work for additional
* information regarding authorship.
Expand All @@ -20,6 +20,7 @@
import java.net.URI;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
Expand All @@ -34,16 +35,19 @@
import org.eclipse.esmf.metamodel.ComplexType;
import org.eclipse.esmf.metamodel.ModelElement;
import org.eclipse.esmf.test.InvalidTestAspect;
import org.eclipse.esmf.test.OrderingTestAspect;
import org.eclipse.esmf.test.TestAspect;
import org.eclipse.esmf.test.TestResources;

import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.RepeatedTest;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;

class AspectModelLoaderTest {
@ParameterizedTest
@EnumSource( value = TestAspect.class )
@EnumSource( TestAspect.class )
void testLoadAspectModelsSourceFilesArePresent( final TestAspect testAspect ) {
final AspectModel aspectModel = TestResources.load( testAspect );
for ( final ModelElement element : aspectModel.elements() ) {
Expand Down Expand Up @@ -90,11 +94,11 @@ void testOfAbstractEntityCyclomaticCreation() {
assertThat( entities ).extracting( "AbstractTestEntity" ).isInstanceOf( AbstractEntity.class );
final AbstractEntity abstractEntity = (AbstractEntity) entities.get( "AbstractTestEntity" );
assertThat( entities ).extracting( "testEntityOne" ).isInstanceOfSatisfying( ComplexType.class, type -> {
org.assertj.core.api.Assertions.assertThat( type ).extracting( ComplexType::getExtends ).extracting( Optional::get )
Assertions.assertThat( type ).extracting( ComplexType::getExtends ).extracting( Optional::get )
.isSameAs( abstractEntity );
} );
assertThat( entities ).extracting( "testEntityTwo" ).isInstanceOfSatisfying( ComplexType.class, type ->
org.assertj.core.api.Assertions.assertThat( type ).extracting( ComplexType::getExtends ).extracting( Optional::get )
Assertions.assertThat( type ).extracting( ComplexType::getExtends ).extracting( Optional::get )
.isSameAs( abstractEntity ) );
}

Expand Down Expand Up @@ -129,4 +133,15 @@ void testLoadMultipleFilesWithOverlappingRdfStatements() {
assertThat( exception ).hasMessageContaining( "Duplicate definition" );
} );
}

@RepeatedTest( 10 )
void testAspectUploadOrdering() {
final OrderingTestAspect aspectName = OrderingTestAspect.ASPECT;
final AspectModel aspectModel = TestResources.load( aspectName );
assertThat( aspectModel ).aspects()
.filteredOn( aspect -> Objects.equals( aspectName.getName(), aspect.getName() ) )
.first()
.satisfies(
aspect -> assertThat( aspect.urn().toString() ).isEqualTo( "urn:samm:org.eclipse.esmf.test.ordering:1.0.0#Aspect" ) );
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 Robert Bosch Manufacturing Solutions GmbH
* Copyright (c) 2025 Robert Bosch Manufacturing Solutions GmbH
*
* See the AUTHORS file(s) distributed with this work for additional
* information regarding authorship.
Expand Down Expand Up @@ -41,6 +41,14 @@ public static AspectModel load( final TestModel model ) {
return new AspectModelLoader( testModelsResolutionStrategy ).load( inputStream, URI.create( "testmodel:" + path ) );
}

public static AspectModel load( final OrderingTestAspect model ) {
final String path = String.format( "valid/%s/%s/%s.ttl", model.getUrn().getNamespaceMainPart(), model.getUrn().getVersion(),
model.getName() );
final InputStream inputStream = TestResources.class.getClassLoader().getResourceAsStream( path );
final ResolutionStrategy testModelsResolutionStrategy = new ClasspathStrategy( "valid" );
return new AspectModelLoader( testModelsResolutionStrategy ).load( inputStream, URI.create( "testmodel:" + path ) );
}

public static AspectModel load( final InvalidTestAspect model ) {
final KnownVersion metaModelVersion = KnownVersion.getLatest();
final String path = String.format( "invalid/%s/%s/%s.ttl", model.getUrn().getNamespaceMainPart(), model.getUrn().getVersion(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (c) 2025 Robert Bosch Manufacturing Solutions GmbH
*
* See the AUTHORS file(s) distributed with this work for additional
* information regarding authorship.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* SPDX-License-Identifier: MPL-2.0
*/

package org.eclipse.esmf.test;

import org.apache.commons.text.CaseUtils;

public enum OrderingTestAspect implements TestOrderingModel {
ASPECT;

@Override
public String getName() {
return CaseUtils.toCamelCase( toString().toLowerCase(), true, '_' );
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (c) 2025 Robert Bosch Manufacturing Solutions GmbH
*
* See the AUTHORS file(s) distributed with this work for additional
* information regarding authorship.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* SPDX-License-Identifier: MPL-2.0
*/

package org.eclipse.esmf.test;

import org.eclipse.esmf.aspectmodel.urn.AspectModelUrn;

public interface TestOrderingModel extends TestModel {
String TEST_NAMESPACE = "urn:samm:org.eclipse.esmf.test.ordering:1.0.0#";

@Override
default AspectModelUrn getUrn() {
return AspectModelUrn.fromUrn( TEST_NAMESPACE + getName() );
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright (c) 2025 Robert Bosch Manufacturing Solutions GmbH
#
# See the AUTHORS file(s) distributed with this work for additional
# information regarding authorship.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
#
# SPDX-License-Identifier: MPL-2.0

@prefix samm: <urn:samm:org.eclipse.esmf.samm:meta-model:2.2.0#> .
@prefix samm-c: <urn:samm:org.eclipse.esmf.samm:characteristic:2.2.0#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

@prefix : <urn:samm:org.eclipse.esmf.test.ordering.dependency:1.0.0#> .

:Aspect a samm:Aspect ;
samm:description "Test dependency aspect "@en ;
samm:properties ( :test ) ;
samm:operations ( ) ;
samm:events ( ) .

:test a samm:Property ;
samm:characteristic :TestCharacteristic .

:TestCharacteristic a samm:Characteristic ;
samm:preferredName "Test Characteristic"@en ;
samm:dataType xsd:short .
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (c) 2025 Robert Bosch Manufacturing Solutions GmbH
#
# See the AUTHORS file(s) distributed with this work for additional
# information regarding authorship.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
#
# SPDX-License-Identifier: MPL-2.0

@prefix samm: <urn:samm:org.eclipse.esmf.samm:meta-model:2.2.0#> .
@prefix ref: <urn:samm:org.eclipse.esmf.test.ordering.dependency:1.0.0#> .

@prefix : <urn:samm:org.eclipse.esmf.test.ordering:1.0.0#> .

:Aspect a samm:Aspect ;
samm:preferredName "Test Aspect"@en ;
samm:description "This is a test description"@en ;
samm:properties (
ref:test
) ;
samm:operations ( ) .
Loading
Loading