Search in sources :

Example 1 with IDataEntry

use of org.eclipse.linuxtools.systemtap.graphing.core.datasets.IDataEntry in project linuxtools by eclipse.

the class TestCreateSystemtapScript method createAndViewDummyData.

private static void createAndViewDummyData(String[] titles, Object[] data) {
    if (data.length % titles.length != 0) {
        throw new IllegalArgumentException("data.length must be a multiple of titles.length.");
    }
    final int numRows = data.length / titles.length;
    IFilteredDataSet dataset = new FilteredRowDataSet(titles);
    for (int i = 0; i < numRows; i++) {
        IDataEntry dataEntry = new RowEntry();
        Object[] values = new Object[titles.length];
        for (int v = 0; v < titles.length; v++) {
            values[v] = data[titles.length * i + v];
        }
        dataEntry.putRow(0, values);
        dataset.setData(dataEntry);
    }
    final File dataFile;
    try {
        dataFile = File.createTempFile("testSet", ".set");
        dataFile.deleteOnExit();
        if (!dataset.writeToFile(dataFile)) {
            throw new IOException();
        }
    } catch (IOException e) {
        fail("Could not create dummy data set.");
        return;
    }
    UIThreadRunnable.syncExec(() -> {
        new ImportDataSetHandler().execute(dataFile.getPath());
    });
    String editorName = dataFile.getName().concat(" Graphs");
    bot.waitUntil(new EditorIsActive(editorName));
}
Also used : ImportDataSetHandler(org.eclipse.linuxtools.internal.systemtap.ui.ide.handlers.ImportDataSetHandler) IOException(java.io.IOException) Point(org.eclipse.swt.graphics.Point) IFilteredDataSet(org.eclipse.linuxtools.systemtap.graphing.core.datasets.IFilteredDataSet) FilteredRowDataSet(org.eclipse.linuxtools.systemtap.graphing.core.datasets.row.FilteredRowDataSet) IDataEntry(org.eclipse.linuxtools.systemtap.graphing.core.datasets.IDataEntry) RowEntry(org.eclipse.linuxtools.systemtap.graphing.core.datasets.row.RowEntry) File(java.io.File)

Example 2 with IDataEntry

use of org.eclipse.linuxtools.systemtap.graphing.core.datasets.IDataEntry in project linuxtools by eclipse.

the class FilteredRowDataSetTest method testRemove.

@Test
public void testRemove() {
    assertFalse(fdata.remove(null));
    assertFalse(fdata.remove(new RowEntry()));
    assertFalse(fdata.remove(-1));
    assertFalse(fdata.remove(10));
    assertEquals(2, fdata.getEntryCount());
    IDataEntry entry = data.getEntry(0);
    assertTrue(fdata.remove(entry));
    assertEquals(1, fdata.getEntryCount());
    assertFalse(fdata.remove(entry));
    assertTrue(fdata.remove(0));
}
Also used : IDataEntry(org.eclipse.linuxtools.systemtap.graphing.core.datasets.IDataEntry) RowEntry(org.eclipse.linuxtools.systemtap.graphing.core.datasets.row.RowEntry) Test(org.junit.Test)

Example 3 with IDataEntry

use of org.eclipse.linuxtools.systemtap.graphing.core.datasets.IDataEntry in project linuxtools by eclipse.

the class RowParserTest method testParse.

@Test
public void testParse() {
    assertNull(parser.parse(null));
    assertNull(parser.parse(new StringBuilder("")));
    assertNull(parser.parse(new StringBuilder("asdf")));
    assertNull(parser.parse(new StringBuilder("1, ")));
    assertNull(parser.parse(new StringBuilder("1, 3")));
    IDataEntry entry = parser.parse(new StringBuilder("1, (2), 3, 4, 5"));
    assertNotNull(entry);
    assertEquals(2, entry.getColCount());
    assertEquals(1, entry.getRowCount());
    assertEquals("1", entry.getRow(0)[0]);
}
Also used : IDataEntry(org.eclipse.linuxtools.systemtap.graphing.core.datasets.IDataEntry) Test(org.junit.Test)

Example 4 with IDataEntry

use of org.eclipse.linuxtools.systemtap.graphing.core.datasets.IDataEntry in project linuxtools by eclipse.

the class TableEntryTest method testCopy.

@Test
public void testCopy() {
    IDataEntry entry2 = entry.copy();
    assertEquals(entry2.getRowCount(), entry.getRowCount());
    assertEquals(entry2.getColCount(), entry.getColCount());
    assertSame(entry2.getRow(0)[1], entry.getRow(0)[1]);
}
Also used : IDataEntry(org.eclipse.linuxtools.systemtap.graphing.core.datasets.IDataEntry) Test(org.junit.Test)

Example 5 with IDataEntry

use of org.eclipse.linuxtools.systemtap.graphing.core.datasets.IDataEntry in project linuxtools by eclipse.

the class TableParserTest method testParse.

@Test
public void testParse() {
    assertNull(parser.parse(null));
    assertNull(parser.parse(new StringBuilder("")));
    assertNull(parser.parse(new StringBuilder("asdf")));
    assertNull(parser.parse(new StringBuilder("1, ")));
    assertNull(parser.parse(new StringBuilder("1, 3")));
    IDataEntry entry = parser.parse(new StringBuilder("1, (2), 3, 4, 5\n\n"));
    assertNotNull(entry);
    assertEquals(2, entry.getColCount());
    assertEquals(2, entry.getRowCount());
    assertEquals("1", entry.getRow(0)[0]);
}
Also used : IDataEntry(org.eclipse.linuxtools.systemtap.graphing.core.datasets.IDataEntry) Test(org.junit.Test)

Aggregations

IDataEntry (org.eclipse.linuxtools.systemtap.graphing.core.datasets.IDataEntry)10 Test (org.junit.Test)7 RowEntry (org.eclipse.linuxtools.systemtap.graphing.core.datasets.row.RowEntry)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 File (java.io.File)1 IOException (java.io.IOException)1 ImportDataSetHandler (org.eclipse.linuxtools.internal.systemtap.ui.ide.handlers.ImportDataSetHandler)1 IFilteredDataSet (org.eclipse.linuxtools.systemtap.graphing.core.datasets.IFilteredDataSet)1 FilteredRowDataSet (org.eclipse.linuxtools.systemtap.graphing.core.datasets.row.FilteredRowDataSet)1 TableEntry (org.eclipse.linuxtools.systemtap.graphing.core.datasets.table.TableEntry)1 Point (org.eclipse.swt.graphics.Point)1