use of org.eclipse.linuxtools.systemtap.graphing.core.filters.RangeFilter in project linuxtools by eclipse.
the class RangeFilterTest method testFilter.
@Test
public void testFilter() {
int width = 4;
int height = 10;
int wrap = height / 3;
ArrayList<Object>[] data = MockDataSet.buildArray(width, height, wrap);
assertEquals(width, data.length);
assertEquals(height, data[0].size());
List<Object>[] data2 = filter.filter(data);
assertEquals(width, data.length);
assertEquals(height, data[0].size());
assertEquals(width, data2.length);
assertEquals(6, data2[0].size());
assertEquals("1", data2[0].get(0));
assertEquals("2", data2[0].get(1));
assertEquals("1", data2[0].get(2));
assertEquals("2", data2[0].get(3));
assertEquals(data[2].get(1), data2[2].get(0));
assertEquals(data[2].get(2), data2[2].get(1));
assertEquals(data[2].get(4), data2[2].get(2));
assertEquals(data[2].get(5), data2[2].get(3));
filter = new RangeFilter(0, 0, 2, RangeFilter.INSIDE_BOUNDS);
data2 = filter.filter(data);
assertEquals(width, data.length);
assertEquals(height, data[0].size());
assertEquals(width, data2.length);
assertEquals(3, data2[0].size());
assertEquals("1", data2[0].get(0));
assertEquals("1", data2[0].get(1));
assertEquals("1", data2[0].get(2));
assertEquals(data[2].get(1), data2[2].get(0));
assertEquals(data[2].get(4), data2[2].get(1));
assertEquals(data[2].get(7), data2[2].get(2));
filter = new RangeFilter(0, 0, 2, RangeFilter.OUTSIDE_BOUNDS | RangeFilter.INCLUSIVE);
data2 = filter.filter(data);
assertEquals(width, data.length);
assertEquals(height, data[0].size());
assertEquals(width, data2.length);
assertEquals(7, data2[0].size());
assertEquals("0", data2[0].get(0));
assertEquals("2", data2[0].get(1));
assertEquals("0", data2[0].get(2));
assertEquals("2", data2[0].get(3));
assertEquals(data[2].get(0), data2[2].get(0));
assertEquals(data[2].get(2), data2[2].get(1));
assertEquals(data[2].get(3), data2[2].get(2));
assertEquals(data[2].get(5), data2[2].get(3));
filter = new RangeFilter(0, 0, 2, RangeFilter.INSIDE_BOUNDS);
data2 = filter.filter(data);
assertEquals(width, data.length);
assertEquals(height, data[0].size());
assertEquals(width, data2.length);
assertEquals(3, data2[0].size());
assertEquals("1", data2[0].get(0));
assertEquals("1", data2[0].get(1));
assertEquals("1", data2[0].get(2));
assertEquals(data[2].get(1), data2[2].get(0));
assertEquals(data[2].get(4), data2[2].get(1));
assertEquals(data[2].get(7), data2[2].get(2));
filter = new RangeFilter(0, 0, 2, RangeFilter.OUTSIDE_BOUNDS);
data2 = filter.filter(data);
assertEquals(width, data.length);
assertEquals(height, data[0].size());
assertEquals(width, data2.length);
assertEquals(0, data2[0].size());
filter = new RangeFilter(-1, 1, 3, 0);
assertNull(filter.filter(data));
}
use of org.eclipse.linuxtools.systemtap.graphing.core.filters.RangeFilter in project linuxtools by eclipse.
the class FilteredRowDataSetTest method testAddFilter.
// End overwrite to ensure the data returned has all the filters applied
// IFilteredDataSet Methods
@Test
public void testAddFilter() {
data.remove(0);
data.remove(0);
RowEntry entry;
entry = new RowEntry();
entry.putRow(0, new Integer[] { 3, 2, 5 });
data.append(entry);
entry = new RowEntry();
entry.putRow(0, new Integer[] { 4, 2, 3 });
data.append(entry);
entry = new RowEntry();
entry.putRow(0, new Integer[] { 7, 2, 9 });
data.append(entry);
entry = new RowEntry();
entry.putRow(0, new Integer[] { 2, 2, 6 });
data.append(entry);
entry = new RowEntry();
entry.putRow(0, new Integer[] { 5, 2, 2 });
data.append(entry);
fdata.addFilter(new RangeFilter(0, 3, 5, RangeFilter.INCLUSIVE | RangeFilter.INSIDE_BOUNDS));
assertEquals(3, fdata.getRowCount());
Object[] row = fdata.getRow(1);
assertEquals(4, ((Integer) row[0]).intValue());
assertEquals(3, ((Integer) row[2]).intValue());
row = fdata.getRow(2);
assertEquals(5, ((Integer) row[0]).intValue());
assertEquals(2, ((Integer) row[1]).intValue());
fdata.addFilter(new SortFilter(2, SortFilter.ASCENDING));
assertEquals(3, fdata.getRowCount());
row = fdata.getRow(0);
assertEquals(5, ((Integer) row[0]).intValue());
assertEquals(2, ((Integer) row[2]).intValue());
row = fdata.getRow(1);
assertEquals(4, ((Integer) row[0]).intValue());
assertEquals(3, ((Integer) row[2]).intValue());
}
use of org.eclipse.linuxtools.systemtap.graphing.core.filters.RangeFilter in project linuxtools by eclipse.
the class FilteredRowDataSetTest method testRemoveFilter.
@Test
public void testRemoveFilter() {
data.remove(0);
data.remove(0);
RowEntry entry;
entry = new RowEntry();
entry.putRow(0, new Integer[] { 3, 2, 5 });
data.append(entry);
entry = new RowEntry();
entry.putRow(0, new Integer[] { 4, 2, 3 });
data.append(entry);
entry = new RowEntry();
entry.putRow(0, new Integer[] { 7, 2, 9 });
data.append(entry);
entry = new RowEntry();
entry.putRow(0, new Integer[] { 2, 2, 6 });
data.append(entry);
entry = new RowEntry();
entry.putRow(0, new Integer[] { 5, 2, 2 });
data.append(entry);
RangeFilter filter = new RangeFilter(0, 3, 5, RangeFilter.INCLUSIVE | RangeFilter.INSIDE_BOUNDS);
fdata.addFilter(filter);
fdata.addFilter(new SortFilter(2, SortFilter.ASCENDING));
fdata.removeFilter(filter);
assertEquals(5, fdata.getRowCount());
Object[] row = fdata.getRow(0);
assertEquals(5, ((Integer) row[0]).intValue());
assertEquals(2, ((Integer) row[2]).intValue());
row = fdata.getRow(1);
assertEquals(4, ((Integer) row[0]).intValue());
assertEquals(3, ((Integer) row[2]).intValue());
}
use of org.eclipse.linuxtools.systemtap.graphing.core.filters.RangeFilter in project linuxtools by eclipse.
the class FilteredTableDataSetTest method testAddFilter.
@Test
public void testAddFilter() {
TableEntry entry;
entry = new TableEntry();
entry.add(new Integer[] { 3, 2, 5 });
dataSet.append(entry);
entry = new TableEntry();
entry.add(new Integer[] { 4, 2, 3 });
dataSet.append(entry);
entry = new TableEntry();
entry.add(new Integer[] { 7, 2, 9 });
dataSet.append(entry);
entry = new TableEntry();
entry.add(new Integer[] { 2, 2, 6 });
dataSet.append(entry);
entry = new TableEntry();
entry.add(new Integer[] { 5, 2, 2 });
dataSet.append(entry);
dataSet.addFilter(new RangeFilter(0, 3, 4, RangeFilter.INCLUSIVE | RangeFilter.INSIDE_BOUNDS));
assertEquals(0, dataSet.getRowCount());
dataSet.clearFilters();
dataSet.addFilter(new RangeFilter(0, 3, 5, RangeFilter.INCLUSIVE | RangeFilter.INSIDE_BOUNDS));
assertEquals(1, dataSet.getRowCount());
Object[] row = dataSet.getRow(0);
assertEquals(5, ((Integer) row[0]).intValue());
assertEquals(2, ((Integer) row[2]).intValue());
}
use of org.eclipse.linuxtools.systemtap.graphing.core.filters.RangeFilter in project linuxtools by eclipse.
the class FilteredTableDataSetTest method testGetFilters.
@Test
public void testGetFilters() {
assertEquals(0, dataSet.getFilters().length);
RangeFilter filter1 = new RangeFilter(0, 3, 5, RangeFilter.INCLUSIVE | RangeFilter.INSIDE_BOUNDS);
SortFilter filter2 = new SortFilter(2, SortFilter.ASCENDING);
dataSet.addFilter(filter1);
dataSet.addFilter(filter2);
IDataSetFilter[] filters = dataSet.getFilters();
assertEquals(2, filters.length);
}
Aggregations