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

EDC - Unit Tests and Coverage #75 #76

Merged
merged 28 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
077716d
chore (ch-edc): reviewing license headers
Oct 4, 2023
2d62e2a
Merge branch 'development' into feat/edc-extension
Oct 4, 2023
8542389
feat (ch-edc): unit tests base structure
Oct 10, 2023
f1612e0
feat: Create TestUtils with mock and start to create application tests
augustocmleal Oct 12, 2023
5127591
feat: AppSender, LoggingMessageDelegate, LogMessageHandler tests impl…
augustocmleal Oct 16, 2023
4d382b5
feat: readme added
augustocmleal Oct 16, 2023
50e0dbc
feat (ch-edc): unit tests coverage tool
Oct 15, 2023
47493b9
feat (ch-edc): unit tests refactoring
Oct 16, 2023
74c44db
feat (ch-edc): unit tests refactoring
Oct 16, 2023
47f4e08
feat (ch-edc): unit tests refactoring
Oct 16, 2023
7a03fb9
feat (ch-edc): TypeManagerUtilTest included
augustocmleal Oct 16, 2023
7a78559
Merge remote-tracking branch 'origin/feat/unit-tests' into feat/unit-…
augustocmleal Oct 16, 2023
eb9f827
feat (ch-edc): unit tests refactoring
Oct 16, 2023
22bf245
Merge remote-tracking branch 'origin/feat/unit-tests' into feat/unit-…
augustocmleal Oct 16, 2023
6199fee
feat (ch-edc): TypeManagerUtilTest successfulParse included
augustocmleal Oct 16, 2023
092d474
feat (ch-edc): TypeManagerUtilTest errorConvertingToJson and successf…
augustocmleal Oct 17, 2023
391c42f
feat (ch-edc): ResponseUtilTest and VocabUtilTest included
augustocmleal Oct 18, 2023
463abc0
feat (ch-edc): extension/multipart unit tests
Oct 19, 2023
660d8ef
feat (ch-edc): TypeManagerUtilTest fixed
augustocmleal Oct 19, 2023
2138f33
feat (ch-edc): unit tests review
Oct 19, 2023
ef8e31f
feat (ch-edc): unit tests and coverage workflow
Oct 19, 2023
08fda1b
feat (ch-edc): unit tests and coverage workflow
Oct 19, 2023
65c2c7e
feat (ch-edc): unit tests and coverage workflow
Oct 19, 2023
790adf9
feat (ch-edc): unit tests and coverage workflow
Oct 19, 2023
f3adc30
Merge branch 'development' into feat/unit-tests
Oct 20, 2023
657405f
chore (ch-edc): workaround to fraunhofer infomodel expired ssl certif…
Oct 23, 2023
3fc6232
feat (ch-edc): creating installation and tests page for the Readme.md
augustocmleal Oct 23, 2023
8ae3ff1
Merge remote-tracking branch 'origin/feat/unit-tests' into feat/unit-…
augustocmleal Oct 23, 2023
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
34 changes: 32 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ on:
- alpha
- development


jobs:
unit-tests:
app-unit-tests:
runs-on: ubuntu-latest

steps:
Expand All @@ -27,3 +26,34 @@ jobs:
cd clearing-house-app
cargo build --verbose
cargo test --verbose

edc-unit-tests:
runs-on: ubuntu-latest
permissions:
pull-requests: write

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'temurin'

- name: Run Unit Tests
run: |
cd clearing-house-edc
./gradlew test jacocoTestReport

- name: Add Coverage Report
id: jacoco
uses: madrapps/jacoco-report@v1.6.1
with:
paths: |
${{ github.workspace }}/clearing-house-edc/core/build/reports/jacoco/test/jacocoTestReport.xml,
${{ github.workspace }}clearing-house-edc/extensions/multipart/build/reports/jacoco/test/jacocoTestReport.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: 70
min-coverage-changed-files: 80
44 changes: 44 additions & 0 deletions clearing-house-edc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
## CLEARING HOUSE EDC
This repository contains the Clearing House Extension that works with the Eclipse Dataspace Connector
allowing logging operations.

