diff --git a/SUMMARY.md b/SUMMARY.md index d93fb910e..0f259b82a 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -12,7 +12,7 @@ * [spring-boot-togglz-sample](boot-togglz-sample/README.md) * [spring-boot-ultimate-redis](boot-ultimate-redis/README.md) * [GraphQL](graphql/README.md) - * [spring-boot-graphql-querydsl](graphql/spring-boot-graphql-querydsl/README.md) + * [spring-boot-graphql-querydsl](graphql/boot-graphql-querydsl/README.md) * [GraphQl implementation using webflux](graphql/boot-graphql-webflux/README.md) * [GraphQl implementation using webmvc](graphql/boot-graphql-webmvc/README.md) * [httpClients](httpClients/README.md) diff --git a/graphql/boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/mapper/PostMapperDecorator.java b/graphql/boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/mapper/PostMapperDecorator.java index 8671a93b0..de42b28b3 100644 --- a/graphql/boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/mapper/PostMapperDecorator.java +++ b/graphql/boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/mapper/PostMapperDecorator.java @@ -41,6 +41,7 @@ void setAfterMappingToPost(CreatePostRequest createPostRequest, @MappingTarget P setTags(createPostRequest.tags(), post); } + @Override public Post setTags(List tagRequests, Post post) { if (!CollectionUtils.isEmpty(tagRequests)) { tagRequests.forEach(tagRequest -> { diff --git a/graphql/spring-boot-graphql-querydsl/.gitignore b/graphql/spring-boot-graphql-querydsl/.gitignore deleted file mode 100644 index c2065bc26..000000000 --- a/graphql/spring-boot-graphql-querydsl/.gitignore +++ /dev/null @@ -1,37 +0,0 @@ -HELP.md -.gradle -build/ -!gradle/wrapper/gradle-wrapper.jar -!**/src/main/**/build/ -!**/src/test/**/build/ - -### STS ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache -bin/ -!**/src/main/**/bin/ -!**/src/test/**/bin/ - -### IntelliJ IDEA ### -.idea -*.iws -*.iml -*.ipr -out/ -!**/src/main/**/out/ -!**/src/test/**/out/ - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ - -### VS Code ### -.vscode/ diff --git a/graphql/spring-boot-graphql-querydsl/Dockerfile b/graphql/spring-boot-graphql-querydsl/Dockerfile deleted file mode 100644 index 6905b8116..000000000 --- a/graphql/spring-boot-graphql-querydsl/Dockerfile +++ /dev/null @@ -1,14 +0,0 @@ -FROM eclipse-temurin:17.0.9_9-jre-focal as builder -WORKDIR application -ARG JAR_FILE=build/libs/spring-boot-graphql-querydsl-0.0.1-SNAPSHOT.jar -COPY ${JAR_FILE} application.jar -RUN java -Djarmode=layertools -jar application.jar extract - -# the second stage of our build will copy the extracted layers -FROM eclipse-temurin:17.0.9_9-jre-focal -WORKDIR application -COPY --from=builder application/dependencies/ ./ -COPY --from=builder application/spring-boot-loader/ ./ -COPY --from=builder application/snapshot-dependencies/ ./ -COPY --from=builder application/application/ ./ -ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"] diff --git a/graphql/spring-boot-graphql-querydsl/README.md b/graphql/spring-boot-graphql-querydsl/README.md deleted file mode 100644 index 940d004d0..000000000 --- a/graphql/spring-boot-graphql-querydsl/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# GraphQL with QueryDSL - -GraphQL is a query language for APIs that allows for more flexible and efficient data querying and manipulation. QueryDSL is a Java-based library that allows for the creation of type-safe queries in a variety of query languages, including GraphQL. - -Together, GraphQL and QueryDSL can provide developers with a powerful toolset for building and managing complex data-driven applications. QueryDSL allows for the creation of type-safe queries in GraphQL, providing a more robust and efficient way to query data from APIs. Additionally, QueryDSL's support for multiple query languages means that developers can easily switch between different query languages without having to rewrite their code. - - -### Run tests - -`./gradlew clean build` - -### Run locally - -```shell -docker-compose -f docker/docker-compose.yml up -d -./gradlew bootRun -Plocal -``` - -### Useful Links - -* Swagger UI: http://localhost:8080/swagger-ui.html -* Actuator Endpoint: http://localhost:8080/actuator - diff --git a/graphql/spring-boot-graphql-querydsl/build.gradle.kts b/graphql/spring-boot-graphql-querydsl/build.gradle.kts deleted file mode 100644 index d5a323b29..000000000 --- a/graphql/spring-boot-graphql-querydsl/build.gradle.kts +++ /dev/null @@ -1,167 +0,0 @@ -import org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL -import org.gradle.api.tasks.testing.logging.TestLogEvent.* -import java.io.Reader -import java.util.* - -plugins { - java - id("org.springframework.boot") version "3.1.5" - id("io.spring.dependency-management") version "1.1.3" - id("com.diffplug.spotless") version "6.22.0" - id("com.gorylenko.gradle-git-properties") version "2.4.1" - id("org.owasp.dependencycheck") version "8.4.2" - jacoco - id("org.sonarqube") version "4.4.1.3373" -} - -group = "com.example.graphql" -version = "0.0.1-SNAPSHOT" -java.sourceCompatibility = JavaVersion.VERSION_17 - -configurations { - compileOnly { - extendsFrom(configurations.annotationProcessor.get()) - } -} - -repositories { - mavenCentral() - maven { url = uri("https://repo.spring.io/milestone") } -} - -dependencies { - implementation("org.springframework.boot:spring-boot-starter-graphql") - implementation("org.springframework.boot:spring-boot-starter-actuator") - implementation("org.springframework.boot:spring-boot-starter-data-jpa") - implementation("org.springframework.boot:spring-boot-starter-validation") - implementation("org.springframework.boot:spring-boot-starter-web") - implementation("org.liquibase:liquibase-core") - // Printing Queries effectively - implementation("net.ttddyy:datasource-proxy:1.9") - - // QueryDSL for JPA - compileOnly("com.querydsl:querydsl-jpa-codegen:5.0.0:jakarta") - implementation("com.querydsl:querydsl-jpa:5.0.0:jakarta") - - // Jakarta EE 10 as SB is using Jakarta EE - implementation("jakarta.persistence:jakarta.persistence-api:3.1.0") - implementation("jakarta.inject:jakarta.inject-api:2.0.1") - implementation("jakarta.annotation:jakarta.annotation-api:2.1.1") - - compileOnly("org.projectlombok:lombok") - runtimeOnly("org.postgresql:postgresql") - annotationProcessor("org.projectlombok:lombok") - annotationProcessor("com.querydsl:querydsl-apt:5.0.0:jakarta") - annotationProcessor("jakarta.persistence:jakarta.persistence-api:3.1.0") - annotationProcessor("jakarta.annotation:jakarta.annotation-api:2.1.1") - - testImplementation("org.springframework.boot:spring-boot-starter-test") - testImplementation("org.springframework.boot:spring-boot-testcontainers") - testImplementation("io.projectreactor:reactor-test") - testImplementation("org.testcontainers:junit-jupiter") - testImplementation("org.testcontainers:postgresql") - testImplementation("org.springframework.graphql:spring-graphql-test") - testImplementation("org.projectlombok:lombok") - testImplementation("org.springframework:spring-webflux") -} - -sourceSets { - named("main") { - java { - srcDirs("src/main/java", "build/generated/sources/annotationProcessor/java/main") - } - } -} - -tasks.named("compileJava") { - dependsOn("processResources") -} - -tasks.withType { - useJUnitPlatform() - - testLogging { - events = setOf(PASSED, FAILED, SKIPPED) - showStandardStreams = true - exceptionFormat = FULL - } - finalizedBy(tasks.jacocoTestReport, tasks.jacocoTestCoverageVerification) -} - -jacoco { - toolVersion = "0.8.11" - //reportsDirectory.set(layout.buildDirectory.dir("customJacocoReportDir")) -} - -tasks.jacocoTestReport { - dependsOn(tasks.test) - reports { - xml.required.set(false) - csv.required.set(false) - html.outputLocation.set(layout.buildDirectory.dir("reports/jacoco")) - } -} - -tasks.jacocoTestCoverageVerification { - violationRules { - rule { - element = "BUNDLE" - //includes = listOf("com.example.graphql.*") - - limit { - counter = "LINE" - value = "COVEREDRATIO" - minimum = "0.47".toBigDecimal() - } - } - } -} - -gitProperties { - failOnNoGitDirectory = false - keys = listOf("git.branch", - "git.commit.id.abbrev", - "git.commit.user.name", - "git.commit.message.full") -} - -spotless { - java { - importOrder() - removeUnusedImports() - palantirJavaFormat("2.30.0") - formatAnnotations() - } -} - -// Reference doc : https://jeremylong.github.io/DependencyCheck/dependency-check-gradle/configuration.html -dependencyCheck { - // the default artifact types that will be analyzed. - analyzedTypes = listOf("jar") - // CI-tools usually needs XML-reports, but humans needs HTML. - formats = listOf("HTML", "JUNIT") - // Specifies if the build should be failed if a CVSS score equal to or above a specified level is identified. - // failBuildOnCVSS = 8.toFloat() - // Output directory where the report should be generated - outputDirectory = "$buildDir/reports/dependency-vulnerabilities" - // specify a list of known issues which contain false-positives to be suppressed - //suppressionFiles = ["$projectDir/config/dependencycheck/dependency-check-suppression.xml"] - // Sets the number of hours to wait before checking for new updates from the NVD, defaults to 4. - cveValidForHours = 24 -} - -sonarqube { - properties { - property("sonar.sourceEncoding", "UTF-8") - property("sonar.projectKey", "rajadilipkolli_mfscreener") - property("sonar.organization", "rajadilipkolli") - property("sonar.host.url", "https://sonarcloud.io") - property("sonar.sources", "src/main/java") - property("sonar.tests", "src/test/java") - property("sonar.exclusions", "src/main/java/**/config/*.*,src/main/java/**/entities/*.*,src/main/java/**/models/*.*,src/main/java/**/exceptions/*.*,src/main/java/**/utils/*.*,src/main/java/**/*Application.*") - property("sonar.test.inclusions", "**/*Test.java,**/*IntegrationTest.java,**/*IT.java") - property("sonar.java.codeCoveragePlugin", "jacoco") - property("sonar.coverage.jacoco.xmlReportPaths", "$buildDir/jacoco/test/jacoco.xml") - property("sonar.junit.reportPaths", "$buildDir/test-results/test") - } -} diff --git a/graphql/spring-boot-graphql-querydsl/docker/docker-compose-app.yml b/graphql/spring-boot-graphql-querydsl/docker/docker-compose-app.yml deleted file mode 100644 index 735793c6b..000000000 --- a/graphql/spring-boot-graphql-querydsl/docker/docker-compose-app.yml +++ /dev/null @@ -1,17 +0,0 @@ -version: '3.8' -services: - - spring-graphql-querydsl: - build: .. - ports: - - "18080:8080" - - "18787:8787" - restart: always - depends_on: - - postgresqldb - environment: - - SPRING_PROFILES_ACTIVE=docker - - SPRING_DATASOURCE_DRIVER_CLASS_NAME=org.postgresql.Driver - - SPRING_DATASOURCE_URL=jdbc:postgresql://postgresqldb:5432/rest - - SPRING_DATASOURCE_USERNAME=local - - SPRING_DATASOURCE_PASSWORD=local diff --git a/graphql/spring-boot-graphql-querydsl/docker/docker-compose.yml b/graphql/spring-boot-graphql-querydsl/docker/docker-compose.yml deleted file mode 100644 index e1d4161ee..000000000 --- a/graphql/spring-boot-graphql-querydsl/docker/docker-compose.yml +++ /dev/null @@ -1,11 +0,0 @@ -version: '3.8' -services: - - postgresqldb: - image: postgres:16.0-alpine - environment: - - POSTGRES_USER=local - - POSTGRES_PASSWORD=local - - POSTGRES_DB=rest - ports: - - "5432:5432" diff --git a/graphql/spring-boot-graphql-querydsl/gradle/wrapper/gradle-wrapper.jar b/graphql/spring-boot-graphql-querydsl/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 7f93135c4..000000000 Binary files a/graphql/spring-boot-graphql-querydsl/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/graphql/spring-boot-graphql-querydsl/gradle/wrapper/gradle-wrapper.properties b/graphql/spring-boot-graphql-querydsl/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 3fa8f862f..000000000 --- a/graphql/spring-boot-graphql-querydsl/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,7 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip -networkTimeout=10000 -validateDistributionUrl=true -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/graphql/spring-boot-graphql-querydsl/gradlew b/graphql/spring-boot-graphql-querydsl/gradlew deleted file mode 100755 index 1aa94a426..000000000 --- a/graphql/spring-boot-graphql-querydsl/gradlew +++ /dev/null @@ -1,249 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -# This is normally unused -# shellcheck disable=SC2034 -APP_BASE_NAME=${0##*/} -# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - if ! command -v java >/dev/null 2>&1 - then - die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC2039,SC3045 - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC2039,SC3045 - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, -# and any embedded shellness will be escaped. -# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be -# treated as '${Hostname}' itself on the command line. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Stop when "xargs" is not available. -if ! command -v xargs >/dev/null 2>&1 -then - die "xargs is not available" -fi - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/graphql/spring-boot-graphql-querydsl/gradlew.bat b/graphql/spring-boot-graphql-querydsl/gradlew.bat deleted file mode 100644 index 6689b85be..000000000 --- a/graphql/spring-boot-graphql-querydsl/gradlew.bat +++ /dev/null @@ -1,92 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -@rem This is normally unused -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/graphql/spring-boot-graphql-querydsl/settings.gradle.kts b/graphql/spring-boot-graphql-querydsl/settings.gradle.kts deleted file mode 100644 index 89607971d..000000000 --- a/graphql/spring-boot-graphql-querydsl/settings.gradle.kts +++ /dev/null @@ -1,9 +0,0 @@ -pluginManagement { - repositories { - maven { url = uri("https://repo.spring.io/milestone") } - gradlePluginPortal() - } -} - - -rootProject.name = "spring-boot-graphql-querydsl" \ No newline at end of file diff --git a/graphql/spring-boot-graphql-querydsl/sonar-project.properties b/graphql/spring-boot-graphql-querydsl/sonar-project.properties deleted file mode 100644 index 1da3ff4a9..000000000 --- a/graphql/spring-boot-graphql-querydsl/sonar-project.properties +++ /dev/null @@ -1,15 +0,0 @@ -sonar.sourceEncoding=UTF-8 -sonar.projectKey=rajadileepkolli_spring-experiments-spring-graphql-querydsl -sonar.organization=rajadileepkolli -sonar.host.url=https://sonarcloud.io - -sonar.sources=src/main/java -sonar.tests=src/test/java -sonar.exclusions=src/main/java/**/config/*.*,src/main/java/**/entities/*.*,src/main/java/**/dtos/*.*,src/main/java/**/models/*.*,src/main/java/**/exceptions/*.*,src/main/java/**/utils/*.*,src/main/java/**/*Application.* -sonar.test.inclusions=**/*Test.java,**/*IntegrationTest.java,**/*IT.java -sonar.java.codeCoveragePlugin=jacoco -sonar.coverage.jacoco.xmlReportPaths=build/reports/jacoco/test/jacocoTestReport.xml -sonar.junit.reportPaths=build/test-results/test,build/test-results/integrationTest -sonar.java.checkstyle.reportPaths=build/reports/checkstyle/main.xml -sonar.java.pmd.reportPaths=build/reports/pmd/main.xml -sonar.java.spotbugs.reportPaths=build/reports/spotbugs/main.html diff --git a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/GraphQueryDSLApplication.java b/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/GraphQueryDSLApplication.java deleted file mode 100644 index f85ec323e..000000000 --- a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/GraphQueryDSLApplication.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.example.graphql.querydsl; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class GraphQueryDSLApplication { - - public static void main(String[] args) { - SpringApplication.run(GraphQueryDSLApplication.class, args); - } -} diff --git a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/config/DatasourceProxyBeanPostProcessor.java b/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/config/DatasourceProxyBeanPostProcessor.java deleted file mode 100644 index 9cb2ddfe1..000000000 --- a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/config/DatasourceProxyBeanPostProcessor.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.example.graphql.querydsl.config; - -import java.lang.reflect.Method; -import javax.sql.DataSource; -import net.ttddyy.dsproxy.listener.logging.SLF4JLogLevel; -import net.ttddyy.dsproxy.support.ProxyDataSource; -import net.ttddyy.dsproxy.support.ProxyDataSourceBuilder; -import org.aopalliance.intercept.MethodInterceptor; -import org.aopalliance.intercept.MethodInvocation; -import org.springframework.aop.framework.ProxyFactory; -import org.springframework.beans.factory.config.BeanPostProcessor; -import org.springframework.stereotype.Component; -import org.springframework.util.ReflectionUtils; - -@Component -public class DatasourceProxyBeanPostProcessor implements BeanPostProcessor { - - @Override - public Object postProcessAfterInitialization(Object bean, String beanName) { - if (bean instanceof DataSource dataSource && !(bean instanceof ProxyDataSource)) { - final ProxyFactory factory = new ProxyFactory(bean); - factory.setProxyTargetClass(true); - factory.addAdvice(new ProxyDataSourceInterceptor(dataSource)); - return factory.getProxy(); - } - return bean; - } - - @Override - public Object postProcessBeforeInitialization(Object bean, String beanName) { - return bean; - } - - private record ProxyDataSourceInterceptor(DataSource dataSource) implements MethodInterceptor { - private ProxyDataSourceInterceptor(final DataSource dataSource) { - this.dataSource = ProxyDataSourceBuilder.create(dataSource) - .name("MyDS") - .multiline() - .logQueryBySlf4j(SLF4JLogLevel.INFO) - .build(); - } - - @Override - public Object invoke(final MethodInvocation invocation) throws Throwable { - final Method proxyMethod = ReflectionUtils.findMethod( - this.dataSource.getClass(), invocation.getMethod().getName()); - if (proxyMethod != null) { - return proxyMethod.invoke(this.dataSource, invocation.getArguments()); - } - return invocation.proceed(); - } - } -} diff --git a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/controller/PostController.java b/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/controller/PostController.java deleted file mode 100644 index d7f91c6a9..000000000 --- a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/controller/PostController.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.example.graphql.querydsl.controller; - -import com.example.graphql.querydsl.model.request.AddTagRequestDTO; -import com.example.graphql.querydsl.model.request.PostRequestDTO; -import com.example.graphql.querydsl.model.response.PostResponse; -import com.example.graphql.querydsl.service.PostService; -import java.util.List; -import lombok.RequiredArgsConstructor; -import org.springframework.graphql.data.method.annotation.Argument; -import org.springframework.graphql.data.method.annotation.MutationMapping; -import org.springframework.graphql.data.method.annotation.QueryMapping; -import org.springframework.stereotype.Controller; - -@Controller -@RequiredArgsConstructor -public class PostController { - - private final PostService postService; - - @QueryMapping - public Long countPosts() { - return this.postService.totalPosts(); - } - - @MutationMapping - public PostResponse createPost(@Argument("postRequestDTO") PostRequestDTO postRequestDTO) { - return this.postService.createPost(postRequestDTO); - } - - @MutationMapping - public PostResponse addTagsToPost(@Argument("addTagRequest") AddTagRequestDTO addTagRequest) { - return this.postService.addTagsToPost(addTagRequest); - } - - @QueryMapping - public List getPostsByUserName(@Argument String name) { - return this.postService.getPostsByUserName(name); - } -} diff --git a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/entities/Post.java b/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/entities/Post.java deleted file mode 100644 index ac3370302..000000000 --- a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/entities/Post.java +++ /dev/null @@ -1,118 +0,0 @@ -package com.example.graphql.querydsl.entities; - -import jakarta.persistence.*; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Objects; -import lombok.Getter; -import lombok.Setter; -import org.hibernate.annotations.GenericGenerator; - -@Entity(name = "Post") -@Table(name = "post") -@Getter -@Setter -public class Post { - - @Id - @GenericGenerator( - name = "sequenceGenerator", - strategy = "enhanced-sequence", - parameters = { - @org.hibernate.annotations.Parameter(name = "optimizer", value = "pooled-lo"), - @org.hibernate.annotations.Parameter(name = "initial_value", value = "1"), - @org.hibernate.annotations.Parameter(name = "increment_size", value = "5") - }) - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") - private Long id; - - private String title; - - @Column(length = 4096) - private String content; - - private LocalDateTime createdOn; - - @OneToMany(cascade = CascadeType.ALL, mappedBy = "post", orphanRemoval = true) - private List comments = new ArrayList<>(); - - @JoinColumn(name = "details_ID") - @OneToOne(cascade = CascadeType.ALL, mappedBy = "post", orphanRemoval = true, fetch = FetchType.LAZY) - private PostDetails details; - - @OneToMany(mappedBy = "post", cascade = CascadeType.ALL, orphanRemoval = true) - private List tags = new ArrayList<>(); - - public Post() { - this.createdOn = LocalDateTime.now(); - } - - public Post(Long id) { - this.id = id; - this.createdOn = LocalDateTime.now(); - } - - public Post(String title) { - this.title = title; - this.createdOn = LocalDateTime.now(); - } - - public void addComment(PostComment comment) { - this.comments.add(comment); - comment.setPost(this); - } - - public void removeComment(PostComment comment) { - this.comments.remove(comment); - comment.setPost(null); - } - - public void addDetails(PostDetails details) { - this.details = details; - details.setPost(this); - } - - public void removeDetails() { - this.details.setPost(null); - this.details = null; - } - - public void addTag(Tag tag) { - PostTag postTag = new PostTag(this, tag); - this.tags.add(postTag); - } - - public void removeTag(Tag tag) { - for (Iterator iterator = this.tags.iterator(); iterator.hasNext(); ) { - PostTag postTag = iterator.next(); - - if (postTag.getPost().equals(this) && postTag.getTag().equals(tag)) { - iterator.remove(); - postTag.setPost(null); - postTag.setTag(null); - } - } - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Post other = (Post) obj; - return Objects.equals(this.details, other.details) && Objects.equals(this.title, other.title); - } - - @Override - public int hashCode() { - return Objects.hash(this.details, this.title); - } -} diff --git a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/entities/PostComment.java b/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/entities/PostComment.java deleted file mode 100644 index 04ce8934e..000000000 --- a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/entities/PostComment.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.example.graphql.querydsl.entities; - -import jakarta.persistence.*; -import java.time.LocalDateTime; -import lombok.Getter; -import lombok.Setter; -import org.hibernate.annotations.GenericGenerator; - -@Entity(name = "PostComment") -@Table(name = "post_comment") -@Getter -@Setter -public class PostComment { - - @Id - @GenericGenerator( - name = "sequenceGenerator", - strategy = "enhanced-sequence", - parameters = { - @org.hibernate.annotations.Parameter(name = "optimizer", value = "pooled-lo"), - @org.hibernate.annotations.Parameter(name = "initial_value", value = "1"), - @org.hibernate.annotations.Parameter(name = "increment_size", value = "5") - }) - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") - private Long id; - - private String review; - - private LocalDateTime createdOn; - - @ManyToOne(fetch = FetchType.LAZY) - private Post post; - - public PostComment() { - this.createdOn = LocalDateTime.now(); - } - - public PostComment(String review) { - this.review = review; - this.createdOn = LocalDateTime.now(); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - return this.review != null && this.review.equals(((PostComment) o).getReview()); - } - - @Override - public int hashCode() { - return getClass().hashCode(); - } -} diff --git a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/entities/PostDetails.java b/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/entities/PostDetails.java deleted file mode 100644 index bf95a1c1e..000000000 --- a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/entities/PostDetails.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.example.graphql.querydsl.entities; - -import jakarta.persistence.*; -import java.time.LocalDateTime; -import java.util.Objects; -import lombok.Getter; -import lombok.Setter; -import org.hibernate.annotations.GenericGenerator; - -@Entity(name = "PostDetails") -@Table(name = "post_details") -@Getter -@Setter -public class PostDetails { - - @Id - @GenericGenerator( - name = "sequenceGenerator", - strategy = "enhanced-sequence", - parameters = { - @org.hibernate.annotations.Parameter(name = "optimizer", value = "pooled-lo"), - @org.hibernate.annotations.Parameter(name = "initial_value", value = "1"), - @org.hibernate.annotations.Parameter(name = "increment_size", value = "5") - }) - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") - private Long id; - - @Column(name = "created_on") - private LocalDateTime createdOn; - - @Column(name = "created_by") - private String createdBy; - - @OneToOne(fetch = FetchType.LAZY) - @MapsId - private Post post; - - public PostDetails() { - this.createdOn = LocalDateTime.now(); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - PostDetails other = (PostDetails) obj; - return Objects.equals(this.createdBy, other.createdBy); - } - - @Override - public int hashCode() { - return Objects.hash(this.createdBy); - } -} diff --git a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/entities/PostTag.java b/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/entities/PostTag.java deleted file mode 100644 index a08f956db..000000000 --- a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/entities/PostTag.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.example.graphql.querydsl.entities; - -import jakarta.persistence.*; -import java.time.LocalDateTime; -import java.util.Objects; -import lombok.Getter; -import lombok.Setter; - -@Entity(name = "PostTag") -@Table(name = "post_tag") -@Setter -@Getter -public class PostTag { - - @EmbeddedId - private PostTagId id; - - @ManyToOne(fetch = FetchType.LAZY) - @MapsId("postId") - private Post post; - - @ManyToOne(fetch = FetchType.LAZY) - @MapsId("tagId") - private Tag tag; - - @Column(name = "created_on") - private LocalDateTime createdOn = LocalDateTime.now(); - - public PostTag() { - this.createdOn = LocalDateTime.now(); - } - - public PostTag(Post post, Tag tag) { - this.post = post; - this.tag = tag; - this.id = new PostTagId(post.getId(), tag.getId()); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (o == null || getClass() != o.getClass()) { - return false; - } - PostTag that = (PostTag) o; - return Objects.equals(this.post, that.post) && Objects.equals(this.tag, that.tag); - } - - @Override - public int hashCode() { - return Objects.hash(this.post, this.tag); - } -} diff --git a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/entities/PostTagId.java b/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/entities/PostTagId.java deleted file mode 100644 index daea86ef0..000000000 --- a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/entities/PostTagId.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.example.graphql.querydsl.entities; - -import jakarta.persistence.Column; -import jakarta.persistence.Embeddable; -import java.io.Serial; -import java.io.Serializable; -import java.util.Objects; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Embeddable -@Getter -@NoArgsConstructor -@AllArgsConstructor -public class PostTagId implements Serializable { - - @Serial - private static final long serialVersionUID = 1L; - - @Column(name = "post_id") - private Long postId; - - @Column(name = "tag_id") - private Long tagId; - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (o == null || getClass() != o.getClass()) { - return false; - } - - PostTagId that = (PostTagId) o; - return Objects.equals(this.postId, that.postId) && Objects.equals(this.tagId, that.tagId); - } - - @Override - public int hashCode() { - return Objects.hash(this.postId, this.tagId); - } -} diff --git a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/entities/Tag.java b/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/entities/Tag.java deleted file mode 100644 index 190da2e77..000000000 --- a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/entities/Tag.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.example.graphql.querydsl.entities; - -import jakarta.persistence.*; -import java.util.Objects; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.hibernate.annotations.GenericGenerator; - -@Entity(name = "Tag") -@Table(name = "tag") -@Getter -@Setter -@NoArgsConstructor // Only to be compliant with JPA -public class Tag { - - @Id - @GenericGenerator( - name = "sequenceGenerator", - strategy = "enhanced-sequence", - parameters = { - @org.hibernate.annotations.Parameter(name = "optimizer", value = "pooled-lo"), - @org.hibernate.annotations.Parameter(name = "initial_value", value = "1"), - @org.hibernate.annotations.Parameter(name = "increment_size", value = "5") - }) - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") - private Long id; - - @Column(nullable = false, unique = true) - private String name; - - public Tag(String name) { - this.name = name; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null || getClass() != obj.getClass()) { - return false; - } - Tag other = (Tag) obj; - return Objects.equals(this.name, other.name); - } - - @Override - public int hashCode() { - return Objects.hash(this.name); - } -} diff --git a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/exception/PostNotFoundException.java b/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/exception/PostNotFoundException.java deleted file mode 100644 index 1f27a24a7..000000000 --- a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/exception/PostNotFoundException.java +++ /dev/null @@ -1,3 +0,0 @@ -package com.example.graphql.querydsl.exception; - -public class PostNotFoundException extends RuntimeException {} diff --git a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/model/PostCommentsDTO.java b/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/model/PostCommentsDTO.java deleted file mode 100644 index 2c9bffeb5..000000000 --- a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/model/PostCommentsDTO.java +++ /dev/null @@ -1,3 +0,0 @@ -package com.example.graphql.querydsl.model; - -public record PostCommentsDTO(String review) {} diff --git a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/model/TagDTO.java b/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/model/TagDTO.java deleted file mode 100644 index b3029d21e..000000000 --- a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/model/TagDTO.java +++ /dev/null @@ -1,3 +0,0 @@ -package com.example.graphql.querydsl.model; - -public record TagDTO(String name) {} diff --git a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/model/request/AddTagRequestDTO.java b/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/model/request/AddTagRequestDTO.java deleted file mode 100644 index d7cc2d979..000000000 --- a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/model/request/AddTagRequestDTO.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.example.graphql.querydsl.model.request; - -import com.example.graphql.querydsl.model.TagDTO; -import java.util.List; - -public record AddTagRequestDTO(List tagNames, Long postId) {} diff --git a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/model/request/PostRequestDTO.java b/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/model/request/PostRequestDTO.java deleted file mode 100644 index c92d2094f..000000000 --- a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/model/request/PostRequestDTO.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.example.graphql.querydsl.model.request; - -import com.example.graphql.querydsl.model.PostCommentsDTO; -import com.example.graphql.querydsl.model.TagDTO; -import jakarta.validation.constraints.NotBlank; -import java.util.List; - -public record PostRequestDTO( - @NotBlank String name, - @NotBlank String title, - @NotBlank String content, - List comments, - List tags) {} diff --git a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/model/response/PostResponse.java b/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/model/response/PostResponse.java deleted file mode 100644 index f9c3fef25..000000000 --- a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/model/response/PostResponse.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.example.graphql.querydsl.model.response; - -import com.example.graphql.querydsl.model.PostCommentsDTO; -import com.example.graphql.querydsl.model.TagDTO; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.time.LocalDateTime; -import java.util.List; - -public record PostResponse( - Long postId, - String title, - String content, - String createdBy, - LocalDateTime createdOn, - @JsonProperty("comments") List comments, - @JsonProperty("tags") List tags) {} diff --git a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/repository/PostDetailsRepository.java b/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/repository/PostDetailsRepository.java deleted file mode 100644 index afb94b0f5..000000000 --- a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/repository/PostDetailsRepository.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.example.graphql.querydsl.repository; - -import com.example.graphql.querydsl.entities.PostDetails; -import org.springframework.data.querydsl.QuerydslPredicateExecutor; -import org.springframework.data.repository.CrudRepository; -import org.springframework.graphql.data.GraphQlRepository; - -@GraphQlRepository -public interface PostDetailsRepository - extends CrudRepository, QuerydslPredicateExecutor { - long countByPost_Details_CreatedByIgnoreCase(String createdBy); -} diff --git a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/repository/PostRepository.java b/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/repository/PostRepository.java deleted file mode 100644 index f49d5574d..000000000 --- a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/repository/PostRepository.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.example.graphql.querydsl.repository; - -import com.example.graphql.querydsl.entities.Post; -import java.util.List; -import org.springframework.data.jpa.repository.EntityGraph; -import org.springframework.data.querydsl.QuerydslPredicateExecutor; -import org.springframework.data.repository.CrudRepository; -import org.springframework.graphql.data.GraphQlRepository; -import org.springframework.lang.NonNull; - -@GraphQlRepository -public interface PostRepository extends CrudRepository, QuerydslPredicateExecutor { - @EntityGraph(attributePaths = {"details", "comments"}) - List findByDetails_CreatedByEqualsIgnoreCase(@NonNull String createdBy); - - @EntityGraph(attributePaths = {"tags.tag"}) - @Override - List findAllById(Iterable longs); -} diff --git a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/repository/TagRepository.java b/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/repository/TagRepository.java deleted file mode 100644 index 57b70474a..000000000 --- a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/repository/TagRepository.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.example.graphql.querydsl.repository; - -import com.example.graphql.querydsl.entities.Tag; -import org.springframework.data.querydsl.QuerydslPredicateExecutor; -import org.springframework.data.repository.CrudRepository; -import org.springframework.graphql.data.GraphQlRepository; - -@GraphQlRepository -public interface TagRepository extends CrudRepository, QuerydslPredicateExecutor {} diff --git a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/service/PostService.java b/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/service/PostService.java deleted file mode 100644 index 6636c19c4..000000000 --- a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/service/PostService.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.example.graphql.querydsl.service; - -import com.example.graphql.querydsl.model.request.AddTagRequestDTO; -import com.example.graphql.querydsl.model.request.PostRequestDTO; -import com.example.graphql.querydsl.model.response.PostResponse; -import java.util.List; - -public interface PostService { - PostResponse createPost(PostRequestDTO postRequestDTO); - - PostResponse addTagsToPost(AddTagRequestDTO addTagRequestDTO); - - Long totalPosts(); - - List getPostsByUserName(String name); -} diff --git a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/service/PostServiceImpl.java b/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/service/PostServiceImpl.java deleted file mode 100644 index 7dd6f7c67..000000000 --- a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/service/PostServiceImpl.java +++ /dev/null @@ -1,132 +0,0 @@ -package com.example.graphql.querydsl.service; - -import com.example.graphql.querydsl.entities.Post; -import com.example.graphql.querydsl.entities.PostComment; -import com.example.graphql.querydsl.entities.PostDetails; -import com.example.graphql.querydsl.entities.PostTag; -import com.example.graphql.querydsl.entities.QTag; -import com.example.graphql.querydsl.entities.Tag; -import com.example.graphql.querydsl.exception.PostNotFoundException; -import com.example.graphql.querydsl.model.PostCommentsDTO; -import com.example.graphql.querydsl.model.TagDTO; -import com.example.graphql.querydsl.model.request.AddTagRequestDTO; -import com.example.graphql.querydsl.model.request.PostRequestDTO; -import com.example.graphql.querydsl.model.response.PostResponse; -import com.example.graphql.querydsl.repository.PostRepository; -import com.example.graphql.querydsl.repository.TagRepository; -import com.querydsl.core.types.Predicate; -import java.util.List; -import java.util.Optional; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.CollectionUtils; - -@Service -@RequiredArgsConstructor -public class PostServiceImpl implements PostService { - - private final PostRepository postRepository; - private final TagRepository tagRepository; - - @Transactional - @Override - public PostResponse createPost(PostRequestDTO postRequestDTO) { - Post post = postRequestDTOToPostIgnoringChild(postRequestDTO); - post.addDetails(postRequestDTOToPostDetails(postRequestDTO)); - addPostCommentsToPost(postRequestDTO.comments(), post); - addPostTagsToPost(postRequestDTO.tags(), post); - return convertToPostDTO(postRepository.save(post)); - } - - @Override - @Transactional - public PostResponse addTagsToPost(AddTagRequestDTO addTagRequestDTO) { - Post post = this.postRepository.findById(addTagRequestDTO.postId()).orElseThrow(PostNotFoundException::new); - addPostTagsToPost(addTagRequestDTO.tagNames(), post); - return convertToPostDTO(postRepository.save(post)); - } - - @Override - public Long totalPosts() { - return this.postRepository.count(); - } - - @Override - @Transactional - public List getPostsByUserName(String name) { - List post = this.postRepository.findByDetails_CreatedByEqualsIgnoreCase(name); - return this.postRepository.findAllById(post.stream().map(Post::getId).toList()).stream() - .map(this::convertToPostDTO) - .toList(); - } - - private PostResponse convertToPostDTO(Post post) { - return new PostResponse( - post.getId(), - post.getTitle(), - post.getContent(), - post.getDetails().getCreatedBy(), - post.getDetails().getCreatedOn(), - getCommentsList(post.getComments()), - getTagsList(post.getTags())); - } - - private List getTagsList(List tags) { - return tags.stream() - .map(postTag -> new TagDTO(postTag.getTag().getName())) - .toList(); - } - - private List getCommentsList(List comments) { - return comments.stream() - .map(postComment -> new PostCommentsDTO(postComment.getReview())) - .toList(); - } - - private void addPostTagsToPost(List tags, Post post) { - if (!CollectionUtils.isEmpty(tags)) { - tags.forEach(tagDTO -> { - Predicate predicate = QTag.tag.name.eq(tagDTO.name()); - Optional tag = this.tagRepository.findOne(predicate); - if (tag.isPresent()) { - PostTag postTag = new PostTag(post, tag.get()); - post.getTags().add(postTag); - } else { - post.addTag(tagRequestDTOToTag(tagDTO)); - } - }); - } - } - - private Tag tagRequestDTOToTag(TagDTO tagDTO) { - Tag tag = new Tag(); - tag.setName(tagDTO.name()); - return this.tagRepository.save(tag); - } - - private void addPostCommentsToPost(List comments, Post post) { - if (!CollectionUtils.isEmpty(comments)) { - comments.forEach(postCommentsDTO -> post.addComment(postRequestDTOToPostComment(postCommentsDTO))); - } - } - - private PostComment postRequestDTOToPostComment(PostCommentsDTO postCommentsDTO) { - PostComment postComment = new PostComment(); - postComment.setReview(postCommentsDTO.review()); - return postComment; - } - - private PostDetails postRequestDTOToPostDetails(PostRequestDTO postRequestDTO) { - PostDetails postDetails = new PostDetails(); - postDetails.setCreatedBy(postRequestDTO.name()); - return postDetails; - } - - private Post postRequestDTOToPostIgnoringChild(PostRequestDTO postRequestDTO) { - Post post = new Post(); - post.setTitle(postRequestDTO.title()); - post.setContent(postRequestDTO.content()); - return post; - } -} diff --git a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/utils/AppConstants.java b/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/utils/AppConstants.java deleted file mode 100644 index 800cb9cd1..000000000 --- a/graphql/spring-boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/utils/AppConstants.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.example.graphql.querydsl.utils; - -public final class AppConstants { - - public static final String PROFILE_TEST = "test"; - public static final String PROFILE_IT = "integration-test"; -} diff --git a/graphql/spring-boot-graphql-querydsl/src/main/resources/application.properties b/graphql/spring-boot-graphql-querydsl/src/main/resources/application.properties deleted file mode 100644 index 85ea8863d..000000000 --- a/graphql/spring-boot-graphql-querydsl/src/main/resources/application.properties +++ /dev/null @@ -1,34 +0,0 @@ -spring.jmx.enabled=false -################ Logging ##################### -logging.level.web=INFO -logging.level.sql=INFO -## To enable transaction details logging -#logging.level.org.springframework.orm.jpa=DEBUG -#logging.level.org.springframework.transaction=DEBUG -#logging.level.org.hibernate.engine.transaction.internal.TransactionImpl=DEBUG -################ Actuator ##################### -management.endpoints.web.exposure.include=configprops,env,health,info,logfile,loggers,metrics,refresh -management.endpoint.health.show-details=always -################ Database ##################### -spring.datasource.url=jdbc:postgresql://localhost:5432/rest?maxIdleTime=PT60S -spring.datasource.username=local -spring.datasource.password=local -spring.jpa.open-in-view=false -spring.data.jpa.repositories.bootstrap-mode=deferred -spring.datasource.hikari.auto-commit=false -spring.jpa.hibernate.ddl-auto=validate -#spring.jpa.properties.hibernate.format_sql=true -spring.jpa.properties.hibernate.jdbc.time_zone=UTC -spring.jpa.properties.hibernate.id.new_generator_mappings=true -spring.jpa.properties.hibernate.id.optimizer.pooled.preferred=pooled-lo -spring.jpa.properties.hibernate.generate_statistics=false -spring.jpa.properties.hibernate.jdbc.batch_size=25 -spring.jpa.properties.hibernate.order_inserts=true -spring.jpa.properties.hibernate.order_updates=true -spring.jpa.properties.hibernate.query.fail_on_pagination_over_collection_fetch=true -spring.jpa.properties.hibernate.query.in_clause_parameter_padding=true -spring.jpa.properties.hibernate.connection.provider_disables_autocommit=true -spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true - -#Enable GraphQL -spring.graphql.graphiql.enabled=true \ No newline at end of file diff --git a/graphql/spring-boot-graphql-querydsl/src/main/resources/db/changelog/create-tables.xml b/graphql/spring-boot-graphql-querydsl/src/main/resources/db/changelog/create-tables.xml deleted file mode 100644 index 57a10a5dd..000000000 --- a/graphql/spring-boot-graphql-querydsl/src/main/resources/db/changelog/create-tables.xml +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/graphql/spring-boot-graphql-querydsl/src/main/resources/db/changelog/db.changelog-master.yaml b/graphql/spring-boot-graphql-querydsl/src/main/resources/db/changelog/db.changelog-master.yaml deleted file mode 100644 index e6e8d5bc0..000000000 --- a/graphql/spring-boot-graphql-querydsl/src/main/resources/db/changelog/db.changelog-master.yaml +++ /dev/null @@ -1,3 +0,0 @@ -databaseChangeLog: - - include: - file: db/changelog/create-tables.xml \ No newline at end of file diff --git a/graphql/spring-boot-graphql-querydsl/src/main/resources/graphql/schema.graphqls b/graphql/spring-boot-graphql-querydsl/src/main/resources/graphql/schema.graphqls deleted file mode 100644 index 03bf60168..000000000 --- a/graphql/spring-boot-graphql-querydsl/src/main/resources/graphql/schema.graphqls +++ /dev/null @@ -1,48 +0,0 @@ -type Query { - getPostsByUserName(name : String) : [PostsDTO!] - countPosts: Int! -} - -type Mutation { - createPost(postRequestDTO : PostRequestDTO ) : PostsDTO - addTagsToPost(addTagRequest: AddTagRequestDTO) : PostsDTO -} - -input AddTagRequestDTO { - tagNames: [TagRequestDTO]! - postId: ID -} - -input PostRequestDTO { - name: String! - title: String! - content: String! - comments: [PostCommentsRequestDTO] - tags: [TagRequestDTO] -} - -input TagRequestDTO { - name: String! -} - -input PostCommentsRequestDTO { - review: String -} - -type PostsDTO { - id: ID - title: String - content: String - createdBy: String - createdOn: String - comments: [PostCommentDTO] - tags: [TagDTO] -} - -type PostCommentDTO { - review: String -} - -type TagDTO { - name: String -} \ No newline at end of file diff --git a/graphql/spring-boot-graphql-querydsl/src/test/java/com/example/graphql/querydsl/GraphQueryDSLApplicationTests.java b/graphql/spring-boot-graphql-querydsl/src/test/java/com/example/graphql/querydsl/GraphQueryDSLApplicationTests.java deleted file mode 100644 index d850906ab..000000000 --- a/graphql/spring-boot-graphql-querydsl/src/test/java/com/example/graphql/querydsl/GraphQueryDSLApplicationTests.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.example.graphql.querydsl; - -import com.example.graphql.querydsl.common.AbstractIntegrationTest; -import com.example.graphql.querydsl.model.PostCommentsDTO; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.graphql.tester.AutoConfigureHttpGraphQlTester; -import org.springframework.graphql.test.tester.HttpGraphQlTester; - -@AutoConfigureHttpGraphQlTester -class GraphQueryDSLApplicationTests extends AbstractIntegrationTest { - - @Autowired - private HttpGraphQlTester graphQlTester; - - @Test - void test_query_insert() { - String query = - """ - mutation { - createPost(postRequestDTO: { - name: "unit", - title: "title1", - content: "content1", - comments: [ - { - review: "review1" - }, - { - review: "review2" - } - ], - tags: [ - { - name: "spring" - } - ] - }) { - title - content - createdBy - createdOn - comments { - review - } - } - } - """; - this.graphQlTester - .document(query) - .execute() - .path("createPost") - .hasValue() - .path("createPost.createdOn") - .hasValue() - .path("createPost.title") - .entity(String.class) - .isEqualTo("title1") - .path("createPost.comments") - .hasValue() - .entityList(PostCommentsDTO.class) - .contains(new PostCommentsDTO("review1"), new PostCommentsDTO("review2")); - } -} diff --git a/graphql/spring-boot-graphql-querydsl/src/test/java/com/example/graphql/querydsl/SerializationTest.java b/graphql/spring-boot-graphql-querydsl/src/test/java/com/example/graphql/querydsl/SerializationTest.java deleted file mode 100644 index f786a6c3d..000000000 --- a/graphql/spring-boot-graphql-querydsl/src/test/java/com/example/graphql/querydsl/SerializationTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.example.graphql.querydsl; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.example.graphql.querydsl.model.PostCommentsDTO; -import com.example.graphql.querydsl.model.TagDTO; -import com.example.graphql.querydsl.model.request.PostRequestDTO; -import java.io.IOException; -import java.util.List; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.json.JsonTest; -import org.springframework.boot.test.json.JacksonTester; -import org.springframework.boot.test.json.JsonContent; - -@JsonTest -class SerializationTest { - - @Autowired - private JacksonTester jacksonTester; - - @Test - void testJson() throws IOException { - List comments = List.of(new PostCommentsDTO("review1"), new PostCommentsDTO("review2")); - List tags = List.of(new TagDTO("java")); - PostRequestDTO postRequestDTO = new PostRequestDTO("junit", "title", "content", comments, tags); - JsonContent json = jacksonTester.write(postRequestDTO); - assertThat(json.getJson()) - .isEqualTo( - "{\"name\":\"junit\",\"title\":\"title\",\"content\":\"content\",\"comments\":[{\"review\":\"review1\"},{\"review\":\"review2\"}],\"tags\":[{\"name\":\"java\"}]}"); - } -} diff --git a/graphql/spring-boot-graphql-querydsl/src/test/java/com/example/graphql/querydsl/common/AbstractIntegrationTest.java b/graphql/spring-boot-graphql-querydsl/src/test/java/com/example/graphql/querydsl/common/AbstractIntegrationTest.java deleted file mode 100644 index 1af013162..000000000 --- a/graphql/spring-boot-graphql-querydsl/src/test/java/com/example/graphql/querydsl/common/AbstractIntegrationTest.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.example.graphql.querydsl.common; - -import static com.example.graphql.querydsl.utils.AppConstants.PROFILE_IT; -import static com.example.graphql.querydsl.utils.AppConstants.PROFILE_TEST; -import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; - -import com.fasterxml.jackson.databind.ObjectMapper; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.testcontainers.context.ImportTestcontainers; -import org.springframework.test.context.ActiveProfiles; - -@ActiveProfiles({PROFILE_TEST, PROFILE_IT}) -@SpringBootTest(webEnvironment = RANDOM_PORT) -@ImportTestcontainers(DBContainerInitializerBase.class) -public abstract class AbstractIntegrationTest { - - @Autowired - protected ObjectMapper objectMapper; -} diff --git a/graphql/spring-boot-graphql-querydsl/src/test/java/com/example/graphql/querydsl/common/DBContainerInitializerBase.java b/graphql/spring-boot-graphql-querydsl/src/test/java/com/example/graphql/querydsl/common/DBContainerInitializerBase.java deleted file mode 100644 index 78abf004e..000000000 --- a/graphql/spring-boot-graphql-querydsl/src/test/java/com/example/graphql/querydsl/common/DBContainerInitializerBase.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.example.graphql.querydsl.common; - -import org.springframework.boot.testcontainers.service.connection.ServiceConnection; -import org.testcontainers.containers.PostgreSQLContainer; -import org.testcontainers.junit.jupiter.Container; - -public interface DBContainerInitializerBase { - - @Container - @ServiceConnection - static final PostgreSQLContainer POSTGRE_SQL_CONTAINER = - new PostgreSQLContainer<>("postgres:15.3-alpine").withReuse(true); -}