Skip to content

Commit

Permalink
fix: support more languages
Browse files Browse the repository at this point in the history
  • Loading branch information
Angular2Guy committed Jul 12, 2024
1 parent 3c30742 commit 733726c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public String getGenerateTests(@RequestParam("url") String url,
}

@GetMapping("/sources")
public GithubSources getSources(@RequestParam("url") String url, @RequestParam(required = false) String testUrl) {
public GithubSources getSources(@RequestParam("url") String url, @RequestParam(name="testUrl", required = false) String testUrl) {
var sources = this.codeGenerationService.createTestSources(URLDecoder.decode(url, StandardCharsets.UTF_8),
true);
var test = Optional.ofNullable(testUrl)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class CodeGenerationService {
private final String ollamaPrompt = """
You are an assistant to generate spring tests for the class under test.
Analyse the classes provided and generate tests for all methods. Base your tests on the test example.
Generate and implement the test methods.
Generate and implement the test methods. Generate and implement complete tests methods.
Generate tests for this class:
{classToTest}
Expand Down Expand Up @@ -95,7 +95,7 @@ private List<GithubSource> createDependencies(final boolean referencedSources, f
return sourceLines.stream().filter(x -> referencedSources).filter(myLine -> myLine.contains("import"))
.filter(myLine -> myLine.contains(basePackage))
.map(myLine -> String.format("%s%s%s", myUrl.split(basePackage.replace(".", "/"))[0].trim(),
myLine.split("import")[1].split(";")[0].replaceAll("\\.", "/").trim(), ".java"))
myLine.split("import")[1].split(";")[0].replaceAll("\\.", "/").trim(), myUrl.substring(myUrl.lastIndexOf('.'))))
.map(myLine -> this.createTestSources(myLine, false)).toList();
}

Expand Down

0 comments on commit 733726c

Please sign in to comment.