From 7d119fc2065cffa04f2dce4d7fc20ecc1772ce95 Mon Sep 17 00:00:00 2001 From: rajadilipkolli Date: Fri, 14 Jun 2024 21:40:15 +0530 Subject: [PATCH 1/5] polish code --- httpClients/README.md | 14 +++++------ .../custom/sequence/web/api/CustomerAPI.java | 12 +++++----- .../web/controllers/OrderControllerTest.java | 24 ++++++++++++------- .../provisioning/datasources/datasource.yml | 3 +-- .../envers/ApplicationIntegrationTest.java | 6 +++-- .../hibernatecache/TestApplication.java | 3 +-- .../controllers/CustomerControllerTest.java | 19 --------------- .../web/controllers/OrderControllerTest.java | 2 +- jpa/boot-jpa-locks/README.md | 4 ++-- .../config/routing/RoutingDataSource.java | 22 ----------------- jpa/multitenancy/README.md | 2 +- .../PrimaryDataSourceConfiguration.java | 4 ++-- .../SecondaryDataSourceConfiguration.java | 4 ++-- .../multitenant/TenantIdentifierResolver.java | 2 +- .../multitenant/TenantRoutingDatasource.java | 22 ----------------- .../multitenancy/utils/DatabaseType.java | 8 +++---- .../multitenant/TenantIdentifierResolver.java | 2 +- .../multitenant/TenantRoutingDatasource.java | 22 ----------------- .../tenant/TenantIdentifierResolver.java | 9 ++++--- .../resources/application-heroku.properties | 2 -- .../partition/ApplicationIntegrationTest.java | 2 +- .../TenantIdentifierResolver.java | 9 ++++--- .../schema/utils/TenantNameType.java | 8 +++---- .../resources/application-heroku.properties | 2 -- 24 files changed, 61 insertions(+), 146 deletions(-) delete mode 100644 jpa/multitenancy/partition/src/main/resources/application-heroku.properties delete mode 100644 jpa/multitenancy/schema/src/main/resources/application-heroku.properties diff --git a/httpClients/README.md b/httpClients/README.md index 63481e111..1dfb9a7a1 100644 --- a/httpClients/README.md +++ b/httpClients/README.md @@ -7,10 +7,10 @@ Overall, the HTTP client can help to make your application more efficient and ea The following table list all sample codes related to the spring boot integrations with external system. -| Name | Description | -|--------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------| -| [http proxy](./http-proxy) | The application, demonstrates the way spring boot application will connect with external system using spring 6 http proxy | -| [rest template](./rest-template) | The application, demonstrates the way spring boot application will connect with external system using rest template | -| [web-client-mvc](./web-client-mvc) | The application, demonstrates the way spring boot application will connect with external system using spring 5's webclient in a servlet environment | -| [web-client-webflux](./web-client-webflux) | The application, demonstrates the way spring boot application will connect with external system using spring 5's webclient in a reactive environment | -| [http client](./boot-restclient) | The application, demonstrates the way spring boot application will connect with external system using spring 6's restclient in a reactive environment | +| Name | Description | +|-------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------| +| [http proxy](./boot-http-proxy) | The application, demonstrates the way spring boot application will connect with external system using spring 6 http proxy | +| [rest template](./boot-rest-template) | The application, demonstrates the way spring boot application will connect with external system using rest template | +| [web-client-mvc](./boot-web-client-mvc) | The application, demonstrates the way spring boot application will connect with external system using spring 5's webclient in a servlet environment | +| [web-client-webflux](./boot-web-client-webflux) | The application, demonstrates the way spring boot application will connect with external system using spring 5's webclient in a reactive environment | +| [http client](./boot-restclient) | The application, demonstrates the way spring boot application will connect with external system using spring 6's restclient in a reactive environment | diff --git a/jpa/boot-data-customsequence/src/main/java/com/example/custom/sequence/web/api/CustomerAPI.java b/jpa/boot-data-customsequence/src/main/java/com/example/custom/sequence/web/api/CustomerAPI.java index e334d21af..1c875885f 100644 --- a/jpa/boot-data-customsequence/src/main/java/com/example/custom/sequence/web/api/CustomerAPI.java +++ b/jpa/boot-data-customsequence/src/main/java/com/example/custom/sequence/web/api/CustomerAPI.java @@ -41,10 +41,10 @@ public interface CustomerAPI { }) }) PagedResult getAllCustomers( - @Parameter(name = "pageNo", description = "", in = ParameterIn.QUERY) int pageNo, - @Parameter(name = "pageSize", description = "", in = ParameterIn.QUERY) int pageSize, - @Parameter(name = "sortBy", description = "", in = ParameterIn.QUERY) String sortBy, - @Parameter(name = "sortDir", description = "", in = ParameterIn.QUERY) String sortDir); + @Parameter(name = "pageNo", in = ParameterIn.QUERY) int pageNo, + @Parameter(name = "pageSize", in = ParameterIn.QUERY) int pageSize, + @Parameter(name = "sortBy", in = ParameterIn.QUERY) String sortBy, + @Parameter(name = "sortDir", in = ParameterIn.QUERY) String sortDir); /** * GET /api/customers/{id} @@ -74,7 +74,7 @@ PagedResult getAllCustomers( }) }) ResponseEntity getCustomerById( - @Parameter(name = "id", description = "", required = true, in = ParameterIn.PATH) + @Parameter(name = "id", required = true, in = ParameterIn.PATH) @PathVariable String id); @@ -106,5 +106,5 @@ ResponseEntity getCustomerById( }) }) CustomerResponse createCustomer( - @Valid @RequestBody(description = "", required = true) Customer customer); + @Valid @RequestBody(required = true) Customer customer); } diff --git a/jpa/boot-data-customsequence/src/test/java/com/example/custom/sequence/web/controllers/OrderControllerTest.java b/jpa/boot-data-customsequence/src/test/java/com/example/custom/sequence/web/controllers/OrderControllerTest.java index 3ce1ff71d..93489a19c 100644 --- a/jpa/boot-data-customsequence/src/test/java/com/example/custom/sequence/web/controllers/OrderControllerTest.java +++ b/jpa/boot-data-customsequence/src/test/java/com/example/custom/sequence/web/controllers/OrderControllerTest.java @@ -25,6 +25,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; + +import org.jetbrains.annotations.NotNull; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -60,15 +62,7 @@ void setUp() { @Test void shouldFetchAllOrders() throws Exception { - List orderResponseList = new ArrayList<>(); - orderResponseList.add( - new OrderResponse("1", "text 1", new CustomerResponse("1", "customer1"))); - orderResponseList.add( - new OrderResponse("2", "text 2", new CustomerResponse("1", "customer1"))); - orderResponseList.add( - new OrderResponse("3", "text 3", new CustomerResponse("1", "customer1"))); - Page page = new PageImpl<>(orderResponseList); - PagedResult orderPagedResult = new PagedResult<>(page); + PagedResult orderPagedResult = getOrderResponsePagedResult(); given(orderService.findAllOrders(0, 10, "id", "asc")).willReturn(orderPagedResult); this.mockMvc @@ -84,6 +78,18 @@ void shouldFetchAllOrders() throws Exception { .andExpect(jsonPath("$.hasPrevious", is(false))); } + private static @NotNull PagedResult getOrderResponsePagedResult() { + List orderResponseList = new ArrayList<>(); + orderResponseList.add( + new OrderResponse("1", "text 1", new CustomerResponse("1", "customer1"))); + orderResponseList.add( + new OrderResponse("2", "text 2", new CustomerResponse("1", "customer1"))); + orderResponseList.add( + new OrderResponse("3", "text 3", new CustomerResponse("1", "customer1"))); + Page page = new PageImpl<>(orderResponseList); + return new PagedResult<>(page); + } + @Test void shouldFindOrderById() throws Exception { String orderId = "1"; diff --git a/jpa/boot-data-envers/config/grafana/provisioning/datasources/datasource.yml b/jpa/boot-data-envers/config/grafana/provisioning/datasources/datasource.yml index fc5c72a80..3627449d7 100755 --- a/jpa/boot-data-envers/config/grafana/provisioning/datasources/datasource.yml +++ b/jpa/boot-data-envers/config/grafana/provisioning/datasources/datasource.yml @@ -4,8 +4,7 @@ apiVersion: 1 deleteDatasources: - name: Prometheus -# list of datasources to insert/update depending -# whats available in the database +# list of datasources to insert/update depending on what's available in the database datasources: - name: Prometheus type: prometheus diff --git a/jpa/boot-data-envers/src/test/java/com/example/envers/ApplicationIntegrationTest.java b/jpa/boot-data-envers/src/test/java/com/example/envers/ApplicationIntegrationTest.java index e4e25aa6c..3fc22c2d6 100644 --- a/jpa/boot-data-envers/src/test/java/com/example/envers/ApplicationIntegrationTest.java +++ b/jpa/boot-data-envers/src/test/java/com/example/envers/ApplicationIntegrationTest.java @@ -43,8 +43,10 @@ void updateIncreasesRevisionNumber() { assertThat(revision) .isPresent() - .hasValueSatisfying(rev -> - assertThat(rev.getRevisionNumber()).isPresent().get().isEqualTo(5)) + .hasValueSatisfying(rev -> { + assertThat(rev.getRevisionNumber()).isPresent(); + assertThat(rev.getRevisionNumber().get()).isEqualTo(5); + }) .hasValueSatisfying(rev -> assertThat(rev.getEntity()) .extracting(Customer::getName) .asString() diff --git a/jpa/boot-hibernate2ndlevelcache-sample/src/test/java/com/example/hibernatecache/TestApplication.java b/jpa/boot-hibernate2ndlevelcache-sample/src/test/java/com/example/hibernatecache/TestApplication.java index ab97cc880..0b65383cf 100644 --- a/jpa/boot-hibernate2ndlevelcache-sample/src/test/java/com/example/hibernatecache/TestApplication.java +++ b/jpa/boot-hibernate2ndlevelcache-sample/src/test/java/com/example/hibernatecache/TestApplication.java @@ -1,7 +1,6 @@ package com.example.hibernatecache; import com.example.hibernatecache.common.ContainersConfig; -import java.io.File; import java.io.FileWriter; import java.io.IOException; import org.springframework.boot.SpringApplication; @@ -33,7 +32,7 @@ GenericContainer redisContainer() throws IOException { ymlContent.formatted(redisContainer.getHost(), redisContainer.getMappedPort(6379)); String resourcesPath = new ClassPathResource("").getURL().getPath(); String yamlFilePath = resourcesPath + "redisson-test.yml"; - try (FileWriter writer = new FileWriter(new File(yamlFilePath))) { + try (FileWriter writer = new FileWriter(yamlFilePath)) { writer.write(finalYml); } return redisContainer; diff --git a/jpa/boot-hibernate2ndlevelcache-sample/src/test/java/com/example/hibernatecache/web/controllers/CustomerControllerTest.java b/jpa/boot-hibernate2ndlevelcache-sample/src/test/java/com/example/hibernatecache/web/controllers/CustomerControllerTest.java index accf85882..e1258045f 100644 --- a/jpa/boot-hibernate2ndlevelcache-sample/src/test/java/com/example/hibernatecache/web/controllers/CustomerControllerTest.java +++ b/jpa/boot-hibernate2ndlevelcache-sample/src/test/java/com/example/hibernatecache/web/controllers/CustomerControllerTest.java @@ -23,8 +23,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; -import org.jetbrains.annotations.NotNull; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; @@ -45,22 +43,6 @@ class CustomerControllerTest { @Autowired private ObjectMapper objectMapper; - private List customerList; - - @BeforeEach - void setUp() { - this.customerList = new ArrayList<>(); - this.customerList.add( - new Customer( - 1L, "firstName 1", "lastName 1", "email1@junit.com", "9876543211", null)); - this.customerList.add( - new Customer( - 2L, "firstName 2", "lastName 2", "email2@junit.com", "9876543212", null)); - this.customerList.add( - new Customer( - 3L, "firstName 3", "lastName 3", "email3@junit.com", "9876543213", null)); - } - @Test void shouldFetchAllCustomers() throws Exception { List customerMappedList = getCustomerResponses(); @@ -82,7 +64,6 @@ void shouldFetchAllCustomers() throws Exception { .andExpect(jsonPath("$.hasPrevious", is(false))); } - @NotNull private static List getCustomerResponses() { List customerMappedList = new ArrayList<>(); customerMappedList.add( diff --git a/jpa/boot-hibernate2ndlevelcache-sample/src/test/java/com/example/hibernatecache/web/controllers/OrderControllerTest.java b/jpa/boot-hibernate2ndlevelcache-sample/src/test/java/com/example/hibernatecache/web/controllers/OrderControllerTest.java index b6ce91226..75919cd52 100644 --- a/jpa/boot-hibernate2ndlevelcache-sample/src/test/java/com/example/hibernatecache/web/controllers/OrderControllerTest.java +++ b/jpa/boot-hibernate2ndlevelcache-sample/src/test/java/com/example/hibernatecache/web/controllers/OrderControllerTest.java @@ -49,7 +49,7 @@ class OrderControllerTest { private List orderList; - Customer customer = + final Customer customer = new Customer(1L, "firstName 1", "lastName 1", "email1@junit.com", "9876543211", null); @BeforeEach diff --git a/jpa/boot-jpa-locks/README.md b/jpa/boot-jpa-locks/README.md index 7d8773155..6c9e0d3d4 100644 --- a/jpa/boot-jpa-locks/README.md +++ b/jpa/boot-jpa-locks/README.md @@ -14,8 +14,8 @@ Here's a brief overview of other propagation modes: The isolation and propagation levels you should use depend on your specific needs. In general: -* If you need to ensure that your data remains consistent and you want to prevent dirty reads, non-repeatable reads, and phantom reads, you should use a higher isolation level like **SERIALIZABLE**. However, this comes at the cost of performance, as it locks the data for the duration of the transaction. -* If performance is a priority and you can tolerate some inconsistencies, you should use a lower isolation level like **READ_UNCOMMITTED**. +* If you need to ensure that your data remains consistent, and you want to prevent dirty reads, non-repeatable reads, and phantom reads, you should use a higher isolation level like **SERIALIZABLE**. However, this comes at the cost of performance, as it locks the data for the duration of the transaction. +* If performance is a priority, and you can tolerate some inconsistencies, you should use a lower isolation level like **READ_UNCOMMITTED**. * Regarding propagation, if you need to execute multiple operations as a single unit of work, use **PROPAGATION_REQUIRED**. If you need to isolate some operations from your current transaction, use **PROPAGATION_REQUIRES_NEW**. If you're going to execute some operations outside a transaction, use PROPAGATION_SUPPORTS. Remember, choosing the right isolation and propagation level is a trade-off between data consistency and performance. diff --git a/jpa/boot-read-replica-postgresql/src/main/java/com/example/demo/readreplica/config/routing/RoutingDataSource.java b/jpa/boot-read-replica-postgresql/src/main/java/com/example/demo/readreplica/config/routing/RoutingDataSource.java index 9e35188d0..577340c9b 100644 --- a/jpa/boot-read-replica-postgresql/src/main/java/com/example/demo/readreplica/config/routing/RoutingDataSource.java +++ b/jpa/boot-read-replica-postgresql/src/main/java/com/example/demo/readreplica/config/routing/RoutingDataSource.java @@ -23,26 +23,4 @@ public static void setReplicaRoute() { protected Object determineCurrentLookupKey() { return routeContext.get(); } - - public boolean isWrapperFor(Class iface) throws java.sql.SQLException { - // TODO Auto-generated method stub - return iface != null && iface.isAssignableFrom(this.getClass()); - } - - public T unwrap(Class iface) throws java.sql.SQLException { - // TODO Auto-generated method stub - try { - if (iface != null && iface.isAssignableFrom(this.getClass())) { - return (T) this; - } - throw new java.sql.SQLException("Auto-generated unwrap failed; Revisit implementation"); - } catch (Exception e) { - throw new java.sql.SQLException(e); - } - } - - public java.util.logging.Logger getParentLogger() { - // TODO Auto-generated method stub - return null; - } } diff --git a/jpa/multitenancy/README.md b/jpa/multitenancy/README.md index 31b402058..9445b2d37 100644 --- a/jpa/multitenancy/README.md +++ b/jpa/multitenancy/README.md @@ -4,7 +4,7 @@ - This allows you to create a single entity class that can be shared by multiple tenants, giving each tenant its own independent instance of the data. -Lets see how it works by using three different approaches: +Let's see how it works by using three different approaches: > Partition tables by tenant id. -> Single table having partition (Supported Only from Hibernate 6) diff --git a/jpa/multitenancy/multidatasource-multitenancy/src/main/java/com/example/multitenancy/config/multidatasource/PrimaryDataSourceConfiguration.java b/jpa/multitenancy/multidatasource-multitenancy/src/main/java/com/example/multitenancy/config/multidatasource/PrimaryDataSourceConfiguration.java index 71cba6c6e..9ff952eba 100644 --- a/jpa/multitenancy/multidatasource-multitenancy/src/main/java/com/example/multitenancy/config/multidatasource/PrimaryDataSourceConfiguration.java +++ b/jpa/multitenancy/multidatasource-multitenancy/src/main/java/com/example/multitenancy/config/multidatasource/PrimaryDataSourceConfiguration.java @@ -37,9 +37,9 @@ LocalContainerEntityManagerFactoryBean primaryEntityManagerFactory( EntityManagerFactoryBuilder builder, @Qualifier("tenantRoutingDatasource") DataSource tenantRoutingDatasource, @Qualifier("multiTenantConnectionProviderImpl") - MultiTenantConnectionProvider multiTenantConnectionProvider, + MultiTenantConnectionProvider multiTenantConnectionProvider, @Qualifier("tenantIdentifierResolver") - CurrentTenantIdentifierResolver currentTenantIdentifierResolver) { + CurrentTenantIdentifierResolver currentTenantIdentifierResolver) { Map hibernateProps = new HashMap<>(); hibernateProps.put( AvailableSettings.MULTI_TENANT_CONNECTION_PROVIDER, multiTenantConnectionProvider); diff --git a/jpa/multitenancy/multidatasource-multitenancy/src/main/java/com/example/multitenancy/config/multidatasource/SecondaryDataSourceConfiguration.java b/jpa/multitenancy/multidatasource-multitenancy/src/main/java/com/example/multitenancy/config/multidatasource/SecondaryDataSourceConfiguration.java index 47d26ec80..6c4f09ca0 100644 --- a/jpa/multitenancy/multidatasource-multitenancy/src/main/java/com/example/multitenancy/config/multidatasource/SecondaryDataSourceConfiguration.java +++ b/jpa/multitenancy/multidatasource-multitenancy/src/main/java/com/example/multitenancy/config/multidatasource/SecondaryDataSourceConfiguration.java @@ -37,9 +37,9 @@ LocalContainerEntityManagerFactoryBean secondaryEntityManagerFactory( EntityManagerFactoryBuilder builder, @Qualifier("tenantRoutingDatasource") DataSource tenantRoutingDatasource, @Qualifier("multiTenantConnectionProviderImpl") - MultiTenantConnectionProvider multiTenantConnectionProvider, + MultiTenantConnectionProvider multiTenantConnectionProvider, @Qualifier("tenantIdentifierResolver") - CurrentTenantIdentifierResolver currentTenantIdentifierResolver) { + CurrentTenantIdentifierResolver currentTenantIdentifierResolver) { Map hibernateProps = new HashMap<>(); hibernateProps.put( AvailableSettings.MULTI_TENANT_CONNECTION_PROVIDER, multiTenantConnectionProvider); diff --git a/jpa/multitenancy/multidatasource-multitenancy/src/main/java/com/example/multitenancy/config/multitenant/TenantIdentifierResolver.java b/jpa/multitenancy/multidatasource-multitenancy/src/main/java/com/example/multitenancy/config/multitenant/TenantIdentifierResolver.java index 4f8e3d4ec..6ae0a8366 100644 --- a/jpa/multitenancy/multidatasource-multitenancy/src/main/java/com/example/multitenancy/config/multitenant/TenantIdentifierResolver.java +++ b/jpa/multitenancy/multidatasource-multitenancy/src/main/java/com/example/multitenancy/config/multitenant/TenantIdentifierResolver.java @@ -10,7 +10,7 @@ @Component("tenantIdentifierResolver") public class TenantIdentifierResolver - implements CurrentTenantIdentifierResolver, HibernatePropertiesCustomizer { + implements CurrentTenantIdentifierResolver, HibernatePropertiesCustomizer { private String currentTenant = "unknown"; diff --git a/jpa/multitenancy/multidatasource-multitenancy/src/main/java/com/example/multitenancy/config/multitenant/TenantRoutingDatasource.java b/jpa/multitenancy/multidatasource-multitenancy/src/main/java/com/example/multitenancy/config/multitenant/TenantRoutingDatasource.java index 25bb466d6..191a915e6 100644 --- a/jpa/multitenancy/multidatasource-multitenancy/src/main/java/com/example/multitenancy/config/multitenant/TenantRoutingDatasource.java +++ b/jpa/multitenancy/multidatasource-multitenancy/src/main/java/com/example/multitenancy/config/multitenant/TenantRoutingDatasource.java @@ -37,26 +37,4 @@ public class TenantRoutingDatasource extends AbstractRoutingDataSource { protected String determineCurrentLookupKey() { return tenantIdentifierResolver.resolveCurrentTenantIdentifier(); } - - public boolean isWrapperFor(Class iface) throws java.sql.SQLException { - // TODO Auto-generated method stub - return iface != null && iface.isAssignableFrom(this.getClass()); - } - - public T unwrap(Class iface) throws java.sql.SQLException { - // TODO Auto-generated method stub - try { - if (iface != null && iface.isAssignableFrom(this.getClass())) { - return (T) this; - } - throw new java.sql.SQLException("Auto-generated unwrap failed; Revisit implementation"); - } catch (Exception e) { - throw new java.sql.SQLException(e); - } - } - - public java.util.logging.Logger getParentLogger() { - // TODO Auto-generated method stub - return null; - } } diff --git a/jpa/multitenancy/multidatasource-multitenancy/src/main/java/com/example/multitenancy/utils/DatabaseType.java b/jpa/multitenancy/multidatasource-multitenancy/src/main/java/com/example/multitenancy/utils/DatabaseType.java index 7bd923c92..af94e607a 100644 --- a/jpa/multitenancy/multidatasource-multitenancy/src/main/java/com/example/multitenancy/utils/DatabaseType.java +++ b/jpa/multitenancy/multidatasource-multitenancy/src/main/java/com/example/multitenancy/utils/DatabaseType.java @@ -1,5 +1,8 @@ package com.example.multitenancy.utils; +import lombok.Getter; + +@Getter public enum DatabaseType { PRIMARY("primary"), SECONDARY("secondary"), @@ -11,11 +14,8 @@ public enum DatabaseType { private final String schemaName; - private DatabaseType(String schemaName) { + DatabaseType(String schemaName) { this.schemaName = schemaName; } - public String getSchemaName() { - return this.schemaName; - } } diff --git a/jpa/multitenancy/multitenancy-db/src/main/java/com/example/multitenancy/db/config/multitenant/TenantIdentifierResolver.java b/jpa/multitenancy/multitenancy-db/src/main/java/com/example/multitenancy/db/config/multitenant/TenantIdentifierResolver.java index 986ee8dcc..700395481 100644 --- a/jpa/multitenancy/multitenancy-db/src/main/java/com/example/multitenancy/db/config/multitenant/TenantIdentifierResolver.java +++ b/jpa/multitenancy/multitenancy-db/src/main/java/com/example/multitenancy/db/config/multitenant/TenantIdentifierResolver.java @@ -10,7 +10,7 @@ @Component public class TenantIdentifierResolver - implements CurrentTenantIdentifierResolver, HibernatePropertiesCustomizer { + implements CurrentTenantIdentifierResolver, HibernatePropertiesCustomizer { private String currentTenant = "unknown"; diff --git a/jpa/multitenancy/multitenancy-db/src/main/java/com/example/multitenancy/db/config/multitenant/TenantRoutingDatasource.java b/jpa/multitenancy/multitenancy-db/src/main/java/com/example/multitenancy/db/config/multitenant/TenantRoutingDatasource.java index e0651c35c..6f9546ddb 100644 --- a/jpa/multitenancy/multitenancy-db/src/main/java/com/example/multitenancy/db/config/multitenant/TenantRoutingDatasource.java +++ b/jpa/multitenancy/multitenancy-db/src/main/java/com/example/multitenancy/db/config/multitenant/TenantRoutingDatasource.java @@ -31,26 +31,4 @@ public class TenantRoutingDatasource extends AbstractRoutingDataSource { protected String determineCurrentLookupKey() { return tenantIdentifierResolver.resolveCurrentTenantIdentifier(); } - - public boolean isWrapperFor(Class iface) throws java.sql.SQLException { - // TODO Auto-generated method stub - return iface != null && iface.isAssignableFrom(this.getClass()); - } - - public T unwrap(Class iface) throws java.sql.SQLException { - // TODO Auto-generated method stub - try { - if (iface != null && iface.isAssignableFrom(this.getClass())) { - return (T) this; - } - throw new java.sql.SQLException("Auto-generated unwrap failed; Revisit implementation"); - } catch (Exception e) { - throw new java.sql.SQLException(e); - } - } - - public java.util.logging.Logger getParentLogger() { - // TODO Auto-generated method stub - return null; - } } diff --git a/jpa/multitenancy/partition/src/main/java/com/example/multitenancy/partition/config/tenant/TenantIdentifierResolver.java b/jpa/multitenancy/partition/src/main/java/com/example/multitenancy/partition/config/tenant/TenantIdentifierResolver.java index a0e98de29..3b62d40a6 100644 --- a/jpa/multitenancy/partition/src/main/java/com/example/multitenancy/partition/config/tenant/TenantIdentifierResolver.java +++ b/jpa/multitenancy/partition/src/main/java/com/example/multitenancy/partition/config/tenant/TenantIdentifierResolver.java @@ -1,21 +1,20 @@ package com.example.multitenancy.partition.config.tenant; import java.util.Map; + +import lombok.Setter; import org.hibernate.cfg.AvailableSettings; import org.hibernate.context.spi.CurrentTenantIdentifierResolver; import org.springframework.boot.autoconfigure.orm.jpa.HibernatePropertiesCustomizer; import org.springframework.stereotype.Component; +@Setter @Component() public class TenantIdentifierResolver - implements CurrentTenantIdentifierResolver, HibernatePropertiesCustomizer { + implements CurrentTenantIdentifierResolver, HibernatePropertiesCustomizer { private String currentTenant = "unknown"; - public void setCurrentTenant(String tenant) { - currentTenant = tenant; - } - @Override public String resolveCurrentTenantIdentifier() { return currentTenant; diff --git a/jpa/multitenancy/partition/src/main/resources/application-heroku.properties b/jpa/multitenancy/partition/src/main/resources/application-heroku.properties deleted file mode 100644 index 6a400b909..000000000 --- a/jpa/multitenancy/partition/src/main/resources/application-heroku.properties +++ /dev/null @@ -1,2 +0,0 @@ -spring.datasource.driver-class-name=org.postgresql.Driver -spring.datasource.url=${JDBC_DATABASE_URL} diff --git a/jpa/multitenancy/partition/src/test/java/com/example/multitenancy/partition/ApplicationIntegrationTest.java b/jpa/multitenancy/partition/src/test/java/com/example/multitenancy/partition/ApplicationIntegrationTest.java index 055258256..f016c0465 100644 --- a/jpa/multitenancy/partition/src/test/java/com/example/multitenancy/partition/ApplicationIntegrationTest.java +++ b/jpa/multitenancy/partition/src/test/java/com/example/multitenancy/partition/ApplicationIntegrationTest.java @@ -117,7 +117,7 @@ void findById() { final Customer vRock = createCustomer(SUBSYSTEM_V, "Rock"); tenantIdentifierResolver.setCurrentTenant(SUBSYSTEM_V); - assertThat(customerRepository.findById(vRock.getId())).isPresent(); + assertThat(customerRepository.findById(vRock.getId())).isPresent().isNotEmpty(); assertThat(customerRepository.findById(vRock.getId()).get().getTenant()) .isEqualTo(SUBSYSTEM_V); assertThat(customerRepository.findById(rock.getId())).isEmpty(); diff --git a/jpa/multitenancy/schema/src/main/java/com/example/multitenancy/schema/config/multitenancy/TenantIdentifierResolver.java b/jpa/multitenancy/schema/src/main/java/com/example/multitenancy/schema/config/multitenancy/TenantIdentifierResolver.java index 46b7b215a..0cb265901 100644 --- a/jpa/multitenancy/schema/src/main/java/com/example/multitenancy/schema/config/multitenancy/TenantIdentifierResolver.java +++ b/jpa/multitenancy/schema/src/main/java/com/example/multitenancy/schema/config/multitenancy/TenantIdentifierResolver.java @@ -1,21 +1,20 @@ package com.example.multitenancy.schema.config.multitenancy; import java.util.Map; + +import lombok.Setter; import org.hibernate.cfg.AvailableSettings; import org.hibernate.context.spi.CurrentTenantIdentifierResolver; import org.springframework.boot.autoconfigure.orm.jpa.HibernatePropertiesCustomizer; import org.springframework.stereotype.Component; +@Setter @Component public class TenantIdentifierResolver - implements CurrentTenantIdentifierResolver, HibernatePropertiesCustomizer { + implements CurrentTenantIdentifierResolver, HibernatePropertiesCustomizer { private String currentTenant = "unknown"; - public void setCurrentTenant(String tenant) { - currentTenant = tenant; - } - @Override public String resolveCurrentTenantIdentifier() { return currentTenant; diff --git a/jpa/multitenancy/schema/src/main/java/com/example/multitenancy/schema/utils/TenantNameType.java b/jpa/multitenancy/schema/src/main/java/com/example/multitenancy/schema/utils/TenantNameType.java index 5c6467ab9..a24796962 100644 --- a/jpa/multitenancy/schema/src/main/java/com/example/multitenancy/schema/utils/TenantNameType.java +++ b/jpa/multitenancy/schema/src/main/java/com/example/multitenancy/schema/utils/TenantNameType.java @@ -1,16 +1,16 @@ package com.example.multitenancy.schema.utils; +import lombok.Getter; + +@Getter public enum TenantNameType { TEST1("test1"), TEST2("test2"); private final String tenantName; - private TenantNameType(String tenantName) { + TenantNameType(String tenantName) { this.tenantName = tenantName; } - public String getTenantName() { - return this.tenantName; - } } diff --git a/jpa/multitenancy/schema/src/main/resources/application-heroku.properties b/jpa/multitenancy/schema/src/main/resources/application-heroku.properties deleted file mode 100644 index 6a400b909..000000000 --- a/jpa/multitenancy/schema/src/main/resources/application-heroku.properties +++ /dev/null @@ -1,2 +0,0 @@ -spring.datasource.driver-class-name=org.postgresql.Driver -spring.datasource.url=${JDBC_DATABASE_URL} From a6ab1a42a978482814427c68fa48c52e19985645 Mon Sep 17 00:00:00 2001 From: rajadilipkolli Date: Fri, 14 Jun 2024 22:27:32 +0530 Subject: [PATCH 2/5] polish code --- .../architecture/CustomConditions.java | 6 ++--- .../gatling/CustomerRequestSimulation.java | 6 ++--- .../provisioning/datasources/datasource.yml | 3 +-- .../mongoes/web/service/SearchService.java | 2 +- ...RestaurantESRepositoryIntegrationTest.java | 22 +++++++++---------- .../opensearch/config/Initializer.java | 2 +- .../services/RestaurantSearchService.java | 2 +- .../opensearch/common/ContainersConfig.java | 4 ++-- .../web/controllers/UserControllerTest.java | 2 -- boot-strategy-plugin/docker-compose-app.yml | 2 +- .../provisioning/datasources/datasource.yml | 3 +-- .../ultimateredis/config/CacheConfig.java | 5 +---- .../graphql/querydsl/entities/Post.java | 2 +- .../GlobalErrorWebExceptionHandler.java | 12 ---------- .../provisioning/datasources/datasource.yml | 3 +-- .../config/graphql/LocalDateTimeScalar.java | 18 ++++++--------- .../graphql/services/AuthorService.java | 3 ++- .../graphql/services/PostDetailsService.java | 4 ++-- .../controllers/PostDetailsController.java | 8 +++++-- .../PostDetailsEntityControllerTest.java | 2 +- .../controllers/PostEntityControllerTest.java | 2 +- .../web/controllers/PostControllerTest.java | 13 +---------- .../exception/GlobalExceptionHandler.java | 2 +- .../resources/application-heroku.properties | 2 -- .../web/controllers/PostControllerTest.java | 2 +- .../config/GlobalExceptionHandler.java | 2 +- .../jooq/r2dbc/config/Initializer.java | 2 +- .../jooq/r2dbc/config/JooqConfiguration.java | 4 ++-- .../example/jooq/r2dbc/entities/Status.java | 2 +- .../ReactiveCommentsControllerTest.java | 2 +- .../quartz/model/common/Message.java | 11 +++------- techstack.md | 2 +- 32 files changed, 60 insertions(+), 97 deletions(-) delete mode 100644 httpClients/boot-web-client-mvc/src/main/resources/application-heroku.properties diff --git a/boot-api-archunit-sample/src/test/java/com/example/archunit/architecture/CustomConditions.java b/boot-api-archunit-sample/src/test/java/com/example/archunit/architecture/CustomConditions.java index 1de11c395..2cceec089 100644 --- a/boot-api-archunit-sample/src/test/java/com/example/archunit/architecture/CustomConditions.java +++ b/boot-api-archunit-sample/src/test/java/com/example/archunit/architecture/CustomConditions.java @@ -43,7 +43,7 @@ public static ArchCondition haveGetterAndSetter(Map e private static ArchCondition buildFieldHaveGetterAndSetterCondition( boolean forceSetters, Map exclusions) { - return new ArchCondition( + return new ArchCondition<>( forceSetters ? HAVE_GETTER_AND_SETTER_DESCRIPTION : HAVE_GETTER_DESCRIPTION) { @Override @@ -84,7 +84,7 @@ public void check(JavaField field, ConditionEvents events) { } private static ArchCondition buildClassHaveEqualsAndHashCodeCondition() { - return new ArchCondition(EQUALS_AND_HASH_CODE_DESCRIPTION) { + return new ArchCondition<>(EQUALS_AND_HASH_CODE_DESCRIPTION) { @Override public void check(JavaClass javaClass, ConditionEvents events) { @@ -109,7 +109,7 @@ public void check(JavaClass javaClass, ConditionEvents events) { } private static ArchCondition buildStaticMethodsAreNotAllowedCondition() { - return new ArchCondition(EQUALS_AND_HASH_CODE_DESCRIPTION) { + return new ArchCondition<>(EQUALS_AND_HASH_CODE_DESCRIPTION) { @Override public void check(JavaClass javaClass, ConditionEvents events) { diff --git a/boot-choas-monkey/src/test/java/com/example/choasmonkey/gatling/CustomerRequestSimulation.java b/boot-choas-monkey/src/test/java/com/example/choasmonkey/gatling/CustomerRequestSimulation.java index 7a0cc3fba..bc98dfff2 100644 --- a/boot-choas-monkey/src/test/java/com/example/choasmonkey/gatling/CustomerRequestSimulation.java +++ b/boot-choas-monkey/src/test/java/com/example/choasmonkey/gatling/CustomerRequestSimulation.java @@ -21,12 +21,12 @@ public class CustomerRequestSimulation extends Simulation { - HttpProtocolBuilder httpProtocol = + final HttpProtocolBuilder httpProtocol = http.baseUrl("http://localhost:8080") .acceptHeader("application/json") .userAgentHeader("Gatling/Performance Test"); - Iterator> feeder = + final Iterator> feeder = Stream.generate( (Supplier>) () -> @@ -34,7 +34,7 @@ public class CustomerRequestSimulation extends Simulation { "text", UUID.randomUUID().toString())) .iterator(); - ScenarioBuilder scn = + final ScenarioBuilder scn = CoreDsl.scenario("Load Test Creating Customers") .feed(feeder) .exec( diff --git a/boot-mongodb-elasticsearch/config/grafana/provisioning/datasources/datasource.yml b/boot-mongodb-elasticsearch/config/grafana/provisioning/datasources/datasource.yml index 4e58703f2..d7903a939 100755 --- a/boot-mongodb-elasticsearch/config/grafana/provisioning/datasources/datasource.yml +++ b/boot-mongodb-elasticsearch/config/grafana/provisioning/datasources/datasource.yml @@ -6,8 +6,7 @@ deleteDatasources: - name: Prometheus orgId: 1 -# list of datasources to insert/update depending -# whats available in the database +# list of datasources to insert/update depending on what's available in the database datasources: # name of the datasource. Required - name: Prometheus diff --git a/boot-mongodb-elasticsearch/src/main/java/com/example/mongoes/web/service/SearchService.java b/boot-mongodb-elasticsearch/src/main/java/com/example/mongoes/web/service/SearchService.java index 7ad5cfc4f..cde6d37cf 100644 --- a/boot-mongodb-elasticsearch/src/main/java/com/example/mongoes/web/service/SearchService.java +++ b/boot-mongodb-elasticsearch/src/main/java/com/example/mongoes/web/service/SearchService.java @@ -133,7 +133,7 @@ public Mono aggregateSearch( }); } - Function, Map>> + final Function, Map>> aggregationFunction = aggregationMap -> { Map> resultMap = new HashMap<>(); diff --git a/boot-mongodb-elasticsearch/src/test/java/com/example/mongoes/elasticsearch/repository/RestaurantESRepositoryIntegrationTest.java b/boot-mongodb-elasticsearch/src/test/java/com/example/mongoes/elasticsearch/repository/RestaurantESRepositoryIntegrationTest.java index 37a638241..4984f274b 100644 --- a/boot-mongodb-elasticsearch/src/test/java/com/example/mongoes/elasticsearch/repository/RestaurantESRepositoryIntegrationTest.java +++ b/boot-mongodb-elasticsearch/src/test/java/com/example/mongoes/elasticsearch/repository/RestaurantESRepositoryIntegrationTest.java @@ -160,7 +160,7 @@ void findByBoroughOrCuisineOrName() { assertThat(searchPage.isEmpty()).isFalse(); assertThat(searchPage.hasContent()).isTrue(); assertThat(searchPage.stream().count()).isEqualTo(2); - Restaurant restaurant1 = searchPage.getContent().get(0).getContent(); + Restaurant restaurant1 = searchPage.getContent().getFirst().getContent(); assertThat(restaurant1.getRestaurantId()).isEqualTo(2L); assertThat(restaurant1.getName()).isEqualTo(RESTAURANT_NAME); assertThat(restaurant1.getBorough()).isEqualTo(BOROUGH_NAME); @@ -208,7 +208,7 @@ void termQueryForBorough() { assertThat(searchPage.isEmpty()).isFalse(); assertThat(searchPage.hasContent()).isTrue(); assertThat(searchPage.stream().count()).isEqualTo(2); - Restaurant restaurant1 = searchPage.getContent().get(0).getContent(); + Restaurant restaurant1 = searchPage.getContent().getFirst().getContent(); assertThat(restaurant1.getRestaurantId()).isEqualTo(2L); assertThat(restaurant1.getName()).isEqualTo(RESTAURANT_NAME); assertThat(restaurant1.getBorough()).isEqualTo(BOROUGH_NAME); @@ -235,7 +235,7 @@ void termsQueryForBorough() { assertThat(searchPage.isEmpty()).isFalse(); assertThat(searchPage.hasContent()).isTrue(); assertThat(searchPage.stream().count()).isEqualTo(2); - Restaurant restaurant1 = searchPage.getContent().get(0).getContent(); + Restaurant restaurant1 = searchPage.getContent().getFirst().getContent(); assertThat(restaurant1.getRestaurantId()).isEqualTo(2L); assertThat(restaurant1.getName()).isEqualTo(RESTAURANT_NAME); assertThat(restaurant1.getBorough()).isEqualTo(BOROUGH_NAME); @@ -264,7 +264,7 @@ void queryBoolWithShould() { assertThat(searchPage.isEmpty()).isFalse(); assertThat(searchPage.hasContent()).isTrue(); assertThat(searchPage.stream().count()).isEqualTo(2); - Restaurant restaurant1 = searchPage.getContent().get(0).getContent(); + Restaurant restaurant1 = searchPage.getContent().getFirst().getContent(); assertThat(restaurant1.getRestaurantId()).isEqualTo(2L); assertThat(restaurant1.getName()).isEqualTo(RESTAURANT_NAME); assertThat(restaurant1.getBorough()).isEqualTo(BOROUGH_NAME); @@ -304,7 +304,7 @@ void wildcardSearch() { assertThat(searchPage.isEmpty()).isFalse(); assertThat(searchPage.hasContent()).isTrue(); assertThat(searchPage.stream().count()).isEqualTo(1); - Restaurant restaurant1 = searchPage.getContent().get(0).getContent(); + Restaurant restaurant1 = searchPage.getContent().getFirst().getContent(); assertThat(restaurant1.getRestaurantId()).isEqualTo(40363920L); assertThat(restaurant1.getName()).isEqualTo("Yono gardens"); assertThat(restaurant1.getBorough()).isEqualTo(BOROUGH_NAME); @@ -331,7 +331,7 @@ void regExpSearch() { assertThat(searchPage.isEmpty()).isFalse(); assertThat(searchPage.hasContent()).isTrue(); assertThat(searchPage.stream().count()).isEqualTo(2); - Restaurant restaurant1 = searchPage.getContent().get(0).getContent(); + Restaurant restaurant1 = searchPage.getContent().getFirst().getContent(); assertThat(restaurant1.getRestaurantId()).isEqualTo(2L); assertThat(restaurant1.getName()).isEqualTo(RESTAURANT_NAME); assertThat(restaurant1.getBorough()).isEqualTo(BOROUGH_NAME); @@ -358,7 +358,7 @@ void searchSimpleQueryForBoroughAndCuisine() { assertThat(searchPage.isEmpty()).isFalse(); assertThat(searchPage.hasContent()).isTrue(); assertThat(searchPage.stream().count()).isEqualTo(2); - Restaurant restaurant1 = searchPage.getContent().get(0).getContent(); + Restaurant restaurant1 = searchPage.getContent().getFirst().getContent(); assertThat(restaurant1.getRestaurantId()).isEqualTo(2L); assertThat(restaurant1.getName()).isEqualTo(RESTAURANT_NAME); assertThat(restaurant1.getBorough()).isEqualTo(BOROUGH_NAME); @@ -383,7 +383,7 @@ void searchRestaurantIdRange() { assertThat(searchPage.isEmpty()).isFalse(); assertThat(searchPage.hasContent()).isTrue(); assertThat(searchPage.stream().count()).isEqualTo(1); - Restaurant restaurant1 = searchPage.getContent().get(0).getContent(); + Restaurant restaurant1 = searchPage.getContent().getFirst().getContent(); assertThat(restaurant1.getRestaurantId()).isEqualTo(2L); assertThat(restaurant1.getName()).isEqualTo(RESTAURANT_NAME); assertThat(restaurant1.getBorough()).isEqualTo(BOROUGH_NAME); @@ -411,7 +411,7 @@ void searchDateRange() { assertThat(searchPage.isEmpty()).isFalse(); assertThat(searchPage.hasContent()).isTrue(); assertThat(searchPage.stream().count()).isEqualTo(2); - Restaurant restaurant1 = searchPage.getContent().get(0).getContent(); + Restaurant restaurant1 = searchPage.getContent().getFirst().getContent(); assertThat(restaurant1.getRestaurantId()).isEqualTo(2L); assertThat(restaurant1.getName()).isEqualTo(RESTAURANT_NAME); assertThat(restaurant1.getBorough()).isEqualTo(BOROUGH_NAME); @@ -437,7 +437,7 @@ void findAll() { assertThat(searchPage.isEmpty()).isFalse(); assertThat(searchPage.hasContent()).isTrue(); assertThat(searchPage.stream().count()).isEqualTo(2); - Restaurant restaurant1 = searchPage.getContent().get(0).getContent(); + Restaurant restaurant1 = searchPage.getContent().getFirst().getContent(); assertThat(restaurant1.getRestaurantId()).isEqualTo(2L); assertThat(restaurant1.getName()).isEqualTo(RESTAURANT_NAME); assertThat(restaurant1.getBorough()).isEqualTo(BOROUGH_NAME); @@ -471,7 +471,7 @@ void aggregation() { .isNotNull() .isExactlyInstanceOf(ElasticsearchAggregations.class); assertThat(searchPage.stream().count()).isEqualTo(1); - Restaurant restaurant1 = searchPage.getContent().get(0).getContent(); + Restaurant restaurant1 = searchPage.getContent().getFirst().getContent(); assertThat(restaurant1.getRestaurantId()).isEqualTo(2L); assertThat(restaurant1.getName()).isEqualTo(RESTAURANT_NAME); assertThat(restaurant1.getBorough()).isEqualTo(BOROUGH_NAME); diff --git a/boot-opensearch-sample/src/main/java/com/example/opensearch/config/Initializer.java b/boot-opensearch-sample/src/main/java/com/example/opensearch/config/Initializer.java index 976c974df..5dc7b7cc4 100644 --- a/boot-opensearch-sample/src/main/java/com/example/opensearch/config/Initializer.java +++ b/boot-opensearch-sample/src/main/java/com/example/opensearch/config/Initializer.java @@ -18,6 +18,6 @@ public Initializer(ApplicationProperties properties) { @Override public void run(String... args) { - log.info("Running Initializer....."); + log.info("Running Initializer..... {}", properties.getCors()); } } diff --git a/boot-opensearch-sample/src/main/java/com/example/opensearch/services/RestaurantSearchService.java b/boot-opensearch-sample/src/main/java/com/example/opensearch/services/RestaurantSearchService.java index beb1c9c0f..ece8adcd2 100644 --- a/boot-opensearch-sample/src/main/java/com/example/opensearch/services/RestaurantSearchService.java +++ b/boot-opensearch-sample/src/main/java/com/example/opensearch/services/RestaurantSearchService.java @@ -126,7 +126,7 @@ public PagedResult aggregateSearch( return new PagedResult<>(searchPage, map); } - Function, Map>> aggregationFunction = + final Function, Map>> aggregationFunction = aggregationMap -> { Map> resultMap = new HashMap<>(); aggregationMap.forEach( diff --git a/boot-opensearch-sample/src/test/java/com/example/opensearch/common/ContainersConfig.java b/boot-opensearch-sample/src/test/java/com/example/opensearch/common/ContainersConfig.java index 290bede6e..a26151678 100644 --- a/boot-opensearch-sample/src/test/java/com/example/opensearch/common/ContainersConfig.java +++ b/boot-opensearch-sample/src/test/java/com/example/opensearch/common/ContainersConfig.java @@ -9,7 +9,7 @@ public class ContainersConfig { @Container - public static OpensearchContainer openSearchContainer = + public static final OpensearchContainer openSearchContainer = new OpensearchContainer<>(DockerImageName.parse("opensearchproject/opensearch:2.14.0")) .withEnv("OPENSEARCH_INITIAL_ADMIN_PASSWORD", "admin"); @@ -20,6 +20,6 @@ public class ContainersConfig { @DynamicPropertySource static void setApplicationProperties(DynamicPropertyRegistry dynamicPropertyRegistry) { dynamicPropertyRegistry.add( - "opensearch.uris", () -> openSearchContainer.getHttpHostAddress()); + "opensearch.uris", openSearchContainer::getHttpHostAddress); } } diff --git a/boot-rest-docs-sample/src/test/java/com/example/restdocs/web/controllers/UserControllerTest.java b/boot-rest-docs-sample/src/test/java/com/example/restdocs/web/controllers/UserControllerTest.java index 0a6679fbe..3ba422e96 100644 --- a/boot-rest-docs-sample/src/test/java/com/example/restdocs/web/controllers/UserControllerTest.java +++ b/boot-rest-docs-sample/src/test/java/com/example/restdocs/web/controllers/UserControllerTest.java @@ -128,7 +128,6 @@ void shouldFindUserById() throws Exception { parameterWithName("id") .description("The id of the user to retrieve")), responseFields(getUserFieldDescriptor()))); - ; } @Test @@ -165,7 +164,6 @@ void shouldCreateNewUser() throws Exception { preprocessResponse(prettyPrint()), requestFields(getUserRequestFieldDescriptor()), responseFields(getUserFieldDescriptor()))); - ; } @Test diff --git a/boot-strategy-plugin/docker-compose-app.yml b/boot-strategy-plugin/docker-compose-app.yml index cb23f6c4a..51e4113ca 100644 --- a/boot-strategy-plugin/docker-compose-app.yml +++ b/boot-strategy-plugin/docker-compose-app.yml @@ -5,7 +5,7 @@ services: image: ghcr.io/rajadilipkolli/my-spring-boot-experiments/boot-strategy-plugin:latest container_name: strategy-plugin-service ports: - - 8080:8080 + - "8080:8080" depends_on: grafana: condition: service_healthy diff --git a/boot-togglz-sample/config/grafana/provisioning/datasources/datasource.yml b/boot-togglz-sample/config/grafana/provisioning/datasources/datasource.yml index 4e58703f2..d7903a939 100755 --- a/boot-togglz-sample/config/grafana/provisioning/datasources/datasource.yml +++ b/boot-togglz-sample/config/grafana/provisioning/datasources/datasource.yml @@ -6,8 +6,7 @@ deleteDatasources: - name: Prometheus orgId: 1 -# list of datasources to insert/update depending -# whats available in the database +# list of datasources to insert/update depending on what's available in the database datasources: # name of the datasource. Required - name: Prometheus diff --git a/boot-ultimate-redis/src/main/java/com/example/ultimateredis/config/CacheConfig.java b/boot-ultimate-redis/src/main/java/com/example/ultimateredis/config/CacheConfig.java index 987ef0d6e..806ada207 100644 --- a/boot-ultimate-redis/src/main/java/com/example/ultimateredis/config/CacheConfig.java +++ b/boot-ultimate-redis/src/main/java/com/example/ultimateredis/config/CacheConfig.java @@ -38,10 +38,7 @@ RedisCacheConfiguration defaultCacheConfig() { @Bean LettuceConnectionFactory redisConnectionFactory(CacheConfigurationProperties properties) { - log.info( - "Redis (/Lettuce) configuration enabled. With cache timeout " - + properties.getTimeoutSeconds() - + " seconds."); + log.info("Redis (/Lettuce) configuration enabled. With cache timeout {} seconds.", properties.getTimeoutSeconds()); RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration(); diff --git a/graphql/boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/entities/Post.java b/graphql/boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/entities/Post.java index adba0c790..9fdd04896 100644 --- a/graphql/boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/entities/Post.java +++ b/graphql/boot-graphql-querydsl/src/main/java/com/example/graphql/querydsl/entities/Post.java @@ -31,7 +31,7 @@ public class Post { private List comments = new ArrayList<>(); @JoinColumn(name = "details_Id") - @OneToOne(cascade = CascadeType.ALL, mappedBy = "post", orphanRemoval = true, fetch = FetchType.LAZY) + @OneToOne(cascade = CascadeType.ALL, mappedBy = "post", orphanRemoval = true) private PostDetails details; @OneToMany(mappedBy = "post", cascade = CascadeType.ALL, orphanRemoval = true) diff --git a/graphql/boot-graphql-webflux/src/main/java/com/example/graphql/exception/GlobalErrorWebExceptionHandler.java b/graphql/boot-graphql-webflux/src/main/java/com/example/graphql/exception/GlobalErrorWebExceptionHandler.java index b56a09972..e68996ba1 100644 --- a/graphql/boot-graphql-webflux/src/main/java/com/example/graphql/exception/GlobalErrorWebExceptionHandler.java +++ b/graphql/boot-graphql-webflux/src/main/java/com/example/graphql/exception/GlobalErrorWebExceptionHandler.java @@ -1,18 +1,14 @@ package com.example.graphql.exception; -import java.util.Map; import org.springframework.boot.autoconfigure.web.ErrorProperties; import org.springframework.boot.autoconfigure.web.WebProperties; import org.springframework.boot.autoconfigure.web.reactive.error.DefaultErrorWebExceptionHandler; import org.springframework.boot.web.reactive.error.ErrorAttributes; import org.springframework.context.ApplicationContext; import org.springframework.core.annotation.Order; -import org.springframework.http.MediaType; import org.springframework.http.codec.ServerCodecConfigurer; import org.springframework.stereotype.Component; -import org.springframework.web.reactive.function.BodyInserters; import org.springframework.web.reactive.function.server.*; -import reactor.core.publisher.Mono; @Component @Order(-2) @@ -33,12 +29,4 @@ protected RouterFunction getRoutingFunction(ErrorAttributes erro return RouterFunctions.route(RequestPredicates.all(), this::renderErrorResponse); } - @Override - protected Mono renderErrorResponse(ServerRequest request) { - Map error = - this.getErrorAttributes(request, this.getErrorAttributeOptions(request, MediaType.ALL)); - return ServerResponse.status(this.getHttpStatus(error)) - .contentType(MediaType.APPLICATION_JSON) - .body(BodyInserters.fromValue(error)); - } } diff --git a/graphql/boot-graphql-webmvc/config/grafana/provisioning/datasources/datasource.yml b/graphql/boot-graphql-webmvc/config/grafana/provisioning/datasources/datasource.yml index 96ec9f904..78c91f6d9 100644 --- a/graphql/boot-graphql-webmvc/config/grafana/provisioning/datasources/datasource.yml +++ b/graphql/boot-graphql-webmvc/config/grafana/provisioning/datasources/datasource.yml @@ -5,8 +5,7 @@ deleteDatasources: - name: Prometheus orgId: 1 -# list of datasources to insert/update depending -# whats available in the database +# list of datasources to insert/update depending on what's available in the database datasources: - name: Prometheus type: prometheus diff --git a/graphql/boot-graphql-webmvc/src/main/java/com/example/graphql/config/graphql/LocalDateTimeScalar.java b/graphql/boot-graphql-webmvc/src/main/java/com/example/graphql/config/graphql/LocalDateTimeScalar.java index 0c02dba8b..8d67c83b5 100644 --- a/graphql/boot-graphql-webmvc/src/main/java/com/example/graphql/config/graphql/LocalDateTimeScalar.java +++ b/graphql/boot-graphql-webmvc/src/main/java/com/example/graphql/config/graphql/LocalDateTimeScalar.java @@ -55,17 +55,13 @@ public LocalDateTime parseValue( // Will be String if the value is specified via external variables object, // and a StringValue // if provided direct in the query. - if (input instanceof StringValue stringValue) { - return parseString(stringValue.getValue()); - } - if (input instanceof String inputString) { - return parseString(inputString); - } - if (input instanceof LocalDateTime localDateTime) { - return localDateTime; - } - throw new CoercingParseValueException( - "Expected a 'String' but was '" + typeName(input) + "'."); + return switch (input) { + case StringValue stringValue -> parseString(stringValue.getValue()); + case String inputString -> parseString(inputString); + case LocalDateTime localDateTime -> localDateTime; + default -> throw new CoercingParseValueException( + "Expected a 'String' but was '" + typeName(input) + "'."); + }; } private LocalDateTime parseString(String input) { diff --git a/graphql/boot-graphql-webmvc/src/main/java/com/example/graphql/services/AuthorService.java b/graphql/boot-graphql-webmvc/src/main/java/com/example/graphql/services/AuthorService.java index 72a89c8af..75e84dc82 100644 --- a/graphql/boot-graphql-webmvc/src/main/java/com/example/graphql/services/AuthorService.java +++ b/graphql/boot-graphql-webmvc/src/main/java/com/example/graphql/services/AuthorService.java @@ -7,6 +7,7 @@ import com.example.graphql.model.response.AuthorResponse; import com.example.graphql.repositories.AuthorRepository; import java.util.List; +import java.util.Objects; import java.util.Optional; import lombok.RequiredArgsConstructor; import org.springframework.core.convert.ConversionService; @@ -45,7 +46,7 @@ public AuthorResponse saveAuthor(AuthorRequest authorRequest) { AuthorEntity authorEntity = this.appConversionService.convert(authorRequest, AuthorEntity.class); return this.appConversionService.convert( - authorRepository.save(authorEntity), AuthorResponse.class); + authorRepository.save(Objects.requireNonNull(authorEntity)), AuthorResponse.class); } public Optional updateAuthor(AuthorRequest authorRequest, Long id) { diff --git a/graphql/boot-graphql-webmvc/src/main/java/com/example/graphql/services/PostDetailsService.java b/graphql/boot-graphql-webmvc/src/main/java/com/example/graphql/services/PostDetailsService.java index 05182ec80..64dd4f78e 100644 --- a/graphql/boot-graphql-webmvc/src/main/java/com/example/graphql/services/PostDetailsService.java +++ b/graphql/boot-graphql-webmvc/src/main/java/com/example/graphql/services/PostDetailsService.java @@ -32,10 +32,10 @@ public Optional findDetailsById(Long id) { } @Transactional - public PostDetailsInfo updatePostDetails( + public Optional updatePostDetails( PostDetailsEntity postDetailsObj, PostDetailsRequest postDetailsRequest) { postDetailsObj.setDetailsKey(postDetailsRequest.detailsKey()); PostDetailsEntity persistedDetails = postDetailsRepository.save(postDetailsObj); - return findPostDetailsById(persistedDetails.getId()).get(); + return findPostDetailsById(persistedDetails.getId()); } } diff --git a/graphql/boot-graphql-webmvc/src/main/java/com/example/graphql/web/controllers/PostDetailsController.java b/graphql/boot-graphql-webmvc/src/main/java/com/example/graphql/web/controllers/PostDetailsController.java index c3df252c0..e64942f8a 100644 --- a/graphql/boot-graphql-webmvc/src/main/java/com/example/graphql/web/controllers/PostDetailsController.java +++ b/graphql/boot-graphql-webmvc/src/main/java/com/example/graphql/web/controllers/PostDetailsController.java @@ -5,6 +5,8 @@ import com.example.graphql.projections.PostDetailsInfo; import com.example.graphql.services.PostDetailsService; import java.util.List; +import java.util.Optional; + import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; @@ -42,9 +44,11 @@ public ResponseEntity updatePostDetails( .findDetailsById(id) .map( postDetailsObj -> - ResponseEntity.ok( + postDetailsService.updatePostDetails( - postDetailsObj, postDetailsEntity))) + postDetailsObj, postDetailsEntity)) + .map(Optional::get) + .map(ResponseEntity::ok) .orElseGet(() -> ResponseEntity.notFound().build()); } } diff --git a/graphql/boot-graphql-webmvc/src/test/java/com/example/graphql/web/controllers/PostDetailsEntityControllerTest.java b/graphql/boot-graphql-webmvc/src/test/java/com/example/graphql/web/controllers/PostDetailsEntityControllerTest.java index 62b68729c..875ceb7a9 100644 --- a/graphql/boot-graphql-webmvc/src/test/java/com/example/graphql/web/controllers/PostDetailsEntityControllerTest.java +++ b/graphql/boot-graphql-webmvc/src/test/java/com/example/graphql/web/controllers/PostDetailsEntityControllerTest.java @@ -87,7 +87,7 @@ void shouldUpdatePostDetails() throws Exception { given(postDetailsService.findDetailsById(postDetailsId)) .willReturn(Optional.of(postDetails)); given(postDetailsService.updatePostDetails(postDetails, postDetailsRequest)) - .willReturn(getPostDetails()); + .willReturn(Optional.of(getPostDetails())); this.mockMvc .perform( diff --git a/graphql/boot-graphql-webmvc/src/test/java/com/example/graphql/web/controllers/PostEntityControllerTest.java b/graphql/boot-graphql-webmvc/src/test/java/com/example/graphql/web/controllers/PostEntityControllerTest.java index 1d4088bc7..1cd7e611d 100644 --- a/graphql/boot-graphql-webmvc/src/test/java/com/example/graphql/web/controllers/PostEntityControllerTest.java +++ b/graphql/boot-graphql-webmvc/src/test/java/com/example/graphql/web/controllers/PostEntityControllerTest.java @@ -45,7 +45,7 @@ class PostEntityControllerTest { private List postEntityList; - private List postResponseList = + private final List postResponseList = List.of( new PostResponse( null, "First Post", false, null, null, null, null, new ArrayList<>()), diff --git a/httpClients/boot-http-proxy/src/test/java/com/example/rest/proxy/web/controllers/PostControllerTest.java b/httpClients/boot-http-proxy/src/test/java/com/example/rest/proxy/web/controllers/PostControllerTest.java index 91004bb5e..bb878bb79 100644 --- a/httpClients/boot-http-proxy/src/test/java/com/example/rest/proxy/web/controllers/PostControllerTest.java +++ b/httpClients/boot-http-proxy/src/test/java/com/example/rest/proxy/web/controllers/PostControllerTest.java @@ -20,9 +20,8 @@ import com.example.rest.proxy.services.PostService; import com.fasterxml.jackson.databind.ObjectMapper; import java.util.ArrayList; -import java.util.List; import java.util.Optional; -import org.junit.jupiter.api.BeforeEach; + import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; @@ -41,16 +40,6 @@ class PostControllerTest { @Autowired private ObjectMapper objectMapper; - private List postList; - - @BeforeEach - void setUp() { - this.postList = new ArrayList<>(); - this.postList.add(new Post(1L, "text 1", 1L, "First Body", new ArrayList<>())); - this.postList.add(new Post(2L, "text 2", 1L, "Second Body", new ArrayList<>())); - this.postList.add(new Post(3L, "text 3", 1L, "Third Body", new ArrayList<>())); - } - @Test void shouldFindPostById() throws Exception { Long postId = 1L; diff --git a/httpClients/boot-web-client-mvc/src/main/java/com/example/rest/webclient/exception/GlobalExceptionHandler.java b/httpClients/boot-web-client-mvc/src/main/java/com/example/rest/webclient/exception/GlobalExceptionHandler.java index 32a34b52a..a8aa4fdbd 100644 --- a/httpClients/boot-web-client-mvc/src/main/java/com/example/rest/webclient/exception/GlobalExceptionHandler.java +++ b/httpClients/boot-web-client-mvc/src/main/java/com/example/rest/webclient/exception/GlobalExceptionHandler.java @@ -42,6 +42,6 @@ ProblemDetail onException(MethodArgumentNotValidException methodArgumentNotValid return problemDetail; } - static record ApiValidationError( + record ApiValidationError( String object, String field, Object rejectedValue, String message) {} } diff --git a/httpClients/boot-web-client-mvc/src/main/resources/application-heroku.properties b/httpClients/boot-web-client-mvc/src/main/resources/application-heroku.properties deleted file mode 100644 index 6a400b909..000000000 --- a/httpClients/boot-web-client-mvc/src/main/resources/application-heroku.properties +++ /dev/null @@ -1,2 +0,0 @@ -spring.datasource.driver-class-name=org.postgresql.Driver -spring.datasource.url=${JDBC_DATABASE_URL} diff --git a/httpClients/boot-web-client-webflux/src/test/java/com/example/rest/webclient/web/controllers/PostControllerTest.java b/httpClients/boot-web-client-webflux/src/test/java/com/example/rest/webclient/web/controllers/PostControllerTest.java index bacc75d43..663d488cc 100644 --- a/httpClients/boot-web-client-webflux/src/test/java/com/example/rest/webclient/web/controllers/PostControllerTest.java +++ b/httpClients/boot-web-client-webflux/src/test/java/com/example/rest/webclient/web/controllers/PostControllerTest.java @@ -109,7 +109,7 @@ void shouldCreateNewPost() { } @Test - void shouldReturn400WhenCreateNewPostWithoutTitle() throws Exception { + void shouldReturn400WhenCreateNewPostWithoutTitle() { PostDto post = new PostDto(null, null, null, null); this.webTestClient diff --git a/jpa/boot-hibernate2ndlevelcache-sample/src/main/java/com/example/hibernatecache/config/GlobalExceptionHandler.java b/jpa/boot-hibernate2ndlevelcache-sample/src/main/java/com/example/hibernatecache/config/GlobalExceptionHandler.java index b4583688b..2c763e495 100644 --- a/jpa/boot-hibernate2ndlevelcache-sample/src/main/java/com/example/hibernatecache/config/GlobalExceptionHandler.java +++ b/jpa/boot-hibernate2ndlevelcache-sample/src/main/java/com/example/hibernatecache/config/GlobalExceptionHandler.java @@ -33,7 +33,7 @@ ProblemDetail onException(MethodArgumentNotValidException methodArgumentNotValid return new ApiValidationError( fieldError.getObjectName(), fieldError.getField(), - fieldError.getRejectedValue(), + Objects.requireNonNull(fieldError.getRejectedValue()), Objects.requireNonNull( fieldError.getDefaultMessage(), "")); }) diff --git a/r2dbc/boot-jooq-r2dbc-sample/src/main/java/com/example/jooq/r2dbc/config/Initializer.java b/r2dbc/boot-jooq-r2dbc-sample/src/main/java/com/example/jooq/r2dbc/config/Initializer.java index 25481c44a..eae3c123d 100644 --- a/r2dbc/boot-jooq-r2dbc-sample/src/main/java/com/example/jooq/r2dbc/config/Initializer.java +++ b/r2dbc/boot-jooq-r2dbc-sample/src/main/java/com/example/jooq/r2dbc/config/Initializer.java @@ -123,7 +123,7 @@ public void run(String... args) { .orderBy(POSTS.CREATED_AT)) .subscribe( data -> log.debug("Retrieved data: {}", data.into(PostResponse.class)), - error -> log.debug("error: " + error), + error -> log.debug("error: ", error), () -> log.debug("done")); } } diff --git a/r2dbc/boot-jooq-r2dbc-sample/src/main/java/com/example/jooq/r2dbc/config/JooqConfiguration.java b/r2dbc/boot-jooq-r2dbc-sample/src/main/java/com/example/jooq/r2dbc/config/JooqConfiguration.java index 21ad21ef1..2a79dccdc 100644 --- a/r2dbc/boot-jooq-r2dbc-sample/src/main/java/com/example/jooq/r2dbc/config/JooqConfiguration.java +++ b/r2dbc/boot-jooq-r2dbc-sample/src/main/java/com/example/jooq/r2dbc/config/JooqConfiguration.java @@ -4,7 +4,7 @@ import org.jooq.DSLContext; import org.jooq.impl.DSL; import org.jooq.impl.DefaultExecuteListenerProvider; -import org.springframework.boot.autoconfigure.jooq.JooqExceptionTranslator; +import org.springframework.boot.autoconfigure.jooq.ExceptionTranslatorExecuteListener; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.annotation.Order; @@ -23,6 +23,6 @@ DSLContext dslContext(ConnectionFactory connectionFactory) { @Bean @Order(0) DefaultExecuteListenerProvider jooqExceptionTranslatorExecuteListenerProvider() { - return new DefaultExecuteListenerProvider(new JooqExceptionTranslator()); + return new DefaultExecuteListenerProvider(ExceptionTranslatorExecuteListener.DEFAULT); } } diff --git a/r2dbc/boot-jooq-r2dbc-sample/src/main/java/com/example/jooq/r2dbc/entities/Status.java b/r2dbc/boot-jooq-r2dbc-sample/src/main/java/com/example/jooq/r2dbc/entities/Status.java index 1b76ff94d..34266adbd 100644 --- a/r2dbc/boot-jooq-r2dbc-sample/src/main/java/com/example/jooq/r2dbc/entities/Status.java +++ b/r2dbc/boot-jooq-r2dbc-sample/src/main/java/com/example/jooq/r2dbc/entities/Status.java @@ -3,5 +3,5 @@ public enum Status { DRAFT, PENDING_MODERATION, - PUBLISHED; + PUBLISHED } diff --git a/r2dbc/boot-r2dbc-sample/src/test/java/com/example/bootr2dbc/web/controllers/ReactiveCommentsControllerTest.java b/r2dbc/boot-r2dbc-sample/src/test/java/com/example/bootr2dbc/web/controllers/ReactiveCommentsControllerTest.java index d48866fbc..863bbf80c 100644 --- a/r2dbc/boot-r2dbc-sample/src/test/java/com/example/bootr2dbc/web/controllers/ReactiveCommentsControllerTest.java +++ b/r2dbc/boot-r2dbc-sample/src/test/java/com/example/bootr2dbc/web/controllers/ReactiveCommentsControllerTest.java @@ -115,7 +115,7 @@ void shouldFindReactiveCommentsById() { } @Test - void shouldReturn404WhenFetchingNonExistingReactiveComments() throws Exception { + void shouldReturn404WhenFetchingNonExistingReactiveComments() { ReactiveComments reactiveComments = reactiveCommentsFlux.next().block(); UUID reactiveCommentsId = reactiveComments.getId(); diff --git a/scheduler/boot-scheduler-quartz/src/main/java/com/scheduler/quartz/model/common/Message.java b/scheduler/boot-scheduler-quartz/src/main/java/com/scheduler/quartz/model/common/Message.java index cd1add508..add2f0142 100644 --- a/scheduler/boot-scheduler-quartz/src/main/java/com/scheduler/quartz/model/common/Message.java +++ b/scheduler/boot-scheduler-quartz/src/main/java/com/scheduler/quartz/model/common/Message.java @@ -3,6 +3,7 @@ import java.io.Serial; import java.io.Serializable; import lombok.Getter; +import lombok.Setter; @Getter public class Message implements Serializable { @@ -41,15 +42,9 @@ public Message(boolean valid) { this.valid = valid; } - public void setValid(boolean valid) { - this.valid = valid; - } - - public void setMsg(String msg) { - this.msg = msg; - } - + @Setter boolean valid; + @Setter String msg; Object data; diff --git a/techstack.md b/techstack.md index 9cddfe704..7eb056d48 100644 --- a/techstack.md +++ b/techstack.md @@ -503,6 +503,6 @@ Full tech stack [here](/techstack.md) |[org.webjars:jquery](http://webjars.org)|v3.7.1|11/16/23|Raja Kolli |MIT|N/A|
-
+
Generated via [Stack File](https://github.com/marketplace/stack-file) From 44e4b023e975b7a3d71c83490c108d00c8a93024 Mon Sep 17 00:00:00 2001 From: rajadilipkolli Date: Fri, 14 Jun 2024 22:32:53 +0530 Subject: [PATCH 3/5] format code --- .../architecture/CustomConditions.java | 3 +- ...RestaurantESRepositoryIntegrationTest.java | 33 ++++++++++++------- .../opensearch/common/ContainersConfig.java | 3 +- .../ultimateredis/config/CacheConfig.java | 4 ++- .../GlobalErrorWebExceptionHandler.java | 1 - .../config/graphql/LocalDateTimeScalar.java | 7 ++-- .../controllers/PostDetailsController.java | 6 ++-- .../web/controllers/PostControllerTest.java | 1 - .../exception/GlobalExceptionHandler.java | 3 +- .../custom/sequence/web/api/CustomerAPI.java | 6 ++-- .../web/controllers/OrderControllerTest.java | 1 - .../multitenancy/utils/DatabaseType.java | 1 - .../tenant/TenantIdentifierResolver.java | 1 - .../TenantIdentifierResolver.java | 1 - .../schema/utils/TenantNameType.java | 1 - .../quartz/model/common/Message.java | 2 ++ 16 files changed, 39 insertions(+), 35 deletions(-) diff --git a/boot-api-archunit-sample/src/test/java/com/example/archunit/architecture/CustomConditions.java b/boot-api-archunit-sample/src/test/java/com/example/archunit/architecture/CustomConditions.java index 2cceec089..ba84f67c2 100644 --- a/boot-api-archunit-sample/src/test/java/com/example/archunit/architecture/CustomConditions.java +++ b/boot-api-archunit-sample/src/test/java/com/example/archunit/architecture/CustomConditions.java @@ -43,8 +43,7 @@ public static ArchCondition haveGetterAndSetter(Map e private static ArchCondition buildFieldHaveGetterAndSetterCondition( boolean forceSetters, Map exclusions) { - return new ArchCondition<>( - forceSetters ? HAVE_GETTER_AND_SETTER_DESCRIPTION : HAVE_GETTER_DESCRIPTION) { + return new ArchCondition<>(forceSetters ? HAVE_GETTER_AND_SETTER_DESCRIPTION : HAVE_GETTER_DESCRIPTION) { @Override public void check(JavaField field, ConditionEvents events) { diff --git a/boot-mongodb-elasticsearch/src/test/java/com/example/mongoes/elasticsearch/repository/RestaurantESRepositoryIntegrationTest.java b/boot-mongodb-elasticsearch/src/test/java/com/example/mongoes/elasticsearch/repository/RestaurantESRepositoryIntegrationTest.java index 4984f274b..21a300fb0 100644 --- a/boot-mongodb-elasticsearch/src/test/java/com/example/mongoes/elasticsearch/repository/RestaurantESRepositoryIntegrationTest.java +++ b/boot-mongodb-elasticsearch/src/test/java/com/example/mongoes/elasticsearch/repository/RestaurantESRepositoryIntegrationTest.java @@ -160,7 +160,8 @@ void findByBoroughOrCuisineOrName() { assertThat(searchPage.isEmpty()).isFalse(); assertThat(searchPage.hasContent()).isTrue(); assertThat(searchPage.stream().count()).isEqualTo(2); - Restaurant restaurant1 = searchPage.getContent().getFirst().getContent(); + Restaurant restaurant1 = + searchPage.getContent().getFirst().getContent(); assertThat(restaurant1.getRestaurantId()).isEqualTo(2L); assertThat(restaurant1.getName()).isEqualTo(RESTAURANT_NAME); assertThat(restaurant1.getBorough()).isEqualTo(BOROUGH_NAME); @@ -208,7 +209,8 @@ void termQueryForBorough() { assertThat(searchPage.isEmpty()).isFalse(); assertThat(searchPage.hasContent()).isTrue(); assertThat(searchPage.stream().count()).isEqualTo(2); - Restaurant restaurant1 = searchPage.getContent().getFirst().getContent(); + Restaurant restaurant1 = + searchPage.getContent().getFirst().getContent(); assertThat(restaurant1.getRestaurantId()).isEqualTo(2L); assertThat(restaurant1.getName()).isEqualTo(RESTAURANT_NAME); assertThat(restaurant1.getBorough()).isEqualTo(BOROUGH_NAME); @@ -235,7 +237,8 @@ void termsQueryForBorough() { assertThat(searchPage.isEmpty()).isFalse(); assertThat(searchPage.hasContent()).isTrue(); assertThat(searchPage.stream().count()).isEqualTo(2); - Restaurant restaurant1 = searchPage.getContent().getFirst().getContent(); + Restaurant restaurant1 = + searchPage.getContent().getFirst().getContent(); assertThat(restaurant1.getRestaurantId()).isEqualTo(2L); assertThat(restaurant1.getName()).isEqualTo(RESTAURANT_NAME); assertThat(restaurant1.getBorough()).isEqualTo(BOROUGH_NAME); @@ -264,7 +267,8 @@ void queryBoolWithShould() { assertThat(searchPage.isEmpty()).isFalse(); assertThat(searchPage.hasContent()).isTrue(); assertThat(searchPage.stream().count()).isEqualTo(2); - Restaurant restaurant1 = searchPage.getContent().getFirst().getContent(); + Restaurant restaurant1 = + searchPage.getContent().getFirst().getContent(); assertThat(restaurant1.getRestaurantId()).isEqualTo(2L); assertThat(restaurant1.getName()).isEqualTo(RESTAURANT_NAME); assertThat(restaurant1.getBorough()).isEqualTo(BOROUGH_NAME); @@ -304,7 +308,8 @@ void wildcardSearch() { assertThat(searchPage.isEmpty()).isFalse(); assertThat(searchPage.hasContent()).isTrue(); assertThat(searchPage.stream().count()).isEqualTo(1); - Restaurant restaurant1 = searchPage.getContent().getFirst().getContent(); + Restaurant restaurant1 = + searchPage.getContent().getFirst().getContent(); assertThat(restaurant1.getRestaurantId()).isEqualTo(40363920L); assertThat(restaurant1.getName()).isEqualTo("Yono gardens"); assertThat(restaurant1.getBorough()).isEqualTo(BOROUGH_NAME); @@ -331,7 +336,8 @@ void regExpSearch() { assertThat(searchPage.isEmpty()).isFalse(); assertThat(searchPage.hasContent()).isTrue(); assertThat(searchPage.stream().count()).isEqualTo(2); - Restaurant restaurant1 = searchPage.getContent().getFirst().getContent(); + Restaurant restaurant1 = + searchPage.getContent().getFirst().getContent(); assertThat(restaurant1.getRestaurantId()).isEqualTo(2L); assertThat(restaurant1.getName()).isEqualTo(RESTAURANT_NAME); assertThat(restaurant1.getBorough()).isEqualTo(BOROUGH_NAME); @@ -358,7 +364,8 @@ void searchSimpleQueryForBoroughAndCuisine() { assertThat(searchPage.isEmpty()).isFalse(); assertThat(searchPage.hasContent()).isTrue(); assertThat(searchPage.stream().count()).isEqualTo(2); - Restaurant restaurant1 = searchPage.getContent().getFirst().getContent(); + Restaurant restaurant1 = + searchPage.getContent().getFirst().getContent(); assertThat(restaurant1.getRestaurantId()).isEqualTo(2L); assertThat(restaurant1.getName()).isEqualTo(RESTAURANT_NAME); assertThat(restaurant1.getBorough()).isEqualTo(BOROUGH_NAME); @@ -383,7 +390,8 @@ void searchRestaurantIdRange() { assertThat(searchPage.isEmpty()).isFalse(); assertThat(searchPage.hasContent()).isTrue(); assertThat(searchPage.stream().count()).isEqualTo(1); - Restaurant restaurant1 = searchPage.getContent().getFirst().getContent(); + Restaurant restaurant1 = + searchPage.getContent().getFirst().getContent(); assertThat(restaurant1.getRestaurantId()).isEqualTo(2L); assertThat(restaurant1.getName()).isEqualTo(RESTAURANT_NAME); assertThat(restaurant1.getBorough()).isEqualTo(BOROUGH_NAME); @@ -411,7 +419,8 @@ void searchDateRange() { assertThat(searchPage.isEmpty()).isFalse(); assertThat(searchPage.hasContent()).isTrue(); assertThat(searchPage.stream().count()).isEqualTo(2); - Restaurant restaurant1 = searchPage.getContent().getFirst().getContent(); + Restaurant restaurant1 = + searchPage.getContent().getFirst().getContent(); assertThat(restaurant1.getRestaurantId()).isEqualTo(2L); assertThat(restaurant1.getName()).isEqualTo(RESTAURANT_NAME); assertThat(restaurant1.getBorough()).isEqualTo(BOROUGH_NAME); @@ -437,7 +446,8 @@ void findAll() { assertThat(searchPage.isEmpty()).isFalse(); assertThat(searchPage.hasContent()).isTrue(); assertThat(searchPage.stream().count()).isEqualTo(2); - Restaurant restaurant1 = searchPage.getContent().getFirst().getContent(); + Restaurant restaurant1 = + searchPage.getContent().getFirst().getContent(); assertThat(restaurant1.getRestaurantId()).isEqualTo(2L); assertThat(restaurant1.getName()).isEqualTo(RESTAURANT_NAME); assertThat(restaurant1.getBorough()).isEqualTo(BOROUGH_NAME); @@ -471,7 +481,8 @@ void aggregation() { .isNotNull() .isExactlyInstanceOf(ElasticsearchAggregations.class); assertThat(searchPage.stream().count()).isEqualTo(1); - Restaurant restaurant1 = searchPage.getContent().getFirst().getContent(); + Restaurant restaurant1 = + searchPage.getContent().getFirst().getContent(); assertThat(restaurant1.getRestaurantId()).isEqualTo(2L); assertThat(restaurant1.getName()).isEqualTo(RESTAURANT_NAME); assertThat(restaurant1.getBorough()).isEqualTo(BOROUGH_NAME); diff --git a/boot-opensearch-sample/src/test/java/com/example/opensearch/common/ContainersConfig.java b/boot-opensearch-sample/src/test/java/com/example/opensearch/common/ContainersConfig.java index a26151678..57140a470 100644 --- a/boot-opensearch-sample/src/test/java/com/example/opensearch/common/ContainersConfig.java +++ b/boot-opensearch-sample/src/test/java/com/example/opensearch/common/ContainersConfig.java @@ -19,7 +19,6 @@ public class ContainersConfig { @DynamicPropertySource static void setApplicationProperties(DynamicPropertyRegistry dynamicPropertyRegistry) { - dynamicPropertyRegistry.add( - "opensearch.uris", openSearchContainer::getHttpHostAddress); + dynamicPropertyRegistry.add("opensearch.uris", openSearchContainer::getHttpHostAddress); } } diff --git a/boot-ultimate-redis/src/main/java/com/example/ultimateredis/config/CacheConfig.java b/boot-ultimate-redis/src/main/java/com/example/ultimateredis/config/CacheConfig.java index 806ada207..796f0621c 100644 --- a/boot-ultimate-redis/src/main/java/com/example/ultimateredis/config/CacheConfig.java +++ b/boot-ultimate-redis/src/main/java/com/example/ultimateredis/config/CacheConfig.java @@ -38,7 +38,9 @@ RedisCacheConfiguration defaultCacheConfig() { @Bean LettuceConnectionFactory redisConnectionFactory(CacheConfigurationProperties properties) { - log.info("Redis (/Lettuce) configuration enabled. With cache timeout {} seconds.", properties.getTimeoutSeconds()); + log.info( + "Redis (/Lettuce) configuration enabled. With cache timeout {} seconds.", + properties.getTimeoutSeconds()); RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration(); diff --git a/graphql/boot-graphql-webflux/src/main/java/com/example/graphql/exception/GlobalErrorWebExceptionHandler.java b/graphql/boot-graphql-webflux/src/main/java/com/example/graphql/exception/GlobalErrorWebExceptionHandler.java index e68996ba1..69ed4e98c 100644 --- a/graphql/boot-graphql-webflux/src/main/java/com/example/graphql/exception/GlobalErrorWebExceptionHandler.java +++ b/graphql/boot-graphql-webflux/src/main/java/com/example/graphql/exception/GlobalErrorWebExceptionHandler.java @@ -28,5 +28,4 @@ public GlobalErrorWebExceptionHandler( protected RouterFunction getRoutingFunction(ErrorAttributes errorAttributes) { return RouterFunctions.route(RequestPredicates.all(), this::renderErrorResponse); } - } diff --git a/graphql/boot-graphql-webmvc/src/main/java/com/example/graphql/config/graphql/LocalDateTimeScalar.java b/graphql/boot-graphql-webmvc/src/main/java/com/example/graphql/config/graphql/LocalDateTimeScalar.java index 8d67c83b5..c4e90255c 100644 --- a/graphql/boot-graphql-webmvc/src/main/java/com/example/graphql/config/graphql/LocalDateTimeScalar.java +++ b/graphql/boot-graphql-webmvc/src/main/java/com/example/graphql/config/graphql/LocalDateTimeScalar.java @@ -59,8 +59,11 @@ public LocalDateTime parseValue( case StringValue stringValue -> parseString(stringValue.getValue()); case String inputString -> parseString(inputString); case LocalDateTime localDateTime -> localDateTime; - default -> throw new CoercingParseValueException( - "Expected a 'String' but was '" + typeName(input) + "'."); + default -> + throw new CoercingParseValueException( + "Expected a 'String' but was '" + + typeName(input) + + "'."); }; } diff --git a/graphql/boot-graphql-webmvc/src/main/java/com/example/graphql/web/controllers/PostDetailsController.java b/graphql/boot-graphql-webmvc/src/main/java/com/example/graphql/web/controllers/PostDetailsController.java index e64942f8a..11619fc84 100644 --- a/graphql/boot-graphql-webmvc/src/main/java/com/example/graphql/web/controllers/PostDetailsController.java +++ b/graphql/boot-graphql-webmvc/src/main/java/com/example/graphql/web/controllers/PostDetailsController.java @@ -6,7 +6,6 @@ import com.example.graphql.services.PostDetailsService; import java.util.List; import java.util.Optional; - import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; @@ -44,9 +43,8 @@ public ResponseEntity updatePostDetails( .findDetailsById(id) .map( postDetailsObj -> - - postDetailsService.updatePostDetails( - postDetailsObj, postDetailsEntity)) + postDetailsService.updatePostDetails( + postDetailsObj, postDetailsEntity)) .map(Optional::get) .map(ResponseEntity::ok) .orElseGet(() -> ResponseEntity.notFound().build()); diff --git a/httpClients/boot-http-proxy/src/test/java/com/example/rest/proxy/web/controllers/PostControllerTest.java b/httpClients/boot-http-proxy/src/test/java/com/example/rest/proxy/web/controllers/PostControllerTest.java index bb878bb79..cc700195e 100644 --- a/httpClients/boot-http-proxy/src/test/java/com/example/rest/proxy/web/controllers/PostControllerTest.java +++ b/httpClients/boot-http-proxy/src/test/java/com/example/rest/proxy/web/controllers/PostControllerTest.java @@ -21,7 +21,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import java.util.ArrayList; import java.util.Optional; - import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; diff --git a/httpClients/boot-web-client-mvc/src/main/java/com/example/rest/webclient/exception/GlobalExceptionHandler.java b/httpClients/boot-web-client-mvc/src/main/java/com/example/rest/webclient/exception/GlobalExceptionHandler.java index a8aa4fdbd..9777fb744 100644 --- a/httpClients/boot-web-client-mvc/src/main/java/com/example/rest/webclient/exception/GlobalExceptionHandler.java +++ b/httpClients/boot-web-client-mvc/src/main/java/com/example/rest/webclient/exception/GlobalExceptionHandler.java @@ -42,6 +42,5 @@ ProblemDetail onException(MethodArgumentNotValidException methodArgumentNotValid return problemDetail; } - record ApiValidationError( - String object, String field, Object rejectedValue, String message) {} + record ApiValidationError(String object, String field, Object rejectedValue, String message) {} } diff --git a/jpa/boot-data-customsequence/src/main/java/com/example/custom/sequence/web/api/CustomerAPI.java b/jpa/boot-data-customsequence/src/main/java/com/example/custom/sequence/web/api/CustomerAPI.java index 1c875885f..448b1c4e0 100644 --- a/jpa/boot-data-customsequence/src/main/java/com/example/custom/sequence/web/api/CustomerAPI.java +++ b/jpa/boot-data-customsequence/src/main/java/com/example/custom/sequence/web/api/CustomerAPI.java @@ -74,8 +74,7 @@ PagedResult getAllCustomers( }) }) ResponseEntity getCustomerById( - @Parameter(name = "id", required = true, in = ParameterIn.PATH) - @PathVariable + @Parameter(name = "id", required = true, in = ParameterIn.PATH) @PathVariable String id); /** @@ -105,6 +104,5 @@ ResponseEntity getCustomerById( schema = @Schema(implementation = ProblemDetail.class)) }) }) - CustomerResponse createCustomer( - @Valid @RequestBody(required = true) Customer customer); + CustomerResponse createCustomer(@Valid @RequestBody(required = true) Customer customer); } diff --git a/jpa/boot-data-customsequence/src/test/java/com/example/custom/sequence/web/controllers/OrderControllerTest.java b/jpa/boot-data-customsequence/src/test/java/com/example/custom/sequence/web/controllers/OrderControllerTest.java index 93489a19c..5aed9b269 100644 --- a/jpa/boot-data-customsequence/src/test/java/com/example/custom/sequence/web/controllers/OrderControllerTest.java +++ b/jpa/boot-data-customsequence/src/test/java/com/example/custom/sequence/web/controllers/OrderControllerTest.java @@ -25,7 +25,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; - import org.jetbrains.annotations.NotNull; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/jpa/multitenancy/multidatasource-multitenancy/src/main/java/com/example/multitenancy/utils/DatabaseType.java b/jpa/multitenancy/multidatasource-multitenancy/src/main/java/com/example/multitenancy/utils/DatabaseType.java index af94e607a..5c899d53a 100644 --- a/jpa/multitenancy/multidatasource-multitenancy/src/main/java/com/example/multitenancy/utils/DatabaseType.java +++ b/jpa/multitenancy/multidatasource-multitenancy/src/main/java/com/example/multitenancy/utils/DatabaseType.java @@ -17,5 +17,4 @@ public enum DatabaseType { DatabaseType(String schemaName) { this.schemaName = schemaName; } - } diff --git a/jpa/multitenancy/partition/src/main/java/com/example/multitenancy/partition/config/tenant/TenantIdentifierResolver.java b/jpa/multitenancy/partition/src/main/java/com/example/multitenancy/partition/config/tenant/TenantIdentifierResolver.java index 3b62d40a6..d8d0998f2 100644 --- a/jpa/multitenancy/partition/src/main/java/com/example/multitenancy/partition/config/tenant/TenantIdentifierResolver.java +++ b/jpa/multitenancy/partition/src/main/java/com/example/multitenancy/partition/config/tenant/TenantIdentifierResolver.java @@ -1,7 +1,6 @@ package com.example.multitenancy.partition.config.tenant; import java.util.Map; - import lombok.Setter; import org.hibernate.cfg.AvailableSettings; import org.hibernate.context.spi.CurrentTenantIdentifierResolver; diff --git a/jpa/multitenancy/schema/src/main/java/com/example/multitenancy/schema/config/multitenancy/TenantIdentifierResolver.java b/jpa/multitenancy/schema/src/main/java/com/example/multitenancy/schema/config/multitenancy/TenantIdentifierResolver.java index 0cb265901..12da09d94 100644 --- a/jpa/multitenancy/schema/src/main/java/com/example/multitenancy/schema/config/multitenancy/TenantIdentifierResolver.java +++ b/jpa/multitenancy/schema/src/main/java/com/example/multitenancy/schema/config/multitenancy/TenantIdentifierResolver.java @@ -1,7 +1,6 @@ package com.example.multitenancy.schema.config.multitenancy; import java.util.Map; - import lombok.Setter; import org.hibernate.cfg.AvailableSettings; import org.hibernate.context.spi.CurrentTenantIdentifierResolver; diff --git a/jpa/multitenancy/schema/src/main/java/com/example/multitenancy/schema/utils/TenantNameType.java b/jpa/multitenancy/schema/src/main/java/com/example/multitenancy/schema/utils/TenantNameType.java index a24796962..3d65a8906 100644 --- a/jpa/multitenancy/schema/src/main/java/com/example/multitenancy/schema/utils/TenantNameType.java +++ b/jpa/multitenancy/schema/src/main/java/com/example/multitenancy/schema/utils/TenantNameType.java @@ -12,5 +12,4 @@ public enum TenantNameType { TenantNameType(String tenantName) { this.tenantName = tenantName; } - } diff --git a/scheduler/boot-scheduler-quartz/src/main/java/com/scheduler/quartz/model/common/Message.java b/scheduler/boot-scheduler-quartz/src/main/java/com/scheduler/quartz/model/common/Message.java index add2f0142..07514099e 100644 --- a/scheduler/boot-scheduler-quartz/src/main/java/com/scheduler/quartz/model/common/Message.java +++ b/scheduler/boot-scheduler-quartz/src/main/java/com/scheduler/quartz/model/common/Message.java @@ -44,8 +44,10 @@ public Message(boolean valid) { @Setter boolean valid; + @Setter String msg; + Object data; public void setData(Object data) { From 84a59b4777a63fabce4edbccc1c195c361f022e3 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Fri, 14 Jun 2024 17:32:03 +0000 Subject: [PATCH 4/5] fix : build issue --- .../graphql/web/controllers/PostDetailsController.java | 4 +--- httpClients/README.md | 2 +- .../example/hibernatecache/config/GlobalExceptionHandler.java | 2 +- jpa/multitenancy/README.md | 2 -- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/graphql/boot-graphql-webmvc/src/main/java/com/example/graphql/web/controllers/PostDetailsController.java b/graphql/boot-graphql-webmvc/src/main/java/com/example/graphql/web/controllers/PostDetailsController.java index 11619fc84..3a390d769 100644 --- a/graphql/boot-graphql-webmvc/src/main/java/com/example/graphql/web/controllers/PostDetailsController.java +++ b/graphql/boot-graphql-webmvc/src/main/java/com/example/graphql/web/controllers/PostDetailsController.java @@ -5,7 +5,6 @@ import com.example.graphql.projections.PostDetailsInfo; import com.example.graphql.services.PostDetailsService; import java.util.List; -import java.util.Optional; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; @@ -41,11 +40,10 @@ public ResponseEntity updatePostDetails( @PathVariable Long id, @RequestBody PostDetailsRequest postDetailsEntity) { return postDetailsService .findDetailsById(id) - .map( + .flatMap( postDetailsObj -> postDetailsService.updatePostDetails( postDetailsObj, postDetailsEntity)) - .map(Optional::get) .map(ResponseEntity::ok) .orElseGet(() -> ResponseEntity.notFound().build()); } diff --git a/httpClients/README.md b/httpClients/README.md index 1dfb9a7a1..953364a9a 100644 --- a/httpClients/README.md +++ b/httpClients/README.md @@ -5,7 +5,7 @@ The HTTP client is built on top of the Java URLConnection class and provides a h It also provides additional features such as automatic handling of authentication and redirects, support for HTTP proxies, and more. Overall, the HTTP client can help to make your application more efficient and easier to work with when it comes to sending and receiving HTTP requests. -The following table list all sample codes related to the spring boot integrations with external system. +The following table lists all sample codes related to the spring boot integrations with external system. | Name | Description | |-------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------| diff --git a/jpa/boot-hibernate2ndlevelcache-sample/src/main/java/com/example/hibernatecache/config/GlobalExceptionHandler.java b/jpa/boot-hibernate2ndlevelcache-sample/src/main/java/com/example/hibernatecache/config/GlobalExceptionHandler.java index 2c763e495..b4583688b 100644 --- a/jpa/boot-hibernate2ndlevelcache-sample/src/main/java/com/example/hibernatecache/config/GlobalExceptionHandler.java +++ b/jpa/boot-hibernate2ndlevelcache-sample/src/main/java/com/example/hibernatecache/config/GlobalExceptionHandler.java @@ -33,7 +33,7 @@ ProblemDetail onException(MethodArgumentNotValidException methodArgumentNotValid return new ApiValidationError( fieldError.getObjectName(), fieldError.getField(), - Objects.requireNonNull(fieldError.getRejectedValue()), + fieldError.getRejectedValue(), Objects.requireNonNull( fieldError.getDefaultMessage(), "")); }) diff --git a/jpa/multitenancy/README.md b/jpa/multitenancy/README.md index 9445b2d37..065b318c1 100644 --- a/jpa/multitenancy/README.md +++ b/jpa/multitenancy/README.md @@ -7,7 +7,5 @@ Let's see how it works by using three different approaches: > Partition tables by tenant id. -> Single table having partition (Supported Only from Hibernate 6) - > Use a separate schema per tenant. -> Single Database having multiple schemas - > Use a separate database per tenant. -> Different Databases having same schema (Could be having different aws regions) From 49a79a72b7354d9aa729646d832a2f593360dc4c Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Fri, 14 Jun 2024 23:06:45 +0530 Subject: [PATCH 5/5] Update README.md --- jpa/multitenancy/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jpa/multitenancy/README.md b/jpa/multitenancy/README.md index 065b318c1..15635ebf8 100644 --- a/jpa/multitenancy/README.md +++ b/jpa/multitenancy/README.md @@ -6,6 +6,6 @@ Let's see how it works by using three different approaches: - > Partition tables by tenant id. -> Single table having partition (Supported Only from Hibernate 6) - > Use a separate schema per tenant. -> Single Database having multiple schemas - > Use a separate database per tenant. -> Different Databases having same schema (Could be having different aws regions) +- Partition tables by tenant id. → Single table having partition (Supported Only from Hibernate 6) +- Use a separate schema per tenant. → Single Database having multiple schemas +- Use a separate database per tenant. → Different Databases having same schema (Could be having different aws regions)