diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7d103e5 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,25 @@ +name: build +on: + push: + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: temurin + cache: 'gradle' + - name: Build and Test + run: ./gradlew check --info + - name: Sonar Analysis + run: ./gradlew jacocoTestReport sonar --info + if: env.SONAR_TOKEN != null + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file diff --git a/build.gradle b/build.gradle index f14b2bf..7918eb8 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,8 @@ plugins { id 'java-library' id 'io.freefair.lombok' version '8.6' + id 'jacoco' + id 'org.sonarqube' } java { @@ -9,6 +11,20 @@ java { } } +jacocoTestReport { + reports { + xml.required = true + } +} + +sonarqube { + properties { + property "sonar.projectKey", "xenit-eu_java-hateoas-hal-client" + property "sonar.organization", "xenit-eu" + property "sonar.host.url", "https://sonarcloud.io" + } +} + test { useJUnitPlatform() } diff --git a/lombok.config b/lombok.config new file mode 100644 index 0000000..b3fb0a2 --- /dev/null +++ b/lombok.config @@ -0,0 +1,4 @@ +config.stopBubbling = true +lombok.addLombokGeneratedAnnotation = true +lombok.nonnull.exceptiontype = IllegalArgumentException +lombok.anyConstructor.addConstructorProperties=true \ No newline at end of file diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..1959472 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,26 @@ +pluginManagement { + plugins { + id 'org.ajoberstar.grgit' version '5.2.2' + id 'org.sonarqube' version '5.0.0.4638' + } +} + +plugins { + id 'org.ajoberstar.reckon.settings' version '0.18.3' + id 'eu.xenit.enterprise-conventions.oss' version '0.5.1' +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + } +} + +reckon { + defaultInferredScope = 'patch' + snapshots() + scopeCalc = calcScopeFromCommitMessages() + stageCalc = { inventory, targetNormal -> java.util.Optional.empty() } +} + +rootProject.name = 'java-hal-client' \ No newline at end of file diff --git a/src/main/java/com/contentgrid/hateoas/client/hal/HalLink.java b/src/main/java/com/contentgrid/hateoas/client/hal/HalLink.java index 91af84f..f1ac583 100644 --- a/src/main/java/com/contentgrid/hateoas/client/hal/HalLink.java +++ b/src/main/java/com/contentgrid/hateoas/client/hal/HalLink.java @@ -11,7 +11,6 @@ @RequiredArgsConstructor(access = AccessLevel.PACKAGE) public class HalLink { - @Getter @NonNull String href; diff --git a/src/test/java/com/contentgrid/hateoas/client/hal/DefaultHalClientTest.java b/src/test/java/com/contentgrid/hateoas/client/hal/DefaultHalClientTest.java index 0bbfdf1..00baa15 100644 --- a/src/test/java/com/contentgrid/hateoas/client/hal/DefaultHalClientTest.java +++ b/src/test/java/com/contentgrid/hateoas/client/hal/DefaultHalClientTest.java @@ -3,16 +3,11 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import java.io.IOException; import java.net.URI; import java.nio.charset.StandardCharsets; import org.junit.jupiter.api.Test; import org.springframework.hateoas.MediaTypes; -import org.springframework.http.HttpRequest; import org.springframework.http.HttpStatus; -import org.springframework.http.client.ClientHttpRequestExecution; -import org.springframework.http.client.ClientHttpRequestInterceptor; -import org.springframework.http.client.ClientHttpResponse; import org.springframework.mock.http.client.MockClientHttpResponse; import org.springframework.web.client.RestClient;