Skip to content

Commit 225ecdf

Browse files
committed
chore: fix sonar issues
Signed-off-by: Stephane Bouchet <[email protected]>
1 parent 4bb5c14 commit 225ecdf

File tree

23 files changed

+148
-134
lines changed

23 files changed

+148
-134
lines changed

build.gradle.kts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ plugins {
22
id("java-library")
33
id("maven-publish")
44
alias(libs.plugins.gradleNexusPublishPlugin)
5+
id("jacoco") // Code coverage
56
alias(libs.plugins.sonarqube) // SonarQube
67
}
78

@@ -40,6 +41,14 @@ tasks {
4041
useJUnitPlatform()
4142
}
4243

44+
jacocoTestReport {
45+
executionData.setFrom(fileTree(layout.buildDirectory).include("/jacoco/*.exec"))
46+
//classDirectories.setFrom(instrumentCode)
47+
reports {
48+
xml.required = true
49+
}
50+
}
51+
4352
sonar {
4453
properties {
4554
property("sonar.projectKey", "redhat-developer_intellij-common-ui-test-library")

src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/NewProjectFirstPage.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import com.intellij.remoterobot.data.RemoteComponent;
1515
import com.intellij.remoterobot.fixtures.ComboBoxFixture;
1616
import com.intellij.remoterobot.fixtures.CommonContainerFixture;
17-
import com.intellij.remoterobot.fixtures.ContainerFixture;
1817
import com.intellij.remoterobot.fixtures.DefaultXpath;
1918
import com.intellij.remoterobot.fixtures.FixtureName;
2019
import com.intellij.remoterobot.fixtures.HeavyWeightWindowFixture;
@@ -167,10 +166,13 @@ public void setProjectSdkIfAvailable(String targetSdkName) {
167166
String label = foundItems.values().stream().findFirst().get();
168167
projectSdkList.jList().clickItem(label, true);
169168
// wait for 'resolving JDK' progressmonitor to end
169+
// TODO for now don't know what kind of dialog is the 'resolving' so just pausing thread
170170
try {
171171
Thread.sleep(5000);
172172
} catch (InterruptedException e) {
173-
throw new RuntimeException(e);
173+
ScreenshotUtils.takeScreenshot(remoteRobot, "interrupted while waiting for " + targetSdkName);
174+
/* Clean up whatever needs to be handled before interrupting */
175+
Thread.currentThread().interrupt();
174176
}
175177
} else {
176178
ScreenshotUtils.takeScreenshot(remoteRobot, "No SDK found starting with " + targetSdkName);

src/main/java/com/redhat/devtools/intellij/commonuitest/utils/constants/XPathDefinitions.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,11 @@ public class XPathDefinitions {
9191
@Language("XPath")
9292
public static final String MY_LIST = "//div[@class='MyList']";
9393
public static final String CODE_WITH_ME_JPANEL = "//div[@class='Wrapper'][.//div[@class='JBLabel']]//div[@class='JPanel']";
94+
@Language("XPath")
9495
public static final String BREAD_CRUMBS = "//div[@class='Breadcrumbs']";
9596
@Language("XPath")
9697
public static final String EMPTY_PROJECT = "//div[@visible_text='Empty Project']";
98+
@Language("XPath")
9799
public static final String SINGLE_HEIGHT_LABEL = "//div[@class='SingleHeightLabel']";
98100
public static final String COLLAPSIBLE_TITLED_SEPARATOR = "//div[@class='CollapsibleTitledSeparator']";
99101
public static final String COLLAPSIBLE_TITLED_SEPARATOR_NEW = "//div[@class='CollapsibleTitledSeparatorImpl']";

src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/LibraryTestBase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class LibraryTestBase {
3838
private static final int TEST_RUNNER_PORT = 8580;
3939

4040
@BeforeAll
41-
protected static void startIntelliJ() {
41+
static void startIntelliJ() {
4242
if (!intelliJHasStarted) {
4343
ideaVersionInt = communityIdeaVersion.toInt();
4444
remoteRobot = UITestRunner.runIde(communityIdeaVersion, TEST_RUNNER_PORT);
@@ -52,7 +52,7 @@ protected static void startIntelliJ() {
5252
}
5353

5454
@AfterAll
55-
protected static void finishTestRun() {
55+
static void finishTestRun() {
5656
FlatWelcomeFrame flatWelcomeFrame = remoteRobot.find(FlatWelcomeFrame.class, Duration.ofSeconds(10));
5757
flatWelcomeFrame.clearExceptions();
5858
flatWelcomeFrame.clearWorkspace();

src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/FlatWelcomeFrameTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,21 @@ class FlatWelcomeFrameTest extends LibraryTestBase {
4040
private FlatWelcomeFrame flatWelcomeFrame;
4141

4242
@AfterEach
43-
public void cleanUp() {
43+
void cleanUp() {
4444
flatWelcomeFrame.clearWorkspace();
4545
flatWelcomeFrame.clearExceptions();
4646
}
4747

4848
@Test
49-
public void createNewProjectLinkTest() {
49+
void createNewProjectLinkTest() {
5050
flatWelcomeFrame = remoteRobot.find(FlatWelcomeFrame.class, Duration.ofSeconds(10));
5151
flatWelcomeFrame.createNewProject();
5252
NewProjectDialogWizard newProjectDialogWizard = remoteRobot.find(NewProjectDialogWizard.class, Duration.ofSeconds(10));
5353
newProjectDialogWizard.cancel();
5454
}
5555

5656
@Test
57-
public void clearWorkspaceTest() {
57+
void clearWorkspaceTest() {
5858
prepareWorkspace(PROJECT_NAME);
5959
flatWelcomeFrame = remoteRobot.find(FlatWelcomeFrame.class, Duration.ofSeconds(10));
6060
flatWelcomeFrame.clearExceptions();
@@ -71,7 +71,7 @@ public void clearWorkspaceTest() {
7171
}
7272

7373
@Test
74-
public void clearExceptionsTest() {
74+
void clearExceptionsTest() {
7575
prepareWorkspace(PROJECT_NAME);
7676
flatWelcomeFrame = remoteRobot.find(FlatWelcomeFrame.class, Duration.ofSeconds(10));
7777
flatWelcomeFrame.clearExceptions();

src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/information/CodeWithMeDialogTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class CodeWithMeDialogTest extends LibraryTestBase {
3939
private static final boolean IDEA_VERSION_WITH_CWM_DIALOG_OPENED = ideaVersionInt >= 20212;
4040

4141
@BeforeAll
42-
public static void prepareProject() {
42+
static void prepareProject() {
4343
if (IDEA_VERSION_WITH_CWM_DIALOG_OPENED) {
4444
NewProjectDialogWizard newProjectDialogWizard = openNewProjectDialogFromWelcomeDialog(remoteRobot);
4545
NewProjectFirstPage newProjectFirstPage = newProjectDialogWizard.find(NewProjectFirstPage.class, Duration.ofSeconds(10));
@@ -71,14 +71,14 @@ public static void prepareProject() {
7171
}
7272

7373
@AfterAll
74-
public static void closeCurrentProject() {
74+
static void closeCurrentProject() {
7575
if (IDEA_VERSION_WITH_CWM_DIALOG_OPENED) {
7676
CreateCloseUtils.closeProject(remoteRobot);
7777
}
7878
}
7979

8080
@Test
81-
public void closeCodeWithMe() {
81+
void closeCodeWithMe() {
8282
if (IDEA_VERSION_WITH_CWM_DIALOG_OPENED) {
8383
CodeWithMeDialog.closeCodeWithMePopupIfItAppears(remoteRobot);
8484
}

src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/information/ProjectStructureDialogTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,21 @@
3131
*
3232
3333
*/
34-
public class ProjectStructureDialogTest extends LibraryTestBase {
34+
class ProjectStructureDialogTest extends LibraryTestBase {
3535
private static final String PROJECT_NAME = "tip_dialog_java_project";
3636

3737
@BeforeAll
38-
public static void prepareProject() {
38+
static void prepareProject() {
3939
CreateCloseUtils.createNewProject(remoteRobot, PROJECT_NAME, CreateCloseUtils.NewProjectType.PLAIN_JAVA);
4040
}
4141

4242
@AfterAll
43-
public static void closeProject() {
43+
static void closeProject() {
4444
CreateCloseUtils.closeProject(remoteRobot);
4545
}
4646

4747
@Test
48-
public void projectStructureDialogTest() {
48+
void projectStructureDialogTest() {
4949
dialogTest(() -> {
5050
ProjectStructureDialog projectStructureDialog = remoteRobot.find(ProjectStructureDialog.class, Duration.ofSeconds(10));
5151
projectStructureDialog.cancel();

src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/information/TipDialogTest.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333
*
3434
3535
*/
36-
public class TipDialogTest extends LibraryTestBase {
36+
class TipDialogTest extends LibraryTestBase {
3737
private TipDialog tipDialog;
3838

3939
@AfterAll
40-
public static void cleanUp() {
40+
static void cleanUp() {
4141
if (ideaVersionInt >= 20213) {
4242
JTreeFixture jTreeFixture = remoteRobot.find(JTreeFixture.class, byXpath(XPathDefinitions.TREE));
4343
jTreeFixture.findText("Projects").click();
@@ -48,24 +48,25 @@ public static void cleanUp() {
4848
}
4949

5050
@BeforeEach
51-
public void prepareTipDialog() {
51+
void prepareTipDialog() {
5252
tipDialog = remoteRobot.find(FlatWelcomeFrame.class).openTipDialog();
5353
}
5454

5555
@Test
56-
public void closeButtonTest() {
57-
remoteRobot.find(TipDialog.class, Duration.ofSeconds(5));
56+
void closeButtonTest() {
57+
Duration timeout = Duration.ofSeconds(5);
58+
remoteRobot.find(TipDialog.class, timeout);
5859
tipDialog.close();
5960
try {
60-
remoteRobot.find(TipDialog.class, Duration.ofSeconds(5));
61+
remoteRobot.find(TipDialog.class, timeout);
6162
fail("The 'Tif of the Day' dialog should be closed but is not.");
6263
} catch (WaitForConditionTimeoutException e) {
6364
LOGGER.log(Level.INFO, e.getMessage(), e);
6465
}
6566
}
6667

6768
@Test
68-
public void dontShowTipsCheckBoxTest() {
69+
void dontShowTipsCheckBoxTest() {
6970
boolean checkboxStateBefore = tipDialog.dontShowTipsCheckBox().isSelected();
7071
tipDialog.dontShowTipsCheckBox().setValue(!checkboxStateBefore);
7172
boolean checkboxStateAfter = tipDialog.dontShowTipsCheckBox().isSelected();

0 commit comments

Comments
 (0)