Search in sources :

Example 1 with HistogramDataProvider

use of org.eclipse.tracecompass.internal.tmf.core.histogram.HistogramDataProvider 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)

Aggregations

NonNull (org.eclipse.jdt.annotation.NonNull)1 HistogramDataProvider (org.eclipse.tracecompass.internal.tmf.core.histogram.HistogramDataProvider)1 SelectionTimeQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter)1 TimeQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter)1 TmfTreeDataModel (org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel)1 TmfTreeModel (org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel)1 ITmfXyModel (org.eclipse.tracecompass.tmf.core.model.xy.ITmfXyModel)1 TmfStatisticsModule (org.eclipse.tracecompass.tmf.core.statistics.TmfStatisticsModule)1 CtfTmfTrace (org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace)1 Test (org.junit.Test)1