~ubuntu-branches/ubuntu/wily/eclipse-linuxtools/wily

« back to all changes in this revision

Viewing changes to systemtap/org.eclipse.linuxtools.systemtap.graphing.core.tests/src/org/eclipse/linuxtools/systemtap/graphing/core/tests/filters/UniqueFilterTest.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam, Jakub Adam, tony mancill
  • Date: 2014-10-11 11:44:05 UTC
  • mfrom: (1.2.4)
  • Revision ID: package-import@ubuntu.com-20141011114405-yazjvxfzzhmi5sgj
Tags: 3.1.0-1
[ Jakub Adam ]
* New upstream release (Closes: #761524).
* Refreshed d/patches.
* Don't build removed feature org.eclipse.linuxtools.tools.launch
  - merged into org.eclipse.linuxtools.profiling.
* Use javac target 1.7.
* Build new feature org.eclipse.linuxtools.dataviewers.feature
  - required by Valgrind integration.
* Build-depend on eclipse-remote-services-api and eclipse-cdt-autotools.
* Bump Standards-Version to 3.9.6.
* Override incompatible-java-bytecode-format - linuxtools needs Java 7.
* Remove unused codeless-jar override.

[ tony mancill ]
* Tweak short package description to make lintian happy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*******************************************************************************
 
2
 * Copyright (c) 2006 IBM Corporation.
 
3
 * All rights reserved. This program and the accompanying materials
 
4
 * are made available under the terms of the Eclipse Public License v1.0
 
5
 * which accompanies this distribution, and is available at
 
6
 * http://www.eclipse.org/legal/epl-v10.html
 
7
 *
 
8
 * Contributors:
 
9
 *     IBM Corporation - Jeff Briggs, Henry Hughes, Ryan Morse
 
10
 *******************************************************************************/
 
11
 
 
12
package org.eclipse.linuxtools.systemtap.graphing.core.tests.filters;
 
13
 
 
14
import static org.junit.Assert.assertEquals;
 
15
import static org.junit.Assert.assertNotNull;
 
16
import static org.junit.Assert.assertNull;
 
17
 
 
18
import java.util.ArrayList;
 
19
import java.util.List;
 
20
 
 
21
import org.eclipse.linuxtools.systemtap.graphing.core.aggregates.MaxAggregate;
 
22
import org.eclipse.linuxtools.systemtap.graphing.core.aggregates.SumAggregate;
 
23
import org.eclipse.linuxtools.systemtap.graphing.core.filters.UniqueFilter;
 
24
import org.eclipse.linuxtools.systemtap.graphing.core.tests.MockDataSet;
 
25
import org.junit.Before;
 
26
import org.junit.Test;
 
27
 
 
28
public class UniqueFilterTest  {
 
29
    @Before
 
30
    public void setUp() {
 
31
        filter = new UniqueFilter(0, new SumAggregate());
 
32
    }
 
33
    @Test
 
34
    public void testUniqueFilter() {
 
35
        filter = new UniqueFilter(-1, new MaxAggregate());
 
36
        assertNotNull(filter);
 
37
    }
 
38
    @Test
 
39
    public void testFilter() {
 
40
        int width = 4;
 
41
        int height = 10;
 
42
        int wrap = height / 3;
 
43
        ArrayList<Object>[] data = MockDataSet.buildArray(width, height, wrap);
 
44
 
 
45
        assertEquals(width, data.length);
 
46
        assertEquals(height, data[0].size());
 
47
 
 
48
        List<Object>[] data2 = filter.filter(data);
 
49
 
 
50
        assertEquals(width, data.length);
 
51
        assertEquals(height, data[0].size());
 
52
        assertEquals(width, data2.length);
 
53
        assertEquals(wrap, data2[0].size());
 
54
        assertEquals("1", data2[0].get(0));
 
55
        assertEquals("2", data2[0].get(1));
 
56
        assertEquals("0", data2[0].get(2));
 
57
 
 
58
        assertEquals(0, ((Number)data2[2].get(0)).intValue());
 
59
        assertEquals(3, ((Number)data2[2].get(1)).intValue());
 
60
        assertEquals(8, ((Number)data2[2].get(2)).intValue());
 
61
 
 
62
        filter = new UniqueFilter(-1, new SumAggregate());
 
63
        assertNull(filter.filter(null));
 
64
 
 
65
        data = MockDataSet.createArrayList(2, new Object());
 
66
        data[0] = new ArrayList<>();
 
67
        data[1] = new ArrayList<>();
 
68
 
 
69
        data[0].add("a");
 
70
        data[0].add("a");
 
71
        data[1].add("b");
 
72
        data[1].add("c");
 
73
        filter = new UniqueFilter(0, new SumAggregate());
 
74
        assertNotNull(filter.filter(data));
 
75
    }
 
76
    @Test
 
77
    public void testGetID() {
 
78
        assertEquals(UniqueFilter.ID, filter.getID());
 
79
    }
 
80
 
 
81
    private UniqueFilter filter;
 
82
}