Search in sources :

Example 1 with TmfTreeCompositeDataProvider

use of org.eclipse.tracecompass.internal.tmf.core.model.tree.TmfTreeCompositeDataProvider 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());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) AnnotationCategoriesModel(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.AnnotationCategoriesModel) ArrayList(java.util.ArrayList) TmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel) Annotation(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation) NonNull(org.eclipse.jdt.annotation.NonNull) AnnotationModel(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.AnnotationModel) TmfTreeModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel) TmfTreeCompositeDataProvider(org.eclipse.tracecompass.internal.tmf.core.model.tree.TmfTreeCompositeDataProvider) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 NonNull (org.eclipse.jdt.annotation.NonNull)1 Annotation (org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation)1 AnnotationCategoriesModel (org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.AnnotationCategoriesModel)1 AnnotationModel (org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.AnnotationModel)1 TmfTreeCompositeDataProvider (org.eclipse.tracecompass.internal.tmf.core.model.tree.TmfTreeCompositeDataProvider)1 TmfTreeDataModel (org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel)1 TmfTreeModel (org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel)1 Test (org.junit.Test)1