Skip to content

Commit 6c5cfbb

Browse files
authored
#323: added spring integration test (#376)
See also PR #339
1 parent 73c3d58 commit 6c5cfbb

File tree

2 files changed

+50
-6
lines changed
  • .github/workflows
  • templates/server/src/main/resources/archetype-resources/core/src/test/java/__packageInPathFormat__/general/common/base

2 files changed

+50
-6
lines changed

.github/workflows/build-pr.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: CI Build PR
2-
on: pull_request_target
2+
on: pull_request
33
jobs:
44
build:
55
runs-on: ubuntu-latest
@@ -14,8 +14,3 @@ jobs:
1414
java-version: '11'
1515
- name: Build project with Maven
1616
run: mvn install
17-
- name: Sonarcloud analysis
18-
env:
19-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
21-
run: mvn org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=devonfw_devon4j
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package ${package}.general.common.base;
2+
3+
import javax.inject.Inject;
4+
5+
import org.junit.jupiter.api.Test;
6+
7+
import com.devonfw.module.basic.common.api.to.AbstractEto;
8+
import com.devonfw.module.beanmapping.common.api.BeanMapper;
9+
10+
import ${package}.general.common.base.test.ApplicationComponentTest;
11+
import ${package}.general.dataaccess.api.ApplicationPersistenceEntity;
12+
13+
/**
14+
* This test verifies that {@link ${package}.SpringBootApp} is able to startup.
15+
*/
16+
public class ApplicationTest extends ApplicationComponentTest {
17+
18+
@Inject
19+
private BeanMapper beanMapper;
20+
21+
/** Test that {@link it.pkg.SpringBootApp} is able to startup. */
22+
@Test
23+
public void testContextLoads() {
24+
25+
// given
26+
Long id = Long.valueOf(4711);
27+
MyEntity entity = new MyEntity();
28+
entity.setId(id);
29+
// when
30+
MyEto eto = this.beanMapper.map(entity, MyEto.class);
31+
// then
32+
assertThat(eto.getId()).isEqualTo(id);
33+
assertThat(eto.getModificationCounter()).isEqualTo(0);
34+
// and when
35+
entity.setModificationCounter(5);
36+
// then
37+
assertThat(eto.getModificationCounter()).isEqualTo(5);
38+
}
39+
40+
/** Dummy entity for testing. */
41+
public static class MyEntity extends ApplicationPersistenceEntity {
42+
private static final long serialVersionUID = 1L;
43+
}
44+
45+
/** Dummy ETO for testing. */
46+
public static class MyEto extends AbstractEto {
47+
private static final long serialVersionUID = 1L;
48+
}
49+
}

0 commit comments

Comments
 (0)