24
24
import java .io .FileNotFoundException ;
25
25
import java .io .FileReader ;
26
26
import java .net .URL ;
27
+ import java .util .ArrayList ;
28
+ import java .util .Collection ;
29
+ import java .util .List ;
27
30
import java .util .jar .Attributes ;
28
31
import java .util .jar .Manifest ;
29
32
37
40
import com .ericsson .eiffel .remrem .protocol .ValidationResult ;
38
41
import com .ericsson .eiffel .remrem .semantics .util .ManifestHandler ;
39
42
import com .ericsson .eiffel .semantics .events .Gav ;
43
+ import com .google .gson .JsonArray ;
44
+ import com .google .gson .JsonElement ;
40
45
import com .google .gson .JsonIOException ;
41
46
import com .google .gson .JsonObject ;
42
47
import com .google .gson .JsonParser ;
@@ -65,8 +70,6 @@ public static void readManifestGav() {
65
70
manifestGav .setGroupId (attributes1 .getValue ("groupId" ));
66
71
manifestGav .setArtifactId (attributes1 .getValue ("artifactId" ));
67
72
manifestGav .setVersion (attributes1 .getValue ("semanticsVersion" ));
68
- } catch (FileNotFoundException e ) {
69
- e .printStackTrace ();
70
73
} catch (Exception e ) {
71
74
e .printStackTrace ();
72
75
}
@@ -148,11 +151,7 @@ public void validateMessage() {
148
151
try {
149
152
input = parser .parse (new FileReader (file )).getAsJsonObject ();
150
153
msg = service .validateMsg (ACTIVITY_FINISHED , input );
151
- } catch (JsonIOException e ) {
152
- e .printStackTrace ();
153
- } catch (JsonSyntaxException e ) {
154
- e .printStackTrace ();
155
- } catch (FileNotFoundException e ) {
154
+ } catch (Exception e ) {
156
155
e .printStackTrace ();
157
156
}
158
157
Assert .assertNotNull (msg );
@@ -169,11 +168,7 @@ public void testGetEventType() {
169
168
try {
170
169
input = parser .parse (new FileReader (file )).getAsJsonObject ();
171
170
eventType = service .getEventType (input );
172
- } catch (JsonIOException e ) {
173
- e .printStackTrace ();
174
- } catch (JsonSyntaxException e ) {
175
- e .printStackTrace ();
176
- } catch (FileNotFoundException e ) {
171
+ } catch (Exception e ) {
177
172
e .printStackTrace ();
178
173
}
179
174
assertEquals ("EiffelActivityFinishedEvent" , eventType );
@@ -189,11 +184,7 @@ public void testGenerateRoutingKey() {
189
184
try {
190
185
input = parser .parse (new FileReader (file )).getAsJsonObject ();
191
186
routingKey = service .generateRoutingKey (input , null , null , null );
192
- } catch (JsonIOException e ) {
193
- e .printStackTrace ();
194
- } catch (JsonSyntaxException e ) {
195
- e .printStackTrace ();
196
- } catch (FileNotFoundException e ) {
187
+ } catch (Exception e ) {
197
188
e .printStackTrace ();
198
189
}
199
190
assertEquals ("eiffel.activity.finished.notag.domainID" , routingKey );
@@ -219,4 +210,28 @@ public void testInvalidPathRemremSemanticsGav() throws Exception {
219
210
manifestGav .setVersion (attributes1 .getValue ("semanticsVersion" ));
220
211
221
212
}
213
+
214
+ @ Test
215
+ public void testGetSupportedEventTypes () {
216
+ URL url = getClass ().getClassLoader ().getResource ("EventTypes.json" );
217
+ String path = url .getPath ().replace ("%20" , " " );
218
+ File file = new File (path );
219
+ JsonObject input = null ;
220
+ boolean checkValue = false ;
221
+ try {
222
+ Collection <String > types = service .getSupportedEventTypes ();
223
+ input = parser .parse (new FileReader (file )).getAsJsonObject ();
224
+ JsonArray eventTypes = input .getAsJsonArray ("eventTypes" );
225
+ List <String > matchingCollection = new ArrayList <>();
226
+ if (eventTypes != null ) {
227
+ for (JsonElement event : eventTypes ) {
228
+ matchingCollection .add (event .getAsString ());
229
+ }
230
+ }
231
+ checkValue = types .containsAll (matchingCollection );
232
+ } catch (Exception e ) {
233
+ e .printStackTrace ();
234
+ }
235
+ assertEquals (true ,checkValue );
236
+ }
222
237
}
0 commit comments