Skip to content

Commit fcc1a07

Browse files
committed
Update tests
1 parent 9fa42dd commit fcc1a07

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/aspectmodel/loader/Instantiator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ private Statement getDataType( final Resource resource ) {
119119
.orElseGet( () -> {
120120
final Statement dataType = resource.getProperty( SammNs.SAMM.dataType() );
121121
if ( dataType == null ) {
122-
throw new IllegalStateException(
122+
throw new AspectLoadingException(
123123
String.format( "No datatype is defined on the Characteristic instance '%s: '.", resource.getLocalName() ) );
124124
}
125125
return dataType;

core/esmf-aspect-meta-model-java/src/test/java/org/eclipse/esmf/aspectmodel/loader/AspectModelLoaderTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@
2828
import java.util.function.Function;
2929
import java.util.stream.Collectors;
3030

31-
import org.eclipse.esmf.aspectmodel.resolver.AspectModelResolverTest;
31+
import org.eclipse.esmf.aspectmodel.AspectLoadingException;
3232
import org.eclipse.esmf.aspectmodel.resolver.FileSystemStrategy;
3333
import org.eclipse.esmf.aspectmodel.resolver.ResolutionStrategy;
3434
import org.eclipse.esmf.metamodel.AbstractEntity;
3535
import org.eclipse.esmf.metamodel.AspectModel;
3636
import org.eclipse.esmf.metamodel.ComplexType;
3737
import org.eclipse.esmf.metamodel.HasDescription;
3838
import org.eclipse.esmf.samm.KnownVersion;
39+
import org.eclipse.esmf.test.InvalidTestAspect;
3940
import org.eclipse.esmf.test.TestAspect;
4041
import org.eclipse.esmf.test.TestResources;
4142

@@ -45,9 +46,8 @@ class AspectModelLoaderTest {
4546

4647
@Test
4748
void loadAspectModelWithoutCharacteristicDatatype() {
48-
assertThatThrownBy( () -> new AspectModelLoader().load( AspectModelResolverTest.class.getResourceAsStream(
49-
String.format( "/%s/invalid_characteristic_datatype.ttl", KnownVersion.SAMM_2_1_0.toString().toLowerCase() ) ) ) )
50-
.isInstanceOf( IllegalStateException.class )
49+
assertThatThrownBy( () -> TestResources.load( InvalidTestAspect.INVALID_CHARACTERISTIC_DATATYPE ) )
50+
.isInstanceOf( AspectLoadingException.class )
5151
.hasMessage( "No datatype is defined on the Characteristic instance 'Characteristic1: '." );
5252
}
5353

core/esmf-aspect-meta-model-java/src/test/java/org/eclipse/esmf/test/TestResources.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,14 @@ public static AspectModel load( final TestAspect model ) {
3333
"valid/" + metaModelVersion.toString().toLowerCase() );
3434
return new AspectModelLoader( testModelsResolutionStrategy ).load( inputStream, Optional.of( URI.create( "testmodel:" + path ) ) );
3535
}
36+
37+
public static AspectModel load( final InvalidTestAspect model ) {
38+
final KnownVersion metaModelVersion = KnownVersion.getLatest();
39+
final String path = String.format( "invalid/%s/%s/%s.ttl", model.getUrn().getNamespaceMainPart(), model.getUrn().getVersion(),
40+
model.getName() );
41+
final InputStream inputStream = TestResources.class.getClassLoader().getResourceAsStream( path );
42+
final ResolutionStrategy testModelsResolutionStrategy = new ClasspathStrategy(
43+
"invalid/" + metaModelVersion.toString().toLowerCase() );
44+
return new AspectModelLoader( testModelsResolutionStrategy ).load( inputStream, Optional.of( URI.create( "testmodel:" + path ) ) );
45+
}
3646
}

core/esmf-test-aspect-models/src/main/java/org/eclipse/esmf/test/InvalidTestAspect.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public enum InvalidTestAspect implements TestModel {
2626
MISSING_ASPECT_DECLARATION,
2727
INVALID_EXAMPLE_VALUE_DATATYPE,
2828
INVALID_PREFERRED_NAME_DATATYPE,
29+
INVALID_CHARACTERISTIC_DATATYPE,
2930
RANGE_CONSTRAINT_WITH_WRONG_TYPE,
3031
MODEL_WITH_CYCLES;
3132

File renamed without changes.

0 commit comments

Comments
 (0)