File tree Expand file tree Collapse file tree 3 files changed +42
-1
lines changed
core/esmf-aspect-meta-model-java/src
main/java/org/eclipse/esmf/aspectmodel/loader
java/org/eclipse/esmf/aspectmodel/loader Expand file tree Collapse file tree 3 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -116,7 +116,14 @@ protected Type getType( final Resource characteristicResource ) {
116
116
private Statement getDataType ( final Resource resource ) {
117
117
return Optional .ofNullable ( resource .getPropertyResourceValue ( SammNs .SAMMC .baseCharacteristic () ) )
118
118
.map ( this ::getDataType )
119
- .orElseGet ( () -> resource .getProperty ( SammNs .SAMM .dataType () ) );
119
+ .orElseGet ( () -> {
120
+ final Statement dataType = resource .getProperty ( SammNs .SAMM .dataType () );
121
+ if ( dataType == null ) {
122
+ throw new IllegalStateException (
123
+ String .format ( "No datatype is defined on the Characteristic instance '%s: '." , resource .getLocalName () ) );
124
+ }
125
+ return dataType ;
126
+ } );
120
127
}
121
128
122
129
protected Optional <Characteristic > getElementCharacteristic ( final Resource collection ) {
Original file line number Diff line number Diff line change 14
14
package org .eclipse .esmf .aspectmodel .loader ;
15
15
16
16
import static org .assertj .core .api .Assertions .assertThat ;
17
+ import static org .assertj .core .api .AssertionsForClassTypes .assertThatThrownBy ;
17
18
18
19
import java .io .File ;
19
20
import java .io .FileInputStream ;
40
41
import org .junit .jupiter .api .Test ;
41
42
42
43
class AspectModelLoaderTest {
44
+
45
+ @ Test
46
+ void loadAspectModelWithoutCharacteristicDatatype () {
47
+ assertThatThrownBy ( () -> new AspectModelLoader ().load ( AspectModelLoaderTest .class .getResourceAsStream (
48
+ String .format ( "/%s/invalid_characteristic_datatype.ttl" , KnownVersion .SAMM_2_1_0 ) ) ) )
49
+ .isInstanceOf ( IllegalStateException .class )
50
+ .hasMessage ( "No datatype is defined on the Characteristic instance 'Characteristic1: '." );
51
+ }
52
+
43
53
@ Test
44
54
void testOfAbstractEntityCyclomaticCreation () {
45
55
final Map <String , ComplexType > entities =
Original file line number Diff line number Diff line change
1
+ # Copyright (c) 2024 Robert Bosch Manufacturing Solutions GmbH
2
+ #
3
+ # See the AUTHORS file(s) distributed with this work for additional
4
+ # information regarding authorship.
5
+ #
6
+ # This Source Code Form is subject to the terms of the Mozilla Public
7
+ # License, v. 2.0. If a copy of the MPL was not distributed with this
8
+ # file, You can obtain one at https://mozilla.org/MPL/2.0/.
9
+ #
10
+ # SPDX-License-Identifier: MPL-2.0
11
+
12
+ @prefix samm: <urn:samm:org.eclipse.esmf.samm:meta-model:2.1.0#> .
13
+ @prefix samm-c: <urn:samm:org.eclipse.esmf.samm:characteristic:2.1.0#> .
14
+ @prefix : <urn:samm:com.example.test:1.0.0#> .
15
+
16
+ :AspectWithoutCharacteristicDatatype a samm:Aspect ;
17
+ samm:properties ( :property1 ) ;
18
+ samm:operations () ;
19
+ samm:events ( ) .
20
+
21
+ :property1 a samm:Property ;
22
+ samm:characteristic :Characteristic1 .
23
+
24
+ :Characteristic1 a samm:Characteristic .
You can’t perform that action at this time.
0 commit comments