Skip to content

Commit

Permalink
Fixed static accesses of methods and fields of the supporting bots ec…
Browse files Browse the repository at this point in the history
…lipse-4diac#377

The incorrect static access to methods and static fields has been
removed and the corresponding suppression annotations

Addresses eclipse-4diac#377
  • Loading branch information
Andrearium committed Sep 3, 2024
1 parent 6847c7d commit 04899da
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class Abstract4diacUITests {
protected static void beforeAll() {
bot = new SWT4diacGefBot();
bot.viewByTitle("Welcome").close(); //$NON-NLS-1$
SWTBotPreferences.TIMEOUT = 30000;
SWTBotPreferences.TIMEOUT = 8000;
SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US"; //$NON-NLS-1$
createProject();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

public class SWTBotConnection {

private static SWT4diacGefBot bot;
private final SWT4diacGefBot bot;

@SuppressWarnings("static-access")
public SWTBotConnection(final SWT4diacGefBot bot) {
Expand All @@ -60,7 +60,7 @@ public SWTBotConnection(final SWT4diacGefBot bot) {
* @param pin2 One of the two pins between a connection is (tried to) create.
* @return SWTBot4diacGefViewer
*/
public static SWTBot4diacGefViewer createConnection(final String pin1, final String pin2) {
public SWTBot4diacGefViewer createConnection(final String pin1, final String pin2) {
final SWTBotGefEditor editor = bot.gefEditor(UITestNamesHelper.PROJECT_NAME);
assertNotNull(editor);
final SWTBot4diacGefViewer viewer = (SWTBot4diacGefViewer) editor.getSWTBotGefViewer();
Expand All @@ -86,11 +86,11 @@ public static SWTBot4diacGefViewer createConnection(final String pin1, final Str
return viewer;
}

public static boolean checkIfConnectionCanBeFound(final String srcPinName, final String dstPinName) {
public boolean checkIfConnectionCanBeFound(final String srcPinName, final String dstPinName) {
return findConnection(srcPinName, dstPinName) != null;
}

public static ConnectionEditPart findConnection(final String srcPinName, final String dstPinName) {
public ConnectionEditPart findConnection(final String srcPinName, final String dstPinName) {
final SWTBotGefEditor editor = bot.gefEditor(UITestNamesHelper.PROJECT_NAME);
final SWTBot4diacGefViewer viewer = (SWTBot4diacGefViewer) editor.getSWTBotGefViewer();
final GraphicalViewer graphicalViewer = viewer.getGraphicalViewer();
Expand Down Expand Up @@ -129,7 +129,7 @@ public static ConnectionEditPart findConnection(final String srcPinName, final S
* @param pin2 Name of pin2.
* @param editor Selected Gef Editor
*/
public static void createConnectionWithinFBTypeWithPropertySheet(final String pin1, final String pin2,
public void createConnectionWithinFBTypeWithPropertySheet(final String pin1, final String pin2,
final SWTBot4diacGefEditor editor) {

final SWTBotGefEditPart port1 = editor.getEditPart(pin1);
Expand Down Expand Up @@ -163,7 +163,7 @@ public static void createConnectionWithinFBTypeWithPropertySheet(final String pi
* @param pin2 Name of pin2.
* @param editor Selected Gef Editor
*/
public static void removeConnectionWithinFBTypeWithPropertySheet(final String pin1, final String pin2,
public void removeConnectionWithinFBTypeWithPropertySheet(final String pin1, final String pin2,
final SWTBot4diacGefEditor editor) {

final SWTBotGefEditPart port1 = editor.getEditPart(pin1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

public class SWTBotFB {

private static SWT4diacGefBot bot;
private final SWT4diacGefBot bot;

@SuppressWarnings("static-access")
public SWTBotFB(final SWT4diacGefBot bot) {
Expand All @@ -54,7 +54,7 @@ public SWTBotFB(final SWT4diacGefBot bot) {
* @param point The Position of the FB on the canvas.
*/
@SuppressWarnings("static-access")
public static void dragAndDropEventsFB(final String fbName, final Point point) {
public void dragAndDropEventsFB(final String fbName, final Point point) {
final SWTBotSystemExplorer sysEx = new SWTBotSystemExplorer(bot);
final SWTBotTreeItem typeLibraryNode = sysEx.expandTypeLibraryTreeItemInSystemExplorer();
bot.waitUntil(treeItemHasNode(typeLibraryNode, UITestNamesHelper.EVENTS_NODE));
Expand Down Expand Up @@ -85,8 +85,8 @@ public static void dragAndDropEventsFB(final String fbName, final Point point) {
* @param editor
* @param name
*/
public static SWTBot4diacGefEditor selectFBWithFBNameInEditor(final SWTBot4diacGefEditor editor,
final String name) {
@SuppressWarnings("static-method")
public SWTBot4diacGefEditor selectFBWithFBNameInEditor(final SWTBot4diacGefEditor editor, final String name) {
assertNotNull(editor);
assertNotNull(editor.getEditPart(name));
editor.click(name);
Expand All @@ -103,7 +103,7 @@ public static SWTBot4diacGefEditor selectFBWithFBNameInEditor(final SWTBot4diacG
* instance name should be deleted.
* @param FbInstanceName The instance name of the FB
*/
public static void deleteFB(final SWTBot4diacGefEditor editor, final String FbInstanceName) {
public void deleteFB(final SWTBot4diacGefEditor editor, final String FbInstanceName) {
editor.setFocus();
final SWTBotGefEditPart fb = editor.getEditPart(FbInstanceName).parent();
fb.select().click();
Expand All @@ -118,7 +118,8 @@ public static void deleteFB(final SWTBot4diacGefEditor editor, final String FbIn
* @param fbName The FB that is searched for.
* @return true if fbName is in the List, otherwise false.
*/
public static boolean isFbSelected(final List<SWTBotGefEditPart> selectedEditParts, final String fbName) {
@SuppressWarnings("static-method")
public boolean isFbSelected(final List<SWTBotGefEditPart> selectedEditParts, final String fbName) {
return selectedEditParts.stream().filter(p -> p.part() instanceof FBEditPart).map(p -> (FBEditPart) p.part())
.anyMatch(fb -> fb.getModel().getName().equals(fbName));
}
Expand All @@ -131,7 +132,8 @@ public static boolean isFbSelected(final List<SWTBotGefEditPart> selectedEditPar
* @param fbName The String of the FB instance name searched for
* @return true if FB is onto editing area, false if not
*/
public static boolean isFBNamePresendOnEditingArea(final SWTBot4diacGefEditor editor, final String fbName) {
@SuppressWarnings("static-method")
public boolean isFBNamePresendOnEditingArea(final SWTBot4diacGefEditor editor, final String fbName) {
final List<SWTBotGefEditPart> editParts = editor.editParts(new BaseMatcher<EditPart>() {
@Override
public boolean matches(final Object item) {
Expand All @@ -148,27 +150,15 @@ public void describeTo(final Description description) {
.anyMatch(fb -> fb.getModel().getName().equals(fbName));
}

// // TODO duplicate method - check also getBoundsOfFB!!!
// protected static Rectangle getAbsolutePosition(final SWTBotGefEditor editor, final String fb) {
// final SWTBotGefEditPart parent = editor.getEditPart(fb).parent();
// assertNotNull(parent);
// final IFigure figurePos = ((GraphicalEditPart) parent.part()).getFigure();
// assertNotNull(figurePos);
// final Rectangle fbBounds = figurePos.getBounds().getCopy();
// assertNotNull(fbBounds);
// figurePos.translateToAbsolute(fbBounds);
// return fbBounds;
// }

/**
* Returns the bounds of the searched function block
*
* @param editor
* @param fBname
* @return The rectangle with the bounds of the function block searched for
*/
// TODO duplicate method - check also getAbsolutePosition!!!
public static Rectangle getBoundsOfFB(final SWTBotGefEditor editor, final String fBname) {
@SuppressWarnings("static-method")
public Rectangle getBoundsOfFB(final SWTBotGefEditor editor, final String fBname) {
editor.getEditPart(fBname);
editor.click(fBname);
final SWTBotGefEditPart parent = editor.getEditPart(fBname).parent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@

public class SWTBotSubapp {

private static SWT4diacGefBot bot;
private final SWT4diacGefBot bot;

@SuppressWarnings("static-access")
public SWTBotSubapp(final SWT4diacGefBot bot) {
this.bot = bot;
}
Expand All @@ -40,13 +39,13 @@ public SWTBotSubapp(final SWT4diacGefBot bot) {
* @param fromYPosition the y value of the starting point
* @param toXPosition the x value of the target point
* @param toYPosition the y value of the target point
* @return
*/
public static void createSubappWithDragRectangle(final int fromXPosition, final int fromYPosition,
final int toXPosition, final int toYPosition) {
public void createSubappWithDragRectangle(final int fromXPosition, final int fromYPosition, final int toXPosition,
final int toYPosition) {
final SWTBot4diacGefEditor editor = (SWTBot4diacGefEditor) bot.gefEditor(UITestNamesHelper.PROJECT_NAME);
editor.drag(fromXPosition, fromYPosition, toXPosition, toYPosition);
bot.menu(UITestNamesHelper.SOURCE).menu(UITestNamesHelper.NEW_SUBAPPLICATION).click();

}

/**
Expand All @@ -57,7 +56,8 @@ public static void createSubappWithDragRectangle(final int fromXPosition, final
* @param subAppName The Subapplication that is searched for.
* @return true if Subapplication is in the List, otherwise false.
*/
public static boolean isSubappSelected(final List<SWTBotGefEditPart> selectedEditParts, final String subAppName) {
@SuppressWarnings("static-method")
public boolean isSubappSelected(final List<SWTBotGefEditPart> selectedEditParts, final String subAppName) {
return selectedEditParts.stream().filter(p -> p.part() instanceof SubAppForFBNetworkEditPart)
.map(p -> (SubAppForFBNetworkEditPart) p.part())
.anyMatch(fb -> subAppName.equals(fb.getModel().getName()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@

public class SWTBotSystemExplorer {

private static SWT4diacGefBot bot;
private final SWT4diacGefBot bot;
private final SWTBotView systemExplorerView;
private static SWTBotTree tree;
private final SWTBotTree tree;

/**
* Creates an instance of {@code SWTBotSystemExplorer} for interacting with the
Expand All @@ -48,7 +48,6 @@ public class SWTBotSystemExplorer {
* @throws AssertionError if the tree widget within the System Explorer view
* cannot be found
*/
@SuppressWarnings("static-access")
public SWTBotSystemExplorer(final SWT4diacGefBot bot) {
this.bot = bot;
this.systemExplorerView = bot.viewById(UITestNamesHelper.SYSTEM_EXPLORER_ID);
Expand All @@ -69,7 +68,7 @@ public SWTBotSystemExplorer(final SWT4diacGefBot bot) {
* tree.
* @return {@code true} if node is visible in tree; {@code false} otherwise
*/
public static boolean isElementInApplicationOfSystemInSystemExplorer(final String element) {
public boolean isElementInApplicationOfSystemInSystemExplorer(final String element) {
final SWTBotTreeItem appNode = expandApplicationTreeItemInSystemExplorer();
bot.waitUntil(treeItemHasNode(appNode, element));
final SWTBotTreeItem elementNode = appNode.getNode(element);
Expand All @@ -86,7 +85,7 @@ public static boolean isElementInApplicationOfSystemInSystemExplorer(final Strin
* of the Application in the System in the SystemExplorer tree.,
* @return {@code true} if FB is visible in tree; {@code false} otherwise
*/
public static boolean isFBInSubAppOfSystemInSystemExplorer(final String fbName) {
public boolean isFBInSubAppOfSystemInSystemExplorer(final String fbName) {
final SWTBotTreeItem subAppNode = expandSubAppTreeItemInSystemExplorer();
final SWTBotTreeItem fbNode = subAppNode.getNode(fbName);
assertNotNull(fbNode);
Expand All @@ -102,7 +101,7 @@ public static boolean isFBInSubAppOfSystemInSystemExplorer(final String fbName)
* @author Andrea Zoitl
* @return {@code true} if node has no children; {@code false} otherwise
*/
public static boolean isSubAppNodeInSystemExplorerEmpty() {
public boolean isSubAppNodeInSystemExplorerEmpty() {
final SWTBotTreeItem subAppNode = expandSubAppTreeItemInSystemExplorer();
final List<String> subAppChildren = subAppNode.getNodes();
return subAppChildren.isEmpty();
Expand All @@ -114,7 +113,7 @@ public static boolean isSubAppNodeInSystemExplorerEmpty() {
* @author Andrea Zoitl
* @return treeProjectItem The expanded Project node
*/
private static SWTBotTreeItem expandProjectTreeItemInSystemExplorer() {
private SWTBotTreeItem expandProjectTreeItemInSystemExplorer() {
final SWTBotTreeItem treeProjectItem = tree.getTreeItem(UITestNamesHelper.PROJECT_NAME);
return treeProjectItem.select().expand();

Expand All @@ -127,7 +126,7 @@ private static SWTBotTreeItem expandProjectTreeItemInSystemExplorer() {
* @return The expanded {@code SWTBotTreeItem} representing the system node in
* the System Explorer
*/
private static SWTBotTreeItem expandSystemTreeItemInSystemExplorer() {
private SWTBotTreeItem expandSystemTreeItemInSystemExplorer() {
final SWTBotTreeItem treeProjectItem = expandProjectTreeItemInSystemExplorer();
bot.waitUntil(treeItemHasNode(treeProjectItem, UITestNamesHelper.PROJECT_NAME_TREE_ITEM));
final SWTBotTreeItem systemNode = treeProjectItem.getNode(UITestNamesHelper.PROJECT_NAME_TREE_ITEM);
Expand All @@ -141,7 +140,7 @@ private static SWTBotTreeItem expandSystemTreeItemInSystemExplorer() {
* @return The expanded {@code SWTBotTreeItem} representing the Type Library
* node in the System Explorer
*/
public static SWTBotTreeItem expandTypeLibraryTreeItemInSystemExplorer() {
public SWTBotTreeItem expandTypeLibraryTreeItemInSystemExplorer() {
final SWTBotTreeItem treeProjectItem = expandProjectTreeItemInSystemExplorer();
bot.waitUntil(treeItemHasNode(treeProjectItem, UITestNamesHelper.TYPE_LIBRARY_NODE));
final SWTBotTreeItem typeLibraryNode = treeProjectItem.getNode(UITestNamesHelper.TYPE_LIBRARY_NODE);
Expand All @@ -155,7 +154,7 @@ public static SWTBotTreeItem expandTypeLibraryTreeItemInSystemExplorer() {
* @return The expanded {@code SWTBotTreeItem} representing the Application node
* in the System Explorer
*/
public static SWTBotTreeItem expandApplicationTreeItemInSystemExplorer() {
public SWTBotTreeItem expandApplicationTreeItemInSystemExplorer() {
final SWTBotTreeItem systemNode = expandSystemTreeItemInSystemExplorer();
bot.waitUntil(treeItemHasNode(systemNode, UITestNamesHelper.PROJECT_NAME_APP));
final SWTBotTreeItem appNode = systemNode.getNode(UITestNamesHelper.PROJECT_NAME_APP);
Expand All @@ -171,7 +170,7 @@ public static SWTBotTreeItem expandApplicationTreeItemInSystemExplorer() {
* @return The expanded {@code SWTBotTreeItem} representing the Subapplication
* (SubApp) node in the System Explorer
*/
private static SWTBotTreeItem expandSubAppTreeItemInSystemExplorer() {
private SWTBotTreeItem expandSubAppTreeItemInSystemExplorer() {
final SWTBotTreeItem appNode = expandApplicationTreeItemInSystemExplorer();
final SWTBotTreeItem subAppNode = appNode.getNode(UITestNamesHelper.SUBAPP);
assertNotNull(subAppNode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class SubapplicationTests extends Abstract4diacUITests {
* Checks if a subapplication can be created via menu by selecting the
* Application editor breadcrumb.
*/
@SuppressWarnings({ "static-method", "static-access" })
@SuppressWarnings("static-method")
@Test
public void createEmptySubappViaMenu() {
final SWTBot4diacGefEditor editor = (SWTBot4diacGefEditor) bot.gefEditor(UITestNamesHelper.PROJECT_NAME);
Expand All @@ -61,7 +61,7 @@ public void createEmptySubappViaMenu() {
* is drawn over the FBs. Then a subapplication is created via menu entry
* "Source" -> "New subapplication"
*/
@SuppressWarnings({ "static-method", "static-access" })
@SuppressWarnings("static-method")
@Test
public void createSubappViaMenu() {
final SWTBotFB fbBot = new SWTBotFB(bot);
Expand Down Expand Up @@ -138,7 +138,7 @@ public void createSubappViaMenuWithConnectionBetweenFBs() {
* a FB outside of the selection. Then a subapplication is created via menu
* entry "Source" -> "New subapplication"
*/
@SuppressWarnings({ "static-method", "static-access" })
@SuppressWarnings("static-method")
@Test
public void createSubappViaMenuWithExistingConnectionOutsideSubapp() {
final SWTBotFB fbBot = new SWTBotFB(bot);
Expand Down Expand Up @@ -177,7 +177,7 @@ public void createSubappViaMenuWithExistingConnectionOutsideSubapp() {
* subapplication is created with them. afterwards it is checked if connection
* can be created in the subapplication.
*/
@SuppressWarnings({ "static-method", "static-access" })
@SuppressWarnings("static-method")
@Test
public void createSubappViaMenuThenCreatingConnection() {
final SWTBotFB fbBot = new SWTBotFB(bot);
Expand Down

0 comments on commit 04899da

Please sign in to comment.