Commit cf00ea12 authored by Dongyue Mou's avatar Dongyue Mou
Browse files

code reviewed

parent 9b85d04c
......@@ -17,11 +17,12 @@ $Id$
+--------------------------------------------------------------------------*/
package org.fortiss.af3.mira.ui.editor;
import static org.fortiss.af3.mira.utils.MiraUtils.getDisplayNameFor;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.swt.SWT;
import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.af3.mira.utils.MiraUtils;
/**
* Sorter for analysis editor
......@@ -29,7 +30,7 @@ import org.fortiss.af3.mira.utils.MiraUtils;
* @author teufl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 5687732380D174DF6A3194ED7EA0633C
* @ConQAT.Rating GREEN Hash: F705566C6BF124ACCEB0A8E4D04301EC
*/
public class AnalysisComparator extends ViewerComparator {
......@@ -91,8 +92,7 @@ public class AnalysisComparator extends ViewerComparator {
rc = p1.getReqId().compareTo(p2.getReqId());
break;
case 1:
// TODO (FH): use import static
rc = MiraUtils.getDisplayNameFor(p1).compareTo(MiraUtils.getDisplayNameFor(p2));
rc = getDisplayNameFor(p1).compareTo(getDisplayNameFor(p2));
break;
case 2:
rc = p1.getName().compareTo(p2.getName());
......
......@@ -19,6 +19,7 @@ package org.fortiss.af3.mira.ui.editor;
import static org.conqat.ide.commons.ui.selection.SelectionUtils.checkAndPickFirst;
import static org.conqat.lib.commons.string.StringUtils.isEmpty;
import static org.fortiss.af3.mira.utils.MiraUtils.getDisplayNameFor;
import static org.fortiss.tooling.kernel.ui.util.DataBindingUtils.DECORATION_KEY;
import org.eclipse.emf.common.notify.Notification;
......@@ -42,7 +43,6 @@ import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.TreeColumn;
import org.fortiss.af3.mira.model.Analysis;
import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.af3.mira.utils.MiraUtils;
import org.fortiss.tooling.base.ui.editor.FormsEditorBase;
import org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService;
......@@ -52,7 +52,7 @@ import org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService;
* @author teufl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 40F5175707862901523B45ED12206F02
* @ConQAT.Rating GREEN Hash: 363B35D5211D697AEAAE4BB24A4B9C41
*/
public class AnalysisEditor<T extends Analysis> extends FormsEditorBase<T> {
......@@ -67,8 +67,7 @@ public class AnalysisEditor<T extends Analysis> extends FormsEditorBase<T> {
String filterString = filterText.getText().toLowerCase().trim();
if(("" + req.getReqId()).toLowerCase().contains(filterString)) {
return true;
// TODO (FH): use import static
} else if(MiraUtils.getDisplayNameFor(req).toLowerCase().contains(filterString)) {
} else if(getDisplayNameFor(req).toLowerCase().contains(filterString)) {
return true;
} else if(!isEmpty(req.getName()) &&
req.getName().toLowerCase().contains(filterString)) {
......@@ -85,17 +84,14 @@ public class AnalysisEditor<T extends Analysis> extends FormsEditorBase<T> {
};
/** single line label grid data factory */
// TODO (FH): use import static
protected static GridDataFactory singleLineLabelFactory = GridDataFactory.swtDefaults()
.align(SWT.RIGHT, SWT.CENTER).grab(false, false);
/** single line input grid data factory */
// TODO (FH): use import static
protected static GridDataFactory singleLineInputFactory = GridDataFactory.swtDefaults()
.align(SWT.FILL, SWT.CENTER).grab(true, false);
/** fill control grid data factory */
// TODO (FH): use import static
protected static GridDataFactory fillControlFactory = GridDataFactory.swtDefaults()
.align(SWT.FILL, SWT.FILL).grab(true, true).hint(SWT.DEFAULT, 200);
......
......@@ -17,18 +17,18 @@ $Id$
+--------------------------------------------------------------------------*/
package org.fortiss.af3.mira.ui.handler;
import static java.util.Collections.sort;
import static org.conqat.lib.commons.string.StringUtils.isEmpty;
import static org.eclipse.ui.plugin.AbstractUIPlugin.imageDescriptorFromPlugin;
import static org.fortiss.af3.mira.ui.AF3MiraUIActivator.PLUGIN_ID;
import static org.fortiss.af3.mira.utils.MiraUtils.getComparator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.resource.ImageDescriptor;
import org.fortiss.af3.mira.model.Analysis;
import org.fortiss.af3.mira.utils.MiraUtils;
import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler;
import org.fortiss.tooling.kernel.ui.extension.base.ModelElementHandlerBase;
......@@ -38,7 +38,7 @@ import org.fortiss.tooling.kernel.ui.extension.base.ModelElementHandlerBase;
* @author mou
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 7443FD3CEEFC3A8C01B9FCC13EC9C9E6
* @ConQAT.Rating GREEN Hash: 661484DA1605F76E52E9C33404A91613
*/
public class AnalysisHandler extends ModelElementHandlerBase<Analysis> {
......@@ -62,7 +62,7 @@ public class AnalysisHandler extends ModelElementHandlerBase<Analysis> {
@Override
public List<EObject> getSubnodes(Analysis element) {
ArrayList<EObject> list = new ArrayList<EObject>(element.getContainedElementsList());
Collections.sort(list, MiraUtils.getComparator());
sort(list, getComparator());
return list;
}
......
......@@ -28,7 +28,7 @@ import org.fortiss.tooling.kernel.extension.IElementCompositor;
* @author hoelzlf
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 3D7F5C78C11F8A7DADDC5934BCDA0C64
* @ConQAT.Rating GREEN Hash: 7AE4AFFE835779EC95C722D162438551
*/
public final class AnalysisFileProjectCompositor extends FileProjectCompositor {
/** {@inheritDoc} */
......
......@@ -17,16 +17,16 @@ $Id$
+--------------------------------------------------------------------------*/
package org.fortiss.af3.mira.model.impl;
import static org.eclipse.emf.common.util.ECollections.unmodifiableEList;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.convertList;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickInstanceOf;
import org.eclipse.emf.common.util.ECollections;
import org.eclipse.emf.common.util.EList;
import org.fortiss.af3.mira.model.Analysis;
import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.af3.mira.model.RequirementRelation;
import org.fortiss.af3.mira.model.glossary.Glossary;
import org.fortiss.af3.mira.model.usecase.UseCase;
import org.fortiss.tooling.kernel.utils.EcoreUtils;
/**
* Static implementation of {@link Analysis}
......@@ -34,32 +34,28 @@ import org.fortiss.tooling.kernel.utils.EcoreUtils;
* @author mou
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 8B95A58A3B21D563A08E3BFFC230837F
* @ConQAT.Rating GREEN Hash: AEE1075C4A7A327A2D9DEA717019F186
*/
public class AnalysisStaticImpl {
/** Return {@link Requirement} list */
public static EList<Requirement> getRequirementsList(Analysis analysis) {
// TODO (FH): use import static
return EcoreUtils.pickInstanceOf(Requirement.class, analysis.getContainedElementsList());
return pickInstanceOf(Requirement.class, analysis.getContainedElementsList());
}
/** Return {@link Glossary} list */
public static EList<Glossary> getGlossariesList(Analysis analysis) {
// TODO (FH): use import static
return EcoreUtils.pickInstanceOf(Glossary.class, analysis.getContainedElementsList());
return pickInstanceOf(Glossary.class, analysis.getContainedElementsList());
}
/** Return {@link RequirementRelation} list */
public static EList<RequirementRelation> getRequirementRelationsList(Analysis analysis) {
// TODO (FH): use import static
return ECollections.unmodifiableEList(EcoreUtils.convertList(RequirementRelation.class,
return unmodifiableEList(convertList(RequirementRelation.class,
analysis.getConnectionsList()));
}
/** Return {@link UseCase} list */
public static EList<UseCase> getUseCase(Analysis analysis) {
// TODO (FH): use import static
return pickInstanceOf(UseCase.class, analysis.getContainedElementsList());
}
}
......@@ -27,7 +27,6 @@ import org.fortiss.af3.mira.model.usecase.Scenario;
import org.fortiss.af3.mira.model.usecase.ScopeSpecification;
import org.fortiss.af3.mira.model.usecase.TriggerSpecification;
import org.fortiss.af3.mira.model.usecase.UseCase;
import org.fortiss.tooling.kernel.utils.EcoreUtils;
/**
* Static implementation of {@link UseCase}
......@@ -35,14 +34,13 @@ import org.fortiss.tooling.kernel.utils.EcoreUtils;
* @author mou
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 0C56FC31CB1E436F48E37DD902FA4F95
* @ConQAT.Rating GREEN Hash: 31A0F3AF1A6CF93252FA9804578AD93C
*/
public class UseCaseStaticImpl {
/** Return all {@link Scenario}s */
public static EList<Scenario> getScenariosList(UseCase useCase) {
// TODO (FH): use import static
return EcoreUtils.pickInstanceOf(Scenario.class, useCase.getContainedElementsList());
return pickInstanceOf(Scenario.class, useCase.getContainedElementsList());
}
/** Return the {@link ScopeSpecification} */
......
<!--
$Id$
@version $Rev$
@ConQAT.Rating YELLOW Hash: EEF7465DDD85822B20447D0D6C51D8AA
@ConQAT.Rating GREEN Hash: 3BE96B055E9ACC4ADC25130808021DB6
-->
<html>
......
<!--
$Id$
@version $Rev$
@ConQAT.Rating YELLOW Hash: 34AFCFD00808D8FD48BFFE177FAE8896
@ConQAT.Rating GREEN Hash: 5AAC3F885B39A4521DF0576E2CF402BE
-->
<html>
......
<!--
$Id$
@version $Rev$
@ConQAT.Rating YELLOW Hash: 256828104A93175A94E2C8D4CA20F444
@ConQAT.Rating GREEN Hash: 8C48B176C47DCD38E36C6E2A7E0F4340
-->
<html>
......
<!--
$Id$
@version $Rev$
@ConQAT.Rating YELLOW Hash: 63A1688FC702B8FD952E9D0CA5C44F1E
@ConQAT.Rating GREEN Hash: D08B92A041D657E89B19BAA378641AA9
-->
<html>
......
......@@ -31,7 +31,7 @@ import org.fortiss.tooling.kernel.service.base.IEObjectAware;
* @author mou
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: C036ADDFC4C421128DB15D0A92698B46
* @ConQAT.Rating GREEN Hash: 525D0D0BF78EC83DB89CCAA0F33E8C9B
*/
public interface ITestSuiteValidationMethodHandler<T extends TestSuite> extends
......
......@@ -17,11 +17,11 @@ $Id$
+--------------------------------------------------------------------------*/
package org.fortiss.af3.testing.ui.menu;
import static java.util.Collections.emptyList;
import static org.conqat.ide.commons.ui.dialog.MessageUtils.showError;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.error;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -45,23 +45,22 @@ import org.fortiss.tooling.kernel.ui.service.IContextMenuService;
import org.fortiss.tooling.kernel.ui.service.INavigatorService;
/**
* Adds execution menu after the global actions for
* {@link ExecutionConfiguration}s.
* Adds execution menu after the global actions for {@link ExecutionConfiguration}s.
*
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 9DFF4A9D112E303E883D417508F4E3FD
* @ConQAT.Rating GREEN Hash: A71C5208CABD94B4999E228213AC7BE5
*/
public final class ValidationMethodMenu implements IContextMenuContributor {
/** Map from execution targets to actions. */
private final Map<ITestSuiteValidator, ValidationAction> actionMap = new HashMap<ITestSuiteValidator, ValidationAction>();
private final Map<ITestSuiteValidator, ValidationAction> actionMap =
new HashMap<ITestSuiteValidator, ValidationAction>();
/** Constructor. */
public ValidationMethodMenu() {
for (ITestSuiteValidator target : ITestSuiteValidationMethodService.INSTANCE
.getValidators()) {
for(ITestSuiteValidator target : ITestSuiteValidationMethodService.INSTANCE.getValidators()) {
actionMap.put(target, new ValidationAction(target));
}
}
......@@ -70,21 +69,21 @@ public final class ValidationMethodMenu implements IContextMenuContributor {
@Override
public List<IContributionItem> getContributedItems(EObject selection,
ContextMenuContextProvider contextProvider) {
if (selection instanceof TestSuite
&& INavigatorService.INSTANCE.isNavigatorView(contextProvider)) {
TestSuite suite = (TestSuite) selection;
if(selection instanceof TestSuite &&
INavigatorService.INSTANCE.isNavigatorView(contextProvider)) {
TestSuite suite = (TestSuite)selection;
List<IContributionItem> contributionItems = new ArrayList<IContributionItem>();
for (ITestSuiteValidator target : actionMap.keySet()) {
for(ITestSuiteValidator target : actionMap.keySet()) {
ValidationAction action = actionMap.get(target);
if (action != null) {
if(action != null) {
action.setSuite(suite);
contributionItems.add(new ActionContributionItem(action));
}
}
return contributionItems;
}
return Collections.emptyList();
return emptyList();
}
/** {@inheritDoc} */
......@@ -113,18 +112,15 @@ public final class ValidationMethodMenu implements IContextMenuContributor {
@Override
public void run() {
try {
final TestSuite newSuite = target.validate(suite,
new NullProgressMonitor());
ICommandStackService.INSTANCE.runAsCommand(suite,
new Runnable() {
@Override
public void run() {
Component testee = (Component) suite
.eContainer();
testee.getSpecificationsList().add(newSuite);
}
});
} catch (Exception e) {
final TestSuite newSuite = target.validate(suite, new NullProgressMonitor());
ICommandStackService.INSTANCE.runAsCommand(suite, new Runnable() {
@Override
public void run() {
Component testee = (Component)suite.eContainer();
testee.getSpecificationsList().add(newSuite);
}
});
} catch(Exception e) {
error(Af3TestingUIActivator.getDefault(), e.getMessage(), e);
showError("Test Suite Validator failed.!", e.getMessage());
}
......
......@@ -28,7 +28,7 @@ import org.fortiss.af3.testing.ui.service.internal.TestSuiteValidationMethodServ
* @author mou
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 949DCF616B77CD457E0084C2AB89BAE5
* @ConQAT.Rating GREEN Hash: 1372C1E2C36F33795EB07AB01787E7EC
*/
public interface ITestSuiteValidationMethodService {
......
......@@ -40,7 +40,7 @@ import org.osgi.framework.Bundle;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 61792AE96A3023DF0AB04B94899FFFC8
* @ConQAT.Rating GREEN Hash: 7F01A7BF34BD09060C8C3FAE9F5A109D
*/
public class TestSuiteValidationMethodService implements
ITestSuiteValidationMethodService {
......
......@@ -35,7 +35,7 @@ import org.junit.runner.RunWith;
* @author wenwenchen
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating YELLOW Hash: 5562B7651440A485B5DC3C723A156353
* @ConQAT.Rating GREEN Hash: 5037D9C74FBFB7C71D923741112CF486
*/
@RunWith(SWTBotJunit4ClassRunner.class)
public class GenerateTestSuiteTest {
......@@ -64,10 +64,6 @@ public class GenerateTestSuiteTest {
/** menu name right click of AccelerationControl */
private static final String Test_Suite_Specification = "Test Suite Specification";
// TODO (FH): remove commented code
// noch unused private static final String Refinement_Specification =
// "Refinement Specification";
/** Test Suite fill */
private static final String RANDOM_INPUT_PROFILE = "Random Input Profile";
......@@ -89,21 +85,20 @@ public class GenerateTestSuiteTest {
bot.menu("File").menu(OPEN_AF3_EXAMPLE).menu(LOAD_ACC_EXAMPLE).click();
bot.sleep(500);
SWTBotTreeItem treeItemACC = bot.viewByTitle("Model Navigator").bot()
.tree().getTreeItem(ACC);
SWTBotTreeItem treeItemAC = treeItemACC.expand().getNode(ACC_SYSTEM)
.expand().getNode(AdaptiveCruiseControl).expand()
.getNode(AccelerationControl);
SWTBotTreeItem treeItemACC =
bot.viewByTitle("Model Navigator").bot().tree().getTreeItem(ACC);
SWTBotTreeItem treeItemAC =
treeItemACC.expand().getNode(ACC_SYSTEM).expand().getNode(AdaptiveCruiseControl)
.expand().getNode(AccelerationControl);
treeItemAC.contextMenu(Test_Suite_Specification).click();
SWTBotTreeItem treeItemTSS = treeItemAC.expand().getNode(
Test_Suite_Specification);
SWTBotTreeItem treeItemTSS = treeItemAC.expand().getNode(Test_Suite_Specification);
treeItemTSS.contextMenu(RANDOM_INPUT_PROFILE).click();
treeItemTSS.contextMenu(GENERATE_TEST_SUITE).click();
List<String> nodes = treeItemAC.getNodes();
String testSuiteName = "";
for (String s : nodes) {
if (s.startsWith("TestSuite"))
for(String s : nodes) {
if(s.startsWith("TestSuite"))
testSuiteName = s;
}
SWTBotTreeItem testSuite = treeItemAC.expand().getNode(testSuiteName);
......
......@@ -31,7 +31,7 @@ import org.fortiss.tooling.kernel.extension.base.PrototypeProviderBase;
* @author mou
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 0CCF202DCC999DCE006FCC1AE3DBC5E4
* @ConQAT.Rating GREEN Hash: 1940DAA3F6642F98324A79F344386B6E
*/
public class TestSuiteSpecificationPrototypeProvider extends PrototypeProviderBase {
......@@ -42,14 +42,10 @@ public class TestSuiteSpecificationPrototypeProvider extends PrototypeProviderBa
@Override
public void registerPrototypes() {
TestSuiteSpecification specification = createTestSuiteSpecification();
// TODO (FH): remove comments; code is self-explanatory
// register test suite specification
registerPrimaryPrototype("Test Suite Specification", specification, CATEGORY_NAME);
// register state coverage profile
registerPrimaryPrototype("State Coverage Profile", createStateCoverage(), CATEGORY_NAME);
// register transition coverage profile
registerPrimaryPrototype("Transition Coverage Profile", createTransitionCoverage(),
CATEGORY_NAME);
}
......
......@@ -28,7 +28,7 @@ import org.fortiss.af3.testing.model.TestSuite;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 3CF3C1B017113DF1743583D570062F83
* @ConQAT.Rating GREEN Hash: 01CC3D5198A1D310390474E6422C22D2
*/
public interface ITestSuiteValidator {
......
......@@ -24,7 +24,7 @@ package org.fortiss.af3.testing.extension.data;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: C08DB587E21C830859C91F9415853439
* @ConQAT.Rating GREEN Hash: F04B0B84707E12FE142BBEAEC82EC82D
*
*/
public class TestSuiteValidationException extends Exception {
......
......@@ -26,7 +26,7 @@ import org.fortiss.af3.testing.Af3TestingActivator;
* @author pfaller
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating YELLOW Hash: 67EFD978D7795C90BA85ACCFE0BC7AF6
* @ConQAT.Rating GREEN Hash: 5BC81B130A32B221B455CA265C320CD2
*/
public enum EPreferences {
......
......@@ -28,6 +28,7 @@ import static org.fortiss.af3.testing.validator.platform.generic.DeploymentGener
import static org.fortiss.af3.testing.validator.platform.generic.SourcePackageGenerator.createMainFile;
import static org.fortiss.af3.testing.validator.platform.generic.SourcePackageGenerator.createSourcePackageFor;
import static org.fortiss.af3.testing.validator.platform.generic.SourcePackageGenerator.createTestCaseCode;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.error;
import java.io.File;
import java.util.Calendar;
......@@ -41,6 +42,7 @@ import org.fortiss.af3.expression.language.Compiler;
import org.fortiss.af3.expression.model.terms.IExpressionTerm;
import org.fortiss.af3.generator.common.model.c.CSourcePackage;
import org.fortiss.af3.generator.common.model.source.SourcePackage;
import org.fortiss.af3.testing.Af3TestingActivator;
import org.fortiss.af3.testing.extension.ITestSuiteValidator;
import org.fortiss.af3.testing.extension.data.TestSuiteValidationException;
import org.fortiss.af3.testing.model.TestCase;
......@@ -58,7 +60,7 @@ import org.fortiss.af3.tools.gcc.MakeRunner;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 856DB6F1FC59D7C5020553BD2421FD72
* @ConQAT.Rating GREEN Hash: B92B1E3BE0A473C5257C6C8935613973
*/
public class GenericGCCPlatformTestSuiteValidator implements ITestSuiteValidator {
/** The timeout for executing "configure" and "make" once during tests. */
......@@ -149,8 +151,8 @@ public class GenericGCCPlatformTestSuiteValidator implements ITestSuiteValidator
tcPack.writeToLocation(targetLocation.getAbsolutePath());
List<String> result = runToolChain();
if(result.size() != tc.getTestStepsLength()) {
System.err
.println("OOOOPS - result and test case have different number of steps!!!");
error(Af3TestingActivator.getDefault(),
"OOOOPS - result and test case have different number of steps!!!");
}
// deleteRecursively(targetLocation);
return result;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment