diff options
author | Christian W. Damus | 2018-06-25 21:10:27 +0000 |
---|---|---|
committer | Remi Schnekenburger | 2018-07-05 14:18:30 +0000 |
commit | 8ba78ef5f3941027769e6c537f078d173177a979 (patch) | |
tree | f39500114f2c62038f329c89f807cc81f3895fc7 /tests/junit/framework | |
parent | 5163156b2c88ede0d999db2f54181a417ec475a4 (diff) | |
download | org.eclipse.papyrus-8ba78ef5f3941027769e6c537f078d173177a979.tar.gz org.eclipse.papyrus-8ba78ef5f3941027769e6c537f078d173177a979.tar.xz org.eclipse.papyrus-8ba78ef5f3941027769e6c537f078d173177a979.zip |
Bug 507479: [SequenceDiagram] Choose lifelines covered by a combined
fragment
Implement properties view for the InteractionFragment::covered
property of combined fragments and interaction operands. Restrict
the selection of covered lifelines to lifelines in the same interaction.
Add warning constraints for consistency of lifelines covered by
- interaction operand as compared to lifelines covered by the
fragments that it owns
- combined fragment as compared to lifelines covered by fragments
of its operands
Update the automatic validation (if the preference is set) of an
interaction operand that has has its owned fragments recomputed to
encompass the entire containing combined fragment, to handle the
impact on its lifeline coverage consistency constraint.
Update headers & plugin version
Change-Id: I340c816a3d62b38b2e811daa90b4d5c0c1fb5493
Signed-off-by: Christian W. Damus <give.a.damus@gmail.com>
Diffstat (limited to 'tests/junit/framework')
2 files changed, 161 insertions, 1 deletions
diff --git a/tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/matchers/DiagramMatchers.java b/tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/matchers/DiagramMatchers.java index 8267e6b3529..f10ae3c30e4 100644 --- a/tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/matchers/DiagramMatchers.java +++ b/tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/matchers/DiagramMatchers.java @@ -8,7 +8,7 @@ * * Contributors: * Christian W. Damus (CEA) - Initial API and implementation - * Christian W. Damus - bugs 533673, 533676 + * Christian W. Damus - bugs 533673, 533676, 507479 * */ package org.eclipse.papyrus.junit.matchers; @@ -164,6 +164,24 @@ public class DiagramMatchers { } /** + * Match an edit-part that has a {@linkplain IPapyrusMarker#SEVERITY_WARNING warning} + * decoration having a message matching a given matcher. + * + * @param messageMatcher + * matcher for the decoration message + * + * @return the decoration matcher + * + * @since 2.2 + * + * @see #hasDecorationThat(int, Matcher) + * @see IPapyrusMarker#SEVERITY_WARNING + */ + public static Matcher<EditPart> hasWarningDecorationThat(Matcher<? super String> messageMatcher) { + return hasDecorationThat(IPapyrusMarker.SEVERITY_WARNING, messageMatcher); + } + + /** * Match an edit-part that has a decoration of a given severity having a message matching * a given matcher. * diff --git a/tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/PreferenceRule.java b/tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/PreferenceRule.java new file mode 100644 index 00000000000..f5570d83c1d --- /dev/null +++ b/tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/PreferenceRule.java @@ -0,0 +1,142 @@ +/***************************************************************************** + * Copyright (c) 2018 Christian W. Damus 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: + * Christian W. Damus - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.junit.utils.rules; + +import java.util.function.BiFunction; + +import org.eclipse.jface.preference.IPreferenceStore; +import org.junit.rules.TestRule; +import org.junit.runner.Description; +import org.junit.runners.model.Statement; + +/** + * A JUnit test rule for ensuring some Eclipse Preference value for the duration + * of a test. + */ +public final class PreferenceRule<T> implements TestRule { + + private final IPreferenceStore store; + private final String key; + private final T value; + private T oldValue; + + private final BiFunction<IPreferenceStore, String, ? extends T> accessor; + private final TriConsumer<IPreferenceStore, String, ? super T> mutator; + + /** + * Initializes me. + * + * @param store + * the preference store on which to operate + * @param key + * the preference key on which to operate + * @param the + * value to set in the preference + */ + private PreferenceRule(IPreferenceStore store, String key, T value, + BiFunction<IPreferenceStore, String, ? extends T> accessor, + TriConsumer<IPreferenceStore, String, ? super T> mutator) { + + super(); + + this.store = store; + this.key = key; + this.value = value; + this.accessor = accessor; + this.mutator = mutator; + } + + @Override + public Statement apply(Statement base, Description description) { + return new Statement() { + + @Override + public void evaluate() throws Throwable { + setPreference(store, key); + + try { + base.evaluate(); + } finally { + restorePreference(store, key); + } + } + }; + } + + protected void setPreference(IPreferenceStore store, String key) { + oldValue = accessor.apply(store, key); + mutator.accept(store, key, value); + } + + protected void restorePreference(IPreferenceStore store, String key) { + mutator.accept(store, key, oldValue); + } + + /** + * Create a boolean-valued preference rule. + * + * @param store + * the preference store + * @param key + * the preference key + * @param value + * the value to set for the duration of the test + * @return the preference rule + */ + public static final PreferenceRule<Boolean> create(IPreferenceStore store, String key, boolean value) { + return new PreferenceRule<Boolean>(store, key, value, + IPreferenceStore::getBoolean, IPreferenceStore::setValue); + } + + /** + * Create a string-valued preference rule. + * + * @param store + * the preference store + * @param key + * the preference key + * @param value + * the value to set for the duration of the test + * @return the preference rule + */ + public static final PreferenceRule<String> create(IPreferenceStore store, String key, String value) { + return new PreferenceRule<String>(store, key, value, + IPreferenceStore::getString, IPreferenceStore::setValue); + } + + /** + * Create an integer-valued preference rule. + * + * @param store + * the preference store + * @param key + * the preference key + * @param value + * the value to set for the duration of the test + * @return the preference rule + */ + public static final PreferenceRule<Integer> create(IPreferenceStore store, String key, int value) { + return new PreferenceRule<Integer>(store, key, value, + IPreferenceStore::getInt, IPreferenceStore::setValue); + } + + // + // Nested types + // + + @FunctionalInterface + private interface TriConsumer<T, U, V> { + void accept(T t, U u, V v); + } +} |