## Install
### Configurations
It is required to configure those parameters:

| Parameter name | Description | Default value |
|----------------------------------------|----------------------------------------------|------------------------|
| `truzzt.clearinghouse.jwt.audience` | Defines the intended recipients of the token | 1 |
| `truzzt.clearinghouse.jwt.issuer` | Person or entity offering the token | 1 |
| `truzzt.clearinghouse.jwt.sign.secret` | Secret key to encode the token | 123 |
| `truzzt.clearinghouse.jwt.expires.at` | Time to token Expiration (in Seconds) | 30 |
| `truzzt.clearinghouse.app.base.url` | Base URL from the clearing house app | http://localhost:8000 |

### Build
To build the project run the command below:

./gradlew build


### Running
Local execution:

java -Dedc.fs.config=launchers/connector-local/resources/config.properties -Dedc.keystore=launchers/connector-local/resources/keystore.jks -Dedc.keystore.password=password -Dedc.vault=launchers/connector-local/resources/vault.properties -jar launchers/connector-local/build/libs/clearing-house-edc.jar

## Tests

### Running Tests
To run the unit-tests execute the following command:

./gradlew test


### Test Coverage
To generate the tests coverage execute the following command:

./gradlew jacocoTestReport

The coverage reports will be available in the following folders:

- [core/build/reports/jacoco/test/html/index.html](./core/build/reports/jacoco/test/html/index.html)
- [extensions/multipart/build/reports/jacoco/test/html/index.html](./extensions/multipart/build/reports/jacoco/test/html/index.html)
8 changes: 4 additions & 4 deletions clearing-house-edc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Microsoft Corporation
* Copyright (c) 2023 Microsoft Corporation
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
Expand All @@ -8,12 +8,12 @@
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* Microsoft Corporation - initial implementation
* truzzt GmbH - Initial implementation
*
*/

plugins {
`java-library`
`java-base`
}

val javaVersion: String by project
Expand All @@ -22,4 +22,4 @@ java {
toolchain {
languageVersion = JavaLanguageVersion.of(javaVersion)
}
}
}
34 changes: 31 additions & 3 deletions clearing-house-edc/core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Microsoft Corporation
* Copyright (c) 2023 Microsoft Corporation
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
Expand All @@ -8,22 +8,50 @@
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* Microsoft Corporation - Initial implementation
* truzzt GmbH - Initial implementation
*
*/

plugins {
`java-library`
`java-test-fixtures`
jacoco
}

val auth0JWTVersion: String by project

configurations.all {
exclude(group = "de.fraunhofer.iais.eis.ids.infomodel", module = "java")
}

dependencies {
api(edc.spi.core)

implementation(edc.ids)
implementation(edc.ids.jsonld.serdes)
implementation(edc.api.management.config)

implementation(libs.jersey.multipart)
implementation("com.auth0:java-jwt:${auth0JWTVersion}")

implementation(":infomodel-java-4.1.3")
implementation(":infomodel-util-4.0.4")

testImplementation(libs.junit.jupiter.api)
testImplementation(libs.mockito.inline)
testImplementation(libs.mockito.inline)

testFixturesImplementation(edc.ids)
testFixturesImplementation("com.auth0:java-jwt:${auth0JWTVersion}")

testRuntimeOnly(libs.junit.jupiter.engine)
}

