diff options
Diffstat (limited to 'tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org')
55 files changed, 4175 insertions, 828 deletions
diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/importfile/AbstractImportCellsTest.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/importfile/AbstractImportCellsTest.java new file mode 100644 index 00000000000..d474492972e --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/importfile/AbstractImportCellsTest.java @@ -0,0 +1,47 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.importfile; + +import org.eclipse.nebula.widgets.nattable.NatTable; +import org.eclipse.nebula.widgets.nattable.selection.command.ClearAllSelectionsCommand; +import org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; + +/** + * This class allows to manage the import CSV file tests into rows. + */ +public abstract class AbstractImportCellsTest extends AbstractImportTest { + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.generic.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + final NatTable natTable = (NatTable) manager.getAdapter(NatTable.class); + natTable.doCommand(new ClearAllSelectionsCommand()); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectCellCommand(manager.getBodyLayerStack().getSelectionLayer(), 0, 0, false, false)); + } + + /** + * @see org.eclipse.papyrus.uml.nattable.generic.tests.insert.AbstractInsertTest#getCommandId() + * + * @return + */ + @Override + public String getCommandId() { + return "org.eclipse.papyrus.infra.nattable.row.import.command"; //$NON-NLS-1$ + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/importfile/AbstractImportEmptyTest.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/importfile/AbstractImportEmptyTest.java new file mode 100644 index 00000000000..cbe4181f118 --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/importfile/AbstractImportEmptyTest.java @@ -0,0 +1,45 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.importfile; + +import org.eclipse.nebula.widgets.nattable.NatTable; +import org.eclipse.nebula.widgets.nattable.selection.command.ClearAllSelectionsCommand; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; + +/** + * This class allows to manage the import CSV file tests into rows. + */ +public abstract class AbstractImportEmptyTest extends AbstractImportTest { + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.generic.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + final NatTable natTable = (NatTable) manager.getAdapter(NatTable.class); + natTable.doCommand(new ClearAllSelectionsCommand()); + } + + /** + * @see org.eclipse.papyrus.uml.nattable.generic.tests.insert.AbstractInsertTest#getCommandId() + * + * @return + */ + @Override + public String getCommandId() { + return "org.eclipse.papyrus.infra.nattable.import.command"; //$NON-NLS-1$ + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/importfile/AbstractImportRowsTest.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/importfile/AbstractImportRowsTest.java new file mode 100644 index 00000000000..1f10605c14d --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/importfile/AbstractImportRowsTest.java @@ -0,0 +1,47 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.importfile; + +import org.eclipse.nebula.widgets.nattable.NatTable; +import org.eclipse.nebula.widgets.nattable.selection.command.ClearAllSelectionsCommand; +import org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; + +/** + * This class allows to manage the import CSV file tests into rows. + */ +public abstract class AbstractImportRowsTest extends AbstractImportTest { + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.generic.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + final NatTable natTable = (NatTable) manager.getAdapter(NatTable.class); + natTable.doCommand(new ClearAllSelectionsCommand()); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectRowsCommand(manager.getBodyLayerStack().getSelectionLayer(), 0, 0, false, false)); + } + + /** + * @see org.eclipse.papyrus.uml.nattable.generic.tests.insert.AbstractInsertTest#getCommandId() + * + * @return + */ + @Override + public String getCommandId() { + return "org.eclipse.papyrus.infra.nattable.row.import.command"; //$NON-NLS-1$ + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/importfile/AbstractImportTest.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/importfile/AbstractImportTest.java new file mode 100644 index 00000000000..42216bb84ad --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/importfile/AbstractImportTest.java @@ -0,0 +1,151 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.importfile; + +import java.net.URL; +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.core.commands.Command; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.IHandler; +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.emf.common.util.URI; +import org.eclipse.papyrus.infra.nattable.common.editor.NatTableEditor; +import org.eclipse.papyrus.infra.nattable.handler.ImportTableHandler; +import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.tools.util.EclipseCommandUtils; +import org.eclipse.papyrus.infra.tools.util.FileUtils; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.Activator; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite.AbstractPasteInsertTest; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.commands.ICommandService; +import org.junit.Assert; +import org.junit.Test; +import org.osgi.framework.Bundle; + +/** + * This class allows to manage the import CSV file tests. + */ +public abstract class AbstractImportTest extends AbstractPasteInsertTest { + + /** + * The path of the model to test. + */ + public static final String INSERT_FOLDER_PATH = "/resources/import/"; //$NON-NLS-1$ + + /** + * The variable name to determinate if the final dialog must be opened for the import. + */ + public static final String OPEN_DIALOG_BOOLEAN_PARAMETER = "openDialog"; //$NON-NLS-1$ + + /** + * The variable name to determinate the selected file path. + */ + public static final String SELECTED_FILE_PATH_STRING_PARAMETER = "selectedFilePath"; //$NON-NLS-1$ + + /** + * Constructor. + */ + public AbstractImportTest() { + super(); + } + + /** + * This allows to test the paste. + * + * @throws Exception + * The caught exception + */ + @Test + public void testImport() throws Exception { + // Open the table and get the manager + testOpenExistingTable(getClass().getSimpleName(), "RequirementTable0"); //$NON-NLS-1$ + final IEditorPart editorPart = editor.getActiveEditor(); + Assert.assertTrue("Table editor must be a nattable editor", editorPart instanceof NatTableEditor); //$NON-NLS-1$ + final INattableModelManager currentManager = (INattableModelManager) editor.getAdapter(INattableModelManager.class); + Assert.assertTrue("The manager must be a nattable model manager", currentManager instanceof NattableModelManager); //$NON-NLS-1$ + final NattableModelManager manager = (NattableModelManager) currentManager; + + // Check the table context before command + checkTableContent(manager, INITIAL_POST_FILE_NAME); + + // Manage the selection + flushDisplayEvents(); + manageSelection(manager); + flushDisplayEvents(); + + // fill the clipboard + final ICommandService commandService = EclipseCommandUtils.getCommandService(); + Assert.assertNotNull("The command service must not be null", commandService); //$NON-NLS-1$ + + // Get the paste command + final Command cmd = commandService.getCommand(getCommandId()); // $NON-NLS-1$ + final IHandler handler = cmd.getHandler(); + Assert.assertTrue("The handler must be enabled", handler.isEnabled()); //$NON-NLS-1$ + + // Execute the command with the non-UI parameters + final Map<Object, Object> parameters = new HashMap<Object, Object>(); + parameters.put(ImportTableHandler.OPEN_DIALOG_BOOLEAN_PARAMETER, Boolean.FALSE); + manageParameters(parameters, manager); + final ExecutionEvent event = new ExecutionEvent(cmd, parameters, null, null); + flushDisplayEvents(); + cmd.executeWithChecks(event); + + // Check the table content after command + checkTableContent(manager, RESULT_POST_FILE_NAME); + + // Undo/Redo + testUndo_Redo(manager); + } + + /** + * This allows to add parameters if necessary + * + * @param parameters + * The parameters for the command. + */ + public void manageParameters(final Map<Object, Object> parameters, final INattableModelManager manager) { + // Create the path for the csv to load (must be with the following form : 'resources/import/TableName.csv') + URI uri = manager.getTable().eResource().getURI(); + uri = uri.trimFileExtension(); + final StringBuffer buffer = new StringBuffer(uri.lastSegment()); + buffer.append(FileUtils.DOT_STRING); + buffer.append(FileUtils.CSV_EXTENSIOn); + + String csvFileAsString = getWantedString(buffer.toString()); + + parameters.put(ImportTableHandler.SELECTED_FILE_PATH_STRING_PARAMETER, csvFileAsString); + } + + /** + * This allows to get the command id. + * + * @return The command id. + */ + public abstract String getCommandId(); + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.tests.AbstractOpenTableTest#getSourcePath() + */ + @Override + protected String getSourcePath() { + return INSERT_FOLDER_PATH; + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/importfile/ImportCellsAll_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/importfile/ImportCellsAll_Test.java new file mode 100644 index 00000000000..595859f0892 --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/importfile/ImportCellsAll_Test.java @@ -0,0 +1,51 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.importfile; + +import org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; + +/** + * Test import all of selection with hidden categories. + */ +public class ImportCellsAll_Test extends AbstractImportCellsTest { + + /** + * Constructor. + */ + public ImportCellsAll_Test() { + super(); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.generic.tests.importfile.AbstractImportEmptyTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + super.manageSelection(manager); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectCellCommand(manager.getBodyLayerStack().getSelectionLayer(), 2, 2, true, false)); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.generic.tests.paste.overwrite.AbstractPasteInsertTest#testUndo_Redo(org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager) + */ + @Override + protected void testUndo_Redo(NattableModelManager treeManager) throws Exception { + // Do nothing : The undo/redo is not implemented for the old basic paste + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/importfile/ImportEmptyAddAll_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/importfile/ImportEmptyAddAll_Test.java new file mode 100644 index 00000000000..3eb0906b5b6 --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/importfile/ImportEmptyAddAll_Test.java @@ -0,0 +1,44 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.importfile; + +import java.util.Map; + +import org.eclipse.papyrus.infra.nattable.handler.ImportTableHandler; +import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager; +import org.eclipse.papyrus.infra.nattable.utils.UserActionConstants; + +/** + * Test import all of selection with hidden categories. + */ +public class ImportEmptyAddAll_Test extends AbstractImportEmptyTest { + + /** + * Constructor. + */ + public ImportEmptyAddAll_Test() { + super(); + } + + /** + * @see org.eclipse.papyrus.uml.nattable.generic.tests.insert.AbstractInsertTest#manageParameters(java.util.Map) + * + * @param parameters + */ + @Override + public void manageParameters(final Map<Object, Object> parameters, final INattableModelManager manager) { + super.manageParameters(parameters, manager); + parameters.put(ImportTableHandler.USER_ACTION__PREFERRED_USER_ACTION, UserActionConstants.ADD_USER_ACTION); + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/importfile/ImportEmptyReplaceAll_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/importfile/ImportEmptyReplaceAll_Test.java new file mode 100644 index 00000000000..ee3f73ac463 --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/importfile/ImportEmptyReplaceAll_Test.java @@ -0,0 +1,44 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.importfile; + +import java.util.Map; + +import org.eclipse.papyrus.infra.nattable.handler.ImportTableHandler; +import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager; +import org.eclipse.papyrus.infra.nattable.utils.UserActionConstants; + +/** + * Test import all of selection with hidden categories. + */ +public class ImportEmptyReplaceAll_Test extends AbstractImportEmptyTest { + + /** + * Constructor. + */ + public ImportEmptyReplaceAll_Test() { + super(); + } + + /** + * @see org.eclipse.papyrus.uml.nattable.generic.tests.insert.AbstractInsertTest#manageParameters(java.util.Map) + * + * @param parameters + */ + @Override + public void manageParameters(final Map<Object, Object> parameters, final INattableModelManager manager) { + super.manageParameters(parameters, manager); + parameters.put(ImportTableHandler.USER_ACTION__PREFERRED_USER_ACTION, UserActionConstants.REPLACE_USER_ACTION); + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/importfile/ImportEmptySkipAll_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/importfile/ImportEmptySkipAll_Test.java new file mode 100644 index 00000000000..0fcf2b0c7f6 --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/importfile/ImportEmptySkipAll_Test.java @@ -0,0 +1,55 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.importfile; + +import java.util.Map; + +import org.eclipse.papyrus.infra.nattable.handler.ImportTableHandler; +import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.nattable.utils.UserActionConstants; + +/** + * Test import all of selection with hidden categories. + */ +public class ImportEmptySkipAll_Test extends AbstractImportEmptyTest { + + /** + * Constructor. + */ + public ImportEmptySkipAll_Test() { + super(); + } + + /** + * @see org.eclipse.papyrus.uml.nattable.generic.tests.insert.AbstractInsertTest#manageParameters(java.util.Map) + * + * @param parameters + */ + @Override + public void manageParameters(final Map<Object, Object> parameters, final INattableModelManager manager) { + super.manageParameters(parameters, manager); + parameters.put(ImportTableHandler.USER_ACTION__PREFERRED_USER_ACTION, UserActionConstants.SKIP_USER_ACTION); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.generic.tests.paste.overwrite.AbstractPasteInsertTest#testUndo_Redo(org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager) + */ + @Override + protected void testUndo_Redo(final NattableModelManager treeManager) throws Exception { + // Do nothing + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/importfile/ImportRowsAddAll_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/importfile/ImportRowsAddAll_Test.java new file mode 100644 index 00000000000..4ff52804eac --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/importfile/ImportRowsAddAll_Test.java @@ -0,0 +1,58 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.importfile; + +import java.util.Map; + +import org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand; +import org.eclipse.papyrus.infra.nattable.handler.ImportTableHandler; +import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.nattable.utils.UserActionConstants; + +/** + * Test import all of selection with hidden categories. + */ +public class ImportRowsAddAll_Test extends AbstractImportRowsTest { + + /** + * Constructor. + */ + public ImportRowsAddAll_Test() { + super(); + } + + /** + * Manage the selection with the shift key. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + super.manageSelection(manager); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectRowsCommand(manager.getBodyLayerStack().getSelectionLayer(), 0, 2, true, false)); + } + + /** + * @see org.eclipse.papyrus.uml.nattable.generic.tests.insert.AbstractInsertTest#manageParameters(java.util.Map) + * + * @param parameters + */ + @Override + public void manageParameters(final Map<Object, Object> parameters, final INattableModelManager manager) { + super.manageParameters(parameters, manager); + parameters.put(ImportTableHandler.USER_ACTION__PREFERRED_USER_ACTION, UserActionConstants.ADD_USER_ACTION); + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/importfile/ImportRowsReplaceAll_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/importfile/ImportRowsReplaceAll_Test.java new file mode 100644 index 00000000000..0c2c09ad125 --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/importfile/ImportRowsReplaceAll_Test.java @@ -0,0 +1,58 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.importfile; + +import java.util.Map; + +import org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand; +import org.eclipse.papyrus.infra.nattable.handler.ImportTableHandler; +import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.nattable.utils.UserActionConstants; + +/** + * Test import all of selection with hidden categories. + */ +public class ImportRowsReplaceAll_Test extends AbstractImportRowsTest { + + /** + * Constructor. + */ + public ImportRowsReplaceAll_Test() { + super(); + } + + /** + * Manage the selection with the shift key. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + super.manageSelection(manager); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectRowsCommand(manager.getBodyLayerStack().getSelectionLayer(), 0, 2, true, false)); + } + + /** + * @see org.eclipse.papyrus.uml.nattable.generic.tests.insert.AbstractInsertTest#manageParameters(java.util.Map) + * + * @param parameters + */ + @Override + public void manageParameters(final Map<Object, Object> parameters, final INattableModelManager manager) { + super.manageParameters(parameters, manager); + parameters.put(ImportTableHandler.USER_ACTION__PREFERRED_USER_ACTION, UserActionConstants.REPLACE_USER_ACTION); + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/importfile/ImportRowsSkipAll_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/importfile/ImportRowsSkipAll_Test.java new file mode 100644 index 00000000000..1306ad2a73c --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/importfile/ImportRowsSkipAll_Test.java @@ -0,0 +1,68 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.importfile; + +import java.util.Map; + +import org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand; +import org.eclipse.papyrus.infra.nattable.handler.ImportTableHandler; +import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.nattable.utils.UserActionConstants; + +/** + * Test import all of selection with hidden categories. + */ +public class ImportRowsSkipAll_Test extends AbstractImportRowsTest { + + /** + * Constructor. + */ + public ImportRowsSkipAll_Test() { + super(); + } + + /** + * Manage the selection with the shift key. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + super.manageSelection(manager); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectRowsCommand(manager.getBodyLayerStack().getSelectionLayer(), 0, 2, true, false)); + } + + /** + * @see org.eclipse.papyrus.uml.nattable.generic.tests.insert.AbstractInsertTest#manageParameters(java.util.Map) + * + * @param parameters + */ + @Override + public void manageParameters(final Map<Object, Object> parameters, final INattableModelManager manager) { + super.manageParameters(parameters, manager); + parameters.put(ImportTableHandler.USER_ACTION__PREFERRED_USER_ACTION, UserActionConstants.SKIP_USER_ACTION); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.generic.tests.paste.overwrite.AbstractPasteInsertTest#testUndo_Redo(org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager) + */ + @Override + protected void testUndo_Redo(final NattableModelManager treeManager) throws Exception { + // Do nothing + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/AbstractInsertEmptyTest.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/AbstractInsertEmptyTest.java new file mode 100644 index 00000000000..bc61b0008d9 --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/AbstractInsertEmptyTest.java @@ -0,0 +1,45 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.insert; + +import org.eclipse.nebula.widgets.nattable.NatTable; +import org.eclipse.nebula.widgets.nattable.selection.command.ClearAllSelectionsCommand; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; + +/** + * This class allows to manage the insert tests. + */ +public abstract class AbstractInsertEmptyTest extends AbstractInsertTest { + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.generic.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + final NatTable natTable = (NatTable) manager.getAdapter(NatTable.class); + natTable.doCommand(new ClearAllSelectionsCommand()); + } + + /** + * @see org.eclipse.papyrus.uml.nattable.generic.tests.insert.AbstractInsertTest#getCommandId() + * + * @return + */ + @Override + public String getCommandId() { + return "org.eclipse.papyrus.infra.nattable.insert"; //$NON-NLS-1$ + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/AbstractInsertRowsTest.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/AbstractInsertRowsTest.java new file mode 100644 index 00000000000..513db46dbe1 --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/AbstractInsertRowsTest.java @@ -0,0 +1,47 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.insert; + +import org.eclipse.nebula.widgets.nattable.NatTable; +import org.eclipse.nebula.widgets.nattable.selection.command.ClearAllSelectionsCommand; +import org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; + +/** + * This class allows to manage the insert tests. + */ +public abstract class AbstractInsertRowsTest extends AbstractInsertTest { + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.generic.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + final NatTable natTable = (NatTable) manager.getAdapter(NatTable.class); + natTable.doCommand(new ClearAllSelectionsCommand()); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectRowsCommand(manager.getBodyLayerStack().getSelectionLayer(), 0, 0, false, false)); + } + + /** + * @see org.eclipse.papyrus.uml.nattable.generic.tests.insert.AbstractInsertTest#getCommandId() + * + * @return + */ + @Override + public String getCommandId() { + return "org.eclipse.papyrus.infra.nattable.row.insert"; //$NON-NLS-1$ + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/AbstractInsertTest.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/AbstractInsertTest.java new file mode 100644 index 00000000000..5ea41eb97fe --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/AbstractInsertTest.java @@ -0,0 +1,139 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.insert; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.core.commands.Command; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.IHandler; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.papyrus.infra.nattable.common.editor.NatTableEditor; +import org.eclipse.papyrus.infra.nattable.handler.PasteInTableHandler; +import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.tools.util.EclipseCommandUtils; +import org.eclipse.papyrus.infra.tools.util.FileUtils; +import org.eclipse.papyrus.junit.utils.GenericUtils; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.Activator; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite.AbstractPasteInsertTest; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.commands.ICommandService; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Test; + +/** + * This class allows to manage the insert tests. + */ +public abstract class AbstractInsertTest extends AbstractPasteInsertTest { + + /** + * The path of the model to test. + */ + public static final String INSERT_FOLDER_PATH = "/resources/insert/"; //$NON-NLS-1$ + + /** + * Constructor. + */ + public AbstractInsertTest() { + super(); + } + + /** + * This allows to test the paste. + * + * @throws Exception + * The caught exception + */ + @Test + public void testInsert() throws Exception { + // Open the table and get the manager + testOpenExistingTable(getClass().getSimpleName(), "RequirementTable0"); //$NON-NLS-1$ + final IEditorPart editorPart = editor.getActiveEditor(); + Assert.assertTrue("Table editor must be a nattable editor", editorPart instanceof NatTableEditor); //$NON-NLS-1$ + final INattableModelManager currentManager = (INattableModelManager) editor.getAdapter(INattableModelManager.class); + Assert.assertTrue("The manager must be a nattable model manager", currentManager instanceof NattableModelManager); //$NON-NLS-1$ + final NattableModelManager manager = (NattableModelManager) currentManager; + + // Check the table context before command + checkTableContent(manager, INITIAL_POST_FILE_NAME); + + // Manage the selection + manageSelection(manager); + flushDisplayEvents(); + + // fill the clipboard + final ICommandService commandService = EclipseCommandUtils.getCommandService(); + Assert.assertNotNull("The command service must not be null", commandService); //$NON-NLS-1$ + final String fileName = getSuffixStateFileName(manager, TOCOPY_POST_FILE_NAME); + final String str = FileUtils.getStringFromPlatformFile(Activator.PLUGIN_ID, getSourcePath(), fileName); + fillClipboard(str); + + // Get the paste command + final Command cmd = commandService.getCommand(getCommandId()); // $NON-NLS-1$ + final IHandler handler = cmd.getHandler(); + Assert.assertTrue("The handler must be enabled", handler.isEnabled()); //$NON-NLS-1$ + + // Execute the command with the non-UI parameters + final Map<Object, Object> parameters = new HashMap<Object, Object>(); + parameters.put(PasteInTableHandler.OPEN_DIALOG_ON_FAIL_BOOLEAN_PARAMETER, Boolean.FALSE); + parameters.put(PasteInTableHandler.OPEN__PROGRESS_MONITOR_DIALOG, Boolean.FALSE); + manageParameters(parameters); + final ExecutionEvent event = new ExecutionEvent(cmd, parameters, null, null); + flushDisplayEvents(); + final Object res = cmd.executeWithChecks(event); + Assert.assertTrue("The result must be a status", res instanceof IStatus); //$NON-NLS-1$ + final IStatus status = (IStatus) res; + + // Check the returned status + checkReturned_Status(status); + + if (status.isOK()) { + // Check the table content after command + checkTableContent(manager, RESULT_POST_FILE_NAME); + + // Undo/Redo + testUndo_Redo(manager); + } + } + + /** + * This allows to add parameters if necessary + * + * @param parameters + * The parameters for the command. + */ + public void manageParameters(final Map<Object, Object> parameters) { + // Do nothing + } + + /** + * This allows to get the command id. + * + * @return The command id. + */ + public abstract String getCommandId(); + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.tests.AbstractOpenTableTest#getSourcePath() + */ + @Override + protected String getSourcePath() { + return INSERT_FOLDER_PATH; + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertEmptyAddAll_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertEmptyAddAll_Test.java new file mode 100644 index 00000000000..b354eff7a09 --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertEmptyAddAll_Test.java @@ -0,0 +1,57 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.insert; + +import java.util.Map; + +import org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand; +import org.eclipse.papyrus.infra.nattable.handler.InsertInTableHandler; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.nattable.utils.UserActionConstants; + +/** + * Test insert all of selection with hidden categories. + */ +public class InsertEmptyAddAll_Test extends AbstractInsertEmptyTest { + + /** + * Constructor. + */ + public InsertEmptyAddAll_Test() { + super(); + } + + /** + * Manage the selection with the shift key. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + super.manageSelection(manager); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectRowsCommand(manager.getBodyLayerStack().getSelectionLayer(), 0, 2, true, false)); + } + + /** + * @see org.eclipse.papyrus.uml.nattable.generic.tests.insert.AbstractInsertTest#manageParameters(java.util.Map) + * + * @param parameters + */ + @Override + public void manageParameters(Map<Object, Object> parameters) { + super.manageParameters(parameters); + parameters.put(InsertInTableHandler.USER_ACTION__PREFERRED_USER_ACTION, UserActionConstants.ADD_USER_ACTION); + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertEmptyAxisIdentifierNotExisting_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertEmptyAxisIdentifierNotExisting_Test.java new file mode 100644 index 00000000000..4caccb4924b --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertEmptyAxisIdentifierNotExisting_Test.java @@ -0,0 +1,59 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.insert; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.MultiStatus; +import org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.nattable.messages.Messages; +import org.junit.Assert; + +/** + * Test insert all of selection with hidden categories. + */ +public class InsertEmptyAxisIdentifierNotExisting_Test extends AbstractInsertEmptyTest { + + /** + * Constructor. + */ + public InsertEmptyAxisIdentifierNotExisting_Test() { + super(); + } + + /** + * Manage the selection with the shift key. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + super.manageSelection(manager); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectRowsCommand(manager.getBodyLayerStack().getSelectionLayer(), 0, 2, true, false)); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#checkReturned_Status(org.eclipse.core.runtime.IStatus) + */ + @Override + protected void checkReturned_Status(final IStatus status) { + Assert.assertEquals("Error must be caught", IStatus.ERROR, status.getSeverity()); //$NON-NLS-1$ + Assert.assertEquals("Error message is not the expected message", Messages.AbstractPasteInSelectionNattableCommandProvider_ThePasteHasNotBeenDoneBecauseOfSomeProblems, status.getMessage()); //$NON-NLS-1$ + Assert.assertTrue("Status must be a multi-status", status instanceof MultiStatus); //$NON-NLS-1$ + Assert.assertEquals("Error message is not the expected message", Messages.AbstractPasteInSelectionNattableCommandProvider_TheAxisUsedAsIdentifierNotAvailable, ((MultiStatus)status).getChildren()[0].getMessage()); //$NON-NLS-1$ + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertEmptyFailColumns_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertEmptyFailColumns_Test.java new file mode 100644 index 00000000000..533f8107b46 --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertEmptyFailColumns_Test.java @@ -0,0 +1,56 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.insert; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.nattable.messages.Messages; +import org.junit.Assert; + +/** + * Test insert when the number of columns to paste is not equals to the number of columns selected. + */ +public class InsertEmptyFailColumns_Test extends AbstractInsertEmptyTest { + + /** + * Constructor. + */ + public InsertEmptyFailColumns_Test() { + super(); + } + + /** + * Manage the selection with the shift key. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + super.manageSelection(manager); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectRowsCommand(manager.getBodyLayerStack().getSelectionLayer(), 0, 2, true, false)); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#checkReturned_Status(org.eclipse.core.runtime.IStatus) + */ + @Override + protected void checkReturned_Status(final IStatus status) { + Assert.assertEquals("Error must be caught", IStatus.ERROR, status.getSeverity()); //$NON-NLS-1$ + Assert.assertEquals("Error message is not the expected message", Messages.AbstractPasteInSelectionNattableCommandProvider_readcolumnsexceedsexistingcolumns, status.getMessage()); //$NON-NLS-1$ + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertEmptyReplaceAll_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertEmptyReplaceAll_Test.java new file mode 100644 index 00000000000..91861a48e2b --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertEmptyReplaceAll_Test.java @@ -0,0 +1,57 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.insert; + +import java.util.Map; + +import org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand; +import org.eclipse.papyrus.infra.nattable.handler.InsertInTableHandler; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.nattable.utils.UserActionConstants; + +/** + * Test insert all of selection with hidden categories. + */ +public class InsertEmptyReplaceAll_Test extends AbstractInsertEmptyTest { + + /** + * Constructor. + */ + public InsertEmptyReplaceAll_Test() { + super(); + } + + /** + * Manage the selection with the shift key. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + super.manageSelection(manager); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectRowsCommand(manager.getBodyLayerStack().getSelectionLayer(), 0, 2, true, false)); + } + + /** + * @see org.eclipse.papyrus.uml.nattable.generic.tests.insert.AbstractInsertTest#manageParameters(java.util.Map) + * + * @param parameters + */ + @Override + public void manageParameters(Map<Object, Object> parameters) { + super.manageParameters(parameters); + parameters.put(InsertInTableHandler.USER_ACTION__PREFERRED_USER_ACTION, UserActionConstants.REPLACE_USER_ACTION); + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertEmptySkipAll_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertEmptySkipAll_Test.java new file mode 100644 index 00000000000..dd645cbc668 --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertEmptySkipAll_Test.java @@ -0,0 +1,68 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.insert; + +import java.util.Map; + +import org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand; +import org.eclipse.papyrus.infra.nattable.handler.InsertInTableHandler; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.nattable.utils.UserActionConstants; + +/** + * Test insert all of selection with hidden categories. + */ +public class InsertEmptySkipAll_Test extends AbstractInsertEmptyTest { + + /** + * Constructor. + */ + public InsertEmptySkipAll_Test() { + super(); + } + + /** + * Manage the selection with the shift key. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + super.manageSelection(manager); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectRowsCommand(manager.getBodyLayerStack().getSelectionLayer(), 0, 2, true, false)); + } + + /** + * @see org.eclipse.papyrus.uml.nattable.generic.tests.insert.AbstractInsertTest#manageParameters(java.util.Map) + * + * @param parameters + */ + @Override + public void manageParameters(Map<Object, Object> parameters) { + super.manageParameters(parameters); + parameters.put(InsertInTableHandler.USER_ACTION__PREFERRED_USER_ACTION, UserActionConstants.SKIP_USER_ACTION); + } + + /** + * @see org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite.AbstractPasteInsertTest#testUndo_Redo(org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager) + * + * @param treeManager + * @throws Exception + */ + @Override + protected void testUndo_Redo(NattableModelManager treeManager) throws Exception { + // Do nothing + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertEmptyWarningNotExisting_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertEmptyWarningNotExisting_Test.java new file mode 100644 index 00000000000..5c3962e3a33 --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertEmptyWarningNotExisting_Test.java @@ -0,0 +1,59 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.insert; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.MultiStatus; +import org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.nattable.messages.Messages; +import org.junit.Assert; + +/** + * Test pastes overwrite all of selection with hidden categories. + */ +public class InsertEmptyWarningNotExisting_Test extends AbstractInsertEmptyTest { + + /** + * Constructor. + */ + public InsertEmptyWarningNotExisting_Test() { + super(); + } + + /** + * Manage the selection with the shift key. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + super.manageSelection(manager); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectRowsCommand(manager.getBodyLayerStack().getSelectionLayer(), 0, 2, true, false)); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#checkReturned_Status(org.eclipse.core.runtime.IStatus) + */ + @Override + protected void checkReturned_Status(final IStatus status) { + Assert.assertEquals("Warning must be caught", IStatus.WARNING, status.getSeverity()); //$NON-NLS-1$ + Assert.assertEquals("Warning message is not the expected message", Messages.AbstractPasteInSelectionNattableCommandProvider_ThePasteHasBeenDoneWithSomeProblems, status.getMessage()); //$NON-NLS-1$ + Assert.assertTrue("Status must be a multi-status", status instanceof MultiStatus); //$NON-NLS-1$ + Assert.assertEquals("Warning message is not the expected message", "The identifier 'Class2' was not found in the selection, so the object was created", ((MultiStatus)status).getChildren()[0].getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertRowsAddAll_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertRowsAddAll_Test.java new file mode 100644 index 00000000000..16d6ecd8c3d --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertRowsAddAll_Test.java @@ -0,0 +1,57 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.insert; + +import java.util.Map; + +import org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand; +import org.eclipse.papyrus.infra.nattable.handler.InsertInTableHandler; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.nattable.utils.UserActionConstants; + +/** + * Test insert all of selection with hidden categories. + */ +public class InsertRowsAddAll_Test extends AbstractInsertRowsTest { + + /** + * Constructor. + */ + public InsertRowsAddAll_Test() { + super(); + } + + /** + * Manage the selection with the shift key. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + super.manageSelection(manager); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectRowsCommand(manager.getBodyLayerStack().getSelectionLayer(), 0, 2, true, false)); + } + + /** + * @see org.eclipse.papyrus.uml.nattable.generic.tests.insert.AbstractInsertTest#manageParameters(java.util.Map) + * + * @param parameters + */ + @Override + public void manageParameters(Map<Object, Object> parameters) { + super.manageParameters(parameters); + parameters.put(InsertInTableHandler.USER_ACTION__PREFERRED_USER_ACTION, UserActionConstants.ADD_USER_ACTION); + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertRowsAxisIdentifierNotExisting_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertRowsAxisIdentifierNotExisting_Test.java new file mode 100644 index 00000000000..8fbcc711713 --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertRowsAxisIdentifierNotExisting_Test.java @@ -0,0 +1,59 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.insert; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.MultiStatus; +import org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.nattable.messages.Messages; +import org.junit.Assert; + +/** + * Test insert all of selection with hidden categories. + */ +public class InsertRowsAxisIdentifierNotExisting_Test extends AbstractInsertRowsTest { + + /** + * Constructor. + */ + public InsertRowsAxisIdentifierNotExisting_Test() { + super(); + } + + /** + * Manage the selection with the shift key. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + super.manageSelection(manager); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectRowsCommand(manager.getBodyLayerStack().getSelectionLayer(), 0, 2, true, false)); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#checkReturned_Status(org.eclipse.core.runtime.IStatus) + */ + @Override + protected void checkReturned_Status(final IStatus status) { + Assert.assertEquals("Error must be caught", IStatus.ERROR, status.getSeverity()); //$NON-NLS-1$ + Assert.assertEquals("Error message is not the expected message", Messages.AbstractPasteInSelectionNattableCommandProvider_ThePasteHasNotBeenDoneBecauseOfSomeProblems, status.getMessage()); //$NON-NLS-1$ + Assert.assertTrue("Status must be a multi-status", status instanceof MultiStatus); //$NON-NLS-1$ + Assert.assertEquals("Error message is not the expected message", Messages.AbstractPasteInSelectionNattableCommandProvider_TheAxisUsedAsIdentifierNotAvailable, ((MultiStatus)status).getChildren()[0].getMessage()); //$NON-NLS-1$ + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertRowsFailColumns_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertRowsFailColumns_Test.java new file mode 100644 index 00000000000..633faac38e8 --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertRowsFailColumns_Test.java @@ -0,0 +1,56 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.insert; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.nattable.messages.Messages; +import org.junit.Assert; + +/** + * Test insert when the number of columns to paste is not equals to the number of columns selected. + */ +public class InsertRowsFailColumns_Test extends AbstractInsertRowsTest { + + /** + * Constructor. + */ + public InsertRowsFailColumns_Test() { + super(); + } + + /** + * Manage the selection with the shift key. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + super.manageSelection(manager); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectRowsCommand(manager.getBodyLayerStack().getSelectionLayer(), 0, 2, true, false)); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#checkReturned_Status(org.eclipse.core.runtime.IStatus) + */ + @Override + protected void checkReturned_Status(final IStatus status) { + Assert.assertEquals("Error must be caught", IStatus.ERROR, status.getSeverity()); //$NON-NLS-1$ + Assert.assertEquals("Error message is not the expected message", Messages.AbstractPasteInSelectionNattableCommandProvider_readcolumnsexceedsexistingcolumns, status.getMessage()); //$NON-NLS-1$ + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertRowsFailRows_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertRowsFailRows_Test.java new file mode 100644 index 00000000000..0bafd6ad9b9 --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertRowsFailRows_Test.java @@ -0,0 +1,57 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.insert; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.nattable.messages.Messages; +import org.junit.Assert; + +/** + * Test insert when the number of rows to paste is not equals to the number of rows selected. + */ +public class InsertRowsFailRows_Test extends AbstractInsertRowsTest { + + /** + * Constructor. + */ + public InsertRowsFailRows_Test() { + super(); + } + + /** + * Manage the selection with the shift key. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + super.manageSelection(manager); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectRowsCommand(manager.getBodyLayerStack().getSelectionLayer(), 0, 1, true, false)); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#checkReturned_Status(org.eclipse.core.runtime.IStatus) + */ + @Override + protected void checkReturned_Status(final IStatus status) { + Assert.assertEquals("Error must be caught", IStatus.ERROR, status.getSeverity()); //$NON-NLS-1$ + Assert.assertEquals("Error message is not the expected message", Messages.AbstractPasteInSelectionNattableCommandProvider_readrowsexceedsexistingrows, status.getMessage()); //$NON-NLS-1$ + } + +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertRowsReplaceAll_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertRowsReplaceAll_Test.java new file mode 100644 index 00000000000..e45a6c9e3e3 --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertRowsReplaceAll_Test.java @@ -0,0 +1,57 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.insert; + +import java.util.Map; + +import org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand; +import org.eclipse.papyrus.infra.nattable.handler.InsertInTableHandler; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.nattable.utils.UserActionConstants; + +/** + * Test insert all of selection with hidden categories. + */ +public class InsertRowsReplaceAll_Test extends AbstractInsertRowsTest { + + /** + * Constructor. + */ + public InsertRowsReplaceAll_Test() { + super(); + } + + /** + * Manage the selection with the shift key. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + super.manageSelection(manager); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectRowsCommand(manager.getBodyLayerStack().getSelectionLayer(), 0, 2, true, false)); + } + + /** + * @see org.eclipse.papyrus.uml.nattable.generic.tests.insert.AbstractInsertTest#manageParameters(java.util.Map) + * + * @param parameters + */ + @Override + public void manageParameters(Map<Object, Object> parameters) { + super.manageParameters(parameters); + parameters.put(InsertInTableHandler.USER_ACTION__PREFERRED_USER_ACTION, UserActionConstants.REPLACE_USER_ACTION); + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertRowsSkipAll_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertRowsSkipAll_Test.java new file mode 100644 index 00000000000..10cb2fc9393 --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertRowsSkipAll_Test.java @@ -0,0 +1,68 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.insert; + +import java.util.Map; + +import org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand; +import org.eclipse.papyrus.infra.nattable.handler.InsertInTableHandler; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.nattable.utils.UserActionConstants; + +/** + * Test insert all of selection with hidden categories. + */ +public class InsertRowsSkipAll_Test extends AbstractInsertRowsTest { + + /** + * Constructor. + */ + public InsertRowsSkipAll_Test() { + super(); + } + + /** + * Manage the selection with the shift key. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + super.manageSelection(manager); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectRowsCommand(manager.getBodyLayerStack().getSelectionLayer(), 0, 2, true, false)); + } + + /** + * @see org.eclipse.papyrus.uml.nattable.generic.tests.insert.AbstractInsertTest#manageParameters(java.util.Map) + * + * @param parameters + */ + @Override + public void manageParameters(Map<Object, Object> parameters) { + super.manageParameters(parameters); + parameters.put(InsertInTableHandler.USER_ACTION__PREFERRED_USER_ACTION, UserActionConstants.SKIP_USER_ACTION); + } + + /** + * @see org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite.AbstractPasteInsertTest#testUndo_Redo(org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager) + * + * @param treeManager + * @throws Exception + */ + @Override + protected void testUndo_Redo(NattableModelManager treeManager) throws Exception { + // Do nothing + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertRowsWarningNotExisting_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertRowsWarningNotExisting_Test.java new file mode 100644 index 00000000000..e3e94e0dc32 --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/insert/InsertRowsWarningNotExisting_Test.java @@ -0,0 +1,59 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.insert; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.MultiStatus; +import org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.nattable.messages.Messages; +import org.junit.Assert; + +/** + * Test pastes overwrite all of selection with hidden categories. + */ +public class InsertRowsWarningNotExisting_Test extends AbstractInsertRowsTest { + + /** + * Constructor. + */ + public InsertRowsWarningNotExisting_Test() { + super(); + } + + /** + * Manage the selection with the shift key. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + super.manageSelection(manager); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectRowsCommand(manager.getBodyLayerStack().getSelectionLayer(), 0, 2, true, false)); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#checkReturned_Status(org.eclipse.core.runtime.IStatus) + */ + @Override + protected void checkReturned_Status(final IStatus status) { + Assert.assertEquals("Warning must be caught", IStatus.WARNING, status.getSeverity()); //$NON-NLS-1$ + Assert.assertEquals("Warning message is not the expected message", Messages.AbstractPasteInSelectionNattableCommandProvider_ThePasteHasBeenDoneWithSomeProblems, status.getMessage()); //$NON-NLS-1$ + Assert.assertTrue("Status must be a multi-status", status instanceof MultiStatus); //$NON-NLS-1$ + Assert.assertEquals("Warning message is not the expected message", "The identifier 'Class2' was not found in the selection, so the object was created", ((MultiStatus)status).getChildren()[0].getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/AbstractPasteCellsOverwriteTest.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/AbstractPasteCellsOverwriteTest.java new file mode 100644 index 00000000000..70f131f2c59 --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/AbstractPasteCellsOverwriteTest.java @@ -0,0 +1,37 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite; + +import org.eclipse.nebula.widgets.nattable.NatTable; +import org.eclipse.nebula.widgets.nattable.selection.command.ClearAllSelectionsCommand; +import org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; + +/** + * This class allows to manage the paste with overwrite tests. + */ +public abstract class AbstractPasteCellsOverwriteTest extends AbstractPasteOverwriteTest { + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + final NatTable natTable = (NatTable) manager.getAdapter(NatTable.class); + natTable.doCommand(new ClearAllSelectionsCommand()); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectCellCommand(manager.getBodyLayerStack().getSelectionLayer(), 0, 0, false, false)); + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/AbstractPasteColumnsOverwriteTest.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/AbstractPasteColumnsOverwriteTest.java new file mode 100644 index 00000000000..7183eac69cd --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/AbstractPasteColumnsOverwriteTest.java @@ -0,0 +1,37 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite; + +import org.eclipse.nebula.widgets.nattable.NatTable; +import org.eclipse.nebula.widgets.nattable.selection.command.ClearAllSelectionsCommand; +import org.eclipse.nebula.widgets.nattable.selection.command.SelectColumnCommand; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; + +/** + * This class allows to manage the paste with overwrite tests. + */ +public abstract class AbstractPasteColumnsOverwriteTest extends AbstractPasteOverwriteTest { + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + final NatTable natTable = (NatTable) manager.getAdapter(NatTable.class); + natTable.doCommand(new ClearAllSelectionsCommand()); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectColumnCommand(manager.getBodyLayerStack().getSelectionLayer(), 0, 0, false, false)); + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/AbstractPasteEmptyOverwriteTest.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/AbstractPasteEmptyOverwriteTest.java new file mode 100644 index 00000000000..1482caa2b86 --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/AbstractPasteEmptyOverwriteTest.java @@ -0,0 +1,121 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.core.commands.Command; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.IHandler; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.nebula.widgets.nattable.NatTable; +import org.eclipse.nebula.widgets.nattable.selection.command.ClearAllSelectionsCommand; +import org.eclipse.papyrus.infra.nattable.common.editor.NatTableEditor; +import org.eclipse.papyrus.infra.nattable.handler.PasteInTableHandler; +import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.tools.util.EclipseCommandUtils; +import org.eclipse.papyrus.infra.tools.util.FileUtils; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.Activator; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.commands.ICommandService; +import org.junit.Assert; +import org.junit.Test; + +/** + * This class allows to manage the paste with overwrite tests. + */ +public abstract class AbstractPasteEmptyOverwriteTest extends AbstractPasteOverwriteTest { + + /** + * This allows to test the paste. + * + * @throws Exception + * The caught exception + */ + @Override + @Test + public void testPaste() throws Exception { + // Open the table and get the manager + testOpenExistingTable(getClass().getSimpleName(), "RequirementTable0"); //$NON-NLS-1$ + final IEditorPart editorPart = editor.getActiveEditor(); + Assert.assertTrue("Table editor must be a nattable editor", editorPart instanceof NatTableEditor); //$NON-NLS-1$ + final INattableModelManager currentManager = (INattableModelManager) editor.getAdapter(INattableModelManager.class); + Assert.assertTrue("The manager must be a nattable model manager", currentManager instanceof NattableModelManager); //$NON-NLS-1$ + final NattableModelManager manager = (NattableModelManager) currentManager; + + // Check the table context before command + checkTableContent(manager, INITIAL_POST_FILE_NAME); + + // Manage the selection + manageSelection(manager); + flushDisplayEvents(); + + // fill the clipboard + final ICommandService commandService = EclipseCommandUtils.getCommandService(); + Assert.assertNotNull("The command service must not be null", commandService); //$NON-NLS-1$ + final String fileName = getSuffixStateFileName(manager, TOCOPY_POST_FILE_NAME); + final String str = FileUtils.getStringFromPlatformFile(Activator.PLUGIN_ID, getSourcePath(), fileName); + fillClipboard(str); + + // Get the paste command + final Command cmd = commandService.getCommand("org.eclipse.ui.edit.paste"); //$NON-NLS-1$ + final IHandler handler = cmd.getHandler(); + Assert.assertTrue("The handler must be enabled", handler.isEnabled()); //$NON-NLS-1$ + + // Execute the command with the non-UI parameters + final Map<Object, Object> parameters = new HashMap<Object, Object>(); + parameters.put(PasteInTableHandler.OPEN_DIALOG_ON_FAIL_BOOLEAN_PARAMETER, Boolean.FALSE); + parameters.put(PasteInTableHandler.OPEN__PROGRESS_MONITOR_DIALOG, Boolean.FALSE); + manageParameters(parameters); + final ExecutionEvent event = new ExecutionEvent(cmd, parameters, null, null); + flushDisplayEvents(); + final Object res = cmd.executeWithChecks(event); + Assert.assertTrue("The result must be a status", res instanceof IStatus); //$NON-NLS-1$ + final IStatus status = (IStatus) res; + + // Check the returned status + checkReturned_Status(status); + + if (status.isOK()) { + // Check the table content after command + checkTableContent(manager, RESULT_POST_FILE_NAME); + + // Undo/Redo + testUndo_Redo(manager); + } + } + + /** + * This allows to add parameters if necessary + * + * @param parameters + * The parameters for the command. + */ + public void manageParameters(final Map<Object, Object> parameters) { + // Do nothing + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + final NatTable natTable = (NatTable) manager.getAdapter(NatTable.class); + natTable.doCommand(new ClearAllSelectionsCommand()); + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/AbstractPasteInsertTest.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/AbstractPasteInsertTest.java new file mode 100644 index 00000000000..de37bb27a2c --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/AbstractPasteInsertTest.java @@ -0,0 +1,204 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite; + +import java.awt.Toolkit; +import java.awt.datatransfer.StringSelection; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.emf.common.util.URI; +import org.eclipse.nebula.widgets.nattable.NatTable; +import org.eclipse.nebula.widgets.nattable.selection.command.ClearAllSelectionsCommand; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.nattable.utils.TableClipboardUtils; +import org.eclipse.papyrus.infra.tools.util.FileUtils; +import org.eclipse.papyrus.junit.utils.GenericUtils; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.Activator; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.without.service.edit.AbstractOpenTableTest; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; + +/** + * This class allows to manage the paste with overwrite tests. + */ +public abstract class AbstractPasteInsertTest extends AbstractOpenTableTest { + + /** + * The path of the model to test. + */ + public static final String PASTE_FOLDER_PATH = "/resources/paste_overwrite/"; //$NON-NLS-1$ + + /** + * The suffix of the file containing the initial content. + */ + public static final String INITIAL_POST_FILE_NAME = "_Initial"; //$NON-NLS-1$ + + /** + * The suffix of the file containing the content to copy. + */ + public static final String TOCOPY_POST_FILE_NAME = "_ToCopy"; //$NON-NLS-1$ + + /** + * The suffix of the file containing the result content. + */ + public static final String RESULT_POST_FILE_NAME = "_Result"; //$NON-NLS-1$ + + /** + * Constructor. + */ + public AbstractPasteInsertTest() { + super(); + } + + /** + * Initialize the model. + * + * @throws Exception + * The caught exception. + */ + @Before + public void initModel() throws Exception { + initModel("RequirementTable0", getClass().getSimpleName(), getBundle()); //$NON-NLS-1$ + }; + + /** + * This allows to set the selection in table for the paste. The initial selection is the first cell of the table. + * + * @param manager + * The tree nattable model manager. + * @throws Exception + * The caught exception. + */ + public abstract void manageSelection(final NattableModelManager manager) throws Exception; + + /** + * This allows to test the undo redo commands. + * + * @param treeManager + * The tree nattable model manager. + * @throws Exception + * The caught exception. + */ + protected void testUndo_Redo(final NattableModelManager treeManager) throws Exception { + // Check the undo + getTransactionalEditingDomain().getCommandStack().undo(); + // Check the table context after undo + checkTableContent(treeManager, INITIAL_POST_FILE_NAME); + + // Check the redo + getTransactionalEditingDomain().getCommandStack().redo(); + // Check the table context after redo + checkTableContent(treeManager, RESULT_POST_FILE_NAME); + } + + /** + * This allows to check the returned status. + * + * @param status + * The status. + */ + protected void checkReturned_Status(final IStatus status) { + Assert.assertTrue("The status must be OK", status.isOK()); //$NON-NLS-1$ + } + + /** + * This allows to check the table content comparing the table content with file content. + * + * @param manager + * The nattable model manager. + * @param suffixFileName + * The suffix of the file to check. + * @throws Exception + * The caught exception. + */ + protected void checkTableContent(final NattableModelManager manager, final String suffixFileName) throws Exception { + final NatTable natTable = (NatTable) manager.getAdapter(NatTable.class); + flushDisplayEvents(); + natTable.doCommand(new ClearAllSelectionsCommand()); + manager.selectAll(); + manager.copyToClipboard(); + String clipboard = getClipboardContent(); + // we check than the contents of the clipboard (so the displayed table) is the same than the wanted result + Assert.assertNotNull("Clipboard must not be null", clipboard); //$NON-NLS-1$ + String str = getWantedString(getSuffixStateFileName(manager, suffixFileName)); + // we check than the contents of the clipboard (so the displayed table) is the same than the wanted result + Assert.assertEquals("The clipboard must be equals to string which one it is filled", str, clipboard); //$NON-NLS-1$ + } + + /** + * Get the string content from a file. + * + * @param fileName + * a file name + * @return + * the text stored in the file associated to this test + */ + protected String getWantedString(final String fileName) { + return FileUtils.getStringFromPlatformFile(Activator.PLUGIN_ID, getSourcePath(), fileName, FileUtils.getSystemPropertyLineSeparator());// $NON-NLS-1$ + } + + /** + * Get the file name corresponding to the model with the suffix in parameter. + * + * @param manager + * The nattable model manager. + * @param suffixFileName + * The suffix of the file to get. + * @return The file name corresponding + */ + protected String getSuffixStateFileName(final NattableModelManager manager, final String suffixFileName) { + URI uri = manager.getTable().eResource().getURI(); + uri = uri.trimFileExtension(); + final StringBuffer buffer = new StringBuffer(uri.lastSegment()); + buffer.append(suffixFileName); + buffer.append(FileUtils.DOT_STRING); + buffer.append(FileUtils.TEXT_EXTENSION); + return buffer.toString(); + } + + /** + * Get the clipboard contents. + * + * @return + * the clipboard contents. + */ + protected String getClipboardContent() { + String clipboard = TableClipboardUtils.getClipboardContentsAsString(); + return clipboard; + } + + /** + * This allows to fill the clipboard with the string in parameter. + * + * @param newClipBoardContents + * The string needed to fill the clipboard. + */ + protected void fillClipboard(final String newClipBoardContents) { + + // its seems that the clipboard must be filled with the same way than we read it! + java.awt.datatransfer.Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + + StringSelection s = new StringSelection(newClipBoardContents); + clipboard.setContents(s, s); + } + + /** + * This allow to close the opened editors. + */ + @AfterClass + public static void endOfTest() { + GenericUtils.closeAllEditors(); + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/AbstractPasteOverwriteTest.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/AbstractPasteOverwriteTest.java new file mode 100644 index 00000000000..34b9489c8fe --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/AbstractPasteOverwriteTest.java @@ -0,0 +1,113 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.core.commands.Command; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.IHandler; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.papyrus.infra.nattable.common.editor.NatTableEditor; +import org.eclipse.papyrus.infra.nattable.handler.PasteInTableHandler; +import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.tools.util.EclipseCommandUtils; +import org.eclipse.papyrus.infra.tools.util.FileUtils; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.Activator; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.commands.ICommandService; +import org.junit.Assert; +import org.junit.Test; + +/** + * This class allows to manage the paste with overwrite tests. + */ +public abstract class AbstractPasteOverwriteTest extends AbstractPasteInsertTest { + + /** + * Constructor. + */ + public AbstractPasteOverwriteTest() { + super(); + } + + /** + * This allows to test the paste. + * + * @throws Exception + * The caught exception + */ + @Test + public void testPaste() throws Exception { + // Open the table and get the manager + testOpenExistingTable(getClass().getSimpleName(), "RequirementTable0"); //$NON-NLS-1$ + final IEditorPart editorPart = editor.getActiveEditor(); + Assert.assertTrue("Table editor must be a nattable editor", editorPart instanceof NatTableEditor); //$NON-NLS-1$ + final INattableModelManager currentManager = (INattableModelManager) editor.getAdapter(INattableModelManager.class); + Assert.assertTrue("The manager must be a nattable model manager", currentManager instanceof NattableModelManager); //$NON-NLS-1$ + final NattableModelManager manager = (NattableModelManager) currentManager; + + // Check the table context before command + checkTableContent(manager, INITIAL_POST_FILE_NAME); + + // Manage the selection + manageSelection(manager); + flushDisplayEvents(); + + // fill the clipboard + final ICommandService commandService = EclipseCommandUtils.getCommandService(); + Assert.assertNotNull("The command service must not be null", commandService); //$NON-NLS-1$ + final String fileName = getSuffixStateFileName(manager, TOCOPY_POST_FILE_NAME); + final String str = FileUtils.getStringFromPlatformFile(Activator.PLUGIN_ID, getSourcePath(), fileName); + fillClipboard(str); + + // Get the paste command + final Command cmd = commandService.getCommand("org.eclipse.ui.edit.paste"); //$NON-NLS-1$ + final IHandler handler = cmd.getHandler(); + Assert.assertTrue("The handler must be enabled", handler.isEnabled()); //$NON-NLS-1$ + + // Execute the command with the non-UI parameters + final Map<Object, Object> parameters = new HashMap<Object, Object>(); + parameters.put(PasteInTableHandler.OPEN_DIALOG_ON_FAIL_BOOLEAN_PARAMETER, Boolean.FALSE); + parameters.put(PasteInTableHandler.OPEN__PROGRESS_MONITOR_DIALOG, Boolean.FALSE); + final ExecutionEvent event = new ExecutionEvent(cmd, parameters, null, null); + flushDisplayEvents(); + final Object res = cmd.executeWithChecks(event); + Assert.assertTrue("The result must be a status", res instanceof IStatus); //$NON-NLS-1$ + final IStatus status = (IStatus) res; + + // Check the returned status + checkReturned_Status(status); + + if (status.isOK()) { + // Check the table content after command + checkTableContent(manager, RESULT_POST_FILE_NAME); + + // Undo/Redo + testUndo_Redo(manager); + } + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.tests.AbstractOpenTableTest#getSourcePath() + */ + @Override + protected String getSourcePath() { + return PASTE_FOLDER_PATH; + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/AbstractPasteRowsOverwriteTest.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/AbstractPasteRowsOverwriteTest.java new file mode 100644 index 00000000000..65cded2830f --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/AbstractPasteRowsOverwriteTest.java @@ -0,0 +1,37 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite; + +import org.eclipse.nebula.widgets.nattable.NatTable; +import org.eclipse.nebula.widgets.nattable.selection.command.ClearAllSelectionsCommand; +import org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; + +/** + * This class allows to manage the paste with overwrite tests. + */ +public abstract class AbstractPasteRowsOverwriteTest extends AbstractPasteOverwriteTest { + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + final NatTable natTable = (NatTable) manager.getAdapter(NatTable.class); + natTable.doCommand(new ClearAllSelectionsCommand()); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectRowsCommand(manager.getBodyLayerStack().getSelectionLayer(), 0, 0, false, false)); + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteCellsOverwriteAll_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteCellsOverwriteAll_Test.java new file mode 100644 index 00000000000..d7d05105b9e --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteCellsOverwriteAll_Test.java @@ -0,0 +1,42 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite; + +import org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; + +/** + * Test pastes overwrite all of selection with hidden categories. + */ +public class PasteCellsOverwriteAll_Test extends AbstractPasteCellsOverwriteTest { + + /** + * Constructor. + */ + public PasteCellsOverwriteAll_Test() { + super(); + } + + /** + * Manage the selection with the shift key. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + super.manageSelection(manager); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectCellCommand(manager.getBodyLayerStack().getSelectionLayer(), 2, 2, true, false)); + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteCellsOverwriteByOneLine_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteCellsOverwriteByOneLine_Test.java new file mode 100644 index 00000000000..c96e4bd7bba --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteCellsOverwriteByOneLine_Test.java @@ -0,0 +1,42 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite; + +import org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; + +/** + * Test pastes overwrite all of selection with hidden categories when a single line is copied. + */ +public class PasteCellsOverwriteByOneLine_Test extends AbstractPasteCellsOverwriteTest { + + /** + * Constructor. + */ + public PasteCellsOverwriteByOneLine_Test() { + super(); + } + + /** + * Manage the selection with the shift key. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + super.manageSelection(manager); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectCellCommand(manager.getBodyLayerStack().getSelectionLayer(), 2, 2, true, false)); + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteCellsOverwriteFailColumns_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteCellsOverwriteFailColumns_Test.java new file mode 100644 index 00000000000..f6baaebcc0b --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteCellsOverwriteFailColumns_Test.java @@ -0,0 +1,56 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.nattable.messages.Messages; +import org.junit.Assert; + +/** + * Test pastes overwrite when the number of columns to paste is not equals to the number of columns selected. + */ +public class PasteCellsOverwriteFailColumns_Test extends AbstractPasteCellsOverwriteTest { + + /** + * Constructor. + */ + public PasteCellsOverwriteFailColumns_Test() { + super(); + } + + /** + * Manage the selection with the shift key. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + super.manageSelection(manager); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectCellCommand(manager.getBodyLayerStack().getSelectionLayer(), 1, 2, true, false)); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#checkReturned_Status(org.eclipse.core.runtime.IStatus) + */ + @Override + protected void checkReturned_Status(final IStatus status) { + Assert.assertEquals("Error must be caught", IStatus.ERROR, status.getSeverity()); //$NON-NLS-1$ + Assert.assertEquals("Error message is not the expected message", Messages.AbstractPasteInSelectionNattableCommandProvider_readcolumnsexceedsexistingcolumns, status.getMessage()); //$NON-NLS-1$ + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteCellsOverwriteFailRows_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteCellsOverwriteFailRows_Test.java new file mode 100644 index 00000000000..5562955bfad --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteCellsOverwriteFailRows_Test.java @@ -0,0 +1,57 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.nattable.messages.Messages; +import org.junit.Assert; + +/** + * Test pastes overwrite when the number of rows to paste is not equals to the number of rows selected. + */ +public class PasteCellsOverwriteFailRows_Test extends AbstractPasteCellsOverwriteTest { + + /** + * Constructor. + */ + public PasteCellsOverwriteFailRows_Test() { + super(); + } + + /** + * Manage the selection with the shift key. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + super.manageSelection(manager); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectCellCommand(manager.getBodyLayerStack().getSelectionLayer(), 2, 1, true, false)); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#checkReturned_Status(org.eclipse.core.runtime.IStatus) + */ + @Override + protected void checkReturned_Status(final IStatus status) { + Assert.assertEquals("Error must be caught", IStatus.ERROR, status.getSeverity()); //$NON-NLS-1$ + Assert.assertEquals("Error message is not the expected message", Messages.AbstractPasteInSelectionNattableCommandProvider_readrowsexceedsexistingrows, status.getMessage()); //$NON-NLS-1$ + } + +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteColumnsOverwriteAll_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteColumnsOverwriteAll_Test.java new file mode 100644 index 00000000000..ddd11bb39da --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteColumnsOverwriteAll_Test.java @@ -0,0 +1,43 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite; + +import org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand; +import org.eclipse.nebula.widgets.nattable.selection.command.SelectColumnCommand; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; + +/** + * Test pastes overwrite all of selection with hidden categories. + */ +public class PasteColumnsOverwriteAll_Test extends AbstractPasteColumnsOverwriteTest { + + /** + * Constructor. + */ + public PasteColumnsOverwriteAll_Test() { + super(); + } + + /** + * Manage the selection with the shift key. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + super.manageSelection(manager); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectColumnCommand(manager.getBodyLayerStack().getSelectionLayer(), 2, 0, true, false)); + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteColumnsOverwriteByOneLine_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteColumnsOverwriteByOneLine_Test.java new file mode 100644 index 00000000000..6540400fd9b --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteColumnsOverwriteByOneLine_Test.java @@ -0,0 +1,47 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite; + +import org.eclipse.nebula.widgets.nattable.NatTable; +import org.eclipse.nebula.widgets.nattable.selection.command.ClearAllSelectionsCommand; +import org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand; +import org.eclipse.nebula.widgets.nattable.selection.command.SelectColumnCommand; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; + +/** + * Test pastes overwrite all of selection with hidden categories when a single line is copied. + */ +public class PasteColumnsOverwriteByOneLine_Test extends AbstractPasteColumnsOverwriteTest { + + /** + * Constructor. + */ + public PasteColumnsOverwriteByOneLine_Test() { + super(); + } + + /** + * Manage the selection with the shift key. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + final NatTable natTable = (NatTable) manager.getAdapter(NatTable.class); + natTable.doCommand(new ClearAllSelectionsCommand()); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectColumnCommand(manager.getBodyLayerStack().getSelectionLayer(), 1, 0, false, false)); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectColumnCommand(manager.getBodyLayerStack().getSelectionLayer(), 2, 0, true, false)); + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteColumnsOverwriteFailColumns_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteColumnsOverwriteFailColumns_Test.java new file mode 100644 index 00000000000..cd7f5820430 --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteColumnsOverwriteFailColumns_Test.java @@ -0,0 +1,57 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand; +import org.eclipse.nebula.widgets.nattable.selection.command.SelectColumnCommand; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.nattable.messages.Messages; +import org.junit.Assert; + +/** + * Test pastes overwrite when the number of columns to paste is not equals to the number of columns selected. + */ +public class PasteColumnsOverwriteFailColumns_Test extends AbstractPasteColumnsOverwriteTest { + + /** + * Constructor. + */ + public PasteColumnsOverwriteFailColumns_Test() { + super(); + } + + /** + * Manage the selection with the shift key. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + super.manageSelection(manager); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectColumnCommand(manager.getBodyLayerStack().getSelectionLayer(), 1, 0, true, false)); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#checkReturned_Status(org.eclipse.core.runtime.IStatus) + */ + @Override + protected void checkReturned_Status(final IStatus status) { + Assert.assertEquals("Error must be caught", IStatus.ERROR, status.getSeverity()); //$NON-NLS-1$ + Assert.assertEquals("Error message is not the expected message", Messages.AbstractPasteInSelectionNattableCommandProvider_readcolumnsexceedsexistingcolumns, status.getMessage()); //$NON-NLS-1$ + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteColumnsOverwriteFailRows_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteColumnsOverwriteFailRows_Test.java new file mode 100644 index 00000000000..aaaee86fc5f --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteColumnsOverwriteFailRows_Test.java @@ -0,0 +1,58 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand; +import org.eclipse.nebula.widgets.nattable.selection.command.SelectColumnCommand; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.nattable.messages.Messages; +import org.junit.Assert; + +/** + * Test pastes overwrite when the number of rows to paste is not equals to the number of rows selected. + */ +public class PasteColumnsOverwriteFailRows_Test extends AbstractPasteColumnsOverwriteTest { + + /** + * Constructor. + */ + public PasteColumnsOverwriteFailRows_Test() { + super(); + } + + /** + * Manage the selection with the shift key. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + super.manageSelection(manager); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectColumnCommand(manager.getBodyLayerStack().getSelectionLayer(), 2, 0, true, false)); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#checkReturned_Status(org.eclipse.core.runtime.IStatus) + */ + @Override + protected void checkReturned_Status(final IStatus status) { + Assert.assertEquals("Error must be caught", IStatus.ERROR, status.getSeverity()); //$NON-NLS-1$ + Assert.assertEquals("Error message is not the expected message", Messages.AbstractPasteInSelectionNattableCommandProvider_readrowsexceedsexistingrows, status.getMessage()); //$NON-NLS-1$ + } + +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteEmptyOverwriteAddAll_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteEmptyOverwriteAddAll_Test.java new file mode 100644 index 00000000000..576f3191021 --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteEmptyOverwriteAddAll_Test.java @@ -0,0 +1,57 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite; + +import java.util.Map; + +import org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand; +import org.eclipse.papyrus.infra.nattable.handler.InsertInTableHandler; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.nattable.utils.UserActionConstants; + +/** + * Test pastes overwrite all of selection with hidden categories. + */ +public class PasteEmptyOverwriteAddAll_Test extends AbstractPasteEmptyOverwriteTest { + + /** + * Constructor. + */ + public PasteEmptyOverwriteAddAll_Test() { + super(); + } + + /** + * Manage the selection with the shift key. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + super.manageSelection(manager); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectRowsCommand(manager.getBodyLayerStack().getSelectionLayer(), 0, 2, true, false)); + } + + /** + * @see org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite.AbstractPasteEmptyOverwriteTest#manageParameters(java.util.Map) + * + * @param parameters + */ + @Override + public void manageParameters(Map<Object, Object> parameters) { + super.manageParameters(parameters); + parameters.put(InsertInTableHandler.USER_ACTION__PREFERRED_USER_ACTION, UserActionConstants.ADD_USER_ACTION); + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteEmptyOverwriteAxisIdentifierNotExisting_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteEmptyOverwriteAxisIdentifierNotExisting_Test.java new file mode 100644 index 00000000000..7627c8e3aca --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteEmptyOverwriteAxisIdentifierNotExisting_Test.java @@ -0,0 +1,59 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.MultiStatus; +import org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.nattable.messages.Messages; +import org.junit.Assert; + +/** + * Test pastes overwrite all of selection with hidden categories. + */ +public class PasteEmptyOverwriteAxisIdentifierNotExisting_Test extends AbstractPasteEmptyOverwriteTest { + + /** + * Constructor. + */ + public PasteEmptyOverwriteAxisIdentifierNotExisting_Test() { + super(); + } + + /** + * Manage the selection with the shift key. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + super.manageSelection(manager); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectRowsCommand(manager.getBodyLayerStack().getSelectionLayer(), 0, 2, true, false)); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#checkReturned_Status(org.eclipse.core.runtime.IStatus) + */ + @Override + protected void checkReturned_Status(final IStatus status) { + Assert.assertEquals("Error must be caught", IStatus.ERROR, status.getSeverity()); //$NON-NLS-1$ + Assert.assertEquals("Error message is not the expected message", Messages.AbstractPasteInSelectionNattableCommandProvider_ThePasteHasNotBeenDoneBecauseOfSomeProblems, status.getMessage()); //$NON-NLS-1$ + Assert.assertTrue("Status must be a multi-status", status instanceof MultiStatus); //$NON-NLS-1$ + Assert.assertEquals("Error message is not the expected message", Messages.AbstractPasteInSelectionNattableCommandProvider_TheAxisUsedAsIdentifierNotAvailable, ((MultiStatus)status).getChildren()[0].getMessage()); //$NON-NLS-1$ + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteEmptyOverwriteFailColumns_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteEmptyOverwriteFailColumns_Test.java new file mode 100644 index 00000000000..6e39521a9b4 --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteEmptyOverwriteFailColumns_Test.java @@ -0,0 +1,56 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.nattable.messages.Messages; +import org.junit.Assert; + +/** + * Test pastes overwrite when the number of columns to paste is not equals to the number of columns selected. + */ +public class PasteEmptyOverwriteFailColumns_Test extends AbstractPasteEmptyOverwriteTest { + + /** + * Constructor. + */ + public PasteEmptyOverwriteFailColumns_Test() { + super(); + } + + /** + * Manage the selection with the shift key. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + super.manageSelection(manager); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectRowsCommand(manager.getBodyLayerStack().getSelectionLayer(), 0, 2, true, false)); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#checkReturned_Status(org.eclipse.core.runtime.IStatus) + */ + @Override + protected void checkReturned_Status(final IStatus status) { + Assert.assertEquals("Error must be caught", IStatus.ERROR, status.getSeverity()); //$NON-NLS-1$ + Assert.assertEquals("Error message is not the expected message", Messages.AbstractPasteInSelectionNattableCommandProvider_readcolumnsexceedsexistingcolumns, status.getMessage()); //$NON-NLS-1$ + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteEmptyOverwriteReplaceAll_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteEmptyOverwriteReplaceAll_Test.java new file mode 100644 index 00000000000..e68e544b934 --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteEmptyOverwriteReplaceAll_Test.java @@ -0,0 +1,57 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite; + +import java.util.Map; + +import org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand; +import org.eclipse.papyrus.infra.nattable.handler.InsertInTableHandler; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.nattable.utils.UserActionConstants; + +/** + * Test pastes overwrite all of selection with hidden categories. + */ +public class PasteEmptyOverwriteReplaceAll_Test extends AbstractPasteEmptyOverwriteTest { + + /** + * Constructor. + */ + public PasteEmptyOverwriteReplaceAll_Test() { + super(); + } + + /** + * Manage the selection with the shift key. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + super.manageSelection(manager); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectRowsCommand(manager.getBodyLayerStack().getSelectionLayer(), 0, 2, true, false)); + } + + /** + * @see org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite.AbstractPasteEmptyOverwriteTest#manageParameters(java.util.Map) + * + * @param parameters + */ + @Override + public void manageParameters(Map<Object, Object> parameters) { + super.manageParameters(parameters); + parameters.put(InsertInTableHandler.USER_ACTION__PREFERRED_USER_ACTION, UserActionConstants.REPLACE_USER_ACTION); + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteEmptyOverwriteSkipAll_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteEmptyOverwriteSkipAll_Test.java new file mode 100644 index 00000000000..a6f340b45bf --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteEmptyOverwriteSkipAll_Test.java @@ -0,0 +1,68 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite; + +import java.util.Map; + +import org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand; +import org.eclipse.papyrus.infra.nattable.handler.InsertInTableHandler; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.nattable.utils.UserActionConstants; + +/** + * Test pastes overwrite all of selection with hidden categories. + */ +public class PasteEmptyOverwriteSkipAll_Test extends AbstractPasteEmptyOverwriteTest { + + /** + * Constructor. + */ + public PasteEmptyOverwriteSkipAll_Test() { + super(); + } + + /** + * Manage the selection with the shift key. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + super.manageSelection(manager); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectRowsCommand(manager.getBodyLayerStack().getSelectionLayer(), 0, 2, true, false)); + } + + /** + * @see org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite.AbstractPasteEmptyOverwriteTest#manageParameters(java.util.Map) + * + * @param parameters + */ + @Override + public void manageParameters(Map<Object, Object> parameters) { + super.manageParameters(parameters); + parameters.put(InsertInTableHandler.USER_ACTION__PREFERRED_USER_ACTION, UserActionConstants.SKIP_USER_ACTION); + } + + /** + * @see org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite.AbstractPasteInsertTest#testUndo_Redo(org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager) + * + * @param treeManager + * @throws Exception + */ + @Override + protected void testUndo_Redo(NattableModelManager treeManager) throws Exception { + // Do nothing + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteEmptyOverwriteWarningNotExisting_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteEmptyOverwriteWarningNotExisting_Test.java new file mode 100644 index 00000000000..e7e5d73bf11 --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteEmptyOverwriteWarningNotExisting_Test.java @@ -0,0 +1,59 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.MultiStatus; +import org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.nattable.messages.Messages; +import org.junit.Assert; + +/** + * Test pastes overwrite all of selection with hidden categories. + */ +public class PasteEmptyOverwriteWarningNotExisting_Test extends AbstractPasteEmptyOverwriteTest { + + /** + * Constructor. + */ + public PasteEmptyOverwriteWarningNotExisting_Test() { + super(); + } + + /** + * Manage the selection with the shift key. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + super.manageSelection(manager); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectRowsCommand(manager.getBodyLayerStack().getSelectionLayer(), 0, 2, true, false)); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#checkReturned_Status(org.eclipse.core.runtime.IStatus) + */ + @Override + protected void checkReturned_Status(final IStatus status) { + Assert.assertEquals("Warning must be caught", IStatus.WARNING, status.getSeverity()); //$NON-NLS-1$ + Assert.assertEquals("Warning message is not the expected message", Messages.AbstractPasteInSelectionNattableCommandProvider_ThePasteHasBeenDoneWithSomeProblems, status.getMessage()); //$NON-NLS-1$ + Assert.assertTrue("Status must be a multi-status", status instanceof MultiStatus); //$NON-NLS-1$ + Assert.assertEquals("Warning message is not the expected message", "The identifier 'Class2' was not found in the selection", ((MultiStatus)status).getChildren()[0].getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteRowsOverwriteAll_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteRowsOverwriteAll_Test.java new file mode 100644 index 00000000000..36b3ccbd5a0 --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteRowsOverwriteAll_Test.java @@ -0,0 +1,42 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite; + +import org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; + +/** + * Test pastes overwrite all of selection with hidden categories. + */ +public class PasteRowsOverwriteAll_Test extends AbstractPasteRowsOverwriteTest { + + /** + * Constructor. + */ + public PasteRowsOverwriteAll_Test() { + super(); + } + + /** + * Manage the selection with the shift key. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + super.manageSelection(manager); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectRowsCommand(manager.getBodyLayerStack().getSelectionLayer(), 0, 2, true, false)); + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteRowsOverwriteAxisIdentifierNotExisting_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteRowsOverwriteAxisIdentifierNotExisting_Test.java new file mode 100644 index 00000000000..84236acd71d --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteRowsOverwriteAxisIdentifierNotExisting_Test.java @@ -0,0 +1,59 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.MultiStatus; +import org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.nattable.messages.Messages; +import org.junit.Assert; + +/** + * Test pastes overwrite all of selection with hidden categories. + */ +public class PasteRowsOverwriteAxisIdentifierNotExisting_Test extends AbstractPasteRowsOverwriteTest { + + /** + * Constructor. + */ + public PasteRowsOverwriteAxisIdentifierNotExisting_Test() { + super(); + } + + /** + * Manage the selection with the shift key. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + super.manageSelection(manager); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectRowsCommand(manager.getBodyLayerStack().getSelectionLayer(), 0, 2, true, false)); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#checkReturned_Status(org.eclipse.core.runtime.IStatus) + */ + @Override + protected void checkReturned_Status(final IStatus status) { + Assert.assertEquals("Error must be caught", IStatus.ERROR, status.getSeverity()); //$NON-NLS-1$ + Assert.assertEquals("Error message is not the expected message", Messages.AbstractPasteInSelectionNattableCommandProvider_ThePasteHasNotBeenDoneBecauseOfSomeProblems, status.getMessage()); //$NON-NLS-1$ + Assert.assertTrue("Status must be a multi-status", status instanceof MultiStatus); //$NON-NLS-1$ + Assert.assertEquals("Error message is not the expected message", Messages.AbstractPasteInSelectionNattableCommandProvider_TheAxisUsedAsIdentifierNotAvailable, ((MultiStatus)status).getChildren()[0].getMessage()); //$NON-NLS-1$ + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteRowsOverwriteFailColumns_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteRowsOverwriteFailColumns_Test.java new file mode 100644 index 00000000000..c6c07a0a370 --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteRowsOverwriteFailColumns_Test.java @@ -0,0 +1,56 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.nattable.messages.Messages; +import org.junit.Assert; + +/** + * Test pastes overwrite when the number of columns to paste is not equals to the number of columns selected. + */ +public class PasteRowsOverwriteFailColumns_Test extends AbstractPasteRowsOverwriteTest { + + /** + * Constructor. + */ + public PasteRowsOverwriteFailColumns_Test() { + super(); + } + + /** + * Manage the selection with the shift key. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + super.manageSelection(manager); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectRowsCommand(manager.getBodyLayerStack().getSelectionLayer(), 0, 2, true, false)); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#checkReturned_Status(org.eclipse.core.runtime.IStatus) + */ + @Override + protected void checkReturned_Status(final IStatus status) { + Assert.assertEquals("Error must be caught", IStatus.ERROR, status.getSeverity()); //$NON-NLS-1$ + Assert.assertEquals("Error message is not the expected message", Messages.AbstractPasteInSelectionNattableCommandProvider_readcolumnsexceedsexistingcolumns, status.getMessage()); //$NON-NLS-1$ + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteRowsOverwriteFailRows_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteRowsOverwriteFailRows_Test.java new file mode 100644 index 00000000000..6cb3f617572 --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteRowsOverwriteFailRows_Test.java @@ -0,0 +1,57 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.nattable.messages.Messages; +import org.junit.Assert; + +/** + * Test pastes overwrite when the number of rows to paste is not equals to the number of rows selected. + */ +public class PasteRowsOverwriteFailRows_Test extends AbstractPasteRowsOverwriteTest { + + /** + * Constructor. + */ + public PasteRowsOverwriteFailRows_Test() { + super(); + } + + /** + * Manage the selection with the shift key. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + super.manageSelection(manager); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectRowsCommand(manager.getBodyLayerStack().getSelectionLayer(), 0, 1, true, false)); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#checkReturned_Status(org.eclipse.core.runtime.IStatus) + */ + @Override + protected void checkReturned_Status(final IStatus status) { + Assert.assertEquals("Error must be caught", IStatus.ERROR, status.getSeverity()); //$NON-NLS-1$ + Assert.assertEquals("Error message is not the expected message", Messages.AbstractPasteInSelectionNattableCommandProvider_readrowsexceedsexistingrows, status.getMessage()); //$NON-NLS-1$ + } + +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteRowsOverwriteWarningNotExisting_Test.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteRowsOverwriteWarningNotExisting_Test.java new file mode 100644 index 00000000000..1bc17741166 --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/overwrite/PasteRowsOverwriteWarningNotExisting_Test.java @@ -0,0 +1,59 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.MultiStatus; +import org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.nattable.messages.Messages; +import org.junit.Assert; + +/** + * Test pastes overwrite all of selection with hidden categories. + */ +public class PasteRowsOverwriteWarningNotExisting_Test extends AbstractPasteRowsOverwriteTest { + + /** + * Constructor. + */ + public PasteRowsOverwriteWarningNotExisting_Test() { + super(); + } + + /** + * Manage the selection with the shift key. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#manageSelection(org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager) + */ + @Override + public void manageSelection(final NattableModelManager manager) throws Exception { + super.manageSelection(manager); + manager.getBodyLayerStack().getSelectionLayer().doCommand(new SelectRowsCommand(manager.getBodyLayerStack().getSelectionLayer(), 0, 2, true, false)); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.overwrite.AbstractPasteOverwriteTest#checkReturned_Status(org.eclipse.core.runtime.IStatus) + */ + @Override + protected void checkReturned_Status(final IStatus status) { + Assert.assertEquals("Warning must be caught", IStatus.WARNING, status.getSeverity()); //$NON-NLS-1$ + Assert.assertEquals("Warning message is not the expected message", Messages.AbstractPasteInSelectionNattableCommandProvider_ThePasteHasBeenDoneWithSomeProblems, status.getMessage()); //$NON-NLS-1$ + Assert.assertTrue("Status must be a multi-status", status instanceof MultiStatus); //$NON-NLS-1$ + Assert.assertEquals("Warning message is not the expected message", "The identifier 'Class2' was not found in the selection", ((MultiStatus)status).getChildren()[0].getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/without/service/edit/AbstractPasteTests.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/without/service/edit/AbstractPasteTests.java index f6fd94403c5..ef67f3ccee0 100644 --- a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/without/service/edit/AbstractPasteTests.java +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/without/service/edit/AbstractPasteTests.java @@ -1,666 +1,666 @@ -/*****************************************************************************
- * Copyright (c) 2014 CEA LIST and others.
- *
- * 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:
- * CEA LIST - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.without.service.edit;
-
-import java.awt.Toolkit;
-import java.awt.datatransfer.StringSelection;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.commands.Command;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.nattable.common.editor.NatTableEditor;
-import org.eclipse.papyrus.infra.nattable.handler.PasteInTableHandler;
-import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
-import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.EObjectTreeItemAxis;
-import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.ITreeItemAxis;
-import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.IPasteConfiguration;
-import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.NattableaxisconfigurationPackage;
-import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.TreeFillingConfiguration;
-import org.eclipse.papyrus.infra.nattable.utils.AxisConfigurationUtils;
-import org.eclipse.papyrus.infra.nattable.utils.AxisUtils;
-import org.eclipse.papyrus.infra.tools.util.EclipseCommandUtils;
-import org.eclipse.papyrus.infra.tools.util.FileUtils;
-import org.eclipse.papyrus.junit.framework.classification.InvalidTest;
-import org.eclipse.papyrus.junit.utils.EditorUtils;
-import org.eclipse.papyrus.junit.utils.GenericUtils;
-import org.eclipse.papyrus.junit.utils.PapyrusProjectUtils;
-import org.eclipse.papyrus.junit.utils.ProjectUtils;
-import org.eclipse.papyrus.sysml.nattable.requirement.tests.Activator;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.commands.ICommandService;
-import org.eclipse.uml2.uml.Class;
-import org.eclipse.uml2.uml.EnumerationLiteral;
-import org.eclipse.uml2.uml.NamedElement;
-import org.eclipse.uml2.uml.Operation;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.Parameter;
-import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.Stereotype;
-import org.eclipse.uml2.uml.UMLPackage;
-import org.eclipse.uml2.uml.VisibilityKind;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-
-/**
- * @author VL222926
- *
- */
-public abstract class AbstractPasteTests extends AbstractOpenTableTest {
-
- public static final String PASTE_FOLDER_PATH = "/resources/paste_tests/"; //$NON-NLS-1$
-
- public static final String OPERATION_BASE_NAME = "Operation"; //$NON-NLS-1$
-
- public static final String PARAMETER_BASE_NAME = "Param"; //$NON-NLS-1$
-
- public static final String PROPERTY_BASE_NAME = "Property"; //$NON-NLS-1$
-
- public static final String CLASS_BASE_NAME = "Class"; //$NON-NLS-1$
-
- public static final String NESTED_CLASS_BASE_NAME = "NestedClass"; //$NON-NLS-1$
-
- public static final String CLASS_ELEMENT_ID = "org.eclipse.papyrus.uml.Class"; //$NON-NLS-1$
- public static final String OPERATION_ELEMENT_ID = "org.eclipse.papyrus.uml.Operation"; //$NON-NLS-1$
- public static final String PARAMETER_ELEMENT_ID = "org.eclipse.papyrus.uml.Parameter"; //$NON-NLS-1$
- public static final String PROPERTY_ELEMENT_ID = "org.eclipse.papyrus.uml.Property"; //$NON-NLS-1$
-
-
- @Before
- public void initModel() throws Exception {
- initModel("requirementTable", getClass().getSimpleName(), getBundle()); //$NON-NLS-1$
- };
-
- /**
- * Inits this.editor
- * Fails or throws an exception if an error occurs
- *
- * @param bundle
- * the source bundle where the model is store
- * @param projectName
- * the project that will created at runtime to execute test
- * @param modelName
- * the model that will be copied and test executed on.
- */
- protected void initModel(String projectName, String modelName, Bundle bundle) throws Exception {
- project = ProjectUtils.createProject(projectName);
- final IFile project1 = PapyrusProjectUtils.copyPapyrusModel(project, bundle, getSourcePath(), "library"); //$NON-NLS-1$
- Display.getDefault().syncExec(new Runnable() {
-
- public void run() {
- try {
- editor = EditorUtils.openPapyrusEditor(project1);
- } catch (Exception ex) {
- Activator.log.error(ex);
- Assert.fail(ex.getMessage());
- }
- }
- });
-
- final IFile porject2 = PapyrusProjectUtils.copyPapyrusModel(project, bundle, getSourcePath(), "model.profile"); //$NON-NLS-1$
- Display.getDefault().syncExec(new Runnable() {
-
- public void run() {
- try {
- editor = EditorUtils.openPapyrusEditor(porject2);
- } catch (Exception ex) {
- Activator.log.error(ex);
- Assert.fail(ex.getMessage());
- }
- }
- });
-
- this.diModelFile = PapyrusProjectUtils.copyPapyrusModel(project, bundle, getSourcePath(), modelName);
- Display.getDefault().syncExec(new Runnable() {
-
- public void run() {
- try {
- editor = EditorUtils.openPapyrusEditor(diModelFile);
- } catch (Exception ex) {
- Activator.log.error(ex);
- Assert.fail(ex.getMessage());
- }
- }
- });
-
- Assert.assertNotNull(editor);
- }
-
-
- protected INattableModelManager getTableManager() {
- IEditorPart tableEditor = editor.getActiveEditor();
- Assert.assertTrue(tableEditor instanceof NatTableEditor);
- INattableModelManager manager = (INattableModelManager) tableEditor.getAdapter(INattableModelManager.class);
- return manager;
- }
-
- /**
- *
- * @throws Exception
- */
- @Test
- public void checkModelForTestConsistency() throws Exception {
- Assert.assertTrue(!getTable().isInvertAxis());
- Assert.assertEquals(org.eclipse.papyrus.sysml.nattable.requirement.config.Activator.TABLE_TYPE, getTable().getTableConfiguration().getType());
- Assert.assertEquals(6, getTable().getCurrentColumnAxisProvider().getAxis().size());
- final IPasteConfiguration conf = (IPasteConfiguration) AxisConfigurationUtils.getIAxisConfigurationUsedInTable(getTable(), NattableaxisconfigurationPackage.eINSTANCE.getPasteEObjectConfiguration(), false);
- Assert.assertTrue(conf.isDetachedMode());
- }
-
- /**
- *
- * @throws Exception
- *
- * This method tests
- * <ul>
- * <li>the open of the table</li>
- * <li>the paste of the table (must be enabled)</li>
- * <li>the new contents of the semantic model</li>
- * <li>the expand (indirectly)</li>
- * <li>the final contents of the table (compared to the pasted string)</li>
- * </ul>
- */
- @Test
- public void testPaste() throws Exception {
- testOpenExistingTable("classTreeTable", " openTest"); //$NON-NLS-1$ //$NON-NLS-2$
- IEditorPart tableEditor = editor.getActiveEditor();
- Assert.assertTrue(tableEditor instanceof NatTableEditor);
- INattableModelManager manager = (INattableModelManager) tableEditor.getAdapter(INattableModelManager.class);
- // Assert.assertTrue(manager instanceof ITreeNattableModelManager);
-
- List<?> rowElements = manager.getRowElementsList();
- int size = rowElements.size();
- Assert.assertEquals(1, size);
-
- // fill the clipboard
- ICommandService commandService = EclipseCommandUtils.getCommandService();
- Assert.assertNotNull(commandService);
- String fileName = getPasteFileName();
- String str = FileUtils.getStringFromPlatformFile(Activator.PLUGIN_ID, getSourcePath(), fileName);
- fillClipboard(str);
-
- Command cmd = commandService.getCommand("org.eclipse.ui.edit.paste"); //$NON-NLS-1$
- IHandler handler = cmd.getHandler();
- Assert.assertTrue(handler.isEnabled());
-
-
- Map<Object, Object> parameters = new HashMap<Object, Object>();
- parameters.put(PasteInTableHandler.OPEN_DIALOG_ON_FAIL_BOOLEAN_PARAMETER, Boolean.FALSE);
- parameters.put(PasteInTableHandler.OPEN__PROGRESS_MONITOR_DIALOG, Boolean.FALSE);
- ExecutionEvent event = new ExecutionEvent(cmd, parameters, null, null);
- flushDisplayEvents();
- Object res = cmd.executeWithChecks(event);
- Assert.assertTrue(res instanceof IStatus);
- IStatus iStatus = (IStatus) res;
- validateReturnedStatus(iStatus);
- if (iStatus.isOK()) {
- verifyModelContents();
- checkTableDataStructure();
- checkCopyToClipboard(str);
- }
- }
-
- protected final void validateReturnedStatus(IStatus status) {
- Assert.assertTrue(status.isOK());
- }
-
- /**
- * This method verifies than the contents of the model is conform to the wanted result
- *
- * @throws Exception
- */
- protected final void verifyModelContents() throws Exception {
- // useful in detached mode to apply stereotype ?
- flushDisplayEvents();
-
- Package context = (Package) getTable().getContext();
- List<NamedElement> members = context.getOwnedMembers();
- Collection<Class> requirements = new HashSet<Class>();
- for (NamedElement member : members) {
- if (member instanceof Class) {
- checkClass((Class) member);
- requirements.add((Class) member);
- }
- }
-
-
- Assert.assertEquals(4, requirements.size());
- }
-
- public static final String REQUIREMENT1_NAME = "Requirement1"; //$NON-NLS-1$
- public static final String REQUIREMENT2_NAME = "Requirement2"; //$NON-NLS-1$
- public static final String REQUIREMENT3_NAME = "Requirement3"; //$NON-NLS-1$
-
- private boolean checkClassColor = false;
-
- @InvalidTest
- @Test
- public void testPasteCheckingColor() throws Exception {
- this.checkClassColor = true;
- testPaste();
- }
-
- protected void checkClass(Class clazz) throws Exception {
- String name = clazz.getName();
-
- Stereotype reqSte = clazz.getAppliedStereotype("SysML::Requirements::Requirement"); //$NON-NLS-1$
- Stereotype taskSte = clazz.getAppliedStereotype("profile::Task"); //$NON-NLS-1$
- Assert.assertNotNull(reqSte);
- Assert.assertNotNull(taskSte);
- String id = (String) clazz.getValue(reqSte, "id"); //$NON-NLS-1$
- String text = (String) clazz.getValue(reqSte, "text"); //$NON-NLS-1$
- Object priority = clazz.getValue(taskSte, "p"); //$NON-NLS-1$
-
- VisibilityKind visibility = clazz.getVisibility();
- Assert.assertNotNull(NLS.bind("priority is null for {0} ", clazz.getName()), priority);
-
- Assert.assertTrue(NLS.bind("Priority must be an instance of EnumerationLiteral, but it is an instance of {0}", priority.getClass().getName()), priority instanceof EnumerationLiteral);
- EnumerationLiteral priority2 = (EnumerationLiteral) priority;
- Object color = clazz.getValue(taskSte, "color"); //$NON-NLS-1$
- EnumerationLiteral color2 = null;
- if (this.checkClassColor) {
- Assert.assertTrue(NLS.bind("Color must be an instance of EnumerationLiteral, but it is an instance of {0}", color.getClass().getName()), color instanceof EnumerationLiteral);
- Assert.assertNotNull(NLS.bind("color is null for {0} ", clazz.getName()), color);
- color2 = (EnumerationLiteral) color;
- }
- if ("RequirementTest".equals(name)) { //$NON-NLS-1$
- // this is the initial requirement, available in the table
- Assert.assertTrue(id == null || id.isEmpty()); //$NON-NLS-1$
- Assert.assertTrue(text == null || text.isEmpty()); //$NON-NLS-1$
- Assert.assertEquals("medium", priority2.getName()); //$NON-NLS-1$
- if (this.checkClassColor) {
- Assert.assertEquals("red", color2.getName()); //$NON-NLS-1$
- }
- Assert.assertEquals(VisibilityKind.PROTECTED_LITERAL, visibility);
- } else if (REQUIREMENT1_NAME.equals(name)) {
- Assert.assertEquals("id1", id); //$NON-NLS-1$
- Assert.assertEquals("text1", text); //$NON-NLS-1$
- Assert.assertEquals("hight", priority2.getName()); //$NON-NLS-1$
- if (this.checkClassColor) {
- Assert.assertEquals("black", color2.getName()); //$NON-NLS-1$
- }
- Assert.assertEquals(VisibilityKind.PUBLIC_LITERAL, visibility);
- } else if (REQUIREMENT2_NAME.equals(name)) {
- Assert.assertEquals("id2", id); //$NON-NLS-1$
- Assert.assertEquals("text2", text); //$NON-NLS-1$
- Assert.assertEquals("medium", priority2.getName()); //$NON-NLS-1$
- if (this.checkClassColor) {
- Assert.assertEquals("red", color2.getName()); //$NON-NLS-1$
- }
- } else if (REQUIREMENT3_NAME.equals(name)) {
- Assert.assertEquals("id3", id); //$NON-NLS-1$
- Assert.assertEquals("text3", text); //$NON-NLS-1$
- Assert.assertEquals("low", priority2.getName()); //$NON-NLS-1$
- if (this.checkClassColor) {
- Assert.assertEquals("blue", color2.getName()); //$NON-NLS-1$
- }
- } else {
- throw new Exception("There is an error in the test"); //$NON-NLS-1$
- }
- }
-
- /**
- *
- * @param newClipBoardContents
- */
- protected void fillClipboard(String newClipBoardContents) {
-
- // its seems that the clipboard must be filled with the same way than we read it!
- java.awt.datatransfer.Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
- StringSelection s = new StringSelection(newClipBoardContents);
- clipboard.setContents(s, s);
- }
-
- protected void checkRootClasses(ITreeItemAxis root, EObject parent) {
- Object tmp = AxisUtils.getRepresentedElement(root);
- Assert.assertTrue(tmp instanceof Class);
- Class clazz = (Class) tmp;
- Assert.assertEquals(parent, clazz.eContainer());
-
- }
-
- protected void checkSynchronizedRoot(List<?> elements) throws ServiceException {
- Assert.assertEquals(1, elements.size());
- for (int i = 0; i < elements.size(); i++) {
- // we check the first level
- Object tmp = elements.get(0);
- Assert.assertTrue(tmp instanceof EObjectTreeItemAxis);
- EObjectTreeItemAxis root = (EObjectTreeItemAxis) tmp;
- tmp = AxisUtils.getRepresentedElement(root);
- Assert.assertTrue(tmp instanceof TreeFillingConfiguration);
- TreeFillingConfiguration fillingConf = (TreeFillingConfiguration) tmp;
- tmp = AxisUtils.getRepresentedElement(fillingConf.getAxisUsedAsAxisProvider());
- Assert.assertEquals(UMLPackage.eINSTANCE.getPackage_PackagedElement(), tmp);
-
-
-
-
- // we check the children : 2 classes
- List<ITreeItemAxis> classes = root.getChildren();
- Assert.assertEquals(2, classes.size());
- for (Object current : classes) {
- Assert.assertTrue(current instanceof ITreeItemAxis);
- ITreeItemAxis axis = (ITreeItemAxis) current;
- checkRootClasses(axis, getTable().getContext());
- }
- }
- }
-
- protected void checkDnDRoot(List<?> elements) throws ServiceException {
- Assert.assertEquals(2, elements.size());
- for (int i = 0; i < elements.size(); i++) {
- Object tmp = elements.get(i);
- Assert.assertTrue(tmp instanceof ITreeItemAxis);
- ITreeItemAxis axis = (ITreeItemAxis) tmp;
- checkRootClasses(axis, getTable().getContext());
- }
- }
-
- public void checkTableDataStructure() throws ServiceException {
- flushDisplayEvents();
- final INattableModelManager manager = (INattableModelManager) this.editor.getAdapter(INattableModelManager.class);
- List<Object> rows = manager.getRowElementsList();
- Assert.assertEquals(4, rows.size());
-
- // TODO : do the check using the clipboard
-
- // boolean tmp = true;
- // while (tmp) {
- // try {
- // tmp = Display.getDefault().readAndDispatch();
- // } catch (Exception e) {
- // Activator.log.error(e);
- // }
- // }
- // Display.getDefault().asyncExec(new Runnable() {
- //
- // @Override
- // public void run() {
- // // TODO Auto-generated method stub
- // ((NattableModelManager) manager).doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null);
- // }
- // });
- // while (tmp) {
- // try {
- // tmp = Display.getDefault().readAndDispatch();
- // } catch (Exception e) {
- // Activator.log.error(e);
- // }
- // }
- // List<?> elements = manager.getRowElementsList();
- //
- // String className = getClass().getSimpleName();
- // className = className.replaceFirst("PasteWithCategories_", ""); //$NON-NLS-1$ //$NON-NLS-2$
- // String[] result = className.split("_"); //$NON-NLS-1$
- // Assert.assertTrue(result.length == 5);
- // String first = result[0];
- // if ("Empty".equals(first)) { //$NON-NLS-1$
- // checkDnDRoot(elements);
- // } else {
- // checkSynchronizedRoot(elements);
- // }
- }
-
-
-
- protected void checkChildrenClasses(ITreeItemAxis axisRepresentingClass) throws Exception {
- List<ITreeItemAxis> axis = axisRepresentingClass.getChildren();
- Assert.assertEquals(3, axis.size());
- ITreeItemAxis propertyAxis = null;
- ITreeItemAxis operationAxis = null;
- ITreeItemAxis nestedClassAxis = null;
- Class clazz = (Class) AxisUtils.getRepresentedElement(axisRepresentingClass);
- for (ITreeItemAxis current : axis) {
- Object tmp = AxisUtils.getRepresentedElement(current);
- if (tmp == UMLPackage.eINSTANCE.getStructuredClassifier_OwnedAttribute()) {
- // property = true;
- propertyAxis = current;
- checkPropertyAxis(propertyAxis, clazz);
- }
- if (tmp == UMLPackage.eINSTANCE.getClass_OwnedOperation()) {
- // operation = true;
- operationAxis = current;
- checkOperationAxis(operationAxis, clazz);
- }
- if (tmp == UMLPackage.eINSTANCE.getClass_NestedClassifier()) {
- nestedClassAxis = current;
- checkNestedClassAxis(nestedClassAxis, clazz);
- // nestedClass = true;
- }
- }
-
- String className = getClass().getSimpleName();
- className = className.replaceFirst("PasteWithCategories_", ""); //$NON-NLS-1$ //$NON-NLS-2$
- String[] result = className.split("_"); //$NON-NLS-1$
- Assert.assertTrue(result.length == 5);
- String depth1 = result[1];
- if (depth1.endsWith("3")) { //$NON-NLS-1$
- Assert.assertNotNull(propertyAxis);
- Assert.assertNotNull(nestedClassAxis);
- Assert.assertNotNull(operationAxis);
-
- } else if (depth1.endsWith("1")) { //$NON-NLS-1$
- Assert.assertTrue(propertyAxis == null);
- Assert.assertTrue(nestedClassAxis == null);
- Assert.assertNotNull(operationAxis);
- } else {
- throw new Exception("We have an error in the tests"); //$NON-NLS-1$
- }
- }
-
- public void checkPropertyAxis(ITreeItemAxis propertyAxis, Class parent) {
- List<ITreeItemAxis> axis = propertyAxis.getChildren();
- Assert.assertEquals(3, axis.size());
- Set<Object> properties = new HashSet<Object>();
- for (ITreeItemAxis tmp : axis) {
- Assert.assertEquals(0, tmp.getChildren());
- Object representedElement = AxisUtils.getRepresentedElement(tmp);
- Assert.assertTrue(representedElement instanceof Property);
- Assert.assertTrue(((EObject) representedElement).eContainer() == parent);
- properties.add(representedElement);
- }
- // if not a property is marked several time has children of it parent itreeitemaxis
- Assert.assertEquals(3, properties.size());
- }
-
- public void checkNestedClassAxis(ITreeItemAxis nestedClassAxis, Class parent) {
- List<ITreeItemAxis> axis = nestedClassAxis.getChildren();
- Assert.assertEquals(3, axis.size());
- Set<Object> properties = new HashSet<Object>();
- for (ITreeItemAxis tmp : axis) {
- Assert.assertEquals(0, tmp.getChildren());
- Object representedElement = AxisUtils.getRepresentedElement(tmp);
- Assert.assertTrue(representedElement instanceof Class);
- Assert.assertTrue(((EObject) representedElement).eContainer() == parent);
- properties.add(representedElement);
- }
- // if not a property is marked several time has children of it parent itreeitemaxis
- Assert.assertEquals(3, properties.size());
-
- }
-
- public void checkOperationAxis(ITreeItemAxis operationAxis, Class parent) {
- List<ITreeItemAxis> axis = operationAxis.getChildren();
- Assert.assertEquals(3, axis.size());
- Set<Object> properties = new HashSet<Object>();
- for (ITreeItemAxis tmp : axis) {
- Assert.assertEquals(1, tmp.getChildren());
- ITreeItemAxis parameterAxis = tmp.getChildren().get(0);
- Assert.assertEquals(UMLPackage.eINSTANCE.getBehavioralFeature_OwnedParameter(), AxisUtils.getRepresentedElement(parameterAxis.getElement()));
- Object representedElement = AxisUtils.getRepresentedElement(tmp);
- Assert.assertTrue(representedElement instanceof Operation);
- Assert.assertTrue(((EObject) representedElement).eContainer() == parent);
- properties.add(representedElement);
- checkParameterAxis(parameterAxis, (Operation) representedElement);
- }
- // if not a property is marked several time has children of it parent itreeitemaxis
- Assert.assertEquals(3, properties.size());
- }
-
-
- public void checkParameterAxis(ITreeItemAxis parameterAxis, Operation parent) {
- List<ITreeItemAxis> axis = parameterAxis.getChildren();
- Assert.assertEquals(3, axis.size());
- Set<Object> parameters = new HashSet<Object>();
- for (ITreeItemAxis tmp : axis) {
- Assert.assertEquals(0, tmp.getChildren());
- Object representedElement = AxisUtils.getRepresentedElement(tmp);
- Assert.assertTrue(representedElement instanceof Parameter);
- Assert.assertTrue(((EObject) representedElement).eContainer() == parent);
- parameters.add(representedElement);
- }
- // if not a property is marked several time has children of it parent itreeitemaxis
- Assert.assertEquals(3, parameters.size());
- }
-
- public void verifyTableContents_1_1_1(List<?> elements) {
- Assert.assertEquals(1, elements.size());
- }
-
- /**
- * This method verify the general appearance of the table, currently it doesn't work, because the tree header are not included in the clipboard
- *
- * @param pastedString
- * @throws Exception
- */
- protected void checkCopyToClipboard(final String pastedString) throws Exception {
-
- if (true) {// TODO, fixme
- return;
- }
- // final INattableModelManager manager = (INattableModelManager) this.editor.getAdapter(INattableModelManager.class);
- //
- // boolean tmp = true;
- // while (tmp) {
- // try {
- // tmp = Display.getDefault().readAndDispatch();
- // } catch (Exception e) {
- // Activator.log.error(e);
- // }
- // }
- // Display.getDefault().asyncExec(new Runnable() {
- //
- // @Override
- // public void run() {
- // // TODO Auto-generated method stub
- // ((NattableModelManager) manager).doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null);
- // }
- // });
- // while (tmp) {
- // try {
- // tmp = Display.getDefault().readAndDispatch();
- // } catch (Exception e) {
- // Activator.log.error(e);
- // }
- // }
- // List<?> elements = manager.getRowElementsList();
- // Assert.assertTrue(" the list managing the rows in not a TreeList", elements instanceof TreeList<?>); //$NON-NLS-1$
- // Assert.assertEquals(2, elements.size());
- // String className = getClass().getSimpleName();
- // className = className.replaceFirst("PasteWithCategories_", ""); //$NON-NLS-1$ //$NON-NLS-2$
- // String[] result = className.split("_"); //$NON-NLS-1$
- // Assert.assertTrue(result.length == 5);
- // String depth1 = result[1];
- // // if (depth1.endsWith("3")) { //$NON-NLS-1$
- // // // verifyTableContents_1_3_1(elements);
- // // } else if (depth1.endsWith("1")) { //$NON-NLS-1$
- // // verifyTableContents_1_1_1(elements);
- // // } else {
- // // throw new Exception("We have an error in the tests"); //$NON-NLS-1$
- // // }
- //
- // // TODO N
- // // Assert.assertEquals(11, elements.size());
- //
- // manager.selectAll();
- // ((AbstractNattableWidgetManager) manager).copyToClipboard();
- //
- // String clipboardContents = TableClipboardUtils.getClipboardContentsAsString();
- // String fileName = getPasteFileName();
- //
- // // String pastedContents = FileUtils.getStringFromPlatformFile(Activator.PLUGIN_ID,get filePath, fileNameWithExtension)
- // int i = 0;
- // i++;
- //
- // StringReader clipboardReader = new StringReader(clipboardContents);
- // StringReader fileReader = new StringReader(pastedString);
- // CSVPasteHelper helperClipboard = new CSVPasteHelper();
- // CSVPasteHelper helperfile = new CSVPasteHelper();
- // CSVParser clipboardParser = helperClipboard.createParser(clipboardReader);
- // CSVParser fileParser = helperfile.createParser(fileReader);
- // RowIterator clipboardRowIter = clipboardParser.parse();
- // RowIterator fileRowIter = fileParser.parse();
- // // doesn't work because tree header are not in the clipboard
- // while (clipboardRowIter.hasNext()) {
- // Assert.assertEquals(fileRowIter.hasNext(), clipboardRowIter.hasNext());
- // CellIterator fileCellIterator = fileRowIter.next();
- // CellIterator clipboardCellIterator = clipboardRowIter.next();
- // while (clipboardCellIterator.hasNext()) {
- // Assert.assertEquals(fileCellIterator.hasNext(), clipboardCellIterator.hasNext());
- // String origin = fileCellIterator.next();
- // String current = clipboardCellIterator.next();
- //
- // // contains and not equals, because due to label provider, it could be different
- // Assert.assertTrue(current.contains(origin));
- // }
- // Assert.assertEquals(fileCellIterator.hasNext(), clipboardCellIterator.hasNext());
- // }
- // Assert.assertEquals(fileRowIter.hasNext(), clipboardRowIter.hasNext());
- }
-
- /**
- *
- * @return
- * the name of the paste file to use
- */
- protected String getPasteFileName() {
- StringBuilder builder = new StringBuilder(getClass().getSimpleName());
- builder.append(FileUtils.DOT_STRING);
- builder.append(FileUtils.TEXT_EXTENSION);
- return builder.toString();
- }
-
-
-
-
-
- @Override
- protected String getSourcePath() {
- return PASTE_FOLDER_PATH;
- }
-
- @Override
- protected Bundle getBundle() {
- return Activator.getDefault().getBundle();
- }
-
- @AfterClass
- public static void endOfTest() {
- GenericUtils.closeAllEditors();
- }
-}
+/***************************************************************************** + * Copyright (c) 2014 CEA LIST and others. + * + * 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: + * CEA LIST - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.without.service.edit; + +import java.awt.Toolkit; +import java.awt.datatransfer.StringSelection; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.eclipse.core.commands.Command; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.IHandler; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.osgi.util.NLS; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.nattable.common.editor.NatTableEditor; +import org.eclipse.papyrus.infra.nattable.handler.PasteInTableHandler; +import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager; +import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.EObjectTreeItemAxis; +import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.ITreeItemAxis; +import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.IPasteConfiguration; +import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.NattableaxisconfigurationPackage; +import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.TreeFillingConfiguration; +import org.eclipse.papyrus.infra.nattable.utils.AxisConfigurationUtils; +import org.eclipse.papyrus.infra.nattable.utils.AxisUtils; +import org.eclipse.papyrus.infra.tools.util.EclipseCommandUtils; +import org.eclipse.papyrus.infra.tools.util.FileUtils; +import org.eclipse.papyrus.junit.framework.classification.InvalidTest; +import org.eclipse.papyrus.junit.utils.EditorUtils; +import org.eclipse.papyrus.junit.utils.GenericUtils; +import org.eclipse.papyrus.junit.utils.PapyrusProjectUtils; +import org.eclipse.papyrus.junit.utils.ProjectUtils; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.Activator; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.commands.ICommandService; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.EnumerationLiteral; +import org.eclipse.uml2.uml.NamedElement; +import org.eclipse.uml2.uml.Operation; +import org.eclipse.uml2.uml.Package; +import org.eclipse.uml2.uml.Parameter; +import org.eclipse.uml2.uml.Property; +import org.eclipse.uml2.uml.Stereotype; +import org.eclipse.uml2.uml.UMLPackage; +import org.eclipse.uml2.uml.VisibilityKind; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.osgi.framework.Bundle; + +/** + * @author VL222926 + * + */ +public abstract class AbstractPasteTests extends AbstractOpenTableTest { + + public static final String PASTE_FOLDER_PATH = "/resources/paste_tests/"; //$NON-NLS-1$ + + public static final String OPERATION_BASE_NAME = "Operation"; //$NON-NLS-1$ + + public static final String PARAMETER_BASE_NAME = "Param"; //$NON-NLS-1$ + + public static final String PROPERTY_BASE_NAME = "Property"; //$NON-NLS-1$ + + public static final String CLASS_BASE_NAME = "Class"; //$NON-NLS-1$ + + public static final String NESTED_CLASS_BASE_NAME = "NestedClass"; //$NON-NLS-1$ + + public static final String CLASS_ELEMENT_ID = "org.eclipse.papyrus.uml.Class"; //$NON-NLS-1$ + public static final String OPERATION_ELEMENT_ID = "org.eclipse.papyrus.uml.Operation"; //$NON-NLS-1$ + public static final String PARAMETER_ELEMENT_ID = "org.eclipse.papyrus.uml.Parameter"; //$NON-NLS-1$ + public static final String PROPERTY_ELEMENT_ID = "org.eclipse.papyrus.uml.Property"; //$NON-NLS-1$ + + + @Before + public void initModel() throws Exception { + initModel("requirementTable", getClass().getSimpleName(), getBundle()); //$NON-NLS-1$ + }; + + /** + * Inits this.editor + * Fails or throws an exception if an error occurs + * + * @param bundle + * the source bundle where the model is store + * @param projectName + * the project that will created at runtime to execute test + * @param modelName + * the model that will be copied and test executed on. + */ + protected void initModel(String projectName, String modelName, Bundle bundle) throws Exception { + project = ProjectUtils.createProject(projectName); + final IFile project1 = PapyrusProjectUtils.copyPapyrusModel(project, bundle, getSourcePath(), "library"); //$NON-NLS-1$ + Display.getDefault().syncExec(new Runnable() { + + public void run() { + try { + editor = EditorUtils.openPapyrusEditor(project1); + } catch (Exception ex) { + Activator.log.error(ex); + Assert.fail(ex.getMessage()); + } + } + }); + + final IFile porject2 = PapyrusProjectUtils.copyPapyrusModel(project, bundle, getSourcePath(), "model.profile"); //$NON-NLS-1$ + Display.getDefault().syncExec(new Runnable() { + + public void run() { + try { + editor = EditorUtils.openPapyrusEditor(porject2); + } catch (Exception ex) { + Activator.log.error(ex); + Assert.fail(ex.getMessage()); + } + } + }); + + this.diModelFile = PapyrusProjectUtils.copyPapyrusModel(project, bundle, getSourcePath(), modelName); + Display.getDefault().syncExec(new Runnable() { + + public void run() { + try { + editor = EditorUtils.openPapyrusEditor(diModelFile); + } catch (Exception ex) { + Activator.log.error(ex); + Assert.fail(ex.getMessage()); + } + } + }); + + Assert.assertNotNull(editor); + } + + + protected INattableModelManager getTableManager() { + IEditorPart tableEditor = editor.getActiveEditor(); + Assert.assertTrue(tableEditor instanceof NatTableEditor); + INattableModelManager manager = (INattableModelManager) tableEditor.getAdapter(INattableModelManager.class); + return manager; + } + + /** + * + * @throws Exception + */ + @Test + public void checkModelForTestConsistency() throws Exception { + Assert.assertTrue(!getTable().isInvertAxis()); + Assert.assertEquals(org.eclipse.papyrus.sysml.nattable.requirement.config.Activator.TABLE_TYPE, getTable().getTableConfiguration().getType()); + Assert.assertEquals(6, getTable().getCurrentColumnAxisProvider().getAxis().size()); + final IPasteConfiguration conf = (IPasteConfiguration) AxisConfigurationUtils.getIAxisConfigurationUsedInTable(getTable(), NattableaxisconfigurationPackage.eINSTANCE.getPasteEObjectConfiguration(), false); + Assert.assertTrue(conf.isDetachedMode()); + } + + /** + * + * @throws Exception + * + * This method tests + * <ul> + * <li>the open of the table</li> + * <li>the paste of the table (must be enabled)</li> + * <li>the new contents of the semantic model</li> + * <li>the expand (indirectly)</li> + * <li>the final contents of the table (compared to the pasted string)</li> + * </ul> + */ + @Test + public void testPaste() throws Exception { + testOpenExistingTable("classTreeTable", " openTest"); //$NON-NLS-1$ //$NON-NLS-2$ + IEditorPart tableEditor = editor.getActiveEditor(); + Assert.assertTrue(tableEditor instanceof NatTableEditor); + INattableModelManager manager = (INattableModelManager) tableEditor.getAdapter(INattableModelManager.class); + // Assert.assertTrue(manager instanceof ITreeNattableModelManager); + + List<?> rowElements = manager.getRowElementsList(); + int size = rowElements.size(); + Assert.assertEquals(1, size); + + // fill the clipboard + ICommandService commandService = EclipseCommandUtils.getCommandService(); + Assert.assertNotNull(commandService); + String fileName = getPasteFileName(); + String str = FileUtils.getStringFromPlatformFile(Activator.PLUGIN_ID, getSourcePath(), fileName); + fillClipboard(str); + + Command cmd = commandService.getCommand("org.eclipse.ui.edit.paste"); //$NON-NLS-1$ + IHandler handler = cmd.getHandler(); + Assert.assertTrue(handler.isEnabled()); + + + Map<Object, Object> parameters = new HashMap<Object, Object>(); + parameters.put(PasteInTableHandler.OPEN_DIALOG_ON_FAIL_BOOLEAN_PARAMETER, Boolean.FALSE); + parameters.put(PasteInTableHandler.OPEN__PROGRESS_MONITOR_DIALOG, Boolean.FALSE); + ExecutionEvent event = new ExecutionEvent(cmd, parameters, null, null); + flushDisplayEvents(); + Object res = cmd.executeWithChecks(event); + Assert.assertTrue(res instanceof IStatus); + IStatus iStatus = (IStatus) res; + validateReturnedStatus(iStatus); + if (iStatus.isOK()) { + verifyModelContents(); + checkTableDataStructure(); + checkCopyToClipboard(str); + } + } + + protected void validateReturnedStatus(IStatus status) { + Assert.assertTrue(status.isOK()); + } + + /** + * This method verifies than the contents of the model is conform to the wanted result + * + * @throws Exception + */ + protected final void verifyModelContents() throws Exception { + // useful in detached mode to apply stereotype ? + flushDisplayEvents(); + + Package context = (Package) getTable().getContext(); + List<NamedElement> members = context.getOwnedMembers(); + Collection<Class> requirements = new HashSet<Class>(); + for (NamedElement member : members) { + if (member instanceof Class) { + checkClass((Class) member); + requirements.add((Class) member); + } + } + + + Assert.assertEquals(4, requirements.size()); + } + + public static final String REQUIREMENT1_NAME = "Requirement1"; //$NON-NLS-1$ + public static final String REQUIREMENT2_NAME = "Requirement2"; //$NON-NLS-1$ + public static final String REQUIREMENT3_NAME = "Requirement3"; //$NON-NLS-1$ + + private boolean checkClassColor = false; + + @InvalidTest + @Test + public void testPasteCheckingColor() throws Exception { + this.checkClassColor = true; + testPaste(); + } + + protected void checkClass(Class clazz) throws Exception { + String name = clazz.getName(); + + Stereotype reqSte = clazz.getAppliedStereotype("SysML::Requirements::Requirement"); //$NON-NLS-1$ + Stereotype taskSte = clazz.getAppliedStereotype("profile::Task"); //$NON-NLS-1$ + Assert.assertNotNull(reqSte); + Assert.assertNotNull(taskSte); + String id = (String) clazz.getValue(reqSte, "id"); //$NON-NLS-1$ + String text = (String) clazz.getValue(reqSte, "text"); //$NON-NLS-1$ + Object priority = clazz.getValue(taskSte, "p"); //$NON-NLS-1$ + + VisibilityKind visibility = clazz.getVisibility(); + Assert.assertNotNull(NLS.bind("priority is null for {0} ", clazz.getName()), priority); + + Assert.assertTrue(NLS.bind("Priority must be an instance of EnumerationLiteral, but it is an instance of {0}", priority.getClass().getName()), priority instanceof EnumerationLiteral); + EnumerationLiteral priority2 = (EnumerationLiteral) priority; + Object color = clazz.getValue(taskSte, "color"); //$NON-NLS-1$ + EnumerationLiteral color2 = null; + if (this.checkClassColor) { + Assert.assertTrue(NLS.bind("Color must be an instance of EnumerationLiteral, but it is an instance of {0}", color.getClass().getName()), color instanceof EnumerationLiteral); + Assert.assertNotNull(NLS.bind("color is null for {0} ", clazz.getName()), color); + color2 = (EnumerationLiteral) color; + } + if ("RequirementTest".equals(name)) { //$NON-NLS-1$ + // this is the initial requirement, available in the table + Assert.assertTrue(id == null || id.isEmpty()); //$NON-NLS-1$ + Assert.assertTrue(text == null || text.isEmpty()); //$NON-NLS-1$ + Assert.assertEquals("medium", priority2.getName()); //$NON-NLS-1$ + if (this.checkClassColor) { + Assert.assertEquals("red", color2.getName()); //$NON-NLS-1$ + } + Assert.assertEquals(VisibilityKind.PROTECTED_LITERAL, visibility); + } else if (REQUIREMENT1_NAME.equals(name)) { + Assert.assertEquals("id1", id); //$NON-NLS-1$ + Assert.assertEquals("text1", text); //$NON-NLS-1$ + Assert.assertEquals("hight", priority2.getName()); //$NON-NLS-1$ + if (this.checkClassColor) { + Assert.assertEquals("black", color2.getName()); //$NON-NLS-1$ + } + Assert.assertEquals(VisibilityKind.PUBLIC_LITERAL, visibility); + } else if (REQUIREMENT2_NAME.equals(name)) { + Assert.assertEquals("id2", id); //$NON-NLS-1$ + Assert.assertEquals("text2", text); //$NON-NLS-1$ + Assert.assertEquals("medium", priority2.getName()); //$NON-NLS-1$ + if (this.checkClassColor) { + Assert.assertEquals("red", color2.getName()); //$NON-NLS-1$ + } + } else if (REQUIREMENT3_NAME.equals(name)) { + Assert.assertEquals("id3", id); //$NON-NLS-1$ + Assert.assertEquals("text3", text); //$NON-NLS-1$ + Assert.assertEquals("low", priority2.getName()); //$NON-NLS-1$ + if (this.checkClassColor) { + Assert.assertEquals("blue", color2.getName()); //$NON-NLS-1$ + } + } else { + throw new Exception("There is an error in the test"); //$NON-NLS-1$ + } + } + + /** + * + * @param newClipBoardContents + */ + protected void fillClipboard(String newClipBoardContents) { + + // its seems that the clipboard must be filled with the same way than we read it! + java.awt.datatransfer.Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + StringSelection s = new StringSelection(newClipBoardContents); + clipboard.setContents(s, s); + } + + protected void checkRootClasses(ITreeItemAxis root, EObject parent) { + Object tmp = AxisUtils.getRepresentedElement(root); + Assert.assertTrue(tmp instanceof Class); + Class clazz = (Class) tmp; + Assert.assertEquals(parent, clazz.eContainer()); + + } + + protected void checkSynchronizedRoot(List<?> elements) throws ServiceException { + Assert.assertEquals(1, elements.size()); + for (int i = 0; i < elements.size(); i++) { + // we check the first level + Object tmp = elements.get(0); + Assert.assertTrue(tmp instanceof EObjectTreeItemAxis); + EObjectTreeItemAxis root = (EObjectTreeItemAxis) tmp; + tmp = AxisUtils.getRepresentedElement(root); + Assert.assertTrue(tmp instanceof TreeFillingConfiguration); + TreeFillingConfiguration fillingConf = (TreeFillingConfiguration) tmp; + tmp = AxisUtils.getRepresentedElement(fillingConf.getAxisUsedAsAxisProvider()); + Assert.assertEquals(UMLPackage.eINSTANCE.getPackage_PackagedElement(), tmp); + + + + + // we check the children : 2 classes + List<ITreeItemAxis> classes = root.getChildren(); + Assert.assertEquals(2, classes.size()); + for (Object current : classes) { + Assert.assertTrue(current instanceof ITreeItemAxis); + ITreeItemAxis axis = (ITreeItemAxis) current; + checkRootClasses(axis, getTable().getContext()); + } + } + } + + protected void checkDnDRoot(List<?> elements) throws ServiceException { + Assert.assertEquals(2, elements.size()); + for (int i = 0; i < elements.size(); i++) { + Object tmp = elements.get(i); + Assert.assertTrue(tmp instanceof ITreeItemAxis); + ITreeItemAxis axis = (ITreeItemAxis) tmp; + checkRootClasses(axis, getTable().getContext()); + } + } + + public void checkTableDataStructure() throws ServiceException { + flushDisplayEvents(); + final INattableModelManager manager = (INattableModelManager) this.editor.getAdapter(INattableModelManager.class); + List<Object> rows = manager.getRowElementsList(); + Assert.assertEquals(4, rows.size()); + + // TODO : do the check using the clipboard + + // boolean tmp = true; + // while (tmp) { + // try { + // tmp = Display.getDefault().readAndDispatch(); + // } catch (Exception e) { + // Activator.log.error(e); + // } + // } + // Display.getDefault().asyncExec(new Runnable() { + // + // @Override + // public void run() { + // // TODO Auto-generated method stub + // ((NattableModelManager) manager).doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null); + // } + // }); + // while (tmp) { + // try { + // tmp = Display.getDefault().readAndDispatch(); + // } catch (Exception e) { + // Activator.log.error(e); + // } + // } + // List<?> elements = manager.getRowElementsList(); + // + // String className = getClass().getSimpleName(); + // className = className.replaceFirst("PasteWithCategories_", ""); //$NON-NLS-1$ //$NON-NLS-2$ + // String[] result = className.split("_"); //$NON-NLS-1$ + // Assert.assertTrue(result.length == 5); + // String first = result[0]; + // if ("Empty".equals(first)) { //$NON-NLS-1$ + // checkDnDRoot(elements); + // } else { + // checkSynchronizedRoot(elements); + // } + } + + + + protected void checkChildrenClasses(ITreeItemAxis axisRepresentingClass) throws Exception { + List<ITreeItemAxis> axis = axisRepresentingClass.getChildren(); + Assert.assertEquals(3, axis.size()); + ITreeItemAxis propertyAxis = null; + ITreeItemAxis operationAxis = null; + ITreeItemAxis nestedClassAxis = null; + Class clazz = (Class) AxisUtils.getRepresentedElement(axisRepresentingClass); + for (ITreeItemAxis current : axis) { + Object tmp = AxisUtils.getRepresentedElement(current); + if (tmp == UMLPackage.eINSTANCE.getStructuredClassifier_OwnedAttribute()) { + // property = true; + propertyAxis = current; + checkPropertyAxis(propertyAxis, clazz); + } + if (tmp == UMLPackage.eINSTANCE.getClass_OwnedOperation()) { + // operation = true; + operationAxis = current; + checkOperationAxis(operationAxis, clazz); + } + if (tmp == UMLPackage.eINSTANCE.getClass_NestedClassifier()) { + nestedClassAxis = current; + checkNestedClassAxis(nestedClassAxis, clazz); + // nestedClass = true; + } + } + + String className = getClass().getSimpleName(); + className = className.replaceFirst("PasteWithCategories_", ""); //$NON-NLS-1$ //$NON-NLS-2$ + String[] result = className.split("_"); //$NON-NLS-1$ + Assert.assertTrue(result.length == 5); + String depth1 = result[1]; + if (depth1.endsWith("3")) { //$NON-NLS-1$ + Assert.assertNotNull(propertyAxis); + Assert.assertNotNull(nestedClassAxis); + Assert.assertNotNull(operationAxis); + + } else if (depth1.endsWith("1")) { //$NON-NLS-1$ + Assert.assertTrue(propertyAxis == null); + Assert.assertTrue(nestedClassAxis == null); + Assert.assertNotNull(operationAxis); + } else { + throw new Exception("We have an error in the tests"); //$NON-NLS-1$ + } + } + + public void checkPropertyAxis(ITreeItemAxis propertyAxis, Class parent) { + List<ITreeItemAxis> axis = propertyAxis.getChildren(); + Assert.assertEquals(3, axis.size()); + Set<Object> properties = new HashSet<Object>(); + for (ITreeItemAxis tmp : axis) { + Assert.assertEquals(0, tmp.getChildren()); + Object representedElement = AxisUtils.getRepresentedElement(tmp); + Assert.assertTrue(representedElement instanceof Property); + Assert.assertTrue(((EObject) representedElement).eContainer() == parent); + properties.add(representedElement); + } + // if not a property is marked several time has children of it parent itreeitemaxis + Assert.assertEquals(3, properties.size()); + } + + public void checkNestedClassAxis(ITreeItemAxis nestedClassAxis, Class parent) { + List<ITreeItemAxis> axis = nestedClassAxis.getChildren(); + Assert.assertEquals(3, axis.size()); + Set<Object> properties = new HashSet<Object>(); + for (ITreeItemAxis tmp : axis) { + Assert.assertEquals(0, tmp.getChildren()); + Object representedElement = AxisUtils.getRepresentedElement(tmp); + Assert.assertTrue(representedElement instanceof Class); + Assert.assertTrue(((EObject) representedElement).eContainer() == parent); + properties.add(representedElement); + } + // if not a property is marked several time has children of it parent itreeitemaxis + Assert.assertEquals(3, properties.size()); + + } + + public void checkOperationAxis(ITreeItemAxis operationAxis, Class parent) { + List<ITreeItemAxis> axis = operationAxis.getChildren(); + Assert.assertEquals(3, axis.size()); + Set<Object> properties = new HashSet<Object>(); + for (ITreeItemAxis tmp : axis) { + Assert.assertEquals(1, tmp.getChildren()); + ITreeItemAxis parameterAxis = tmp.getChildren().get(0); + Assert.assertEquals(UMLPackage.eINSTANCE.getBehavioralFeature_OwnedParameter(), AxisUtils.getRepresentedElement(parameterAxis.getElement())); + Object representedElement = AxisUtils.getRepresentedElement(tmp); + Assert.assertTrue(representedElement instanceof Operation); + Assert.assertTrue(((EObject) representedElement).eContainer() == parent); + properties.add(representedElement); + checkParameterAxis(parameterAxis, (Operation) representedElement); + } + // if not a property is marked several time has children of it parent itreeitemaxis + Assert.assertEquals(3, properties.size()); + } + + + public void checkParameterAxis(ITreeItemAxis parameterAxis, Operation parent) { + List<ITreeItemAxis> axis = parameterAxis.getChildren(); + Assert.assertEquals(3, axis.size()); + Set<Object> parameters = new HashSet<Object>(); + for (ITreeItemAxis tmp : axis) { + Assert.assertEquals(0, tmp.getChildren()); + Object representedElement = AxisUtils.getRepresentedElement(tmp); + Assert.assertTrue(representedElement instanceof Parameter); + Assert.assertTrue(((EObject) representedElement).eContainer() == parent); + parameters.add(representedElement); + } + // if not a property is marked several time has children of it parent itreeitemaxis + Assert.assertEquals(3, parameters.size()); + } + + public void verifyTableContents_1_1_1(List<?> elements) { + Assert.assertEquals(1, elements.size()); + } + + /** + * This method verify the general appearance of the table, currently it doesn't work, because the tree header are not included in the clipboard + * + * @param pastedString + * @throws Exception + */ + protected void checkCopyToClipboard(final String pastedString) throws Exception { + + if (true) {// TODO, fixme + return; + } + // final INattableModelManager manager = (INattableModelManager) this.editor.getAdapter(INattableModelManager.class); + // + // boolean tmp = true; + // while (tmp) { + // try { + // tmp = Display.getDefault().readAndDispatch(); + // } catch (Exception e) { + // Activator.log.error(e); + // } + // } + // Display.getDefault().asyncExec(new Runnable() { + // + // @Override + // public void run() { + // // TODO Auto-generated method stub + // ((NattableModelManager) manager).doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null); + // } + // }); + // while (tmp) { + // try { + // tmp = Display.getDefault().readAndDispatch(); + // } catch (Exception e) { + // Activator.log.error(e); + // } + // } + // List<?> elements = manager.getRowElementsList(); + // Assert.assertTrue(" the list managing the rows in not a TreeList", elements instanceof TreeList<?>); //$NON-NLS-1$ + // Assert.assertEquals(2, elements.size()); + // String className = getClass().getSimpleName(); + // className = className.replaceFirst("PasteWithCategories_", ""); //$NON-NLS-1$ //$NON-NLS-2$ + // String[] result = className.split("_"); //$NON-NLS-1$ + // Assert.assertTrue(result.length == 5); + // String depth1 = result[1]; + // // if (depth1.endsWith("3")) { //$NON-NLS-1$ + // // // verifyTableContents_1_3_1(elements); + // // } else if (depth1.endsWith("1")) { //$NON-NLS-1$ + // // verifyTableContents_1_1_1(elements); + // // } else { + // // throw new Exception("We have an error in the tests"); //$NON-NLS-1$ + // // } + // + // // TODO N + // // Assert.assertEquals(11, elements.size()); + // + // manager.selectAll(); + // ((AbstractNattableWidgetManager) manager).copyToClipboard(); + // + // String clipboardContents = TableClipboardUtils.getClipboardContentsAsString(); + // String fileName = getPasteFileName(); + // + // // String pastedContents = FileUtils.getStringFromPlatformFile(Activator.PLUGIN_ID,get filePath, fileNameWithExtension) + // int i = 0; + // i++; + // + // StringReader clipboardReader = new StringReader(clipboardContents); + // StringReader fileReader = new StringReader(pastedString); + // CSVPasteHelper helperClipboard = new CSVPasteHelper(); + // CSVPasteHelper helperfile = new CSVPasteHelper(); + // CSVParser clipboardParser = helperClipboard.createParser(clipboardReader); + // CSVParser fileParser = helperfile.createParser(fileReader); + // RowIterator clipboardRowIter = clipboardParser.parse(); + // RowIterator fileRowIter = fileParser.parse(); + // // doesn't work because tree header are not in the clipboard + // while (clipboardRowIter.hasNext()) { + // Assert.assertEquals(fileRowIter.hasNext(), clipboardRowIter.hasNext()); + // CellIterator fileCellIterator = fileRowIter.next(); + // CellIterator clipboardCellIterator = clipboardRowIter.next(); + // while (clipboardCellIterator.hasNext()) { + // Assert.assertEquals(fileCellIterator.hasNext(), clipboardCellIterator.hasNext()); + // String origin = fileCellIterator.next(); + // String current = clipboardCellIterator.next(); + // + // // contains and not equals, because due to label provider, it could be different + // Assert.assertTrue(current.contains(origin)); + // } + // Assert.assertEquals(fileCellIterator.hasNext(), clipboardCellIterator.hasNext()); + // } + // Assert.assertEquals(fileRowIter.hasNext(), clipboardRowIter.hasNext()); + } + + /** + * + * @return + * the name of the paste file to use + */ + protected String getPasteFileName() { + StringBuilder builder = new StringBuilder(getClass().getSimpleName()); + builder.append(FileUtils.DOT_STRING); + builder.append(FileUtils.TEXT_EXTENSION); + return builder.toString(); + } + + + + + + @Override + protected String getSourcePath() { + return PASTE_FOLDER_PATH; + } + + @Override + protected Bundle getBundle() { + return Activator.getDefault().getBundle(); + } + + @AfterClass + public static void endOfTest() { + GenericUtils.closeAllEditors(); + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/without/service/edit/Bug443814_Enumeration.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/without/service/edit/Bug443814_Enumeration.java index 822611e90cc..cbe5c1cda10 100644 --- a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/without/service/edit/Bug443814_Enumeration.java +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/paste/without/service/edit/Bug443814_Enumeration.java @@ -1,162 +1,173 @@ -/*****************************************************************************
- * Copyright (c) 2014 CEA LIST and others.
- *
- * 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:
- * CEA LIST - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.without.service.edit;
-
-import java.util.List;
-
-import org.eclipse.emf.ecore.EEnum;
-import org.eclipse.emf.ecore.EEnumLiteral;
-import org.eclipse.papyrus.infra.emf.nattable.dataprovider.EEnumComboBoxDataProvider;
-import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis;
-import org.eclipse.papyrus.infra.nattable.utils.AxisUtils;
-import org.eclipse.papyrus.uml.nattable.dataprovider.UMLStereotypeSingleEnumerationComboBoxDataProvider;
-import org.eclipse.papyrus.uml.nattable.utils.UMLTableUtils;
-import org.eclipse.uml2.uml.UMLPackage;
-import org.eclipse.uml2.uml.VisibilityKind;
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * @author VL222926
- *
- */
-public class Bug443814_Enumeration extends AbstractPasteTests {
-
- /**
- * @see org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.without.service.edit.AbstractPasteTests#getSourcePath()
- *
- * @return
- */
- @Override
- protected String getSourcePath() {
- return "/resources/paste_tests/without_service_edit/bug443814/"; //$NON-NLS-1$
- }
-
- @Test
- public void availableColorTest() throws Exception {
-
- StringBuilder builder = new StringBuilder(UMLTableUtils.PROPERTY_OF_STEREOTYPE_PREFIX);
- builder.append("profile::Task::color"); //$NON-NLS-1$
- String wantedProperty = builder.toString();
- testOpenExistingTable("classTreeTable", " openTest"); //$NON-NLS-1$ //$NON-NLS-2$
- List<IAxis> iAxis = getTable().getCurrentColumnAxisProvider().getAxis();
- IAxis colorAxis = null;
- Object representedElement = null;
-
- for (IAxis current : iAxis) {
- representedElement = AxisUtils.getRepresentedElement(current);
- if (wantedProperty.equals(representedElement)){
- colorAxis = current;
- break;
- }
- }
- Assert.assertNotNull(colorAxis);
- Assert.assertNotNull(representedElement);
-
- UMLStereotypeSingleEnumerationComboBoxDataProvider provider = new UMLStereotypeSingleEnumerationComboBoxDataProvider(colorAxis, getTableManager());
- List<?> values = provider.getValues(iAxis.indexOf(colorAxis), 0);
- boolean findBlack = false;
- boolean findRed = false;
- boolean findBlue = false;
- for(Object current : values){
- Assert.assertTrue(current instanceof EEnumLiteral);
- EEnumLiteral lit = (EEnumLiteral) current;
- if(lit.getLiteral().equals("black")){ //$NON-NLS-1$
- findBlack = true;
- }
- if(lit.getLiteral().equals("red")){ //$NON-NLS-1$
- findRed = true;
- }
- if(lit.getLiteral().equals("blue")){ //$NON-NLS-1$
- findBlue = true;
- }
- }
-
-
- Assert.assertTrue(findBlack);
- Assert.assertTrue(findRed);
- Assert.assertTrue(findBlue);
- }
-
- @Test
- public void availablePriorityTest() throws Exception {
- StringBuilder builder = new StringBuilder(UMLTableUtils.PROPERTY_OF_STEREOTYPE_PREFIX);
- builder.append("profile::Task::p"); //$NON-NLS-1$
- String wantedProperty = builder.toString();
- testOpenExistingTable("classTreeTable", " openTest"); //$NON-NLS-1$ //$NON-NLS-2$
- List<IAxis> iAxis = getTable().getCurrentColumnAxisProvider().getAxis();
- IAxis priorityAxis = null;
- Object representedElement = null;
-
- for (IAxis current : iAxis) {
- representedElement = AxisUtils.getRepresentedElement(current);
- if (wantedProperty.equals(representedElement)){
- priorityAxis = current;
- break;
- }
- }
- Assert.assertNotNull(priorityAxis);
- Assert.assertNotNull(representedElement);
-
- UMLStereotypeSingleEnumerationComboBoxDataProvider provider = new UMLStereotypeSingleEnumerationComboBoxDataProvider(priorityAxis, getTableManager());
- List<?> values = provider.getValues(iAxis.indexOf(priorityAxis), 0);
- boolean findHight = false;
- boolean findMedium = false;
- boolean findLow = false;
- for(Object current : values){
- Assert.assertTrue(current instanceof EEnumLiteral);
- EEnumLiteral lit = (EEnumLiteral) current;
- if(lit.getLiteral().equals("hight")){ //$NON-NLS-1$
- findHight = true;
- }
- if(lit.getLiteral().equals("medium")){ //$NON-NLS-1$
- findMedium = true;
- }
- if(lit.getLiteral().equals("low")){ //$NON-NLS-1$
- findLow = true;
- }
- }
-
-
- Assert.assertTrue(findHight);
- Assert.assertTrue(findMedium);
- Assert.assertTrue(findLow);
- }
-
- @Test
- public void availableVisibilityTest() throws Exception {
- testOpenExistingTable("classTreeTable", " openTest"); //$NON-NLS-1$ //$NON-NLS-2$
- List<IAxis> iAxis = getTable().getCurrentColumnAxisProvider().getAxis();
- IAxis visibilityAxis = null;
- Object representedElement = null;
- for (IAxis current : iAxis) {
- representedElement = AxisUtils.getRepresentedElement(current);
- if (UMLPackage.eINSTANCE.getNamedElement_Visibility() == representedElement) {
- visibilityAxis = current;
- break;
- }
- }
- Assert.assertNotNull(visibilityAxis);
- Assert.assertNotNull(representedElement);
- EEnumComboBoxDataProvider provider = new EEnumComboBoxDataProvider((EEnum) UMLPackage.eINSTANCE.getNamedElement_Visibility().getEType());
- List<?> values = provider.getValues(iAxis.indexOf(visibilityAxis), 0);
- Assert.assertEquals(4, values.size());
- Assert.assertTrue(values.contains(VisibilityKind.PACKAGE_LITERAL));
- Assert.assertTrue(values.contains(VisibilityKind.PUBLIC_LITERAL));
- Assert.assertTrue(values.contains(VisibilityKind.PRIVATE_LITERAL));
- Assert.assertTrue(values.contains(VisibilityKind.PROTECTED_LITERAL));
-
- }
-
-}
+/***************************************************************************** + * Copyright (c) 2014 CEA LIST and others. + * + * 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: + * CEA LIST - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.without.service.edit; + +import java.util.List; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.emf.ecore.EEnum; +import org.eclipse.emf.ecore.EEnumLiteral; +import org.eclipse.papyrus.infra.emf.nattable.dataprovider.EEnumComboBoxDataProvider; +import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis; +import org.eclipse.papyrus.infra.nattable.utils.AxisUtils; +import org.eclipse.papyrus.uml.nattable.dataprovider.UMLStereotypeSingleEnumerationComboBoxDataProvider; +import org.eclipse.papyrus.uml.nattable.utils.UMLTableUtils; +import org.eclipse.uml2.uml.UMLPackage; +import org.eclipse.uml2.uml.VisibilityKind; +import org.junit.Assert; +import org.junit.Test; + +/** + * @author VL222926 + * + */ +public class Bug443814_Enumeration extends AbstractPasteTests { + + /** + * @see org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.without.service.edit.AbstractPasteTests#getSourcePath() + * + * @return + */ + @Override + protected String getSourcePath() { + return "/resources/paste_tests/without_service_edit/bug443814/"; //$NON-NLS-1$ + } + + @Test + public void availableColorTest() throws Exception { + + StringBuilder builder = new StringBuilder(UMLTableUtils.PROPERTY_OF_STEREOTYPE_PREFIX); + builder.append("profile::Task::color"); //$NON-NLS-1$ + String wantedProperty = builder.toString(); + testOpenExistingTable("classTreeTable", " openTest"); //$NON-NLS-1$ //$NON-NLS-2$ + List<IAxis> iAxis = getTable().getCurrentColumnAxisProvider().getAxis(); + IAxis colorAxis = null; + Object representedElement = null; + + for (IAxis current : iAxis) { + representedElement = AxisUtils.getRepresentedElement(current); + if (wantedProperty.equals(representedElement)) { + colorAxis = current; + break; + } + } + Assert.assertNotNull(colorAxis); + Assert.assertNotNull(representedElement); + + UMLStereotypeSingleEnumerationComboBoxDataProvider provider = new UMLStereotypeSingleEnumerationComboBoxDataProvider(colorAxis, getTableManager()); + List<?> values = provider.getValues(iAxis.indexOf(colorAxis), 0); + boolean findBlack = false; + boolean findRed = false; + boolean findBlue = false; + for (Object current : values) { + Assert.assertTrue(current instanceof EEnumLiteral); + EEnumLiteral lit = (EEnumLiteral) current; + if (lit.getLiteral().equals("black")) { //$NON-NLS-1$ + findBlack = true; + } + if (lit.getLiteral().equals("red")) { //$NON-NLS-1$ + findRed = true; + } + if (lit.getLiteral().equals("blue")) { //$NON-NLS-1$ + findBlue = true; + } + } + + + Assert.assertTrue(findBlack); + Assert.assertTrue(findRed); + Assert.assertTrue(findBlue); + } + + @Test + public void availablePriorityTest() throws Exception { + StringBuilder builder = new StringBuilder(UMLTableUtils.PROPERTY_OF_STEREOTYPE_PREFIX); + builder.append("profile::Task::p"); //$NON-NLS-1$ + String wantedProperty = builder.toString(); + testOpenExistingTable("classTreeTable", " openTest"); //$NON-NLS-1$ //$NON-NLS-2$ + List<IAxis> iAxis = getTable().getCurrentColumnAxisProvider().getAxis(); + IAxis priorityAxis = null; + Object representedElement = null; + + for (IAxis current : iAxis) { + representedElement = AxisUtils.getRepresentedElement(current); + if (wantedProperty.equals(representedElement)) { + priorityAxis = current; + break; + } + } + Assert.assertNotNull(priorityAxis); + Assert.assertNotNull(representedElement); + + UMLStereotypeSingleEnumerationComboBoxDataProvider provider = new UMLStereotypeSingleEnumerationComboBoxDataProvider(priorityAxis, getTableManager()); + List<?> values = provider.getValues(iAxis.indexOf(priorityAxis), 0); + boolean findHight = false; + boolean findMedium = false; + boolean findLow = false; + for (Object current : values) { + Assert.assertTrue(current instanceof EEnumLiteral); + EEnumLiteral lit = (EEnumLiteral) current; + if (lit.getLiteral().equals("hight")) { //$NON-NLS-1$ + findHight = true; + } + if (lit.getLiteral().equals("medium")) { //$NON-NLS-1$ + findMedium = true; + } + if (lit.getLiteral().equals("low")) { //$NON-NLS-1$ + findLow = true; + } + } + + + Assert.assertTrue(findHight); + Assert.assertTrue(findMedium); + Assert.assertTrue(findLow); + } + + @Test + public void availableVisibilityTest() throws Exception { + testOpenExistingTable("classTreeTable", " openTest"); //$NON-NLS-1$ //$NON-NLS-2$ + List<IAxis> iAxis = getTable().getCurrentColumnAxisProvider().getAxis(); + IAxis visibilityAxis = null; + Object representedElement = null; + for (IAxis current : iAxis) { + representedElement = AxisUtils.getRepresentedElement(current); + if (UMLPackage.eINSTANCE.getNamedElement_Visibility() == representedElement) { + visibilityAxis = current; + break; + } + } + Assert.assertNotNull(visibilityAxis); + Assert.assertNotNull(representedElement); + EEnumComboBoxDataProvider provider = new EEnumComboBoxDataProvider((EEnum) UMLPackage.eINSTANCE.getNamedElement_Visibility().getEType()); + List<?> values = provider.getValues(iAxis.indexOf(visibilityAxis), 0); + Assert.assertEquals(4, values.size()); + Assert.assertTrue(values.contains(VisibilityKind.PACKAGE_LITERAL)); + Assert.assertTrue(values.contains(VisibilityKind.PUBLIC_LITERAL)); + Assert.assertTrue(values.contains(VisibilityKind.PRIVATE_LITERAL)); + Assert.assertTrue(values.contains(VisibilityKind.PROTECTED_LITERAL)); + + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.without.service.edit.AbstractPasteTests#validateReturnedStatus(org.eclipse.core.runtime.IStatus) + */ + @Override + protected void validateReturnedStatus(final IStatus status) { + Assert.assertEquals("Status must be a warning", IStatus.WARNING, status.getSeverity()); + } + +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/tests/AllTests.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/tests/AllTests.java index 5ab17f28ae2..c58c524d934 100755 --- a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/tests/AllTests.java +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/tests/AllTests.java @@ -16,6 +16,45 @@ import org.eclipse.papyrus.sysml.nattable.requirement.tests.bugs.AxisChangeIndex import org.eclipse.papyrus.sysml.nattable.requirement.tests.bugs.AxisChangeIndexWithoutConfigurationTest; import org.eclipse.papyrus.sysml.nattable.requirement.tests.bugs.InvertedAxisChangeIndexWithConfigurationTest; import org.eclipse.papyrus.sysml.nattable.requirement.tests.bugs.InvertedAxisChangeIndexWithoutConfigurationTest; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.importfile.ImportCellsAll_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.importfile.ImportEmptyAddAll_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.importfile.ImportEmptyReplaceAll_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.importfile.ImportEmptySkipAll_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.importfile.ImportRowsAddAll_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.importfile.ImportRowsReplaceAll_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.importfile.ImportRowsSkipAll_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.insert.InsertEmptyAddAll_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.insert.InsertEmptyAxisIdentifierNotExisting_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.insert.InsertEmptyFailColumns_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.insert.InsertEmptyReplaceAll_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.insert.InsertEmptySkipAll_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.insert.InsertEmptyWarningNotExisting_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.insert.InsertRowsAddAll_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.insert.InsertRowsAxisIdentifierNotExisting_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.insert.InsertRowsFailColumns_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.insert.InsertRowsFailRows_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.insert.InsertRowsReplaceAll_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.insert.InsertRowsSkipAll_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.insert.InsertRowsWarningNotExisting_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite.PasteCellsOverwriteAll_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite.PasteCellsOverwriteByOneLine_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite.PasteCellsOverwriteFailColumns_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite.PasteCellsOverwriteFailRows_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite.PasteColumnsOverwriteAll_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite.PasteColumnsOverwriteByOneLine_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite.PasteColumnsOverwriteFailColumns_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite.PasteColumnsOverwriteFailRows_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite.PasteEmptyOverwriteAddAll_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite.PasteEmptyOverwriteAxisIdentifierNotExisting_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite.PasteEmptyOverwriteFailColumns_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite.PasteEmptyOverwriteReplaceAll_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite.PasteEmptyOverwriteSkipAll_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite.PasteEmptyOverwriteWarningNotExisting_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite.PasteRowsOverwriteAll_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite.PasteRowsOverwriteAxisIdentifierNotExisting_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite.PasteRowsOverwriteFailColumns_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite.PasteRowsOverwriteFailRows_Test; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.overwrite.PasteRowsOverwriteWarningNotExisting_Test; import org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.without.service.edit.Bug443814_Enumeration; import org.junit.runner.RunWith; import org.eclipse.papyrus.junit.framework.classification.ClassificationSuite; @@ -36,6 +75,55 @@ import org.junit.runners.Suite.SuiteClasses; OpenTableTest.class, TableCreationInUMLModel.class, RevealRequirementTableTest.class, + + // Paste Overwrite tests + PasteCellsOverwriteAll_Test.class, + PasteCellsOverwriteByOneLine_Test.class, + PasteCellsOverwriteFailColumns_Test.class, + PasteCellsOverwriteFailRows_Test.class, + + PasteColumnsOverwriteAll_Test.class, + PasteColumnsOverwriteByOneLine_Test.class, + PasteColumnsOverwriteFailColumns_Test.class, + PasteColumnsOverwriteFailRows_Test.class, + + PasteRowsOverwriteAll_Test.class, + PasteRowsOverwriteFailColumns_Test.class, + PasteRowsOverwriteFailRows_Test.class, + PasteRowsOverwriteWarningNotExisting_Test.class, + PasteRowsOverwriteAxisIdentifierNotExisting_Test.class, + + PasteEmptyOverwriteReplaceAll_Test.class, + PasteEmptyOverwriteAddAll_Test.class, + PasteEmptyOverwriteSkipAll_Test.class, + PasteEmptyOverwriteFailColumns_Test.class, + PasteEmptyOverwriteWarningNotExisting_Test.class, + PasteEmptyOverwriteAxisIdentifierNotExisting_Test.class, + + // Insert tests + InsertRowsAddAll_Test.class, + InsertRowsReplaceAll_Test.class, + InsertRowsSkipAll_Test.class, + InsertRowsFailColumns_Test.class, + InsertRowsFailRows_Test.class, + InsertRowsWarningNotExisting_Test.class, + InsertRowsAxisIdentifierNotExisting_Test.class, + + InsertEmptyReplaceAll_Test.class, + InsertEmptyAddAll_Test.class, + InsertEmptySkipAll_Test.class, + InsertEmptyFailColumns_Test.class, + InsertEmptyWarningNotExisting_Test.class, + InsertEmptyAxisIdentifierNotExisting_Test.class, + + // Import tests + ImportCellsAll_Test.class, + ImportEmptyReplaceAll_Test.class, + ImportEmptyAddAll_Test.class, + ImportEmptySkipAll_Test.class, + ImportRowsReplaceAll_Test.class, + ImportRowsAddAll_Test.class, + ImportRowsSkipAll_Test.class }) public class AllTests { |