Skip to content

Commit

Permalink
#323: added spring integration test (#376)
Browse files Browse the repository at this point in the history
See also PR #339
  • Loading branch information
hohwille authored Apr 16, 2021
1 parent 73c3d58 commit 6c5cfbb
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 6 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: CI Build PR
on: pull_request_target
on: pull_request
jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -14,8 +14,3 @@ jobs:
java-version: '11'
- name: Build project with Maven
run: mvn install
- name: Sonarcloud analysis
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=devonfw_devon4j
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package ${package}.general.common.base;

import javax.inject.Inject;

import org.junit.jupiter.api.Test;

import com.devonfw.module.basic.common.api.to.AbstractEto;
import com.devonfw.module.beanmapping.common.api.BeanMapper;

import ${package}.general.common.base.test.ApplicationComponentTest;
import ${package}.general.dataaccess.api.ApplicationPersistenceEntity;

/**
* This test verifies that {@link ${package}.SpringBootApp} is able to startup.
*/
public class ApplicationTest extends ApplicationComponentTest {

@Inject
private BeanMapper beanMapper;

/** Test that {@link it.pkg.SpringBootApp} is able to startup. */
@Test
public void testContextLoads() {

// given
Long id = Long.valueOf(4711);
MyEntity entity = new MyEntity();
entity.setId(id);
// when
MyEto eto = this.beanMapper.map(entity, MyEto.class);
// then
assertThat(eto.getId()).isEqualTo(id);
assertThat(eto.getModificationCounter()).isEqualTo(0);
// and when
entity.setModificationCounter(5);
// then
assertThat(eto.getModificationCounter()).isEqualTo(5);
}

/** Dummy entity for testing. */
public static class MyEntity extends ApplicationPersistenceEntity {
private static final long serialVersionUID = 1L;
}

/** Dummy ETO for testing. */
public static class MyEto extends AbstractEto {
private static final long serialVersionUID = 1L;
}
}

0 comments on commit 6c5cfbb

Please sign in to comment.