TMF: Add support for requirements in AnalysisModuleTestHelper
authorGuilliano Molaire <guilliamo-jaime.molaire@polymtl.ca>
Mon, 21 Apr 2014 14:48:58 +0000 (10:48 -0400)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Wed, 30 Apr 2014 15:04:55 +0000 (11:04 -0400)
Implementation of getRequirements and getValidTraceTypes in the analysis module
test helper so it can be used by test cases. An analysis requirement factory
has been added for the same purpose.

Change-Id: Ibfb3c9beb28893b77a2b80453b3ea75d407105a9
Signed-off-by: Guilliano Molaire <guilliamo-jaime.molaire@polymtl.ca>
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/24284
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Hudson CI
Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Tested-by: Genevieve Bastien <gbastien+lttng@versatic.net>
org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/analysis/AnalysisModuleTestHelper.java
org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/analysis/AnalysisRequirementFactory.java [new file with mode: 0644]

index dc8165ba2e9ce4797773230b789f1154760bbdfe..aa9cdff3e956b970aae9e38606c00c16eaa2d7d8 100644 (file)
@@ -8,6 +8,7 @@
  *
  * Contributors:
  *   Geneviève Bastien - Initial API and implementation
+ *   Guilliano Molaire - Implementation of requirements and valid trace types getters
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.tests.stubs.analysis;
@@ -24,6 +25,8 @@ import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
 import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub2;
 import org.osgi.framework.Bundle;
 
+import com.google.common.collect.ImmutableList;
+
 /**
  * Analysis Module Helper for the stub analysis source
  *
@@ -122,11 +125,24 @@ public class AnalysisModuleTestHelper implements IAnalysisModuleHelper {
 
     @Override
     public Iterable<Class<? extends ITmfTrace>> getValidTraceTypes() {
-        return Collections.EMPTY_SET;
+        return ImmutableList.<Class<? extends ITmfTrace>> of(
+                TmfTraceStub.class,
+                TmfTraceStub2.class);
     }
 
     @Override
     public Iterable<TmfAnalysisRequirement> getAnalysisRequirements() {
-        return Collections.EMPTY_SET;
+        switch (fModule) {
+        case TEST:
+            return ImmutableList.of(
+                    AnalysisRequirementFactory.REQUIREMENT_1,
+                    AnalysisRequirementFactory.REQUIREMENT_3);
+        case TEST2:
+            return ImmutableList.of(
+                    AnalysisRequirementFactory.REQUIREMENT_2,
+                    AnalysisRequirementFactory.REQUIREMENT_3);
+        default:
+            return Collections.EMPTY_SET;
+        }
     }
 }
diff --git a/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/analysis/AnalysisRequirementFactory.java b/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/analysis/AnalysisRequirementFactory.java
new file mode 100644 (file)
index 0000000..21f5b98
--- /dev/null
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2014 École Polytechnique de Montréal
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Guilliano Molaire - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.tests.stubs.analysis;
+
+import java.util.Set;
+
+import org.eclipse.linuxtools.tmf.core.analysis.TmfAnalysisRequirement;
+import org.eclipse.linuxtools.tmf.core.analysis.TmfAnalysisRequirement.ValuePriorityLevel;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Factory class to facilitate requirement usage across test case
+ */
+@SuppressWarnings("javadoc")
+public final class AnalysisRequirementFactory {
+
+    private AnalysisRequirementFactory() {}
+
+    public static final String REQUIREMENT_TYPE_1 = "car";
+    public static final String REQUIREMENT_TYPE_2 = "factory";
+    public static final String REQUIREMENT_TYPE_3 = "code";
+
+    public static final String REQUIREMENT_VALUE_1 = "value1";
+    public static final String REQUIREMENT_VALUE_2 = "value2";
+    public static final String REQUIREMENT_VALUE_3 = "value3";
+    public static final String REQUIREMENT_VALUE_4 = "value4";
+    public static final String REQUIREMENT_VALUE_5 = "value5";
+
+    public static final Set<String> REQUIREMENT_VALUES_1 = ImmutableSet.of(
+            REQUIREMENT_VALUE_1,
+            REQUIREMENT_VALUE_2,
+            REQUIREMENT_VALUE_3,
+            REQUIREMENT_VALUE_5
+            );
+
+    public static final Set<String> REQUIREMENT_VALUES_2 = ImmutableSet.of(
+            REQUIREMENT_VALUE_2,
+            REQUIREMENT_VALUE_3
+            );
+
+    public static final Set<String> REQUIREMENT_VALUES_3 = ImmutableSet.of(
+            REQUIREMENT_VALUE_3,
+            REQUIREMENT_VALUE_4,
+            REQUIREMENT_VALUE_5
+            );
+
+    public static final TmfAnalysisRequirement REQUIREMENT_1 =
+            new TmfAnalysisRequirement(REQUIREMENT_TYPE_1, REQUIREMENT_VALUES_1, ValuePriorityLevel.MANDATORY);
+    public static final TmfAnalysisRequirement REQUIREMENT_2 =
+            new TmfAnalysisRequirement(REQUIREMENT_TYPE_2);
+    public static final TmfAnalysisRequirement REQUIREMENT_3 =
+            new TmfAnalysisRequirement(REQUIREMENT_TYPE_3, REQUIREMENT_VALUES_3, ValuePriorityLevel.MANDATORY);
+
+    static {
+        REQUIREMENT_2.addValue(REQUIREMENT_VALUE_1, ValuePriorityLevel.MANDATORY);
+        REQUIREMENT_2.addValue(REQUIREMENT_VALUE_2, ValuePriorityLevel.OPTIONAL);
+        REQUIREMENT_2.addValue(REQUIREMENT_VALUE_3, ValuePriorityLevel.MANDATORY);
+        REQUIREMENT_2.addValue(REQUIREMENT_VALUE_4, ValuePriorityLevel.OPTIONAL);
+        REQUIREMENT_2.addValue(REQUIREMENT_VALUE_5, ValuePriorityLevel.MANDATORY);
+    }
+}
This page took 0.026668 seconds and 5 git commands to generate.