15
15
16
16
import static org .assertj .core .api .Assertions .assertThat ;
17
17
18
+ import java .net .URISyntaxException ;
19
+ import java .nio .file .Path ;
20
+ import java .nio .file .Paths ;
21
+ import java .util .List ;
18
22
import java .util .Map ;
19
23
import java .util .Optional ;
20
24
import java .util .function .Function ;
21
25
import java .util .stream .Collectors ;
22
26
23
27
import org .eclipse .esmf .metamodel .AbstractEntity ;
28
+ import org .eclipse .esmf .metamodel .AspectModel ;
24
29
import org .eclipse .esmf .metamodel .ComplexType ;
25
30
import org .eclipse .esmf .test .TestAspect ;
26
31
import org .eclipse .esmf .test .TestResources ;
30
35
class AspectModelLoaderTest {
31
36
@ Test
32
37
public void testOfAbstractEntityCyclomaticCreation () {
33
- final Map <String , ComplexType > entities =
34
- TestResources .load ( TestAspect .ASPECT_WITH_MULTIPLE_ENTITIES_SAME_EXTEND ).elements ().stream ()
35
- .filter ( ComplexType .class ::isInstance )
36
- .map ( ComplexType .class ::cast )
37
- .collect ( Collectors .toMap ( ComplexType ::getName , Function .identity () ) );
38
+ final Map <String , ComplexType > entities = TestResources .load ( TestAspect .ASPECT_WITH_MULTIPLE_ENTITIES_SAME_EXTEND ).elements ()
39
+ .stream ().filter ( ComplexType .class ::isInstance ).map ( ComplexType .class ::cast )
40
+ .collect ( Collectors .toMap ( ComplexType ::getName , Function .identity () ) );
38
41
39
42
assertThat ( entities ).extracting ( "AbstractTestEntity" ).isInstanceOf ( AbstractEntity .class );
40
43
final AbstractEntity abstractEntity = (AbstractEntity ) entities .get ( "AbstractTestEntity" );
41
- assertThat ( entities ).extracting ( "testEntityOne" ).isInstanceOfSatisfying ( ComplexType .class , type ->
42
- assertThat ( type ).extracting ( ComplexType ::getExtends ).extracting ( Optional ::get ).isSameAs ( abstractEntity ) );
43
- assertThat ( entities ).extracting ( "testEntityTwo" ).isInstanceOfSatisfying ( ComplexType .class , type ->
44
- assertThat ( type ).extracting ( ComplexType ::getExtends ).extracting ( Optional ::get ).isSameAs ( abstractEntity ) );
44
+ assertThat ( entities ).extracting ( "testEntityOne" ).isInstanceOfSatisfying ( ComplexType .class ,
45
+ type -> assertThat ( type ).extracting ( ComplexType ::getExtends ).extracting ( Optional ::get ).isSameAs ( abstractEntity ) );
46
+ assertThat ( entities ).extracting ( "testEntityTwo" ).isInstanceOfSatisfying ( ComplexType .class ,
47
+ type -> assertThat ( type ).extracting ( ComplexType ::getExtends ).extracting ( Optional ::get ).isSameAs ( abstractEntity ) );
48
+ }
49
+
50
+ @ Test
51
+ public void testLoadAspectModelFromZipArchive () throws URISyntaxException {
52
+ final ClassLoader classLoader = getClass ().getClassLoader ();
53
+ final Path archivePath = Paths .get ( classLoader .getResource ( "namespaces.zip" ).toURI () );
54
+ final AspectModel aspectModel = new AspectModelLoader ().loadFromArchive ( archivePath .toString () );
55
+
56
+ assertThat ( aspectModel .namespaces () ).hasSize ( 2 );
57
+ assertThat ( aspectModel .namespaces ().get ( 0 ).getName () ).contains ( "urn:samm:org.eclipse.examples:1.1.0" );
58
+ assertThat ( aspectModel .namespaces ().get ( 1 ).getName () ).contains ( "urn:samm:org.eclipse.examples:1.0.0" );
59
+
60
+ final List <String > aspectsNames = List .of ( "Movement2" , "Movement3" , "Movement" , "SimpleAspect" );
61
+
62
+ assertThat ( aspectModel .files () ).hasSize ( 4 );
63
+ assertThat ( aspectModel .files () )
64
+ .anySatisfy ( aspectModelFile -> {
65
+ assertThat ( aspectsNames ).contains ( aspectModelFile .aspect ().getName () );
66
+ } );
45
67
}
46
68
}
0 commit comments