|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2024 Robert Bosch Manufacturing Solutions GmbH |
| 2 | + * Copyright (c) 2025 Robert Bosch Manufacturing Solutions GmbH |
3 | 3 | *
|
4 | 4 | * See the AUTHORS file(s) distributed with this work for additional
|
5 | 5 | * information regarding authorship.
|
|
11 | 11 | * SPDX-License-Identifier: MPL-2.0
|
12 | 12 | */
|
13 | 13 |
|
14 |
| -package org.eclipse.esmf.test; |
| 14 | +package org.eclipse.esmf.test.shared; |
15 | 15 |
|
16 | 16 | import org.eclipse.esmf.aspectmodel.AspectModelFile;
|
17 | 17 | import org.eclipse.esmf.aspectmodel.urn.AspectModelUrn;
|
|
28 | 28 | import org.eclipse.esmf.metamodel.Namespace;
|
29 | 29 | import org.eclipse.esmf.metamodel.Operation;
|
30 | 30 | import org.eclipse.esmf.metamodel.Property;
|
| 31 | +import org.eclipse.esmf.metamodel.QuantityKind; |
31 | 32 | import org.eclipse.esmf.metamodel.Scalar;
|
32 | 33 | import org.eclipse.esmf.metamodel.ScalarValue;
|
33 | 34 | import org.eclipse.esmf.metamodel.Type;
|
|
56 | 57 | import org.eclipse.esmf.metamodel.constraint.RegularExpressionConstraint;
|
57 | 58 |
|
58 | 59 | import org.apache.jena.rdf.model.Model;
|
| 60 | +import org.assertj.core.api.InstanceOfAssertFactory; |
59 | 61 |
|
60 | 62 | /**
|
61 | 63 | * Convenience wrapper for the construction of all SAMM-related assertsThat() methods. Intended use is by
|
@@ -188,6 +190,14 @@ public static <SELF extends AspectModelAssert<SELF, ACTUAL>, ACTUAL extends Aspe
|
188 | 190 | return new PropertyAssert<>( property );
|
189 | 191 | }
|
190 | 192 |
|
| 193 | + @SuppressWarnings( "IncorrectFormatting" ) |
| 194 | + //@formatter:off |
| 195 | + public static <SELF extends QuantityKindAssert<SELF, ACTUAL>, ACTUAL extends QuantityKind> QuantityKindAssert<SELF, ACTUAL> |
| 196 | + assertThat( final ACTUAL quantityKind ) { |
| 197 | + //@formatter:on |
| 198 | + return new QuantityKindAssert<>( quantityKind ); |
| 199 | + } |
| 200 | + |
191 | 201 | @SuppressWarnings( "IncorrectFormatting" )
|
192 | 202 | //@formatter:off
|
193 | 203 | public static <SELF extends ScalarAssert<SELF, ACTUAL>, ACTUAL extends Scalar> ScalarAssert<SELF, ACTUAL>
|
@@ -391,4 +401,54 @@ ConstraintAssert.FixedPointConstraintAssert<SELF, ACTUAL> assertThat( final ACTU
|
391 | 401 | //@formatter:on
|
392 | 402 | return new ConstraintAssert.FixedPointConstraintAssert<>( element );
|
393 | 403 | }
|
| 404 | + |
| 405 | + // Assertion factories that are required when asserts for collections should be chained with their actual type, e.g.: |
| 406 | + // assertThat( aspectModel ).namespaces().first( as( NAMESPACE ) ).hasName( "urn:samm:org.eclipse.esmf.test:1.0.0" ); |
| 407 | + // Without the InstanceOfAssertFactory, first() on a ListAssert would only provide a generic ObjectAssert; |
| 408 | + // with it the result of first() is an actual NamespaceAssert. |
| 409 | + |
| 410 | + public static final InstanceOfAssertFactory<AbstractEntity, AbstractEntityAssert<?, ?>> ABSTRACT_ENTITY = |
| 411 | + new InstanceOfAssertFactory<>( AbstractEntity.class, AspectModelAsserts::assertThat ); |
| 412 | + public static final InstanceOfAssertFactory<Aspect, AspectAssert<?, ?>> ASPECT = |
| 413 | + new InstanceOfAssertFactory<>( Aspect.class, AspectModelAsserts::assertThat ); |
| 414 | + public static final InstanceOfAssertFactory<AspectModel, AspectModelAssert<?, ?>> ASPECT_MODEL = |
| 415 | + new InstanceOfAssertFactory<>( AspectModel.class, AspectModelAsserts::assertThat ); |
| 416 | + public static final InstanceOfAssertFactory<AspectModelFile, AspectModelFileAssert<?, ?>> ASPECT_MODEL_FILE = |
| 417 | + new InstanceOfAssertFactory<>( AspectModelFile.class, AspectModelAsserts::assertThat ); |
| 418 | + public static final InstanceOfAssertFactory<AspectModelUrn, AspectModelUrnAssert<?, ?>> ASPECT_MODEL_URN = |
| 419 | + new InstanceOfAssertFactory<>( AspectModelUrn.class, AspectModelAsserts::assertThat ); |
| 420 | + public static final InstanceOfAssertFactory<Characteristic, CharacteristicAssert<?, ?>> CHARACTERISTIC = |
| 421 | + new InstanceOfAssertFactory<>( Characteristic.class, AspectModelAsserts::assertThat ); |
| 422 | + public static final InstanceOfAssertFactory<CollectionValue, CollectionValueAssert<?, ?>> COLLECTION_VALUE = |
| 423 | + new InstanceOfAssertFactory<>( CollectionValue.class, AspectModelAsserts::assertThat ); |
| 424 | + public static final InstanceOfAssertFactory<Constraint, ConstraintAssert<?, ?>> CONSTRAINT = |
| 425 | + new InstanceOfAssertFactory<>( Constraint.class, AspectModelAsserts::assertThat ); |
| 426 | + public static final InstanceOfAssertFactory<Entity, EntityAssert<?, ?>> ENTITY = |
| 427 | + new InstanceOfAssertFactory<>( Entity.class, AspectModelAsserts::assertThat ); |
| 428 | + public static final InstanceOfAssertFactory<EntityInstance, EntityInstanceAssert<?, ?>> ENTITY_INSTANCE = |
| 429 | + new InstanceOfAssertFactory<>( EntityInstance.class, AspectModelAsserts::assertThat ); |
| 430 | + public static final InstanceOfAssertFactory<Event, EventAssert<?, ?>> EVENT = |
| 431 | + new InstanceOfAssertFactory<>( Event.class, AspectModelAsserts::assertThat ); |
| 432 | + public static final InstanceOfAssertFactory<Model, ModelAssert<?, ?>> MODEL = |
| 433 | + new InstanceOfAssertFactory<>( Model.class, AspectModelAsserts::assertThat ); |
| 434 | + public static final InstanceOfAssertFactory<ModelElement, ModelElementAssert<?, ?>> MODEL_ELEMENT = |
| 435 | + new InstanceOfAssertFactory<>( ModelElement.class, AspectModelAsserts::assertThat ); |
| 436 | + public static final InstanceOfAssertFactory<Namespace, NamespaceAssert<?, ?>> NAMESPACE = |
| 437 | + new InstanceOfAssertFactory<>( Namespace.class, AspectModelAsserts::assertThat ); |
| 438 | + public static final InstanceOfAssertFactory<Operation, OperationAssert<?, ?>> OPERATION = |
| 439 | + new InstanceOfAssertFactory<>( Operation.class, AspectModelAsserts::assertThat ); |
| 440 | + public static final InstanceOfAssertFactory<Property, PropertyAssert<?, ?>> PROPERTY = |
| 441 | + new InstanceOfAssertFactory<>( Property.class, AspectModelAsserts::assertThat ); |
| 442 | + public static final InstanceOfAssertFactory<QuantityKind, QuantityKindAssert<?, ?>> QUANTITY_KIND = |
| 443 | + new InstanceOfAssertFactory<>( QuantityKind.class, AspectModelAsserts::assertThat ); |
| 444 | + public static final InstanceOfAssertFactory<Scalar, ScalarAssert<?, ?>> SCALAR = |
| 445 | + new InstanceOfAssertFactory<>( Scalar.class, AspectModelAsserts::assertThat ); |
| 446 | + public static final InstanceOfAssertFactory<ScalarValue, ScalarValueAssert<?, ?>> SCALAR_VALUE = |
| 447 | + new InstanceOfAssertFactory<>( ScalarValue.class, AspectModelAsserts::assertThat ); |
| 448 | + public static final InstanceOfAssertFactory<Type, TypeAssert<?, ?>> TYPE = |
| 449 | + new InstanceOfAssertFactory<>( Type.class, AspectModelAsserts::assertThat ); |
| 450 | + public static final InstanceOfAssertFactory<Unit, UnitAssert<?, ?>> UNIT = |
| 451 | + new InstanceOfAssertFactory<>( Unit.class, AspectModelAsserts::assertThat ); |
| 452 | + public static final InstanceOfAssertFactory<Value, ValueAssert<?, ?>> VALUE = |
| 453 | + new InstanceOfAssertFactory<>( Value.class, AspectModelAsserts::assertThat ); |
394 | 454 | }
|
0 commit comments