Skip to content

Commit

Permalink
fix: generation for xml path without parent (#124)
Browse files Browse the repository at this point in the history
fixes #163

example - `mulefd test-api.xml` will not fail now.

[patch]
  • Loading branch information
manikmagar authored Oct 12, 2020
1 parent 4af6232 commit a2ceadf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/com/javastreets/mulefd/app/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ CommandModel getCommandModel() {
if (Files.isDirectory(sourcePath))
resolvedTarget = sourcePath;
if (Files.isRegularFile(sourcePath))
resolvedTarget = sourcePath.toFile().getParentFile().toPath();
resolvedTarget = sourcePath.toAbsolutePath().getParent();
}
cm.setTargetPath(resolvedTarget);
cm.setDiagramType(diagramType);
Expand Down
22 changes: 22 additions & 0 deletions src/test/java/com/javastreets/mulefd/app/ApplicationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,28 @@ void commandLineWithSourceDirectory() {

}

@Test
@DisplayName("When parsing source file without parent folder, sets parent as target")
void commandLineWithBareSourceFile() throws Exception {
tempDir.createNewFile();
Path sourceFile = Paths.get("db-config.xml");
sourceFile.toFile().delete();
Files.copy(Paths.get("src/test/resources/renderer/component-configs/db-config.xml"),
sourceFile);
String[] args = new String[] {sourceFile.toString()};
Application application = new Application();
new CommandLine(application).parseArgs(args);
CommandModel model = application.getCommandModel();

CommandModel expectedModel = new CommandModel();
expectedModel.setSourcePath(sourceFile);
expectedModel.setTargetPath(sourceFile.toAbsolutePath().getParent());
expectedModel.setDiagramType(DiagramType.GRAPH);
expectedModel.setOutputFilename("mule-diagram.png");
expectedModel.setGenerateSingles(false);
assertThat(model).isEqualToComparingFieldByField(expectedModel);
}

@Test
@DisplayName("When parsing source file, sets parent as target")
void commandLineWithSourceFile() throws Exception {
Expand Down

0 comments on commit a2ceadf

Please sign in to comment.