Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: added the junit plugin and added the codecoverage reporting capa… #1

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
98df13b
fix: added the junit plugin and added the codecoverage reporting capa…
lfdesousa Apr 22, 2024
84f4d57
test: Added Unit Test to the IdRequestConverter on ITI67 transaction
lfdesousa Apr 22, 2024
201b87b
test: Added Unit Test to the IdRequestConverter on ITI67 transaction
lfdesousa Apr 22, 2024
39c2f29
test: Added back the ITI65 and ITI66 tests, but we have one issue on …
lfdesousa Apr 23, 2024
e14474e
test: Added a missing reference to the POM so that the class SampleDa…
lfdesousa Apr 23, 2024
92b95d5
chore: removed empty test file from this round.
lfdesousa Apr 24, 2024
c9f240d
chore: started to configure the maven pipeline to the mag.
lfdesousa May 2, 2024
5fd3445
chore: made some minor changes to have the tests passing, this is not…
lfdesousa May 3, 2024
446b4ed
chore: fixed the dependency graph update to match what we have on ipf
lfdesousa May 3, 2024
8992fc7
chore: added the generation of the code coverage report
lfdesousa May 6, 2024
e9b501a
chore: debug action to make sure the code coverage report is where we…
lfdesousa May 6, 2024
b488880
chore: added the action JaCoCo Code Coverage Reporter, test it to see…
lfdesousa May 6, 2024
d5f942d
chore: ignore the whole class, like we had to do locally and test again.
lfdesousa May 6, 2024
1130658
chore: try to publish the Code Coverage Job Summary
lfdesousa May 6, 2024
e29d535
chore: Try another plugin that is based on a badge given the percenta…
lfdesousa May 6, 2024
af3bda6
chore: Removed the actions from:PavanMudigonda, since we have a decen…
lfdesousa May 6, 2024
2876379
chore: did one more test to understand what is going on with ssl
lfdesousa May 6, 2024
d1ab8ae
chore: we had to disable two more https settings and enable all the t…
lfdesousa May 6, 2024
ea153d8
chore: uses the latest version of the action
lfdesousa May 6, 2024
f8b49c9
Merge branch 'feature/UnitTests' into feature/compileTools
lfdesousa May 7, 2024
1c5ea6c
chore: changed to the correct version of Java
lfdesousa May 7, 2024
4e64dad
chore: disabed broken ITI66 tests, until we understand what is going …
lfdesousa May 7, 2024
1b78107
chore: workaround for the issue: https://github.com/swisspost/MobileA…
lfdesousa May 7, 2024
fd351f6
chore: fixed the broken ssl on the mag, when we execute it from the c…
lfdesousa May 8, 2024
67052f8
chore: fixed the broken tests when SSL is enabled
lfdesousa May 8, 2024
5c1fb86
Merge branch 'master' into feature/compileTools
lfdesousa May 15, 2024
cd8f5bf
Update application-test.yml
lfdesousa May 15, 2024
3f0b42f
chore: enable the actuator endpoints to answer the requirements of ha…
lfdesousa May 15, 2024
d50d73d
chore: added the prometheus metrics support to the mag
lfdesousa May 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Java CI with Maven

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
cache: maven
- name: Build with Maven
run: mvn -B package --file pom.xml

- name: Generate the Jacoco report
run: mvn jacoco:report

- name: Generate JaCoCo Badge
id: jacoco
uses: cicirello/[email protected]
- name: Log coverage percentage
run: |
echo "coverage = ${{ steps.jacoco.outputs.coverage }}"
echo "branch coverage = ${{ steps.jacoco.outputs.branches }}"

- name: Upload JaCoCo coverage report
uses: actions/upload-artifact@v2
with:
name: jacoco-report
path: target/site/jacoco/

# Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
- name: Update dependency graph
uses: advanced-security/maven-dependency-submission-action@v3
51 changes: 49 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.10.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down Expand Up @@ -102,6 +109,12 @@
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<scope>runtime</scope>
</dependency>

