File tree 2 files changed +41
-7
lines changed
core/esmf-aspect-meta-model-java/src
main/java/org/eclipse/esmf/aspectmodel/resolver
test/java/org/eclipse/esmf/aspectmodel/resolver
2 files changed +41
-7
lines changed Original file line number Diff line number Diff line change 13
13
14
14
package org .eclipse .esmf .aspectmodel .resolver ;
15
15
16
- import static org .apache .commons .lang3 .StringUtils .isBlank ;
17
-
18
16
import java .io .ByteArrayInputStream ;
19
17
import java .io .File ;
20
18
import java .io .FileInputStream ;
@@ -92,12 +90,10 @@ private static String content( final InputStream inputStream ) {
92
90
private static List <String > headerComment ( final String content ) {
93
91
final List <String > list = content .lines ()
94
92
.dropWhile ( String ::isBlank )
95
- .takeWhile ( line -> line .startsWith ( "#" ) || isBlank ( line ) )
96
- .map ( line -> line .startsWith ( "#" ) ? line . substring ( 1 ).trim () : line )
93
+ .takeWhile ( line -> line .startsWith ( "#" ) )
94
+ .map ( line -> line .substring ( 1 ).trim () )
97
95
.toList ();
98
- return !list .isEmpty () && list .get ( list .size () - 1 ).isEmpty ()
99
- ? list .subList ( 0 , list .size () - 1 )
100
- : list ;
96
+ return list ;
101
97
}
102
98
103
99
public static RawAspectModelFile load ( final InputStream inputStream ) {
Original file line number Diff line number Diff line change @@ -62,6 +62,44 @@ void testLoadDataModelExpectSuccess() throws URISyntaxException {
62
62
} ).doesNotThrowAnyException ();
63
63
}
64
64
65
+ @ Test
66
+ void testLoadModelWithNoEmptyLineAfterHeaderCommentBlock () {
67
+ assertThat ( AspectModelFileLoader .load ( """
68
+ #
69
+ # Test copyright
70
+ #
71
+ @prefix : <urn:samm:com.xyz:0.0.1#> .
72
+ """ ) )
73
+ .headerComment ().hasSize ( 3 ).matches ( list -> list .get ( 1 ).contains ( "Test copyright" ) );
74
+ assertThat ( AspectModelFileLoader .load ( """
75
+ #
76
+ # Test copyright
77
+ #
78
+
79
+ @prefix : <urn:samm:com.xyz:0.0.1#> .
80
+ """ ) )
81
+ .headerComment ().hasSize ( 3 ).matches ( list -> list .get ( 1 ).contains ( "Test copyright" ) );
82
+ assertThat ( AspectModelFileLoader .load ( """
83
+ #
84
+ # Test copyright
85
+ #
86
+
87
+ # Another comment
88
+ @prefix : <urn:samm:com.xyz:0.0.1#> .
89
+ """ ) )
90
+ .headerComment ().hasSize ( 3 ).matches ( list -> list .get ( 1 ).contains ( "Test copyright" ) );
91
+ assertThat ( AspectModelFileLoader .load ( """
92
+ #
93
+ # Test copyright
94
+ #
95
+
96
+ # Another comment
97
+
98
+ @prefix : <urn:samm:com.xyz:0.0.1#> .
99
+ """ ) )
100
+ .headerComment ().hasSize ( 3 ).matches ( list -> list .get ( 1 ).contains ( "Test copyright" ) );
101
+ }
102
+
65
103
@ Test
66
104
void testLoadLegacyBammModelWithoutPrefixesExpectSuccess () throws URISyntaxException {
67
105
final File aspectModelsRootDirectory = new File (
You can’t perform that action at this time.
0 commit comments