Skip to content

Commit

Permalink
bugfix for #4 "creation of test classes fails on nested maven project" (
Browse files Browse the repository at this point in the history
#7)

* bugfix for #4 "creation of test classes fails on nested maven project"
* Remove the block of commented-out lines of code.
* Remove the block of commented-out lines of code.
  • Loading branch information
fofocx authored and seratch committed Mar 30, 2017
1 parent 291c391 commit 8c307eb
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 16 deletions.
Expand Up @@ -46,8 +46,8 @@ protected Configuration getConfiguration(IPreferenceStore store, ISelection sele
} }
if (!isNotSelected(structuredSelection) && !isSelectedSeveral(structuredSelection)) { if (!isNotSelected(structuredSelection) && !isSelectedSeveral(structuredSelection)) {
String projectName = getProjectName(structuredSelection); String projectName = getProjectName(structuredSelection);
String projectRootPath = getWorkspaceRootAbsolutePath(getIWorkspaceRoot()) String projectRootPath = getIWorkspaceRoot().findMember(projectName).getLocationURI().getPath()
+ StringValue.DirectorySeparator.General + projectName + StringValue.DirectorySeparator.General; + StringValue.DirectorySeparator.General;
String configFilepath = projectRootPath + "junithelper-config.properties"; String configFilepath = projectRootPath + "junithelper-config.properties";
File configProperites = new File(configFilepath); File configProperites = new File(configFilepath);
if (configProperites.exists()) { if (configProperites.exists()) {
Expand Down Expand Up @@ -108,10 +108,6 @@ protected String getPathFromProjectRoot(StructuredSelection structuredSelection)
return ResourcePathUtil.getPathStartsFromProjectRoot(structuredSelection); return ResourcePathUtil.getPathStartsFromProjectRoot(structuredSelection);
} }


protected String getWorkspaceRootAbsolutePath(IWorkspaceRoot workspaceRoot) {
return workspaceRoot.getLocation().toString();
}

protected String getResourcePathForTargetClassFile(StructuredSelection structuredSelection) { protected String getResourcePathForTargetClassFile(StructuredSelection structuredSelection) {
// path started from project root // path started from project root
String pathFromProjectRoot = getPathFromProjectRoot(structuredSelection); String pathFromProjectRoot = getPathFromProjectRoot(structuredSelection);
Expand Down
Expand Up @@ -102,8 +102,8 @@ public void run(IAction action) {
// get project path, resource path // get project path, resource path
projectName = getProjectName(structuredSelection); projectName = getProjectName(structuredSelection);
resourcePathForTargetClassFile = getResourcePathForTargetClassFile(structuredSelection); resourcePathForTargetClassFile = getResourcePathForTargetClassFile(structuredSelection);
String projectRootAbsolutePath = getWorkspaceRootAbsolutePath(getIWorkspaceRoot()) String projectRootAbsolutePath = getIWorkspaceRoot().findMember(projectName).getLocationURI().getPath()
+ StringValue.DirectorySeparator.General + projectName + StringValue.DirectorySeparator.General; + StringValue.DirectorySeparator.General;


resourcePathForTestClassFile = resourcePathForTargetClassFile.replaceFirst( resourcePathForTestClassFile = resourcePathForTargetClassFile.replaceFirst(
config.directoryPathOfProductSourceCode, config.directoryPathOfTestSourceCode).replace( config.directoryPathOfProductSourceCode, config.directoryPathOfTestSourceCode).replace(
Expand Down
Expand Up @@ -74,8 +74,8 @@ public void run(IAction action) {
config.directoryPathOfProductSourceCode, config.directoryPathOfTestSourceCode).replaceFirst( config.directoryPathOfProductSourceCode, config.directoryPathOfTestSourceCode).replaceFirst(
"[^(Test)]\\.java$", StringValue.JUnit.TestClassNameSuffix + StringValue.FileExtension.JavaFile); "[^(Test)]\\.java$", StringValue.JUnit.TestClassNameSuffix + StringValue.FileExtension.JavaFile);
String projectName = getProjectName(structuredSelection); String projectName = getProjectName(structuredSelection);
String projectRootAbsolutePath = getWorkspaceRootAbsolutePath(getIWorkspaceRoot()) String projectRootAbsolutePath = getIWorkspaceRoot().findMember(projectName).getLocationURI().getPath()
+ StringValue.DirectorySeparator.General + projectName + StringValue.DirectorySeparator.General; + StringValue.DirectorySeparator.General;


// ---------------------------------------- // ----------------------------------------
// check selection // check selection
Expand Down
Expand Up @@ -74,8 +74,8 @@ public void run(IAction action) {
config.directoryPathOfProductSourceCode, config.directoryPathOfTestSourceCode).replaceFirst( config.directoryPathOfProductSourceCode, config.directoryPathOfTestSourceCode).replaceFirst(
"[^(Test)]\\.java$", StringValue.JUnit.TestClassNameSuffix + StringValue.FileExtension.JavaFile); "[^(Test)]\\.java$", StringValue.JUnit.TestClassNameSuffix + StringValue.FileExtension.JavaFile);
String projectName = getProjectName(structuredSelection); String projectName = getProjectName(structuredSelection);
String projectRootAbsolutePath = getWorkspaceRootAbsolutePath(getIWorkspaceRoot()) String projectRootAbsolutePath = getIWorkspaceRoot().findMember(projectName).getLocationURI().getPath()
+ StringValue.DirectorySeparator.General + projectName + StringValue.DirectorySeparator.General; + StringValue.DirectorySeparator.General;


// ---------------------------------------- // ----------------------------------------
// check selection // check selection
Expand Down
Expand Up @@ -98,8 +98,8 @@ public void run(IAction action) {
StringValue.FileExtension.JavaFile, StringValue.FileExtension.JavaFile,
StringValue.JUnit.TestClassNameSuffix + StringValue.FileExtension.JavaFile); StringValue.JUnit.TestClassNameSuffix + StringValue.FileExtension.JavaFile);


String projectRootAbsolutePath = getWorkspaceRootAbsolutePath(getIWorkspaceRoot()) String projectRootAbsolutePath = getIWorkspaceRoot().findMember(projectName).getLocationURI().getPath()
+ StringValue.DirectorySeparator.General + projectName + StringValue.DirectorySeparator.General; + StringValue.DirectorySeparator.General;


String testCaseFileAbsolutePath = projectRootAbsolutePath + resourcePathForTestCaseFile; String testCaseFileAbsolutePath = projectRootAbsolutePath + resourcePathForTestCaseFile;


Expand Down
Expand Up @@ -72,8 +72,8 @@ public void run(IAction action) {
// get project path, resource path // get project path, resource path
String resourcePathForTestClassFile = getResourcePathForTargetClassFile(structuredSelection); String resourcePathForTestClassFile = getResourcePathForTargetClassFile(structuredSelection);
String projectName = getProjectName(structuredSelection); String projectName = getProjectName(structuredSelection);
String projectRootPath = getWorkspaceRootAbsolutePath(getIWorkspaceRoot()) String projectRootPath = getIWorkspaceRoot().findMember(projectName).getLocationURI().getPath()
+ StringValue.DirectorySeparator.General + projectName + StringValue.DirectorySeparator.General; + StringValue.DirectorySeparator.General;


// ---------------------------------------- // ----------------------------------------
// check selection // check selection
Expand Down

0 comments on commit 8c307eb

Please sign in to comment.