Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorcdamus2013-03-27 16:32:44 -0400
committercdamus2013-03-27 16:32:44 -0400
commitc59cc3de0506d92e7b15bb8b45c158885ebddd59 (patch)
treef8720dc4fc9d37e1037359caec9a279427814d77 /tests
parent837eb33886370b6ac417cf4c153ed90b97363403 (diff)
downloadorg.eclipse.papyrus-c59cc3de0506d92e7b15bb8b45c158885ebddd59.tar.gz
org.eclipse.papyrus-c59cc3de0506d92e7b15bb8b45c158885ebddd59.tar.xz
org.eclipse.papyrus-c59cc3de0506d92e7b15bb8b45c158885ebddd59.zip
Add support for custom attributes to CDOPapyrusMarker.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=404441
Diffstat (limited to 'tests')
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/META-INF/MANIFEST.MF3
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/src/org/eclipse/papyrus/cdo/internal/ui/markers/tests/CDOPapyrusMarkerTest.java148
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/src/org/eclipse/papyrus/cdo/ui/tests/AllTests.java5
3 files changed, 153 insertions, 3 deletions
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/META-INF/MANIFEST.MF b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/META-INF/MANIFEST.MF
index 03969d968e9..3dc5c285cf9 100644
--- a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/META-INF/MANIFEST.MF
@@ -20,7 +20,8 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.papyrus.cdo.ui;bundle-version="0.10.0",
org.eclipse.papyrus.infra.services.validation;bundle-version="0.10.0",
org.eclipse.papyrus.infra.services.markerlistener;bundle-version="0.10.0",
- org.eclipse.papyrus.cdo.validation.problems;bundle-version="0.10.0"
+ org.eclipse.papyrus.cdo.validation.problems;bundle-version="0.10.0",
+ org.eclipse.papyrus.cdo.validation.problems.edit;bundle-version="0.10.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Localization: plugin
Import-Package: com.google.common.base;version="10.0.1",
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/src/org/eclipse/papyrus/cdo/internal/ui/markers/tests/CDOPapyrusMarkerTest.java b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/src/org/eclipse/papyrus/cdo/internal/ui/markers/tests/CDOPapyrusMarkerTest.java
new file mode 100644
index 00000000000..4d9592e2f7c
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/src/org/eclipse/papyrus/cdo/internal/ui/markers/tests/CDOPapyrusMarkerTest.java
@@ -0,0 +1,148 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.markers.tests;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.Map;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.emf.ecore.EValidator;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.papyrus.cdo.core.tests.AbstractPapyrusCDOTest;
+import org.eclipse.papyrus.cdo.internal.ui.Activator;
+import org.eclipse.papyrus.cdo.internal.ui.markers.CDOPapyrusMarker;
+import org.eclipse.papyrus.cdo.validation.problems.EProblem;
+import org.eclipse.papyrus.cdo.validation.problems.ESeverity;
+import org.eclipse.papyrus.cdo.validation.problems.ProblemsFactory;
+import org.eclipse.papyrus.cdo.validation.problems.edit.ProblemEditUtil;
+import org.eclipse.papyrus.infra.services.markerlistener.IPapyrusMarker;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * This is the CDOPapyrusMarkerTest type. Enjoy.
+ */
+public class CDOPapyrusMarkerTest extends AbstractPapyrusCDOTest {
+
+ private static final String URI = EcoreUtil.getURI(EcorePackage.Literals.ECLASS).toString();
+
+ private static final String MESSAGE = "Hello, world";
+
+ private static final int SEVERITY = IMarker.SEVERITY_WARNING;
+
+ private static final String ATTR_BOOLEAN = "aBoolean";
+
+ private static final boolean ATTR_BOOLEAN_VALUE = true;
+
+ private static final String ATTR_INTEGER = "anInteger";
+
+ private static final int ATTR_INTEGER_VALUE = 42;
+
+ private static final String ATTR_STRING = "aString";
+
+ private static final String ATTR_STRING_VALUE = "this is a string";
+
+ private CDOPapyrusMarker fixture;
+
+ public CDOPapyrusMarkerTest() {
+ super();
+ }
+
+ @Test
+ public void testGetURI() throws CoreException {
+ assertThat(fixture.getAttribute(EValidator.URI_ATTRIBUTE), is((Object)URI));
+ assertThat(fixture.getAttribute(EValidator.URI_ATTRIBUTE, ""), is(URI));
+ }
+
+ @Test
+ public void testGetMessage() throws CoreException {
+ assertThat(fixture.getAttribute(IPapyrusMarker.MESSAGE), is((Object)MESSAGE));
+ assertThat(fixture.getAttribute(IPapyrusMarker.MESSAGE, ""), is(MESSAGE));
+ }
+
+ @Test
+ public void testGetSeverity() throws CoreException {
+ assertThat(fixture.getAttribute(IPapyrusMarker.SEVERITY), is((Object)SEVERITY));
+ assertThat(fixture.getAttribute(IPapyrusMarker.SEVERITY, -1), is(SEVERITY));
+ }
+
+ @Test
+ public void testGetBoolean() throws CoreException {
+ assertThat(fixture.getAttribute(ATTR_BOOLEAN), is((Object)ATTR_BOOLEAN_VALUE));
+ assertThat(fixture.getAttribute(ATTR_BOOLEAN, false), is(ATTR_BOOLEAN_VALUE));
+ }
+
+ @Test
+ public void testGetInteger() throws CoreException {
+ assertThat(fixture.getAttribute(ATTR_INTEGER), is((Object)ATTR_INTEGER_VALUE));
+ assertThat(fixture.getAttribute(ATTR_INTEGER, 0), is(ATTR_INTEGER_VALUE));
+ }
+
+ @Test
+ public void testGetString() throws CoreException {
+ assertThat(fixture.getAttribute(ATTR_STRING), is((Object)ATTR_STRING_VALUE));
+ assertThat(fixture.getAttribute(ATTR_STRING, ""), is(ATTR_STRING_VALUE));
+ }
+
+ @Test
+ public void testGetAttributes() throws CoreException {
+ Map<String, ?> attributes = fixture.getAttributes();
+
+ assertThat(attributes.get(EValidator.URI_ATTRIBUTE), is((Object)URI));
+ assertThat(attributes.get(IPapyrusMarker.MESSAGE), is((Object)MESSAGE));
+ assertThat(attributes.get(IPapyrusMarker.SEVERITY), is((Object)SEVERITY));
+
+ assertThat(attributes.get(ATTR_BOOLEAN), is((Object)ATTR_BOOLEAN_VALUE));
+ assertThat(attributes.get(ATTR_INTEGER), is((Object)ATTR_INTEGER_VALUE));
+ assertThat(attributes.get(ATTR_STRING), is((Object)ATTR_STRING_VALUE));
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testGetBooleanWrong() throws CoreException {
+ fixture.getAttribute(ATTR_INTEGER, false);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testGetIntegerWrong() throws CoreException {
+ fixture.getAttribute(ATTR_STRING, 0);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testGetStringWrong() throws CoreException {
+ fixture.getAttribute(ATTR_BOOLEAN, "");
+ }
+
+ //
+ // Test framework
+ //
+
+ @Before
+ public void createFixture() throws CoreException {
+ EProblem problem = ProblemsFactory.eINSTANCE.createEProblem();
+ problem.setElement(EcorePackage.Literals.ECLASS);
+ problem.setMessage(MESSAGE);
+ problem.setSeverity(ESeverity.WARNING);
+ problem.setSource(Activator.PLUGIN_ID);
+
+ fixture = CDOPapyrusMarker.wrap(new ProblemEditUtil(new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE))).apply(problem);
+
+ fixture.setAttribute(ATTR_BOOLEAN, ATTR_BOOLEAN_VALUE);
+ fixture.setAttribute(ATTR_INTEGER, ATTR_INTEGER_VALUE);
+ fixture.setAttribute(ATTR_STRING, ATTR_STRING_VALUE);
+ }
+
+}
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/src/org/eclipse/papyrus/cdo/ui/tests/AllTests.java b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/src/org/eclipse/papyrus/cdo/ui/tests/AllTests.java
index d5d2a15b435..4c02a05d91b 100644
--- a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/src/org/eclipse/papyrus/cdo/ui/tests/AllTests.java
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/src/org/eclipse/papyrus/cdo/ui/tests/AllTests.java
@@ -13,6 +13,7 @@ package org.eclipse.papyrus.cdo.ui.tests;
import org.eclipse.papyrus.cdo.internal.ui.editors.tests.BasicEditorTest;
import org.eclipse.papyrus.cdo.internal.ui.editors.tests.DawnEditorAdapterTest;
+import org.eclipse.papyrus.cdo.internal.ui.markers.tests.CDOPapyrusMarkerTest;
import org.eclipse.papyrus.cdo.internal.ui.markers.tests.ModelValidationMarkersTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@@ -22,8 +23,8 @@ import org.junit.runners.Suite.SuiteClasses;
* This is the AllTests type. Enjoy.
*/
@RunWith(Suite.class)
-@SuiteClasses({BasicEditorTest.class, DawnEditorAdapterTest.class,
- ModelValidationMarkersTest.class})
+@SuiteClasses({ BasicEditorTest.class, DawnEditorAdapterTest.class, //
+ModelValidationMarkersTest.class, CDOPapyrusMarkerTest.class })
public class AllTests {
public AllTests() {

Back to the top