1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 École Polytechnique de Montréal
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Geneviève Bastien - Initial API and implementation
11 * Guilliano Molaire - Implementation of requirements and valid trace types getters
12 *******************************************************************************/
14 package org
.eclipse
.tracecompass
.tmf
.tests
.stubs
.analysis
;
16 import static org
.eclipse
.tracecompass
.common
.core
.NonNullUtils
.checkNotNull
;
18 import java
.util
.Collections
;
20 import org
.eclipse
.core
.runtime
.Platform
;
21 import org
.eclipse
.jdt
.annotation
.NonNull
;
22 import org
.eclipse
.tracecompass
.tmf
.core
.analysis
.IAnalysisModule
;
23 import org
.eclipse
.tracecompass
.tmf
.core
.analysis
.IAnalysisModuleHelper
;
24 import org
.eclipse
.tracecompass
.tmf
.core
.analysis
.TmfAnalysisRequirement
;
25 import org
.eclipse
.tracecompass
.tmf
.core
.exceptions
.TmfAnalysisException
;
26 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
27 import org
.eclipse
.tracecompass
.tmf
.tests
.stubs
.trace
.TmfTraceStub
;
28 import org
.eclipse
.tracecompass
.tmf
.tests
.stubs
.trace
.TmfTraceStub2
;
29 import org
.osgi
.framework
.Bundle
;
31 import com
.google
.common
.collect
.ImmutableList
;
34 * Analysis Module Helper for the stub analysis source
36 * @author Geneviève Bastien
38 public class AnalysisModuleTestHelper
implements IAnalysisModuleHelper
{
41 * Enum to select an analysis module for this stub
43 public enum moduleStubEnum
{
46 /** Test analysis 2 */
50 private moduleStubEnum fModule
;
56 * The type identifying the module for this helper
58 public AnalysisModuleTestHelper(moduleStubEnum module
) {
63 public String
getId() {
68 public String
getName() {
69 return checkNotNull(fModule
.name());
73 public boolean isAutomatic() {
78 public String
getHelpText() {
83 public String
getHelpText(@NonNull ITmfTrace trace
) {
88 public String
getIcon() {
93 public Bundle
getBundle() {
94 return Platform
.getBundle("org.eclipse.linuxtools.tmf.core.tests");
98 public boolean appliesToTraceType(Class
<?
extends ITmfTrace
> traceclass
) {
101 return TmfTraceStub
.class.isAssignableFrom(traceclass
);
103 return TmfTraceStub2
.class.isAssignableFrom(traceclass
);
110 public IAnalysisModule
newModule(ITmfTrace trace
) throws TmfAnalysisException
{
111 IAnalysisModule module
= null;
114 module
= new TestAnalysis();
115 module
.setName(getName());
116 module
.setId(getId());
117 module
.setAutomatic(isAutomatic());
118 module
.setTrace(trace
);
121 module
= new TestAnalysis2();
122 module
.setName(getName());
123 module
.setId(getId());
124 module
.setAutomatic(isAutomatic());
125 module
.setTrace(trace
);
135 public Iterable
<Class
<?
extends ITmfTrace
>> getValidTraceTypes() {
136 return ImmutableList
.<Class
<?
extends ITmfTrace
>> of(
138 TmfTraceStub2
.class);
142 public Iterable
<TmfAnalysisRequirement
> getAnalysisRequirements() {
145 return ImmutableList
.of(
146 AnalysisRequirementFactory
.REQUIREMENT_1
,
147 AnalysisRequirementFactory
.REQUIREMENT_3
);
149 return ImmutableList
.of(
150 AnalysisRequirementFactory
.REQUIREMENT_2
,
151 AnalysisRequirementFactory
.REQUIREMENT_3
);
153 return Collections
.EMPTY_SET
;