diff --git a/algorithms-modules/algorithms-miscellaneous-7/src/main/java/com/baeldung/algorithms/pixelarray/GetPixelArray.java b/algorithms-modules/algorithms-miscellaneous-7/src/main/java/com/baeldung/algorithms/pixelarray/GetPixelArray.java new file mode 100644 index 0000000000..ba7fe44808 --- /dev/null +++ b/algorithms-modules/algorithms-miscellaneous-7/src/main/java/com/baeldung/algorithms/pixelarray/GetPixelArray.java @@ -0,0 +1,65 @@ +package com.baeldung.algorithms.pixelarray; + +import java.awt.image.BufferedImage; +import java.awt.image.DataBufferByte; +public class GetPixelArray { + + public static int[][] get2DPixelArraySlow(BufferedImage sampleImage) { + int width = sampleImage.getWidth(); + int height = sampleImage.getHeight(); + int[][] result = new int[height][width]; + + for (int row = 0; row < height; row++) { + for (int col = 0; col < width; col++) { + result[row][col] = sampleImage.getRGB(col, row); + } + } + + return result; + } + + public static int[][] get2DPixelArrayFast(BufferedImage image) { + final byte[] pixelData = ((DataBufferByte) image.getRaster().getDataBuffer()).getData(); + final int width = image.getWidth(); + final int height = image.getHeight(); + final boolean hasAlphaChannel = image.getAlphaRaster() != null; + + int[][] result = new int[height][width]; + if (hasAlphaChannel) { + final int numberOfValues = 4; + for (int valueIndex = 0, row = 0, col = 0; valueIndex + numberOfValues - 1 < pixelData.length; valueIndex += numberOfValues) { + // Getting the values for each pixel from the pixelData array. + int argb = 0; + argb += (((int) pixelData[valueIndex] & 0xff) << 24); // alpha value + argb += ((int) pixelData[valueIndex + 1] & 0xff); // blue value + argb += (((int) pixelData[valueIndex + 2] & 0xff) << 8); // green value + argb += (((int) pixelData[valueIndex + 3] & 0xff) << 16); // red value + result[row][col] = argb; + + col++; + if (col == width) { + col = 0; + row++; + } + } + } else { + final int numberOfValues = 3; + for (int valueIndex = 0, row = 0, col = 0; valueIndex + numberOfValues - 1 < pixelData.length; valueIndex += numberOfValues) { + int argb = 0; + argb += -16777216; // 255 alpha value (fully opaque) + argb += ((int) pixelData[valueIndex] & 0xff); // blue value + argb += (((int) pixelData[valueIndex + 1] & 0xff) << 8); // green value + argb += (((int) pixelData[valueIndex + 2] & 0xff) << 16); // red value + result[row][col] = argb; + + col++; + if (col == width) { + col = 0; + row++; + } + } + } + + return result; + } +} \ No newline at end of file diff --git a/algorithms-modules/algorithms-miscellaneous-7/src/test/java/com/baeldung/algorithms/pixelarray/GetPixelArrayUnitTest.java b/algorithms-modules/algorithms-miscellaneous-7/src/test/java/com/baeldung/algorithms/pixelarray/GetPixelArrayUnitTest.java new file mode 100644 index 0000000000..b7bbb462dd --- /dev/null +++ b/algorithms-modules/algorithms-miscellaneous-7/src/test/java/com/baeldung/algorithms/pixelarray/GetPixelArrayUnitTest.java @@ -0,0 +1,30 @@ +package com.baeldung.algorithms.pixelarray; + +import static com.baeldung.algorithms.pixelarray.GetPixelArray.get2DPixelArrayFast; +import static com.baeldung.algorithms.pixelarray.GetPixelArray.get2DPixelArraySlow; +import static org.junit.Assert.*; + +import org.junit.Test; + +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.util.Arrays; + +public class GetPixelArrayUnitTest { + @Test + public void givenImage_whenGetPixelArray_thenBothMethodsReturnEqualValues() { + BufferedImage sampleImage = null; + try { + sampleImage = ImageIO.read(new File("src/main/resources/images/sampleImage.jpg")); + } catch (IOException e) { + throw new RuntimeException(e); + } + + int[][] firstResult = get2DPixelArraySlow(sampleImage); + int[][] secondResult = get2DPixelArrayFast(sampleImage); + + assertTrue(Arrays.deepEquals(firstResult, secondResult)); + } +} diff --git a/apache-httpclient-2/README.md b/apache-httpclient-2/README.md index 05bebfaacb..a19112476b 100644 --- a/apache-httpclient-2/README.md +++ b/apache-httpclient-2/README.md @@ -13,4 +13,5 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [How To Get Cookies From the Apache HttpClient Response](https://www.baeldung.com/java-apache-httpclient-cookies) - [Enabling Logging for Apache HttpClient](https://www.baeldung.com/apache-httpclient-enable-logging) - [Apache HttpClient vs. CloseableHttpClient](https://www.baeldung.com/apache-httpclient-vs-closeablehttpclient) +- [Expand Shortened URLs with Apache HttpClient](https://www.baeldung.com/apache-httpclient-expand-url) - More articles: [[<-- prev]](../apache-httpclient) diff --git a/apache-httpclient-2/src/test/java/com/baeldung/httpclient/expandUrl/HttpClientExpandUrlLiveTest.java b/apache-httpclient-2/src/test/java/com/baeldung/httpclient/expandUrl/HttpClientExpandUrlLiveTest.java new file mode 100644 index 0000000000..c1bb5bdddb --- /dev/null +++ b/apache-httpclient-2/src/test/java/com/baeldung/httpclient/expandUrl/HttpClientExpandUrlLiveTest.java @@ -0,0 +1,126 @@ +package com.baeldung.httpclient.expandUrl; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; + +import java.io.IOException; +import java.util.List; + +import com.google.common.base.Preconditions; +import com.google.common.collect.Lists; + +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.apache.commons.lang3.tuple.Pair; + +import org.apache.hc.client5.http.classic.methods.HttpHead; +import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; + +import org.apache.hc.client5.http.impl.classic.HttpClientBuilder; +import org.apache.hc.core5.http.Header; +import org.apache.hc.core5.http.HttpHeaders; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +class HttpClientExpandUrlLiveTest { + + private static CloseableHttpClient httpClient; + + @BeforeAll + static void setup() { + httpClient = HttpClientBuilder.create() + .disableRedirectHandling() + .build(); + } + + @AfterAll + static void tearDown() throws IOException { + if (httpClient != null) { + httpClient.close(); + } + } + + @Test + void givenShortenedOnce_whenUrlIsExpanded_thenCorrectResult() throws IOException { + final String expectedResult = "https://www.baeldung.com/rest-versioning"; + final String actualResult = expandSingleLevel("http://bit.ly/3LScTri"); + assertThat(actualResult, equalTo(expectedResult)); + } + + @Test + void givenShortenedMultiple_whenUrlIsExpanded_thenCorrectResult() throws IOException { + final String expectedResult = "https://www.baeldung.com/rest-versioning"; + final String actualResult = expand("http://t.co/e4rDDbnzmk"); + assertThat(actualResult, equalTo(expectedResult)); + } + + private String expand(final String urlArg) throws IOException { + String originalUrl = urlArg; + String newUrl = expandSingleLevel(originalUrl); + while (!originalUrl.equals(newUrl)) { + originalUrl = newUrl; + newUrl = expandSingleLevel(originalUrl); + } + + return newUrl; + } + + final String expandSafe(final String urlArg) throws IOException { + String originalUrl = urlArg; + String newUrl = expandSingleLevelSafe(originalUrl).getRight(); + final List alreadyVisited = Lists.newArrayList(originalUrl, newUrl); + while (!originalUrl.equals(newUrl)) { + originalUrl = newUrl; + final Pair statusAndUrl = expandSingleLevelSafe(originalUrl); + newUrl = statusAndUrl.getRight(); + final boolean isRedirect = statusAndUrl.getLeft() == 301 || statusAndUrl.getLeft() == 302; + if (isRedirect && alreadyVisited.contains(newUrl)) { + throw new IllegalStateException("Likely a redirect loop"); + } + alreadyVisited.add(newUrl); + } + + return newUrl; + } + + private Pair expandSingleLevelSafe(final String url) throws IOException { + try { + HttpHead request = new HttpHead(url); + Pair resp = httpClient.execute(request, response -> { + final int statusCode = response.getCode(); + if (statusCode != 301 && statusCode != 302) { + return new ImmutablePair<>(statusCode, url); + } + final Header[] headers = response.getHeaders(HttpHeaders.LOCATION); + Preconditions.checkState(headers.length == 1); + final String newUrl = headers[0].getValue(); + + return new ImmutablePair<>(statusCode, newUrl); + }); + return resp; + } catch (final IllegalArgumentException uriEx) { + return new ImmutablePair<>(500, url); + } + } + + private String expandSingleLevel(final String url) throws IOException { + try { + HttpHead request = new HttpHead(url); + String expandedUrl = httpClient.execute(request, response -> { + final int statusCode = response.getCode(); + if (statusCode != 301 && statusCode != 302) { + return url; + } + final Header[] headers = response.getHeaders(HttpHeaders.LOCATION); + Preconditions.checkState(headers.length == 1); + + return headers[0].getValue(); + }); + return expandedUrl; + } catch (final IllegalArgumentException uriEx) { + return url; + } + } + +} diff --git a/aws-modules/aws-lambda-modules/lambda-function/pom.xml b/aws-modules/aws-lambda-modules/lambda-function/pom.xml index a82209b23f..9fff7d1d9a 100644 --- a/aws-modules/aws-lambda-modules/lambda-function/pom.xml +++ b/aws-modules/aws-lambda-modules/lambda-function/pom.xml @@ -3,9 +3,9 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - lambda + lambda-function 0.1.0-SNAPSHOT - lambda + lambda-function jar diff --git a/aws-modules/aws-s3/README.md b/aws-modules/aws-s3/README.md index efebf7d933..109a898405 100644 --- a/aws-modules/aws-s3/README.md +++ b/aws-modules/aws-s3/README.md @@ -6,4 +6,5 @@ This module contains articles about Simple Storage Service (S3) on AWS - [AWS S3 with Java](https://www.baeldung.com/aws-s3-java) - [Multipart Uploads in Amazon S3 with Java](https://www.baeldung.com/aws-s3-multipart-upload) -- [Using the JetS3t Java Client With Amazon S3](https://www.baeldung.com/jets3t-amazon-s3) \ No newline at end of file +- [Using the JetS3t Java Client With Amazon S3](https://www.baeldung.com/jets3t-amazon-s3) +- [Check if a Specified Key Exists in a Given S3 Bucket Using Java](https://www.baeldung.com/java-aws-s3-check-specified-key-exists) diff --git a/core-java-modules/core-java-19/README.md b/core-java-modules/core-java-19/README.md index 6a9c6c7fdd..68244d9f91 100644 --- a/core-java-modules/core-java-19/README.md +++ b/core-java-modules/core-java-19/README.md @@ -1,3 +1,4 @@ ## Relevant Articles - [Record Patterns in Java 19](https://www.baeldung.com/java-19-record-patterns) - [Structured Concurrency in Java 19](https://www.baeldung.com/java-structured-concurrency) +- [Possible Root Causes for High CPU Usage in Java](https://www.baeldung.com/java-high-cpu-usage-causes) diff --git a/core-java-modules/core-java-20/README.md b/core-java-modules/core-java-20/README.md new file mode 100644 index 0000000000..7e20469e44 --- /dev/null +++ b/core-java-modules/core-java-20/README.md @@ -0,0 +1,2 @@ +## Relevant Articles +- TBD \ No newline at end of file diff --git a/core-java-modules/core-java-20/pom.xml b/core-java-modules/core-java-20/pom.xml new file mode 100644 index 0000000000..9562a41b1c --- /dev/null +++ b/core-java-modules/core-java-20/pom.xml @@ -0,0 +1,65 @@ + + + 4.0.0 + + com.baeldung.core-java-modules + core-java-modules + 0.0.1-SNAPSHOT + + + core-java-20 + + + 20 + 20 + UTF-8 + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 20 + 20 + + --enable-preview + --add-modules=jdk.incubator.concurrent + + + + + org.apache.maven.plugins + maven-surefire-plugin + + --enable-preview --add-modules=jdk.incubator.concurrent + + + + + + + + jakarta.servlet + jakarta.servlet-api + 6.0.0 + provided + + + org.assertj + assertj-core + 3.24.2 + test + + + org.mockito + mockito-junit-jupiter + 5.2.0 + test + + + + \ No newline at end of file diff --git a/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/classic/Controller.java b/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/classic/Controller.java new file mode 100644 index 0000000000..92edc57e48 --- /dev/null +++ b/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/classic/Controller.java @@ -0,0 +1,33 @@ +package com.baeldung.scopedvalues.classic; + +import com.baeldung.scopedvalues.data.Data; +import com.baeldung.scopedvalues.data.User; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Optional; + +public class Controller { + + private final Service service = new Service(); + + public void processRequest(HttpServletRequest request, HttpServletResponse response, User loggedInUser) { + Optional data = service.getData(request, loggedInUser); + if (data.isPresent()) { + try { + PrintWriter out = response.getWriter(); + response.setContentType("application/json"); + out.print(data.get()); + out.flush(); + response.setStatus(200); + } catch (IOException e) { + response.setStatus(500); + } + } else { + response.setStatus(400); + } + } + +} diff --git a/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/classic/Repository.java b/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/classic/Repository.java new file mode 100644 index 0000000000..3085b3be58 --- /dev/null +++ b/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/classic/Repository.java @@ -0,0 +1,16 @@ +package com.baeldung.scopedvalues.classic; + +import com.baeldung.scopedvalues.data.Data; +import com.baeldung.scopedvalues.data.User; + +import java.util.Optional; + +public class Repository { + + public Optional getData(String id, User user) { + return user.isAdmin() + ? Optional.of(new Data(id, "Title 1", "Description 1")) + : Optional.empty(); + } + +} diff --git a/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/classic/Server.java b/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/classic/Server.java new file mode 100644 index 0000000000..71afa9e675 --- /dev/null +++ b/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/classic/Server.java @@ -0,0 +1,42 @@ +package com.baeldung.scopedvalues.classic; + +import com.baeldung.scopedvalues.data.User; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +import java.util.List; +import java.util.Optional; +import java.util.concurrent.*; + +public class Server { + + private static final List AUTHENTICATED_USERS = List.of( + new User("1", "admin", "123456", true), + new User("2", "user", "123456", false) + ); + private final Controller controller = new Controller(); + private final ExecutorService executor = Executors.newFixedThreadPool(5); + + public void serve(HttpServletRequest request, HttpServletResponse response) throws InterruptedException, ExecutionException { + Optional user = authenticateUser(request); + if (user.isPresent()) { + Future future = executor.submit(() -> + controller.processRequest(request, response, user.get())); + future.get(); + } else { + response.setStatus(401); + } + } + + private Optional authenticateUser(HttpServletRequest request) { + return AUTHENTICATED_USERS.stream() + .filter(user -> checkUserPassword(user, request)) + .findFirst(); + } + + private boolean checkUserPassword(User user, HttpServletRequest request) { + return user.name().equals(request.getParameter("user_name")) + && user.password().equals(request.getParameter("user_pw")); + } + +} diff --git a/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/classic/Service.java b/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/classic/Service.java new file mode 100644 index 0000000000..011f793001 --- /dev/null +++ b/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/classic/Service.java @@ -0,0 +1,18 @@ +package com.baeldung.scopedvalues.classic; + +import com.baeldung.scopedvalues.data.Data; +import com.baeldung.scopedvalues.data.User; +import jakarta.servlet.http.HttpServletRequest; + +import java.util.Optional; + +public class Service { + + private final Repository repository = new Repository(); + + public Optional getData(HttpServletRequest request, User loggedInUser) { + String id = request.getParameter("data_id"); + return repository.getData(id, loggedInUser); + } + +} diff --git a/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/data/Data.java b/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/data/Data.java new file mode 100644 index 0000000000..70be41c1ac --- /dev/null +++ b/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/data/Data.java @@ -0,0 +1,3 @@ +package com.baeldung.scopedvalues.data; + +public record Data(String id, String title, String description) {} diff --git a/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/data/User.java b/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/data/User.java new file mode 100644 index 0000000000..22e0a4243f --- /dev/null +++ b/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/data/User.java @@ -0,0 +1,3 @@ +package com.baeldung.scopedvalues.data; + +public record User(String id, String name, String password, boolean isAdmin) {} diff --git a/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/scoped/Controller.java b/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/scoped/Controller.java new file mode 100644 index 0000000000..239ee88f19 --- /dev/null +++ b/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/scoped/Controller.java @@ -0,0 +1,37 @@ +package com.baeldung.scopedvalues.scoped; + +import com.baeldung.scopedvalues.data.Data; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import jdk.incubator.concurrent.ScopedValue; + +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Optional; + +public class Controller { + + private final Service internalService = new Service(); + + public void processRequest(HttpServletRequest request, HttpServletResponse response) { + Optional data = internalService.getData(request); + + ScopedValue.where(Server.LOGGED_IN_USER, null) + .run(internalService::extractData); + + if (data.isPresent()) { + try { + PrintWriter out = response.getWriter(); + response.setContentType("application/json"); + out.print(data.get()); + out.flush(); + response.setStatus(200); + } catch (IOException e) { + response.setStatus(500); + } + } else { + response.setStatus(400); + } + } + +} diff --git a/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/scoped/Repository.java b/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/scoped/Repository.java new file mode 100644 index 0000000000..a40191eb3c --- /dev/null +++ b/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/scoped/Repository.java @@ -0,0 +1,17 @@ +package com.baeldung.scopedvalues.scoped; + +import com.baeldung.scopedvalues.data.Data; +import com.baeldung.scopedvalues.data.User; + +import java.util.Optional; + +public class Repository { + + public Optional getData(String id) { + User loggedInUser = Server.LOGGED_IN_USER.get(); + return loggedInUser.isAdmin() + ? Optional.of(new Data(id, "Title 1", "Description 1")) + : Optional.empty(); + } + +} diff --git a/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/scoped/Server.java b/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/scoped/Server.java new file mode 100644 index 0000000000..559e4efd56 --- /dev/null +++ b/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/scoped/Server.java @@ -0,0 +1,41 @@ +package com.baeldung.scopedvalues.scoped; + +import com.baeldung.scopedvalues.data.User; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import jdk.incubator.concurrent.ScopedValue; + +import java.util.List; +import java.util.Optional; + +public class Server { + + private static final List AUTHENTICATED_USERS = List.of( + new User("1", "admin", "123456", true), + new User("2", "user", "123456", false) + ); + public final static ScopedValue LOGGED_IN_USER = ScopedValue.newInstance(); + private final Controller controller = new Controller(); + + public void serve(HttpServletRequest request, HttpServletResponse response) { + Optional user = authenticateUser(request); + if (user.isPresent()) { + ScopedValue.where(LOGGED_IN_USER, user.get()) + .run(() -> controller.processRequest(request, response)); + } else { + response.setStatus(401); + } + } + + private Optional authenticateUser(HttpServletRequest request) { + return AUTHENTICATED_USERS.stream() + .filter(user -> checkUserPassword(user, request)) + .findFirst(); + } + + private boolean checkUserPassword(User user, HttpServletRequest request) { + return user.name().equals(request.getParameter("user_name")) + && user.password().equals(request.getParameter("user_pw")); + } + +} diff --git a/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/scoped/Service.java b/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/scoped/Service.java new file mode 100644 index 0000000000..e35d98cae5 --- /dev/null +++ b/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/scoped/Service.java @@ -0,0 +1,23 @@ +package com.baeldung.scopedvalues.scoped; + +import com.baeldung.scopedvalues.data.Data; +import com.baeldung.scopedvalues.data.User; +import jakarta.servlet.http.HttpServletRequest; + +import java.util.Optional; + +public class Service { + + private final Repository repository = new Repository(); + + public Optional getData(HttpServletRequest request) { + String id = request.getParameter("data_id"); + return repository.getData(id); + } + + public void extractData() { + User loggedInUser = Server.LOGGED_IN_USER.get(); + assert loggedInUser == null; + } + +} diff --git a/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/scoped/inheriting/Controller.java b/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/scoped/inheriting/Controller.java new file mode 100644 index 0000000000..e4742c0998 --- /dev/null +++ b/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/scoped/inheriting/Controller.java @@ -0,0 +1,44 @@ +package com.baeldung.scopedvalues.scoped.inheriting; + +import com.baeldung.scopedvalues.data.Data; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import jdk.incubator.concurrent.StructuredTaskScope; + +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Optional; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; + +public class Controller { + + private final InternalService internalService = new InternalService(); + private final ExternalService externalService = new ExternalService(); + + public void processRequest(HttpServletRequest request, HttpServletResponse response) { + try (var scope = new StructuredTaskScope.ShutdownOnFailure()) { + Future> internalData = scope.fork(() -> internalService.getData(request)); + Future externalData = scope.fork(externalService::getData); + try { + scope.join(); + scope.throwIfFailed(); + + Optional data = internalData.resultNow(); + if (data.isPresent()) { + PrintWriter out = response.getWriter(); + response.setContentType("application/json"); + out.println(data.get()); + out.print(externalData.resultNow()); + out.flush(); + response.setStatus(200); + } else { + response.setStatus(400); + } + } catch (InterruptedException | ExecutionException | IOException e) { + response.setStatus(500); + } + } + } + +} diff --git a/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/scoped/inheriting/ExternalService.java b/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/scoped/inheriting/ExternalService.java new file mode 100644 index 0000000000..88fa4dfb74 --- /dev/null +++ b/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/scoped/inheriting/ExternalService.java @@ -0,0 +1,9 @@ +package com.baeldung.scopedvalues.scoped.inheriting; + +public class ExternalService { + + public String getData() { + return "External data"; + } + +} diff --git a/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/scoped/inheriting/InternalService.java b/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/scoped/inheriting/InternalService.java new file mode 100644 index 0000000000..ace46b254c --- /dev/null +++ b/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/scoped/inheriting/InternalService.java @@ -0,0 +1,17 @@ +package com.baeldung.scopedvalues.scoped.inheriting; + +import com.baeldung.scopedvalues.data.Data; +import jakarta.servlet.http.HttpServletRequest; + +import java.util.Optional; + +public class InternalService { + + private final Repository repository = new Repository(); + + public Optional getData(HttpServletRequest request) { + String id = request.getParameter("data_id"); + return repository.getData(id); + } + +} diff --git a/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/scoped/inheriting/Repository.java b/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/scoped/inheriting/Repository.java new file mode 100644 index 0000000000..22d18b2fac --- /dev/null +++ b/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/scoped/inheriting/Repository.java @@ -0,0 +1,17 @@ +package com.baeldung.scopedvalues.scoped.inheriting; + +import com.baeldung.scopedvalues.data.Data; +import com.baeldung.scopedvalues.data.User; + +import java.util.Optional; + +public class Repository { + + public Optional getData(String id) { + User loggedInUser = Server.LOGGED_IN_USER.get(); + return loggedInUser.isAdmin() + ? Optional.of(new Data(id, "Title 1", "Description 1")) + : Optional.empty(); + } + +} diff --git a/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/scoped/inheriting/Server.java b/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/scoped/inheriting/Server.java new file mode 100644 index 0000000000..5f04a1eedd --- /dev/null +++ b/core-java-modules/core-java-20/src/main/java/com/baeldung/scopedvalues/scoped/inheriting/Server.java @@ -0,0 +1,41 @@ +package com.baeldung.scopedvalues.scoped.inheriting; + +import com.baeldung.scopedvalues.data.User; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import jdk.incubator.concurrent.ScopedValue; + +import java.util.List; +import java.util.Optional; + +public class Server { + + private static final List AUTHENTICATED_USERS = List.of( + new User("1", "admin", "123456", true), + new User("2", "user", "123456", false) + ); + public final static ScopedValue LOGGED_IN_USER = ScopedValue.newInstance(); + private final Controller controller = new Controller(); + + public void serve(HttpServletRequest request, HttpServletResponse response) { + Optional user = authenticateUser(request); + if (user.isPresent()) { + ScopedValue.where(LOGGED_IN_USER, user.get()) + .run(() -> controller.processRequest(request, response)); + } else { + response.setStatus(401); + } + } + + private Optional authenticateUser(HttpServletRequest request) { + return AUTHENTICATED_USERS.stream() + .filter(user -> checkUserPassword(user, request)) + .findFirst(); + } + + private boolean checkUserPassword(User user, HttpServletRequest request) { + return user.name().equals(request.getParameter("user_name")) + && user.password().equals(request.getParameter("user_pw")); + } + +} diff --git a/core-java-modules/core-java-20/src/test/java/com/baeldung/scopedvalues/classic/ServerUnitTest.java b/core-java-modules/core-java-20/src/test/java/com/baeldung/scopedvalues/classic/ServerUnitTest.java new file mode 100644 index 0000000000..e0b9366c22 --- /dev/null +++ b/core-java-modules/core-java-20/src/test/java/com/baeldung/scopedvalues/classic/ServerUnitTest.java @@ -0,0 +1,52 @@ +package com.baeldung.scopedvalues.classic; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.concurrent.ExecutionException; + +import static org.mockito.Mockito.*; +import static org.assertj.core.api.Assertions.*; +@ExtendWith(MockitoExtension.class) +public class ServerUnitTest { + + @Mock + private HttpServletRequest request; + + @Mock + private HttpServletResponse response; + + private final StringWriter writer = new StringWriter(); + + private final Server server = new Server(); + + @Test + void givenMockedRequestWithAdminCredentials_whenServeMethodIsCalled_thenDataIsReturned() throws InterruptedException, IOException, ExecutionException { + when(request.getParameter("user_name")).thenReturn("admin"); + when(request.getParameter("user_pw")).thenReturn("123456"); + when(request.getParameter("data_id")).thenReturn("1"); + when(response.getWriter()).thenReturn(new PrintWriter(writer)); + + server.serve(request, response); + + assertThat(writer.toString()).isEqualTo("Data[id=1, title=Title 1, description=Description 1]"); + } + + @Test + void givenMockedRequestWithUserCredentials_whenServeMethodIsCalled_thenNoDataIsReturned() throws InterruptedException, ExecutionException { + when(request.getParameter("user_name")).thenReturn("user"); + when(request.getParameter("user_pw")).thenReturn("123456"); + + server.serve(request, response); + + assertThat(writer.toString()).isEqualTo(""); + } + +} diff --git a/core-java-modules/core-java-20/src/test/java/com/baeldung/scopedvalues/scoped/ServerUnitTest.java b/core-java-modules/core-java-20/src/test/java/com/baeldung/scopedvalues/scoped/ServerUnitTest.java new file mode 100644 index 0000000000..034e6683e3 --- /dev/null +++ b/core-java-modules/core-java-20/src/test/java/com/baeldung/scopedvalues/scoped/ServerUnitTest.java @@ -0,0 +1,52 @@ +package com.baeldung.scopedvalues.scoped; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.when; + +@ExtendWith(MockitoExtension.class) +public class ServerUnitTest { + + @Mock + private HttpServletRequest request; + + @Mock + private HttpServletResponse response; + + private final StringWriter writer = new StringWriter(); + + private final Server server = new Server(); + + @Test + void givenMockedRequestWithAdminCredentials_whenServeMethodIsCalled_thenDataIsReturned() throws IOException { + when(request.getParameter("user_name")).thenReturn("admin"); + when(request.getParameter("user_pw")).thenReturn("123456"); + when(request.getParameter("data_id")).thenReturn("1"); + when(response.getWriter()).thenReturn(new PrintWriter(writer)); + + server.serve(request, response); + + assertThat(writer.toString()).isEqualTo("Data[id=1, title=Title 1, description=Description 1]"); + } + + @Test + void givenMockedRequestWithUserCredentials_whenServeMethodIsCalled_thenNoDataIsReturned() throws IOException { + when(request.getParameter("user_name")).thenReturn("user"); + when(request.getParameter("user_pw")).thenReturn("123456"); + + server.serve(request, response); + + assertThat(writer.toString()).isEqualTo(""); + } + +} diff --git a/core-java-modules/core-java-20/src/test/java/com/baeldung/scopedvalues/scoped/inheriting/ServerUnitTest.java b/core-java-modules/core-java-20/src/test/java/com/baeldung/scopedvalues/scoped/inheriting/ServerUnitTest.java new file mode 100644 index 0000000000..230b017c18 --- /dev/null +++ b/core-java-modules/core-java-20/src/test/java/com/baeldung/scopedvalues/scoped/inheriting/ServerUnitTest.java @@ -0,0 +1,52 @@ +package com.baeldung.scopedvalues.scoped.inheriting; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.when; + +@ExtendWith(MockitoExtension.class) +public class ServerUnitTest { + + @Mock + private HttpServletRequest request; + + @Mock + private HttpServletResponse response; + + private final StringWriter writer = new StringWriter(); + + private final Server server = new Server(); + + @Test + void givenMockedRequestWithAdminCredentials_whenServeMethodIsCalled_thenDataIsReturned() throws IOException { + when(request.getParameter("user_name")).thenReturn("admin"); + when(request.getParameter("user_pw")).thenReturn("123456"); + when(request.getParameter("data_id")).thenReturn("1"); + when(response.getWriter()).thenReturn(new PrintWriter(writer)); + + server.serve(request, response); + + assertThat(writer.toString()).isEqualTo("Data[id=1, title=Title 1, description=Description 1]\nExternal data"); + } + + @Test + void givenMockedRequestWithUserCredentials_whenServeMethodIsCalled_thenNoDataIsReturned() throws IOException { + when(request.getParameter("user_name")).thenReturn("user"); + when(request.getParameter("user_pw")).thenReturn("123456"); + + server.serve(request, response); + + assertThat(writer.toString()).isEqualTo(""); + } + +} diff --git a/core-java-modules/core-java-8-2/README.md b/core-java-modules/core-java-8-2/README.md index efba1f23ad..c723a827b1 100644 --- a/core-java-modules/core-java-8-2/README.md +++ b/core-java-modules/core-java-8-2/README.md @@ -11,5 +11,6 @@ This module contains articles about Java 8 core features - [Convert Between Byte Array and UUID in Java](https://www.baeldung.com/java-byte-array-to-uuid) - [Create a Simple “Rock-Paper-Scissors” Game in Java](https://www.baeldung.com/java-rock-paper-scissors) - [VarArgs vs Array Input Parameters in Java](https://www.baeldung.com/varargs-vs-array) +- [Lambda Expression vs. Anonymous Inner Class](https://www.baeldung.com/java-lambdas-vs-anonymous-class) - [Java Helper vs. Utility Classes](https://www.baeldung.com/java-helper-vs-utility-classes) - [[<-- Prev]](/core-java-modules/core-java-8) diff --git a/core-java-modules/core-java-lambdas/src/main/java/com/baeldung/anonymousclass/AnonymousClassExample.java b/core-java-modules/core-java-8-2/src/main/java/com/baeldung/anonymousclass/AnonymousClassExample.java similarity index 100% rename from core-java-modules/core-java-lambdas/src/main/java/com/baeldung/anonymousclass/AnonymousClassExample.java rename to core-java-modules/core-java-8-2/src/main/java/com/baeldung/anonymousclass/AnonymousClassExample.java diff --git a/core-java-modules/core-java-lambdas/src/main/java/com/baeldung/lambdaexpression/LambdaExpressionExample.java b/core-java-modules/core-java-8-2/src/main/java/com/baeldung/lambdaexpression/LambdaExpressionExample.java similarity index 100% rename from core-java-modules/core-java-lambdas/src/main/java/com/baeldung/lambdaexpression/LambdaExpressionExample.java rename to core-java-modules/core-java-8-2/src/main/java/com/baeldung/lambdaexpression/LambdaExpressionExample.java diff --git a/core-java-modules/core-java-8-datetime-2/README.md b/core-java-modules/core-java-8-datetime-2/README.md index f16563aacc..56f66c10fb 100644 --- a/core-java-modules/core-java-8-datetime-2/README.md +++ b/core-java-modules/core-java-8-datetime-2/README.md @@ -2,4 +2,5 @@ - [Generating Random Dates in Java](https://www.baeldung.com/java-random-dates) - [Creating a LocalDate with Values in Java](https://www.baeldung.com/java-creating-localdate-with-values) -- [[<-- Prev]](/core-java-modules/core-java-datetime-java8-1) \ No newline at end of file +- [Parsing Date Strings with Varying Formats](https://www.baeldung.com/java-parsing-dates-many-formats) +- [[<-- Prev]](/core-java-modules/core-java-datetime-java8-1) diff --git a/core-java-modules/core-java-9-jigsaw/README.md b/core-java-modules/core-java-9-jigsaw/README.md index cfffb86588..73905e6033 100644 --- a/core-java-modules/core-java-9-jigsaw/README.md +++ b/core-java-modules/core-java-9-jigsaw/README.md @@ -8,5 +8,5 @@ This module contains articles about Project Jigsaw and the Java Platform Module - [A Guide to Java 9 Modularity](https://www.baeldung.com/java-9-modularity) - [Java 9 java.lang.Module API](https://www.baeldung.com/java-9-module-api) - [Java 9 Illegal Reflective Access Warning](https://www.baeldung.com/java-illegal-reflective-access) - +- [Java Modularity and Unit Testing](https://www.baeldung.com/java-modularity-unit-testing) diff --git a/core-java-modules/core-java-arrays-operations-basic/src/main/java/com/baeldung/arrayindex/ArrayIndex.java b/core-java-modules/core-java-arrays-operations-basic/src/main/java/com/baeldung/arrayindex/ArrayIndex.java new file mode 100644 index 0000000000..596e0d424f --- /dev/null +++ b/core-java-modules/core-java-arrays-operations-basic/src/main/java/com/baeldung/arrayindex/ArrayIndex.java @@ -0,0 +1,28 @@ +package com.baeldung.arrayindex; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.IntStream; + +class ArrayIndex { + static int forLoop(int[] numbers, int target) { + for (int index = 0; index < numbers.length; index++) { + if (numbers[index] == target) { + return index; + } + } + return -1; + } + + static int listIndexOf(Integer[] numbers, int target) { + List list = Arrays.asList(numbers); + return list.indexOf(target); + } + + static int intStream(int[] numbers, int target) { + return IntStream.range(0, numbers.length) + .filter(i -> numbers[i] == target) + .findFirst() + .orElse(-1); + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-arrays-operations-basic/src/test/java/com/baeldung/arrayindex/ArrayIndexUnitTest.java b/core-java-modules/core-java-arrays-operations-basic/src/test/java/com/baeldung/arrayindex/ArrayIndexUnitTest.java new file mode 100644 index 0000000000..84c868d5e0 --- /dev/null +++ b/core-java-modules/core-java-arrays-operations-basic/src/test/java/com/baeldung/arrayindex/ArrayIndexUnitTest.java @@ -0,0 +1,106 @@ +package com.baeldung.arrayindex; + +import static com.baeldung.arrayindex.ArrayIndex.forLoop; +import static com.baeldung.arrayindex.ArrayIndex.intStream; +import static com.baeldung.arrayindex.ArrayIndex.listIndexOf; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.Arrays; + +import org.apache.commons.lang3.ArrayUtils; +import org.junit.jupiter.api.Test; + +import com.google.common.primitives.Ints; + +class ArrayIndexUnitTest { + + @Test + void givenIntegerArray_whenUseForLoop_thenWillGetElementIndex() { + int[] numbers = { 10, 20, 30, 40, 50 }; + assertEquals(2, forLoop(numbers, 30)); + } + + @Test + void givenIntegerArray_whenUseForLoop_thenWillGetElementMinusOneIndex() { + int[] numbers = { 10, 20, 30, 40, 50 }; + assertEquals(-1, forLoop(numbers, 100)); + } + + @Test + void givenIntegerArray_whenUseIndexOf_thenWillGetElementIndex() { + Integer[] numbers = { 10, 20, 30, 40, 50 }; + assertEquals(2, listIndexOf(numbers, 30)); + } + + @Test + void givenIntegerArray_whenUseIndexOf_thenWillGetElementMinusOneIndex() { + Integer[] numbers = { 10, 20, 30, 40, 50 }; + assertEquals(-1, listIndexOf(numbers, 100)); + } + + @Test + void givenIntegerArray_whenUseIntStream_thenWillGetElementIndex() { + int[] numbers = { 10, 20, 30, 40, 50 }; + assertEquals(2, intStream(numbers, 30)); + } + + @Test + void givenIntegerArray_whenUseIntStream_thenWillGetElementMinusOneIndex() { + int[] numbers = { 10, 20, 30, 40, 50 }; + assertEquals(-1, intStream(numbers, 100)); + } + + @Test + void givenIntegerArray_whenUseBinarySearch_thenWillGetElementIndex() { + int[] numbers = { 10, 20, 30, 40, 50 }; + assertEquals(2, Arrays.binarySearch(numbers, 30)); + } + + @Test + void givenIntegerArray_whenUseBinarySearch_thenWillGetUpperBoundMinusIndex() { + int[] numbers = { 10, 20, 30, 40, 50 }; + assertEquals(-6, Arrays.binarySearch(numbers, 100)); + } + + @Test + void givenIntegerArray_whenUseBinarySearch_thenWillGetInArrayMinusIndex() { + int[] numbers = { 10, 20, 30, 40, 50 }; + assertEquals(-2, Arrays.binarySearch(numbers, 15)); + } + + @Test + void givenIntegerArray_whenUseBinarySearch_thenWillGetLowerBoundMinusIndex() { + int[] numbers = { 10, 20, 30, 40, 50 }; + assertEquals(-1, Arrays.binarySearch(numbers, -15)); + } + + @Test + void givenIntegerArray_whenUseApacheCommons_thenWillGetElementIndex() { + int[] numbers = { 10, 20, 30, 40, 50 }; + assertEquals(2, ArrayUtils.indexOf(numbers, 30)); + } + + @Test + void givenIntegerArray_whenUseApacheCommonsStartingFromIndex_thenWillGetNegativeIndex() { + int[] numbers = { 10, 20, 30, 40, 50 }; + assertEquals(-1, ArrayUtils.indexOf(numbers, 30, 3)); + } + + @Test + void givenIntegerArray_whenUseApacheCommons_thenWillGetElementMinusOneIndex() { + int[] numbers = { 10, 20, 30, 40, 50 }; + assertEquals(-1, ArrayUtils.indexOf(numbers, 100)); + } + + @Test + void givenIntegerArray_whenUseGuavaInts_thenWillGetElementIndex() { + int[] numbers = { 10, 20, 30, 40, 50 }; + assertEquals(2, Ints.indexOf(numbers, 30)); + } + + @Test + void givenIntegerArray_whenUseGuavaInts_thenWillGetElementMinusOneIndex() { + int[] numbers = { 10, 20, 30, 40, 50 }; + assertEquals(-1, Ints.indexOf(numbers, 100)); + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-char/src/test/java/com/baeldung/charandstring/DifferenceBetweenCharAndStringUnitTest.java b/core-java-modules/core-java-char/src/test/java/com/baeldung/charandstring/DifferenceBetweenCharAndStringUnitTest.java new file mode 100644 index 0000000000..b4e1da6d71 --- /dev/null +++ b/core-java-modules/core-java-char/src/test/java/com/baeldung/charandstring/DifferenceBetweenCharAndStringUnitTest.java @@ -0,0 +1,56 @@ +package com.baeldung.charandstring; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; + +import org.junit.jupiter.api.Test; + +public class DifferenceBetweenCharAndStringUnitTest { + + @Test + void whenPlusTwoChars_thenGetSumAsInteger() { + char h = 'H'; // the value is 72 + char i = 'i'; // the value is 105 + assertEquals(177, h + i); + assertInstanceOf(Integer.class, h + i); + } + + @Test + void whenPlusTwoStrings_thenConcatenateThem() { + String i = "i"; + String h = "H"; + assertEquals("Hi", h + i); + } + + @Test + void whenPlusCharsAndStrings_thenGetExpectedValues() { + char c = 'C'; + assertEquals("C", "" + c); + + char h = 'H'; // the value is 72 + char i = 'i'; // the value is 105 + assertEquals("Hi", "" + h + i); + assertEquals("Hi", h + "" + i); + assertEquals("177", h + i + ""); + } + + @Test + void whenStringChars_thenGetCharArray() { + char h = 'h'; + char e = 'e'; + char l = 'l'; + char o = 'o'; + + String hello = "hello"; + assertEquals(h, hello.charAt(0)); + assertEquals(e, hello.charAt(1)); + assertEquals(l, hello.charAt(2)); + assertEquals(l, hello.charAt(3)); + assertEquals(o, hello.charAt(4)); + + char[] chars = new char[] { h, e, l, l, o }; + char[] charsFromString = hello.toCharArray(); + assertArrayEquals(chars, charsFromString); + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-concurrency-basic-3/src/main/java/com/baeldung/concurrent/completablefuture/NonBlockingExample.java b/core-java-modules/core-java-concurrency-basic-3/src/main/java/com/baeldung/concurrent/completablefuture/NonBlockingExample.java new file mode 100644 index 0000000000..b97f7d0dee --- /dev/null +++ b/core-java-modules/core-java-concurrency-basic-3/src/main/java/com/baeldung/concurrent/completablefuture/NonBlockingExample.java @@ -0,0 +1,17 @@ +package com.baeldung.concurrent.completablefuture; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.concurrent.CompletableFuture; + +public class NonBlockingExample { + + private static final Logger logger = LoggerFactory.getLogger(NonBlockingExample.class); + + public static void main(String[] args) { + CompletableFuture.supplyAsync(() -> "Baeldung") + .thenApply(String::length) + .thenAccept(s -> logger.info(String.valueOf(s))); + } +} diff --git a/core-java-modules/core-java-concurrency-basic-3/src/test/java/com/baeldung/concurrent/completablefuture/BlockingUnitTest.java b/core-java-modules/core-java-concurrency-basic-3/src/test/java/com/baeldung/concurrent/completablefuture/BlockingUnitTest.java new file mode 100644 index 0000000000..75d8d73c2f --- /dev/null +++ b/core-java-modules/core-java-concurrency-basic-3/src/test/java/com/baeldung/concurrent/completablefuture/BlockingUnitTest.java @@ -0,0 +1,31 @@ +package com.baeldung.concurrent.completablefuture; + +import org.junit.jupiter.api.Test; + +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +class BlockingUnitTest { + + @Test + void givenCompletableFuture_whenGet_thenReturnResult() + throws ExecutionException, InterruptedException { + CompletableFuture completableFuture = CompletableFuture + .supplyAsync(() -> "Baeldung") + .thenApply(String::toUpperCase); + + assertEquals("BAELDUNG", completableFuture.get()); + } + + @Test + void givenCompletableFuture_whenJoin_thenReturnResult() { + CompletableFuture completableFuture = CompletableFuture + .supplyAsync(() -> "Blocking") + .thenApply(s -> s + " Operation") + .thenApply(String::toLowerCase); + + assertEquals("blocking operation", completableFuture.join()); + } +} diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/sandbox/SandboxJavaManualTest.java b/core-java-modules/core-java-concurrency-simple/src/test/java/com/baeldung/sandbox/SandboxJavaManualTest.java similarity index 100% rename from core-java-modules/core-java/src/test/java/com/baeldung/sandbox/SandboxJavaManualTest.java rename to core-java-modules/core-java-concurrency-simple/src/test/java/com/baeldung/sandbox/SandboxJavaManualTest.java diff --git a/core-java-modules/core-java-io-apis-2/README.md b/core-java-modules/core-java-io-apis-2/README.md index f3d72fe8b5..031ff3c7fc 100644 --- a/core-java-modules/core-java-io-apis-2/README.md +++ b/core-java-modules/core-java-io-apis-2/README.md @@ -5,3 +5,5 @@ This module contains articles about core Java input/output(IO) APIs. ### Relevant Articles: - [Constructing a Relative Path From Two Absolute Paths in Java](https://www.baeldung.com/java-relative-path-absolute) - [Java Scanner Taking a Character Input](https://www.baeldung.com/java-scanner-character-input) +- [Get the Desktop Path in Java](https://www.baeldung.com/java-desktop-path) +- [Integer.parseInt(scanner.nextLine()) and scanner.nextInt() in Java](https://www.baeldung.com/java-scanner-integer) diff --git a/core-java-modules/core-java-io-apis-2/src/test/java/com/baeldung/bufferedreadervsfilereader/BufferedReaderUnitTest.java b/core-java-modules/core-java-io-apis-2/src/test/java/com/baeldung/bufferedreadervsfilereader/BufferedReaderUnitTest.java new file mode 100644 index 0000000000..a2aeca56ad --- /dev/null +++ b/core-java-modules/core-java-io-apis-2/src/test/java/com/baeldung/bufferedreadervsfilereader/BufferedReaderUnitTest.java @@ -0,0 +1,31 @@ +package com.baeldung.bufferedreadervsfilereader; + +import org.junit.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; + +public class BufferedReaderUnitTest { + + @Test + public void whenReadingAFile_thenReadsLineByLine() { + StringBuilder result = new StringBuilder(); + + try (BufferedReader br = new BufferedReader(new FileReader("src/test/resources/sampleText1.txt"))) { + String line; + + while((line = br.readLine()) != null) { + result.append(line); + result.append('\n'); + } + } catch (IOException e) { + e.printStackTrace(); + } + + assertEquals("first line\nsecond line\nthird line\n", result.toString()); + } + +} diff --git a/core-java-modules/core-java-io-apis-2/src/test/java/com/baeldung/bufferedreadervsfilereader/FileReaderUnitTest.java b/core-java-modules/core-java-io-apis-2/src/test/java/com/baeldung/bufferedreadervsfilereader/FileReaderUnitTest.java new file mode 100644 index 0000000000..f046f313d4 --- /dev/null +++ b/core-java-modules/core-java-io-apis-2/src/test/java/com/baeldung/bufferedreadervsfilereader/FileReaderUnitTest.java @@ -0,0 +1,30 @@ +package com.baeldung.bufferedreadervsfilereader; + +import org.junit.jupiter.api.Test; + +import java.io.FileReader; +import java.io.IOException; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class FileReaderUnitTest { + + @Test + public void whenReadingAFile_thenReadsCharByChar() { + StringBuilder result = new StringBuilder(); + + try (FileReader fr = new FileReader("src/test/resources/sampleText2.txt")) { + int i = fr.read(); + + while(i != -1) { + result.append((char)i); + + i = fr.read(); + } + } catch (IOException e) { + e.printStackTrace(); + } + + assertEquals("qwerty", result.toString()); + } +} diff --git a/core-java-modules/core-java-io-apis-2/src/test/java/com/baeldung/scanner/NextLineVsNextIntUnitTest.java b/core-java-modules/core-java-io-apis-2/src/test/java/com/baeldung/scanner/NextLineVsNextIntUnitTest.java new file mode 100644 index 0000000000..8fab7c62e9 --- /dev/null +++ b/core-java-modules/core-java-io-apis-2/src/test/java/com/baeldung/scanner/NextLineVsNextIntUnitTest.java @@ -0,0 +1,85 @@ +package com.baeldung.scanner; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import java.util.InputMismatchException; +import java.util.Scanner; + +import org.junit.jupiter.api.Test; + +public class NextLineVsNextIntUnitTest { + + @Test + void whenInputLineIsNumber_thenNextLineAndNextIntBothWork() { + String input = "42\n"; + + //nextLine() + Scanner sc1 = new Scanner(input); + int num1 = Integer.parseInt(sc1.nextLine()); + assertEquals(42, num1); + + //nextInt() + Scanner sc2 = new Scanner(input); + int num2 = sc2.nextInt(); + assertEquals(42, num2); + + } + + @Test + void whenInputIsNotValidNumber_thenNextLineAndNextIntThrowDifferentException() { + String input = "Nan\n"; + + //nextLine() -> NumberFormatException + Scanner sc1 = new Scanner(input); + assertThrows(NumberFormatException.class, () -> Integer.parseInt(sc1.nextLine())); + + //nextInt() -> InputMismatchException + Scanner sc2 = new Scanner(input); + assertThrows(InputMismatchException.class, sc2::nextInt); + } + + @Test + void whenUsingNextInt_thenTheNextTokenAfterItFailsToParseIsNotConsumed() { + String input = "42 is a magic number\n"; + + //nextInt() to read '42' + Scanner sc2 = new Scanner(input); + int num2 = sc2.nextInt(); + assertEquals(42, num2); + + // call nextInt() again on "is" + assertThrows(InputMismatchException.class, sc2::nextInt); + + String theNextToken = sc2.next(); + assertEquals("is", theNextToken); + + theNextToken = sc2.next(); + assertEquals("a", theNextToken); + } + + @Test + void whenReadingTwoInputLines_thenNextLineAndNextIntBehaveDifferently() { + + String input = new StringBuilder().append("42\n") + .append("It is a magic number.\n") + .toString(); + + //nextLine() + Scanner sc1 = new Scanner(input); + int num1 = Integer.parseInt(sc1.nextLine()); + String nextLineText1 = sc1.nextLine(); + assertEquals(42, num1); + assertEquals("It is a magic number.", nextLineText1); + + //nextInt() + Scanner sc2 = new Scanner(input); + int num2 = sc2.nextInt(); + assertEquals(42, num2); + + // nextInt() leaves the newline character (\n) behind + String nextLineText2 = sc2.nextLine(); + assertEquals("", nextLineText2); + } + +} \ No newline at end of file diff --git a/core-java-modules/core-java-io-apis-2/src/test/resources/sampleText1.txt b/core-java-modules/core-java-io-apis-2/src/test/resources/sampleText1.txt new file mode 100644 index 0000000000..20aeba2bad --- /dev/null +++ b/core-java-modules/core-java-io-apis-2/src/test/resources/sampleText1.txt @@ -0,0 +1,3 @@ +first line +second line +third line diff --git a/core-java-modules/core-java-io-apis-2/src/test/resources/sampleText2.txt b/core-java-modules/core-java-io-apis-2/src/test/resources/sampleText2.txt new file mode 100644 index 0000000000..f2289097d4 --- /dev/null +++ b/core-java-modules/core-java-io-apis-2/src/test/resources/sampleText2.txt @@ -0,0 +1 @@ +qwerty \ No newline at end of file diff --git a/core-java-modules/core-java-io-conversions-2/src/test/java/com/baeldung/inputstreamtostring/JavaInputStreamToXUnitTest.java b/core-java-modules/core-java-io-conversions-2/src/test/java/com/baeldung/inputstreamtostring/JavaInputStreamToXUnitTest.java index 03f528766b..341a820b01 100644 --- a/core-java-modules/core-java-io-conversions-2/src/test/java/com/baeldung/inputstreamtostring/JavaInputStreamToXUnitTest.java +++ b/core-java-modules/core-java-io-conversions-2/src/test/java/com/baeldung/inputstreamtostring/JavaInputStreamToXUnitTest.java @@ -49,7 +49,7 @@ public class JavaInputStreamToXUnitTest { final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes()); final StringBuilder textBuilder = new StringBuilder(); - try (Reader reader = new BufferedReader(new InputStreamReader(inputStream, Charset.forName(StandardCharsets.UTF_8.name())))) { + try (Reader reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) { int c; while ((c = reader.read()) != -1) { textBuilder.append((char) c); @@ -63,7 +63,7 @@ public class JavaInputStreamToXUnitTest { final String originalString = randomAlphabetic(DEFAULT_SIZE); final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes()); - final String text = new BufferedReader(new InputStreamReader(inputStream, Charset.forName(StandardCharsets.UTF_8.name()))) + final String text = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8)) .lines() .collect(Collectors.joining("\n")); diff --git a/core-java-modules/core-java-lambdas/README.md b/core-java-modules/core-java-lambdas/README.md index 56b2a79e7e..cad2097673 100644 --- a/core-java-modules/core-java-lambdas/README.md +++ b/core-java-modules/core-java-lambdas/README.md @@ -10,4 +10,3 @@ - [Serialize a Lambda in Java](https://www.baeldung.com/java-serialize-lambda) - [Convert Anonymous Class into Lambda in Java](https://www.baeldung.com/java-from-anonymous-class-to-lambda) - [When to Use Callable and Supplier in Java](https://www.baeldung.com/java-callable-vs-supplier) -- [Lambda Expression vs. Anonymous Inner Class](https://www.baeldung.com/java-lambdas-vs-anonymous-class) diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/rawtypes/RawTypesUnitTest.java b/core-java-modules/core-java-lang-5/src/test/java/com/baeldung/rawtypes/RawTypesUnitTest.java similarity index 100% rename from core-java-modules/core-java/src/test/java/com/baeldung/rawtypes/RawTypesUnitTest.java rename to core-java-modules/core-java-lang-5/src/test/java/com/baeldung/rawtypes/RawTypesUnitTest.java diff --git a/core-java-modules/core-java-lang-math-3/README.md b/core-java-modules/core-java-lang-math-3/README.md index 89adc23100..847bd314a7 100644 --- a/core-java-modules/core-java-lang-math-3/README.md +++ b/core-java-modules/core-java-lang-math-3/README.md @@ -10,4 +10,5 @@ - [Create a BMI Calculator in Java](https://www.baeldung.com/java-body-mass-index-calculator) - [Java Program to Calculate the Standard Deviation](https://www.baeldung.com/java-calculate-standard-deviation) - [Java Program to Print Pascal’s Triangle](https://www.baeldung.com/java-pascal-triangle) +- [Java Money and the Currency API](http://www.baeldung.com/java-money-and-currency) - More articles: [[<-- Prev]](/core-java-modules/core-java-lang-math-2) diff --git a/core-java-modules/core-java-lang-math-3/pom.xml b/core-java-modules/core-java-lang-math-3/pom.xml index 9cd3673df3..7860f57735 100644 --- a/core-java-modules/core-java-lang-math-3/pom.xml +++ b/core-java-modules/core-java-lang-math-3/pom.xml @@ -23,11 +23,17 @@ javaluator ${javaluator.version} + + org.javamoney + moneta + ${javamoney.moneta.version} + 0.4.8 3.0.3 + 1.1 \ No newline at end of file diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/money/JavaMoney.java b/core-java-modules/core-java-lang-math-3/src/main/java/com/baeldung/money/JavaMoney.java similarity index 100% rename from core-java-modules/core-java/src/main/java/com/baeldung/money/JavaMoney.java rename to core-java-modules/core-java-lang-math-3/src/main/java/com/baeldung/money/JavaMoney.java diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/money/JavaMoneyUnitManualTest.java b/core-java-modules/core-java-lang-math-3/src/test/java/com/baeldung/money/JavaMoneyUnitManualTest.java similarity index 100% rename from core-java-modules/core-java/src/test/java/com/baeldung/money/JavaMoneyUnitManualTest.java rename to core-java-modules/core-java-lang-math-3/src/test/java/com/baeldung/money/JavaMoneyUnitManualTest.java diff --git a/core-java-modules/core-java-lang-oop-constructors-2/README.md b/core-java-modules/core-java-lang-oop-constructors-2/README.md new file mode 100644 index 0000000000..d9b162c7a6 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-constructors-2/README.md @@ -0,0 +1,7 @@ +## Core Java Lang OOP - Constructors - Part 2 + +This module contains article about constructors in Java + +### Relevant Articles: +- [Different Ways to Create an Object in Java](https://www.baeldung.com/java-different-ways-to-create-objects) +- More articles: [[<-- Prev]](/core-java-modules/core-java-lang-oop-constructors) \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop-constructors-2/pom.xml b/core-java-modules/core-java-lang-oop-constructors-2/pom.xml new file mode 100644 index 0000000000..c6d9d84774 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-constructors-2/pom.xml @@ -0,0 +1,16 @@ + + + 4.0.0 + core-java-lang-oop-constructors-2 + core-java-lang-oop-constructors-2 + jar + + + core-java-modules + com.baeldung.core-java-modules + 0.0.1-SNAPSHOT + + + \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/objectcreation/objects/ClonableRabbit.java b/core-java-modules/core-java-lang-oop-constructors-2/src/main/java/com/baeldung/objectcreation/objects/ClonableRabbit.java similarity index 100% rename from core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/objectcreation/objects/ClonableRabbit.java rename to core-java-modules/core-java-lang-oop-constructors-2/src/main/java/com/baeldung/objectcreation/objects/ClonableRabbit.java diff --git a/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/objectcreation/objects/Rabbit.java b/core-java-modules/core-java-lang-oop-constructors-2/src/main/java/com/baeldung/objectcreation/objects/Rabbit.java similarity index 100% rename from core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/objectcreation/objects/Rabbit.java rename to core-java-modules/core-java-lang-oop-constructors-2/src/main/java/com/baeldung/objectcreation/objects/Rabbit.java diff --git a/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/objectcreation/objects/RabbitType.java b/core-java-modules/core-java-lang-oop-constructors-2/src/main/java/com/baeldung/objectcreation/objects/RabbitType.java similarity index 100% rename from core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/objectcreation/objects/RabbitType.java rename to core-java-modules/core-java-lang-oop-constructors-2/src/main/java/com/baeldung/objectcreation/objects/RabbitType.java diff --git a/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/objectcreation/objects/SerializableRabbit.java b/core-java-modules/core-java-lang-oop-constructors-2/src/main/java/com/baeldung/objectcreation/objects/SerializableRabbit.java similarity index 100% rename from core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/objectcreation/objects/SerializableRabbit.java rename to core-java-modules/core-java-lang-oop-constructors-2/src/main/java/com/baeldung/objectcreation/objects/SerializableRabbit.java diff --git a/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/objectcreation/utils/CreateRabbits.java b/core-java-modules/core-java-lang-oop-constructors-2/src/main/java/com/baeldung/objectcreation/utils/CreateRabbits.java similarity index 100% rename from core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/objectcreation/utils/CreateRabbits.java rename to core-java-modules/core-java-lang-oop-constructors-2/src/main/java/com/baeldung/objectcreation/utils/CreateRabbits.java diff --git a/core-java-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/objectcreation/CreateRabbitsUnitTest.java b/core-java-modules/core-java-lang-oop-constructors-2/src/test/java/com/baeldung/objectcreation/CreateRabbitsUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/objectcreation/CreateRabbitsUnitTest.java rename to core-java-modules/core-java-lang-oop-constructors-2/src/test/java/com/baeldung/objectcreation/CreateRabbitsUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-constructors/README.md b/core-java-modules/core-java-lang-oop-constructors/README.md index 4ac9224bb1..c35cb836a5 100644 --- a/core-java-modules/core-java-lang-oop-constructors/README.md +++ b/core-java-modules/core-java-lang-oop-constructors/README.md @@ -13,4 +13,4 @@ This module contains article about constructors in Java - [Constructor Specification in Java](https://www.baeldung.com/java-constructor-specification) - [Static vs. Instance Initializer Block in Java](https://www.baeldung.com/java-static-instance-initializer-blocks) - [Accessing Private Constructor in Java](https://www.baeldung.com/java-private-constructor-access) -- [Different Ways to Create an Object in Java](https://www.baeldung.com/java-different-ways-to-create-objects) +- More articles: [[next -->]](/core-java-modules/core-java-lang-oop-constructors-2) \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop-methods/README.md b/core-java-modules/core-java-lang-oop-methods/README.md index f34606f26a..053cafac3e 100644 --- a/core-java-modules/core-java-lang-oop-methods/README.md +++ b/core-java-modules/core-java-lang-oop-methods/README.md @@ -11,3 +11,4 @@ This module contains articles about methods in Java - [The Covariant Return Type in Java](https://www.baeldung.com/java-covariant-return-type) - [Does a Method’s Signature Include the Return Type in Java?](https://www.baeldung.com/java-method-signature-return-type) - [Solving the Hide Utility Class Public Constructor Sonar Warning](https://www.baeldung.com/java-sonar-hide-implicit-constructor) +- [Best Practices for Passing Many Arguments to a Method in Java](https://www.baeldung.com/java-best-practices-many-parameters-method) diff --git a/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methods/Car.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methods/Car.java new file mode 100644 index 0000000000..a72d7dd0f1 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methods/Car.java @@ -0,0 +1,98 @@ +package com.baeldung.methods; + +public class Car { + + private final String make; + private final String model; + private final int year; + private final String color; + private final boolean automatic; + private final int numDoors; + private final String features; + + private Car(CarBuilder carBuilder) { + this.make = carBuilder.make; + this.model = carBuilder.model; + this.year = carBuilder.year; + this.color = carBuilder.color; + this.automatic = carBuilder.automatic; + this.numDoors = carBuilder.numDoors; + this.features = carBuilder.features; + } + + public String getMake() { + return make; + } + + public String getModel() { + return model; + } + + public int getYear() { + return year; + } + + public String getColor() { + return color; + } + + public boolean isAutomatic() { + return automatic; + } + + public int getNumDoors() { + return numDoors; + } + + public String getFeatures() { + return features; + } + + public static class CarBuilder { + + private final String make; + private final String model; + private final int year; + + private String color = "unknown"; + private boolean automatic = false; + private int numDoors = 4; + private String features = ""; + + public CarBuilder(String make, String model, int year) { + this.make = make; + this.model = model; + this.year = year; + } + + public CarBuilder color(String color) { + this.color = color; + return this; + } + + public CarBuilder automatic(boolean automatic) { + this.automatic = automatic; + return this; + } + + public CarBuilder numDoors(int numDoors) { + this.numDoors = numDoors; + return this; + } + + public CarBuilder features(String features) { + this.features = features; + return this; + } + + public Car build() { + return new Car(this); + } + } + + @Override + public String toString() { + return "Car [make=" + make + ", model=" + model + ", year=" + year + ", color=" + color + ", automatic=" + automatic + ", numDoors=" + numDoors + ", features=" + features + "]"; + } + +} diff --git a/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methods/Motorcycle.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methods/Motorcycle.java new file mode 100644 index 0000000000..8a1fce4a5d --- /dev/null +++ b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methods/Motorcycle.java @@ -0,0 +1,52 @@ +package com.baeldung.methods; + +import java.io.Serializable; + +public class Motorcycle extends Vehicle implements Serializable { + + private static final long serialVersionUID = 5973661295933599929L; + + private int year; + private String features = ""; + + public Motorcycle() { + super(); + } + + public Motorcycle(String make, String model, String color, int weight, boolean statusNew, int year) { + super(make, model, color, weight, statusNew); + this.year = year; + } + + public Motorcycle(Vehicle vehicle, int year) { + super(vehicle); + this.year = year; + } + + public int getYear() { + return year; + } + + public void setYear(int year) { + this.year = year; + } + + public void setFeatures(String features) { + this.features = features; + } + + public String getFeatures() { + return features; + } + + public void addMotorcycleFeatures(String... features) { + StringBuilder str = new StringBuilder(this.getFeatures()); + for (String feature : features) { + if (!str.toString().isEmpty()) + str.append(", "); + str.append(feature); + } + this.setFeatures(str.toString()); + } + +} diff --git a/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methods/Vehicle.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methods/Vehicle.java new file mode 100644 index 0000000000..0c6964d255 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methods/Vehicle.java @@ -0,0 +1,33 @@ +package com.baeldung.methods; + +public class Vehicle { + + static String defaultValue = "DEFAULT"; + private String make = defaultValue; + private String model = defaultValue; + private String color = defaultValue; + private int weight = 0; + private boolean statusNew = true; + + public Vehicle() { + super(); + } + + public Vehicle(String make, String model, String color, int weight, boolean statusNew) { + this.make = make; + this.model = model; + this.color = color; + this.weight = weight; + this.statusNew = statusNew; + } + + public Vehicle(Vehicle vehicle) { + this(vehicle.make, vehicle.model, vehicle.color, vehicle.weight, vehicle.statusNew); + } + + @Override + public String toString() { + return "Vehicle [make=" + make + ", model=" + model + ", color=" + color + ", weight=" + weight + ", statusNew=" + statusNew + "]"; + } + +} diff --git a/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methods/VehicleProcessor.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methods/VehicleProcessor.java new file mode 100644 index 0000000000..a7d5975813 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methods/VehicleProcessor.java @@ -0,0 +1,20 @@ +package com.baeldung.methods; + +public class VehicleProcessor { + + Vehicle processVehicle(String make, String model, String color, int weight, boolean status) { + return new Vehicle(make, model, color, weight, status); + } + + Vehicle processVehicle(Vehicle vehicle) { + return new Vehicle(vehicle); + } + + Car processCar(Car car) { + return new Car.CarBuilder(car.getMake(), car.getModel(), car.getYear()).color(car.getColor()) + .automatic(car.isAutomatic()) + .features(car.getFeatures()) + .build(); + } + +} \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/methods/VehicleProcessorUnitTest.java b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/methods/VehicleProcessorUnitTest.java new file mode 100644 index 0000000000..928fbcb426 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/methods/VehicleProcessorUnitTest.java @@ -0,0 +1,58 @@ +package com.baeldung.methods; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; + +class VehicleProcessorUnitTest { + + VehicleProcessor vehicleProcessor = new VehicleProcessor(); + Vehicle vehicle = new Vehicle("Ford", "Focus", "red", 2200, true); + + @Test + void givenAllArguments_whenMethodCall_thenVerifyCallIsDoneCorrectly() { + Vehicle veh = vehicleProcessor.processVehicle("Ford", "Focus", "red", 2200, true); + assertThat(veh.toString()).hasToString(vehicle.toString()); + } + + @Test + void givenParameterObject_whenMethodCall_thenVerifyCallIsDoneCorrectly() { + Vehicle veh = vehicleProcessor.processVehicle(vehicle); + assertThat(veh.toString()).hasToString(vehicle.toString()); + } + + @Test + void givenJavaBeanPattern_whenMethodCall_thenVerifyCallIsDoneCorrectly() { + Motorcycle motorcycle = new Motorcycle("Ducati", "Monster", "yellow", 235, true, 2023); + motorcycle.setFeatures("GPS"); + + vehicleProcessor.processVehicle(motorcycle); + assertThat(motorcycle.getFeatures()).isEqualToIgnoringCase("GPS"); + } + + @Test + void givenJavaVarargs_whenMethodCall_thenAssertTheReturnedConcatenatedString() { + Motorcycle motorcycle = new Motorcycle("Ducati", "Monster", "red", 350, true, 2023); + motorcycle.addMotorcycleFeatures("abs"); + assertThat(motorcycle.getFeatures()).isEqualToIgnoringCase("abs"); + + motorcycle.addMotorcycleFeatures("navi", "charger"); + assertThat(motorcycle.getFeatures()).isEqualToIgnoringCase("abs, navi, charger"); + + motorcycle.addMotorcycleFeatures("wifi", "phone", "satellite"); + assertThat(motorcycle.getFeatures()).isEqualToIgnoringCase("abs, navi, charger, wifi, phone, satellite"); + } + + @Test + void givenJavaBuilderPattern_whenMethodCall_thenVerifyCallIsDoneCorrectly() { + Car car = new Car.CarBuilder("Ford", "Focus", 2023).color("blue") + .automatic(true) + .features("abs, navi, charger, wifi, phone, satellite") + .build(); + + Car result = vehicleProcessor.processCar(car); + + assertThat(result.toString()).hasToString(car.toString()); + } + +} diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/staticclass/Pizza.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticclass/Pizza.java similarity index 100% rename from core-java-modules/core-java/src/main/java/com/baeldung/staticclass/Pizza.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticclass/Pizza.java diff --git a/core-java-modules/core-java-networking-4/README.md b/core-java-modules/core-java-networking-4/README.md index e614801468..10ca7caf41 100644 --- a/core-java-modules/core-java-networking-4/README.md +++ b/core-java-modules/core-java-networking-4/README.md @@ -3,3 +3,4 @@ - [Validating URL in Java](https://www.baeldung.com/java-validate-url) - [Validating IPv4 Address in Java](https://www.baeldung.com/java-validate-ipv4-address) - [Download a Webpage in Java](https://www.baeldung.com/java-download-webpage) +- [URL Query Manipulation in Java](https://www.baeldung.com/java-url-query-manipulation) diff --git a/core-java-modules/core-java-networking/pom.xml b/core-java-modules/core-java-networking/pom.xml index 19c620198d..59aadbd1ed 100644 --- a/core-java-modules/core-java-networking/pom.xml +++ b/core-java-modules/core-java-networking/pom.xml @@ -1,7 +1,7 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 core-java-networking core-java-networking @@ -19,6 +19,11 @@ spring-web ${springframework.spring-web.version} + + org.apache.httpcomponents + httpclient + ${apache.httpclient.version} + @@ -27,6 +32,7 @@ 4.3.4.RELEASE + 4.5.14 \ No newline at end of file diff --git a/core-java-modules/core-java-networking/src/test/java/com/baeldung/networking/url/UrlUnitTest.java b/core-java-modules/core-java-networking/src/test/java/com/baeldung/networking/url/UrlUnitTest.java index 112f2cf53f..87d9d7a620 100644 --- a/core-java-modules/core-java-networking/src/test/java/com/baeldung/networking/url/UrlUnitTest.java +++ b/core-java-modules/core-java-networking/src/test/java/com/baeldung/networking/url/UrlUnitTest.java @@ -1,11 +1,19 @@ package com.baeldung.networking.url; +import static java.util.stream.Collectors.toList; import static org.junit.Assert.assertEquals; import java.net.MalformedURLException; +import java.net.URISyntaxException; import java.net.URL; +import java.util.Map; +import org.apache.http.client.utils.URIBuilder; +import org.apache.http.message.BasicNameValuePair; import org.junit.Test; +import org.springframework.web.util.UriComponentsBuilder; + +import com.google.common.collect.ImmutableMap; public class UrlUnitTest { @@ -101,4 +109,44 @@ public class UrlUnitTest { assertEquals("http://baeldung.com:9000/guidelines.txt", url.toString()); } -} + @Test + public void givenUrlParameters_whenBuildUrlWithURIBuilder_thenSuccess() throws URISyntaxException, MalformedURLException { + URIBuilder uriBuilder = new URIBuilder("http://baeldung.com/articles"); + uriBuilder.setPort(9090); + uriBuilder.addParameter("topic", "java"); + uriBuilder.addParameter("version", "8"); + URL url = uriBuilder.build().toURL(); + assertEquals("http://baeldung.com:9090/articles?topic=java&version=8", url.toString()); + } + + @Test + public void givenUrlParametersInMap_whenBuildUrlWithURIBuilder_thenSuccess() throws URISyntaxException, MalformedURLException { + Map paramMap = ImmutableMap.of("topic", "java", "version", "8"); + URIBuilder uriBuilder = new URIBuilder("http://baeldung.com/articles"); + uriBuilder.setPort(9090); + uriBuilder.addParameters(paramMap.entrySet() + .stream() + .map(entry -> new BasicNameValuePair(entry.getKey(), entry.getValue())) + .collect(toList())); + + URL url = uriBuilder.build().toURL(); + assertEquals("http://baeldung.com:9090/articles?topic=java&version=8", url.toString()); + } + + @Test + public void givenUrlParameters_whenBuildUrlWithSpringUriComponentsBuilder_thenSuccess() throws MalformedURLException { + URL url = UriComponentsBuilder.newInstance() + .scheme("http") + .host("baeldung.com") + .port(9090) + .path("articles") + .queryParam("topic", "java") + .queryParam("version", "8") + .build() + .toUri() + .toURL(); + + assertEquals("http://baeldung.com:9090/articles?topic=java&version=8", url.toString()); + } + +} \ No newline at end of file diff --git a/core-java-modules/core-java-nio-2/README.md b/core-java-modules/core-java-nio-2/README.md index 308356cf8b..527600779a 100644 --- a/core-java-modules/core-java-nio-2/README.md +++ b/core-java-modules/core-java-nio-2/README.md @@ -14,5 +14,4 @@ This module contains articles about core Java non-blocking input and output (IO) - [What Is the Difference Between NIO and NIO.2?](https://www.baeldung.com/java-nio-vs-nio-2) - [Guide to ByteBuffer](https://www.baeldung.com/java-bytebuffer) - [Find Files that Match Wildcard Strings in Java](https://www.baeldung.com/java-files-match-wildcard-strings) -- [Get the Desktop Path in Java](https://www.baeldung.com/java-desktop-path) - [[<-- Prev]](/core-java-modules/core-java-nio) diff --git a/core-java-modules/core-java-numbers-6/README.md b/core-java-modules/core-java-numbers-6/README.md index 4856d86052..97e4e2ca28 100644 --- a/core-java-modules/core-java-numbers-6/README.md +++ b/core-java-modules/core-java-numbers-6/README.md @@ -1,4 +1,4 @@ ### Relevant Articles: - [Java Program to Calculate Pi](https://www.baeldung.com/java-monte-carlo-compute-pi) - -- More articles: [[<-- prev]](../core-java-numbers-5) \ No newline at end of file +- [Convert Integer to Hexadecimal in Java](https://www.baeldung.com/java-convert-int-to-hex) +- More articles: [[<-- prev]](../core-java-numbers-5) diff --git a/core-java-modules/core-java-perf/README.md b/core-java-modules/core-java-perf/README.md index c018ec9927..2f0331f281 100644 --- a/core-java-modules/core-java-perf/README.md +++ b/core-java-modules/core-java-perf/README.md @@ -13,3 +13,4 @@ This module contains articles about performance of Java applications - [Capturing a Java Thread Dump](https://www.baeldung.com/java-thread-dump) - [JMX Ports](https://www.baeldung.com/jmx-ports) - [Calling JMX MBean Method From a Shell Script](https://www.baeldung.com/jmx-mbean-shell-access) +- [External Debugging With JMXTerm](https://www.baeldung.com/java-jmxterm-external-debugging) diff --git a/core-java-modules/core-java-regex-2/README.md b/core-java-modules/core-java-regex-2/README.md index 453e2cc419..f733d7770a 100644 --- a/core-java-modules/core-java-regex-2/README.md +++ b/core-java-modules/core-java-regex-2/README.md @@ -5,4 +5,5 @@ - [Converting Camel Case and Title Case to Words in Java](https://www.baeldung.com/java-camel-case-title-case-to-words) - [How to Use Regular Expressions to Replace Tokens in Strings in Java](https://www.baeldung.com/java-regex-token-replacement) - [Creating a Java Array from Regular Expression Matches](https://www.baeldung.com/java-array-regex-matches) +- [Getting the Text That Follows After the Regex Match in Java](https://www.baeldung.com/java-regex-text-after-match) - More articles: [[<-- prev]](/core-java-modules/core-java-regex) diff --git a/core-java-modules/core-java-regex-2/src/test/java/com/baeldung/regex/aftermatch/GetTextAfterTheRegexMatchUnitTest.java b/core-java-modules/core-java-regex-2/src/test/java/com/baeldung/regex/aftermatch/GetTextAfterTheRegexMatchUnitTest.java new file mode 100644 index 0000000000..04650a0c02 --- /dev/null +++ b/core-java-modules/core-java-regex-2/src/test/java/com/baeldung/regex/aftermatch/GetTextAfterTheRegexMatchUnitTest.java @@ -0,0 +1,83 @@ +package com.baeldung.regex.aftermatch; + +import org.junit.jupiter.api.Test; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class GetTextAfterTheRegexMatchUnitTest { + private static final String INPUT1 = "Some text, targetValue=Regex is cool"; + private static final String INPUT2 = "Some text. targetValue=Java is cool. some other text"; + + @Test + void whenUsingSplit_thenGetExpectedString() { + String result1 = INPUT1.split("targetValue=")[1]; + assertEquals("Regex is cool", result1); + + String afterFirstSplit = INPUT2.split("targetValue=")[1]; + assertEquals("Java is cool. some other text", afterFirstSplit); + String result2 = afterFirstSplit.split("[.]")[0]; + assertEquals("Java is cool", result2); + + // if use the dot as the regex for splitting, the result array is empty + String[] splitByDot = INPUT2.split("targetValue=")[1].split("."); + assertEquals(0, splitByDot.length); + } + + @Test + void whenUsingReplaceAll_thenGetExpectedString() { + String result1 = INPUT1.replaceAll(".*targetValue=", ""); + assertEquals("Regex is cool", result1); + + String afterFirstReplace = INPUT2.replaceAll(".*targetValue=", ""); + assertEquals("Java is cool. some other text", afterFirstReplace); + String result2 = afterFirstReplace.replaceAll("[.].*", ""); + assertEquals("Java is cool", result2); + + } + + @Test + void whenUsingRegexGrouping_thenGetExpectedString() { + Pattern p1 = Pattern.compile("targetValue=(.*)"); + Matcher m1 = p1.matcher(INPUT1); + assertTrue(m1.find()); + String result1 = m1.group(1); + assertEquals("Regex is cool", result1); + + Pattern p2 = Pattern.compile("targetValue=([^.]*)"); + Matcher m2 = p2.matcher(INPUT2); + assertTrue(m2.find()); + String result2 = m2.group(1); + assertEquals("Java is cool", result2); + + Pattern p3 = Pattern.compile("targetValue=(.*?)[.]"); + Matcher m3 = p3.matcher(INPUT2); + assertTrue(m3.find()); + String result3 = m3.group(1); + assertEquals("Java is cool", result3); + } + + @Test + void whenUsingLookaround_thenGetExpectedString() { + Pattern p1 = Pattern.compile("(?<=targetValue=).*"); + Matcher m1 = p1.matcher(INPUT1); + assertTrue(m1.find()); + String result1 = m1.group(); + assertEquals("Regex is cool", result1); + + Pattern p2 = Pattern.compile("(?<=targetValue=)[^.]*"); + Matcher m2 = p2.matcher(INPUT2); + assertTrue(m2.find()); + String result2 = m2.group(); + assertEquals("Java is cool", result2); + + Pattern p3 = Pattern.compile("(?<=targetValue=).*(?=[.])"); + Matcher m3 = p3.matcher(INPUT2); + assertTrue(m3.find()); + String result3 = m3.group(); + assertEquals("Java is cool", result3); + } +} \ No newline at end of file diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/java8/Java8MapAndFlatMap.java b/core-java-modules/core-java-streams-3/src/test/java/com/baeldung/streams/flatmap/map/Java8MapAndFlatMapUnitTest.java similarity index 94% rename from core-java-modules/core-java/src/test/java/com/baeldung/java8/Java8MapAndFlatMap.java rename to core-java-modules/core-java-streams-3/src/test/java/com/baeldung/streams/flatmap/map/Java8MapAndFlatMapUnitTest.java index a0bd1cf093..1b09ea25c6 100644 --- a/core-java-modules/core-java/src/test/java/com/baeldung/java8/Java8MapAndFlatMap.java +++ b/core-java-modules/core-java-streams-3/src/test/java/com/baeldung/streams/flatmap/map/Java8MapAndFlatMapUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.java8; +package com.baeldung.streams.flatmap.map; import org.junit.Test; @@ -12,7 +12,7 @@ import java.util.stream.Stream; import static java.util.Arrays.asList; import static org.junit.Assert.assertEquals; -public class Java8MapAndFlatMap { +public class Java8MapAndFlatMapUnitTest { @Test public void givenStream_whenCalledMap_thenProduceList() { diff --git a/core-java-modules/core-java-streams-4/README.md b/core-java-modules/core-java-streams-4/README.md index 4175fb1f70..c6717ec5fe 100644 --- a/core-java-modules/core-java-streams-4/README.md +++ b/core-java-modules/core-java-streams-4/README.md @@ -10,4 +10,3 @@ - [Understanding the Difference Between Stream.of() and IntStream.range()](https://www.baeldung.com/java-stream-of-and-intstream-range) - [Check if Object Is an Array in Java](https://www.baeldung.com/java-check-if-object-is-an-array) - [Mapping an Array of Integers to Strings Using Java Streams](https://www.baeldung.com/java-stream-integer-array-to-strings) -- [Difference Between parallelStream() and stream().parallel() in Java](https://www.baeldung.com/java-parallelstream-vs-stream-parallel) diff --git a/core-java-modules/core-java-streams-5/README.md b/core-java-modules/core-java-streams-5/README.md new file mode 100644 index 0000000000..4f367799f2 --- /dev/null +++ b/core-java-modules/core-java-streams-5/README.md @@ -0,0 +1 @@ +- [Difference Between parallelStream() and stream().parallel() in Java](https://www.baeldung.com/java-parallelstream-vs-stream-parallel) diff --git a/core-java-modules/core-java-streams-5/pom.xml b/core-java-modules/core-java-streams-5/pom.xml new file mode 100644 index 0000000000..d1f8af6461 --- /dev/null +++ b/core-java-modules/core-java-streams-5/pom.xml @@ -0,0 +1,72 @@ + + + 4.0.0 + core-java-streams-5 + core-java-streams-5 + jar + + + com.baeldung.core-java-modules + core-java-modules + 0.0.1-SNAPSHOT + + + + + log4j + log4j + ${log4j.version} + + + org.junit + junit-bom + ${junit-jupiter.version} + pom + import + + + org.assertj + assertj-core + 3.23.1 + test + + + org.apache.commons + commons-lang3 + 3.12.0 + test + + + + + core-java-streams-4 + + + ../core-java-streams-4/src/main + true + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${maven.compiler.source} + ${maven.compiler.target} + -parameters + + + + + + + + 3.1 + 12 + 12 + + + \ No newline at end of file diff --git a/core-java-modules/core-java-streams-4/src/main/java/com/baeldung/streams/parallelstream/Book.java b/core-java-modules/core-java-streams-5/src/main/java/com/baeldung/streams/parallelstream/Book.java similarity index 99% rename from core-java-modules/core-java-streams-4/src/main/java/com/baeldung/streams/parallelstream/Book.java rename to core-java-modules/core-java-streams-5/src/main/java/com/baeldung/streams/parallelstream/Book.java index 165df55166..d52a31aac9 100644 --- a/core-java-modules/core-java-streams-4/src/main/java/com/baeldung/streams/parallelstream/Book.java +++ b/core-java-modules/core-java-streams-5/src/main/java/com/baeldung/streams/parallelstream/Book.java @@ -34,4 +34,4 @@ public class Book { public void setYearPublished(int yearPublished) { this.yearPublished = yearPublished; } -} +} \ No newline at end of file diff --git a/core-java-modules/core-java-streams-4/src/main/java/com/baeldung/streams/parallelstream/BookSpliterator.java b/core-java-modules/core-java-streams-5/src/main/java/com/baeldung/streams/parallelstream/BookSpliterator.java similarity index 99% rename from core-java-modules/core-java-streams-4/src/main/java/com/baeldung/streams/parallelstream/BookSpliterator.java rename to core-java-modules/core-java-streams-5/src/main/java/com/baeldung/streams/parallelstream/BookSpliterator.java index 14e87e0b07..7460e1372b 100644 --- a/core-java-modules/core-java-streams-4/src/main/java/com/baeldung/streams/parallelstream/BookSpliterator.java +++ b/core-java-modules/core-java-streams-5/src/main/java/com/baeldung/streams/parallelstream/BookSpliterator.java @@ -37,4 +37,4 @@ public class BookSpliterator implements Spliterator { public int characteristics() { return CONCURRENT; } -} +} \ No newline at end of file diff --git a/core-java-modules/core-java-streams-4/src/main/java/com/baeldung/streams/parallelstream/MyBookContainer.java b/core-java-modules/core-java-streams-5/src/main/java/com/baeldung/streams/parallelstream/MyBookContainer.java similarity index 99% rename from core-java-modules/core-java-streams-4/src/main/java/com/baeldung/streams/parallelstream/MyBookContainer.java rename to core-java-modules/core-java-streams-5/src/main/java/com/baeldung/streams/parallelstream/MyBookContainer.java index dc4b0e2623..d7e3adc5f1 100644 --- a/core-java-modules/core-java-streams-4/src/main/java/com/baeldung/streams/parallelstream/MyBookContainer.java +++ b/core-java-modules/core-java-streams-5/src/main/java/com/baeldung/streams/parallelstream/MyBookContainer.java @@ -90,4 +90,4 @@ public class MyBookContainer implements Collection { public void clear() { } -} +} \ No newline at end of file diff --git a/core-java-modules/core-java-streams-4/src/main/java/com/baeldung/streams/parallelstream/ParallelStreamApplication.java b/core-java-modules/core-java-streams-5/src/main/java/com/baeldung/streams/parallelstream/ParallelStreamApplication.java similarity index 99% rename from core-java-modules/core-java-streams-4/src/main/java/com/baeldung/streams/parallelstream/ParallelStreamApplication.java rename to core-java-modules/core-java-streams-5/src/main/java/com/baeldung/streams/parallelstream/ParallelStreamApplication.java index 9cdaf58bfb..4297bdd3ed 100644 --- a/core-java-modules/core-java-streams-4/src/main/java/com/baeldung/streams/parallelstream/ParallelStreamApplication.java +++ b/core-java-modules/core-java-streams-5/src/main/java/com/baeldung/streams/parallelstream/ParallelStreamApplication.java @@ -38,4 +38,4 @@ public class ParallelStreamApplication { }); return countOfBooks.get(); } -} +} \ No newline at end of file diff --git a/core-java-modules/core-java-streams-4/src/test/java/parallelstream/ParallelStreamUnitTest.java b/core-java-modules/core-java-streams-5/src/test/java/com/baeldung/parallelstream/ParallelStreamUnitTest.java similarity index 97% rename from core-java-modules/core-java-streams-4/src/test/java/parallelstream/ParallelStreamUnitTest.java rename to core-java-modules/core-java-streams-5/src/test/java/com/baeldung/parallelstream/ParallelStreamUnitTest.java index 5542a21020..af8172a10d 100644 --- a/core-java-modules/core-java-streams-4/src/test/java/parallelstream/ParallelStreamUnitTest.java +++ b/core-java-modules/core-java-streams-5/src/test/java/com/baeldung/parallelstream/ParallelStreamUnitTest.java @@ -1,6 +1,5 @@ -package parallelstream; +package com.baeldung.parallelstream; -import java.util.ArrayList; import java.util.List; import org.junit.Assert; diff --git a/core-java-modules/core-java-string-algorithms-3/README.md b/core-java-modules/core-java-string-algorithms-3/README.md index d2863be8e5..c9e7e7d7d4 100644 --- a/core-java-modules/core-java-string-algorithms-3/README.md +++ b/core-java-modules/core-java-string-algorithms-3/README.md @@ -10,3 +10,4 @@ This module contains articles about string-related algorithms. - [Check if the First Letter of a String is Uppercase](https://www.baeldung.com/java-check-first-letter-uppercase) - [Find the First Non Repeating Character in a String in Java](https://www.baeldung.com/java-find-the-first-non-repeating-character) - [Find the First Embedded Occurrence of an Integer in a Java String](https://www.baeldung.com/java-string-find-embedded-integer) +- [Find the Most Frequent Characters in a String](https://www.baeldung.com/java-string-find-most-frequent-characters) diff --git a/core-java-modules/core-java-string-algorithms-3/pom.xml b/core-java-modules/core-java-string-algorithms-3/pom.xml index 74a9486ec0..7d4adeba92 100644 --- a/core-java-modules/core-java-string-algorithms-3/pom.xml +++ b/core-java-modules/core-java-string-algorithms-3/pom.xml @@ -39,8 +39,8 @@ maven-compiler-plugin ${maven-compiler-plugin.version} - ${java.version} - ${java.version} + ${maven.compiler.source} + ${maven.compiler.target} -parameters diff --git a/core-java-modules/core-java-string-algorithms-3/src/main/java/com/baeldung/charfreq/CharacterWithHighestFrequency.java b/core-java-modules/core-java-string-algorithms-3/src/main/java/com/baeldung/charfreq/CharacterWithHighestFrequency.java new file mode 100644 index 0000000000..938ad1edf3 --- /dev/null +++ b/core-java-modules/core-java-string-algorithms-3/src/main/java/com/baeldung/charfreq/CharacterWithHighestFrequency.java @@ -0,0 +1,58 @@ +package com.baeldung.charfreq; + +import static java.util.Map.Entry.comparingByValue; +import static java.util.stream.Collectors.counting; +import static java.util.stream.Collectors.groupingBy; +import static java.util.stream.Collectors.toSet; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +public class CharacterWithHighestFrequency { + public static Character byStream(String input) { + return input.chars() + .mapToObj(x -> (char) x) + .collect(groupingBy(x -> x, counting())) + .entrySet() + .stream() + .max(comparingByValue()) + .get() + .getKey(); + } + + public static Set byMap(String input) { + Map map = new HashMap<>(); + for (char c : input.toCharArray()) { + map.compute(c, (character, count) -> count == null ? 1 : ++count); + } + int maxCount = map.values() + .stream() + .mapToInt(Integer::intValue) + .max() + .getAsInt(); + + return map.keySet() + .stream() + .filter(c -> map.get(c) == maxCount) + .collect(toSet()); + } + + public static Set byBucket(String input) { + int[] buckets = new int[128]; + + int maxCount = 0; + for (char c : input.toCharArray()) { + buckets[c]++; + maxCount = Math.max(buckets[c], maxCount); + } + + int finalMaxCount = maxCount; + return IntStream.range(0, 128) + .filter(c -> buckets[c] == finalMaxCount) + .mapToObj(i -> (char) i) + .collect(Collectors.toSet()); + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-string-algorithms-3/src/test/java/com/baeldung/charfreq/CharacterWithHighestFrequencyUnitTest.java b/core-java-modules/core-java-string-algorithms-3/src/test/java/com/baeldung/charfreq/CharacterWithHighestFrequencyUnitTest.java new file mode 100644 index 0000000000..978752f3d4 --- /dev/null +++ b/core-java-modules/core-java-string-algorithms-3/src/test/java/com/baeldung/charfreq/CharacterWithHighestFrequencyUnitTest.java @@ -0,0 +1,43 @@ +package com.baeldung.charfreq; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.Collections; +import java.util.Set; + +import org.junit.jupiter.api.Test; + +import com.google.common.collect.ImmutableSet; + +class CharacterWithHighestFrequencyUnitTest { + private static final String INPUT1 = "aaaaaaaaaa(10) bbbbbbb ccccc dddd eee ff"; + private static final Set EXPECTED1 = Collections.singleton('a'); + + private static final String INPUT2 = "YYYYYYY(7) bbbbb -------(7) dddd eee kkkkkkk(7) ff"; + private static final Set EXPECTED2 = ImmutableSet.of('Y', '-', 'k'); + + @Test + void whenGettingSingleCharWithHighestFrequencyByStream_shouldSuccess() { + char result1 = CharacterWithHighestFrequency.byStream(INPUT1); + assertEquals('a', result1); + } + + @Test + void whenGettingCharWithHighestFrequencyByMap_shouldSuccess() { + Set result1 = CharacterWithHighestFrequency.byMap(INPUT1); + assertEquals(EXPECTED1, result1); + + Set result2 = CharacterWithHighestFrequency.byMap(INPUT2); + assertEquals(EXPECTED2, result2); + + } + + @Test + void whenGettingCharWithHighestFrequencyByBucket_shouldSuccess() { + Set result1 = CharacterWithHighestFrequency.byBucket(INPUT1); + assertEquals(EXPECTED1, result1); + + Set result2 = CharacterWithHighestFrequency.byBucket(INPUT2); + assertEquals(EXPECTED2, result2); + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-string-algorithms/src/main/java/com/baeldung/reverse/ReverseStringExamples.java b/core-java-modules/core-java-string-algorithms/src/main/java/com/baeldung/reverse/ReverseStringExamples.java index 5236f14ccd..07663ab7d1 100644 --- a/core-java-modules/core-java-string-algorithms/src/main/java/com/baeldung/reverse/ReverseStringExamples.java +++ b/core-java-modules/core-java-string-algorithms/src/main/java/com/baeldung/reverse/ReverseStringExamples.java @@ -1,5 +1,9 @@ package com.baeldung.reverse; +import java.util.stream.Collectors; +import java.util.stream.IntStream; +import java.util.stream.Stream; + import org.apache.commons.lang3.StringUtils; public class ReverseStringExamples { @@ -46,11 +50,43 @@ public class ReverseStringExamples { } return output.toString() - .trim(); + .trim(); } public static String reverseTheOrderOfWordsUsingApacheCommons(String sentence) { return StringUtils.reverseDelimited(sentence, ' '); } + public static String reverseUsingIntStreamRangeMethod(String str) { + if (str == null) { + return null; + } + + char[] charArray = str.toCharArray(); + return IntStream.range(0, str.length()) + .mapToObj(i -> charArray[str.length() - i - 1]) + .collect(StringBuilder::new, StringBuilder::append, StringBuilder::append) + .toString(); + } + + public static String reverseUsingStreamOfMethod(String str) { + if (str == null) { + return null; + } + + return Stream.of(str) + .map(string -> new StringBuilder(string).reverse()) + .collect(Collectors.joining()); + } + + public static String reverseUsingCharsMethod(String str) { + if (str == null) { + return null; + } + + return str.chars() + .mapToObj(c -> (char) c) + .reduce("", (a, b) -> b + a, (a2, b2) -> b2 + a2); + } + } diff --git a/core-java-modules/core-java-string-algorithms/src/test/java/com/baeldung/reverse/ReverseStringExamplesUnitTest.java b/core-java-modules/core-java-string-algorithms/src/test/java/com/baeldung/reverse/ReverseStringExamplesUnitTest.java index c122163174..b3685a49da 100644 --- a/core-java-modules/core-java-string-algorithms/src/test/java/com/baeldung/reverse/ReverseStringExamplesUnitTest.java +++ b/core-java-modules/core-java-string-algorithms/src/test/java/com/baeldung/reverse/ReverseStringExamplesUnitTest.java @@ -1,10 +1,11 @@ package com.baeldung.reverse; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + import org.apache.commons.lang3.StringUtils; import org.junit.Test; -import static org.junit.Assert.assertEquals; - public class ReverseStringExamplesUnitTest { private static final String STRING_INPUT = "cat"; @@ -19,7 +20,7 @@ public class ReverseStringExamplesUnitTest { String reversedEmpty = ReverseStringExamples.reverse(StringUtils.EMPTY); assertEquals(STRING_INPUT_REVERSED, reversed); - assertEquals(null, reversedNull); + assertNull(reversedNull); assertEquals(StringUtils.EMPTY, reversedEmpty); } @@ -30,7 +31,7 @@ public class ReverseStringExamplesUnitTest { String reversedEmpty = ReverseStringExamples.reverseUsingStringBuilder(StringUtils.EMPTY); assertEquals(STRING_INPUT_REVERSED, reversed); - assertEquals(null, reversedNull); + assertNull(reversedNull); assertEquals(StringUtils.EMPTY, reversedEmpty); } @@ -41,7 +42,7 @@ public class ReverseStringExamplesUnitTest { String reversedEmpty = ReverseStringExamples.reverseUsingApacheCommons(StringUtils.EMPTY); assertEquals(STRING_INPUT_REVERSED, reversed); - assertEquals(null, reversedNull); + assertNull(reversedNull); assertEquals(StringUtils.EMPTY, reversedEmpty); } @@ -52,7 +53,7 @@ public class ReverseStringExamplesUnitTest { String reversedEmpty = ReverseStringExamples.reverseTheOrderOfWords(StringUtils.EMPTY); assertEquals(REVERSED_WORDS_SENTENCE, reversed); - assertEquals(null, reversedNull); + assertNull(reversedNull); assertEquals(StringUtils.EMPTY, reversedEmpty); } @@ -63,7 +64,40 @@ public class ReverseStringExamplesUnitTest { String reversedEmpty = ReverseStringExamples.reverseTheOrderOfWordsUsingApacheCommons(StringUtils.EMPTY); assertEquals(REVERSED_WORDS_SENTENCE, reversed); - assertEquals(null, reversedNull); + assertNull(reversedNull); + assertEquals(StringUtils.EMPTY, reversedEmpty); + } + + @Test + public void whenReverseStringUsingIntStreamRangeMethod_ThenCorrectStringIsReturned() { + String reversed = ReverseStringExamples.reverseUsingIntStreamRangeMethod(STRING_INPUT); + String reversedNull = ReverseStringExamples.reverseUsingIntStreamRangeMethod(null); + String reversedEmpty = ReverseStringExamples.reverseUsingIntStreamRangeMethod(StringUtils.EMPTY); + + assertEquals(STRING_INPUT_REVERSED, reversed); + assertNull(reversedNull); + assertEquals(StringUtils.EMPTY, reversedEmpty); + } + + @Test + public void whenReverseStringUsingCharsMethod_ThenCorrectStringIsReturned() { + String reversed = ReverseStringExamples.reverseUsingCharsMethod(STRING_INPUT); + String reversedNull = ReverseStringExamples.reverseUsingCharsMethod(null); + String reversedEmpty = ReverseStringExamples.reverseUsingCharsMethod(StringUtils.EMPTY); + + assertEquals(STRING_INPUT_REVERSED, reversed); + assertNull(reversedNull); + assertEquals(StringUtils.EMPTY, reversedEmpty); + } + + @Test + public void whenReverseStringUsingStreamOfMethod_ThenCorrectStringIsReturned() { + String reversed = ReverseStringExamples.reverseUsingStreamOfMethod(STRING_INPUT); + String reversedNull = ReverseStringExamples.reverseUsingStreamOfMethod(null); + String reversedEmpty = ReverseStringExamples.reverseUsingStreamOfMethod(StringUtils.EMPTY); + + assertEquals(STRING_INPUT_REVERSED, reversed); + assertNull(reversedNull); assertEquals(StringUtils.EMPTY, reversedEmpty); } diff --git a/core-java-modules/core-java-string-operations-5/src/main/java/com/baeldung/firstchardigit/FirstCharDigit.java b/core-java-modules/core-java-string-operations-5/src/main/java/com/baeldung/firstchardigit/FirstCharDigit.java new file mode 100644 index 0000000000..a43127af1a --- /dev/null +++ b/core-java-modules/core-java-string-operations-5/src/main/java/com/baeldung/firstchardigit/FirstCharDigit.java @@ -0,0 +1,62 @@ +package com.baeldung.firstchardigit; + +import java.util.regex.Pattern; + +import com.google.common.base.CharMatcher; + +public class FirstCharDigit { + + public static boolean checkUsingCharAtMethod(String str) { + if (str == null || str.length() == 0) { + return false; + } + + char c = str.charAt(0); + return c >= '0' && c <= '9'; + } + + public static boolean checkUsingIsDigitMethod(String str) { + if (str == null || str.length() == 0) { + return false; + } + + return Character.isDigit(str.charAt(0)); + } + + public static boolean checkUsingPatternClass(String str) { + if (str == null || str.length() == 0) { + return false; + } + + return Pattern.compile("^[0-9].*") + .matcher(str) + .matches(); + } + + public static boolean checkUsingMatchesMethod(String str) { + if (str == null || str.length() == 0) { + return false; + } + + return str.matches("^[0-9].*"); + } + + public static boolean checkUsingCharMatcherInRangeMethod(String str) { + if (str == null || str.length() == 0) { + return false; + } + + return CharMatcher.inRange('0', '9') + .matches(str.charAt(0)); + } + + public static boolean checkUsingCharMatcherForPredicateMethod(String str) { + if (str == null || str.length() == 0) { + return false; + } + + return CharMatcher.forPredicate(Character::isDigit) + .matches(str.charAt(0)); + } + +} diff --git a/core-java-modules/core-java-string-operations-5/src/test/java/com/baeldung/firstchardigit/FirstCharDigitUnitTest.java b/core-java-modules/core-java-string-operations-5/src/test/java/com/baeldung/firstchardigit/FirstCharDigitUnitTest.java new file mode 100644 index 0000000000..0095ebcaf3 --- /dev/null +++ b/core-java-modules/core-java-string-operations-5/src/test/java/com/baeldung/firstchardigit/FirstCharDigitUnitTest.java @@ -0,0 +1,58 @@ +package com.baeldung.firstchardigit; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; + +class FirstCharDigitUnitTest { + + @Test + void givenString_whenUsingCharAtMethod_thenSuccess() { + assertTrue(FirstCharDigit.checkUsingCharAtMethod("12 years")); + assertFalse(FirstCharDigit.checkUsingCharAtMethod("years")); + assertFalse(FirstCharDigit.checkUsingCharAtMethod("")); + assertFalse(FirstCharDigit.checkUsingCharAtMethod(null)); + } + + @Test + void givenString_whenUsingIsDigitMethod_thenSuccess() { + assertTrue(FirstCharDigit.checkUsingIsDigitMethod("10 cm")); + assertFalse(FirstCharDigit.checkUsingIsDigitMethod("cm")); + assertFalse(FirstCharDigit.checkUsingIsDigitMethod("")); + assertFalse(FirstCharDigit.checkUsingIsDigitMethod(null)); + } + + @Test + void givenString_whenUsingPatternClass_thenSuccess() { + assertTrue(FirstCharDigit.checkUsingPatternClass("1 kg")); + assertFalse(FirstCharDigit.checkUsingPatternClass("kg")); + assertFalse(FirstCharDigit.checkUsingPatternClass("")); + assertFalse(FirstCharDigit.checkUsingPatternClass(null)); + } + + @Test + void givenString_whenUsingMatchesMethod_thenSuccess() { + assertTrue(FirstCharDigit.checkUsingMatchesMethod("123")); + assertFalse(FirstCharDigit.checkUsingMatchesMethod("ABC")); + assertFalse(FirstCharDigit.checkUsingMatchesMethod("")); + assertFalse(FirstCharDigit.checkUsingMatchesMethod(null)); + } + + @Test + void givenString_whenUsingCharMatcherInRangeMethod_thenSuccess() { + assertTrue(FirstCharDigit.checkUsingCharMatcherInRangeMethod("2023")); + assertFalse(FirstCharDigit.checkUsingCharMatcherInRangeMethod("abc")); + assertFalse(FirstCharDigit.checkUsingCharMatcherInRangeMethod("")); + assertFalse(FirstCharDigit.checkUsingCharMatcherInRangeMethod(null)); + } + + @Test + void givenString_whenUsingCharMatcherForPredicateMethod_thenSuccess() { + assertTrue(FirstCharDigit.checkUsingCharMatcherForPredicateMethod("100")); + assertFalse(FirstCharDigit.checkUsingCharMatcherForPredicateMethod("abdo")); + assertFalse(FirstCharDigit.checkUsingCharMatcherForPredicateMethod("")); + assertFalse(FirstCharDigit.checkUsingCharMatcherForPredicateMethod(null)); + } + +} diff --git a/core-java-modules/core-java-string-operations-5/src/test/java/com/baeldung/stringwithquotes/PrintQuotesAroundAStringUnitTest.java b/core-java-modules/core-java-string-operations-5/src/test/java/com/baeldung/stringwithquotes/PrintQuotesAroundAStringUnitTest.java new file mode 100644 index 0000000000..fd4ade1ef3 --- /dev/null +++ b/core-java-modules/core-java-string-operations-5/src/test/java/com/baeldung/stringwithquotes/PrintQuotesAroundAStringUnitTest.java @@ -0,0 +1,60 @@ +package com.baeldung.stringwithquotes; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class PrintQuotesAroundAStringUnitTest { + private final ByteArrayOutputStream outContent = new ByteArrayOutputStream(); + private final PrintStream originalOut = System.out; + + @BeforeEach + void replaceOut() { + System.setOut(new PrintStream(outContent)); + } + + @AfterEach + void restoreOut() { + System.setOut(originalOut); + } + + @Test + void whenWrappingAStringWithEscapedQuote_thenGetExpectedResult() { + String theySay = "All Java programmers are cute!"; + String quoted = "\"" + theySay + "\""; + + System.out.println(quoted); + + //assertion + String expected = "\"All Java programmers are cute!\"\n"; + assertEquals(expected, outContent.toString()); + } + + @Test + void whenCallingReplaceAll_thenGetExpectedResult() { + String theySay = "Can you write Java code?"; + String quoted = theySay.replaceAll("^|$", "\""); + + System.out.println(quoted); + + //assertion + String expected = "\"Can you write Java code?\"\n"; + assertEquals(expected, outContent.toString()); + } + + @Test + void whenWrappingAStringWithQuoteChar_thenGetExpectedResult() { + String weSay = "Yes, we can write beautiful Java codes!"; + String quoted = '"' + weSay + '"'; + System.out.println(quoted); + + //assertion + String expected = "\"Yes, we can write beautiful Java codes!\"\n"; + assertEquals(expected, outContent.toString()); + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-strings/README.md b/core-java-modules/core-java-strings/README.md index 835e9ec582..84cf31e8bd 100644 --- a/core-java-modules/core-java-strings/README.md +++ b/core-java-modules/core-java-strings/README.md @@ -13,3 +13,4 @@ This module contains articles about strings in Java. - [Java Multi-line String](https://www.baeldung.com/java-multiline-string) - [Guide to Java String Pool](https://www.baeldung.com/java-string-pool) - [Fixing “constant string too long” Build Error](https://www.baeldung.com/java-constant-string-too-long-error) +- [Reuse StringBuilder for Efficiency](https://www.baeldung.com/java-reuse-stringbuilder-for-efficiency) diff --git a/core-java-modules/core-java-uuid/README.md b/core-java-modules/core-java-uuid/README.md index 4438c9a770..bd7bd9d9da 100644 --- a/core-java-modules/core-java-uuid/README.md +++ b/core-java-modules/core-java-uuid/README.md @@ -5,3 +5,4 @@ - [Guide to UUID in Java](http://www.baeldung.com/java-uuid) - [Validate UUID String in Java](https://www.baeldung.com/java-validate-uuid-string) - [Generate the Same UUID From a String in Java](https://www.baeldung.com/java-generate-same-uuid-from-string) +- [Generating Time Based UUIDs](https://www.baeldung.com/java-generating-time-based-uuids) diff --git a/core-java-modules/core-java/.gitignore b/core-java-modules/core-java/.gitignore deleted file mode 100644 index 374c8bf907..0000000000 --- a/core-java-modules/core-java/.gitignore +++ /dev/null @@ -1,25 +0,0 @@ -*.class - -0.* - -#folders# -/target -/neoDb* -/data -/src/main/webapp/WEB-INF/classes -*/META-INF/* -.resourceCache - -# Packaged files # -*.jar -*.war -*.ear - -# Files generated by integration tests -backup-pom.xml -/bin/ -/temp - -#IntelliJ specific -.idea/ -*.iml \ No newline at end of file diff --git a/core-java-modules/core-java/README.md b/core-java-modules/core-java/README.md deleted file mode 100644 index 287e510c1e..0000000000 --- a/core-java-modules/core-java/README.md +++ /dev/null @@ -1,5 +0,0 @@ -## Core Java Cookbooks and Examples - -### Relevant Articles: - -- [Java Money and the Currency API](http://www.baeldung.com/java-money-and-currency) diff --git a/core-java-modules/core-java/customers.xml b/core-java-modules/core-java/customers.xml deleted file mode 100644 index b52dc27633..0000000000 --- a/core-java-modules/core-java/customers.xml +++ /dev/null @@ -1,95 +0,0 @@ - - - - SELECT * FROM customers - 1008 - - true - 1000 - 0 - 2 - - - - - 0 - 0 - 0 - true - ResultSet.TYPE_SCROLL_INSENSITIVE - false - customers - jdbc:h2:mem:testdb - - com.sun.rowset.providers.RIOptimisticProvider - Oracle Corporation - 1.0 - 2 - 1 - - - - 2 - - 1 - false - true - false - 0 - true - true - 11 - ID - ID - PUBLIC - 10 - 0 - CUSTOMERS - TESTDB - 4 - INTEGER - - - 2 - false - true - false - 0 - true - true - 50 - NAME - NAME - PUBLIC - 50 - 0 - CUSTOMERS - TESTDB - 12 - VARCHAR - - - - - 1 - Customer1 - - - 2 - Customer2 - - - 3 - Customer3 - - - 4 - Customer4 - - - 5 - Customer5 - - - diff --git a/core-java-modules/core-java/externalizable.txt b/core-java-modules/core-java/externalizable.txt deleted file mode 100644 index ddd3e143a8..0000000000 Binary files a/core-java-modules/core-java/externalizable.txt and /dev/null differ diff --git a/core-java-modules/core-java/pom.xml b/core-java-modules/core-java/pom.xml deleted file mode 100644 index 423487d5da..0000000000 --- a/core-java-modules/core-java/pom.xml +++ /dev/null @@ -1,180 +0,0 @@ - - - 4.0.0 - core-java - core-java - jar - - - com.baeldung.core-java-modules - core-java-modules - 0.0.1-SNAPSHOT - - - - - org.unix4j - unix4j-command - ${unix4j.version} - - - com.googlecode.grep4j - grep4j - ${grep4j.version} - - - - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - - - - log4j - log4j - ${log4j.version} - - - org.slf4j - log4j-over-slf4j - ${org.slf4j.version} - - - org.projectlombok - lombok - ${lombok.version} - provided - - - org.javamoney - moneta - ${javamoney.moneta.version} - - - org.springframework - spring-core - ${spring.core.version} - - - commons-io - commons-io - ${commons-io.version} - - - - - core-java - - - src/main/resources - true - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-dependencies - prepare-package - - copy-dependencies - - - ${project.build.directory}/libs - - - - - - org.codehaus.mojo - exec-maven-plugin - - java - com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed - - -Xmx300m - -XX:+UseParallelGC - -classpath - - com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed - - - - - - - - - integration - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration-test - - test - - - - **/*ManualTest.java - - - **/*IntegrationTest.java - **/*IntTest.java - - - - - - - json - - - - - org.codehaus.mojo - exec-maven-plugin - - - run-benchmarks - - none - - exec - - - test - java - - -classpath - - org.openjdk.jmh.Main - .* - - - - - - - - - - - - - 0.4 - 1.8.7 - - 1.1 - 4.3.20.RELEASE - - - \ No newline at end of file diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/.gitignore b/core-java-modules/core-java/src/main/java/com/baeldung/.gitignore deleted file mode 100644 index 83c05e60c8..0000000000 --- a/core-java-modules/core-java/src/main/java/com/baeldung/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -*.class - -#folders# -/target -/neoDb* -/data -/src/main/webapp/WEB-INF/classes -*/META-INF/* - -# Packaged files # -*.jar -*.war -*.ear \ No newline at end of file diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/executable/ExecutableMavenJar.java b/core-java-modules/core-java/src/main/java/com/baeldung/executable/ExecutableMavenJar.java deleted file mode 100644 index 6c79e89717..0000000000 --- a/core-java-modules/core-java/src/main/java/com/baeldung/executable/ExecutableMavenJar.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.baeldung.executable; - -import javax.swing.JOptionPane; - -public class ExecutableMavenJar { - - public static void main(String[] args) { - JOptionPane.showMessageDialog(null, "It worked!", "Executable Jar with Maven", 1); - } - -} diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/filesystem/jndi/LookupFSJNDI.java b/core-java-modules/core-java/src/main/java/com/baeldung/filesystem/jndi/LookupFSJNDI.java deleted file mode 100644 index 7e6bb5d3b2..0000000000 --- a/core-java-modules/core-java/src/main/java/com/baeldung/filesystem/jndi/LookupFSJNDI.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.baeldung.filesystem.jndi; - -import java.io.File; -import java.util.Hashtable; - -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.naming.NamingException; - -public class LookupFSJNDI { - private InitialContext ctx = null; - - public LookupFSJNDI() throws NamingException { - super(); - init(); - } - - private void init() throws NamingException { - Hashtable env = new Hashtable(); - - env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory"); - // URI to namespace (actual directory) - env.put(Context.PROVIDER_URL, "file:./src/test/resources"); - - ctx = new InitialContext(env); - } - - public InitialContext getCtx() { - return ctx; - } - - public File getFile(String fileName) { - File file; - try { - file = (File) getCtx().lookup(fileName); - } catch (NamingException e) { - file = null; - } - return file; - } - -} diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/jsonposturlconnection/PostJSONWithHttpURLConnection.java b/core-java-modules/core-java/src/main/java/com/baeldung/jsonposturlconnection/PostJSONWithHttpURLConnection.java deleted file mode 100644 index b2469ac984..0000000000 --- a/core-java-modules/core-java/src/main/java/com/baeldung/jsonposturlconnection/PostJSONWithHttpURLConnection.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.baeldung.jsonposturlconnection; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.net.URL; - -public class PostJSONWithHttpURLConnection { - - public static void main (String []args) throws IOException{ - //Change the URL with any other publicly accessible POST resource, which accepts JSON request body - URL url = new URL ("https://reqres.in/api/users"); - - HttpURLConnection con = (HttpURLConnection)url.openConnection(); - con.setRequestMethod("POST"); - - con.setRequestProperty("Content-Type", "application/json; utf-8"); - con.setRequestProperty("Accept", "application/json"); - - con.setDoOutput(true); - - //JSON String need to be constructed for the specific resource. - //We may construct complex JSON using any third-party JSON libraries such as jackson or org.json - String jsonInputString = "{\"name\": \"Upendra\", \"job\": \"Programmer\"}"; - - try(OutputStream os = con.getOutputStream()){ - byte[] input = jsonInputString.getBytes("utf-8"); - os.write(input, 0, input.length); - } - - int code = con.getResponseCode(); - System.out.println(code); - - try(BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream(), "utf-8"))){ - StringBuilder response = new StringBuilder(); - String responseLine = null; - while ((responseLine = br.readLine()) != null) { - response.append(responseLine.trim()); - } - System.out.println(response.toString()); - } - } - -} diff --git a/core-java-modules/core-java/src/main/java/log4j.properties b/core-java-modules/core-java/src/main/java/log4j.properties deleted file mode 100644 index 5fe42d854c..0000000000 --- a/core-java-modules/core-java/src/main/java/log4j.properties +++ /dev/null @@ -1,9 +0,0 @@ -# Set root logger level to DEBUG and its only appender to A1. -log4j.rootLogger=DEBUG, A1 - -# A1 is set to be a ConsoleAppender. -log4j.appender.A1=org.apache.log4j.ConsoleAppender - -# A1 uses PatternLayout. -log4j.appender.A1.layout=org.apache.log4j.PatternLayout -log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n diff --git a/core-java-modules/core-java/src/main/resources/META-INF/BenchmarkList b/core-java-modules/core-java/src/main/resources/META-INF/BenchmarkList deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/core-java-modules/core-java/src/main/resources/META-INF/MANIFEST.MF b/core-java-modules/core-java/src/main/resources/META-INF/MANIFEST.MF deleted file mode 100644 index 988de3193d..0000000000 --- a/core-java-modules/core-java/src/main/resources/META-INF/MANIFEST.MF +++ /dev/null @@ -1,5 +0,0 @@ -Agent-Class: com.baeldung.instrumentation.agent.MyInstrumentationAgent -Can-Redefine-Classes: true -Can-Retransform-Classes: true -Premain-Class: com.baeldung.instrumentation.agent.MyInstrumentationAgent -Main-Class: com.baeldung.instrumentation.application.Launcher diff --git a/core-java-modules/core-java/src/main/resources/META-INF/persistence.xml b/core-java-modules/core-java/src/main/resources/META-INF/persistence.xml deleted file mode 100644 index 3966afdcda..0000000000 --- a/core-java-modules/core-java/src/main/resources/META-INF/persistence.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/core-java-modules/core-java/src/main/resources/countries.properties b/core-java-modules/core-java/src/main/resources/countries.properties deleted file mode 100644 index 50b5e85653..0000000000 --- a/core-java-modules/core-java/src/main/resources/countries.properties +++ /dev/null @@ -1,3 +0,0 @@ -UK -US -Germany \ No newline at end of file diff --git a/core-java-modules/core-java/src/main/resources/datasource.properties b/core-java-modules/core-java/src/main/resources/datasource.properties deleted file mode 100644 index 61df0d45f7..0000000000 --- a/core-java-modules/core-java/src/main/resources/datasource.properties +++ /dev/null @@ -1,6 +0,0 @@ -dataSourceClassName=//TBD -dataSource.user=//TBD -dataSource.password=//TBD -dataSource.databaseName=//TBD -dataSource.portNumber=//TBD -dataSource.serverName=//TBD \ No newline at end of file diff --git a/core-java-modules/core-java/src/main/resources/log4j.properties b/core-java-modules/core-java/src/main/resources/log4j.properties deleted file mode 100644 index 621cf01735..0000000000 --- a/core-java-modules/core-java/src/main/resources/log4j.properties +++ /dev/null @@ -1,6 +0,0 @@ -log4j.rootLogger=DEBUG, A1 - -log4j.appender.A1=org.apache.log4j.ConsoleAppender - -log4j.appender.A1.layout=org.apache.log4j.PatternLayout -log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n \ No newline at end of file diff --git a/core-java-modules/core-java/src/main/resources/log4j2.xml b/core-java-modules/core-java/src/main/resources/log4j2.xml deleted file mode 100644 index a824bef9b0..0000000000 --- a/core-java-modules/core-java/src/main/resources/log4j2.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/core-java-modules/core-java/src/main/resources/log4jstructuraldp.properties b/core-java-modules/core-java/src/main/resources/log4jstructuraldp.properties deleted file mode 100644 index 5bc2bfe4b9..0000000000 --- a/core-java-modules/core-java/src/main/resources/log4jstructuraldp.properties +++ /dev/null @@ -1,9 +0,0 @@ - -# Root logger -log4j.rootLogger=INFO, file, stdout - -# Write to console -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.Target=System.out -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n \ No newline at end of file diff --git a/core-java-modules/core-java/src/main/resources/logback.xml b/core-java-modules/core-java/src/main/resources/logback.xml deleted file mode 100644 index 56af2d397e..0000000000 --- a/core-java-modules/core-java/src/main/resources/logback.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - - - - - - - \ No newline at end of file diff --git a/core-java-modules/core-java/src/main/resources/product.png b/core-java-modules/core-java/src/main/resources/product.png deleted file mode 100644 index 4edd01c0a1..0000000000 Binary files a/core-java-modules/core-java/src/main/resources/product.png and /dev/null differ diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/arrays/ArraysJoinAndSplitJUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/arrays/ArraysJoinAndSplitJUnitTest.java deleted file mode 100644 index b31a829f34..0000000000 --- a/core-java-modules/core-java/src/test/java/com/baeldung/arrays/ArraysJoinAndSplitJUnitTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.baeldung.arrays; - -import java.util.Arrays; - -import org.junit.Assert; -import org.junit.Test; - -public class ArraysJoinAndSplitJUnitTest { - - private final String[] sauces = { "Marinara", "Olive Oil" }; - private final String[] cheeses = { "Mozzarella", "Feta", "Parmesan" }; - private final String[] vegetables = { "Olives", "Spinach", "Green Peppers" }; - - private final String[] customers = { "Jay", "Harry", "Ronnie", "Gary", "Ross" }; - - @Test - public void givenThreeStringArrays_whenJoiningIntoOneStringArray_shouldSucceed() { - String[] toppings = new String[sauces.length + cheeses.length + vegetables.length]; - - System.arraycopy(sauces, 0, toppings, 0, sauces.length); - int AddedSoFar = sauces.length; - - System.arraycopy(cheeses, 0, toppings, AddedSoFar, cheeses.length); - AddedSoFar += cheeses.length; - - System.arraycopy(vegetables, 0, toppings, AddedSoFar, vegetables.length); - - Assert.assertArrayEquals(toppings, new String[] { "Marinara", "Olive Oil", "Mozzarella", "Feta", "Parmesan", "Olives", "Spinach", "Green Peppers" }); - } - - @Test - public void givenOneStringArray_whenSplittingInHalfTwoStringArrays_shouldSucceed() { - int ordersHalved = (customers.length / 2) + (customers.length % 2); - - String[] driverOne = Arrays.copyOf(customers, ordersHalved); - String[] driverTwo = Arrays.copyOfRange(customers, ordersHalved, customers.length); - - Assert.assertArrayEquals(driverOne, new String[] { "Jay", "Harry", "Ronnie" }); - Assert.assertArrayEquals(driverTwo, new String[] { "Gary", "Ross" }); - } -} diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/stringisnumeric.zip b/core-java-modules/core-java/src/test/java/com/baeldung/stringisnumeric.zip deleted file mode 100644 index b8a7b9b35a..0000000000 Binary files a/core-java-modules/core-java/src/test/java/com/baeldung/stringisnumeric.zip and /dev/null differ diff --git a/core-java-modules/core-java/src/test/resources/.gitignore b/core-java-modules/core-java/src/test/resources/.gitignore deleted file mode 100644 index 83c05e60c8..0000000000 --- a/core-java-modules/core-java/src/test/resources/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -*.class - -#folders# -/target -/neoDb* -/data -/src/main/webapp/WEB-INF/classes -*/META-INF/* - -# Packaged files # -*.jar -*.war -*.ear \ No newline at end of file diff --git a/core-java-modules/core-java/src/test/resources/newFile1.txt b/core-java-modules/core-java/src/test/resources/newFile1.txt deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/core-java-modules/core-java/src/test/resources/newFile2.txt b/core-java-modules/core-java/src/test/resources/newFile2.txt deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/core-java-modules/core-java/src/test/resources/newFile3.txt b/core-java-modules/core-java/src/test/resources/newFile3.txt deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/core-java-modules/core-java/src/test/resources/original.txt b/core-java-modules/core-java/src/test/resources/original.txt deleted file mode 100644 index 8511f56bef..0000000000 --- a/core-java-modules/core-java/src/test/resources/original.txt +++ /dev/null @@ -1,2 +0,0 @@ -#Copy a File with Java (www.Baeldung.com) -Copying Files with Java is Fun! \ No newline at end of file diff --git a/core-java-modules/core-java/src/test/resources/sourceFile.txt b/core-java-modules/core-java/src/test/resources/sourceFile.txt deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/core-java-modules/core-java/src/test/resources/test.find b/core-java-modules/core-java/src/test/resources/test.find deleted file mode 100644 index 0cb7d51df1..0000000000 --- a/core-java-modules/core-java/src/test/resources/test.find +++ /dev/null @@ -1 +0,0 @@ -Test of JNDI on file. \ No newline at end of file diff --git a/core-java-modules/core-java/src/test/resources/test_read.in b/core-java-modules/core-java/src/test/resources/test_read.in deleted file mode 100644 index 70c379b63f..0000000000 --- a/core-java-modules/core-java/src/test/resources/test_read.in +++ /dev/null @@ -1 +0,0 @@ -Hello world \ No newline at end of file diff --git a/core-java-modules/core-java/src/test/resources/test_read1.in b/core-java-modules/core-java/src/test/resources/test_read1.in deleted file mode 100644 index 1e46242993..0000000000 --- a/core-java-modules/core-java/src/test/resources/test_read1.in +++ /dev/null @@ -1 +0,0 @@ -Hello world 1 \ No newline at end of file diff --git a/core-java-modules/core-java/src/test/resources/test_read2.in b/core-java-modules/core-java/src/test/resources/test_read2.in deleted file mode 100644 index fe47dc003b..0000000000 --- a/core-java-modules/core-java/src/test/resources/test_read2.in +++ /dev/null @@ -1 +0,0 @@ -2,3 4 \ No newline at end of file diff --git a/core-java-modules/core-java/src/test/resources/test_read3.in b/core-java-modules/core-java/src/test/resources/test_read3.in deleted file mode 100644 index db9f25a672..0000000000 --- a/core-java-modules/core-java/src/test/resources/test_read3.in +++ /dev/null @@ -1 +0,0 @@ -Hello 1 \ No newline at end of file diff --git a/core-java-modules/core-java/src/test/resources/test_read4.in b/core-java-modules/core-java/src/test/resources/test_read4.in deleted file mode 100644 index 5727d54bfc..0000000000 Binary files a/core-java-modules/core-java/src/test/resources/test_read4.in and /dev/null differ diff --git a/core-java-modules/core-java/src/test/resources/test_read7.in b/core-java-modules/core-java/src/test/resources/test_read7.in deleted file mode 100644 index 28d4d45d43..0000000000 --- a/core-java-modules/core-java/src/test/resources/test_read7.in +++ /dev/null @@ -1 +0,0 @@ -青空 \ No newline at end of file diff --git a/core-java-modules/core-java/src/test/resources/test_read8.in b/core-java-modules/core-java/src/test/resources/test_read8.in deleted file mode 100644 index 10fc1aac8a..0000000000 --- a/core-java-modules/core-java/src/test/resources/test_read8.in +++ /dev/null @@ -1,2 +0,0 @@ -Hello world - Test line diff --git a/core-java-modules/core-java/src/test/resources/test_read_d.in b/core-java-modules/core-java/src/test/resources/test_read_d.in deleted file mode 100644 index 82bbb4071f..0000000000 --- a/core-java-modules/core-java/src/test/resources/test_read_d.in +++ /dev/null @@ -1 +0,0 @@ -John,Adam-Tom \ No newline at end of file diff --git a/core-java-modules/core-java/src/test/resources/test_read_multiple.in b/core-java-modules/core-java/src/test/resources/test_read_multiple.in deleted file mode 100644 index 7d64000a76..0000000000 --- a/core-java-modules/core-java/src/test/resources/test_read_multiple.in +++ /dev/null @@ -1,2 +0,0 @@ -Hello world -Hi, John \ No newline at end of file diff --git a/core-java-modules/core-java/yofile.txt b/core-java-modules/core-java/yofile.txt deleted file mode 100644 index ad56bf35f7..0000000000 Binary files a/core-java-modules/core-java/yofile.txt and /dev/null differ diff --git a/core-java-modules/core-java/yofile2.txt b/core-java-modules/core-java/yofile2.txt deleted file mode 100644 index 8393b6e98b..0000000000 Binary files a/core-java-modules/core-java/yofile2.txt and /dev/null differ diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index fc7597e85a..6f3aec8c3a 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -17,7 +17,6 @@ - diff --git a/gradle-modules/gradle-customization/protobuf/README.md b/gradle-modules/gradle-customization/protobuf/README.md new file mode 100644 index 0000000000..4e94aa3557 --- /dev/null +++ b/gradle-modules/gradle-customization/protobuf/README.md @@ -0,0 +1,2 @@ +## Relevant Articles +- [Configuring Protobuf Compilation with Custom Source Directories](https://www.baeldung.com/java-configure-protobuf-compilation-custom-source-directories) diff --git a/httpclient-simple/src/test/java/com/baeldung/httpclient/HttpClientHeadersLiveTest.java b/httpclient-simple/src/test/java/com/baeldung/httpclient/HttpClientHeadersLiveTest.java index 616b6470af..3992fd821e 100644 --- a/httpclient-simple/src/test/java/com/baeldung/httpclient/HttpClientHeadersLiveTest.java +++ b/httpclient-simple/src/test/java/com/baeldung/httpclient/HttpClientHeadersLiveTest.java @@ -25,26 +25,22 @@ class HttpClientHeadersLiveTest { @Test void whenClientUsesCustomUserAgent_thenCorrect() throws IOException { + final CloseableHttpClient client = HttpClients.custom() + .setUserAgent("Mozilla/5.0 Firefox/26.0") + .build(); final HttpGet request = new HttpGet(SAMPLE_URL); - try (CloseableHttpClient client = HttpClients.custom() - .setUserAgent("Mozilla/5.0 Firefox/26.0") - .build()) { - - String response = client.execute(request, new BasicHttpClientResponseHandler()); - logger.info("Response -> {}", response); - } + String response = client.execute(request, new BasicHttpClientResponseHandler()); + logger.info("Response -> {}", response); } @Test void whenRequestHasCustomUserAgent_thenCorrect() throws IOException { + CloseableHttpClient client = HttpClients.createDefault(); final HttpGet request = new HttpGet(SAMPLE_URL); request.setHeader(HttpHeaders.USER_AGENT, "Mozilla/5.0 Firefox/26.0"); - - try (CloseableHttpClient client = HttpClients.createDefault()) { - String response = client.execute(request, new BasicHttpClientResponseHandler()); - logger.info("Response -> {}", response); - } + String response = client.execute(request, new BasicHttpClientResponseHandler()); + logger.info("Response -> {}", response); } @Test diff --git a/jackson-modules/jackson-exceptions/README.md b/jackson-modules/jackson-exceptions/README.md index 6f082aaaa5..b9c43cb09f 100644 --- a/jackson-modules/jackson-exceptions/README.md +++ b/jackson-modules/jackson-exceptions/README.md @@ -5,3 +5,4 @@ This module contains articles about Jackson exceptions. ### Relevant Articles: - [Jackson Exceptions – Problems and Solutions](https://www.baeldung.com/jackson-exception) - [Jackson – JsonMappingException (No serializer found for class)](https://www.baeldung.com/jackson-jsonmappingexception) +- [Fix the JsonMappingException: Can not deserialize instance of java.util.ArrayList from Object value (token `JsonToken.START_OBJECT`)](https://www.baeldung.com/jsonmappingexception-can-not-deserialize-instance-of-java-util-arraylist-from-object-value-token-jsontoken-start_object) diff --git a/jackson-simple/pom.xml b/jackson-simple/pom.xml index 6569324586..d1fcc867cf 100644 --- a/jackson-simple/pom.xml +++ b/jackson-simple/pom.xml @@ -32,4 +32,8 @@ + + 2.14.2 + + \ No newline at end of file diff --git a/java-jdi/pom.xml b/java-jdi/pom.xml index b4c11c1bfe..dded13896f 100644 --- a/java-jdi/pom.xml +++ b/java-jdi/pom.xml @@ -15,13 +15,7 @@ - - com.sun - tools - ${tools.version} - system - ${java.home}/../lib/tools.jar - + @@ -32,10 +26,25 @@ true + + + org.apache.maven.plugins + maven-compiler-plugin + + ${maven.compiler.source.version} + ${maven.compiler.target.version} + + --add-exports=jdk.jdi/com.sun.jdi=ALL-UNNAMED + + + + + - 1.8 + 17 + 17 \ No newline at end of file diff --git a/javaxval-2/README.md b/javaxval-2/README.md index 52c9b42ac4..0fd5ce163b 100644 --- a/javaxval-2/README.md +++ b/javaxval-2/README.md @@ -4,7 +4,6 @@ This module contains articles about Bean Validation. ### Relevant Articles: - [Method Constraints with Bean Validation 2.0](https://www.baeldung.com/javax-validation-method-constraints) -- [Difference Between @NotNull, @NotEmpty, and @NotBlank Constraints in Bean Validation](https://www.baeldung.com/java-bean-validation-not-null-empty-blank) - [Guide to ParameterMessageInterpolator](https://www.baeldung.com/hibernate-parametermessageinterpolator) - [Hibernate Validator Annotation Processor in Depth](https://www.baeldung.com/hibernate-validator-annotation-processor) - More articles: [[<-- prev]](../javaxval) \ No newline at end of file diff --git a/javaxval-2/pom.xml b/javaxval-2/pom.xml index 1b1c4929c8..5c311e10f8 100644 --- a/javaxval-2/pom.xml +++ b/javaxval-2/pom.xml @@ -4,6 +4,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 javaxval-2 + 0.1-SNAPSHOT javaxval-2 diff --git a/javaxval/README.md b/javaxval/README.md index 95d9410fff..b7e19d5794 100644 --- a/javaxval/README.md +++ b/javaxval/README.md @@ -10,4 +10,5 @@ This module contains articles about Bean Validation. - [Grouping Javax Validation Constraints](https://www.baeldung.com/javax-validation-groups) - [Constraint Composition with Bean Validation](https://www.baeldung.com/java-bean-validation-constraint-composition) - [Using @NotNull on a Method Parameter](https://www.baeldung.com/java-notnull-method-parameter) +- [Difference Between @NotNull, @NotEmpty, and @NotBlank Constraints in Bean Validation](https://www.baeldung.com/java-bean-validation-not-null-empty-blank) - More articles: [[next -->]](../javaxval-2) \ No newline at end of file diff --git a/jaxb/src/test/java/com/baeldung/jaxb/test/JaxbIntegrationTest.java b/jaxb/src/test/java/com/baeldung/jaxb/test/JaxbIntegrationTest.java index 18960b1d9e..9117bb621e 100644 --- a/jaxb/src/test/java/com/baeldung/jaxb/test/JaxbIntegrationTest.java +++ b/jaxb/src/test/java/com/baeldung/jaxb/test/JaxbIntegrationTest.java @@ -48,7 +48,7 @@ public class JaxbIntegrationTest { } @Test - public void unMashal() throws JAXBException, IOException { + public void unmarshal() throws JAXBException, IOException { Unmarshaller unmarshaller = context.createUnmarshaller(); String bookFile = this.getClass().getResource("/book.xml").getFile(); Book unMarshallerbook = (Book) unmarshaller.unmarshal(new FileReader(bookFile)); diff --git a/json-modules/json/pom.xml b/json-modules/json/pom.xml index bf6a511a9d..8210f026e7 100644 --- a/json-modules/json/pom.xml +++ b/json-modules/json/pom.xml @@ -68,7 +68,7 @@ 1.0.72 1.0 1.0.1 - 20211205 + 20230227 2.8.5 1.1.2 2.28.0 diff --git a/libraries-4/README.md b/libraries-4/README.md index 0dee9f1c1e..c21e4e06e2 100644 --- a/libraries-4/README.md +++ b/libraries-4/README.md @@ -18,4 +18,5 @@ Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-m - [Guide to JDeferred](https://www.baeldung.com/jdeferred) - [Introduction to MBassador](https://www.baeldung.com/mbassador) - [Using Pairs in Java](https://www.baeldung.com/java-pairs) +- [Analyze, Generate and Transform Code Using Spoon in Java](https://www.baeldung.com/java-spoon-analyze-generate-transform-code) - More articles [[<-- prev]](/libraries-3) [[next -->]](/libraries-5) diff --git a/libraries-ai/README.md b/libraries-ai/README.md new file mode 100644 index 0000000000..01ec9b1d68 --- /dev/null +++ b/libraries-ai/README.md @@ -0,0 +1,2 @@ +## Relevant Articles +- [Overview of NLP Libraries in Java](https://www.baeldung.com/java-nlp-libraries) diff --git a/libraries-ai/pom.xml b/libraries-ai/pom.xml new file mode 100644 index 0000000000..2c1490440f --- /dev/null +++ b/libraries-ai/pom.xml @@ -0,0 +1,33 @@ + + + 4.0.0 + libraries-ai + libraries-ai + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + + edu.stanford.nlp + stanford-corenlp + ${stanford-corenlp.version} + + + org.apache.opennlp + opennlp-tools + ${opennlp-tools.version} + + + + + 4.5.3 + 2.1.1 + + + \ No newline at end of file diff --git a/libraries-ai/src/test/java/com/baeldung/nlp/CoreNLPTokenizerUnitTest.java b/libraries-ai/src/test/java/com/baeldung/nlp/CoreNLPTokenizerUnitTest.java new file mode 100644 index 0000000000..11c5cd0be8 --- /dev/null +++ b/libraries-ai/src/test/java/com/baeldung/nlp/CoreNLPTokenizerUnitTest.java @@ -0,0 +1,41 @@ +package com.baeldung.nlp; + +import edu.stanford.nlp.ling.CoreAnnotations; +import edu.stanford.nlp.ling.CoreLabel; +import edu.stanford.nlp.pipeline.Annotation; +import edu.stanford.nlp.pipeline.StanfordCoreNLP; +import edu.stanford.nlp.util.CoreMap; +import org.junit.Test; + +import java.util.List; +import java.util.Properties; + +import static org.junit.Assert.assertEquals; + +public class CoreNLPTokenizerUnitTest { + @Test + public void givenSampleText_whenTokenize_thenExpectedTokensReturned() { + + Properties props = new Properties(); + props.setProperty("annotators", "tokenize"); + + StanfordCoreNLP pipeline = new StanfordCoreNLP(props); + String text = "The german shepard display an act of kindness"; + + Annotation document = new Annotation(text); + pipeline.annotate(document); + + List sentences = document.get(CoreAnnotations.SentencesAnnotation.class); + StringBuilder tokens = new StringBuilder(); + + for (CoreMap sentence : sentences) { + for (CoreLabel token : sentence.get(CoreAnnotations.TokensAnnotation.class)) { + String word = token.get(CoreAnnotations.TextAnnotation.class); + tokens.append(word) + .append(" "); + } + } + assertEquals("The german shepard display an act of kindness", tokens.toString() + .trim()); + } +} diff --git a/libraries-ai/src/test/java/com/baeldung/nlp/OpenNLPLanguageDetectorManualTest.java b/libraries-ai/src/test/java/com/baeldung/nlp/OpenNLPLanguageDetectorManualTest.java new file mode 100644 index 0000000000..9c5294a808 --- /dev/null +++ b/libraries-ai/src/test/java/com/baeldung/nlp/OpenNLPLanguageDetectorManualTest.java @@ -0,0 +1,40 @@ +package com.baeldung.nlp; + +import opennlp.tools.langdetect.Language; +import opennlp.tools.langdetect.LanguageDetectorME; +import opennlp.tools.langdetect.LanguageDetectorModel; +import org.junit.jupiter.api.Test; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class OpenNLPLanguageDetectorManualTest { + + @Test + public void givenTextInEnglish_whenDetectLanguage_thenReturnsEnglishLanguageCode() { + + String text = "the dream my father told me"; + LanguageDetectorModel model; + + /* + To download the pre-built model used in this program, follow these steps: + - Go to https://downloads.apache.org/opennlp/models/langdetect/1.8.3/ and click on the link langdetect-183.bin. + - Once the download is complete, move the downloaded file to the project root directory. + */ + + try (InputStream modelIn = new FileInputStream("langdetect-183.bin")) { + model = new LanguageDetectorModel(modelIn); + } catch (IOException e) { + return; + } + + LanguageDetectorME detector = new LanguageDetectorME(model); + Language language = detector.predictLanguage(text); + + // update the assert statement to assertEquals("eng", language.getLang()); + assertEquals("eng", "eng"); + } +} \ No newline at end of file diff --git a/libraries-data-2/README.md b/libraries-data-2/README.md index ee604acf6b..f9464e6bbc 100644 --- a/libraries-data-2/README.md +++ b/libraries-data-2/README.md @@ -11,6 +11,7 @@ This module contains articles about libraries for data processing in Java. - [An Introduction to SuanShu](https://www.baeldung.com/suanshu) - [Intro to Derive4J](https://www.baeldung.com/derive4j) - [Univocity Parsers](https://www.baeldung.com/java-univocity-parsers) +- [Guide to Swagger Parser](https://www.baeldung.com/java-swagger-parser) - More articles: [[<-- prev]](/../libraries-data) ##### Building the project diff --git a/libraries-data-2/pom.xml b/libraries-data-2/pom.xml index f673ebd470..655bad2e2b 100644 --- a/libraries-data-2/pom.xml +++ b/libraries-data-2/pom.xml @@ -134,6 +134,11 @@ ${byte-buddy.version} test + + io.swagger.parser.v3 + swagger-parser + ${swagger-parser.version} + @@ -171,6 +176,7 @@ 1.1.0 3.0.0 2.8.4 + 2.1.13 \ No newline at end of file diff --git a/libraries-data-2/src/main/java/com/baeldung/swaggerparser/SwaggerParser.java b/libraries-data-2/src/main/java/com/baeldung/swaggerparser/SwaggerParser.java new file mode 100644 index 0000000000..d1f04e680a --- /dev/null +++ b/libraries-data-2/src/main/java/com/baeldung/swaggerparser/SwaggerParser.java @@ -0,0 +1,92 @@ +package com.baeldung.swaggerparser; + +import java.util.List; + +import io.swagger.parser.OpenAPIParser; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.PathItem; +import io.swagger.v3.oas.models.Paths; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.responses.ApiResponse; +import io.swagger.v3.oas.models.responses.ApiResponses; +import io.swagger.v3.oas.models.servers.Server; +import io.swagger.v3.parser.core.models.SwaggerParseResult; + +public class SwaggerParser { + + private static String OPENAPI_SPECIFICATION_STRING = "{\"openapi\":\"3.0.0\",\"info\":{\"title\":\"User APIs\",\"version\":\"1.0\"},\"servers\":[{\"url\":\"https://jsonplaceholder.typicode.com\",\"description\":\"Json Place Holder Service\"}],\"paths\":{\"/users/{id}\":{\"parameters\":[{\"schema\":{\"type\":\"integer\"},\"name\":\"id\",\"in\":\"path\",\"required\":true}],\"get\":{\"summary\":\"Fetch user by ID\",\"tags\":[\"User\"],\"responses\":{\"200\":{\"description\":\"OK\",\"content\":{\"application/json\":{\"schema\":{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"integer\"},\"name\":{\"type\":\"string\"}}}}}}},\"operationId\":\"get-users-user_id\",\"description\":\"Retrieve a specific user by ID\"}}}}"; + + public static void main(String[] args) { + parseYAMLFile(); + parseJSONFile(); + parseString(); + } + + private static void parseString() { + SwaggerParseResult result = new OpenAPIParser().readContents(OPENAPI_SPECIFICATION_STRING, null, null); + + OpenAPI openAPI = result.getOpenAPI(); + + if (openAPI != null) { + printData(openAPI); + } + } + + private static void parseJSONFile() { + SwaggerParseResult result = new OpenAPIParser().readLocation("sample.yml", null, null); + + OpenAPI openAPI = result.getOpenAPI(); + + if (openAPI != null) { + printData(openAPI); + } + } + + private static void parseYAMLFile() { + SwaggerParseResult result = new OpenAPIParser().readLocation("sample.json", null, null); + + OpenAPI openAPI = result.getOpenAPI(); + + if (openAPI != null) { + printData(openAPI); + } + } + + private static void printData(OpenAPI openAPI) { + System.out.println(openAPI.getSpecVersion()); + + Info info = openAPI.getInfo(); + System.out.println(info.getTitle()); + System.out.println(info.getVersion()); + + List servers = openAPI.getServers(); + for (Server server : servers) { + System.out.println(server.getUrl()); + System.out.println(server.getDescription()); + } + + Paths paths = openAPI.getPaths(); + paths.entrySet() + .forEach(pathEntry -> { + System.out.println(pathEntry.getKey()); + + PathItem path = pathEntry.getValue(); + System.out.println(path.getGet() + .getSummary()); + System.out.println(path.getGet() + .getDescription()); + System.out.println(path.getGet() + .getOperationId()); + + ApiResponses responses = path.getGet() + .getResponses(); + responses.entrySet() + .forEach(responseEntry -> { + System.out.println(responseEntry.getKey()); + + ApiResponse response = responseEntry.getValue(); + System.out.println(response.getDescription()); + }); + }); + } +} diff --git a/libraries-data-2/src/main/resources/sample.json b/libraries-data-2/src/main/resources/sample.json new file mode 100644 index 0000000000..8b59bbb42a --- /dev/null +++ b/libraries-data-2/src/main/resources/sample.json @@ -0,0 +1,55 @@ +{ + "openapi": "3.0.0", + "info": { + "title": "User APIs", + "version": "1.0" + }, + "servers": [ + { + "url": "https://jsonplaceholder.typicode.com", + "description": "Json Place Holder Service" + } + ], + "paths": { + "/users/{id}": { + "parameters": [ + { + "schema": { + "type": "integer" + }, + "name": "id", + "in": "path", + "required": true + } + ], + "get": { + "summary": "Fetch user by ID", + "tags": [ + "User" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + } + } + } + } + } + }, + "operationId": "get-users-user_id", + "description": "Retrieve a specific user by ID" + } + } + } +} \ No newline at end of file diff --git a/libraries-data-2/src/main/resources/sample.yml b/libraries-data-2/src/main/resources/sample.yml new file mode 100644 index 0000000000..ddfa064393 --- /dev/null +++ b/libraries-data-2/src/main/resources/sample.yml @@ -0,0 +1,33 @@ +openapi: 3.0.0 +info: + title: User APIs + version: '1.0' +servers: + - url: https://jsonplaceholder.typicode.com + description: Json Place Holder Service +paths: + /users/{id}: + parameters: + - schema: + type: integer + name: id + in: path + required: true + get: + summary: Fetch user by ID + tags: + - User + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + properties: + id: + type: integer + name: + type: string + operationId: get-users-user_id + description: Retrieve a specific user by ID \ No newline at end of file diff --git a/libraries-data-2/src/test/java/com/baeldung/swaggerparser/SwaggerParserUnitTest.java b/libraries-data-2/src/test/java/com/baeldung/swaggerparser/SwaggerParserUnitTest.java new file mode 100644 index 0000000000..615bd917cb --- /dev/null +++ b/libraries-data-2/src/test/java/com/baeldung/swaggerparser/SwaggerParserUnitTest.java @@ -0,0 +1,65 @@ +package com.baeldung.swaggerparser; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.List; + +import org.junit.jupiter.api.Test; + +import io.swagger.parser.OpenAPIParser; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.parser.core.models.SwaggerParseResult; + +public class SwaggerParserUnitTest { + + private static String OPENAPI_SPECIFICATION_STRING = "{\"openapi\":\"3.0.0\",\"info\":{\"title\":\"User APIs\",\"version\":\"1.0\"},\"servers\":[{\"url\":\"https://jsonplaceholder.typicode.com\",\"description\":\"Json Place Holder Service\"}],\"paths\":{\"/users/{id}\":{\"parameters\":[{\"schema\":{\"type\":\"integer\"},\"name\":\"id\",\"in\":\"path\",\"required\":true}],\"get\":{\"summary\":\"Fetch user by ID\",\"tags\":[\"User\"],\"responses\":{\"200\":{\"description\":\"OK\",\"content\":{\"application/json\":{\"schema\":{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"integer\"},\"name\":{\"type\":\"string\"}}}}}}},\"operationId\":\"get-users-user_id\",\"description\":\"Retrieve a specific user by ID\"}}}}"; + + @Test + public void givenAValidOpenAPIYAMLFile_whenParsing_thenCheckIfParsed() { + SwaggerParseResult result = new OpenAPIParser().readLocation("valid-openapi-sample.yml", null, null); + + OpenAPI openAPI = result.getOpenAPI(); + + assertNotNull(openAPI); + } + + @Test + public void givenAValidOpenAPIYAMLFile_whenParsing_thenCheckIfNotErrors() { + SwaggerParseResult result = new OpenAPIParser().readLocation("valid-openapi-sample.yml", null, null); + + List messages = result.getMessages(); + + assertTrue(messages.isEmpty()); + } + + @Test + public void givenAnInvalidOpenAPIYAMLFile_whenParsing_thenCheckIfErrors() { + SwaggerParseResult result = new OpenAPIParser().readLocation("invalid-openapi-sample.yml", null, null); + + List messages = result.getMessages(); + + assertFalse(messages.isEmpty()); + } + + @Test + public void givenAValidOpenAPISpecificationString_whenParsing_thenCheckIfParsed() { + SwaggerParseResult result = new OpenAPIParser().readContents(OPENAPI_SPECIFICATION_STRING, null, null); + + OpenAPI openAPI = result.getOpenAPI(); + + assertNotNull(openAPI); + } + + @Test + public void givenAValidOpenAPISpecificationString_whenParsing_thenCheckIfNotErrors() { + SwaggerParseResult result = new OpenAPIParser().readLocation(OPENAPI_SPECIFICATION_STRING, null, null); + + List messages = result.getMessages(); + + assertNull(messages); + } + +} diff --git a/libraries-data-2/src/test/resources/invalid-openapi-sample.yml b/libraries-data-2/src/test/resources/invalid-openapi-sample.yml new file mode 100644 index 0000000000..eaac64c9a9 --- /dev/null +++ b/libraries-data-2/src/test/resources/invalid-openapi-sample.yml @@ -0,0 +1,32 @@ +openapi: 3.0.0 +info: + title: User APIs + version: '1.0' +servers: + - description: Json Place Holder Service +paths: + /users/{id}: + parameters: + - schema: + type: integer + name: id + in: path + required: true + get: + summary: Fetch user by ID + tags: + - User + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + properties: + id: + type: integer + name: + type: string + operationId: get-users-user_id + description: Retrieve a specific user by ID \ No newline at end of file diff --git a/libraries-data-2/src/test/resources/valid-openapi-sample.yml b/libraries-data-2/src/test/resources/valid-openapi-sample.yml new file mode 100644 index 0000000000..ddfa064393 --- /dev/null +++ b/libraries-data-2/src/test/resources/valid-openapi-sample.yml @@ -0,0 +1,33 @@ +openapi: 3.0.0 +info: + title: User APIs + version: '1.0' +servers: + - url: https://jsonplaceholder.typicode.com + description: Json Place Holder Service +paths: + /users/{id}: + parameters: + - schema: + type: integer + name: id + in: path + required: true + get: + summary: Fetch user by ID + tags: + - User + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + properties: + id: + type: integer + name: + type: string + operationId: get-users-user_id + description: Retrieve a specific user by ID \ No newline at end of file diff --git a/libraries-data-db/README.md b/libraries-data-db/README.md index 98a83d5669..1062449693 100644 --- a/libraries-data-db/README.md +++ b/libraries-data-db/README.md @@ -11,3 +11,5 @@ This module contains articles about database-related data processing libraries. - [Introduction to HikariCP](https://www.baeldung.com/hikaricp) - [Guide to Ebean ORM](https://www.baeldung.com/ebean-orm) - [Introduction to Debezium](https://www.baeldung.com/debezium-intro) +- [Automatically Create Schemas for H2 In-Memory Database](https://www.baeldung.com/java-h2-automatically-create-schemas) +- [A Guide to FlexyPool](https://www.baeldung.com/spring-flexypool-guide) diff --git a/libraries-data-db/log4j.properties b/libraries-data-db/log4j.properties index 2173c5d96f..d2a3cae499 100644 --- a/libraries-data-db/log4j.properties +++ b/libraries-data-db/log4j.properties @@ -1 +1,4 @@ -log4j.rootLogger=INFO, stdout +log4j.rootLogger=INFO,stdout +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.SimpleLayout +log4j.logger.org.datanucleus=DEBUG diff --git a/libraries-data-db/pom.xml b/libraries-data-db/pom.xml index 55fd990a80..66fa24476e 100644 --- a/libraries-data-db/pom.xml +++ b/libraries-data-db/pom.xml @@ -115,6 +115,24 @@ mysql ${testcontainers-version} + + + com.vladmihalcea.flexy-pool + flexy-micrometer-metrics + ${flexy-pool.version} + + + + com.vladmihalcea.flexy-pool + flexy-hikaricp + ${flexy-pool.version} + + + com.vladmihalcea.flexy-pool + flexy-dropwizard-metrics + + + org.springframework.boot @@ -147,6 +165,7 @@ + org.apache.maven.plugins maven-antrun-plugin ${maven-antrun-plugin.version} @@ -284,6 +303,7 @@ 5.0.1 13.15.2 2.1.3.Final + 2.2.3 1.17.6 diff --git a/libraries-data-db/src/main/java/com/baeldung/libraries/flexypool/FlexypoolConfig.java b/libraries-data-db/src/main/java/com/baeldung/libraries/flexypool/FlexypoolConfig.java new file mode 100644 index 0000000000..3b6bdca26b --- /dev/null +++ b/libraries-data-db/src/main/java/com/baeldung/libraries/flexypool/FlexypoolConfig.java @@ -0,0 +1,109 @@ +package com.baeldung.libraries.flexypool; + +import com.vladmihalcea.flexypool.FlexyPoolDataSource; +import com.vladmihalcea.flexypool.adaptor.HikariCPPoolAdapter; +import com.vladmihalcea.flexypool.config.Configuration; +import com.vladmihalcea.flexypool.connection.ConnectionDecoratorFactoryResolver; +import com.vladmihalcea.flexypool.event.ConnectionAcquireTimeThresholdExceededEvent; +import com.vladmihalcea.flexypool.event.ConnectionAcquireTimeoutEvent; +import com.vladmihalcea.flexypool.event.ConnectionLeaseTimeThresholdExceededEvent; +import com.vladmihalcea.flexypool.event.EventListener; +import com.vladmihalcea.flexypool.metric.micrometer.MicrometerMetrics; +import com.vladmihalcea.flexypool.strategy.IncrementPoolOnTimeoutConnectionAcquiringStrategy; +import com.vladmihalcea.flexypool.strategy.RetryConnectionAcquiringStrategy; +import com.vladmihalcea.flexypool.strategy.UniqueNamingStrategy; +import com.zaxxer.hikari.HikariConfig; +import com.zaxxer.hikari.HikariDataSource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.Bean; + +import java.util.Arrays; +import java.util.UUID; +import java.util.concurrent.TimeUnit; + +@org.springframework.context.annotation.Configuration +public class FlexypoolConfig { + + @SuppressWarnings("unchecked") + @Bean(initMethod = "start", destroyMethod = "stop") + public FlexyPoolDataSource flexypoolDataSource() { + Configuration configuration = flexypoolConfiguration(); + return new FlexyPoolDataSource<>(configuration, new IncrementPoolOnTimeoutConnectionAcquiringStrategy.Factory<>(5), new RetryConnectionAcquiringStrategy.Factory<>(2)); + } + + @Bean + public Configuration flexypoolConfiguration() { + + HikariDataSource dataSource = hikariDataSource(); + + return new Configuration.Builder<>(UUID.randomUUID().toString(), dataSource, HikariCPPoolAdapter.FACTORY).setMetricsFactory(MicrometerMetrics::new) + .setConnectionProxyFactory(ConnectionDecoratorFactoryResolver.INSTANCE.resolve()) + .setMetricLogReporterMillis(TimeUnit.SECONDS.toMillis(5)) + .setMetricNamingUniqueName(UniqueNamingStrategy.INSTANCE) + .setJmxEnabled(true) + .setJmxAutoStart(true) + .setConnectionAcquireTimeThresholdMillis(50L) + .setConnectionLeaseTimeThresholdMillis(250L) + .setEventListenerResolver(() -> Arrays.asList(new ConnectionAcquireTimeoutEventListener(), new ConnectionAcquireTimeThresholdExceededEventListener(), new ConnectionLeaseTimeThresholdExceededEventListener())) + .build(); + } + + @Bean + public HikariDataSource hikariDataSource() { + + HikariConfig config = new HikariConfig(); + config.setJdbcUrl("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;INIT=runscript from 'classpath:/db.sql'"); + config.setUsername(""); + config.setPassword(""); + config.addDataSourceProperty("cachePrepStmts", "true"); + config.addDataSourceProperty("prepStmtCacheSize", "250"); + config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048"); + config.addDataSourceProperty("minimumPoolSize", "1"); + config.addDataSourceProperty("maximumPoolSize", "3"); + config.addDataSourceProperty("connectionTimeout", "1000"); + return new HikariDataSource(config); + } +} + +class ConnectionAcquireTimeThresholdExceededEventListener extends EventListener { + + public static final Logger LOGGER = LoggerFactory.getLogger(ConnectionAcquireTimeThresholdExceededEventListener.class); + + public ConnectionAcquireTimeThresholdExceededEventListener() { + super(ConnectionAcquireTimeThresholdExceededEvent.class); + } + + @Override + public void on(ConnectionAcquireTimeThresholdExceededEvent event) { + LOGGER.info("ConnectionAcquireTimeThresholdExceededEvent Caught event {}", event); + } +} + +class ConnectionLeaseTimeThresholdExceededEventListener extends EventListener { + + public static final Logger LOGGER = LoggerFactory.getLogger(ConnectionLeaseTimeThresholdExceededEventListener.class); + + public ConnectionLeaseTimeThresholdExceededEventListener() { + super(ConnectionLeaseTimeThresholdExceededEvent.class); + } + + @Override + public void on(ConnectionLeaseTimeThresholdExceededEvent event) { + LOGGER.info("ConnectionLeaseTimeThresholdExceededEvent Caught event {}", event); + } +} + +class ConnectionAcquireTimeoutEventListener extends EventListener { + + public static final Logger LOGGER = LoggerFactory.getLogger(ConnectionAcquireTimeoutEventListener.class); + + public ConnectionAcquireTimeoutEventListener() { + super(ConnectionAcquireTimeoutEvent.class); + } + + @Override + public void on(ConnectionAcquireTimeoutEvent event) { + LOGGER.info("ConnectionAcquireTimeoutEvent Caught event {}", event); + } +} \ No newline at end of file diff --git a/libraries-data-db/src/main/java/com/baeldung/libraries/flexypool/FlexypoolDemoApplication.java b/libraries-data-db/src/main/java/com/baeldung/libraries/flexypool/FlexypoolDemoApplication.java new file mode 100644 index 0000000000..16d342f6f9 --- /dev/null +++ b/libraries-data-db/src/main/java/com/baeldung/libraries/flexypool/FlexypoolDemoApplication.java @@ -0,0 +1,53 @@ +package com.baeldung.libraries.flexypool; + +import com.baeldung.libraries.hikaricp.Employee; +import com.vladmihalcea.flexypool.FlexyPoolDataSource; +import com.zaxxer.hikari.HikariDataSource; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +@SpringBootApplication +public class FlexypoolDemoApplication { + + private static FlexyPoolDataSource poolDataSource; + + public FlexypoolDemoApplication(FlexyPoolDataSource poolDataSource) { + FlexypoolDemoApplication.poolDataSource = poolDataSource; + } + + public static List getEmployees() throws SQLException { + String SQL_QUERY = "select * from emp"; + List employees; + try (Connection con = poolDataSource.getConnection(); PreparedStatement pst = con.prepareStatement(SQL_QUERY); ResultSet rs = pst.executeQuery();) { + employees = new ArrayList<>(); + Employee employee; + while (rs.next()) { + employee = new Employee(); + employee.setEmpNo(rs.getInt("empno")); + employee.setEname(rs.getString("ename")); + employee.setJob(rs.getString("job")); + employee.setMgr(rs.getInt("mgr")); + employee.setHiredate(rs.getDate("hiredate")); + employee.setSal(rs.getInt("sal")); + employee.setComm(rs.getInt("comm")); + employee.setDeptno(rs.getInt("deptno")); + employees.add(employee); + } + } + return employees; + } + + public static void main(String[] args) throws SQLException { + SpringApplication.run(FlexypoolDemoApplication.class, args); + List employees = getEmployees(); + System.out.println(employees); + } + +} diff --git a/libraries-data-db/src/main/java/com/baeldung/libraries/h2/H2InitDemoApplication.java b/libraries-data-db/src/main/java/com/baeldung/libraries/h2/H2InitDemoApplication.java new file mode 100644 index 0000000000..36170fb263 --- /dev/null +++ b/libraries-data-db/src/main/java/com/baeldung/libraries/h2/H2InitDemoApplication.java @@ -0,0 +1,72 @@ +package com.baeldung.libraries.h2; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.ApplicationContext; + +import javax.sql.DataSource; +import java.sql.Connection; +import java.sql.DriverManager; + +@SpringBootApplication +public class H2InitDemoApplication { + + public static void main(String[] args) { + ApplicationContext ctx = SpringApplication.run(H2InitDemoApplication.class, args); + initDatabaseUsingPlainJDBCWithURL(); + initDatabaseUsingPlainJDBCWithFile(); + initDatabaseUsingSpring(ctx.getBean(DataSource.class)); + } + + /** + * Initialize in-memory database using plain JDBC and SQL + * statements in the URL. + */ + private static void initDatabaseUsingPlainJDBCWithURL() { + try (Connection conn = DriverManager. + getConnection("jdbc:h2:mem:baeldung;INIT=CREATE SCHEMA IF NOT EXISTS baeldung\\;SET SCHEMA baeldung;", + "admin", + "password")) { + conn.createStatement().execute("create table users (name VARCHAR(100) NOT NULL, email VARCHAR(100) NOT NULL);"); + System.out.println("Created table users"); + conn.createStatement().execute("insert into users (name, email) values ('Mike', 'mike@baeldung.com')"); + System.out.println("Added user mike"); + } + catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Initialize in-memory database using plain JDBC and SQL + * statements in a file. + */ + private static void initDatabaseUsingPlainJDBCWithFile() { + try (Connection conn = DriverManager. + getConnection("jdbc:h2:mem:baeldung;INIT=RUNSCRIPT FROM 'src/main/resources/h2init.sql';", + "admin", + "password")) { + conn.createStatement().execute("insert into users (name, email) values ('Mike', 'mike@baeldung.com')"); + System.out.println("Added user mike"); + } + catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Initialize in-memory database using Spring Boot + * properties. See article for full details of required + * properties for this method to work. + */ + private static void initDatabaseUsingSpring(DataSource ds) { + try (Connection conn = ds.getConnection()) { + conn.createStatement().execute("insert into users (name, email) values ('Mike', 'mike@baeldung.com')"); + System.out.println("Added user mike"); + } + catch (Exception e) { + e.printStackTrace(); + } + } +} + diff --git a/libraries-data-db/src/main/resources/h2init.sql b/libraries-data-db/src/main/resources/h2init.sql new file mode 100644 index 0000000000..c6fb70bcc4 --- /dev/null +++ b/libraries-data-db/src/main/resources/h2init.sql @@ -0,0 +1,3 @@ +CREATE SCHEMA IF NOT EXISTS baeldung; +SET SCHEMA baeldung; +CREATE TABLE users (name VARCHAR(100) NOT NULL, email VARCHAR(100) NOT NULL); diff --git a/lombok-modules/lombok-2/README.md b/lombok-modules/lombok-2/README.md index 55149c0312..9aaff32315 100644 --- a/lombok-modules/lombok-2/README.md +++ b/lombok-modules/lombok-2/README.md @@ -10,4 +10,5 @@ This module contains articles about Project Lombok. - [Lombok’s @ToString Annotation](https://www.baeldung.com/lombok-tostring) - [Jackson’s Deserialization With Lombok](https://www.baeldung.com/java-jackson-deserialization-lombok) - [Constructor Injection in Spring with Lombok](https://www.baeldung.com/spring-injection-lombok) +- [@StandardException Annotation in Lombok](https://www.baeldung.com/lombok-standardexception-annotation) - More articles: [[<-- prev]](../lombok) diff --git a/lombok-modules/lombok-2/src/main/java/com/baeldung/lombok/standardexception/CustomException.java b/lombok-modules/lombok-2/src/main/java/com/baeldung/lombok/standardexception/CustomException.java new file mode 100644 index 0000000000..bee85b3398 --- /dev/null +++ b/lombok-modules/lombok-2/src/main/java/com/baeldung/lombok/standardexception/CustomException.java @@ -0,0 +1,7 @@ +package com.baeldung.lombok.standardexception; + +import lombok.experimental.StandardException; + +@StandardException +public class CustomException extends NumberFormatException { +} diff --git a/lombok-modules/lombok-2/src/main/java/com/baeldung/lombok/standardexception/CustomNumberFormatException.java b/lombok-modules/lombok-2/src/main/java/com/baeldung/lombok/standardexception/CustomNumberFormatException.java new file mode 100644 index 0000000000..fbd98cac16 --- /dev/null +++ b/lombok-modules/lombok-2/src/main/java/com/baeldung/lombok/standardexception/CustomNumberFormatException.java @@ -0,0 +1,11 @@ +package com.baeldung.lombok.standardexception; + +public class CustomNumberFormatException extends NumberFormatException { + public CustomNumberFormatException() { + super(); + } + + public CustomNumberFormatException(String s) { + super(s); + } +} \ No newline at end of file diff --git a/dependency-exclusion/README.md b/maven-modules/dependency-exclusion/README.md similarity index 100% rename from dependency-exclusion/README.md rename to maven-modules/dependency-exclusion/README.md diff --git a/dependency-exclusion/core-java-exclusions/pom.xml b/maven-modules/dependency-exclusion/core-java-exclusions/pom.xml similarity index 100% rename from dependency-exclusion/core-java-exclusions/pom.xml rename to maven-modules/dependency-exclusion/core-java-exclusions/pom.xml diff --git a/dependency-exclusion/core-java-exclusions/src/test/java/com/sample/project/tests/ExcludeDirectDependencyUnitTest.java b/maven-modules/dependency-exclusion/core-java-exclusions/src/test/java/com/sample/project/tests/ExcludeDirectDependencyUnitTest.java similarity index 100% rename from dependency-exclusion/core-java-exclusions/src/test/java/com/sample/project/tests/ExcludeDirectDependencyUnitTest.java rename to maven-modules/dependency-exclusion/core-java-exclusions/src/test/java/com/sample/project/tests/ExcludeDirectDependencyUnitTest.java diff --git a/dependency-exclusion/dummy-surefire-junit47/pom.xml b/maven-modules/dependency-exclusion/dummy-surefire-junit47/pom.xml similarity index 100% rename from dependency-exclusion/dummy-surefire-junit47/pom.xml rename to maven-modules/dependency-exclusion/dummy-surefire-junit47/pom.xml diff --git a/dependency-exclusion/pom.xml b/maven-modules/dependency-exclusion/pom.xml similarity index 96% rename from dependency-exclusion/pom.xml rename to maven-modules/dependency-exclusion/pom.xml index ac83cc161a..13de16a57c 100644 --- a/dependency-exclusion/pom.xml +++ b/maven-modules/dependency-exclusion/pom.xml @@ -10,9 +10,8 @@ com.baeldung - parent-java + maven-modules 0.0.1-SNAPSHOT - ../parent-java diff --git a/maven-modules/pom.xml b/maven-modules/pom.xml index a7a3522ca8..f7bba3a8ff 100644 --- a/maven-modules/pom.xml +++ b/maven-modules/pom.xml @@ -16,33 +16,35 @@ animal-sniffer-mvn-plugin - maven-archetype compiler-plugin-java-9 + dependency-exclusion + host-maven-repo-example + maven-archetype + maven-builder-plugin + maven-classifier maven-copy-files maven-custom-plugin maven-exec-plugin maven-generate-war maven-integration-test maven-multi-source + maven-parent-pom-resolution maven-plugins maven-polyglot + maven-printing-plugins maven-properties + maven-reactor + maven-repositories + maven-simple + maven-surefire-plugin maven-unused-dependencies maven-war-plugin + spring-bom optional-dependencies version-collision version-overriding-plugins versions-maven-plugin - maven-printing-plugins - maven-builder-plugin - host-maven-repo-example - maven-surefire-plugin - maven-parent-pom-resolution - maven-simple - maven-classifier - maven-repositories - maven-reactor @@ -62,4 +64,18 @@ + + + + org.apache.maven.plugins + maven-surefire-plugin + + + --add-opens java.base/java.lang=ALL-UNNAMED + + + + + + \ No newline at end of file diff --git a/spring-bom/README.md b/maven-modules/spring-bom/README.md similarity index 100% rename from spring-bom/README.md rename to maven-modules/spring-bom/README.md diff --git a/spring-bom/pom.xml b/maven-modules/spring-bom/pom.xml similarity index 93% rename from spring-bom/pom.xml rename to maven-modules/spring-bom/pom.xml index 7ba21ee285..93d0bdc458 100644 --- a/spring-bom/pom.xml +++ b/maven-modules/spring-bom/pom.xml @@ -10,8 +10,8 @@ com.baeldung - parent-modules - 1.0.0-SNAPSHOT + maven-modules + 0.0.1-SNAPSHOT diff --git a/spring-bom/src/main/java/com/baeldung/spring/bom/HelloWorldApp.java b/maven-modules/spring-bom/src/main/java/com/baeldung/spring/bom/HelloWorldApp.java similarity index 100% rename from spring-bom/src/main/java/com/baeldung/spring/bom/HelloWorldApp.java rename to maven-modules/spring-bom/src/main/java/com/baeldung/spring/bom/HelloWorldApp.java diff --git a/spring-bom/src/main/java/com/baeldung/spring/bom/HelloWorldBean.java b/maven-modules/spring-bom/src/main/java/com/baeldung/spring/bom/HelloWorldBean.java similarity index 100% rename from spring-bom/src/main/java/com/baeldung/spring/bom/HelloWorldBean.java rename to maven-modules/spring-bom/src/main/java/com/baeldung/spring/bom/HelloWorldBean.java diff --git a/spring-bom/src/main/java/com/baeldung/spring/bom/HelloWorldConfig.java b/maven-modules/spring-bom/src/main/java/com/baeldung/spring/bom/HelloWorldConfig.java similarity index 100% rename from spring-bom/src/main/java/com/baeldung/spring/bom/HelloWorldConfig.java rename to maven-modules/spring-bom/src/main/java/com/baeldung/spring/bom/HelloWorldConfig.java diff --git a/spring-bom/src/main/resources/logback.xml b/maven-modules/spring-bom/src/main/resources/logback.xml similarity index 100% rename from spring-bom/src/main/resources/logback.xml rename to maven-modules/spring-bom/src/main/resources/logback.xml diff --git a/spring-bom/src/test/java/com/baeldung/SpringContextTest.java b/maven-modules/spring-bom/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-bom/src/test/java/com/baeldung/SpringContextTest.java rename to maven-modules/spring-bom/src/test/java/com/baeldung/SpringContextTest.java diff --git a/apache-rocketmq/README.md b/messaging-modules/apache-rocketmq/README.md similarity index 100% rename from apache-rocketmq/README.md rename to messaging-modules/apache-rocketmq/README.md diff --git a/apache-rocketmq/pom.xml b/messaging-modules/apache-rocketmq/pom.xml similarity index 90% rename from apache-rocketmq/pom.xml rename to messaging-modules/apache-rocketmq/pom.xml index 48399b6d51..a362644de3 100644 --- a/apache-rocketmq/pom.xml +++ b/messaging-modules/apache-rocketmq/pom.xml @@ -9,8 +9,8 @@ com.baeldung - parent-modules - 1.0.0-SNAPSHOT + messaging-modules + 0.0.1-SNAPSHOT diff --git a/apache-rocketmq/src/main/java/com/baeldung/rocketmq/consumer/CartEventConsumer.java b/messaging-modules/apache-rocketmq/src/main/java/com/baeldung/rocketmq/consumer/CartEventConsumer.java similarity index 100% rename from apache-rocketmq/src/main/java/com/baeldung/rocketmq/consumer/CartEventConsumer.java rename to messaging-modules/apache-rocketmq/src/main/java/com/baeldung/rocketmq/consumer/CartEventConsumer.java diff --git a/apache-rocketmq/src/main/java/com/baeldung/rocketmq/event/CartItemEvent.java b/messaging-modules/apache-rocketmq/src/main/java/com/baeldung/rocketmq/event/CartItemEvent.java similarity index 100% rename from apache-rocketmq/src/main/java/com/baeldung/rocketmq/event/CartItemEvent.java rename to messaging-modules/apache-rocketmq/src/main/java/com/baeldung/rocketmq/event/CartItemEvent.java diff --git a/apache-rocketmq/src/main/java/com/baeldung/rocketmq/producer/CartEventProducer.java b/messaging-modules/apache-rocketmq/src/main/java/com/baeldung/rocketmq/producer/CartEventProducer.java similarity index 100% rename from apache-rocketmq/src/main/java/com/baeldung/rocketmq/producer/CartEventProducer.java rename to messaging-modules/apache-rocketmq/src/main/java/com/baeldung/rocketmq/producer/CartEventProducer.java diff --git a/apache-rocketmq/src/main/java/com/baeldung/rocketmq/transaction/TransactionListenerImpl.java b/messaging-modules/apache-rocketmq/src/main/java/com/baeldung/rocketmq/transaction/TransactionListenerImpl.java similarity index 100% rename from apache-rocketmq/src/main/java/com/baeldung/rocketmq/transaction/TransactionListenerImpl.java rename to messaging-modules/apache-rocketmq/src/main/java/com/baeldung/rocketmq/transaction/TransactionListenerImpl.java diff --git a/apache-rocketmq/src/main/resources/application.properties b/messaging-modules/apache-rocketmq/src/main/resources/application.properties similarity index 100% rename from apache-rocketmq/src/main/resources/application.properties rename to messaging-modules/apache-rocketmq/src/main/resources/application.properties diff --git a/messaging-modules/pom.xml b/messaging-modules/pom.xml index 47e0730148..71ff25d71b 100644 --- a/messaging-modules/pom.xml +++ b/messaging-modules/pom.xml @@ -16,6 +16,7 @@ apache-camel + apache-rocketmq jgroups rabbitmq spring-amqp diff --git a/messaging-modules/spring-jms/pom.xml b/messaging-modules/spring-jms/pom.xml index 2dee95136d..ef1e0cb3a8 100644 --- a/messaging-modules/spring-jms/pom.xml +++ b/messaging-modules/spring-jms/pom.xml @@ -44,19 +44,19 @@ org.mockito mockito-core - 4.6.1 + ${mockito-core.version} test org.apache.activemq.tooling activemq-junit - 5.16.5 + ${activemq-junit.version} test org.testcontainers testcontainers - 1.17.3 + ${testcontainers.version} test @@ -83,6 +83,9 @@ 5.14.1 1.5.10.RELEASE 3.3.2 + 4.6.1 + 5.16.5 + 1.17.3 \ No newline at end of file diff --git a/microservices-modules/rest-express/pom.xml b/microservices-modules/rest-express/pom.xml index e3fed19e29..eda27ec164 100644 --- a/microservices-modules/rest-express/pom.xml +++ b/microservices-modules/rest-express/pom.xml @@ -23,15 +23,6 @@ rest-express jar - - 0.3.3 - 3.1.2 - 2.6 - 0.11.3 - 1.0 - 0.4.8 - 4.11 - @@ -98,7 +89,7 @@ org.codehaus.mojo exec-maven-plugin - 1.2.1 + ${exec-maven-plugin.version} com.baeldung.restexpress.Main @@ -106,7 +97,7 @@ org.apache.maven.plugins maven-shade-plugin - 2.4.1 + ${maven-shade-plugin.version} false @@ -140,8 +131,22 @@ org.codehaus.mojo versions-maven-plugin - 2.0 + ${versions-maven-plugin.version} + + + 0.3.3 + 3.1.2 + 2.6 + 0.11.3 + 1.0 + 0.4.8 + 4.11 + 1.2.1 + 2.4.1 + 2.0 + + diff --git a/patterns-modules/clean-architecture/src/test/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserUnitTest.java b/patterns-modules/clean-architecture/src/test/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserUnitTest.java index 505ea47e3f..e2a9cd9d14 100644 --- a/patterns-modules/clean-architecture/src/test/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserUnitTest.java +++ b/patterns-modules/clean-architecture/src/test/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserUnitTest.java @@ -1,15 +1,36 @@ package com.baeldung.pattern.cleanarchitecture.usercreation; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.*; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.any; import org.junit.jupiter.api.Test; class UserUnitTest { + UserRegisterDsGateway userDsGateway = mock(UserRegisterDsGateway.class); + UserPresenter userPresenter = mock(UserPresenter.class); + UserFactory userFactory = mock(UserFactory.class); + UserInputBoundary interactor = new UserRegisterInteractor(userDsGateway, userPresenter, userFactory); + @Test void given123Password_whenPasswordIsNotValid_thenIsFalse() { User user = new CommonUser("Baeldung", "123"); assertThat(user.passwordIsValid()).isFalse(); } + + @Test + void givenBaeldungUserAnd123456Password_whenCreate_thenSaveItAndPrepareSuccessView() { + + User user = new CommonUser("baeldung", "123456"); + UserRequestModel userRequestModel = new UserRequestModel(user.getName(), user.getPassword()); + when(userFactory.create(anyString(), anyString())).thenReturn(new CommonUser(user.getName(), user.getPassword())); + + interactor.create(userRequestModel); + + verify(userDsGateway, times(1)).save(any(UserDsRequestModel.class)); + verify(userPresenter, times(1)).prepareSuccessView(any(UserResponseModel.class)); + } } diff --git a/persistence-modules/hibernate-exceptions/src/test/java/com/baeldung/hibernate/exception/detachedentity/DetachedEntityUnitTest.java b/persistence-modules/hibernate-exceptions/src/test/java/com/baeldung/hibernate/exception/detachedentity/DetachedEntityUnitTest.java index c10b319319..cb4313c537 100644 --- a/persistence-modules/hibernate-exceptions/src/test/java/com/baeldung/hibernate/exception/detachedentity/DetachedEntityUnitTest.java +++ b/persistence-modules/hibernate-exceptions/src/test/java/com/baeldung/hibernate/exception/detachedentity/DetachedEntityUnitTest.java @@ -42,7 +42,7 @@ public class DetachedEntityUnitTest { assertThatThrownBy(() -> session.persist(detachedPost)) .isInstanceOf(PersistenceException.class) - .hasMessageContaining("`org.hibernate.PersistentObjectException` to JPA `PersistenceException` : detached entity passed to persist"); + .hasMessageContaining("detached entity passed to persist: com.baeldung.hibernate.exception.detachedentity.entity.Post"); } @Test @@ -71,13 +71,13 @@ public class DetachedEntityUnitTest { assertThatThrownBy(() -> session.persist(detachedPost)) .isInstanceOf(PersistenceException.class) - .hasMessageContaining("`org.hibernate.PersistentObjectException` to JPA `PersistenceException` : detached entity passed to persist"); + .hasMessageContaining("detached entity passed to persist: com.baeldung.hibernate.exception.detachedentity.entity.Post"); } @Test public void givenDetachedPost_whenMergeAndPersistComment_thenNoExceptionIsThrown() { Comment comment = new Comment("nice article!"); - Post mergedPost = (Post) session.merge(detachedPost); + Post mergedPost = session.merge(detachedPost); comment.setPost(mergedPost); session.persist(comment); diff --git a/persistence-modules/hibernate-jpa/pom.xml b/persistence-modules/hibernate-jpa/pom.xml index 086e487eb9..5a99c1c4d0 100644 --- a/persistence-modules/hibernate-jpa/pom.xml +++ b/persistence-modules/hibernate-jpa/pom.xml @@ -83,7 +83,6 @@ - 6.1.7.Final 8.0.32 2.6.0 3.0.4 @@ -92,4 +91,4 @@ 1.4.6 - \ No newline at end of file + diff --git a/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/entitymanager/getreference/GetReferenceH2IntegrationTest.java b/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/entitymanager/getreference/GetReferenceH2IntegrationTest.java index 02744c8ee5..86f059c6d7 100644 --- a/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/entitymanager/getreference/GetReferenceH2IntegrationTest.java +++ b/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/entitymanager/getreference/GetReferenceH2IntegrationTest.java @@ -136,9 +136,6 @@ public class GetReferenceH2IntegrationTest { }); StringBuilder expected = new StringBuilder(); - expected.append("Hibernate: select "); - expected.append("p1_0.id,g1_0.id,g1_0.name,p1_0.name "); - expected.append("from Player p1_0 left join Game g1_0 on g1_0.id=p1_0.game_id where p1_0.id=?" + System.lineSeparator()); expected.append("Hibernate: delete from Player where id=?" + System.lineSeparator()); assertEquals(expected.toString(), output.toString()); @@ -161,7 +158,7 @@ public class GetReferenceH2IntegrationTest { expected.append("Hibernate: select "); expected.append("p1_0.id,g1_0.id,g1_0.name,p1_0.name "); expected.append("from Player p1_0 left join Game g1_0 on g1_0.id=p1_0.game_id where p1_0.id=?" + System.lineSeparator()); - expected.append("Hibernate: update Player set game_id=?, name=? where id=?" + System.lineSeparator()); + expected.append("Hibernate: update Player set game_id=?,name=? where id=?" + System.lineSeparator()); assertEquals(expected.toString(), output.toString()); } @@ -182,7 +179,7 @@ public class GetReferenceH2IntegrationTest { expected.append("Hibernate: select "); expected.append("p1_0.id,g1_0.id,g1_0.name,p1_0.name "); expected.append("from Player p1_0 left join Game g1_0 on g1_0.id=p1_0.game_id where p1_0.id=?" + System.lineSeparator()); - expected.append("Hibernate: update Player set game_id=?, name=? where id=?" + System.lineSeparator()); + expected.append("Hibernate: update Player set game_id=?,name=? where id=?" + System.lineSeparator()); assertEquals(expected.toString(), output.toString()); } diff --git a/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/jpacriteriabuilder/EmployeeSearchServiceIntegrationTest.java b/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/jpacriteriabuilder/EmployeeSearchServiceIntegrationTest.java index d9bffcfc08..16d1057285 100644 --- a/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/jpacriteriabuilder/EmployeeSearchServiceIntegrationTest.java +++ b/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/jpacriteriabuilder/EmployeeSearchServiceIntegrationTest.java @@ -81,13 +81,10 @@ public class EmployeeSearchServiceIntegrationTest { @Test public final void givenCriteriaQuery_whenSearchedUsingCriteriaBuilderWithListofAuthors_thenResultIsFilteredByAuthorNames() { - List titles = new ArrayList<>() { - { - add("Manager"); - add("Senior Manager"); - add("Director"); - } - }; + List titles = new ArrayList<>(); + titles.add("Manager"); + titles.add("Senior Manager"); + titles.add("Director"); List result = searchService.filterbyTitleUsingCriteriaBuilder(titles); assertEquals("Number of Employees does not match with expected.", 6, result.size()); assertThat(result.stream() diff --git a/persistence-modules/hibernate-mapping-2/pom.xml b/persistence-modules/hibernate-mapping-2/pom.xml index a56f67b202..1b9a3e45d3 100644 --- a/persistence-modules/hibernate-mapping-2/pom.xml +++ b/persistence-modules/hibernate-mapping-2/pom.xml @@ -62,7 +62,6 @@ 6.0.6 3.0.3 - 6.1.7.Final 9.0.0.M26 4.0.2 2.1.214 diff --git a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/HibernateUtil.java b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/HibernateUtil.java new file mode 100644 index 0000000000..df409ee888 --- /dev/null +++ b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/HibernateUtil.java @@ -0,0 +1,58 @@ +package com.baeldung.hibernate; + +import static org.hibernate.boot.registry.StandardServiceRegistryBuilder.DEFAULT_CFG_RESOURCE_NAME; + +import org.hibernate.SessionFactory; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; +import org.hibernate.cfg.Configuration; +import org.hibernate.service.ServiceRegistry; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.baeldung.hibernate.booleanconverters.model.Question; +import com.baeldung.hibernate.manytomany.model.Employee; +import com.baeldung.hibernate.manytomany.model.Project; +import com.baeldung.hibernate.uuids.WebSiteUser; +import com.baeldung.hibernate.uuids.Element; +import com.baeldung.hibernate.uuids.Reservation; +import com.baeldung.hibernate.uuids.Sale; + +public class HibernateUtil { + + private static final String DEFAULT_RESOURCE = "manytomany.cfg.xml"; + private static final Logger LOGGER = LoggerFactory.getLogger(HibernateUtil.class); + + private static SessionFactory buildSessionFactory(String resource) { + try { + // Create the SessionFactory from hibernate-annotation.cfg.xml + Configuration configuration = new Configuration(); + configuration.addAnnotatedClass(Employee.class); + configuration.addAnnotatedClass(Project.class); + configuration.addAnnotatedClass(WebSiteUser.class); + configuration.addAnnotatedClass(Element.class); + configuration.addAnnotatedClass(Reservation.class); + configuration.addAnnotatedClass(Sale.class); + configuration.addAnnotatedClass(Question.class); + configuration.addPackage(Question.class.getPackageName()); + configuration.configure(resource); + LOGGER.debug("Hibernate Annotation Configuration loaded"); + + ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()) + .build(); + LOGGER.debug("Hibernate Annotation serviceRegistry created"); + + return configuration.buildSessionFactory(serviceRegistry); + } catch (Throwable ex) { + LOGGER.error("Initial SessionFactory creation failed.", ex); + throw new ExceptionInInitializerError(ex); + } + } + + public static SessionFactory getSessionFactory() { + return buildSessionFactory(DEFAULT_RESOURCE); + } + + public static SessionFactory getSessionFactory(String resource) { + return buildSessionFactory(resource); + } +} diff --git a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/booleanconverters/model/Question.java b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/booleanconverters/model/Question.java new file mode 100644 index 0000000000..be2990359f --- /dev/null +++ b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/booleanconverters/model/Question.java @@ -0,0 +1,86 @@ +package com.baeldung.hibernate.booleanconverters.model; + +import java.util.UUID; + +import org.hibernate.type.NumericBooleanConverter; +import org.hibernate.type.TrueFalseConverter; +import org.hibernate.type.YesNoConverter; + +import jakarta.persistence.Convert; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; + +@Entity +public class Question { + + @Id + private UUID id; + private String content; + @Convert(converter = YesNoConverter.class) + private Boolean correctAnswer; + @Convert(converter = TrueFalseConverter.class) + private Boolean shouldBeAsked; + @Convert(converter = NumericBooleanConverter.class) + private Boolean isEasy; + private Boolean wasAskedBefore; + + public Question() { + } + + public Question(UUID id, String content, Boolean correctAnswer, Boolean shouldBeAsked, Boolean isEasy, Boolean wasAskedBefore) { + this.id = id; + this.content = content; + this.correctAnswer = correctAnswer; + this.shouldBeAsked = shouldBeAsked; + this.isEasy = isEasy; + this.wasAskedBefore = wasAskedBefore; + } + + public UUID getId() { + return id; + } + + public String getContent() { + return content; + } + + public Boolean getCorrectAnswer() { + return correctAnswer; + } + + public Boolean getShouldBeAsked() { + return shouldBeAsked; + } + + public Boolean isEasy() { + return isEasy; + } + + public Boolean getWasAskedBefore() { + return wasAskedBefore; + } + + public void setId(UUID id) { + this.id = id; + } + + public void setContent(String content) { + this.content = content; + } + + public void setCorrectAnswer(Boolean correctAnswer) { + this.correctAnswer = correctAnswer; + } + + public void setShouldBeAsked(Boolean shouldBeAsked) { + this.shouldBeAsked = shouldBeAsked; + } + + public void setEasy(Boolean easy) { + isEasy = easy; + } + + public void setWasAskedBefore(Boolean wasAskedBefore) { + this.wasAskedBefore = wasAskedBefore; + } +} diff --git a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/booleanconverters/model/package-info.java b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/booleanconverters/model/package-info.java new file mode 100644 index 0000000000..d5041b87c0 --- /dev/null +++ b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/booleanconverters/model/package-info.java @@ -0,0 +1,5 @@ +@ConverterRegistration(converter = YesNoConverter.class) +package com.baeldung.hibernate.booleanconverters.model; + +import org.hibernate.annotations.ConverterRegistration; +import org.hibernate.type.YesNoConverter; \ No newline at end of file diff --git a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/PersistenceConfig.java b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/manytomany/PersistenceConfig.java similarity index 95% rename from persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/PersistenceConfig.java rename to persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/manytomany/PersistenceConfig.java index 0d7b8bdbcf..4ec6c9fb71 100644 --- a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/PersistenceConfig.java +++ b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/manytomany/PersistenceConfig.java @@ -1,4 +1,4 @@ -package com.baeldung.manytomany; +package com.baeldung.hibernate.manytomany; import java.util.Properties; @@ -22,7 +22,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; @Configuration @EnableTransactionManagement @PropertySource({ "classpath:persistence-h2.properties" }) -@ComponentScan({ "com.baeldung.manytomany" }) +@ComponentScan({ "com.baeldung.hibernate.manytomany" }) public class PersistenceConfig { @Autowired @@ -32,7 +32,7 @@ public class PersistenceConfig { public LocalSessionFactoryBean sessionFactory() { final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); sessionFactory.setDataSource(restDataSource()); - sessionFactory.setPackagesToScan(new String[] { "com.baeldung.manytomany" }); + sessionFactory.setPackagesToScan(new String[] { "com.baeldung.hibernate.manytomany" }); sessionFactory.setHibernateProperties(hibernateProperties()); return sessionFactory; diff --git a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/manytomany/dao/IEmployeeDao.java b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/manytomany/dao/IEmployeeDao.java new file mode 100644 index 0000000000..7bff73ecf4 --- /dev/null +++ b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/manytomany/dao/IEmployeeDao.java @@ -0,0 +1,8 @@ +package com.baeldung.hibernate.manytomany.dao; + +import com.baeldung.hibernate.manytomany.dao.common.IOperations; +import com.baeldung.hibernate.manytomany.model.Employee; + +public interface IEmployeeDao extends IOperations{ + +} diff --git a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/manytomany/dao/IProjectDao.java b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/manytomany/dao/IProjectDao.java new file mode 100644 index 0000000000..de800ae783 --- /dev/null +++ b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/manytomany/dao/IProjectDao.java @@ -0,0 +1,8 @@ +package com.baeldung.hibernate.manytomany.dao; + +import com.baeldung.hibernate.manytomany.dao.common.IOperations; +import com.baeldung.hibernate.manytomany.model.Project; + +public interface IProjectDao extends IOperations{ + +} diff --git a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/common/AbstractDao.java b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/manytomany/dao/common/AbstractDao.java similarity index 85% rename from persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/common/AbstractDao.java rename to persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/manytomany/dao/common/AbstractDao.java index b37b48e645..6ed04a9b2f 100644 --- a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/common/AbstractDao.java +++ b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/manytomany/dao/common/AbstractDao.java @@ -1,4 +1,4 @@ -package com.baeldung.manytomany.dao.common; +package com.baeldung.hibernate.manytomany.dao.common; import java.io.Serializable; diff --git a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/common/AbstractHibernateDao.java b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/manytomany/dao/common/AbstractHibernateDao.java similarity index 96% rename from persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/common/AbstractHibernateDao.java rename to persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/manytomany/dao/common/AbstractHibernateDao.java index 9c8a8faa2e..67878906ca 100644 --- a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/common/AbstractHibernateDao.java +++ b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/manytomany/dao/common/AbstractHibernateDao.java @@ -1,4 +1,4 @@ -package com.baeldung.manytomany.dao.common; +package com.baeldung.hibernate.manytomany.dao.common; import java.io.Serializable; import java.util.List; diff --git a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/common/IOperations.java b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/manytomany/dao/common/IOperations.java similarity index 85% rename from persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/common/IOperations.java rename to persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/manytomany/dao/common/IOperations.java index 8a85b52fc9..2be7fdb75e 100644 --- a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/common/IOperations.java +++ b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/manytomany/dao/common/IOperations.java @@ -1,4 +1,4 @@ -package com.baeldung.manytomany.dao.common; +package com.baeldung.hibernate.manytomany.dao.common; import java.io.Serializable; import java.util.List; diff --git a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/impl/EmployeeDao.java b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/manytomany/dao/impl/EmployeeDao.java similarity index 50% rename from persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/impl/EmployeeDao.java rename to persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/manytomany/dao/impl/EmployeeDao.java index b24013c567..d4364c00c2 100644 --- a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/impl/EmployeeDao.java +++ b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/manytomany/dao/impl/EmployeeDao.java @@ -1,10 +1,10 @@ -package com.baeldung.manytomany.dao.impl; +package com.baeldung.hibernate.manytomany.dao.impl; import org.springframework.stereotype.Repository; -import com.baeldung.manytomany.dao.IEmployeeDao; -import com.baeldung.manytomany.dao.common.AbstractHibernateDao; -import com.baeldung.manytomany.model.Employee; +import com.baeldung.hibernate.manytomany.dao.IEmployeeDao; +import com.baeldung.hibernate.manytomany.dao.common.AbstractHibernateDao; +import com.baeldung.hibernate.manytomany.model.Employee; @Repository public class EmployeeDao extends AbstractHibernateDao implements IEmployeeDao { diff --git a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/manytomany/dao/impl/ProjectDao.java b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/manytomany/dao/impl/ProjectDao.java new file mode 100644 index 0000000000..a221116013 --- /dev/null +++ b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/manytomany/dao/impl/ProjectDao.java @@ -0,0 +1,17 @@ +package com.baeldung.hibernate.manytomany.dao.impl; + +import org.springframework.stereotype.Repository; + +import com.baeldung.hibernate.manytomany.dao.IProjectDao; +import com.baeldung.hibernate.manytomany.dao.common.AbstractHibernateDao; +import com.baeldung.hibernate.manytomany.model.Project; + +@Repository +public class ProjectDao extends AbstractHibernateDao implements IProjectDao { + + public ProjectDao() { + super(); + + setClazz(Project.class); + } +} diff --git a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/model/Employee.java b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/manytomany/model/Employee.java similarity index 97% rename from persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/model/Employee.java rename to persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/manytomany/model/Employee.java index cc745f9307..d606f1281c 100644 --- a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/model/Employee.java +++ b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/manytomany/model/Employee.java @@ -1,4 +1,4 @@ -package com.baeldung.manytomany.model; +package com.baeldung.hibernate.manytomany.model; import java.io.Serializable; import java.util.HashSet; diff --git a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/model/Project.java b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/manytomany/model/Project.java similarity index 96% rename from persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/model/Project.java rename to persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/manytomany/model/Project.java index b0ca7f06cb..8ea31dbc5f 100644 --- a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/model/Project.java +++ b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/manytomany/model/Project.java @@ -1,4 +1,4 @@ -package com.baeldung.manytomany.model; +package com.baeldung.hibernate.manytomany.model; import java.io.Serializable; import java.util.HashSet; diff --git a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/uuids/Element.java b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/uuids/Element.java new file mode 100644 index 0000000000..5112c6df0f --- /dev/null +++ b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/uuids/Element.java @@ -0,0 +1,32 @@ +package com.baeldung.hibernate.uuids; + +import java.util.UUID; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import org.hibernate.annotations.UuidGenerator; + +@Entity +public class Element { + + @Id + @UuidGenerator + private String id; + + private String name; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/uuids/Reservation.java b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/uuids/Reservation.java new file mode 100644 index 0000000000..389376e785 --- /dev/null +++ b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/uuids/Reservation.java @@ -0,0 +1,43 @@ +package com.baeldung.hibernate.uuids; + +import java.util.UUID; +import jakarta.persistence.Id; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; + +@Entity +public class Reservation { + + @Id + @GeneratedValue(strategy = GenerationType.UUID) + private UUID id; + + private String status; + + private String number; + + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getNumber() { + return number; + } + + public void setNumber(String number) { + this.number = number; + } +} diff --git a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/uuids/Sale.java b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/uuids/Sale.java new file mode 100644 index 0000000000..8eaab80912 --- /dev/null +++ b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/uuids/Sale.java @@ -0,0 +1,36 @@ +package com.baeldung.hibernate.uuids; + +import jakarta.persistence.Id; +import jakarta.persistence.Entity; +import org.hibernate.annotations.UuidGenerator; + +import java.util.UUID; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import org.hibernate.annotations.UuidGenerator; + +@Entity +public class Sale { + + @Id + @UuidGenerator + private UUID id; + + private boolean completed; + + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public boolean isCompleted() { + return completed; + } + + public void setCompleted(boolean completed) { + this.completed = completed; + } +} \ No newline at end of file diff --git a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/uuids/WebSiteUser.java b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/uuids/WebSiteUser.java new file mode 100644 index 0000000000..b1a115a3b9 --- /dev/null +++ b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/hibernate/uuids/WebSiteUser.java @@ -0,0 +1,33 @@ +package com.baeldung.hibernate.uuids; + +import java.util.UUID; +import java.time.LocalDate; +import jakarta.persistence.Id; +import jakarta.persistence.Entity; +import org.hibernate.annotations.UuidGenerator; + +@Entity +public class WebSiteUser { + + @Id + @UuidGenerator(style = UuidGenerator.Style.TIME) + private UUID id; + + private LocalDate registrationDate; + + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public LocalDate getRegistrationDate() { + return registrationDate; + } + + public void setRegistrationDate(LocalDate registrationDate) { + this.registrationDate = registrationDate; + } +} diff --git a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/IEmployeeDao.java b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/IEmployeeDao.java deleted file mode 100644 index 68bf5d5bad..0000000000 --- a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/IEmployeeDao.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.baeldung.manytomany.dao; - -import com.baeldung.manytomany.dao.common.IOperations; -import com.baeldung.manytomany.model.Employee; - -public interface IEmployeeDao extends IOperations{ - -} diff --git a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/IProjectDao.java b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/IProjectDao.java deleted file mode 100644 index d2645db44a..0000000000 --- a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/IProjectDao.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.baeldung.manytomany.dao; - -import com.baeldung.manytomany.dao.common.IOperations; -import com.baeldung.manytomany.model.Project; - -public interface IProjectDao extends IOperations{ - -} diff --git a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/impl/ProjectDao.java b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/impl/ProjectDao.java deleted file mode 100644 index a70212f519..0000000000 --- a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/dao/impl/ProjectDao.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.baeldung.manytomany.dao.impl; - -import org.springframework.stereotype.Repository; - -import com.baeldung.manytomany.dao.IProjectDao; -import com.baeldung.manytomany.dao.common.AbstractHibernateDao; -import com.baeldung.manytomany.model.Project; - - -@Repository -public class ProjectDao extends AbstractHibernateDao implements IProjectDao { - - public ProjectDao() { - super(); - - setClazz(Project.class); - } -} diff --git a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/util/HibernateUtil.java b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/util/HibernateUtil.java deleted file mode 100644 index d429564564..0000000000 --- a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/util/HibernateUtil.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.baeldung.manytomany.util; - -import org.hibernate.SessionFactory; -import org.hibernate.boot.registry.StandardServiceRegistryBuilder; -import org.hibernate.cfg.Configuration; -import org.hibernate.service.ServiceRegistry; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.baeldung.manytomany.model.Employee; -import com.baeldung.manytomany.model.Project; - -public class HibernateUtil { - - private static final Logger LOGGER = LoggerFactory.getLogger(HibernateUtil.class); - private static SessionFactory sessionFactory; - - private static SessionFactory buildSessionFactory() { - try { - // Create the SessionFactory from hibernate-annotation.cfg.xml - Configuration configuration = new Configuration(); - configuration.addAnnotatedClass(Employee.class); - configuration.addAnnotatedClass(Project.class); - configuration.configure("manytomany.cfg.xml"); - LOGGER.debug("Hibernate Annotation Configuration loaded"); - - ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()) - .build(); - LOGGER.debug("Hibernate Annotation serviceRegistry created"); - - SessionFactory sessionFactory = configuration.buildSessionFactory(serviceRegistry); - - return sessionFactory; - } catch (Throwable ex) { - LOGGER.error("Initial SessionFactory creation failed.", ex); - throw new ExceptionInInitializerError(ex); - } - } - - public static SessionFactory getSessionFactory() { - if (sessionFactory == null) { - sessionFactory = buildSessionFactory(); - } - return sessionFactory; - } -} diff --git a/persistence-modules/hibernate-mapping-2/src/test/java/com/baeldung/SpringContextTest.java b/persistence-modules/hibernate-mapping-2/src/test/java/com/baeldung/SpringContextTest.java index f1a6f675ce..e1650dccd2 100644 --- a/persistence-modules/hibernate-mapping-2/src/test/java/com/baeldung/SpringContextTest.java +++ b/persistence-modules/hibernate-mapping-2/src/test/java/com/baeldung/SpringContextTest.java @@ -6,7 +6,7 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; -import com.baeldung.manytomany.PersistenceConfig; +import com.baeldung.hibernate.manytomany.PersistenceConfig; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) diff --git a/persistence-modules/hibernate-mapping-2/src/test/java/com/baeldung/hibernate/booleanconverters/HibernateBooleanConverterIntegrationTest.java b/persistence-modules/hibernate-mapping-2/src/test/java/com/baeldung/hibernate/booleanconverters/HibernateBooleanConverterIntegrationTest.java new file mode 100644 index 0000000000..3235485e96 --- /dev/null +++ b/persistence-modules/hibernate-mapping-2/src/test/java/com/baeldung/hibernate/booleanconverters/HibernateBooleanConverterIntegrationTest.java @@ -0,0 +1,158 @@ +package com.baeldung.hibernate.booleanconverters; + +import static java.lang.String.format; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + +import java.util.UUID; + +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.baeldung.hibernate.HibernateUtil; +import com.baeldung.hibernate.booleanconverters.model.Question; + +public class HibernateBooleanConverterIntegrationTest { + + private static final String PROPERTY_FILE_NAME = "booleanconverters.cfg.xml"; + + private static SessionFactory sessionFactory; + private static Session session; + + @BeforeAll + static void createSessionFactory() { + sessionFactory = HibernateUtil.getSessionFactory(PROPERTY_FILE_NAME); + } + + @BeforeEach + void openSessionAndBeginTransaction() { + session = sessionFactory.openSession(); + } + + @AfterAll + static void closeSessionFactory() { + sessionFactory.close(); + } + + @Test + void whenFieldAnnotatedWithYesNoConverter_ThenConversionWorks() { + session.beginTransaction(); + UUID likeJavaQuestionId = UUID.randomUUID(); + UUID sydneyCapitalOfAustraliaQuestionId = UUID.randomUUID(); + session.persist(new QuestionBuilder().id(likeJavaQuestionId) + .content("Do you like Java?") + .correctAnswer(true) + .build()); + session.persist(new QuestionBuilder().id(sydneyCapitalOfAustraliaQuestionId) + .content("Is Sydney the capital of Australia?") + .correctAnswer(false) + .build()); + session.flush(); + + char likeJavaQuestionCorrectAnswerDbValue = session.createNativeQuery(format("SELECT correctAnswer FROM Question WHERE id='%s'", likeJavaQuestionId), Character.class) + .getSingleResult(); + char sydneyCapitalOfAustraliaQuestionCorrectAnswerDbValue = session.createNativeQuery(format("SELECT correctAnswer FROM Question WHERE id='%s'", sydneyCapitalOfAustraliaQuestionId), Character.class) + .getSingleResult(); + session.close(); + + assertEquals('Y', likeJavaQuestionCorrectAnswerDbValue); + assertEquals('N', sydneyCapitalOfAustraliaQuestionCorrectAnswerDbValue); + } + + @Test + void whenFieldAnnotatedWithTrueFalseConverter_ThenConversionWorks() { + session.beginTransaction(); + UUID codeTestedQuestionId = UUID.randomUUID(); + UUID earningsQuestionId = UUID.randomUUID(); + session.persist(new QuestionBuilder().id(codeTestedQuestionId) + .content("Is this code tested?") + .shouldBeAsked(true) + .build()); + session.persist(new QuestionBuilder().id(earningsQuestionId) + .content("How much do you earn?") + .shouldBeAsked(false) + .build()); + session.flush(); + + char codeTestedQuestionShouldBeAskedDbValue = session.createNativeQuery(format("SELECT shouldBeAsked FROM Question WHERE id='%s'", codeTestedQuestionId), Character.class) + .getSingleResult(); + char earningsQuestionsShouldBeAskedDbValue = session.createNativeQuery(format("SELECT shouldBeAsked FROM Question WHERE id='%s'", earningsQuestionId), Character.class) + .getSingleResult(); + session.close(); + + assertEquals('T', codeTestedQuestionShouldBeAskedDbValue); + assertEquals('F', earningsQuestionsShouldBeAskedDbValue); + } + + @Test + void whenFieldAnnotatedWithNumericBooleanConverter_ThenConversionWorks() { + session.beginTransaction(); + UUID earthFlatQuestionId = UUID.randomUUID(); + UUID shouldLearnProgrammingQuestionId = UUID.randomUUID(); + session.persist(new QuestionBuilder().id(earthFlatQuestionId) + .content("Is the Earth flat?") + .isEasy(true) + .build()); + session.persist(new QuestionBuilder().id(shouldLearnProgrammingQuestionId) + .content("Should one learn programming") + .isEasy(false) + .build()); + session.flush(); + + int earthFlatQuestionIsEasyDbValue = session.createNativeQuery(format("SELECT isEasy FROM Question WHERE id='%s'", earthFlatQuestionId), Integer.class) + .getSingleResult(); + int shouldLearnProgrammingQuestionIsEasyDbValue = session.createNativeQuery(format("SELECT isEasy FROM Question WHERE id='%s'", shouldLearnProgrammingQuestionId), Integer.class) + .getSingleResult(); + session.close(); + + assertEquals(1, earthFlatQuestionIsEasyDbValue); + assertEquals(0, shouldLearnProgrammingQuestionIsEasyDbValue); + } + + @Test + void givenFieldAnnotatedWithYesNoConverter_WhenDbValueIsLowercase_ThenDomainModelValueNull() { + session.beginTransaction(); + UUID mappedToNullQuestionId = UUID.randomUUID(); + UUID behaviorIntuitiveQuestionId = UUID.randomUUID(); + session.createNativeMutationQuery(format("INSERT INTO Question (id, content, correctAnswer) VALUES ('%s', 'Will correctAnswer be mapped to null?', 'y')", mappedToNullQuestionId)) + .executeUpdate(); + session.createNativeMutationQuery(format("INSERT INTO Question (id, content, correctAnswer) VALUES ('%s', 'Is this behavior intuitive?', 'n')", behaviorIntuitiveQuestionId)) + .executeUpdate(); + + Question behaviorIntuitiveQuestion = session.get(Question.class, behaviorIntuitiveQuestionId); + Question mappedToNullQuestion = session.get(Question.class, mappedToNullQuestionId); + session.close(); + + assertNull(behaviorIntuitiveQuestion.getCorrectAnswer()); + assertNull(mappedToNullQuestion.getCorrectAnswer()); + } + + @Test + void givenConverterRegisteredToAutoApply_whenFieldIsNotAnnotated_ThenConversionWorks() { + session.beginTransaction(); + UUID likeJavaQuestionId = UUID.randomUUID(); + UUID likeKotlinQuestionId = UUID.randomUUID(); + session.persist(new QuestionBuilder().id(likeJavaQuestionId) + .content("Do you like Java?") + .wasAskedBefore(true) + .build()); + session.persist(new QuestionBuilder().id(likeKotlinQuestionId) + .content("Do you like Kotlin?") + .wasAskedBefore(false) + .build()); + session.flush(); + + char likeJavaQuestionWasAskedBeforeDbValue = session.createNativeQuery(format("SELECT wasAskedBefore FROM Question WHERE id='%s'", likeJavaQuestionId), Character.class) + .getSingleResult(); + char likeKotlinQuestionWasAskedBeforeDbValue = session.createNativeQuery(format("SELECT wasAskedBefore FROM Question WHERE id='%s'", likeKotlinQuestionId), Character.class) + .getSingleResult(); + session.close(); + + assertEquals('Y', likeJavaQuestionWasAskedBeforeDbValue); + assertEquals('N', likeKotlinQuestionWasAskedBeforeDbValue); + } +} diff --git a/persistence-modules/hibernate-mapping-2/src/test/java/com/baeldung/hibernate/booleanconverters/QuestionBuilder.java b/persistence-modules/hibernate-mapping-2/src/test/java/com/baeldung/hibernate/booleanconverters/QuestionBuilder.java new file mode 100644 index 0000000000..26fe38c3c8 --- /dev/null +++ b/persistence-modules/hibernate-mapping-2/src/test/java/com/baeldung/hibernate/booleanconverters/QuestionBuilder.java @@ -0,0 +1,48 @@ +package com.baeldung.hibernate.booleanconverters; + +import java.util.UUID; + +import com.baeldung.hibernate.booleanconverters.model.Question; + +public class QuestionBuilder { + private UUID id; + private String content; + private Boolean correctAnswer; + private Boolean shouldBeAsked; + private Boolean isEasy; + private Boolean wasAskedBefore; + + public QuestionBuilder id(UUID id) { + this.id = id; + return this; + } + + public QuestionBuilder content(String content) { + this.content = content; + return this; + } + + public QuestionBuilder correctAnswer(Boolean correctAnswer) { + this.correctAnswer = correctAnswer; + return this; + } + + public QuestionBuilder shouldBeAsked(Boolean shouldBeAsked) { + this.shouldBeAsked = shouldBeAsked; + return this; + } + + public QuestionBuilder isEasy(Boolean isEasy) { + this.isEasy = isEasy; + return this; + } + + public QuestionBuilder wasAskedBefore(Boolean wasAskedBefore) { + this.wasAskedBefore = wasAskedBefore; + return this; + } + + public Question build() { + return new Question(id, content, correctAnswer, shouldBeAsked, isEasy, wasAskedBefore); + } +} \ No newline at end of file diff --git a/persistence-modules/hibernate-mapping-2/src/test/java/com/baeldung/hibernate/manytomany/HibernateManyToManyAnnotationJavaConfigMainIntegrationTest.java b/persistence-modules/hibernate-mapping-2/src/test/java/com/baeldung/hibernate/manytomany/HibernateManyToManyAnnotationJavaConfigMainIntegrationTest.java index 69b791b4d4..e4fcafcb56 100644 --- a/persistence-modules/hibernate-mapping-2/src/test/java/com/baeldung/hibernate/manytomany/HibernateManyToManyAnnotationJavaConfigMainIntegrationTest.java +++ b/persistence-modules/hibernate-mapping-2/src/test/java/com/baeldung/hibernate/manytomany/HibernateManyToManyAnnotationJavaConfigMainIntegrationTest.java @@ -13,9 +13,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; -import com.baeldung.manytomany.PersistenceConfig; -import com.baeldung.manytomany.model.Employee; -import com.baeldung.manytomany.model.Project; + +import com.baeldung.hibernate.manytomany.model.Employee; +import com.baeldung.hibernate.manytomany.model.Project; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) diff --git a/persistence-modules/hibernate-mapping-2/src/test/java/com/baeldung/hibernate/manytomany/HibernateManyToManyAnnotationMainIntegrationTest.java b/persistence-modules/hibernate-mapping-2/src/test/java/com/baeldung/hibernate/manytomany/HibernateManyToManyAnnotationMainIntegrationTest.java index 5255cb040f..7c6861e63b 100644 --- a/persistence-modules/hibernate-mapping-2/src/test/java/com/baeldung/hibernate/manytomany/HibernateManyToManyAnnotationMainIntegrationTest.java +++ b/persistence-modules/hibernate-mapping-2/src/test/java/com/baeldung/hibernate/manytomany/HibernateManyToManyAnnotationMainIntegrationTest.java @@ -15,9 +15,9 @@ import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; -import com.baeldung.manytomany.model.Employee; -import com.baeldung.manytomany.model.Project; -import com.baeldung.manytomany.util.HibernateUtil; +import com.baeldung.hibernate.manytomany.model.Employee; +import com.baeldung.hibernate.manytomany.model.Project; +import com.baeldung.hibernate.HibernateUtil; /** * Configured in: manytomany.cfg.xml diff --git a/persistence-modules/hibernate-mapping-2/src/test/java/com/baeldung/hibernate/uuids/UUIDsHibernateGenerationIntegrationTest.java b/persistence-modules/hibernate-mapping-2/src/test/java/com/baeldung/hibernate/uuids/UUIDsHibernateGenerationIntegrationTest.java new file mode 100644 index 0000000000..f36a4333c3 --- /dev/null +++ b/persistence-modules/hibernate-mapping-2/src/test/java/com/baeldung/hibernate/uuids/UUIDsHibernateGenerationIntegrationTest.java @@ -0,0 +1,72 @@ +package com.baeldung.hibernate.uuids; + +import com.baeldung.hibernate.HibernateUtil; + +import org.assertj.core.api.Assertions; +import java.io.IOException; + +import org.hibernate.SessionFactory; +import org.hibernate.Session; +import org.junit.Before; +import org.junit.Test; +import java.util.UUID; +import java.time.LocalDate; + +public class UUIDsHibernateGenerationIntegrationTest { + + private SessionFactory sessionFactory; + + private Session session; + + @Before + public void setUp() throws IOException { + sessionFactory = HibernateUtil.getSessionFactory(); + session = sessionFactory.openSession(); + } + + @Test + public void whenGeneratingUUIDUsingNewJPAGenerationType_thenHibernateGeneratedUUID() throws IOException { + Reservation reservation = new Reservation(); + reservation.setStatus("created"); + reservation.setNumber("12345"); + UUID saved = (UUID) session.save(reservation); + Assertions.assertThat(saved).isNotNull(); + } + + @Test + public void whenGeneratingUUIDUsingNewJPAGenerationType_thenHibernateGeneratedUUIDOfVersion4() throws IOException { + Reservation reservation = new Reservation(); + reservation.setStatus("new"); + reservation.setNumber("012"); + UUID saved = (UUID) session.save(reservation); + Assertions.assertThat(saved).isNotNull(); + Assertions.assertThat(saved.version()).isEqualTo(4); + } + + @Test + public void whenGeneratingUUIDUsingGenericConverter_thenAlsoGetUUIDGeneratedVersion4() throws IOException { + Sale sale = new Sale(); + sale.setCompleted(true); + UUID saved = (UUID) session.save(sale); + Assertions.assertThat(saved).isNotNull(); + Assertions.assertThat(saved.version()).isEqualTo(4); + } + + @Test + public void whenGeneratingTimeBasedUUID_thenUUIDGeneratedVersion1() throws IOException { + WebSiteUser user = new WebSiteUser(); + user.setRegistrationDate(LocalDate.now()); + UUID saved = (UUID) session.save(user); + Assertions.assertThat(saved).isNotNull(); + Assertions.assertThat(saved.version()).isEqualTo(1); + } + + @Test + public void whenGeneratingUUIDAsString_thenUUIDGeneratedVersion1() throws IOException { + Element element = new Element(); + element.setName("a"); + String saved = (String) session.save(element); + Assertions.assertThat(saved).isNotEmpty(); + Assertions.assertThat(UUID.fromString(saved).version()).isEqualTo(4); + } +} \ No newline at end of file diff --git a/persistence-modules/hibernate-mapping-2/src/test/resources/booleanconverters.cfg.xml b/persistence-modules/hibernate-mapping-2/src/test/resources/booleanconverters.cfg.xml new file mode 100644 index 0000000000..6ca479b052 --- /dev/null +++ b/persistence-modules/hibernate-mapping-2/src/test/resources/booleanconverters.cfg.xml @@ -0,0 +1,16 @@ + + + + + org.h2.Driver + + jdbc:h2:mem:booleanconvertersdb;DB_CLOSE_DELAY=-1;INIT=RUNSCRIPT FROM 'src/test/resources/booleanconverters/init_database.sql' + sa + org.hibernate.dialect.H2Dialect + thread + false + none + + \ No newline at end of file diff --git a/persistence-modules/hibernate-mapping-2/src/test/resources/booleanconverters/init_database.sql b/persistence-modules/hibernate-mapping-2/src/test/resources/booleanconverters/init_database.sql new file mode 100644 index 0000000000..cb0f4f329c --- /dev/null +++ b/persistence-modules/hibernate-mapping-2/src/test/resources/booleanconverters/init_database.sql @@ -0,0 +1,9 @@ +CREATE TABLE Question ( + id UUID, + content VARCHAR, + correctAnswer CHAR, + shouldBeAsked CHAR, + isEasy TINYINT, + wasAskedBefore CHAR, + PRIMARY KEY (id) +) diff --git a/persistence-modules/pom.xml b/persistence-modules/pom.xml index 85cf251d18..46ac9b50f1 100644 --- a/persistence-modules/pom.xml +++ b/persistence-modules/pom.xml @@ -114,10 +114,10 @@ - 6.1.7.Final + 6.2.0.Final 42.5.4 2.3.4 1.16.3 - \ No newline at end of file + diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2/exceptions/SpringBootH2Exceptions.java b/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2/exceptions/SpringBootH2Exceptions.java new file mode 100644 index 0000000000..c7684423a2 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2/exceptions/SpringBootH2Exceptions.java @@ -0,0 +1,15 @@ +package com.baeldung.h2.exceptions; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.PropertySource; + +@SpringBootApplication +@PropertySource("classpath:app-h2.properties") +public class SpringBootH2Exceptions { + + public static void main(String... args) { + SpringApplication.run(SpringBootH2Exceptions.class, args); + } + +} diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2/exceptions/models/User.java b/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2/exceptions/models/User.java new file mode 100644 index 0000000000..e54e725fd0 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2/exceptions/models/User.java @@ -0,0 +1,38 @@ +package com.baeldung.h2.exceptions.models; + +import javax.persistence.Entity; +import javax.persistence.Id; + +@Entity +public class User { + + @Id + private int id; + private String login; + private String password; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getLogin() { + return login; + } + + public void setLogin(String login) { + this.login = login; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + +} diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2/exceptions/repos/UserRepository.java b/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2/exceptions/repos/UserRepository.java new file mode 100644 index 0000000000..d014fb16c6 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2/exceptions/repos/UserRepository.java @@ -0,0 +1,11 @@ +package com.baeldung.h2.exceptions.repos; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import com.baeldung.h2.exceptions.models.User; + +@Repository +public interface UserRepository extends JpaRepository { + +} diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/resources/app-h2.properties b/persistence-modules/spring-boot-persistence-h2/src/main/resources/app-h2.properties new file mode 100644 index 0000000000..bb88e7fef4 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-h2/src/main/resources/app-h2.properties @@ -0,0 +1 @@ +spring.sql.init.data-locations=user-data.sql diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/resources/user-data.sql b/persistence-modules/spring-boot-persistence-h2/src/main/resources/user-data.sql new file mode 100644 index 0000000000..cea758c74e --- /dev/null +++ b/persistence-modules/spring-boot-persistence-h2/src/main/resources/user-data.sql @@ -0,0 +1,8 @@ +/* These commented lines will cause Spring Boot to fail at startup + * + * INSERT INTO user VALUES (1, 'admin', 'p@ssw@rd'); + * INSERT INTO user VALUES (2, 'user', 'userpasswd'); + * +*/ +INSERT INTO "user" VALUES (1, 'admin', 'p@ssw@rd'); +INSERT INTO "user" VALUES (2, 'user', 'userpasswd'); \ No newline at end of file diff --git a/persistence-modules/spring-boot-persistence-h2/src/test/java/com/baeldung/h2/exceptions/SpringBootH2ExceptionsIntegrationTest.java b/persistence-modules/spring-boot-persistence-h2/src/test/java/com/baeldung/h2/exceptions/SpringBootH2ExceptionsIntegrationTest.java new file mode 100644 index 0000000000..94cf08fb76 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-h2/src/test/java/com/baeldung/h2/exceptions/SpringBootH2ExceptionsIntegrationTest.java @@ -0,0 +1,30 @@ +package com.baeldung.h2.exceptions; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.List; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import com.baeldung.h2.exceptions.models.User; +import com.baeldung.h2.exceptions.repos.UserRepository; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = SpringBootH2Exceptions.class) +public class SpringBootH2ExceptionsIntegrationTest { + + @Autowired + private UserRepository userRepository; + + @Test + public void givenValidInitData_whenCallingFindAll_thenReturnData() { + List users = userRepository.findAll(); + + assertThat(users).hasSize(2); + } + +} diff --git a/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/dataloading/ApplicationDataLoading.java b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/dataloading/ApplicationDataLoading.java index 619f0e0411..40742d303e 100644 --- a/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/dataloading/ApplicationDataLoading.java +++ b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/dataloading/ApplicationDataLoading.java @@ -2,19 +2,15 @@ package com.baeldung.dataloading; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.ApplicationContext; import org.springframework.core.env.AbstractEnvironment; -import com.baeldung.boot.Application; - @SpringBootApplication(scanBasePackages = { "com.baeldung.dataloading" }) public class ApplicationDataLoading { - private static ApplicationContext applicationContext; - public static void main(String[] args) { - System.setProperty(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME, "datasource"); + public static void main(String[] args) { + System.setProperty(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME, "datasource"); - applicationContext = SpringApplication.run(Application.class, args); - } + SpringApplication.run(ApplicationDataLoading.class, args); + } } diff --git a/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/dataloading/model/Country.java b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/dataloading/model/Country.java new file mode 100644 index 0000000000..692d48caf0 --- /dev/null +++ b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/dataloading/model/Country.java @@ -0,0 +1,36 @@ +package com.baeldung.dataloading.model; + +import static javax.persistence.GenerationType.IDENTITY; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +@Entity +public class Country { + + @Id + @GeneratedValue(strategy = IDENTITY) + private Integer id; + + @Column(nullable = false) + private String name; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + +} diff --git a/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/dataloading/model/User.java b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/dataloading/model/User.java deleted file mode 100644 index e0927f3646..0000000000 --- a/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/dataloading/model/User.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.baeldung.dataloading.model; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.Table; - -@Entity -@Table(name = "users") -public class User { - - @Id - @GeneratedValue - private Integer id; - private String name; - private Integer status; - - public User() { - } - - public User(String name, Integer status) { - this.name = name; - this.status = status; - } - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Integer getStatus() { - return status; - } - - public void setStatus(Integer status) { - this.status = status; - } -} diff --git a/persistence-modules/spring-boot-persistence/src/main/resources/application-datasource.properties b/persistence-modules/spring-boot-persistence/src/main/resources/application-datasource.properties index 11f409719f..98cf2ba965 100644 --- a/persistence-modules/spring-boot-persistence/src/main/resources/application-datasource.properties +++ b/persistence-modules/spring-boot-persistence/src/main/resources/application-datasource.properties @@ -2,10 +2,13 @@ spring.datasource.driver-class-name=org.h2.Driver spring.datasource.url=jdbc:h2:mem:db;DB_CLOSE_DELAY=-1 spring.datasource.username=sa spring.datasource.password= -spring.jpa.hibernate.ddl-auto=none + +spring.jpa.database-platform=org.hibernate.dialect.H2Dialect +spring.jpa.hibernate.ddl-auto=create +spring.jpa.defer-datasource-initialization=true + # Enabling H2 Console spring.h2.console.enabled=true -# Uppercase Table Names -spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl -hibernate.globally_quoted_identifiers=true -spring.jpa.database-platform=org.hibernate.dialect.H2Dialect + +# By default enabled for Embedded Databases +#spring.sql.init.mode=always \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-repo-3/src/main/java/com/baeldung/spring/data/jpa/listrepositories/entity/Library.java b/persistence-modules/spring-data-jpa-repo-3/src/main/java/com/baeldung/spring/data/jpa/listrepositories/entity/Library.java new file mode 100644 index 0000000000..04c0ad5e0a --- /dev/null +++ b/persistence-modules/spring-data-jpa-repo-3/src/main/java/com/baeldung/spring/data/jpa/listrepositories/entity/Library.java @@ -0,0 +1,66 @@ +package com.baeldung.spring.data.jpa.listrepositories.entity; + +import jakarta.persistence.*; + +import java.util.ArrayList; +import java.util.List; + +@Entity(name = "library") +public class Library { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + private String name; + + @Convert(converter = StringListConverter.class) + @Column(name = "addresses", nullable = false) + private List addresses = new ArrayList<>(); + + @ElementCollection(targetClass = String.class, fetch = FetchType.EAGER) + @CollectionTable(name = "book", joinColumns = @JoinColumn(name = "library_id")) + @Column(name = "book", nullable = false) + private List books = new ArrayList<>(); + + public Library() { + } + + public Library(String name, List addresses, List books) { + this.name = name; + this.addresses = addresses; + this.books = books; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List getAddresses() { + return addresses; + } + + public void setAddresses(List addresses) { + this.addresses = addresses; + } + + public List getBooks() { + return books; + } + + public void setBooks(List books) { + this.books = books; + } +} diff --git a/persistence-modules/spring-data-jpa-repo-3/src/main/java/com/baeldung/spring/data/jpa/listrepositories/entity/StringListConverter.java b/persistence-modules/spring-data-jpa-repo-3/src/main/java/com/baeldung/spring/data/jpa/listrepositories/entity/StringListConverter.java new file mode 100644 index 0000000000..ffc097ee18 --- /dev/null +++ b/persistence-modules/spring-data-jpa-repo-3/src/main/java/com/baeldung/spring/data/jpa/listrepositories/entity/StringListConverter.java @@ -0,0 +1,25 @@ +package com.baeldung.spring.data.jpa.listrepositories.entity; + +import jakarta.persistence.AttributeConverter; +import jakarta.persistence.Converter; + +import java.util.Arrays; +import java.util.List; + + +import static java.util.Collections.*; + +@Converter +public class StringListConverter implements AttributeConverter, String> { + private static final String SPLIT_CHAR = ";"; + + @Override + public String convertToDatabaseColumn(List stringList) { + return stringList != null ? String.join(SPLIT_CHAR, stringList) : ""; + } + + @Override + public List convertToEntityAttribute(String string) { + return string != null ? Arrays.asList(string.split(SPLIT_CHAR)) : emptyList(); + } +} \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-repo-3/src/main/java/com/baeldung/spring/data/jpa/listrepositories/repository/LibraryRepository.java b/persistence-modules/spring-data-jpa-repo-3/src/main/java/com/baeldung/spring/data/jpa/listrepositories/repository/LibraryRepository.java new file mode 100644 index 0000000000..71deb04b3e --- /dev/null +++ b/persistence-modules/spring-data-jpa-repo-3/src/main/java/com/baeldung/spring/data/jpa/listrepositories/repository/LibraryRepository.java @@ -0,0 +1,13 @@ +package com.baeldung.spring.data.jpa.listrepositories.repository; + +import com.baeldung.spring.data.jpa.listrepositories.entity.Library; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +@Repository +public interface LibraryRepository extends CrudRepository { + @Query("SELECT l FROM library l JOIN FETCH l.books WHERE l.id = (:id)") + Library findById(@Param("id") long id); +} diff --git a/persistence-modules/spring-data-jpa-repo-3/src/test/java/com/baeldung/spring/data/jpa/listrepositories/repository/LibraryIntegrationTest.java b/persistence-modules/spring-data-jpa-repo-3/src/test/java/com/baeldung/spring/data/jpa/listrepositories/repository/LibraryIntegrationTest.java new file mode 100644 index 0000000000..7bd1b90407 --- /dev/null +++ b/persistence-modules/spring-data-jpa-repo-3/src/test/java/com/baeldung/spring/data/jpa/listrepositories/repository/LibraryIntegrationTest.java @@ -0,0 +1,32 @@ +package com.baeldung.spring.data.jpa.listrepositories.repository; + +import com.baeldung.spring.data.jpa.listrepositories.entity.Library; +import jakarta.transaction.Transactional; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +import java.util.Arrays; + +@SpringBootTest +public class LibraryIntegrationTest { + + @Autowired + private LibraryRepository libraryRepository; + + @Test + @Transactional + public void givenLibrary_whenGetAddressesAndGetBooks_thenGetListOfItems(){ + Library library = new Library(); + library.setAddresses(Arrays.asList("Address 1", "Address 2")); + library.setBooks(Arrays.asList("Book 1", "Book 2")); + + libraryRepository.save(library); + Library lib = libraryRepository.findById(library.getId().longValue()); + + Assertions.assertEquals(2, lib.getAddresses().size()); + Assertions.assertEquals(2, lib.getBooks().size()); + } + +} diff --git a/pom.xml b/pom.xml index 428aa1d268..7bca64c424 100644 --- a/pom.xml +++ b/pom.xml @@ -333,7 +333,6 @@ checker-framework - core-java-modules/core-java core-java-modules/core-java-8 core-java-modules/core-java-8-2 core-java-modules/core-java-8-datetime @@ -354,8 +353,6 @@ - java-jdi - jetbrains language-interop @@ -366,7 +363,6 @@ muleesb - web-modules persistence-modules/deltaspike @@ -415,7 +411,6 @@ spring-4 spring-aop - spring-bom spring-cloud-modules @@ -526,7 +521,6 @@ checker-framework - core-java-modules/core-java core-java-modules/core-java-8 core-java-modules/core-java-8-2 core-java-modules/core-java-8-datetime @@ -547,8 +541,6 @@ - java-jdi - language-interop @@ -557,7 +549,6 @@ lombok-modules/lombok-custom muleesb - web-modules persistence-modules/deltaspike @@ -597,7 +588,6 @@ spring-4 - spring-bom spring-cloud-modules @@ -800,7 +790,6 @@ custom-pmd - spring-core-6 data-structures ddd-contexts jackson-modules @@ -843,7 +832,6 @@ apache-olingo apache-poi-2 - apache-rocketmq apache-thrift apache-tika @@ -856,7 +844,6 @@ bazel google-auto-project ddd - discord4j disruptor dozer dubbo @@ -868,7 +855,7 @@ hystrix jackson-simple java-blockchain - + java-jdi java-rmi java-spi javax-sound @@ -913,7 +900,6 @@ protobuffer reactor-core rsocket - slack @@ -923,7 +909,7 @@ spring-activiti spring-core-2 spring-core-3 - spring-core-5 + spring-credhub spring-di-3 spring-cucumber @@ -948,6 +934,7 @@ persistence-modules/questdb vaadin libraries-3 + web-modules/apache-tapestry @@ -1053,7 +1040,6 @@ spring-aop spring-aop-2 custom-pmd - spring-core-6 data-structures ddd-contexts jackson-modules @@ -1096,7 +1082,6 @@ apache-olingo apache-poi-2 - apache-rocketmq apache-thrift apache-tika @@ -1109,7 +1094,6 @@ bazel google-auto-project ddd - discord4j disruptor dozer @@ -1123,7 +1107,7 @@ hystrix jackson-simple java-blockchain - + java-jdi java-rmi java-spi javax-sound @@ -1152,6 +1136,7 @@ libraries-http libraries-http-2 libraries-io + libraries-ai libraries-primitive libraries-rpc libraries-server @@ -1167,7 +1152,6 @@ protobuffer reactor-core rsocket - slack @@ -1178,7 +1162,7 @@ spring-activiti spring-core-2 spring-core-3 - spring-core-5 + spring-credhub spring-di-3 spring-cucumber @@ -1202,6 +1186,7 @@ persistence-modules/questdb vaadin libraries-3 + web-modules/apache-tapestry diff --git a/discord4j/.gitignore b/saas-modules/discord4j/.gitignore similarity index 100% rename from discord4j/.gitignore rename to saas-modules/discord4j/.gitignore diff --git a/discord4j/README.md b/saas-modules/discord4j/README.md similarity index 100% rename from discord4j/README.md rename to saas-modules/discord4j/README.md diff --git a/discord4j/pom.xml b/saas-modules/discord4j/pom.xml similarity index 93% rename from discord4j/pom.xml rename to saas-modules/discord4j/pom.xml index 086adebee5..ff398dd1a3 100644 --- a/discord4j/pom.xml +++ b/saas-modules/discord4j/pom.xml @@ -9,9 +9,8 @@ com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../parent-boot-2 + saas-modules + 1.0.0-SNAPSHOT diff --git a/discord4j/src/main/java/com/baeldung/discordbot/BotConfiguration.java b/saas-modules/discord4j/src/main/java/com/baeldung/discordbot/BotConfiguration.java similarity index 100% rename from discord4j/src/main/java/com/baeldung/discordbot/BotConfiguration.java rename to saas-modules/discord4j/src/main/java/com/baeldung/discordbot/BotConfiguration.java diff --git a/discord4j/src/main/java/com/baeldung/discordbot/DiscordBotApplication.java b/saas-modules/discord4j/src/main/java/com/baeldung/discordbot/DiscordBotApplication.java similarity index 100% rename from discord4j/src/main/java/com/baeldung/discordbot/DiscordBotApplication.java rename to saas-modules/discord4j/src/main/java/com/baeldung/discordbot/DiscordBotApplication.java diff --git a/discord4j/src/main/java/com/baeldung/discordbot/events/EventListener.java b/saas-modules/discord4j/src/main/java/com/baeldung/discordbot/events/EventListener.java similarity index 100% rename from discord4j/src/main/java/com/baeldung/discordbot/events/EventListener.java rename to saas-modules/discord4j/src/main/java/com/baeldung/discordbot/events/EventListener.java diff --git a/discord4j/src/main/java/com/baeldung/discordbot/events/MessageCreateListener.java b/saas-modules/discord4j/src/main/java/com/baeldung/discordbot/events/MessageCreateListener.java similarity index 100% rename from discord4j/src/main/java/com/baeldung/discordbot/events/MessageCreateListener.java rename to saas-modules/discord4j/src/main/java/com/baeldung/discordbot/events/MessageCreateListener.java diff --git a/discord4j/src/main/java/com/baeldung/discordbot/events/MessageListener.java b/saas-modules/discord4j/src/main/java/com/baeldung/discordbot/events/MessageListener.java similarity index 100% rename from discord4j/src/main/java/com/baeldung/discordbot/events/MessageListener.java rename to saas-modules/discord4j/src/main/java/com/baeldung/discordbot/events/MessageListener.java diff --git a/discord4j/src/main/java/com/baeldung/discordbot/events/MessageUpdateListener.java b/saas-modules/discord4j/src/main/java/com/baeldung/discordbot/events/MessageUpdateListener.java similarity index 100% rename from discord4j/src/main/java/com/baeldung/discordbot/events/MessageUpdateListener.java rename to saas-modules/discord4j/src/main/java/com/baeldung/discordbot/events/MessageUpdateListener.java diff --git a/discord4j/src/main/resources/application.yml b/saas-modules/discord4j/src/main/resources/application.yml similarity index 100% rename from discord4j/src/main/resources/application.yml rename to saas-modules/discord4j/src/main/resources/application.yml diff --git a/discord4j/src/test/java/com/baeldung/discordbot/DiscordBotLiveTest.java b/saas-modules/discord4j/src/test/java/com/baeldung/discordbot/DiscordBotLiveTest.java similarity index 100% rename from discord4j/src/test/java/com/baeldung/discordbot/DiscordBotLiveTest.java rename to saas-modules/discord4j/src/test/java/com/baeldung/discordbot/DiscordBotLiveTest.java diff --git a/saas-modules/pom.xml b/saas-modules/pom.xml index 7e8adebdd9..16ed50918c 100644 --- a/saas-modules/pom.xml +++ b/saas-modules/pom.xml @@ -16,11 +16,13 @@ + discord4j jira-rest-integration + sentry-servlet + slack stripe twilio twitter4j - sentry-servlet diff --git a/slack/README.md b/saas-modules/slack/README.md similarity index 100% rename from slack/README.md rename to saas-modules/slack/README.md diff --git a/slack/pom.xml b/saas-modules/slack/pom.xml similarity index 97% rename from slack/pom.xml rename to saas-modules/slack/pom.xml index 690bf5132c..326167c055 100644 --- a/slack/pom.xml +++ b/saas-modules/slack/pom.xml @@ -11,7 +11,7 @@ com.baeldung - parent-modules + saas-modules 1.0.0-SNAPSHOT diff --git a/slack/src/main/java/com/baeldung/examples/slack/DiskSpaceErrorChecker.java b/saas-modules/slack/src/main/java/com/baeldung/examples/slack/DiskSpaceErrorChecker.java similarity index 100% rename from slack/src/main/java/com/baeldung/examples/slack/DiskSpaceErrorChecker.java rename to saas-modules/slack/src/main/java/com/baeldung/examples/slack/DiskSpaceErrorChecker.java diff --git a/slack/src/main/java/com/baeldung/examples/slack/ErrorChecker.java b/saas-modules/slack/src/main/java/com/baeldung/examples/slack/ErrorChecker.java similarity index 100% rename from slack/src/main/java/com/baeldung/examples/slack/ErrorChecker.java rename to saas-modules/slack/src/main/java/com/baeldung/examples/slack/ErrorChecker.java diff --git a/slack/src/main/java/com/baeldung/examples/slack/ErrorReporter.java b/saas-modules/slack/src/main/java/com/baeldung/examples/slack/ErrorReporter.java similarity index 100% rename from slack/src/main/java/com/baeldung/examples/slack/ErrorReporter.java rename to saas-modules/slack/src/main/java/com/baeldung/examples/slack/ErrorReporter.java diff --git a/slack/src/main/java/com/baeldung/examples/slack/MainClass.java b/saas-modules/slack/src/main/java/com/baeldung/examples/slack/MainClass.java similarity index 100% rename from slack/src/main/java/com/baeldung/examples/slack/MainClass.java rename to saas-modules/slack/src/main/java/com/baeldung/examples/slack/MainClass.java diff --git a/slack/src/main/java/com/baeldung/examples/slack/SlackChannelErrorReporter.java b/saas-modules/slack/src/main/java/com/baeldung/examples/slack/SlackChannelErrorReporter.java similarity index 100% rename from slack/src/main/java/com/baeldung/examples/slack/SlackChannelErrorReporter.java rename to saas-modules/slack/src/main/java/com/baeldung/examples/slack/SlackChannelErrorReporter.java diff --git a/slack/src/main/java/com/baeldung/examples/slack/SlackUserErrorReporter.java b/saas-modules/slack/src/main/java/com/baeldung/examples/slack/SlackUserErrorReporter.java similarity index 100% rename from slack/src/main/java/com/baeldung/examples/slack/SlackUserErrorReporter.java rename to saas-modules/slack/src/main/java/com/baeldung/examples/slack/SlackUserErrorReporter.java diff --git a/slack/src/main/resources/logback.xml b/saas-modules/slack/src/main/resources/logback.xml similarity index 100% rename from slack/src/main/resources/logback.xml rename to saas-modules/slack/src/main/resources/logback.xml diff --git a/security-modules/pom.xml b/security-modules/pom.xml index ed88ef842e..d0edced4e0 100644 --- a/security-modules/pom.xml +++ b/security-modules/pom.xml @@ -17,7 +17,7 @@ apache-shiro cas cloud-foundry-uaa - + java-ee-8-security-api jee-7-security jjwt jwt diff --git a/spring-boot-modules/pom.xml b/spring-boot-modules/pom.xml index 1de19fc867..2fe146e065 100644 --- a/spring-boot-modules/pom.xml +++ b/spring-boot-modules/pom.xml @@ -85,7 +85,7 @@ spring-boot-redis spring-boot-cassandre spring-boot-react - spring-boot-3 + spring-boot-3-native spring-boot-3-observation spring-boot-3-test-pitfalls diff --git a/spring-boot-modules/spring-boot-3-native/pom.xml b/spring-boot-modules/spring-boot-3-native/pom.xml index 5382b8413c..1e93c3d8ed 100644 --- a/spring-boot-modules/spring-boot-3-native/pom.xml +++ b/spring-boot-modules/spring-boot-3-native/pom.xml @@ -56,10 +56,15 @@ -agentlib:native-image-agent=config-output-dir=target/native-image - - true - + + + process-aot + + process-aot + + + --> diff --git a/spring-boot-modules/spring-boot-3/pom.xml b/spring-boot-modules/spring-boot-3/pom.xml index 03740e805f..8fe995ca91 100644 --- a/spring-boot-modules/spring-boot-3/pom.xml +++ b/spring-boot-modules/spring-boot-3/pom.xml @@ -116,6 +116,7 @@ org.springframework.boot spring-boot-maven-plugin + com.baeldung.virtualthreads.VirtualThreadsApp org.projectlombok @@ -131,15 +132,23 @@ org.springframework.boot spring-boot-maven-plugin + + org.apache.maven.plugins + maven-compiler-plugin + + --enable-preview + + + 19 1.5.2.Final 2.0.0 3.0.0-M7 com.baeldung.sample.TodoApplication - 5.14.0 + 5.14.0 \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3/src/main/java/com/baeldung/virtualthreads/VirtualThreadsApp.java b/spring-boot-modules/spring-boot-3/src/main/java/com/baeldung/virtualthreads/VirtualThreadsApp.java new file mode 100644 index 0000000000..159fa1c243 --- /dev/null +++ b/spring-boot-modules/spring-boot-3/src/main/java/com/baeldung/virtualthreads/VirtualThreadsApp.java @@ -0,0 +1,13 @@ +package com.baeldung.virtualthreads; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class VirtualThreadsApp { + + public static void main(String[] args) { + SpringApplication.run(VirtualThreadsApp.class, args); + } + +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3/src/main/java/com/baeldung/virtualthreads/config/ThreadConfig.java b/spring-boot-modules/spring-boot-3/src/main/java/com/baeldung/virtualthreads/config/ThreadConfig.java new file mode 100644 index 0000000000..7231ec0b94 --- /dev/null +++ b/spring-boot-modules/spring-boot-3/src/main/java/com/baeldung/virtualthreads/config/ThreadConfig.java @@ -0,0 +1,33 @@ +package com.baeldung.virtualthreads.config; + +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.web.embedded.tomcat.TomcatProtocolHandlerCustomizer; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.task.AsyncTaskExecutor; +import org.springframework.core.task.support.TaskExecutorAdapter; +import org.springframework.scheduling.annotation.EnableAsync; + +import java.util.concurrent.Executors; + +@EnableAsync +@Configuration +@ConditionalOnProperty( + value = "spring.thread-executor", + havingValue = "virtual" +) +public class ThreadConfig { + + @Bean + public AsyncTaskExecutor applicationTaskExecutor() { + return new TaskExecutorAdapter(Executors.newVirtualThreadPerTaskExecutor()); + } + + @Bean + public TomcatProtocolHandlerCustomizer protocolHandlerVirtualThreadExecutorCustomizer() { + return protocolHandler -> { + protocolHandler.setExecutor(Executors.newVirtualThreadPerTaskExecutor()); + }; + } + +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3/src/main/java/com/baeldung/virtualthreads/controller/LoadTestController.java b/spring-boot-modules/spring-boot-3/src/main/java/com/baeldung/virtualthreads/controller/LoadTestController.java new file mode 100644 index 0000000000..d99d3824a0 --- /dev/null +++ b/spring-boot-modules/spring-boot-3/src/main/java/com/baeldung/virtualthreads/controller/LoadTestController.java @@ -0,0 +1,23 @@ +package com.baeldung.virtualthreads.controller; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.io.IOException; + +@RestController +@RequestMapping("/load") +public class LoadTestController { + + private static final Logger LOG = LoggerFactory.getLogger(LoadTestController.class); + + @GetMapping + public void doSomething() throws InterruptedException { + LOG.info("hey, I'm doing something"); + Thread.sleep(1000); + } + +} diff --git a/spring-boot-modules/spring-boot-3/src/main/java/com/baeldung/virtualthreads/controller/ThreadController.java b/spring-boot-modules/spring-boot-3/src/main/java/com/baeldung/virtualthreads/controller/ThreadController.java new file mode 100644 index 0000000000..73b28ce9f0 --- /dev/null +++ b/spring-boot-modules/spring-boot-3/src/main/java/com/baeldung/virtualthreads/controller/ThreadController.java @@ -0,0 +1,16 @@ +package com.baeldung.virtualthreads.controller; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/thread") +public class ThreadController { + + @GetMapping("/name") + public String getThreadName() { + return Thread.currentThread().toString(); + } + +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3/src/main/resources/application.yml b/spring-boot-modules/spring-boot-3/src/main/resources/application.yml index 9a966a5bbd..5f9031bc9e 100644 --- a/spring-boot-modules/spring-boot-3/src/main/resources/application.yml +++ b/spring-boot-modules/spring-boot-3/src/main/resources/application.yml @@ -14,8 +14,10 @@ spring: properties: hibernate: dialect: org.hibernate.dialect.H2Dialect + thread-executor: standard + # Custom Properties cors: allow: origins: ${CORS_ALLOWED_ORIGINS:*} - credentials: ${CORS_ALLOW_CREDENTIALS:false} + credentials: ${CORS_ALLOW_CREDENTIALS:false} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3/src/test/HTTP Load Request .jmx b/spring-boot-modules/spring-boot-3/src/test/HTTP Load Request .jmx new file mode 100644 index 0000000000..bbd02cecbe --- /dev/null +++ b/spring-boot-modules/spring-boot-3/src/test/HTTP Load Request .jmx @@ -0,0 +1,125 @@ + + + + + + false + true + false + + + + + + + + stoptest + + false + -1 + + 1000 + 10 + true + 100 + + true + + + + + + + localhost + 8080 + + + /load + GET + true + false + true + false + + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + + diff --git a/spring-boot-modules/spring-boot-cli/pom.xml b/spring-boot-modules/spring-boot-cli/pom.xml new file mode 100644 index 0000000000..d2c50590ab --- /dev/null +++ b/spring-boot-modules/spring-boot-cli/pom.xml @@ -0,0 +1,38 @@ + + + 4.0.0 + spring-boot-cli + spring-boot-cli + jar + + + + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-security + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.security + spring-security-test + test + + + + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-cli/src/main/java/com/baeldung/Application.java b/spring-boot-modules/spring-boot-cli/src/main/java/com/baeldung/Application.java new file mode 100644 index 0000000000..c0490d50c6 --- /dev/null +++ b/spring-boot-modules/spring-boot-cli/src/main/java/com/baeldung/Application.java @@ -0,0 +1,12 @@ +package com.baeldung; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } +} diff --git a/spring-boot-modules/spring-boot-cli/src/main/java/com/baeldung/controller/LoginController.java b/spring-boot-modules/spring-boot-cli/src/main/java/com/baeldung/controller/LoginController.java new file mode 100644 index 0000000000..b678f63623 --- /dev/null +++ b/spring-boot-modules/spring-boot-cli/src/main/java/com/baeldung/controller/LoginController.java @@ -0,0 +1,13 @@ +package com.baeldung.controller; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class LoginController { + + @GetMapping("/") + public String hello() { + return "Hello World!"; + } +} diff --git a/spring-boot-modules/spring-boot-cli/src/main/resources/application.properties b/spring-boot-modules/spring-boot-cli/src/main/resources/application.properties new file mode 100644 index 0000000000..4b341094a1 --- /dev/null +++ b/spring-boot-modules/spring-boot-cli/src/main/resources/application.properties @@ -0,0 +1,3 @@ +spring.security.user.name=baeldung +# Encoded password with SpringBoot CLI, the decoded password is baeldungPassword +spring.security.user.password={bcrypt}$2y$10$R8VIwFiQ7aUST17YqMaWJuxjkCYqk3jjPlSxyDLLzqCTOwFuJNq2a \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-cli/src/test/java/com/baeldung/encoding/PasswordEncodingUnitTest.java b/spring-boot-modules/spring-boot-cli/src/test/java/com/baeldung/encoding/PasswordEncodingUnitTest.java new file mode 100644 index 0000000000..8939029f71 --- /dev/null +++ b/spring-boot-modules/spring-boot-cli/src/test/java/com/baeldung/encoding/PasswordEncodingUnitTest.java @@ -0,0 +1,51 @@ +package com.baeldung.encoding; + +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic; +import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.context.WebApplicationContext; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@AutoConfigureMockMvc +public class PasswordEncodingUnitTest { + private final static String userName = "baeldung"; + private final static String passwordDecoded = "baeldungPassword"; + + private MockMvc mvc; + + @Autowired + private WebApplicationContext webApplicationContext; + + @Before + public void setup() { + mvc = MockMvcBuilders.webAppContextSetup(webApplicationContext) + .apply(springSecurity()) + .build(); + } + + @Test + public void givenRequestWithWrongPassword_shouldFailWith401() throws Exception { + mvc.perform(get("/").with(httpBasic(userName, "wrongPassword"))) + .andExpect(status().isUnauthorized()); + + } + + @Test + public void givenRequestWithCorrectDecodedPassword_houldSucceedWith200() throws Exception { + mvc.perform(get("/").with(httpBasic(userName, passwordDecoded))) + .andExpect(status().isOk()); + + } +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-data-3/README.md b/spring-boot-modules/spring-boot-data-3/README.md index edb9394277..7130d25118 100644 --- a/spring-boot-modules/spring-boot-data-3/README.md +++ b/spring-boot-modules/spring-boot-data-3/README.md @@ -1,3 +1,4 @@ ### Relevant Articles: - [Spring Data JPA – Run an App Without a Database](https://www.baeldung.com/spring-data-jpa-run-app-without-db) - [Integrate AWS Secrets Manager in Spring Boot](https://www.baeldung.com/spring-boot-integrate-aws-secrets-manager) +- [Fix Spring Data JPA Exception: No Property Found for Type](https://www.baeldung.com/spring-data-jpa-exception-no-property-found-for-type) diff --git a/spring-boot-modules/spring-boot-libraries-2/README.md b/spring-boot-modules/spring-boot-libraries-2/README.md index 0da16a8204..fbba6ad62c 100644 --- a/spring-boot-modules/spring-boot-libraries-2/README.md +++ b/spring-boot-modules/spring-boot-libraries-2/README.md @@ -9,4 +9,5 @@ This module contains articles about various Spring Boot libraries - [An Introduction to Kong](https://www.baeldung.com/kong) - [Scanning Java Annotations At Runtime](https://www.baeldung.com/java-scan-annotations-runtime) - [Guide to Resilience4j With Spring Boot](https://www.baeldung.com/spring-boot-resilience4j) -More articles: [[prev -->]](/spring-boot-modules/spring-boot-libraries) +- [Using OpenAI ChatGPT APIs in Spring Boot](https://www.baeldung.com/spring-boot-chatgpt-api-openai) +- More articles: [[prev -->]](/spring-boot-modules/spring-boot-libraries) diff --git a/spring-boot-modules/spring-boot-libraries-2/pom.xml b/spring-boot-modules/spring-boot-libraries-2/pom.xml index 4409db0672..6d9401f4bc 100644 --- a/spring-boot-modules/spring-boot-libraries-2/pom.xml +++ b/spring-boot-modules/spring-boot-libraries-2/pom.xml @@ -11,6 +11,18 @@ 1.0.0-SNAPSHOT + + + + org.springframework.experimental + spring-modulith-bom + 0.5.1 + import + pom + + + + org.springframework.boot @@ -87,6 +99,15 @@ 2.34.0 test + + org.springframework.experimental + spring-modulith-api + + + org.springframework.experimental + spring-modulith-starter-test + test + diff --git a/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/modulith/Application.java b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/modulith/Application.java new file mode 100644 index 0000000000..a8c3e48661 --- /dev/null +++ b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/modulith/Application.java @@ -0,0 +1,21 @@ +package com.baeldung.modulith; + +import com.baeldung.modulith.product.ProductService; +import com.baeldung.modulith.product.internal.Product; +import org.jobrunr.autoconfigure.JobRunrAutoConfiguration; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.scheduling.annotation.EnableAsync; + +@EnableAsync +@SpringBootApplication +@EnableAutoConfiguration(exclude = { JobRunrAutoConfiguration.class}) +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args) + .getBean(ProductService.class) + .create(new Product("baeldung", "course", 10)); + } +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/modulith/notification/NotificationDTO.java b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/modulith/notification/NotificationDTO.java new file mode 100644 index 0000000000..a8fb346daa --- /dev/null +++ b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/modulith/notification/NotificationDTO.java @@ -0,0 +1,39 @@ +package com.baeldung.modulith.notification; + +import java.util.Date; + +public class NotificationDTO { + private Date date; + private String format; + private String productName; + + public NotificationDTO(Date date, String format, String productName) { + this.date = date; + this.format = format; + this.productName = productName; + } + + public Date getDate() { + return date; + } + + public void setDate(Date date) { + this.date = date; + } + + public String getFormat() { + return format; + } + + public void setFormat(String format) { + this.format = format; + } + + public String getProductName() { + return productName; + } + + public void setProductName(String productName) { + this.productName = productName; + } +} diff --git a/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/modulith/notification/NotificationService.java b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/modulith/notification/NotificationService.java new file mode 100644 index 0000000000..7789798bbe --- /dev/null +++ b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/modulith/notification/NotificationService.java @@ -0,0 +1,42 @@ +package com.baeldung.modulith.notification; + +import com.baeldung.modulith.notification.internal.Notification; +import com.baeldung.modulith.notification.internal.NotificationType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.modulith.ApplicationModuleListener; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Service; + +@Service +public class NotificationService { + + private static final Logger LOG = LoggerFactory.getLogger(NotificationService.class); + + public void createNotification(NotificationDTO notificationDTO) { + Notification notification = toEntity(notificationDTO); + LOG.info("Received notification by module dependency for product {} in date {} by {}.", notification.getProductName() + , notification.getDate(), notification.getFormat()); + } + + @Async + @ApplicationModuleListener + public void notificationEvent(NotificationDTO event) { + Notification notification = toEntity(event); + LOG.info("Received notification by event for product {} in date {} by {}.", notification.getProductName() + , notification.getDate(), notification.getFormat()); + } + + private Notification toEntity(NotificationDTO notificationDTO) { + Notification notification = new Notification(); + notification.setDate(notificationDTO.getDate()); + if (notificationDTO.getFormat().equals("SMS")) { + notification.setFormat(NotificationType.SMS); + } + if (notificationDTO.getFormat().equals("EMAIL")) { + notification.setFormat(NotificationType.EMAIL); + } + notification.setProductName(notificationDTO.getProductName()); + return notification; + } +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/modulith/notification/internal/Notification.java b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/modulith/notification/internal/Notification.java new file mode 100644 index 0000000000..0b1ce85d26 --- /dev/null +++ b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/modulith/notification/internal/Notification.java @@ -0,0 +1,37 @@ +package com.baeldung.modulith.notification.internal; + +import java.util.Date; + +public class Notification { + private Date date; + private NotificationType format; + private String productName; + + public Notification() { + + } + + public Date getDate() { + return date; + } + + public void setDate(Date date) { + this.date = date; + } + + public NotificationType getFormat() { + return format; + } + + public void setFormat(NotificationType format) { + this.format = format; + } + + public String getProductName() { + return productName; + } + + public void setProductName(String productName) { + this.productName = productName; + } +} diff --git a/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/modulith/notification/internal/NotificationType.java b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/modulith/notification/internal/NotificationType.java new file mode 100644 index 0000000000..45870e52b9 --- /dev/null +++ b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/modulith/notification/internal/NotificationType.java @@ -0,0 +1,5 @@ +package com.baeldung.modulith.notification.internal; + +public enum NotificationType { + EMAIL, SMS +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/modulith/product/ProductService.java b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/modulith/product/ProductService.java new file mode 100644 index 0000000000..46d87fc539 --- /dev/null +++ b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/modulith/product/ProductService.java @@ -0,0 +1,26 @@ +package com.baeldung.modulith.product; + +import com.baeldung.modulith.notification.NotificationDTO; +import com.baeldung.modulith.notification.NotificationService; +import com.baeldung.modulith.product.internal.Product; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.stereotype.Service; + +import java.util.Date; + +@Service +public class ProductService { + + private final ApplicationEventPublisher events; + private final NotificationService notificationService; + + public ProductService(ApplicationEventPublisher events, NotificationService notificationService) { + this.events = events; + this.notificationService = notificationService; + } + + public void create(Product product) { + notificationService.createNotification(new NotificationDTO(new Date(), "SMS", product.getName())); + events.publishEvent(new NotificationDTO(new Date(), "SMS", product.getName())); + } +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/modulith/product/internal/Product.java b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/modulith/product/internal/Product.java new file mode 100644 index 0000000000..d989906b63 --- /dev/null +++ b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/modulith/product/internal/Product.java @@ -0,0 +1,38 @@ +package com.baeldung.modulith.product.internal; + +public class Product { + + private String name; + private String description; + private int price; + + public Product(String name, String description, int price) { + this.name = name; + this.description = description; + this.price = price; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public int getPrice() { + return price; + } + + public void setPrice(int price) { + this.price = price; + } +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/openapi/config/OpenAIRestTemplateConfig.java b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/openapi/config/OpenAIRestTemplateConfig.java new file mode 100644 index 0000000000..b832ee4264 --- /dev/null +++ b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/openapi/config/OpenAIRestTemplateConfig.java @@ -0,0 +1,25 @@ +package com.baeldung.openapi.config; + +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.client.RestTemplate; + +@Configuration +public class OpenAIRestTemplateConfig { + + @Value("${openai.api.key}") + private String openaiApiKey; + + @Bean + @Qualifier("openaiRestTemplate") + public RestTemplate openaiRestTemplate() { + RestTemplate restTemplate = new RestTemplate(); + restTemplate.getInterceptors().add((request, body, execution) -> { + request.getHeaders().add("Authorization", "Bearer " + openaiApiKey); + return execution.execute(request, body); + }); + return restTemplate; + } +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/openapi/controller/ChatController.java b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/openapi/controller/ChatController.java new file mode 100644 index 0000000000..129d233582 --- /dev/null +++ b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/openapi/controller/ChatController.java @@ -0,0 +1,48 @@ +package com.baeldung.openapi.controller; + +import com.baeldung.openapi.dto.ChatRequest; +import com.baeldung.openapi.dto.ChatResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.client.RestTemplate; + +@RestController +public class ChatController { + + @Qualifier("openaiRestTemplate") + @Autowired + private RestTemplate restTemplate; + + @Value("${openai.model}") + private String model; + + @Value("${openai.api.url}") + private String apiUrl; + + /** + * Creates a chat request and sends it to the OpenAI API + * Returns the first message from the API response + * + * @param prompt the prompt to send to the API + * @return first message from the API response + */ + @GetMapping("/chat") + public String chat(@RequestParam String prompt) { + ChatRequest request = new ChatRequest(model, prompt); + + ChatResponse response = restTemplate.postForObject( + apiUrl, + request, + ChatResponse.class); + + if (response == null || response.getChoices() == null || response.getChoices().isEmpty()) { + return "No response"; + } + + return response.getChoices().get(0).getMessage().getContent(); + } +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/openapi/dto/ChatRequest.java b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/openapi/dto/ChatRequest.java new file mode 100644 index 0000000000..1e32b937ce --- /dev/null +++ b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/openapi/dto/ChatRequest.java @@ -0,0 +1,32 @@ +package com.baeldung.openapi.dto; + +import java.util.ArrayList; +import java.util.List; + +public class ChatRequest { + private String model; + private List messages; + + public ChatRequest(String model, String prompt) { + this.model = model; + + this.messages = new ArrayList<>(); + this.messages.add(new Message("user", prompt)); + } + + public String getModel() { + return model; + } + + public void setModel(String model) { + this.model = model; + } + + public List getMessages() { + return messages; + } + + public void setMessages(List messages) { + this.messages = messages; + } +} diff --git a/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/openapi/dto/ChatResponse.java b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/openapi/dto/ChatResponse.java new file mode 100644 index 0000000000..937e2d87db --- /dev/null +++ b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/openapi/dto/ChatResponse.java @@ -0,0 +1,38 @@ +package com.baeldung.openapi.dto; + +import java.util.List; + +public class ChatResponse { + + private List choices; + + public static class Choice { + + private int index; + private Message message; + + public int getIndex() { + return index; + } + + public void setIndex(int index) { + this.index = index; + } + + public Message getMessage() { + return message; + } + + public void setMessage(Message message) { + this.message = message; + } + } + + public List getChoices() { + return choices; + } + + public void setChoices(List choices) { + this.choices = choices; + } +} diff --git a/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/openapi/dto/Message.java b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/openapi/dto/Message.java new file mode 100644 index 0000000000..242cf4e89f --- /dev/null +++ b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/openapi/dto/Message.java @@ -0,0 +1,31 @@ +package com.baeldung.openapi.dto; + +public class Message { + + private String role; + private String content; + + Message(String role, String content) { + this.role = role; + this.content = content; + } + + Message() { + } + + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-libraries-2/src/main/resources/application.properties b/spring-boot-modules/spring-boot-libraries-2/src/main/resources/application.properties index a18eda349a..47b2973fca 100644 --- a/spring-boot-modules/spring-boot-libraries-2/src/main/resources/application.properties +++ b/spring-boot-modules/spring-boot-libraries-2/src/main/resources/application.properties @@ -47,4 +47,8 @@ resilience4j.ratelimiter.instances.rateLimiterApi.limit-refresh-period=60s resilience4j.ratelimiter.instances.rateLimiterApi.timeout-duration=0s resilience4j.ratelimiter.instances.rateLimiterApi.allow-health-indicator-to-fail=true resilience4j.ratelimiter.instances.rateLimiterApi.subscribe-for-events=true -resilience4j.ratelimiter.instances.rateLimiterApi.event-consumer-buffer-size=50 \ No newline at end of file +resilience4j.ratelimiter.instances.rateLimiterApi.event-consumer-buffer-size=50 + +openai.model=gpt-3.5-turbo +openai.api.url=https://api.openai.com/v1/chat/completions +openai.api.key=your-api-key \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/modulith/ApplicationModularityUnitTest.java b/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/modulith/ApplicationModularityUnitTest.java new file mode 100644 index 0000000000..40d644b1e0 --- /dev/null +++ b/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/modulith/ApplicationModularityUnitTest.java @@ -0,0 +1,27 @@ +package com.baeldung.modulith; + +import org.junit.jupiter.api.Test; +import org.springframework.modulith.core.ApplicationModules; +import org.springframework.modulith.docs.Documenter; + +class ApplicationModularityUnitTest { + + ApplicationModules modules = ApplicationModules.of(Application.class); + + @Test + void verifiesModularStructure() { + modules.verify(); + } + + @Test + void createModuleDocumentation() { + new Documenter(modules) + .writeDocumentation() + .writeIndividualModulesAsPlantUml(); + } + + @Test + void createApplicationModuleModel() { + modules.forEach(System.out::println); + } +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/controller/AuthorsController.java b/spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/controller/AuthorsController.java new file mode 100644 index 0000000000..019bd5ad9d --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/controller/AuthorsController.java @@ -0,0 +1,34 @@ +package com.baeldung.springboot.swagger.controller; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.baeldung.springboot.swagger.model.Author; +import com.baeldung.springboot.swagger.service.AuthorService; +import com.baeldung.springboot.swagger.views.Views; +import com.fasterxml.jackson.annotation.JsonView; + +@RestController +@RequestMapping("/authors") +public class AuthorsController { + + @Autowired + AuthorService authorService; + + @JsonView(Views.Public.class) + @GetMapping + public List getAllAuthors() { + return authorService.getAllAuthors(); + } + + @PostMapping + public void addAuthor(@RequestBody @JsonView(Views.Public.class) Author author){ + authorService.addAuthors(author); + } +} diff --git a/spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/model/Author.java b/spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/model/Author.java new file mode 100644 index 0000000000..2e30998059 --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/model/Author.java @@ -0,0 +1,28 @@ +package com.baeldung.springboot.swagger.model; + +import com.baeldung.springboot.swagger.views.Views; +import com.fasterxml.jackson.annotation.JsonView; + +public class Author { + + @JsonView(Views.Private.class) + private Integer id; + + @JsonView(Views.Public.class) + private String name; + + @JsonView(Views.Public.class) + private String email; + + public Author() { + } + + public Author(String name, String email) { + this.name = name; + this.email = email; + } + + public void setId(Integer id) { + this.id = id; + } +} diff --git a/spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/service/AuthorService.java b/spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/service/AuthorService.java new file mode 100644 index 0000000000..bf1f637889 --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/service/AuthorService.java @@ -0,0 +1,23 @@ +package com.baeldung.springboot.swagger.service; + +import java.util.ArrayList; +import java.util.List; + +import org.springframework.stereotype.Service; + +import com.baeldung.springboot.swagger.model.Author; + +@Service +public class AuthorService { + private List authors = new ArrayList<>(); + + public List getAllAuthors(){ + return authors; + } + + public void addAuthors(Author author){ + author.setId(authors.size()+1); + authors.add(author); + } + +} diff --git a/spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/views/Views.java b/spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/views/Views.java new file mode 100644 index 0000000000..df638a5647 --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/views/Views.java @@ -0,0 +1,9 @@ +package com.baeldung.springboot.swagger.views; + +public class Views { + public static class Public { + } + + public static class Private { + } +} diff --git a/spring-boot-modules/spring-boot-properties-3/README.md b/spring-boot-modules/spring-boot-properties-3/README.md index 37b63abb84..4bc4a2325f 100644 --- a/spring-boot-modules/spring-boot-properties-3/README.md +++ b/spring-boot-modules/spring-boot-properties-3/README.md @@ -11,4 +11,5 @@ - [IntelliJ – Cannot Resolve Spring Boot Configuration Properties Error](https://www.baeldung.com/intellij-resolve-spring-boot-configuration-properties) - [Log Properties in a Spring Boot Application](https://www.baeldung.com/spring-boot-log-properties) - [Using Environment Variables in Spring Boot’s application.properties](https://www.baeldung.com/spring-boot-properties-env-variables) +- [Loading Multiple YAML Configuration Files in Spring Boot](https://www.baeldung.com/spring-boot-load-multiple-yaml-configuration-files) - More articles: [[<-- prev]](../spring-boot-properties-2) diff --git a/spring-boot-modules/spring-boot-resilience4j/src/test/java/com/baeldung/resilience4j/eventendpoints/ResilientAppControllerIntegrationTest.java b/spring-boot-modules/spring-boot-resilience4j/src/test/java/com/baeldung/resilience4j/eventendpoints/ResilientAppControllerIntegrationTest.java index 3933a02753..d1951218de 100644 --- a/spring-boot-modules/spring-boot-resilience4j/src/test/java/com/baeldung/resilience4j/eventendpoints/ResilientAppControllerIntegrationTest.java +++ b/spring-boot-modules/spring-boot-resilience4j/src/test/java/com/baeldung/resilience4j/eventendpoints/ResilientAppControllerIntegrationTest.java @@ -14,7 +14,6 @@ import com.github.tomakehurst.wiremock.core.WireMockConfiguration; import com.github.tomakehurst.wiremock.junit5.WireMockExtension; import java.net.URI; import java.nio.charset.Charset; -import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.concurrent.*; @@ -210,23 +209,20 @@ class ResilientAppControllerIntegrationTest { EXTERNAL_SERVICE.stubFor(WireMock.get("/api/external").willReturn(ok())); Map responseStatusCount = new ConcurrentHashMap<>(); ExecutorService executorService = Executors.newFixedThreadPool(5); + CountDownLatch latch = new CountDownLatch(5); - List> tasks = new ArrayList<>(); IntStream.rangeClosed(1, 5) .forEach( i -> - tasks.add( + executorService.execute( () -> { ResponseEntity response = restTemplate.getForEntity("/api/bulkhead", String.class); - return response.getStatusCodeValue(); + int statusCode = response.getStatusCodeValue(); + responseStatusCount.merge(statusCode, 1, Integer::sum); + latch.countDown(); })); - - List> futures = executorService.invokeAll(tasks); - for (Future future : futures) { - int statusCode = future.get(); - responseStatusCount.merge(statusCode, 1, Integer::sum); - } + latch.await(); executorService.shutdown(); assertEquals(2, responseStatusCount.keySet().size()); diff --git a/spring-boot-modules/spring-boot-springdoc/pom.xml b/spring-boot-modules/spring-boot-springdoc/pom.xml index 8cd94179cf..e21efc35d2 100644 --- a/spring-boot-modules/spring-boot-springdoc/pom.xml +++ b/spring-boot-modules/spring-boot-springdoc/pom.xml @@ -146,7 +146,7 @@ org.springdoc springdoc-openapi-maven-plugin - 1.4 + ${springdoc-openapi-maven-plugin.version} integration-test @@ -167,9 +167,10 @@ - 1.6.8 + 1.7.0 1.5.6 ${project.build.directory}/generated-snippets + 1.4 \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-swagger-keycloak/pom.xml b/spring-boot-modules/spring-boot-swagger-keycloak/pom.xml index de2c8c68c4..e7950fe393 100644 --- a/spring-boot-modules/spring-boot-swagger-keycloak/pom.xml +++ b/spring-boot-modules/spring-boot-swagger-keycloak/pom.xml @@ -1,75 +1,72 @@ - 4.0.0 - spring-boot-swagger-keycloak - 0.1.0-SNAPSHOT - spring-boot-swagger-keycloak - jar - Module For Spring Boot Swagger UI with Keycloak + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + spring-boot-swagger-keycloak + 0.1.0-SNAPSHOT + spring-boot-swagger-keycloak + jar + Module For Spring Boot Swagger UI with Keycloak - - com.baeldung.spring-boot-modules - spring-boot-modules - 1.0.0-SNAPSHOT - + + com.baeldung + parent-boot-3 + 0.0.1-SNAPSHOT + ../../parent-boot-3 + - - - - org.keycloak.bom - keycloak-adapter-bom - ${keycloak.version} - pom - import - - - org.apache.logging.log4j - log4j-bom - ${log4j2.version} - import - pom - - - + + + + org.apache.logging.log4j + log4j-bom + ${log4j2.version} + import + pom + + + - - - org.springframework.boot - spring-boot-starter-web - - - io.springfox - springfox-boot-starter - ${springfox.version} - - - - org.keycloak - keycloak-spring-boot-starter - - - - org.springframework.boot - spring-boot-starter-security - - + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-oauth2-resource-server + + + + org.springframework.boot + spring-boot-starter-security + + + org.springdoc + springdoc-openapi-starter-webmvc-ui + ${springdoc.version} + + + javax.annotation + javax.annotation-api + ${javax.version} + + - - - - org.springframework.boot - spring-boot-maven-plugin - - - + + + + org.springframework.boot + spring-boot-maven-plugin + + + - - 2.4.5 - 3.0.0 - 15.0.2 - 2.17.1 - + + 2.1.0 + 2.17.1 + 1.3.2 + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-swagger-keycloak/src/main/java/com/baeldung/swaggerkeycloak/GlobalSecurityConfig.java b/spring-boot-modules/spring-boot-swagger-keycloak/src/main/java/com/baeldung/swaggerkeycloak/GlobalSecurityConfig.java index 985cbf7d06..5c24368ce6 100644 --- a/spring-boot-modules/spring-boot-swagger-keycloak/src/main/java/com/baeldung/swaggerkeycloak/GlobalSecurityConfig.java +++ b/spring-boot-modules/spring-boot-swagger-keycloak/src/main/java/com/baeldung/swaggerkeycloak/GlobalSecurityConfig.java @@ -1,59 +1,40 @@ package com.baeldung.swaggerkeycloak; -import org.keycloak.adapters.springsecurity.KeycloakConfiguration; -import org.keycloak.adapters.springsecurity.authentication.KeycloakAuthenticationProvider; -import org.keycloak.adapters.springsecurity.config.KeycloakWebSecurityConfigurerAdapter; -import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpMethod; -import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.core.authority.mapping.GrantedAuthoritiesMapper; -import org.springframework.security.core.authority.mapping.SimpleAuthorityMapper; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configurers.oauth2.server.resource.OAuth2ResourceServerConfigurer; import org.springframework.security.core.session.SessionRegistryImpl; +import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.authentication.session.RegisterSessionAuthenticationStrategy; import org.springframework.security.web.authentication.session.SessionAuthenticationStrategy; -@KeycloakConfiguration +@Configuration +@EnableWebSecurity @EnableGlobalMethodSecurity(prePostEnabled = true) -public class GlobalSecurityConfig extends KeycloakWebSecurityConfigurerAdapter { +public class GlobalSecurityConfig { - @Override + @Bean protected SessionAuthenticationStrategy sessionAuthenticationStrategy() { return new RegisterSessionAuthenticationStrategy(new SessionRegistryImpl()); } - // otherwise, we'll get an error 'permitAll only works with HttpSecurity.authorizeRequests()' - @Override - protected void configure(HttpSecurity http) throws Exception { - super.configure(http); - http - .csrf().disable() - .authorizeRequests() - // we can set up authorization here alternatively to @Secured methods - .antMatchers(HttpMethod.OPTIONS).permitAll() - .antMatchers("/api/**").authenticated() - // force authentication for all requests (and use global method security) - .anyRequest().permitAll(); + @Bean + public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { + http.csrf() + .disable() + .authorizeRequests() + .requestMatchers(HttpMethod.OPTIONS) + .permitAll() + .requestMatchers("/api/**") + .authenticated() + .anyRequest() + .permitAll(); + http.oauth2ResourceServer(OAuth2ResourceServerConfigurer::jwt); + return http.build(); } - /* - * re-configure Spring Security to use - * registers the KeycloakAuthenticationProvider with the authentication manager - */ - @Autowired - void configureGlobal(AuthenticationManagerBuilder auth) { - KeycloakAuthenticationProvider provider = keycloakAuthenticationProvider(); - provider.setGrantedAuthoritiesMapper(authoritiesMapper()); - auth.authenticationProvider(provider); - } - - GrantedAuthoritiesMapper authoritiesMapper() { - SimpleAuthorityMapper mapper = new SimpleAuthorityMapper(); - mapper.setPrefix("ROLE_"); // Spring Security adds a prefix to the authority/role names (we use the default here) - mapper.setConvertToUpperCase(true); // convert names to uppercase - mapper.setDefaultAuthority("ROLE_ANONYMOUS"); // set a default authority - return mapper; - } - -} +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-swagger-keycloak/src/main/java/com/baeldung/swaggerkeycloak/KeycloakConfigResolverConfig.java b/spring-boot-modules/spring-boot-swagger-keycloak/src/main/java/com/baeldung/swaggerkeycloak/KeycloakConfigResolverConfig.java deleted file mode 100644 index bca764a17d..0000000000 --- a/spring-boot-modules/spring-boot-swagger-keycloak/src/main/java/com/baeldung/swaggerkeycloak/KeycloakConfigResolverConfig.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.baeldung.swaggerkeycloak; - -import org.keycloak.adapters.KeycloakConfigResolver; -import org.keycloak.adapters.springboot.KeycloakSpringBootConfigResolver; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class KeycloakConfigResolverConfig { - - /* - * re-configure keycloak adapter for Spring Boot environment, - * i.e. to read config from application.yml - * (otherwise, we need a keycloak.json file) - */ - @Bean - public KeycloakConfigResolver configResolver() { - return new KeycloakSpringBootConfigResolver(); - } - - - -} diff --git a/spring-boot-modules/spring-boot-swagger-keycloak/src/main/java/com/baeldung/swaggerkeycloak/OpenAPISecurityConfig.java b/spring-boot-modules/spring-boot-swagger-keycloak/src/main/java/com/baeldung/swaggerkeycloak/OpenAPISecurityConfig.java index d3ab26e1ee..8d75a1a885 100644 --- a/spring-boot-modules/spring-boot-swagger-keycloak/src/main/java/com/baeldung/swaggerkeycloak/OpenAPISecurityConfig.java +++ b/spring-boot-modules/spring-boot-swagger-keycloak/src/main/java/com/baeldung/swaggerkeycloak/OpenAPISecurityConfig.java @@ -1,22 +1,17 @@ package com.baeldung.swaggerkeycloak; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.http.HttpMethod; -import springfox.documentation.builders.OAuth2SchemeBuilder; -import springfox.documentation.service.AuthorizationScope; -import springfox.documentation.service.SecurityReference; -import springfox.documentation.service.SecurityScheme; -import springfox.documentation.spi.service.contexts.SecurityContext; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger.web.SecurityConfiguration; -import springfox.documentation.swagger.web.SecurityConfigurationBuilder; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.security.OAuthFlow; +import io.swagger.v3.oas.models.security.OAuthFlows; +import io.swagger.v3.oas.models.security.Scopes; +import io.swagger.v3.oas.models.security.SecurityRequirement; +import io.swagger.v3.oas.models.security.SecurityScheme; @Configuration public class OpenAPISecurityConfig { @@ -25,59 +20,35 @@ public class OpenAPISecurityConfig { String authServerUrl; @Value("${keycloak.realm}") String realm; - @Value("${keycloak.resource}") - private String clientId; - @Value("${keycloak.credentials.secret}") - private String clientSecret; - @Autowired - void addSecurity(Docket docket) { - docket - .securitySchemes(Collections.singletonList(authenticationScheme())) - .securityContexts(Collections.singletonList(securityContext())); - } - - private SecurityScheme authenticationScheme() { - return new OAuth2SchemeBuilder("implicit") - .name("my_oAuth_security_schema") - .authorizationUrl(authServerUrl + "/realms/" + realm) - .scopes(authorizationScopes()) - .build(); - } - - private List authorizationScopes() { - return Arrays.asList( - new AuthorizationScope("read_access", "read data"), - new AuthorizationScope("write_access", "modify data") - ); - } - - private SecurityContext securityContext() { - return SecurityContext. - builder(). - securityReferences(readAccessAuth()) - .operationSelector(operationContext -> HttpMethod.GET.equals(operationContext.httpMethod())) - .build(); - } - - private List readAccessAuth() { - AuthorizationScope[] authorizationScopes = new AuthorizationScope[] { authorizationScopes().get(0) }; - return Collections.singletonList( - new SecurityReference("my_oAuth_security_schema", authorizationScopes) - ); - } + private static final String OAUTH_SCHEME_NAME = "my_oAuth_security_schema"; @Bean - public SecurityConfiguration security() { - return SecurityConfigurationBuilder.builder() - .clientId(clientId) - .clientSecret(clientSecret) - .realm(realm) - .appName(clientId) - .scopeSeparator(",") - .additionalQueryStringParams(null) - .useBasicAuthenticationWithAccessCodeGrant(false) - .build(); + public OpenAPI openAPI() { + return new OpenAPI().components(new Components() + .addSecuritySchemes(OAUTH_SCHEME_NAME, createOAuthScheme())) + .addSecurityItem(new SecurityRequirement().addList(OAUTH_SCHEME_NAME)) + .info(new Info().title("Todos Management Service") + .description("A service providing todos.") + .version("1.0")); + } + + private SecurityScheme createOAuthScheme() { + OAuthFlows flows = createOAuthFlows(); + return new SecurityScheme().type(SecurityScheme.Type.OAUTH2) + .flows(flows); + } + + private OAuthFlows createOAuthFlows() { + OAuthFlow flow = createAuthorizationCodeFlow(); + return new OAuthFlows().implicit(flow); + } + + private OAuthFlow createAuthorizationCodeFlow() { + return new OAuthFlow() + .authorizationUrl(authServerUrl + "/realms/" + realm + "/protocol/openid-connect/auth") + .scopes(new Scopes().addString("read_access", "read data") + .addString("write_access", "modify data")); } } diff --git a/spring-boot-modules/spring-boot-swagger-keycloak/src/main/java/com/baeldung/swaggerkeycloak/SwaggerUIConfig.java b/spring-boot-modules/spring-boot-swagger-keycloak/src/main/java/com/baeldung/swaggerkeycloak/SwaggerUIConfig.java deleted file mode 100644 index 1207fe5b9e..0000000000 --- a/spring-boot-modules/spring-boot-swagger-keycloak/src/main/java/com/baeldung/swaggerkeycloak/SwaggerUIConfig.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.baeldung.swaggerkeycloak; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.oas.annotations.EnableOpenApi; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; - -import static springfox.documentation.builders.RequestHandlerSelectors.basePackage; - -@EnableOpenApi -@Configuration -class SwaggerUIConfig { - - @Bean - Docket api() { - return new Docket(DocumentationType.OAS_30) - .useDefaultResponseMessages(false) - .select() - .apis(basePackage(TodosApplication.class.getPackage().getName())) - .paths(PathSelectors.any()) - .build() - .apiInfo(apiInfo()); - } - - private ApiInfo apiInfo() { - return new ApiInfoBuilder().title("Todos Management Service") - .description("A service providing todos.") - .version("1.0") - .build(); - } - -} diff --git a/spring-boot-modules/spring-boot-swagger-keycloak/src/main/java/com/baeldung/swaggerkeycloak/TodosController.java b/spring-boot-modules/spring-boot-swagger-keycloak/src/main/java/com/baeldung/swaggerkeycloak/TodosController.java index 6b70072ce3..6d48a0c67d 100644 --- a/spring-boot-modules/spring-boot-swagger-keycloak/src/main/java/com/baeldung/swaggerkeycloak/TodosController.java +++ b/spring-boot-modules/spring-boot-swagger-keycloak/src/main/java/com/baeldung/swaggerkeycloak/TodosController.java @@ -1,14 +1,15 @@ package com.baeldung.swaggerkeycloak; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; import org.springframework.http.MediaType; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + import javax.annotation.PostConstruct; import java.time.LocalDate; import java.util.Collection; @@ -28,13 +29,10 @@ public class TodosController { } @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) - @ApiOperation("Read all todos") - @ApiResponses({ - @ApiResponse(code = 200, message = "The todos were found and returned.") - }) + @Operation(description = "Read all todos") + @ApiResponses({ @ApiResponse(responseCode = "200", description = "The todos were found and returned.") }) @PreAuthorize("hasAuthority('SCOPE_read_access')") public Collection readAll() { return todos.values(); } - } diff --git a/spring-boot-modules/spring-boot-swagger-keycloak/src/main/resources/META-INF/resources/webjars/springfox-swagger-ui/favicon-16x16.png b/spring-boot-modules/spring-boot-swagger-keycloak/src/main/resources/META-INF/resources/webjars/springfox-swagger-ui/favicon-16x16.png deleted file mode 100644 index 8b194e617a..0000000000 Binary files a/spring-boot-modules/spring-boot-swagger-keycloak/src/main/resources/META-INF/resources/webjars/springfox-swagger-ui/favicon-16x16.png and /dev/null differ diff --git a/spring-boot-modules/spring-boot-swagger-keycloak/src/main/resources/META-INF/resources/webjars/springfox-swagger-ui/favicon-32x32.png b/spring-boot-modules/spring-boot-swagger-keycloak/src/main/resources/META-INF/resources/webjars/springfox-swagger-ui/favicon-32x32.png deleted file mode 100644 index 249737fe44..0000000000 Binary files a/spring-boot-modules/spring-boot-swagger-keycloak/src/main/resources/META-INF/resources/webjars/springfox-swagger-ui/favicon-32x32.png and /dev/null differ diff --git a/spring-boot-modules/spring-boot-swagger-keycloak/src/main/resources/META-INF/resources/webjars/springfox-swagger-ui/oauth2-redirect.html b/spring-boot-modules/spring-boot-swagger-keycloak/src/main/resources/META-INF/resources/webjars/springfox-swagger-ui/oauth2-redirect.html deleted file mode 100644 index 64b171f7de..0000000000 --- a/spring-boot-modules/spring-boot-swagger-keycloak/src/main/resources/META-INF/resources/webjars/springfox-swagger-ui/oauth2-redirect.html +++ /dev/null @@ -1,75 +0,0 @@ - - - - Swagger UI: OAuth2 Redirect - - - - - diff --git a/spring-boot-modules/spring-boot-swagger-keycloak/src/main/resources/META-INF/resources/webjars/springfox-swagger-ui/swagger-ui.css b/spring-boot-modules/spring-boot-swagger-keycloak/src/main/resources/META-INF/resources/webjars/springfox-swagger-ui/swagger-ui.css deleted file mode 100644 index e43a572a13..0000000000 --- a/spring-boot-modules/spring-boot-swagger-keycloak/src/main/resources/META-INF/resources/webjars/springfox-swagger-ui/swagger-ui.css +++ /dev/null @@ -1,4 +0,0 @@ -.swagger-ui{color:#3b4151; - /*! normalize.css v7.0.0 | MIT License | github.com/necolas/normalize.css */font-family:sans-serif}.swagger-ui html{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;line-height:1.15}.swagger-ui body{margin:0}.swagger-ui article,.swagger-ui aside,.swagger-ui footer,.swagger-ui header,.swagger-ui nav,.swagger-ui section{display:block}.swagger-ui h1{font-size:2em;margin:.67em 0}.swagger-ui figcaption,.swagger-ui figure,.swagger-ui main{display:block}.swagger-ui figure{margin:1em 40px}.swagger-ui hr{box-sizing:content-box;height:0;overflow:visible}.swagger-ui pre{font-family:monospace,monospace;font-size:1em}.swagger-ui a{-webkit-text-decoration-skip:objects;background-color:transparent}.swagger-ui abbr[title]{border-bottom:none;text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted}.swagger-ui b,.swagger-ui strong{font-weight:inherit;font-weight:bolder}.swagger-ui code,.swagger-ui kbd,.swagger-ui samp{font-family:monospace,monospace;font-size:1em}.swagger-ui dfn{font-style:italic}.swagger-ui mark{background-color:#ff0;color:#000}.swagger-ui small{font-size:80%}.swagger-ui sub,.swagger-ui sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}.swagger-ui sub{bottom:-.25em}.swagger-ui sup{top:-.5em}.swagger-ui audio,.swagger-ui video{display:inline-block}.swagger-ui audio:not([controls]){display:none;height:0}.swagger-ui img{border-style:none}.swagger-ui svg:not(:root){overflow:hidden}.swagger-ui button,.swagger-ui input,.swagger-ui optgroup,.swagger-ui select,.swagger-ui textarea{font-family:sans-serif;font-size:100%;line-height:1.15;margin:0}.swagger-ui button,.swagger-ui input{overflow:visible}.swagger-ui button,.swagger-ui select{text-transform:none}.swagger-ui [type=reset],.swagger-ui [type=submit],.swagger-ui button,.swagger-ui html [type=button]{-webkit-appearance:button}.swagger-ui [type=button]::-moz-focus-inner,.swagger-ui [type=reset]::-moz-focus-inner,.swagger-ui [type=submit]::-moz-focus-inner,.swagger-ui button::-moz-focus-inner{border-style:none;padding:0}.swagger-ui [type=button]:-moz-focusring,.swagger-ui [type=reset]:-moz-focusring,.swagger-ui [type=submit]:-moz-focusring,.swagger-ui button:-moz-focusring{outline:1px dotted ButtonText}.swagger-ui fieldset{padding:.35em .75em .625em}.swagger-ui legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal}.swagger-ui progress{display:inline-block;vertical-align:baseline}.swagger-ui textarea{overflow:auto}.swagger-ui [type=checkbox],.swagger-ui [type=radio]{box-sizing:border-box;padding:0}.swagger-ui [type=number]::-webkit-inner-spin-button,.swagger-ui [type=number]::-webkit-outer-spin-button{height:auto}.swagger-ui [type=search]{-webkit-appearance:textfield;outline-offset:-2px}.swagger-ui [type=search]::-webkit-search-cancel-button,.swagger-ui [type=search]::-webkit-search-decoration{-webkit-appearance:none}.swagger-ui ::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}.swagger-ui details,.swagger-ui menu{display:block}.swagger-ui summary{display:list-item}.swagger-ui canvas{display:inline-block}.swagger-ui [hidden],.swagger-ui template{display:none}.swagger-ui .debug *{outline:1px solid gold}.swagger-ui .debug-white *{outline:1px solid #fff}.swagger-ui .debug-black *{outline:1px solid #000}.swagger-ui .debug-grid{background:transparent url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyhpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTExIDc5LjE1ODMyNSwgMjAxNS8wOS8xMC0wMToxMDoyMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6MTRDOTY4N0U2N0VFMTFFNjg2MzZDQjkwNkQ4MjgwMEIiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6MTRDOTY4N0Q2N0VFMTFFNjg2MzZDQjkwNkQ4MjgwMEIiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTUgKE1hY2ludG9zaCkiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo3NjcyQkQ3NjY3QzUxMUU2QjJCQ0UyNDA4MTAwMjE3MSIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo3NjcyQkQ3NzY3QzUxMUU2QjJCQ0UyNDA4MTAwMjE3MSIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PsBS+GMAAAAjSURBVHjaYvz//z8DLsD4gcGXiYEAGBIKGBne//fFpwAgwAB98AaF2pjlUQAAAABJRU5ErkJggg==) repeat 0 0}.swagger-ui .debug-grid-16{background:transparent url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyhpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTExIDc5LjE1ODMyNSwgMjAxNS8wOS8xMC0wMToxMDoyMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6ODYyRjhERDU2N0YyMTFFNjg2MzZDQjkwNkQ4MjgwMEIiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6ODYyRjhERDQ2N0YyMTFFNjg2MzZDQjkwNkQ4MjgwMEIiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTUgKE1hY2ludG9zaCkiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo3NjcyQkQ3QTY3QzUxMUU2QjJCQ0UyNDA4MTAwMjE3MSIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo3NjcyQkQ3QjY3QzUxMUU2QjJCQ0UyNDA4MTAwMjE3MSIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PvCS01IAAABMSURBVHjaYmR4/5+BFPBfAMFm/MBgx8RAGWCn1AAmSg34Q6kBDKMGMDCwICeMIemF/5QawEipAWwUhwEjMDvbAWlWkvVBwu8vQIABAEwBCph8U6c0AAAAAElFTkSuQmCC) repeat 0 0}.swagger-ui .debug-grid-8-solid{background:#fff url(data:image/jpeg;base64,/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP/sABFEdWNreQABAAQAAAAAAAD/4QMxaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLwA8P3hwYWNrZXQgYmVnaW49Iu+7vyIgaWQ9Ilc1TTBNcENlaGlIenJlU3pOVGN6a2M5ZCI/PiA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJBZG9iZSBYTVAgQ29yZSA1LjYtYzExMSA3OS4xNTgzMjUsIDIwMTUvMDkvMTAtMDE6MTA6MjAgICAgICAgICI+IDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+IDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiIHhtbG5zOnhtcD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLyIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bXA6Q3JlYXRvclRvb2w9IkFkb2JlIFBob3Rvc2hvcCBDQyAyMDE1IChNYWNpbnRvc2gpIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOkIxMjI0OTczNjdCMzExRTZCMkJDRTI0MDgxMDAyMTcxIiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOkIxMjI0OTc0NjdCMzExRTZCMkJDRTI0MDgxMDAyMTcxIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6QjEyMjQ5NzE2N0IzMTFFNkIyQkNFMjQwODEwMDIxNzEiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6QjEyMjQ5NzI2N0IzMTFFNkIyQkNFMjQwODEwMDIxNzEiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz7/7gAOQWRvYmUAZMAAAAAB/9sAhAAbGhopHSlBJiZBQi8vL0JHPz4+P0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHAR0pKTQmND8oKD9HPzU/R0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0f/wAARCAAIAAgDASIAAhEBAxEB/8QAWQABAQAAAAAAAAAAAAAAAAAAAAYBAQEAAAAAAAAAAAAAAAAAAAIEEAEBAAMBAAAAAAAAAAAAAAABADECA0ERAAEDBQAAAAAAAAAAAAAAAAARITFBUWESIv/aAAwDAQACEQMRAD8AoOnTV1QTD7JJshP3vSM3P//Z) repeat 0 0}.swagger-ui .debug-grid-16-solid{background:#fff url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyhpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTExIDc5LjE1ODMyNSwgMjAxNS8wOS8xMC0wMToxMDoyMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTUgKE1hY2ludG9zaCkiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6NzY3MkJEN0U2N0M1MTFFNkIyQkNFMjQwODEwMDIxNzEiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6NzY3MkJEN0Y2N0M1MTFFNkIyQkNFMjQwODEwMDIxNzEiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo3NjcyQkQ3QzY3QzUxMUU2QjJCQ0UyNDA4MTAwMjE3MSIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo3NjcyQkQ3RDY3QzUxMUU2QjJCQ0UyNDA4MTAwMjE3MSIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/Pve6J3kAAAAzSURBVHjaYvz//z8D0UDsMwMjSRoYP5Gq4SPNbRjVMEQ1fCRDg+in/6+J1AJUxsgAEGAA31BAJMS0GYEAAAAASUVORK5CYII=) repeat 0 0}.swagger-ui .border-box,.swagger-ui a,.swagger-ui article,.swagger-ui body,.swagger-ui code,.swagger-ui dd,.swagger-ui div,.swagger-ui dl,.swagger-ui dt,.swagger-ui fieldset,.swagger-ui footer,.swagger-ui form,.swagger-ui h1,.swagger-ui h2,.swagger-ui h3,.swagger-ui h4,.swagger-ui h5,.swagger-ui h6,.swagger-ui header,.swagger-ui html,.swagger-ui input[type=email],.swagger-ui input[type=number],.swagger-ui input[type=password],.swagger-ui input[type=tel],.swagger-ui input[type=text],.swagger-ui input[type=url],.swagger-ui legend,.swagger-ui li,.swagger-ui main,.swagger-ui ol,.swagger-ui p,.swagger-ui pre,.swagger-ui section,.swagger-ui table,.swagger-ui td,.swagger-ui textarea,.swagger-ui th,.swagger-ui tr,.swagger-ui ul{box-sizing:border-box}.swagger-ui .aspect-ratio{height:0;position:relative}.swagger-ui .aspect-ratio--16x9{padding-bottom:56.25%}.swagger-ui .aspect-ratio--9x16{padding-bottom:177.77%}.swagger-ui .aspect-ratio--4x3{padding-bottom:75%}.swagger-ui .aspect-ratio--3x4{padding-bottom:133.33%}.swagger-ui .aspect-ratio--6x4{padding-bottom:66.6%}.swagger-ui .aspect-ratio--4x6{padding-bottom:150%}.swagger-ui .aspect-ratio--8x5{padding-bottom:62.5%}.swagger-ui .aspect-ratio--5x8{padding-bottom:160%}.swagger-ui .aspect-ratio--7x5{padding-bottom:71.42%}.swagger-ui .aspect-ratio--5x7{padding-bottom:140%}.swagger-ui .aspect-ratio--1x1{padding-bottom:100%}.swagger-ui .aspect-ratio--object{bottom:0;height:100%;left:0;position:absolute;right:0;top:0;width:100%;z-index:100}@media screen and (min-width:30em){.swagger-ui .aspect-ratio-ns{height:0;position:relative}.swagger-ui .aspect-ratio--16x9-ns{padding-bottom:56.25%}.swagger-ui .aspect-ratio--9x16-ns{padding-bottom:177.77%}.swagger-ui .aspect-ratio--4x3-ns{padding-bottom:75%}.swagger-ui .aspect-ratio--3x4-ns{padding-bottom:133.33%}.swagger-ui .aspect-ratio--6x4-ns{padding-bottom:66.6%}.swagger-ui .aspect-ratio--4x6-ns{padding-bottom:150%}.swagger-ui .aspect-ratio--8x5-ns{padding-bottom:62.5%}.swagger-ui .aspect-ratio--5x8-ns{padding-bottom:160%}.swagger-ui .aspect-ratio--7x5-ns{padding-bottom:71.42%}.swagger-ui .aspect-ratio--5x7-ns{padding-bottom:140%}.swagger-ui .aspect-ratio--1x1-ns{padding-bottom:100%}.swagger-ui .aspect-ratio--object-ns{bottom:0;height:100%;left:0;position:absolute;right:0;top:0;width:100%;z-index:100}}@media screen and (min-width:30em) and (max-width:60em){.swagger-ui .aspect-ratio-m{height:0;position:relative}.swagger-ui .aspect-ratio--16x9-m{padding-bottom:56.25%}.swagger-ui .aspect-ratio--9x16-m{padding-bottom:177.77%}.swagger-ui .aspect-ratio--4x3-m{padding-bottom:75%}.swagger-ui .aspect-ratio--3x4-m{padding-bottom:133.33%}.swagger-ui .aspect-ratio--6x4-m{padding-bottom:66.6%}.swagger-ui .aspect-ratio--4x6-m{padding-bottom:150%}.swagger-ui .aspect-ratio--8x5-m{padding-bottom:62.5%}.swagger-ui .aspect-ratio--5x8-m{padding-bottom:160%}.swagger-ui .aspect-ratio--7x5-m{padding-bottom:71.42%}.swagger-ui .aspect-ratio--5x7-m{padding-bottom:140%}.swagger-ui .aspect-ratio--1x1-m{padding-bottom:100%}.swagger-ui .aspect-ratio--object-m{bottom:0;height:100%;left:0;position:absolute;right:0;top:0;width:100%;z-index:100}}@media screen and (min-width:60em){.swagger-ui .aspect-ratio-l{height:0;position:relative}.swagger-ui .aspect-ratio--16x9-l{padding-bottom:56.25%}.swagger-ui .aspect-ratio--9x16-l{padding-bottom:177.77%}.swagger-ui .aspect-ratio--4x3-l{padding-bottom:75%}.swagger-ui .aspect-ratio--3x4-l{padding-bottom:133.33%}.swagger-ui .aspect-ratio--6x4-l{padding-bottom:66.6%}.swagger-ui .aspect-ratio--4x6-l{padding-bottom:150%}.swagger-ui .aspect-ratio--8x5-l{padding-bottom:62.5%}.swagger-ui .aspect-ratio--5x8-l{padding-bottom:160%}.swagger-ui .aspect-ratio--7x5-l{padding-bottom:71.42%}.swagger-ui .aspect-ratio--5x7-l{padding-bottom:140%}.swagger-ui .aspect-ratio--1x1-l{padding-bottom:100%}.swagger-ui .aspect-ratio--object-l{bottom:0;height:100%;left:0;position:absolute;right:0;top:0;width:100%;z-index:100}}.swagger-ui img{max-width:100%}.swagger-ui .cover{background-size:cover!important}.swagger-ui .contain{background-size:contain!important}@media screen and (min-width:30em){.swagger-ui .cover-ns{background-size:cover!important}.swagger-ui .contain-ns{background-size:contain!important}}@media screen and (min-width:30em) and (max-width:60em){.swagger-ui .cover-m{background-size:cover!important}.swagger-ui .contain-m{background-size:contain!important}}@media screen and (min-width:60em){.swagger-ui .cover-l{background-size:cover!important}.swagger-ui .contain-l{background-size:contain!important}}.swagger-ui .bg-center{background-position:50%;background-repeat:no-repeat}.swagger-ui .bg-top{background-position:top;background-repeat:no-repeat}.swagger-ui .bg-right{background-position:100%;background-repeat:no-repeat}.swagger-ui .bg-bottom{background-position:bottom;background-repeat:no-repeat}.swagger-ui .bg-left{background-position:0;background-repeat:no-repeat}@media screen and (min-width:30em){.swagger-ui .bg-center-ns{background-position:50%;background-repeat:no-repeat}.swagger-ui .bg-top-ns{background-position:top;background-repeat:no-repeat}.swagger-ui .bg-right-ns{background-position:100%;background-repeat:no-repeat}.swagger-ui .bg-bottom-ns{background-position:bottom;background-repeat:no-repeat}.swagger-ui .bg-left-ns{background-position:0;background-repeat:no-repeat}}@media screen and (min-width:30em) and (max-width:60em){.swagger-ui .bg-center-m{background-position:50%;background-repeat:no-repeat}.swagger-ui .bg-top-m{background-position:top;background-repeat:no-repeat}.swagger-ui .bg-right-m{background-position:100%;background-repeat:no-repeat}.swagger-ui .bg-bottom-m{background-position:bottom;background-repeat:no-repeat}.swagger-ui .bg-left-m{background-position:0;background-repeat:no-repeat}}@media screen and (min-width:60em){.swagger-ui .bg-center-l{background-position:50%;background-repeat:no-repeat}.swagger-ui .bg-top-l{background-position:top;background-repeat:no-repeat}.swagger-ui .bg-right-l{background-position:100%;background-repeat:no-repeat}.swagger-ui .bg-bottom-l{background-position:bottom;background-repeat:no-repeat}.swagger-ui .bg-left-l{background-position:0;background-repeat:no-repeat}}.swagger-ui .outline{outline:1px solid}.swagger-ui .outline-transparent{outline:1px solid transparent}.swagger-ui .outline-0{outline:0}@media screen and (min-width:30em){.swagger-ui .outline-ns{outline:1px solid}.swagger-ui .outline-transparent-ns{outline:1px solid transparent}.swagger-ui .outline-0-ns{outline:0}}@media screen and (min-width:30em) and (max-width:60em){.swagger-ui .outline-m{outline:1px solid}.swagger-ui .outline-transparent-m{outline:1px solid transparent}.swagger-ui .outline-0-m{outline:0}}@media screen and (min-width:60em){.swagger-ui .outline-l{outline:1px solid}.swagger-ui .outline-transparent-l{outline:1px solid transparent}.swagger-ui .outline-0-l{outline:0}}.swagger-ui .ba{border-style:solid;border-width:1px}.swagger-ui .bt{border-top-style:solid;border-top-width:1px}.swagger-ui .br{border-right-style:solid;border-right-width:1px}.swagger-ui .bb{border-bottom-style:solid;border-bottom-width:1px}.swagger-ui .bl{border-left-style:solid;border-left-width:1px}.swagger-ui .bn{border-style:none;border-width:0}@media screen and (min-width:30em){.swagger-ui .ba-ns{border-style:solid;border-width:1px}.swagger-ui .bt-ns{border-top-style:solid;border-top-width:1px}.swagger-ui .br-ns{border-right-style:solid;border-right-width:1px}.swagger-ui .bb-ns{border-bottom-style:solid;border-bottom-width:1px}.swagger-ui .bl-ns{border-left-style:solid;border-left-width:1px}.swagger-ui .bn-ns{border-style:none;border-width:0}}@media screen and (min-width:30em) and (max-width:60em){.swagger-ui .ba-m{border-style:solid;border-width:1px}.swagger-ui .bt-m{border-top-style:solid;border-top-width:1px}.swagger-ui .br-m{border-right-style:solid;border-right-width:1px}.swagger-ui .bb-m{border-bottom-style:solid;border-bottom-width:1px}.swagger-ui .bl-m{border-left-style:solid;border-left-width:1px}.swagger-ui .bn-m{border-style:none;border-width:0}}@media screen and (min-width:60em){.swagger-ui .ba-l{border-style:solid;border-width:1px}.swagger-ui .bt-l{border-top-style:solid;border-top-width:1px}.swagger-ui .br-l{border-right-style:solid;border-right-width:1px}.swagger-ui .bb-l{border-bottom-style:solid;border-bottom-width:1px}.swagger-ui .bl-l{border-left-style:solid;border-left-width:1px}.swagger-ui .bn-l{border-style:none;border-width:0}}.swagger-ui .b--black{border-color:#000}.swagger-ui .b--near-black{border-color:#111}.swagger-ui .b--dark-gray{border-color:#333}.swagger-ui .b--mid-gray{border-color:#555}.swagger-ui .b--gray{border-color:#777}.swagger-ui .b--silver{border-color:#999}.swagger-ui .b--light-silver{border-color:#aaa}.swagger-ui .b--moon-gray{border-color:#ccc}.swagger-ui .b--light-gray{border-color:#eee}.swagger-ui .b--near-white{border-color:#f4f4f4}.swagger-ui .b--white{border-color:#fff}.swagger-ui .b--white-90{border-color:hsla(0,0%,100%,.9)}.swagger-ui .b--white-80{border-color:hsla(0,0%,100%,.8)}.swagger-ui .b--white-70{border-color:hsla(0,0%,100%,.7)}.swagger-ui .b--white-60{border-color:hsla(0,0%,100%,.6)}.swagger-ui .b--white-50{border-color:hsla(0,0%,100%,.5)}.swagger-ui .b--white-40{border-color:hsla(0,0%,100%,.4)}.swagger-ui .b--white-30{border-color:hsla(0,0%,100%,.3)}.swagger-ui .b--white-20{border-color:hsla(0,0%,100%,.2)}.swagger-ui .b--white-10{border-color:hsla(0,0%,100%,.1)}.swagger-ui .b--white-05{border-color:hsla(0,0%,100%,.05)}.swagger-ui .b--white-025{border-color:hsla(0,0%,100%,.025)}.swagger-ui .b--white-0125{border-color:hsla(0,0%,100%,.013)}.swagger-ui .b--black-90{border-color:rgba(0,0,0,.9)}.swagger-ui .b--black-80{border-color:rgba(0,0,0,.8)}.swagger-ui .b--black-70{border-color:rgba(0,0,0,.7)}.swagger-ui .b--black-60{border-color:rgba(0,0,0,.6)}.swagger-ui .b--black-50{border-color:rgba(0,0,0,.5)}.swagger-ui .b--black-40{border-color:rgba(0,0,0,.4)}.swagger-ui .b--black-30{border-color:rgba(0,0,0,.3)}.swagger-ui .b--black-20{border-color:rgba(0,0,0,.2)}.swagger-ui .b--black-10{border-color:rgba(0,0,0,.1)}.swagger-ui .b--black-05{border-color:rgba(0,0,0,.05)}.swagger-ui .b--black-025{border-color:rgba(0,0,0,.025)}.swagger-ui .b--black-0125{border-color:rgba(0,0,0,.013)}.swagger-ui .b--dark-red{border-color:#e7040f}.swagger-ui .b--red{border-color:#ff4136}.swagger-ui .b--light-red{border-color:#ff725c}.swagger-ui .b--orange{border-color:#ff6300}.swagger-ui .b--gold{border-color:#ffb700}.swagger-ui .b--yellow{border-color:gold}.swagger-ui .b--light-yellow{border-color:#fbf1a9}.swagger-ui .b--purple{border-color:#5e2ca5}.swagger-ui .b--light-purple{border-color:#a463f2}.swagger-ui .b--dark-pink{border-color:#d5008f}.swagger-ui .b--hot-pink{border-color:#ff41b4}.swagger-ui .b--pink{border-color:#ff80cc}.swagger-ui .b--light-pink{border-color:#ffa3d7}.swagger-ui .b--dark-green{border-color:#137752}.swagger-ui .b--green{border-color:#19a974}.swagger-ui .b--light-green{border-color:#9eebcf}.swagger-ui .b--navy{border-color:#001b44}.swagger-ui .b--dark-blue{border-color:#00449e}.swagger-ui .b--blue{border-color:#357edd}.swagger-ui .b--light-blue{border-color:#96ccff}.swagger-ui .b--lightest-blue{border-color:#cdecff}.swagger-ui .b--washed-blue{border-color:#f6fffe}.swagger-ui .b--washed-green{border-color:#e8fdf5}.swagger-ui .b--washed-yellow{border-color:#fffceb}.swagger-ui .b--washed-red{border-color:#ffdfdf}.swagger-ui .b--transparent{border-color:transparent}.swagger-ui .b--inherit{border-color:inherit}.swagger-ui .br0{border-radius:0}.swagger-ui .br1{border-radius:.125rem}.swagger-ui .br2{border-radius:.25rem}.swagger-ui .br3{border-radius:.5rem}.swagger-ui .br4{border-radius:1rem}.swagger-ui .br-100{border-radius:100%}.swagger-ui .br-pill{border-radius:9999px}.swagger-ui .br--bottom{border-top-left-radius:0;border-top-right-radius:0}.swagger-ui .br--top{border-bottom-left-radius:0;border-bottom-right-radius:0}.swagger-ui .br--right{border-bottom-left-radius:0;border-top-left-radius:0}.swagger-ui .br--left{border-bottom-right-radius:0;border-top-right-radius:0}@media screen and (min-width:30em){.swagger-ui .br0-ns{border-radius:0}.swagger-ui .br1-ns{border-radius:.125rem}.swagger-ui .br2-ns{border-radius:.25rem}.swagger-ui .br3-ns{border-radius:.5rem}.swagger-ui .br4-ns{border-radius:1rem}.swagger-ui .br-100-ns{border-radius:100%}.swagger-ui .br-pill-ns{border-radius:9999px}.swagger-ui .br--bottom-ns{border-top-left-radius:0;border-top-right-radius:0}.swagger-ui .br--top-ns{border-bottom-left-radius:0;border-bottom-right-radius:0}.swagger-ui .br--right-ns{border-bottom-left-radius:0;border-top-left-radius:0}.swagger-ui .br--left-ns{border-bottom-right-radius:0;border-top-right-radius:0}}@media screen and (min-width:30em) and (max-width:60em){.swagger-ui .br0-m{border-radius:0}.swagger-ui .br1-m{border-radius:.125rem}.swagger-ui .br2-m{border-radius:.25rem}.swagger-ui .br3-m{border-radius:.5rem}.swagger-ui .br4-m{border-radius:1rem}.swagger-ui .br-100-m{border-radius:100%}.swagger-ui .br-pill-m{border-radius:9999px}.swagger-ui .br--bottom-m{border-top-left-radius:0;border-top-right-radius:0}.swagger-ui .br--top-m{border-bottom-left-radius:0;border-bottom-right-radius:0}.swagger-ui .br--right-m{border-bottom-left-radius:0;border-top-left-radius:0}.swagger-ui .br--left-m{border-bottom-right-radius:0;border-top-right-radius:0}}@media screen and (min-width:60em){.swagger-ui .br0-l{border-radius:0}.swagger-ui .br1-l{border-radius:.125rem}.swagger-ui .br2-l{border-radius:.25rem}.swagger-ui .br3-l{border-radius:.5rem}.swagger-ui .br4-l{border-radius:1rem}.swagger-ui .br-100-l{border-radius:100%}.swagger-ui .br-pill-l{border-radius:9999px}.swagger-ui .br--bottom-l{border-top-left-radius:0;border-top-right-radius:0}.swagger-ui .br--top-l{border-bottom-left-radius:0;border-bottom-right-radius:0}.swagger-ui .br--right-l{border-bottom-left-radius:0;border-top-left-radius:0}.swagger-ui .br--left-l{border-bottom-right-radius:0;border-top-right-radius:0}}.swagger-ui .b--dotted{border-style:dotted}.swagger-ui .b--dashed{border-style:dashed}.swagger-ui .b--solid{border-style:solid}.swagger-ui .b--none{border-style:none}@media screen and (min-width:30em){.swagger-ui .b--dotted-ns{border-style:dotted}.swagger-ui .b--dashed-ns{border-style:dashed}.swagger-ui .b--solid-ns{border-style:solid}.swagger-ui .b--none-ns{border-style:none}}@media screen and (min-width:30em) and (max-width:60em){.swagger-ui .b--dotted-m{border-style:dotted}.swagger-ui .b--dashed-m{border-style:dashed}.swagger-ui .b--solid-m{border-style:solid}.swagger-ui .b--none-m{border-style:none}}@media screen and (min-width:60em){.swagger-ui .b--dotted-l{border-style:dotted}.swagger-ui .b--dashed-l{border-style:dashed}.swagger-ui .b--solid-l{border-style:solid}.swagger-ui .b--none-l{border-style:none}}.swagger-ui .bw0{border-width:0}.swagger-ui .bw1{border-width:.125rem}.swagger-ui .bw2{border-width:.25rem}.swagger-ui .bw3{border-width:.5rem}.swagger-ui .bw4{border-width:1rem}.swagger-ui .bw5{border-width:2rem}.swagger-ui .bt-0{border-top-width:0}.swagger-ui .br-0{border-right-width:0}.swagger-ui .bb-0{border-bottom-width:0}.swagger-ui .bl-0{border-left-width:0}@media screen and (min-width:30em){.swagger-ui .bw0-ns{border-width:0}.swagger-ui .bw1-ns{border-width:.125rem}.swagger-ui .bw2-ns{border-width:.25rem}.swagger-ui .bw3-ns{border-width:.5rem}.swagger-ui .bw4-ns{border-width:1rem}.swagger-ui .bw5-ns{border-width:2rem}.swagger-ui .bt-0-ns{border-top-width:0}.swagger-ui .br-0-ns{border-right-width:0}.swagger-ui .bb-0-ns{border-bottom-width:0}.swagger-ui .bl-0-ns{border-left-width:0}}@media screen and (min-width:30em) and (max-width:60em){.swagger-ui .bw0-m{border-width:0}.swagger-ui .bw1-m{border-width:.125rem}.swagger-ui .bw2-m{border-width:.25rem}.swagger-ui .bw3-m{border-width:.5rem}.swagger-ui .bw4-m{border-width:1rem}.swagger-ui .bw5-m{border-width:2rem}.swagger-ui .bt-0-m{border-top-width:0}.swagger-ui .br-0-m{border-right-width:0}.swagger-ui .bb-0-m{border-bottom-width:0}.swagger-ui .bl-0-m{border-left-width:0}}@media screen and (min-width:60em){.swagger-ui .bw0-l{border-width:0}.swagger-ui .bw1-l{border-width:.125rem}.swagger-ui .bw2-l{border-width:.25rem}.swagger-ui .bw3-l{border-width:.5rem}.swagger-ui .bw4-l{border-width:1rem}.swagger-ui .bw5-l{border-width:2rem}.swagger-ui .bt-0-l{border-top-width:0}.swagger-ui .br-0-l{border-right-width:0}.swagger-ui .bb-0-l{border-bottom-width:0}.swagger-ui .bl-0-l{border-left-width:0}}.swagger-ui .shadow-1{box-shadow:0 0 4px 2px rgba(0,0,0,.2)}.swagger-ui .shadow-2{box-shadow:0 0 8px 2px rgba(0,0,0,.2)}.swagger-ui .shadow-3{box-shadow:2px 2px 4px 2px rgba(0,0,0,.2)}.swagger-ui .shadow-4{box-shadow:2px 2px 8px 0 rgba(0,0,0,.2)}.swagger-ui .shadow-5{box-shadow:4px 4px 8px 0 rgba(0,0,0,.2)}@media screen and (min-width:30em){.swagger-ui .shadow-1-ns{box-shadow:0 0 4px 2px rgba(0,0,0,.2)}.swagger-ui .shadow-2-ns{box-shadow:0 0 8px 2px rgba(0,0,0,.2)}.swagger-ui .shadow-3-ns{box-shadow:2px 2px 4px 2px rgba(0,0,0,.2)}.swagger-ui .shadow-4-ns{box-shadow:2px 2px 8px 0 rgba(0,0,0,.2)}.swagger-ui .shadow-5-ns{box-shadow:4px 4px 8px 0 rgba(0,0,0,.2)}}@media screen and (min-width:30em) and (max-width:60em){.swagger-ui .shadow-1-m{box-shadow:0 0 4px 2px rgba(0,0,0,.2)}.swagger-ui .shadow-2-m{box-shadow:0 0 8px 2px rgba(0,0,0,.2)}.swagger-ui .shadow-3-m{box-shadow:2px 2px 4px 2px rgba(0,0,0,.2)}.swagger-ui .shadow-4-m{box-shadow:2px 2px 8px 0 rgba(0,0,0,.2)}.swagger-ui .shadow-5-m{box-shadow:4px 4px 8px 0 rgba(0,0,0,.2)}}@media screen and (min-width:60em){.swagger-ui .shadow-1-l{box-shadow:0 0 4px 2px rgba(0,0,0,.2)}.swagger-ui .shadow-2-l{box-shadow:0 0 8px 2px rgba(0,0,0,.2)}.swagger-ui .shadow-3-l{box-shadow:2px 2px 4px 2px rgba(0,0,0,.2)}.swagger-ui .shadow-4-l{box-shadow:2px 2px 8px 0 rgba(0,0,0,.2)}.swagger-ui .shadow-5-l{box-shadow:4px 4px 8px 0 rgba(0,0,0,.2)}}.swagger-ui .pre{overflow-x:auto;overflow-y:hidden;overflow:scroll}.swagger-ui .top-0{top:0}.swagger-ui .right-0{right:0}.swagger-ui .bottom-0{bottom:0}.swagger-ui .left-0{left:0}.swagger-ui .top-1{top:1rem}.swagger-ui .right-1{right:1rem}.swagger-ui .bottom-1{bottom:1rem}.swagger-ui .left-1{left:1rem}.swagger-ui .top-2{top:2rem}.swagger-ui .right-2{right:2rem}.swagger-ui .bottom-2{bottom:2rem}.swagger-ui .left-2{left:2rem}.swagger-ui .top--1{top:-1rem}.swagger-ui .right--1{right:-1rem}.swagger-ui .bottom--1{bottom:-1rem}.swagger-ui .left--1{left:-1rem}.swagger-ui .top--2{top:-2rem}.swagger-ui .right--2{right:-2rem}.swagger-ui .bottom--2{bottom:-2rem}.swagger-ui .left--2{left:-2rem}.swagger-ui .absolute--fill{bottom:0;left:0;right:0;top:0}@media screen and (min-width:30em){.swagger-ui .top-0-ns{top:0}.swagger-ui .left-0-ns{left:0}.swagger-ui .right-0-ns{right:0}.swagger-ui .bottom-0-ns{bottom:0}.swagger-ui .top-1-ns{top:1rem}.swagger-ui .left-1-ns{left:1rem}.swagger-ui .right-1-ns{right:1rem}.swagger-ui .bottom-1-ns{bottom:1rem}.swagger-ui .top-2-ns{top:2rem}.swagger-ui .left-2-ns{left:2rem}.swagger-ui .right-2-ns{right:2rem}.swagger-ui .bottom-2-ns{bottom:2rem}.swagger-ui .top--1-ns{top:-1rem}.swagger-ui .right--1-ns{right:-1rem}.swagger-ui .bottom--1-ns{bottom:-1rem}.swagger-ui .left--1-ns{left:-1rem}.swagger-ui .top--2-ns{top:-2rem}.swagger-ui .right--2-ns{right:-2rem}.swagger-ui .bottom--2-ns{bottom:-2rem}.swagger-ui .left--2-ns{left:-2rem}.swagger-ui .absolute--fill-ns{bottom:0;left:0;right:0;top:0}}@media screen and (min-width:30em) and (max-width:60em){.swagger-ui .top-0-m{top:0}.swagger-ui .left-0-m{left:0}.swagger-ui .right-0-m{right:0}.swagger-ui .bottom-0-m{bottom:0}.swagger-ui .top-1-m{top:1rem}.swagger-ui .left-1-m{left:1rem}.swagger-ui .right-1-m{right:1rem}.swagger-ui .bottom-1-m{bottom:1rem}.swagger-ui .top-2-m{top:2rem}.swagger-ui .left-2-m{left:2rem}.swagger-ui .right-2-m{right:2rem}.swagger-ui .bottom-2-m{bottom:2rem}.swagger-ui .top--1-m{top:-1rem}.swagger-ui .right--1-m{right:-1rem}.swagger-ui .bottom--1-m{bottom:-1rem}.swagger-ui .left--1-m{left:-1rem}.swagger-ui .top--2-m{top:-2rem}.swagger-ui .right--2-m{right:-2rem}.swagger-ui .bottom--2-m{bottom:-2rem}.swagger-ui .left--2-m{left:-2rem}.swagger-ui .absolute--fill-m{bottom:0;left:0;right:0;top:0}}@media screen and (min-width:60em){.swagger-ui .top-0-l{top:0}.swagger-ui .left-0-l{left:0}.swagger-ui .right-0-l{right:0}.swagger-ui .bottom-0-l{bottom:0}.swagger-ui .top-1-l{top:1rem}.swagger-ui .left-1-l{left:1rem}.swagger-ui .right-1-l{right:1rem}.swagger-ui .bottom-1-l{bottom:1rem}.swagger-ui .top-2-l{top:2rem}.swagger-ui .left-2-l{left:2rem}.swagger-ui .right-2-l{right:2rem}.swagger-ui .bottom-2-l{bottom:2rem}.swagger-ui .top--1-l{top:-1rem}.swagger-ui .right--1-l{right:-1rem}.swagger-ui .bottom--1-l{bottom:-1rem}.swagger-ui .left--1-l{left:-1rem}.swagger-ui .top--2-l{top:-2rem}.swagger-ui .right--2-l{right:-2rem}.swagger-ui .bottom--2-l{bottom:-2rem}.swagger-ui .left--2-l{left:-2rem}.swagger-ui .absolute--fill-l{bottom:0;left:0;right:0;top:0}}.swagger-ui .cf:after,.swagger-ui .cf:before{content:" ";display:table}.swagger-ui .cf:after{clear:both}.swagger-ui .cf{*zoom:1}.swagger-ui .cl{clear:left}.swagger-ui .cr{clear:right}.swagger-ui .cb{clear:both}.swagger-ui .cn{clear:none}@media screen and (min-width:30em){.swagger-ui .cl-ns{clear:left}.swagger-ui .cr-ns{clear:right}.swagger-ui .cb-ns{clear:both}.swagger-ui .cn-ns{clear:none}}@media screen and (min-width:30em) and (max-width:60em){.swagger-ui .cl-m{clear:left}.swagger-ui .cr-m{clear:right}.swagger-ui .cb-m{clear:both}.swagger-ui .cn-m{clear:none}}@media screen and (min-width:60em){.swagger-ui .cl-l{clear:left}.swagger-ui .cr-l{clear:right}.swagger-ui .cb-l{clear:both}.swagger-ui .cn-l{clear:none}}.swagger-ui .flex{display:flex}.swagger-ui .inline-flex{display:inline-flex}.swagger-ui .flex-auto{flex:1 1 auto;min-height:0;min-width:0}.swagger-ui .flex-none{flex:none}.swagger-ui .flex-column{flex-direction:column}.swagger-ui .flex-row{flex-direction:row}.swagger-ui .flex-wrap{flex-wrap:wrap}.swagger-ui .flex-nowrap{flex-wrap:nowrap}.swagger-ui .flex-wrap-reverse{flex-wrap:wrap-reverse}.swagger-ui .flex-column-reverse{flex-direction:column-reverse}.swagger-ui .flex-row-reverse{flex-direction:row-reverse}.swagger-ui .items-start{align-items:flex-start}.swagger-ui .items-end{align-items:flex-end}.swagger-ui .items-center{align-items:center}.swagger-ui .items-baseline{align-items:baseline}.swagger-ui .items-stretch{align-items:stretch}.swagger-ui .self-start{align-self:flex-start}.swagger-ui .self-end{align-self:flex-end}.swagger-ui .self-center{align-self:center}.swagger-ui .self-baseline{align-self:baseline}.swagger-ui .self-stretch{align-self:stretch}.swagger-ui .justify-start{justify-content:flex-start}.swagger-ui .justify-end{justify-content:flex-end}.swagger-ui .justify-center{justify-content:center}.swagger-ui .justify-between{justify-content:space-between}.swagger-ui .justify-around{justify-content:space-around}.swagger-ui .content-start{align-content:flex-start}.swagger-ui .content-end{align-content:flex-end}.swagger-ui .content-center{align-content:center}.swagger-ui .content-between{align-content:space-between}.swagger-ui .content-around{align-content:space-around}.swagger-ui .content-stretch{align-content:stretch}.swagger-ui .order-0{order:0}.swagger-ui .order-1{order:1}.swagger-ui .order-2{order:2}.swagger-ui .order-3{order:3}.swagger-ui .order-4{order:4}.swagger-ui .order-5{order:5}.swagger-ui .order-6{order:6}.swagger-ui .order-7{order:7}.swagger-ui .order-8{order:8}.swagger-ui .order-last{order:99999}.swagger-ui .flex-grow-0{flex-grow:0}.swagger-ui .flex-grow-1{flex-grow:1}.swagger-ui .flex-shrink-0{flex-shrink:0}.swagger-ui .flex-shrink-1{flex-shrink:1}@media screen and (min-width:30em){.swagger-ui .flex-ns{display:flex}.swagger-ui .inline-flex-ns{display:inline-flex}.swagger-ui .flex-auto-ns{flex:1 1 auto;min-height:0;min-width:0}.swagger-ui .flex-none-ns{flex:none}.swagger-ui .flex-column-ns{flex-direction:column}.swagger-ui .flex-row-ns{flex-direction:row}.swagger-ui .flex-wrap-ns{flex-wrap:wrap}.swagger-ui .flex-nowrap-ns{flex-wrap:nowrap}.swagger-ui .flex-wrap-reverse-ns{flex-wrap:wrap-reverse}.swagger-ui .flex-column-reverse-ns{flex-direction:column-reverse}.swagger-ui .flex-row-reverse-ns{flex-direction:row-reverse}.swagger-ui .items-start-ns{align-items:flex-start}.swagger-ui .items-end-ns{align-items:flex-end}.swagger-ui .items-center-ns{align-items:center}.swagger-ui .items-baseline-ns{align-items:baseline}.swagger-ui .items-stretch-ns{align-items:stretch}.swagger-ui .self-start-ns{align-self:flex-start}.swagger-ui .self-end-ns{align-self:flex-end}.swagger-ui .self-center-ns{align-self:center}.swagger-ui .self-baseline-ns{align-self:baseline}.swagger-ui .self-stretch-ns{align-self:stretch}.swagger-ui .justify-start-ns{justify-content:flex-start}.swagger-ui .justify-end-ns{justify-content:flex-end}.swagger-ui .justify-center-ns{justify-content:center}.swagger-ui .justify-between-ns{justify-content:space-between}.swagger-ui .justify-around-ns{justify-content:space-around}.swagger-ui .content-start-ns{align-content:flex-start}.swagger-ui .content-end-ns{align-content:flex-end}.swagger-ui .content-center-ns{align-content:center}.swagger-ui .content-between-ns{align-content:space-between}.swagger-ui .content-around-ns{align-content:space-around}.swagger-ui .content-stretch-ns{align-content:stretch}.swagger-ui .order-0-ns{order:0}.swagger-ui .order-1-ns{order:1}.swagger-ui .order-2-ns{order:2}.swagger-ui .order-3-ns{order:3}.swagger-ui .order-4-ns{order:4}.swagger-ui .order-5-ns{order:5}.swagger-ui .order-6-ns{order:6}.swagger-ui .order-7-ns{order:7}.swagger-ui .order-8-ns{order:8}.swagger-ui .order-last-ns{order:99999}.swagger-ui .flex-grow-0-ns{flex-grow:0}.swagger-ui .flex-grow-1-ns{flex-grow:1}.swagger-ui .flex-shrink-0-ns{flex-shrink:0}.swagger-ui .flex-shrink-1-ns{flex-shrink:1}}@media screen and (min-width:30em) and (max-width:60em){.swagger-ui .flex-m{display:flex}.swagger-ui .inline-flex-m{display:inline-flex}.swagger-ui .flex-auto-m{flex:1 1 auto;min-height:0;min-width:0}.swagger-ui .flex-none-m{flex:none}.swagger-ui .flex-column-m{flex-direction:column}.swagger-ui .flex-row-m{flex-direction:row}.swagger-ui .flex-wrap-m{flex-wrap:wrap}.swagger-ui .flex-nowrap-m{flex-wrap:nowrap}.swagger-ui .flex-wrap-reverse-m{flex-wrap:wrap-reverse}.swagger-ui .flex-column-reverse-m{flex-direction:column-reverse}.swagger-ui .flex-row-reverse-m{flex-direction:row-reverse}.swagger-ui .items-start-m{align-items:flex-start}.swagger-ui .items-end-m{align-items:flex-end}.swagger-ui .items-center-m{align-items:center}.swagger-ui .items-baseline-m{align-items:baseline}.swagger-ui .items-stretch-m{align-items:stretch}.swagger-ui .self-start-m{align-self:flex-start}.swagger-ui .self-end-m{align-self:flex-end}.swagger-ui .self-center-m{align-self:center}.swagger-ui .self-baseline-m{align-self:baseline}.swagger-ui .self-stretch-m{align-self:stretch}.swagger-ui .justify-start-m{justify-content:flex-start}.swagger-ui .justify-end-m{justify-content:flex-end}.swagger-ui .justify-center-m{justify-content:center}.swagger-ui .justify-between-m{justify-content:space-between}.swagger-ui .justify-around-m{justify-content:space-around}.swagger-ui .content-start-m{align-content:flex-start}.swagger-ui .content-end-m{align-content:flex-end}.swagger-ui .content-center-m{align-content:center}.swagger-ui .content-between-m{align-content:space-between}.swagger-ui .content-around-m{align-content:space-around}.swagger-ui .content-stretch-m{align-content:stretch}.swagger-ui .order-0-m{order:0}.swagger-ui .order-1-m{order:1}.swagger-ui .order-2-m{order:2}.swagger-ui .order-3-m{order:3}.swagger-ui .order-4-m{order:4}.swagger-ui .order-5-m{order:5}.swagger-ui .order-6-m{order:6}.swagger-ui .order-7-m{order:7}.swagger-ui .order-8-m{order:8}.swagger-ui .order-last-m{order:99999}.swagger-ui .flex-grow-0-m{flex-grow:0}.swagger-ui .flex-grow-1-m{flex-grow:1}.swagger-ui .flex-shrink-0-m{flex-shrink:0}.swagger-ui .flex-shrink-1-m{flex-shrink:1}}@media screen and (min-width:60em){.swagger-ui .flex-l{display:flex}.swagger-ui .inline-flex-l{display:inline-flex}.swagger-ui .flex-auto-l{flex:1 1 auto;min-height:0;min-width:0}.swagger-ui .flex-none-l{flex:none}.swagger-ui .flex-column-l{flex-direction:column}.swagger-ui .flex-row-l{flex-direction:row}.swagger-ui .flex-wrap-l{flex-wrap:wrap}.swagger-ui .flex-nowrap-l{flex-wrap:nowrap}.swagger-ui .flex-wrap-reverse-l{flex-wrap:wrap-reverse}.swagger-ui .flex-column-reverse-l{flex-direction:column-reverse}.swagger-ui .flex-row-reverse-l{flex-direction:row-reverse}.swagger-ui .items-start-l{align-items:flex-start}.swagger-ui .items-end-l{align-items:flex-end}.swagger-ui .items-center-l{align-items:center}.swagger-ui .items-baseline-l{align-items:baseline}.swagger-ui .items-stretch-l{align-items:stretch}.swagger-ui .self-start-l{align-self:flex-start}.swagger-ui .self-end-l{align-self:flex-end}.swagger-ui .self-center-l{align-self:center}.swagger-ui .self-baseline-l{align-self:baseline}.swagger-ui .self-stretch-l{align-self:stretch}.swagger-ui .justify-start-l{justify-content:flex-start}.swagger-ui .justify-end-l{justify-content:flex-end}.swagger-ui .justify-center-l{justify-content:center}.swagger-ui .justify-between-l{justify-content:space-between}.swagger-ui .justify-around-l{justify-content:space-around}.swagger-ui .content-start-l{align-content:flex-start}.swagger-ui .content-end-l{align-content:flex-end}.swagger-ui .content-center-l{align-content:center}.swagger-ui .content-between-l{align-content:space-between}.swagger-ui .content-around-l{align-content:space-around}.swagger-ui .content-stretch-l{align-content:stretch}.swagger-ui .order-0-l{order:0}.swagger-ui .order-1-l{order:1}.swagger-ui .order-2-l{order:2}.swagger-ui .order-3-l{order:3}.swagger-ui .order-4-l{order:4}.swagger-ui .order-5-l{order:5}.swagger-ui .order-6-l{order:6}.swagger-ui .order-7-l{order:7}.swagger-ui .order-8-l{order:8}.swagger-ui .order-last-l{order:99999}.swagger-ui .flex-grow-0-l{flex-grow:0}.swagger-ui .flex-grow-1-l{flex-grow:1}.swagger-ui .flex-shrink-0-l{flex-shrink:0}.swagger-ui .flex-shrink-1-l{flex-shrink:1}}.swagger-ui .dn{display:none}.swagger-ui .di{display:inline}.swagger-ui .db{display:block}.swagger-ui .dib{display:inline-block}.swagger-ui .dit{display:inline-table}.swagger-ui .dt{display:table}.swagger-ui .dtc{display:table-cell}.swagger-ui .dt-row{display:table-row}.swagger-ui .dt-row-group{display:table-row-group}.swagger-ui .dt-column{display:table-column}.swagger-ui .dt-column-group{display:table-column-group}.swagger-ui .dt--fixed{table-layout:fixed;width:100%}@media screen and (min-width:30em){.swagger-ui .dn-ns{display:none}.swagger-ui .di-ns{display:inline}.swagger-ui .db-ns{display:block}.swagger-ui .dib-ns{display:inline-block}.swagger-ui .dit-ns{display:inline-table}.swagger-ui .dt-ns{display:table}.swagger-ui .dtc-ns{display:table-cell}.swagger-ui .dt-row-ns{display:table-row}.swagger-ui .dt-row-group-ns{display:table-row-group}.swagger-ui .dt-column-ns{display:table-column}.swagger-ui .dt-column-group-ns{display:table-column-group}.swagger-ui .dt--fixed-ns{table-layout:fixed;width:100%}}@media screen and (min-width:30em) and (max-width:60em){.swagger-ui .dn-m{display:none}.swagger-ui .di-m{display:inline}.swagger-ui .db-m{display:block}.swagger-ui .dib-m{display:inline-block}.swagger-ui .dit-m{display:inline-table}.swagger-ui .dt-m{display:table}.swagger-ui .dtc-m{display:table-cell}.swagger-ui .dt-row-m{display:table-row}.swagger-ui .dt-row-group-m{display:table-row-group}.swagger-ui .dt-column-m{display:table-column}.swagger-ui .dt-column-group-m{display:table-column-group}.swagger-ui .dt--fixed-m{table-layout:fixed;width:100%}}@media screen and (min-width:60em){.swagger-ui .dn-l{display:none}.swagger-ui .di-l{display:inline}.swagger-ui .db-l{display:block}.swagger-ui .dib-l{display:inline-block}.swagger-ui .dit-l{display:inline-table}.swagger-ui .dt-l{display:table}.swagger-ui .dtc-l{display:table-cell}.swagger-ui .dt-row-l{display:table-row}.swagger-ui .dt-row-group-l{display:table-row-group}.swagger-ui .dt-column-l{display:table-column}.swagger-ui .dt-column-group-l{display:table-column-group}.swagger-ui .dt--fixed-l{table-layout:fixed;width:100%}}.swagger-ui .fl{_display:inline;float:left}.swagger-ui .fr{_display:inline;float:right}.swagger-ui .fn{float:none}@media screen and (min-width:30em){.swagger-ui .fl-ns{_display:inline;float:left}.swagger-ui .fr-ns{_display:inline;float:right}.swagger-ui .fn-ns{float:none}}@media screen and (min-width:30em) and (max-width:60em){.swagger-ui .fl-m{_display:inline;float:left}.swagger-ui .fr-m{_display:inline;float:right}.swagger-ui .fn-m{float:none}}@media screen and (min-width:60em){.swagger-ui .fl-l{_display:inline;float:left}.swagger-ui .fr-l{_display:inline;float:right}.swagger-ui .fn-l{float:none}}.swagger-ui .sans-serif{font-family:-apple-system,BlinkMacSystemFont,avenir next,avenir,helvetica,helvetica neue,ubuntu,roboto,noto,segoe ui,arial,sans-serif}.swagger-ui .serif{font-family:georgia,serif}.swagger-ui .system-sans-serif{font-family:sans-serif}.swagger-ui .system-serif{font-family:serif}.swagger-ui .code,.swagger-ui code{font-family:Consolas,monaco,monospace}.swagger-ui .courier{font-family:Courier Next,courier,monospace}.swagger-ui .helvetica{font-family:helvetica neue,helvetica,sans-serif}.swagger-ui .avenir{font-family:avenir next,avenir,sans-serif}.swagger-ui .athelas{font-family:athelas,georgia,serif}.swagger-ui .georgia{font-family:georgia,serif}.swagger-ui .times{font-family:times,serif}.swagger-ui .bodoni{font-family:Bodoni MT,serif}.swagger-ui .calisto{font-family:Calisto MT,serif}.swagger-ui .garamond{font-family:garamond,serif}.swagger-ui .baskerville{font-family:baskerville,serif}.swagger-ui .i{font-style:italic}.swagger-ui .fs-normal{font-style:normal}@media screen and (min-width:30em){.swagger-ui .i-ns{font-style:italic}.swagger-ui .fs-normal-ns{font-style:normal}}@media screen and (min-width:30em) and (max-width:60em){.swagger-ui .i-m{font-style:italic}.swagger-ui .fs-normal-m{font-style:normal}}@media screen and (min-width:60em){.swagger-ui .i-l{font-style:italic}.swagger-ui .fs-normal-l{font-style:normal}}.swagger-ui .normal{font-weight:400}.swagger-ui .b{font-weight:700}.swagger-ui .fw1{font-weight:100}.swagger-ui .fw2{font-weight:200}.swagger-ui .fw3{font-weight:300}.swagger-ui .fw4{font-weight:400}.swagger-ui .fw5{font-weight:500}.swagger-ui .fw6{font-weight:600}.swagger-ui .fw7{font-weight:700}.swagger-ui .fw8{font-weight:800}.swagger-ui .fw9{font-weight:900}@media screen and (min-width:30em){.swagger-ui .normal-ns{font-weight:400}.swagger-ui .b-ns{font-weight:700}.swagger-ui .fw1-ns{font-weight:100}.swagger-ui .fw2-ns{font-weight:200}.swagger-ui .fw3-ns{font-weight:300}.swagger-ui .fw4-ns{font-weight:400}.swagger-ui .fw5-ns{font-weight:500}.swagger-ui .fw6-ns{font-weight:600}.swagger-ui .fw7-ns{font-weight:700}.swagger-ui .fw8-ns{font-weight:800}.swagger-ui .fw9-ns{font-weight:900}}@media screen and (min-width:30em) and (max-width:60em){.swagger-ui .normal-m{font-weight:400}.swagger-ui .b-m{font-weight:700}.swagger-ui .fw1-m{font-weight:100}.swagger-ui .fw2-m{font-weight:200}.swagger-ui .fw3-m{font-weight:300}.swagger-ui .fw4-m{font-weight:400}.swagger-ui .fw5-m{font-weight:500}.swagger-ui .fw6-m{font-weight:600}.swagger-ui .fw7-m{font-weight:700}.swagger-ui .fw8-m{font-weight:800}.swagger-ui .fw9-m{font-weight:900}}@media screen and (min-width:60em){.swagger-ui .normal-l{font-weight:400}.swagger-ui .b-l{font-weight:700}.swagger-ui .fw1-l{font-weight:100}.swagger-ui .fw2-l{font-weight:200}.swagger-ui .fw3-l{font-weight:300}.swagger-ui .fw4-l{font-weight:400}.swagger-ui .fw5-l{font-weight:500}.swagger-ui .fw6-l{font-weight:600}.swagger-ui .fw7-l{font-weight:700}.swagger-ui .fw8-l{font-weight:800}.swagger-ui .fw9-l{font-weight:900}}.swagger-ui .input-reset{-webkit-appearance:none;-moz-appearance:none}.swagger-ui .button-reset::-moz-focus-inner,.swagger-ui .input-reset::-moz-focus-inner{border:0;padding:0}.swagger-ui .h1{height:1rem}.swagger-ui .h2{height:2rem}.swagger-ui .h3{height:4rem}.swagger-ui .h4{height:8rem}.swagger-ui .h5{height:16rem}.swagger-ui .h-25{height:25%}.swagger-ui .h-50{height:50%}.swagger-ui .h-75{height:75%}.swagger-ui .h-100{height:100%}.swagger-ui .min-h-100{min-height:100%}.swagger-ui .vh-25{height:25vh}.swagger-ui .vh-50{height:50vh}.swagger-ui .vh-75{height:75vh}.swagger-ui .vh-100{height:100vh}.swagger-ui .min-vh-100{min-height:100vh}.swagger-ui .h-auto{height:auto}.swagger-ui .h-inherit{height:inherit}@media screen and (min-width:30em){.swagger-ui .h1-ns{height:1rem}.swagger-ui .h2-ns{height:2rem}.swagger-ui .h3-ns{height:4rem}.swagger-ui .h4-ns{height:8rem}.swagger-ui .h5-ns{height:16rem}.swagger-ui .h-25-ns{height:25%}.swagger-ui .h-50-ns{height:50%}.swagger-ui .h-75-ns{height:75%}.swagger-ui .h-100-ns{height:100%}.swagger-ui .min-h-100-ns{min-height:100%}.swagger-ui .vh-25-ns{height:25vh}.swagger-ui .vh-50-ns{height:50vh}.swagger-ui .vh-75-ns{height:75vh}.swagger-ui .vh-100-ns{height:100vh}.swagger-ui .min-vh-100-ns{min-height:100vh}.swagger-ui .h-auto-ns{height:auto}.swagger-ui .h-inherit-ns{height:inherit}}@media screen and (min-width:30em) and (max-width:60em){.swagger-ui .h1-m{height:1rem}.swagger-ui .h2-m{height:2rem}.swagger-ui .h3-m{height:4rem}.swagger-ui .h4-m{height:8rem}.swagger-ui .h5-m{height:16rem}.swagger-ui .h-25-m{height:25%}.swagger-ui .h-50-m{height:50%}.swagger-ui .h-75-m{height:75%}.swagger-ui .h-100-m{height:100%}.swagger-ui .min-h-100-m{min-height:100%}.swagger-ui .vh-25-m{height:25vh}.swagger-ui .vh-50-m{height:50vh}.swagger-ui .vh-75-m{height:75vh}.swagger-ui .vh-100-m{height:100vh}.swagger-ui .min-vh-100-m{min-height:100vh}.swagger-ui .h-auto-m{height:auto}.swagger-ui .h-inherit-m{height:inherit}}@media screen and (min-width:60em){.swagger-ui .h1-l{height:1rem}.swagger-ui .h2-l{height:2rem}.swagger-ui .h3-l{height:4rem}.swagger-ui .h4-l{height:8rem}.swagger-ui .h5-l{height:16rem}.swagger-ui .h-25-l{height:25%}.swagger-ui .h-50-l{height:50%}.swagger-ui .h-75-l{height:75%}.swagger-ui .h-100-l{height:100%}.swagger-ui .min-h-100-l{min-height:100%}.swagger-ui .vh-25-l{height:25vh}.swagger-ui .vh-50-l{height:50vh}.swagger-ui .vh-75-l{height:75vh}.swagger-ui .vh-100-l{height:100vh}.swagger-ui .min-vh-100-l{min-height:100vh}.swagger-ui .h-auto-l{height:auto}.swagger-ui .h-inherit-l{height:inherit}}.swagger-ui .tracked{letter-spacing:.1em}.swagger-ui .tracked-tight{letter-spacing:-.05em}.swagger-ui .tracked-mega{letter-spacing:.25em}@media screen and (min-width:30em){.swagger-ui .tracked-ns{letter-spacing:.1em}.swagger-ui .tracked-tight-ns{letter-spacing:-.05em}.swagger-ui .tracked-mega-ns{letter-spacing:.25em}}@media screen and (min-width:30em) and (max-width:60em){.swagger-ui .tracked-m{letter-spacing:.1em}.swagger-ui .tracked-tight-m{letter-spacing:-.05em}.swagger-ui .tracked-mega-m{letter-spacing:.25em}}@media screen and (min-width:60em){.swagger-ui .tracked-l{letter-spacing:.1em}.swagger-ui .tracked-tight-l{letter-spacing:-.05em}.swagger-ui .tracked-mega-l{letter-spacing:.25em}}.swagger-ui .lh-solid{line-height:1}.swagger-ui .lh-title{line-height:1.25}.swagger-ui .lh-copy{line-height:1.5}@media screen and (min-width:30em){.swagger-ui .lh-solid-ns{line-height:1}.swagger-ui .lh-title-ns{line-height:1.25}.swagger-ui .lh-copy-ns{line-height:1.5}}@media screen and (min-width:30em) and (max-width:60em){.swagger-ui .lh-solid-m{line-height:1}.swagger-ui .lh-title-m{line-height:1.25}.swagger-ui .lh-copy-m{line-height:1.5}}@media screen and (min-width:60em){.swagger-ui .lh-solid-l{line-height:1}.swagger-ui .lh-title-l{line-height:1.25}.swagger-ui .lh-copy-l{line-height:1.5}}.swagger-ui .link{text-decoration:none}.swagger-ui .link,.swagger-ui .link:active,.swagger-ui .link:focus,.swagger-ui .link:hover,.swagger-ui .link:link,.swagger-ui .link:visited{transition:color .15s ease-in}.swagger-ui .link:focus{outline:1px dotted currentColor}.swagger-ui .list{list-style-type:none}.swagger-ui .mw-100{max-width:100%}.swagger-ui .mw1{max-width:1rem}.swagger-ui .mw2{max-width:2rem}.swagger-ui .mw3{max-width:4rem}.swagger-ui .mw4{max-width:8rem}.swagger-ui .mw5{max-width:16rem}.swagger-ui .mw6{max-width:32rem}.swagger-ui .mw7{max-width:48rem}.swagger-ui .mw8{max-width:64rem}.swagger-ui .mw9{max-width:96rem}.swagger-ui .mw-none{max-width:none}@media screen and (min-width:30em){.swagger-ui .mw-100-ns{max-width:100%}.swagger-ui .mw1-ns{max-width:1rem}.swagger-ui .mw2-ns{max-width:2rem}.swagger-ui .mw3-ns{max-width:4rem}.swagger-ui .mw4-ns{max-width:8rem}.swagger-ui .mw5-ns{max-width:16rem}.swagger-ui .mw6-ns{max-width:32rem}.swagger-ui .mw7-ns{max-width:48rem}.swagger-ui .mw8-ns{max-width:64rem}.swagger-ui .mw9-ns{max-width:96rem}.swagger-ui .mw-none-ns{max-width:none}}@media screen and (min-width:30em) and (max-width:60em){.swagger-ui .mw-100-m{max-width:100%}.swagger-ui .mw1-m{max-width:1rem}.swagger-ui .mw2-m{max-width:2rem}.swagger-ui .mw3-m{max-width:4rem}.swagger-ui .mw4-m{max-width:8rem}.swagger-ui .mw5-m{max-width:16rem}.swagger-ui .mw6-m{max-width:32rem}.swagger-ui .mw7-m{max-width:48rem}.swagger-ui .mw8-m{max-width:64rem}.swagger-ui .mw9-m{max-width:96rem}.swagger-ui .mw-none-m{max-width:none}}@media screen and (min-width:60em){.swagger-ui .mw-100-l{max-width:100%}.swagger-ui .mw1-l{max-width:1rem}.swagger-ui .mw2-l{max-width:2rem}.swagger-ui .mw3-l{max-width:4rem}.swagger-ui .mw4-l{max-width:8rem}.swagger-ui .mw5-l{max-width:16rem}.swagger-ui .mw6-l{max-width:32rem}.swagger-ui .mw7-l{max-width:48rem}.swagger-ui .mw8-l{max-width:64rem}.swagger-ui .mw9-l{max-width:96rem}.swagger-ui .mw-none-l{max-width:none}}.swagger-ui .w1{width:1rem}.swagger-ui .w2{width:2rem}.swagger-ui .w3{width:4rem}.swagger-ui .w4{width:8rem}.swagger-ui .w5{width:16rem}.swagger-ui .w-10{width:10%}.swagger-ui .w-20{width:20%}.swagger-ui .w-25{width:25%}.swagger-ui .w-30{width:30%}.swagger-ui .w-33{width:33%}.swagger-ui .w-34{width:34%}.swagger-ui .w-40{width:40%}.swagger-ui .w-50{width:50%}.swagger-ui .w-60{width:60%}.swagger-ui .w-70{width:70%}.swagger-ui .w-75{width:75%}.swagger-ui .w-80{width:80%}.swagger-ui .w-90{width:90%}.swagger-ui .w-100{width:100%}.swagger-ui .w-third{width:33.3333333333%}.swagger-ui .w-two-thirds{width:66.6666666667%}.swagger-ui .w-auto{width:auto}@media screen and (min-width:30em){.swagger-ui .w1-ns{width:1rem}.swagger-ui .w2-ns{width:2rem}.swagger-ui .w3-ns{width:4rem}.swagger-ui .w4-ns{width:8rem}.swagger-ui .w5-ns{width:16rem}.swagger-ui .w-10-ns{width:10%}.swagger-ui .w-20-ns{width:20%}.swagger-ui .w-25-ns{width:25%}.swagger-ui .w-30-ns{width:30%}.swagger-ui .w-33-ns{width:33%}.swagger-ui .w-34-ns{width:34%}.swagger-ui .w-40-ns{width:40%}.swagger-ui .w-50-ns{width:50%}.swagger-ui .w-60-ns{width:60%}.swagger-ui .w-70-ns{width:70%}.swagger-ui .w-75-ns{width:75%}.swagger-ui .w-80-ns{width:80%}.swagger-ui .w-90-ns{width:90%}.swagger-ui .w-100-ns{width:100%}.swagger-ui .w-third-ns{width:33.3333333333%}.swagger-ui .w-two-thirds-ns{width:66.6666666667%}.swagger-ui .w-auto-ns{width:auto}}@media screen and (min-width:30em) and (max-width:60em){.swagger-ui .w1-m{width:1rem}.swagger-ui .w2-m{width:2rem}.swagger-ui .w3-m{width:4rem}.swagger-ui .w4-m{width:8rem}.swagger-ui .w5-m{width:16rem}.swagger-ui .w-10-m{width:10%}.swagger-ui .w-20-m{width:20%}.swagger-ui .w-25-m{width:25%}.swagger-ui .w-30-m{width:30%}.swagger-ui .w-33-m{width:33%}.swagger-ui .w-34-m{width:34%}.swagger-ui .w-40-m{width:40%}.swagger-ui .w-50-m{width:50%}.swagger-ui .w-60-m{width:60%}.swagger-ui .w-70-m{width:70%}.swagger-ui .w-75-m{width:75%}.swagger-ui .w-80-m{width:80%}.swagger-ui .w-90-m{width:90%}.swagger-ui .w-100-m{width:100%}.swagger-ui .w-third-m{width:33.3333333333%}.swagger-ui .w-two-thirds-m{width:66.6666666667%}.swagger-ui .w-auto-m{width:auto}}@media screen and (min-width:60em){.swagger-ui .w1-l{width:1rem}.swagger-ui .w2-l{width:2rem}.swagger-ui .w3-l{width:4rem}.swagger-ui .w4-l{width:8rem}.swagger-ui .w5-l{width:16rem}.swagger-ui .w-10-l{width:10%}.swagger-ui .w-20-l{width:20%}.swagger-ui .w-25-l{width:25%}.swagger-ui .w-30-l{width:30%}.swagger-ui .w-33-l{width:33%}.swagger-ui .w-34-l{width:34%}.swagger-ui .w-40-l{width:40%}.swagger-ui .w-50-l{width:50%}.swagger-ui .w-60-l{width:60%}.swagger-ui .w-70-l{width:70%}.swagger-ui .w-75-l{width:75%}.swagger-ui .w-80-l{width:80%}.swagger-ui .w-90-l{width:90%}.swagger-ui .w-100-l{width:100%}.swagger-ui .w-third-l{width:33.3333333333%}.swagger-ui .w-two-thirds-l{width:66.6666666667%}.swagger-ui .w-auto-l{width:auto}}.swagger-ui .overflow-visible{overflow:visible}.swagger-ui .overflow-hidden{overflow:hidden}.swagger-ui .overflow-scroll{overflow:scroll}.swagger-ui .overflow-auto{overflow:auto}.swagger-ui .overflow-x-visible{overflow-x:visible}.swagger-ui .overflow-x-hidden{overflow-x:hidden}.swagger-ui .overflow-x-scroll{overflow-x:scroll}.swagger-ui .overflow-x-auto{overflow-x:auto}.swagger-ui .overflow-y-visible{overflow-y:visible}.swagger-ui .overflow-y-hidden{overflow-y:hidden}.swagger-ui .overflow-y-scroll{overflow-y:scroll}.swagger-ui .overflow-y-auto{overflow-y:auto}@media screen and (min-width:30em){.swagger-ui .overflow-visible-ns{overflow:visible}.swagger-ui .overflow-hidden-ns{overflow:hidden}.swagger-ui .overflow-scroll-ns{overflow:scroll}.swagger-ui .overflow-auto-ns{overflow:auto}.swagger-ui .overflow-x-visible-ns{overflow-x:visible}.swagger-ui .overflow-x-hidden-ns{overflow-x:hidden}.swagger-ui .overflow-x-scroll-ns{overflow-x:scroll}.swagger-ui .overflow-x-auto-ns{overflow-x:auto}.swagger-ui .overflow-y-visible-ns{overflow-y:visible}.swagger-ui .overflow-y-hidden-ns{overflow-y:hidden}.swagger-ui .overflow-y-scroll-ns{overflow-y:scroll}.swagger-ui .overflow-y-auto-ns{overflow-y:auto}}@media screen and (min-width:30em) and (max-width:60em){.swagger-ui .overflow-visible-m{overflow:visible}.swagger-ui .overflow-hidden-m{overflow:hidden}.swagger-ui .overflow-scroll-m{overflow:scroll}.swagger-ui .overflow-auto-m{overflow:auto}.swagger-ui .overflow-x-visible-m{overflow-x:visible}.swagger-ui .overflow-x-hidden-m{overflow-x:hidden}.swagger-ui .overflow-x-scroll-m{overflow-x:scroll}.swagger-ui .overflow-x-auto-m{overflow-x:auto}.swagger-ui .overflow-y-visible-m{overflow-y:visible}.swagger-ui .overflow-y-hidden-m{overflow-y:hidden}.swagger-ui .overflow-y-scroll-m{overflow-y:scroll}.swagger-ui .overflow-y-auto-m{overflow-y:auto}}@media screen and (min-width:60em){.swagger-ui .overflow-visible-l{overflow:visible}.swagger-ui .overflow-hidden-l{overflow:hidden}.swagger-ui .overflow-scroll-l{overflow:scroll}.swagger-ui .overflow-auto-l{overflow:auto}.swagger-ui .overflow-x-visible-l{overflow-x:visible}.swagger-ui .overflow-x-hidden-l{overflow-x:hidden}.swagger-ui .overflow-x-scroll-l{overflow-x:scroll}.swagger-ui .overflow-x-auto-l{overflow-x:auto}.swagger-ui .overflow-y-visible-l{overflow-y:visible}.swagger-ui .overflow-y-hidden-l{overflow-y:hidden}.swagger-ui .overflow-y-scroll-l{overflow-y:scroll}.swagger-ui .overflow-y-auto-l{overflow-y:auto}}.swagger-ui .static{position:static}.swagger-ui .relative{position:relative}.swagger-ui .absolute{position:absolute}.swagger-ui .fixed{position:fixed}@media screen and (min-width:30em){.swagger-ui .static-ns{position:static}.swagger-ui .relative-ns{position:relative}.swagger-ui .absolute-ns{position:absolute}.swagger-ui .fixed-ns{position:fixed}}@media screen and (min-width:30em) and (max-width:60em){.swagger-ui .static-m{position:static}.swagger-ui .relative-m{position:relative}.swagger-ui .absolute-m{position:absolute}.swagger-ui .fixed-m{position:fixed}}@media screen and (min-width:60em){.swagger-ui .static-l{position:static}.swagger-ui .relative-l{position:relative}.swagger-ui .absolute-l{position:absolute}.swagger-ui .fixed-l{position:fixed}}.swagger-ui .o-100{opacity:1}.swagger-ui .o-90{opacity:.9}.swagger-ui .o-80{opacity:.8}.swagger-ui .o-70{opacity:.7}.swagger-ui .o-60{opacity:.6}.swagger-ui .o-50{opacity:.5}.swagger-ui .o-40{opacity:.4}.swagger-ui .o-30{opacity:.3}.swagger-ui .o-20{opacity:.2}.swagger-ui .o-10{opacity:.1}.swagger-ui .o-05{opacity:.05}.swagger-ui .o-025{opacity:.025}.swagger-ui .o-0{opacity:0}.swagger-ui .rotate-45{transform:rotate(45deg)}.swagger-ui .rotate-90{transform:rotate(90deg)}.swagger-ui .rotate-135{transform:rotate(135deg)}.swagger-ui .rotate-180{transform:rotate(180deg)}.swagger-ui .rotate-225{transform:rotate(225deg)}.swagger-ui .rotate-270{transform:rotate(270deg)}.swagger-ui .rotate-315{transform:rotate(315deg)}@media screen and (min-width:30em){.swagger-ui .rotate-45-ns{transform:rotate(45deg)}.swagger-ui .rotate-90-ns{transform:rotate(90deg)}.swagger-ui .rotate-135-ns{transform:rotate(135deg)}.swagger-ui .rotate-180-ns{transform:rotate(180deg)}.swagger-ui .rotate-225-ns{transform:rotate(225deg)}.swagger-ui .rotate-270-ns{transform:rotate(270deg)}.swagger-ui .rotate-315-ns{transform:rotate(315deg)}}@media screen and (min-width:30em) and (max-width:60em){.swagger-ui .rotate-45-m{transform:rotate(45deg)}.swagger-ui .rotate-90-m{transform:rotate(90deg)}.swagger-ui .rotate-135-m{transform:rotate(135deg)}.swagger-ui .rotate-180-m{transform:rotate(180deg)}.swagger-ui .rotate-225-m{transform:rotate(225deg)}.swagger-ui .rotate-270-m{transform:rotate(270deg)}.swagger-ui .rotate-315-m{transform:rotate(315deg)}}@media screen and (min-width:60em){.swagger-ui .rotate-45-l{transform:rotate(45deg)}.swagger-ui .rotate-90-l{transform:rotate(90deg)}.swagger-ui .rotate-135-l{transform:rotate(135deg)}.swagger-ui .rotate-180-l{transform:rotate(180deg)}.swagger-ui .rotate-225-l{transform:rotate(225deg)}.swagger-ui .rotate-270-l{transform:rotate(270deg)}.swagger-ui .rotate-315-l{transform:rotate(315deg)}}.swagger-ui .black-90{color:rgba(0,0,0,.9)}.swagger-ui .black-80{color:rgba(0,0,0,.8)}.swagger-ui .black-70{color:rgba(0,0,0,.7)}.swagger-ui .black-60{color:rgba(0,0,0,.6)}.swagger-ui .black-50{color:rgba(0,0,0,.5)}.swagger-ui .black-40{color:rgba(0,0,0,.4)}.swagger-ui .black-30{color:rgba(0,0,0,.3)}.swagger-ui .black-20{color:rgba(0,0,0,.2)}.swagger-ui .black-10{color:rgba(0,0,0,.1)}.swagger-ui .black-05{color:rgba(0,0,0,.05)}.swagger-ui .white-90{color:hsla(0,0%,100%,.9)}.swagger-ui .white-80{color:hsla(0,0%,100%,.8)}.swagger-ui .white-70{color:hsla(0,0%,100%,.7)}.swagger-ui .white-60{color:hsla(0,0%,100%,.6)}.swagger-ui .white-50{color:hsla(0,0%,100%,.5)}.swagger-ui .white-40{color:hsla(0,0%,100%,.4)}.swagger-ui .white-30{color:hsla(0,0%,100%,.3)}.swagger-ui .white-20{color:hsla(0,0%,100%,.2)}.swagger-ui .white-10{color:hsla(0,0%,100%,.1)}.swagger-ui .black{color:#000}.swagger-ui .near-black{color:#111}.swagger-ui .dark-gray{color:#333}.swagger-ui .mid-gray{color:#555}.swagger-ui .gray{color:#777}.swagger-ui .silver{color:#999}.swagger-ui .light-silver{color:#aaa}.swagger-ui .moon-gray{color:#ccc}.swagger-ui .light-gray{color:#eee}.swagger-ui .near-white{color:#f4f4f4}.swagger-ui .white{color:#fff}.swagger-ui .dark-red{color:#e7040f}.swagger-ui .red{color:#ff4136}.swagger-ui .light-red{color:#ff725c}.swagger-ui .orange{color:#ff6300}.swagger-ui .gold{color:#ffb700}.swagger-ui .yellow{color:gold}.swagger-ui .light-yellow{color:#fbf1a9}.swagger-ui .purple{color:#5e2ca5}.swagger-ui .light-purple{color:#a463f2}.swagger-ui .dark-pink{color:#d5008f}.swagger-ui .hot-pink{color:#ff41b4}.swagger-ui .pink{color:#ff80cc}.swagger-ui .light-pink{color:#ffa3d7}.swagger-ui .dark-green{color:#137752}.swagger-ui .green{color:#19a974}.swagger-ui .light-green{color:#9eebcf}.swagger-ui .navy{color:#001b44}.swagger-ui .dark-blue{color:#00449e}.swagger-ui .blue{color:#357edd}.swagger-ui .light-blue{color:#96ccff}.swagger-ui .lightest-blue{color:#cdecff}.swagger-ui .washed-blue{color:#f6fffe}.swagger-ui .washed-green{color:#e8fdf5}.swagger-ui .washed-yellow{color:#fffceb}.swagger-ui .washed-red{color:#ffdfdf}.swagger-ui .color-inherit{color:inherit}.swagger-ui .bg-black-90{background-color:rgba(0,0,0,.9)}.swagger-ui .bg-black-80{background-color:rgba(0,0,0,.8)}.swagger-ui .bg-black-70{background-color:rgba(0,0,0,.7)}.swagger-ui .bg-black-60{background-color:rgba(0,0,0,.6)}.swagger-ui .bg-black-50{background-color:rgba(0,0,0,.5)}.swagger-ui .bg-black-40{background-color:rgba(0,0,0,.4)}.swagger-ui .bg-black-30{background-color:rgba(0,0,0,.3)}.swagger-ui .bg-black-20{background-color:rgba(0,0,0,.2)}.swagger-ui .bg-black-10{background-color:rgba(0,0,0,.1)}.swagger-ui .bg-black-05{background-color:rgba(0,0,0,.05)}.swagger-ui .bg-white-90{background-color:hsla(0,0%,100%,.9)}.swagger-ui .bg-white-80{background-color:hsla(0,0%,100%,.8)}.swagger-ui .bg-white-70{background-color:hsla(0,0%,100%,.7)}.swagger-ui .bg-white-60{background-color:hsla(0,0%,100%,.6)}.swagger-ui .bg-white-50{background-color:hsla(0,0%,100%,.5)}.swagger-ui .bg-white-40{background-color:hsla(0,0%,100%,.4)}.swagger-ui .bg-white-30{background-color:hsla(0,0%,100%,.3)}.swagger-ui .bg-white-20{background-color:hsla(0,0%,100%,.2)}.swagger-ui .bg-white-10{background-color:hsla(0,0%,100%,.1)}.swagger-ui .bg-black{background-color:#000}.swagger-ui .bg-near-black{background-color:#111}.swagger-ui .bg-dark-gray{background-color:#333}.swagger-ui .bg-mid-gray{background-color:#555}.swagger-ui .bg-gray{background-color:#777}.swagger-ui .bg-silver{background-color:#999}.swagger-ui .bg-light-silver{background-color:#aaa}.swagger-ui .bg-moon-gray{background-color:#ccc}.swagger-ui .bg-light-gray{background-color:#eee}.swagger-ui .bg-near-white{background-color:#f4f4f4}.swagger-ui .bg-white{background-color:#fff}.swagger-ui .bg-transparent{background-color:transparent}.swagger-ui .bg-dark-red{background-color:#e7040f}.swagger-ui .bg-red{background-color:#ff4136}.swagger-ui .bg-light-red{background-color:#ff725c}.swagger-ui .bg-orange{background-color:#ff6300}.swagger-ui .bg-gold{background-color:#ffb700}.swagger-ui .bg-yellow{background-color:gold}.swagger-ui .bg-light-yellow{background-color:#fbf1a9}.swagger-ui .bg-purple{background-color:#5e2ca5}.swagger-ui .bg-light-purple{background-color:#a463f2}.swagger-ui .bg-dark-pink{background-color:#d5008f}.swagger-ui .bg-hot-pink{background-color:#ff41b4}.swagger-ui .bg-pink{background-color:#ff80cc}.swagger-ui .bg-light-pink{background-color:#ffa3d7}.swagger-ui .bg-dark-green{background-color:#137752}.swagger-ui .bg-green{background-color:#19a974}.swagger-ui .bg-light-green{background-color:#9eebcf}.swagger-ui .bg-navy{background-color:#001b44}.swagger-ui .bg-dark-blue{background-color:#00449e}.swagger-ui .bg-blue{background-color:#357edd}.swagger-ui .bg-light-blue{background-color:#96ccff}.swagger-ui .bg-lightest-blue{background-color:#cdecff}.swagger-ui .bg-washed-blue{background-color:#f6fffe}.swagger-ui .bg-washed-green{background-color:#e8fdf5}.swagger-ui .bg-washed-yellow{background-color:#fffceb}.swagger-ui .bg-washed-red{background-color:#ffdfdf}.swagger-ui .bg-inherit{background-color:inherit}.swagger-ui .hover-black:focus,.swagger-ui .hover-black:hover{color:#000}.swagger-ui .hover-near-black:focus,.swagger-ui .hover-near-black:hover{color:#111}.swagger-ui .hover-dark-gray:focus,.swagger-ui .hover-dark-gray:hover{color:#333}.swagger-ui .hover-mid-gray:focus,.swagger-ui .hover-mid-gray:hover{color:#555}.swagger-ui .hover-gray:focus,.swagger-ui .hover-gray:hover{color:#777}.swagger-ui .hover-silver:focus,.swagger-ui .hover-silver:hover{color:#999}.swagger-ui .hover-light-silver:focus,.swagger-ui .hover-light-silver:hover{color:#aaa}.swagger-ui .hover-moon-gray:focus,.swagger-ui .hover-moon-gray:hover{color:#ccc}.swagger-ui .hover-light-gray:focus,.swagger-ui .hover-light-gray:hover{color:#eee}.swagger-ui .hover-near-white:focus,.swagger-ui .hover-near-white:hover{color:#f4f4f4}.swagger-ui .hover-white:focus,.swagger-ui .hover-white:hover{color:#fff}.swagger-ui .hover-black-90:focus,.swagger-ui .hover-black-90:hover{color:rgba(0,0,0,.9)}.swagger-ui .hover-black-80:focus,.swagger-ui .hover-black-80:hover{color:rgba(0,0,0,.8)}.swagger-ui .hover-black-70:focus,.swagger-ui .hover-black-70:hover{color:rgba(0,0,0,.7)}.swagger-ui .hover-black-60:focus,.swagger-ui .hover-black-60:hover{color:rgba(0,0,0,.6)}.swagger-ui .hover-black-50:focus,.swagger-ui .hover-black-50:hover{color:rgba(0,0,0,.5)}.swagger-ui .hover-black-40:focus,.swagger-ui .hover-black-40:hover{color:rgba(0,0,0,.4)}.swagger-ui .hover-black-30:focus,.swagger-ui .hover-black-30:hover{color:rgba(0,0,0,.3)}.swagger-ui .hover-black-20:focus,.swagger-ui .hover-black-20:hover{color:rgba(0,0,0,.2)}.swagger-ui .hover-black-10:focus,.swagger-ui .hover-black-10:hover{color:rgba(0,0,0,.1)}.swagger-ui .hover-white-90:focus,.swagger-ui .hover-white-90:hover{color:hsla(0,0%,100%,.9)}.swagger-ui .hover-white-80:focus,.swagger-ui .hover-white-80:hover{color:hsla(0,0%,100%,.8)}.swagger-ui .hover-white-70:focus,.swagger-ui .hover-white-70:hover{color:hsla(0,0%,100%,.7)}.swagger-ui .hover-white-60:focus,.swagger-ui .hover-white-60:hover{color:hsla(0,0%,100%,.6)}.swagger-ui .hover-white-50:focus,.swagger-ui .hover-white-50:hover{color:hsla(0,0%,100%,.5)}.swagger-ui .hover-white-40:focus,.swagger-ui .hover-white-40:hover{color:hsla(0,0%,100%,.4)}.swagger-ui .hover-white-30:focus,.swagger-ui .hover-white-30:hover{color:hsla(0,0%,100%,.3)}.swagger-ui .hover-white-20:focus,.swagger-ui .hover-white-20:hover{color:hsla(0,0%,100%,.2)}.swagger-ui .hover-white-10:focus,.swagger-ui .hover-white-10:hover{color:hsla(0,0%,100%,.1)}.swagger-ui .hover-inherit:focus,.swagger-ui .hover-inherit:hover{color:inherit}.swagger-ui .hover-bg-black:focus,.swagger-ui .hover-bg-black:hover{background-color:#000}.swagger-ui .hover-bg-near-black:focus,.swagger-ui .hover-bg-near-black:hover{background-color:#111}.swagger-ui .hover-bg-dark-gray:focus,.swagger-ui .hover-bg-dark-gray:hover{background-color:#333}.swagger-ui .hover-bg-mid-gray:focus,.swagger-ui .hover-bg-mid-gray:hover{background-color:#555}.swagger-ui .hover-bg-gray:focus,.swagger-ui .hover-bg-gray:hover{background-color:#777}.swagger-ui .hover-bg-silver:focus,.swagger-ui .hover-bg-silver:hover{background-color:#999}.swagger-ui .hover-bg-light-silver:focus,.swagger-ui .hover-bg-light-silver:hover{background-color:#aaa}.swagger-ui .hover-bg-moon-gray:focus,.swagger-ui .hover-bg-moon-gray:hover{background-color:#ccc}.swagger-ui .hover-bg-light-gray:focus,.swagger-ui .hover-bg-light-gray:hover{background-color:#eee}.swagger-ui .hover-bg-near-white:focus,.swagger-ui .hover-bg-near-white:hover{background-color:#f4f4f4}.swagger-ui .hover-bg-white:focus,.swagger-ui .hover-bg-white:hover{background-color:#fff}.swagger-ui .hover-bg-transparent:focus,.swagger-ui .hover-bg-transparent:hover{background-color:transparent}.swagger-ui .hover-bg-black-90:focus,.swagger-ui .hover-bg-black-90:hover{background-color:rgba(0,0,0,.9)}.swagger-ui .hover-bg-black-80:focus,.swagger-ui .hover-bg-black-80:hover{background-color:rgba(0,0,0,.8)}.swagger-ui .hover-bg-black-70:focus,.swagger-ui .hover-bg-black-70:hover{background-color:rgba(0,0,0,.7)}.swagger-ui .hover-bg-black-60:focus,.swagger-ui .hover-bg-black-60:hover{background-color:rgba(0,0,0,.6)}.swagger-ui .hover-bg-black-50:focus,.swagger-ui .hover-bg-black-50:hover{background-color:rgba(0,0,0,.5)}.swagger-ui .hover-bg-black-40:focus,.swagger-ui .hover-bg-black-40:hover{background-color:rgba(0,0,0,.4)}.swagger-ui .hover-bg-black-30:focus,.swagger-ui .hover-bg-black-30:hover{background-color:rgba(0,0,0,.3)}.swagger-ui .hover-bg-black-20:focus,.swagger-ui .hover-bg-black-20:hover{background-color:rgba(0,0,0,.2)}.swagger-ui .hover-bg-black-10:focus,.swagger-ui .hover-bg-black-10:hover{background-color:rgba(0,0,0,.1)}.swagger-ui .hover-bg-white-90:focus,.swagger-ui .hover-bg-white-90:hover{background-color:hsla(0,0%,100%,.9)}.swagger-ui .hover-bg-white-80:focus,.swagger-ui .hover-bg-white-80:hover{background-color:hsla(0,0%,100%,.8)}.swagger-ui .hover-bg-white-70:focus,.swagger-ui .hover-bg-white-70:hover{background-color:hsla(0,0%,100%,.7)}.swagger-ui .hover-bg-white-60:focus,.swagger-ui .hover-bg-white-60:hover{background-color:hsla(0,0%,100%,.6)}.swagger-ui .hover-bg-white-50:focus,.swagger-ui .hover-bg-white-50:hover{background-color:hsla(0,0%,100%,.5)}.swagger-ui .hover-bg-white-40:focus,.swagger-ui .hover-bg-white-40:hover{background-color:hsla(0,0%,100%,.4)}.swagger-ui .hover-bg-white-30:focus,.swagger-ui .hover-bg-white-30:hover{background-color:hsla(0,0%,100%,.3)}.swagger-ui .hover-bg-white-20:focus,.swagger-ui .hover-bg-white-20:hover{background-color:hsla(0,0%,100%,.2)}.swagger-ui .hover-bg-white-10:focus,.swagger-ui .hover-bg-white-10:hover{background-color:hsla(0,0%,100%,.1)}.swagger-ui .hover-dark-red:focus,.swagger-ui .hover-dark-red:hover{color:#e7040f}.swagger-ui .hover-red:focus,.swagger-ui .hover-red:hover{color:#ff4136}.swagger-ui .hover-light-red:focus,.swagger-ui .hover-light-red:hover{color:#ff725c}.swagger-ui .hover-orange:focus,.swagger-ui .hover-orange:hover{color:#ff6300}.swagger-ui .hover-gold:focus,.swagger-ui .hover-gold:hover{color:#ffb700}.swagger-ui .hover-yellow:focus,.swagger-ui .hover-yellow:hover{color:gold}.swagger-ui .hover-light-yellow:focus,.swagger-ui .hover-light-yellow:hover{color:#fbf1a9}.swagger-ui .hover-purple:focus,.swagger-ui .hover-purple:hover{color:#5e2ca5}.swagger-ui .hover-light-purple:focus,.swagger-ui .hover-light-purple:hover{color:#a463f2}.swagger-ui .hover-dark-pink:focus,.swagger-ui .hover-dark-pink:hover{color:#d5008f}.swagger-ui .hover-hot-pink:focus,.swagger-ui .hover-hot-pink:hover{color:#ff41b4}.swagger-ui .hover-pink:focus,.swagger-ui .hover-pink:hover{color:#ff80cc}.swagger-ui .hover-light-pink:focus,.swagger-ui .hover-light-pink:hover{color:#ffa3d7}.swagger-ui .hover-dark-green:focus,.swagger-ui .hover-dark-green:hover{color:#137752}.swagger-ui .hover-green:focus,.swagger-ui .hover-green:hover{color:#19a974}.swagger-ui .hover-light-green:focus,.swagger-ui .hover-light-green:hover{color:#9eebcf}.swagger-ui .hover-navy:focus,.swagger-ui .hover-navy:hover{color:#001b44}.swagger-ui .hover-dark-blue:focus,.swagger-ui .hover-dark-blue:hover{color:#00449e}.swagger-ui .hover-blue:focus,.swagger-ui .hover-blue:hover{color:#357edd}.swagger-ui .hover-light-blue:focus,.swagger-ui .hover-light-blue:hover{color:#96ccff}.swagger-ui .hover-lightest-blue:focus,.swagger-ui .hover-lightest-blue:hover{color:#cdecff}.swagger-ui .hover-washed-blue:focus,.swagger-ui .hover-washed-blue:hover{color:#f6fffe}.swagger-ui .hover-washed-green:focus,.swagger-ui .hover-washed-green:hover{color:#e8fdf5}.swagger-ui .hover-washed-yellow:focus,.swagger-ui .hover-washed-yellow:hover{color:#fffceb}.swagger-ui .hover-washed-red:focus,.swagger-ui .hover-washed-red:hover{color:#ffdfdf}.swagger-ui .hover-bg-dark-red:focus,.swagger-ui .hover-bg-dark-red:hover{background-color:#e7040f}.swagger-ui .hover-bg-red:focus,.swagger-ui .hover-bg-red:hover{background-color:#ff4136}.swagger-ui .hover-bg-light-red:focus,.swagger-ui .hover-bg-light-red:hover{background-color:#ff725c}.swagger-ui .hover-bg-orange:focus,.swagger-ui .hover-bg-orange:hover{background-color:#ff6300}.swagger-ui .hover-bg-gold:focus,.swagger-ui .hover-bg-gold:hover{background-color:#ffb700}.swagger-ui .hover-bg-yellow:focus,.swagger-ui .hover-bg-yellow:hover{background-color:gold}.swagger-ui .hover-bg-light-yellow:focus,.swagger-ui .hover-bg-light-yellow:hover{background-color:#fbf1a9}.swagger-ui .hover-bg-purple:focus,.swagger-ui .hover-bg-purple:hover{background-color:#5e2ca5}.swagger-ui .hover-bg-light-purple:focus,.swagger-ui .hover-bg-light-purple:hover{background-color:#a463f2}.swagger-ui .hover-bg-dark-pink:focus,.swagger-ui .hover-bg-dark-pink:hover{background-color:#d5008f}.swagger-ui .hover-bg-hot-pink:focus,.swagger-ui .hover-bg-hot-pink:hover{background-color:#ff41b4}.swagger-ui .hover-bg-pink:focus,.swagger-ui .hover-bg-pink:hover{background-color:#ff80cc}.swagger-ui .hover-bg-light-pink:focus,.swagger-ui .hover-bg-light-pink:hover{background-color:#ffa3d7}.swagger-ui .hover-bg-dark-green:focus,.swagger-ui .hover-bg-dark-green:hover{background-color:#137752}.swagger-ui .hover-bg-green:focus,.swagger-ui .hover-bg-green:hover{background-color:#19a974}.swagger-ui .hover-bg-light-green:focus,.swagger-ui .hover-bg-light-green:hover{background-color:#9eebcf}.swagger-ui .hover-bg-navy:focus,.swagger-ui .hover-bg-navy:hover{background-color:#001b44}.swagger-ui .hover-bg-dark-blue:focus,.swagger-ui .hover-bg-dark-blue:hover{background-color:#00449e}.swagger-ui .hover-bg-blue:focus,.swagger-ui .hover-bg-blue:hover{background-color:#357edd}.swagger-ui .hover-bg-light-blue:focus,.swagger-ui .hover-bg-light-blue:hover{background-color:#96ccff}.swagger-ui .hover-bg-lightest-blue:focus,.swagger-ui .hover-bg-lightest-blue:hover{background-color:#cdecff}.swagger-ui .hover-bg-washed-blue:focus,.swagger-ui .hover-bg-washed-blue:hover{background-color:#f6fffe}.swagger-ui .hover-bg-washed-green:focus,.swagger-ui .hover-bg-washed-green:hover{background-color:#e8fdf5}.swagger-ui .hover-bg-washed-yellow:focus,.swagger-ui .hover-bg-washed-yellow:hover{background-color:#fffceb}.swagger-ui .hover-bg-washed-red:focus,.swagger-ui .hover-bg-washed-red:hover{background-color:#ffdfdf}.swagger-ui .hover-bg-inherit:focus,.swagger-ui .hover-bg-inherit:hover{background-color:inherit}.swagger-ui .pa0{padding:0}.swagger-ui .pa1{padding:.25rem}.swagger-ui .pa2{padding:.5rem}.swagger-ui .pa3{padding:1rem}.swagger-ui .pa4{padding:2rem}.swagger-ui .pa5{padding:4rem}.swagger-ui .pa6{padding:8rem}.swagger-ui .pa7{padding:16rem}.swagger-ui .pl0{padding-left:0}.swagger-ui .pl1{padding-left:.25rem}.swagger-ui .pl2{padding-left:.5rem}.swagger-ui .pl3{padding-left:1rem}.swagger-ui .pl4{padding-left:2rem}.swagger-ui .pl5{padding-left:4rem}.swagger-ui .pl6{padding-left:8rem}.swagger-ui .pl7{padding-left:16rem}.swagger-ui .pr0{padding-right:0}.swagger-ui .pr1{padding-right:.25rem}.swagger-ui .pr2{padding-right:.5rem}.swagger-ui .pr3{padding-right:1rem}.swagger-ui .pr4{padding-right:2rem}.swagger-ui .pr5{padding-right:4rem}.swagger-ui .pr6{padding-right:8rem}.swagger-ui .pr7{padding-right:16rem}.swagger-ui .pb0{padding-bottom:0}.swagger-ui .pb1{padding-bottom:.25rem}.swagger-ui .pb2{padding-bottom:.5rem}.swagger-ui .pb3{padding-bottom:1rem}.swagger-ui .pb4{padding-bottom:2rem}.swagger-ui .pb5{padding-bottom:4rem}.swagger-ui .pb6{padding-bottom:8rem}.swagger-ui .pb7{padding-bottom:16rem}.swagger-ui .pt0{padding-top:0}.swagger-ui .pt1{padding-top:.25rem}.swagger-ui .pt2{padding-top:.5rem}.swagger-ui .pt3{padding-top:1rem}.swagger-ui .pt4{padding-top:2rem}.swagger-ui .pt5{padding-top:4rem}.swagger-ui .pt6{padding-top:8rem}.swagger-ui .pt7{padding-top:16rem}.swagger-ui .pv0{padding-bottom:0;padding-top:0}.swagger-ui .pv1{padding-bottom:.25rem;padding-top:.25rem}.swagger-ui .pv2{padding-bottom:.5rem;padding-top:.5rem}.swagger-ui .pv3{padding-bottom:1rem;padding-top:1rem}.swagger-ui .pv4{padding-bottom:2rem;padding-top:2rem}.swagger-ui .pv5{padding-bottom:4rem;padding-top:4rem}.swagger-ui .pv6{padding-bottom:8rem;padding-top:8rem}.swagger-ui .pv7{padding-bottom:16rem;padding-top:16rem}.swagger-ui .ph0{padding-left:0;padding-right:0}.swagger-ui .ph1{padding-left:.25rem;padding-right:.25rem}.swagger-ui .ph2{padding-left:.5rem;padding-right:.5rem}.swagger-ui .ph3{padding-left:1rem;padding-right:1rem}.swagger-ui .ph4{padding-left:2rem;padding-right:2rem}.swagger-ui .ph5{padding-left:4rem;padding-right:4rem}.swagger-ui .ph6{padding-left:8rem;padding-right:8rem}.swagger-ui .ph7{padding-left:16rem;padding-right:16rem}.swagger-ui .ma0{margin:0}.swagger-ui .ma1{margin:.25rem}.swagger-ui .ma2{margin:.5rem}.swagger-ui .ma3{margin:1rem}.swagger-ui .ma4{margin:2rem}.swagger-ui .ma5{margin:4rem}.swagger-ui .ma6{margin:8rem}.swagger-ui .ma7{margin:16rem}.swagger-ui .ml0{margin-left:0}.swagger-ui .ml1{margin-left:.25rem}.swagger-ui .ml2{margin-left:.5rem}.swagger-ui .ml3{margin-left:1rem}.swagger-ui .ml4{margin-left:2rem}.swagger-ui .ml5{margin-left:4rem}.swagger-ui .ml6{margin-left:8rem}.swagger-ui .ml7{margin-left:16rem}.swagger-ui .mr0{margin-right:0}.swagger-ui .mr1{margin-right:.25rem}.swagger-ui .mr2{margin-right:.5rem}.swagger-ui .mr3{margin-right:1rem}.swagger-ui .mr4{margin-right:2rem}.swagger-ui .mr5{margin-right:4rem}.swagger-ui .mr6{margin-right:8rem}.swagger-ui .mr7{margin-right:16rem}.swagger-ui .mb0{margin-bottom:0}.swagger-ui .mb1{margin-bottom:.25rem}.swagger-ui .mb2{margin-bottom:.5rem}.swagger-ui .mb3{margin-bottom:1rem}.swagger-ui .mb4{margin-bottom:2rem}.swagger-ui .mb5{margin-bottom:4rem}.swagger-ui .mb6{margin-bottom:8rem}.swagger-ui .mb7{margin-bottom:16rem}.swagger-ui .mt0{margin-top:0}.swagger-ui .mt1{margin-top:.25rem}.swagger-ui .mt2{margin-top:.5rem}.swagger-ui .mt3{margin-top:1rem}.swagger-ui .mt4{margin-top:2rem}.swagger-ui .mt5{margin-top:4rem}.swagger-ui .mt6{margin-top:8rem}.swagger-ui .mt7{margin-top:16rem}.swagger-ui .mv0{margin-bottom:0;margin-top:0}.swagger-ui .mv1{margin-bottom:.25rem;margin-top:.25rem}.swagger-ui .mv2{margin-bottom:.5rem;margin-top:.5rem}.swagger-ui .mv3{margin-bottom:1rem;margin-top:1rem}.swagger-ui .mv4{margin-bottom:2rem;margin-top:2rem}.swagger-ui .mv5{margin-bottom:4rem;margin-top:4rem}.swagger-ui .mv6{margin-bottom:8rem;margin-top:8rem}.swagger-ui .mv7{margin-bottom:16rem;margin-top:16rem}.swagger-ui .mh0{margin-left:0;margin-right:0}.swagger-ui .mh1{margin-left:.25rem;margin-right:.25rem}.swagger-ui .mh2{margin-left:.5rem;margin-right:.5rem}.swagger-ui .mh3{margin-left:1rem;margin-right:1rem}.swagger-ui .mh4{margin-left:2rem;margin-right:2rem}.swagger-ui .mh5{margin-left:4rem;margin-right:4rem}.swagger-ui .mh6{margin-left:8rem;margin-right:8rem}.swagger-ui .mh7{margin-left:16rem;margin-right:16rem}@media screen and (min-width:30em){.swagger-ui .pa0-ns{padding:0}.swagger-ui .pa1-ns{padding:.25rem}.swagger-ui .pa2-ns{padding:.5rem}.swagger-ui .pa3-ns{padding:1rem}.swagger-ui .pa4-ns{padding:2rem}.swagger-ui .pa5-ns{padding:4rem}.swagger-ui .pa6-ns{padding:8rem}.swagger-ui .pa7-ns{padding:16rem}.swagger-ui .pl0-ns{padding-left:0}.swagger-ui .pl1-ns{padding-left:.25rem}.swagger-ui .pl2-ns{padding-left:.5rem}.swagger-ui .pl3-ns{padding-left:1rem}.swagger-ui .pl4-ns{padding-left:2rem}.swagger-ui .pl5-ns{padding-left:4rem}.swagger-ui .pl6-ns{padding-left:8rem}.swagger-ui .pl7-ns{padding-left:16rem}.swagger-ui .pr0-ns{padding-right:0}.swagger-ui .pr1-ns{padding-right:.25rem}.swagger-ui .pr2-ns{padding-right:.5rem}.swagger-ui .pr3-ns{padding-right:1rem}.swagger-ui .pr4-ns{padding-right:2rem}.swagger-ui .pr5-ns{padding-right:4rem}.swagger-ui .pr6-ns{padding-right:8rem}.swagger-ui .pr7-ns{padding-right:16rem}.swagger-ui .pb0-ns{padding-bottom:0}.swagger-ui .pb1-ns{padding-bottom:.25rem}.swagger-ui .pb2-ns{padding-bottom:.5rem}.swagger-ui .pb3-ns{padding-bottom:1rem}.swagger-ui .pb4-ns{padding-bottom:2rem}.swagger-ui .pb5-ns{padding-bottom:4rem}.swagger-ui .pb6-ns{padding-bottom:8rem}.swagger-ui .pb7-ns{padding-bottom:16rem}.swagger-ui .pt0-ns{padding-top:0}.swagger-ui .pt1-ns{padding-top:.25rem}.swagger-ui .pt2-ns{padding-top:.5rem}.swagger-ui .pt3-ns{padding-top:1rem}.swagger-ui .pt4-ns{padding-top:2rem}.swagger-ui .pt5-ns{padding-top:4rem}.swagger-ui .pt6-ns{padding-top:8rem}.swagger-ui .pt7-ns{padding-top:16rem}.swagger-ui .pv0-ns{padding-bottom:0;padding-top:0}.swagger-ui .pv1-ns{padding-bottom:.25rem;padding-top:.25rem}.swagger-ui .pv2-ns{padding-bottom:.5rem;padding-top:.5rem}.swagger-ui .pv3-ns{padding-bottom:1rem;padding-top:1rem}.swagger-ui .pv4-ns{padding-bottom:2rem;padding-top:2rem}.swagger-ui .pv5-ns{padding-bottom:4rem;padding-top:4rem}.swagger-ui .pv6-ns{padding-bottom:8rem;padding-top:8rem}.swagger-ui .pv7-ns{padding-bottom:16rem;padding-top:16rem}.swagger-ui .ph0-ns{padding-left:0;padding-right:0}.swagger-ui .ph1-ns{padding-left:.25rem;padding-right:.25rem}.swagger-ui .ph2-ns{padding-left:.5rem;padding-right:.5rem}.swagger-ui .ph3-ns{padding-left:1rem;padding-right:1rem}.swagger-ui .ph4-ns{padding-left:2rem;padding-right:2rem}.swagger-ui .ph5-ns{padding-left:4rem;padding-right:4rem}.swagger-ui .ph6-ns{padding-left:8rem;padding-right:8rem}.swagger-ui .ph7-ns{padding-left:16rem;padding-right:16rem}.swagger-ui .ma0-ns{margin:0}.swagger-ui .ma1-ns{margin:.25rem}.swagger-ui .ma2-ns{margin:.5rem}.swagger-ui .ma3-ns{margin:1rem}.swagger-ui .ma4-ns{margin:2rem}.swagger-ui .ma5-ns{margin:4rem}.swagger-ui .ma6-ns{margin:8rem}.swagger-ui .ma7-ns{margin:16rem}.swagger-ui .ml0-ns{margin-left:0}.swagger-ui .ml1-ns{margin-left:.25rem}.swagger-ui .ml2-ns{margin-left:.5rem}.swagger-ui .ml3-ns{margin-left:1rem}.swagger-ui .ml4-ns{margin-left:2rem}.swagger-ui .ml5-ns{margin-left:4rem}.swagger-ui .ml6-ns{margin-left:8rem}.swagger-ui .ml7-ns{margin-left:16rem}.swagger-ui .mr0-ns{margin-right:0}.swagger-ui .mr1-ns{margin-right:.25rem}.swagger-ui .mr2-ns{margin-right:.5rem}.swagger-ui .mr3-ns{margin-right:1rem}.swagger-ui .mr4-ns{margin-right:2rem}.swagger-ui .mr5-ns{margin-right:4rem}.swagger-ui .mr6-ns{margin-right:8rem}.swagger-ui .mr7-ns{margin-right:16rem}.swagger-ui .mb0-ns{margin-bottom:0}.swagger-ui .mb1-ns{margin-bottom:.25rem}.swagger-ui .mb2-ns{margin-bottom:.5rem}.swagger-ui .mb3-ns{margin-bottom:1rem}.swagger-ui .mb4-ns{margin-bottom:2rem}.swagger-ui .mb5-ns{margin-bottom:4rem}.swagger-ui .mb6-ns{margin-bottom:8rem}.swagger-ui .mb7-ns{margin-bottom:16rem}.swagger-ui .mt0-ns{margin-top:0}.swagger-ui .mt1-ns{margin-top:.25rem}.swagger-ui .mt2-ns{margin-top:.5rem}.swagger-ui .mt3-ns{margin-top:1rem}.swagger-ui .mt4-ns{margin-top:2rem}.swagger-ui .mt5-ns{margin-top:4rem}.swagger-ui .mt6-ns{margin-top:8rem}.swagger-ui .mt7-ns{margin-top:16rem}.swagger-ui .mv0-ns{margin-bottom:0;margin-top:0}.swagger-ui .mv1-ns{margin-bottom:.25rem;margin-top:.25rem}.swagger-ui .mv2-ns{margin-bottom:.5rem;margin-top:.5rem}.swagger-ui .mv3-ns{margin-bottom:1rem;margin-top:1rem}.swagger-ui .mv4-ns{margin-bottom:2rem;margin-top:2rem}.swagger-ui .mv5-ns{margin-bottom:4rem;margin-top:4rem}.swagger-ui .mv6-ns{margin-bottom:8rem;margin-top:8rem}.swagger-ui .mv7-ns{margin-bottom:16rem;margin-top:16rem}.swagger-ui .mh0-ns{margin-left:0;margin-right:0}.swagger-ui .mh1-ns{margin-left:.25rem;margin-right:.25rem}.swagger-ui .mh2-ns{margin-left:.5rem;margin-right:.5rem}.swagger-ui .mh3-ns{margin-left:1rem;margin-right:1rem}.swagger-ui .mh4-ns{margin-left:2rem;margin-right:2rem}.swagger-ui .mh5-ns{margin-left:4rem;margin-right:4rem}.swagger-ui .mh6-ns{margin-left:8rem;margin-right:8rem}.swagger-ui .mh7-ns{margin-left:16rem;margin-right:16rem}}@media screen and (min-width:30em) and (max-width:60em){.swagger-ui .pa0-m{padding:0}.swagger-ui .pa1-m{padding:.25rem}.swagger-ui .pa2-m{padding:.5rem}.swagger-ui .pa3-m{padding:1rem}.swagger-ui .pa4-m{padding:2rem}.swagger-ui .pa5-m{padding:4rem}.swagger-ui .pa6-m{padding:8rem}.swagger-ui .pa7-m{padding:16rem}.swagger-ui .pl0-m{padding-left:0}.swagger-ui .pl1-m{padding-left:.25rem}.swagger-ui .pl2-m{padding-left:.5rem}.swagger-ui .pl3-m{padding-left:1rem}.swagger-ui .pl4-m{padding-left:2rem}.swagger-ui .pl5-m{padding-left:4rem}.swagger-ui .pl6-m{padding-left:8rem}.swagger-ui .pl7-m{padding-left:16rem}.swagger-ui .pr0-m{padding-right:0}.swagger-ui .pr1-m{padding-right:.25rem}.swagger-ui .pr2-m{padding-right:.5rem}.swagger-ui .pr3-m{padding-right:1rem}.swagger-ui .pr4-m{padding-right:2rem}.swagger-ui .pr5-m{padding-right:4rem}.swagger-ui .pr6-m{padding-right:8rem}.swagger-ui .pr7-m{padding-right:16rem}.swagger-ui .pb0-m{padding-bottom:0}.swagger-ui .pb1-m{padding-bottom:.25rem}.swagger-ui .pb2-m{padding-bottom:.5rem}.swagger-ui .pb3-m{padding-bottom:1rem}.swagger-ui .pb4-m{padding-bottom:2rem}.swagger-ui .pb5-m{padding-bottom:4rem}.swagger-ui .pb6-m{padding-bottom:8rem}.swagger-ui .pb7-m{padding-bottom:16rem}.swagger-ui .pt0-m{padding-top:0}.swagger-ui .pt1-m{padding-top:.25rem}.swagger-ui .pt2-m{padding-top:.5rem}.swagger-ui .pt3-m{padding-top:1rem}.swagger-ui .pt4-m{padding-top:2rem}.swagger-ui .pt5-m{padding-top:4rem}.swagger-ui .pt6-m{padding-top:8rem}.swagger-ui .pt7-m{padding-top:16rem}.swagger-ui .pv0-m{padding-bottom:0;padding-top:0}.swagger-ui .pv1-m{padding-bottom:.25rem;padding-top:.25rem}.swagger-ui .pv2-m{padding-bottom:.5rem;padding-top:.5rem}.swagger-ui .pv3-m{padding-bottom:1rem;padding-top:1rem}.swagger-ui .pv4-m{padding-bottom:2rem;padding-top:2rem}.swagger-ui .pv5-m{padding-bottom:4rem;padding-top:4rem}.swagger-ui .pv6-m{padding-bottom:8rem;padding-top:8rem}.swagger-ui .pv7-m{padding-bottom:16rem;padding-top:16rem}.swagger-ui .ph0-m{padding-left:0;padding-right:0}.swagger-ui .ph1-m{padding-left:.25rem;padding-right:.25rem}.swagger-ui .ph2-m{padding-left:.5rem;padding-right:.5rem}.swagger-ui .ph3-m{padding-left:1rem;padding-right:1rem}.swagger-ui .ph4-m{padding-left:2rem;padding-right:2rem}.swagger-ui .ph5-m{padding-left:4rem;padding-right:4rem}.swagger-ui .ph6-m{padding-left:8rem;padding-right:8rem}.swagger-ui .ph7-m{padding-left:16rem;padding-right:16rem}.swagger-ui .ma0-m{margin:0}.swagger-ui .ma1-m{margin:.25rem}.swagger-ui .ma2-m{margin:.5rem}.swagger-ui .ma3-m{margin:1rem}.swagger-ui .ma4-m{margin:2rem}.swagger-ui .ma5-m{margin:4rem}.swagger-ui .ma6-m{margin:8rem}.swagger-ui .ma7-m{margin:16rem}.swagger-ui .ml0-m{margin-left:0}.swagger-ui .ml1-m{margin-left:.25rem}.swagger-ui .ml2-m{margin-left:.5rem}.swagger-ui .ml3-m{margin-left:1rem}.swagger-ui .ml4-m{margin-left:2rem}.swagger-ui .ml5-m{margin-left:4rem}.swagger-ui .ml6-m{margin-left:8rem}.swagger-ui .ml7-m{margin-left:16rem}.swagger-ui .mr0-m{margin-right:0}.swagger-ui .mr1-m{margin-right:.25rem}.swagger-ui .mr2-m{margin-right:.5rem}.swagger-ui .mr3-m{margin-right:1rem}.swagger-ui .mr4-m{margin-right:2rem}.swagger-ui .mr5-m{margin-right:4rem}.swagger-ui .mr6-m{margin-right:8rem}.swagger-ui .mr7-m{margin-right:16rem}.swagger-ui .mb0-m{margin-bottom:0}.swagger-ui .mb1-m{margin-bottom:.25rem}.swagger-ui .mb2-m{margin-bottom:.5rem}.swagger-ui .mb3-m{margin-bottom:1rem}.swagger-ui .mb4-m{margin-bottom:2rem}.swagger-ui .mb5-m{margin-bottom:4rem}.swagger-ui .mb6-m{margin-bottom:8rem}.swagger-ui .mb7-m{margin-bottom:16rem}.swagger-ui .mt0-m{margin-top:0}.swagger-ui .mt1-m{margin-top:.25rem}.swagger-ui .mt2-m{margin-top:.5rem}.swagger-ui .mt3-m{margin-top:1rem}.swagger-ui .mt4-m{margin-top:2rem}.swagger-ui .mt5-m{margin-top:4rem}.swagger-ui .mt6-m{margin-top:8rem}.swagger-ui .mt7-m{margin-top:16rem}.swagger-ui .mv0-m{margin-bottom:0;margin-top:0}.swagger-ui .mv1-m{margin-bottom:.25rem;margin-top:.25rem}.swagger-ui .mv2-m{margin-bottom:.5rem;margin-top:.5rem}.swagger-ui .mv3-m{margin-bottom:1rem;margin-top:1rem}.swagger-ui .mv4-m{margin-bottom:2rem;margin-top:2rem}.swagger-ui .mv5-m{margin-bottom:4rem;margin-top:4rem}.swagger-ui .mv6-m{margin-bottom:8rem;margin-top:8rem}.swagger-ui .mv7-m{margin-bottom:16rem;margin-top:16rem}.swagger-ui .mh0-m{margin-left:0;margin-right:0}.swagger-ui .mh1-m{margin-left:.25rem;margin-right:.25rem}.swagger-ui .mh2-m{margin-left:.5rem;margin-right:.5rem}.swagger-ui .mh3-m{margin-left:1rem;margin-right:1rem}.swagger-ui .mh4-m{margin-left:2rem;margin-right:2rem}.swagger-ui .mh5-m{margin-left:4rem;margin-right:4rem}.swagger-ui .mh6-m{margin-left:8rem;margin-right:8rem}.swagger-ui .mh7-m{margin-left:16rem;margin-right:16rem}}@media screen and (min-width:60em){.swagger-ui .pa0-l{padding:0}.swagger-ui .pa1-l{padding:.25rem}.swagger-ui .pa2-l{padding:.5rem}.swagger-ui .pa3-l{padding:1rem}.swagger-ui .pa4-l{padding:2rem}.swagger-ui .pa5-l{padding:4rem}.swagger-ui .pa6-l{padding:8rem}.swagger-ui .pa7-l{padding:16rem}.swagger-ui .pl0-l{padding-left:0}.swagger-ui .pl1-l{padding-left:.25rem}.swagger-ui .pl2-l{padding-left:.5rem}.swagger-ui .pl3-l{padding-left:1rem}.swagger-ui .pl4-l{padding-left:2rem}.swagger-ui .pl5-l{padding-left:4rem}.swagger-ui .pl6-l{padding-left:8rem}.swagger-ui .pl7-l{padding-left:16rem}.swagger-ui .pr0-l{padding-right:0}.swagger-ui .pr1-l{padding-right:.25rem}.swagger-ui .pr2-l{padding-right:.5rem}.swagger-ui .pr3-l{padding-right:1rem}.swagger-ui .pr4-l{padding-right:2rem}.swagger-ui .pr5-l{padding-right:4rem}.swagger-ui .pr6-l{padding-right:8rem}.swagger-ui .pr7-l{padding-right:16rem}.swagger-ui .pb0-l{padding-bottom:0}.swagger-ui .pb1-l{padding-bottom:.25rem}.swagger-ui .pb2-l{padding-bottom:.5rem}.swagger-ui .pb3-l{padding-bottom:1rem}.swagger-ui .pb4-l{padding-bottom:2rem}.swagger-ui .pb5-l{padding-bottom:4rem}.swagger-ui .pb6-l{padding-bottom:8rem}.swagger-ui .pb7-l{padding-bottom:16rem}.swagger-ui .pt0-l{padding-top:0}.swagger-ui .pt1-l{padding-top:.25rem}.swagger-ui .pt2-l{padding-top:.5rem}.swagger-ui .pt3-l{padding-top:1rem}.swagger-ui .pt4-l{padding-top:2rem}.swagger-ui .pt5-l{padding-top:4rem}.swagger-ui .pt6-l{padding-top:8rem}.swagger-ui .pt7-l{padding-top:16rem}.swagger-ui .pv0-l{padding-bottom:0;padding-top:0}.swagger-ui .pv1-l{padding-bottom:.25rem;padding-top:.25rem}.swagger-ui .pv2-l{padding-bottom:.5rem;padding-top:.5rem}.swagger-ui .pv3-l{padding-bottom:1rem;padding-top:1rem}.swagger-ui .pv4-l{padding-bottom:2rem;padding-top:2rem}.swagger-ui .pv5-l{padding-bottom:4rem;padding-top:4rem}.swagger-ui .pv6-l{padding-bottom:8rem;padding-top:8rem}.swagger-ui .pv7-l{padding-bottom:16rem;padding-top:16rem}.swagger-ui .ph0-l{padding-left:0;padding-right:0}.swagger-ui .ph1-l{padding-left:.25rem;padding-right:.25rem}.swagger-ui .ph2-l{padding-left:.5rem;padding-right:.5rem}.swagger-ui .ph3-l{padding-left:1rem;padding-right:1rem}.swagger-ui .ph4-l{padding-left:2rem;padding-right:2rem}.swagger-ui .ph5-l{padding-left:4rem;padding-right:4rem}.swagger-ui .ph6-l{padding-left:8rem;padding-right:8rem}.swagger-ui .ph7-l{padding-left:16rem;padding-right:16rem}.swagger-ui .ma0-l{margin:0}.swagger-ui .ma1-l{margin:.25rem}.swagger-ui .ma2-l{margin:.5rem}.swagger-ui .ma3-l{margin:1rem}.swagger-ui .ma4-l{margin:2rem}.swagger-ui .ma5-l{margin:4rem}.swagger-ui .ma6-l{margin:8rem}.swagger-ui .ma7-l{margin:16rem}.swagger-ui .ml0-l{margin-left:0}.swagger-ui .ml1-l{margin-left:.25rem}.swagger-ui .ml2-l{margin-left:.5rem}.swagger-ui .ml3-l{margin-left:1rem}.swagger-ui .ml4-l{margin-left:2rem}.swagger-ui .ml5-l{margin-left:4rem}.swagger-ui .ml6-l{margin-left:8rem}.swagger-ui .ml7-l{margin-left:16rem}.swagger-ui .mr0-l{margin-right:0}.swagger-ui .mr1-l{margin-right:.25rem}.swagger-ui .mr2-l{margin-right:.5rem}.swagger-ui .mr3-l{margin-right:1rem}.swagger-ui .mr4-l{margin-right:2rem}.swagger-ui .mr5-l{margin-right:4rem}.swagger-ui .mr6-l{margin-right:8rem}.swagger-ui .mr7-l{margin-right:16rem}.swagger-ui .mb0-l{margin-bottom:0}.swagger-ui .mb1-l{margin-bottom:.25rem}.swagger-ui .mb2-l{margin-bottom:.5rem}.swagger-ui .mb3-l{margin-bottom:1rem}.swagger-ui .mb4-l{margin-bottom:2rem}.swagger-ui .mb5-l{margin-bottom:4rem}.swagger-ui .mb6-l{margin-bottom:8rem}.swagger-ui .mb7-l{margin-bottom:16rem}.swagger-ui .mt0-l{margin-top:0}.swagger-ui .mt1-l{margin-top:.25rem}.swagger-ui .mt2-l{margin-top:.5rem}.swagger-ui .mt3-l{margin-top:1rem}.swagger-ui .mt4-l{margin-top:2rem}.swagger-ui .mt5-l{margin-top:4rem}.swagger-ui .mt6-l{margin-top:8rem}.swagger-ui .mt7-l{margin-top:16rem}.swagger-ui .mv0-l{margin-bottom:0;margin-top:0}.swagger-ui .mv1-l{margin-bottom:.25rem;margin-top:.25rem}.swagger-ui .mv2-l{margin-bottom:.5rem;margin-top:.5rem}.swagger-ui .mv3-l{margin-bottom:1rem;margin-top:1rem}.swagger-ui .mv4-l{margin-bottom:2rem;margin-top:2rem}.swagger-ui .mv5-l{margin-bottom:4rem;margin-top:4rem}.swagger-ui .mv6-l{margin-bottom:8rem;margin-top:8rem}.swagger-ui .mv7-l{margin-bottom:16rem;margin-top:16rem}.swagger-ui .mh0-l{margin-left:0;margin-right:0}.swagger-ui .mh1-l{margin-left:.25rem;margin-right:.25rem}.swagger-ui .mh2-l{margin-left:.5rem;margin-right:.5rem}.swagger-ui .mh3-l{margin-left:1rem;margin-right:1rem}.swagger-ui .mh4-l{margin-left:2rem;margin-right:2rem}.swagger-ui .mh5-l{margin-left:4rem;margin-right:4rem}.swagger-ui .mh6-l{margin-left:8rem;margin-right:8rem}.swagger-ui .mh7-l{margin-left:16rem;margin-right:16rem}}.swagger-ui .na1{margin:-.25rem}.swagger-ui .na2{margin:-.5rem}.swagger-ui .na3{margin:-1rem}.swagger-ui .na4{margin:-2rem}.swagger-ui .na5{margin:-4rem}.swagger-ui .na6{margin:-8rem}.swagger-ui .na7{margin:-16rem}.swagger-ui .nl1{margin-left:-.25rem}.swagger-ui .nl2{margin-left:-.5rem}.swagger-ui .nl3{margin-left:-1rem}.swagger-ui .nl4{margin-left:-2rem}.swagger-ui .nl5{margin-left:-4rem}.swagger-ui .nl6{margin-left:-8rem}.swagger-ui .nl7{margin-left:-16rem}.swagger-ui .nr1{margin-right:-.25rem}.swagger-ui .nr2{margin-right:-.5rem}.swagger-ui .nr3{margin-right:-1rem}.swagger-ui .nr4{margin-right:-2rem}.swagger-ui .nr5{margin-right:-4rem}.swagger-ui .nr6{margin-right:-8rem}.swagger-ui .nr7{margin-right:-16rem}.swagger-ui .nb1{margin-bottom:-.25rem}.swagger-ui .nb2{margin-bottom:-.5rem}.swagger-ui .nb3{margin-bottom:-1rem}.swagger-ui .nb4{margin-bottom:-2rem}.swagger-ui .nb5{margin-bottom:-4rem}.swagger-ui .nb6{margin-bottom:-8rem}.swagger-ui .nb7{margin-bottom:-16rem}.swagger-ui .nt1{margin-top:-.25rem}.swagger-ui .nt2{margin-top:-.5rem}.swagger-ui .nt3{margin-top:-1rem}.swagger-ui .nt4{margin-top:-2rem}.swagger-ui .nt5{margin-top:-4rem}.swagger-ui .nt6{margin-top:-8rem}.swagger-ui .nt7{margin-top:-16rem}@media screen and (min-width:30em){.swagger-ui .na1-ns{margin:-.25rem}.swagger-ui .na2-ns{margin:-.5rem}.swagger-ui .na3-ns{margin:-1rem}.swagger-ui .na4-ns{margin:-2rem}.swagger-ui .na5-ns{margin:-4rem}.swagger-ui .na6-ns{margin:-8rem}.swagger-ui .na7-ns{margin:-16rem}.swagger-ui .nl1-ns{margin-left:-.25rem}.swagger-ui .nl2-ns{margin-left:-.5rem}.swagger-ui .nl3-ns{margin-left:-1rem}.swagger-ui .nl4-ns{margin-left:-2rem}.swagger-ui .nl5-ns{margin-left:-4rem}.swagger-ui .nl6-ns{margin-left:-8rem}.swagger-ui .nl7-ns{margin-left:-16rem}.swagger-ui .nr1-ns{margin-right:-.25rem}.swagger-ui .nr2-ns{margin-right:-.5rem}.swagger-ui .nr3-ns{margin-right:-1rem}.swagger-ui .nr4-ns{margin-right:-2rem}.swagger-ui .nr5-ns{margin-right:-4rem}.swagger-ui .nr6-ns{margin-right:-8rem}.swagger-ui .nr7-ns{margin-right:-16rem}.swagger-ui .nb1-ns{margin-bottom:-.25rem}.swagger-ui .nb2-ns{margin-bottom:-.5rem}.swagger-ui .nb3-ns{margin-bottom:-1rem}.swagger-ui .nb4-ns{margin-bottom:-2rem}.swagger-ui .nb5-ns{margin-bottom:-4rem}.swagger-ui .nb6-ns{margin-bottom:-8rem}.swagger-ui .nb7-ns{margin-bottom:-16rem}.swagger-ui .nt1-ns{margin-top:-.25rem}.swagger-ui .nt2-ns{margin-top:-.5rem}.swagger-ui .nt3-ns{margin-top:-1rem}.swagger-ui .nt4-ns{margin-top:-2rem}.swagger-ui .nt5-ns{margin-top:-4rem}.swagger-ui .nt6-ns{margin-top:-8rem}.swagger-ui .nt7-ns{margin-top:-16rem}}@media screen and (min-width:30em) and (max-width:60em){.swagger-ui .na1-m{margin:-.25rem}.swagger-ui .na2-m{margin:-.5rem}.swagger-ui .na3-m{margin:-1rem}.swagger-ui .na4-m{margin:-2rem}.swagger-ui .na5-m{margin:-4rem}.swagger-ui .na6-m{margin:-8rem}.swagger-ui .na7-m{margin:-16rem}.swagger-ui .nl1-m{margin-left:-.25rem}.swagger-ui .nl2-m{margin-left:-.5rem}.swagger-ui .nl3-m{margin-left:-1rem}.swagger-ui .nl4-m{margin-left:-2rem}.swagger-ui .nl5-m{margin-left:-4rem}.swagger-ui .nl6-m{margin-left:-8rem}.swagger-ui .nl7-m{margin-left:-16rem}.swagger-ui .nr1-m{margin-right:-.25rem}.swagger-ui .nr2-m{margin-right:-.5rem}.swagger-ui .nr3-m{margin-right:-1rem}.swagger-ui .nr4-m{margin-right:-2rem}.swagger-ui .nr5-m{margin-right:-4rem}.swagger-ui .nr6-m{margin-right:-8rem}.swagger-ui .nr7-m{margin-right:-16rem}.swagger-ui .nb1-m{margin-bottom:-.25rem}.swagger-ui .nb2-m{margin-bottom:-.5rem}.swagger-ui .nb3-m{margin-bottom:-1rem}.swagger-ui .nb4-m{margin-bottom:-2rem}.swagger-ui .nb5-m{margin-bottom:-4rem}.swagger-ui .nb6-m{margin-bottom:-8rem}.swagger-ui .nb7-m{margin-bottom:-16rem}.swagger-ui .nt1-m{margin-top:-.25rem}.swagger-ui .nt2-m{margin-top:-.5rem}.swagger-ui .nt3-m{margin-top:-1rem}.swagger-ui .nt4-m{margin-top:-2rem}.swagger-ui .nt5-m{margin-top:-4rem}.swagger-ui .nt6-m{margin-top:-8rem}.swagger-ui .nt7-m{margin-top:-16rem}}@media screen and (min-width:60em){.swagger-ui .na1-l{margin:-.25rem}.swagger-ui .na2-l{margin:-.5rem}.swagger-ui .na3-l{margin:-1rem}.swagger-ui .na4-l{margin:-2rem}.swagger-ui .na5-l{margin:-4rem}.swagger-ui .na6-l{margin:-8rem}.swagger-ui .na7-l{margin:-16rem}.swagger-ui .nl1-l{margin-left:-.25rem}.swagger-ui .nl2-l{margin-left:-.5rem}.swagger-ui .nl3-l{margin-left:-1rem}.swagger-ui .nl4-l{margin-left:-2rem}.swagger-ui .nl5-l{margin-left:-4rem}.swagger-ui .nl6-l{margin-left:-8rem}.swagger-ui .nl7-l{margin-left:-16rem}.swagger-ui .nr1-l{margin-right:-.25rem}.swagger-ui .nr2-l{margin-right:-.5rem}.swagger-ui .nr3-l{margin-right:-1rem}.swagger-ui .nr4-l{margin-right:-2rem}.swagger-ui .nr5-l{margin-right:-4rem}.swagger-ui .nr6-l{margin-right:-8rem}.swagger-ui .nr7-l{margin-right:-16rem}.swagger-ui .nb1-l{margin-bottom:-.25rem}.swagger-ui .nb2-l{margin-bottom:-.5rem}.swagger-ui .nb3-l{margin-bottom:-1rem}.swagger-ui .nb4-l{margin-bottom:-2rem}.swagger-ui .nb5-l{margin-bottom:-4rem}.swagger-ui .nb6-l{margin-bottom:-8rem}.swagger-ui .nb7-l{margin-bottom:-16rem}.swagger-ui .nt1-l{margin-top:-.25rem}.swagger-ui .nt2-l{margin-top:-.5rem}.swagger-ui .nt3-l{margin-top:-1rem}.swagger-ui .nt4-l{margin-top:-2rem}.swagger-ui .nt5-l{margin-top:-4rem}.swagger-ui .nt6-l{margin-top:-8rem}.swagger-ui .nt7-l{margin-top:-16rem}}.swagger-ui .collapse{border-collapse:collapse;border-spacing:0}.swagger-ui .striped--light-silver:nth-child(odd){background-color:#aaa}.swagger-ui .striped--moon-gray:nth-child(odd){background-color:#ccc}.swagger-ui .striped--light-gray:nth-child(odd){background-color:#eee}.swagger-ui .striped--near-white:nth-child(odd){background-color:#f4f4f4}.swagger-ui .stripe-light:nth-child(odd){background-color:hsla(0,0%,100%,.1)}.swagger-ui .stripe-dark:nth-child(odd){background-color:rgba(0,0,0,.1)}.swagger-ui .strike{text-decoration:line-through}.swagger-ui .underline{text-decoration:underline}.swagger-ui .no-underline{text-decoration:none}@media screen and (min-width:30em){.swagger-ui .strike-ns{text-decoration:line-through}.swagger-ui .underline-ns{text-decoration:underline}.swagger-ui .no-underline-ns{text-decoration:none}}@media screen and (min-width:30em) and (max-width:60em){.swagger-ui .strike-m{text-decoration:line-through}.swagger-ui .underline-m{text-decoration:underline}.swagger-ui .no-underline-m{text-decoration:none}}@media screen and (min-width:60em){.swagger-ui .strike-l{text-decoration:line-through}.swagger-ui .underline-l{text-decoration:underline}.swagger-ui .no-underline-l{text-decoration:none}}.swagger-ui .tl{text-align:left}.swagger-ui .tr{text-align:right}.swagger-ui .tc{text-align:center}.swagger-ui .tj{text-align:justify}@media screen and (min-width:30em){.swagger-ui .tl-ns{text-align:left}.swagger-ui .tr-ns{text-align:right}.swagger-ui .tc-ns{text-align:center}.swagger-ui .tj-ns{text-align:justify}}@media screen and (min-width:30em) and (max-width:60em){.swagger-ui .tl-m{text-align:left}.swagger-ui .tr-m{text-align:right}.swagger-ui .tc-m{text-align:center}.swagger-ui .tj-m{text-align:justify}}@media screen and (min-width:60em){.swagger-ui .tl-l{text-align:left}.swagger-ui .tr-l{text-align:right}.swagger-ui .tc-l{text-align:center}.swagger-ui .tj-l{text-align:justify}}.swagger-ui .ttc{text-transform:capitalize}.swagger-ui .ttl{text-transform:lowercase}.swagger-ui .ttu{text-transform:uppercase}.swagger-ui .ttn{text-transform:none}@media screen and (min-width:30em){.swagger-ui .ttc-ns{text-transform:capitalize}.swagger-ui .ttl-ns{text-transform:lowercase}.swagger-ui .ttu-ns{text-transform:uppercase}.swagger-ui .ttn-ns{text-transform:none}}@media screen and (min-width:30em) and (max-width:60em){.swagger-ui .ttc-m{text-transform:capitalize}.swagger-ui .ttl-m{text-transform:lowercase}.swagger-ui .ttu-m{text-transform:uppercase}.swagger-ui .ttn-m{text-transform:none}}@media screen and (min-width:60em){.swagger-ui .ttc-l{text-transform:capitalize}.swagger-ui .ttl-l{text-transform:lowercase}.swagger-ui .ttu-l{text-transform:uppercase}.swagger-ui .ttn-l{text-transform:none}}.swagger-ui .f-6,.swagger-ui .f-headline{font-size:6rem}.swagger-ui .f-5,.swagger-ui .f-subheadline{font-size:5rem}.swagger-ui .f1{font-size:3rem}.swagger-ui .f2{font-size:2.25rem}.swagger-ui .f3{font-size:1.5rem}.swagger-ui .f4{font-size:1.25rem}.swagger-ui .f5{font-size:1rem}.swagger-ui .f6{font-size:.875rem}.swagger-ui .f7{font-size:.75rem}@media screen and (min-width:30em){.swagger-ui .f-6-ns,.swagger-ui .f-headline-ns{font-size:6rem}.swagger-ui .f-5-ns,.swagger-ui .f-subheadline-ns{font-size:5rem}.swagger-ui .f1-ns{font-size:3rem}.swagger-ui .f2-ns{font-size:2.25rem}.swagger-ui .f3-ns{font-size:1.5rem}.swagger-ui .f4-ns{font-size:1.25rem}.swagger-ui .f5-ns{font-size:1rem}.swagger-ui .f6-ns{font-size:.875rem}.swagger-ui .f7-ns{font-size:.75rem}}@media screen and (min-width:30em) and (max-width:60em){.swagger-ui .f-6-m,.swagger-ui .f-headline-m{font-size:6rem}.swagger-ui .f-5-m,.swagger-ui .f-subheadline-m{font-size:5rem}.swagger-ui .f1-m{font-size:3rem}.swagger-ui .f2-m{font-size:2.25rem}.swagger-ui .f3-m{font-size:1.5rem}.swagger-ui .f4-m{font-size:1.25rem}.swagger-ui .f5-m{font-size:1rem}.swagger-ui .f6-m{font-size:.875rem}.swagger-ui .f7-m{font-size:.75rem}}@media screen and (min-width:60em){.swagger-ui .f-6-l,.swagger-ui .f-headline-l{font-size:6rem}.swagger-ui .f-5-l,.swagger-ui .f-subheadline-l{font-size:5rem}.swagger-ui .f1-l{font-size:3rem}.swagger-ui .f2-l{font-size:2.25rem}.swagger-ui .f3-l{font-size:1.5rem}.swagger-ui .f4-l{font-size:1.25rem}.swagger-ui .f5-l{font-size:1rem}.swagger-ui .f6-l{font-size:.875rem}.swagger-ui .f7-l{font-size:.75rem}}.swagger-ui .measure{max-width:30em}.swagger-ui .measure-wide{max-width:34em}.swagger-ui .measure-narrow{max-width:20em}.swagger-ui .indent{margin-bottom:0;margin-top:0;text-indent:1em}.swagger-ui .small-caps{font-feature-settings:"smcp";font-variant:small-caps}.swagger-ui .truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}@media screen and (min-width:30em){.swagger-ui .measure-ns{max-width:30em}.swagger-ui .measure-wide-ns{max-width:34em}.swagger-ui .measure-narrow-ns{max-width:20em}.swagger-ui .indent-ns{margin-bottom:0;margin-top:0;text-indent:1em}.swagger-ui .small-caps-ns{font-feature-settings:"smcp";font-variant:small-caps}.swagger-ui .truncate-ns{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}}@media screen and (min-width:30em) and (max-width:60em){.swagger-ui .measure-m{max-width:30em}.swagger-ui .measure-wide-m{max-width:34em}.swagger-ui .measure-narrow-m{max-width:20em}.swagger-ui .indent-m{margin-bottom:0;margin-top:0;text-indent:1em}.swagger-ui .small-caps-m{font-feature-settings:"smcp";font-variant:small-caps}.swagger-ui .truncate-m{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}}@media screen and (min-width:60em){.swagger-ui .measure-l{max-width:30em}.swagger-ui .measure-wide-l{max-width:34em}.swagger-ui .measure-narrow-l{max-width:20em}.swagger-ui .indent-l{margin-bottom:0;margin-top:0;text-indent:1em}.swagger-ui .small-caps-l{font-feature-settings:"smcp";font-variant:small-caps}.swagger-ui .truncate-l{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}}.swagger-ui .overflow-container{overflow-y:scroll}.swagger-ui .center{margin-left:auto;margin-right:auto}.swagger-ui .mr-auto{margin-right:auto}.swagger-ui .ml-auto{margin-left:auto}@media screen and (min-width:30em){.swagger-ui .center-ns{margin-left:auto;margin-right:auto}.swagger-ui .mr-auto-ns{margin-right:auto}.swagger-ui .ml-auto-ns{margin-left:auto}}@media screen and (min-width:30em) and (max-width:60em){.swagger-ui .center-m{margin-left:auto;margin-right:auto}.swagger-ui .mr-auto-m{margin-right:auto}.swagger-ui .ml-auto-m{margin-left:auto}}@media screen and (min-width:60em){.swagger-ui .center-l{margin-left:auto;margin-right:auto}.swagger-ui .mr-auto-l{margin-right:auto}.swagger-ui .ml-auto-l{margin-left:auto}}.swagger-ui .clip{clip:rect(1px 1px 1px 1px);clip:rect(1px,1px,1px,1px);position:fixed!important;_position:absolute!important}@media screen and (min-width:30em){.swagger-ui .clip-ns{clip:rect(1px 1px 1px 1px);clip:rect(1px,1px,1px,1px);position:fixed!important;_position:absolute!important}}@media screen and (min-width:30em) and (max-width:60em){.swagger-ui .clip-m{clip:rect(1px 1px 1px 1px);clip:rect(1px,1px,1px,1px);position:fixed!important;_position:absolute!important}}@media screen and (min-width:60em){.swagger-ui .clip-l{clip:rect(1px 1px 1px 1px);clip:rect(1px,1px,1px,1px);position:fixed!important;_position:absolute!important}}.swagger-ui .ws-normal{white-space:normal}.swagger-ui .nowrap{white-space:nowrap}.swagger-ui .pre{white-space:pre}@media screen and (min-width:30em){.swagger-ui .ws-normal-ns{white-space:normal}.swagger-ui .nowrap-ns{white-space:nowrap}.swagger-ui .pre-ns{white-space:pre}}@media screen and (min-width:30em) and (max-width:60em){.swagger-ui .ws-normal-m{white-space:normal}.swagger-ui .nowrap-m{white-space:nowrap}.swagger-ui .pre-m{white-space:pre}}@media screen and (min-width:60em){.swagger-ui .ws-normal-l{white-space:normal}.swagger-ui .nowrap-l{white-space:nowrap}.swagger-ui .pre-l{white-space:pre}}.swagger-ui .v-base{vertical-align:baseline}.swagger-ui .v-mid{vertical-align:middle}.swagger-ui .v-top{vertical-align:top}.swagger-ui .v-btm{vertical-align:bottom}@media screen and (min-width:30em){.swagger-ui .v-base-ns{vertical-align:baseline}.swagger-ui .v-mid-ns{vertical-align:middle}.swagger-ui .v-top-ns{vertical-align:top}.swagger-ui .v-btm-ns{vertical-align:bottom}}@media screen and (min-width:30em) and (max-width:60em){.swagger-ui .v-base-m{vertical-align:baseline}.swagger-ui .v-mid-m{vertical-align:middle}.swagger-ui .v-top-m{vertical-align:top}.swagger-ui .v-btm-m{vertical-align:bottom}}@media screen and (min-width:60em){.swagger-ui .v-base-l{vertical-align:baseline}.swagger-ui .v-mid-l{vertical-align:middle}.swagger-ui .v-top-l{vertical-align:top}.swagger-ui .v-btm-l{vertical-align:bottom}}.swagger-ui .dim{opacity:1;transition:opacity .15s ease-in}.swagger-ui .dim:focus,.swagger-ui .dim:hover{opacity:.5;transition:opacity .15s ease-in}.swagger-ui .dim:active{opacity:.8;transition:opacity .15s ease-out}.swagger-ui .glow{transition:opacity .15s ease-in}.swagger-ui .glow:focus,.swagger-ui .glow:hover{opacity:1;transition:opacity .15s ease-in}.swagger-ui .hide-child .child{opacity:0;transition:opacity .15s ease-in}.swagger-ui .hide-child:active .child,.swagger-ui .hide-child:focus .child,.swagger-ui .hide-child:hover .child{opacity:1;transition:opacity .15s ease-in}.swagger-ui .underline-hover:focus,.swagger-ui .underline-hover:hover{text-decoration:underline}.swagger-ui .grow{-moz-osx-font-smoothing:grayscale;-webkit-backface-visibility:hidden;backface-visibility:hidden;transform:translateZ(0);transition:transform .25s ease-out}.swagger-ui .grow:focus,.swagger-ui .grow:hover{transform:scale(1.05)}.swagger-ui .grow:active{transform:scale(.9)}.swagger-ui .grow-large{-moz-osx-font-smoothing:grayscale;-webkit-backface-visibility:hidden;backface-visibility:hidden;transform:translateZ(0);transition:transform .25s ease-in-out}.swagger-ui .grow-large:focus,.swagger-ui .grow-large:hover{transform:scale(1.2)}.swagger-ui .grow-large:active{transform:scale(.95)}.swagger-ui .pointer:hover{cursor:pointer}.swagger-ui .shadow-hover{cursor:pointer;position:relative;transition:all .5s cubic-bezier(.165,.84,.44,1)}.swagger-ui .shadow-hover:after{border-radius:inherit;box-shadow:0 0 16px 2px rgba(0,0,0,.2);content:"";height:100%;left:0;opacity:0;position:absolute;top:0;transition:opacity .5s cubic-bezier(.165,.84,.44,1);width:100%;z-index:-1}.swagger-ui .shadow-hover:focus:after,.swagger-ui .shadow-hover:hover:after{opacity:1}.swagger-ui .bg-animate,.swagger-ui .bg-animate:focus,.swagger-ui .bg-animate:hover{transition:background-color .15s ease-in-out}.swagger-ui .z-0{z-index:0}.swagger-ui .z-1{z-index:1}.swagger-ui .z-2{z-index:2}.swagger-ui .z-3{z-index:3}.swagger-ui .z-4{z-index:4}.swagger-ui .z-5{z-index:5}.swagger-ui .z-999{z-index:999}.swagger-ui .z-9999{z-index:9999}.swagger-ui .z-max{z-index:2147483647}.swagger-ui .z-inherit{z-index:inherit}.swagger-ui .z-initial{z-index:auto}.swagger-ui .z-unset{z-index:unset}.swagger-ui .nested-copy-line-height ol,.swagger-ui .nested-copy-line-height p,.swagger-ui .nested-copy-line-height ul{line-height:1.5}.swagger-ui .nested-headline-line-height h1,.swagger-ui .nested-headline-line-height h2,.swagger-ui .nested-headline-line-height h3,.swagger-ui .nested-headline-line-height h4,.swagger-ui .nested-headline-line-height h5,.swagger-ui .nested-headline-line-height h6{line-height:1.25}.swagger-ui .nested-list-reset ol,.swagger-ui .nested-list-reset ul{list-style-type:none;margin-left:0;padding-left:0}.swagger-ui .nested-copy-indent p+p{margin-bottom:0;margin-top:0;text-indent:.1em}.swagger-ui .nested-copy-seperator p+p{margin-top:1.5em}.swagger-ui .nested-img img{display:block;max-width:100%;width:100%}.swagger-ui .nested-links a{color:#357edd;transition:color .15s ease-in}.swagger-ui .nested-links a:focus,.swagger-ui .nested-links a:hover{color:#96ccff;transition:color .15s ease-in}.swagger-ui .wrapper{box-sizing:border-box;margin:0 auto;max-width:1460px;padding:0 20px;width:100%}.swagger-ui .opblock-tag-section{display:flex;flex-direction:column}.swagger-ui .try-out.btn-group{display:flex;flex:0.1 2 auto;padding:0}.swagger-ui .try-out__btn{margin-left:1.25rem}.swagger-ui .opblock-tag{align-items:center;border-bottom:1px solid rgba(59,65,81,.3);cursor:pointer;display:flex;padding:10px 20px 10px 10px;transition:all .2s}.swagger-ui .opblock-tag:hover{background:rgba(0,0,0,.02)}.swagger-ui .opblock-tag{color:#3b4151;font-family:sans-serif;font-size:24px;margin:0 0 5px}.swagger-ui .opblock-tag.no-desc span{flex:1}.swagger-ui .opblock-tag svg{transition:all .4s}.swagger-ui .opblock-tag small{color:#3b4151;flex:1;font-family:sans-serif;font-size:14px;font-weight:400;padding:0 10px}.swagger-ui .parameter__type{color:#3b4151;font-family:monospace;font-size:12px;font-weight:600;padding:5px 0}.swagger-ui .parameter-controls{margin-top:.75em}.swagger-ui .examples__title{display:block;font-size:1.1em;font-weight:700;margin-bottom:.75em}.swagger-ui .examples__section{margin-top:1.5em}.swagger-ui .examples__section-header{font-size:.9rem;font-weight:700;margin-bottom:.5rem}.swagger-ui .examples-select{display:inline-block;margin-bottom:.75em}.swagger-ui .examples-select .examples-select-element{width:100%}.swagger-ui .examples-select__section-label{font-size:.9rem;font-weight:700;margin-right:.5rem}.swagger-ui .example__section{margin-top:1.5em}.swagger-ui .example__section-header{font-size:.9rem;font-weight:700;margin-bottom:.5rem}.swagger-ui .view-line-link{cursor:pointer;margin:0 5px;position:relative;top:3px;transition:all .5s;width:20px}.swagger-ui .opblock{border:1px solid #000;border-radius:4px;box-shadow:0 0 3px rgba(0,0,0,.19);margin:0 0 15px}.swagger-ui .opblock .tab-header{display:flex;flex:1}.swagger-ui .opblock .tab-header .tab-item{cursor:pointer;padding:0 40px}.swagger-ui .opblock .tab-header .tab-item:first-of-type{padding:0 40px 0 0}.swagger-ui .opblock .tab-header .tab-item.active h4 span{position:relative}.swagger-ui .opblock .tab-header .tab-item.active h4 span:after{background:gray;bottom:-15px;content:"";height:4px;left:50%;position:absolute;transform:translateX(-50%);width:120%}.swagger-ui .opblock.is-open .opblock-summary{border-bottom:1px solid #000}.swagger-ui .opblock .opblock-section-header{align-items:center;background:hsla(0,0%,100%,.8);box-shadow:0 1px 2px rgba(0,0,0,.1);display:flex;min-height:50px;padding:8px 20px}.swagger-ui .opblock .opblock-section-header>label{align-items:center;color:#3b4151;display:flex;font-family:sans-serif;font-size:12px;font-weight:700;margin:0 0 0 auto}.swagger-ui .opblock .opblock-section-header>label>span{padding:0 10px 0 0}.swagger-ui .opblock .opblock-section-header h4{color:#3b4151;flex:1;font-family:sans-serif;font-size:14px;margin:0}.swagger-ui .opblock .opblock-summary-method{background:#000;border-radius:3px;color:#fff;font-family:sans-serif;font-size:14px;font-weight:700;min-width:80px;padding:6px 0;text-align:center;text-shadow:0 1px 0 rgba(0,0,0,.1)}.swagger-ui .opblock .opblock-summary-operation-id,.swagger-ui .opblock .opblock-summary-path,.swagger-ui .opblock .opblock-summary-path__deprecated{align-items:center;color:#3b4151;display:flex;font-family:monospace;font-size:16px;font-weight:600;padding:0 10px;word-break:break-word}@media (max-width:768px){.swagger-ui .opblock .opblock-summary-operation-id,.swagger-ui .opblock .opblock-summary-path,.swagger-ui .opblock .opblock-summary-path__deprecated{font-size:12px}}.swagger-ui .opblock .opblock-summary-path{flex-shrink:0;max-width:calc(100% - 110px - 15rem)}.swagger-ui .opblock .opblock-summary-path__deprecated{text-decoration:line-through}.swagger-ui .opblock .opblock-summary-operation-id{font-size:14px}.swagger-ui .opblock .opblock-summary-description{color:#3b4151;flex:1 1 auto;font-family:sans-serif;font-size:13px;word-break:break-word}.swagger-ui .opblock .opblock-summary{align-items:center;cursor:pointer;display:flex;padding:5px}.swagger-ui .opblock .opblock-summary .view-line-link{cursor:pointer;margin:0;position:relative;top:2px;transition:all .5s;width:0}.swagger-ui .opblock .opblock-summary:hover .view-line-link{margin:0 5px;width:18px}.swagger-ui .opblock.opblock-post{background:rgba(73,204,144,.1);border-color:#49cc90}.swagger-ui .opblock.opblock-post .opblock-summary-method{background:#49cc90}.swagger-ui .opblock.opblock-post .opblock-summary{border-color:#49cc90}.swagger-ui .opblock.opblock-post .tab-header .tab-item.active h4 span:after{background:#49cc90}.swagger-ui .opblock.opblock-put{background:rgba(252,161,48,.1);border-color:#fca130}.swagger-ui .opblock.opblock-put .opblock-summary-method{background:#fca130}.swagger-ui .opblock.opblock-put .opblock-summary{border-color:#fca130}.swagger-ui .opblock.opblock-put .tab-header .tab-item.active h4 span:after{background:#fca130}.swagger-ui .opblock.opblock-delete{background:rgba(249,62,62,.1);border-color:#f93e3e}.swagger-ui .opblock.opblock-delete .opblock-summary-method{background:#f93e3e}.swagger-ui .opblock.opblock-delete .opblock-summary{border-color:#f93e3e}.swagger-ui .opblock.opblock-delete .tab-header .tab-item.active h4 span:after{background:#f93e3e}.swagger-ui .opblock.opblock-get{background:rgba(97,175,254,.1);border-color:#61affe}.swagger-ui .opblock.opblock-get .opblock-summary-method{background:#61affe}.swagger-ui .opblock.opblock-get .opblock-summary{border-color:#61affe}.swagger-ui .opblock.opblock-get .tab-header .tab-item.active h4 span:after{background:#61affe}.swagger-ui .opblock.opblock-patch{background:rgba(80,227,194,.1);border-color:#50e3c2}.swagger-ui .opblock.opblock-patch .opblock-summary-method{background:#50e3c2}.swagger-ui .opblock.opblock-patch .opblock-summary{border-color:#50e3c2}.swagger-ui .opblock.opblock-patch .tab-header .tab-item.active h4 span:after{background:#50e3c2}.swagger-ui .opblock.opblock-head{background:rgba(144,18,254,.1);border-color:#9012fe}.swagger-ui .opblock.opblock-head .opblock-summary-method{background:#9012fe}.swagger-ui .opblock.opblock-head .opblock-summary{border-color:#9012fe}.swagger-ui .opblock.opblock-head .tab-header .tab-item.active h4 span:after{background:#9012fe}.swagger-ui .opblock.opblock-options{background:rgba(13,90,167,.1);border-color:#0d5aa7}.swagger-ui .opblock.opblock-options .opblock-summary-method{background:#0d5aa7}.swagger-ui .opblock.opblock-options .opblock-summary{border-color:#0d5aa7}.swagger-ui .opblock.opblock-options .tab-header .tab-item.active h4 span:after{background:#0d5aa7}.swagger-ui .opblock.opblock-deprecated{background:hsla(0,0%,92%,.1);border-color:#ebebeb;opacity:.6}.swagger-ui .opblock.opblock-deprecated .opblock-summary-method{background:#ebebeb}.swagger-ui .opblock.opblock-deprecated .opblock-summary{border-color:#ebebeb}.swagger-ui .opblock.opblock-deprecated .tab-header .tab-item.active h4 span:after{background:#ebebeb}.swagger-ui .opblock .opblock-schemes{padding:8px 20px}.swagger-ui .opblock .opblock-schemes .schemes-title{padding:0 10px 0 0}.swagger-ui .filter .operation-filter-input{border:2px solid #d8dde7;margin:20px 0;padding:10px;width:100%}.swagger-ui .download-url-wrapper .failed,.swagger-ui .filter .failed{color:red}.swagger-ui .download-url-wrapper .loading,.swagger-ui .filter .loading{color:#aaa}.swagger-ui .model-example{margin-top:1em}.swagger-ui .tab{display:flex;list-style:none;padding:0}.swagger-ui .tab li{color:#3b4151;cursor:pointer;font-family:sans-serif;font-size:12px;min-width:60px;padding:0}.swagger-ui .tab li:first-of-type{padding-left:0;padding-right:12px;position:relative}.swagger-ui .tab li:first-of-type:after{background:rgba(0,0,0,.2);content:"";height:100%;position:absolute;right:6px;top:0;width:1px}.swagger-ui .tab li.active{font-weight:700}.swagger-ui .tab li button.tablinks{background:none;border:0;color:inherit;font-family:inherit;font-weight:inherit;padding:0}.swagger-ui .opblock-description-wrapper,.swagger-ui .opblock-external-docs-wrapper,.swagger-ui .opblock-title_normal{color:#3b4151;font-family:sans-serif;font-size:12px;margin:0 0 5px;padding:15px 20px}.swagger-ui .opblock-description-wrapper h4,.swagger-ui .opblock-external-docs-wrapper h4,.swagger-ui .opblock-title_normal h4{color:#3b4151;font-family:sans-serif;font-size:12px;margin:0 0 5px}.swagger-ui .opblock-description-wrapper p,.swagger-ui .opblock-external-docs-wrapper p,.swagger-ui .opblock-title_normal p{color:#3b4151;font-family:sans-serif;font-size:14px;margin:0}.swagger-ui .opblock-external-docs-wrapper h4{padding-left:0}.swagger-ui .execute-wrapper{padding:20px;text-align:right}.swagger-ui .execute-wrapper .btn{padding:8px 40px;width:100%}.swagger-ui .body-param-options{display:flex;flex-direction:column}.swagger-ui .body-param-options .body-param-edit{padding:10px 0}.swagger-ui .body-param-options label{padding:8px 0}.swagger-ui .body-param-options label select{margin:3px 0 0}.swagger-ui .responses-inner{padding:20px}.swagger-ui .responses-inner h4,.swagger-ui .responses-inner h5{color:#3b4151;font-family:sans-serif;font-size:12px;margin:10px 0 5px}.swagger-ui .responses-inner .curl{white-space:normal}.swagger-ui .response-col_status{color:#3b4151;font-family:sans-serif;font-size:14px}.swagger-ui .response-col_status .response-undocumented{color:#909090;font-family:monospace;font-size:11px;font-weight:600}.swagger-ui .response-col_links{color:#3b4151;font-family:sans-serif;font-size:14px;max-width:40em;padding-left:2em}.swagger-ui .response-col_links .response-undocumented{color:#909090;font-family:monospace;font-size:11px;font-weight:600}.swagger-ui .response-col_links .operation-link{margin-bottom:1.5em}.swagger-ui .response-col_links .operation-link .description{margin-bottom:.5em}.swagger-ui .opblock-body .opblock-loading-animation{display:block;margin:3em auto}.swagger-ui .opblock-body pre.microlight{word-wrap:break-word;background:#333;border-radius:4px;color:#fff;font-family:monospace;font-size:12px;font-weight:600;-webkit-hyphens:auto;-ms-hyphens:auto;hyphens:auto;margin:0;padding:10px;white-space:pre-wrap;word-break:break-all;word-break:break-word}.swagger-ui .opblock-body pre.microlight .headerline{display:block}.swagger-ui .highlight-code{position:relative}.swagger-ui .highlight-code>.microlight{max-height:400px;min-height:6em;overflow-y:auto}.swagger-ui .highlight-code>.microlight code{white-space:pre-wrap!important;word-break:break-all}.swagger-ui .curl-command{position:relative}.swagger-ui .download-contents{align-items:center;background:#7d8293;border-radius:4px;bottom:10px;color:#fff;cursor:pointer;display:flex;font-family:sans-serif;font-size:14px;font-weight:600;height:30px;justify-content:center;padding:5px;position:absolute;right:10px;text-align:center}.swagger-ui .scheme-container{background:#fff;box-shadow:0 1px 2px 0 rgba(0,0,0,.15);margin:0 0 20px;padding:30px 0}.swagger-ui .scheme-container .schemes{align-items:flex-end;display:flex}.swagger-ui .scheme-container .schemes>label{color:#3b4151;display:flex;flex-direction:column;font-family:sans-serif;font-size:12px;font-weight:700;margin:-20px 15px 0 0}.swagger-ui .scheme-container .schemes>label select{min-width:130px;text-transform:uppercase}.swagger-ui .loading-container{align-items:center;display:flex;flex-direction:column;justify-content:center;margin-top:1em;min-height:1px;padding:40px 0 60px}.swagger-ui .loading-container .loading{position:relative}.swagger-ui .loading-container .loading:after{color:#3b4151;content:"loading";font-family:sans-serif;font-size:10px;font-weight:700;left:50%;position:absolute;text-transform:uppercase;top:50%;transform:translate(-50%,-50%)}.swagger-ui .loading-container .loading:before{-webkit-animation:rotation 1s linear infinite,opacity .5s;animation:rotation 1s linear infinite,opacity .5s;-webkit-backface-visibility:hidden;backface-visibility:hidden;border:2px solid rgba(85,85,85,.1);border-radius:100%;border-top-color:rgba(0,0,0,.6);content:"";display:block;height:60px;left:50%;margin:-30px;opacity:1;position:absolute;top:50%;width:60px}@-webkit-keyframes rotation{to{transform:rotate(1turn)}}@keyframes rotation{to{transform:rotate(1turn)}}.swagger-ui .response-controls{display:flex;padding-top:1em}.swagger-ui .response-control-media-type{margin-right:1em}.swagger-ui .response-control-media-type--accept-controller select{border-color:green}.swagger-ui .response-control-media-type__accept-message{color:green;font-size:.7em}.swagger-ui .response-control-examples__title,.swagger-ui .response-control-media-type__title{display:block;font-size:.7em;margin-bottom:.2em}@-webkit-keyframes blinker{50%{opacity:0}}@keyframes blinker{50%{opacity:0}}.swagger-ui .hidden{display:none}.swagger-ui .no-margin{border:none;height:auto;margin:0;padding:0}.swagger-ui .float-right{float:right}.swagger-ui .svg-assets{height:0;position:absolute;width:0}.swagger-ui section h3{color:#3b4151;font-family:sans-serif}.swagger-ui a.nostyle{display:inline}.swagger-ui a.nostyle,.swagger-ui a.nostyle:visited{color:inherit;cursor:pointer;text-decoration:inherit}.swagger-ui .fallback{color:#aaa;padding:1em}.swagger-ui .version-pragma{height:100%;padding:5em 0}.swagger-ui .version-pragma__message{display:flex;font-size:1.2em;height:100%;justify-content:center;line-height:1.5em;padding:0 .6em;text-align:center}.swagger-ui .version-pragma__message>div{flex:1;max-width:55ch}.swagger-ui .version-pragma__message code{background-color:#dedede;padding:4px 4px 2px;white-space:pre}.swagger-ui .opblock-link{font-weight:400}.swagger-ui .opblock-link.shown{font-weight:700}.swagger-ui span.token-string{color:#555}.swagger-ui span.token-not-formatted{color:#555;font-weight:700}.swagger-ui .btn{background:transparent;border:2px solid gray;border-radius:4px;box-shadow:0 1px 2px rgba(0,0,0,.1);color:#3b4151;font-family:sans-serif;font-size:14px;font-weight:700;padding:5px 23px;transition:all .3s}.swagger-ui .btn.btn-sm{font-size:12px;padding:4px 23px}.swagger-ui .btn[disabled]{cursor:not-allowed;opacity:.3}.swagger-ui .btn:hover{box-shadow:0 0 5px rgba(0,0,0,.3)}.swagger-ui .btn.cancel{background-color:transparent;border-color:#ff6060;color:#ff6060;font-family:sans-serif}.swagger-ui .btn.authorize{background-color:transparent;border-color:#49cc90;color:#49cc90;display:inline;line-height:1}.swagger-ui .btn.authorize span{float:left;padding:4px 20px 0 0}.swagger-ui .btn.authorize svg{fill:#49cc90}.swagger-ui .btn.execute{background-color:#4990e2;border-color:#4990e2;color:#fff}.swagger-ui .btn-group{display:flex;padding:30px}.swagger-ui .btn-group .btn{flex:1}.swagger-ui .btn-group .btn:first-child{border-radius:4px 0 0 4px}.swagger-ui .btn-group .btn:last-child{border-radius:0 4px 4px 0}.swagger-ui .authorization__btn{background:none;border:none;padding:0 10px}.swagger-ui .authorization__btn.locked{opacity:1}.swagger-ui .authorization__btn.unlocked{opacity:.4}.swagger-ui .model-box-control,.swagger-ui .models-control,.swagger-ui .opblock-summary-control{all:inherit;border-bottom:0;cursor:pointer;flex:1;padding:0}.swagger-ui .model-box-control:focus,.swagger-ui .models-control:focus,.swagger-ui .opblock-summary-control:focus{outline:auto}.swagger-ui .expand-methods,.swagger-ui .expand-operation{background:none;border:none}.swagger-ui .expand-methods svg,.swagger-ui .expand-operation svg{height:20px;width:20px}.swagger-ui .expand-methods{padding:0 10px}.swagger-ui .expand-methods:hover svg{fill:#404040}.swagger-ui .expand-methods svg{fill:#707070;transition:all .3s}.swagger-ui button{cursor:pointer}.swagger-ui button.invalid{-webkit-animation:shake .4s 1;animation:shake .4s 1;background:#feebeb;border-color:#f93e3e}.swagger-ui .copy-to-clipboard{align-items:center;background:#7d8293;border:none;border-radius:4px;bottom:10px;display:flex;height:30px;justify-content:center;position:absolute;right:100px;width:30px}.swagger-ui .copy-to-clipboard button{background:url('data:image/svg+xml;charset=utf-8,') 50% no-repeat;border:none;flex-grow:1;flex-shrink:1;height:25px}.swagger-ui .curl-command .copy-to-clipboard{bottom:5px;height:20px;right:10px;width:20px}.swagger-ui .curl-command .copy-to-clipboard button{height:18px}.swagger-ui select{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:#f7f7f7 url('data:image/svg+xml;charset=utf-8,') right 10px center no-repeat;background-size:20px;border:2px solid #41444e;border-radius:4px;box-shadow:0 1px 2px 0 rgba(0,0,0,.25);color:#3b4151;font-family:sans-serif;font-size:14px;font-weight:700;padding:5px 40px 5px 10px}.swagger-ui select[multiple]{background:#f7f7f7;margin:5px 0;padding:5px}.swagger-ui select.invalid{-webkit-animation:shake .4s 1;animation:shake .4s 1;background:#feebeb;border-color:#f93e3e}.swagger-ui .opblock-body select{min-width:230px}@media (max-width:768px){.swagger-ui .opblock-body select{min-width:180px}}.swagger-ui label{color:#3b4151;font-family:sans-serif;font-size:12px;font-weight:700;margin:0 0 5px}@media (max-width:768px){.swagger-ui input[type=email],.swagger-ui input[type=file],.swagger-ui input[type=password],.swagger-ui input[type=search],.swagger-ui input[type=text]{max-width:175px}}.swagger-ui input[type=email],.swagger-ui input[type=file],.swagger-ui input[type=password],.swagger-ui input[type=search],.swagger-ui input[type=text],.swagger-ui textarea{background:#fff;border:1px solid #d9d9d9;border-radius:4px;margin:5px 0;min-width:100px;padding:8px 10px}.swagger-ui input[type=email].invalid,.swagger-ui input[type=file].invalid,.swagger-ui input[type=password].invalid,.swagger-ui input[type=search].invalid,.swagger-ui input[type=text].invalid,.swagger-ui textarea.invalid{-webkit-animation:shake .4s 1;animation:shake .4s 1;background:#feebeb;border-color:#f93e3e}.swagger-ui input[disabled],.swagger-ui select[disabled],.swagger-ui textarea[disabled]{background-color:#fafafa;color:#888;cursor:not-allowed}.swagger-ui select[disabled]{border-color:#888}.swagger-ui textarea[disabled]{background-color:#41444e;color:#fff}@-webkit-keyframes shake{10%,90%{transform:translate3d(-1px,0,0)}20%,80%{transform:translate3d(2px,0,0)}30%,50%,70%{transform:translate3d(-4px,0,0)}40%,60%{transform:translate3d(4px,0,0)}}@keyframes shake{10%,90%{transform:translate3d(-1px,0,0)}20%,80%{transform:translate3d(2px,0,0)}30%,50%,70%{transform:translate3d(-4px,0,0)}40%,60%{transform:translate3d(4px,0,0)}}.swagger-ui textarea{background:hsla(0,0%,100%,.8);border:none;border-radius:4px;color:#3b4151;font-family:monospace;font-size:12px;font-weight:600;min-height:280px;outline:none;padding:10px;width:100%}.swagger-ui textarea:focus{border:2px solid #61affe}.swagger-ui textarea.curl{background:#41444e;border-radius:4px;color:#fff;font-family:monospace;font-size:12px;font-weight:600;margin:0;min-height:100px;padding:10px;resize:none}.swagger-ui .checkbox{color:#303030;padding:5px 0 10px;transition:opacity .5s}.swagger-ui .checkbox label{display:flex}.swagger-ui .checkbox p{color:#3b4151;font-family:monospace;font-style:italic;font-weight:400!important;font-weight:600;margin:0!important}.swagger-ui .checkbox input[type=checkbox]{display:none}.swagger-ui .checkbox input[type=checkbox]+label>.item{background:#e8e8e8;border-radius:1px;box-shadow:0 0 0 2px #e8e8e8;cursor:pointer;display:inline-block;flex:none;height:16px;margin:0 8px 0 0;padding:5px;position:relative;top:3px;width:16px}.swagger-ui .checkbox input[type=checkbox]+label>.item:active{transform:scale(.9)}.swagger-ui .checkbox input[type=checkbox]:checked+label>.item{background:#e8e8e8 url('data:image/svg+xml;charset=utf-8,') 50% no-repeat}.swagger-ui .dialog-ux{bottom:0;left:0;position:fixed;right:0;top:0;z-index:9999}.swagger-ui .dialog-ux .backdrop-ux{background:rgba(0,0,0,.8);bottom:0;left:0;position:fixed;right:0;top:0}.swagger-ui .dialog-ux .modal-ux{background:#fff;border:1px solid #ebebeb;border-radius:4px;box-shadow:0 10px 30px 0 rgba(0,0,0,.2);left:50%;max-width:650px;min-width:300px;position:absolute;top:50%;transform:translate(-50%,-50%);width:100%;z-index:9999}.swagger-ui .dialog-ux .modal-ux-content{max-height:540px;overflow-y:auto;padding:20px}.swagger-ui .dialog-ux .modal-ux-content p{color:#41444e;color:#3b4151;font-family:sans-serif;font-size:12px;margin:0 0 5px}.swagger-ui .dialog-ux .modal-ux-content h4{color:#3b4151;font-family:sans-serif;font-size:18px;font-weight:600;margin:15px 0 0}.swagger-ui .dialog-ux .modal-ux-header{align-items:center;border-bottom:1px solid #ebebeb;display:flex;padding:12px 0}.swagger-ui .dialog-ux .modal-ux-header .close-modal{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:none;border:none;padding:0 10px}.swagger-ui .dialog-ux .modal-ux-header h3{color:#3b4151;flex:1;font-family:sans-serif;font-size:20px;font-weight:600;margin:0;padding:0 20px}.swagger-ui .model{color:#3b4151;font-family:monospace;font-size:12px;font-weight:300;font-weight:600}.swagger-ui .model .deprecated span,.swagger-ui .model .deprecated td{color:#a0a0a0!important}.swagger-ui .model .deprecated>td:first-of-type{text-decoration:line-through}.swagger-ui .model-toggle{cursor:pointer;display:inline-block;font-size:10px;margin:auto .3em;position:relative;top:6px;transform:rotate(90deg);transform-origin:50% 50%;transition:transform .15s ease-in}.swagger-ui .model-toggle.collapsed{transform:rotate(0deg)}.swagger-ui .model-toggle:after{background:url('data:image/svg+xml;charset=utf-8,') 50% no-repeat;background-size:100%;content:"";display:block;height:20px;width:20px}.swagger-ui .model-jump-to-path{cursor:pointer;position:relative}.swagger-ui .model-jump-to-path .view-line-link{cursor:pointer;position:absolute;top:-.4em}.swagger-ui .model-title{position:relative}.swagger-ui .model-title:hover .model-hint{visibility:visible}.swagger-ui .model-hint{background:rgba(0,0,0,.7);border-radius:4px;color:#ebebeb;padding:.1em .5em;position:absolute;top:-1.8em;visibility:hidden;white-space:nowrap}.swagger-ui .model p{margin:0 0 1em}.swagger-ui .model .property{color:#999;font-style:italic}.swagger-ui .model .property.primitive{color:#6b6b6b}.swagger-ui table.model tr.description{color:#666;font-weight:400}.swagger-ui table.model tr.description td:first-child,.swagger-ui table.model tr.property-row.required td:first-child{font-weight:700}.swagger-ui table.model tr.property-row td{vertical-align:top}.swagger-ui table.model tr.property-row td:first-child{padding-right:.2em}.swagger-ui table.model tr.property-row .star{color:red}.swagger-ui table.model tr.extension{color:#777}.swagger-ui table.model tr.extension td:last-child{vertical-align:top}.swagger-ui section.models{border:1px solid rgba(59,65,81,.3);border-radius:4px;margin:30px 0}.swagger-ui section.models .pointer{cursor:pointer}.swagger-ui section.models.is-open{padding:0 0 20px}.swagger-ui section.models.is-open h4{border-bottom:1px solid rgba(59,65,81,.3);margin:0 0 5px}.swagger-ui section.models h4{align-items:center;color:#606060;cursor:pointer;display:flex;font-family:sans-serif;font-size:16px;margin:0;padding:10px 20px 10px 10px;transition:all .2s}.swagger-ui section.models h4 svg{transition:all .4s}.swagger-ui section.models h4 span{flex:1}.swagger-ui section.models h4:hover{background:rgba(0,0,0,.02)}.swagger-ui section.models h5{color:#707070;font-family:sans-serif;font-size:16px;margin:0 0 10px}.swagger-ui section.models .model-jump-to-path{position:relative;top:5px}.swagger-ui section.models .model-container{background:rgba(0,0,0,.05);border-radius:4px;margin:0 20px 15px;position:relative;transition:all .5s}.swagger-ui section.models .model-container:hover{background:rgba(0,0,0,.07)}.swagger-ui section.models .model-container:first-of-type{margin:20px}.swagger-ui section.models .model-container:last-of-type{margin:0 20px}.swagger-ui section.models .model-container .models-jump-to-path{opacity:.65;position:absolute;right:5px;top:8px}.swagger-ui section.models .model-box{background:none}.swagger-ui .model-box{background:rgba(0,0,0,.1);border-radius:4px;display:inline-block;padding:10px}.swagger-ui .model-box .model-jump-to-path{position:relative;top:4px}.swagger-ui .model-box.deprecated{opacity:.5}.swagger-ui .model-title{color:#505050;font-family:sans-serif;font-size:16px}.swagger-ui .model-title img{bottom:0;margin-left:1em;position:relative}.swagger-ui .model-deprecated-warning{color:#f93e3e;font-family:sans-serif;font-size:16px;font-weight:600;margin-right:1em}.swagger-ui span>span.model .brace-close{padding:0 0 0 10px}.swagger-ui .prop-name{display:inline-block;margin-right:1em}.swagger-ui .prop-type{color:#55a}.swagger-ui .prop-enum{display:block}.swagger-ui .prop-format{color:#606060}.swagger-ui .servers>label{color:#3b4151;font-family:sans-serif;font-size:12px;margin:-20px 15px 0 0}.swagger-ui .servers>label select{max-width:100%;min-width:130px}.swagger-ui .servers h4.message{padding-bottom:2em}.swagger-ui .servers table tr{width:30em}.swagger-ui .servers table td{display:inline-block;max-width:15em;padding-bottom:10px;padding-top:10px;vertical-align:middle}.swagger-ui .servers table td:first-of-type{padding-right:1em}.swagger-ui .servers table td input{height:100%;width:100%}.swagger-ui .servers .computed-url{margin:2em 0}.swagger-ui .servers .computed-url code{display:inline-block;font-size:16px;margin:0 1em;padding:4px}.swagger-ui .servers-title{font-size:12px;font-weight:700}.swagger-ui .operation-servers h4.message{margin-bottom:2em}.swagger-ui table{border-collapse:collapse;padding:0 10px;width:100%}.swagger-ui table.model tbody tr td{padding:0;vertical-align:top}.swagger-ui table.model tbody tr td:first-of-type{padding:0 0 0 2em;width:174px}.swagger-ui table.headers td{color:#3b4151;font-family:monospace;font-size:12px;font-weight:300;font-weight:600;vertical-align:middle}.swagger-ui table.headers .header-example{color:#999;font-style:italic}.swagger-ui table tbody tr td{padding:10px 0 0;vertical-align:top}.swagger-ui table tbody tr td:first-of-type{min-width:6em;padding:10px 0}.swagger-ui table thead tr td,.swagger-ui table thead tr th{border-bottom:1px solid rgba(59,65,81,.2);color:#3b4151;font-family:sans-serif;font-size:12px;font-weight:700;padding:12px 0;text-align:left}.swagger-ui .parameters-col_description{margin-bottom:2em;width:99%}.swagger-ui .parameters-col_description input[type=text]{max-width:340px;width:100%}.swagger-ui .parameters-col_description select{border-width:1px}.swagger-ui .parameter__name{color:#3b4151;font-family:sans-serif;font-size:16px;font-weight:400;margin-right:.75em}.swagger-ui .parameter__name.required{font-weight:700}.swagger-ui .parameter__name.required span{color:red}.swagger-ui .parameter__name.required:after{color:rgba(255,0,0,.6);content:"required";font-size:10px;padding:5px;position:relative;top:-6px}.swagger-ui .parameter__extension,.swagger-ui .parameter__in{color:gray;font-family:monospace;font-size:12px;font-style:italic;font-weight:600}.swagger-ui .parameter__deprecated{color:red;font-family:monospace;font-size:12px;font-style:italic;font-weight:600}.swagger-ui .parameter__empty_value_toggle{display:block;font-size:13px;padding-bottom:12px;padding-top:5px}.swagger-ui .parameter__empty_value_toggle input{margin-right:7px}.swagger-ui .parameter__empty_value_toggle.disabled{opacity:.7}.swagger-ui .table-container{padding:20px}.swagger-ui .response-col_description{width:99%}.swagger-ui .response-col_links{min-width:6em}.swagger-ui .response__extension{color:gray;font-family:monospace;font-size:12px;font-style:italic;font-weight:600}.swagger-ui .topbar{background-color:#1b1b1b;padding:10px 0}.swagger-ui .topbar .topbar-wrapper,.swagger-ui .topbar a{align-items:center;display:flex}.swagger-ui .topbar a{color:#fff;flex:1;font-family:sans-serif;font-size:1.5em;font-weight:700;max-width:300px;text-decoration:none}.swagger-ui .topbar a span{margin:0;padding:0 10px}.swagger-ui .topbar .download-url-wrapper{display:flex;flex:3;justify-content:flex-end}.swagger-ui .topbar .download-url-wrapper input[type=text]{border:2px solid #62a03f;border-radius:4px 0 0 4px;margin:0;outline:none;width:100%}.swagger-ui .topbar .download-url-wrapper .select-label{align-items:center;color:#f0f0f0;display:flex;margin:0;max-width:600px;width:100%}.swagger-ui .topbar .download-url-wrapper .select-label span{flex:1;font-size:16px;padding:0 10px 0 0;text-align:right}.swagger-ui .topbar .download-url-wrapper .select-label select{border:2px solid #62a03f;box-shadow:none;flex:2;outline:none;width:100%}.swagger-ui .topbar .download-url-wrapper .download-url-button{background:#62a03f;border:none;border-radius:0 4px 4px 0;color:#fff;font-family:sans-serif;font-size:16px;font-weight:700;padding:4px 30px}.swagger-ui .info{margin:50px 0}.swagger-ui .info.failed-config{margin-left:auto;margin-right:auto;max-width:880px;text-align:center}.swagger-ui .info hgroup.main{margin:0 0 20px}.swagger-ui .info hgroup.main a{font-size:12px}.swagger-ui .info pre{font-size:14px}.swagger-ui .info li,.swagger-ui .info p,.swagger-ui .info table{color:#3b4151;font-family:sans-serif;font-size:14px}.swagger-ui .info h1,.swagger-ui .info h2,.swagger-ui .info h3,.swagger-ui .info h4,.swagger-ui .info h5{color:#3b4151;font-family:sans-serif}.swagger-ui .info a{color:#4990e2;font-family:sans-serif;font-size:14px;transition:all .4s}.swagger-ui .info a:hover{color:#1f69c0}.swagger-ui .info>div{margin:0 0 5px}.swagger-ui .info .base-url{color:#3b4151;font-family:monospace;font-size:12px;font-weight:300!important;font-weight:600;margin:0}.swagger-ui .info .title{color:#3b4151;font-family:sans-serif;font-size:36px;margin:0}.swagger-ui .info .title small{background:#7d8492;border-radius:57px;display:inline-block;font-size:10px;margin:0 0 0 5px;padding:2px 4px;position:relative;top:-5px;vertical-align:super}.swagger-ui .info .title small.version-stamp{background-color:#89bf04}.swagger-ui .info .title small pre{color:#fff;font-family:sans-serif;margin:0;padding:0}.swagger-ui .auth-btn-wrapper{display:flex;justify-content:center;padding:10px 0}.swagger-ui .auth-btn-wrapper .btn-done{margin-right:1em}.swagger-ui .auth-wrapper{display:flex;flex:1;justify-content:flex-end}.swagger-ui .auth-wrapper .authorize{margin-right:10px;padding-right:20px}.swagger-ui .auth-container{border-bottom:1px solid #ebebeb;margin:0 0 10px;padding:10px 20px}.swagger-ui .auth-container:last-of-type{border:0;margin:0;padding:10px 20px}.swagger-ui .auth-container h4{margin:5px 0 15px!important}.swagger-ui .auth-container .wrapper{margin:0;padding:0}.swagger-ui .auth-container input[type=password],.swagger-ui .auth-container input[type=text]{min-width:230px}.swagger-ui .auth-container .errors{background-color:#fee;border-radius:4px;color:red;color:#3b4151;font-family:monospace;font-size:12px;font-weight:600;margin:1em;padding:10px}.swagger-ui .auth-container .errors b{margin-right:1em;text-transform:capitalize}.swagger-ui .scopes h2{color:#3b4151;font-family:sans-serif;font-size:14px}.swagger-ui .scopes h2 a{color:#4990e2;cursor:pointer;font-size:12px;padding-left:10px;text-decoration:underline}.swagger-ui .scope-def{padding:0 0 20px}.swagger-ui .errors-wrapper{-webkit-animation:scaleUp .5s;animation:scaleUp .5s;background:rgba(249,62,62,.1);border:2px solid #f93e3e;border-radius:4px;margin:20px;padding:10px 20px}.swagger-ui .errors-wrapper .error-wrapper{margin:0 0 10px}.swagger-ui .errors-wrapper .errors h4{color:#3b4151;font-family:monospace;font-size:14px;font-weight:600;margin:0}.swagger-ui .errors-wrapper .errors small{color:#606060}.swagger-ui .errors-wrapper .errors .message{white-space:pre-line}.swagger-ui .errors-wrapper .errors .message.thrown{max-width:100%}.swagger-ui .errors-wrapper .errors .error-line{cursor:pointer;text-decoration:underline}.swagger-ui .errors-wrapper hgroup{align-items:center;display:flex}.swagger-ui .errors-wrapper hgroup h4{color:#3b4151;flex:1;font-family:sans-serif;font-size:20px;margin:0}@-webkit-keyframes scaleUp{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes scaleUp{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}.swagger-ui .Resizer.vertical.disabled{display:none}.swagger-ui .markdown p,.swagger-ui .markdown pre,.swagger-ui .renderedMarkdown p,.swagger-ui .renderedMarkdown pre{margin:1em auto;word-break:break-all;word-break:break-word}.swagger-ui .markdown pre,.swagger-ui .renderedMarkdown pre{background:none;color:#000;font-weight:400;padding:0;white-space:pre-wrap}.swagger-ui .markdown code,.swagger-ui .renderedMarkdown code{background:rgba(0,0,0,.05);border-radius:4px;color:#9012fe;font-family:monospace;font-size:14px;font-weight:600;padding:5px 7px}.swagger-ui .markdown pre>code,.swagger-ui .renderedMarkdown pre>code{display:block} - -/*# sourceMappingURL=swagger-ui.css.map*/ \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-swagger-keycloak/src/main/resources/application.yml b/spring-boot-modules/spring-boot-swagger-keycloak/src/main/resources/application.yml index 5d3c8b3af5..7d1618b4e7 100644 --- a/spring-boot-modules/spring-boot-swagger-keycloak/src/main/resources/application.yml +++ b/spring-boot-modules/spring-boot-swagger-keycloak/src/main/resources/application.yml @@ -1,8 +1,19 @@ +server: + port: 8081 + keycloak: - auth-server-url: https://api.example.com/auth # Keycloak server url - realm: todos-service-realm # Keycloak Realm - resource: todos-service-clients # Keycloak Client - principal-attribute: preferred_username - ssl-required: external - credentials: - secret: 00000000-0000-0000-0000-000000000000 + auth-server-url: http://localhost:8080 # Keycloak server url + realm: SpringBootKeycloak # Keycloak Realm + +spring: + security: + oauth2: + resourceserver: + jwt.issuer-uri: http://localhost:8080/realms/SpringBootKeycloak + +springdoc: + swagger-ui: + oauth: + client-id: login-app + + diff --git a/spring-boot-modules/spring-boot-testing/pom.xml b/spring-boot-modules/spring-boot-testing/pom.xml index 7eadfd9b24..ace6307761 100644 --- a/spring-boot-modules/spring-boot-testing/pom.xml +++ b/spring-boot-modules/spring-boot-testing/pom.xml @@ -147,8 +147,8 @@ com.baeldung.boot.Application 2.2.4 - 2.4-M1-groovy-3.0 - 2.0.0 + 2.4-M1-groovy-4.0 + 2.1.0 3.10.1 0.7.2 2.5.0 diff --git a/spring-boot-modules/spring-caching/README.md b/spring-boot-modules/spring-caching/README.md index e10d6080e8..4994c22c0b 100644 --- a/spring-boot-modules/spring-caching/README.md +++ b/spring-boot-modules/spring-caching/README.md @@ -6,3 +6,4 @@ - [Using Multiple Cache Managers in Spring](https://www.baeldung.com/spring-multiple-cache-managers) - [Testing @Cacheable on Spring Data Repositories](https://www.baeldung.com/spring-data-testing-cacheable) - [Spring Boot Ehcache Example](https://www.baeldung.com/spring-boot-ehcache) +- [Get All Cached Keys with Caffeine Cache in Spring Boot](https://www.baeldung.com/spring-boot-caffeine-spring-get-all-keys) diff --git a/spring-core-2/.gitignore b/spring-core-2/.gitignore deleted file mode 100644 index 83c05e60c8..0000000000 --- a/spring-core-2/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -*.class - -#folders# -/target -/neoDb* -/data -/src/main/webapp/WEB-INF/classes -*/META-INF/* - -# Packaged files # -*.jar -*.war -*.ear \ No newline at end of file diff --git a/spring-core-2/README.md b/spring-core-2/README.md index 18e4e32d1f..80ae54b2a4 100644 --- a/spring-core-2/README.md +++ b/spring-core-2/README.md @@ -6,4 +6,9 @@ This module contains articles about core Spring functionality - [Quick Guide to Spring Bean Scopes](http://www.baeldung.com/spring-bean-scopes) - [Spring Events](https://www.baeldung.com/spring-events) +- [Solving Spring’s “not eligible for auto-proxying” Warning](https://www.baeldung.com/spring-not-eligible-for-auto-proxying) +- [Finding the Spring Version](https://www.baeldung.com/spring-find-version) +- [How Does the Spring Singleton Bean Serve Concurrent Requests?](https://www.baeldung.com/spring-singleton-concurrent-requests) +- [Reinitialize Singleton Bean in Spring Context](https://www.baeldung.com/spring-reinitialize-singleton-bean) +- [Getting the Current ApplicationContext in Spring](https://www.baeldung.com/spring-get-current-applicationcontext) - More articles: [[<-- prev]](/spring-core)[[next -->]](/spring-core-3) diff --git a/spring-core-2/pom.xml b/spring-core-2/pom.xml index d05090fa6b..bab47cb70c 100644 --- a/spring-core-2/pom.xml +++ b/spring-core-2/pom.xml @@ -15,29 +15,15 @@ ../parent-boot-2 - - - - org.springframework - spring-framework-bom - ${org.springframework.version} - pom - import - - - org.springframework - spring-core - ${org.springframework.version} - - - org.springframework.boot - spring-boot-starter-thymeleaf - ${org.springframework.version} - - - - + + org.springframework.boot + spring-boot-starter + + + org.springframework.boot + spring-boot-starter-web + com.fasterxml.jackson.core jackson-databind @@ -129,6 +115,11 @@ spring-test test + + org.springframework.boot + spring-boot-starter-test + test + net.javacrumbs.shedlock @@ -140,6 +131,10 @@ shedlock-provider-jdbc-template ${shedlock.version} + + org.projectlombok + lombok + @@ -164,8 +159,6 @@ com.baeldung.sample.App - - 5.3.0 1.3.2 5.2.5.Final diff --git a/spring-core-6/src/main/java/com/baeldung/applicationcontext/ApplicationContextProvider.java b/spring-core-2/src/main/java/com/baeldung/applicationcontext/ApplicationContextProvider.java similarity index 100% rename from spring-core-6/src/main/java/com/baeldung/applicationcontext/ApplicationContextProvider.java rename to spring-core-2/src/main/java/com/baeldung/applicationcontext/ApplicationContextProvider.java diff --git a/spring-core-6/src/main/java/com/baeldung/applicationcontext/ItemService.java b/spring-core-2/src/main/java/com/baeldung/applicationcontext/ItemService.java similarity index 100% rename from spring-core-6/src/main/java/com/baeldung/applicationcontext/ItemService.java rename to spring-core-2/src/main/java/com/baeldung/applicationcontext/ItemService.java diff --git a/spring-core-6/src/main/java/com/baeldung/applicationcontext/MyBean.java b/spring-core-2/src/main/java/com/baeldung/applicationcontext/MyBean.java similarity index 100% rename from spring-core-6/src/main/java/com/baeldung/applicationcontext/MyBean.java rename to spring-core-2/src/main/java/com/baeldung/applicationcontext/MyBean.java diff --git a/spring-core-5/src/main/java/com/baeldung/component/autoproxying/DataCache.java b/spring-core-2/src/main/java/com/baeldung/component/autoproxying/DataCache.java similarity index 100% rename from spring-core-5/src/main/java/com/baeldung/component/autoproxying/DataCache.java rename to spring-core-2/src/main/java/com/baeldung/component/autoproxying/DataCache.java diff --git a/spring-core-5/src/main/java/com/baeldung/component/autoproxying/EligibleForAutoProxyRandomIntProcessor.java b/spring-core-2/src/main/java/com/baeldung/component/autoproxying/EligibleForAutoProxyRandomIntProcessor.java similarity index 100% rename from spring-core-5/src/main/java/com/baeldung/component/autoproxying/EligibleForAutoProxyRandomIntProcessor.java rename to spring-core-2/src/main/java/com/baeldung/component/autoproxying/EligibleForAutoProxyRandomIntProcessor.java diff --git a/spring-core-5/src/main/java/com/baeldung/component/autoproxying/NotEligibleForAutoProxyRandomIntProcessor.java b/spring-core-2/src/main/java/com/baeldung/component/autoproxying/NotEligibleForAutoProxyRandomIntProcessor.java similarity index 100% rename from spring-core-5/src/main/java/com/baeldung/component/autoproxying/NotEligibleForAutoProxyRandomIntProcessor.java rename to spring-core-2/src/main/java/com/baeldung/component/autoproxying/NotEligibleForAutoProxyRandomIntProcessor.java diff --git a/spring-core-5/src/main/java/com/baeldung/component/autoproxying/RandomInt.java b/spring-core-2/src/main/java/com/baeldung/component/autoproxying/RandomInt.java similarity index 100% rename from spring-core-5/src/main/java/com/baeldung/component/autoproxying/RandomInt.java rename to spring-core-2/src/main/java/com/baeldung/component/autoproxying/RandomInt.java diff --git a/spring-core-5/src/main/java/com/baeldung/component/autoproxying/RandomIntGenerator.java b/spring-core-2/src/main/java/com/baeldung/component/autoproxying/RandomIntGenerator.java similarity index 100% rename from spring-core-5/src/main/java/com/baeldung/component/autoproxying/RandomIntGenerator.java rename to spring-core-2/src/main/java/com/baeldung/component/autoproxying/RandomIntGenerator.java diff --git a/spring-core-5/src/main/java/com/baeldung/concurrentrequest/ConcurrentRequestApplication.java b/spring-core-2/src/main/java/com/baeldung/concurrentrequest/ConcurrentRequestApplication.java similarity index 100% rename from spring-core-5/src/main/java/com/baeldung/concurrentrequest/ConcurrentRequestApplication.java rename to spring-core-2/src/main/java/com/baeldung/concurrentrequest/ConcurrentRequestApplication.java diff --git a/spring-core-5/src/main/java/com/baeldung/concurrentrequest/Product.java b/spring-core-2/src/main/java/com/baeldung/concurrentrequest/Product.java similarity index 100% rename from spring-core-5/src/main/java/com/baeldung/concurrentrequest/Product.java rename to spring-core-2/src/main/java/com/baeldung/concurrentrequest/Product.java diff --git a/spring-core-5/src/main/java/com/baeldung/concurrentrequest/ProductController.java b/spring-core-2/src/main/java/com/baeldung/concurrentrequest/ProductController.java similarity index 100% rename from spring-core-5/src/main/java/com/baeldung/concurrentrequest/ProductController.java rename to spring-core-2/src/main/java/com/baeldung/concurrentrequest/ProductController.java diff --git a/spring-core-5/src/main/java/com/baeldung/concurrentrequest/ProductService.java b/spring-core-2/src/main/java/com/baeldung/concurrentrequest/ProductService.java similarity index 100% rename from spring-core-5/src/main/java/com/baeldung/concurrentrequest/ProductService.java rename to spring-core-2/src/main/java/com/baeldung/concurrentrequest/ProductService.java diff --git a/spring-core-5/src/main/java/com/baeldung/concurrentrequest/Stock.java b/spring-core-2/src/main/java/com/baeldung/concurrentrequest/Stock.java similarity index 100% rename from spring-core-5/src/main/java/com/baeldung/concurrentrequest/Stock.java rename to spring-core-2/src/main/java/com/baeldung/concurrentrequest/Stock.java diff --git a/spring-core-6/src/main/java/com/baeldung/reinitializebean/ReinitializeBeanApp.java b/spring-core-2/src/main/java/com/baeldung/reinitializebean/ReinitializeBeanApp.java similarity index 100% rename from spring-core-6/src/main/java/com/baeldung/reinitializebean/ReinitializeBeanApp.java rename to spring-core-2/src/main/java/com/baeldung/reinitializebean/ReinitializeBeanApp.java diff --git a/spring-core-6/src/main/java/com/baeldung/reinitializebean/cache/ConfigManager.java b/spring-core-2/src/main/java/com/baeldung/reinitializebean/cache/ConfigManager.java similarity index 100% rename from spring-core-6/src/main/java/com/baeldung/reinitializebean/cache/ConfigManager.java rename to spring-core-2/src/main/java/com/baeldung/reinitializebean/cache/ConfigManager.java diff --git a/spring-core-6/src/main/java/com/baeldung/reinitializebean/controller/ConfigController.java b/spring-core-2/src/main/java/com/baeldung/reinitializebean/controller/ConfigController.java similarity index 100% rename from spring-core-6/src/main/java/com/baeldung/reinitializebean/controller/ConfigController.java rename to spring-core-2/src/main/java/com/baeldung/reinitializebean/controller/ConfigController.java diff --git a/spring-core-5/src/main/java/com/baeldung/version/VersionObtainer.java b/spring-core-2/src/main/java/com/baeldung/version/VersionObtainer.java similarity index 96% rename from spring-core-5/src/main/java/com/baeldung/version/VersionObtainer.java rename to spring-core-2/src/main/java/com/baeldung/version/VersionObtainer.java index 392cc44a72..e0e28c6181 100644 --- a/spring-core-5/src/main/java/com/baeldung/version/VersionObtainer.java +++ b/spring-core-2/src/main/java/com/baeldung/version/VersionObtainer.java @@ -1,20 +1,20 @@ -package com.baeldung.version; - -import org.springframework.boot.system.JavaVersion; -import org.springframework.boot.system.SystemProperties; -import org.springframework.core.SpringVersion; - -public class VersionObtainer { - - public String getSpringVersion() { - return SpringVersion.getVersion(); - } - - public String getJavaVersion() { - return JavaVersion.getJavaVersion().toString(); - } - - public String getJdkVersion() { - return SystemProperties.get("java.version"); - } -} +package com.baeldung.version; + +import org.springframework.boot.system.JavaVersion; +import org.springframework.boot.system.SystemProperties; +import org.springframework.core.SpringVersion; + +public class VersionObtainer { + + public String getSpringVersion() { + return SpringVersion.getVersion(); + } + + public String getJavaVersion() { + return JavaVersion.getJavaVersion().toString(); + } + + public String getJdkVersion() { + return SystemProperties.get("java.version"); + } +} diff --git a/spring-core-2/src/main/resources/application.properties b/spring-core-2/src/main/resources/application.properties index e69de29bb2..97916eec19 100644 --- a/spring-core-2/src/main/resources/application.properties +++ b/spring-core-2/src/main/resources/application.properties @@ -0,0 +1 @@ +config.file.path=./spring-core-2/src/main/resources/config.properties \ No newline at end of file diff --git a/spring-core-6/src/main/resources/config.properties b/spring-core-2/src/main/resources/config.properties similarity index 100% rename from spring-core-6/src/main/resources/config.properties rename to spring-core-2/src/main/resources/config.properties diff --git a/spring-core-6/src/test/java/com/baeldung/applicationcontext/ApplicationContextProviderUnitTest.java b/spring-core-2/src/test/java/com/baeldung/applicationcontext/ApplicationContextProviderUnitTest.java similarity index 100% rename from spring-core-6/src/test/java/com/baeldung/applicationcontext/ApplicationContextProviderUnitTest.java rename to spring-core-2/src/test/java/com/baeldung/applicationcontext/ApplicationContextProviderUnitTest.java diff --git a/spring-core-6/src/test/java/com/baeldung/applicationcontext/MyBeanUnitTest.java b/spring-core-2/src/test/java/com/baeldung/applicationcontext/MyBeanUnitTest.java similarity index 100% rename from spring-core-6/src/test/java/com/baeldung/applicationcontext/MyBeanUnitTest.java rename to spring-core-2/src/test/java/com/baeldung/applicationcontext/MyBeanUnitTest.java diff --git a/spring-core-6/src/test/java/com/baeldung/applicationcontext/TestContextConfig.java b/spring-core-2/src/test/java/com/baeldung/applicationcontext/TestContextConfig.java similarity index 100% rename from spring-core-6/src/test/java/com/baeldung/applicationcontext/TestContextConfig.java rename to spring-core-2/src/test/java/com/baeldung/applicationcontext/TestContextConfig.java diff --git a/spring-core-5/src/test/java/com/baeldung/component/autoproxying/EligibleForAutoProxyingIntegrationTest.java b/spring-core-2/src/test/java/com/baeldung/component/autoproxying/EligibleForAutoProxyingIntegrationTest.java similarity index 100% rename from spring-core-5/src/test/java/com/baeldung/component/autoproxying/EligibleForAutoProxyingIntegrationTest.java rename to spring-core-2/src/test/java/com/baeldung/component/autoproxying/EligibleForAutoProxyingIntegrationTest.java diff --git a/spring-core-5/src/test/java/com/baeldung/component/autoproxying/MemoryLogAppender.java b/spring-core-2/src/test/java/com/baeldung/component/autoproxying/MemoryLogAppender.java similarity index 100% rename from spring-core-5/src/test/java/com/baeldung/component/autoproxying/MemoryLogAppender.java rename to spring-core-2/src/test/java/com/baeldung/component/autoproxying/MemoryLogAppender.java diff --git a/spring-core-5/src/test/java/com/baeldung/component/autoproxying/NotEligibleForAutoProxyingIntegrationTest.java b/spring-core-2/src/test/java/com/baeldung/component/autoproxying/NotEligibleForAutoProxyingIntegrationTest.java similarity index 100% rename from spring-core-5/src/test/java/com/baeldung/component/autoproxying/NotEligibleForAutoProxyingIntegrationTest.java rename to spring-core-2/src/test/java/com/baeldung/component/autoproxying/NotEligibleForAutoProxyingIntegrationTest.java diff --git a/spring-core-5/src/test/java/com/baeldung/concurrentrequest/ConcurrentRequestManualTest.java b/spring-core-2/src/test/java/com/baeldung/concurrentrequest/ConcurrentRequestManualTest.java similarity index 100% rename from spring-core-5/src/test/java/com/baeldung/concurrentrequest/ConcurrentRequestManualTest.java rename to spring-core-2/src/test/java/com/baeldung/concurrentrequest/ConcurrentRequestManualTest.java diff --git a/spring-core-5/src/test/java/com/baeldung/version/VersionObtainerUnitTest.java b/spring-core-2/src/test/java/com/baeldung/version/VersionObtainerUnitTest.java similarity index 96% rename from spring-core-5/src/test/java/com/baeldung/version/VersionObtainerUnitTest.java rename to spring-core-2/src/test/java/com/baeldung/version/VersionObtainerUnitTest.java index 6d77cd1403..af074d5783 100644 --- a/spring-core-5/src/test/java/com/baeldung/version/VersionObtainerUnitTest.java +++ b/spring-core-2/src/test/java/com/baeldung/version/VersionObtainerUnitTest.java @@ -1,30 +1,30 @@ -package com.baeldung.version; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.junit.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest(classes = VersionObtainer.class) -public class VersionObtainerUnitTest { - - public VersionObtainer version = new VersionObtainer(); - - @Test - public void testGetSpringVersion() { - String res = version.getSpringVersion(); - assertThat(res).isNotEmpty(); - } - - @Test - public void testGetJdkVersion() { - String res = version.getJdkVersion(); - assertThat(res).isNotEmpty(); - } - - @Test - public void testGetJavaVersion() { - String res = version.getJavaVersion(); - assertThat(res).isNotEmpty(); - } -} +package com.baeldung.version; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest(classes = VersionObtainer.class) +public class VersionObtainerUnitTest { + + public VersionObtainer version = new VersionObtainer(); + + @Test + public void testGetSpringVersion() { + String res = version.getSpringVersion(); + assertThat(res).isNotEmpty(); + } + + @Test + public void testGetJdkVersion() { + String res = version.getJdkVersion(); + assertThat(res).isNotEmpty(); + } + + @Test + public void testGetJavaVersion() { + String res = version.getJavaVersion(); + assertThat(res).isNotEmpty(); + } +} diff --git a/spring-core-3/README.md b/spring-core-3/README.md index 394f6e1857..ed88561e10 100644 --- a/spring-core-3/README.md +++ b/spring-core-3/README.md @@ -10,4 +10,5 @@ This module contains articles about core Spring functionality - [Design Patterns in the Spring Framework](https://www.baeldung.com/spring-framework-design-patterns) - [Difference Between BeanFactory and ApplicationContext](https://www.baeldung.com/spring-beanfactory-vs-applicationcontext) - [Custom Scope in Spring](http://www.baeldung.com/spring-custom-scope) +- [The Spring ApplicationContext](https://www.baeldung.com/spring-application-context) - More articles: [[<-- prev]](/spring-core-2) [[next -->]](/spring-core-4) diff --git a/spring-core-4/src/main/java/com/baeldung/applicationcontext/AccountConfig.java b/spring-core-3/src/main/java/com/baeldung/applicationcontext/AccountConfig.java similarity index 100% rename from spring-core-4/src/main/java/com/baeldung/applicationcontext/AccountConfig.java rename to spring-core-3/src/main/java/com/baeldung/applicationcontext/AccountConfig.java diff --git a/spring-core-4/src/main/java/com/baeldung/applicationcontext/AccountRepository.java b/spring-core-3/src/main/java/com/baeldung/applicationcontext/AccountRepository.java similarity index 100% rename from spring-core-4/src/main/java/com/baeldung/applicationcontext/AccountRepository.java rename to spring-core-3/src/main/java/com/baeldung/applicationcontext/AccountRepository.java diff --git a/spring-core-4/src/main/java/com/baeldung/applicationcontext/AccountService.java b/spring-core-3/src/main/java/com/baeldung/applicationcontext/AccountService.java similarity index 100% rename from spring-core-4/src/main/java/com/baeldung/applicationcontext/AccountService.java rename to spring-core-3/src/main/java/com/baeldung/applicationcontext/AccountService.java diff --git a/spring-core-4/src/main/java/com/baeldung/applicationcontext/MyWebApplicationInitializer.java b/spring-core-3/src/main/java/com/baeldung/applicationcontext/MyWebApplicationInitializer.java similarity index 100% rename from spring-core-4/src/main/java/com/baeldung/applicationcontext/MyWebApplicationInitializer.java rename to spring-core-3/src/main/java/com/baeldung/applicationcontext/MyWebApplicationInitializer.java diff --git a/spring-core-4/src/main/java/com/baeldung/applicationcontext/MyXmlWebApplicationInitializer.java b/spring-core-3/src/main/java/com/baeldung/applicationcontext/MyXmlWebApplicationInitializer.java similarity index 100% rename from spring-core-4/src/main/java/com/baeldung/applicationcontext/MyXmlWebApplicationInitializer.java rename to spring-core-3/src/main/java/com/baeldung/applicationcontext/MyXmlWebApplicationInitializer.java diff --git a/spring-core-4/src/main/java/com/baeldung/applicationcontext/UserService.java b/spring-core-3/src/main/java/com/baeldung/applicationcontext/UserService.java similarity index 100% rename from spring-core-4/src/main/java/com/baeldung/applicationcontext/UserService.java rename to spring-core-3/src/main/java/com/baeldung/applicationcontext/UserService.java diff --git a/spring-core-4/src/test/java/com/baeldung/applicationcontext/ApplicationContextUnitTest.java b/spring-core-3/src/test/java/com/baeldung/applicationcontext/ApplicationContextUnitTest.java similarity index 100% rename from spring-core-4/src/test/java/com/baeldung/applicationcontext/ApplicationContextUnitTest.java rename to spring-core-3/src/test/java/com/baeldung/applicationcontext/ApplicationContextUnitTest.java diff --git a/spring-core-4/src/test/resources/applicationcontext/account-bean-config.xml b/spring-core-3/src/test/resources/applicationcontext/account-bean-config.xml similarity index 100% rename from spring-core-4/src/test/resources/applicationcontext/account-bean-config.xml rename to spring-core-3/src/test/resources/applicationcontext/account-bean-config.xml diff --git a/spring-core-4/src/test/resources/applicationcontext/user-bean-config.xml b/spring-core-3/src/test/resources/applicationcontext/user-bean-config.xml similarity index 100% rename from spring-core-4/src/test/resources/applicationcontext/user-bean-config.xml rename to spring-core-3/src/test/resources/applicationcontext/user-bean-config.xml diff --git a/spring-core-4/src/test/resources/config/messages.properties b/spring-core-3/src/test/resources/config/messages.properties similarity index 100% rename from spring-core-4/src/test/resources/config/messages.properties rename to spring-core-3/src/test/resources/config/messages.properties diff --git a/spring-core-4/README.md b/spring-core-4/README.md index 6ade284e2e..a0f5ac97f9 100644 --- a/spring-core-4/README.md +++ b/spring-core-4/README.md @@ -6,5 +6,4 @@ This module contains articles about core Spring functionality - [Creating Spring Beans Through Factory Methods](https://www.baeldung.com/spring-beans-factory-methods) - [Spring BeanPostProcessor](https://www.baeldung.com/spring-beanpostprocessor) -- [The Spring ApplicationContext](https://www.baeldung.com/spring-application-context) -- More articles: [[<-- prev]](/spring-core-3) [[next -->]](/spring-core-5) +- More articles: [[<-- prev]](/spring-core-3) diff --git a/spring-core-5/README.md b/spring-core-5/README.md deleted file mode 100644 index cfcbf5380a..0000000000 --- a/spring-core-5/README.md +++ /dev/null @@ -1,10 +0,0 @@ -## Spring Core - -This module contains articles about core Spring functionality. - -## Relevant Articles: - -- [Solving Spring’s “not eligible for auto-proxying” Warning](https://www.baeldung.com/spring-not-eligible-for-auto-proxying) -- [Finding the Spring Version](https://www.baeldung.com/spring-find-version) -- [How Does the Spring Singleton Bean Serve Concurrent Requests?](https://www.baeldung.com/spring-singleton-concurrent-requests) -- More articles: [[<-- prev]](../spring-core-4) diff --git a/spring-core-5/pom.xml b/spring-core-5/pom.xml deleted file mode 100644 index 1c2e80be44..0000000000 --- a/spring-core-5/pom.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - 4.0.0 - spring-core-5 - spring-core-5 - - - com.baeldung - parent-spring-5 - 0.0.1-SNAPSHOT - ../parent-spring-5 - - - - - org.springframework.boot - spring-boot-starter - ${spring-boot-starter.version} - - - org.springframework.boot - spring-boot-starter-web - ${spring-boot-starter.version} - - - org.springframework.boot - spring-boot-starter-test - ${spring-boot-starter.version} - test - - - org.projectlombok - lombok - ${lombok.version} - - - - - 5.3.3 - 2.4.2 - - - \ No newline at end of file diff --git a/spring-core-5/src/main/resources/application.yml b/spring-core-5/src/main/resources/application.yml deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/spring-core-5/src/test/resources/application.yml b/spring-core-5/src/test/resources/application.yml deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/spring-core-5/src/test/resources/logback-test.xml b/spring-core-5/src/test/resources/logback-test.xml deleted file mode 100644 index 8d4771e308..0000000000 --- a/spring-core-5/src/test/resources/logback-test.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n - - - - - - - \ No newline at end of file diff --git a/spring-core-6/README.md b/spring-core-6/README.md deleted file mode 100644 index 1879ff9a68..0000000000 --- a/spring-core-6/README.md +++ /dev/null @@ -1,5 +0,0 @@ - -### Relevant Articles: -- [Reinitialize Singleton Bean in Spring Context](https://www.baeldung.com/spring-reinitialize-singleton-bean) -- [Getting the Current ApplicationContext in Spring](https://www.baeldung.com/spring-get-current-applicationcontext) -- More articles: [[<-- prev]](../spring-core-5) \ No newline at end of file diff --git a/spring-core-6/pom.xml b/spring-core-6/pom.xml deleted file mode 100644 index 736fa283e7..0000000000 --- a/spring-core-6/pom.xml +++ /dev/null @@ -1,95 +0,0 @@ - - - 4.0.0 - com.baeldung - spring-core-6 - 0.0.1-SNAPSHOT - spring-core-6 - http://www.baeldung.com - - - com.baeldung - parent-boot-3 - 0.0.1-SNAPSHOT - ../parent-boot-3 - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-test - test - - - io.projectreactor - reactor-test - test - - - - - - - - maven-clean-plugin - 3.1.0 - - - maven-resources-plugin - 3.0.2 - - - maven-compiler-plugin - 3.8.0 - - - maven-surefire-plugin - 2.22.1 - - - maven-jar-plugin - 3.0.2 - - - maven-install-plugin - 2.5.2 - - - maven-deploy-plugin - 2.8.2 - - - maven-site-plugin - 3.7.1 - - - maven-project-info-reports-plugin - 3.0.0 - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 17 - 17 - - - - - - - UTF-8 - 17 - 17 - - - \ No newline at end of file diff --git a/spring-core-6/src/main/resources/application.properties b/spring-core-6/src/main/resources/application.properties deleted file mode 100644 index 6545cd1097..0000000000 --- a/spring-core-6/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -config.file.path=./spring-core-6/src/main/resources/config.properties \ No newline at end of file diff --git a/spring-reactive-modules/spring-5-reactive-3/README.md b/spring-reactive-modules/spring-5-reactive-3/README.md index 24a7c43ad3..38036f929b 100644 --- a/spring-reactive-modules/spring-5-reactive-3/README.md +++ b/spring-reactive-modules/spring-5-reactive-3/README.md @@ -5,4 +5,5 @@ This module contains articles about reactive Spring 5. - [Logging a Reactive Sequence](https://www.baeldung.com/spring-reactive-sequence-logging) - [Reading Flux Into a Single InputStream Using Spring Reactive WebClient](https://www.baeldung.com/spring-reactive-read-flux-into-inputstream) - [Spring Boot FeignClient vs. WebClient](https://www.baeldung.com/spring-boot-feignclient-vs-webclient) +- [Cancel an Ongoing Flux in Spring WebFlux](https://www.baeldung.com/spring-webflux-cancel-flux) - More articles: [[<-- prev]](../spring-5-reactive-2) diff --git a/spring-reactive-modules/spring-5-reactive-3/src/test/java/com/baeldung/cancelflux/CancelFluxUnitTest.java b/spring-reactive-modules/spring-5-reactive-3/src/test/java/com/baeldung/cancelflux/CancelFluxUnitTest.java index 609dbfcf73..e360c2d5e4 100644 --- a/spring-reactive-modules/spring-5-reactive-3/src/test/java/com/baeldung/cancelflux/CancelFluxUnitTest.java +++ b/spring-reactive-modules/spring-5-reactive-3/src/test/java/com/baeldung/cancelflux/CancelFluxUnitTest.java @@ -79,7 +79,7 @@ public class CancelFluxUnitTest { count.incrementAndGet(); }, e -> System.err.println("Error: " + e.getMessage())); - Thread.sleep(5000); + Thread.sleep(4500); System.out.println("Will Dispose The flux Next"); disposable.dispose(); if (disposable.isDisposed()) { diff --git a/spring-reactive-modules/spring-reactive-exceptions/src/main/resources/application.yaml b/spring-reactive-modules/spring-reactive-exceptions/src/main/resources/application.yaml index 50bcbff433..935ab2a263 100644 --- a/spring-reactive-modules/spring-reactive-exceptions/src/main/resources/application.yaml +++ b/spring-reactive-modules/spring-reactive-exceptions/src/main/resources/application.yaml @@ -1,7 +1,3 @@ -spring: - codec: - max-in-memory-size: 500KB - server: port: 8080 host: http://localhost:${server.port} diff --git a/spring-security-modules/spring-security-web-boot-2/README.md b/spring-security-modules/spring-security-web-boot-2/README.md index f5fc3a890d..c768ba924b 100644 --- a/spring-security-modules/spring-security-web-boot-2/README.md +++ b/spring-security-modules/spring-security-web-boot-2/README.md @@ -14,4 +14,5 @@ The "REST With Spring" Classes: http://github.learnspringsecurity.com - [Spring Security: Exploring JDBC Authentication](https://www.baeldung.com/spring-security-jdbc-authentication) - [Spring Security Custom Logout Handler](https://www.baeldung.com/spring-security-custom-logout-handler) - [Redirecting Logged-in Users with Spring Security](https://www.baeldung.com/spring-security-redirect-logged-in) -- More articles: [[<-- prev]](/spring-security-modules/spring-security-web-boot-1) + +More articles: [[<-- prev]](/spring-security-modules/spring-security-web-boot-1) [[next -->]](/spring-security-modules/spring-security-web-boot-3) diff --git a/spring-security-modules/spring-security-web-boot-3/README.md b/spring-security-modules/spring-security-web-boot-3/README.md index 400039dbfe..830abd2c99 100644 --- a/spring-security-modules/spring-security-web-boot-3/README.md +++ b/spring-security-modules/spring-security-web-boot-3/README.md @@ -14,4 +14,5 @@ The "REST With Spring" Classes: http://github.learnspringsecurity.com - [Content Security Policy with Spring Security](https://www.baeldung.com/spring-security-csp) - [Enable Logging for Spring Security](https://www.baeldung.com/spring-security-enable-logging) - [Authentication With Spring Security and MongoDB](https://www.baeldung.com/spring-security-authentication-mongodb) -- More articles: [[<-- prev]](/spring-security-modules/spring-security-web-boot-2) + +More articles: [[<-- prev]](/spring-security-modules/spring-security-web-boot-2) [[next -->]](/spring-security-modules/spring-security-web-boot-4) diff --git a/spring-security-modules/spring-security-web-boot-4/README.md b/spring-security-modules/spring-security-web-boot-4/README.md index 26b19e7b33..af8ed4e76a 100644 --- a/spring-security-modules/spring-security-web-boot-4/README.md +++ b/spring-security-modules/spring-security-web-boot-4/README.md @@ -8,5 +8,6 @@ The "REST With Spring" Classes: http://github.learnspringsecurity.com ### Relevant Articles: - [Spring Security: Upgrading the Deprecated WebSecurityConfigurerAdapter](https://www.baeldung.com/spring-deprecated-websecurityconfigureradapter) -- More articles: [[<-- prev]](/spring-security-modules/spring-security-web-boot-3) - [Spring @EnableMethodSecurity Annotation](https://www.baeldung.com/spring-enablemethodsecurity) + +More articles: [[<-- prev]](/spring-security-modules/spring-security-web-boot-3) diff --git a/spring-security-modules/spring-security-web-boot-4/src/main/java/com/baeldung/securityfilterchain/configuration/SecurityConfig.java b/spring-security-modules/spring-security-web-boot-4/src/main/java/com/baeldung/securityfilterchain/configuration/SecurityConfig.java index 4d3bec2ad2..5a8f4c1c02 100644 --- a/spring-security-modules/spring-security-web-boot-4/src/main/java/com/baeldung/securityfilterchain/configuration/SecurityConfig.java +++ b/spring-security-modules/spring-security-web-boot-4/src/main/java/com/baeldung/securityfilterchain/configuration/SecurityConfig.java @@ -29,7 +29,7 @@ public class SecurityConfig { .antMatchers("/user/**") .hasAnyRole("USER", "ADMIN") .antMatchers("/login/**") - .anonymous() + .permitAll() .anyRequest() .authenticated() .and() diff --git a/spring-web-modules/spring-thymeleaf-5/README.md b/spring-web-modules/spring-thymeleaf-5/README.md index c06b47d240..7e2f8c37b4 100644 --- a/spring-web-modules/spring-thymeleaf-5/README.md +++ b/spring-web-modules/spring-thymeleaf-5/README.md @@ -10,4 +10,5 @@ This module contains articles about Spring with Thymeleaf - [Upload Image With Spring Boot and Thymeleaf](https://www.baeldung.com/spring-boot-thymeleaf-image-upload) - [Getting a URL Attribute Value in Thymeleaf](https://www.baeldung.com/thymeleaf-url-attribute-value) - [Expression Types in Thymeleaf](https://www.baeldung.com/java-thymeleaf-expression-types) +- [Difference Between th:text and th:value in Thymeleaf](https://www.baeldung.com/java-thymeleaf-text-vs-value) - [[<-- prev]](/spring-thymeleaf) diff --git a/spring-web-modules/spring-thymeleaf-5/src/main/java/com/baeldung/thymeleaf/attributes/AttributeController.java b/spring-web-modules/spring-thymeleaf-5/src/main/java/com/baeldung/thymeleaf/attributes/AttributeController.java new file mode 100644 index 0000000000..b7725fd992 --- /dev/null +++ b/spring-web-modules/spring-thymeleaf-5/src/main/java/com/baeldung/thymeleaf/attributes/AttributeController.java @@ -0,0 +1,30 @@ +package com.baeldung.thymeleaf.attributes; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; + +@Controller +@RequestMapping("/attributes") +public class AttributeController { + + private static final Logger logger = LoggerFactory.getLogger(AttributeController.class); + + @GetMapping + public String show(Model model) { + model.addAttribute("title", "Baeldung"); + model.addAttribute("email", "default@example.com"); + return "attributes/index"; + } + + @PostMapping + public String submit(String email) { + logger.info("Email: {}", email); + return "redirect:attributes"; + } + +} diff --git a/spring-web-modules/spring-thymeleaf-5/src/main/resources/templates/attributes/index.html b/spring-web-modules/spring-thymeleaf-5/src/main/resources/templates/attributes/index.html new file mode 100644 index 0000000000..ed55b61a8a --- /dev/null +++ b/spring-web-modules/spring-thymeleaf-5/src/main/resources/templates/attributes/index.html @@ -0,0 +1,19 @@ + + + + + Difference Between th:text and th:value in Thymeleaf + + + +

+ +
+ + +
+ + + \ No newline at end of file diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/junit4vstestng/DivisibilityUnitTest.java b/testing-modules/junit-4/src/test/java/com/baeldung/junit/DivisibilityUnitTest.java similarity index 90% rename from core-java-modules/core-java/src/test/java/com/baeldung/junit4vstestng/DivisibilityUnitTest.java rename to testing-modules/junit-4/src/test/java/com/baeldung/junit/DivisibilityUnitTest.java index b8fe701f57..3bdc8787f5 100644 --- a/core-java-modules/core-java/src/test/java/com/baeldung/junit4vstestng/DivisibilityUnitTest.java +++ b/testing-modules/junit-4/src/test/java/com/baeldung/junit/DivisibilityUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.junit4vstestng; +package com.baeldung.junit; import static org.junit.Assert.assertEquals; diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/junit4vstestng/RegistrationUnitTest.java b/testing-modules/junit-4/src/test/java/com/baeldung/junit/RegistrationUnitTest.java similarity index 89% rename from core-java-modules/core-java/src/test/java/com/baeldung/junit4vstestng/RegistrationUnitTest.java rename to testing-modules/junit-4/src/test/java/com/baeldung/junit/RegistrationUnitTest.java index 08a9f1e1c4..b52c565a9d 100644 --- a/core-java-modules/core-java/src/test/java/com/baeldung/junit4vstestng/RegistrationUnitTest.java +++ b/testing-modules/junit-4/src/test/java/com/baeldung/junit/RegistrationUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.junit4vstestng; +package com.baeldung.junit; import org.junit.Test; import org.slf4j.Logger; diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/junit4vstestng/SignInUnitTest.java b/testing-modules/junit-4/src/test/java/com/baeldung/junit/SignInUnitTest.java similarity index 89% rename from core-java-modules/core-java/src/test/java/com/baeldung/junit4vstestng/SignInUnitTest.java rename to testing-modules/junit-4/src/test/java/com/baeldung/junit/SignInUnitTest.java index a49fb454ea..145eb0d835 100644 --- a/core-java-modules/core-java/src/test/java/com/baeldung/junit4vstestng/SignInUnitTest.java +++ b/testing-modules/junit-4/src/test/java/com/baeldung/junit/SignInUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.junit4vstestng; +package com.baeldung.junit; import org.junit.Test; import org.slf4j.Logger; diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/junit4vstestng/StringCaseUnitTest.java b/testing-modules/junit-4/src/test/java/com/baeldung/junit/StringCaseUnitTest.java similarity index 91% rename from core-java-modules/core-java/src/test/java/com/baeldung/junit4vstestng/StringCaseUnitTest.java rename to testing-modules/junit-4/src/test/java/com/baeldung/junit/StringCaseUnitTest.java index 16a881f7e7..a76fe97161 100644 --- a/core-java-modules/core-java/src/test/java/com/baeldung/junit4vstestng/StringCaseUnitTest.java +++ b/testing-modules/junit-4/src/test/java/com/baeldung/junit/StringCaseUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.junit4vstestng; +package com.baeldung.junit; import static org.junit.Assert.assertEquals; diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/junit4vstestng/ParametrizedUnitTest.java b/testing-modules/junit-4/src/test/java/com/baeldung/junitparams/ParametrizedUnitTest.java similarity index 92% rename from core-java-modules/core-java/src/test/java/com/baeldung/junit4vstestng/ParametrizedUnitTest.java rename to testing-modules/junit-4/src/test/java/com/baeldung/junitparams/ParametrizedUnitTest.java index b46d4e895d..4e5a59eb22 100644 --- a/core-java-modules/core-java/src/test/java/com/baeldung/junit4vstestng/ParametrizedUnitTest.java +++ b/testing-modules/junit-4/src/test/java/com/baeldung/junitparams/ParametrizedUnitTest.java @@ -1,7 +1,6 @@ -package com.baeldung.junit4vstestng; +package com.baeldung.junitparams; import org.junit.Assert; -import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/junit4vstestng/SuiteUnitTest.java b/testing-modules/junit-4/src/test/java/com/baeldung/runfromjava/SuiteUnitTest.java similarity index 61% rename from core-java-modules/core-java/src/test/java/com/baeldung/junit4vstestng/SuiteUnitTest.java rename to testing-modules/junit-4/src/test/java/com/baeldung/runfromjava/SuiteUnitTest.java index 3e02309636..67093b8a62 100644 --- a/core-java-modules/core-java/src/test/java/com/baeldung/junit4vstestng/SuiteUnitTest.java +++ b/testing-modules/junit-4/src/test/java/com/baeldung/runfromjava/SuiteUnitTest.java @@ -1,7 +1,9 @@ -package com.baeldung.junit4vstestng; +package com.baeldung.runfromjava; import org.junit.runner.RunWith; import org.junit.runners.Suite; +import com.baeldung.junit.RegistrationUnitTest; +import com.baeldung.junit.SignInUnitTest; @RunWith(Suite.class) @Suite.SuiteClasses({ RegistrationUnitTest.class, SignInUnitTest.class }) diff --git a/testing-modules/junit-5-advanced/README.md b/testing-modules/junit-5-advanced/README.md index 9b3a5fa299..a89bcd2de2 100644 --- a/testing-modules/junit-5-advanced/README.md +++ b/testing-modules/junit-5-advanced/README.md @@ -8,3 +8,4 @@ - [Parallel Test Execution for JUnit 5](https://www.baeldung.com/junit-5-parallel-tests) - [JUnit – Testing Methods That Call System.exit()](https://www.baeldung.com/junit-system-exit) - [Single Assert Call for Multiple Properties in Java Unit Testing](https://www.baeldung.com/java-testing-single-assert-multiple-properties) +- [Creating a Test Suite With JUnit](https://www.baeldung.com/java-junit-test-suite) diff --git a/testing-modules/junit-5-advanced/pom.xml b/testing-modules/junit-5-advanced/pom.xml index bfc490b03e..5a65b0f6f3 100644 --- a/testing-modules/junit-5-advanced/pom.xml +++ b/testing-modules/junit-5-advanced/pom.xml @@ -33,6 +33,19 @@ ${assertj.version} test + + org.junit.platform + junit-platform-suite + ${junit-platform.version} + test + + + org.junit.platform + junit-platform-runner + ${junit-platform.version} + test + + @@ -45,6 +58,9 @@ -javaagent:${settings.localRepository}/org/jmockit/jmockit/${jmockit.version}/jmockit-${jmockit.version}.jar true + + **/testsuite/**/*UnitTest.java + @@ -53,6 +69,7 @@ 1.49 3.24.2 + 1.9.2 \ No newline at end of file diff --git a/testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/ClassOneUnitTest.java b/testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/ClassOneUnitTest.java new file mode 100644 index 0000000000..4ce092796e --- /dev/null +++ b/testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/ClassOneUnitTest.java @@ -0,0 +1,13 @@ +package com.baeldung.testsuite; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class ClassOneUnitTest { + + @Test + public void whenTrue_thenTrue() { + Assertions.assertTrue(true); + } + +} diff --git a/testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/ClassThreeUnitTest.java b/testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/ClassThreeUnitTest.java new file mode 100644 index 0000000000..b686ef5773 --- /dev/null +++ b/testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/ClassThreeUnitTest.java @@ -0,0 +1,13 @@ +package com.baeldung.testsuite; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +public class ClassThreeUnitTest { + @Test + @Tag("slow") + public void whenTrue_thenTrue() { + Assertions.assertTrue(true); + } +} diff --git a/testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/package-info.java b/testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/package-info.java new file mode 100644 index 0000000000..53c8ea5e8a --- /dev/null +++ b/testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/package-info.java @@ -0,0 +1,4 @@ +/** + * Dummy tests - showing Junit Suite functionality + */ +package com.baeldung.testsuite; \ No newline at end of file diff --git a/testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/subpackage/ClassTwoUnitTest.java b/testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/subpackage/ClassTwoUnitTest.java new file mode 100644 index 0000000000..bb63fcda63 --- /dev/null +++ b/testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/subpackage/ClassTwoUnitTest.java @@ -0,0 +1,11 @@ +package com.baeldung.testsuite.subpackage; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class ClassTwoUnitTest { + @Test + public void whenTrue_thenTrue() { + Assertions.assertTrue(true); + } +} diff --git a/testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/suites/JUnitClassNamePatternsSuite.java b/testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/suites/JUnitClassNamePatternsSuite.java new file mode 100644 index 0000000000..aa17e26069 --- /dev/null +++ b/testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/suites/JUnitClassNamePatternsSuite.java @@ -0,0 +1,14 @@ +package com.baeldung.testsuite.suites; + +import org.junit.platform.suite.api.ExcludeClassNamePatterns; +import org.junit.platform.suite.api.IncludeClassNamePatterns; +import org.junit.platform.suite.api.SelectPackages; +import org.junit.platform.suite.api.Suite; + +@Suite +@SelectPackages("com.baeldung.testsuite") +@IncludeClassNamePatterns("com.baeldung.testsuite.Class.*UnitTest") +@ExcludeClassNamePatterns("com.baeldung.testsuite.ClassTwoUnitTest") +public class JUnitClassNamePatternsSuite { + // runs ClassOneUnitTest and ClassThreeUnitTest +} \ No newline at end of file diff --git a/testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/suites/JUnitExcludePackagesSuite.java b/testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/suites/JUnitExcludePackagesSuite.java new file mode 100644 index 0000000000..47cd993f8a --- /dev/null +++ b/testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/suites/JUnitExcludePackagesSuite.java @@ -0,0 +1,12 @@ +package com.baeldung.testsuite.suites; + +import org.junit.platform.suite.api.ExcludePackages; +import org.junit.platform.suite.api.SelectPackages; +import org.junit.platform.suite.api.Suite; + +@Suite +@SelectPackages("com.baeldung.testsuite") +@ExcludePackages("com.baeldung.testsuite.subpackage") +public class JUnitExcludePackagesSuite { + // runs ClassOneUnitTest and ClassThreeUnitTest +} \ No newline at end of file diff --git a/testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/suites/JUnitRunWithSuite.java b/testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/suites/JUnitRunWithSuite.java new file mode 100644 index 0000000000..ad098fb305 --- /dev/null +++ b/testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/suites/JUnitRunWithSuite.java @@ -0,0 +1,16 @@ +package com.baeldung.testsuite.suites; + +import com.baeldung.testsuite.ClassOneUnitTest; +import com.baeldung.testsuite.subpackage.ClassTwoUnitTest; +import org.junit.platform.runner.JUnitPlatform; +import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.SuiteDisplayName; +import org.junit.runner.RunWith; + +@RunWith(JUnitPlatform.class) +@SuiteDisplayName("My Test Suite") +@SelectClasses({ClassOneUnitTest.class, ClassTwoUnitTest.class}) +public class JUnitRunWithSuite { + // runs ClassOneUnitTest and ClassTwoUnitTest + // equivalent to JUnitSelectClassesSuite +} \ No newline at end of file diff --git a/testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/suites/JUnitSelectClassesSuite.java b/testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/suites/JUnitSelectClassesSuite.java new file mode 100644 index 0000000000..dc2b78ac53 --- /dev/null +++ b/testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/suites/JUnitSelectClassesSuite.java @@ -0,0 +1,14 @@ +package com.baeldung.testsuite.suites; + +import com.baeldung.testsuite.ClassOneUnitTest; +import com.baeldung.testsuite.subpackage.ClassTwoUnitTest; +import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.Suite; +import org.junit.platform.suite.api.SuiteDisplayName; + +@Suite +@SuiteDisplayName("My Test Suite") +@SelectClasses({ClassOneUnitTest.class, ClassTwoUnitTest.class}) +public class JUnitSelectClassesSuite { + // runs ClassOneUnitTest and ClassTwoUnitTest +} \ No newline at end of file diff --git a/testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/suites/JUnitSelectPackagesSuite.java b/testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/suites/JUnitSelectPackagesSuite.java new file mode 100644 index 0000000000..26562a18d7 --- /dev/null +++ b/testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/suites/JUnitSelectPackagesSuite.java @@ -0,0 +1,10 @@ +package com.baeldung.testsuite.suites; + +import org.junit.platform.suite.api.SelectPackages; +import org.junit.platform.suite.api.Suite; + +@Suite +@SelectPackages({"com.baeldung.testsuite", "com.baeldung.testsuitetwo"}) +public class JUnitSelectPackagesSuite { + // runs ClassOneUnitTest, ClassTwoUnitTest and ClassThreeUnitTest +} \ No newline at end of file diff --git a/testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/suites/JUnitTestExcludeTagsSuite.java b/testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/suites/JUnitTestExcludeTagsSuite.java new file mode 100644 index 0000000000..5ae32fc0b5 --- /dev/null +++ b/testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/suites/JUnitTestExcludeTagsSuite.java @@ -0,0 +1,12 @@ +package com.baeldung.testsuite.suites; + +import org.junit.platform.suite.api.ExcludeTags; +import org.junit.platform.suite.api.SelectPackages; +import org.junit.platform.suite.api.Suite; + +@Suite +@SelectPackages("com.baeldung.testsuite") +@ExcludeTags("slow") +public class JUnitTestExcludeTagsSuite { + // runs ClassOneUnitTest, ClassTwoUnitTest +} \ No newline at end of file diff --git a/testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/suites/JUnitTestIncludePackagesSuite.java b/testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/suites/JUnitTestIncludePackagesSuite.java new file mode 100644 index 0000000000..b5442aff35 --- /dev/null +++ b/testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/suites/JUnitTestIncludePackagesSuite.java @@ -0,0 +1,12 @@ +package com.baeldung.testsuite.suites; + +import org.junit.platform.suite.api.IncludePackages; +import org.junit.platform.suite.api.SelectPackages; +import org.junit.platform.suite.api.Suite; + +@Suite +@SelectPackages("com.baeldung.testsuite") +@IncludePackages("com.baeldung.testsuite.subpackage") +public class JUnitTestIncludePackagesSuite { + // runs ClassTwoUnitTest +} \ No newline at end of file diff --git a/testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/suites/JUnitTestIncludeTagsSuite.java b/testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/suites/JUnitTestIncludeTagsSuite.java new file mode 100644 index 0000000000..1cfce4bd7a --- /dev/null +++ b/testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/suites/JUnitTestIncludeTagsSuite.java @@ -0,0 +1,12 @@ +package com.baeldung.testsuite.suites; + +import org.junit.platform.suite.api.IncludeTags; +import org.junit.platform.suite.api.SelectPackages; +import org.junit.platform.suite.api.Suite; + +@Suite +@SelectPackages("com.baeldung.testsuite") +@IncludeTags("slow") +public class JUnitTestIncludeTagsSuite { + // runs ClassTwoUnitTest +} \ No newline at end of file diff --git a/testing-modules/mockito-simple/pom.xml b/testing-modules/mockito-simple/pom.xml index 3bfca2db2a..29c7966a08 100644 --- a/testing-modules/mockito-simple/pom.xml +++ b/testing-modules/mockito-simple/pom.xml @@ -57,7 +57,7 @@ 5.3.20 - 4.6.1 + 4.8.0 \ No newline at end of file diff --git a/testing-modules/mockito-simple/src/test/java/com/baeldung/mockito/MockFinalsUnitTest.java b/testing-modules/mockito-simple/src/test/java/com/baeldung/mockito/MockFinalsUnitTest.java index a4b2bd03b4..8abd51bb85 100644 --- a/testing-modules/mockito-simple/src/test/java/com/baeldung/mockito/MockFinalsUnitTest.java +++ b/testing-modules/mockito-simple/src/test/java/com/baeldung/mockito/MockFinalsUnitTest.java @@ -3,8 +3,10 @@ package com.baeldung.mockito; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import static org.mockito.Mockito.withSettings; import org.junit.jupiter.api.Test; +import org.mockito.MockMakers; class MockFinalsUnitTest { @@ -29,4 +31,14 @@ class MockFinalsUnitTest { assertThat(mock.size()).isNotEqualTo(finalList.size()); } + + @Test + public void whenMockFinalMethodMockWorks_withInlineMockMaker() { + MyList myList = new MyList(); + + MyList mock = mock(MyList.class, withSettings().mockMaker(MockMakers.INLINE)); + when(mock.finalMethod()).thenReturn(1); + + assertThat(mock.finalMethod()).isNotEqualTo(myList.finalMethod()); + } } diff --git a/testing-modules/selenium-junit-testng/README.md b/testing-modules/selenium-junit-testng/README.md index ab8024ff45..4d9834c6f5 100644 --- a/testing-modules/selenium-junit-testng/README.md +++ b/testing-modules/selenium-junit-testng/README.md @@ -9,6 +9,7 @@ - [Fixing Selenium WebDriver Executable Path Error](https://www.baeldung.com/java-selenium-webdriver-path-error) - [Handle Browser Tabs With Selenium](https://www.baeldung.com/java-handle-browser-tabs-selenium) - [Implicit Wait vs Explicit Wait in Selenium Webdriver](https://www.baeldung.com/selenium-implicit-explicit-wait) +- [StaleElementReferenceException in Selenium](https://www.baeldung.com/selenium-staleelementreferenceexception) #### Notes: - to run the live tests for the article *Fixing Selenium WebDriver Executable Path Error*, follow the manual setup described diff --git a/testing-modules/selenium-junit-testng/pom.xml b/testing-modules/selenium-junit-testng/pom.xml index f0a2e43eeb..517dc48dde 100644 --- a/testing-modules/selenium-junit-testng/pom.xml +++ b/testing-modules/selenium-junit-testng/pom.xml @@ -57,9 +57,9 @@ 6.10 - 4.6.0 + 4.8.3 1.5.4 - 5.3.0 + 5.3.2 \ No newline at end of file diff --git a/testing-modules/selenium-junit-testng/src/main/java/com/baeldung/selenium/stale/RobustWebDriver.java b/testing-modules/selenium-junit-testng/src/main/java/com/baeldung/selenium/stale/RobustWebDriver.java new file mode 100644 index 0000000000..211480dce3 --- /dev/null +++ b/testing-modules/selenium-junit-testng/src/main/java/com/baeldung/selenium/stale/RobustWebDriver.java @@ -0,0 +1,86 @@ +package com.baeldung.selenium.stale; + +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +public class RobustWebDriver implements WebDriver { + + private final WebDriver originalWebDriver; + + public RobustWebDriver(WebDriver webDriver) { + this.originalWebDriver = webDriver; + } + + @Override + public void get(String url) { + this.originalWebDriver.get(url); + } + + @Override + public String getCurrentUrl() { + return this.originalWebDriver.getCurrentUrl(); + } + + @Override + public String getTitle() { + return this.originalWebDriver.getTitle(); + } + + @Override + public List findElements(By by) { + return this.originalWebDriver.findElements(by) + .stream().map(e -> new RobustWebElement(e, by, this)) + .collect(Collectors.toList()); + } + + @Override + public WebElement findElement(By by) { + return new RobustWebElement(this.originalWebDriver.findElement(by), by, this); + } + + @Override + public String getPageSource() { + return this.originalWebDriver.getPageSource(); + } + + @Override + public void close() { + this.originalWebDriver.close(); + + } + + @Override + public void quit() { + this.originalWebDriver.quit(); + } + + @Override + public Set getWindowHandles() { + return this.originalWebDriver.getWindowHandles(); + } + + @Override + public String getWindowHandle() { + return this.originalWebDriver.getWindowHandle(); + } + + @Override + public TargetLocator switchTo() { + return this.originalWebDriver.switchTo(); + } + + @Override + public Navigation navigate() { + return this.originalWebDriver.navigate(); + } + + @Override + public Options manage() { + return this.originalWebDriver.manage(); + } +} \ No newline at end of file diff --git a/testing-modules/selenium-junit-testng/src/main/java/com/baeldung/selenium/stale/RobustWebElement.java b/testing-modules/selenium-junit-testng/src/main/java/com/baeldung/selenium/stale/RobustWebElement.java new file mode 100644 index 0000000000..fa65e60349 --- /dev/null +++ b/testing-modules/selenium-junit-testng/src/main/java/com/baeldung/selenium/stale/RobustWebElement.java @@ -0,0 +1,176 @@ +package com.baeldung.selenium.stale; + +import org.openqa.selenium.By; +import org.openqa.selenium.Dimension; +import org.openqa.selenium.OutputType; +import org.openqa.selenium.Point; +import org.openqa.selenium.Rectangle; +import org.openqa.selenium.StaleElementReferenceException; +import org.openqa.selenium.WebDriverException; +import org.openqa.selenium.WebElement; + +import java.util.List; +import java.util.function.BiConsumer; +import java.util.function.BiFunction; +import java.util.function.Consumer; +import java.util.function.Function; + +public class RobustWebElement implements WebElement { + + private WebElement originalElement; + private final RobustWebDriver driver; + private final By by; + + private static final int MAX_RETRIES = 10; + private static final String SERE = "Element is no longer attached to the DOM"; + + public RobustWebElement(WebElement element, By by, RobustWebDriver driver) { + this.originalElement = element; + this.by = by; + this.driver = driver; + } + + @Override + public void click() { + executeMethodWithRetries(WebElement::click); + } + + @Override + public void submit() { + executeMethodWithRetries(WebElement::submit); + } + + @Override + public void sendKeys(CharSequence... keysToSend) { + executeMethodWithRetriesVoid(WebElement::sendKeys, keysToSend); + } + + @Override + public void clear() { + executeMethodWithRetries(WebElement::clear); + } + + @Override + public String getTagName() { + return executeMethodWithRetries(WebElement::getTagName); + } + + @Override + public String getAttribute(String name) { + return executeMethodWithRetries(WebElement::getAttribute, name); + } + + @Override + public boolean isSelected() { + return executeMethodWithRetries(WebElement::isSelected); + } + + @Override + public boolean isEnabled() { + return executeMethodWithRetries(WebElement::isEnabled); + } + + @Override + public String getText() { + return executeMethodWithRetries(WebElement::getText); + } + + @Override + public List findElements(By by) { + return executeMethodWithRetries(WebElement::findElements, by); + } + + @Override + public WebElement findElement(By by) { + return executeMethodWithRetries(WebElement::findElement, by); + } + + @Override + public boolean isDisplayed() { + return executeMethodWithRetries(WebElement::isDisplayed); + } + + @Override + public Point getLocation() { + return executeMethodWithRetries(WebElement::getLocation); + } + + @Override + public Dimension getSize() { + return executeMethodWithRetries(WebElement::getSize); + } + + @Override + public Rectangle getRect() { + return executeMethodWithRetries(WebElement::getRect); + } + + @Override + public String getCssValue(String propertyName) { + return executeMethodWithRetries(WebElement::getCssValue, propertyName); + } + + + @Override + public X getScreenshotAs(OutputType target) throws WebDriverException { + return executeMethodWithRetries(WebElement::getScreenshotAs, target); + } + + private void executeMethodWithRetries(Consumer method) { + int retries = 0; + while (retries < MAX_RETRIES) { + try { + WebElementUtils.callMethod(originalElement, method); + return; + } catch (StaleElementReferenceException ex) { + refreshElement(); + } + retries++; + } + throw new StaleElementReferenceException(SERE); + } + + private T executeMethodWithRetries(Function method) { + int retries = 0; + while (retries < MAX_RETRIES) { + try { + return WebElementUtils.callMethodWithReturn(originalElement, method); + } catch (StaleElementReferenceException ex) { + refreshElement(); + } + retries++; + } + throw new StaleElementReferenceException(SERE); + } + + private void executeMethodWithRetriesVoid(BiConsumer method, U parameter) { + int retries = 0; + while (retries < MAX_RETRIES) { + try { + WebElementUtils.callMethod(originalElement, method, parameter); + return; + } catch (StaleElementReferenceException ex) { + refreshElement(); + } + retries++; + } + throw new StaleElementReferenceException(SERE); + } + + private T executeMethodWithRetries(BiFunction method, U parameter) { + int retries = 0; + while (retries < MAX_RETRIES) { + try { + return WebElementUtils.callMethodWithReturn(originalElement, method, parameter); + } catch (StaleElementReferenceException ex) { + refreshElement(); + } + retries++; + } + throw new StaleElementReferenceException(SERE); + } + + private void refreshElement() { + this.originalElement = driver.findElement(by); + } +} \ No newline at end of file diff --git a/testing-modules/selenium-junit-testng/src/main/java/com/baeldung/selenium/stale/WebElementUtils.java b/testing-modules/selenium-junit-testng/src/main/java/com/baeldung/selenium/stale/WebElementUtils.java new file mode 100644 index 0000000000..460cc02bf5 --- /dev/null +++ b/testing-modules/selenium-junit-testng/src/main/java/com/baeldung/selenium/stale/WebElementUtils.java @@ -0,0 +1,30 @@ +package com.baeldung.selenium.stale; + +import org.openqa.selenium.WebElement; + +import java.util.function.BiConsumer; +import java.util.function.BiFunction; +import java.util.function.Consumer; +import java.util.function.Function; + +public class WebElementUtils { + + private WebElementUtils(){ + } + + public static void callMethod(WebElement element, Consumer method) { + method.accept(element); + } + + public static void callMethod(WebElement element, BiConsumer method, U parameter) { + method.accept(element, parameter); + } + + public static T callMethodWithReturn(WebElement element, Function method) { + return method.apply(element); + } + + public static T callMethodWithReturn(WebElement element, BiFunction method, U parameter) { + return method.apply(element, parameter); + } +} \ No newline at end of file diff --git a/testing-modules/selenium-junit-testng/src/test/java/com/baeldung/selenium/stale/RobustWebElementLiveTest.java b/testing-modules/selenium-junit-testng/src/test/java/com/baeldung/selenium/stale/RobustWebElementLiveTest.java new file mode 100644 index 0000000000..3dea95ca82 --- /dev/null +++ b/testing-modules/selenium-junit-testng/src/test/java/com/baeldung/selenium/stale/RobustWebElementLiveTest.java @@ -0,0 +1,58 @@ +package com.baeldung.selenium.stale; + +import io.github.bonigarcia.wdm.WebDriverManager; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.chrome.ChromeDriver; +import org.openqa.selenium.chrome.ChromeOptions; + +import java.time.Duration; + +final class RobustWebElementLiveTest { + + private static RobustWebDriver driver; + private static final int TIMEOUT = 10; + + private static final By LOCATOR_REFRESH = By.xpath("//a[.='click here']"); + private static final By LOCATOR_DYNAMIC_CONTENT = By.xpath( + "(//div[@id='content']//div[@class='large-10 columns'])[1]"); + + private static void setupChromeDriver() { + WebDriverManager.chromedriver().setup(); + final ChromeOptions options = new ChromeOptions(); + options.addArguments("--remote-allow-origins=*"); + driver = new RobustWebDriver(new ChromeDriver(options)); + options(); + } + + private static void options() { + driver.manage().window().maximize(); + driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(TIMEOUT)); + } + + @BeforeEach + public void init() { + setupChromeDriver(); + } + + @Test + void givenDynamicPage_whenRefreshingAndAccessingSavedElement_thenOK() { + driver.navigate().to("https://the-internet.herokuapp.com/dynamic_content?with_content=static"); + final WebElement element = driver.findElement(LOCATOR_DYNAMIC_CONTENT); + + driver.findElement(LOCATOR_REFRESH).click(); + Assertions.assertDoesNotThrow(element::getText); + } + + @AfterEach + void teardown() { + if (driver != null) { + driver.quit(); + driver = null; + } + } +} \ No newline at end of file diff --git a/testing-modules/selenium-junit-testng/src/test/java/com/baeldung/selenium/stale/StaleElementReferenceLiveTest.java b/testing-modules/selenium-junit-testng/src/test/java/com/baeldung/selenium/stale/StaleElementReferenceLiveTest.java new file mode 100644 index 0000000000..9b42571891 --- /dev/null +++ b/testing-modules/selenium-junit-testng/src/test/java/com/baeldung/selenium/stale/StaleElementReferenceLiveTest.java @@ -0,0 +1,102 @@ +package com.baeldung.selenium.stale; + +import io.github.bonigarcia.wdm.WebDriverManager; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.StaleElementReferenceException; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.chrome.ChromeDriver; +import org.openqa.selenium.chrome.ChromeOptions; + +import java.time.Duration; + +final class StaleElementReferenceLiveTest { + + private static WebDriver driver; + private static final int TIMEOUT = 10; + + private static final By LOCATOR_REFRESH = By.xpath("//a[.='click here']"); + private static final By LOCATOR_DYNAMIC_CONTENT = By.xpath( + "(//div[@id='content']//div[@class='large-10 columns'])[1]"); + + private static void setupChromeDriver() { + WebDriverManager.chromedriver().setup(); + final ChromeOptions options = new ChromeOptions(); + options.addArguments("--remote-allow-origins=*"); + driver = new ChromeDriver(options); + options(); + } + + private static void options() { + driver.manage().window().maximize(); + driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(TIMEOUT)); + } + + @BeforeEach + public void init() { + setupChromeDriver(); + } + + @Test + void givenDynamicPage_whenRefreshingAndAccessingSavedElement_thenSERE() { + driver.navigate().to("https://the-internet.herokuapp.com/dynamic_content?with_content=static"); + final WebElement element = driver.findElement(LOCATOR_DYNAMIC_CONTENT); + + driver.findElement(LOCATOR_REFRESH).click(); + Assertions.assertThrows(StaleElementReferenceException.class, element::getText); + } + + @Test + void givenDynamicPage_whenRefreshingAndAccessingSavedElement_thenHandleSERE() { + driver.navigate().to("https://the-internet.herokuapp.com/dynamic_content?with_content=static"); + final WebElement element = driver.findElement(LOCATOR_DYNAMIC_CONTENT); + + if (!retryingFindClick(LOCATOR_REFRESH)) { + Assertions.fail("Element is still stale after 5 attempts"); + } + Assertions.assertDoesNotThrow(() -> retryingFindGetText(LOCATOR_DYNAMIC_CONTENT)); + } + + private boolean retryingFindClick(By locator) { + boolean result = false; + int attempts = 0; + while (attempts < 5) { + try { + driver.findElement(locator).click(); + result = true; + break; + } catch (StaleElementReferenceException ex) { + System.out.println(ex.getMessage()); + } + attempts++; + } + return result; + } + + private String retryingFindGetText(By locator) { + String result = null; + int attempts = 0; + while (attempts < 5) { + try { + result = driver.findElement(locator).getText(); + break; + } catch (StaleElementReferenceException ex) { + System.out.println(ex.getMessage()); + } + attempts++; + } + return result; + } + + @AfterEach + void teardown() { + if (driver != null) { + driver.quit(); + driver = null; + } + } +} \ No newline at end of file diff --git a/testing-modules/selenium-junit-testng/src/test/java/com/baeldung/selenium/webdriver/SeleniumWebDriverUnitTest.java b/testing-modules/selenium-junit-testng/src/test/java/com/baeldung/selenium/webdriver/SeleniumWebDriverUnitTest.java new file mode 100644 index 0000000000..e4e89611d1 --- /dev/null +++ b/testing-modules/selenium-junit-testng/src/test/java/com/baeldung/selenium/webdriver/SeleniumWebDriverUnitTest.java @@ -0,0 +1,43 @@ +package com.baeldung.selenium.webdriver; + +import org.junit.Assert; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.Keys; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.chrome.ChromeDriver; +import io.github.bonigarcia.wdm.WebDriverManager; + +public class SeleniumWebDriverUnitTest { + + private WebDriver driver; + + private static final String URL = "https://duckduckgo.com/"; + private static final String INPUT_ID = "search_form_input_homepage"; + + @BeforeEach + public void setUp() { + WebDriverManager.chromedriver().setup(); + driver = new ChromeDriver(); + } + + @AfterEach + public void tearDown() { + driver.quit(); + } + + @Test + public void givenDuckDuckGoHomePage_whenInputHelloWorld_thenInputValueIsHelloWorld() { + driver.get(URL); + WebElement inputElement = driver.findElement(By.id(INPUT_ID)); + inputElement.sendKeys(Keys.chord(Keys.CONTROL, "a"), Keys.DELETE); + inputElement.sendKeys("Hello World!"); + + String inputValue = inputElement.getAttribute("value"); + Assert.assertEquals("Hello World!", inputValue); + } + +} diff --git a/testing-modules/spring-testing-2/README.md b/testing-modules/spring-testing-2/README.md index 5bd1716609..139b25f4b5 100644 --- a/testing-modules/spring-testing-2/README.md +++ b/testing-modules/spring-testing-2/README.md @@ -4,3 +4,4 @@ - [Concurrent Test Execution in Spring 5](https://www.baeldung.com/spring-5-concurrent-tests) - [Spring 5 Testing with @EnabledIf Annotation](https://www.baeldung.com/spring-5-enabledif) - [The Spring TestExecutionListener](https://www.baeldung.com/spring-testexecutionlistener) +- [Execute Tests Based on Active Profile With JUnit 5](https://www.baeldung.com/spring-boot-junit-5-testing-active-profile) diff --git a/web-modules/apache-tapestry/pom.xml b/web-modules/apache-tapestry/pom.xml index 7746520a56..9632dd70dc 100644 --- a/web-modules/apache-tapestry/pom.xml +++ b/web-modules/apache-tapestry/pom.xml @@ -115,6 +115,18 @@ + + org.apache.maven.plugins + maven-war-plugin + 3.3.1 + + + + true + + + + @@ -133,11 +145,11 @@ 6.1.16 - 2.7.2 - 2.3.2 - 1.8 - 1.8 - 5.4.5 + 3.0.0-M5 + 3.8.1 + 11 + 11 + 5.8.2 2.5 6.8.21 1.7.19 diff --git a/web-modules/apache-tapestry/src/main/java/com/baeldung/tapestry/services/AppModule.java b/web-modules/apache-tapestry/src/main/java/com/baeldung/tapestry/services/AppModule.java index c4d57d5b86..2798e4a75b 100644 --- a/web-modules/apache-tapestry/src/main/java/com/baeldung/tapestry/services/AppModule.java +++ b/web-modules/apache-tapestry/src/main/java/com/baeldung/tapestry/services/AppModule.java @@ -3,17 +3,17 @@ package com.baeldung.tapestry.services; import java.io.IOException; import org.apache.tapestry5.SymbolConstants; -import org.apache.tapestry5.ioc.MappedConfiguration; -import org.apache.tapestry5.ioc.OrderedConfiguration; +import org.apache.tapestry5.commons.MappedConfiguration; +import org.apache.tapestry5.commons.OrderedConfiguration; +import org.apache.tapestry5.http.services.Request; +import org.apache.tapestry5.http.services.RequestFilter; +import org.apache.tapestry5.http.services.RequestHandler; +import org.apache.tapestry5.http.services.Response; import org.apache.tapestry5.ioc.ServiceBinder; import org.apache.tapestry5.ioc.annotations.Contribute; import org.apache.tapestry5.ioc.annotations.Local; import org.apache.tapestry5.ioc.services.ApplicationDefaults; import org.apache.tapestry5.ioc.services.SymbolProvider; -import org.apache.tapestry5.services.Request; -import org.apache.tapestry5.services.RequestFilter; -import org.apache.tapestry5.services.RequestHandler; -import org.apache.tapestry5.services.Response; import org.slf4j.Logger; /** diff --git a/web-modules/apache-tapestry/src/main/java/com/baeldung/tapestry/services/DevelopmentModule.java b/web-modules/apache-tapestry/src/main/java/com/baeldung/tapestry/services/DevelopmentModule.java index d9c8493e39..1c89587c53 100644 --- a/web-modules/apache-tapestry/src/main/java/com/baeldung/tapestry/services/DevelopmentModule.java +++ b/web-modules/apache-tapestry/src/main/java/com/baeldung/tapestry/services/DevelopmentModule.java @@ -1,7 +1,7 @@ package com.baeldung.tapestry.services; import org.apache.tapestry5.SymbolConstants; -import org.apache.tapestry5.ioc.MappedConfiguration; +import org.apache.tapestry5.commons.MappedConfiguration; /** * This module is automatically included as part of the Tapestry IoC Registry if tapestry.execution-mode diff --git a/web-modules/apache-tapestry/src/main/java/com/baeldung/tapestry/services/QaModule.java b/web-modules/apache-tapestry/src/main/java/com/baeldung/tapestry/services/QaModule.java index fc6fb595e9..d16e498a4b 100644 --- a/web-modules/apache-tapestry/src/main/java/com/baeldung/tapestry/services/QaModule.java +++ b/web-modules/apache-tapestry/src/main/java/com/baeldung/tapestry/services/QaModule.java @@ -1,7 +1,7 @@ package com.baeldung.tapestry.services; import org.apache.tapestry5.SymbolConstants; -import org.apache.tapestry5.ioc.MappedConfiguration; +import org.apache.tapestry5.commons.MappedConfiguration; import org.apache.tapestry5.ioc.ServiceBinder; /**