|
2 | 2 | * Copyright © Magento, Inc. All rights reserved.
|
3 | 3 | * See COPYING.txt for license details.
|
4 | 4 | */
|
| 5 | + |
5 | 6 | package com.magento.idea.magento2plugin.actions.generation.generator;
|
6 | 7 |
|
7 | 8 | import com.intellij.psi.PsiDirectory;
|
|
10 | 11 | import com.magento.idea.magento2plugin.BaseProjectTestCase;
|
11 | 12 | import com.magento.idea.magento2plugin.magento.packages.File;
|
12 | 13 | import com.magento.idea.magento2plugin.project.util.GetProjectBasePath;
|
| 14 | +import org.junit.After; |
13 | 15 | import org.junit.Before;
|
14 | 16 |
|
15 |
| -abstract public class BaseGeneratorTestCase extends BaseProjectTestCase { |
16 |
| - private static final String testDataFolderPath = "testData" + File.separator + "actions" + File.separator; |
17 |
| - private static final String fixturesFolderPath = "generation" + File.separator + "generator" + File.separator; |
| 17 | +public abstract class BaseGeneratorTestCase extends BaseProjectTestCase { |
| 18 | + private static final String TEST_DATA_FOLDER_PATH = "testData" + File.separator |
| 19 | + + "actions" + File.separator; |
| 20 | + private static final String FIXTURES_FOLDER_PATH = "generation" + File.separator |
| 21 | + + "generator" + File.separator; |
18 | 22 |
|
19 | 23 | @Override
|
20 | 24 | @Before
|
21 | 25 | protected void setUp() throws Exception {
|
22 | 26 | super.setUp();
|
23 |
| - myFixture.setTestDataPath(testDataFolderPath); |
| 27 | + myFixture.setTestDataPath(TEST_DATA_FOLDER_PATH); |
24 | 28 | }
|
25 | 29 |
|
26 | 30 | @Override
|
| 31 | + @After |
27 | 32 | protected void tearDown() throws Exception {
|
28 | 33 | super.tearDown();
|
29 | 34 | LightPlatformTestCase.closeAndDeleteProject();
|
30 | 35 | }
|
31 | 36 |
|
32 |
| - protected String getFixturePath(String fileName) { |
33 |
| - return prepareFixturePath(fileName, fixturesFolderPath); |
| 37 | + protected String getFixturePath(final String fileName) { |
| 38 | + return prepareFixturePath(fileName, FIXTURES_FOLDER_PATH); |
34 | 39 | }
|
35 | 40 |
|
| 41 | + @SuppressWarnings({"PMD.JUnitAssertionsShouldIncludeMessage"}) |
36 | 42 | protected void assertGeneratedFileIsCorrect(
|
37 |
| - PsiFile expectedFile, |
38 |
| - String expectedDirectory, |
39 |
| - PsiFile resultFile) { |
40 |
| - |
| 43 | + final PsiFile expectedFile, |
| 44 | + final String expectedDirectory, |
| 45 | + final PsiFile resultFile |
| 46 | + ) { |
41 | 47 | assertTrue(resultFile.getContainingDirectory().getVirtualFile().getPath()
|
42 |
| - .endsWith(expectedDirectory)); |
| 48 | + .endsWith(expectedDirectory)); |
43 | 49 | assertEquals(expectedFile.getText(), resultFile.getText());
|
44 | 50 | assertEquals(expectedFile.getName(), resultFile.getName());
|
45 | 51 | }
|
46 | 52 |
|
47 | 53 | protected PsiDirectory getProjectDirectory() {
|
48 | 54 | return myFixture.getPsiManager().findDirectory(
|
49 |
| - GetProjectBasePath.execute(myFixture.getProject()) |
| 55 | + GetProjectBasePath.execute(myFixture.getProject()) |
50 | 56 | );
|
51 | 57 | }
|
52 | 58 | }
|
0 commit comments