Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGéry Deloge2016-10-18 09:48:40 +0000
committerGerrit Code Review @ Eclipse.org2016-11-21 16:01:53 +0000
commit2c65267aa977d293bd29bc177797a52860d6e208 (patch)
treed1c871d54232680ba7fb0de2a65be0b7969305cb /extraplugins
parent10273d3480dccd86ba701f67bb7b00457b1abdd1 (diff)
downloadorg.eclipse.papyrus-2c65267aa977d293bd29bc177797a52860d6e208.tar.gz
org.eclipse.papyrus-2c65267aa977d293bd29bc177797a52860d6e208.tar.xz
org.eclipse.papyrus-2c65267aa977d293bd29bc177797a52860d6e208.zip
Bug 506124: export requirements in csv
Change-Id: Ic189589cd354c8a9a1c3ca9dfe4543699fd3152d Signed-off-by: Géry Deloge <gery.deloge@cea.fr>
Diffstat (limited to 'extraplugins')
-rw-r--r--extraplugins/requirements/org.eclipse.papyrus.requirements.export/.classpath7
-rw-r--r--extraplugins/requirements/org.eclipse.papyrus.requirements.export/.project28
-rw-r--r--extraplugins/requirements/org.eclipse.papyrus.requirements.export/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--extraplugins/requirements/org.eclipse.papyrus.requirements.export/META-INF/MANIFEST.MF17
-rw-r--r--extraplugins/requirements/org.eclipse.papyrus.requirements.export/about.html28
-rw-r--r--extraplugins/requirements/org.eclipse.papyrus.requirements.export/build.properties7
-rw-r--r--extraplugins/requirements/org.eclipse.papyrus.requirements.export/plugin.xml59
-rw-r--r--extraplugins/requirements/org.eclipse.papyrus.requirements.export/pom.xml13
-rw-r--r--extraplugins/requirements/org.eclipse.papyrus.requirements.export/src/org/eclipse/papyrus/requirements/export/Activator.java68
-rw-r--r--extraplugins/requirements/org.eclipse.papyrus.requirements.export/src/org/eclipse/papyrus/requirements/export/ExportRequirementCommandHandler.java209
-rw-r--r--extraplugins/requirements/org.eclipse.papyrus.requirements.export/src/org/eclipse/papyrus/requirements/export/ExportRequirementCommandHandlerTest.java121
11 files changed, 564 insertions, 0 deletions
diff --git a/extraplugins/requirements/org.eclipse.papyrus.requirements.export/.classpath b/extraplugins/requirements/org.eclipse.papyrus.requirements.export/.classpath
new file mode 100644
index 00000000000..b862a296d38
--- /dev/null
+++ b/extraplugins/requirements/org.eclipse.papyrus.requirements.export/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/extraplugins/requirements/org.eclipse.papyrus.requirements.export/.project b/extraplugins/requirements/org.eclipse.papyrus.requirements.export/.project
new file mode 100644
index 00000000000..5504beb1817
--- /dev/null
+++ b/extraplugins/requirements/org.eclipse.papyrus.requirements.export/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.requirements.export</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/extraplugins/requirements/org.eclipse.papyrus.requirements.export/.settings/org.eclipse.jdt.core.prefs b/extraplugins/requirements/org.eclipse.papyrus.requirements.export/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..295926d9641
--- /dev/null
+++ b/extraplugins/requirements/org.eclipse.papyrus.requirements.export/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/extraplugins/requirements/org.eclipse.papyrus.requirements.export/META-INF/MANIFEST.MF b/extraplugins/requirements/org.eclipse.papyrus.requirements.export/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..a71063d5afc
--- /dev/null
+++ b/extraplugins/requirements/org.eclipse.papyrus.requirements.export/META-INF/MANIFEST.MF
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Export
+Bundle-SymbolicName: org.eclipse.papyrus.requirements.export;singleton:=true
+Bundle-Version: 0.7.0.qualifier
+Bundle-Activator: org.eclipse.papyrus.requirements.export.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.core.expressions,
+ org.eclipse.papyrus.requirements.sysml.testers;bundle-version="0.7.0",
+ org.eclipse.papyrus.infra.emf,
+ org.eclipse.uml2.uml,
+ org.eclipse.papyrus.uml.tools.utils,
+ org.eclipse.papyrus.infra.emf.gmf,
+ org.eclipse.papyrus.sysml
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Bundle-ActivationPolicy: lazy
diff --git a/extraplugins/requirements/org.eclipse.papyrus.requirements.export/about.html b/extraplugins/requirements/org.eclipse.papyrus.requirements.export/about.html
new file mode 100644
index 00000000000..82d49bf5f81
--- /dev/null
+++ b/extraplugins/requirements/org.eclipse.papyrus.requirements.export/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 5, 2007</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html>
diff --git a/extraplugins/requirements/org.eclipse.papyrus.requirements.export/build.properties b/extraplugins/requirements/org.eclipse.papyrus.requirements.export/build.properties
new file mode 100644
index 00000000000..e3693a3b66e
--- /dev/null
+++ b/extraplugins/requirements/org.eclipse.papyrus.requirements.export/build.properties
@@ -0,0 +1,7 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ about.html,\
+ plugin.xml
+src.includes = about.html
diff --git a/extraplugins/requirements/org.eclipse.papyrus.requirements.export/plugin.xml b/extraplugins/requirements/org.eclipse.papyrus.requirements.export/plugin.xml
new file mode 100644
index 00000000000..2966d3f8ca4
--- /dev/null
+++ b/extraplugins/requirements/org.eclipse.papyrus.requirements.export/plugin.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ allPopups="true"
+ locationURI="popup:org.eclipse.papyrus.views.modelexplorer.modelexplorer.popup?after=org.eclipse.papyrus.uml.import.menu">
+ <menu
+ id="org.eclipse.papyrus.infra.gmfdiag.export.menu"
+ label="&amp;Export">
+ <command
+ commandId="org.eclipse.papyrus.requirements.export.exportRequirements"
+ label="Export Requirements..."
+ style="push"
+ tooltip="export requirements in csv">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="selection">
+
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.papyrus.requirements.sysml.testers.appliesSysMLRequirementsProfile"
+ value="true">
+ </test>
+ </with>
+ </visibleWhen>
+ </command>
+ </menu>
+ </menuContribution>
+ </extension>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ description="export requirements in csv"
+ id="org.eclipse.papyrus.requirements.export.exportRequirements"
+ name="exportRequirements">
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ class="org.eclipse.papyrus.requirements.export.ExportRequirementCommandHandler"
+ commandId="org.eclipse.papyrus.requirements.export.exportRequirements">
+ <enabledWhen>
+ <with
+ variable="selection">
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.papyrus.requirements.sysml.testers.appliesSysMLRequirementsProfile"
+ value="true">
+ </test>
+ </with>
+ </enabledWhen>
+ </handler>
+ </extension>
+
+</plugin>
diff --git a/extraplugins/requirements/org.eclipse.papyrus.requirements.export/pom.xml b/extraplugins/requirements/org.eclipse.papyrus.requirements.export/pom.xml
new file mode 100644
index 00000000000..3dd17ef8f01
--- /dev/null
+++ b/extraplugins/requirements/org.eclipse.papyrus.requirements.export/pom.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>org.eclipse.papyrus.extra.releng</artifactId>
+ <groupId>org.eclipse.papyrus</groupId>
+ <version>3.0.0-SNAPSHOT</version>
+ <relativePath>../../../releng/extra</relativePath>
+ </parent>
+ <artifactId>org.eclipse.papyrus.requirements.export</artifactId>
+ <version>0.7.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+</project> \ No newline at end of file
diff --git a/extraplugins/requirements/org.eclipse.papyrus.requirements.export/src/org/eclipse/papyrus/requirements/export/Activator.java b/extraplugins/requirements/org.eclipse.papyrus.requirements.export/src/org/eclipse/papyrus/requirements/export/Activator.java
new file mode 100644
index 00000000000..42066002976
--- /dev/null
+++ b/extraplugins/requirements/org.eclipse.papyrus.requirements.export/src/org/eclipse/papyrus/requirements/export/Activator.java
@@ -0,0 +1,68 @@
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST.
+ *
+ *
+ * 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:
+ *
+ * Géry Deloge (gery.deloge@cea.fr) CEATech AQUI - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.requirements.export;
+
+import org.eclipse.papyrus.infra.core.log.LogHelper;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.requirements.export"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ public static LogHelper log;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/extraplugins/requirements/org.eclipse.papyrus.requirements.export/src/org/eclipse/papyrus/requirements/export/ExportRequirementCommandHandler.java b/extraplugins/requirements/org.eclipse.papyrus.requirements.export/src/org/eclipse/papyrus/requirements/export/ExportRequirementCommandHandler.java
new file mode 100644
index 00000000000..44855d518d4
--- /dev/null
+++ b/extraplugins/requirements/org.eclipse.papyrus.requirements.export/src/org/eclipse/papyrus/requirements/export/ExportRequirementCommandHandler.java
@@ -0,0 +1,209 @@
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST.
+ *
+ *
+ * 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:
+ *
+ * Géry Deloge (gery.deloge@cea.fr) CEATech AQUI - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.requirements.export;
+
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.expressions.IEvaluationContext;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.UnexecutableCommand;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.ui.command.AbstractCommandHandler;
+import org.eclipse.papyrus.sysml.requirements.Requirement;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.PackageableElement;
+import org.eclipse.uml2.uml.util.UMLUtil;
+
+public class ExportRequirementCommandHandler extends AbstractCommandHandler {
+
+ private final String FS = ",";
+ private static Logger LOGGER = Logger.getLogger(ExportRequirementCommandHandler.class.getName());
+
+ @Override
+ protected Command getCommand(IEvaluationContext context) {
+
+ List<EObject> selectedElements = getSelectedElements();
+ if (selectedElements.size() == 1) {
+
+ if (selectedElements.get(0) instanceof Package) {
+ final Package myPackage = (Package) selectedElements.get(0);
+
+ final String currentName = myPackage.getName();
+ if (currentName != null) {
+ TransactionalEditingDomain editingDomain = getEditingDomain(context);
+ AbstractTransactionalCommand cmd = new AbstractTransactionalCommand(editingDomain, "ExportCommand", //$NON-NLS-1$
+ null, null) {
+
+ /**
+ * @param monitor
+ * @param info
+ * @return
+ * @throws ExecutionException
+ * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor,
+ * org.eclipse.core.runtime.IAdaptable)
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info)
+ throws ExecutionException {
+ FileDialog dialog = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE);
+ dialog.setText("Save requirements as");
+ dialog.setFileName(currentName + ".csv");
+ dialog.setFilterPath(System.getProperty("user.home"));
+ dialog.setOverwrite(true);
+ String result = dialog.open();
+
+
+
+ if (result != null) {
+ try {
+ saveRequirements(result);
+ } catch (IOException e) {
+ Activator.log.error("can't save to file " + result, e);
+ }
+ }
+ return CommandResult.newOKCommandResult();
+ }
+
+ public boolean canUndo(){
+ return false;
+ }
+
+ };
+ return new GMFtoEMFCommandWrapper(cmd);
+ }
+ }
+ }
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ private Collection<Requirement> getRequirements(Package pkg) {
+ Collection<Requirement> requirements = new ArrayList<Requirement>();
+
+ for (NamedElement member : pkg.getMembers()) {
+ Requirement requirement = UMLUtil.getStereotypeApplication(member, Requirement.class);
+
+ if (requirement != null) {
+ requirements.add(requirement);
+ }
+ }
+
+ return requirements;
+ }
+
+
+ /*
+ * file format :
+ * package name , req ID , req name , req text
+ * package name is empty if the req parent is a requirement
+ *
+ * encoding is current system encoding
+ */
+ private void saveRequirements(String filename) throws IOException {
+
+ List<EObject> selectedElements = getSelectedElements();
+ if (selectedElements.size() == 1) {
+ Package selectedPackage = (Package) selectedElements.get(0);
+ List<String> msg = new ArrayList<>();
+ addRequirements(selectedPackage, msg);
+
+ Path path = Paths.get(filename);
+ Files.write(path, msg, Charset.forName(System.getProperty("file.encoding", "UTF-8")));
+ }
+ }
+
+ private void addRequirements(Package pkg, List<String> list) {
+ for (Requirement req : getRequirements(pkg)) {
+
+ list.add(getRow(req));
+
+ EList<Classifier> classList = req.getBase_Class().getNestedClassifiers();
+ for (Classifier classifier : classList) {
+
+ Requirement requirement = UMLUtil.getStereotypeApplication(classifier, Requirement.class);
+ if (requirement != null) {
+ list.add(getRow(requirement));
+ }
+ }
+ }
+
+ // iterate over sub packages
+ for (PackageableElement subPkg : pkg.getPackagedElements()) {
+ if (subPkg instanceof Package) {
+ addRequirements((Package) subPkg, list);
+ }
+ }
+ }
+
+ protected String formatCsvField(String field) {
+ String ret = "";
+
+ if(field != null){
+ ret = field;
+ }
+ if (ret.contains("\"") || ret.contains(FS)) {
+ String newField = field.replace("\"", "\"\"");
+ if(ret.length() > 1 && newField.startsWith("\"") && newField.endsWith("\""))
+ ret = newField;
+ else
+ ret = "\"" + newField + "\"";
+ }
+ if (ret.contains("\r\n")) {
+ ret = ret.replace("\r\n", " ");
+ }
+ if (ret.contains("\n")) {
+ ret = ret.replace("\n", " ");
+ }
+ return ret;
+ }
+
+ private String getRow(Requirement req) {
+ List<String> list = new ArrayList<>();
+
+ Package ppackage = req.getBase_Class().getPackage();
+ if (ppackage != null) {
+ list.add(formatCsvField(ppackage.getQualifiedName()));
+ } else {
+ list.add("");
+ }
+ list.add(req.getId());
+ list.add(formatCsvField(req.getBase_Class().getName()));
+ list.add(formatCsvField(req.getText()));
+
+ return list.stream().collect(Collectors.joining(FS));
+ }
+}
diff --git a/extraplugins/requirements/org.eclipse.papyrus.requirements.export/src/org/eclipse/papyrus/requirements/export/ExportRequirementCommandHandlerTest.java b/extraplugins/requirements/org.eclipse.papyrus.requirements.export/src/org/eclipse/papyrus/requirements/export/ExportRequirementCommandHandlerTest.java
new file mode 100644
index 00000000000..9c27af1dfd9
--- /dev/null
+++ b/extraplugins/requirements/org.eclipse.papyrus.requirements.export/src/org/eclipse/papyrus/requirements/export/ExportRequirementCommandHandlerTest.java
@@ -0,0 +1,121 @@
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST.
+ *
+ *
+ * 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:
+ *
+ * Géry Deloge (gery.deloge@cea.fr) CEATech AQUI - Initial API and implementation
+ *
+ *****************************************************************************/
+
+/* to execute tests, decomment and add junit to plugin dependencies */
+/*
+package org.eclipse.papyrus.requirements.export;
+
+import org.eclipse.papyrus.requirements.export.ExportRequirementCommandHandler;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestCase;
+
+
+public class ExportRequirementCommandHandlerTest extends TestCase {
+
+
+ @Test
+ public void testFormatCsvField1(){
+
+ ExportRequirementCommandHandler handler = new ExportRequirementCommandHandler();
+
+ String test = "";
+ assertEquals("", handler.formatCsvField(test));
+ }
+
+ @Test
+ public void testFormatCsvField2(){
+
+ ExportRequirementCommandHandler handler = new ExportRequirementCommandHandler();
+
+ String test = "1";
+ assertEquals(test, handler.formatCsvField(test));
+ }
+
+ @Test
+ public void testFormatCsvField3(){
+
+ ExportRequirementCommandHandler handler = new ExportRequirementCommandHandler();
+
+ String test = "\"1\"";
+ assertEquals("\"\"1\"\"", handler.formatCsvField(test));
+ }
+
+ @Test
+ public void testFormatCsvField4(){
+
+ ExportRequirementCommandHandler handler = new ExportRequirementCommandHandler();
+
+ String test = "1,2";
+ assertEquals("\"" + test + "\"", handler.formatCsvField(test));
+ }
+
+ @Test
+ public void testFormatCsvField5(){
+
+ ExportRequirementCommandHandler handler = new ExportRequirementCommandHandler();
+
+ String test = "1,\"2\"";
+ assertEquals("\"1,\"\"2\"\"\"", handler.formatCsvField(test));
+ }
+
+ @Test
+ public void testFormatCsvField6(){
+
+ ExportRequirementCommandHandler handler = new ExportRequirementCommandHandler();
+
+ String test = "1\n2";
+ assertEquals("1 2", handler.formatCsvField(test));
+ }
+
+ @Test
+ public void testFormatCsvField7(){
+
+ ExportRequirementCommandHandler handler = new ExportRequirementCommandHandler();
+
+ String test = "1\r\n2";
+ assertEquals("1 2", handler.formatCsvField(test));
+ }
+
+ @Test
+ public void testFormatCsvField8(){
+
+ ExportRequirementCommandHandler handler = new ExportRequirementCommandHandler();
+
+ String test = "\"\"";
+ assertEquals("\"\"\"\"", handler.formatCsvField(test));
+ }
+
+ @Test
+ public void testFormatCsvField9(){
+
+ ExportRequirementCommandHandler handler = new ExportRequirementCommandHandler();
+
+ String test = "\"";
+ assertEquals("\"\"\"\"", handler.formatCsvField(test));
+ }
+
+ @Test
+ public void testFormatCsvField10(){
+
+ ExportRequirementCommandHandler handler = new ExportRequirementCommandHandler();
+
+ String test = "1 \"2\"";
+ assertEquals("\"1 \"\"2\"\"\"", handler.formatCsvField(test));
+ }
+
+}
+*/ \ No newline at end of file

Back to the top