tmf.core: Introduce TmfTimestamp factory methods
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.core.tests / src / org / eclipse / tracecompass / tmf / core / tests / filter / TmfFilterOrNodeTest.java
CommitLineData
ebc1e992
PT
1/*******************************************************************************
2 * Copyright (c) 2015 Ericsson
3 *
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
8 *
9 * Contributors:
10 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
12
13package org.eclipse.tracecompass.tmf.core.tests.filter;
14
15import static org.junit.Assert.assertEquals;
16import static org.junit.Assert.assertFalse;
17import static org.junit.Assert.assertTrue;
18
19import java.util.Arrays;
20import java.util.HashSet;
21import java.util.Set;
22
23import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
24import org.eclipse.tracecompass.tmf.core.event.TmfEvent;
25import org.eclipse.tracecompass.tmf.core.event.TmfEventField;
26import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterAndNode;
27import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterCompareNode;
28import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterContainsNode;
29import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterEqualsNode;
30import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterMatchesNode;
31import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterOrNode;
32import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterTraceTypeNode;
b2c971ec 33import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
ebc1e992
PT
34import org.junit.Before;
35import org.junit.Test;
36
37/**
38 * Test suite for the {@link TmfFilterOrNode} class.
39 *
40 * @author Patrick Tasse
41 */
42@SuppressWarnings("javadoc")
b0d2c558 43public class TmfFilterOrNodeTest extends TmfFilterTreeNodeTestBase {
ebc1e992
PT
44
45 // ------------------------------------------------------------------------
46 // Variables
47 // ------------------------------------------------------------------------
48
49 private ITmfEventField fContent = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, null, null);
b2c971ec 50 private TmfEvent fEvent = new TmfEvent(TRACE, 0, TmfTimestamp.fromNanos(1), EVENT_TYPE, fContent);
ebc1e992
PT
51 private TmfFilterOrNode fFilter;
52
53 // ------------------------------------------------------------------------
54 // Tests
55 // ------------------------------------------------------------------------
56
57 @Before
58 public void createFilter() {
59 fFilter = new TmfFilterOrNode(null);
60 fFilterNode = fFilter;
61 }
62
63 @Test
64 public void testMatches() {
65 fFilter.addChild(TRUE_NODE);
66 fFilter.addChild(TRUE_NODE);
67 assertTrue(fFilter.matches(fEvent));
68
69 fFilter.replaceChild(0, FALSE_NODE);
70 assertTrue(fFilter.matches(fEvent));
71
72 fFilter.setNot(true);
73 assertFalse(fFilter.matches(fEvent));
74 }
75
76 @Test
77 public void testGetName() {
78 assertEquals("getName()", "OR", fFilter.getNodeName());
79 }
80
81 @Test
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()));
92 }
93}
This page took 0.107775 seconds and 5 git commands to generate.