Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Struckmann2014-11-07 08:28:11 +0000
committerSebastian Struckmann2014-11-07 08:28:30 +0000
commit9574693786500dfcd507a35d8a997f6945132263 (patch)
tree4dca5af5ff09f34e32de5940243108a38e7c192d
parentbfa47b2559085988bc917fb2ffd7e4e9563e3aaf (diff)
downloadorg.eclipse.jubula.core-9574693786500dfcd507a35d8a997f6945132263.tar.gz
org.eclipse.jubula.core-9574693786500dfcd507a35d8a997f6945132263.tar.xz
org.eclipse.jubula.core-9574693786500dfcd507a35d8a997f6945132263.zip
Sprint task - Java API - Added handling of parameters to converter
-rw-r--r--org.eclipse.jubula.client.api.converter.ui/src/org/eclipse/jubula/client/api/converter/ui/handlers/ConvertProjectHandler.java8
-rw-r--r--org.eclipse.jubula.client.api.converter/build.properties3
-rw-r--r--org.eclipse.jubula.client.api.converter/src/org/eclipse/jubula/client/api/converter/NodeInfo.java18
-rw-r--r--org.eclipse.jubula.client.api.converter/src/org/eclipse/jubula/client/api/converter/utils/ParamUtils.java55
-rw-r--r--org.eclipse.jubula.client.api.converter/templates/NodeGenerator.javajet54
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/TestExecution.java2
-rw-r--r--org.eclipse.jubula.client.ui.rcp/META-INF/MANIFEST.MF1
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/views/dataset/AbstractDataSetPage.java5
-rw-r--r--org.eclipse.jubula.toolkit.api.gen/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.jubula.toolkit.api.gen/src/org/eclipse/jubula/toolkit/api/gen/internal/utils/NameLoader.java9
-rw-r--r--org.eclipse.jubula.toolkit.api/src/org/eclipse/jubula/toolkit/enums/ValueSets.java22
-rw-r--r--org.eclipse.jubula.toolkit.common/src/org/eclipse/jubula/toolkit/common/businessprocess/ToolkitSupportBP.java10
12 files changed, 164 insertions, 26 deletions
diff --git a/org.eclipse.jubula.client.api.converter.ui/src/org/eclipse/jubula/client/api/converter/ui/handlers/ConvertProjectHandler.java b/org.eclipse.jubula.client.api.converter.ui/src/org/eclipse/jubula/client/api/converter/ui/handlers/ConvertProjectHandler.java
index c12e75809..753feac54 100644
--- a/org.eclipse.jubula.client.api.converter.ui/src/org/eclipse/jubula/client/api/converter/ui/handlers/ConvertProjectHandler.java
+++ b/org.eclipse.jubula.client.api.converter.ui/src/org/eclipse/jubula/client/api/converter/ui/handlers/ConvertProjectHandler.java
@@ -18,6 +18,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Iterator;
+import java.util.Locale;
import java.util.NoSuchElementException;
import java.util.regex.Pattern;
@@ -46,6 +47,7 @@ import org.eclipse.jubula.client.core.persistence.ISpecPersistable;
import org.eclipse.jubula.client.core.persistence.ProjectPM;
import org.eclipse.jubula.client.ui.handlers.AbstractHandler;
import org.eclipse.jubula.client.ui.rcp.Plugin;
+import org.eclipse.jubula.client.ui.rcp.businessprocess.WorkingLanguageBP;
import org.eclipse.jubula.client.ui.utils.ErrorHandlingUtil;
import org.eclipse.jubula.tools.internal.constants.StringConstants;
import org.eclipse.jubula.tools.internal.exception.JBException;
@@ -73,6 +75,10 @@ public class ConvertProjectHandler extends AbstractHandler {
/** target package name space */
private static String genPackage;
+
+ /** the project language */
+ private static Locale language =
+ WorkingLanguageBP.getInstance().getWorkingLanguage();
/**
* {@inheritDoc}
@@ -271,7 +277,7 @@ public class ConvertProjectHandler extends AbstractHandler {
file.createNewFile();
NodeGenerator gen = new NodeGenerator();
NodeInfo info = new NodeInfo(file.getName(), node,
- genPackage, defaultToolkit);
+ genPackage, defaultToolkit, language);
String content = gen.generate(info);
writeContentToFile(file, content);
} catch (IOException e) {
diff --git a/org.eclipse.jubula.client.api.converter/build.properties b/org.eclipse.jubula.client.api.converter/build.properties
index 1cbd75378..59f51a276 100644
--- a/org.eclipse.jubula.client.api.converter/build.properties
+++ b/org.eclipse.jubula.client.api.converter/build.properties
@@ -10,4 +10,5 @@ source.. = src/,\
output.. = bin/
bin.includes = META-INF/,\
.,\
- about.html
+ about.html,\
+ resources/
diff --git a/org.eclipse.jubula.client.api.converter/src/org/eclipse/jubula/client/api/converter/NodeInfo.java b/org.eclipse.jubula.client.api.converter/src/org/eclipse/jubula/client/api/converter/NodeInfo.java
index 0454424a5..37e4f11ed 100644
--- a/org.eclipse.jubula.client.api.converter/src/org/eclipse/jubula/client/api/converter/NodeInfo.java
+++ b/org.eclipse.jubula.client.api.converter/src/org/eclipse/jubula/client/api/converter/NodeInfo.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.jubula.client.api.converter;
+import java.util.Locale;
+
import org.apache.commons.lang.StringUtils;
import org.eclipse.jubula.client.core.model.INodePO;
@@ -31,18 +33,24 @@ public class NodeInfo {
/** the default toolkit */
private String m_defaultToolkit;
+ /** the project default language */
+ private Locale m_language;
+
/**
* @param className the class name
* @param node the node
* @param packageBasePath the base path of the package
* @param defaultToolkit the default toolkit
+ * @param language the project language
*/
public NodeInfo (String className, INodePO node,
- String packageBasePath, String defaultToolkit) {
+ String packageBasePath, String defaultToolkit,
+ Locale language) {
m_className = StringUtils.substringBeforeLast(className, ".java"); //$NON-NLS-1$
m_node = node;
m_packageBasePath = packageBasePath;
m_defaultToolkit = defaultToolkit;
+ m_language = language;
}
/**
@@ -72,4 +80,12 @@ public class NodeInfo {
public String getDefaultToolkit() {
return m_defaultToolkit;
}
+
+ /**
+ * @return The project language
+ */
+ public Locale getLanguage() {
+ return m_language;
+ }
+
}
diff --git a/org.eclipse.jubula.client.api.converter/src/org/eclipse/jubula/client/api/converter/utils/ParamUtils.java b/org.eclipse.jubula.client.api.converter/src/org/eclipse/jubula/client/api/converter/utils/ParamUtils.java
new file mode 100644
index 000000000..23a7dbd32
--- /dev/null
+++ b/org.eclipse.jubula.client.api.converter/src/org/eclipse/jubula/client/api/converter/utils/ParamUtils.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2014 BREDEX GmbH.
+ * 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:
+ * BREDEX GmbH - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.jubula.client.api.converter.utils;
+
+import java.util.Locale;
+
+import org.apache.commons.lang.StringUtils;
+import org.eclipse.jubula.client.core.model.IParamDescriptionPO;
+import org.eclipse.jubula.client.core.model.IParameterInterfacePO;
+import org.eclipse.jubula.client.ui.rcp.views.dataset.AbstractDataSetPage;
+import org.eclipse.jubula.tools.internal.constants.StringConstants;
+
+/**
+ * @created 05.11.2014
+ */
+public class ParamUtils {
+
+ /**
+ * private constructor
+ */
+ private ParamUtils() {
+ // private
+ }
+
+ /**
+ * Returns a parameter value for a node
+ * @param node the node
+ * @param param the parameter
+ * @param locale the language
+ * @return the value
+ */
+ public static String getValueForParam(IParameterInterfacePO node,
+ IParamDescriptionPO param, Locale locale) {
+ String paramType = param.getType();
+ String value = AbstractDataSetPage.getGuiStringForParamValue(
+ node, param, 0, locale);
+ if (value.startsWith(StringConstants.EQUALS_SIGN)) {
+ value = StringUtils.substringAfter(value,
+ StringConstants.EQUALS_SIGN);
+ } else if (paramType.equals("java.lang.String")) { //$NON-NLS-1$
+ value = StringConstants.QUOTE + value + StringConstants.QUOTE;
+ }
+ return value;
+ }
+
+
+}
diff --git a/org.eclipse.jubula.client.api.converter/templates/NodeGenerator.javajet b/org.eclipse.jubula.client.api.converter/templates/NodeGenerator.javajet
index d41454bb9..9add971c1 100644
--- a/org.eclipse.jubula.client.api.converter/templates/NodeGenerator.javajet
+++ b/org.eclipse.jubula.client.api.converter/templates/NodeGenerator.javajet
@@ -5,6 +5,7 @@ imports="java.util.*
org.eclipse.jubula.client.api.converter.exceptions.InvalidNodeNameException
org.eclipse.jubula.client.api.converter.utils.CompNameLoader
org.eclipse.jubula.client.api.converter.utils.ProjectCache
+ org.eclipse.jubula.client.api.converter.utils.ParamUtils
org.eclipse.jubula.client.api.converter.utils.Utils
org.eclipse.jubula.client.core.model.ICapPO
org.eclipse.jubula.client.core.model.IExecTestCasePO
@@ -15,6 +16,7 @@ imports="java.util.*
org.eclipse.jubula.client.core.model.ISpecTestCasePO
org.eclipse.jubula.client.core.model.ITestSuitePO
org.eclipse.jubula.client.ui.rcp.Plugin
+ org.eclipse.jubula.toolkit.api.gen.internal.utils.NameLoader
org.eclipse.jubula.toolkit.common.businessprocess.ToolkitSupportBP
org.eclipse.jubula.toolkit.common.xml.businessprocess.ComponentBuilder
org.eclipse.jubula.tools.internal.constants.StringConstants
@@ -31,8 +33,10 @@ Logger log = LoggerFactory.getLogger(NodeGenerator.class);
NodeInfo info = (NodeInfo)argument;
String className = info.getClassName();
INodePO node = info.getNode();
+Locale locale = info.getLanguage();
Iterator<INodePO> iterator = node.getNodeListIterator();
String packageBase = info.getPackageBasePath();
+NameLoader nameLoader = NameLoader.getInstance();
IProjectPO project = null;
try {
project = ProjectCache.get(node.getParentProjectId());
@@ -56,7 +60,18 @@ import org.eclipse.jubula.client.AUT;
public class <%=className%> {
- public static void execute() {
+ public static void execute(
+ <%if (node instanceof ISpecTestCasePO) {
+ ISpecTestCasePO tc = (ISpecTestCasePO) node;
+ Iterator<IParamDescriptionPO> paramIterator = tc.getParameterListIter();
+ while (paramIterator.hasNext()) {
+ IParamDescriptionPO param = paramIterator.next();
+ String paramType = nameLoader.findTypeForParameter(param.getType(), StringConstants.EMPTY);
+ String paramName = param.getName();%>
+ <%=paramType%> <%=paramName%><%if(paramIterator.hasNext()){%>,<%}%>
+ <%}%>
+ <%}%>
+ ) {
AUT aut = null;
<%while (iterator.hasNext()) {
@@ -69,16 +84,16 @@ public class <%=className%> {
boolean hasDefaultMapping = loader.get("hasDefaultMapping").equals("true");
String componentNameToCreate;
String factoryName;
+ ConcreteComponent cc = null;
+ CompSystem compSystem = ComponentBuilder.getInstance().getCompSystem();
+ Component c = compSystem.getComponentForType(componentFromCap);
+ if (c instanceof ConcreteComponent) {
+ cc = (ConcreteComponent)c;
+ }
if (hasDefaultMapping) {
String toolkitID = info.getDefaultToolkit();
factoryName = Utils.getFactoryName(toolkitID);
- ConcreteComponent cc = null;
- CompSystem compSystem = ComponentBuilder.getInstance().getCompSystem();
- Component c = compSystem.getComponentForType(componentFromCap);
- if (c instanceof ConcreteComponent) {
- cc = (ConcreteComponent)c;
- }
- ConcreteComponent componentToCreate = ToolkitSupportBP.getMostConcreteRealizingComponentInToolkit(toolkitID, cc);
+ ConcreteComponent componentToCreate = ToolkitSupportBP.getMostAbstractRealizingComponentInToolkit(toolkitID, cc);
CompNameLoader newLoader = new CompNameLoader(componentToCreate.getType());
componentNameToCreate = newLoader.get("componentTypeName");
} else {
@@ -89,11 +104,15 @@ public class <%=className%> {
aut.execute(
<%=factoryName%>.create<%=componentNameToCreate%>(<%if (!hasDefaultMapping) {%>null<%}%>)
.<%=actionName%>(
- <%Iterator<IParamDescriptionPO> paramIterator = cap.getParameterList().iterator();
- while (paramIterator.hasNext()) {
- IParamDescriptionPO param = paramIterator.next();%>
- null<%if(paramIterator.hasNext()){%>,<%}%>
- <%}%>
+ <%Iterator<IParamDescriptionPO> childParamIterator = cap.getParameterListIter();
+ while (childParamIterator.hasNext()) {
+ IParamDescriptionPO param = childParamIterator.next();
+ String paramType = param.getUniqueId();
+ String enumType = nameLoader.getEnumForParam(paramType);
+ String paramValue = ParamUtils.getValueForParam(cap, param, locale);
+ Boolean isEnum = enumType != null;%>
+ <%if (isEnum) {%><%=enumType%>.valueOf(<%}%><%=paramValue%><%if (isEnum) {%>)<%}%><%if(childParamIterator.hasNext()){%>,<%}%>
+ <%}%>
),
null);
<%} else {%>
@@ -116,7 +135,14 @@ public class <%=className%> {
log.error(e.getLocalizedMessage());
}
testCaseName = Utils.getFullyQualifiedTranslatedName(spec, packageBase, projectName);%>
- <%=testCaseName%>.execute();
+ <%=testCaseName%>.execute(
+ <%Iterator<IParamDescriptionPO> childParamIterator = exec.getParameterListIter();
+ while (childParamIterator.hasNext()) {
+ IParamDescriptionPO param = childParamIterator.next();
+ String paramValue = ParamUtils.getValueForParam(exec, param, locale);%>
+ <%=paramValue%><%if(childParamIterator.hasNext()){%>,<%}%>
+ <%}%>
+ );
<%} else if (child instanceof IRefTestSuitePO) {
IRefTestSuitePO ref = (IRefTestSuitePO)child;
ITestSuitePO testSuite = ref.getTestSuite();
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/TestExecution.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/TestExecution.java
index 49394aaa6..9d51d5e10 100644
--- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/TestExecution.java
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/TestExecution.java
@@ -885,7 +885,7 @@ public class TestExecution {
String toolkit = aut.getToolkit();
if (cc.hasDefaultMapping() && cc.getComponentClass() != null) {
return ToolkitSupportBP.
- getIdentifierOfMostConcreteRealizingComponentInToolkit(
+ getIdentifierOfMostAbstractRealizingComponentInToolkit(
toolkit, cc);
}
}
diff --git a/org.eclipse.jubula.client.ui.rcp/META-INF/MANIFEST.MF b/org.eclipse.jubula.client.ui.rcp/META-INF/MANIFEST.MF
index f3a03f5ee..f7c19fc3a 100644
--- a/org.eclipse.jubula.client.ui.rcp/META-INF/MANIFEST.MF
+++ b/org.eclipse.jubula.client.ui.rcp/META-INF/MANIFEST.MF
@@ -38,6 +38,7 @@ Export-Package: org.eclipse.jubula.client.ui.rcp,
org.eclipse.jubula.client.ui.rcp.sourceprovider,
org.eclipse.jubula.client.ui.rcp.utils,
org.eclipse.jubula.client.ui.rcp.views,
+ org.eclipse.jubula.client.ui.rcp.views.dataset,
org.eclipse.jubula.client.ui.rcp.views.problemview,
org.eclipse.jubula.client.ui.rcp.widgets,
org.eclipse.jubula.client.ui.rcp.widgets.autconfig,
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/views/dataset/AbstractDataSetPage.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/views/dataset/AbstractDataSetPage.java
index 395990d19..2fbe6e4a8 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/views/dataset/AbstractDataSetPage.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/views/dataset/AbstractDataSetPage.java
@@ -1301,8 +1301,9 @@ public abstract class AbstractDataSetPage extends Page
* the selected locale
* @return a valid string for gui presentation of the given param value
*/
- private String getGuiStringForParamValue(IParameterInterfacePO paramObj,
- IParamDescriptionPO desc, int rowCount, Locale locale) {
+ public static String getGuiStringForParamValue(
+ IParameterInterfacePO paramObj, IParamDescriptionPO desc,
+ int rowCount, Locale locale) {
return AbstractParamInterfaceBP.getGuiStringForParamValue(paramObj,
desc, rowCount, locale);
}
diff --git a/org.eclipse.jubula.toolkit.api.gen/META-INF/MANIFEST.MF b/org.eclipse.jubula.toolkit.api.gen/META-INF/MANIFEST.MF
index 56d3efd8b..83d63e57c 100644
--- a/org.eclipse.jubula.toolkit.api.gen/META-INF/MANIFEST.MF
+++ b/org.eclipse.jubula.toolkit.api.gen/META-INF/MANIFEST.MF
@@ -25,4 +25,5 @@ Require-Bundle: org.apache.commons.logging;bundle-version="[1.0.0,2.0.0)",
org.eclipse.jubula.toolkit.swt.provider;bundle-version="[2.4.0,2.5.0)",
org.eclipse.jubula.toolkit.winapps.provider;bundle-version="[2.4.0,2.5.0)",
org.eclipse.jubula.toolkit.win.provider;bundle-version="[2.4.0,2.5.0)"
-Export-Package: org.eclipse.jubula.toolkit.api.gen.internal.genmodel
+Export-Package: org.eclipse.jubula.toolkit.api.gen.internal.genmodel,
+ org.eclipse.jubula.toolkit.api.gen.internal.utils
diff --git a/org.eclipse.jubula.toolkit.api.gen/src/org/eclipse/jubula/toolkit/api/gen/internal/utils/NameLoader.java b/org.eclipse.jubula.toolkit.api.gen/src/org/eclipse/jubula/toolkit/api/gen/internal/utils/NameLoader.java
index 17690be21..3dcf94d3f 100644
--- a/org.eclipse.jubula.toolkit.api.gen/src/org/eclipse/jubula/toolkit/api/gen/internal/utils/NameLoader.java
+++ b/org.eclipse.jubula.toolkit.api.gen/src/org/eclipse/jubula/toolkit/api/gen/internal/utils/NameLoader.java
@@ -255,4 +255,13 @@ public class NameLoader {
public boolean isInEnumMap(String name) {
return m_enumMappingProperties.containsValue(name);
}
+
+ /**
+ * Returns the enum type for a param
+ * @param paramType the param
+ * @return the enum
+ */
+ public String getEnumForParam(String paramType) {
+ return m_enumMappingProperties.getProperty(paramType);
+ }
}
diff --git a/org.eclipse.jubula.toolkit.api/src/org/eclipse/jubula/toolkit/enums/ValueSets.java b/org.eclipse.jubula.toolkit.api/src/org/eclipse/jubula/toolkit/enums/ValueSets.java
index 708240394..24470f45c 100644
--- a/org.eclipse.jubula.toolkit.api/src/org/eclipse/jubula/toolkit/enums/ValueSets.java
+++ b/org.eclipse.jubula.toolkit.api/src/org/eclipse/jubula/toolkit/enums/ValueSets.java
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.jubula.toolkit.enums;
+import java.util.HashMap;
+import java.util.Map;
+
/** @author BREDEX GmbH */
public final class ValueSets {
@@ -308,9 +311,19 @@ public final class ValueSets {
/** secondary value*/
secondary(3);
+ /** mapping integer values to respective enums */
+ private static Map<Integer, InteractionMode> map =
+ new HashMap<Integer, InteractionMode>();
+
/** holds the value necessary for the RC side */
private final Integer m_rcValue;
+ static {
+ for (InteractionMode mode : InteractionMode.values()) {
+ map.put(mode.rcIntValue(), mode);
+ }
+ }
+
/**
* Constructor
*
@@ -334,6 +347,15 @@ public final class ValueSets {
public Integer rcIntValue() {
return m_rcValue;
}
+
+ /**
+ * Returns the interaction mode corresponding to a given integer
+ * @param i the integer
+ * @return the corresponding interaction mode
+ */
+ public static InteractionMode valueOf(Integer i) {
+ return map.get(i);
+ }
}
/** Constructor */
private ValueSets() {
diff --git a/org.eclipse.jubula.toolkit.common/src/org/eclipse/jubula/toolkit/common/businessprocess/ToolkitSupportBP.java b/org.eclipse.jubula.toolkit.common/src/org/eclipse/jubula/toolkit/common/businessprocess/ToolkitSupportBP.java
index ea810281e..a577871b8 100644
--- a/org.eclipse.jubula.toolkit.common/src/org/eclipse/jubula/toolkit/common/businessprocess/ToolkitSupportBP.java
+++ b/org.eclipse.jubula.toolkit.common/src/org/eclipse/jubula/toolkit/common/businessprocess/ToolkitSupportBP.java
@@ -194,7 +194,7 @@ public class ToolkitSupportBP {
}
/**
- * Returns a pseudo component identifier representing the most concrete
+ * Returns a pseudo component identifier representing the most abstract
* realizing toolkit component for an abstract component with default mapping
* or <code>null</code> if none can be found
*
@@ -205,10 +205,10 @@ public class ToolkitSupportBP {
* @return the component identifier
*/
public static IComponentIdentifier
- getIdentifierOfMostConcreteRealizingComponentInToolkit(
+ getIdentifierOfMostAbstractRealizingComponentInToolkit(
String toolkitID, ConcreteComponent cc) {
ConcreteComponent concreteComponent =
- getMostConcreteRealizingComponentInToolkit(toolkitID, cc);
+ getMostAbstractRealizingComponentInToolkit(toolkitID, cc);
IComponentIdentifier technicalName = new ComponentIdentifier();
technicalName.setComponentClassName(
concreteComponent
@@ -217,7 +217,7 @@ public class ToolkitSupportBP {
}
/**
- * Returns the most concrete realizing toolkit component
+ * Returns the most abstract realizing toolkit component
* for an abstract component with default mapping
* or <code>null</code> if none can be found
*
@@ -227,7 +227,7 @@ public class ToolkitSupportBP {
* the concrete component
* @return the component
*/
- public static ConcreteComponent getMostConcreteRealizingComponentInToolkit(
+ public static ConcreteComponent getMostAbstractRealizingComponentInToolkit(
String toolkitID, ConcreteComponent cc) {
String toolkitIdToSearchIn = toolkitID;
Set realizers = cc.getAllRealizers();

Back to the top