-
-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
361 additions
and
274 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
15 changes: 8 additions & 7 deletions
15
.../jhipster/lite/generator/server/javatool/jacoco/application/JacocoApplicationService.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 |
---|---|---|
@@ -1,19 +1,20 @@ | ||
package tech.jhipster.lite.generator.server.javatool.jacoco.application; | ||
|
||
import org.springframework.stereotype.Component; | ||
import tech.jhipster.lite.generator.project.domain.Project; | ||
import tech.jhipster.lite.generator.server.javatool.jacoco.domain.JacocoService; | ||
import tech.jhipster.lite.generator.server.javatool.jacoco.domain.JacocoThresholdModuleFactory; | ||
import tech.jhipster.lite.module.domain.JHipsterModule; | ||
import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; | ||
|
||
@Component | ||
public class JacocoApplicationService { | ||
|
||
private final JacocoService jacocoService; | ||
private final JacocoThresholdModuleFactory factory; | ||
|
||
public JacocoApplicationService(JacocoService jacocoService) { | ||
this.jacocoService = jacocoService; | ||
public JacocoApplicationService() { | ||
factory = new JacocoThresholdModuleFactory(); | ||
} | ||
|
||
public void addCheckMinimumCoverage(Project project) { | ||
jacocoService.addCheckMinimumCoverage(project); | ||
public JHipsterModule buildModule(JHipsterModuleProperties properties) { | ||
return factory.buildModule(properties); | ||
} | ||
} |
25 changes: 0 additions & 25 deletions
25
.../java/tech/jhipster/lite/generator/server/javatool/jacoco/domain/JacocoDomainService.java
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
src/main/java/tech/jhipster/lite/generator/server/javatool/jacoco/domain/JacocoService.java
This file was deleted.
Oops, something went wrong.
54 changes: 54 additions & 0 deletions
54
...h/jhipster/lite/generator/server/javatool/jacoco/domain/JacocoThresholdModuleFactory.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,54 @@ | ||
package tech.jhipster.lite.generator.server.javatool.jacoco.domain; | ||
|
||
import static tech.jhipster.lite.module.domain.JHipsterModule.*; | ||
|
||
import tech.jhipster.lite.error.domain.Assert; | ||
import tech.jhipster.lite.module.domain.JHipsterModule; | ||
import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; | ||
|
||
public class JacocoThresholdModuleFactory { | ||
|
||
public JHipsterModule buildModule(JHipsterModuleProperties properties) { | ||
Assert.notNull("properties", properties); | ||
|
||
return moduleBuilder(properties) | ||
.mandatoryReplacements() | ||
.in("pom.xml") | ||
.add( | ||
lineAfterRegex( | ||
"<outputDirectory>target\\/jacoco\\/<\\/outputDirectory>[\n\r]*\\s*<\\/configuration>[\n\r]*\\s*<\\/execution>\\s*$" | ||
), | ||
""" | ||
<execution> | ||
<id>check</id> | ||
<goals> | ||
<goal>check</goal> | ||
</goals> | ||
<configuration> | ||
<dataFile>target/jacoco/allTest.exec</dataFile> | ||
<rules> | ||
<rule> | ||
<element>CLASS</element> | ||
<limits> | ||
<limit> | ||
<counter>LINE</counter> | ||
<value>COVEREDRATIO</value> | ||
<minimum>1.00</minimum> | ||
</limit> | ||
<limit> | ||
<counter>BRANCH</counter> | ||
<value>COVEREDRATIO</value> | ||
<minimum>1.00</minimum> | ||
</limit> | ||
</limits> | ||
</rule> | ||
</rules> | ||
</configuration> | ||
</execution>\ | ||
""" | ||
) | ||
.and() | ||
.and() | ||
.build(); | ||
} | ||
} |
22 changes: 0 additions & 22 deletions
22
.../lite/generator/server/javatool/jacoco/infrastructure/config/JacocoBeanConfiguration.java
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
...tor/server/javatool/jacoco/infrastructure/primary/JacocoThresholdModuleConfiguration.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,22 @@ | ||
package tech.jhipster.lite.generator.server.javatool.jacoco.infrastructure.primary; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import tech.jhipster.lite.generator.server.javatool.jacoco.application.JacocoApplicationService; | ||
import tech.jhipster.lite.module.infrastructure.primary.JHipsterModuleApiDoc; | ||
import tech.jhipster.lite.module.infrastructure.primary.JHipsterModuleResource; | ||
|
||
@Configuration | ||
class JacocoThresholdModuleConfiguration { | ||
|
||
@Bean | ||
JHipsterModuleResource jacocoModuleThreshold(JacocoApplicationService jacoco) { | ||
return JHipsterModuleResource | ||
.builder() | ||
.legacyUrl("/api/servers/java/jacoco-minimum-coverage") | ||
.slug("jacoco-check-min-coverage") | ||
.withoutProperties() | ||
.apiDoc(new JHipsterModuleApiDoc("Java", "Add JaCoCo configuration to check minimum coverage")) | ||
.factory(jacoco::buildModule); | ||
} | ||
} |
35 changes: 0 additions & 35 deletions
35
...ter/lite/generator/server/javatool/jacoco/infrastructure/primary/rest/JacocoResource.java
This file was deleted.
Oops, something went wrong.
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
42 changes: 42 additions & 0 deletions
42
src/main/java/tech/jhipster/lite/module/domain/replacement/RegexNeedleAfterReplacer.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,42 @@ | ||
package tech.jhipster.lite.module.domain.replacement; | ||
|
||
import java.util.function.BiFunction; | ||
import java.util.regex.Pattern; | ||
import tech.jhipster.lite.error.domain.Assert; | ||
import tech.jhipster.lite.module.domain.JHipsterModule; | ||
|
||
public record RegexNeedleAfterReplacer(Pattern pattern) implements ElementReplacer { | ||
public RegexNeedleAfterReplacer { | ||
Assert.notNull("pattern", pattern); | ||
} | ||
|
||
@Override | ||
public boolean notMatchIn(String content) { | ||
return !pattern().matcher(content).find(); | ||
} | ||
|
||
@Override | ||
public BiFunction<String, String, String> replacer() { | ||
return (content, replacement) -> | ||
linePattern().matcher(content).replaceAll(result -> result.group() + JHipsterModule.LINE_BREAK + replacement); | ||
} | ||
|
||
private Pattern linePattern() { | ||
String stringPattern = searchMatcher(); | ||
|
||
if (isLinePattern(stringPattern)) { | ||
return pattern(); | ||
} | ||
|
||
return Pattern.compile(stringPattern + ".*$", pattern().flags()); | ||
} | ||
|
||
private boolean isLinePattern(String stringPattern) { | ||
return stringPattern.endsWith("$"); | ||
} | ||
|
||
@Override | ||
public String searchMatcher() { | ||
return pattern().pattern(); | ||
} | ||
} |
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
37 changes: 0 additions & 37 deletions
37
src/main/resources/generator/server/javatool/jacoco/jacoco-check-coverage.patch
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Feature: Jacoco threshold module | ||
|
||
Scenario: Should apply jacoco threshol module | ||
When I apply "jacoco-check-min-coverage" module to default project with maven file without properties | ||
Then I should have "<value>COVEREDRATIO</value>" in "pom.xml" |
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
30 changes: 0 additions & 30 deletions
30
...hipster/lite/generator/server/javatool/jacoco/application/JacocoApplicationServiceIT.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.