tmf.core: Introduce TmfTimestamp factory methods
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.core.tests / src / org / eclipse / tracecompass / tmf / core / tests / filter / TmfFilterNodeTest.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.TmfFilterNode;
32import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterOrNode;
33import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterTraceTypeNode;
b2c971ec 34import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
ebc1e992
PT
35import org.junit.Before;
36import org.junit.Test;
37
38/**
39 * Test suite for the {@link TmfFilterNode} class.
40 *
41 * @author Patrick Tasse
42 */
43@SuppressWarnings("javadoc")
b0d2c558 44public class TmfFilterNodeTest extends TmfFilterTreeNodeTestBase {
ebc1e992
PT
45
46 // ------------------------------------------------------------------------
47 // Variables
48 // ------------------------------------------------------------------------
49
50 private static final String FILTER = "filter";
51 private ITmfEventField fContent = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, null, null);
b2c971ec 52 private TmfEvent fEvent = new TmfEvent(TRACE, 0, TmfTimestamp.fromNanos(1), EVENT_TYPE, fContent);
ebc1e992
PT
53 private TmfFilterNode fFilter;
54
55 // ------------------------------------------------------------------------
56 // Tests
57 // ------------------------------------------------------------------------
58
59 @Before
60 public void createFilter() {
61 fFilter = new TmfFilterNode(null, FILTER);
62 fFilterNode = fFilter;
63 }
64
65 @Test
66 public void testMatches() {
67 fFilter.addChild(TRUE_NODE);
68 assertTrue(fFilter.matches(fEvent));
69
70 fFilter.replaceChild(0, FALSE_NODE);
71 assertFalse(fFilter.matches(fEvent));
72 }
73
74 @Test
75 public void testGetFilterName() {
76 assertEquals("getFilterName()", FILTER, fFilter.getFilterName());
77 }
78
79 @Test
80 public void testGetName() {
81 assertEquals("getName()", "FILTER", fFilter.getNodeName());
82 }
83
84 @Test
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()));
95 }
96}
This page took 0.048813 seconds and 5 git commands to generate.