<!-- <dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-rest-starter</artifactId>
Expand Down Expand Up @@ -298,7 +311,18 @@
<version>${camel-version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openehealth.ipf.commons</groupId>
<artifactId>ipf-commons-ihe-xds</artifactId>
<version>${ipf-version}</version>
<scope>test</scope>
<type>test-jar</type>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -373,7 +397,30 @@
</executions>
</plugin>
<!-- end::unpack[] -->

<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.12</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<!-- attached to Maven test phase -->
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>
</build>
Expand Down
15 changes: 15 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,18 @@ camel:
spring:
application:
name: mobile-access-gateway

management:
endpoint:
health:
probes:
enabled: true
shutdown:
enabled: true
info:
enabled: true
endpoints:
web:
exposure:
include: "*"
exclude: "env,beans"
2 changes: 1 addition & 1 deletion src/test/java/ch.bfh.ti.i4mi.mag.ppqm/Ppq4Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.apache.camel.support.DefaultExchange;
import org.hl7.fhir.r4.model.Bundle;
import org.hl7.fhir.r4.model.OperationOutcome;
import org.junit.Ignore;
import org.junit.jupiter.api.Test;
import org.openehealth.ipf.commons.ihe.fhir.chppqm.ChPpqmUtils;
import org.openehealth.ipf.platform.camel.core.util.Exchanges;
Expand Down Expand Up @@ -166,5 +167,4 @@ public void testDeleteFailure() throws Exception {
}
assertTrue(exceptionHandled);
}

}
46 changes: 46 additions & 0 deletions src/test/java/ch/bfh/ti/i4mi/mag/TestBase.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package ch.bfh.ti.i4mi.mag;

import ch.bfh.ti.i4mi.mag.MobileAccessGateway;
import lombok.extern.slf4j.Slf4j;
import org.apache.camel.CamelContext;
import org.apache.camel.ProducerTemplate;
import org.junit.jupiter.api.BeforeAll;
import org.openehealth.ipf.commons.ihe.xacml20.Xacml20Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.ActiveProfiles;

import java.util.Locale;

/**
* @author Dmytro Rud
*/
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
@Import(MobileAccessGateway.class)
@ActiveProfiles("test")
@Slf4j
abstract public class TestBase {

@Autowired
protected CamelContext camelContext;

@Autowired
protected ProducerTemplate producerTemplate;

@Value("${server.port}")
protected Integer serverPort;

@BeforeAll
public static void beforeAll() {
Xacml20Utils.initializeHerasaf();
Locale.setDefault(Locale.ENGLISH);

// System.setProperty("javax.net.ssl.keyStore", "src/main/resources/example-server-certificate.p12");
// System.setProperty("javax.net.ssl.keyStorePassword", "a1b2c3");
// System.setProperty("javax.net.ssl.trustStore", "src/main/resources/example-server-certificate.p12");
// System.setProperty("javax.net.ssl.trustStorePassword", "a1b2c3");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package ch.bfh.ti.i4mi.mag.mhd.iti66;

import ch.bfh.ti.i4mi.mag.TestBase;
import org.junit.jupiter.api.Test;
import org.openehealth.ipf.commons.ihe.xds.core.requests.QueryRegistry;
import org.openehealth.ipf.commons.ihe.xds.core.requests.query.GetSubmissionSetAndContentsQuery;
import org.openehealth.ipf.commons.ihe.xds.core.transform.requests.QueryRegistryTransformer;
import org.openehealth.ipf.commons.ihe.xds.core.validate.requests.AdhocQueryRequestValidator;

import static org.junit.jupiter.api.Assertions.*;
import static org.openehealth.ipf.commons.ihe.xds.XDS.Interactions.ITI_18;

public class IdRequestConverterTest extends TestBase {

private final IdRequestConverter _sut;
private final QueryRegistryTransformer _queryRegistryTransformer;

public IdRequestConverterTest() {
_sut = new IdRequestConverter();
_queryRegistryTransformer = new QueryRegistryTransformer();
}

@Test
public void idToGetDocumentQuery_MissingFhirHeader_null() {
QueryRegistry result = _sut.idToGetDocumentsQuery("");
assertNull(result);
}

@Test
public void idToGetDocumentQuery_NotContainingSlash_null() {
QueryRegistry result = _sut.idToGetDocumentsQuery("some-fhir-uri");
assertNull(result);
}

@Test
public void idToGetDocumentQuery_ValidFhirHttpUri_QueryValidated() {
QueryRegistry result = _sut.idToGetDocumentsQuery("some-fhir-uri/12345");

var uuid = ((GetSubmissionSetAndContentsQuery) result.getQuery()).getUuid();

assertTrue(result.getQuery() instanceof GetSubmissionSetAndContentsQuery);
assertEquals("12345", uuid);

var ebXmlResult = _queryRegistryTransformer.toEbXML(result);
AdhocQueryRequestValidator.getInstance().validate(ebXmlResult, ITI_18);
}
}
Loading
Loading