From: Guilliano Molaire Date: Mon, 21 Apr 2014 14:48:58 +0000 (-0400) Subject: TMF: Add support for requirements in AnalysisModuleTestHelper X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=7076c47b838c3d7bd0b68d9c814937225eb2820a;p=deliverable%2Ftracecompass.git TMF: Add support for requirements in AnalysisModuleTestHelper 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 Signed-off-by: Alexandre Montplaisir Reviewed-on: https://git.eclipse.org/r/24284 Reviewed-by: Matthew Khouzam Tested-by: Hudson CI Reviewed-by: Genevieve Bastien Tested-by: Genevieve Bastien --- diff --git a/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/analysis/AnalysisModuleTestHelper.java b/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/analysis/AnalysisModuleTestHelper.java index dc8165ba2e..aa9cdff3e9 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/analysis/AnalysisModuleTestHelper.java +++ b/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/analysis/AnalysisModuleTestHelper.java @@ -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> getValidTraceTypes() { - return Collections.EMPTY_SET; + return ImmutableList.> of( + TmfTraceStub.class, + TmfTraceStub2.class); } @Override public Iterable 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 index 0000000000..21f5b98e12 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/analysis/AnalysisRequirementFactory.java @@ -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 REQUIREMENT_VALUES_1 = ImmutableSet.of( + REQUIREMENT_VALUE_1, + REQUIREMENT_VALUE_2, + REQUIREMENT_VALUE_3, + REQUIREMENT_VALUE_5 + ); + + public static final Set REQUIREMENT_VALUES_2 = ImmutableSet.of( + REQUIREMENT_VALUE_2, + REQUIREMENT_VALUE_3 + ); + + public static final Set 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); + } +}