forked from jhipster/jhipster-lite
-
Notifications
You must be signed in to change notification settings - Fork 0
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 jhipster#9607 from murdos/feature/approvals-testing
Module: Approval testing using ApprovalTests
- Loading branch information
Showing
9 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
...erator/server/javatool/approvaltesting/application/ApprovalTestingApplicationService.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,20 @@ | ||
package tech.jhipster.lite.generator.server.javatool.approvaltesting.application; | ||
|
||
import org.springframework.stereotype.Service; | ||
import tech.jhipster.lite.generator.server.javatool.approvaltesting.domain.ApprovalTestingModuleFactory; | ||
import tech.jhipster.lite.module.domain.JHipsterModule; | ||
import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; | ||
|
||
@Service | ||
public class ApprovalTestingApplicationService { | ||
|
||
private final ApprovalTestingModuleFactory approvalTesting; | ||
|
||
public ApprovalTestingApplicationService() { | ||
approvalTesting = new ApprovalTestingModuleFactory(); | ||
} | ||
|
||
public JHipsterModule build(JHipsterModuleProperties properties) { | ||
return approvalTesting.build(properties); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...r/lite/generator/server/javatool/approvaltesting/domain/ApprovalTestingModuleFactory.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.approvaltesting.domain; | ||
|
||
import static tech.jhipster.lite.module.domain.JHipsterModule.*; | ||
|
||
import tech.jhipster.lite.module.domain.JHipsterModule; | ||
import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; | ||
import tech.jhipster.lite.shared.error.domain.Assert; | ||
|
||
public class ApprovalTestingModuleFactory { | ||
|
||
public JHipsterModule build(JHipsterModuleProperties properties) { | ||
Assert.notNull("properties", properties); | ||
|
||
//@formatter:off | ||
return moduleBuilder(properties) | ||
.javaDependencies() | ||
.addTestDependency(groupId("com.approvaltests"), artifactId("approvaltests"), versionSlug("approvaltests")) | ||
.and() | ||
.build(); | ||
//@formatter:on | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...r/javatool/approvaltesting/infrastructure/primary/AdvancedTestingModuleConfiguration.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,25 @@ | ||
package tech.jhipster.lite.generator.server.javatool.approvaltesting.infrastructure.primary; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import tech.jhipster.lite.generator.server.javatool.approvaltesting.application.ApprovalTestingApplicationService; | ||
import tech.jhipster.lite.generator.slug.domain.JHLiteFeatureSlug; | ||
import tech.jhipster.lite.generator.slug.domain.JHLiteModuleSlug; | ||
import tech.jhipster.lite.module.domain.resource.JHipsterModuleOrganization; | ||
import tech.jhipster.lite.module.domain.resource.JHipsterModulePropertiesDefinition; | ||
import tech.jhipster.lite.module.domain.resource.JHipsterModuleResource; | ||
|
||
@Configuration | ||
class AdvancedTestingModuleConfiguration { | ||
|
||
@Bean | ||
JHipsterModuleResource approvalTestsModule(ApprovalTestingApplicationService approvalTesting) { | ||
return JHipsterModuleResource.builder() | ||
.slug(JHLiteModuleSlug.APPROVAL_TESTS) | ||
.propertiesDefinition(JHipsterModulePropertiesDefinition.builder().build()) | ||
.apiDoc("Advanced testing", "Add ApprovalTests library for Approval testing") | ||
.organization(JHipsterModuleOrganization.builder().addDependency(JHLiteFeatureSlug.JAVA_BUILD_TOOL).build()) | ||
.tags("server", "testing") | ||
.factory(approvalTesting::build); | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
src/main/java/tech/jhipster/lite/generator/server/javatool/approvaltesting/package-info.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,2 @@ | ||
@tech.jhipster.lite.BusinessContext | ||
package tech.jhipster.lite.generator.server.javatool.approvaltesting; |
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
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,6 @@ | ||
Feature: Approval testing module | ||
|
||
Scenario: Should apply approval-tests module in maven project | ||
When I apply "approval-tests" module to default project with maven file | ||
| packageName | tech.jhipster.chips | | ||
Then I should have "<artifactId>approvaltests</artifactId>" in "pom.xml" |
36 changes: 36 additions & 0 deletions
36
...te/generator/server/javatool/approvaltesting/domain/ApprovalTestingModuleFactoryTest.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,36 @@ | ||
package tech.jhipster.lite.generator.server.javatool.approvaltesting.domain; | ||
|
||
import static tech.jhipster.lite.TestFileUtils.*; | ||
import static tech.jhipster.lite.module.infrastructure.secondary.JHipsterModulesAssertions.*; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import tech.jhipster.lite.UnitTest; | ||
import tech.jhipster.lite.module.domain.JHipsterModule; | ||
import tech.jhipster.lite.module.domain.JHipsterModulesFixture; | ||
import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; | ||
|
||
@UnitTest | ||
class ApprovalTestingModuleFactoryTest { | ||
|
||
private final ApprovalTestingModuleFactory factory = new ApprovalTestingModuleFactory(); | ||
|
||
@Test | ||
void shouldBuildApprovalTestsModule() { | ||
JHipsterModuleProperties properties = JHipsterModulesFixture.propertiesBuilder(tmpDirForTest()).build(); | ||
|
||
JHipsterModule module = factory.build(properties); | ||
|
||
assertThatModuleWithFiles(module, pomFile()) | ||
.hasFile("pom.xml") | ||
.containing( | ||
""" | ||
<dependency> | ||
<groupId>com.approvaltests</groupId> | ||
<artifactId>approvaltests</artifactId> | ||
<version>${approvaltests.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
""" | ||
); | ||
} | ||
} |
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