Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2015-03-09 22:08:42 +0000
committerChristian W. Damus2015-03-09 22:11:21 +0000
commitc036a25da9a0080b7028e08bb47c862564d18619 (patch)
treefcbe072133f65e28516f64be534248bfde99939a /tests/junit/plugins/junit
parentd485df9ba4f2806f5586e991287b23825bf9c976 (diff)
downloadorg.eclipse.papyrus-c036a25da9a0080b7028e08bb47c862564d18619.tar.gz
org.eclipse.papyrus-c036a25da9a0080b7028e08bb47c862564d18619.tar.xz
org.eclipse.papyrus-c036a25da9a0080b7028e08bb47c862564d18619.zip
Bug 461717: [Assistants] Separate semantic and visual element types
https://bugs.eclipse.org/bugs/show_bug.cgi?id=461717 Add generation of semantic super-element-type reference in generated visual element types. Add an option in the wizard to suppress this semantic supertype reference. Add JUnit tests to verify the semantic supertype in the diagram-specific scenario and its absence in the generic element types scenario. Update the user documentation for the new behaviour and option in the wizard.
Diffstat (limited to 'tests/junit/plugins/junit')
-rw-r--r--tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/matchers/MoreMatchers.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/matchers/MoreMatchers.java b/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/matchers/MoreMatchers.java
index fe1592fad4f..83d694294b1 100644
--- a/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/matchers/MoreMatchers.java
+++ b/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/matchers/MoreMatchers.java
@@ -13,10 +13,13 @@
package org.eclipse.papyrus.junit.matchers;
+import java.util.regex.Pattern;
+
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
+import com.google.common.base.Strings;
import com.google.common.collect.Iterables;
/**
@@ -30,10 +33,12 @@ public class MoreMatchers {
public static <N extends Number & Comparable<N>> Matcher<N> greaterThan(final N minimum) {
return new BaseMatcher<N>() {
+ @Override
public void describeTo(Description description) {
description.appendText("greater than ").appendValue(minimum);
}
+ @Override
@SuppressWarnings("unchecked")
public boolean matches(Object item) {
return ((N) item).compareTo(minimum) > 0;
@@ -43,10 +48,12 @@ public class MoreMatchers {
public static <N extends Number & Comparable<N>> Matcher<N> lessThan(final N maximum) {
return new BaseMatcher<N>() {
+ @Override
public void describeTo(Description description) {
description.appendText("less than ").appendValue(maximum);
}
+ @Override
@SuppressWarnings("unchecked")
public boolean matches(Object item) {
return ((N) item).compareTo(maximum) < 0;
@@ -56,13 +63,47 @@ public class MoreMatchers {
public static Matcher<Iterable<?>> isEmpty() {
return new BaseMatcher<Iterable<?>>() {
+ @Override
public void describeTo(Description description) {
description.appendText("is empty");
}
+ @Override
public boolean matches(Object item) {
return Iterables.isEmpty((Iterable<?>) item);
}
};
}
+
+ public static Matcher<String> regexMatches(final String pattern) {
+ return new BaseMatcher<String>() {
+ @Override
+ public void describeTo(Description description) {
+ description.appendText("matches /").appendText(pattern).appendText("/");
+ }
+
+ @Override
+ public boolean matches(Object item) {
+ String string = (String) item;
+ return !Strings.isNullOrEmpty(string) && string.matches(pattern);
+ }
+ };
+ }
+
+ public static Matcher<String> regexContains(final String pattern) {
+ final Pattern regex = Pattern.compile(pattern);
+
+ return new BaseMatcher<String>() {
+ @Override
+ public void describeTo(Description description) {
+ description.appendText("contains /").appendText(pattern).appendText("/");
+ }
+
+ @Override
+ public boolean matches(Object item) {
+ String string = (String) item;
+ return !Strings.isNullOrEmpty(string) && regex.matcher(string).find();
+ }
+ };
+ }
}

Back to the top