use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel in project tracecompass by tracecompass.
the class CounterDataProvider method addTreeViewerEntries.
/**
* Recursively add all child entries of a parent branch from the state system.
*/
private void addTreeViewerEntries(ITmfStateSystem ss, long parentId, int quark, List<TmfTreeDataModel> entries) {
for (int childQuark : ss.getSubAttributes(quark, false)) {
long id = getId(childQuark);
TmfTreeDataModel childBranch = new TmfTreeDataModel(id, parentId, Collections.singletonList(ss.getAttributeName(childQuark)));
entries.add(childBranch);
addTreeViewerEntries(ss, id, childQuark, entries);
}
}
use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel in project tracecompass by tracecompass.
the class InputOutputDataProviderTest method testDiskActivity.
/**
* Test the data provider
*/
@Test
public void testDiskActivity() {
DisksIODataProvider provider = getProvider();
Collection<@NonNull DiskActivity> diskActivity = fTestCase.getDiskActivity();
for (DiskActivity test : diskActivity) {
Map<@NonNull String, @NonNull Object> parameters = test.getTimeQuery();
TmfModelResponse<@NonNull TmfTreeModel<@NonNull TmfTreeDataModel>> response = provider.fetchTree(parameters, PROGRESS_MONITOR);
assertEquals(ITmfResponse.Status.COMPLETED, response.getStatus());
TmfTreeModel<@NonNull TmfTreeDataModel> model = response.getModel();
assertNotNull(model);
parameters = test.getTimeQueryForModel(model);
TmfModelResponse<@NonNull ITmfXyModel> yResponse = provider.fetchXY(parameters, PROGRESS_MONITOR);
assertEquals(ITmfResponse.Status.COMPLETED, yResponse.getStatus());
ITmfXyModel yModel = yResponse.getModel();
assertNotNull(yModel);
Collection<@NonNull ISeriesModel> data = yModel.getSeriesData();
assertEquals(1, data.size());
ISeriesModel ySeries = data.iterator().next();
double[] expected = test.getActivity();
double[] actual = ySeries.getData();
for (int i = 0; i < expected.length; i++) {
assertTrue(String.format("No actual value at position %d for %s", i, test), actual.length > i);
assertEquals(String.format("Value at position %d for %s", i, test), expected[i], actual[i], 0.001);
}
assertEquals(String.format("More values than expected for %s", test), expected.length, actual.length);
}
}
use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel in project tracecompass by tracecompass.
the class TmfTreeDataModelTest method testCompositeTree.
/**
* Test {@link TmfTreeCompositeDataProvider}
*/
@Test
public void testCompositeTree() {
List<DummyDataProvider> ddps = new ArrayList<>();
for (int i = 0; i < 3; i++) {
ddps.add(new DummyDataProvider(i));
}
TmfTreeCompositeDataProvider<@NonNull TmfTreeDataModel, @NonNull DummyDataProvider> composite = new TmfTreeCompositeDataProvider<>(ddps, "composite-dummy");
assertNotNull(composite);
NullProgressMonitor monitor = new NullProgressMonitor();
TmfModelResponse<@NonNull TmfTreeModel<@NonNull TmfTreeDataModel>> tree = composite.fetchTree(Collections.emptyMap(), monitor);
TmfTreeModel<@NonNull TmfTreeDataModel> model = tree.getModel();
assertNotNull(model);
assertEquals(Arrays.asList("header"), model.getHeaders());
assertEquals(3, model.getEntries().size());
// AnnotationCategories
TmfModelResponse<@NonNull AnnotationCategoriesModel> returnVal = composite.fetchAnnotationCategories(Collections.emptyMap(), monitor);
AnnotationCategoriesModel categoryModel = returnVal.getModel();
assertNotNull(categoryModel);
assertEquals(Arrays.asList("common", "0", "1", "2"), categoryModel.getAnnotationCategories());
// Annotations
TmfModelResponse<@NonNull AnnotationModel> annotations = composite.fetchAnnotations(Collections.emptyMap(), monitor);
AnnotationModel annotationsModel = annotations.getModel();
assertNotNull(annotationsModel);
Collection<@NonNull Annotation> collection = annotationsModel.getAnnotations().get("test");
assertNotNull(collection);
assertEquals(6, collection.size());
}
use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel in project tracecompass by tracecompass.
the class TmfTreeDataModelTest method testEqualsSymmetry.
/**
* Run the {@link TmfTreeDataModel#equals} method test.
*/
@Test
public void testEqualsSymmetry() {
TmfTreeDataModel model0 = createModel(0);
TmfTreeDataModel model1 = createModel(1);
assertTrue(EQUALS, model0.equals(fModel0));
assertTrue(EQUALS, fModel0.equals(model0));
assertTrue(EQUALS, model1.equals(fModel1));
assertTrue(EQUALS, fModel1.equals(model1));
}
use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel in project tracecompass by tracecompass.
the class TmfTreeDataModelTest method testToString.
/**
* Test {@link TmfTreeDataModel#toString()}
*/
@Test
public void testToString() {
assertEquals(TO_STRING, "<name=[label1, label2, label3] id=0 parentId=-1 style=null hasRowModel=true>", fModel0.toString());
assertEquals(TO_STRING, "<name=[label4, label5, label6, label7] id=1 parentId=0 style=Style [1, {}] hasRowModel=false>", fModel1.toString());
TmfTreeDataModel model2 = createModel(2);
assertEquals(TO_STRING, "<name=[Name] id=2 parentId=-1 style=null hasRowModel=true>", model2.toString());
}
Aggregations