forked from eclipsesource/papyrus-seqd
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests for semantic ordering after creation on top of lifeline #1
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d79b980
Remove useless creation of list and ignore polyglot.build.properties
planger 3b29069
Nudge also first element on insertion of execution #343
planger 7fabc04
Address review comments by Christian
planger 5f6ddf6
Fix nudging after removal of first element on lifeline
planger 5420798
Merge remote-tracking branch 'origin/master' into 343-ctd
planger b2af6db
Add tests for semantic ordering after creation on top
planger 0843c3f
Fix wrong name of receive of message 2
planger 73cbf48
Improve ModelEditFixture.isSemanticallyBefore()
planger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
...ion.model.tests/src/org/eclipse/papyrus/uml/interaction/model/tests/ModelEditFixture.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/***************************************************************************** | ||
* Copyright (c) 2018 EclipseSource 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: | ||
* Philip Langer - Initial API and implementation | ||
*****************************************************************************/ | ||
package org.eclipse.papyrus.uml.interaction.model.tests; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import org.eclipse.gmf.runtime.notation.View; | ||
import org.eclipse.papyrus.uml.interaction.internal.model.impl.LogicalModelPlugin; | ||
import org.eclipse.papyrus.uml.interaction.model.MElement; | ||
import org.eclipse.papyrus.uml.interaction.model.MExecution; | ||
import org.eclipse.papyrus.uml.interaction.model.MInteraction; | ||
import org.eclipse.papyrus.uml.interaction.model.MLifeline; | ||
import org.eclipse.papyrus.uml.interaction.model.MMessage; | ||
import org.eclipse.papyrus.uml.interaction.model.MOccurrence; | ||
import org.eclipse.papyrus.uml.interaction.model.spi.DiagramHelper; | ||
import org.eclipse.papyrus.uml.interaction.model.spi.LayoutHelper; | ||
import org.eclipse.papyrus.uml.interaction.tests.rules.ModelFixture.Edit; | ||
import org.eclipse.uml2.uml.Element; | ||
import org.eclipse.uml2.uml.ExecutionSpecification; | ||
import org.eclipse.uml2.uml.InteractionFragment; | ||
import org.eclipse.uml2.uml.Message; | ||
|
||
@SuppressWarnings("restriction") | ||
public class ModelEditFixture extends Edit { | ||
|
||
public DiagramHelper diagramHelper() { | ||
return LogicalModelPlugin.getInstance().getDiagramHelper(this.getEditingDomain()); | ||
} | ||
|
||
public LayoutHelper layoutHelper() { | ||
return LogicalModelPlugin.getInstance().getLayoutHelper(this.getEditingDomain()); | ||
} | ||
|
||
public int getLifelineBodyTop(MLifeline lifeline) { | ||
View shape = lifeline.getDiagramView().orElse(null); | ||
return layoutHelper().getTop(diagramHelper().getLifelineBodyShape(shape)); | ||
} | ||
|
||
public MInteraction getMInteraction() { | ||
return MInteraction.getInstance(getInteraction(), getSequenceDiagram().get()); | ||
} | ||
|
||
public Optional<MMessage> getMMessage(Message message) { | ||
return getMInteraction().getMessage(message); | ||
} | ||
|
||
public Optional<MExecution> getMExecution(ExecutionSpecification execution) { | ||
Optional<MElement<? extends ExecutionSpecification>> element = getMInteraction() | ||
.getElement(execution); | ||
if (element.isPresent() && element.get() instanceof MExecution) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The usual way to do this is return element.filter(MExecution.class::isInstance).map(MExecution.class::cast); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (y) |
||
return Optional.of((MExecution)element.get()); | ||
} | ||
return Optional.empty(); | ||
} | ||
|
||
public <T extends MElement<? extends Element>> T getElement(String qnFormat, String name, Class<T> type) { | ||
cdamus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
String qName = String.format(qnFormat, name); | ||
|
||
Element element = getElement(qName); | ||
return Optional.ofNullable(element).flatMap(getMInteraction()::getElement).filter(type::isInstance) | ||
.map(type::cast).orElseThrow(() -> new AssertionError("no such element: " + name)); //$NON-NLS-1$ | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public <T extends MElement<? extends Element>> T getElement(String qnFormat, String name) { | ||
return (T)getElement(qnFormat, name, MElement.class); | ||
} | ||
|
||
@SuppressWarnings({"boxing" }) | ||
public Object isSemanticallyBefore(MOccurrence<? extends Element> one, | ||
MOccurrence<? extends Element> other) { | ||
List<InteractionFragment> fragments = getMInteraction().getElement().getFragments(); | ||
int indexOfOne = fragments.indexOf(one.getElement()); | ||
int indexOfOther = fragments.indexOf(other.getElement()); | ||
return indexOfOne >= 0 && indexOfOther >= 0 && indexOfOther > indexOfOne; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! We've needed this for a while. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, glad you like it!