- String stats = twoTraceMatch.toString();
- assertEquals("TmfEventMatches [ Number of matches found: 46 ]" +
- "Trace 0:" + cr +
- " 3 unmatched incoming events" + cr +
- " 2 unmatched outgoing events" + cr +
- "Trace 1:" + cr +
- " 2 unmatched incoming events" + cr +
- " 1 unmatched outgoing events" + cr, stats);
+ /* Set method and fields accessible to make sure the counts are ok */
+ try {
+ /* Verify number of matches */
+ Method method = TmfEventMatching.class.getDeclaredMethod("getProcessingUnit");
+ method.setAccessible(true);
+ IMatchProcessingUnit procUnit = (IMatchProcessingUnit) method.invoke(twoTraceMatch);
+ assertEquals(46, procUnit.countMatches());
+
+ /* Verify unmatched incoming */
+ Field fieldIn = twoTraceMatch.getClass().getDeclaredField("fUnmatchedIn");
+ fieldIn.setAccessible(true);
+ Map<?, ?> unmatched = (Map<?, ?> ) fieldIn.get(twoTraceMatch);
+ Map<?, ?> unmatchedTrace = (Map<?, ?>) unmatched.get(trace1);
+ assertEquals(3, unmatchedTrace.size());
+ unmatchedTrace = (Map<?, ?>) unmatched.get(trace2);
+ assertEquals(2, unmatchedTrace.size());
+
+ /* Verify unmatched outgoing */
+ Field fieldOut = twoTraceMatch.getClass().getDeclaredField("fUnmatchedOut");
+ fieldOut.setAccessible(true);
+ unmatched = (Map<?, ?> ) fieldOut.get(twoTraceMatch);
+ unmatchedTrace = (Map<?, ?>) unmatched.get(trace1);
+ assertEquals(2, unmatchedTrace.size());
+ unmatchedTrace = (Map<?, ?>) unmatched.get(trace2);
+ assertEquals(1, unmatchedTrace.size());
+
+ } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchFieldException e) {
+ fail(e.getMessage());
+ }