diff --git a/.github/workflows/gradle-build-feature.yml b/.github/workflows/gradle-build-feature.yml index fc023588e..d33770c90 100644 --- a/.github/workflows/gradle-build-feature.yml +++ b/.github/workflows/gradle-build-feature.yml @@ -25,12 +25,6 @@ jobs: with: distribution: 'temurin' # See 'Supported distributions' for available options java-version: 21 - - name: Cache SonarQube packages - uses: actions/cache@v4 - with: - path: ~/.sonar/cache - key: ${{ runner.os }}-sonar - restore-keys: ${{ runner.os }}-sonar - name: Cache Gradle packages uses: actions/cache@v4 with: @@ -39,19 +33,7 @@ jobs: restore-keys: ${{ runner.os }}-gradle - name: Validate Gradle wrapper uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b - - name: Build with Gradle - uses: gradle/gradle-build-action@4137be6a8bf7d7133955359dbd952c0ca73b1021 - with: - arguments: assemble - name: Gradle runs tests uses: gradle/gradle-build-action@4137be6a8bf7d7133955359dbd952c0ca73b1021 with: arguments: check -# - name: Do SonarQube checks -# uses: gradle/gradle-build-action@4137be6a8bf7d7133955359dbd952c0ca73b1021 -# with: -# arguments: sonarqube --info -# env: -# GITHUB_TOKEN: ${{ secrets.GIT_HUB_TOKEN }} -# SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} -# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/gradle-build-native-feature.yml b/.github/workflows/gradle-build-native-feature.yml new file mode 100644 index 000000000..21266cd59 --- /dev/null +++ b/.github/workflows/gradle-build-native-feature.yml @@ -0,0 +1,39 @@ +name: Gradle Build - Native - Feature / Bug +on: + push: + branches: + - 'feature-**/*' + - 'bugfix-**/*' + - 'chore-**/*' + - 'doc-**/*' + - 'hotfix-**/*' + - 'dependabot/**/*' +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Node LTS + uses: actions/setup-node@v4 + with: + node-version: '20' + - name: Set up GraalVM 21 + uses: graalvm/setup-graalvm@v1.1.8 + with: + distribution: 'graalvm' + java-version: '21' + - name: Cache Gradle packages + uses: actions/cache@v4 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} + restore-keys: ${{ runner.os }}-gradle + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b + - name: Gradle runs tests + uses: gradle/gradle-build-action@4137be6a8bf7d7133955359dbd952c0ca73b1021 + with: + arguments: nativeTest diff --git a/.github/workflows/gradle-dependency-submission.yml b/.github/workflows/gradle-dependency-submission.yml new file mode 100644 index 000000000..3aa1f9b73 --- /dev/null +++ b/.github/workflows/gradle-dependency-submission.yml @@ -0,0 +1,22 @@ +name: Gradle Dependency Submission + +on: + push: + branches: [ 'develop', 'master', 'feature-2532/graal' ] + +permissions: + contents: write + +jobs: + dependency-submission: + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 21 + - name: Generate and submit dependency graph + uses: gradle/actions/dependency-submission@v4 diff --git a/.github/workflows/gradle-build-development.yml b/.github/workflows/gradle-deploy-develop.yml similarity index 60% rename from .github/workflows/gradle-build-development.yml rename to .github/workflows/gradle-deploy-develop.yml index f15575971..6c6be65db 100644 --- a/.github/workflows/gradle-build-development.yml +++ b/.github/workflows/gradle-deploy-develop.yml @@ -3,84 +3,87 @@ on: push: branches: - 'develop' - env: PROJECT_ID: ${{ secrets.RUN_PROJECT }} RUN_REGION: us-central1 SERVICE_NAME: checkins-develop + TARGET_URL: https://checkins-develop-tuvcfzotpq-uc.a.run.app jobs: - build: + test: runs-on: ubuntu-latest - environment: - name: Development - url: https://checkins-develop-tuvcfzotpq-uc.a.run.app/ steps: - uses: actions/checkout@v4 with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + fetch-depth: 0 - name: Set up Node LTS uses: actions/setup-node@v4 with: node-version: '20' - - name: Set up JDK 21 + - name: Set up Temurin 21 uses: actions/setup-java@v4 with: - distribution: 'temurin' # See 'Supported distributions' for available options + distribution: 'temurin' java-version: 21 - - name: Cache SonarQube packages + - name: Cache Gradle packages uses: actions/cache@v4 with: - path: ~/.sonar/cache - key: ${{ runner.os }}-sonar - restore-keys: ${{ runner.os }}-sonar + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} + restore-keys: ${{ runner.os }}-gradle + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + - name: Run tests with Gradle + run: ./gradlew check + deploy: + permissions: + contents: 'read' + id-token: 'write' + runs-on: ubuntu-latest + environment: + name: Development + url: ${{ env.TARGET_URL }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Node LTS + uses: actions/setup-node@v4 + with: + node-version: '20' + - name: Set up Temurin 21 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 21 - name: Cache Gradle packages uses: actions/cache@v4 with: path: ~/.gradle/caches key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} restore-keys: ${{ runner.os }}-gradle - - name: Validate Gradle wrapper - uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b - - name: Build with Gradle - uses: gradle/gradle-build-action@4137be6a8bf7d7133955359dbd952c0ca73b1021 - with: - arguments: assemble - env: - VITE_APP_API_URL: https://checkins-develop-tuvcfzotpq-uc.a.run.app - - name: Gradle runs tests - uses: gradle/gradle-build-action@4137be6a8bf7d7133955359dbd952c0ca73b1021 + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + - id: 'auth' + uses: 'google-github-actions/auth@v2' with: - arguments: check -# - name: Do SonarQube checks -# uses: gradle/gradle-build-action@4137be6a8bf7d7133955359dbd952c0ca73b1021 -# with: -# arguments: sonarqube --info -# env: -# GITHUB_TOKEN: ${{ secrets.GIT_HUB_TOKEN }} -# SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} -# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - - name: Setup python - run: | - sudo apt-get install python2.7 - - name: Export gcloud related env variable - run: export CLOUDSDK_PYTHON="/usr/bin/python2" - # Setup gcloud CLI - - uses: google-github-actions/setup-gcloud@v0 + project_id: 'oci-intern-2019' + workload_identity_provider: 'projects/832140020593/locations/global/workloadIdentityPools/github/providers/my-repo' + - name: 'Set up Cloud SDK' + uses: google-github-actions/setup-gcloud@v2 with: - version: "290.0.1" - service_account_key: ${{ secrets.RUN_SA_KEY }} - project_id: ${{ secrets.RUN_PROJECT }} - - name: Auth Configure Docker + version: '>= 363.0.0' + - name: 'Auth Configure Docker' run: |- gcloud --quiet auth configure-docker - name: Build the Docker image run: |- + ./gradlew assemble cd server docker build --tag "gcr.io/$PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA" . + env: + VITE_APP_API_URL: ${{ env.TARGET_URL }} - name: Push the Docker image to Google Container Registry - run: |- - cd server - docker push "gcr.io/$PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA" + run: docker push "gcr.io/$PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA" - name: Deploy image to Cloud Run run: |- gcloud run deploy "$SERVICE_NAME" \ @@ -103,7 +106,7 @@ jobs: --set-env-vars "MJ_APIKEY_PUBLIC=${{ secrets.MJ_APIKEY_PUBLIC }}" \ --set-env-vars "MJ_APIKEY_PRIVATE=${{ secrets.MJ_APIKEY_PRIVATE }}" \ --set-env-vars "GIT_HUB_TOKEN=${{ secrets.GIT_HUB_TOKEN }}" \ - --set-env-vars "WEB_ADDRESS=https://checkins-develop-tuvcfzotpq-uc.a.run.app" \ + --set-env-vars "WEB_ADDRESS=${{ env.TARGET_URL }}" \ --set-env-vars "FROM_ADDRESS=kimberlinm@objectcomputing.com" \ --set-env-vars "FROM_NAME=Check-Ins - DEVELOP" \ --set-env-vars "^@^MICRONAUT_ENVIRONMENTS=dev,cloud,google,gcp" \ diff --git a/.github/workflows/gradle-deploy-native-develop.yml b/.github/workflows/gradle-deploy-native-develop.yml new file mode 100644 index 000000000..1ddc5d225 --- /dev/null +++ b/.github/workflows/gradle-deploy-native-develop.yml @@ -0,0 +1,114 @@ +name: Gradle Build & Deploy - Native - Develop +on: + push: + branches: + - 'develop' +env: + PROJECT_ID: ${{ secrets.RUN_PROJECT }} + RUN_REGION: us-central1 + SERVICE_NAME: checkins-develop-native + TARGET_URL: https://checkins-develop-native-832140020593.us-central1.run.app +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Node LTS + uses: actions/setup-node@v4 + with: + node-version: '20' + - name: Set up GraalVM 21 + uses: graalvm/setup-graalvm@v1.1.8 + with: + distribution: 'graalvm' + java-version: '21' + - name: Cache Gradle packages + uses: actions/cache@v4 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} + restore-keys: ${{ runner.os }}-gradle + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + - name: Run tests with Gradle + run: ./gradlew nativeTest + deploy: + permissions: + contents: 'read' + id-token: 'write' + runs-on: ubuntu-latest + environment: + name: Development - Native + url: ${{ env.TARGET_URL }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Node LTS + uses: actions/setup-node@v4 + with: + node-version: '20' + - name: Set up GraalVM 21 + uses: graalvm/setup-graalvm@v1.1.8 + with: + distribution: 'graalvm' + java-version: '21' + - name: Cache Gradle packages + uses: actions/cache@v4 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} + restore-keys: ${{ runner.os }}-gradle + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + - id: 'auth' + uses: 'google-github-actions/auth@v2' + with: + project_id: 'oci-intern-2019' + workload_identity_provider: 'projects/832140020593/locations/global/workloadIdentityPools/github/providers/my-repo' + - name: 'Set up Cloud SDK' + uses: google-github-actions/setup-gcloud@v2 + with: + version: '>= 363.0.0' + - name: 'Auth Configure Docker' + run: |- + gcloud --quiet auth configure-docker + - name: Build a native docker image + run: ./gradlew dockerBuildNative + env: + VITE_APP_API_URL: ${{ env.TARGET_URL }} + - name: Push the Docker image to Google Container Registry + run: |- + cd server + docker push "gcr.io/$PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA" + - name: Deploy image to Cloud Run + run: |- + gcloud run deploy "$SERVICE_NAME" \ + --quiet \ + --region "$RUN_REGION" \ + --image "gcr.io/$PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA" \ + --memory 1Gi \ + --add-cloudsql-instances ${{ secrets.DB_CONNECTION_NAME }} \ + --set-env-vars "CLOUD_DB_CONNECTION_NAME=${{ secrets.DB_CONNECTION_NAME }}" \ + --set-env-vars "DB_NAME=${{ secrets.DB_NAME }}" \ + --set-env-vars "DATASOURCES_DEFAULT_PASSWORD=${{ secrets.DB_PASSWORD }}" \ + --set-env-vars "DATASOURCES_DEFAULT_USERNAME=${{ secrets.DB_USERNAME }}" \ + --set-env-vars "AES_KEY=${{ secrets.AES_KEY }}" \ + --set-env-vars "OAUTH_CLIENT_ID=${{ secrets.OAUTH_CLIENT_ID }}" \ + --set-env-vars "OAUTH_CLIENT_SECRET=${{ secrets.OAUTH_CLIENT_SECRET }}" \ + --set-env-vars "OAUTH_CALLBACK_URI"=${{ secrets.OAUTH_CALLBACK_URI }} \ + --set-env-vars "DIRECTORY_ID=${{ secrets.DIRECTORY_ID }}" \ + --set-env-vars "SERVICE_ACCOUNT_CREDENTIALS=${{ secrets.SERVICE_ACCOUNT_CREDENTIALS }}" \ + --set-env-vars "GSUITE_SUPER_ADMIN=${{ secrets.GSUITE_SUPER_ADMIN }}" \ + --set-env-vars "MJ_APIKEY_PUBLIC=${{ secrets.MJ_APIKEY_PUBLIC }}" \ + --set-env-vars "MJ_APIKEY_PRIVATE=${{ secrets.MJ_APIKEY_PRIVATE }}" \ + --set-env-vars "GIT_HUB_TOKEN=${{ secrets.GIT_HUB_TOKEN }}" \ + --set-env-vars "WEB_ADDRESS=${{ env.TARGET_URL }}" \ + --set-env-vars "FROM_ADDRESS=kimberlinm@objectcomputing.com" \ + --set-env-vars "FROM_NAME=Check-Ins - DEVELOP" \ + --set-env-vars "^@^MICRONAUT_ENVIRONMENTS=dev,cloud,google,gcp" \ + --platform "managed" \ + --max-instances 2 \ + --allow-unauthenticated diff --git a/server/build.gradle b/server/build.gradle index f3def31d7..093723c4a 100755 --- a/server/build.gradle +++ b/server/build.gradle @@ -1,7 +1,6 @@ import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform plugins { - id 'java-library' id 'maven-publish' id("com.gradleup.shadow") version "8.3.1" id("io.micronaut.application") version "4.4.2" @@ -29,6 +28,35 @@ micronaut { } } +dockerBuildNative { + def imageNameFromGithub = [] + if (System.getenv('PROJECT_ID') != null && System.getenv('SERVICE_NAME') && System.getenv('GITHUB_SHA')) { + imageNameFromGithub = ["gcr.io/${System.getenv('PROJECT_ID')}/${System.getenv('SERVICE_NAME')}:${System.getenv("GITHUB_SHA")}".toString()] + } + images = ["checkins:latest"] + imageNameFromGithub +} + +graalvmNative { + toolchainDetection = false + binaries { + all { + imageName.set('check-ins') + + // See https://github.com/micronaut-projects/micronaut-core/issues/10771 + buildArgs.add("--initialize-at-build-time=kotlin.coroutines.intrinsics.CoroutineSingletons") + + // When we are building for production (on CI), we do not want to include the dev migrations. + def isProduction = System.getenv('SERVICE_NAME') != null && System.getenv('SERVICE_NAME') == 'checkins-master' + def migrationLocations = isProduction ? "db/common" : "db/common,db/dev" + logger.lifecycle("ℹ️ Building with the migrations from: $migrationLocations") + + // Graal cannot scan for migrations at run-time, so we use this to specify the locations. + // See https://micronaut-projects.github.io/micronaut-flyway/latest/guide/#graalvm + buildArgs.add("-Dflyway.locations=$migrationLocations") + } + } +} + configurations { yarnBuildElements { canBeResolved = true @@ -89,7 +117,7 @@ dependencies { implementation "com.google.apis:google-api-services-gmail:v1-rev20240422-2.0.0" implementation "com.google.apis:google-api-services-admin-directory:directory_v1-rev20240509-2.0.0" - implementation 'com.google.cloud.sql:postgres-socket-factory:1.18.1' + implementation 'com.google.cloud.sql:postgres-socket-factory:1.19.0' implementation("io.micronaut.reactor:micronaut-reactor") implementation("io.micrometer:context-propagation") diff --git a/server/src/main/java/com/objectcomputing/checkins/services/feedback/suggestions/FeedbackSuggestionDTO.java b/server/src/main/java/com/objectcomputing/checkins/services/feedback/suggestions/FeedbackSuggestionDTO.java index be7e9f603..0cde7db13 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/feedback/suggestions/FeedbackSuggestionDTO.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/feedback/suggestions/FeedbackSuggestionDTO.java @@ -1,5 +1,6 @@ package com.objectcomputing.checkins.services.feedback.suggestions; +import io.micronaut.core.annotation.Introspected; import io.micronaut.core.annotation.Nullable; import lombok.AllArgsConstructor; import lombok.Data; @@ -8,6 +9,7 @@ import java.util.UUID; @Data +@Introspected @NoArgsConstructor @AllArgsConstructor public class FeedbackSuggestionDTO { diff --git a/server/src/main/java/com/objectcomputing/checkins/services/feedback_answer/question_and_answer/QuestionAndAnswerServices.java b/server/src/main/java/com/objectcomputing/checkins/services/feedback_answer/question_and_answer/QuestionAndAnswerServices.java index 8e6badf7f..18322d512 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/feedback_answer/question_and_answer/QuestionAndAnswerServices.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/feedback_answer/question_and_answer/QuestionAndAnswerServices.java @@ -3,6 +3,7 @@ import com.objectcomputing.checkins.services.feedback_answer.FeedbackAnswer; import com.objectcomputing.checkins.services.feedback_request.FeedbackRequest; import com.objectcomputing.checkins.services.feedback_template.template_question.TemplateQuestion; +import io.micronaut.core.annotation.Introspected; import io.micronaut.core.annotation.Nullable; import lombok.Getter; import lombok.Setter; @@ -14,6 +15,7 @@ public interface QuestionAndAnswerServices { @Setter @Getter + @Introspected class Tuple { private TemplateQuestion question; private FeedbackAnswer answer; diff --git a/server/src/main/java/com/objectcomputing/checkins/services/memberprofile/memberphoto/GooglePhotoAccessor.java b/server/src/main/java/com/objectcomputing/checkins/services/memberprofile/memberphoto/GooglePhotoAccessor.java index f610582ae..c2a74f6c8 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/memberprofile/memberphoto/GooglePhotoAccessor.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/memberprofile/memberphoto/GooglePhotoAccessor.java @@ -3,7 +3,7 @@ /** * Interface to access Google Photo data, and allow for simpler mocking in tests */ -interface GooglePhotoAccessor { +public interface GooglePhotoAccessor { byte[] getPhotoData(String workEmail); } diff --git a/server/src/main/java/com/objectcomputing/checkins/services/memberprofile/retentionreport/RetentionReportResponseDTO.java b/server/src/main/java/com/objectcomputing/checkins/services/memberprofile/retentionreport/RetentionReportResponseDTO.java index dc61c4bce..27cd6be7c 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/memberprofile/retentionreport/RetentionReportResponseDTO.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/memberprofile/retentionreport/RetentionReportResponseDTO.java @@ -1,5 +1,6 @@ package com.objectcomputing.checkins.services.memberprofile.retentionreport; +import io.micronaut.core.annotation.Introspected; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Getter; import lombok.Setter; @@ -8,6 +9,7 @@ @Setter @Getter +@Introspected public class RetentionReportResponseDTO { @Schema(description = "Total retention rate for specified period") diff --git a/server/src/main/java/com/objectcomputing/checkins/services/reports/CompensationHistory.java b/server/src/main/java/com/objectcomputing/checkins/services/reports/CompensationHistory.java index b64dbb955..bfabaf4b5 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/reports/CompensationHistory.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/reports/CompensationHistory.java @@ -4,6 +4,7 @@ import com.objectcomputing.checkins.services.memberprofile.MemberProfileRepository; import com.objectcomputing.checkins.exceptions.BadArgException; +import io.micronaut.core.annotation.Introspected; import org.apache.commons.csv.CSVParser; import org.apache.commons.csv.CSVRecord; @@ -22,6 +23,7 @@ public class CompensationHistory extends CSVProcessor { + @Introspected public record Compensation( UUID memberId, LocalDate startDate, diff --git a/server/src/main/java/com/objectcomputing/checkins/services/reports/CurrentInformation.java b/server/src/main/java/com/objectcomputing/checkins/services/reports/CurrentInformation.java index 6674a576f..ec44709df 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/reports/CurrentInformation.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/reports/CurrentInformation.java @@ -5,6 +5,7 @@ import com.objectcomputing.checkins.services.memberprofile.MemberProfileRepository; import com.objectcomputing.checkins.exceptions.BadArgException; +import io.micronaut.core.annotation.Introspected; import org.apache.commons.csv.CSVParser; import org.apache.commons.csv.CSVRecord; @@ -18,6 +19,7 @@ public class CurrentInformation extends CSVProcessor { + @Introspected public record Information( UUID memberId, float salary, diff --git a/server/src/main/java/com/objectcomputing/checkins/services/reports/Feedback.java b/server/src/main/java/com/objectcomputing/checkins/services/reports/Feedback.java index 35673d4c3..2285c5e03 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/reports/Feedback.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/reports/Feedback.java @@ -11,7 +11,9 @@ @Getter @Introspected class Feedback { + @AllArgsConstructor + @Introspected @Getter public static class Answer { private final String memberName; diff --git a/server/src/main/java/com/objectcomputing/checkins/services/reports/PositionHistory.java b/server/src/main/java/com/objectcomputing/checkins/services/reports/PositionHistory.java index b8cbe28c5..957ff6344 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/reports/PositionHistory.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/reports/PositionHistory.java @@ -4,6 +4,7 @@ import com.objectcomputing.checkins.services.memberprofile.MemberProfileRepository; import com.objectcomputing.checkins.exceptions.BadArgException; +import io.micronaut.core.annotation.Introspected; import org.apache.commons.csv.CSVParser; import org.apache.commons.csv.CSVRecord; @@ -22,6 +23,7 @@ public class PositionHistory extends CSVProcessor { + @Introspected public record Position( UUID memberId, LocalDate date, diff --git a/server/src/main/java/com/objectcomputing/checkins/services/reports/ReportHours.java b/server/src/main/java/com/objectcomputing/checkins/services/reports/ReportHours.java index 11b27a646..0ec2d3f5d 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/reports/ReportHours.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/reports/ReportHours.java @@ -1,5 +1,8 @@ package com.objectcomputing.checkins.services.reports; +import io.micronaut.core.annotation.Introspected; + +@Introspected record ReportHours( float contributionHours, float ptoHours, diff --git a/server/src/main/java/com/objectcomputing/checkins/services/reports/ReportKudos.java b/server/src/main/java/com/objectcomputing/checkins/services/reports/ReportKudos.java index 064bc743d..b3787b7db 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/reports/ReportKudos.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/reports/ReportKudos.java @@ -1,7 +1,10 @@ package com.objectcomputing.checkins.services.reports; +import io.micronaut.core.annotation.Introspected; + import java.time.LocalDate; +@Introspected record ReportKudos( LocalDate dateCreated, String message, diff --git a/server/src/main/java/com/objectcomputing/checkins/services/reviews/ReviewPeriod.java b/server/src/main/java/com/objectcomputing/checkins/services/reviews/ReviewPeriod.java index c51753c1a..b92d85704 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/reviews/ReviewPeriod.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/reviews/ReviewPeriod.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; +import com.objectcomputing.checkins.util.serialize.LocalDateTimeSerializer; import io.micronaut.core.annotation.Introspected; import io.micronaut.core.annotation.Nullable; import io.micronaut.data.annotation.AutoPopulated; diff --git a/server/src/main/java/com/objectcomputing/checkins/services/reviews/ReviewPeriodCreateDTO.java b/server/src/main/java/com/objectcomputing/checkins/services/reviews/ReviewPeriodCreateDTO.java index 6b10842e3..e8091b1f7 100644 --- a/server/src/main/java/com/objectcomputing/checkins/services/reviews/ReviewPeriodCreateDTO.java +++ b/server/src/main/java/com/objectcomputing/checkins/services/reviews/ReviewPeriodCreateDTO.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; +import com.objectcomputing.checkins.util.serialize.LocalDateTimeSerializer; import io.micronaut.core.annotation.Introspected; import io.micronaut.core.annotation.Nullable; import io.swagger.v3.oas.annotations.media.Schema; diff --git a/server/src/main/java/com/objectcomputing/checkins/util/serialize/LocalDateTimeSerializer.java b/server/src/main/java/com/objectcomputing/checkins/util/serialize/LocalDateTimeSerializer.java new file mode 100644 index 000000000..5e70e2ca3 --- /dev/null +++ b/server/src/main/java/com/objectcomputing/checkins/util/serialize/LocalDateTimeSerializer.java @@ -0,0 +1,17 @@ +package com.objectcomputing.checkins.util.serialize; + +import io.micronaut.core.annotation.Introspected; + +import java.time.format.DateTimeFormatter; + +@Introspected +public class LocalDateTimeSerializer extends com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer { + + protected LocalDateTimeSerializer() { + super(); + } + + public LocalDateTimeSerializer(DateTimeFormatter t) { + super(t); + } +} \ No newline at end of file diff --git a/server/src/main/resources/META-INF/native-image/com.objectcomputing/checkins/reflect-config.json b/server/src/main/resources/META-INF/native-image/com.objectcomputing/checkins/reflect-config.json new file mode 100644 index 000000000..c7ac5c8c3 --- /dev/null +++ b/server/src/main/resources/META-INF/native-image/com.objectcomputing/checkins/reflect-config.json @@ -0,0 +1,55 @@ +[ + { + "name": "com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer", + "allDeclaredConstructors" : true, + "allPublicConstructors" : true + }, + { + "name": "com.objectcomputing.checkins.util.serialize.LocalDateTimeSerializer", + "allDeclaredConstructors" : true, + "allPublicConstructors" : true + }, + { + "name": "com.objectcomputing.checkins.services.permissions.PermissionSerializer", + "allDeclaredConstructors" : true, + "allPublicConstructors" : true + }, + { + "name": "com.objectcomputing.checkins.services.settings.SettingOptionSerializer", + "allDeclaredConstructors" : true, + "allPublicConstructors" : true + }, + { + "name": "com.objectcomputing.checkins.services.settings.SettingOptionDeserializer", + "allDeclaredConstructors" : true, + "allPublicConstructors" : true + }, + { + "name": "org.flywaydb.database.postgresql.PostgreSQLConfigurationExtension", + "condition": { + "typeReachable": "org.flywaydb.core.internal.plugin.PluginRegister" + }, + "allPublicConstructors": true, + "allPublicMethods": true + }, + { + "name": "io.micronaut.http.hateoas.JsonError", + "queryAllDeclaredMethods": true, + "allDeclaredFields": true, + "queryAllDeclaredConstructors": true, + "methods": [ + { + "name": "logref", + "parameterTypes": [ + "java.lang.String" + ] + }, + { + "name": "path", + "parameterTypes": [ + "java.lang.String" + ] + } + ] + } +] \ No newline at end of file diff --git a/server/src/test/java/com/objectcomputing/checkins/security/CheckinsOpenIdAuthenticationMapperTest.java b/server/src/test/java/com/objectcomputing/checkins/security/CheckinsOpenIdAuthenticationMapperTest.java index bc4329a95..a51ec9a4f 100644 --- a/server/src/test/java/com/objectcomputing/checkins/security/CheckinsOpenIdAuthenticationMapperTest.java +++ b/server/src/test/java/com/objectcomputing/checkins/security/CheckinsOpenIdAuthenticationMapperTest.java @@ -18,7 +18,9 @@ import org.junit.jupiter.api.Test; import reactor.test.StepVerifier; +import java.util.HashSet; import java.util.List; +import java.util.Set; import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.*; @@ -58,7 +60,7 @@ void testCreateAuthenticationResponse() { Authentication authentication = auth.getAuthentication().orElse(null); assertNotNull(authentication); assertEquals(MemberProfileUtils.getFullName(memberProfile), authentication.getName()); - assertThat(authentication.getRoles(), CoreMatchers.hasItems(RoleType.Constants.PDL_ROLE, RoleType.Constants.ADMIN_ROLE)); + assertEquals(Set.of(RoleType.Constants.PDL_ROLE, RoleType.Constants.ADMIN_ROLE), new HashSet<>(authentication.getRoles())); assertTrue(roles.containsAll(authentication.getRoles())); assertEquals(roles.size(), authentication.getRoles().size()); }).verifyComplete(); diff --git a/server/src/test/java/com/objectcomputing/checkins/security/SecurityRuleResultTest.java b/server/src/test/java/com/objectcomputing/checkins/security/SecurityRuleResultTest.java index c6a5e6120..f0e083b8f 100644 --- a/server/src/test/java/com/objectcomputing/checkins/security/SecurityRuleResultTest.java +++ b/server/src/test/java/com/objectcomputing/checkins/security/SecurityRuleResultTest.java @@ -19,6 +19,7 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledInNativeImage; import org.mockito.Mock; import org.reactivestreams.Publisher; import reactor.test.StepVerifier; @@ -32,6 +33,9 @@ import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.openMocks; +// Disabled in nativeTest, as we get an exception from Mockito +// java.lang.NoClassDefFoundError: Could not initialize class org.mockito.internal.configuration.plugins.Plugins +@DisabledInNativeImage class SecurityRuleResultTest extends TestContainersSuite { private static final List USER_PERMISSIONS = List.of( diff --git a/server/src/test/java/com/objectcomputing/checkins/services/TestContainersSuite.java b/server/src/test/java/com/objectcomputing/checkins/services/TestContainersSuite.java index 0cbb4c108..931cd8eb9 100644 --- a/server/src/test/java/com/objectcomputing/checkins/services/TestContainersSuite.java +++ b/server/src/test/java/com/objectcomputing/checkins/services/TestContainersSuite.java @@ -72,9 +72,9 @@ private void deleteAllEntities() { getRoleRepository().deleteAll(); getCheckInRepository().deleteAll(); getFeedbackRequestRepository().deleteAll(); + getReviewPeriodRepository().deleteAll(); getFeedbackTemplateRepository().deleteAll(); getMemberProfileRepository().deleteAll(); - getReviewPeriodRepository().deleteAll(); getReviewAssignmentRepository().deleteAll(); } diff --git a/server/src/test/java/com/objectcomputing/checkins/services/checkindocument/CheckinDocumentServiceImplTest.java b/server/src/test/java/com/objectcomputing/checkins/services/checkindocument/CheckinDocumentServiceImplTest.java index 1084f6632..595aaadc9 100644 --- a/server/src/test/java/com/objectcomputing/checkins/services/checkindocument/CheckinDocumentServiceImplTest.java +++ b/server/src/test/java/com/objectcomputing/checkins/services/checkindocument/CheckinDocumentServiceImplTest.java @@ -9,6 +9,7 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledInNativeImage; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -17,9 +18,22 @@ import java.util.Set; import java.util.UUID; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; - +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.any; +import static org.mockito.Mockito.eq; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.reset; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +// Disabled in nativeTest, as we get an exception from Mockito +// => org.graalvm.nativeimage.MissingReflectionRegistrationError: The program tried to reflectively access the proxy class +// inheriting [org.mockito.plugins.MockMaker] without it being registered for runtime reflection +@DisabledInNativeImage class CheckinDocumentServiceImplTest extends TestContainersSuite { @Mock diff --git a/server/src/test/java/com/objectcomputing/checkins/services/feedback_request/FeedbackRequestTest.java b/server/src/test/java/com/objectcomputing/checkins/services/feedback_request/FeedbackRequestTest.java index ca1f88844..d88933965 100644 --- a/server/src/test/java/com/objectcomputing/checkins/services/feedback_request/FeedbackRequestTest.java +++ b/server/src/test/java/com/objectcomputing/checkins/services/feedback_request/FeedbackRequestTest.java @@ -18,6 +18,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledInNativeImage; import org.mockito.Mockito; import java.time.LocalDate; @@ -37,6 +38,9 @@ import static org.mockito.Mockito.when; @Property(name = "replace.mailjet.factory", value = StringUtils.TRUE) +// Disabled in nativeTest, as we get an exception from Mockito +// => java.lang.NoClassDefFoundError: Could not initialize class org.mockito.Mockito +@DisabledInNativeImage class FeedbackRequestTest extends TestContainersSuite { private FeedbackRequestRepository feedbackReqRepository; diff --git a/server/src/test/java/com/objectcomputing/checkins/services/file/FileControllerTest.java b/server/src/test/java/com/objectcomputing/checkins/services/file/FileControllerTest.java index b62eece9c..314fa1f6e 100644 --- a/server/src/test/java/com/objectcomputing/checkins/services/file/FileControllerTest.java +++ b/server/src/test/java/com/objectcomputing/checkins/services/file/FileControllerTest.java @@ -15,6 +15,7 @@ import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledInNativeImage; import java.io.File; import java.io.FileWriter; @@ -26,9 +27,20 @@ import static com.objectcomputing.checkins.services.role.RoleType.Constants.MEMBER_ROLE; import static io.micronaut.http.MediaType.MULTIPART_FORM_DATA; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; - +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.any; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +// Disabled in nativeTest, as we get an exception from Mockito +// => java.lang.NoClassDefFoundError: Could not initialize class org.mockito.Mockito +@DisabledInNativeImage class FileControllerTest extends TestContainersSuite { @Inject diff --git a/server/src/test/java/com/objectcomputing/checkins/services/file/FileServicesImplTest.java b/server/src/test/java/com/objectcomputing/checkins/services/file/FileServicesImplTest.java index 4efc3852d..cbbfbd97c 100644 --- a/server/src/test/java/com/objectcomputing/checkins/services/file/FileServicesImplTest.java +++ b/server/src/test/java/com/objectcomputing/checkins/services/file/FileServicesImplTest.java @@ -25,6 +25,7 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledInNativeImage; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.invocation.InvocationOnMock; @@ -60,6 +61,9 @@ import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.openMocks; +// Disabled in nativeTest, as we get an exception from Mockito +// => java.lang.NoClassDefFoundError: Could not initialize class org.mockito.internal.configuration.plugins.Plugins +@DisabledInNativeImage class FileServicesImplTest extends TestContainersSuite { private static File testFile; diff --git a/server/src/test/java/com/objectcomputing/checkins/services/guild/GuildTest.java b/server/src/test/java/com/objectcomputing/checkins/services/guild/GuildTest.java index 6d1a8b02d..961a04907 100644 --- a/server/src/test/java/com/objectcomputing/checkins/services/guild/GuildTest.java +++ b/server/src/test/java/com/objectcomputing/checkins/services/guild/GuildTest.java @@ -23,6 +23,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledInNativeImage; import org.mockito.Mockito; import java.util.Arrays; @@ -46,6 +47,9 @@ import static org.mockito.Mockito.when; @Property(name = "replace.mailjet.factory", value = StringUtils.TRUE) +// Disabled in nativeTest, as we get an exception from Mockito +// => java.lang.NoClassDefFoundError: Could not initialize class org.mockito.Mockito +@DisabledInNativeImage class GuildTest extends TestContainersSuite { @Inject diff --git a/server/src/test/java/com/objectcomputing/checkins/services/member_skill/MemberSkillServiceImplTest.java b/server/src/test/java/com/objectcomputing/checkins/services/member_skill/MemberSkillServiceImplTest.java index 2afed973a..ea5ef3780 100644 --- a/server/src/test/java/com/objectcomputing/checkins/services/member_skill/MemberSkillServiceImplTest.java +++ b/server/src/test/java/com/objectcomputing/checkins/services/member_skill/MemberSkillServiceImplTest.java @@ -11,6 +11,7 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledInNativeImage; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -26,13 +27,15 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.eq; import static org.mockito.Mockito.never; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +// Disabled in nativeTest, as we get an exception from Mockito +// => java.lang.NoClassDefFoundError: Could not initialize class org.mockito.internal.configuration.plugins.Plugins +@DisabledInNativeImage class MemberSkillServiceImplTest extends TestContainersSuite { @Mock diff --git a/server/src/test/java/com/objectcomputing/checkins/services/member_skill/skillsreport/SkillsReportServicesImplTest.java b/server/src/test/java/com/objectcomputing/checkins/services/member_skill/skillsreport/SkillsReportServicesImplTest.java index 5bc7b4127..17e64ee38 100644 --- a/server/src/test/java/com/objectcomputing/checkins/services/member_skill/skillsreport/SkillsReportServicesImplTest.java +++ b/server/src/test/java/com/objectcomputing/checkins/services/member_skill/skillsreport/SkillsReportServicesImplTest.java @@ -12,6 +12,7 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledInNativeImage; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -35,6 +36,9 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +// Disabled in nativeTest, as we get an exception from Mockito +// => java.lang.NoClassDefFoundError: Could not initialize class org.mockito.internal.configuration.plugins.Plugins +@DisabledInNativeImage class SkillsReportServicesImplTest extends TestContainersSuite { @Mock diff --git a/server/src/test/java/com/objectcomputing/checkins/services/memberprofile/MemberProfileTest.java b/server/src/test/java/com/objectcomputing/checkins/services/memberprofile/MemberProfileTest.java index 1c6156445..aa70d850e 100644 --- a/server/src/test/java/com/objectcomputing/checkins/services/memberprofile/MemberProfileTest.java +++ b/server/src/test/java/com/objectcomputing/checkins/services/memberprofile/MemberProfileTest.java @@ -18,6 +18,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledInNativeImage; import org.mockito.Mockito; import java.time.LocalDate; @@ -33,6 +34,9 @@ import static org.mockito.Mockito.when; @Property(name = "replace.mailjet.factory", value = StringUtils.TRUE) +// Disabled in nativeTest, as we get an exception from Mockito +// => java.lang.NoClassDefFoundError: Could not initialize class org.mockito.Mockito +@DisabledInNativeImage class MemberProfileTest extends TestContainersSuite { @Inject diff --git a/server/src/test/java/com/objectcomputing/checkins/services/memberprofile/csvreport/MemberProfileReportServicesImplTest.java b/server/src/test/java/com/objectcomputing/checkins/services/memberprofile/csvreport/MemberProfileReportServicesImplTest.java index c55fda5aa..244d78cf4 100644 --- a/server/src/test/java/com/objectcomputing/checkins/services/memberprofile/csvreport/MemberProfileReportServicesImplTest.java +++ b/server/src/test/java/com/objectcomputing/checkins/services/memberprofile/csvreport/MemberProfileReportServicesImplTest.java @@ -8,6 +8,7 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledInNativeImage; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; @@ -21,10 +22,14 @@ import java.util.List; import java.util.UUID; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.eq; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.when; +// Disabled in nativeTest, as we get an exception from Mockito +// => java.lang.NoClassDefFoundError: Could not initialize class org.mockito.internal.configuration.plugins.Plugins +@DisabledInNativeImage class MemberProfileReportServicesImplTest extends TestContainersSuite { @Mock diff --git a/server/src/test/java/com/objectcomputing/checkins/services/memberprofile/currentuser/CurrentUserControllerTest.java b/server/src/test/java/com/objectcomputing/checkins/services/memberprofile/currentuser/CurrentUserControllerTest.java index 96b7f012e..0f8107236 100644 --- a/server/src/test/java/com/objectcomputing/checkins/services/memberprofile/currentuser/CurrentUserControllerTest.java +++ b/server/src/test/java/com/objectcomputing/checkins/services/memberprofile/currentuser/CurrentUserControllerTest.java @@ -14,6 +14,7 @@ import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledInNativeImage; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -26,6 +27,9 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.Mockito.when; +// Disabled in nativeTest, as we get an exception from Mockito +// => java.lang.NoClassDefFoundError: Could not initialize class org.mockito.internal.configuration.plugins.Plugins +@DisabledInNativeImage class CurrentUserControllerTest extends TestContainersSuite implements MemberProfileFixture, RoleFixture { private static final Map userAttributes = new HashMap<>(); diff --git a/server/src/test/java/com/objectcomputing/checkins/services/memberprofile/currentuser/CurrentUserServicesImplTest.java b/server/src/test/java/com/objectcomputing/checkins/services/memberprofile/currentuser/CurrentUserServicesImplTest.java index 7a1753bcd..47abbcbe6 100644 --- a/server/src/test/java/com/objectcomputing/checkins/services/memberprofile/currentuser/CurrentUserServicesImplTest.java +++ b/server/src/test/java/com/objectcomputing/checkins/services/memberprofile/currentuser/CurrentUserServicesImplTest.java @@ -10,6 +10,7 @@ import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledInNativeImage; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -18,8 +19,14 @@ import static com.objectcomputing.checkins.services.memberprofile.MemberProfileTestUtil.mkMemberProfile; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.Mockito.*; - +import static org.mockito.Mockito.any; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +// Disabled in nativeTest, as we get an exception from Mockito +// => java.lang.NoClassDefFoundError: Could not initialize class org.mockito.internal.configuration.plugins.Plugins +@DisabledInNativeImage class CurrentUserServicesImplTest extends TestContainersSuite { @Mock diff --git a/server/src/test/java/com/objectcomputing/checkins/services/memberprofile/memberphoto/MemberPhotoControllerTest.java b/server/src/test/java/com/objectcomputing/checkins/services/memberprofile/memberphoto/MemberPhotoControllerTest.java index c85658032..a16bddb9e 100644 --- a/server/src/test/java/com/objectcomputing/checkins/services/memberprofile/memberphoto/MemberPhotoControllerTest.java +++ b/server/src/test/java/com/objectcomputing/checkins/services/memberprofile/memberphoto/MemberPhotoControllerTest.java @@ -9,6 +9,7 @@ import io.micronaut.test.annotation.MockBean; import jakarta.inject.Inject; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledInNativeImage; import java.util.Base64; @@ -21,6 +22,9 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +// Disabled in nativeTest, as we get an exception from Mockito +// => Message: Could not initialize class org.mockito.Mockito +@DisabledInNativeImage class MemberPhotoControllerTest extends TestContainersSuite { @Inject diff --git a/server/src/test/java/com/objectcomputing/checkins/services/memberprofile/memberphoto/MemberPhotoServiceImplTest.java b/server/src/test/java/com/objectcomputing/checkins/services/memberprofile/memberphoto/MemberPhotoServiceImplTest.java index ab371dee1..2108e86bc 100644 --- a/server/src/test/java/com/objectcomputing/checkins/services/memberprofile/memberphoto/MemberPhotoServiceImplTest.java +++ b/server/src/test/java/com/objectcomputing/checkins/services/memberprofile/memberphoto/MemberPhotoServiceImplTest.java @@ -11,6 +11,7 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledInNativeImage; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -26,6 +27,9 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +// Disabled in nativeTest, as we get an exception from Mockito +// => java.lang.NoClassDefFoundError: Could not initialize class org.mockito.internal.configuration.plugins.Plugins +@DisabledInNativeImage class MemberPhotoServiceImplTest extends TestContainersSuite { @Mock diff --git a/server/src/test/java/com/objectcomputing/checkins/services/pulseresponse/PulseResponseTest.java b/server/src/test/java/com/objectcomputing/checkins/services/pulseresponse/PulseResponseTest.java index dcfc1b673..e56aa79a5 100644 --- a/server/src/test/java/com/objectcomputing/checkins/services/pulseresponse/PulseResponseTest.java +++ b/server/src/test/java/com/objectcomputing/checkins/services/pulseresponse/PulseResponseTest.java @@ -19,6 +19,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledInNativeImage; import org.mockito.Mockito; import java.time.LocalDate; @@ -38,6 +39,9 @@ import static org.mockito.Mockito.when; @Property(name = "replace.mailjet.factory", value = StringUtils.TRUE) +// Disabled in nativeTest, as we get an exception from Mockito +// => java.lang.NoClassDefFoundError: Could not initialize class org.mockito.Mockito +@DisabledInNativeImage class PulseResponseTest extends TestContainersSuite { @Inject diff --git a/server/src/test/java/com/objectcomputing/checkins/services/request_notifications/CheckServicesImplTest.java b/server/src/test/java/com/objectcomputing/checkins/services/request_notifications/CheckServicesImplTest.java index db095bf37..7c43b3d9d 100644 --- a/server/src/test/java/com/objectcomputing/checkins/services/request_notifications/CheckServicesImplTest.java +++ b/server/src/test/java/com/objectcomputing/checkins/services/request_notifications/CheckServicesImplTest.java @@ -8,6 +8,7 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledInNativeImage; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -20,6 +21,9 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +// Disabled in nativeTest, as we get an exception from Mockito +// => java.lang.NoClassDefFoundError: Could not initialize class org.mockito.internal.configuration.plugins.Plugins +@DisabledInNativeImage class CheckServicesImplTest extends TestContainersSuite { @Mock diff --git a/server/src/test/java/com/objectcomputing/checkins/services/reviews/ReviewPeriodControllerTest.java b/server/src/test/java/com/objectcomputing/checkins/services/reviews/ReviewPeriodControllerTest.java index d770df6f9..0835a0c97 100644 --- a/server/src/test/java/com/objectcomputing/checkins/services/reviews/ReviewPeriodControllerTest.java +++ b/server/src/test/java/com/objectcomputing/checkins/services/reviews/ReviewPeriodControllerTest.java @@ -27,10 +27,13 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.List; @@ -51,6 +54,8 @@ class ReviewPeriodControllerTest extends TestContainersSuite implements ReviewAssignmentFixture, ReviewPeriodFixture, MemberProfileFixture, RoleFixture, FeedbackRequestFixture { + public static final Logger LOG = LoggerFactory.getLogger(ReviewPeriodControllerTest.class); + @Inject @Client("/services/review-periods") private HttpClient client; @@ -191,6 +196,13 @@ void testReviewPeriodCreateDTOSerialization() throws JsonProcessingException { reviewPeriodCreateDTO.setPeriodStartDate(LocalDateTime.now()); reviewPeriodCreateDTO.setPeriodEndDate(LocalDateTime.now()); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); + String expectedLaunchDateFormat = formatter.format(reviewPeriodCreateDTO.getLaunchDate()); + String expectedSelfReviewCloseDateFormat = formatter.format(reviewPeriodCreateDTO.getSelfReviewCloseDate()); + String expectedCloseDateFormat = formatter.format(reviewPeriodCreateDTO.getCloseDate()); + String expectedPeriodStartDateFormat = formatter.format(reviewPeriodCreateDTO.getPeriodStartDate()); + String expectedPeriodEndDateFormat = formatter.format(reviewPeriodCreateDTO.getPeriodEndDate()); + final HttpRequest request = HttpRequest. POST("/", reviewPeriodCreateDTO).basicAuth(ADMIN_ROLE, ADMIN_ROLE); final HttpResponse response = client.toBlocking().exchange(request, String.class); @@ -201,25 +213,18 @@ void testReviewPeriodCreateDTOSerialization() throws JsonProcessingException { assertEquals(HttpStatus.CREATED, response.getStatus()); ObjectMapper objectMapper = new ObjectMapper(); - String expectedJson = objectMapper.writeValueAsString(reviewPeriodCreateDTO); - - String expectedLaunchDateFormat = objectMapper.readTree(expectedJson).get("launchDate").asText(); String actualLaunchDateFormat = objectMapper.readTree(actualJson).get("launchDate").asText(); assertEquals(expectedLaunchDateFormat, actualLaunchDateFormat); - String expectedSelfReviewCloseDateFormat = objectMapper.readTree(expectedJson).get("selfReviewCloseDate").asText(); String actualSelfReviewCloseDateFormat = objectMapper.readTree(actualJson).get("selfReviewCloseDate").asText(); assertEquals(expectedSelfReviewCloseDateFormat, actualSelfReviewCloseDateFormat); - String expectedCloseDateFormat = objectMapper.readTree(expectedJson).get("closeDate").asText(); String actualCloseDateFormat = objectMapper.readTree(actualJson).get("closeDate").asText(); assertEquals(expectedCloseDateFormat, actualCloseDateFormat); - String expectedPeriodStartDateFormat = objectMapper.readTree(expectedJson).get("periodStartDate").asText(); String actualPeriodStartDateFormat = objectMapper.readTree(actualJson).get("periodStartDate").asText(); assertEquals(expectedPeriodStartDateFormat, actualPeriodStartDateFormat); - String expectedPeriodEndDateFormat = objectMapper.readTree(expectedJson).get("periodEndDate").asText(); String actualPeriodEndDateFormat = objectMapper.readTree(actualJson).get("periodEndDate").asText(); assertEquals(expectedPeriodEndDateFormat, actualPeriodEndDateFormat); } diff --git a/server/src/test/resources/META-INF/native-image/com.objectcomputing/checkins-test/reflect-config.json b/server/src/test/resources/META-INF/native-image/com.objectcomputing/checkins-test/reflect-config.json new file mode 100644 index 000000000..fadf978ec --- /dev/null +++ b/server/src/test/resources/META-INF/native-image/com.objectcomputing/checkins-test/reflect-config.json @@ -0,0 +1,22 @@ +[ + { + "name": "com.github.dockerjava.api.model.RuntimeInfo", + "queryAllDeclaredMethods": true, + "allDeclaredFields": true, + "queryAllDeclaredConstructors": true, + "methods": [ + { + "name": "", + "parameterTypes": [ + + ] + }, + { + "name": "setPath", + "parameterTypes": [ + "java.lang.String" + ] + } + ] + } +] \ No newline at end of file