tasks.test {
useJUnitPlatform()
}
tasks.jacocoTestReport {
reports {
xml.required = true
}
dependsOn(tasks.test)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 sovity GmbH
* Copyright (c) 2023 truzzt GmbH
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
Expand All @@ -8,7 +8,7 @@
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* sovity GmbH - initial API and implementation
* truzzt GmbH - Initial implementation
*
*/
package de.truzzt.clearinghouse.edc.app;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 sovity GmbH
* Copyright (c) 2023 truzzt GmbH
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
Expand All @@ -8,7 +8,7 @@
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* sovity GmbH - initial API and implementation
* truzzt GmbH - Initial implementation
*
*/
package de.truzzt.clearinghouse.edc.app.delegate;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/*
* Copyright (c) 2023 truzzt GmbH
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* truzzt GmbH - Initial implementation
*
*/
package de.truzzt.clearinghouse.edc.app.delegate;

import de.truzzt.clearinghouse.edc.dto.HandlerRequest;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Microsoft Corporation
* Copyright (c) 2023 truzzt GmbH
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
Expand All @@ -8,10 +8,9 @@
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* Microsoft Corporation - Initial implementation
* truzzt GmbH - Initial implementation
*
*/

package de.truzzt.clearinghouse.edc.dto;

import org.jetbrains.annotations.NotNull;
Expand All @@ -24,7 +23,7 @@ public class AppSenderRequest<B> {
private final String token;
private final B body;

private AppSenderRequest(@NotNull String url, @NotNull String token, @NotNull B body) {
public AppSenderRequest(@NotNull String url, @NotNull String token, @NotNull B body) {
this.url = url;
this.token = token;
this.body = body;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Microsoft Corporation
* Copyright (c) 2023 Microsoft Corporation
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
Expand All @@ -9,9 +9,9 @@
*
* Contributors:
* Microsoft Corporation - Initial implementation
* truzzt GmbH - EDC extension implementation
*
*/

package de.truzzt.clearinghouse.edc.dto;

import de.truzzt.clearinghouse.edc.types.ids.Message;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Microsoft Corporation
* Copyright (c) 2023 Microsoft Corporation
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
Expand All @@ -9,9 +9,9 @@
*
* Contributors:
* Microsoft Corporation - Initial implementation
* truzzt GmbH - EDC extension implementation
*
*/

package de.truzzt.clearinghouse.edc.dto;

import de.truzzt.clearinghouse.edc.types.ids.Message;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Microsoft Corporation
* Copyright (c) 2023 truzzt GmbH
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
Expand All @@ -8,10 +8,9 @@
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* Microsoft Corporation - Initial implementation
* truzzt GmbH - Initial implementation
*
*/

package de.truzzt.clearinghouse.edc.dto;

import com.fasterxml.jackson.annotation.JsonProperty;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Microsoft Corporation
* Copyright (c) 2023 truzzt GmbH
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
Expand All @@ -8,10 +8,9 @@
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* Microsoft Corporation - Initial implementation
* truzzt GmbH - Initial implementation
*
*/

package de.truzzt.clearinghouse.edc.dto;

import com.fasterxml.jackson.annotation.JsonProperty;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
/*
* Copyright (c) 2023 Microsoft Corporation
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* Microsoft Corporation - Initial implementation
* truzzt GmbH - EDC extension implementation
*
*/
package de.truzzt.clearinghouse.edc.handler;

import com.auth0.jwt.JWT;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/*
* Copyright (c) 2023 truzzt GmbH
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* truzzt GmbH - Initial implementation
*
*/
package de.truzzt.clearinghouse.edc.handler;

import de.truzzt.clearinghouse.edc.app.AppSender;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Microsoft Corporation
* Copyright (c) 2023 Microsoft Corporation
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
Expand All @@ -8,10 +8,10 @@
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* truzzt GmbH - Initial implementation
* Microsoft Corporation - Initial implementation
* truzzt GmbH - EDC extension implementation
*
*/

package de.truzzt.clearinghouse.edc.types;

import com.fasterxml.jackson.core.JsonProcessingException;
Expand All @@ -37,9 +37,9 @@ public <T> T parse(InputStream inputStream, Class<T> type) {
}
}

public byte[] toJson(Object object) {
public String toJson(Object object) {
try {
return mapper.writeValueAsBytes(object);
return mapper.writeValueAsString(object);
} catch (JsonProcessingException e) {
throw new EdcException("Error converting to JSON", e);
}
Expand Down
Loading