-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: implement test for moving prototype
Add tests and cleanup interfaces and responsibilities
- Loading branch information
Showing
8 changed files
with
198 additions
and
18 deletions.
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
64 changes: 64 additions & 0 deletions
64
src/test/java/de/vette/idea/neos/fusion/refactoring/MovePrototypeTest.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,64 @@ | ||
package de.vette.idea.neos.fusion.refactoring; | ||
|
||
import com.intellij.testFramework.fixtures.BasePlatformTestCase; | ||
import de.vette.idea.neos.lang.fusion.refactoring.MovePrototypeDialog; | ||
import de.vette.idea.neos.lang.fusion.refactoring.MovePrototypeProcessor; | ||
import de.vette.idea.neos.lang.fusion.refactoring.MovePrototypeToFile; | ||
import util.FusionTestUtils; | ||
|
||
import java.io.File; | ||
|
||
public class MovePrototypeTest extends BasePlatformTestCase { | ||
|
||
@Override | ||
protected String getTestDataPath() { | ||
return FusionTestUtils.BASE_TEST_DATA_PATH; | ||
} | ||
|
||
public void testFindAllPrototypesInFile() { | ||
myFixture.configureByFile("fusion/refactoring/move_prototypes_before.fusion"); | ||
var signatures = MovePrototypeToFile.findAllPrototypeSignatures(myFixture.getFile()); | ||
var signatureNames = signatures.stream().map(signature -> signature.getType().getText()); | ||
assertContainsElements( | ||
signatureNames.toList(), | ||
"Vendor.Package:Prototype.CopiedFrom", | ||
"Vendor.Package:Prototype.WithImplementation", | ||
"Vendor.Package:Prototype.Example2" | ||
); | ||
} | ||
|
||
public void testSuggestedTargetFileName() { | ||
myFixture.configureByFile("fusion/refactoring/move_prototypes_before.fusion"); | ||
var signatures = MovePrototypeToFile.findAllPrototypeSignatures(myFixture.getFile()); | ||
String basePath = "current" + File.separator + "path" + File.separator; | ||
String sourceFilePath = basePath + "CopiedFrom.fusion"; | ||
|
||
var suggestedFilename = MovePrototypeDialog.getSuggestedTargetFileName(sourceFilePath, signatures); | ||
assertEquals(basePath + "WithImplementation.fusion", suggestedFilename); | ||
} | ||
|
||
public void testMoveSinglePrototypes() { | ||
myFixture.configureByFile("fusion/refactoring/move_prototypes_before.fusion"); | ||
var signatures = MovePrototypeToFile.findAllPrototypeSignatures(myFixture.getFile()); | ||
|
||
var after = myFixture.addFileToProject("after.fusion", ""); | ||
myFixture.configureFromTempProjectFile("after.fusion"); | ||
|
||
var processor = new MovePrototypeProcessor(getProject(), "Move Prototypes", after, signatures.subList(1, 2), false); | ||
processor.run(); | ||
myFixture.checkResultByFile("after.fusion", "fusion/refactoring/move_prototypes_target2.fusion", false); | ||
} | ||
|
||
public void testMoveMultiplePrototypes() { | ||
myFixture.configureByFile("fusion/refactoring/move_prototypes_before.fusion"); | ||
var signatures = MovePrototypeToFile.findAllPrototypeSignatures(myFixture.getFile()); | ||
|
||
var after = myFixture.addFileToProject("after.fusion", ""); | ||
myFixture.configureFromTempProjectFile("after.fusion"); | ||
|
||
var processor = new MovePrototypeProcessor(getProject(), "Move Prototypes", after, signatures.subList(0, 2), false); | ||
processor.run(); | ||
myFixture.checkResultByFile("fusion/refactoring/move_prototypes_before.fusion", "fusion/refactoring/move_prototypes_after1.fusion", false); | ||
myFixture.checkResultByFile("after.fusion", "fusion/refactoring/move_prototypes_target1.fusion", false); | ||
} | ||
} |
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,14 @@ | ||
Namespace.Controller.Action = Vendor.Package:Prototype.At.Path { | ||
prototype(Vendor.Package:Prototype.OverrideInPath) { | ||
} | ||
} | ||
|
||
# Some global comment | ||
# with multiple lines | ||
|
||
|
||
|
||
prototype(Vendor.Package:Prototype.Example2) { | ||
prototype(Vendor.Package:OverrideInPrototype) { | ||
} | ||
} |
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,24 @@ | ||
Namespace.Controller.Action = Vendor.Package:Prototype.At.Path { | ||
prototype(Vendor.Package:Prototype.OverrideInPath) { | ||
} | ||
} | ||
|
||
# Some global comment | ||
# with multiple lines | ||
|
||
# A comment for Prototype.CopiedFrom | ||
# that can span multiple lines | ||
prototype(Vendor.Package:Prototype.CopiedFrom) < prototype(Vendor.Package:Example1) { | ||
} | ||
|
||
/** | ||
* Comment block for Prototype.WithImplementation | ||
*/ | ||
prototype(Vendor.Package:Prototype.WithImplementation) { | ||
@class = 'Vendor\\Package\\Fusion\\WithImplementationImplementation' | ||
} | ||
|
||
prototype(Vendor.Package:Prototype.Example2) { | ||
prototype(Vendor.Package:OverrideInPrototype) { | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
testData/fusion/refactoring/move_prototypes_target1.fusion
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,10 @@ | ||
# A comment for Prototype.CopiedFrom | ||
# that can span multiple lines | ||
prototype(Vendor.Package:Prototype.CopiedFrom) < prototype(Vendor.Package:Example1) { | ||
} | ||
/** | ||
* Comment block for Prototype.WithImplementation | ||
*/ | ||
prototype(Vendor.Package:Prototype.WithImplementation) { | ||
@class = 'Vendor\\Package\\Fusion\\WithImplementationImplementation' | ||
} |
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,6 @@ | ||
/** | ||
* Comment block for Prototype.WithImplementation | ||
*/ | ||
prototype(Vendor.Package:Prototype.WithImplementation) { | ||
@class = 'Vendor\\Package\\Fusion\\WithImplementationImplementation' | ||
} |