use of org.eclipse.tracecompass.tmf.core.filter.model.ITmfFilterTreeNode in project tracecompass by tracecompass.
the class TmfFilterHelperTest method testInputRegexNoAspect.
/**
* Test a regex whose parameter is not an aspect name
*/
@Test
public void testInputRegexNoAspect() {
ITmfEventAspect<@NonNull Object> contentAspect = TmfBaseAspects.getContentsAspect().forField(FIELD1_NAME);
String regex = FIELD1_NAME + " == \"" + FIELD1_VALUE1 + "\"";
ITmfFilter filter = getFilter(regex);
assertTrue(filter instanceof TmfFilterRootNode);
TmfFilterRootNode node = (TmfFilterRootNode) filter;
assertEquals(1, node.getChildrenCount());
ITmfFilterTreeNode child = node.getChild(0);
assertTrue(child instanceof TmfFilterEqualsNode);
TmfFilterEqualsNode equalsNode = (TmfFilterEqualsNode) child;
assertEquals(contentAspect, equalsNode.getEventAspect());
assertEquals(FIELD1_VALUE1, equalsNode.getValue());
// Test expected behavior on events
assertTrue(filter.matches(fEvent1));
assertFalse(filter.matches(fEvent2));
assertFalse(filter.matches(fEvent3));
}
use of org.eclipse.tracecompass.tmf.core.filter.model.ITmfFilterTreeNode in project tracecompass by tracecompass.
the class TmfFilterHelperTest method testInputRegexPresent.
/**
* Test a regex with present
*/
@Test
public void testInputRegexPresent() {
ITmfEventAspect<@NonNull Object> aspect = TmfBaseAspects.getContentsAspect().forField(FIELD1_NAME);
String regex = FIELD1_NAME + " present";
ITmfFilter filter = getFilter(regex);
// verify the main root node
assertTrue(filter instanceof TmfFilterRootNode);
TmfFilterRootNode node = (TmfFilterRootNode) filter;
assertEquals(1, node.getChildrenCount());
ITmfFilterTreeNode child = node.getChild(0);
assertTrue(child instanceof TmfFilterMatchesNode);
// verify the equals node
TmfFilterMatchesNode equalsNode = (TmfFilterMatchesNode) child;
assertEquals(aspect, equalsNode.getEventAspect());
assertEquals(".*", equalsNode.getRegex());
// Test expected behavior on events
assertTrue(filter.matches(fEvent1));
assertFalse(filter.matches(fEvent2));
assertTrue(filter.matches(fEvent3));
}
use of org.eclipse.tracecompass.tmf.core.filter.model.ITmfFilterTreeNode in project tracecompass by tracecompass.
the class TmfFilterTreeNodeTestBase method testRemove.
@Test
public void testRemove() {
ITmfFilterTreeNode child = fFilterNode.clone();
assertEquals("addChild()", 0, fFilterNode.addChild(child));
assertEquals("remove()", child, child.remove());
assertEquals("hasChildren()", false, fFilterNode.hasChildren());
}
use of org.eclipse.tracecompass.tmf.core.filter.model.ITmfFilterTreeNode in project tracecompass by tracecompass.
the class TmfFilterTreeNodeTestBase method testRemoveChild.
@Test
public void testRemoveChild() {
ITmfFilterTreeNode child = fFilterNode.clone();
assertEquals("addChild()", 0, fFilterNode.addChild(child));
assertEquals("removeChild()", child, fFilterNode.removeChild(child));
assertEquals("hasChildren()", false, fFilterNode.hasChildren());
}
use of org.eclipse.tracecompass.tmf.core.filter.model.ITmfFilterTreeNode in project tracecompass by tracecompass.
the class FilterManager method setSavedFilters.
/**
* Set the passed filters as the currently saved ones.
*
* @param filters
* The filters to save
*/
public static void setSavedFilters(ITmfFilterTreeNode[] filters) {
fRoot = new TmfFilterRootNode();
for (ITmfFilterTreeNode filter : filters) {
fRoot.addChild(filter.clone());
}
try {
TmfFilterXMLWriter writerXML = new TmfFilterXMLWriter(fRoot);
writerXML.saveTree(SAVED_FILTERS_PATH_NAME);
} catch (ParserConfigurationException e) {
// $NON-NLS-1$
Activator.logError("Error saving filter xml file: " + SAVED_FILTERS_PATH_NAME, e);
}
}
Aggregations