This repository has been archived by the owner on Apr 12, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
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 #49 from open-prevo/feature/17_IntegrationTest
Add integration test
- Loading branch information
Showing
40 changed files
with
729 additions
and
156 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
language: java | ||
|
||
sudo: required | ||
services: | ||
- docker |
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 @@ | ||
FROM openjdk:8 | ||
RUN mkdir /opt/app | ||
COPY build/libs/adapter-dummy-0.0.1-SNAPSHOT.jar /opt/app/app.jar | ||
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/opt/app/app.jar"] | ||
EXPOSE 8080 |
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
32 changes: 0 additions & 32 deletions
32
adapter-dummy/src/main/java/ch/prevo/open/node/data/provider/DummyProvider.java
This file was deleted.
Oops, something went wrong.
75 changes: 75 additions & 0 deletions
75
adapter-dummy/src/main/java/ch/prevo/open/node/data/provider/JsonAdapter.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,75 @@ | ||
package ch.prevo.open.node.data.provider; | ||
|
||
import static java.util.Collections.emptyList; | ||
|
||
import java.nio.charset.Charset; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import javax.annotation.PostConstruct; | ||
import javax.inject.Inject; | ||
|
||
import org.apache.commons.io.IOUtils; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.core.io.Resource; | ||
import org.springframework.core.io.ResourceLoader; | ||
import org.springframework.stereotype.Repository; | ||
import com.fasterxml.jackson.databind.JavaType; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
import ch.prevo.open.data.api.JobEnd; | ||
import ch.prevo.open.data.api.JobStart; | ||
|
||
/** | ||
* Sample json dummy adapter to provide hardcoded test data. | ||
*/ | ||
@Repository | ||
public class JsonAdapter implements JobStartProvider, JobEndProvider { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(JsonAdapter.class); | ||
|
||
@Value("${open.prevo.json.adapter.files.jobstart}") | ||
private String jobStartJsonFile; | ||
|
||
@Value("${open.prevo.json.adapter.files.jobend}") | ||
private String jobEndJsonFile; | ||
|
||
@Inject | ||
private ResourceLoader resourceLoader; | ||
|
||
@Inject | ||
private ObjectMapper objectMapper; | ||
|
||
private List<JobStart> jobStartInformation; | ||
private List<JobEnd> jobEndInformation; | ||
|
||
@PostConstruct | ||
public void init() { | ||
this.jobStartInformation = new ArrayList<>(readJsonFile(jobStartJsonFile, JobStart.class)); | ||
this.jobEndInformation = new ArrayList<>(readJsonFile(jobEndJsonFile, JobEnd.class)); | ||
} | ||
|
||
private <T> List<T> readJsonFile(String filePath, Class<T> clazz) { | ||
LOGGER.debug("Read json file {} in adapter", filePath); | ||
try { | ||
Resource jsonResource = resourceLoader.getResource(filePath); | ||
String jsonString = IOUtils.toString(jsonResource.getInputStream(), Charset.forName("UTF-8")); | ||
JavaType type = objectMapper.getTypeFactory().constructParametricType(List.class, clazz); | ||
return objectMapper.readValue(jsonString, type); | ||
} catch (Exception e) { | ||
LOGGER.error("Could not initialize dummy json adapter", e); | ||
} | ||
return emptyList(); | ||
} | ||
|
||
@Override | ||
public List<JobStart> getJobStarts() { | ||
return jobStartInformation; | ||
} | ||
|
||
@Override | ||
public List<JobEnd> getJobEnds() { | ||
return jobEndInformation; | ||
} | ||
} |
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,3 @@ | ||
# open prevo properties | ||
open.prevo.json.adapter.files.jobstart=classpath:sample-job-start-data.json | ||
open.prevo.json.adapter.files.jobend=classpath:sample-job-end-data.json |
32 changes: 32 additions & 0 deletions
32
adapter-dummy/src/main/resources/pakt-sample-job-end-data.json
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,32 @@ | ||
[ | ||
{ | ||
"techId": "", | ||
"jobInfo": { | ||
"retirementFundUid": "CHE-109.537.488-Helvetia-Prisma-Sammelstiftung", | ||
"internalReferenz": "", | ||
"oasiNumber": "756.1234.5678.97", | ||
"internalPersonId": "", | ||
"date": null | ||
} | ||
}, | ||
{ | ||
"techId": "", | ||
"jobInfo": { | ||
"retirementFundUid": "CHE-109.537.488-Helvetia-Prisma-Sammelstiftung", | ||
"internalReferenz": "", | ||
"oasiNumber": "756.3421.5678.97", | ||
"internalPersonId": "", | ||
"date": null | ||
} | ||
}, | ||
{ | ||
"techId": "", | ||
"jobInfo": { | ||
"retirementFundUid": "CHE-109.537.488-Helvetia-Prisma-Sammelstiftung", | ||
"internalReferenz": "", | ||
"oasiNumber": "756.3324.5678.58", | ||
"internalPersonId": "", | ||
"date": null | ||
} | ||
} | ||
] |
35 changes: 35 additions & 0 deletions
35
adapter-dummy/src/main/resources/pakt-sample-job-start-data.json
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,35 @@ | ||
[ | ||
{ | ||
"techId": "", | ||
"jobInfo": { | ||
"retirementFundUid": "CHE-109.537.488-Helvetia-Prisma-Sammelstiftung", | ||
"internalReferenz": "", | ||
"oasiNumber": "756.1335.5778.23", | ||
"internalPersonId": "", | ||
"date": null | ||
}, | ||
"capitalTransferInfo": null | ||
}, | ||
{ | ||
"techId": "", | ||
"jobInfo": { | ||
"retirementFundUid": "CHE-109.537.488-Helvetia-Prisma-Sammelstiftung", | ||
"internalReferenz": "", | ||
"oasiNumber": "756.9874.5778.58", | ||
"internalPersonId": "", | ||
"date": null | ||
}, | ||
"capitalTransferInfo": null | ||
}, | ||
{ | ||
"techId": "", | ||
"jobInfo": { | ||
"retirementFundUid": "CHE-109.537.488-Helvetia-Prisma-Sammelstiftung", | ||
"internalReferenz": "", | ||
"oasiNumber": "756.3256.6598.23", | ||
"internalPersonId": "", | ||
"date": null | ||
}, | ||
"capitalTransferInfo": null | ||
} | ||
] |
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,32 @@ | ||
[ | ||
{ | ||
"techId": "", | ||
"jobInfo": { | ||
"retirementFundUid": "CHE-109.740.084-Baloise-Sammelstiftung", | ||
"internalReferenz": "", | ||
"oasiNumber": "756.1335.5778.23", | ||
"internalPersonId": "", | ||
"date": null | ||
} | ||
}, | ||
{ | ||
"techId": "", | ||
"jobInfo": { | ||
"retirementFundUid": "CHE-109.740.084-Baloise-Sammelstiftung", | ||
"internalReferenz": "", | ||
"oasiNumber": "756.3412.8844.97", | ||
"internalPersonId": "", | ||
"date": null | ||
} | ||
}, | ||
{ | ||
"techId": "", | ||
"jobInfo": { | ||
"retirementFundUid": "CHE-109.740.084-Baloise-Sammelstiftung", | ||
"internalReferenz": "", | ||
"oasiNumber": "756.9534.5271.94", | ||
"internalPersonId": "", | ||
"date": null | ||
} | ||
} | ||
] |
35 changes: 35 additions & 0 deletions
35
adapter-dummy/src/main/resources/sample-job-start-data.json
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,35 @@ | ||
[ | ||
{ | ||
"techId": "", | ||
"jobInfo": { | ||
"retirementFundUid": "CHE-109.740.084-Baloise-Sammelstiftung", | ||
"internalReferenz": "", | ||
"oasiNumber": "756.1234.5678.97", | ||
"internalPersonId": "", | ||
"date": null | ||
}, | ||
"capitalTransferInfo": null | ||
}, | ||
{ | ||
"techId": "", | ||
"jobInfo": { | ||
"retirementFundUid": "CHE-109.740.084-Baloise-Sammelstiftung", | ||
"internalReferenz": "", | ||
"oasiNumber": "756.1298.6578.97", | ||
"internalPersonId": "", | ||
"date": null | ||
}, | ||
"capitalTransferInfo": null | ||
}, | ||
{ | ||
"techId": "", | ||
"jobInfo": { | ||
"retirementFundUid": "CHE-109.740.084-Baloise-Sammelstiftung", | ||
"internalReferenz": "", | ||
"oasiNumber": "756.5678.1234.17", | ||
"internalPersonId": "", | ||
"date": null | ||
}, | ||
"capitalTransferInfo": null | ||
} | ||
] |
35 changes: 35 additions & 0 deletions
35
adapter-dummy/src/test/java/ch/prevo/open/node/data/provider/JsonAdapterTest.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,35 @@ | ||
package ch.prevo.open.node.data.provider; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.util.List; | ||
import javax.inject.Inject; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.context.junit4.SpringRunner; | ||
|
||
import ch.prevo.open.data.api.JobEnd; | ||
import ch.prevo.open.data.api.JobStart; | ||
import ch.prevo.open.node.NodeApplication; | ||
|
||
@RunWith(SpringRunner.class) | ||
@SpringBootTest(classes = NodeApplication.class) | ||
public class JsonAdapterTest { | ||
|
||
@Inject | ||
private JsonAdapter jsonAdapter; | ||
|
||
@Test | ||
public void getJobStartInformation() { | ||
List<JobStart> jobEndInformation = jsonAdapter.getJobStarts(); | ||
assertThat(jobEndInformation).hasSize(3); | ||
} | ||
|
||
@Test | ||
public void getJobEndInformation() { | ||
List<JobEnd> jobEndInformation = jsonAdapter.getJobEnds(); | ||
assertThat(jobEndInformation).hasSize(3); | ||
} | ||
} |
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,3 @@ | ||
# open prevo properties | ||
open.prevo.json.adapter.files.jobstart=classpath:node-rest-test-jobstart.json | ||
open.prevo.json.adapter.files.jobend=classpath:node-rest-test-jobend.json |
33 changes: 33 additions & 0 deletions
33
adapter-dummy/src/test/resources/node-rest-test-jobend.json
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,33 @@ | ||
|
||
[ | ||
{ | ||
"techId": "", | ||
"jobInfo": { | ||
"retirementFundUid": "CHE-109.740.084", | ||
"internalReferenz": "", | ||
"oasiNumber": "756.1335.5778.23", | ||
"internalPersonId": "", | ||
"date": null | ||
} | ||
}, | ||
{ | ||
"techId": "", | ||
"jobInfo": { | ||
"retirementFundUid": "CHE-109.537.488", | ||
"internalReferenz": "", | ||
"oasiNumber": "756.3412.8844.97", | ||
"internalPersonId": "", | ||
"date": null | ||
} | ||
}, | ||
{ | ||
"techId": "", | ||
"jobInfo": { | ||
"retirementFundUid": "CHE-109.740.078", | ||
"internalReferenz": "", | ||
"oasiNumber": "756.9534.5271.94", | ||
"internalPersonId": "", | ||
"date": null | ||
} | ||
} | ||
] |
35 changes: 35 additions & 0 deletions
35
adapter-dummy/src/test/resources/node-rest-test-jobstart.json
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,35 @@ | ||
[ | ||
{ | ||
"techId": "", | ||
"jobInfo": { | ||
"retirementFundUid": "CHE-109.740.084", | ||
"internalReferenz": "", | ||
"oasiNumber": "756.1234.5678.9", | ||
"internalPersonId": "", | ||
"date": null | ||
}, | ||
"capitalTransferInfo": null | ||
}, | ||
{ | ||
"techId": "", | ||
"jobInfo": { | ||
"retirementFundUid": "CHE-109.537.488", | ||
"internalReferenz": "", | ||
"oasiNumber": "756.1298.6578.97", | ||
"internalPersonId": "", | ||
"date": null | ||
}, | ||
"capitalTransferInfo": null | ||
}, | ||
{ | ||
"techId": "", | ||
"jobInfo": { | ||
"retirementFundUid": "CHE-109.740.078", | ||
"internalReferenz": "", | ||
"oasiNumber": "756.5678.1234.17", | ||
"internalPersonId": "", | ||
"date": null | ||
}, | ||
"capitalTransferInfo": null | ||
} | ||
] |
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
Oops, something went wrong.