Search in sources :

Example 11 with TmfTreeDataModel

use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel in project tracecompass by tracecompass.

the class HistogramDataProviderTest method testHelloLost.

/**
 * Test the {@link HistogramDataProvider} with the
 * {@link CtfTestTrace#HELLO_LOST} trace. Ensure that the expected tree and xy
 * models are returned
 *
 * @throws TmfAnalysisException
 *             if the trace is set more that once
 */
@Test
public void testHelloLost() throws TmfAnalysisException {
    CtfTmfTrace trace = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.HELLO_LOST);
    TmfStatisticsModule module = new TmfStatisticsModule();
    module.setName("Statistics");
    assertTrue("Statistics Analysis should apply to this trace", module.setTrace(trace));
    assertEquals("Statistics Analysis shouls be schedulable", Status.OK_STATUS, module.schedule());
    assertTrue("Statistics Analysis should run successfully", module.waitForCompletion());
    try {
        HistogramDataProvider provider = new HistogramDataProvider(trace, module);
        TmfModelResponse<@NonNull TmfTreeModel<@NonNull TmfTreeDataModel>> treeResponse = provider.fetchTree(FetchParametersUtils.timeQueryToMap(new TimeQueryFilter(START, END, 2)), null);
        assertEquals("Response Status should be COMPLETED, as we waited for the analysis to complete", ITmfResponse.Status.COMPLETED, treeResponse.getStatus());
        TmfTreeModel<@NonNull TmfTreeDataModel> treeModel = treeResponse.getModel();
        assertNotNull(treeModel);
        assertEquals(EXPECTED_FULL_PATHS, getFullPaths(treeModel.getEntries()));
        List<Long> ids = Lists.transform(treeModel.getEntries(), TmfTreeDataModel::getId);
        SelectionTimeQueryFilter selectionFilter = new SelectionTimeQueryFilter(START, END, 100, ids);
        TmfModelResponse<@NonNull ITmfXyModel> xyResponse = provider.fetchXY(FetchParametersUtils.selectionTimeQueryToMap(selectionFilter), null);
        assertEquals("Response Status should be COMPLETED, as we waited for the analysis to complete", ITmfResponse.Status.COMPLETED, xyResponse.getStatus());
        ITmfXyModel xyModel = xyResponse.getModel();
        assertNotNull(xyModel);
        assertEquals(EXPECTED_YDATA, Maps.uniqueIndex(xyModel.getSeriesData(), ISeriesModel::getId));
    } finally {
        module.dispose();
        CtfTmfTestTraceUtils.dispose(CtfTestTrace.HELLO_LOST);
    }
}
Also used : TmfStatisticsModule(org.eclipse.tracecompass.tmf.core.statistics.TmfStatisticsModule) HistogramDataProvider(org.eclipse.tracecompass.internal.tmf.core.histogram.HistogramDataProvider) TmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel) SelectionTimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter) NonNull(org.eclipse.jdt.annotation.NonNull) TmfTreeModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel) TimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter) SelectionTimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter) CtfTmfTrace(org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace) ITmfXyModel(org.eclipse.tracecompass.tmf.core.model.xy.ITmfXyModel) Test(org.junit.Test)

Example 12 with TmfTreeDataModel

use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel in project tracecompass by tracecompass.

the class HistogramDataProviderTest method getFullPath.

private static String getFullPath(Map<Long, TmfTreeDataModel> map, TmfTreeDataModel model) {
    StringBuilder builder = new StringBuilder(model.getName());
    TmfTreeDataModel parent = map.get(model.getParentId());
    while (parent != null) {
        builder.insert(0, parent.getName() + '/');
        parent = map.get(parent.getParentId());
    }
    return builder.toString();
}
Also used : TmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel)

Example 13 with TmfTreeDataModel

use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel in project tracecompass by tracecompass.

the class TmfTreeDataModelTest method testHashCode.

// ------------------------------------------------------------------------
// TmfTreeDataModel#hashCode
// ------------------------------------------------------------------------
/**
 * Run the {@link TmfTreeDataModel#hashCode} method test.
 */
@Test
public void testHashCode() {
    TmfTreeDataModel model0 = createModel(0);
    TmfTreeDataModel model1 = createModel(1);
    assertTrue(HASH_CODE, fModel0.hashCode() == model0.hashCode());
    assertTrue(HASH_CODE, fModel1.hashCode() == model1.hashCode());
    assertTrue(HASH_CODE, fModel0.hashCode() != model1.hashCode());
    assertTrue(HASH_CODE, fModel1.hashCode() != model0.hashCode());
}
Also used : TmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel) Test(org.junit.Test)

Example 14 with TmfTreeDataModel

use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel in project tracecompass by tracecompass.

the class TmfTreeDataModelTest method testEqualsNull.

/**
 * Run the {@link TmfTreeDataModel#equals} method test.
 */
@Test
public void testEqualsNull() {
    TmfTreeDataModel model0 = null;
    assertFalse(EQUALS, fModel0.equals(model0));
    assertFalse(EQUALS, fModel1.equals(model0));
}
Also used : TmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel) Test(org.junit.Test)

Example 15 with TmfTreeDataModel

use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel in project tracecompass by tracecompass.

the class TmfTreeDataModelTest method testEqualsTransivity.

/**
 * Run the {@link TmfTreeDataModel#equals} method test.
 */
@Test
public void testEqualsTransivity() {
    TmfTreeDataModel model0 = createModel(0);
    TmfTreeDataModel model1 = createModel(0);
    TmfTreeDataModel model2 = createModel(0);
    assertTrue(EQUALS, model0.equals(model1));
    assertTrue(EQUALS, model1.equals(model2));
    assertTrue(EQUALS, model0.equals(model2));
}
Also used : TmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel) Test(org.junit.Test)

Aggregations

TmfTreeDataModel (org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel)21 Test (org.junit.Test)9 TmfTreeModel (org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel)8 ArrayList (java.util.ArrayList)5 NonNull (org.eclipse.jdt.annotation.NonNull)4 ITmfTreeDataModel (org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel)4 HashMap (java.util.HashMap)3 AtomicLong (java.util.concurrent.atomic.AtomicLong)3 Nullable (org.eclipse.jdt.annotation.Nullable)3 SelectionTimeQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter)3 TmfModelResponse (org.eclipse.tracecompass.tmf.core.response.TmfModelResponse)3 Map (java.util.Map)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 ITmfStateSystem (org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)2 OutputElementStyle (org.eclipse.tracecompass.tmf.core.model.OutputElementStyle)2 TimeQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter)2 ITmfTreeXYDataProvider (org.eclipse.tracecompass.tmf.core.model.xy.ITmfTreeXYDataProvider)2 ITmfXyModel (org.eclipse.tracecompass.tmf.core.model.xy.ITmfXyModel)2 ITmfTreeViewerEntry (org.eclipse.tracecompass.tmf.ui.viewers.tree.ITmfTreeViewerEntry)2 TmfGenericTreeEntry (org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfGenericTreeEntry)2