14f953f5ed15fdb1aa8fc318aceca0fd5348c0dd
1 /*******************************************************************************
2 * Copyright (c) 2015 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.tmf
.core
.tests
.filter
;
15 import static org
.junit
.Assert
.assertEquals
;
16 import static org
.junit
.Assert
.assertFalse
;
17 import static org
.junit
.Assert
.assertTrue
;
19 import java
.util
.Arrays
;
20 import java
.util
.HashSet
;
23 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEventField
;
24 import org
.eclipse
.tracecompass
.tmf
.core
.event
.TmfEvent
;
25 import org
.eclipse
.tracecompass
.tmf
.core
.event
.TmfEventField
;
26 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.TmfFilterAndNode
;
27 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.TmfFilterCompareNode
;
28 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.TmfFilterContainsNode
;
29 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.TmfFilterEqualsNode
;
30 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.TmfFilterMatchesNode
;
31 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.TmfFilterNode
;
32 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.TmfFilterOrNode
;
33 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.TmfFilterTraceTypeNode
;
34 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.TmfNanoTimestamp
;
35 import org
.junit
.Before
;
36 import org
.junit
.Test
;
39 * Test suite for the {@link TmfFilterNode} class.
41 * @author Patrick Tasse
43 @SuppressWarnings("javadoc")
44 public class TmfFilterNodeTest
extends TmfFilterTreeNodeTest
{
46 // ------------------------------------------------------------------------
48 // ------------------------------------------------------------------------
50 private static final String FILTER
= "filter";
51 private ITmfEventField fContent
= new TmfEventField(ITmfEventField
.ROOT_FIELD_ID
, null, null);
52 private TmfEvent fEvent
= new TmfEvent(TRACE
, 0, new TmfNanoTimestamp(1), EVENT_TYPE
, fContent
);
53 private TmfFilterNode fFilter
;
55 // ------------------------------------------------------------------------
57 // ------------------------------------------------------------------------
60 public void createFilter() {
61 fFilter
= new TmfFilterNode(null, FILTER
);
62 fFilterNode
= fFilter
;
66 public void testMatches() {
67 fFilter
.addChild(TRUE_NODE
);
68 assertTrue(fFilter
.matches(fEvent
));
70 fFilter
.replaceChild(0, FALSE_NODE
);
71 assertFalse(fFilter
.matches(fEvent
));
75 public void testGetFilterName() {
76 assertEquals("getFilterName()", FILTER
, fFilter
.getFilterName());
80 public void testGetName() {
81 assertEquals("getName()", "FILTER", fFilter
.getNodeName());
85 public void testGetValidChildren() {
86 Set
<String
> validChildren
= new HashSet
<>(Arrays
.asList(
87 TmfFilterTraceTypeNode
.NODE_NAME
,
88 TmfFilterAndNode
.NODE_NAME
,
89 TmfFilterOrNode
.NODE_NAME
,
90 TmfFilterContainsNode
.NODE_NAME
,
91 TmfFilterEqualsNode
.NODE_NAME
,
92 TmfFilterMatchesNode
.NODE_NAME
,
93 TmfFilterCompareNode
.NODE_NAME
));
94 assertEquals("getValidChildren()", validChildren
, new HashSet
<>(fFilter
.getValidChildren()));
This page took 0.033626 seconds and 4 git commands to generate.