-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from Zir0-93/i46
closes #46
- Loading branch information
Showing
3 changed files
with
108 additions
and
16 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
81 changes: 81 additions & 0 deletions
81
clarpse/src/test/java/com/clarity/java/ComponentCodeTest.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,81 @@ | ||
package com.clarity.java; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.junit.Test; | ||
|
||
import com.clarity.parser.ClarpseProject; | ||
import com.clarity.parser.Lang; | ||
import com.clarity.parser.ParseRequestContent; | ||
import com.clarity.parser.RawFile; | ||
import com.clarity.sourcemodel.OOPSourceCodeModel; | ||
|
||
public class ComponentCodeTest { | ||
|
||
@Test | ||
public void testClassLevelCode() throws Exception { | ||
|
||
final String code = "public class Test { @Override Test(String str) { Object localVar;} @Deprecated interface Cakes { abstract void tester(); } }"; | ||
final ParseRequestContent rawData = new ParseRequestContent(Lang.JAVA); | ||
rawData.insertFile(new RawFile("file2.java", code)); | ||
final ClarpseProject parseService = new ClarpseProject(rawData); | ||
final OOPSourceCodeModel generatedSourceModel = parseService.result(); | ||
assertTrue(generatedSourceModel.getComponent("Test").code().trim().replaceAll("[\\n\\t\\r ]", "") | ||
.equalsIgnoreCase(code.trim().replaceAll("[\\n\\t ]", ""))); | ||
} | ||
|
||
@Test | ||
public void testMethodLevelCode() throws Exception { | ||
|
||
final String code = "public class Test { @Override Test(String str) { Object localVar;} @Deprecated interface Cakes { abstract void tester(); } }"; | ||
final ParseRequestContent rawData = new ParseRequestContent(Lang.JAVA); | ||
rawData.insertFile(new RawFile("file2.java", code)); | ||
final ClarpseProject parseService = new ClarpseProject(rawData); | ||
final OOPSourceCodeModel generatedSourceModel = parseService.result(); | ||
assertTrue(generatedSourceModel.getComponent("Test.Test(java.lang.String)").code().trim() | ||
.replaceAll("[\\n\\t\\r ]", "") | ||
.equalsIgnoreCase("@Override Test(String str) { Object localVar;}".trim().replaceAll("[\\n\\t ]", ""))); | ||
} | ||
|
||
@Test | ||
public void testMethodParamLevelCode() throws Exception { | ||
|
||
final String code = "public class Test { @Override Test(String str) { Object localVar;} @Deprecated interface Cakes { abstract void tester(); } }"; | ||
final ParseRequestContent rawData = new ParseRequestContent(Lang.JAVA); | ||
rawData.insertFile(new RawFile("file2.java", code)); | ||
final ClarpseProject parseService = new ClarpseProject(rawData); | ||
final OOPSourceCodeModel generatedSourceModel = parseService.result(); | ||
assertTrue(generatedSourceModel.getComponent("Test.Test(java.lang.String).str").code().trim() | ||
.replaceAll("[\\n\\t\\r ]", "").equalsIgnoreCase("String str".trim().replaceAll("[\\n\\t ]", ""))); | ||
} | ||
|
||
@Test | ||
public void testInterfaceLevelCode() throws Exception { | ||
|
||
final String code = "public class Test { @Override Test(String str) { Object localVar;} @Deprecated interface Cakes { abstract void tester(); } }"; | ||
final ParseRequestContent rawData = new ParseRequestContent(Lang.JAVA); | ||
rawData.insertFile(new RawFile("file2.java", code)); | ||
final ClarpseProject parseService = new ClarpseProject(rawData); | ||
final OOPSourceCodeModel generatedSourceModel = parseService.result(); | ||
assertTrue(generatedSourceModel | ||
.getComponent("Test.Cakes") | ||
.code() | ||
.trim() | ||
.replaceAll("[\\n\\t\\r ]", "") | ||
.equalsIgnoreCase( | ||
"@Deprecated interface Cakes { abstract void tester(); }".trim().replaceAll("[\\n\\t ]", ""))); | ||
} | ||
|
||
@Test | ||
public void testInterfaceMethodLevelCode() throws Exception { | ||
|
||
final String code = "public class Test { @Override Test(String str) { Object localVar;} @Deprecated interface Cakes { abstract void tester(); } }"; | ||
final ParseRequestContent rawData = new ParseRequestContent(Lang.JAVA); | ||
rawData.insertFile(new RawFile("file2.java", code)); | ||
final ClarpseProject parseService = new ClarpseProject(rawData); | ||
final OOPSourceCodeModel generatedSourceModel = parseService.result(); | ||
assertTrue(generatedSourceModel.getComponent("Test.Cakes.tester()").code().trim().replaceAll("[\\n\\t ]", "") | ||
.equalsIgnoreCase("abstract void tester();".trim().replaceAll("[\\n\\t\\r ]", ""))); | ||
} | ||
|
||
} |