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
.TmfFilterOrNode
;
32 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.TmfFilterTraceTypeNode
;
33 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.TmfNanoTimestamp
;
34 import org
.junit
.Before
;
35 import org
.junit
.Test
;
38 * Test suite for the {@link TmfFilterAndNode} class.
40 * @author Patrick Tasse
42 @SuppressWarnings("javadoc")
43 public class TmfFilterAndNodeTest
extends TmfFilterTreeNodeTest
{
45 // ------------------------------------------------------------------------
47 // ------------------------------------------------------------------------
49 private ITmfEventField fContent
= new TmfEventField(ITmfEventField
.ROOT_FIELD_ID
, null, null);
50 private TmfEvent fEvent
= new TmfEvent(TRACE
, 0, new TmfNanoTimestamp(1), EVENT_TYPE
, fContent
);
51 private TmfFilterAndNode fFilter
;
53 // ------------------------------------------------------------------------
55 // ------------------------------------------------------------------------
58 public void createFilter() {
59 fFilter
= new TmfFilterAndNode(null);
60 fFilterNode
= fFilter
;
64 public void testMatches() {
65 fFilter
.addChild(TRUE_NODE
);
66 fFilter
.addChild(TRUE_NODE
);
67 assertTrue(fFilter
.matches(fEvent
));
69 fFilter
.replaceChild(0, FALSE_NODE
);
70 assertFalse(fFilter
.matches(fEvent
));
73 assertTrue(fFilter
.matches(fEvent
));
77 public void testGetName() {
78 assertEquals("getName()", "AND", fFilter
.getNodeName());
82 public void testGetValidChildren() {
83 Set
<String
> validChildren
= new HashSet
<>(Arrays
.asList(
84 TmfFilterTraceTypeNode
.NODE_NAME
,
85 TmfFilterAndNode
.NODE_NAME
,
86 TmfFilterOrNode
.NODE_NAME
,
87 TmfFilterContainsNode
.NODE_NAME
,
88 TmfFilterEqualsNode
.NODE_NAME
,
89 TmfFilterMatchesNode
.NODE_NAME
,
90 TmfFilterCompareNode
.NODE_NAME
));
91 assertEquals("getValidChildren()", validChildren
, new HashSet
<>(fFilter
.getValidChildren()));
This page took 0.034206 seconds and 6 git commands to generate.