Skip to content

Commit c308fdd

Browse files
committed
Fixed PMD issues
1 parent 6597899 commit c308fdd

File tree

8 files changed

+54
-43
lines changed

8 files changed

+54
-43
lines changed

testData/linemarker/php/GraphQlResolverUsageLinemarkerRegistrar/regularClassShouldNotHaveLinemarker/ClassNotConfiguredInSchema.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88

99
class ClassNotConfiguredInSchema
1010
{
11-
}
11+
}

testData/linemarker/php/GraphQlResolverUsageLinemarkerRegistrar/resolverClassShouldHaveLinemarker/Resolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010

1111
class ImplementsResolverInterface implements ResolverInterface
1212
{
13-
}
13+
}

tests/com/magento/idea/magento2plugin/linemarker/LinemarkerFixtureTestCase.java

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright © Magento, Inc. All rights reserved.
33
* See COPYING.txt for license details.
44
*/
5+
56
package com.magento.idea.magento2plugin.linemarker;
67

78
import com.intellij.codeInsight.daemon.LineMarkerInfo;
@@ -14,27 +15,26 @@
1415

1516
abstract public class LinemarkerFixtureTestCase extends BaseProjectTestCase {
1617

17-
private static final String testDataFolderPath = "testData" + File.separator + "linemarker" + File.separator;
18+
private static final String TEST_DATA_PATH = "testData" + File.separator + "linemarker" + File.separator;
1819

1920
@Override
2021
protected void setUp() throws Exception {
2122
super.setUp();
22-
myFixture.setTestDataPath(testDataFolderPath);
23+
myFixture.setTestDataPath(TEST_DATA_PATH);
2324
}
2425

25-
protected String getFixturePath(String fileName, String folder) {
26+
protected String getFixturePath(final String fileName, final String folder) {
2627
return prepareFixturePath(fileName, folder + File.separator);
2728
}
2829

29-
protected void assertHasLinemarkerWithTooltipAndIcon(String tooltip, String icon) {
30+
protected void assertHasLinemarkerWithTooltipAndIcon(final String tooltip, final String icon) {
3031
myFixture.doHighlighting();
31-
String lineMarkerNotFound = "Failed that documents contains linemarker with the tooltip `%s`";
3232

33-
List<LineMarkerInfo<?>> lineMarkers = getDocumentLineMarkers();
33+
final List<LineMarkerInfo<?>> lineMarkers = getDocumentLineMarkers();
3434
assertNotEmpty(lineMarkers);
35-
for (LineMarkerInfo lineMarkerInfo: lineMarkers) {
36-
String lineMarkerTooltip = lineMarkerInfo.getLineMarkerTooltip();
37-
Icon lineMarkerIcon = lineMarkerInfo.getIcon();
35+
for (final LineMarkerInfo lineMarkerInfo: lineMarkers) {
36+
final String lineMarkerTooltip = lineMarkerInfo.getLineMarkerTooltip();
37+
final Icon lineMarkerIcon = lineMarkerInfo.getIcon();
3838
if (lineMarkerTooltip == null || lineMarkerIcon == null) {
3939
continue;
4040
}
@@ -44,18 +44,19 @@ protected void assertHasLinemarkerWithTooltipAndIcon(String tooltip, String icon
4444
}
4545
}
4646

47+
final String lineMarkerNotFound = "Failed that documents contains linemarker with the tooltip `%s`";
4748
fail(String.format(lineMarkerNotFound, tooltip));
4849
}
4950

50-
protected void assertHasNoLinemarkerWithTooltipAndIcon(String tooltip, String icon) {
51+
protected void assertHasNoLinemarkerWithTooltipAndIcon(final String tooltip, final String icon) {
5152
myFixture.doHighlighting();
52-
String lineMarkerExist = "Failed that documents not contains linemarker with the tooltip `%s`";
53+
final String lineMarkerExist = "Failed that documents not contains linemarker with the tooltip `%s`";
5354

54-
List<LineMarkerInfo<?>> lineMarkers = getDocumentLineMarkers();
55+
final List<LineMarkerInfo<?>> lineMarkers = getDocumentLineMarkers();
5556
assertNotEmpty(lineMarkers);
56-
for (LineMarkerInfo lineMarkerInfo: lineMarkers) {
57-
String lineMarkerTooltip = lineMarkerInfo.getLineMarkerTooltip();
58-
Icon lineMarkerIcon = lineMarkerInfo.getIcon();
57+
for (final LineMarkerInfo lineMarkerInfo: lineMarkers) {
58+
final String lineMarkerTooltip = lineMarkerInfo.getLineMarkerTooltip();
59+
final Icon lineMarkerIcon = lineMarkerInfo.getIcon();
5960
if (lineMarkerTooltip == null || lineMarkerIcon == null) {
6061
continue;
6162
}

tests/com/magento/idea/magento2plugin/linemarker/graphqls/GraphQlResolverClassLinemarkerRegistrarTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
public class GraphQlResolverClassLinemarkerRegistrarTest extends LinemarkerFixtureTestCase {
1111

1212
/**
13-
* Tests linemarkers in the schema.graphqls file for PHP resolver classes
13+
* Tests linemarkers in the schema.graphqls file for PHP resolver classes.
1414
*/
1515
public void testWithValidSchemaResolver() {
1616
myFixture.configureByFile(this.getFixturePath("schema.graphqls", "graphqls"));

tests/com/magento/idea/magento2plugin/linemarker/php/ConfigurationTypeClassLinemarkerRegistrarTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,21 @@
22
* Copyright © Magento, Inc. All rights reserved.
33
* See COPYING.txt for license details.
44
*/
5+
56
package com.magento.idea.magento2plugin.linemarker.php;
67

78
import com.magento.idea.magento2plugin.linemarker.LinemarkerFixtureTestCase;
89

910
public class ConfigurationTypeClassLinemarkerRegistrarTest extends LinemarkerFixtureTestCase {
1011

1112
public void testTypeNameClassShouldHaveLinemarker() {
12-
String filePath = this.getFixturePath("Topmenu.php", "php");
13-
myFixture.configureByFile(filePath);
13+
myFixture.configureByFile(this.getFixturePath("Topmenu.php", "php"));
1414

1515
assertHasLinemarkerWithTooltipAndIcon("Navigate to configuration", "/fileTypes/xml.svg");
1616
}
1717

1818
public void testRegularPhpClassShouldNotHaveLinemarker() {
19-
String filePath = this.getFixturePath("ClassNotConfiguredInDiXml.php", "php");
20-
myFixture.configureByFile(filePath);
19+
myFixture.configureByFile(this.getFixturePath("ClassNotConfiguredInDiXml.php", "php"));
2120

2221
assertHasNoLinemarkerWithTooltipAndIcon("Navigate to configuration", "/fileTypes/xml.svg");
2322
}

tests/com/magento/idea/magento2plugin/linemarker/php/GraphQlResolverUsageLinemarkerRegistrarTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,19 @@
88
import com.magento.idea.magento2plugin.linemarker.LinemarkerFixtureTestCase;
99

1010
public class GraphQlResolverUsageLinemarkerRegistrarTest extends LinemarkerFixtureTestCase {
11+
12+
/**
13+
* Tests linemarkers in the resolver class.
14+
*/
1115
public void testResolverClassShouldHaveLinemarker() {
1216
myFixture.configureByFile(this.getFixturePath("Resolver.php", "php"));
1317

1418
assertHasNoLinemarkerWithTooltipAndIcon("Navigate to schema", "/icons/graphqlFile.svg");
1519
}
1620

21+
/**
22+
* Tests linemarkers in the regular class.
23+
*/
1724
public void testRegularClassShouldNotHaveLinemarker() {
1825
myFixture.configureByFile(this.getFixturePath("ClassNotConfiguredInSchema.php", "php"));
1926

tests/com/magento/idea/magento2plugin/linemarker/php/ObserverClassLinemarkerRegistrarTest.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,27 @@
22
* Copyright © Magento, Inc. All rights reserved.
33
* See COPYING.txt for license details.
44
*/
5+
56
package com.magento.idea.magento2plugin.linemarker.php;
67

78
import com.magento.idea.magento2plugin.linemarker.LinemarkerFixtureTestCase;
89

910
public class ObserverClassLinemarkerRegistrarTest extends LinemarkerFixtureTestCase {
1011

12+
/**
13+
* Tests linemarkers in the Observer class.
14+
*/
1115
public void testObserverClassShouldHaveLinemarker() {
12-
String filePath = this.getFixturePath("TestObserver.php", "php");
13-
myFixture.configureByFile(filePath);
16+
myFixture.configureByFile(this.getFixturePath("TestObserver.php", "php"));
1417

1518
assertHasLinemarkerWithTooltipAndIcon("Navigate to configuration", "/fileTypes/xml.svg");
1619
}
1720

21+
/**
22+
* Tests linemarkers in the regular class.
23+
*/
1824
public void testRegularPhpClassShouldNotHaveLinemarker() {
19-
String filePath = this.getFixturePath("TestNotObserver.php", "php");
20-
myFixture.configureByFile(filePath);
25+
myFixture.configureByFile(this.getFixturePath("TestNotObserver.php", "php"));
2126

2227
assertHasNoLinemarkerWithTooltipAndIcon("Navigate to configuration", "/fileTypes/xml.svg");
2328
}

tests/com/magento/idea/magento2plugin/linemarker/php/WebApiLinemarkerRegistrarTest.java

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,63 +2,62 @@
22
* Copyright © Magento, Inc. All rights reserved.
33
* See COPYING.txt for license details.
44
*/
5+
56
package com.magento.idea.magento2plugin.linemarker.php;
67

78
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
89
import com.magento.idea.magento2plugin.MagentoIcons;
910
import com.magento.idea.magento2plugin.linemarker.LinemarkerFixtureTestCase;
1011

12+
@SuppressWarnings("PMD.JUnitTestContainsTooManyAsserts")
1113
public class WebApiLinemarkerRegistrarTest extends LinemarkerFixtureTestCase {
1214

13-
private static final String expectedClassLineMarkerTooltip =
15+
private static final String EXPECTED_CLASS_LINE_MARKER_TOOLTIP =
1416
"Navigate to Web API configuration:<pre> PUT /V1/blog/post\n" +
1517
" POST /V1/blog/update\n" +
1618
"</pre>";
1719

18-
private static final String expectedMethodCreateLineMarkerTooltip =
20+
private static final String EXPECTED_METHOD_CREATE_LINE_MARKER_TOOLTIP =
1921
"Navigate to Web API configuration:<pre> POST /V1/blog/update\n" +
2022
"</pre>";
2123

22-
private static final String expectedMethodUpdateLineMarkerTooltip =
24+
private static final String EXPECTED_METHOD_UPDATE_LINE_MARKER_TOOLTIP =
2325
"Navigate to Web API configuration:<pre> PUT /V1/blog/post\n" +
2426
"</pre>";
2527

2628
/**
27-
* Class configured as WEB API service in web_api.xml should have WEB API line markers
29+
* Class configured as WEB API service in web_api.xml should have WEB API line markers.
2830
*/
2931
public void testWebApiServiceShouldHaveLinemarker() {
30-
String filePath = this.getFixturePath("TestService.php", "php");
31-
3232
//work around for issue caused by com.magento.idea.magento2plugin.linemarker.xml.LineMarkerXmlTagDecorator
3333
//in com.intellij.psi.impl.smartPointers.SmartPsiElementPointerImpl.createElementInfo
34-
boolean isInStressTestCurrent = ApplicationInfoImpl.isInStressTest();
34+
final boolean isInStressTestCurrent = ApplicationInfoImpl.isInStressTest();
3535
ApplicationInfoImpl.setInStressTest(true);
3636

37-
myFixture.configureByFile(filePath);
37+
myFixture.configureByFile(this.getFixturePath("TestService.php", "php"));
3838

3939
//assert class line marker
40-
assertHasLinemarkerWithTooltipAndIcon(expectedClassLineMarkerTooltip, MagentoIcons.WEB_API.toString());
40+
assertHasLinemarkerWithTooltipAndIcon(EXPECTED_CLASS_LINE_MARKER_TOOLTIP, MagentoIcons.WEB_API.toString());
4141

4242
//assert methods line markers
43-
assertHasLinemarkerWithTooltipAndIcon(expectedMethodCreateLineMarkerTooltip, MagentoIcons.WEB_API.toString());
44-
assertHasLinemarkerWithTooltipAndIcon(expectedMethodUpdateLineMarkerTooltip, MagentoIcons.WEB_API.toString());
43+
assertHasLinemarkerWithTooltipAndIcon(EXPECTED_METHOD_CREATE_LINE_MARKER_TOOLTIP, MagentoIcons.WEB_API.toString());
44+
assertHasLinemarkerWithTooltipAndIcon(EXPECTED_METHOD_UPDATE_LINE_MARKER_TOOLTIP, MagentoIcons.WEB_API.toString());
4545

4646
//restore default value
4747
ApplicationInfoImpl.setInStressTest(isInStressTestCurrent);
4848
}
4949

5050
/**
51-
* Regular class should not have WEB API line markers
51+
* Regular class should not have WEB API line markers.
5252
*/
5353
public void testRegularPhpClassShouldNotHaveLinemarker() {
54-
String filePath = this.getFixturePath("ClassNotConfiguredInWebApiXml.php", "php");
55-
myFixture.configureByFile(filePath);
54+
myFixture.configureByFile(this.getFixturePath("ClassNotConfiguredInWebApiXml.php", "php"));
5655

5756
//assert class line marker
58-
assertHasNoLinemarkerWithTooltipAndIcon(expectedClassLineMarkerTooltip, MagentoIcons.WEB_API.toString());
57+
assertHasNoLinemarkerWithTooltipAndIcon(EXPECTED_CLASS_LINE_MARKER_TOOLTIP, MagentoIcons.WEB_API.toString());
5958

6059
//assert methods line markers
61-
assertHasNoLinemarkerWithTooltipAndIcon(expectedMethodCreateLineMarkerTooltip, MagentoIcons.WEB_API.toString());
62-
assertHasNoLinemarkerWithTooltipAndIcon(expectedMethodUpdateLineMarkerTooltip, MagentoIcons.WEB_API.toString());
60+
assertHasNoLinemarkerWithTooltipAndIcon(EXPECTED_METHOD_CREATE_LINE_MARKER_TOOLTIP, MagentoIcons.WEB_API.toString());
61+
assertHasNoLinemarkerWithTooltipAndIcon(EXPECTED_METHOD_UPDATE_LINE_MARKER_TOOLTIP, MagentoIcons.WEB_API.toString());
6362
}
6463
}

0 commit comments

Comments
 (0)