From 220a0bffe06107362ff6aa7aeb978bea5b91d624 Mon Sep 17 00:00:00 2001 From: DOHA Date: Tue, 19 Feb 2019 20:18:13 +0200 Subject: [PATCH 001/531] add user-info endpoint live test --- .../org/baeldung/config/AuthServerConfig.java | 2 +- .../org/baeldung/config/SecurityConfig.java | 3 +- .../baeldung/UserInfoEndpointLiveTest.java | 51 +++++++++++++++++++ 3 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 spring-security-sso/spring-security-sso-auth-server/src/test/java/org/baeldung/UserInfoEndpointLiveTest.java diff --git a/spring-security-sso/spring-security-sso-auth-server/src/main/java/org/baeldung/config/AuthServerConfig.java b/spring-security-sso/spring-security-sso-auth-server/src/main/java/org/baeldung/config/AuthServerConfig.java index 07057c3875..0835f3d721 100644 --- a/spring-security-sso/spring-security-sso-auth-server/src/main/java/org/baeldung/config/AuthServerConfig.java +++ b/spring-security-sso/spring-security-sso-auth-server/src/main/java/org/baeldung/config/AuthServerConfig.java @@ -30,7 +30,7 @@ public class AuthServerConfig extends AuthorizationServerConfigurerAdapter { .authorizedGrantTypes("authorization_code") .scopes("user_info") .autoApprove(true) - .redirectUris("http://localhost:8082/ui/login","http://localhost:8083/ui2/login","http://localhost:8082/login") + .redirectUris("http://localhost:8082/ui/login","http://localhost:8083/ui2/login","http://localhost:8082/login","http://www.example.com/") // .accessTokenValiditySeconds(3600) ; // 1 hour } diff --git a/spring-security-sso/spring-security-sso-auth-server/src/main/java/org/baeldung/config/SecurityConfig.java b/spring-security-sso/spring-security-sso-auth-server/src/main/java/org/baeldung/config/SecurityConfig.java index 5cebf4f4d2..2254de8e39 100644 --- a/spring-security-sso/spring-security-sso-auth-server/src/main/java/org/baeldung/config/SecurityConfig.java +++ b/spring-security-sso/spring-security-sso-auth-server/src/main/java/org/baeldung/config/SecurityConfig.java @@ -22,7 +22,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { .authenticated() .and() .formLogin() - .permitAll(); + .permitAll() + .and().csrf().disable(); } // @formatter:on @Override diff --git a/spring-security-sso/spring-security-sso-auth-server/src/test/java/org/baeldung/UserInfoEndpointLiveTest.java b/spring-security-sso/spring-security-sso-auth-server/src/test/java/org/baeldung/UserInfoEndpointLiveTest.java new file mode 100644 index 0000000000..ffdb1df8fe --- /dev/null +++ b/spring-security-sso/spring-security-sso-auth-server/src/test/java/org/baeldung/UserInfoEndpointLiveTest.java @@ -0,0 +1,51 @@ +package org.baeldung; +import static org.junit.Assert.assertEquals; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; + +import io.restassured.RestAssured; +import io.restassured.response.Response; + +public class UserInfoEndpointLiveTest { + + @Test + public void givenAccessToken_whenAccessUserInfoEndpoint_thenSuccess() { + String accessToken = obtainAccessTokenUsingAuthorizationCodeFlow("john","123"); + Response response = RestAssured.given().header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken).get("http://localhost:8081/auth/user/me"); + + assertEquals(HttpStatus.OK.value(), response.getStatusCode()); + assertEquals("john", response.jsonPath().get("name")); + } + + private String obtainAccessTokenUsingAuthorizationCodeFlow(String username, String password) { + final String authServerUri = "http://localhost:8081/auth"; + final String redirectUrl = "http://www.example.com/"; + final String authorizeUrl = authServerUri + "/oauth/authorize?response_type=code&client_id=SampleClientId&redirect_uri=" + redirectUrl; + final String tokenUrl = authServerUri + "/oauth/token"; + + // user login + Response response = RestAssured.given().formParams("username", username, "password", password).post(authServerUri + "/login"); + final String cookieValue = response.getCookie("JSESSIONID"); + + // get authorization code + RestAssured.given().cookie("JSESSIONID", cookieValue).get(authorizeUrl); + response = RestAssured.given().cookie("JSESSIONID", cookieValue).post(authorizeUrl); + assertEquals(HttpStatus.FOUND.value(), response.getStatusCode()); + final String location = response.getHeader(HttpHeaders.LOCATION); + final String code = location.substring(location.indexOf("code=") + 5); + + // get access token + Map params = new HashMap(); + params.put("grant_type", "authorization_code"); + params.put("code", code); + params.put("client_id", "SampleClientId"); + params.put("redirect_uri", redirectUrl); + response = RestAssured.given().auth().basic("SampleClientId", "secret").formParams(params).post(tokenUrl); + return response.jsonPath().getString("access_token"); + } +} From 3cfedd04944c92af8d2f1b463670d0c3d0171320 Mon Sep 17 00:00:00 2001 From: DOHA Date: Sun, 24 Feb 2019 13:44:34 +0200 Subject: [PATCH 002/531] keycloak - change server port --- spring-boot-keycloak/src/main/resources/application.properties | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spring-boot-keycloak/src/main/resources/application.properties b/spring-boot-keycloak/src/main/resources/application.properties index f667d3b27e..6e7da2cb90 100644 --- a/spring-boot-keycloak/src/main/resources/application.properties +++ b/spring-boot-keycloak/src/main/resources/application.properties @@ -1,3 +1,6 @@ +### server port +server.port=8081 + #Keycloak Configuration keycloak.auth-server-url=http://localhost:8180/auth keycloak.realm=SpringBootKeycloak From 9ed70233ff537b0793b89323944642e4c0aa77a4 Mon Sep 17 00:00:00 2001 From: Chirag Dewan Date: Mon, 25 Feb 2019 11:42:51 +0530 Subject: [PATCH 003/531] BAEL2489 - Avoid check for null statement in Java --- core-java/pom.xml | 40 +++++++++++++------ .../java/com/baeldung/nulls/APIContracts.java | 29 ++++++++++++++ .../java/com/baeldung/nulls/Assertions.java | 13 ++++++ .../com/baeldung/nulls/EmptyCollections.java | 24 +++++++++++ .../baeldung/nulls/FindBugsAnnotations.java | 28 +++++++++++++ .../com/baeldung/nulls/Preconditions.java | 32 +++++++++++++++ .../baeldung/nulls/PrimitivesAndWrapper.java | 24 +++++++++++ .../java/com/baeldung/nulls/UsingLombok.java | 10 +++++ .../java/com/baeldung/nulls/UsingObjects.java | 24 +++++++++++ .../com/baeldung/nulls/UsingOptional.java | 23 +++++++++++ .../com/baeldung/nulls/UsingStringUtils.java | 17 ++++++++ 11 files changed, 251 insertions(+), 13 deletions(-) create mode 100644 core-java/src/main/java/com/baeldung/nulls/APIContracts.java create mode 100644 core-java/src/main/java/com/baeldung/nulls/Assertions.java create mode 100644 core-java/src/main/java/com/baeldung/nulls/EmptyCollections.java create mode 100644 core-java/src/main/java/com/baeldung/nulls/FindBugsAnnotations.java create mode 100644 core-java/src/main/java/com/baeldung/nulls/Preconditions.java create mode 100644 core-java/src/main/java/com/baeldung/nulls/PrimitivesAndWrapper.java create mode 100644 core-java/src/main/java/com/baeldung/nulls/UsingLombok.java create mode 100644 core-java/src/main/java/com/baeldung/nulls/UsingObjects.java create mode 100644 core-java/src/main/java/com/baeldung/nulls/UsingOptional.java create mode 100644 core-java/src/main/java/com/baeldung/nulls/UsingStringUtils.java diff --git a/core-java/pom.xml b/core-java/pom.xml index 463b65a4ce..e8548600f8 100644 --- a/core-java/pom.xml +++ b/core-java/pom.xml @@ -129,6 +129,13 @@ system ${java.home}/../lib/tools.jar + + org.jetbrains + annotations + ${intellij.annotations.version} + + + @@ -209,7 +216,8 @@ true - + org.baeldung.executable.ExecutableMavenJar @@ -264,12 +272,12 @@ -Xmx300m -XX:+UseParallelGC -classpath - + com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed - + org.apache.maven.plugins maven-javadoc-plugin @@ -330,7 +338,7 @@ java -classpath - + org.openjdk.jmh.Main .* @@ -363,7 +371,8 @@ true - ${project.build.outputDirectory}/META-INF/MANIFEST.MF + ${project.build.outputDirectory}/META-INF/MANIFEST.MF + @@ -397,12 +406,14 @@ true - ${project.build.outputDirectory}/META-INF/MANIFEST.MF + ${project.build.outputDirectory}/META-INF/MANIFEST.MF + com/baeldung/instrumentation/application/MyAtm.class - com/baeldung/instrumentation/application/MyAtmApplication.class + com/baeldung/instrumentation/application/MyAtmApplication.class + com/baeldung/instrumentation/application/Launcher.class @@ -432,12 +443,14 @@ true - ${project.build.outputDirectory}/META-INF/MANIFEST.MF + ${project.build.outputDirectory}/META-INF/MANIFEST.MF + com/baeldung/instrumentation/agent/AtmTransformer.class - com/baeldung/instrumentation/agent/MyInstrumentationAgent.class + com/baeldung/instrumentation/agent/MyInstrumentationAgent.class + @@ -449,7 +462,7 @@ - + 2.8.2 @@ -470,12 +483,12 @@ 2.21.0 - + 1.1 1.4.197 2.1.0.1 1.19 - + 1.19 3.0.0-M1 3.0.2 @@ -486,7 +499,8 @@ 61.1 3.21.0-GA - + 1.8.0 + 16.0.2 diff --git a/core-java/src/main/java/com/baeldung/nulls/APIContracts.java b/core-java/src/main/java/com/baeldung/nulls/APIContracts.java new file mode 100644 index 0000000000..f8dfba25dd --- /dev/null +++ b/core-java/src/main/java/com/baeldung/nulls/APIContracts.java @@ -0,0 +1,29 @@ +package com.baeldung.nulls; + +public class APIContracts { + + /** + * Prints the value of {@code param} if not null. Prints {@code null} otherwise. + * @param param + */ + public void print(Object param) { + System.out.println("Printing " + param); + } + + /** + * + * @return non null result + * @throws Exception - if result is null + */ + public Object process() throws Exception { + Object result = doSomething(); + if (result == null) + throw new Exception("Processing fail. Got a null response"); + else + return result; + } + + private Object doSomething() { + return null; + } +} diff --git a/core-java/src/main/java/com/baeldung/nulls/Assertions.java b/core-java/src/main/java/com/baeldung/nulls/Assertions.java new file mode 100644 index 0000000000..a0d692623f --- /dev/null +++ b/core-java/src/main/java/com/baeldung/nulls/Assertions.java @@ -0,0 +1,13 @@ +package com.baeldung.nulls; + +public class Assertions { + + public void accept(Object param){ + assert param != null; + + doSomething(param); + } + + private void doSomething(Object param) { + } +} diff --git a/core-java/src/main/java/com/baeldung/nulls/EmptyCollections.java b/core-java/src/main/java/com/baeldung/nulls/EmptyCollections.java new file mode 100644 index 0000000000..95e49e4e91 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/nulls/EmptyCollections.java @@ -0,0 +1,24 @@ +package com.baeldung.nulls; + +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class EmptyCollections { + + public List names(){ + if (userExist()) + return Stream.of(readName()).collect(Collectors.toList()); + else + return Collections.emptyList(); + } + + private boolean userExist() { + return false; + } + + private String readName() { + return "test"; + } +} diff --git a/core-java/src/main/java/com/baeldung/nulls/FindBugsAnnotations.java b/core-java/src/main/java/com/baeldung/nulls/FindBugsAnnotations.java new file mode 100644 index 0000000000..f879f033c9 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/nulls/FindBugsAnnotations.java @@ -0,0 +1,28 @@ +package com.baeldung.nulls; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +public class FindBugsAnnotations { + + public void accept(@Nonnull Object param) { + System.out.println(param.toString()); + } + + public void print(@Nullable Object param) { + System.out.println("Printing " + param); + } + + @Nonnull + public Object process() throws Exception { + Object result = doSomething(); + if (result == null) + throw new Exception("Processing fail. Got a null response"); + else + return result; + } + + private Object doSomething() { + return null; + } +} diff --git a/core-java/src/main/java/com/baeldung/nulls/Preconditions.java b/core-java/src/main/java/com/baeldung/nulls/Preconditions.java new file mode 100644 index 0000000000..ff32db46dd --- /dev/null +++ b/core-java/src/main/java/com/baeldung/nulls/Preconditions.java @@ -0,0 +1,32 @@ +package com.baeldung.nulls; + +public class Preconditions { + + public void goodAccept(String one, String two, String three) { + if (null == one || null == two || three == null) + throw new IllegalArgumentException(); + } + + public void badAccept(String one, String two, String three){ + if (null == one) + throw new IllegalArgumentException(); + else + process(one); + + if (null == two) + throw new IllegalArgumentException(); + else + process(two); + + if (null == three) + throw new IllegalArgumentException(); + else + process(three); + + } + + private void process(String one) { + } + + +} diff --git a/core-java/src/main/java/com/baeldung/nulls/PrimitivesAndWrapper.java b/core-java/src/main/java/com/baeldung/nulls/PrimitivesAndWrapper.java new file mode 100644 index 0000000000..dce7a05308 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/nulls/PrimitivesAndWrapper.java @@ -0,0 +1,24 @@ +package com.baeldung.nulls; + +public class PrimitivesAndWrapper { + + public static int sum(int a, int b) { + return a + b; + } + + public static Integer sum(Integer a, Integer b) { + return a + b; + } + + public static Integer goodSum(Integer a, Integer b) { + if (a != null && b != null) + return a + b; + else + throw new IllegalArgumentException(); + } + + public static void main(String[] args) { + sum(0, 0); + sum(null, null); + } +} diff --git a/core-java/src/main/java/com/baeldung/nulls/UsingLombok.java b/core-java/src/main/java/com/baeldung/nulls/UsingLombok.java new file mode 100644 index 0000000000..73db0742c8 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/nulls/UsingLombok.java @@ -0,0 +1,10 @@ +package com.baeldung.nulls; + +import lombok.NonNull; + +public class UsingLombok { + + public void accept(@NonNull Object param){ + System.out.println(param); + } +} diff --git a/core-java/src/main/java/com/baeldung/nulls/UsingObjects.java b/core-java/src/main/java/com/baeldung/nulls/UsingObjects.java new file mode 100644 index 0000000000..e8a3262ce7 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/nulls/UsingObjects.java @@ -0,0 +1,24 @@ +package com.baeldung.nulls; + +import java.util.Objects; + +public class UsingObjects { + + private String checked; + + public void accept(Object param) { + try { + Objects.requireNonNull(param); + } catch (NullPointerException e) { + //doSomethingElseToo + e.printStackTrace(); + } + } + + public void caller() throws Exception { + if (Objects.nonNull(checked)) + accept(checked); + else + throw new Exception(); + } +} diff --git a/core-java/src/main/java/com/baeldung/nulls/UsingOptional.java b/core-java/src/main/java/com/baeldung/nulls/UsingOptional.java new file mode 100644 index 0000000000..626afc311d --- /dev/null +++ b/core-java/src/main/java/com/baeldung/nulls/UsingOptional.java @@ -0,0 +1,23 @@ +package com.baeldung.nulls; + +import java.util.Optional; + +public class UsingOptional { + + public Optional process() { + if (isProcessed()) + return Optional.of("dummy"); + else + return Optional.empty(); + } + + public void caller() { + Optional result = process(); + result.ifPresent(p -> System.out.println(p)); + result.orElseThrow(() -> new IllegalArgumentException()); + } + + private boolean isProcessed() { + return false; + } +} diff --git a/core-java/src/main/java/com/baeldung/nulls/UsingStringUtils.java b/core-java/src/main/java/com/baeldung/nulls/UsingStringUtils.java new file mode 100644 index 0000000000..8cbf3752e1 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/nulls/UsingStringUtils.java @@ -0,0 +1,17 @@ +package com.baeldung.nulls; + + +import org.apache.commons.lang3.StringUtils; + +public class UsingStringUtils { + + public void accept(String param) { + if (StringUtils.isNotEmpty(param)) + System.out.println(param); + } + + public void acceptOnlyNonBlank(String param) { + if (StringUtils.isNotBlank(param)) + System.out.println(param); + } +} From 70016f1d76e69db776dc7de6ddee390e3db18bb3 Mon Sep 17 00:00:00 2001 From: Loredana Date: Tue, 26 Feb 2019 22:28:52 +0200 Subject: [PATCH 004/531] fix spring-data-jpa module --- persistence-modules/spring-data-jpa/pom.xml | 4 + .../com/baeldung/{ => boot}/Application.java | 5 +- .../boot/config/PersistenceConfiguration.java | 33 ++ .../daos}/ArticleRepository.java | 5 +- .../daos}/CustomItemRepository.java | 4 +- .../daos}/CustomItemTypeRepository.java | 4 +- .../daos}/ExtendedRepository.java | 2 +- .../daos}/ExtendedStudentRepository.java | 4 +- .../daos}/IBarCrudRepository.java | 5 +- .../baeldung/{dao => boot/daos}/IFooDao.java | 5 +- .../daos}/InventoryRepository.java | 5 +- .../daos}/ItemTypeRepository.java | 4 +- .../daos}/LocationRepository.java | 4 +- .../daos}/ReadOnlyLocationRepository.java | 4 +- .../daos}/StoreRepository.java | 4 +- .../daos}/impl/CustomItemRepositoryImpl.java | 6 +- .../impl/CustomItemTypeRepositoryImpl.java | 6 +- .../daos}/impl/ExtendedRepositoryImpl.java | 5 +- .../daos}/impl/PersonInsertRepository.java | 5 +- .../{ => boot}/ddd/event/Aggregate.java | 2 +- .../{ => boot}/ddd/event/Aggregate2.java | 2 +- .../ddd/event/Aggregate2Repository.java | 2 +- .../{ => boot}/ddd/event/Aggregate3.java | 2 +- .../ddd/event/Aggregate3Repository.java | 2 +- .../ddd/event/AggregateRepository.java | 2 +- .../{ => boot}/ddd/event/DddConfig.java | 2 +- .../baeldung/boot/ddd/event/DomainEvent.java | 8 + .../{ => boot}/ddd/event/DomainService.java | 2 +- .../baeldung/{ => boot}/domain/Article.java | 2 +- .../com/baeldung/{ => boot}/domain/Bar.java | 2 +- .../com/baeldung/{ => boot}/domain/Foo.java | 2 +- .../com/baeldung/{ => boot}/domain/Item.java | 2 +- .../baeldung/{ => boot}/domain/ItemType.java | 2 +- .../com/baeldung/{ => boot}/domain/KVTag.java | 2 +- .../baeldung/{ => boot}/domain/Location.java | 2 +- .../{ => boot}/domain/MerchandiseEntity.java | 2 +- .../baeldung/{ => boot}/domain/Person.java | 2 +- .../user => boot/domain}/Possession.java | 2 +- .../baeldung/{ => boot}/domain/SkillTag.java | 2 +- .../com/baeldung/{ => boot}/domain/Store.java | 2 +- .../baeldung/{ => boot}/domain/Student.java | 2 +- .../java/com/baeldung/boot/domain/User.java | 86 ++++ .../passenger/CustomPassengerRepository.java | 2 +- .../{ => boot}/passenger/Passenger.java | 2 +- .../passenger/PassengerRepository.java | 2 +- .../passenger/PassengerRepositoryImpl.java | 2 +- .../baeldung/boot/services/IBarService.java | 7 + .../{ => boot}/services/IFooService.java | 5 +- .../{ => boot}/services/IOperations.java | 2 +- .../services/impl/AbstractService.java | 4 +- .../impl/AbstractSpringDataJpaService.java | 4 +- .../impl/BarSpringDataJpaService.java | 9 +- .../{ => boot}/services/impl/FooService.java | 9 +- .../user/PossessionRepository.java | 5 +- .../baeldung/boot/user/UserRepository.java | 81 ++++ .../boot/user/UserRepositoryCustom.java | 10 + .../boot/user/UserRepositoryCustomImpl.java | 43 ++ .../config/PersistenceConfiguration.java | 97 ----- .../com/baeldung/ddd/event/DomainEvent.java | 8 - .../multipledb/MultipleDbApplication.java | 14 + .../PersistenceProductConfiguration.java | 8 +- .../PersistenceUserConfiguration.java | 8 +- .../com/baeldung/multipledb/Possession.java | 82 ++++ .../multipledb/PossessionRepository.java | 9 + .../product => multipledb}/Product.java | 2 +- .../ProductRepository.java | 4 +- .../java/com/baeldung/multipledb/User.java | 76 ++++ .../com/baeldung/services/IBarService.java | 7 - .../src/main/resources/application.properties | 20 +- .../src/main/resources/persistence.properties | 2 - .../ArticleRepositoryIntegrationTest.java | 15 +- ...endedStudentRepositoryIntegrationTest.java | 11 +- .../InventoryRepositoryIntegrationTest.java | 12 +- .../daos}/JpaRepositoriesIntegrationTest.java | 24 +- ...PersonInsertRepositoryIntegrationTest.java | 7 +- .../boot/daos/UserRepositoryCommon.java | 405 ++++++++++++++++++ .../daos/UserRepositoryIntegrationTest.java | 37 ++ .../UserRepositoryTCAutoIntegrationTest.java | 40 ++ .../daos/UserRepositoryTCIntegrationTest.java | 56 +++ .../Aggregate2EventsIntegrationTest.java | 6 +- .../Aggregate3EventsIntegrationTest.java | 6 +- .../event/AggregateEventsIntegrationTest.java | 7 +- .../ddd/event/TestEventHandler.java | 4 +- .../PassengerRepositoryIntegrationTest.java | 5 +- ...ractServicePersistenceIntegrationTest.java | 5 +- .../FooServicePersistenceIntegrationTest.java | 13 +- .../SpringDataJPABarAuditIntegrationTest.java | 11 +- .../JpaMultipleDBIntegrationTest.java | 21 +- .../ProductRepositoryIntegrationTest.java | 10 +- .../SpringContextIntegrationTest.java | 2 +- .../SpringJpaContextIntegrationTest.java | 8 +- 91 files changed, 1202 insertions(+), 277 deletions(-) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{ => boot}/Application.java (75%) create mode 100644 persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/config/PersistenceConfiguration.java rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{dao/repositories => boot/daos}/ArticleRepository.java (90%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{dao/repositories => boot/daos}/CustomItemRepository.java (74%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{dao/repositories => boot/daos}/CustomItemTypeRepository.java (71%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{dao/repositories => boot/daos}/ExtendedRepository.java (90%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{dao/repositories => boot/daos}/ExtendedStudentRepository.java (54%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{dao/repositories => boot/daos}/IBarCrudRepository.java (71%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{dao => boot/daos}/IFooDao.java (83%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{dao/repositories => boot/daos}/InventoryRepository.java (63%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{dao/repositories => boot/daos}/ItemTypeRepository.java (76%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{dao/repositories => boot/daos}/LocationRepository.java (72%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{dao/repositories => boot/daos}/ReadOnlyLocationRepository.java (79%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{dao/repositories => boot/daos}/StoreRepository.java (79%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{dao/repositories => boot/daos}/impl/CustomItemRepositoryImpl.java (83%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{dao/repositories => boot/daos}/impl/CustomItemTypeRepositoryImpl.java (84%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{dao/repositories => boot/daos}/impl/ExtendedRepositoryImpl.java (93%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{dao/repositories => boot/daos}/impl/PersonInsertRepository.java (90%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{ => boot}/ddd/event/Aggregate.java (95%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{ => boot}/ddd/event/Aggregate2.java (95%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{ => boot}/ddd/event/Aggregate2Repository.java (80%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{ => boot}/ddd/event/Aggregate3.java (91%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{ => boot}/ddd/event/Aggregate3Repository.java (83%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{ => boot}/ddd/event/AggregateRepository.java (80%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{ => boot}/ddd/event/DddConfig.java (89%) create mode 100644 persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/ddd/event/DomainEvent.java rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{ => boot}/ddd/event/DomainService.java (95%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{ => boot}/domain/Article.java (92%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{ => boot}/domain/Bar.java (99%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{ => boot}/domain/Foo.java (98%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{ => boot}/domain/Item.java (97%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{ => boot}/domain/ItemType.java (96%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{ => boot}/domain/KVTag.java (94%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{ => boot}/domain/Location.java (96%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{ => boot}/domain/MerchandiseEntity.java (97%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{ => boot}/domain/Person.java (95%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{domain/user => boot/domain}/Possession.java (98%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{ => boot}/domain/SkillTag.java (93%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{ => boot}/domain/Store.java (97%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{ => boot}/domain/Student.java (97%) create mode 100644 persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/User.java rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{ => boot}/passenger/CustomPassengerRepository.java (77%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{ => boot}/passenger/Passenger.java (98%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{ => boot}/passenger/PassengerRepository.java (92%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{ => boot}/passenger/PassengerRepositoryImpl.java (93%) create mode 100644 persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/services/IBarService.java rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{ => boot}/services/IFooService.java (76%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{ => boot}/services/IOperations.java (92%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{ => boot}/services/impl/AbstractService.java (94%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{ => boot}/services/impl/AbstractSpringDataJpaService.java (92%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{ => boot}/services/impl/BarSpringDataJpaService.java (79%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{ => boot}/services/impl/FooService.java (87%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{dao/repositories => boot}/user/PossessionRepository.java (62%) create mode 100644 persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/user/UserRepository.java create mode 100644 persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/user/UserRepositoryCustom.java create mode 100644 persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/user/UserRepositoryCustomImpl.java delete mode 100644 persistence-modules/spring-data-jpa/src/main/java/com/baeldung/config/PersistenceConfiguration.java delete mode 100644 persistence-modules/spring-data-jpa/src/main/java/com/baeldung/ddd/event/DomainEvent.java create mode 100644 persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/MultipleDbApplication.java rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{config => multipledb}/PersistenceProductConfiguration.java (90%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{config => multipledb}/PersistenceUserConfiguration.java (90%) create mode 100644 persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/Possession.java create mode 100644 persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/PossessionRepository.java rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{domain/product => multipledb}/Product.java (97%) rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/{dao/repositories/product => multipledb}/ProductRepository.java (76%) create mode 100644 persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/User.java delete mode 100644 persistence-modules/spring-data-jpa/src/main/java/com/baeldung/services/IBarService.java rename persistence-modules/spring-data-jpa/src/test/java/com/baeldung/{dao/repositories => boot/daos}/ArticleRepositoryIntegrationTest.java (82%) rename persistence-modules/spring-data-jpa/src/test/java/com/baeldung/{dao/repositories => boot/daos}/ExtendedStudentRepositoryIntegrationTest.java (80%) rename persistence-modules/spring-data-jpa/src/test/java/com/baeldung/{dao/repositories => boot/daos}/InventoryRepositoryIntegrationTest.java (85%) rename persistence-modules/spring-data-jpa/src/test/java/com/baeldung/{dao/repositories => boot/daos}/JpaRepositoriesIntegrationTest.java (80%) rename persistence-modules/spring-data-jpa/src/test/java/com/baeldung/{dao/repositories => boot/daos}/PersonInsertRepositoryIntegrationTest.java (94%) create mode 100644 persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/daos/UserRepositoryCommon.java create mode 100644 persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/daos/UserRepositoryIntegrationTest.java create mode 100644 persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/daos/UserRepositoryTCAutoIntegrationTest.java create mode 100644 persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/daos/UserRepositoryTCIntegrationTest.java rename persistence-modules/spring-data-jpa/src/test/java/com/baeldung/{ => boot}/ddd/event/Aggregate2EventsIntegrationTest.java (90%) rename persistence-modules/spring-data-jpa/src/test/java/com/baeldung/{ => boot}/ddd/event/Aggregate3EventsIntegrationTest.java (90%) rename persistence-modules/spring-data-jpa/src/test/java/com/baeldung/{ => boot}/ddd/event/AggregateEventsIntegrationTest.java (91%) rename persistence-modules/spring-data-jpa/src/test/java/com/baeldung/{ => boot}/ddd/event/TestEventHandler.java (68%) rename persistence-modules/spring-data-jpa/src/test/java/com/baeldung/{ => boot}/passenger/PassengerRepositoryIntegrationTest.java (97%) rename persistence-modules/spring-data-jpa/src/test/java/com/baeldung/{ => boot}/services/AbstractServicePersistenceIntegrationTest.java (98%) rename persistence-modules/spring-data-jpa/src/test/java/com/baeldung/{ => boot}/services/FooServicePersistenceIntegrationTest.java (85%) rename persistence-modules/spring-data-jpa/src/test/java/com/baeldung/{ => boot}/services/SpringDataJPABarAuditIntegrationTest.java (87%) rename persistence-modules/spring-data-jpa/src/test/java/com/baeldung/{services => multipledb}/JpaMultipleDBIntegrationTest.java (83%) rename persistence-modules/spring-data-jpa/src/test/java/com/baeldung/{dao/repositories/product => multipledb}/ProductRepositoryIntegrationTest.java (93%) diff --git a/persistence-modules/spring-data-jpa/pom.xml b/persistence-modules/spring-data-jpa/pom.xml index 401f4877ac..91bcbb69b2 100644 --- a/persistence-modules/spring-data-jpa/pom.xml +++ b/persistence-modules/spring-data-jpa/pom.xml @@ -80,5 +80,9 @@ test + + + com.baeldung.boot.Application + \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/Application.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/Application.java similarity index 75% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/Application.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/Application.java index 72d29d9fa5..1f078801e2 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/Application.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/Application.java @@ -1,10 +1,11 @@ -package com.baeldung; +package com.baeldung.boot; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import com.baeldung.dao.repositories.impl.ExtendedRepositoryImpl; +import com.baeldung.boot.daos.impl.ExtendedRepositoryImpl; +import com.baeldung.multipledb.MultipleDbApplication; @SpringBootApplication @EnableJpaRepositories(repositoryBaseClass = ExtendedRepositoryImpl.class) diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/config/PersistenceConfiguration.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/config/PersistenceConfiguration.java new file mode 100644 index 0000000000..64e3cd8c9a --- /dev/null +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/config/PersistenceConfiguration.java @@ -0,0 +1,33 @@ +package com.baeldung.boot.config; + +import com.baeldung.boot.daos.impl.ExtendedRepositoryImpl; +import com.baeldung.boot.services.IBarService; +import com.baeldung.boot.services.impl.BarSpringDataJpaService; +import com.google.common.base.Preconditions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.*; +import org.springframework.core.env.Environment; +import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; +import org.springframework.data.jpa.repository.config.EnableJpaAuditing; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.jdbc.datasource.DriverManagerDataSource; +import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.JpaVendorAdapter; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; +import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +import javax.sql.DataSource; +import java.util.Properties; + +@Configuration +@Profile("!tc") +public class PersistenceConfiguration { + + @Bean + public IBarService barSpringDataJpaService() { + return new BarSpringDataJpaService(); + } + +} \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/ArticleRepository.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/ArticleRepository.java similarity index 90% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/ArticleRepository.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/ArticleRepository.java index 8402c099d9..73397ad42e 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/ArticleRepository.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/ArticleRepository.java @@ -1,10 +1,11 @@ -package com.baeldung.dao.repositories; +package com.baeldung.boot.daos; -import com.baeldung.domain.Article; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; +import com.baeldung.boot.domain.Article; + import java.util.Date; import java.util.List; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/CustomItemRepository.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/CustomItemRepository.java similarity index 74% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/CustomItemRepository.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/CustomItemRepository.java index ba077ccf1f..207f992b33 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/CustomItemRepository.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/CustomItemRepository.java @@ -1,8 +1,8 @@ -package com.baeldung.dao.repositories; +package com.baeldung.boot.daos; import org.springframework.stereotype.Repository; -import com.baeldung.domain.Item; +import com.baeldung.boot.domain.Item; @Repository public interface CustomItemRepository { diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/CustomItemTypeRepository.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/CustomItemTypeRepository.java similarity index 71% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/CustomItemTypeRepository.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/CustomItemTypeRepository.java index 81ebdf3fda..832d61408c 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/CustomItemTypeRepository.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/CustomItemTypeRepository.java @@ -1,8 +1,8 @@ -package com.baeldung.dao.repositories; +package com.baeldung.boot.daos; import org.springframework.stereotype.Repository; -import com.baeldung.domain.ItemType; +import com.baeldung.boot.domain.ItemType; @Repository public interface CustomItemTypeRepository { diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/ExtendedRepository.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/ExtendedRepository.java similarity index 90% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/ExtendedRepository.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/ExtendedRepository.java index 9e82f02fa6..adb2af4320 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/ExtendedRepository.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/ExtendedRepository.java @@ -1,4 +1,4 @@ -package com.baeldung.dao.repositories; +package com.baeldung.boot.daos; import java.io.Serializable; import java.util.List; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/ExtendedStudentRepository.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/ExtendedStudentRepository.java similarity index 54% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/ExtendedStudentRepository.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/ExtendedStudentRepository.java index 199e4e5ff6..c9b0192536 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/ExtendedStudentRepository.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/ExtendedStudentRepository.java @@ -1,6 +1,6 @@ -package com.baeldung.dao.repositories; +package com.baeldung.boot.daos; -import com.baeldung.domain.Student; +import com.baeldung.boot.domain.Student; public interface ExtendedStudentRepository extends ExtendedRepository { } diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/IBarCrudRepository.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/IBarCrudRepository.java similarity index 71% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/IBarCrudRepository.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/IBarCrudRepository.java index 54a7d77691..921fabe3fb 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/IBarCrudRepository.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/IBarCrudRepository.java @@ -1,8 +1,9 @@ -package com.baeldung.dao.repositories; +package com.baeldung.boot.daos; -import com.baeldung.domain.Bar; import org.springframework.data.repository.CrudRepository; +import com.baeldung.boot.domain.Bar; + import java.io.Serializable; public interface IBarCrudRepository extends CrudRepository { diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/IFooDao.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/IFooDao.java similarity index 83% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/IFooDao.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/IFooDao.java index bb3c229945..d537772076 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/IFooDao.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/IFooDao.java @@ -1,10 +1,11 @@ -package com.baeldung.dao; +package com.baeldung.boot.daos; -import com.baeldung.domain.Foo; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; +import com.baeldung.boot.domain.Foo; + public interface IFooDao extends JpaRepository { @Query("SELECT f FROM Foo f WHERE LOWER(f.name) = LOWER(:name)") diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/InventoryRepository.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/InventoryRepository.java similarity index 63% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/InventoryRepository.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/InventoryRepository.java index a575f0b915..606f3993d5 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/InventoryRepository.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/InventoryRepository.java @@ -1,7 +1,8 @@ -package com.baeldung.dao.repositories; +package com.baeldung.boot.daos; -import com.baeldung.domain.MerchandiseEntity; import org.springframework.data.repository.CrudRepository; +import com.baeldung.boot.domain.MerchandiseEntity; + public interface InventoryRepository extends CrudRepository { } diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/ItemTypeRepository.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/ItemTypeRepository.java similarity index 76% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/ItemTypeRepository.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/ItemTypeRepository.java index 2af83bc322..413c09e968 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/ItemTypeRepository.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/ItemTypeRepository.java @@ -1,9 +1,9 @@ -package com.baeldung.dao.repositories; +package com.baeldung.boot.daos; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; -import com.baeldung.domain.ItemType; +import com.baeldung.boot.domain.ItemType; @Repository public interface ItemTypeRepository extends JpaRepository, CustomItemTypeRepository, CustomItemRepository { diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/LocationRepository.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/LocationRepository.java similarity index 72% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/LocationRepository.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/LocationRepository.java index 27bbe27af0..697ce295d0 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/LocationRepository.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/LocationRepository.java @@ -1,9 +1,9 @@ -package com.baeldung.dao.repositories; +package com.baeldung.boot.daos; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; -import com.baeldung.domain.Location; +import com.baeldung.boot.domain.Location; @Repository public interface LocationRepository extends JpaRepository { diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/ReadOnlyLocationRepository.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/ReadOnlyLocationRepository.java similarity index 79% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/ReadOnlyLocationRepository.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/ReadOnlyLocationRepository.java index 8f68cdbbe5..3a2ea3cda5 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/ReadOnlyLocationRepository.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/ReadOnlyLocationRepository.java @@ -1,10 +1,10 @@ -package com.baeldung.dao.repositories; +package com.baeldung.boot.daos; import java.util.Optional; import org.springframework.data.repository.Repository; -import com.baeldung.domain.Location; +import com.baeldung.boot.domain.Location; @org.springframework.stereotype.Repository public interface ReadOnlyLocationRepository extends Repository { diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/StoreRepository.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/StoreRepository.java similarity index 79% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/StoreRepository.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/StoreRepository.java index 9318c32ee9..ae13f75f66 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/StoreRepository.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/StoreRepository.java @@ -1,11 +1,11 @@ -package com.baeldung.dao.repositories; +package com.baeldung.boot.daos; import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; -import com.baeldung.domain.Store; +import com.baeldung.boot.domain.Store; @Repository public interface StoreRepository extends JpaRepository { diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/impl/CustomItemRepositoryImpl.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/impl/CustomItemRepositoryImpl.java similarity index 83% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/impl/CustomItemRepositoryImpl.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/impl/CustomItemRepositoryImpl.java index 53def88af0..7c681eb49f 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/impl/CustomItemRepositoryImpl.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/impl/CustomItemRepositoryImpl.java @@ -1,12 +1,12 @@ -package com.baeldung.dao.repositories.impl; +package com.baeldung.boot.daos.impl; import javax.persistence.EntityManager; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; -import com.baeldung.domain.Item; -import com.baeldung.dao.repositories.CustomItemRepository; +import com.baeldung.boot.daos.CustomItemRepository; +import com.baeldung.boot.domain.Item; @Repository public class CustomItemRepositoryImpl implements CustomItemRepository { diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/impl/CustomItemTypeRepositoryImpl.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/impl/CustomItemTypeRepositoryImpl.java similarity index 84% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/impl/CustomItemTypeRepositoryImpl.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/impl/CustomItemTypeRepositoryImpl.java index 2b49f2380c..d7cba7c2c6 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/impl/CustomItemTypeRepositoryImpl.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/impl/CustomItemTypeRepositoryImpl.java @@ -1,4 +1,4 @@ -package com.baeldung.dao.repositories.impl; +package com.baeldung.boot.daos.impl; import javax.persistence.EntityManager; @@ -7,8 +7,8 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; -import com.baeldung.domain.ItemType; -import com.baeldung.dao.repositories.CustomItemTypeRepository; +import com.baeldung.boot.daos.CustomItemTypeRepository; +import com.baeldung.boot.domain.ItemType; @Repository public class CustomItemTypeRepositoryImpl implements CustomItemTypeRepository { diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/impl/ExtendedRepositoryImpl.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/impl/ExtendedRepositoryImpl.java similarity index 93% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/impl/ExtendedRepositoryImpl.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/impl/ExtendedRepositoryImpl.java index f6f06efb51..fbe6695844 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/impl/ExtendedRepositoryImpl.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/impl/ExtendedRepositoryImpl.java @@ -1,4 +1,4 @@ -package com.baeldung.dao.repositories.impl; +package com.baeldung.boot.daos.impl; import java.io.Serializable; import java.util.List; @@ -10,10 +10,11 @@ import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Root; import javax.transaction.Transactional; -import com.baeldung.dao.repositories.ExtendedRepository; import org.springframework.data.jpa.repository.support.JpaEntityInformation; import org.springframework.data.jpa.repository.support.SimpleJpaRepository; +import com.baeldung.boot.daos.ExtendedRepository; + public class ExtendedRepositoryImpl extends SimpleJpaRepository implements ExtendedRepository { private EntityManager entityManager; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/impl/PersonInsertRepository.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/impl/PersonInsertRepository.java similarity index 90% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/impl/PersonInsertRepository.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/impl/PersonInsertRepository.java index d809385456..373532e1c3 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/impl/PersonInsertRepository.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/daos/impl/PersonInsertRepository.java @@ -1,8 +1,9 @@ -package com.baeldung.dao.repositories.impl; +package com.baeldung.boot.daos.impl; -import com.baeldung.domain.Person; import org.springframework.stereotype.Repository; +import com.baeldung.boot.domain.Person; + import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import javax.transaction.Transactional; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/ddd/event/Aggregate.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/ddd/event/Aggregate.java similarity index 95% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/ddd/event/Aggregate.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/ddd/event/Aggregate.java index bf6ff0a0b9..e435f4c85c 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/ddd/event/Aggregate.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/ddd/event/Aggregate.java @@ -1,7 +1,7 @@ /** * */ -package com.baeldung.ddd.event; +package com.baeldung.boot.ddd.event; import javax.persistence.Entity; import javax.persistence.Id; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/ddd/event/Aggregate2.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/ddd/event/Aggregate2.java similarity index 95% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/ddd/event/Aggregate2.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/ddd/event/Aggregate2.java index 3d2816299a..08f61db812 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/ddd/event/Aggregate2.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/ddd/event/Aggregate2.java @@ -1,7 +1,7 @@ /** * */ -package com.baeldung.ddd.event; +package com.baeldung.boot.ddd.event; import java.util.ArrayList; import java.util.Collection; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/ddd/event/Aggregate2Repository.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/ddd/event/Aggregate2Repository.java similarity index 80% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/ddd/event/Aggregate2Repository.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/ddd/event/Aggregate2Repository.java index 2a95abe347..7f09c410fc 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/ddd/event/Aggregate2Repository.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/ddd/event/Aggregate2Repository.java @@ -1,7 +1,7 @@ /** * */ -package com.baeldung.ddd.event; +package com.baeldung.boot.ddd.event; import org.springframework.data.repository.CrudRepository; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/ddd/event/Aggregate3.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/ddd/event/Aggregate3.java similarity index 91% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/ddd/event/Aggregate3.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/ddd/event/Aggregate3.java index e0c3131b06..f664322a59 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/ddd/event/Aggregate3.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/ddd/event/Aggregate3.java @@ -1,7 +1,7 @@ /** * */ -package com.baeldung.ddd.event; +package com.baeldung.boot.ddd.event; import javax.persistence.Entity; import javax.persistence.GeneratedValue; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/ddd/event/Aggregate3Repository.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/ddd/event/Aggregate3Repository.java similarity index 83% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/ddd/event/Aggregate3Repository.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/ddd/event/Aggregate3Repository.java index e442bdb210..93f50bb5cf 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/ddd/event/Aggregate3Repository.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/ddd/event/Aggregate3Repository.java @@ -1,7 +1,7 @@ /** * */ -package com.baeldung.ddd.event; +package com.baeldung.boot.ddd.event; import org.springframework.data.repository.CrudRepository; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/ddd/event/AggregateRepository.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/ddd/event/AggregateRepository.java similarity index 80% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/ddd/event/AggregateRepository.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/ddd/event/AggregateRepository.java index 5a15156d03..1c2d3884bf 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/ddd/event/AggregateRepository.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/ddd/event/AggregateRepository.java @@ -1,7 +1,7 @@ /** * */ -package com.baeldung.ddd.event; +package com.baeldung.boot.ddd.event; import org.springframework.data.repository.CrudRepository; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/ddd/event/DddConfig.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/ddd/event/DddConfig.java similarity index 89% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/ddd/event/DddConfig.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/ddd/event/DddConfig.java index 1315b11875..34cf21463b 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/ddd/event/DddConfig.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/ddd/event/DddConfig.java @@ -1,7 +1,7 @@ /** * */ -package com.baeldung.ddd.event; +package com.baeldung.boot.ddd.event; import org.springframework.boot.SpringBootConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/ddd/event/DomainEvent.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/ddd/event/DomainEvent.java new file mode 100644 index 0000000000..e7626e742d --- /dev/null +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/ddd/event/DomainEvent.java @@ -0,0 +1,8 @@ +/** + * + */ +package com.baeldung.boot.ddd.event; + +class DomainEvent { + +} diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/ddd/event/DomainService.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/ddd/event/DomainService.java similarity index 95% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/ddd/event/DomainService.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/ddd/event/DomainService.java index 082c9bd88e..80aa5ca6cb 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/ddd/event/DomainService.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/ddd/event/DomainService.java @@ -1,7 +1,7 @@ /** * */ -package com.baeldung.ddd.event; +package com.baeldung.boot.ddd.event; import javax.transaction.Transactional; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/Article.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/Article.java similarity index 92% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/Article.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/Article.java index 3b5a8be088..de4dbed1a0 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/Article.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/Article.java @@ -1,4 +1,4 @@ -package com.baeldung.domain; +package com.baeldung.boot.domain; import javax.persistence.*; import java.util.Date; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/Bar.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/Bar.java similarity index 99% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/Bar.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/Bar.java index efd297bafc..35d1903801 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/Bar.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/Bar.java @@ -1,4 +1,4 @@ -package com.baeldung.domain; +package com.baeldung.boot.domain; import com.google.common.collect.Sets; import org.hibernate.annotations.OrderBy; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/Foo.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/Foo.java similarity index 98% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/Foo.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/Foo.java index ef88840746..5030e5600b 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/Foo.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/Foo.java @@ -1,4 +1,4 @@ -package com.baeldung.domain; +package com.baeldung.boot.domain; import org.hibernate.envers.Audited; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/Item.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/Item.java similarity index 97% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/Item.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/Item.java index 1e58fb25ba..8ac06af15a 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/Item.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/Item.java @@ -1,4 +1,4 @@ -package com.baeldung.domain; +package com.baeldung.boot.domain; import java.math.BigDecimal; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/ItemType.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/ItemType.java similarity index 96% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/ItemType.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/ItemType.java index b0349e0471..8a52a9847c 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/ItemType.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/ItemType.java @@ -1,4 +1,4 @@ -package com.baeldung.domain; +package com.baeldung.boot.domain; import java.util.ArrayList; import java.util.List; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/KVTag.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/KVTag.java similarity index 94% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/KVTag.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/KVTag.java index b3e7d78b30..1901f43c0a 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/KVTag.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/KVTag.java @@ -1,4 +1,4 @@ -package com.baeldung.domain; +package com.baeldung.boot.domain; import javax.persistence.Embeddable; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/Location.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/Location.java similarity index 96% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/Location.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/Location.java index 4ca7295986..9c1b93d551 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/Location.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/Location.java @@ -1,4 +1,4 @@ -package com.baeldung.domain; +package com.baeldung.boot.domain; import java.util.ArrayList; import java.util.List; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/MerchandiseEntity.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/MerchandiseEntity.java similarity index 97% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/MerchandiseEntity.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/MerchandiseEntity.java index bfc690e0e2..e94c23de86 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/MerchandiseEntity.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/MerchandiseEntity.java @@ -1,4 +1,4 @@ -package com.baeldung.domain; +package com.baeldung.boot.domain; import javax.persistence.Entity; import javax.persistence.GeneratedValue; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/Person.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/Person.java similarity index 95% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/Person.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/Person.java index 30d7370982..88894ccc72 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/Person.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/Person.java @@ -1,4 +1,4 @@ -package com.baeldung.domain; +package com.baeldung.boot.domain; import javax.persistence.Entity; import javax.persistence.Id; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/user/Possession.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/Possession.java similarity index 98% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/user/Possession.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/Possession.java index b1427c0270..44cdce86c0 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/user/Possession.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/Possession.java @@ -1,4 +1,4 @@ -package com.baeldung.domain.user; +package com.baeldung.boot.domain; import javax.persistence.*; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/SkillTag.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/SkillTag.java similarity index 93% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/SkillTag.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/SkillTag.java index 1f2778c589..0933a3e6af 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/SkillTag.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/SkillTag.java @@ -1,4 +1,4 @@ -package com.baeldung.domain; +package com.baeldung.boot.domain; import javax.persistence.Embeddable; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/Store.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/Store.java similarity index 97% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/Store.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/Store.java index 4172051c71..5b4b831cc7 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/Store.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/Store.java @@ -1,4 +1,4 @@ -package com.baeldung.domain; +package com.baeldung.boot.domain; import java.util.ArrayList; import java.util.List; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/Student.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/Student.java similarity index 97% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/Student.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/Student.java index bd7eaeb24b..1003167cc7 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/Student.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/Student.java @@ -1,4 +1,4 @@ -package com.baeldung.domain; +package com.baeldung.boot.domain; import javax.persistence.ElementCollection; import javax.persistence.Entity; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/User.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/User.java new file mode 100644 index 0000000000..5c709307ac --- /dev/null +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/domain/User.java @@ -0,0 +1,86 @@ +package com.baeldung.boot.domain; + +import javax.persistence.*; +import java.util.List; + +@Entity +@Table(name = "users") +public class User { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private int id; + private String name; + private int age; + @Column(unique = true, nullable = false) + private String email; + private Integer status; + @OneToMany + List possessionList; + + public User() { + super(); + } + + public User(String name, String email, Integer status) { + this.name = name; + this.email = email; + this.status = status; + } + + public int getId() { + return id; + } + + public void setId(final int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + public String getEmail() { + return email; + } + + public void setEmail(final String email) { + this.email = email; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public int getAge() { + return age; + } + + public void setAge(final int age) { + this.age = age; + } + + public List getPossessionList() { + return possessionList; + } + + public void setPossessionList(List possessionList) { + this.possessionList = possessionList; + } + + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(); + builder.append("User [name=").append(name).append(", id=").append(id).append("]"); + return builder.toString(); + } + +} \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/passenger/CustomPassengerRepository.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/passenger/CustomPassengerRepository.java similarity index 77% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/passenger/CustomPassengerRepository.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/passenger/CustomPassengerRepository.java index 7ae44bfbda..7152286c83 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/passenger/CustomPassengerRepository.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/passenger/CustomPassengerRepository.java @@ -1,4 +1,4 @@ -package com.baeldung.passenger; +package com.baeldung.boot.passenger; import java.util.List; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/passenger/Passenger.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/passenger/Passenger.java similarity index 98% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/passenger/Passenger.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/passenger/Passenger.java index a96b1edb20..c75107a783 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/passenger/Passenger.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/passenger/Passenger.java @@ -1,4 +1,4 @@ -package com.baeldung.passenger; +package com.baeldung.boot.passenger; import javax.persistence.Basic; import javax.persistence.Column; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/passenger/PassengerRepository.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/passenger/PassengerRepository.java similarity index 92% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/passenger/PassengerRepository.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/passenger/PassengerRepository.java index 6ae6afb403..107ea838ed 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/passenger/PassengerRepository.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/passenger/PassengerRepository.java @@ -1,4 +1,4 @@ -package com.baeldung.passenger; +package com.baeldung.boot.passenger; import org.springframework.data.domain.Sort; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/passenger/PassengerRepositoryImpl.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/passenger/PassengerRepositoryImpl.java similarity index 93% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/passenger/PassengerRepositoryImpl.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/passenger/PassengerRepositoryImpl.java index bd6e535e3e..508c669066 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/passenger/PassengerRepositoryImpl.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/passenger/PassengerRepositoryImpl.java @@ -1,4 +1,4 @@ -package com.baeldung.passenger; +package com.baeldung.boot.passenger; import org.springframework.stereotype.Repository; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/services/IBarService.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/services/IBarService.java new file mode 100644 index 0000000000..8054cbba59 --- /dev/null +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/services/IBarService.java @@ -0,0 +1,7 @@ +package com.baeldung.boot.services; + +import com.baeldung.boot.domain.Bar; + +public interface IBarService extends IOperations { + // +} diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/services/IFooService.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/services/IFooService.java similarity index 76% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/services/IFooService.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/services/IFooService.java index 7e16ace5b6..871cccdd45 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/services/IFooService.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/services/IFooService.java @@ -1,9 +1,10 @@ -package com.baeldung.services; +package com.baeldung.boot.services; -import com.baeldung.domain.Foo; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; +import com.baeldung.boot.domain.Foo; + public interface IFooService extends IOperations { Foo retrieveByName(String name); diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/services/IOperations.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/services/IOperations.java similarity index 92% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/services/IOperations.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/services/IOperations.java index d50d465639..ec2b866b6f 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/services/IOperations.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/services/IOperations.java @@ -1,4 +1,4 @@ -package com.baeldung.services; +package com.baeldung.boot.services; import org.springframework.data.domain.Page; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/services/impl/AbstractService.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/services/impl/AbstractService.java similarity index 94% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/services/impl/AbstractService.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/services/impl/AbstractService.java index 708524225b..8e4f643adc 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/services/impl/AbstractService.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/services/impl/AbstractService.java @@ -1,6 +1,6 @@ -package com.baeldung.services.impl; +package com.baeldung.boot.services.impl; -import com.baeldung.services.IOperations; +import com.baeldung.boot.services.IOperations; import com.google.common.collect.Lists; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/services/impl/AbstractSpringDataJpaService.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/services/impl/AbstractSpringDataJpaService.java similarity index 92% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/services/impl/AbstractSpringDataJpaService.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/services/impl/AbstractSpringDataJpaService.java index 28c86bee28..a73a6bd7fc 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/services/impl/AbstractSpringDataJpaService.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/services/impl/AbstractSpringDataJpaService.java @@ -1,6 +1,6 @@ -package com.baeldung.services.impl; +package com.baeldung.boot.services.impl; -import com.baeldung.services.IOperations; +import com.baeldung.boot.services.IOperations; import com.google.common.collect.Lists; import org.springframework.data.repository.CrudRepository; import org.springframework.transaction.annotation.Transactional; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/services/impl/BarSpringDataJpaService.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/services/impl/BarSpringDataJpaService.java similarity index 79% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/services/impl/BarSpringDataJpaService.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/services/impl/BarSpringDataJpaService.java index ca3e5f868d..80568f2fd4 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/services/impl/BarSpringDataJpaService.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/services/impl/BarSpringDataJpaService.java @@ -1,8 +1,9 @@ -package com.baeldung.services.impl; +package com.baeldung.boot.services.impl; + +import com.baeldung.boot.daos.IBarCrudRepository; +import com.baeldung.boot.domain.Bar; +import com.baeldung.boot.services.IBarService; -import com.baeldung.domain.Bar; -import com.baeldung.dao.repositories.IBarCrudRepository; -import com.baeldung.services.IBarService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.repository.CrudRepository; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/services/impl/FooService.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/services/impl/FooService.java similarity index 87% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/services/impl/FooService.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/services/impl/FooService.java index 319ab3a825..04eec63854 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/services/impl/FooService.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/services/impl/FooService.java @@ -1,9 +1,10 @@ -package com.baeldung.services.impl; +package com.baeldung.boot.services.impl; import com.google.common.collect.Lists; -import com.baeldung.dao.IFooDao; -import com.baeldung.domain.Foo; -import com.baeldung.services.IFooService; +import com.baeldung.boot.daos.IFooDao; +import com.baeldung.boot.domain.Foo; +import com.baeldung.boot.services.IFooService; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/user/PossessionRepository.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/user/PossessionRepository.java similarity index 62% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/user/PossessionRepository.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/user/PossessionRepository.java index f0eeb475c1..63af5ca05d 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/user/PossessionRepository.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/user/PossessionRepository.java @@ -1,8 +1,9 @@ -package com.baeldung.dao.repositories.user; +package com.baeldung.boot.user; -import com.baeldung.domain.user.Possession; import org.springframework.data.jpa.repository.JpaRepository; +import com.baeldung.boot.domain.Possession; + public interface PossessionRepository extends JpaRepository { } diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/user/UserRepository.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/user/UserRepository.java new file mode 100644 index 0000000000..1097387e7b --- /dev/null +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/user/UserRepository.java @@ -0,0 +1,81 @@ +package com.baeldung.boot.user; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; + +import com.baeldung.boot.domain.User; + +import java.util.Collection; +import java.util.List; +import java.util.stream.Stream; + +public interface UserRepository extends JpaRepository , UserRepositoryCustom{ + + Stream findAllByName(String name); + + @Query("SELECT u FROM User u WHERE u.status = 1") + Collection findAllActiveUsers(); + + @Query(value = "SELECT * FROM Users u WHERE u.status = 1", nativeQuery = true) + Collection findAllActiveUsersNative(); + + @Query("SELECT u FROM User u WHERE u.status = ?1") + User findUserByStatus(Integer status); + + @Query(value = "SELECT * FROM Users u WHERE u.status = ?1", nativeQuery = true) + User findUserByStatusNative(Integer status); + + @Query("SELECT u FROM User u WHERE u.status = ?1 and u.name = ?2") + User findUserByStatusAndName(Integer status, String name); + + @Query("SELECT u FROM User u WHERE u.status = :status and u.name = :name") + User findUserByStatusAndNameNamedParams(@Param("status") Integer status, @Param("name") String name); + + @Query(value = "SELECT * FROM Users u WHERE u.status = :status AND u.name = :name", nativeQuery = true) + User findUserByStatusAndNameNamedParamsNative(@Param("status") Integer status, @Param("name") String name); + + @Query("SELECT u FROM User u WHERE u.status = :status and u.name = :name") + User findUserByUserStatusAndUserName(@Param("status") Integer userStatus, @Param("name") String userName); + + @Query("SELECT u FROM User u WHERE u.name like ?1%") + User findUserByNameLike(String name); + + @Query("SELECT u FROM User u WHERE u.name like :name%") + User findUserByNameLikeNamedParam(@Param("name") String name); + + @Query(value = "SELECT * FROM users u WHERE u.name LIKE ?1%", nativeQuery = true) + User findUserByNameLikeNative(String name); + + @Query(value = "SELECT u FROM User u") + List findAllUsers(Sort sort); + + @Query(value = "SELECT u FROM User u ORDER BY id") + Page findAllUsersWithPagination(Pageable pageable); + + @Query(value = "SELECT * FROM Users ORDER BY id", countQuery = "SELECT count(*) FROM Users", nativeQuery = true) + Page findAllUsersWithPaginationNative(Pageable pageable); + + @Modifying + @Query("update User u set u.status = :status where u.name = :name") + int updateUserSetStatusForName(@Param("status") Integer status, @Param("name") String name); + + @Modifying + @Query(value = "UPDATE Users u SET u.status = ? WHERE u.name = ?", nativeQuery = true) + int updateUserSetStatusForNameNative(Integer status, String name); + + @Query(value = "INSERT INTO Users (name, age, email, status) VALUES (:name, :age, :email, :status)", nativeQuery = true) + @Modifying + void insertUser(@Param("name") String name, @Param("age") Integer age, @Param("status") Integer status, @Param("email") String email); + + @Modifying + @Query(value = "UPDATE Users u SET status = ? WHERE u.name = ?", nativeQuery = true) + int updateUserSetStatusForNameNativePostgres(Integer status, String name); + + @Query(value = "SELECT u FROM User u WHERE u.name IN :names") + List findUserByNameList(@Param("names") Collection names); +} diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/user/UserRepositoryCustom.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/user/UserRepositoryCustom.java new file mode 100644 index 0000000000..7690463093 --- /dev/null +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/user/UserRepositoryCustom.java @@ -0,0 +1,10 @@ +package com.baeldung.boot.user; + +import java.util.List; +import java.util.Set; + +import com.baeldung.boot.domain.User; + +public interface UserRepositoryCustom { + List findUserByEmails(Set emails); +} diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/user/UserRepositoryCustomImpl.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/user/UserRepositoryCustomImpl.java new file mode 100644 index 0000000000..8739a1a868 --- /dev/null +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/boot/user/UserRepositoryCustomImpl.java @@ -0,0 +1,43 @@ +package com.baeldung.boot.user; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Path; +import javax.persistence.criteria.Predicate; +import javax.persistence.criteria.Root; + +import com.baeldung.boot.domain.User; + +public class UserRepositoryCustomImpl implements UserRepositoryCustom { + + @PersistenceContext + private EntityManager entityManager; + + @Override + public List findUserByEmails(Set emails) { + CriteriaBuilder cb = entityManager.getCriteriaBuilder(); + CriteriaQuery query = cb.createQuery(User.class); + Root user = query.from(User.class); + + Path emailPath = user.get("email"); + + List predicates = new ArrayList<>(); + for (String email : emails) { + + predicates.add(cb.like(emailPath, email)); + + } + query.select(user) + .where(cb.or(predicates.toArray(new Predicate[predicates.size()]))); + + return entityManager.createQuery(query) + .getResultList(); + } + +} diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/config/PersistenceConfiguration.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/config/PersistenceConfiguration.java deleted file mode 100644 index 891624443b..0000000000 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/config/PersistenceConfiguration.java +++ /dev/null @@ -1,97 +0,0 @@ -package com.baeldung.config; - -import com.baeldung.dao.repositories.impl.ExtendedRepositoryImpl; -import com.baeldung.services.IBarService; -import com.baeldung.services.impl.BarSpringDataJpaService; -import com.google.common.base.Preconditions; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.*; -import org.springframework.core.env.Environment; -import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; -import org.springframework.data.jpa.repository.config.EnableJpaAuditing; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import org.springframework.jdbc.datasource.DriverManagerDataSource; -import org.springframework.orm.jpa.JpaTransactionManager; -import org.springframework.orm.jpa.JpaVendorAdapter; -import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; -import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -import javax.sql.DataSource; -import java.util.Properties; - -@Configuration -@ComponentScan({ "com.baeldung.dao", "com.baeldung.services" }) -@EnableTransactionManagement -@EnableJpaRepositories(basePackages = { "com.baeldung.dao" }, repositoryBaseClass = ExtendedRepositoryImpl.class) -@EnableJpaAuditing -@PropertySource("classpath:persistence.properties") -@Profile("!tc") -public class PersistenceConfiguration { - - @Autowired - private Environment env; - - public PersistenceConfiguration() { - super(); - } - - @Bean - public LocalContainerEntityManagerFactoryBean entityManagerFactory() { - final LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean(); - emf.setDataSource(dataSource()); - emf.setPackagesToScan("com.baeldung.domain"); - - final JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); - emf.setJpaVendorAdapter(vendorAdapter); - emf.setJpaProperties(hibernateProperties()); - - return emf; - } - - @Bean - public DataSource dataSource() { - final DriverManagerDataSource dataSource = new DriverManagerDataSource(); - dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName"))); - dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("jdbc.url"))); - dataSource.setUsername(Preconditions.checkNotNull(env.getProperty("jdbc.user"))); - dataSource.setPassword(Preconditions.checkNotNull(env.getProperty("jdbc.pass"))); - - return dataSource; - } - - @Bean - public PlatformTransactionManager transactionManager() { - final JpaTransactionManager transactionManager = new JpaTransactionManager(); - transactionManager.setEntityManagerFactory(entityManagerFactory().getObject()); - return transactionManager; - } - - @Bean - public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { - return new PersistenceExceptionTranslationPostProcessor(); - } - - @Bean - public IBarService barSpringDataJpaService() { - return new BarSpringDataJpaService(); - } - - private final Properties hibernateProperties() { - final Properties hibernateProperties = new Properties(); - hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); - hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); - - hibernateProperties.setProperty("hibernate.show_sql", "true"); - // hibernateProperties.setProperty("hibernate.format_sql", "true"); - // hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", "true"); - - // Envers properties - hibernateProperties.setProperty("org.hibernate.envers.audit_table_suffix", - env.getProperty("envers.audit_table_suffix")); - - return hibernateProperties; - } - -} \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/ddd/event/DomainEvent.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/ddd/event/DomainEvent.java deleted file mode 100644 index 1e6479d4fc..0000000000 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/ddd/event/DomainEvent.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * - */ -package com.baeldung.ddd.event; - -class DomainEvent { - -} diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/MultipleDbApplication.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/MultipleDbApplication.java new file mode 100644 index 0000000000..8ff6799e31 --- /dev/null +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/MultipleDbApplication.java @@ -0,0 +1,14 @@ +package com.baeldung.multipledb; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class MultipleDbApplication { + + public static void main(String[] args) { + SpringApplication.run(MultipleDbApplication.class, args); + } + +} + diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/config/PersistenceProductConfiguration.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/PersistenceProductConfiguration.java similarity index 90% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/config/PersistenceProductConfiguration.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/PersistenceProductConfiguration.java index ecaee82ae5..d79e721e31 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/config/PersistenceProductConfiguration.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/PersistenceProductConfiguration.java @@ -1,4 +1,4 @@ -package com.baeldung.config; +package com.baeldung.multipledb; import com.google.common.base.Preconditions; import org.springframework.beans.factory.annotation.Autowired; @@ -17,9 +17,9 @@ import org.springframework.transaction.PlatformTransactionManager; import javax.sql.DataSource; import java.util.HashMap; -@Configuration +//@Configuration @PropertySource({"classpath:persistence-multiple-db.properties"}) -@EnableJpaRepositories(basePackages = "com.baeldung.dao.repositories.product", entityManagerFactoryRef = "productEntityManager", transactionManagerRef = "productTransactionManager") +@EnableJpaRepositories(basePackages = "com.baeldung.multipledb", entityManagerFactoryRef = "productEntityManager", transactionManagerRef = "productTransactionManager") @Profile("!tc") public class PersistenceProductConfiguration { @Autowired @@ -35,7 +35,7 @@ public class PersistenceProductConfiguration { public LocalContainerEntityManagerFactoryBean productEntityManager() { final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(productDataSource()); - em.setPackagesToScan("com.baeldung.domain.product"); + em.setPackagesToScan("com.baeldung.multipledb"); final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); em.setJpaVendorAdapter(vendorAdapter); diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/config/PersistenceUserConfiguration.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/PersistenceUserConfiguration.java similarity index 90% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/config/PersistenceUserConfiguration.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/PersistenceUserConfiguration.java index 6893d889e6..572065314d 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/config/PersistenceUserConfiguration.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/PersistenceUserConfiguration.java @@ -1,4 +1,4 @@ -package com.baeldung.config; +package com.baeldung.multipledb; import com.google.common.base.Preconditions; import org.springframework.beans.factory.annotation.Autowired; @@ -14,9 +14,9 @@ import org.springframework.transaction.PlatformTransactionManager; import javax.sql.DataSource; import java.util.HashMap; -@Configuration +//@Configuration @PropertySource({"classpath:persistence-multiple-db.properties"}) -@EnableJpaRepositories(basePackages = "com.baeldung.dao.repositories.user", entityManagerFactoryRef = "userEntityManager", transactionManagerRef = "userTransactionManager") +@EnableJpaRepositories(basePackages = "com.baeldung.multipledb", entityManagerFactoryRef = "userEntityManager", transactionManagerRef = "userTransactionManager") @Profile("!tc") public class PersistenceUserConfiguration { @Autowired @@ -33,7 +33,7 @@ public class PersistenceUserConfiguration { public LocalContainerEntityManagerFactoryBean userEntityManager() { final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(userDataSource()); - em.setPackagesToScan("com.baeldung.domain.user"); + em.setPackagesToScan("com.baeldung.multipledb"); final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); em.setJpaVendorAdapter(vendorAdapter); diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/Possession.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/Possession.java new file mode 100644 index 0000000000..0281184dec --- /dev/null +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/Possession.java @@ -0,0 +1,82 @@ +package com.baeldung.multipledb; + +import javax.persistence.*; + +@Entity +@Table +public class Possession { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private long id; + + private String name; + + public Possession() { + super(); + } + + public Possession(final String name) { + super(); + + this.name = name; + } + + public long getId() { + return id; + } + + public void setId(final int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = (prime * result) + (int) (id ^ (id >>> 32)); + result = (prime * result) + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Possession other = (Possession) obj; + if (id != other.id) { + return false; + } + if (name == null) { + if (other.name != null) { + return false; + } + } else if (!name.equals(other.name)) { + return false; + } + return true; + } + + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(); + builder.append("Possesion [id=").append(id).append(", name=").append(name).append("]"); + return builder.toString(); + } + +} diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/PossessionRepository.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/PossessionRepository.java new file mode 100644 index 0000000000..104a0ca6b5 --- /dev/null +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/PossessionRepository.java @@ -0,0 +1,9 @@ +package com.baeldung.multipledb; + +import org.springframework.data.jpa.repository.JpaRepository; + +import com.baeldung.boot.domain.Possession; + +public interface PossessionRepository extends JpaRepository { + +} diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/product/Product.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/Product.java similarity index 97% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/product/Product.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/Product.java index 2f82e3e318..1edbd924a3 100755 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/domain/product/Product.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/Product.java @@ -1,4 +1,4 @@ -package com.baeldung.domain.product; +package com.baeldung.multipledb; import javax.persistence.Entity; import javax.persistence.Id; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/product/ProductRepository.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/ProductRepository.java similarity index 76% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/product/ProductRepository.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/ProductRepository.java index 1f9f5f9195..b82b0989de 100755 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/product/ProductRepository.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/ProductRepository.java @@ -1,6 +1,4 @@ -package com.baeldung.dao.repositories.product; - -import com.baeldung.domain.product.Product; +package com.baeldung.multipledb; import java.util.List; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/User.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/User.java new file mode 100644 index 0000000000..e173794d74 --- /dev/null +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/User.java @@ -0,0 +1,76 @@ +package com.baeldung.multipledb; + +import javax.persistence.*; +import java.util.List; + +@Entity +@Table(name = "users") +public class User { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private int id; + private String name; + private int age; + @Column(unique = true, nullable = false) + private String email; + private Integer status; + + public User() { + super(); + } + + public User(String name, String email, Integer status) { + this.name = name; + this.email = email; + this.status = status; + } + + public int getId() { + return id; + } + + public void setId(final int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + public String getEmail() { + return email; + } + + public void setEmail(final String email) { + this.email = email; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public int getAge() { + return age; + } + + public void setAge(final int age) { + this.age = age; + } + + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(); + builder.append("User [name=").append(name).append(", id=").append(id).append("]"); + return builder.toString(); + } + +} \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/services/IBarService.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/services/IBarService.java deleted file mode 100644 index 7e127488db..0000000000 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/services/IBarService.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.baeldung.services; - -import com.baeldung.domain.Bar; - -public interface IBarService extends IOperations { - // -} diff --git a/persistence-modules/spring-data-jpa/src/main/resources/application.properties b/persistence-modules/spring-data-jpa/src/main/resources/application.properties index 37fb9ca9c4..9ea2ad8970 100644 --- a/persistence-modules/spring-data-jpa/src/main/resources/application.properties +++ b/persistence-modules/spring-data-jpa/src/main/resources/application.properties @@ -1,17 +1,9 @@ -# spring.datasource.x -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=sa +#spring.datasource.data=import_entities.sql +#spring.jpa.properties.hibernate.hbm2ddl.import_files=import_entities.sql -# hibernate.X -hibernate.dialect=org.hibernate.dialect.H2Dialect -hibernate.show_sql=true -hibernate.hbm2ddl.auto=create-drop -hibernate.cache.use_second_level_cache=true -hibernate.cache.use_query_cache=true -hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFactory +spring.main.allow-bean-definition-overriding=true -spring.datasource.data=import_entities.sql -spring.main.allow-bean-definition-overriding=true \ No newline at end of file +# envers.X +#spring.jpa.properties.hibernate.hbm2ddl.import_files=import_entities.sql +spring.datasource.data=classpath:import_entities.sql \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa/src/main/resources/persistence.properties b/persistence-modules/spring-data-jpa/src/main/resources/persistence.properties index 3543e1b52b..6bc83edf34 100644 --- a/persistence-modules/spring-data-jpa/src/main/resources/persistence.properties +++ b/persistence-modules/spring-data-jpa/src/main/resources/persistence.properties @@ -12,5 +12,3 @@ hibernate.cache.use_second_level_cache=true hibernate.cache.use_query_cache=true hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFactory -# envers.X -envers.audit_table_suffix=_audit_log \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/dao/repositories/ArticleRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/daos/ArticleRepositoryIntegrationTest.java similarity index 82% rename from persistence-modules/spring-data-jpa/src/test/java/com/baeldung/dao/repositories/ArticleRepositoryIntegrationTest.java rename to persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/daos/ArticleRepositoryIntegrationTest.java index 093e744003..dfb04b3dfb 100644 --- a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/dao/repositories/ArticleRepositoryIntegrationTest.java +++ b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/daos/ArticleRepositoryIntegrationTest.java @@ -1,13 +1,16 @@ -package com.baeldung.dao.repositories; +package com.baeldung.boot.daos; + +import com.baeldung.boot.Application; +import com.baeldung.boot.config.PersistenceConfiguration; +import com.baeldung.boot.daos.ArticleRepository; +import com.baeldung.boot.domain.Article; -import com.baeldung.config.PersistenceConfiguration; -import com.baeldung.config.PersistenceProductConfiguration; -import com.baeldung.config.PersistenceUserConfiguration; -import com.baeldung.domain.Article; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.Import; import org.springframework.test.context.junit4.SpringRunner; import java.text.SimpleDateFormat; @@ -18,7 +21,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @RunWith(SpringRunner.class) -@DataJpaTest(excludeAutoConfiguration = {PersistenceConfiguration.class, PersistenceUserConfiguration.class, PersistenceProductConfiguration.class}) +@DataJpaTest(properties="spring.datasource.data=classpath:import_entities.sql") public class ArticleRepositoryIntegrationTest { @Autowired diff --git a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/dao/repositories/ExtendedStudentRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/daos/ExtendedStudentRepositoryIntegrationTest.java similarity index 80% rename from persistence-modules/spring-data-jpa/src/test/java/com/baeldung/dao/repositories/ExtendedStudentRepositoryIntegrationTest.java rename to persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/daos/ExtendedStudentRepositoryIntegrationTest.java index b19a34df82..66de5911db 100644 --- a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/dao/repositories/ExtendedStudentRepositoryIntegrationTest.java +++ b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/daos/ExtendedStudentRepositoryIntegrationTest.java @@ -1,7 +1,10 @@ -package com.baeldung.dao.repositories; +package com.baeldung.boot.daos; + +import com.baeldung.boot.Application; +import com.baeldung.boot.config.PersistenceConfiguration; +import com.baeldung.boot.daos.ExtendedStudentRepository; +import com.baeldung.boot.domain.Student; -import com.baeldung.config.PersistenceConfiguration; -import com.baeldung.domain.Student; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -15,7 +18,7 @@ import java.util.List; import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringRunner.class) -@ContextConfiguration(classes = {PersistenceConfiguration.class}) +@ContextConfiguration(classes = {Application.class}) @DirtiesContext public class ExtendedStudentRepositoryIntegrationTest { @Resource diff --git a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/dao/repositories/InventoryRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/daos/InventoryRepositoryIntegrationTest.java similarity index 85% rename from persistence-modules/spring-data-jpa/src/test/java/com/baeldung/dao/repositories/InventoryRepositoryIntegrationTest.java rename to persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/daos/InventoryRepositoryIntegrationTest.java index 9d6334445c..877e59d5a2 100644 --- a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/dao/repositories/InventoryRepositoryIntegrationTest.java +++ b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/daos/InventoryRepositoryIntegrationTest.java @@ -1,11 +1,15 @@ -package com.baeldung.dao.repositories; +package com.baeldung.boot.daos; + +import com.baeldung.boot.Application; +import com.baeldung.boot.config.PersistenceConfiguration; +import com.baeldung.boot.daos.InventoryRepository; +import com.baeldung.boot.domain.MerchandiseEntity; -import com.baeldung.config.PersistenceConfiguration; -import com.baeldung.domain.MerchandiseEntity; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; import java.math.BigDecimal; @@ -15,7 +19,7 @@ import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; @RunWith(SpringRunner.class) -@DataJpaTest(excludeAutoConfiguration = {PersistenceConfiguration.class}) +@SpringBootTest(classes=Application.class) public class InventoryRepositoryIntegrationTest { private static final String ORIGINAL_TITLE = "Pair of Pants"; diff --git a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/dao/repositories/JpaRepositoriesIntegrationTest.java b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/daos/JpaRepositoriesIntegrationTest.java similarity index 80% rename from persistence-modules/spring-data-jpa/src/test/java/com/baeldung/dao/repositories/JpaRepositoriesIntegrationTest.java rename to persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/daos/JpaRepositoriesIntegrationTest.java index 01405c0b8a..30925d9b68 100644 --- a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/dao/repositories/JpaRepositoriesIntegrationTest.java +++ b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/daos/JpaRepositoriesIntegrationTest.java @@ -1,4 +1,4 @@ -package com.baeldung.dao.repositories; +package com.baeldung.boot.daos; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertFalse; @@ -13,18 +13,24 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; -import com.baeldung.config.PersistenceConfiguration; -import com.baeldung.config.PersistenceProductConfiguration; -import com.baeldung.config.PersistenceUserConfiguration; -import com.baeldung.domain.Item; -import com.baeldung.domain.ItemType; -import com.baeldung.domain.Location; -import com.baeldung.domain.Store; +import com.baeldung.boot.Application; +import com.baeldung.boot.config.PersistenceConfiguration; +import com.baeldung.boot.daos.ItemTypeRepository; +import com.baeldung.boot.daos.LocationRepository; +import com.baeldung.boot.daos.ReadOnlyLocationRepository; +import com.baeldung.boot.daos.StoreRepository; +import com.baeldung.boot.domain.Item; +import com.baeldung.boot.domain.ItemType; +import com.baeldung.boot.domain.Location; +import com.baeldung.boot.domain.Store; +import com.baeldung.multipledb.PersistenceProductConfiguration; +import com.baeldung.multipledb.PersistenceUserConfiguration; @RunWith(SpringRunner.class) -@DataJpaTest(excludeAutoConfiguration = { PersistenceConfiguration.class, PersistenceUserConfiguration.class, PersistenceProductConfiguration.class }) +@DataJpaTest(properties="spring.datasource.data=classpath:import_entities.sql") public class JpaRepositoriesIntegrationTest { @Autowired private LocationRepository locationRepository; diff --git a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/dao/repositories/PersonInsertRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/daos/PersonInsertRepositoryIntegrationTest.java similarity index 94% rename from persistence-modules/spring-data-jpa/src/test/java/com/baeldung/dao/repositories/PersonInsertRepositoryIntegrationTest.java rename to persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/daos/PersonInsertRepositoryIntegrationTest.java index b248cf8bf1..9d45c17035 100644 --- a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/dao/repositories/PersonInsertRepositoryIntegrationTest.java +++ b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/daos/PersonInsertRepositoryIntegrationTest.java @@ -1,7 +1,8 @@ -package com.baeldung.dao.repositories; +package com.baeldung.boot.daos; + +import com.baeldung.boot.daos.impl.PersonInsertRepository; +import com.baeldung.boot.domain.Person; -import com.baeldung.dao.repositories.impl.PersonInsertRepository; -import com.baeldung.domain.Person; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; diff --git a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/daos/UserRepositoryCommon.java b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/daos/UserRepositoryCommon.java new file mode 100644 index 0000000000..e101d35de1 --- /dev/null +++ b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/daos/UserRepositoryCommon.java @@ -0,0 +1,405 @@ +package com.baeldung.boot.daos; + +import com.baeldung.boot.domain.User; +import com.baeldung.boot.user.UserRepository; + +import org.junit.After; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Sort; +import org.springframework.data.jpa.domain.JpaSort; +import org.springframework.data.mapping.PropertyReferenceException; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import java.util.stream.Stream; + +import static org.assertj.core.api.Assertions.assertThat; + +class UserRepositoryCommon { + + final String USER_EMAIL = "email@example.com"; + final String USER_EMAIL2 = "email2@example.com"; + final String USER_EMAIL3 = "email3@example.com"; + final String USER_EMAIL4 = "email4@example.com"; + final Integer INACTIVE_STATUS = 0; + final Integer ACTIVE_STATUS = 1; + final String USER_EMAIL5 = "email5@example.com"; + final String USER_EMAIL6 = "email6@example.com"; + final String USER_NAME_ADAM = "Adam"; + final String USER_NAME_PETER = "Peter"; + + @Autowired + protected UserRepository userRepository; + + @Test + @Transactional + public void givenUsersWithSameNameInDB_WhenFindAllByName_ThenReturnStreamOfUsers() { + User user1 = new User(); + user1.setName(USER_NAME_ADAM); + user1.setEmail(USER_EMAIL); + userRepository.save(user1); + + User user2 = new User(); + user2.setName(USER_NAME_ADAM); + user2.setEmail(USER_EMAIL2); + userRepository.save(user2); + + User user3 = new User(); + user3.setName(USER_NAME_ADAM); + user3.setEmail(USER_EMAIL3); + userRepository.save(user3); + + User user4 = new User(); + user4.setName("SAMPLE"); + user4.setEmail(USER_EMAIL4); + userRepository.save(user4); + + try (Stream foundUsersStream = userRepository.findAllByName(USER_NAME_ADAM)) { + assertThat(foundUsersStream.count()).isEqualTo(3l); + } + } + + @Test + public void givenUsersInDB_WhenFindAllWithQueryAnnotation_ThenReturnCollectionWithActiveUsers() { + User user1 = new User(); + user1.setName(USER_NAME_ADAM); + user1.setEmail(USER_EMAIL); + user1.setStatus(ACTIVE_STATUS); + userRepository.save(user1); + + User user2 = new User(); + user2.setName(USER_NAME_ADAM); + user2.setEmail(USER_EMAIL2); + user2.setStatus(ACTIVE_STATUS); + userRepository.save(user2); + + User user3 = new User(); + user3.setName(USER_NAME_ADAM); + user3.setEmail(USER_EMAIL3); + user3.setStatus(INACTIVE_STATUS); + userRepository.save(user3); + + Collection allActiveUsers = userRepository.findAllActiveUsers(); + + assertThat(allActiveUsers.size()).isEqualTo(2); + } + + @Test + public void givenUsersInDB_WhenFindAllWithQueryAnnotationNative_ThenReturnCollectionWithActiveUsers() { + User user1 = new User(); + user1.setName(USER_NAME_ADAM); + user1.setEmail(USER_EMAIL); + user1.setStatus(ACTIVE_STATUS); + userRepository.save(user1); + + User user2 = new User(); + user2.setName(USER_NAME_ADAM); + user2.setEmail(USER_EMAIL2); + user2.setStatus(ACTIVE_STATUS); + userRepository.save(user2); + + User user3 = new User(); + user3.setName(USER_NAME_ADAM); + user3.setEmail(USER_EMAIL3); + user3.setStatus(INACTIVE_STATUS); + userRepository.save(user3); + + Collection allActiveUsers = userRepository.findAllActiveUsersNative(); + + assertThat(allActiveUsers.size()).isEqualTo(2); + } + + @Test + public void givenUserInDB_WhenFindUserByStatusWithQueryAnnotation_ThenReturnActiveUser() { + User user = new User(); + user.setName(USER_NAME_ADAM); + user.setEmail(USER_EMAIL); + user.setStatus(ACTIVE_STATUS); + userRepository.save(user); + + User userByStatus = userRepository.findUserByStatus(ACTIVE_STATUS); + + assertThat(userByStatus.getName()).isEqualTo(USER_NAME_ADAM); + } + + @Test + public void givenUserInDB_WhenFindUserByStatusWithQueryAnnotationNative_ThenReturnActiveUser() { + User user = new User(); + user.setName(USER_NAME_ADAM); + user.setEmail(USER_EMAIL); + user.setStatus(ACTIVE_STATUS); + userRepository.save(user); + + User userByStatus = userRepository.findUserByStatusNative(ACTIVE_STATUS); + + assertThat(userByStatus.getName()).isEqualTo(USER_NAME_ADAM); + } + + @Test + public void givenUsersInDB_WhenFindUserByStatusAndNameWithQueryAnnotationIndexedParams_ThenReturnOneUser() { + User user = new User(); + user.setName(USER_NAME_ADAM); + user.setEmail(USER_EMAIL); + user.setStatus(ACTIVE_STATUS); + userRepository.save(user); + + User user2 = new User(); + user2.setName(USER_NAME_PETER); + user2.setEmail(USER_EMAIL2); + user2.setStatus(ACTIVE_STATUS); + userRepository.save(user2); + + User userByStatus = userRepository.findUserByStatusAndName(ACTIVE_STATUS, USER_NAME_ADAM); + + assertThat(userByStatus.getName()).isEqualTo(USER_NAME_ADAM); + } + + @Test + public void givenUsersInDB_WhenFindUserByStatusAndNameWithQueryAnnotationNamedParams_ThenReturnOneUser() { + User user = new User(); + user.setName(USER_NAME_ADAM); + user.setEmail(USER_EMAIL); + user.setStatus(ACTIVE_STATUS); + userRepository.save(user); + + User user2 = new User(); + user2.setName(USER_NAME_PETER); + user2.setEmail(USER_EMAIL2); + user2.setStatus(ACTIVE_STATUS); + userRepository.save(user2); + + User userByStatus = userRepository.findUserByStatusAndNameNamedParams(ACTIVE_STATUS, USER_NAME_ADAM); + + assertThat(userByStatus.getName()).isEqualTo(USER_NAME_ADAM); + } + + @Test + public void givenUsersInDB_WhenFindUserByStatusAndNameWithQueryAnnotationNativeNamedParams_ThenReturnOneUser() { + User user = new User(); + user.setName(USER_NAME_ADAM); + user.setEmail(USER_EMAIL); + user.setStatus(ACTIVE_STATUS); + userRepository.save(user); + + User user2 = new User(); + user2.setName(USER_NAME_PETER); + user2.setEmail(USER_EMAIL2); + user2.setStatus(ACTIVE_STATUS); + userRepository.save(user2); + + User userByStatus = userRepository.findUserByStatusAndNameNamedParamsNative(ACTIVE_STATUS, USER_NAME_ADAM); + + assertThat(userByStatus.getName()).isEqualTo(USER_NAME_ADAM); + } + + @Test + public void givenUsersInDB_WhenFindUserByStatusAndNameWithQueryAnnotationNamedParamsCustomNames_ThenReturnOneUser() { + User user = new User(); + user.setName(USER_NAME_ADAM); + user.setEmail(USER_EMAIL); + user.setStatus(ACTIVE_STATUS); + userRepository.save(user); + + User user2 = new User(); + user2.setName(USER_NAME_PETER); + user2.setEmail(USER_EMAIL2); + user2.setStatus(ACTIVE_STATUS); + userRepository.save(user2); + + User userByStatus = userRepository.findUserByUserStatusAndUserName(ACTIVE_STATUS, USER_NAME_ADAM); + + assertThat(userByStatus.getName()).isEqualTo(USER_NAME_ADAM); + } + + @Test + public void givenUsersInDB_WhenFindUserByNameLikeWithQueryAnnotationIndexedParams_ThenReturnUser() { + User user = new User(); + user.setName(USER_NAME_ADAM); + user.setEmail(USER_EMAIL); + user.setStatus(ACTIVE_STATUS); + userRepository.save(user); + + User userByStatus = userRepository.findUserByNameLike("Ad"); + + assertThat(userByStatus.getName()).isEqualTo(USER_NAME_ADAM); + } + + @Test + public void givenUsersInDB_WhenFindUserByNameLikeWithQueryAnnotationNamedParams_ThenReturnUser() { + User user = new User(); + user.setName(USER_NAME_ADAM); + user.setEmail(USER_EMAIL); + user.setStatus(ACTIVE_STATUS); + userRepository.save(user); + + User userByStatus = userRepository.findUserByNameLikeNamedParam("Ad"); + + assertThat(userByStatus.getName()).isEqualTo(USER_NAME_ADAM); + } + + @Test + public void givenUsersInDB_WhenFindUserByNameLikeWithQueryAnnotationNative_ThenReturnUser() { + User user = new User(); + user.setName(USER_NAME_ADAM); + user.setEmail(USER_EMAIL); + user.setStatus(ACTIVE_STATUS); + userRepository.save(user); + + User userByStatus = userRepository.findUserByNameLikeNative("Ad"); + + assertThat(userByStatus.getName()).isEqualTo(USER_NAME_ADAM); + } + + @Test + public void givenUsersInDB_WhenFindAllWithSortByName_ThenReturnUsersSorted() { + userRepository.save(new User(USER_NAME_ADAM, USER_EMAIL, ACTIVE_STATUS)); + userRepository.save(new User(USER_NAME_PETER, USER_EMAIL2, ACTIVE_STATUS)); + userRepository.save(new User("SAMPLE", USER_EMAIL3, INACTIVE_STATUS)); + + List usersSortByName = userRepository.findAll(new Sort(Sort.Direction.ASC, "name")); + + assertThat(usersSortByName.get(0) + .getName()).isEqualTo(USER_NAME_ADAM); + } + + @Test(expected = PropertyReferenceException.class) + public void givenUsersInDB_WhenFindAllSortWithFunction_ThenThrowException() { + userRepository.save(new User(USER_NAME_ADAM, USER_EMAIL, ACTIVE_STATUS)); + userRepository.save(new User(USER_NAME_PETER, USER_EMAIL2, ACTIVE_STATUS)); + userRepository.save(new User("SAMPLE", USER_EMAIL3, INACTIVE_STATUS)); + + userRepository.findAll(new Sort(Sort.Direction.ASC, "name")); + + List usersSortByNameLength = userRepository.findAll(new Sort("LENGTH(name)")); + + assertThat(usersSortByNameLength.get(0) + .getName()).isEqualTo(USER_NAME_ADAM); + } + + @Test + public void givenUsersInDB_WhenFindAllSortWithFunctionQueryAnnotationJPQL_ThenReturnUsersSorted() { + userRepository.save(new User(USER_NAME_ADAM, USER_EMAIL, ACTIVE_STATUS)); + userRepository.save(new User(USER_NAME_PETER, USER_EMAIL2, ACTIVE_STATUS)); + userRepository.save(new User("SAMPLE", USER_EMAIL3, INACTIVE_STATUS)); + + userRepository.findAllUsers(new Sort("name")); + + List usersSortByNameLength = userRepository.findAllUsers(JpaSort.unsafe("LENGTH(name)")); + + assertThat(usersSortByNameLength.get(0) + .getName()).isEqualTo(USER_NAME_ADAM); + } + + @Test + public void givenUsersInDB_WhenFindAllWithPageRequestQueryAnnotationJPQL_ThenReturnPageOfUsers() { + userRepository.save(new User(USER_NAME_ADAM, USER_EMAIL, ACTIVE_STATUS)); + userRepository.save(new User(USER_NAME_PETER, USER_EMAIL2, ACTIVE_STATUS)); + userRepository.save(new User("SAMPLE", USER_EMAIL3, INACTIVE_STATUS)); + userRepository.save(new User("SAMPLE1", USER_EMAIL4, INACTIVE_STATUS)); + userRepository.save(new User("SAMPLE2", USER_EMAIL5, INACTIVE_STATUS)); + userRepository.save(new User("SAMPLE3", USER_EMAIL6, INACTIVE_STATUS)); + + Page usersPage = userRepository.findAllUsersWithPagination(new PageRequest(1, 3)); + + assertThat(usersPage.getContent() + .get(0) + .getName()).isEqualTo("SAMPLE1"); + } + + @Test + public void givenUsersInDB_WhenFindAllWithPageRequestQueryAnnotationNative_ThenReturnPageOfUsers() { + userRepository.save(new User(USER_NAME_ADAM, USER_EMAIL, ACTIVE_STATUS)); + userRepository.save(new User(USER_NAME_PETER, USER_EMAIL2, ACTIVE_STATUS)); + userRepository.save(new User("SAMPLE", USER_EMAIL3, INACTIVE_STATUS)); + userRepository.save(new User("SAMPLE1", USER_EMAIL4, INACTIVE_STATUS)); + userRepository.save(new User("SAMPLE2", USER_EMAIL5, INACTIVE_STATUS)); + userRepository.save(new User("SAMPLE3", USER_EMAIL6, INACTIVE_STATUS)); + + Page usersSortByNameLength = userRepository.findAllUsersWithPaginationNative(new PageRequest(1, 3)); + + assertThat(usersSortByNameLength.getContent() + .get(0) + .getName()).isEqualTo("SAMPLE1"); + } + + @Test + @Transactional + public void givenUsersInDB_WhenUpdateStatusForNameModifyingQueryAnnotationJPQL_ThenModifyMatchingUsers() { + userRepository.save(new User("SAMPLE", USER_EMAIL, ACTIVE_STATUS)); + userRepository.save(new User("SAMPLE1", USER_EMAIL2, ACTIVE_STATUS)); + userRepository.save(new User("SAMPLE", USER_EMAIL3, ACTIVE_STATUS)); + userRepository.save(new User("SAMPLE3", USER_EMAIL4, ACTIVE_STATUS)); + + int updatedUsersSize = userRepository.updateUserSetStatusForName(INACTIVE_STATUS, "SAMPLE"); + + assertThat(updatedUsersSize).isEqualTo(2); + } + + @Test + public void givenUsersInDB_WhenFindByEmailsWithDynamicQuery_ThenReturnCollection() { + + User user1 = new User(); + user1.setEmail(USER_EMAIL); + userRepository.save(user1); + + User user2 = new User(); + user2.setEmail(USER_EMAIL2); + userRepository.save(user2); + + User user3 = new User(); + user3.setEmail(USER_EMAIL3); + userRepository.save(user3); + + Set emails = new HashSet<>(); + emails.add(USER_EMAIL2); + emails.add(USER_EMAIL3); + + Collection usersWithEmails = userRepository.findUserByEmails(emails); + + assertThat(usersWithEmails.size()).isEqualTo(2); + } + + @Test + public void givenUsersInDBWhenFindByNameListReturnCollection() { + + User user1 = new User(); + user1.setName(USER_NAME_ADAM); + user1.setEmail(USER_EMAIL); + userRepository.save(user1); + + User user2 = new User(); + user2.setName(USER_NAME_PETER); + user2.setEmail(USER_EMAIL2); + userRepository.save(user2); + + List names = Arrays.asList(USER_NAME_ADAM, USER_NAME_PETER); + + List usersWithNames = userRepository.findUserByNameList(names); + + assertThat(usersWithNames.size()).isEqualTo(2); + } + + + @Test + @Transactional + public void whenInsertedWithQuery_ThenUserIsPersisted() { + userRepository.insertUser(USER_NAME_ADAM, 1, ACTIVE_STATUS, USER_EMAIL); + userRepository.insertUser(USER_NAME_PETER, 1, ACTIVE_STATUS, USER_EMAIL2); + + User userAdam = userRepository.findUserByNameLike(USER_NAME_ADAM); + User userPeter = userRepository.findUserByNameLike(USER_NAME_PETER); + + assertThat(userAdam).isNotNull(); + assertThat(userAdam.getEmail()).isEqualTo(USER_EMAIL); + assertThat(userPeter).isNotNull(); + assertThat(userPeter.getEmail()).isEqualTo(USER_EMAIL2); + } + + @After + public void cleanUp() { + userRepository.deleteAll(); + } +} diff --git a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/daos/UserRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/daos/UserRepositoryIntegrationTest.java new file mode 100644 index 0000000000..ac8fdf8ea2 --- /dev/null +++ b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/daos/UserRepositoryIntegrationTest.java @@ -0,0 +1,37 @@ +package com.baeldung.boot.daos; + +import com.baeldung.boot.Application; +import com.baeldung.boot.config.PersistenceConfiguration; +import com.baeldung.boot.domain.User; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.transaction.annotation.Transactional; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Created by adam. + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = Application.class) +@DirtiesContext +public class UserRepositoryIntegrationTest extends UserRepositoryCommon { + + @Test + @Transactional + public void givenUsersInDBWhenUpdateStatusForNameModifyingQueryAnnotationNativeThenModifyMatchingUsers() { + userRepository.save(new User("SAMPLE", USER_EMAIL, ACTIVE_STATUS)); + userRepository.save(new User("SAMPLE1", USER_EMAIL2, ACTIVE_STATUS)); + userRepository.save(new User("SAMPLE", USER_EMAIL3, ACTIVE_STATUS)); + userRepository.save(new User("SAMPLE3", USER_EMAIL4, ACTIVE_STATUS)); + userRepository.flush(); + + int updatedUsersSize = userRepository.updateUserSetStatusForNameNative(INACTIVE_STATUS, "SAMPLE"); + + assertThat(updatedUsersSize).isEqualTo(2); + } +} diff --git a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/daos/UserRepositoryTCAutoIntegrationTest.java b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/daos/UserRepositoryTCAutoIntegrationTest.java new file mode 100644 index 0000000000..599546fdbf --- /dev/null +++ b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/daos/UserRepositoryTCAutoIntegrationTest.java @@ -0,0 +1,40 @@ +package com.baeldung.boot.daos; + +import com.baeldung.boot.domain.User; +import com.baeldung.util.BaeldungPostgresqlContainer; +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.transaction.annotation.Transactional; +import org.testcontainers.containers.PostgreSQLContainer; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Created by adam. + */ +@RunWith(SpringRunner.class) +@SpringBootTest +@ActiveProfiles({"tc", "tc-auto"}) +public class UserRepositoryTCAutoIntegrationTest extends UserRepositoryCommon { + + @ClassRule + public static PostgreSQLContainer postgreSQLContainer = BaeldungPostgresqlContainer.getInstance(); + + @Test + @Transactional + public void givenUsersInDB_WhenUpdateStatusForNameModifyingQueryAnnotationNativePostgres_ThenModifyMatchingUsers() { + userRepository.save(new User("SAMPLE", USER_EMAIL, ACTIVE_STATUS)); + userRepository.save(new User("SAMPLE1", USER_EMAIL2, ACTIVE_STATUS)); + userRepository.save(new User("SAMPLE", USER_EMAIL3, ACTIVE_STATUS)); + userRepository.save(new User("SAMPLE3", USER_EMAIL4, ACTIVE_STATUS)); + userRepository.flush(); + + int updatedUsersSize = userRepository.updateUserSetStatusForNameNativePostgres(INACTIVE_STATUS, "SAMPLE"); + + assertThat(updatedUsersSize).isEqualTo(2); + } +} diff --git a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/daos/UserRepositoryTCIntegrationTest.java b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/daos/UserRepositoryTCIntegrationTest.java new file mode 100644 index 0000000000..2c5f7bcfa6 --- /dev/null +++ b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/daos/UserRepositoryTCIntegrationTest.java @@ -0,0 +1,56 @@ +package com.baeldung.boot.daos; + +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.util.TestPropertyValues; +import org.springframework.context.ApplicationContextInitializer; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.transaction.annotation.Transactional; +import org.testcontainers.containers.PostgreSQLContainer; + +import com.baeldung.boot.domain.User; + +import static org.assertj.core.api.Assertions.assertThat; + +@RunWith(SpringRunner.class) +@SpringBootTest +@ActiveProfiles("tc") +@ContextConfiguration(initializers = {UserRepositoryTCIntegrationTest.Initializer.class}) +public class UserRepositoryTCIntegrationTest extends UserRepositoryCommon { + + @ClassRule + public static PostgreSQLContainer postgreSQLContainer = new PostgreSQLContainer("postgres:11.1") + .withDatabaseName("integration-tests-db") + .withUsername("sa") + .withPassword("sa"); + + @Test + @Transactional + public void givenUsersInDB_WhenUpdateStatusForNameModifyingQueryAnnotationNative_ThenModifyMatchingUsers() { + userRepository.save(new User("SAMPLE", USER_EMAIL, ACTIVE_STATUS)); + userRepository.save(new User("SAMPLE1", USER_EMAIL2, ACTIVE_STATUS)); + userRepository.save(new User("SAMPLE", USER_EMAIL3, ACTIVE_STATUS)); + userRepository.save(new User("SAMPLE3", USER_EMAIL4, ACTIVE_STATUS)); + userRepository.flush(); + + int updatedUsersSize = userRepository.updateUserSetStatusForNameNativePostgres(INACTIVE_STATUS, "SAMPLE"); + + assertThat(updatedUsersSize).isEqualTo(2); + } + + static class Initializer + implements ApplicationContextInitializer { + public void initialize(ConfigurableApplicationContext configurableApplicationContext) { + TestPropertyValues.of( + "spring.datasource.url=" + postgreSQLContainer.getJdbcUrl(), + "spring.datasource.username=" + postgreSQLContainer.getUsername(), + "spring.datasource.password=" + postgreSQLContainer.getPassword() + ).applyTo(configurableApplicationContext.getEnvironment()); + } + } +} diff --git a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/ddd/event/Aggregate2EventsIntegrationTest.java b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/ddd/event/Aggregate2EventsIntegrationTest.java similarity index 90% rename from persistence-modules/spring-data-jpa/src/test/java/com/baeldung/ddd/event/Aggregate2EventsIntegrationTest.java rename to persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/ddd/event/Aggregate2EventsIntegrationTest.java index 3f650d4d63..e76b932cb9 100644 --- a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/ddd/event/Aggregate2EventsIntegrationTest.java +++ b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/ddd/event/Aggregate2EventsIntegrationTest.java @@ -1,7 +1,7 @@ /** * */ -package com.baeldung.ddd.event; +package com.baeldung.boot.ddd.event; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.times; @@ -15,6 +15,10 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; +import com.baeldung.boot.ddd.event.Aggregate2; +import com.baeldung.boot.ddd.event.Aggregate2Repository; +import com.baeldung.boot.ddd.event.DomainEvent; + @SpringJUnitConfig @SpringBootTest class Aggregate2EventsIntegrationTest { diff --git a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/ddd/event/Aggregate3EventsIntegrationTest.java b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/ddd/event/Aggregate3EventsIntegrationTest.java similarity index 90% rename from persistence-modules/spring-data-jpa/src/test/java/com/baeldung/ddd/event/Aggregate3EventsIntegrationTest.java rename to persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/ddd/event/Aggregate3EventsIntegrationTest.java index 893dcac3f8..4193e932ee 100644 --- a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/ddd/event/Aggregate3EventsIntegrationTest.java +++ b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/ddd/event/Aggregate3EventsIntegrationTest.java @@ -1,7 +1,7 @@ /** * */ -package com.baeldung.ddd.event; +package com.baeldung.boot.ddd.event; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.times; @@ -14,6 +14,10 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; +import com.baeldung.boot.ddd.event.Aggregate3; +import com.baeldung.boot.ddd.event.Aggregate3Repository; +import com.baeldung.boot.ddd.event.DomainEvent; + @SpringJUnitConfig @SpringBootTest class Aggregate3EventsIntegrationTest { diff --git a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/ddd/event/AggregateEventsIntegrationTest.java b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/ddd/event/AggregateEventsIntegrationTest.java similarity index 91% rename from persistence-modules/spring-data-jpa/src/test/java/com/baeldung/ddd/event/AggregateEventsIntegrationTest.java rename to persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/ddd/event/AggregateEventsIntegrationTest.java index f0e1147245..ac607063b2 100644 --- a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/ddd/event/AggregateEventsIntegrationTest.java +++ b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/ddd/event/AggregateEventsIntegrationTest.java @@ -1,4 +1,4 @@ -package com.baeldung.ddd.event; +package com.baeldung.boot.ddd.event; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.times; @@ -16,6 +16,11 @@ import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.annotation.Bean; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; +import com.baeldung.boot.ddd.event.Aggregate; +import com.baeldung.boot.ddd.event.AggregateRepository; +import com.baeldung.boot.ddd.event.DomainEvent; +import com.baeldung.boot.ddd.event.DomainService; + @SpringJUnitConfig @SpringBootTest class AggregateEventsIntegrationTest { diff --git a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/ddd/event/TestEventHandler.java b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/ddd/event/TestEventHandler.java similarity index 68% rename from persistence-modules/spring-data-jpa/src/test/java/com/baeldung/ddd/event/TestEventHandler.java rename to persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/ddd/event/TestEventHandler.java index 721402c17a..0f499834eb 100644 --- a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/ddd/event/TestEventHandler.java +++ b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/ddd/event/TestEventHandler.java @@ -1,10 +1,12 @@ /** * */ -package com.baeldung.ddd.event; +package com.baeldung.boot.ddd.event; import org.springframework.transaction.event.TransactionalEventListener; +import com.baeldung.boot.ddd.event.DomainEvent; + interface TestEventHandler { @TransactionalEventListener void handleEvent(DomainEvent event); diff --git a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/passenger/PassengerRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/passenger/PassengerRepositoryIntegrationTest.java similarity index 97% rename from persistence-modules/spring-data-jpa/src/test/java/com/baeldung/passenger/PassengerRepositoryIntegrationTest.java rename to persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/passenger/PassengerRepositoryIntegrationTest.java index 8cd19cec03..afb97211f5 100644 --- a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/passenger/PassengerRepositoryIntegrationTest.java +++ b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/passenger/PassengerRepositoryIntegrationTest.java @@ -1,4 +1,4 @@ -package com.baeldung.passenger; +package com.baeldung.boot.passenger; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.contains; @@ -24,6 +24,9 @@ import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; import org.springframework.test.context.junit4.SpringRunner; +import com.baeldung.boot.passenger.Passenger; +import com.baeldung.boot.passenger.PassengerRepository; + @DataJpaTest @RunWith(SpringRunner.class) public class PassengerRepositoryIntegrationTest { diff --git a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/services/AbstractServicePersistenceIntegrationTest.java b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/services/AbstractServicePersistenceIntegrationTest.java similarity index 98% rename from persistence-modules/spring-data-jpa/src/test/java/com/baeldung/services/AbstractServicePersistenceIntegrationTest.java rename to persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/services/AbstractServicePersistenceIntegrationTest.java index acac66f2f7..bf0c85fca6 100644 --- a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/services/AbstractServicePersistenceIntegrationTest.java +++ b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/services/AbstractServicePersistenceIntegrationTest.java @@ -1,6 +1,7 @@ -package com.baeldung.services; +package com.baeldung.boot.services; -import com.baeldung.domain.Foo; +import com.baeldung.boot.domain.Foo; +import com.baeldung.boot.services.IOperations; import com.baeldung.util.IDUtil; import org.hamcrest.Matchers; import org.junit.Ignore; diff --git a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/services/FooServicePersistenceIntegrationTest.java b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/services/FooServicePersistenceIntegrationTest.java similarity index 85% rename from persistence-modules/spring-data-jpa/src/test/java/com/baeldung/services/FooServicePersistenceIntegrationTest.java rename to persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/services/FooServicePersistenceIntegrationTest.java index fd17d033e1..f0e4aa7317 100644 --- a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/services/FooServicePersistenceIntegrationTest.java +++ b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/services/FooServicePersistenceIntegrationTest.java @@ -1,11 +1,16 @@ -package com.baeldung.services; +package com.baeldung.boot.services; + +import com.baeldung.boot.Application; +import com.baeldung.boot.config.PersistenceConfiguration; +import com.baeldung.boot.domain.Foo; +import com.baeldung.boot.services.IFooService; +import com.baeldung.boot.services.IOperations; -import com.baeldung.config.PersistenceConfiguration; -import com.baeldung.domain.Foo; import org.junit.Ignore; 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.dao.DataIntegrityViolationException; import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.test.context.ContextConfiguration; @@ -16,7 +21,7 @@ import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; import static org.junit.Assert.assertNotNull; @RunWith(SpringRunner.class) -@ContextConfiguration(classes = {PersistenceConfiguration.class}, loader = AnnotationConfigContextLoader.class) +@SpringBootTest(classes=Application.class) public class FooServicePersistenceIntegrationTest extends AbstractServicePersistenceIntegrationTest { @Autowired diff --git a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/services/SpringDataJPABarAuditIntegrationTest.java b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/services/SpringDataJPABarAuditIntegrationTest.java similarity index 87% rename from persistence-modules/spring-data-jpa/src/test/java/com/baeldung/services/SpringDataJPABarAuditIntegrationTest.java rename to persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/services/SpringDataJPABarAuditIntegrationTest.java index f3b857c73d..810cf70769 100644 --- a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/services/SpringDataJPABarAuditIntegrationTest.java +++ b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/services/SpringDataJPABarAuditIntegrationTest.java @@ -1,4 +1,4 @@ -package com.baeldung.services; +package com.baeldung.boot.services; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -16,16 +16,19 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.test.context.SpringBootTest; import org.springframework.security.test.context.support.WithMockUser; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; -import com.baeldung.config.PersistenceConfiguration; -import com.baeldung.domain.Bar; +import com.baeldung.boot.Application; +import com.baeldung.boot.config.PersistenceConfiguration; +import com.baeldung.boot.domain.Bar; +import com.baeldung.boot.services.IBarService; @RunWith(SpringRunner.class) -@ContextConfiguration(classes = { PersistenceConfiguration.class }, loader = AnnotationConfigContextLoader.class) +@SpringBootTest(classes=Application.class) public class SpringDataJPABarAuditIntegrationTest { private static Logger logger = LoggerFactory.getLogger(SpringDataJPABarAuditIntegrationTest.class); diff --git a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/services/JpaMultipleDBIntegrationTest.java b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/multipledb/JpaMultipleDBIntegrationTest.java similarity index 83% rename from persistence-modules/spring-data-jpa/src/test/java/com/baeldung/services/JpaMultipleDBIntegrationTest.java rename to persistence-modules/spring-data-jpa/src/test/java/com/baeldung/multipledb/JpaMultipleDBIntegrationTest.java index 71a3fb0b44..74f347caae 100644 --- a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/services/JpaMultipleDBIntegrationTest.java +++ b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/multipledb/JpaMultipleDBIntegrationTest.java @@ -1,4 +1,4 @@ -package com.baeldung.services; +package com.baeldung.multipledb; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -10,6 +10,7 @@ import java.util.Optional; 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.dao.DataIntegrityViolationException; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; @@ -17,17 +18,17 @@ import org.springframework.test.context.junit4.SpringRunner; import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.Transactional; -import com.baeldung.config.PersistenceProductConfiguration; -import com.baeldung.config.PersistenceUserConfiguration; -import com.baeldung.dao.repositories.product.ProductRepository; -import com.baeldung.dao.repositories.user.PossessionRepository; -import com.baeldung.dao.repositories.user.UserRepository; -import com.baeldung.domain.product.Product; -import com.baeldung.domain.user.Possession; -import com.baeldung.domain.user.User; +import com.baeldung.boot.domain.Possession; +import com.baeldung.boot.domain.User; +import com.baeldung.boot.user.PossessionRepository; +import com.baeldung.boot.user.UserRepository; +import com.baeldung.multipledb.PersistenceProductConfiguration; +import com.baeldung.multipledb.PersistenceUserConfiguration; +import com.baeldung.multipledb.Product; +import com.baeldung.multipledb.ProductRepository; @RunWith(SpringRunner.class) -@ContextConfiguration(classes = { PersistenceUserConfiguration.class, PersistenceProductConfiguration.class }) +@SpringBootTest(classes=MultipleDbApplication.class) @EnableTransactionManagement @DirtiesContext public class JpaMultipleDBIntegrationTest { diff --git a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/dao/repositories/product/ProductRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/multipledb/ProductRepositoryIntegrationTest.java similarity index 93% rename from persistence-modules/spring-data-jpa/src/test/java/com/baeldung/dao/repositories/product/ProductRepositoryIntegrationTest.java rename to persistence-modules/spring-data-jpa/src/test/java/com/baeldung/multipledb/ProductRepositoryIntegrationTest.java index 4caa0f0ca4..7b85cb479a 100644 --- a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/dao/repositories/product/ProductRepositoryIntegrationTest.java +++ b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/multipledb/ProductRepositoryIntegrationTest.java @@ -1,4 +1,4 @@ -package com.baeldung.dao.repositories.product; +package com.baeldung.multipledb; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasSize; @@ -13,6 +13,7 @@ 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.context.SpringBootTest; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; @@ -22,11 +23,12 @@ import org.springframework.test.context.junit4.SpringRunner; import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.Transactional; -import com.baeldung.config.PersistenceProductConfiguration; -import com.baeldung.domain.product.Product; +import com.baeldung.multipledb.PersistenceProductConfiguration; +import com.baeldung.multipledb.Product; +import com.baeldung.multipledb.ProductRepository; @RunWith(SpringRunner.class) -@ContextConfiguration(classes = { PersistenceProductConfiguration.class }) +@SpringBootTest(classes=MultipleDbApplication.class) @EnableTransactionManagement public class ProductRepositoryIntegrationTest { diff --git a/persistence-modules/spring-data-jpa/src/test/java/org/baeldung/SpringContextIntegrationTest.java b/persistence-modules/spring-data-jpa/src/test/java/org/baeldung/SpringContextIntegrationTest.java index 7f906bdbcd..e885d0fe51 100644 --- a/persistence-modules/spring-data-jpa/src/test/java/org/baeldung/SpringContextIntegrationTest.java +++ b/persistence-modules/spring-data-jpa/src/test/java/org/baeldung/SpringContextIntegrationTest.java @@ -5,7 +5,7 @@ import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; -import com.baeldung.Application; +import com.baeldung.boot.Application; @RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class) diff --git a/persistence-modules/spring-data-jpa/src/test/java/org/baeldung/SpringJpaContextIntegrationTest.java b/persistence-modules/spring-data-jpa/src/test/java/org/baeldung/SpringJpaContextIntegrationTest.java index 66b5b20b97..4a36407884 100644 --- a/persistence-modules/spring-data-jpa/src/test/java/org/baeldung/SpringJpaContextIntegrationTest.java +++ b/persistence-modules/spring-data-jpa/src/test/java/org/baeldung/SpringJpaContextIntegrationTest.java @@ -6,10 +6,10 @@ import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; -import com.baeldung.Application; -import com.baeldung.config.PersistenceConfiguration; -import com.baeldung.config.PersistenceProductConfiguration; -import com.baeldung.config.PersistenceUserConfiguration; +import com.baeldung.boot.Application; +import com.baeldung.boot.config.PersistenceConfiguration; +import com.baeldung.multipledb.PersistenceProductConfiguration; +import com.baeldung.multipledb.PersistenceUserConfiguration; @RunWith(SpringRunner.class) @DataJpaTest(excludeAutoConfiguration = { From 3170e3c96e8d9eefc8ccc887902f605a69b981b7 Mon Sep 17 00:00:00 2001 From: worldpeacez0991 <36908871+worldpeacez0991@users.noreply.github.com> Date: Fri, 8 Mar 2019 14:56:15 +0800 Subject: [PATCH 005/531] Update CourseService.java From beanutils.java, The method copyProperties(Object dest, Object orig) is improperly used in this example. --- .../main/java/com/baeldung/commons/beanutils/CourseService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries-apache-commons/src/main/java/com/baeldung/commons/beanutils/CourseService.java b/libraries-apache-commons/src/main/java/com/baeldung/commons/beanutils/CourseService.java index 538fa3accb..2c7644fd64 100644 --- a/libraries-apache-commons/src/main/java/com/baeldung/commons/beanutils/CourseService.java +++ b/libraries-apache-commons/src/main/java/com/baeldung/commons/beanutils/CourseService.java @@ -29,6 +29,6 @@ public class CourseService { } public static void copyProperties(Course course, CourseEntity courseEntity) throws IllegalAccessException, InvocationTargetException { - BeanUtils.copyProperties(course, courseEntity); + BeanUtils.copyProperties(courseEntity, course); } } From 90bd26c8b1c9257b2633ff9291c4b7a7d9d54f50 Mon Sep 17 00:00:00 2001 From: worldpeacez0991 <36908871+worldpeacez0991@users.noreply.github.com> Date: Fri, 8 Mar 2019 15:13:27 +0800 Subject: [PATCH 006/531] Update CourseServiceUnitTest.java junit method 'assertNotNull' added twice. --- .../com/baeldung/commons/beanutils/CourseServiceUnitTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries-apache-commons/src/test/java/com/baeldung/commons/beanutils/CourseServiceUnitTest.java b/libraries-apache-commons/src/test/java/com/baeldung/commons/beanutils/CourseServiceUnitTest.java index 833d91b2c4..e9b2ce93ca 100644 --- a/libraries-apache-commons/src/test/java/com/baeldung/commons/beanutils/CourseServiceUnitTest.java +++ b/libraries-apache-commons/src/test/java/com/baeldung/commons/beanutils/CourseServiceUnitTest.java @@ -44,6 +44,8 @@ public class CourseServiceUnitTest { CourseEntity courseEntity = new CourseEntity(); CourseService.copyProperties(course, courseEntity); + assertNotNull(course.getName()); + assertNotNull(courseEntity.getName()); Assert.assertEquals(course.getName(), courseEntity.getName()); Assert.assertEquals(course.getCodes(), courseEntity.getCodes()); Assert.assertNull(courseEntity.getStudent("ST-1")); From 320b48ccfe1c2efbbfdfad18536554419b2948d3 Mon Sep 17 00:00:00 2001 From: worldpeacez0991 <36908871+worldpeacez0991@users.noreply.github.com> Date: Fri, 8 Mar 2019 15:15:32 +0800 Subject: [PATCH 007/531] Update CourseServiceUnitTest.java --- .../com/baeldung/commons/beanutils/CourseServiceUnitTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries-apache-commons/src/test/java/com/baeldung/commons/beanutils/CourseServiceUnitTest.java b/libraries-apache-commons/src/test/java/com/baeldung/commons/beanutils/CourseServiceUnitTest.java index e9b2ce93ca..0772611a7b 100644 --- a/libraries-apache-commons/src/test/java/com/baeldung/commons/beanutils/CourseServiceUnitTest.java +++ b/libraries-apache-commons/src/test/java/com/baeldung/commons/beanutils/CourseServiceUnitTest.java @@ -45,7 +45,7 @@ public class CourseServiceUnitTest { CourseService.copyProperties(course, courseEntity); assertNotNull(course.getName()); - assertNotNull(courseEntity.getName()); + assertNotNull(courseEntity.getName()); Assert.assertEquals(course.getName(), courseEntity.getName()); Assert.assertEquals(course.getCodes(), courseEntity.getCodes()); Assert.assertNull(courseEntity.getStudent("ST-1")); From 2f5ff0c75b88acc812db995c6b549b12151fd2ae Mon Sep 17 00:00:00 2001 From: Orange Date: Fri, 8 Mar 2019 19:39:51 +0800 Subject: [PATCH 008/531] Update ProxyAcceptCookiePolicy.java The guide says: When we create an instance of ProxyAcceptCookiePolicy, we pass in a String of the domain address we would like to accept cookies from **in addition to** the original server. --- .../baeldung/networking/cookies/ProxyAcceptCookiePolicy.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core-java-networking/src/main/java/com/baeldung/networking/cookies/ProxyAcceptCookiePolicy.java b/core-java-networking/src/main/java/com/baeldung/networking/cookies/ProxyAcceptCookiePolicy.java index 0b5f6d7714..9fbbee8501 100644 --- a/core-java-networking/src/main/java/com/baeldung/networking/cookies/ProxyAcceptCookiePolicy.java +++ b/core-java-networking/src/main/java/com/baeldung/networking/cookies/ProxyAcceptCookiePolicy.java @@ -17,8 +17,8 @@ public class ProxyAcceptCookiePolicy implements CookiePolicy { host = uri.getHost(); } - if (!HttpCookie.domainMatches(acceptedProxy, host)) { - return false; + if (HttpCookie.domainMatches(acceptedProxy, host)) { + return true; } return CookiePolicy.ACCEPT_ORIGINAL_SERVER.shouldAccept(uri, cookie); From e98a39ba255eda7ec75d1a5ca62814cfb153fb3d Mon Sep 17 00:00:00 2001 From: mikr Date: Sun, 10 Mar 2019 19:28:09 +0100 Subject: [PATCH 009/531] BAEL-2562 New section in Generics article --- .../src/main/java/com/baeldung/generics/Generics.java | 7 +++++++ .../java/com/baeldung/generics/GenericsUnitTest.java | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/generics/Generics.java b/core-java-lang-syntax/src/main/java/com/baeldung/generics/Generics.java index e0536ca02e..1c4082c58b 100644 --- a/core-java-lang-syntax/src/main/java/com/baeldung/generics/Generics.java +++ b/core-java-lang-syntax/src/main/java/com/baeldung/generics/Generics.java @@ -1,5 +1,6 @@ package com.baeldung.generics; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.function.Function; @@ -28,4 +29,10 @@ public class Generics { buildings.forEach(Building::paint); } + public static List createList(int a) { + List list = new ArrayList<>(); + list.add(a); + return list; + } + } \ No newline at end of file diff --git a/core-java-lang-syntax/src/test/java/com/baeldung/generics/GenericsUnitTest.java b/core-java-lang-syntax/src/test/java/com/baeldung/generics/GenericsUnitTest.java index aca0b182a0..0bdf0afc15 100644 --- a/core-java-lang-syntax/src/test/java/com/baeldung/generics/GenericsUnitTest.java +++ b/core-java-lang-syntax/src/test/java/com/baeldung/generics/GenericsUnitTest.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.List; import static org.hamcrest.CoreMatchers.hasItems; +import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.fail; @@ -66,4 +67,12 @@ public class GenericsUnitTest { } } + @Test + public void givenAnInt_whenAddedToAGenericIntegerList_thenAListItemCanBeAssignedToAnInt() { + int number = 7; + List list = Generics.createList(number); + int otherNumber = list.get(0); + assertThat(otherNumber, is(number)); + } + } \ No newline at end of file From 83d82a657449fc38fb32c171f704744321a86e66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=B0=9A=E6=B8=9D?= Date: Tue, 12 Mar 2019 19:11:40 +0800 Subject: [PATCH 010/531] add calculateUsingFactory test case --- .../java/com/baeldung/reduceIfelse/CalculatorUnitTest.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core-java-8/src/test/java/com/baeldung/reduceIfelse/CalculatorUnitTest.java b/core-java-8/src/test/java/com/baeldung/reduceIfelse/CalculatorUnitTest.java index fa351930d8..1ff34bee89 100644 --- a/core-java-8/src/test/java/com/baeldung/reduceIfelse/CalculatorUnitTest.java +++ b/core-java-8/src/test/java/com/baeldung/reduceIfelse/CalculatorUnitTest.java @@ -29,4 +29,11 @@ public class CalculatorUnitTest { int result = calculator.calculate(new AddCommand(3, 7)); assertEquals(10, result); } + + @Test + public void whenCalculateUsingFactory_thenReturnCorrectResult() { + Calculator calculator = new Calculator(); + int result = calculator.calculateUsingFactory(3, 4, "add"); + assertEquals(7, result); + } } From b1a4f6bb219a26f652a9820ca94ab07602780119 Mon Sep 17 00:00:00 2001 From: Chirag Dewan Date: Sat, 16 Mar 2019 11:35:29 +0530 Subject: [PATCH 011/531] BAEL2489 Avoid check for null statement in Java --- core-java/pom.xml | 26 ++++------- .../java/com/baeldung/nulls/APIContracts.java | 7 +-- .../com/baeldung/nulls/Preconditions.java | 15 ++++--- .../baeldung/nulls/PrimitivesAndWrapper.java | 8 +--- .../java/com/baeldung/nulls/UsingObjects.java | 16 ++----- .../com/baeldung/nulls/UsingOptional.java | 26 ++++++----- .../com/baeldung/nulls/UsingStringUtils.java | 11 +++-- .../nulls/PrimitivesAndWrapperTest.java | 35 +++++++++++++++ .../com/baeldung/nulls/UsingLombokTest.java | 25 +++++++++++ .../com/baeldung/nulls/UsingObjectsTest.java | 31 +++++++++++++ .../com/baeldung/nulls/UsingOptionalTest.java | 37 ++++++++++++++++ .../baeldung/nulls/UsingStringUtilsTest.java | 43 +++++++++++++++++++ 12 files changed, 221 insertions(+), 59 deletions(-) create mode 100644 core-java/src/test/java/com/baeldung/nulls/PrimitivesAndWrapperTest.java create mode 100644 core-java/src/test/java/com/baeldung/nulls/UsingLombokTest.java create mode 100644 core-java/src/test/java/com/baeldung/nulls/UsingObjectsTest.java create mode 100644 core-java/src/test/java/com/baeldung/nulls/UsingOptionalTest.java create mode 100644 core-java/src/test/java/com/baeldung/nulls/UsingStringUtilsTest.java diff --git a/core-java/pom.xml b/core-java/pom.xml index e8548600f8..9c5a17d25c 100644 --- a/core-java/pom.xml +++ b/core-java/pom.xml @@ -216,8 +216,7 @@ true - + org.baeldung.executable.ExecutableMavenJar @@ -272,7 +271,7 @@ -Xmx300m -XX:+UseParallelGC -classpath - + com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed @@ -338,7 +337,7 @@ java -classpath - + org.openjdk.jmh.Main .* @@ -371,8 +370,7 @@ true - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - + ${project.build.outputDirectory}/META-INF/MANIFEST.MF @@ -406,14 +404,12 @@ true - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - + ${project.build.outputDirectory}/META-INF/MANIFEST.MF com/baeldung/instrumentation/application/MyAtm.class - com/baeldung/instrumentation/application/MyAtmApplication.class - + com/baeldung/instrumentation/application/MyAtmApplication.class com/baeldung/instrumentation/application/Launcher.class @@ -443,14 +439,12 @@ true - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - + ${project.build.outputDirectory}/META-INF/MANIFEST.MF com/baeldung/instrumentation/agent/AtmTransformer.class - com/baeldung/instrumentation/agent/MyInstrumentationAgent.class - + com/baeldung/instrumentation/agent/MyInstrumentationAgent.class @@ -462,7 +456,6 @@ - 2.8.2 @@ -483,12 +476,10 @@ 2.21.0 - 1.1 1.4.197 2.1.0.1 1.19 - 1.19 3.0.0-M1 3.0.2 @@ -499,7 +490,6 @@ 61.1 3.21.0-GA - 1.8.0 16.0.2 diff --git a/core-java/src/main/java/com/baeldung/nulls/APIContracts.java b/core-java/src/main/java/com/baeldung/nulls/APIContracts.java index f8dfba25dd..7d6abf53b8 100644 --- a/core-java/src/main/java/com/baeldung/nulls/APIContracts.java +++ b/core-java/src/main/java/com/baeldung/nulls/APIContracts.java @@ -4,6 +4,7 @@ public class APIContracts { /** * Prints the value of {@code param} if not null. Prints {@code null} otherwise. + * * @param param */ public void print(Object param) { @@ -11,16 +12,16 @@ public class APIContracts { } /** - * * @return non null result * @throws Exception - if result is null */ public Object process() throws Exception { Object result = doSomething(); - if (result == null) + if (result == null) { throw new Exception("Processing fail. Got a null response"); - else + } else { return result; + } } private Object doSomething() { diff --git a/core-java/src/main/java/com/baeldung/nulls/Preconditions.java b/core-java/src/main/java/com/baeldung/nulls/Preconditions.java index ff32db46dd..447026f1e3 100644 --- a/core-java/src/main/java/com/baeldung/nulls/Preconditions.java +++ b/core-java/src/main/java/com/baeldung/nulls/Preconditions.java @@ -3,22 +3,26 @@ package com.baeldung.nulls; public class Preconditions { public void goodAccept(String one, String two, String three) { - if (null == one || null == two || three == null) + if (one == null || two == null || three == null) throw new IllegalArgumentException(); + + process(one); + process(two); + process(three); } - public void badAccept(String one, String two, String three){ - if (null == one) + public void badAccept(String one, String two, String three) { + if (one == null) throw new IllegalArgumentException(); else process(one); - if (null == two) + if (two == null) throw new IllegalArgumentException(); else process(two); - if (null == three) + if (three == null) throw new IllegalArgumentException(); else process(three); @@ -28,5 +32,4 @@ public class Preconditions { private void process(String one) { } - } diff --git a/core-java/src/main/java/com/baeldung/nulls/PrimitivesAndWrapper.java b/core-java/src/main/java/com/baeldung/nulls/PrimitivesAndWrapper.java index dce7a05308..8f662b3760 100644 --- a/core-java/src/main/java/com/baeldung/nulls/PrimitivesAndWrapper.java +++ b/core-java/src/main/java/com/baeldung/nulls/PrimitivesAndWrapper.java @@ -2,11 +2,11 @@ package com.baeldung.nulls; public class PrimitivesAndWrapper { - public static int sum(int a, int b) { + public static int primitiveSum(int a, int b) { return a + b; } - public static Integer sum(Integer a, Integer b) { + public static Integer wrapperSum(Integer a, Integer b) { return a + b; } @@ -17,8 +17,4 @@ public class PrimitivesAndWrapper { throw new IllegalArgumentException(); } - public static void main(String[] args) { - sum(0, 0); - sum(null, null); - } } diff --git a/core-java/src/main/java/com/baeldung/nulls/UsingObjects.java b/core-java/src/main/java/com/baeldung/nulls/UsingObjects.java index e8a3262ce7..7383ae84a7 100644 --- a/core-java/src/main/java/com/baeldung/nulls/UsingObjects.java +++ b/core-java/src/main/java/com/baeldung/nulls/UsingObjects.java @@ -4,21 +4,13 @@ import java.util.Objects; public class UsingObjects { - private String checked; - - public void accept(Object param) { + public void accept(Object param) throws Exception { try { Objects.requireNonNull(param); } catch (NullPointerException e) { - //doSomethingElseToo - e.printStackTrace(); - } - } - - public void caller() throws Exception { - if (Objects.nonNull(checked)) - accept(checked); - else throw new Exception(); + } + + //doSomething() } } diff --git a/core-java/src/main/java/com/baeldung/nulls/UsingOptional.java b/core-java/src/main/java/com/baeldung/nulls/UsingOptional.java index 626afc311d..6c17290a72 100644 --- a/core-java/src/main/java/com/baeldung/nulls/UsingOptional.java +++ b/core-java/src/main/java/com/baeldung/nulls/UsingOptional.java @@ -4,20 +4,24 @@ import java.util.Optional; public class UsingOptional { - public Optional process() { - if (isProcessed()) - return Optional.of("dummy"); - else + public Optional process(boolean processed) { + + String response = doSomething(processed); + + if (response == null) { return Optional.empty(); + } + + return Optional.of(response); } - public void caller() { - Optional result = process(); - result.ifPresent(p -> System.out.println(p)); - result.orElseThrow(() -> new IllegalArgumentException()); + private String doSomething(boolean processed) { + + if (processed) { + return "passed"; + } else { + return null; + } } - private boolean isProcessed() { - return false; - } } diff --git a/core-java/src/main/java/com/baeldung/nulls/UsingStringUtils.java b/core-java/src/main/java/com/baeldung/nulls/UsingStringUtils.java index 8cbf3752e1..c7c73b73eb 100644 --- a/core-java/src/main/java/com/baeldung/nulls/UsingStringUtils.java +++ b/core-java/src/main/java/com/baeldung/nulls/UsingStringUtils.java @@ -1,17 +1,22 @@ package com.baeldung.nulls; - import org.apache.commons.lang3.StringUtils; public class UsingStringUtils { public void accept(String param) { - if (StringUtils.isNotEmpty(param)) + if (StringUtils.isNotEmpty(param)) { System.out.println(param); + } else { + throw new IllegalArgumentException(); + } } public void acceptOnlyNonBlank(String param) { - if (StringUtils.isNotBlank(param)) + if (StringUtils.isNotBlank(param)) { System.out.println(param); + } else { + throw new IllegalArgumentException(); + } } } diff --git a/core-java/src/test/java/com/baeldung/nulls/PrimitivesAndWrapperTest.java b/core-java/src/test/java/com/baeldung/nulls/PrimitivesAndWrapperTest.java new file mode 100644 index 0000000000..4e0f44e555 --- /dev/null +++ b/core-java/src/test/java/com/baeldung/nulls/PrimitivesAndWrapperTest.java @@ -0,0 +1,35 @@ +package com.baeldung.nulls; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import org.junit.jupiter.api.Test; + +class PrimitivesAndWrapperTest { + + @Test + public void givenWrappers_whenBothArgsNonNull_thenReturnResult() { + + Integer sum = PrimitivesAndWrapper.wrapperSum(0, 0); + + assertEquals(0, sum.intValue()); + } + + @Test() + public void givenWrappers_whenOneArgIsNull_thenThrowNullPointerException() { + assertThrows(NullPointerException.class, () -> PrimitivesAndWrapper.wrapperSum(null, 2)); + } + + @Test() + public void givenWrappers_whenBothArgsAreNull_thenThrowNullPointerException() { + assertThrows(NullPointerException.class, () -> PrimitivesAndWrapper.wrapperSum(null, null)); + } + + @Test() + public void givenWrappersWithNullCheck_whenAnyArgIsNull_thenThrowIllegalArgumentException() { + assertThrows(IllegalArgumentException.class, () -> PrimitivesAndWrapper.goodSum(null, 2)); + } + + + +} \ No newline at end of file diff --git a/core-java/src/test/java/com/baeldung/nulls/UsingLombokTest.java b/core-java/src/test/java/com/baeldung/nulls/UsingLombokTest.java new file mode 100644 index 0000000000..5a41d444a4 --- /dev/null +++ b/core-java/src/test/java/com/baeldung/nulls/UsingLombokTest.java @@ -0,0 +1,25 @@ +package com.baeldung.nulls; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class UsingLombokTest { + + private UsingLombok classUnderTest; + + @BeforeEach + public void setup() { + classUnderTest = new UsingLombok(); + } + + @Test + public void whenNullArg_thenThrowNullPointerException() { + + assertThrows(NullPointerException.class, () -> classUnderTest.accept(null)); + + } + +} \ No newline at end of file diff --git a/core-java/src/test/java/com/baeldung/nulls/UsingObjectsTest.java b/core-java/src/test/java/com/baeldung/nulls/UsingObjectsTest.java new file mode 100644 index 0000000000..74170d980b --- /dev/null +++ b/core-java/src/test/java/com/baeldung/nulls/UsingObjectsTest.java @@ -0,0 +1,31 @@ +package com.baeldung.nulls; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +class UsingObjectsTest { + + private UsingObjects classUnderTest; + + @BeforeEach + public void setup() { + classUnderTest = new UsingObjects(); + } + + @Test + public void whenArgIsNull_thenThrowException() { + + assertThrows(Exception.class, () -> classUnderTest.accept(null)); + } + + @Test + public void whenArgIsNonNull_thenDoesNotThrowException() { + + assertDoesNotThrow(() -> classUnderTest.accept("test ")); + } + +} \ No newline at end of file diff --git a/core-java/src/test/java/com/baeldung/nulls/UsingOptionalTest.java b/core-java/src/test/java/com/baeldung/nulls/UsingOptionalTest.java new file mode 100644 index 0000000000..5c42b9dff1 --- /dev/null +++ b/core-java/src/test/java/com/baeldung/nulls/UsingOptionalTest.java @@ -0,0 +1,37 @@ +package com.baeldung.nulls; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.Optional; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +class UsingOptionalTest { + + private UsingOptional classUnderTest; + + @BeforeEach + public void setup() { + classUnderTest = new UsingOptional(); + } + + @Test + public void whenArgIsFalse_thenReturnEmptyResponse() { + Optional result = classUnderTest.process(false); + assertFalse(result.isPresent()); + } + + @Test + public void whenArgIsTrue_thenReturnValidResponse() { + Optional result = classUnderTest.process(true); + assertTrue(result.isPresent()); + } + + @Test + public void whenArgIsFalse_thenChainResponseAndThrowException() { + assertThrows(Exception.class, () -> classUnderTest.process(false).orElseThrow(() -> new Exception())); + } +} \ No newline at end of file diff --git a/core-java/src/test/java/com/baeldung/nulls/UsingStringUtilsTest.java b/core-java/src/test/java/com/baeldung/nulls/UsingStringUtilsTest.java new file mode 100644 index 0000000000..d10364b85e --- /dev/null +++ b/core-java/src/test/java/com/baeldung/nulls/UsingStringUtilsTest.java @@ -0,0 +1,43 @@ +package com.baeldung.nulls; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class UsingStringUtilsTest { + + private UsingStringUtils classUnderTest; + + @BeforeEach + public void setup() { + classUnderTest = new UsingStringUtils(); + } + + @Test + public void givenAccept_whenArgIsNull_throwIllegalArgumentException() { + Assertions.assertThrows(IllegalArgumentException.class, () -> classUnderTest.accept(null)); + } + + @Test + public void givenAccept_whenArgIsEmpty_throwIllegalArgumentException() { + Assertions.assertThrows(IllegalArgumentException.class, () -> classUnderTest.accept("")); + } + + @Test + public void givenAcceptOnlyNonBlank_whenArgIsNull_throwIllegalArgumentException() { + Assertions.assertThrows(IllegalArgumentException.class, () -> classUnderTest.acceptOnlyNonBlank(null)); + } + + @Test + public void givenAcceptOnlyNonBlank_whenArgIsEmpty_throwIllegalArgumentException() { + Assertions.assertThrows(IllegalArgumentException.class, () -> classUnderTest.acceptOnlyNonBlank("")); + } + + @Test + public void givenAcceptOnlyNonBlank_whenArgIsBlank_throwIllegalArgumentException() { + Assertions.assertThrows(IllegalArgumentException.class, () -> classUnderTest.acceptOnlyNonBlank(" ")); + } + +} \ No newline at end of file From 55f7da49485868a475e191f504bd1166d655f8b0 Mon Sep 17 00:00:00 2001 From: Chirag Dewan Date: Sat, 16 Mar 2019 11:51:03 +0530 Subject: [PATCH 012/531] BAEL2489 Avoid check for null statement in Java --- ...vesAndWrapperTest.java => PrimitivesAndWrapperUnitTest.java} | 2 +- .../nulls/{UsingLombokTest.java => UsingLombokUnitTest.java} | 2 +- .../nulls/{UsingObjectsTest.java => UsingObjectsUnitTest.java} | 2 +- .../{UsingOptionalTest.java => UsingOptionalUnitTest.java} | 2 +- ...{UsingStringUtilsTest.java => UsingStringUtilsUnitTest.java} | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) rename core-java/src/test/java/com/baeldung/nulls/{PrimitivesAndWrapperTest.java => PrimitivesAndWrapperUnitTest.java} (96%) rename core-java/src/test/java/com/baeldung/nulls/{UsingLombokTest.java => UsingLombokUnitTest.java} (94%) rename core-java/src/test/java/com/baeldung/nulls/{UsingObjectsTest.java => UsingObjectsUnitTest.java} (95%) rename core-java/src/test/java/com/baeldung/nulls/{UsingOptionalTest.java => UsingOptionalUnitTest.java} (97%) rename core-java/src/test/java/com/baeldung/nulls/{UsingStringUtilsTest.java => UsingStringUtilsUnitTest.java} (97%) diff --git a/core-java/src/test/java/com/baeldung/nulls/PrimitivesAndWrapperTest.java b/core-java/src/test/java/com/baeldung/nulls/PrimitivesAndWrapperUnitTest.java similarity index 96% rename from core-java/src/test/java/com/baeldung/nulls/PrimitivesAndWrapperTest.java rename to core-java/src/test/java/com/baeldung/nulls/PrimitivesAndWrapperUnitTest.java index 4e0f44e555..67fe173883 100644 --- a/core-java/src/test/java/com/baeldung/nulls/PrimitivesAndWrapperTest.java +++ b/core-java/src/test/java/com/baeldung/nulls/PrimitivesAndWrapperUnitTest.java @@ -5,7 +5,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import org.junit.jupiter.api.Test; -class PrimitivesAndWrapperTest { +class PrimitivesAndWrapperUnitTest { @Test public void givenWrappers_whenBothArgsNonNull_thenReturnResult() { diff --git a/core-java/src/test/java/com/baeldung/nulls/UsingLombokTest.java b/core-java/src/test/java/com/baeldung/nulls/UsingLombokUnitTest.java similarity index 94% rename from core-java/src/test/java/com/baeldung/nulls/UsingLombokTest.java rename to core-java/src/test/java/com/baeldung/nulls/UsingLombokUnitTest.java index 5a41d444a4..c157ad6630 100644 --- a/core-java/src/test/java/com/baeldung/nulls/UsingLombokTest.java +++ b/core-java/src/test/java/com/baeldung/nulls/UsingLombokUnitTest.java @@ -6,7 +6,7 @@ import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; -class UsingLombokTest { +class UsingLombokUnitTest { private UsingLombok classUnderTest; diff --git a/core-java/src/test/java/com/baeldung/nulls/UsingObjectsTest.java b/core-java/src/test/java/com/baeldung/nulls/UsingObjectsUnitTest.java similarity index 95% rename from core-java/src/test/java/com/baeldung/nulls/UsingObjectsTest.java rename to core-java/src/test/java/com/baeldung/nulls/UsingObjectsUnitTest.java index 74170d980b..6939caa4fb 100644 --- a/core-java/src/test/java/com/baeldung/nulls/UsingObjectsTest.java +++ b/core-java/src/test/java/com/baeldung/nulls/UsingObjectsUnitTest.java @@ -7,7 +7,7 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -class UsingObjectsTest { +class UsingObjectsUnitTest { private UsingObjects classUnderTest; diff --git a/core-java/src/test/java/com/baeldung/nulls/UsingOptionalTest.java b/core-java/src/test/java/com/baeldung/nulls/UsingOptionalUnitTest.java similarity index 97% rename from core-java/src/test/java/com/baeldung/nulls/UsingOptionalTest.java rename to core-java/src/test/java/com/baeldung/nulls/UsingOptionalUnitTest.java index 5c42b9dff1..45367204b7 100644 --- a/core-java/src/test/java/com/baeldung/nulls/UsingOptionalTest.java +++ b/core-java/src/test/java/com/baeldung/nulls/UsingOptionalUnitTest.java @@ -9,7 +9,7 @@ import java.util.Optional; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -class UsingOptionalTest { +class UsingOptionalUnitTest { private UsingOptional classUnderTest; diff --git a/core-java/src/test/java/com/baeldung/nulls/UsingStringUtilsTest.java b/core-java/src/test/java/com/baeldung/nulls/UsingStringUtilsUnitTest.java similarity index 97% rename from core-java/src/test/java/com/baeldung/nulls/UsingStringUtilsTest.java rename to core-java/src/test/java/com/baeldung/nulls/UsingStringUtilsUnitTest.java index d10364b85e..451775abe1 100644 --- a/core-java/src/test/java/com/baeldung/nulls/UsingStringUtilsTest.java +++ b/core-java/src/test/java/com/baeldung/nulls/UsingStringUtilsUnitTest.java @@ -6,7 +6,7 @@ import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; -class UsingStringUtilsTest { +class UsingStringUtilsUnitTest { private UsingStringUtils classUnderTest; From 66146ea761ecb3ef0fb01ea26807da0ca41dd3ac Mon Sep 17 00:00:00 2001 From: Chirag Dewan Date: Tue, 19 Mar 2019 20:40:26 +0530 Subject: [PATCH 013/531] BAEL2489 Avoid check for null statement in Java --- .../com/baeldung/nulls/EmptyCollections.java | 7 ++++--- .../baeldung/nulls/FindBugsAnnotations.java | 5 +++-- .../com/baeldung/nulls/Preconditions.java | 18 ++++++++++------- .../baeldung/nulls/PrimitivesAndWrapper.java | 5 +++-- .../java/com/baeldung/nulls/UsingObjects.java | 11 +++------- .../nulls/PrimitivesAndWrapperUnitTest.java | 8 ++++---- .../baeldung/nulls/UsingOptionalUnitTest.java | 5 +++++ .../nulls/UsingStringUtilsUnitTest.java | 20 +++++++++---------- 8 files changed, 43 insertions(+), 36 deletions(-) diff --git a/core-java/src/main/java/com/baeldung/nulls/EmptyCollections.java b/core-java/src/main/java/com/baeldung/nulls/EmptyCollections.java index 95e49e4e91..5958cf8dc6 100644 --- a/core-java/src/main/java/com/baeldung/nulls/EmptyCollections.java +++ b/core-java/src/main/java/com/baeldung/nulls/EmptyCollections.java @@ -7,11 +7,12 @@ import java.util.stream.Stream; public class EmptyCollections { - public List names(){ - if (userExist()) + public List names() { + if (userExist()) { return Stream.of(readName()).collect(Collectors.toList()); - else + } else { return Collections.emptyList(); + } } private boolean userExist() { diff --git a/core-java/src/main/java/com/baeldung/nulls/FindBugsAnnotations.java b/core-java/src/main/java/com/baeldung/nulls/FindBugsAnnotations.java index f879f033c9..a3804f6af5 100644 --- a/core-java/src/main/java/com/baeldung/nulls/FindBugsAnnotations.java +++ b/core-java/src/main/java/com/baeldung/nulls/FindBugsAnnotations.java @@ -16,10 +16,11 @@ public class FindBugsAnnotations { @Nonnull public Object process() throws Exception { Object result = doSomething(); - if (result == null) + if (result == null) { throw new Exception("Processing fail. Got a null response"); - else + } else { return result; + } } private Object doSomething() { diff --git a/core-java/src/main/java/com/baeldung/nulls/Preconditions.java b/core-java/src/main/java/com/baeldung/nulls/Preconditions.java index 447026f1e3..9d9633a13e 100644 --- a/core-java/src/main/java/com/baeldung/nulls/Preconditions.java +++ b/core-java/src/main/java/com/baeldung/nulls/Preconditions.java @@ -3,8 +3,9 @@ package com.baeldung.nulls; public class Preconditions { public void goodAccept(String one, String two, String three) { - if (one == null || two == null || three == null) + if (one == null || two == null || three == null) { throw new IllegalArgumentException(); + } process(one); process(two); @@ -12,20 +13,23 @@ public class Preconditions { } public void badAccept(String one, String two, String three) { - if (one == null) + if (one == null) { throw new IllegalArgumentException(); - else + } else { process(one); + } - if (two == null) + if (two == null) { throw new IllegalArgumentException(); - else + } else { process(two); + } - if (three == null) + if (three == null) { throw new IllegalArgumentException(); - else + } else { process(three); + } } diff --git a/core-java/src/main/java/com/baeldung/nulls/PrimitivesAndWrapper.java b/core-java/src/main/java/com/baeldung/nulls/PrimitivesAndWrapper.java index 8f662b3760..c75918c486 100644 --- a/core-java/src/main/java/com/baeldung/nulls/PrimitivesAndWrapper.java +++ b/core-java/src/main/java/com/baeldung/nulls/PrimitivesAndWrapper.java @@ -11,10 +11,11 @@ public class PrimitivesAndWrapper { } public static Integer goodSum(Integer a, Integer b) { - if (a != null && b != null) + if (a != null && b != null) { return a + b; - else + } else { throw new IllegalArgumentException(); + } } } diff --git a/core-java/src/main/java/com/baeldung/nulls/UsingObjects.java b/core-java/src/main/java/com/baeldung/nulls/UsingObjects.java index 7383ae84a7..5384edee5e 100644 --- a/core-java/src/main/java/com/baeldung/nulls/UsingObjects.java +++ b/core-java/src/main/java/com/baeldung/nulls/UsingObjects.java @@ -4,13 +4,8 @@ import java.util.Objects; public class UsingObjects { - public void accept(Object param) throws Exception { - try { - Objects.requireNonNull(param); - } catch (NullPointerException e) { - throw new Exception(); - } - - //doSomething() + public void accept(Object param) { + Objects.requireNonNull(param); + // doSomething() } } diff --git a/core-java/src/test/java/com/baeldung/nulls/PrimitivesAndWrapperUnitTest.java b/core-java/src/test/java/com/baeldung/nulls/PrimitivesAndWrapperUnitTest.java index 67fe173883..3c524387a4 100644 --- a/core-java/src/test/java/com/baeldung/nulls/PrimitivesAndWrapperUnitTest.java +++ b/core-java/src/test/java/com/baeldung/nulls/PrimitivesAndWrapperUnitTest.java @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test; class PrimitivesAndWrapperUnitTest { @Test - public void givenWrappers_whenBothArgsNonNull_thenReturnResult() { + public void givenBothArgsNonNull_whenCallingWrapperSum_thenReturnSum() { Integer sum = PrimitivesAndWrapper.wrapperSum(0, 0); @@ -16,17 +16,17 @@ class PrimitivesAndWrapperUnitTest { } @Test() - public void givenWrappers_whenOneArgIsNull_thenThrowNullPointerException() { + public void givenOneArgIsNull_whenCallingWrapperSum_thenThrowNullPointerException() { assertThrows(NullPointerException.class, () -> PrimitivesAndWrapper.wrapperSum(null, 2)); } @Test() - public void givenWrappers_whenBothArgsAreNull_thenThrowNullPointerException() { + public void givenBothArgsNull_whenCallingWrapperSum_thenThrowNullPointerException() { assertThrows(NullPointerException.class, () -> PrimitivesAndWrapper.wrapperSum(null, null)); } @Test() - public void givenWrappersWithNullCheck_whenAnyArgIsNull_thenThrowIllegalArgumentException() { + public void givenOneArgNull_whenCallingGoodSum_thenThrowIllegalArgumentException() { assertThrows(IllegalArgumentException.class, () -> PrimitivesAndWrapper.goodSum(null, 2)); } diff --git a/core-java/src/test/java/com/baeldung/nulls/UsingOptionalUnitTest.java b/core-java/src/test/java/com/baeldung/nulls/UsingOptionalUnitTest.java index 45367204b7..d9d245369b 100644 --- a/core-java/src/test/java/com/baeldung/nulls/UsingOptionalUnitTest.java +++ b/core-java/src/test/java/com/baeldung/nulls/UsingOptionalUnitTest.java @@ -20,18 +20,23 @@ class UsingOptionalUnitTest { @Test public void whenArgIsFalse_thenReturnEmptyResponse() { + Optional result = classUnderTest.process(false); + assertFalse(result.isPresent()); } @Test public void whenArgIsTrue_thenReturnValidResponse() { + Optional result = classUnderTest.process(true); + assertTrue(result.isPresent()); } @Test public void whenArgIsFalse_thenChainResponseAndThrowException() { + assertThrows(Exception.class, () -> classUnderTest.process(false).orElseThrow(() -> new Exception())); } } \ No newline at end of file diff --git a/core-java/src/test/java/com/baeldung/nulls/UsingStringUtilsUnitTest.java b/core-java/src/test/java/com/baeldung/nulls/UsingStringUtilsUnitTest.java index 451775abe1..99b1dbe6b4 100644 --- a/core-java/src/test/java/com/baeldung/nulls/UsingStringUtilsUnitTest.java +++ b/core-java/src/test/java/com/baeldung/nulls/UsingStringUtilsUnitTest.java @@ -16,28 +16,28 @@ class UsingStringUtilsUnitTest { } @Test - public void givenAccept_whenArgIsNull_throwIllegalArgumentException() { - Assertions.assertThrows(IllegalArgumentException.class, () -> classUnderTest.accept(null)); + public void givenArgIsNull_whenCallingAccept_throwIllegalArgumentException() { + assertThrows(IllegalArgumentException.class, () -> classUnderTest.accept(null)); } @Test - public void givenAccept_whenArgIsEmpty_throwIllegalArgumentException() { - Assertions.assertThrows(IllegalArgumentException.class, () -> classUnderTest.accept("")); + public void givenArgIsEmpty_whenCallingAccept_throwIllegalArgumentException() { + assertThrows(IllegalArgumentException.class, () -> classUnderTest.accept("")); } @Test - public void givenAcceptOnlyNonBlank_whenArgIsNull_throwIllegalArgumentException() { - Assertions.assertThrows(IllegalArgumentException.class, () -> classUnderTest.acceptOnlyNonBlank(null)); + public void givenArgIsNull_whenCallingAcceptOnlyNonBlank_throwIllegalArgumentException() { + assertThrows(IllegalArgumentException.class, () -> classUnderTest.acceptOnlyNonBlank(null)); } @Test - public void givenAcceptOnlyNonBlank_whenArgIsEmpty_throwIllegalArgumentException() { - Assertions.assertThrows(IllegalArgumentException.class, () -> classUnderTest.acceptOnlyNonBlank("")); + public void givenArgIsEmpty_whenCallingAcceptOnlyNonBlank_throwIllegalArgumentException() { + assertThrows(IllegalArgumentException.class, () -> classUnderTest.acceptOnlyNonBlank("")); } @Test - public void givenAcceptOnlyNonBlank_whenArgIsBlank_throwIllegalArgumentException() { - Assertions.assertThrows(IllegalArgumentException.class, () -> classUnderTest.acceptOnlyNonBlank(" ")); + public void givenArgIsBlank_whenCallingAcceptOnlyNonBlank_throwIllegalArgumentException() { + assertThrows(IllegalArgumentException.class, () -> classUnderTest.acceptOnlyNonBlank(" ")); } } \ No newline at end of file From 51be79991023cbc8d1a7ca2ed400eb2659fbf2ca Mon Sep 17 00:00:00 2001 From: Anurag Date: Fri, 22 Mar 2019 17:13:00 +0530 Subject: [PATCH 014/531] [BAEL-1951] Guide to FileChannel --- .../filechannel/FileChannelUnitTest.java | 181 ++++++++++++++++++ .../src/test/resources/test_truncate.txt | 1 + .../test_write_using_filechannel.txt | 1 + 3 files changed, 183 insertions(+) create mode 100644 core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java create mode 100644 core-java-io/src/test/resources/test_truncate.txt create mode 100644 core-java-io/src/test/resources/test_write_using_filechannel.txt diff --git a/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java b/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java new file mode 100644 index 0000000000..497ce33f0d --- /dev/null +++ b/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java @@ -0,0 +1,181 @@ +package com.baeldung.filechannel; + +import static org.junit.Assert.assertEquals; + +import java.io.ByteArrayOutputStream; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.nio.ByteBuffer; +import java.nio.channels.FileChannel; + +import org.junit.Test; + +public class FileChannelUnitTest { + @Test + public void givenFile_whenReadWithFileChannelUsingRandomAccessFile_thenCorrect() throws IOException { + String expected_value = "Hello world"; + String file = "src/test/resources/test_read.in"; + RandomAccessFile reader = new RandomAccessFile(file, "r"); + FileChannel channel = reader.getChannel(); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + + int bufferSize = 1024; + if (bufferSize > channel.size()) { + bufferSize = (int) channel.size(); + } + ByteBuffer buff = ByteBuffer.allocate(bufferSize); + int noOfBytesRead = channel.read(buff); + + while (noOfBytesRead != -1) { + if (buff.hasArray()) { + out.write(buff.array(), 0, buff.position()); + buff.clear(); + noOfBytesRead = channel.read(buff); + } + } + + assertEquals(expected_value, out.toString()); + out.close(); + channel.close(); + reader.close(); + } + + @Test + public void givenFile_whenReadWithFileChannelUsingFileInputStream_thenCorrect() throws IOException { + String expected_value = "Hello world"; + String file = "src/test/resources/test_read.in"; + ByteArrayOutputStream out = new ByteArrayOutputStream(); + FileInputStream fin = new FileInputStream(file); + FileChannel channel = fin.getChannel(); + + int bufferSize = 1024; + if (bufferSize > channel.size()) { + bufferSize = (int) channel.size(); + } + ByteBuffer buff = ByteBuffer.allocate(bufferSize); + int noOfBytesRead = channel.read(buff); + + while (noOfBytesRead != -1) { + if (buff.hasArray()) { + out.write(buff.array(), 0, buff.position()); + buff.clear(); + noOfBytesRead = channel.read(buff); + } + } + + assertEquals(expected_value, out.toString()); + channel.close(); + fin.close(); + } + + @Test + public void whenWriteWithFileChannelUsingRandomAccessFile_thenCorrect() throws IOException { + String input = "Hello world"; + String file = "src/test/resources/test_write_using_filechannel.txt"; + + RandomAccessFile writer = new RandomAccessFile(file, "rw"); + FileChannel channel = writer.getChannel(); + + ByteBuffer buff = ByteBuffer.wrap(input.getBytes()); + while (buff.hasRemaining()) { + channel.write(buff); + } + channel.close(); + writer.close(); + + // verify + RandomAccessFile reader = new RandomAccessFile(file, "r"); + assertEquals(input, reader.readLine()); + reader.close(); + } + + @Test + public void whenWriteWithFileChannelUsingFileOutputStream_thenCorrect() throws IOException { + String input = "Hello world"; + String file = "src/test/resources/test_write_using_filechannel.txt"; + + FileOutputStream fout = new FileOutputStream(file); + FileChannel channel = fout.getChannel(); + + ByteBuffer buff = ByteBuffer.wrap(input.getBytes()); + while (buff.hasRemaining()) { + channel.write(buff); + } + + channel.close(); + fout.close(); + + // verify + RandomAccessFile reader = new RandomAccessFile(file, "r"); + assertEquals(input, reader.readLine()); + reader.close(); + } + + @Test + public void givenFile_whenReadWithFileChannelGetPosition_thenCorrect() throws IOException { + long expected_value = 11; + String file = "src/test/resources/test_read.in"; + ByteArrayOutputStream out = new ByteArrayOutputStream(); + RandomAccessFile reader = new RandomAccessFile(file, "r"); + FileChannel channel = reader.getChannel(); + + int bufferSize = 1024; + if (bufferSize > channel.size()) { + bufferSize = (int) channel.size(); + } + ByteBuffer buff = ByteBuffer.allocate(bufferSize); + int noOfBytesRead = channel.read(buff); + + while (noOfBytesRead != -1) { + if (buff.hasArray()) { + out.write(buff.array(), 0, buff.position()); + buff.clear(); + noOfBytesRead = channel.read(buff); + } + } + + assertEquals(expected_value, channel.position()); + + channel.position(4); + assertEquals(4, channel.position()); + + channel.close(); + reader.close(); + } + + @Test + public void whenGetFileSize_thenCorrect() throws IOException { + long expectedSize = 11; + String file = "src/test/resources/test_read.in"; + RandomAccessFile reader = new RandomAccessFile(file, "r"); + FileChannel channel = reader.getChannel(); + + long imageFileSize = channel.size(); + assertEquals(expectedSize, imageFileSize); + + channel.close(); + reader.close(); + } + + @Test + public void whenTruncateFile_thenCorrect() throws IOException { + long expectedSize = 5; + String input = "this is a test input"; + String file = "src/test/resources/test_truncate.txt"; + + FileOutputStream fout = new FileOutputStream(file); + FileChannel channel = fout.getChannel(); + + ByteBuffer buff = ByteBuffer.wrap(input.getBytes()); + channel.write(buff); + buff.flip(); + + channel = channel.truncate(5); + assertEquals(expectedSize, channel.size()); + + fout.close(); + channel.close(); + } +} diff --git a/core-java-io/src/test/resources/test_truncate.txt b/core-java-io/src/test/resources/test_truncate.txt new file mode 100644 index 0000000000..26d3b38cdd --- /dev/null +++ b/core-java-io/src/test/resources/test_truncate.txt @@ -0,0 +1 @@ +this \ No newline at end of file diff --git a/core-java-io/src/test/resources/test_write_using_filechannel.txt b/core-java-io/src/test/resources/test_write_using_filechannel.txt new file mode 100644 index 0000000000..70c379b63f --- /dev/null +++ b/core-java-io/src/test/resources/test_write_using_filechannel.txt @@ -0,0 +1 @@ +Hello world \ No newline at end of file From 0a542104143cbaccb2990e3c684bb45f0b729fc5 Mon Sep 17 00:00:00 2001 From: Anurag Date: Fri, 22 Mar 2019 17:48:47 +0530 Subject: [PATCH 015/531] minor fix --- .../test/java/com/baeldung/filechannel/FileChannelUnitTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java b/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java index 497ce33f0d..312ec7a459 100644 --- a/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java +++ b/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java @@ -66,6 +66,7 @@ public class FileChannelUnitTest { } assertEquals(expected_value, out.toString()); + out.close(); channel.close(); fin.close(); } @@ -141,6 +142,7 @@ public class FileChannelUnitTest { channel.position(4); assertEquals(4, channel.position()); + out.close(); channel.close(); reader.close(); } From 2d3ac05704911c462ea62faca302731dd949e274 Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Sat, 23 Mar 2019 17:03:37 +0400 Subject: [PATCH 016/531] convert java8 to milliseconds --- .../com/baeldung/convert/ConvertDateTime.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 java-dates/src/main/java/com/baeldung/convert/ConvertDateTime.java diff --git a/java-dates/src/main/java/com/baeldung/convert/ConvertDateTime.java b/java-dates/src/main/java/com/baeldung/convert/ConvertDateTime.java new file mode 100644 index 0000000000..548912ea07 --- /dev/null +++ b/java-dates/src/main/java/com/baeldung/convert/ConvertDateTime.java @@ -0,0 +1,33 @@ +package com.baeldung.convert; + +import org.joda.time.DateTime; +import org.joda.time.format.DateTimeFormat; +import org.joda.time.format.DateTimeFormatter; + +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; + +public class ConvertDateTime { + + public static void main(String[] args) { + + java8(); + joda(); + } + + private static void joda() { + String s = "00:00:01.2"; + DateTimeFormatter format = DateTimeFormat.forPattern("HH:mm:ss.S"); + DateTime dateTime = format.parseDateTime(s); + System.out.println(dateTime.getMillisOfSecond()); + } + + private static void java8() { + LocalDateTime localDateTime = LocalDateTime.now(); + + ZoneId id = ZoneId.systemDefault(); + ZonedDateTime zdt = ZonedDateTime.of(localDateTime, id); + System.out.println(zdt.toInstant().toEpochMilli()); + } +} From 19ec10a6306c56846f2ad18c957c57d1b9f78007 Mon Sep 17 00:00:00 2001 From: mprevisic Date: Sat, 23 Mar 2019 19:04:55 +0100 Subject: [PATCH 017/531] BAEL-1970 spring logging level while testing --- .../java/com/baeldung/testlog/TestLog.java | 22 ++++++ .../testloglevel/TestLogLevelApplication.java | 15 ++++ .../testloglevel/TestLogLevelController.java | 29 ++++++++ ...ltiProfileTestLogLevelIntegrationTest.java | 70 +++++++++++++++++++ .../LogbackTestLogLevelIntegrationTest.java | 70 +++++++++++++++++++ ...estLogLevelWithProfileIntegrationTest.java | 68 ++++++++++++++++++ .../application-logback-test2.properties | 1 + ...pplication-logback-testloglevel.properties | 1 + .../application-testloglevel.properties | 2 + .../test/resources/logback-multiprofile.xml | 18 +++++ .../test/resources/logback-testloglevel.xml | 13 ++++ 11 files changed, 309 insertions(+) create mode 100644 spring-boot-testing/src/main/java/com/baeldung/testlog/TestLog.java create mode 100644 spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelApplication.java create mode 100644 spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelController.java create mode 100644 spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackMultiProfileTestLogLevelIntegrationTest.java create mode 100644 spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackTestLogLevelIntegrationTest.java create mode 100644 spring-boot-testing/src/test/java/com/baeldung/testloglevel/TestLogLevelWithProfileIntegrationTest.java create mode 100644 spring-boot-testing/src/test/resources/application-logback-test2.properties create mode 100644 spring-boot-testing/src/test/resources/application-logback-testloglevel.properties create mode 100644 spring-boot-testing/src/test/resources/application-testloglevel.properties create mode 100644 spring-boot-testing/src/test/resources/logback-multiprofile.xml create mode 100644 spring-boot-testing/src/test/resources/logback-testloglevel.xml diff --git a/spring-boot-testing/src/main/java/com/baeldung/testlog/TestLog.java b/spring-boot-testing/src/main/java/com/baeldung/testlog/TestLog.java new file mode 100644 index 0000000000..bc5d5700e5 --- /dev/null +++ b/spring-boot-testing/src/main/java/com/baeldung/testlog/TestLog.java @@ -0,0 +1,22 @@ +package com.baeldung.testlog; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class TestLog { + + Logger LOG = LoggerFactory.getLogger(this.getClass()); + + public void info(String msg) { + LOG.info(msg); + } + + public void error(String msg) { + LOG.error(msg); + } + + public void trace(String msg) { + LOG.trace(msg); + } + +} diff --git a/spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelApplication.java b/spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelApplication.java new file mode 100644 index 0000000000..315bd735b9 --- /dev/null +++ b/spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelApplication.java @@ -0,0 +1,15 @@ +package com.baeldung.testloglevel; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +import com.baeldung.boot.Application; + +@SpringBootApplication +public class TestLogLevelApplication { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + +} diff --git a/spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelController.java b/spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelController.java new file mode 100644 index 0000000000..7349c20b65 --- /dev/null +++ b/spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelController.java @@ -0,0 +1,29 @@ +package com.baeldung.testloglevel; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.baeldung.testlog.TestLog; + +@RestController +public class TestLogLevelController { + + Logger LOG = LoggerFactory.getLogger(this.getClass()); + + @GetMapping("/testLogLevel") + public String testLogLevel() { + LOG.trace("This is a TRACE log"); + LOG.debug("This is a DEBUG log"); + LOG.info("This is an INFO log"); + LOG.error("This is an ERROR log"); + + new TestLog().trace("This is a TRACE log in another package"); + new TestLog().info("This is an INFO log in another package"); + new TestLog().error("This is an ERROR log in another package"); + + return "Added some log output to console..."; + } + +} \ No newline at end of file diff --git a/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackMultiProfileTestLogLevelIntegrationTest.java b/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackMultiProfileTestLogLevelIntegrationTest.java new file mode 100644 index 0000000000..5192a1f00e --- /dev/null +++ b/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackMultiProfileTestLogLevelIntegrationTest.java @@ -0,0 +1,70 @@ +package com.baeldung.testloglevel; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.test.rule.OutputCapture; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = TestLogLevelApplication.class) +@EnableAutoConfiguration(exclude = SecurityAutoConfiguration.class) +@ActiveProfiles("logback-test2") +public class LogbackMultiProfileTestLogLevelIntegrationTest { + + @Autowired + private TestRestTemplate restTemplate; + + @Rule + public OutputCapture outputCapture = new OutputCapture(); + + private String baseUrl = "/testLogLevel"; + + @Test + public void givenErrorRootLevelAndTraceLevelForOurPackage_whenCall_thenPrintTraceLogsForOurPackage() { + ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); + + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThatOutputContainsLogForOurPackage("TRACE"); + } + + @Test + public void givenErrorRootLevelAndTraceLevelForOurPackage_whenCall_thenNoTraceLogsForOtherPackages() { + ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); + + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThatOutputDoesntContainLogForOtherPackages("TRACE"); + } + + @Test + public void givenErrorRootLevelAndTraceLevelForOurPackage_whenCall_thenPrintErrorLogs() { + ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); + + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThatOutputContainsLogForOurPackage("ERROR"); + assertThatOutputContainsLogForOtherPackages("ERROR"); + } + + private void assertThatOutputContainsLogForOurPackage(String level) { + assertThat(outputCapture.toString()).containsPattern("TestLogLevelController.*" + level + ".*"); + } + + private void assertThatOutputDoesntContainLogForOtherPackages(String level) { + assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).doesNotContain(level); + } + + private void assertThatOutputContainsLogForOtherPackages(String level) { + assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).contains(level); + } + +} diff --git a/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackTestLogLevelIntegrationTest.java b/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackTestLogLevelIntegrationTest.java new file mode 100644 index 0000000000..c0571265a9 --- /dev/null +++ b/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackTestLogLevelIntegrationTest.java @@ -0,0 +1,70 @@ +package com.baeldung.testloglevel; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.test.rule.OutputCapture; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, classes = TestLogLevelApplication.class) +@EnableAutoConfiguration(exclude = SecurityAutoConfiguration.class) +@ActiveProfiles("logback-testloglevel") +public class LogbackTestLogLevelIntegrationTest { + + @Autowired + private TestRestTemplate restTemplate; + + @Rule + public OutputCapture outputCapture = new OutputCapture(); + + private String baseUrl = "/testLogLevel"; + + @Test + public void givenErrorRootLevelAndDebugLevelForOurPackage_whenCall_thenPrintDebugLogsForOurPackage() { + ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); + + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThatOutputContainsLogForOurPackage("DEBUG"); + } + + @Test + public void givenErrorRootLevelAndDebugLevelForOurPackage_whenCall_thenNoDebugLogsForOtherPackages() { + ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); + + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThatOutputDoesntContainLogForOtherPackages("DEBUG"); + } + + @Test + public void givenErrorRootLevelAndDebugLevelForOurPackage_whenCall_thenPrintErrorLogs() { + ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); + + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThatOutputContainsLogForOurPackage("ERROR"); + assertThatOutputContainsLogForOtherPackages("ERROR"); + } + + private void assertThatOutputContainsLogForOurPackage(String level) { + assertThat(outputCapture.toString()).containsPattern("TestLogLevelController.*" + level + ".*"); + } + + private void assertThatOutputDoesntContainLogForOtherPackages(String level) { + assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).doesNotContain(level); + } + + private void assertThatOutputContainsLogForOtherPackages(String level) { + assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).contains(level); + } + +} diff --git a/spring-boot-testing/src/test/java/com/baeldung/testloglevel/TestLogLevelWithProfileIntegrationTest.java b/spring-boot-testing/src/test/java/com/baeldung/testloglevel/TestLogLevelWithProfileIntegrationTest.java new file mode 100644 index 0000000000..976e7d5f76 --- /dev/null +++ b/spring-boot-testing/src/test/java/com/baeldung/testloglevel/TestLogLevelWithProfileIntegrationTest.java @@ -0,0 +1,68 @@ +package com.baeldung.testloglevel; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.test.rule.OutputCapture; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + +import static org.assertj.core.api.Assertions.assertThat; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, classes = TestLogLevelApplication.class) +@EnableAutoConfiguration(exclude = SecurityAutoConfiguration.class) +@ActiveProfiles("testloglevel") +public class TestLogLevelWithProfileIntegrationTest { + + @Autowired + private TestRestTemplate restTemplate; + + @Rule + public OutputCapture outputCapture = new OutputCapture(); + + @Test + public void givenInfoRootLevelAndDebugLevelForOurPackage_whenCall_thenPrintDebugLogsForOurPackage() { + ResponseEntity response = restTemplate.getForEntity("http://localhost:8080/testLogLevel", String.class); + + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThatOutputContainsLogForOurPackage("DEBUG"); + } + + @Test + public void givenInfoRootLevelAndDebugLevelForOurPackage_whenCall_thenNoDebugLogsForOtherPackages() { + ResponseEntity response = restTemplate.getForEntity("http://localhost:8080/testLogLevel", String.class); + + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThatOutputDoesntContainLogForOtherPackages("DEBUG"); + } + + @Test + public void givenInfoRootLevelAndDebugLevelForOurPackage_whenCall_thenPrintInfoLogs() { + ResponseEntity response = restTemplate.getForEntity("http://localhost:8080/testLogLevel", String.class); + + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThatOutputContainsLogForOurPackage("INFO"); + assertThatOutputContainsLogForOtherPackages("INFO"); + } + + private void assertThatOutputContainsLogForOurPackage(String level) { + assertThat(outputCapture.toString()).containsPattern("TestLogLevelController.*" + level + ".*"); + } + + private void assertThatOutputDoesntContainLogForOtherPackages(String level) { + assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).doesNotContain(level); + } + + private void assertThatOutputContainsLogForOtherPackages(String level) { + assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).contains(level); + } + +} diff --git a/spring-boot-testing/src/test/resources/application-logback-test2.properties b/spring-boot-testing/src/test/resources/application-logback-test2.properties new file mode 100644 index 0000000000..aeed46e3ca --- /dev/null +++ b/spring-boot-testing/src/test/resources/application-logback-test2.properties @@ -0,0 +1 @@ +logging.config=classpath:logback-multiprofile.xml \ No newline at end of file diff --git a/spring-boot-testing/src/test/resources/application-logback-testloglevel.properties b/spring-boot-testing/src/test/resources/application-logback-testloglevel.properties new file mode 100644 index 0000000000..81d9b2e7c6 --- /dev/null +++ b/spring-boot-testing/src/test/resources/application-logback-testloglevel.properties @@ -0,0 +1 @@ +logging.config=classpath:logback-testloglevel.xml \ No newline at end of file diff --git a/spring-boot-testing/src/test/resources/application-testloglevel.properties b/spring-boot-testing/src/test/resources/application-testloglevel.properties new file mode 100644 index 0000000000..b5adb4cc11 --- /dev/null +++ b/spring-boot-testing/src/test/resources/application-testloglevel.properties @@ -0,0 +1,2 @@ +logging.level.com.baeldung.testloglevel=DEBUG +logging.level.root=INFO \ No newline at end of file diff --git a/spring-boot-testing/src/test/resources/logback-multiprofile.xml b/spring-boot-testing/src/test/resources/logback-multiprofile.xml new file mode 100644 index 0000000000..3711f1ec71 --- /dev/null +++ b/spring-boot-testing/src/test/resources/logback-multiprofile.xml @@ -0,0 +1,18 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-boot-testing/src/test/resources/logback-testloglevel.xml b/spring-boot-testing/src/test/resources/logback-testloglevel.xml new file mode 100644 index 0000000000..b02462a155 --- /dev/null +++ b/spring-boot-testing/src/test/resources/logback-testloglevel.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file From 6c6e9ed53dc3a68523da6f53393065a943f9fe2c Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Sun, 24 Mar 2019 11:08:54 +0400 Subject: [PATCH 018/531] convert with simple date formatting --- .../com/baeldung/convert/ConvertDateTime.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/java-dates/src/main/java/com/baeldung/convert/ConvertDateTime.java b/java-dates/src/main/java/com/baeldung/convert/ConvertDateTime.java index 548912ea07..c4d771a7e6 100644 --- a/java-dates/src/main/java/com/baeldung/convert/ConvertDateTime.java +++ b/java-dates/src/main/java/com/baeldung/convert/ConvertDateTime.java @@ -4,16 +4,39 @@ import org.joda.time.DateTime; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.ZonedDateTime; +import java.util.Calendar; +import java.util.Date; public class ConvertDateTime { - public static void main(String[] args) { + public static void main(String[] args) throws ParseException { java8(); joda(); + Date date = simpleDateTimeFormatter(); + calendar(date); + } + + private static void calendar(Date date) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + System.out.println("Calender - Time in milliseconds : " + calendar.getTimeInMillis()); + } + + private static Date simpleDateTimeFormatter() throws ParseException { + SimpleDateFormat sdf = new SimpleDateFormat("dd-M-yyyy hh:mm:ss"); + String dateInString = "22-01-2015 10:20:56"; + Date date = sdf.parse(dateInString); + + System.out.println(dateInString); + System.out.println("Date - Time in milliseconds : " + date.getTime()); + + return date; } private static void joda() { From 92b67b36a68ff098532cfaa2546791cfb91b3aed Mon Sep 17 00:00:00 2001 From: Anurag Date: Sun, 24 Mar 2019 16:12:45 +0530 Subject: [PATCH 019/531] changes in read code. --- .../baeldung/filechannel/FileChannelUnitTest.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java b/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java index 312ec7a459..c3d7e5610c 100644 --- a/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java +++ b/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java @@ -9,6 +9,7 @@ import java.io.IOException; import java.io.RandomAccessFile; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; +import java.nio.charset.StandardCharsets; import org.junit.Test; @@ -26,17 +27,15 @@ public class FileChannelUnitTest { bufferSize = (int) channel.size(); } ByteBuffer buff = ByteBuffer.allocate(bufferSize); - int noOfBytesRead = channel.read(buff); - while (noOfBytesRead != -1) { + while (channel.read(buff) > 0) { if (buff.hasArray()) { out.write(buff.array(), 0, buff.position()); buff.clear(); - noOfBytesRead = channel.read(buff); } } - assertEquals(expected_value, out.toString()); + assertEquals(expected_value, new String(out.toByteArray(), StandardCharsets.UTF_8)); out.close(); channel.close(); reader.close(); @@ -55,13 +54,11 @@ public class FileChannelUnitTest { bufferSize = (int) channel.size(); } ByteBuffer buff = ByteBuffer.allocate(bufferSize); - int noOfBytesRead = channel.read(buff); - while (noOfBytesRead != -1) { + while (channel.read(buff) > 0) { if (buff.hasArray()) { out.write(buff.array(), 0, buff.position()); buff.clear(); - noOfBytesRead = channel.read(buff); } } @@ -127,13 +124,11 @@ public class FileChannelUnitTest { bufferSize = (int) channel.size(); } ByteBuffer buff = ByteBuffer.allocate(bufferSize); - int noOfBytesRead = channel.read(buff); - while (noOfBytesRead != -1) { + while (channel.read(buff) > 0) { if (buff.hasArray()) { out.write(buff.array(), 0, buff.position()); buff.clear(); - noOfBytesRead = channel.read(buff); } } From 8054742acba0410da7d599ddace1c18121aa1fad Mon Sep 17 00:00:00 2001 From: Anurag Date: Sun, 24 Mar 2019 16:20:10 +0530 Subject: [PATCH 020/531] minor fix. --- .../test/java/com/baeldung/filechannel/FileChannelUnitTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java b/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java index c3d7e5610c..35ba9aca65 100644 --- a/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java +++ b/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java @@ -62,7 +62,7 @@ public class FileChannelUnitTest { } } - assertEquals(expected_value, out.toString()); + assertEquals(expected_value, new String(out.toByteArray(), StandardCharsets.UTF_8)); out.close(); channel.close(); fin.close(); From 7d87f2963c2fbc727d488f0b4c0b66bf12f4199d Mon Sep 17 00:00:00 2001 From: macroscopic64 Date: Mon, 25 Mar 2019 23:04:50 +0530 Subject: [PATCH 021/531] [BAEL-2073] Java 9 Migration Issues and Resolution --- prejpms/pom.xml | 73 +++++++++++++++++ .../main/java/com/baeldung/prejpms/App.java | 79 +++++++++++++++++++ .../main/java/com/baeldung/prejpms/Book.java | 39 +++++++++ prejpms/src/main/resources/logback.xml | 10 +++ 4 files changed, 201 insertions(+) create mode 100644 prejpms/pom.xml create mode 100644 prejpms/src/main/java/com/baeldung/prejpms/App.java create mode 100644 prejpms/src/main/java/com/baeldung/prejpms/Book.java create mode 100644 prejpms/src/main/resources/logback.xml diff --git a/prejpms/pom.xml b/prejpms/pom.xml new file mode 100644 index 0000000000..0f0216682e --- /dev/null +++ b/prejpms/pom.xml @@ -0,0 +1,73 @@ + + 4.0.0 + prejpms + 0.0.1-SNAPSHOT + jar + pre-jpms + + + parent-modules + com.baeldung + 1.0.0-SNAPSHOT + + + + + org.slf4j + slf4j-api + 1.7.25 + + + + pre-jpms + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.0 + + 1.8 + 1.8 + + + + org.apache.maven.plugins + maven-dependency-plugin + 3.1.1 + + + copy-dependencies + package + + copy-dependencies + + + + ${project.build.directory}/dependency-jars/ + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + com.baeldung.prejpms.App + true + dependency-jars/ + + + + + + + + + UTF-8 + + diff --git a/prejpms/src/main/java/com/baeldung/prejpms/App.java b/prejpms/src/main/java/com/baeldung/prejpms/App.java new file mode 100644 index 0000000000..0b38201302 --- /dev/null +++ b/prejpms/src/main/java/com/baeldung/prejpms/App.java @@ -0,0 +1,79 @@ +package com.baeldung.prejpms; + +import java.io.StringWriter; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.sun.crypto.provider.SunJCE; + +import sun.misc.BASE64Encoder; +import sun.reflect.Reflection; + +public class App { + + private static final Logger logger = LoggerFactory.getLogger(App.class); + + public static void main(String[] args) throws Exception { + + getCrytpographyProviderName(); + getCallStackClassNames(); + getXmlFromObject(new Book(100, "Java Modules Architecture")); + getBase64EncodedString("Java"); + } + + private static void getCrytpographyProviderName() { + try { + logger.info("1. Java Cryptography Extension - Provider Name: " + new SunJCE().getName() + "\n"); + } catch (Throwable e) { + logger.error(e.toString()); + } + } + + private static void getCallStackClassNames() { + try { + int i = 0; + StringBuffer sbStack = new StringBuffer(); + while (true) { + Class caller = Reflection.getCallerClass(i++); + if (caller == null) { + break; + } else { + sbStack.append(caller.getName()) + .append("\n"); + } + } + logger.info("2. Call Stack Class Names:\n" + sbStack.toString()); + } catch (Throwable e) { + logger.error(e.toString()); + } + } + + private static void getXmlFromObject(Book book) { + try { + Marshaller marshallerObj = JAXBContext.newInstance(Book.class) + .createMarshaller(); + marshallerObj.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); + + StringWriter sw = new StringWriter(); + marshallerObj.marshal(book, sw); + logger.info("3. Xml for Book object:\n" + sw); + } catch (Throwable e) { + logger.error(e.toString()); + } + + } + + private static void getBase64EncodedString(String inputString) { + try { + String encodedString = new BASE64Encoder().encode(inputString.getBytes()); + logger.info("4. Base Encoded String: " + encodedString); + } catch (Throwable e) { + logger.error(e.toString()); + } + } +} diff --git a/prejpms/src/main/java/com/baeldung/prejpms/Book.java b/prejpms/src/main/java/com/baeldung/prejpms/Book.java new file mode 100644 index 0000000000..57b19bf3c1 --- /dev/null +++ b/prejpms/src/main/java/com/baeldung/prejpms/Book.java @@ -0,0 +1,39 @@ +package com.baeldung.prejpms; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "book") +public class Book { + private long id; + private String name; + + public Book() { + + } + + public Book(long id, String name) { + this.id = id; + this.name = name; + } + + @XmlAttribute + public void setId(Long id) { + this.id = id; + } + + @XmlElement(name = "title") + public void setName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public Long getId() { + return id; + } + +} diff --git a/prejpms/src/main/resources/logback.xml b/prejpms/src/main/resources/logback.xml new file mode 100644 index 0000000000..7c5914e58e --- /dev/null +++ b/prejpms/src/main/resources/logback.xml @@ -0,0 +1,10 @@ + + + + [%level] %msg%n + + + + + + \ No newline at end of file From c7c5d56eb392038c8f577537c44eeedcdf1ae7c5 Mon Sep 17 00:00:00 2001 From: Chirag Dewan Date: Tue, 26 Mar 2019 21:47:51 +0530 Subject: [PATCH 022/531] BAEL2489 Avoid check for null statement in Java --- patterns/design-patterns-2/pom.xml | 18 ++++++++++++++++++ .../java/com/baeldung/nulls/APIContracts.java | 0 .../java/com/baeldung/nulls/Assertions.java | 0 .../com/baeldung/nulls/EmptyCollections.java | 0 .../baeldung/nulls/FindBugsAnnotations.java | 9 +++++---- .../java/com/baeldung/nulls/Preconditions.java | 0 .../baeldung/nulls/PrimitivesAndWrapper.java | 0 .../java/com/baeldung/nulls/UsingLombok.java | 0 .../java/com/baeldung/nulls/UsingObjects.java | 0 .../java/com/baeldung/nulls/UsingOptional.java | 0 .../com/baeldung/nulls/UsingStringUtils.java | 0 .../nulls/PrimitivesAndWrapperUnitTest.java | 4 ++-- .../baeldung/nulls/UsingLombokUnitTest.java | 3 +-- .../baeldung/nulls/UsingObjectsUnitTest.java | 9 ++++----- .../baeldung/nulls/UsingOptionalUnitTest.java | 10 +++++----- .../nulls/UsingStringUtilsUnitTest.java | 3 +-- 16 files changed, 36 insertions(+), 20 deletions(-) rename {core-java => patterns/design-patterns-2}/src/main/java/com/baeldung/nulls/APIContracts.java (100%) rename {core-java => patterns/design-patterns-2}/src/main/java/com/baeldung/nulls/Assertions.java (100%) rename {core-java => patterns/design-patterns-2}/src/main/java/com/baeldung/nulls/EmptyCollections.java (100%) rename {core-java => patterns/design-patterns-2}/src/main/java/com/baeldung/nulls/FindBugsAnnotations.java (78%) rename {core-java => patterns/design-patterns-2}/src/main/java/com/baeldung/nulls/Preconditions.java (100%) rename {core-java => patterns/design-patterns-2}/src/main/java/com/baeldung/nulls/PrimitivesAndWrapper.java (100%) rename {core-java => patterns/design-patterns-2}/src/main/java/com/baeldung/nulls/UsingLombok.java (100%) rename {core-java => patterns/design-patterns-2}/src/main/java/com/baeldung/nulls/UsingObjects.java (100%) rename {core-java => patterns/design-patterns-2}/src/main/java/com/baeldung/nulls/UsingOptional.java (100%) rename {core-java => patterns/design-patterns-2}/src/main/java/com/baeldung/nulls/UsingStringUtils.java (100%) rename {core-java => patterns/design-patterns-2}/src/test/java/com/baeldung/nulls/PrimitivesAndWrapperUnitTest.java (99%) rename {core-java => patterns/design-patterns-2}/src/test/java/com/baeldung/nulls/UsingLombokUnitTest.java (82%) rename {core-java => patterns/design-patterns-2}/src/test/java/com/baeldung/nulls/UsingObjectsUnitTest.java (84%) rename {core-java => patterns/design-patterns-2}/src/test/java/com/baeldung/nulls/UsingOptionalUnitTest.java (99%) rename {core-java => patterns/design-patterns-2}/src/test/java/com/baeldung/nulls/UsingStringUtilsUnitTest.java (93%) diff --git a/patterns/design-patterns-2/pom.xml b/patterns/design-patterns-2/pom.xml index 2a0213065b..5c3e70b046 100644 --- a/patterns/design-patterns-2/pom.xml +++ b/patterns/design-patterns-2/pom.xml @@ -15,11 +15,29 @@ + + org.jetbrains + annotations + ${intellij.annotations.version} + + + org.projectlombok + lombok + ${lombok.version} + provided + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + UTF-8 1.8 1.8 + 16.0.2 + 3.5 diff --git a/core-java/src/main/java/com/baeldung/nulls/APIContracts.java b/patterns/design-patterns-2/src/main/java/com/baeldung/nulls/APIContracts.java similarity index 100% rename from core-java/src/main/java/com/baeldung/nulls/APIContracts.java rename to patterns/design-patterns-2/src/main/java/com/baeldung/nulls/APIContracts.java diff --git a/core-java/src/main/java/com/baeldung/nulls/Assertions.java b/patterns/design-patterns-2/src/main/java/com/baeldung/nulls/Assertions.java similarity index 100% rename from core-java/src/main/java/com/baeldung/nulls/Assertions.java rename to patterns/design-patterns-2/src/main/java/com/baeldung/nulls/Assertions.java diff --git a/core-java/src/main/java/com/baeldung/nulls/EmptyCollections.java b/patterns/design-patterns-2/src/main/java/com/baeldung/nulls/EmptyCollections.java similarity index 100% rename from core-java/src/main/java/com/baeldung/nulls/EmptyCollections.java rename to patterns/design-patterns-2/src/main/java/com/baeldung/nulls/EmptyCollections.java diff --git a/core-java/src/main/java/com/baeldung/nulls/FindBugsAnnotations.java b/patterns/design-patterns-2/src/main/java/com/baeldung/nulls/FindBugsAnnotations.java similarity index 78% rename from core-java/src/main/java/com/baeldung/nulls/FindBugsAnnotations.java rename to patterns/design-patterns-2/src/main/java/com/baeldung/nulls/FindBugsAnnotations.java index a3804f6af5..697d5e4959 100644 --- a/core-java/src/main/java/com/baeldung/nulls/FindBugsAnnotations.java +++ b/patterns/design-patterns-2/src/main/java/com/baeldung/nulls/FindBugsAnnotations.java @@ -1,11 +1,12 @@ package com.baeldung.nulls; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + public class FindBugsAnnotations { - public void accept(@Nonnull Object param) { + public void accept(@NotNull Object param) { System.out.println(param.toString()); } @@ -13,7 +14,7 @@ public class FindBugsAnnotations { System.out.println("Printing " + param); } - @Nonnull + @NotNull public Object process() throws Exception { Object result = doSomething(); if (result == null) { diff --git a/core-java/src/main/java/com/baeldung/nulls/Preconditions.java b/patterns/design-patterns-2/src/main/java/com/baeldung/nulls/Preconditions.java similarity index 100% rename from core-java/src/main/java/com/baeldung/nulls/Preconditions.java rename to patterns/design-patterns-2/src/main/java/com/baeldung/nulls/Preconditions.java diff --git a/core-java/src/main/java/com/baeldung/nulls/PrimitivesAndWrapper.java b/patterns/design-patterns-2/src/main/java/com/baeldung/nulls/PrimitivesAndWrapper.java similarity index 100% rename from core-java/src/main/java/com/baeldung/nulls/PrimitivesAndWrapper.java rename to patterns/design-patterns-2/src/main/java/com/baeldung/nulls/PrimitivesAndWrapper.java diff --git a/core-java/src/main/java/com/baeldung/nulls/UsingLombok.java b/patterns/design-patterns-2/src/main/java/com/baeldung/nulls/UsingLombok.java similarity index 100% rename from core-java/src/main/java/com/baeldung/nulls/UsingLombok.java rename to patterns/design-patterns-2/src/main/java/com/baeldung/nulls/UsingLombok.java diff --git a/core-java/src/main/java/com/baeldung/nulls/UsingObjects.java b/patterns/design-patterns-2/src/main/java/com/baeldung/nulls/UsingObjects.java similarity index 100% rename from core-java/src/main/java/com/baeldung/nulls/UsingObjects.java rename to patterns/design-patterns-2/src/main/java/com/baeldung/nulls/UsingObjects.java diff --git a/core-java/src/main/java/com/baeldung/nulls/UsingOptional.java b/patterns/design-patterns-2/src/main/java/com/baeldung/nulls/UsingOptional.java similarity index 100% rename from core-java/src/main/java/com/baeldung/nulls/UsingOptional.java rename to patterns/design-patterns-2/src/main/java/com/baeldung/nulls/UsingOptional.java diff --git a/core-java/src/main/java/com/baeldung/nulls/UsingStringUtils.java b/patterns/design-patterns-2/src/main/java/com/baeldung/nulls/UsingStringUtils.java similarity index 100% rename from core-java/src/main/java/com/baeldung/nulls/UsingStringUtils.java rename to patterns/design-patterns-2/src/main/java/com/baeldung/nulls/UsingStringUtils.java diff --git a/core-java/src/test/java/com/baeldung/nulls/PrimitivesAndWrapperUnitTest.java b/patterns/design-patterns-2/src/test/java/com/baeldung/nulls/PrimitivesAndWrapperUnitTest.java similarity index 99% rename from core-java/src/test/java/com/baeldung/nulls/PrimitivesAndWrapperUnitTest.java rename to patterns/design-patterns-2/src/test/java/com/baeldung/nulls/PrimitivesAndWrapperUnitTest.java index 3c524387a4..49655619f6 100644 --- a/core-java/src/test/java/com/baeldung/nulls/PrimitivesAndWrapperUnitTest.java +++ b/patterns/design-patterns-2/src/test/java/com/baeldung/nulls/PrimitivesAndWrapperUnitTest.java @@ -1,10 +1,10 @@ package com.baeldung.nulls; +import org.junit.jupiter.api.Test; + import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; -import org.junit.jupiter.api.Test; - class PrimitivesAndWrapperUnitTest { @Test diff --git a/core-java/src/test/java/com/baeldung/nulls/UsingLombokUnitTest.java b/patterns/design-patterns-2/src/test/java/com/baeldung/nulls/UsingLombokUnitTest.java similarity index 82% rename from core-java/src/test/java/com/baeldung/nulls/UsingLombokUnitTest.java rename to patterns/design-patterns-2/src/test/java/com/baeldung/nulls/UsingLombokUnitTest.java index c157ad6630..b322344aba 100644 --- a/core-java/src/test/java/com/baeldung/nulls/UsingLombokUnitTest.java +++ b/patterns/design-patterns-2/src/test/java/com/baeldung/nulls/UsingLombokUnitTest.java @@ -1,10 +1,9 @@ package com.baeldung.nulls; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertThrows; class UsingLombokUnitTest { diff --git a/core-java/src/test/java/com/baeldung/nulls/UsingObjectsUnitTest.java b/patterns/design-patterns-2/src/test/java/com/baeldung/nulls/UsingObjectsUnitTest.java similarity index 84% rename from core-java/src/test/java/com/baeldung/nulls/UsingObjectsUnitTest.java rename to patterns/design-patterns-2/src/test/java/com/baeldung/nulls/UsingObjectsUnitTest.java index 6939caa4fb..e1f5a288e6 100644 --- a/core-java/src/test/java/com/baeldung/nulls/UsingObjectsUnitTest.java +++ b/patterns/design-patterns-2/src/test/java/com/baeldung/nulls/UsingObjectsUnitTest.java @@ -1,12 +1,11 @@ package com.baeldung.nulls; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertThrows; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - class UsingObjectsUnitTest { private UsingObjects classUnderTest; @@ -19,7 +18,7 @@ class UsingObjectsUnitTest { @Test public void whenArgIsNull_thenThrowException() { - assertThrows(Exception.class, () -> classUnderTest.accept(null)); + assertThrows(NullPointerException.class, () -> classUnderTest.accept(null)); } @Test diff --git a/core-java/src/test/java/com/baeldung/nulls/UsingOptionalUnitTest.java b/patterns/design-patterns-2/src/test/java/com/baeldung/nulls/UsingOptionalUnitTest.java similarity index 99% rename from core-java/src/test/java/com/baeldung/nulls/UsingOptionalUnitTest.java rename to patterns/design-patterns-2/src/test/java/com/baeldung/nulls/UsingOptionalUnitTest.java index d9d245369b..8f896cedfa 100644 --- a/core-java/src/test/java/com/baeldung/nulls/UsingOptionalUnitTest.java +++ b/patterns/design-patterns-2/src/test/java/com/baeldung/nulls/UsingOptionalUnitTest.java @@ -1,14 +1,14 @@ package com.baeldung.nulls; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.util.Optional; + import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -import java.util.Optional; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - class UsingOptionalUnitTest { private UsingOptional classUnderTest; diff --git a/core-java/src/test/java/com/baeldung/nulls/UsingStringUtilsUnitTest.java b/patterns/design-patterns-2/src/test/java/com/baeldung/nulls/UsingStringUtilsUnitTest.java similarity index 93% rename from core-java/src/test/java/com/baeldung/nulls/UsingStringUtilsUnitTest.java rename to patterns/design-patterns-2/src/test/java/com/baeldung/nulls/UsingStringUtilsUnitTest.java index 99b1dbe6b4..f7c51a7dc5 100644 --- a/core-java/src/test/java/com/baeldung/nulls/UsingStringUtilsUnitTest.java +++ b/patterns/design-patterns-2/src/test/java/com/baeldung/nulls/UsingStringUtilsUnitTest.java @@ -1,10 +1,9 @@ package com.baeldung.nulls; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertThrows; class UsingStringUtilsUnitTest { From 187199f924c6d3b4fc2c0387176f8bfab33f4751 Mon Sep 17 00:00:00 2001 From: Chirag Dewan Date: Wed, 27 Mar 2019 21:25:19 +0530 Subject: [PATCH 023/531] BAEL2489 Avoid check for null statement in Java - Removing unused pom changes --- core-java/pom.xml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/core-java/pom.xml b/core-java/pom.xml index 9c5a17d25c..ff5235096a 100644 --- a/core-java/pom.xml +++ b/core-java/pom.xml @@ -129,12 +129,6 @@ system ${java.home}/../lib/tools.jar - - org.jetbrains - annotations - ${intellij.annotations.version} - - @@ -491,6 +485,5 @@ 3.21.0-GA 1.8.0 - 16.0.2 From f0797a0c04e6526f4b0067d13084d0b51a423d08 Mon Sep 17 00:00:00 2001 From: Sushant Date: Thu, 28 Mar 2019 07:19:55 +0100 Subject: [PATCH 024/531] Multi set --- .../baeldung/guava/GuavaMultiSetUnitTest.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java diff --git a/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java b/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java new file mode 100644 index 0000000000..4f28f8ebfc --- /dev/null +++ b/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java @@ -0,0 +1,20 @@ +package org.baeldung.guava; + +import com.google.common.collect.HashMultiset; +import com.google.common.collect.Multiset; +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +public class GuavaMultiSetUnitTest { + + @Test + public void add_multipleValues() { + Multiset bookStore = HashMultiset.create(); + bookStore.add("Potter"); + bookStore.add("Potter"); + + assertThat(bookStore.contains("Potter")).isTrue(); + assertThat(bookStore.count("Potter")).isEqualTo(2); + } +} From af98a10b23067e486ca7d149e5e93bad55801a2f Mon Sep 17 00:00:00 2001 From: Sushant Date: Thu, 28 Mar 2019 07:33:31 +0100 Subject: [PATCH 025/531] Fix --- .../src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java b/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java index 4f28f8ebfc..faadc349d0 100644 --- a/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java +++ b/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java @@ -15,6 +15,6 @@ public class GuavaMultiSetUnitTest { bookStore.add("Potter"); assertThat(bookStore.contains("Potter")).isTrue(); - assertThat(bookStore.count("Potter")).isEqualTo(2); + assertThat(bookStore.count("Potter")).isEqualTo(3); } } From de1c689114edd968f3d37c4baa127e8b06a3f2f4 Mon Sep 17 00:00:00 2001 From: Chirag Dewan Date: Thu, 28 Mar 2019 22:03:57 +0530 Subject: [PATCH 026/531] BAEL2489 Avoid check for null statement in Java - Removing unused pom changes --- core-java/pom.xml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core-java/pom.xml b/core-java/pom.xml index ff5235096a..06f126e1d0 100644 --- a/core-java/pom.xml +++ b/core-java/pom.xml @@ -129,7 +129,6 @@ system ${java.home}/../lib/tools.jar - @@ -450,6 +449,7 @@ + 2.8.2 @@ -470,10 +470,12 @@ 2.21.0 + 1.1 1.4.197 2.1.0.1 1.19 + 1.19 3.0.0-M1 3.0.2 @@ -484,6 +486,7 @@ 61.1 3.21.0-GA + 1.8.0 From 0aeed3e745a08294bcbb716cea42b02e12178819 Mon Sep 17 00:00:00 2001 From: dev-chirag <41482403+dev-chirag@users.noreply.github.com> Date: Thu, 28 Mar 2019 22:28:14 +0530 Subject: [PATCH 027/531] Delete pom.xml Removing unused changes in core-java --- core-java/pom.xml | 492 ---------------------------------------------- 1 file changed, 492 deletions(-) delete mode 100644 core-java/pom.xml diff --git a/core-java/pom.xml b/core-java/pom.xml deleted file mode 100644 index 06f126e1d0..0000000000 --- a/core-java/pom.xml +++ /dev/null @@ -1,492 +0,0 @@ - - 4.0.0 - core-java - 0.1.0-SNAPSHOT - core-java - jar - - - com.baeldung - parent-java - 0.0.1-SNAPSHOT - ../parent-java - - - - - - commons-io - commons-io - ${commons-io.version} - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - - - org.unix4j - unix4j-command - ${unix4j.version} - - - com.googlecode.grep4j - grep4j - ${grep4j.version} - - - - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - - - com.google.code.gson - gson - ${gson.version} - - - - log4j - log4j - ${log4j.version} - - - org.slf4j - log4j-over-slf4j - ${org.slf4j.version} - - - org.projectlombok - lombok - ${lombok.version} - provided - - - - org.assertj - assertj-core - ${assertj-core.version} - test - - - org.javamoney - moneta - ${javamoney.moneta.version} - - - org.owasp.esapi - esapi - ${esapi.version} - - - com.sun.messaging.mq - fscontext - ${fscontext.version} - - - com.codepoetics - protonpack - ${protonpack.version} - - - one.util - streamex - ${streamex.version} - - - io.vavr - vavr - ${vavr.version} - - - org.openjdk.jmh - jmh-core - ${jmh-core.version} - - - org.openjdk.jmh - jmh-generator-annprocess - ${jmh-generator-annprocess.version} - - - com.h2database - h2 - ${h2database.version} - - - - org.javassist - javassist - ${javaassist.version} - - - com.sun - tools - ${sun.tools.version} - system - ${java.home}/../lib/tools.jar - - - - - core-java - - - src/main/resources - true - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-dependencies - prepare-package - - copy-dependencies - - - ${project.build.directory}/libs - - - - - - - org.apache.maven.plugins - maven-jar-plugin - ${maven-jar-plugin.version} - - - - true - libs/ - org.baeldung.executable.ExecutableMavenJar - - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - package - - single - - - ${project.basedir} - - - org.baeldung.executable.ExecutableMavenJar - - - - jar-with-dependencies - - - - - - - - org.apache.maven.plugins - maven-shade-plugin - ${maven-shade-plugin.version} - - - - shade - - - true - - - org.baeldung.executable.ExecutableMavenJar - - - - - - - - - com.jolira - onejar-maven-plugin - ${onejar-maven-plugin.version} - - - - org.baeldung.executable.ExecutableMavenJar - true - ${project.build.finalName}-onejar.${project.packaging} - - - one-jar - - - - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring-boot-maven-plugin.version} - - - - repackage - - - spring-boot - org.baeldung.executable.ExecutableMavenJar - - - - - - - org.codehaus.mojo - exec-maven-plugin - ${exec-maven-plugin.version} - - java - com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed - - -Xmx300m - -XX:+UseParallelGC - -classpath - - com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - ${maven-javadoc-plugin.version} - - 1.8 - 1.8 - - - - - - - - integration - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration-test - - test - - - - **/*ManualTest.java - - - **/*IntegrationTest.java - **/*IntTest.java - - - - - - - json - - - - - org.codehaus.mojo - exec-maven-plugin - ${exec-maven-plugin.version} - - - run-benchmarks - - none - - exec - - - test - java - - -classpath - - org.openjdk.jmh.Main - .* - - - - - - - - - - - - buildAgentLoader - - - - org.apache.maven.plugins - maven-jar-plugin - - - package - - jar - - - agentLoader - target/classes - - - true - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - - - com/baeldung/instrumentation/application/AgentLoader.class - com/baeldung/instrumentation/application/Launcher.class - - - - - - - - - - buildApplication - - - - org.apache.maven.plugins - maven-jar-plugin - - - package - - jar - - - application - target/classes - - - true - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - - - com/baeldung/instrumentation/application/MyAtm.class - com/baeldung/instrumentation/application/MyAtmApplication.class - com/baeldung/instrumentation/application/Launcher.class - - - - - - - - - - buildAgent - - - - org.apache.maven.plugins - maven-jar-plugin - - - package - - jar - - - agent - target/classes - - - true - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - - - com/baeldung/instrumentation/agent/AtmTransformer.class - com/baeldung/instrumentation/agent/MyInstrumentationAgent.class - - - - - - - - - - - - - - 2.8.2 - - - 3.5 - 2.5 - 3.6.1 - 1.0.3 - 0.4 - 1.8.7 - 4.6-b01 - 1.13 - 0.6.5 - 0.9.0 - - - 3.10.0 - - - 2.21.0 - - 1.1 - 1.4.197 - 2.1.0.1 - 1.19 - - 1.19 - 3.0.0-M1 - 3.0.2 - 1.4.4 - 3.1.1 - 2.0.3.RELEASE - 1.6.0 - 61.1 - - 3.21.0-GA - - 1.8.0 - - From 4eb3c8567a65ef3fb7b7626130f21b9c1b0cfceb Mon Sep 17 00:00:00 2001 From: Chirag Dewan Date: Thu, 28 Mar 2019 22:43:31 +0530 Subject: [PATCH 028/531] BAEL2489 Avoid check for null statement in Java - Removing unused pom changes --- core-java/pom.xml | 492 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 492 insertions(+) create mode 100644 core-java/pom.xml diff --git a/core-java/pom.xml b/core-java/pom.xml new file mode 100644 index 0000000000..463b65a4ce --- /dev/null +++ b/core-java/pom.xml @@ -0,0 +1,492 @@ + + 4.0.0 + core-java + 0.1.0-SNAPSHOT + core-java + jar + + + com.baeldung + parent-java + 0.0.1-SNAPSHOT + ../parent-java + + + + + + commons-io + commons-io + ${commons-io.version} + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + org.unix4j + unix4j-command + ${unix4j.version} + + + com.googlecode.grep4j + grep4j + ${grep4j.version} + + + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + com.google.code.gson + gson + ${gson.version} + + + + log4j + log4j + ${log4j.version} + + + org.slf4j + log4j-over-slf4j + ${org.slf4j.version} + + + org.projectlombok + lombok + ${lombok.version} + provided + + + + org.assertj + assertj-core + ${assertj-core.version} + test + + + org.javamoney + moneta + ${javamoney.moneta.version} + + + org.owasp.esapi + esapi + ${esapi.version} + + + com.sun.messaging.mq + fscontext + ${fscontext.version} + + + com.codepoetics + protonpack + ${protonpack.version} + + + one.util + streamex + ${streamex.version} + + + io.vavr + vavr + ${vavr.version} + + + org.openjdk.jmh + jmh-core + ${jmh-core.version} + + + org.openjdk.jmh + jmh-generator-annprocess + ${jmh-generator-annprocess.version} + + + com.h2database + h2 + ${h2database.version} + + + + org.javassist + javassist + ${javaassist.version} + + + com.sun + tools + ${sun.tools.version} + system + ${java.home}/../lib/tools.jar + + + + + core-java + + + src/main/resources + true + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + prepare-package + + copy-dependencies + + + ${project.build.directory}/libs + + + + + + + org.apache.maven.plugins + maven-jar-plugin + ${maven-jar-plugin.version} + + + + true + libs/ + org.baeldung.executable.ExecutableMavenJar + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + package + + single + + + ${project.basedir} + + + org.baeldung.executable.ExecutableMavenJar + + + + jar-with-dependencies + + + + + + + + org.apache.maven.plugins + maven-shade-plugin + ${maven-shade-plugin.version} + + + + shade + + + true + + + org.baeldung.executable.ExecutableMavenJar + + + + + + + + + com.jolira + onejar-maven-plugin + ${onejar-maven-plugin.version} + + + + org.baeldung.executable.ExecutableMavenJar + true + ${project.build.finalName}-onejar.${project.packaging} + + + one-jar + + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot-maven-plugin.version} + + + + repackage + + + spring-boot + org.baeldung.executable.ExecutableMavenJar + + + + + + + org.codehaus.mojo + exec-maven-plugin + ${exec-maven-plugin.version} + + java + com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed + + -Xmx300m + -XX:+UseParallelGC + -classpath + + com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + ${maven-javadoc-plugin.version} + + 1.8 + 1.8 + + + + + + + + integration + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration-test + + test + + + + **/*ManualTest.java + + + **/*IntegrationTest.java + **/*IntTest.java + + + + + + + json + + + + + org.codehaus.mojo + exec-maven-plugin + ${exec-maven-plugin.version} + + + run-benchmarks + + none + + exec + + + test + java + + -classpath + + org.openjdk.jmh.Main + .* + + + + + + + + + + + + buildAgentLoader + + + + org.apache.maven.plugins + maven-jar-plugin + + + package + + jar + + + agentLoader + target/classes + + + true + + ${project.build.outputDirectory}/META-INF/MANIFEST.MF + + + + com/baeldung/instrumentation/application/AgentLoader.class + com/baeldung/instrumentation/application/Launcher.class + + + + + + + + + + buildApplication + + + + org.apache.maven.plugins + maven-jar-plugin + + + package + + jar + + + application + target/classes + + + true + + ${project.build.outputDirectory}/META-INF/MANIFEST.MF + + + + com/baeldung/instrumentation/application/MyAtm.class + com/baeldung/instrumentation/application/MyAtmApplication.class + com/baeldung/instrumentation/application/Launcher.class + + + + + + + + + + buildAgent + + + + org.apache.maven.plugins + maven-jar-plugin + + + package + + jar + + + agent + target/classes + + + true + + ${project.build.outputDirectory}/META-INF/MANIFEST.MF + + + + com/baeldung/instrumentation/agent/AtmTransformer.class + com/baeldung/instrumentation/agent/MyInstrumentationAgent.class + + + + + + + + + + + + + + 2.8.2 + + + 3.5 + 2.5 + 3.6.1 + 1.0.3 + 0.4 + 1.8.7 + 4.6-b01 + 1.13 + 0.6.5 + 0.9.0 + + + 3.10.0 + + + 2.21.0 + + 1.1 + 1.4.197 + 2.1.0.1 + 1.19 + + 1.19 + 3.0.0-M1 + 3.0.2 + 1.4.4 + 3.1.1 + 2.0.3.RELEASE + 1.6.0 + 61.1 + + 3.21.0-GA + + 1.8.0 + + From cef5964b6b5781b8b2bebb7b5e7a95d8c4378d09 Mon Sep 17 00:00:00 2001 From: Josephine Barboza Date: Sat, 30 Mar 2019 14:28:28 +0530 Subject: [PATCH 029/531] BAEL-2766 Maps in Groovy --- .../groovy/com/baeldung/map/MapTest.groovy | 146 ++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 core-groovy/src/test/groovy/com/baeldung/map/MapTest.groovy diff --git a/core-groovy/src/test/groovy/com/baeldung/map/MapTest.groovy b/core-groovy/src/test/groovy/com/baeldung/map/MapTest.groovy new file mode 100644 index 0000000000..8bd9302412 --- /dev/null +++ b/core-groovy/src/test/groovy/com/baeldung/map/MapTest.groovy @@ -0,0 +1,146 @@ +package com.baeldung.groovy.map; + +import static groovy.test.GroovyAssert.* +import org.junit.Test + +class MapTest{ + + @Test + void createMap() { + + def emptyMap = [:] + assertNotNull(emptyMap) + + assertTrue(emptyMap instanceof java.util.LinkedHashMap) + + def map = [name:"Jerry", age: 42, city: "New York"] + assertTrue(map.size() == 3) + } + + @Test + void addItemsToMap() { + + def map = [name:"Jerry"] + + map["age"] = 42 + + map.city = "New York" + + def hobbyLiteral = "hobby" + def hobbyMap = [(hobbyLiteral): "Singing"] + map.putAll(hobbyMap) + + assertTrue(map == [name:"Jerry", age: 42, city: "New York", hobby:"Singing"]) + + map.plus([1:20]) // returns new map + + map << [2:30] + + } + + @Test + void getItemsFromMap() { + + def map = [name:"Jerry", age: 42, city: "New York", hobby:"Singing"] + + assertTrue(map["name"] == "Jerry") + + assertTrue(map.name == "Jerry") + + def propertyAge = "age" + assertTrue(map[propertyAge] == 42) + } + + @Test + void removeItemsFromMap() { + + def map = [1:20, a:30, 2:42, 4:34, ba:67, 6:39, 7:49] + + def minusMap = map.minus([2:42, 4:34]); + assertTrue(minusMap == [1:20, a:30, ba:67, 6:39, 7:49]) + + minusMap.removeAll{it -> it.key instanceof String} + assertTrue( minusMap == [ 1:20, 6:39, 7:49]) + + minusMap.retainAll{it -> it.value %2 == 0} + assertTrue( minusMap == [1:20]) + } + + @Test + void iteratingOnMaps(){ + def map = [name:"Jerry", age: 42, city: "New York", hobby:"Singing"] + + map.each{ entry -> println "$entry.key: $entry.value" } + + map.eachWithIndex{ entry, i -> println "$i $entry.key: $entry.value" } + + map.eachWithIndex{ key, value, i -> println "$i $key: $value" } + } + + @Test + void filteringAndSearchingMaps(){ + def map = [name:"Jerry", age: 42, city: "New York", hobby:"Singing"] + + assertTrue(map.find{ it.value == "New York"}.key == "city") + + assertTrue(map.findAll{ it.value == "New York"} == [city : "New York"]) + + map.grep{it.value == "New York"}.each{ it -> assertTrue(it.key == "city" && it.value == "New York")} + + assertTrue(map.every{it -> it.value instanceof String} == false) + + assertTrue(map.any{it -> it.value instanceof String} == true) + } + + @Test + void collect(){ + + def map = [1: [name:"Jerry", age: 42, city: "New York"], + 2: [name:"Long", age: 25, city: "New York"], + 3: [name:"Dustin", age: 29, city: "New York"], + 4: [name:"Dustin", age: 34, city: "New York"]] + + def names = map.collect{entry -> entry.value.name} // returns only list + assertTrue(names == ["Jerry", "Long", "Dustin", "Dustin"]) + + def uniqueNames = map.collect([] as HashSet){entry -> entry.value.name} + assertTrue(uniqueNames == ["Jerry", "Long", "Dustin"] as Set) + + def idNames = map.collectEntries{key, value -> [key, value.name]} + assertTrue(idNames == [1:"Jerry", 2: "Long", 3:"Dustin", 4: "Dustin"]) + + def below30Names = map.findAll{it.value.age < 30}.collect{key, value -> value.name} + assertTrue(below30Names == ["Long", "Dustin"]) + + + } + + @Test + void group(){ + def map = [1:20, 2: 40, 3: 11, 4: 93] + + def subMap = map.groupBy{it.value % 2} + println subMap + assertTrue(subMap == [0:[1:20, 2:40 ], 1:[3:11, 4:93]]) + + def keySubMap = map.subMap([1, 2]) + assertTrue(keySubMap == [1:20, 2:40]) + + } + + @Test + void sorting(){ + def map = [ab:20, a: 40, cb: 11, ba: 93] + + def naturallyOrderedMap = map.sort() + assertTrue([a:40, ab:20, ba:93, cb:11] == naturallyOrderedMap) + + def compSortedMap = map.sort({ k1, k2 -> k1 <=> k2 } as Comparator) + assertTrue([a:40, ab:20, ba:93, cb:11] == compSortedMap) + + def cloSortedMap = map.sort({ it1, it2 -> it1.value <=> it1.value }) + assertTrue([cb:11, ab:20, a:40, ba:93] == cloSortedMap) + + } + +} \ No newline at end of file From af4e221fa85c8a171581e9136528d2255c351445 Mon Sep 17 00:00:00 2001 From: Denis Zhdanov Date: Sun, 31 Mar 2019 08:15:02 +0800 Subject: [PATCH 030/531] BAEL-2779 Guide to classgraph library --- libraries/pom.xml | 7 ++ .../classgraph/ClassGraphUnitTest.java | 78 +++++++++++++++++++ .../classgraph/ClassWithAnnotation.java | 5 ++ .../classgraph/FieldWithAnnotation.java | 7 ++ .../classgraph/MethodWithAnnotation.java | 8 ++ .../MethodWithAnnotationParameterDao.java | 8 ++ .../MethodWithAnnotationParameterWeb.java | 8 ++ .../baeldung/classgraph/TestAnnotation.java | 14 ++++ .../src/test/resources/classgraph/my.config | 1 + 9 files changed, 136 insertions(+) create mode 100644 libraries/src/test/java/com/baeldung/classgraph/ClassGraphUnitTest.java create mode 100644 libraries/src/test/java/com/baeldung/classgraph/ClassWithAnnotation.java create mode 100644 libraries/src/test/java/com/baeldung/classgraph/FieldWithAnnotation.java create mode 100644 libraries/src/test/java/com/baeldung/classgraph/MethodWithAnnotation.java create mode 100644 libraries/src/test/java/com/baeldung/classgraph/MethodWithAnnotationParameterDao.java create mode 100644 libraries/src/test/java/com/baeldung/classgraph/MethodWithAnnotationParameterWeb.java create mode 100644 libraries/src/test/java/com/baeldung/classgraph/TestAnnotation.java create mode 100644 libraries/src/test/resources/classgraph/my.config diff --git a/libraries/pom.xml b/libraries/pom.xml index 7823732224..a6179a843d 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -699,6 +699,12 @@ ${reflections.version} + + io.github.classgraph + classgraph + ${classgraph.version} + + @@ -916,6 +922,7 @@ 2.7.1 3.6 0.9.11 + 4.8.22 diff --git a/libraries/src/test/java/com/baeldung/classgraph/ClassGraphUnitTest.java b/libraries/src/test/java/com/baeldung/classgraph/ClassGraphUnitTest.java new file mode 100644 index 0000000000..5767396948 --- /dev/null +++ b/libraries/src/test/java/com/baeldung/classgraph/ClassGraphUnitTest.java @@ -0,0 +1,78 @@ +package com.baeldung.classgraph; + +import io.github.classgraph.*; +import org.junit.Test; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.function.Consumer; + +import static org.assertj.core.api.Assertions.assertThat; + +public class ClassGraphUnitTest { + + @Test + public void whenClassAnnotationFilterIsDefined_thenTargetClassesCanBeFound() { + doTest(result -> { + ClassInfoList classInfos = result.getClassesWithAnnotation(TestAnnotation.class.getName()); + assertThat(classInfos).extracting(ClassInfo::getName).contains(ClassWithAnnotation.class.getName()); + }); + } + + @Test + public void whenMethodAnnotationFilterIsDefined_thenTargetClassesCanBeFound() { + doTest(result -> { + ClassInfoList classInfos = result.getClassesWithMethodAnnotation(TestAnnotation.class.getName()); + assertThat(classInfos).extracting(ClassInfo::getName).contains(MethodWithAnnotation.class.getName()); + }); + } + + @Test + public void whenMethodAnnotationValueFilterIsDefined_thenTargetClassesCanBeFound() { + doTest(result -> { + ClassInfoList classInfos = result.getClassesWithMethodAnnotation(TestAnnotation.class.getName()); + ClassInfoList filteredClassInfos = classInfos.filter(classInfo -> { + return classInfo.getMethodInfo().stream().anyMatch(methodInfo -> { + AnnotationInfo annotationInfo = methodInfo.getAnnotationInfo(TestAnnotation.class.getName()); + if (annotationInfo == null) { + return false; + } + + return "web".equals(annotationInfo.getParameterValues().getValue("value")); + }); + }); + assertThat(filteredClassInfos) + .extracting(ClassInfo::getName) + .contains(MethodWithAnnotationParameterWeb.class.getName()); + }); + } + + @Test + public void whenFieldAnnotationFilterIsDefined_thenTargetClassesCanBeFound() { + doTest(result -> { + ClassInfoList classInfos = result.getClassesWithFieldAnnotation(TestAnnotation.class.getName()); + assertThat(classInfos).extracting(ClassInfo::getName).contains(FieldWithAnnotation.class.getName()); + }); + } + + @Test + public void whenResourceIsUsed_thenItCanBeFoundAndLoaded() throws IOException { + try (ScanResult result = new ClassGraph().whitelistPaths("classgraph").scan()) { + ResourceList resources = result.getResourcesWithExtension("config"); + assertThat(resources).extracting(Resource::getPath).containsOnly("classgraph/my.config"); + assertThat(resources.get(0).getContentAsString()).isEqualTo("my data"); + } + } + + private void doTest(Consumer checker) { + try (ScanResult result = new ClassGraph().enableAllInfo() + .whitelistPackages(getClass().getPackage().getName()) + .scan()) + { + checker.accept(result); + } + } +} diff --git a/libraries/src/test/java/com/baeldung/classgraph/ClassWithAnnotation.java b/libraries/src/test/java/com/baeldung/classgraph/ClassWithAnnotation.java new file mode 100644 index 0000000000..0f3eeef293 --- /dev/null +++ b/libraries/src/test/java/com/baeldung/classgraph/ClassWithAnnotation.java @@ -0,0 +1,5 @@ +package com.baeldung.classgraph; + +@TestAnnotation +public class ClassWithAnnotation { +} diff --git a/libraries/src/test/java/com/baeldung/classgraph/FieldWithAnnotation.java b/libraries/src/test/java/com/baeldung/classgraph/FieldWithAnnotation.java new file mode 100644 index 0000000000..c5d1cc6062 --- /dev/null +++ b/libraries/src/test/java/com/baeldung/classgraph/FieldWithAnnotation.java @@ -0,0 +1,7 @@ +package com.baeldung.classgraph; + +public class FieldWithAnnotation { + + @TestAnnotation + private String s; +} diff --git a/libraries/src/test/java/com/baeldung/classgraph/MethodWithAnnotation.java b/libraries/src/test/java/com/baeldung/classgraph/MethodWithAnnotation.java new file mode 100644 index 0000000000..12d0c9927c --- /dev/null +++ b/libraries/src/test/java/com/baeldung/classgraph/MethodWithAnnotation.java @@ -0,0 +1,8 @@ +package com.baeldung.classgraph; + +public class MethodWithAnnotation { + + @TestAnnotation + public void service() { + } +} diff --git a/libraries/src/test/java/com/baeldung/classgraph/MethodWithAnnotationParameterDao.java b/libraries/src/test/java/com/baeldung/classgraph/MethodWithAnnotationParameterDao.java new file mode 100644 index 0000000000..9e38f42013 --- /dev/null +++ b/libraries/src/test/java/com/baeldung/classgraph/MethodWithAnnotationParameterDao.java @@ -0,0 +1,8 @@ +package com.baeldung.classgraph; + +public class MethodWithAnnotationParameterDao { + + @TestAnnotation("dao") + public void service() { + } +} diff --git a/libraries/src/test/java/com/baeldung/classgraph/MethodWithAnnotationParameterWeb.java b/libraries/src/test/java/com/baeldung/classgraph/MethodWithAnnotationParameterWeb.java new file mode 100644 index 0000000000..1ef3d46b6f --- /dev/null +++ b/libraries/src/test/java/com/baeldung/classgraph/MethodWithAnnotationParameterWeb.java @@ -0,0 +1,8 @@ +package com.baeldung.classgraph; + +public class MethodWithAnnotationParameterWeb { + + @TestAnnotation("web") + public void service() { + } +} diff --git a/libraries/src/test/java/com/baeldung/classgraph/TestAnnotation.java b/libraries/src/test/java/com/baeldung/classgraph/TestAnnotation.java new file mode 100644 index 0000000000..f47ec180a9 --- /dev/null +++ b/libraries/src/test/java/com/baeldung/classgraph/TestAnnotation.java @@ -0,0 +1,14 @@ +package com.baeldung.classgraph; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import static java.lang.annotation.ElementType.*; + +@Target({TYPE, METHOD, FIELD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface TestAnnotation { + + String value() default ""; +} diff --git a/libraries/src/test/resources/classgraph/my.config b/libraries/src/test/resources/classgraph/my.config new file mode 100644 index 0000000000..b99df573f6 --- /dev/null +++ b/libraries/src/test/resources/classgraph/my.config @@ -0,0 +1 @@ +my data \ No newline at end of file From 72d38fd1cac1b61fabbbdb6aa903dd5666a583ce Mon Sep 17 00:00:00 2001 From: Sushant Date: Sun, 31 Mar 2019 15:10:04 +0300 Subject: [PATCH 031/531] Add unit test --- .../baeldung/guava/GuavaMultiSetUnitTest.java | 69 ++++++++++++++++--- 1 file changed, 61 insertions(+), 8 deletions(-) diff --git a/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java b/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java index faadc349d0..b3f097cf9a 100644 --- a/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java +++ b/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java @@ -4,17 +4,70 @@ import com.google.common.collect.HashMultiset; import com.google.common.collect.Multiset; import org.junit.Test; +import java.util.HashMap; +import java.util.Map; + import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; public class GuavaMultiSetUnitTest { - @Test - public void add_multipleValues() { - Multiset bookStore = HashMultiset.create(); - bookStore.add("Potter"); - bookStore.add("Potter"); + @Test + public void givenMultiSet_whenAddAndRemoveValues_shouldReturnCorrectCount() { + Multiset bookStore = HashMultiset.create(); + bookStore.add("Potter"); + bookStore.add("Potter"); + bookStore.add("Potter"); - assertThat(bookStore.contains("Potter")).isTrue(); - assertThat(bookStore.count("Potter")).isEqualTo(3); - } + assertThat(bookStore.contains("Potter")).isTrue(); + assertThat(bookStore.count("Potter")).isEqualTo(3); + + bookStore.remove("Potter"); + assertThat(bookStore.contains("Potter")).isTrue(); + assertThat(bookStore.count("Potter")).isEqualTo(2); + } + + @Test + public void givenMultiSet_whenSetCount_shouldReturnCorrectCount() { + Multiset bookStore = HashMultiset.create(); + bookStore.setCount("Potter", 50); //add 50 to the count + assertThat(bookStore.count("Potter")).isEqualTo(50); + } + + @Test + public void givenMultiSet_whenSettingNegativeCount_shouldThrowException() { + Multiset bookStore = HashMultiset.create(); + assertThatThrownBy(() -> bookStore.setCount("Potter", -1)).isInstanceOf(IllegalArgumentException.class); + } + + @Test + public void givenMultiSet_whenSettingCountWithOldCount_shouldReturnCorrectValue() { + Multiset bookStore = HashMultiset.create(); + assertThat(bookStore.setCount("Potter", 0, 2)).isTrue(); + assertThat(bookStore.setCount("Potter", 50, 5)).isFalse(); + } + + @Test + public void givenMap_compareMultiSetOperations() { + Map bookStore = new HashMap<>(); + bookStore.put("Potter", 1); + bookStore.put("Potter", 2); + bookStore.put("Potter", 3); + + assertThat(bookStore.containsKey("Potter")).isTrue(); + assertThat(bookStore.get("Potter")).isEqualTo(3); + + bookStore.put("Potter", null); + assertThat(bookStore.containsKey("Potter")).isTrue(); + + bookStore.put("Potter", -1); + assertThat(bookStore.containsKey("Potter")).isTrue(); + + bookStore.put("Potter", 2); + assertThat(bookStore.containsKey("Potter")).isTrue(); + assertThat(bookStore.get("Potter")).isEqualTo(2); + + bookStore.put("Potter", 52); + assertThat(bookStore.get("Potter")).isEqualTo(52); + } } From 45bf5898d5128b12ca2d5d3a1c3323dd0bf1dab9 Mon Sep 17 00:00:00 2001 From: Sushant Date: Sun, 31 Mar 2019 17:26:08 +0300 Subject: [PATCH 032/531] Remove comment --- .../org/baeldung/guava/GuavaMultiSetUnitTest.java | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java b/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java index b3f097cf9a..3d75cc38a3 100644 --- a/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java +++ b/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java @@ -30,7 +30,7 @@ public class GuavaMultiSetUnitTest { @Test public void givenMultiSet_whenSetCount_shouldReturnCorrectCount() { Multiset bookStore = HashMultiset.create(); - bookStore.setCount("Potter", 50); //add 50 to the count + bookStore.setCount("Potter", 50); assertThat(bookStore.count("Potter")).isEqualTo(50); } @@ -50,24 +50,18 @@ public class GuavaMultiSetUnitTest { @Test public void givenMap_compareMultiSetOperations() { Map bookStore = new HashMap<>(); - bookStore.put("Potter", 1); - bookStore.put("Potter", 2); bookStore.put("Potter", 3); assertThat(bookStore.containsKey("Potter")).isTrue(); assertThat(bookStore.get("Potter")).isEqualTo(3); + bookStore.put("Potter", 2); + assertThat(bookStore.get("Potter")).isEqualTo(2); + bookStore.put("Potter", null); assertThat(bookStore.containsKey("Potter")).isTrue(); bookStore.put("Potter", -1); assertThat(bookStore.containsKey("Potter")).isTrue(); - - bookStore.put("Potter", 2); - assertThat(bookStore.containsKey("Potter")).isTrue(); - assertThat(bookStore.get("Potter")).isEqualTo(2); - - bookStore.put("Potter", 52); - assertThat(bookStore.get("Potter")).isEqualTo(52); } } From 2bd55bb19522e26868ff5cdad329b178c5b59a94 Mon Sep 17 00:00:00 2001 From: Anshul Bansal Date: Mon, 1 Apr 2019 19:32:50 +0300 Subject: [PATCH 033/531] BAEL-2800_Copying_a_HashMap_in_Java --- .../baeldung/copyinghashmap/CopyHashMap.java | 46 ++++++++ .../copyinghashmap/CopyHashMapUnitTest.java | 100 ++++++++++++++++++ .../com/baeldung/copyinghashmap/Employee.java | 38 +++++++ 3 files changed, 184 insertions(+) create mode 100644 core-java-collections/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java create mode 100644 core-java-collections/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java create mode 100644 core-java-collections/src/test/java/com/baeldung/copyinghashmap/Employee.java diff --git a/core-java-collections/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java b/core-java-collections/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java new file mode 100644 index 0000000000..e6935afbe2 --- /dev/null +++ b/core-java-collections/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java @@ -0,0 +1,46 @@ +package com.baeldung.copyinghashmap; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +import org.apache.commons.lang3.SerializationUtils; + +public class CopyHashMap { + + public static HashMap basicCopy(HashMap originalMap, HashMap copyMap) { + Set entries = originalMap.entrySet(); + for(Map.Entry mapEntry: entries) { + copyMap.put(mapEntry.getKey(), mapEntry.getValue()); + } + + return copyMap; + } + + + public static Map copyUsingPutAll(Map originalMap, Map copyMap) { + copyMap.putAll(originalMap); + + return copyMap; + } + + public static HashMap copyUsingJava8Stream(HashMap originalMap) { + Set entries = originalMap.entrySet(); + HashMap copyMap = (HashMap) entries + .stream() + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + return copyMap; + } + + public static HashMap shallowCopy(HashMap originalMap) { + //return new HashMap(originalMap); + return (HashMap) originalMap.clone(); + } + + public static HashMap deepCopy(HashMap originalMap) { + return SerializationUtils.clone(originalMap); + } + +} diff --git a/core-java-collections/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java b/core-java-collections/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java new file mode 100644 index 0000000000..57fccadaef --- /dev/null +++ b/core-java-collections/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java @@ -0,0 +1,100 @@ +package com.baeldung.copyinghashmap; + +import static org.junit.Assert.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; + +import com.google.common.collect.ImmutableMap; + +public class CopyHashMapUnitTest { + + @Test + public void givenHashmap_whenCopy_thenCopyContainsAllMappings() { + + HashMap colorMap = new HashMap<>(); + colorMap.put("1", "Red"); + colorMap.put("2", "Blue"); + colorMap.put("3", "Green"); + + System.out.println("ColorMap content : " + colorMap); + + HashMap colorMapCopy = new HashMap<>(); + colorMapCopy.put("1", "Orange"); + colorMapCopy.put("4", "Black"); + + colorMapCopy = CopyHashMap.basicCopy(colorMap, colorMapCopy); + + System.out.println("ColorMapCopy content : " +colorMapCopy); + + assertEquals(4, colorMapCopy.size()); + } + + @Test + public void givenHashMap_whenShallowCopy_thenCopyisNotSameAsOriginal() { + + HashMap employeeMap = new HashMap<>(); + Employee emp1 = new Employee("John", "Smith"); + Employee emp2 = new Employee("Norman", "Lewis"); + employeeMap.put("employee1",emp1); + employeeMap.put("employee2",emp2); + + HashMap employeeMapShallowCopy = CopyHashMap.shallowCopy(employeeMap); + + assertThat(employeeMapShallowCopy).isNotSameAs(employeeMap); + + } + + @Test + public void givenHashMap_whenShallowCopyModifyingOriginalObject_thenCopyShouldChange() { + + HashMap employeeMap = new HashMap<>(); + Employee emp1 = new Employee("John", "Smith"); + Employee emp2 = new Employee("Norman", "Lewis"); + employeeMap.put("employee1",emp1); + employeeMap.put("employee2",emp2); + HashMap employeeMapShallowCopy = CopyHashMap.shallowCopy(employeeMap); + + emp1.setFirstName("Johny"); + + assertThat(employeeMapShallowCopy.get("employee1")) + .isEqualTo(employeeMap.get("employee1")); + + } + + @Test + public void givenHashMap_whenDeepCopyModifyingOriginalObject_thenCopyShouldNotChange() { + + HashMap employeeMap = new HashMap<>(); + Employee emp1 = new Employee("John", "Smith"); + Employee emp2 = new Employee("Norman", "Lewis"); + employeeMap.put("employee1",emp1); + employeeMap.put("employee2",emp2); + HashMap employeeMapDeepCopy = CopyHashMap.deepCopy(employeeMap); + + emp1.setFirstName("Johny"); + + assertThat(employeeMapDeepCopy.get("employee1")) + .isNotEqualTo(employeeMap.get("employee1")); + + } + + @Test + public void givenImmutableMap_whenCopyUsingGuava_thenCopyShouldNotChange() { + + Map heightMap = ImmutableMap. builder() + .put("emp1", 160) + .put("emp2", 165) + .put("emp3", 163) + .build(); + Map heightMapCopy = ImmutableMap.copyOf(heightMap); + + assertThat(heightMapCopy).isSameAs(heightMap); + + } + + +} diff --git a/core-java-collections/src/test/java/com/baeldung/copyinghashmap/Employee.java b/core-java-collections/src/test/java/com/baeldung/copyinghashmap/Employee.java new file mode 100644 index 0000000000..9ec4327b5f --- /dev/null +++ b/core-java-collections/src/test/java/com/baeldung/copyinghashmap/Employee.java @@ -0,0 +1,38 @@ +package com.baeldung.copyinghashmap; + +import java.io.Serializable; + +public class Employee implements Serializable{ + + private String firstName; + private String lastName; + + public Employee(String firstName, String lastName) { + super(); + this.firstName = firstName; + this.lastName = lastName; + } + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + @Override + public String toString() { + return this.firstName + " " + this.lastName; + } + +} + + From 6b104db2bbb3e90af6ac94ffe8cd78c0b08765bc Mon Sep 17 00:00:00 2001 From: Chirag Dewan Date: Tue, 2 Apr 2019 17:14:37 +0530 Subject: [PATCH 034/531] BAEL2489 Avoid check for null statement in Java - adding ofnullable to Optional example --- .../src/main/java/com/baeldung/nulls/UsingOptional.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/patterns/design-patterns-2/src/main/java/com/baeldung/nulls/UsingOptional.java b/patterns/design-patterns-2/src/main/java/com/baeldung/nulls/UsingOptional.java index 6c17290a72..d5dd56e760 100644 --- a/patterns/design-patterns-2/src/main/java/com/baeldung/nulls/UsingOptional.java +++ b/patterns/design-patterns-2/src/main/java/com/baeldung/nulls/UsingOptional.java @@ -8,11 +8,7 @@ public class UsingOptional { String response = doSomething(processed); - if (response == null) { - return Optional.empty(); - } - - return Optional.of(response); + return Optional.ofNullable(response); } private String doSomething(boolean processed) { From b6bf4415a204bb604f8c17dabd92c96d8d07dc89 Mon Sep 17 00:00:00 2001 From: macroscopic64 Date: Wed, 3 Apr 2019 00:04:39 +0530 Subject: [PATCH 035/531] [BAEL-2073] Java 9 Migration Issues and Resolution --- .../main/java/com/baeldung/prejpms/App.java | 36 +++++++++---------- .../main/java/com/baeldung/prejpms/Book.java | 4 +-- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/prejpms/src/main/java/com/baeldung/prejpms/App.java b/prejpms/src/main/java/com/baeldung/prejpms/App.java index 0b38201302..1afaae30e4 100644 --- a/prejpms/src/main/java/com/baeldung/prejpms/App.java +++ b/prejpms/src/main/java/com/baeldung/prejpms/App.java @@ -16,7 +16,7 @@ import sun.reflect.Reflection; public class App { - private static final Logger logger = LoggerFactory.getLogger(App.class); + private static final Logger LOGGER = LoggerFactory.getLogger(App.class); public static void main(String[] args) throws Exception { @@ -28,28 +28,26 @@ public class App { private static void getCrytpographyProviderName() { try { - logger.info("1. Java Cryptography Extension - Provider Name: " + new SunJCE().getName() + "\n"); + LOGGER.info("1. JCE Provider Name: {}\n", new SunJCE().getName()); } catch (Throwable e) { - logger.error(e.toString()); + LOGGER.error(e.toString()); } } private static void getCallStackClassNames() { try { - int i = 0; StringBuffer sbStack = new StringBuffer(); - while (true) { - Class caller = Reflection.getCallerClass(i++); - if (caller == null) { - break; - } else { - sbStack.append(caller.getName()) - .append("\n"); - } - } - logger.info("2. Call Stack Class Names:\n" + sbStack.toString()); + int i = 0; + Class caller = Reflection.getCallerClass(i++); + do { + sbStack.append(i + ".") + .append(caller.getName()) + .append("\n"); + caller = Reflection.getCallerClass(i++); + } while (caller != null); + LOGGER.info("2. Call Stack:\n{}", sbStack); } catch (Throwable e) { - logger.error(e.toString()); + LOGGER.error(e.toString()); } } @@ -61,9 +59,9 @@ public class App { StringWriter sw = new StringWriter(); marshallerObj.marshal(book, sw); - logger.info("3. Xml for Book object:\n" + sw); + LOGGER.info("3. Xml for Book object:\n{}", sw); } catch (Throwable e) { - logger.error(e.toString()); + LOGGER.error(e.toString()); } } @@ -71,9 +69,9 @@ public class App { private static void getBase64EncodedString(String inputString) { try { String encodedString = new BASE64Encoder().encode(inputString.getBytes()); - logger.info("4. Base Encoded String: " + encodedString); + LOGGER.info("4. Base Encoded String: {}", encodedString); } catch (Throwable e) { - logger.error(e.toString()); + LOGGER.error(e.toString()); } } } diff --git a/prejpms/src/main/java/com/baeldung/prejpms/Book.java b/prejpms/src/main/java/com/baeldung/prejpms/Book.java index 57b19bf3c1..6780c73738 100644 --- a/prejpms/src/main/java/com/baeldung/prejpms/Book.java +++ b/prejpms/src/main/java/com/baeldung/prejpms/Book.java @@ -10,9 +10,8 @@ public class Book { private String name; public Book() { - } - + public Book(long id, String name) { this.id = id; this.name = name; @@ -35,5 +34,4 @@ public class Book { public Long getId() { return id; } - } From 4878cc2716cc81f5d324bee098516a44a5f74483 Mon Sep 17 00:00:00 2001 From: Anshul Bansal Date: Wed, 3 Apr 2019 15:06:33 +0300 Subject: [PATCH 036/531] BAEL-2800_Copying_a_HashMap_in_Java new module added --- core-java-collections-2/README.md | 6 ++ core-java-collections-2/pom.xml | 78 +++++++++++++++++++ .../baeldung/copyinghashmap/CopyHashMap.java | 0 .../copyinghashmap/CopyHashMapUnitTest.java | 0 .../com/baeldung/copyinghashmap/Employee.java | 0 pom.xml | 2 + 6 files changed, 86 insertions(+) create mode 100644 core-java-collections-2/README.md create mode 100644 core-java-collections-2/pom.xml rename {core-java-collections => core-java-collections-2}/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java (100%) rename {core-java-collections => core-java-collections-2}/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java (100%) rename {core-java-collections => core-java-collections-2}/src/test/java/com/baeldung/copyinghashmap/Employee.java (100%) diff --git a/core-java-collections-2/README.md b/core-java-collections-2/README.md new file mode 100644 index 0000000000..da02928118 --- /dev/null +++ b/core-java-collections-2/README.md @@ -0,0 +1,6 @@ +========= + +## Core Java Collections 2 + +### Relevant Articles: +- Java - Copying a HashMap diff --git a/core-java-collections-2/pom.xml b/core-java-collections-2/pom.xml new file mode 100644 index 0000000000..677e6fd312 --- /dev/null +++ b/core-java-collections-2/pom.xml @@ -0,0 +1,78 @@ + + 4.0.0 + core-java-collections-2 + 0.1.0-SNAPSHOT + core-java-collections-2 + jar + + + com.baeldung + parent-java + 0.0.1-SNAPSHOT + ../parent-java + + + + + org.apache.commons + commons-collections4 + ${commons-collections4.version} + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + org.eclipse.collections + eclipse-collections + ${eclipse.collections.version} + + + org.assertj + assertj-core + ${assertj.version} + test + + + org.junit.platform + junit-platform-runner + ${junit.platform.version} + test + + + org.openjdk.jmh + jmh-core + ${openjdk.jmh.version} + + + org.openjdk.jmh + jmh-generator-annprocess + ${openjdk.jmh.version} + + + org.apache.commons + commons-exec + ${commons-exec.version} + + + org.projectlombok + lombok + ${lombok.version} + provided + + + + + 1.19 + 1.2.0 + 3.8.1 + 4.1 + 4.01 + 1.7.0 + 3.11.1 + 7.1.0 + 1.3 + + diff --git a/core-java-collections/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java b/core-java-collections-2/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java similarity index 100% rename from core-java-collections/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java rename to core-java-collections-2/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java diff --git a/core-java-collections/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java b/core-java-collections-2/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java similarity index 100% rename from core-java-collections/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java rename to core-java-collections-2/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java diff --git a/core-java-collections/src/test/java/com/baeldung/copyinghashmap/Employee.java b/core-java-collections-2/src/test/java/com/baeldung/copyinghashmap/Employee.java similarity index 100% rename from core-java-collections/src/test/java/com/baeldung/copyinghashmap/Employee.java rename to core-java-collections-2/src/test/java/com/baeldung/copyinghashmap/Employee.java diff --git a/pom.xml b/pom.xml index 615fc7b46e..6da150bb61 100644 --- a/pom.xml +++ b/pom.xml @@ -383,6 +383,7 @@ core-java-arrays core-java-collections + core-java-collections-2 core-java-collections-list core-java-concurrency-basic core-java-concurrency-collections @@ -1030,6 +1031,7 @@ core-java-arrays core-java-collections + core-java-collections-2 core-java-collections-list core-java-concurrency-basic core-java-concurrency-collections From cdb37dddda62807df8686e7bb77cfcb0ba8cc4cd Mon Sep 17 00:00:00 2001 From: Anshul Bansal Date: Wed, 3 Apr 2019 17:14:31 +0300 Subject: [PATCH 037/531] BAEL-2800_Copying_a_HashMap_in_Java - methods added --- .../baeldung/copyinghashmap/CopyHashMap.java | 25 ++++++++++-- .../copyinghashmap/CopyHashMapUnitTest.java | 38 ++++++++----------- 2 files changed, 36 insertions(+), 27 deletions(-) diff --git a/core-java-collections-2/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java b/core-java-collections-2/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java index e6935afbe2..a1dc4fe6bb 100644 --- a/core-java-collections-2/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java +++ b/core-java-collections-2/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java @@ -8,8 +8,17 @@ import java.util.stream.Collectors; import org.apache.commons.lang3.SerializationUtils; public class CopyHashMap { + + public static HashMap copyUsingConstructor(HashMap originalMap) { + return new HashMap(originalMap); + } + + public static HashMap copyUsingClone(HashMap originalMap) { + return (HashMap) originalMap.clone(); + } - public static HashMap basicCopy(HashMap originalMap, HashMap copyMap) { + public static HashMap copyUsingPut(HashMap originalMap) { + HashMap copyMap = new HashMap(); Set entries = originalMap.entrySet(); for(Map.Entry mapEntry: entries) { copyMap.put(mapEntry.getKey(), mapEntry.getValue()); @@ -18,8 +27,8 @@ public class CopyHashMap { return copyMap; } - - public static Map copyUsingPutAll(Map originalMap, Map copyMap) { + public static Map copyUsingPutAll(Map originalMap) { + HashMap copyMap = new HashMap(); copyMap.putAll(originalMap); return copyMap; @@ -34,8 +43,16 @@ public class CopyHashMap { return copyMap; } + public static HashMap copyMapAndConvertCmsToInches(HashMap originalMap) { + Set entries = originalMap.entrySet(); + HashMap copyMap = (HashMap) entries + .stream() + .collect(Collectors.toMap(mapEntry -> mapEntry.getKey(), mapEntry -> (int)mapEntry.getValue()/2.54)); + + return copyMap; + } + public static HashMap shallowCopy(HashMap originalMap) { - //return new HashMap(originalMap); return (HashMap) originalMap.clone(); } diff --git a/core-java-collections-2/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java b/core-java-collections-2/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java index 57fccadaef..d49317b3dc 100644 --- a/core-java-collections-2/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java +++ b/core-java-collections-2/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java @@ -12,27 +12,6 @@ import com.google.common.collect.ImmutableMap; public class CopyHashMapUnitTest { - @Test - public void givenHashmap_whenCopy_thenCopyContainsAllMappings() { - - HashMap colorMap = new HashMap<>(); - colorMap.put("1", "Red"); - colorMap.put("2", "Blue"); - colorMap.put("3", "Green"); - - System.out.println("ColorMap content : " + colorMap); - - HashMap colorMapCopy = new HashMap<>(); - colorMapCopy.put("1", "Orange"); - colorMapCopy.put("4", "Black"); - - colorMapCopy = CopyHashMap.basicCopy(colorMap, colorMapCopy); - - System.out.println("ColorMapCopy content : " +colorMapCopy); - - assertEquals(4, colorMapCopy.size()); - } - @Test public void givenHashMap_whenShallowCopy_thenCopyisNotSameAsOriginal() { @@ -80,7 +59,21 @@ public class CopyHashMapUnitTest { assertThat(employeeMapDeepCopy.get("employee1")) .isNotEqualTo(employeeMap.get("employee1")); - } + } + + @Test + public void givenHashMapWithValuesInCms_whenCopy_thenCopyMapShouldHaveValuesInInches() { + + HashMap heightMap = new HashMap<>(); + heightMap.put("emp1", 160); + heightMap.put("emp2", 165); + heightMap.put("emp3", 163); + HashMap heightMapInInches = CopyHashMap.copyMapAndConvertCmsToInches(heightMap); + + assertThat(heightMap).isNotEqualTo(heightMapInInches); + + assertThat(heightMap.get("emp1")/2.54).isEqualTo(heightMapInInches.get("emp1")); + } @Test public void givenImmutableMap_whenCopyUsingGuava_thenCopyShouldNotChange() { @@ -95,6 +88,5 @@ public class CopyHashMapUnitTest { assertThat(heightMapCopy).isSameAs(heightMap); } - } From 3b43bddf04bb0b25c51ffad2645a59c9dc5f8334 Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Thu, 4 Apr 2019 10:12:04 +0400 Subject: [PATCH 038/531] convert final --- .../com/baeldung/convert/ConvertDateTime.java | 35 ++++++++----------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/java-dates/src/main/java/com/baeldung/convert/ConvertDateTime.java b/java-dates/src/main/java/com/baeldung/convert/ConvertDateTime.java index c4d771a7e6..d52dd1b989 100644 --- a/java-dates/src/main/java/com/baeldung/convert/ConvertDateTime.java +++ b/java-dates/src/main/java/com/baeldung/convert/ConvertDateTime.java @@ -1,9 +1,5 @@ package com.baeldung.convert; -import org.joda.time.DateTime; -import org.joda.time.format.DateTimeFormat; -import org.joda.time.format.DateTimeFormatter; - import java.text.ParseException; import java.text.SimpleDateFormat; import java.time.LocalDateTime; @@ -22,35 +18,32 @@ public class ConvertDateTime { calendar(date); } + private static Date simpleDateTimeFormatter() throws ParseException { + SimpleDateFormat sdf = new SimpleDateFormat("dd-M-yyyy hh:mm:ss"); + String dateInString = "22-04-2019 10:20:56"; + Date date = sdf.parse(dateInString); + + System.out.println("Date - Time in milliseconds : " + date.getTime()); + + return date; + } + private static void calendar(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); System.out.println("Calender - Time in milliseconds : " + calendar.getTimeInMillis()); } - private static Date simpleDateTimeFormatter() throws ParseException { - SimpleDateFormat sdf = new SimpleDateFormat("dd-M-yyyy hh:mm:ss"); - String dateInString = "22-01-2015 10:20:56"; - Date date = sdf.parse(dateInString); - - System.out.println(dateInString); - System.out.println("Date - Time in milliseconds : " + date.getTime()); - - return date; - } - private static void joda() { - String s = "00:00:01.2"; - DateTimeFormatter format = DateTimeFormat.forPattern("HH:mm:ss.S"); - DateTime dateTime = format.parseDateTime(s); - System.out.println(dateTime.getMillisOfSecond()); + org.joda.time.DateTime jodaDateTime = new org.joda.time.DateTime(new Date()); + long delta = jodaDateTime.getMillis(); + System.out.println("Joda - Time in milliseconds : " + delta); } private static void java8() { LocalDateTime localDateTime = LocalDateTime.now(); - ZoneId id = ZoneId.systemDefault(); ZonedDateTime zdt = ZonedDateTime.of(localDateTime, id); - System.out.println(zdt.toInstant().toEpochMilli()); + System.out.println("Java 8 - Time in milliseconds : " + zdt.toInstant().toEpochMilli()); } } From c302858a81eff35dd33f61a6c4435ed63df0d294 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Thu, 4 Apr 2019 21:33:45 +0800 Subject: [PATCH 039/531] Update README.md --- core-java-9/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-9/README.md b/core-java-9/README.md index 2477a38c00..9ce419b054 100644 --- a/core-java-9/README.md +++ b/core-java-9/README.md @@ -27,4 +27,4 @@ - [Immutable Set in Java](https://www.baeldung.com/java-immutable-set) - [Multi-Release Jar Files](https://www.baeldung.com/java-multi-release-jar) - [Ahead of Time Compilation (AoT)](https://www.baeldung.com/ahead-of-time-compilation) - +- [Java 9 Process API Improvements](https://www.baeldung.com/java-9-process-api) From 3660bfd8c36fbfb4bdf7fbaad4c69c1e00565092 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Thu, 4 Apr 2019 21:44:38 +0800 Subject: [PATCH 040/531] Update README.md --- core-java-9/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-9/README.md b/core-java-9/README.md index 9ce419b054..41b52be95b 100644 --- a/core-java-9/README.md +++ b/core-java-9/README.md @@ -28,3 +28,4 @@ - [Multi-Release Jar Files](https://www.baeldung.com/java-multi-release-jar) - [Ahead of Time Compilation (AoT)](https://www.baeldung.com/ahead-of-time-compilation) - [Java 9 Process API Improvements](https://www.baeldung.com/java-9-process-api) +- [Guide to java.lang.Process API](https://www.baeldung.com/java-process-api) From 4b9a7f3420aa8300a45d155924cb2af5babb278a Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Thu, 4 Apr 2019 21:51:14 +0800 Subject: [PATCH 041/531] Update README.md --- persistence-modules/hibernate5/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/persistence-modules/hibernate5/README.md b/persistence-modules/hibernate5/README.md index a37720a428..68008bc8fe 100644 --- a/persistence-modules/hibernate5/README.md +++ b/persistence-modules/hibernate5/README.md @@ -32,3 +32,4 @@ - [Common Hibernate Exceptions](https://www.baeldung.com/hibernate-exceptions) - [Hibernate Aggregate Functions](https://www.baeldung.com/hibernate-aggregate-functions) - [Hibernate Query Plan Cache](https://www.baeldung.com/hibernate-query-plan-cache) +- [TransactionRequiredException Error](https://www.baeldung.com/jpa-transaction-required-exception) From 23900480b9f02a7713a61d01bec734527751902b Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 5 Apr 2019 11:01:18 +0800 Subject: [PATCH 042/531] Update README.md --- core-java-lang/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-lang/README.md b/core-java-lang/README.md index eaedc93eed..f8922154a9 100644 --- a/core-java-lang/README.md +++ b/core-java-lang/README.md @@ -42,3 +42,4 @@ - [Attaching Values to Java Enum](https://www.baeldung.com/java-enum-values) - [Variable Scope in Java](https://www.baeldung.com/java-variable-scope) - [Java Classes and Objects](https://www.baeldung.com/java-classes-objects) +- [Comparator and Comparable in Java](https://www.baeldung.com/java-comparator-comparable) From a3aa7058a49c62fa994d3dbd5dd2de699fc8910f Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 5 Apr 2019 11:02:51 +0800 Subject: [PATCH 043/531] Update README.md --- core-java-io/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-io/README.md b/core-java-io/README.md index 05b9165147..1516c54247 100644 --- a/core-java-io/README.md +++ b/core-java-io/README.md @@ -40,3 +40,4 @@ - [How to Write to a CSV File in Java](https://www.baeldung.com/java-csv) - [List Files in a Directory in Java](https://www.baeldung.com/java-list-directory-files) - [Java InputStream to Byte Array and ByteBuffer](https://www.baeldung.com/convert-input-stream-to-array-of-bytes) +- [How to Copy a File with Java](https://www.baeldung.com/java-copy-file) From 698537630f9b2b761cef3df0584cf7a2a6acd883 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 5 Apr 2019 12:44:13 +0800 Subject: [PATCH 044/531] Update README.md --- libraries/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/README.md b/libraries/README.md index 57f22631f1..6a3afd3b40 100644 --- a/libraries/README.md +++ b/libraries/README.md @@ -67,6 +67,7 @@ - [Introduction to Functional Java](https://www.baeldung.com/java-functional-library) - [Intro to Derive4J](https://www.baeldung.com/derive4j) - [A Guide to the Reflections Library](https://www.baeldung.com/reflections-library) +- [A Guide to Google-Http-Client](https://www.baeldung.com/google-http-client) The libraries module contains examples related to small libraries that are relatively easy to use and does not require any separate module of its own. From aacaeb33847a9a450916bf9d26c9954ffa3f75be Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 5 Apr 2019 12:50:34 +0800 Subject: [PATCH 045/531] Update README.md --- spring-rest-shell/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-rest-shell/README.md b/spring-rest-shell/README.md index 901d9a51ee..b250f06a4b 100644 --- a/spring-rest-shell/README.md +++ b/spring-rest-shell/README.md @@ -2,4 +2,4 @@ ### Relevant Articles -- [Spring REST Shell](http://www.baeldung.com/spring-rest-shell) \ No newline at end of file +- [Introduction to Spring REST Shell](http://www.baeldung.com/spring-rest-shell) From 79068d5dc5fbf2e089fa3f592d4fdab0577dced8 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 5 Apr 2019 12:52:31 +0800 Subject: [PATCH 046/531] Update README.md --- testing-modules/junit-5/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing-modules/junit-5/README.md b/testing-modules/junit-5/README.md index d686396a1d..aafdd75e81 100644 --- a/testing-modules/junit-5/README.md +++ b/testing-modules/junit-5/README.md @@ -6,7 +6,7 @@ - [A Guide to JUnit 5 Extensions](http://www.baeldung.com/junit-5-extensions) - [Inject Parameters into JUnit Jupiter Unit Tests](http://www.baeldung.com/junit-5-parameters) - [Mockito and JUnit 5 – Using ExtendWith](http://www.baeldung.com/mockito-junit-5-extension) -- [JUnit 5 – @RunWith](http://www.baeldung.com/junit-5-runwith) +- [JUnit 5 @RunWith](http://www.baeldung.com/junit-5-runwith) - [JUnit 5 @Test Annotation](http://www.baeldung.com/junit-5-test-annotation) - [Assert an Exception is Thrown in JUnit 4 and 5](http://www.baeldung.com/junit-assert-exception) - [@Before vs @BeforeClass vs @BeforeEach vs @BeforeAll](http://www.baeldung.com/junit-before-beforeclass-beforeeach-beforeall) From 40069bd1171b9afa6b375bc8fa265b94a5d8eeda Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 5 Apr 2019 12:58:49 +0800 Subject: [PATCH 047/531] Update README.md --- core-java-concurrency-advanced/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-concurrency-advanced/README.md b/core-java-concurrency-advanced/README.md index f48fd30c73..47137f8045 100644 --- a/core-java-concurrency-advanced/README.md +++ b/core-java-concurrency-advanced/README.md @@ -12,7 +12,7 @@ - [Guide to the Java Phaser](http://www.baeldung.com/java-phaser) - [An Introduction to Atomic Variables in Java](http://www.baeldung.com/java-atomic-variables) - [CyclicBarrier in Java](http://www.baeldung.com/java-cyclic-barrier) -- [Guide to Volatile Keyword in Java](http://www.baeldung.com/java-volatile) +- [Guide to the Volatile Keyword in Java](http://www.baeldung.com/java-volatile) - [Semaphores in Java](http://www.baeldung.com/java-semaphore) - [Daemon Threads in Java](http://www.baeldung.com/java-daemon-thread) - [Priority-based Job Scheduling in Java](http://www.baeldung.com/java-priority-job-schedule) From d1dbec58a61052fe0c403a1cf193701569f5b2e5 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 5 Apr 2019 13:07:25 +0800 Subject: [PATCH 048/531] Update README.md --- core-java-concurrency-basic/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-concurrency-basic/README.md b/core-java-concurrency-basic/README.md index 7d106095e7..406b635785 100644 --- a/core-java-concurrency-basic/README.md +++ b/core-java-concurrency-basic/README.md @@ -7,7 +7,7 @@ - [A Guide to the Java ExecutorService](http://www.baeldung.com/java-executor-service-tutorial) - [Guide to java.util.concurrent.Future](http://www.baeldung.com/java-future) - [Difference Between Wait and Sleep in Java](http://www.baeldung.com/java-wait-and-sleep) -- [Guide to Synchronized Keyword in Java](http://www.baeldung.com/java-synchronized) +- [Guide to the Synchronized Keyword in Java](http://www.baeldung.com/java-synchronized) - [Overview of the java.util.concurrent](http://www.baeldung.com/java-util-concurrent) - [Implementing a Runnable vs Extending a Thread](http://www.baeldung.com/java-runnable-vs-extending-thread) - [How to Kill a Java Thread](http://www.baeldung.com/java-thread-stop) From 9de4b9f8c4ba4e8b5fb60508f89d0d532ed58da6 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 5 Apr 2019 13:09:30 +0800 Subject: [PATCH 049/531] Update README.md --- libraries/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/README.md b/libraries/README.md index 6a3afd3b40..8518684316 100644 --- a/libraries/README.md +++ b/libraries/README.md @@ -6,7 +6,7 @@ - [Introduction to Apache Flink with Java](http://www.baeldung.com/apache-flink) - [Introduction to JSONassert](http://www.baeldung.com/jsonassert) - [Intro to JaVers](http://www.baeldung.com/javers) -- [Intro to Serenity BDD](http://www.baeldung.com/serenity-bdd) +- [Introduction to Serenity BDD](http://www.baeldung.com/serenity-bdd) - [Merging Streams in Java](http://www.baeldung.com/java-merge-streams) - [Serenity BDD and Screenplay](http://www.baeldung.com/serenity-screenplay) - [Introduction to Quartz](http://www.baeldung.com/quartz) From 88481eb3797f91917ed228779d4293258b717635 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 5 Apr 2019 13:11:31 +0800 Subject: [PATCH 050/531] Update README.md --- spring-cloud/spring-cloud-zookeeper/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-cloud/spring-cloud-zookeeper/README.md b/spring-cloud/spring-cloud-zookeeper/README.md index a639833452..a49a448833 100644 --- a/spring-cloud/spring-cloud-zookeeper/README.md +++ b/spring-cloud/spring-cloud-zookeeper/README.md @@ -1,2 +1,2 @@ ### Relevant Articles: -- [An Introduction to Spring Cloud Zookeeper](http://www.baeldung.com/spring-cloud-zookeeper) +- [An Intro to Spring Cloud Zookeeper](http://www.baeldung.com/spring-cloud-zookeeper) From 8ce6c28d521567d0e8afe95a005323edf1accdd8 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 5 Apr 2019 13:19:39 +0800 Subject: [PATCH 051/531] Update README.MD --- spring-boot/README.MD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot/README.MD b/spring-boot/README.MD index 7d270c9c25..994fd1e093 100644 --- a/spring-boot/README.MD +++ b/spring-boot/README.MD @@ -11,7 +11,7 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Using Custom Banners in Spring Boot](http://www.baeldung.com/spring-boot-custom-banners) - [Guide to Internationalization in Spring Boot](http://www.baeldung.com/spring-boot-internationalization) - [Create a Custom FailureAnalyzer with Spring Boot](http://www.baeldung.com/spring-boot-failure-analyzer) -- [Dynamic DTO Validation Config Retrieved from DB](http://www.baeldung.com/spring-dynamic-dto-validation) +- [Dynamic DTO Validation Config Retrieved from the Database](http://www.baeldung.com/spring-dynamic-dto-validation) - [Custom Information in Spring Boot Info Endpoint](http://www.baeldung.com/spring-boot-info-actuator-custom) - [Using @JsonComponent in Spring Boot](http://www.baeldung.com/spring-boot-jsoncomponent) - [Testing in Spring Boot](http://www.baeldung.com/spring-boot-testing) From 9959a79bf150a71a51046be0fa7009322aeadaae Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 5 Apr 2019 13:26:33 +0800 Subject: [PATCH 052/531] Update README.md --- guava-modules/guava-21/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guava-modules/guava-21/README.md b/guava-modules/guava-21/README.md index 68c1ac4a8e..4e897325b6 100644 --- a/guava-modules/guava-21/README.md +++ b/guava-modules/guava-21/README.md @@ -1,4 +1,4 @@ ### Relevant articles: -- [New Stream, Comparator and Collector Functionality in Guava 21](http://www.baeldung.com/guava-21-new) +- [New Stream, Comparator and Collector in Guava 21](http://www.baeldung.com/guava-21-new) - [New in Guava 21 common.util.concurrent](http://www.baeldung.com/guava-21-util-concurrent) - [Zipping Collections in Java](http://www.baeldung.com/java-collections-zip) From f3bdfa5f85c17cc811e12c990a593c0ee25eddec Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 5 Apr 2019 13:46:28 +0800 Subject: [PATCH 053/531] Update README.MD --- spring-boot/README.MD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot/README.MD b/spring-boot/README.MD index 994fd1e093..f947e998d0 100644 --- a/spring-boot/README.MD +++ b/spring-boot/README.MD @@ -6,7 +6,7 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [A Guide to Spring in Eclipse STS](http://www.baeldung.com/eclipse-sts-spring) - [The @ServletComponentScan Annotation in Spring Boot](http://www.baeldung.com/spring-servletcomponentscan) - [Intro to Building an Application with Spring Boot](http://www.baeldung.com/intro-to-spring-boot) -- [How to Register a Servlet in a Java Web Application](http://www.baeldung.com/register-servlet) +- [How to Register a Servlet in a Java](http://www.baeldung.com/register-servlet) - [Guide to Spring WebUtils and ServletRequestUtils](http://www.baeldung.com/spring-webutils-servletrequestutils) - [Using Custom Banners in Spring Boot](http://www.baeldung.com/spring-boot-custom-banners) - [Guide to Internationalization in Spring Boot](http://www.baeldung.com/spring-boot-internationalization) From 9e251afadc5a877be48b0c3f7ae00e0ae416492d Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 5 Apr 2019 13:47:36 +0800 Subject: [PATCH 054/531] Update README.md --- spring-mvc-java/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-mvc-java/README.md b/spring-mvc-java/README.md index 497b0f4c1f..a7e0798593 100644 --- a/spring-mvc-java/README.md +++ b/spring-mvc-java/README.md @@ -19,7 +19,7 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Introduction to HtmlUnit](http://www.baeldung.com/htmlunit) - [Spring @RequestMapping New Shortcut Annotations](http://www.baeldung.com/spring-new-requestmapping-shortcuts) - [Guide to Spring Handler Mappings](http://www.baeldung.com/spring-handler-mappings) -- [Uploading and Displaying Excel Files with Spring MVC](http://www.baeldung.com/spring-mvc-excel-files) +- [Upload and Display Excel Files with Spring MVC](http://www.baeldung.com/spring-mvc-excel-files) - [Spring MVC Custom Validation](http://www.baeldung.com/spring-mvc-custom-validator) - [web.xml vs Initializer with Spring](http://www.baeldung.com/spring-xml-vs-java-config) - [The HttpMediaTypeNotAcceptableException in Spring MVC](http://www.baeldung.com/spring-httpmediatypenotacceptable) From 4f29f3daea855b11466e53b43eb88a991cf94196 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 5 Apr 2019 13:51:20 +0800 Subject: [PATCH 055/531] Update README.md --- couchbase/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/couchbase/README.md b/couchbase/README.md index 9b76609593..7a99ce4299 100644 --- a/couchbase/README.md +++ b/couchbase/README.md @@ -3,7 +3,7 @@ ### Relevant Articles: - [Introduction to Couchbase SDK for Java](http://www.baeldung.com/java-couchbase-sdk) - [Using Couchbase in a Spring Application](http://www.baeldung.com/couchbase-sdk-spring) -- [Asynchronous Batch Opereations in Couchbase](http://www.baeldung.com/async-batch-operations-in-couchbase) +- [Asynchronous Batch Operations in Couchbase](http://www.baeldung.com/async-batch-operations-in-couchbase) - [Querying Couchbase with MapReduce Views](http://www.baeldung.com/couchbase-query-mapreduce-view) - [Querying Couchbase with N1QL](http://www.baeldung.com/n1ql-couchbase) From 0c2315a6ee3a0bddc30a4a1a6aafb41825d4c8ad Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 5 Apr 2019 13:53:07 +0800 Subject: [PATCH 056/531] Update README.md --- core-java-8/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-8/README.md b/core-java-8/README.md index 99182da390..d11d2debce 100644 --- a/core-java-8/README.md +++ b/core-java-8/README.md @@ -3,7 +3,7 @@ ## Core Java 8 Cookbooks and Examples ### Relevant Articles: -- [Java 8 Collectors](http://www.baeldung.com/java-8-collectors) +- [Guide to Java 8’s Collectors](http://www.baeldung.com/java-8-collectors) - [Functional Interfaces in Java 8](http://www.baeldung.com/java-8-functional-interfaces) - [Java 8 – Powerful Comparison with Lambdas](http://www.baeldung.com/java-8-sort-lambda) - [New Features in Java 8](http://www.baeldung.com/java-8-new-features) From 95f217d1a7123520baedcc3c8b12c8dca183823e Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 5 Apr 2019 13:55:54 +0800 Subject: [PATCH 057/531] Update README.md --- persistence-modules/spring-data-couchbase-2/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/persistence-modules/spring-data-couchbase-2/README.md b/persistence-modules/spring-data-couchbase-2/README.md index 2b6a1faddf..3145fc653a 100644 --- a/persistence-modules/spring-data-couchbase-2/README.md +++ b/persistence-modules/spring-data-couchbase-2/README.md @@ -2,7 +2,7 @@ ### Relevant Articles: - [Intro to Spring Data Couchbase](http://www.baeldung.com/spring-data-couchbase) -- [Entity Validation, Query Consistency, and Optimistic Locking in Spring Data Couchbase](http://www.baeldung.com/entity-validation-locking-and-query-consistency-in-spring-data-couchbase) +- [Entity Validation, Optimistic Locking, and Query Consistency in Spring Data Couchbase](http://www.baeldung.com/entity-validation-locking-and-query-consistency-in-spring-data-couchbase) - [Multiple Buckets and Spatial View Queries in Spring Data Couchbase](http://www.baeldung.com/spring-data-couchbase-buckets-and-spatial-view-queries) ### Overview From 5830fc4a5eb6eec3ebb2c34e6a0384ca53aa4677 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 5 Apr 2019 13:59:29 +0800 Subject: [PATCH 058/531] Update README.md --- spring-security-mvc-persisted-remember-me/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-security-mvc-persisted-remember-me/README.md b/spring-security-mvc-persisted-remember-me/README.md index e505537be1..db2ae890f9 100644 --- a/spring-security-mvc-persisted-remember-me/README.md +++ b/spring-security-mvc-persisted-remember-me/README.md @@ -6,7 +6,7 @@ The "Learn Spring Security" Classes: http://github.learnspringsecurity.com ### Relevant Articles: -- [Spring Security Persisted Remember Me](http://www.baeldung.com/spring-security-persistent-remember-me) +- [Spring Security – Persistent Remember Me](http://www.baeldung.com/spring-security-persistent-remember-me) ### Build the Project ``` From 1dc994fd44665e6d753990f116485faf64f90f7f Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 5 Apr 2019 14:00:27 +0800 Subject: [PATCH 059/531] Update README.md --- httpclient/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpclient/README.md b/httpclient/README.md index 87fb38706d..c5956068c6 100644 --- a/httpclient/README.md +++ b/httpclient/README.md @@ -9,7 +9,7 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [HttpClient 4 – Send Custom Cookie](http://www.baeldung.com/httpclient-4-cookies) - [HttpClient 4 – Get the Status Code](http://www.baeldung.com/httpclient-status-code) -- [HttpClient 4 – Cancel / Abort Request](http://www.baeldung.com/httpclient-cancel-request) +- [HttpClient 4 – Cancel Request](http://www.baeldung.com/httpclient-cancel-request) - [HttpClient 4 Cookbook](http://www.baeldung.com/httpclient4) - [Unshorten URLs with HttpClient](http://www.baeldung.com/unshorten-url-httpclient) - [HttpClient 4 – Follow Redirects for POST](http://www.baeldung.com/httpclient-redirect-on-http-post) From 4b5bbbb62e3e08d7a2bef0e3d0b47632bf0c1142 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 5 Apr 2019 14:02:54 +0800 Subject: [PATCH 060/531] Update README.md --- core-java-9/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-9/README.md b/core-java-9/README.md index 41b52be95b..993beae0c8 100644 --- a/core-java-9/README.md +++ b/core-java-9/README.md @@ -14,7 +14,7 @@ - [Java 9 Optional API Additions](http://www.baeldung.com/java-9-optional) - [Java 9 Reactive Streams](http://www.baeldung.com/java-9-reactive-streams) - [Java 9 java.util.Objects Additions](http://www.baeldung.com/java-9-objects-new) -- [Java 9 Variable Handles Demistyfied](http://www.baeldung.com/java-variable-handles) +- [Java 9 Variable Handles Demystified](http://www.baeldung.com/java-variable-handles) - [Exploring the New HTTP Client in Java 9 and 11](http://www.baeldung.com/java-9-http-client) - [Method Handles in Java](http://www.baeldung.com/java-method-handles) - [Introduction to Chronicle Queue](http://www.baeldung.com/java-chronicle-queue) From b3a0966da9b6ad3cbe25976a168eac47a88fa990 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 5 Apr 2019 14:04:00 +0800 Subject: [PATCH 061/531] Update README.md --- core-java-concurrency-advanced/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-concurrency-advanced/README.md b/core-java-concurrency-advanced/README.md index 47137f8045..8e99858693 100644 --- a/core-java-concurrency-advanced/README.md +++ b/core-java-concurrency-advanced/README.md @@ -20,6 +20,6 @@ - [Print Even and Odd Numbers Using 2 Threads](https://www.baeldung.com/java-even-odd-numbers-with-2-threads) - [Java CyclicBarrier vs CountDownLatch](https://www.baeldung.com/java-cyclicbarrier-countdownlatch) - [Guide to the Fork/Join Framework in Java](http://www.baeldung.com/java-fork-join) -- [A Guide to ThreadLocalRandom in Java](http://www.baeldung.com/java-thread-local-random) +- [Guide to ThreadLocalRandom in Java](http://www.baeldung.com/java-thread-local-random) - [The Thread.join() Method in Java](http://www.baeldung.com/java-thread-join) - [Passing Parameters to Java Threads](https://www.baeldung.com/java-thread-parameters) From b53ac8b5aa98bf2eaec0607624142cb79eef931d Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 5 Apr 2019 14:07:35 +0800 Subject: [PATCH 062/531] Update README.md --- logging-modules/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/logging-modules/README.md b/logging-modules/README.md index 0f12d7eb22..17405847b1 100644 --- a/logging-modules/README.md +++ b/logging-modules/README.md @@ -4,5 +4,4 @@ ### Relevant Articles: - [Creating a Custom Logback Appender](http://www.baeldung.com/custom-logback-appender) -- [Get Log Output in JSON Format](http://www.baeldung.com/java-log-json-output) - [A Guide To Logback](http://www.baeldung.com/logback) From 03a291fbeb96d67b15c07431bb6ad53a945d154d Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 5 Apr 2019 14:08:15 +0800 Subject: [PATCH 063/531] Update README.md --- logging-modules/log4j2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/logging-modules/log4j2/README.md b/logging-modules/log4j2/README.md index 2cf6f9768f..f365d67ea8 100644 --- a/logging-modules/log4j2/README.md +++ b/logging-modules/log4j2/README.md @@ -4,3 +4,4 @@ - [Log4j 2 and Lambda Expressions](http://www.baeldung.com/log4j-2-lazy-logging) - [Programmatic Configuration with Log4j 2](http://www.baeldung.com/log4j2-programmatic-config) - [Creating a Custom Log4j2 Appender](https://www.baeldung.com/log4j2-custom-appender) +- [Get Log Output in JSON Format](http://www.baeldung.com/java-log-json-output) From 2b71caf114417473f6bae08bd4611cac07e0424f Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 5 Apr 2019 14:12:39 +0800 Subject: [PATCH 064/531] Update README.md --- libraries-server/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries-server/README.md b/libraries-server/README.md index 75c12fd61a..4baf6c4c1f 100644 --- a/libraries-server/README.md +++ b/libraries-server/README.md @@ -3,7 +3,7 @@ - [Embedded Jetty Server in Java](http://www.baeldung.com/jetty-embedded) - [Introduction to Netty](http://www.baeldung.com/netty) - [Exceptions in Netty](http://www.baeldung.com/netty-exception-handling) -- [Programatically Create, Configure, and Run a Tomcat Server](http://www.baeldung.com/tomcat-programmatic-setup) +- [Programmatically Create, Configure, and Run a Tomcat Server](http://www.baeldung.com/tomcat-programmatic-setup) - [Creating and Configuring Jetty 9 Server in Java](http://www.baeldung.com/jetty-java-programmatic) - [Testing Netty with EmbeddedChannel](http://www.baeldung.com/testing-netty-embedded-channel) - [MQTT Client in Java](https://www.baeldung.com/java-mqtt-client) From 9ae6eccf8ce05e3a1fdf868ca1fddce0f7c2ff28 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 5 Apr 2019 14:14:51 +0800 Subject: [PATCH 065/531] Update README.md --- spring-batch/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-batch/README.md b/spring-batch/README.md index 737e7e13f5..ddd830cd47 100644 --- a/spring-batch/README.md +++ b/spring-batch/README.md @@ -6,5 +6,5 @@ ### Relevant Articles: - [Introduction to Spring Batch](http://www.baeldung.com/introduction-to-spring-batch) - [Spring Batch using Partitioner](http://www.baeldung.com/spring-batch-partitioner) -- [Spring Batch Tasklets vs Chunks Approach](http://www.baeldung.com/spring-batch-tasklet-chunk) +- [Spring Batch – Tasklets vs Chunks](http://www.baeldung.com/spring-batch-tasklet-chunk) - [How to Trigger and Stop a Scheduled Spring Batch Job](http://www.baeldung.com/spring-batch-start-stop-job) From f2c1a76081e8c4aa74f258a03ef7a6a2a7bdcc4d Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 5 Apr 2019 14:19:59 +0800 Subject: [PATCH 066/531] Update README.md --- testing-modules/testing/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing-modules/testing/README.md b/testing-modules/testing/README.md index e96b26ab41..56a6212d29 100644 --- a/testing-modules/testing/README.md +++ b/testing-modules/testing/README.md @@ -18,6 +18,6 @@ - [Custom JUnit 4 Test Runners](http://www.baeldung.com/junit-4-custom-runners) - [Guide to JSpec](http://www.baeldung.com/jspec) - [Custom Assertions with AssertJ](http://www.baeldung.com/assertj-custom-assertion) -- [Using Conditions with AssertJ](http://www.baeldung.com/assertj-conditions) +- [Using Conditions with AssertJ Assertions](http://www.baeldung.com/assertj-conditions) - [Guide to JavaFaker](https://www.baeldung.com/java-faker) - [Running JUnit Tests Programmatically, from a Java Application](https://www.baeldung.com/junit-tests-run-programmatically-from-java) From f90fc505ef9d534bc967ab223613fb2f29fce2ce Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 5 Apr 2019 14:23:48 +0800 Subject: [PATCH 067/531] Update README.md --- persistence-modules/spring-data-jpa/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/persistence-modules/spring-data-jpa/README.md b/persistence-modules/spring-data-jpa/README.md index 48c3180262..4e390c2faf 100644 --- a/persistence-modules/spring-data-jpa/README.md +++ b/persistence-modules/spring-data-jpa/README.md @@ -5,7 +5,7 @@ ### Relevant Articles: - [Spring JPA – Multiple Databases](http://www.baeldung.com/spring-data-jpa-multiple-databases) - [Spring Data JPA – Adding a Method in All Repositories](http://www.baeldung.com/spring-data-jpa-method-in-all-repositories) -- [Advanced Tagging Implementation with JPA](http://www.baeldung.com/jpa-tagging-advanced) +- [An Advanced Tagging Implementation with JPA](http://www.baeldung.com/jpa-tagging-advanced) - [Spring Data JPA @Query](http://www.baeldung.com/spring-data-jpa-query) - [Spring Data Annotations](http://www.baeldung.com/spring-data-annotations) - [Spring Data Java 8 Support](http://www.baeldung.com/spring-data-java-8) From 9ec0744569a034588a740f3234b0b1f90b2f66a9 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 5 Apr 2019 14:30:22 +0800 Subject: [PATCH 068/531] Update README.MD --- spring-boot/README.MD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot/README.MD b/spring-boot/README.MD index f947e998d0..3b92063d83 100644 --- a/spring-boot/README.MD +++ b/spring-boot/README.MD @@ -21,7 +21,7 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Getting Started with GraphQL and Spring Boot](http://www.baeldung.com/spring-graphql) - [Guide to Spring Type Conversions](http://www.baeldung.com/spring-type-conversions) - [An Introduction to Kong](http://www.baeldung.com/kong) -- [Spring Boot Customize Whitelabel Error Page](http://www.baeldung.com/spring-boot-custom-error-page) +- [Spring Boot: Customize Whitelabel Error Page](http://www.baeldung.com/spring-boot-custom-error-page) - [Spring Boot: Configuring a Main Class](http://www.baeldung.com/spring-boot-main-class) - [A Quick Intro to the SpringBootServletInitializer](http://www.baeldung.com/spring-boot-servlet-initializer) - [How to Define a Spring Boot Filter?](http://www.baeldung.com/spring-boot-add-filter) From 008de5e2c8f76ddd2f9296ae6dd2b0a2bbcb5508 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 5 Apr 2019 14:33:58 +0800 Subject: [PATCH 069/531] Update README.md --- core-java/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java/README.md b/core-java/README.md index cbc9251b0b..c2d1b4a06b 100644 --- a/core-java/README.md +++ b/core-java/README.md @@ -29,7 +29,7 @@ - [What is the serialVersionUID?](http://www.baeldung.com/java-serial-version-uid) - [A Guide to the ResourceBundle](http://www.baeldung.com/java-resourcebundle) - [Class Loaders in Java](http://www.baeldung.com/java-classloaders) -- [Guide to Java Clock Class](http://www.baeldung.com/java-clock) +- [Guide to the Java Clock Class](http://www.baeldung.com/java-clock) - [Importance of Main Manifest Attribute in a Self-Executing JAR](http://www.baeldung.com/java-jar-executable-manifest-main-class) - [Java Global Exception Handler](http://www.baeldung.com/java-global-exception-handler) - [How to Get the Size of an Object in Java](http://www.baeldung.com/java-size-of-object) From a2839c1514a0b0da601ca46f64c3d901b30a6351 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 5 Apr 2019 14:35:12 +0800 Subject: [PATCH 070/531] Update README.md --- azure/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure/README.md b/azure/README.md index c60186e1ce..ae8c443660 100644 --- a/azure/README.md +++ b/azure/README.md @@ -1,4 +1,4 @@ ### Relevant Articles: -- [Deploy Spring Boot App to Azure](http://www.baeldung.com/spring-boot-azure) +- [Deploy a Spring Boot App to Azure](http://www.baeldung.com/spring-boot-azure) From 2713a327ee93aab454dc2b58678a655c93225f1e Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 5 Apr 2019 14:36:56 +0800 Subject: [PATCH 071/531] Update README.md --- testing-modules/testing/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing-modules/testing/README.md b/testing-modules/testing/README.md index 56a6212d29..4a7829e867 100644 --- a/testing-modules/testing/README.md +++ b/testing-modules/testing/README.md @@ -19,5 +19,5 @@ - [Guide to JSpec](http://www.baeldung.com/jspec) - [Custom Assertions with AssertJ](http://www.baeldung.com/assertj-custom-assertion) - [Using Conditions with AssertJ Assertions](http://www.baeldung.com/assertj-conditions) -- [Guide to JavaFaker](https://www.baeldung.com/java-faker) +- [A Guide to JavaFaker](https://www.baeldung.com/java-faker) - [Running JUnit Tests Programmatically, from a Java Application](https://www.baeldung.com/junit-tests-run-programmatically-from-java) From 288e67d5737742245e0b559d0ef7939101fe1d3c Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 5 Apr 2019 14:38:32 +0800 Subject: [PATCH 072/531] Update README.md --- persistence-modules/java-jpa/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/persistence-modules/java-jpa/README.md b/persistence-modules/java-jpa/README.md index 2424999fb3..336dd4f43f 100644 --- a/persistence-modules/java-jpa/README.md +++ b/persistence-modules/java-jpa/README.md @@ -2,7 +2,7 @@ - [A Guide to SqlResultSetMapping](http://www.baeldung.com/jpa-sql-resultset-mapping) - [A Guide to Stored Procedures with JPA](http://www.baeldung.com/jpa-stored-procedures) -- [Fixing the JPA error “java.lang.String cannot be cast to Ljava.lang.String;â€](https://www.baeldung.com/jpa-error-java-lang-string-cannot-be-cast) +- [Fixing the JPA error “java.lang.String cannot be cast to "java.lang.String;â€](https://www.baeldung.com/jpa-error-java-lang-string-cannot-be-cast) - [JPA Entity Graph](https://www.baeldung.com/jpa-entity-graph) - [JPA 2.2 Support for Java 8 Date/Time Types](https://www.baeldung.com/jpa-java-time) - [Converting Between LocalDate and SQL Date](https://www.baeldung.com/java-convert-localdate-sql-date) From 2b25465e5c0606c9575f2bca5d0459a9b7af37b1 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 5 Apr 2019 14:40:00 +0800 Subject: [PATCH 073/531] Update README.md --- core-java-concurrency-basic/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-concurrency-basic/README.md b/core-java-concurrency-basic/README.md index 406b635785..f33ae08571 100644 --- a/core-java-concurrency-basic/README.md +++ b/core-java-concurrency-basic/README.md @@ -15,5 +15,5 @@ - [wait and notify() Methods in Java](http://www.baeldung.com/java-wait-notify) - [Life Cycle of a Thread in Java](http://www.baeldung.com/java-thread-lifecycle) - [Runnable vs. Callable in Java](http://www.baeldung.com/java-runnable-callable) -- [What is Thread-Safety and How to Achieve it](https://www.baeldung.com/java-thread-safety) +- [What is Thread-Safety and How to Achieve it?](https://www.baeldung.com/java-thread-safety) - [How to Start a Thread in Java](https://www.baeldung.com/java-start-thread) From e20526f9b4144902b5a45cb9dc2f646d1c1805a7 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 5 Apr 2019 14:48:29 +0800 Subject: [PATCH 074/531] Update README.md --- patterns/principles/solid/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patterns/principles/solid/README.md b/patterns/principles/solid/README.md index e2d72ecd28..ddd2f78b7e 100644 --- a/patterns/principles/solid/README.md +++ b/patterns/principles/solid/README.md @@ -1,5 +1,5 @@ ### Relevant Articles: -- [A Guide to Solid Principles](https://www.baeldung.com/solid-principles) +- [A Solid Guide to Solid Principles](https://www.baeldung.com/solid-principles) From 0fa205e1e72db7c1c8d4b2d5d90b819ebe56678b Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 5 Apr 2019 14:51:29 +0800 Subject: [PATCH 075/531] Update README.md --- spring-boot-data/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-data/README.md b/spring-boot-data/README.md index 21f7303c48..d93b8c3e93 100644 --- a/spring-boot-data/README.md +++ b/spring-boot-data/README.md @@ -1,2 +1,2 @@ ### Relevant Articles: -- [Formatting JSON Dates in Spring ](https://www.baeldung.com/spring-boot-formatting-json-dates) \ No newline at end of file +- [Formatting JSON Dates in Spring Boot](https://www.baeldung.com/spring-boot-formatting-json-dates) From 0f9f18f72dd5f068e6b0bb782dfb179f2846cca4 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 5 Apr 2019 14:53:40 +0800 Subject: [PATCH 076/531] Update README.md --- gson/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gson/README.md b/gson/README.md index fec0506488..268116a2ac 100644 --- a/gson/README.md +++ b/gson/README.md @@ -11,6 +11,6 @@ - [Convert JSON to a Map Using Gson](https://www.baeldung.com/gson-json-to-map) - [Working with Primitive Values in Gson](https://www.baeldung.com/java-gson-primitives) - [Convert String to JsonObject with Gson](https://www.baeldung.com/gson-string-to-jsonobject) -- [Mapping Multiple JSON Fields to One Java Field](https://www.baeldung.com/json-multiple-fields-single-java-field) +- [Mapping Multiple JSON Fields to a Single Java Field](https://www.baeldung.com/json-multiple-fields-single-java-field) - [Serializing and Deserializing a List with Gson](https://www.baeldung.com/gson-list) From 2f8c8569121e81cf20f6891acfb266fae267afe2 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 5 Apr 2019 14:54:32 +0800 Subject: [PATCH 077/531] Update README.md --- tensorflow-java/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow-java/README.md b/tensorflow-java/README.md index aa9e9e56b9..f826375ac1 100644 --- a/tensorflow-java/README.md +++ b/tensorflow-java/README.md @@ -1,3 +1,3 @@ ## Relevant articles: -- [TensorFlow for Java](https://www.baeldung.com/tensorflow-java) +- [Introduction to Tensorflow for Java](https://www.baeldung.com/tensorflow-java) From 8455bfc1d0536647cf179fbabb09bb14e1f6e130 Mon Sep 17 00:00:00 2001 From: Anshul Bansal Date: Fri, 5 Apr 2019 10:48:46 +0300 Subject: [PATCH 078/531] BAEL-2800_Copying_a_HashMap_in_Java - space problem fix --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6da150bb61..1f3901111d 100644 --- a/pom.xml +++ b/pom.xml @@ -1031,7 +1031,7 @@ core-java-arrays core-java-collections - core-java-collections-2 + core-java-collections-2 core-java-collections-list core-java-concurrency-basic core-java-concurrency-collections From b17c1c720f9d719c8877f04402b32eeeb7e8dd9b Mon Sep 17 00:00:00 2001 From: Anshul Bansal Date: Fri, 5 Apr 2019 12:53:14 +0300 Subject: [PATCH 079/531] BAEL-2800_Copying_a_HashMap_in_Java - code cleanup --- .../baeldung/copyinghashmap/CopyHashMap.java | 4 +- .../copyinghashmap/CopyHashMapUnitTest.java | 57 +++++++++---------- .../com/baeldung/copyinghashmap/Employee.java | 26 +++------ 3 files changed, 38 insertions(+), 49 deletions(-) diff --git a/core-java-collections-2/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java b/core-java-collections-2/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java index a1dc4fe6bb..11ead4ee38 100644 --- a/core-java-collections-2/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java +++ b/core-java-collections-2/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java @@ -43,11 +43,11 @@ public class CopyHashMap { return copyMap; } - public static HashMap copyMapAndConvertCmsToInches(HashMap originalMap) { + public static HashMap copyMapAndDivideValuesBy2(HashMap originalMap) { Set entries = originalMap.entrySet(); HashMap copyMap = (HashMap) entries .stream() - .collect(Collectors.toMap(mapEntry -> mapEntry.getKey(), mapEntry -> (int)mapEntry.getValue()/2.54)); + .collect(Collectors.toMap(mapEntry -> mapEntry.getKey(), mapEntry -> (int)mapEntry.getValue()/2)); return copyMap; } diff --git a/core-java-collections-2/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java b/core-java-collections-2/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java index d49317b3dc..91848a86a9 100644 --- a/core-java-collections-2/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java +++ b/core-java-collections-2/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java @@ -15,64 +15,63 @@ public class CopyHashMapUnitTest { @Test public void givenHashMap_whenShallowCopy_thenCopyisNotSameAsOriginal() { - HashMap employeeMap = new HashMap<>(); - Employee emp1 = new Employee("John", "Smith"); - Employee emp2 = new Employee("Norman", "Lewis"); - employeeMap.put("employee1",emp1); - employeeMap.put("employee2",emp2); + HashMap map = new HashMap<>(); + Employee emp1 = new Employee("John"); + Employee emp2 = new Employee("Norman"); + map.put("emp1",emp1); + map.put("emp2",emp2); - HashMap employeeMapShallowCopy = CopyHashMap.shallowCopy(employeeMap); + HashMap shallowCopy = CopyHashMap.shallowCopy(map); - assertThat(employeeMapShallowCopy).isNotSameAs(employeeMap); + assertThat(shallowCopy).isNotSameAs(map); } @Test public void givenHashMap_whenShallowCopyModifyingOriginalObject_thenCopyShouldChange() { - HashMap employeeMap = new HashMap<>(); - Employee emp1 = new Employee("John", "Smith"); - Employee emp2 = new Employee("Norman", "Lewis"); - employeeMap.put("employee1",emp1); - employeeMap.put("employee2",emp2); - HashMap employeeMapShallowCopy = CopyHashMap.shallowCopy(employeeMap); + HashMap map = new HashMap<>(); + Employee emp1 = new Employee("John"); + Employee emp2 = new Employee("Norman"); + map.put("emp1",emp1); + map.put("emp2",emp2); - emp1.setFirstName("Johny"); + HashMap shallowCopy = CopyHashMap.shallowCopy(map); - assertThat(employeeMapShallowCopy.get("employee1")) - .isEqualTo(employeeMap.get("employee1")); + emp1.setName("Johny"); + + assertThat(shallowCopy.get("emp1")).isEqualTo(map.get("emp1")); } @Test public void givenHashMap_whenDeepCopyModifyingOriginalObject_thenCopyShouldNotChange() { - HashMap employeeMap = new HashMap<>(); - Employee emp1 = new Employee("John", "Smith"); - Employee emp2 = new Employee("Norman", "Lewis"); - employeeMap.put("employee1",emp1); - employeeMap.put("employee2",emp2); - HashMap employeeMapDeepCopy = CopyHashMap.deepCopy(employeeMap); + HashMap map = new HashMap<>(); + Employee emp1 = new Employee("John"); + Employee emp2 = new Employee("Norman"); + map.put("emp1",emp1); + map.put("emp2",emp2); + HashMap deepCopy = CopyHashMap.deepCopy(map); - emp1.setFirstName("Johny"); + emp1.setName("Johny"); - assertThat(employeeMapDeepCopy.get("employee1")) - .isNotEqualTo(employeeMap.get("employee1")); + assertThat(deepCopy.get("emp1")).isNotEqualTo(map.get("emp1")); } @Test - public void givenHashMapWithValuesInCms_whenCopy_thenCopyMapShouldHaveValuesInInches() { + public void givenHashMap_whenCopy_thenCopyMapShouldHaveValuesDivideBy2() { HashMap heightMap = new HashMap<>(); heightMap.put("emp1", 160); heightMap.put("emp2", 165); heightMap.put("emp3", 163); - HashMap heightMapInInches = CopyHashMap.copyMapAndConvertCmsToInches(heightMap); + HashMap heightMapCopy = CopyHashMap.copyMapAndDivideValuesBy2(heightMap); - assertThat(heightMap).isNotEqualTo(heightMapInInches); + assertThat(heightMap).isNotEqualTo(heightMapCopy); - assertThat(heightMap.get("emp1")/2.54).isEqualTo(heightMapInInches.get("emp1")); + assertThat(heightMap.get("emp1")/2).isEqualTo(heightMapCopy.get("emp1")); } @Test diff --git a/core-java-collections-2/src/test/java/com/baeldung/copyinghashmap/Employee.java b/core-java-collections-2/src/test/java/com/baeldung/copyinghashmap/Employee.java index 9ec4327b5f..b47fdc768e 100644 --- a/core-java-collections-2/src/test/java/com/baeldung/copyinghashmap/Employee.java +++ b/core-java-collections-2/src/test/java/com/baeldung/copyinghashmap/Employee.java @@ -4,33 +4,23 @@ import java.io.Serializable; public class Employee implements Serializable{ - private String firstName; - private String lastName; + private String name; - public Employee(String firstName, String lastName) { + public Employee(String name) { super(); - this.firstName = firstName; - this.lastName = lastName; + this.name = name; } - public String getFirstName() { - return firstName; + public String getName() { + return name; } - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; + public void setName(String name) { + this.name = name; } @Override public String toString() { - return this.firstName + " " + this.lastName; + return this.name; } } From 96903671b60c180c519cee18e53f73a932c326b3 Mon Sep 17 00:00:00 2001 From: Anshul Bansal Date: Sat, 6 Apr 2019 07:47:46 +0300 Subject: [PATCH 080/531] BAEL-2800_Copying_a_HashMap_in_Java --- .../copyinghashmap/CopyHashMapUnitTest.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/core-java-collections-2/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java b/core-java-collections-2/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java index 91848a86a9..ce41e9d810 100644 --- a/core-java-collections-2/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java +++ b/core-java-collections-2/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java @@ -76,15 +76,16 @@ public class CopyHashMapUnitTest { @Test public void givenImmutableMap_whenCopyUsingGuava_thenCopyShouldNotChange() { + Employee emp1 = new Employee("John"); + Employee emp2 = new Employee("Norman"); - Map heightMap = ImmutableMap. builder() - .put("emp1", 160) - .put("emp2", 165) - .put("emp3", 163) + Map map = ImmutableMap. builder() + .put("emp1",emp1) + .put("emp2",emp2) .build(); - Map heightMapCopy = ImmutableMap.copyOf(heightMap); + Map mapCopy = ImmutableMap.copyOf(map); - assertThat(heightMapCopy).isSameAs(heightMap); + assertThat(mapCopy).isSameAs(map); } From 68ffec2c2cea5dc021003e7ae95b4f6138114020 Mon Sep 17 00:00:00 2001 From: Anshul Bansal Date: Sat, 6 Apr 2019 07:49:57 +0300 Subject: [PATCH 081/531] BAEL-2800_Copying_a_HashMap_in_Java --- .../com/baeldung/copyinghashmap/CopyHashMap.java | 9 --------- .../copyinghashmap/CopyHashMapUnitTest.java | 16 +--------------- 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/core-java-collections-2/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java b/core-java-collections-2/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java index 11ead4ee38..e673335f62 100644 --- a/core-java-collections-2/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java +++ b/core-java-collections-2/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java @@ -43,15 +43,6 @@ public class CopyHashMap { return copyMap; } - public static HashMap copyMapAndDivideValuesBy2(HashMap originalMap) { - Set entries = originalMap.entrySet(); - HashMap copyMap = (HashMap) entries - .stream() - .collect(Collectors.toMap(mapEntry -> mapEntry.getKey(), mapEntry -> (int)mapEntry.getValue()/2)); - - return copyMap; - } - public static HashMap shallowCopy(HashMap originalMap) { return (HashMap) originalMap.clone(); } diff --git a/core-java-collections-2/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java b/core-java-collections-2/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java index ce41e9d810..f0434f9bfe 100644 --- a/core-java-collections-2/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java +++ b/core-java-collections-2/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java @@ -58,21 +58,7 @@ public class CopyHashMapUnitTest { assertThat(deepCopy.get("emp1")).isNotEqualTo(map.get("emp1")); - } - - @Test - public void givenHashMap_whenCopy_thenCopyMapShouldHaveValuesDivideBy2() { - - HashMap heightMap = new HashMap<>(); - heightMap.put("emp1", 160); - heightMap.put("emp2", 165); - heightMap.put("emp3", 163); - HashMap heightMapCopy = CopyHashMap.copyMapAndDivideValuesBy2(heightMap); - - assertThat(heightMap).isNotEqualTo(heightMapCopy); - - assertThat(heightMap.get("emp1")/2).isEqualTo(heightMapCopy.get("emp1")); - } + } @Test public void givenImmutableMap_whenCopyUsingGuava_thenCopyShouldNotChange() { From 8b345126ddf1e379c21f200199376265f4041994 Mon Sep 17 00:00:00 2001 From: Alfonso Lentini Date: Sat, 6 Apr 2019 12:50:10 +0200 Subject: [PATCH 082/531] =?UTF-8?q?=C3=82Google=20Tink=20implementation=20?= =?UTF-8?q?examples?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libraries-security/pom.xml | 7 ++ .../java/com/baeldung/tink/TinkUnitTest.java | 101 ++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 libraries-security/src/test/java/com/baeldung/tink/TinkUnitTest.java diff --git a/libraries-security/pom.xml b/libraries-security/pom.xml index 9f125361ba..17d57fe203 100644 --- a/libraries-security/pom.xml +++ b/libraries-security/pom.xml @@ -32,6 +32,12 @@ ${scribejava.version} + + com.google.crypto.tink + tink + ${tink.version} + + junit junit @@ -55,6 +61,7 @@ 5.6.0 2.3.3.RELEASE 1.3.1 + 1.2.2 1.2.2 diff --git a/libraries-security/src/test/java/com/baeldung/tink/TinkUnitTest.java b/libraries-security/src/test/java/com/baeldung/tink/TinkUnitTest.java new file mode 100644 index 0000000000..b98c698016 --- /dev/null +++ b/libraries-security/src/test/java/com/baeldung/tink/TinkUnitTest.java @@ -0,0 +1,101 @@ +package com.baeldung.tink; + +import com.google.crypto.tink.*; +import com.google.crypto.tink.aead.AeadConfig; +import com.google.crypto.tink.aead.AeadFactory; +import com.google.crypto.tink.aead.AeadKeyTemplates; +import com.google.crypto.tink.config.TinkConfig; +import com.google.crypto.tink.hybrid.HybridDecryptFactory; +import com.google.crypto.tink.hybrid.HybridEncryptFactory; +import com.google.crypto.tink.hybrid.HybridKeyTemplates; +import com.google.crypto.tink.mac.MacFactory; +import com.google.crypto.tink.mac.MacKeyTemplates; +import com.google.crypto.tink.signature.PublicKeySignFactory; +import com.google.crypto.tink.signature.PublicKeyVerifyFactory; +import com.google.crypto.tink.signature.SignatureKeyTemplates; +import org.junit.Assert; +import org.junit.Test; + +import java.security.GeneralSecurityException; + +public class TinkUnitTest { + + private static final String PLAINTEXT = "BAELDUNG"; + private static final String DATA = "TINK"; + + @Test + public void givenPlaintext_whenEncryptWithAead_thenPlaintextIsEncrypted() throws GeneralSecurityException { + + AeadConfig.register(); + + KeysetHandle keysetHandle = KeysetHandle.generateNew( + AeadKeyTemplates.AES256_GCM); + + Aead aead = AeadFactory.getPrimitive(keysetHandle); + + byte[] ciphertext = aead.encrypt(PLAINTEXT.getBytes(), + DATA.getBytes()); + + Assert.assertNotEquals(PLAINTEXT, new String(ciphertext)); + } + + @Test + public void givenData_whenComputeMAC_thenVerifyMAC() throws GeneralSecurityException { + + TinkConfig.register(); + + KeysetHandle keysetHandle = KeysetHandle.generateNew( + MacKeyTemplates.HMAC_SHA256_128BITTAG); + + Mac mac = MacFactory.getPrimitive(keysetHandle); + + byte[] tag = mac.computeMac(DATA.getBytes()); + + mac.verifyMac(tag, DATA.getBytes()); + } + + @Test + public void givenData_whenSignData_thenVerifySignature() throws GeneralSecurityException { + + TinkConfig.register(); + + KeysetHandle privateKeysetHandle = KeysetHandle.generateNew( + SignatureKeyTemplates.ECDSA_P256); + + PublicKeySign signer = PublicKeySignFactory.getPrimitive(privateKeysetHandle); + + byte[] signature = signer.sign(DATA.getBytes()); + + KeysetHandle publicKeysetHandle = + privateKeysetHandle.getPublicKeysetHandle(); + + PublicKeyVerify verifier = PublicKeyVerifyFactory.getPrimitive(publicKeysetHandle); + + verifier.verify(signature, DATA.getBytes()); + } + + @Test + public void givenPlaintext_whenEncryptWithHybridEncryption_thenVerifyDecryptedIsEqual() throws GeneralSecurityException { + + TinkConfig.register(); + + KeysetHandle privateKeysetHandle = KeysetHandle.generateNew( + HybridKeyTemplates.ECIES_P256_HKDF_HMAC_SHA256_AES128_CTR_HMAC_SHA256); + + KeysetHandle publicKeysetHandle = privateKeysetHandle.getPublicKeysetHandle(); + + HybridEncrypt hybridEncrypt = HybridEncryptFactory.getPrimitive(publicKeysetHandle); + + HybridDecrypt hybridDecrypt = HybridDecryptFactory.getPrimitive(privateKeysetHandle); + + String contextInfo = "Tink"; + + byte[] ciphertext = hybridEncrypt.encrypt(PLAINTEXT.getBytes(), contextInfo.getBytes()); + + byte[] plaintextDecrypted = hybridDecrypt.decrypt(ciphertext, contextInfo.getBytes()); + + Assert.assertEquals(PLAINTEXT,new String(plaintextDecrypted)); + } +} + + From 5957f65495b2a15a41f61465006862056817928f Mon Sep 17 00:00:00 2001 From: mprevisic Date: Sat, 6 Apr 2019 20:42:44 +0200 Subject: [PATCH 083/531] BAEL-1970 improved examples after code review --- .../baeldung/component/OtherComponent.java | 19 +++++ .../java/com/baeldung/testlog/TestLog.java | 22 ------ .../testloglevel/TestLogLevelApplication.java | 8 +-- .../testloglevel/TestLogLevelController.java | 30 ++++---- .../LogbackTestLogLevelIntegrationTest.java | 4 +- ...estLogLevelWithProfileIntegrationTest.java | 70 ++++++++++--------- .../application-logback-test.properties | 1 + ...pplication-logback-testloglevel.properties | 1 - ...es => application-logging-test.properties} | 0 ...back-testloglevel.xml => logback-test.xml} | 2 +- 10 files changed, 79 insertions(+), 78 deletions(-) create mode 100644 spring-boot-testing/src/main/java/com/baeldung/component/OtherComponent.java delete mode 100644 spring-boot-testing/src/main/java/com/baeldung/testlog/TestLog.java create mode 100644 spring-boot-testing/src/test/resources/application-logback-test.properties delete mode 100644 spring-boot-testing/src/test/resources/application-logback-testloglevel.properties rename spring-boot-testing/src/test/resources/{application-testloglevel.properties => application-logging-test.properties} (100%) rename spring-boot-testing/src/test/resources/{logback-testloglevel.xml => logback-test.xml} (95%) diff --git a/spring-boot-testing/src/main/java/com/baeldung/component/OtherComponent.java b/spring-boot-testing/src/main/java/com/baeldung/component/OtherComponent.java new file mode 100644 index 0000000000..61f5b440c3 --- /dev/null +++ b/spring-boot-testing/src/main/java/com/baeldung/component/OtherComponent.java @@ -0,0 +1,19 @@ +package com.baeldung.component; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +@Component +public class OtherComponent { + + private static final Logger LOG = LoggerFactory.getLogger(OtherComponent.class); + + public void processData() { + LOG.trace("This is a TRACE log from OtherComponent"); + LOG.debug("This is a DEBUG log from OtherComponent"); + LOG.info("This is an INFO log from OtherComponent"); + LOG.error("This is an ERROR log from OtherComponent"); + } + +} diff --git a/spring-boot-testing/src/main/java/com/baeldung/testlog/TestLog.java b/spring-boot-testing/src/main/java/com/baeldung/testlog/TestLog.java deleted file mode 100644 index bc5d5700e5..0000000000 --- a/spring-boot-testing/src/main/java/com/baeldung/testlog/TestLog.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.baeldung.testlog; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class TestLog { - - Logger LOG = LoggerFactory.getLogger(this.getClass()); - - public void info(String msg) { - LOG.info(msg); - } - - public void error(String msg) { - LOG.error(msg); - } - - public void trace(String msg) { - LOG.trace(msg); - } - -} diff --git a/spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelApplication.java b/spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelApplication.java index 315bd735b9..ed8218c6a3 100644 --- a/spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelApplication.java +++ b/spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelApplication.java @@ -5,11 +5,11 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import com.baeldung.boot.Application; -@SpringBootApplication +@SpringBootApplication(scanBasePackages = {"com.baeldung.testloglevel", "com.baeldung.component"}) public class TestLogLevelApplication { - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } } diff --git a/spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelController.java b/spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelController.java index 7349c20b65..22078562b4 100644 --- a/spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelController.java +++ b/spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelController.java @@ -2,28 +2,30 @@ package com.baeldung.testloglevel; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; -import com.baeldung.testlog.TestLog; +import com.baeldung.component.OtherComponent; @RestController public class TestLogLevelController { - Logger LOG = LoggerFactory.getLogger(this.getClass()); + private static final Logger LOG = LoggerFactory.getLogger(TestLogLevelController.class); - @GetMapping("/testLogLevel") - public String testLogLevel() { - LOG.trace("This is a TRACE log"); - LOG.debug("This is a DEBUG log"); - LOG.info("This is an INFO log"); - LOG.error("This is an ERROR log"); + @Autowired + private OtherComponent otherComponent; - new TestLog().trace("This is a TRACE log in another package"); - new TestLog().info("This is an INFO log in another package"); - new TestLog().error("This is an ERROR log in another package"); + @GetMapping("/testLogLevel") + public String testLogLevel() { + LOG.trace("This is a TRACE log"); + LOG.debug("This is a DEBUG log"); + LOG.info("This is an INFO log"); + LOG.error("This is an ERROR log"); - return "Added some log output to console..."; - } + otherComponent.processData(); -} \ No newline at end of file + return "Added some log output to console..."; + } + +} diff --git a/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackTestLogLevelIntegrationTest.java b/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackTestLogLevelIntegrationTest.java index c0571265a9..5fb40a2f36 100644 --- a/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackTestLogLevelIntegrationTest.java +++ b/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackTestLogLevelIntegrationTest.java @@ -17,9 +17,9 @@ import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, classes = TestLogLevelApplication.class) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = TestLogLevelApplication.class) @EnableAutoConfiguration(exclude = SecurityAutoConfiguration.class) -@ActiveProfiles("logback-testloglevel") +@ActiveProfiles("logback-test") public class LogbackTestLogLevelIntegrationTest { @Autowired diff --git a/spring-boot-testing/src/test/java/com/baeldung/testloglevel/TestLogLevelWithProfileIntegrationTest.java b/spring-boot-testing/src/test/java/com/baeldung/testloglevel/TestLogLevelWithProfileIntegrationTest.java index 976e7d5f76..5609ce6c01 100644 --- a/spring-boot-testing/src/test/java/com/baeldung/testloglevel/TestLogLevelWithProfileIntegrationTest.java +++ b/spring-boot-testing/src/test/java/com/baeldung/testloglevel/TestLogLevelWithProfileIntegrationTest.java @@ -17,52 +17,54 @@ import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, classes = TestLogLevelApplication.class) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = TestLogLevelApplication.class) @EnableAutoConfiguration(exclude = SecurityAutoConfiguration.class) -@ActiveProfiles("testloglevel") +@ActiveProfiles("logging-test") public class TestLogLevelWithProfileIntegrationTest { - @Autowired - private TestRestTemplate restTemplate; + @Autowired + private TestRestTemplate restTemplate; - @Rule - public OutputCapture outputCapture = new OutputCapture(); + @Rule + public OutputCapture outputCapture = new OutputCapture(); - @Test - public void givenInfoRootLevelAndDebugLevelForOurPackage_whenCall_thenPrintDebugLogsForOurPackage() { - ResponseEntity response = restTemplate.getForEntity("http://localhost:8080/testLogLevel", String.class); + private String baseUrl = "/testLogLevel"; - assertThat(response.getStatusCode().value()).isEqualTo(200); - assertThatOutputContainsLogForOurPackage("DEBUG"); - } + @Test + public void givenInfoRootLevelAndDebugLevelForOurPackage_whenCall_thenPrintDebugLogsForOurPackage() { + ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); - @Test - public void givenInfoRootLevelAndDebugLevelForOurPackage_whenCall_thenNoDebugLogsForOtherPackages() { - ResponseEntity response = restTemplate.getForEntity("http://localhost:8080/testLogLevel", String.class); + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThatOutputContainsLogForOurPackage("DEBUG"); + } - assertThat(response.getStatusCode().value()).isEqualTo(200); - assertThatOutputDoesntContainLogForOtherPackages("DEBUG"); - } + @Test + public void givenInfoRootLevelAndDebugLevelForOurPackage_whenCall_thenNoDebugLogsForOtherPackages() { + ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); - @Test - public void givenInfoRootLevelAndDebugLevelForOurPackage_whenCall_thenPrintInfoLogs() { - ResponseEntity response = restTemplate.getForEntity("http://localhost:8080/testLogLevel", String.class); + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThatOutputDoesntContainLogForOtherPackages("DEBUG"); + } - assertThat(response.getStatusCode().value()).isEqualTo(200); - assertThatOutputContainsLogForOurPackage("INFO"); - assertThatOutputContainsLogForOtherPackages("INFO"); - } + @Test + public void givenInfoRootLevelAndDebugLevelForOurPackage_whenCall_thenPrintInfoLogs() { + ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); - private void assertThatOutputContainsLogForOurPackage(String level) { - assertThat(outputCapture.toString()).containsPattern("TestLogLevelController.*" + level + ".*"); - } + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThatOutputContainsLogForOurPackage("INFO"); + assertThatOutputContainsLogForOtherPackages("INFO"); + } - private void assertThatOutputDoesntContainLogForOtherPackages(String level) { - assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).doesNotContain(level); - } + private void assertThatOutputContainsLogForOurPackage(String level) { + assertThat(outputCapture.toString()).containsPattern("TestLogLevelController.*" + level + ".*"); + } - private void assertThatOutputContainsLogForOtherPackages(String level) { - assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).contains(level); - } + private void assertThatOutputDoesntContainLogForOtherPackages(String level) { + assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).doesNotContain(level); + } + + private void assertThatOutputContainsLogForOtherPackages(String level) { + assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).contains(level); + } } diff --git a/spring-boot-testing/src/test/resources/application-logback-test.properties b/spring-boot-testing/src/test/resources/application-logback-test.properties new file mode 100644 index 0000000000..587302fa01 --- /dev/null +++ b/spring-boot-testing/src/test/resources/application-logback-test.properties @@ -0,0 +1 @@ +logging.config=classpath:logback-test.xml diff --git a/spring-boot-testing/src/test/resources/application-logback-testloglevel.properties b/spring-boot-testing/src/test/resources/application-logback-testloglevel.properties deleted file mode 100644 index 81d9b2e7c6..0000000000 --- a/spring-boot-testing/src/test/resources/application-logback-testloglevel.properties +++ /dev/null @@ -1 +0,0 @@ -logging.config=classpath:logback-testloglevel.xml \ No newline at end of file diff --git a/spring-boot-testing/src/test/resources/application-testloglevel.properties b/spring-boot-testing/src/test/resources/application-logging-test.properties similarity index 100% rename from spring-boot-testing/src/test/resources/application-testloglevel.properties rename to spring-boot-testing/src/test/resources/application-logging-test.properties diff --git a/spring-boot-testing/src/test/resources/logback-testloglevel.xml b/spring-boot-testing/src/test/resources/logback-test.xml similarity index 95% rename from spring-boot-testing/src/test/resources/logback-testloglevel.xml rename to spring-boot-testing/src/test/resources/logback-test.xml index b02462a155..9c6df17024 100644 --- a/spring-boot-testing/src/test/resources/logback-testloglevel.xml +++ b/spring-boot-testing/src/test/resources/logback-test.xml @@ -10,4 +10,4 @@ - \ No newline at end of file + From f6d74e0c86dc7b4c97d49ef3eb0e40e74ca1eb54 Mon Sep 17 00:00:00 2001 From: Alexander Molochko Date: Sun, 7 Apr 2019 00:18:30 +0300 Subject: [PATCH 084/531] InputStream to String in Kotlin BAEL-2654 --- .../inputstream/InputStreamExtension.kt | 17 ++++++++ .../inputstream/InputStreamToStringTest.kt | 43 +++++++++++++++++++ .../src/test/resources/inputstream2string.txt | 2 + 3 files changed, 62 insertions(+) create mode 100644 core-kotlin-2/src/main/kotlin/com/baeldung/inputstream/InputStreamExtension.kt create mode 100644 core-kotlin-2/src/test/kotlin/com/baeldung/inputstream/InputStreamToStringTest.kt create mode 100644 core-kotlin-2/src/test/resources/inputstream2string.txt diff --git a/core-kotlin-2/src/main/kotlin/com/baeldung/inputstream/InputStreamExtension.kt b/core-kotlin-2/src/main/kotlin/com/baeldung/inputstream/InputStreamExtension.kt new file mode 100644 index 0000000000..2f765b0193 --- /dev/null +++ b/core-kotlin-2/src/main/kotlin/com/baeldung/inputstream/InputStreamExtension.kt @@ -0,0 +1,17 @@ +package com.baeldung.inputstream + +import java.io.InputStream + +fun InputStream.readUpToNullChar(nullChar: Char = '\n'): String { + val stringBuilder = StringBuilder() + var currentChar = this.read().toChar() + while (currentChar != nullChar) { + stringBuilder.append(currentChar) + currentChar = this.read().toChar() + if (this.available() <= 0) { + stringBuilder.append(currentChar) + break + } + } + return stringBuilder.toString() +} \ No newline at end of file diff --git a/core-kotlin-2/src/test/kotlin/com/baeldung/inputstream/InputStreamToStringTest.kt b/core-kotlin-2/src/test/kotlin/com/baeldung/inputstream/InputStreamToStringTest.kt new file mode 100644 index 0000000000..93a2dc2fa4 --- /dev/null +++ b/core-kotlin-2/src/test/kotlin/com/baeldung/inputstream/InputStreamToStringTest.kt @@ -0,0 +1,43 @@ +package com.baeldung.range + +import com.baeldung.inputstream.readUpToNullChar +import kotlinx.io.core.use +import org.junit.Test +import java.io.BufferedReader +import java.io.File +import kotlin.test.assertEquals + +class InputStreamToStringTest { + private val fileName = "src/test/resources/inputstream2string.txt" + private val fileFullContent = "Computer programming can be a hassle\r\n" + + "It's like trying to take a defended castle" + private val fileContentUpToNullChar = "Computer programming can be a hassle\r\n" + + "It" + + @Test + fun whenReadFileWithBufferedReader_thenFullFileContentIsReadAsString() { + val file = File(fileName) + val inputStream = file.inputStream() + val content = inputStream.bufferedReader().use(BufferedReader::readText) + assertEquals(fileFullContent, content) + } + + @Test + fun whenReadFileUpToNullChar_thenPartBeforeNullCharIsReadAsString() { + val file = File(fileName) + val inputStream = file.inputStream() + val content = inputStream.use { it.readUpToNullChar('\'') } + assertEquals(fileContentUpToNullChar, content) + } + + @Test + fun whenReadFileWithoutContainingNullChar_thenFullFileContentIsReadAsString() { + val file = File(fileName) + val inputStream = file.inputStream() + val content = inputStream.use { it.readUpToNullChar('-') } + assertEquals(fileFullContent, content) + } + + +} + diff --git a/core-kotlin-2/src/test/resources/inputstream2string.txt b/core-kotlin-2/src/test/resources/inputstream2string.txt new file mode 100644 index 0000000000..40ef9fc5f3 --- /dev/null +++ b/core-kotlin-2/src/test/resources/inputstream2string.txt @@ -0,0 +1,2 @@ +Computer programming can be a hassle +It's like trying to take a defended castle \ No newline at end of file From a707c0c95918e8d0751cd5890d3489cfe58af20f Mon Sep 17 00:00:00 2001 From: Alexander Molochko Date: Sun, 7 Apr 2019 00:27:48 +0300 Subject: [PATCH 085/531] Update package name --- .../kotlin/com/baeldung/inputstream/InputStreamToStringTest.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core-kotlin-2/src/test/kotlin/com/baeldung/inputstream/InputStreamToStringTest.kt b/core-kotlin-2/src/test/kotlin/com/baeldung/inputstream/InputStreamToStringTest.kt index 93a2dc2fa4..d7f0401af0 100644 --- a/core-kotlin-2/src/test/kotlin/com/baeldung/inputstream/InputStreamToStringTest.kt +++ b/core-kotlin-2/src/test/kotlin/com/baeldung/inputstream/InputStreamToStringTest.kt @@ -1,6 +1,5 @@ -package com.baeldung.range +package com.baeldung.inputstream -import com.baeldung.inputstream.readUpToNullChar import kotlinx.io.core.use import org.junit.Test import java.io.BufferedReader From fe53a23d41bb69d36f2ea5e7885d214b461cbd81 Mon Sep 17 00:00:00 2001 From: Anurag Goyal Date: Sun, 7 Apr 2019 16:48:07 +0530 Subject: [PATCH 086/531] updated post review comments --- .../filechannel/FileChannelUnitTest.java | 288 ++++++++++-------- 1 file changed, 156 insertions(+), 132 deletions(-) diff --git a/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java b/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java index 35ba9aca65..37b203241b 100644 --- a/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java +++ b/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java @@ -1,6 +1,7 @@ package com.baeldung.filechannel; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import java.io.ByteArrayOutputStream; import java.io.FileInputStream; @@ -8,171 +9,194 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.RandomAccessFile; import java.nio.ByteBuffer; +import java.nio.MappedByteBuffer; import java.nio.channels.FileChannel; +import java.nio.channels.FileLock; +import java.nio.channels.OverlappingFileLockException; import java.nio.charset.StandardCharsets; import org.junit.Test; public class FileChannelUnitTest { - @Test - public void givenFile_whenReadWithFileChannelUsingRandomAccessFile_thenCorrect() throws IOException { - String expected_value = "Hello world"; - String file = "src/test/resources/test_read.in"; - RandomAccessFile reader = new RandomAccessFile(file, "r"); - FileChannel channel = reader.getChannel(); - ByteArrayOutputStream out = new ByteArrayOutputStream(); - int bufferSize = 1024; - if (bufferSize > channel.size()) { - bufferSize = (int) channel.size(); - } - ByteBuffer buff = ByteBuffer.allocate(bufferSize); + @Test + public void givenFile_whenReadWithFileChannelUsingRandomAccessFile_thenCorrect() throws IOException { + String expected_value = "Hello world"; + String file = "src/test/resources/test_read.in"; + + try (RandomAccessFile reader = new RandomAccessFile(file, "r"); + FileChannel channel = reader.getChannel(); + ByteArrayOutputStream out = new ByteArrayOutputStream();) { - while (channel.read(buff) > 0) { - if (buff.hasArray()) { - out.write(buff.array(), 0, buff.position()); - buff.clear(); - } - } + int bufferSize = 1024; + if (bufferSize > channel.size()) { + bufferSize = (int) channel.size(); + } + ByteBuffer buff = ByteBuffer.allocate(bufferSize); - assertEquals(expected_value, new String(out.toByteArray(), StandardCharsets.UTF_8)); - out.close(); - channel.close(); - reader.close(); - } + while (channel.read(buff) > 0) { + if (buff.hasArray()) { + out.write(buff.array(), 0, buff.position()); + buff.clear(); + } + } - @Test - public void givenFile_whenReadWithFileChannelUsingFileInputStream_thenCorrect() throws IOException { - String expected_value = "Hello world"; - String file = "src/test/resources/test_read.in"; - ByteArrayOutputStream out = new ByteArrayOutputStream(); - FileInputStream fin = new FileInputStream(file); - FileChannel channel = fin.getChannel(); + assertEquals(expected_value, new String(out.toByteArray(), StandardCharsets.UTF_8)); + } + } - int bufferSize = 1024; - if (bufferSize > channel.size()) { - bufferSize = (int) channel.size(); - } - ByteBuffer buff = ByteBuffer.allocate(bufferSize); + + @Test + public void givenFile_whenReadWithFileChannelUsingFileInputStream_thenCorrect() throws IOException { + String expected_value = "Hello world"; + String file = "src/test/resources/test_read.in"; - while (channel.read(buff) > 0) { - if (buff.hasArray()) { - out.write(buff.array(), 0, buff.position()); - buff.clear(); - } - } + try (ByteArrayOutputStream out = new ByteArrayOutputStream(); + FileInputStream fin = new FileInputStream(file); + FileChannel channel = fin.getChannel();) { - assertEquals(expected_value, new String(out.toByteArray(), StandardCharsets.UTF_8)); - out.close(); - channel.close(); - fin.close(); - } + int bufferSize = 1024; + if (bufferSize > channel.size()) { + bufferSize = (int) channel.size(); + } + ByteBuffer buff = ByteBuffer.allocate(bufferSize); - @Test - public void whenWriteWithFileChannelUsingRandomAccessFile_thenCorrect() throws IOException { - String input = "Hello world"; - String file = "src/test/resources/test_write_using_filechannel.txt"; + while (channel.read(buff) > 0) { + if (buff.hasArray()) { + out.write(buff.array(), 0, buff.position()); + buff.clear(); + } + } - RandomAccessFile writer = new RandomAccessFile(file, "rw"); - FileChannel channel = writer.getChannel(); + assertEquals(expected_value, new String(out.toByteArray(), StandardCharsets.UTF_8)); - ByteBuffer buff = ByteBuffer.wrap(input.getBytes()); - while (buff.hasRemaining()) { - channel.write(buff); - } - channel.close(); - writer.close(); + } + } + + + @Test + public void givenFile_whenReadAFileSectionIntoMemoryWithFileChannel_thenCorrect() throws IOException { + String expected_value = "world"; + String file = "src/test/resources/test_read.in"; - // verify - RandomAccessFile reader = new RandomAccessFile(file, "r"); - assertEquals(input, reader.readLine()); - reader.close(); - } + try (RandomAccessFile reader = new RandomAccessFile(file, "r"); + FileChannel channel = reader.getChannel(); + ByteArrayOutputStream out = new ByteArrayOutputStream();) { - @Test - public void whenWriteWithFileChannelUsingFileOutputStream_thenCorrect() throws IOException { - String input = "Hello world"; - String file = "src/test/resources/test_write_using_filechannel.txt"; + MappedByteBuffer buff = channel.map(FileChannel.MapMode.READ_ONLY, 6, 5); - FileOutputStream fout = new FileOutputStream(file); - FileChannel channel = fout.getChannel(); + if(buff.hasRemaining()) { + byte[] data = new byte[buff.remaining()]; + buff.get(data); + assertEquals(expected_value, new String(data, StandardCharsets.UTF_8)); + + } + + } + } + + + @Test + public void whenWriteWithFileChannelUsingRandomAccessFile_thenCorrect() + throws IOException { + String expected = "Hello world"; + String file = "src/test/resources/test_write_using_filechannel.txt"; + + try (RandomAccessFile writer = new RandomAccessFile(file, "rw"); + FileChannel channel = writer.getChannel();){ + ByteBuffer buff = ByteBuffer.wrap("Hello world".getBytes(StandardCharsets.UTF_8)); + + if (buff.hasRemaining()) { + channel.write(buff); + } + + // verify + RandomAccessFile reader = new RandomAccessFile(file, "r"); + assertEquals(expected, reader.readLine()); + reader.close(); + } + } + + + @Test + public void givenFile_whenWriteAFileUsingLockAFileSectionWithFileChannel_thenCorrect() throws IOException { + String file = "src/test/resources/test_read.in"; - ByteBuffer buff = ByteBuffer.wrap(input.getBytes()); - while (buff.hasRemaining()) { - channel.write(buff); - } + try (RandomAccessFile reader = new RandomAccessFile(file, "rw"); + FileChannel channel = reader.getChannel(); + FileLock fileLock = channel.tryLock(6, 5, Boolean.FALSE );){ + + + assertNotNull(fileLock); + + }catch(OverlappingFileLockException | IOException ex) { + + + } + + } + - channel.close(); - fout.close(); + @Test + public void givenFile_whenReadWithFileChannelGetPosition_thenCorrect() throws IOException { + long expected_value = 11; + String file = "src/test/resources/test_read.in"; - // verify - RandomAccessFile reader = new RandomAccessFile(file, "r"); - assertEquals(input, reader.readLine()); - reader.close(); - } + try (ByteArrayOutputStream out = new ByteArrayOutputStream(); + RandomAccessFile reader = new RandomAccessFile(file, "r"); + FileChannel channel = reader.getChannel();) { - @Test - public void givenFile_whenReadWithFileChannelGetPosition_thenCorrect() throws IOException { - long expected_value = 11; - String file = "src/test/resources/test_read.in"; - ByteArrayOutputStream out = new ByteArrayOutputStream(); - RandomAccessFile reader = new RandomAccessFile(file, "r"); - FileChannel channel = reader.getChannel(); + int bufferSize = 1024; + if (bufferSize > channel.size()) { + bufferSize = (int) channel.size(); + } + ByteBuffer buff = ByteBuffer.allocate(bufferSize); - int bufferSize = 1024; - if (bufferSize > channel.size()) { - bufferSize = (int) channel.size(); - } - ByteBuffer buff = ByteBuffer.allocate(bufferSize); + while (channel.read(buff) > 0) { + out.write(buff.array(), 0, buff.position()); + buff.clear(); + } - while (channel.read(buff) > 0) { - if (buff.hasArray()) { - out.write(buff.array(), 0, buff.position()); - buff.clear(); - } - } + assertEquals(expected_value, channel.position()); - assertEquals(expected_value, channel.position()); + channel.position(4); + assertEquals(4, channel.position()); - channel.position(4); - assertEquals(4, channel.position()); + } + } - out.close(); - channel.close(); - reader.close(); - } + + @Test + public void whenGetFileSize_thenCorrect() throws IOException { + long expectedSize = 11; + String file = "src/test/resources/test_read.in"; + + try (RandomAccessFile reader = new RandomAccessFile(file, "r"); + FileChannel channel = reader.getChannel();) { - @Test - public void whenGetFileSize_thenCorrect() throws IOException { - long expectedSize = 11; - String file = "src/test/resources/test_read.in"; - RandomAccessFile reader = new RandomAccessFile(file, "r"); - FileChannel channel = reader.getChannel(); + long imageFileSize = channel.size(); + assertEquals(expectedSize, imageFileSize); + } - long imageFileSize = channel.size(); - assertEquals(expectedSize, imageFileSize); + } - channel.close(); - reader.close(); - } + @Test + public void whenTruncateFile_thenCorrect() throws IOException { + long expectedSize = 5; + String input = "this is a test input"; + String file = "src/test/resources/test_truncate.txt"; - @Test - public void whenTruncateFile_thenCorrect() throws IOException { - long expectedSize = 5; - String input = "this is a test input"; - String file = "src/test/resources/test_truncate.txt"; + FileOutputStream fout = new FileOutputStream(file); + FileChannel channel = fout.getChannel(); - FileOutputStream fout = new FileOutputStream(file); - FileChannel channel = fout.getChannel(); + ByteBuffer buff = ByteBuffer.wrap(input.getBytes()); + channel.write(buff); + buff.flip(); - ByteBuffer buff = ByteBuffer.wrap(input.getBytes()); - channel.write(buff); - buff.flip(); + channel = channel.truncate(5); + assertEquals(expectedSize, channel.size()); - channel = channel.truncate(5); - assertEquals(expectedSize, channel.size()); - - fout.close(); - channel.close(); - } + fout.close(); + channel.close(); + } } From 27559b3a7fab1bd1e97e5d3690eb07a76afe2ed0 Mon Sep 17 00:00:00 2001 From: Sushant Date: Sun, 7 Apr 2019 15:14:30 +0300 Subject: [PATCH 087/531] Split into separate test cases --- .../baeldung/guava/GuavaMultiSetUnitTest.java | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java b/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java index 3d75cc38a3..47411031b9 100644 --- a/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java +++ b/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java @@ -13,7 +13,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; public class GuavaMultiSetUnitTest { @Test - public void givenMultiSet_whenAddAndRemoveValues_shouldReturnCorrectCount() { + public void givenMultiSet_whenAddingValues_shouldReturnCorrectCount() { Multiset bookStore = HashMultiset.create(); bookStore.add("Potter"); bookStore.add("Potter"); @@ -21,10 +21,17 @@ public class GuavaMultiSetUnitTest { assertThat(bookStore.contains("Potter")).isTrue(); assertThat(bookStore.count("Potter")).isEqualTo(3); + } + + @Test + public void givenMultiSet_whenRemovingValues_shouldReturnCorrectCount() { + Multiset bookStore = HashMultiset.create(); + bookStore.add("Potter"); + bookStore.add("Potter"); bookStore.remove("Potter"); assertThat(bookStore.contains("Potter")).isTrue(); - assertThat(bookStore.count("Potter")).isEqualTo(2); + assertThat(bookStore.count("Potter")).isEqualTo(1); } @Test @@ -37,14 +44,32 @@ public class GuavaMultiSetUnitTest { @Test public void givenMultiSet_whenSettingNegativeCount_shouldThrowException() { Multiset bookStore = HashMultiset.create(); - assertThatThrownBy(() -> bookStore.setCount("Potter", -1)).isInstanceOf(IllegalArgumentException.class); + assertThatThrownBy(() -> bookStore.setCount("Potter", -1)) + .isInstanceOf(IllegalArgumentException.class); } @Test - public void givenMultiSet_whenSettingCountWithOldCount_shouldReturnCorrectValue() { + public void givenMultiSet_whenSettingCountWithEmptySet_shouldBeSuccessful() { Multiset bookStore = HashMultiset.create(); assertThat(bookStore.setCount("Potter", 0, 2)).isTrue(); - assertThat(bookStore.setCount("Potter", 50, 5)).isFalse(); + } + + @Test + public void givenMultiSet_whenSettingCountWithCorrectValue_shouldBeSuccessful() { + Multiset bookStore = HashMultiset.create(); + bookStore.add("Potter"); + bookStore.add("Potter"); + + assertThat(bookStore.setCount("Potter", 2, 52)).isTrue(); + } + + @Test + public void givenMultiSet_whenSettingCountWithIncorrectValue_shouldFail() { + Multiset bookStore = HashMultiset.create(); + bookStore.add("Potter"); + bookStore.add("Potter"); + + assertThat(bookStore.setCount("Potter", 5, 52)).isFalse(); } @Test From 256a81b6f44ad28000e04dd964d3d6a790004b06 Mon Sep 17 00:00:00 2001 From: Kacper Koza Date: Sun, 7 Apr 2019 23:25:38 +0200 Subject: [PATCH 088/531] Update spock to 1.3 --- testing-modules/groovy-spock/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing-modules/groovy-spock/pom.xml b/testing-modules/groovy-spock/pom.xml index 77b6fbeb28..50c85b82ed 100644 --- a/testing-modules/groovy-spock/pom.xml +++ b/testing-modules/groovy-spock/pom.xml @@ -48,7 +48,7 @@ - 1.3-RC1-groovy-2.4 + 1.3-groovy-2.4 2.4.7 1.5 From e0f9f6822e512bb05d27f6cca8dbbb3b1ce8a1c9 Mon Sep 17 00:00:00 2001 From: Kacper Koza Date: Mon, 8 Apr 2019 00:03:13 +0200 Subject: [PATCH 089/531] BAEL_spock_extensions --- .../groovy-spock/src/test/resources/SpockConfig.groovy | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/testing-modules/groovy-spock/src/test/resources/SpockConfig.groovy b/testing-modules/groovy-spock/src/test/resources/SpockConfig.groovy index ed94e61cbf..4b017aeefc 100644 --- a/testing-modules/groovy-spock/src/test/resources/SpockConfig.groovy +++ b/testing-modules/groovy-spock/src/test/resources/SpockConfig.groovy @@ -2,7 +2,10 @@ import extensions.TimeoutTest import spock.lang.Issue runner { - filterStackTrace true + + if (System.getenv("FILTER_STACKTRACE") == null) { + filterStackTrace false + } report { issueNamePrefix 'Bug ' From 569c1c5728dc24a1c5717608c05b744fd9e0d16a Mon Sep 17 00:00:00 2001 From: Kacper Koza Date: Mon, 8 Apr 2019 00:34:13 +0200 Subject: [PATCH 090/531] BAEL_spock_extensions --- .../src/test/groovy/extensions/IgnoreIfTest.groovy | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/testing-modules/groovy-spock/src/test/groovy/extensions/IgnoreIfTest.groovy b/testing-modules/groovy-spock/src/test/groovy/extensions/IgnoreIfTest.groovy index 91da2ff1ec..9010481220 100644 --- a/testing-modules/groovy-spock/src/test/groovy/extensions/IgnoreIfTest.groovy +++ b/testing-modules/groovy-spock/src/test/groovy/extensions/IgnoreIfTest.groovy @@ -7,6 +7,16 @@ import spock.lang.Specification class IgnoreIfTest extends Specification { @IgnoreIf({System.getProperty("os.name").contains("windows")}) - def "I won't run on windows"() { } + def "I won't run on windows"() { + expect: + true + } + + @IgnoreIf({ os.isWindows() }) + def "I'm using Spock helper classes to run only on windows"() { + expect: + true + } + } From aae74f3b6cce2260442e9c3469f0f22a0f22c319 Mon Sep 17 00:00:00 2001 From: Anshul Bansal Date: Mon, 8 Apr 2019 11:08:20 +0300 Subject: [PATCH 091/531] BAEL-2800_Copying_a_HashMap_in_Java - generic types added --- .../baeldung/copyinghashmap/CopyHashMap.java | 35 ++++++++++--------- .../copyinghashmap/CopyHashMapUnitTest.java | 7 ++-- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/core-java-collections-2/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java b/core-java-collections-2/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java index e673335f62..972f48a3bf 100644 --- a/core-java-collections-2/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java +++ b/core-java-collections-2/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java @@ -2,6 +2,7 @@ package com.baeldung.copyinghashmap; import java.util.HashMap; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import java.util.stream.Collectors; @@ -9,45 +10,45 @@ import org.apache.commons.lang3.SerializationUtils; public class CopyHashMap { - public static HashMap copyUsingConstructor(HashMap originalMap) { - return new HashMap(originalMap); + public static HashMap copyUsingConstructor(HashMap originalMap) { + return new HashMap(originalMap); } - public static HashMap copyUsingClone(HashMap originalMap) { - return (HashMap) originalMap.clone(); + public static HashMap copyUsingClone(HashMap originalMap) { + return (HashMap) originalMap.clone(); } - public static HashMap copyUsingPut(HashMap originalMap) { - HashMap copyMap = new HashMap(); - Set entries = originalMap.entrySet(); - for(Map.Entry mapEntry: entries) { - copyMap.put(mapEntry.getKey(), mapEntry.getValue()); + public static HashMap copyUsingPut(HashMap originalMap) { + HashMap copyMap = new HashMap(); + Set> entries = originalMap.entrySet(); + for(Map.Entry mapEntry: entries) { + copyMap.put((K)mapEntry.getKey(), (V)mapEntry.getValue()); } return copyMap; } - public static Map copyUsingPutAll(Map originalMap) { - HashMap copyMap = new HashMap(); + public static HashMap copyUsingPutAll(HashMap originalMap) { + HashMap copyMap = new HashMap(); copyMap.putAll(originalMap); return copyMap; } - public static HashMap copyUsingJava8Stream(HashMap originalMap) { - Set entries = originalMap.entrySet(); - HashMap copyMap = (HashMap) entries + public static HashMap copyUsingJava8Stream(HashMap originalMap) { + Set> entries = originalMap.entrySet(); + HashMap copyMap = (HashMap) entries .stream() .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); return copyMap; } - public static HashMap shallowCopy(HashMap originalMap) { - return (HashMap) originalMap.clone(); + public static HashMap shallowCopy(HashMap originalMap) { + return (HashMap) originalMap.clone(); } - public static HashMap deepCopy(HashMap originalMap) { + public static HashMap deepCopy(HashMap originalMap) { return SerializationUtils.clone(originalMap); } diff --git a/core-java-collections-2/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java b/core-java-collections-2/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java index f0434f9bfe..c71e17e94e 100644 --- a/core-java-collections-2/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java +++ b/core-java-collections-2/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java @@ -1,6 +1,5 @@ package com.baeldung.copyinghashmap; -import static org.junit.Assert.assertEquals; import static org.assertj.core.api.Assertions.assertThat; import java.util.HashMap; @@ -21,7 +20,7 @@ public class CopyHashMapUnitTest { map.put("emp1",emp1); map.put("emp2",emp2); - HashMap shallowCopy = CopyHashMap.shallowCopy(map); + HashMap shallowCopy = CopyHashMap.shallowCopy(map); assertThat(shallowCopy).isNotSameAs(map); @@ -36,7 +35,7 @@ public class CopyHashMapUnitTest { map.put("emp1",emp1); map.put("emp2",emp2); - HashMap shallowCopy = CopyHashMap.shallowCopy(map); + HashMap shallowCopy = CopyHashMap.shallowCopy(map); emp1.setName("Johny"); @@ -52,7 +51,7 @@ public class CopyHashMapUnitTest { Employee emp2 = new Employee("Norman"); map.put("emp1",emp1); map.put("emp2",emp2); - HashMap deepCopy = CopyHashMap.deepCopy(map); + HashMap deepCopy = CopyHashMap.deepCopy(map); emp1.setName("Johny"); From 990610ee292f73e3794338dd1f4b96bd192e106e Mon Sep 17 00:00:00 2001 From: Alexander Molochko Date: Mon, 8 Apr 2019 16:37:34 +0300 Subject: [PATCH 092/531] Add manual example, fix names --- .../inputstream/InputStreamExtension.kt | 7 +++-- .../inputstream/InputStreamToStringTest.kt | 31 +++++++++++++++---- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/core-kotlin-2/src/main/kotlin/com/baeldung/inputstream/InputStreamExtension.kt b/core-kotlin-2/src/main/kotlin/com/baeldung/inputstream/InputStreamExtension.kt index 2f765b0193..e94a2e84ee 100644 --- a/core-kotlin-2/src/main/kotlin/com/baeldung/inputstream/InputStreamExtension.kt +++ b/core-kotlin-2/src/main/kotlin/com/baeldung/inputstream/InputStreamExtension.kt @@ -2,10 +2,10 @@ package com.baeldung.inputstream import java.io.InputStream -fun InputStream.readUpToNullChar(nullChar: Char = '\n'): String { +fun InputStream.readUpToChar(stopChar: Char): String { val stringBuilder = StringBuilder() var currentChar = this.read().toChar() - while (currentChar != nullChar) { + while (currentChar != stopChar) { stringBuilder.append(currentChar) currentChar = this.read().toChar() if (this.available() <= 0) { @@ -14,4 +14,5 @@ fun InputStream.readUpToNullChar(nullChar: Char = '\n'): String { } } return stringBuilder.toString() -} \ No newline at end of file +} + diff --git a/core-kotlin-2/src/test/kotlin/com/baeldung/inputstream/InputStreamToStringTest.kt b/core-kotlin-2/src/test/kotlin/com/baeldung/inputstream/InputStreamToStringTest.kt index d7f0401af0..0a053d61ec 100644 --- a/core-kotlin-2/src/test/kotlin/com/baeldung/inputstream/InputStreamToStringTest.kt +++ b/core-kotlin-2/src/test/kotlin/com/baeldung/inputstream/InputStreamToStringTest.kt @@ -10,7 +10,7 @@ class InputStreamToStringTest { private val fileName = "src/test/resources/inputstream2string.txt" private val fileFullContent = "Computer programming can be a hassle\r\n" + "It's like trying to take a defended castle" - private val fileContentUpToNullChar = "Computer programming can be a hassle\r\n" + + private val fileContentUpToStopChar = "Computer programming can be a hassle\r\n" + "It" @Test @@ -22,18 +22,37 @@ class InputStreamToStringTest { } @Test - fun whenReadFileUpToNullChar_thenPartBeforeNullCharIsReadAsString() { + fun whenReadFileWithBufferedReaderManually_thenFullFileContentIsReadAsString() { val file = File(fileName) val inputStream = file.inputStream() - val content = inputStream.use { it.readUpToNullChar('\'') } - assertEquals(fileContentUpToNullChar, content) + val reader = BufferedReader(inputStream.reader()) + val content = StringBuilder() + try { + var line = reader.readLine() + while (line != null) { + content.append(line) + line = reader.readLine() + } + } finally { + reader.close() + } + assertEquals(fileFullContent.replace("\r\n", ""), content.toString()) + } @Test - fun whenReadFileWithoutContainingNullChar_thenFullFileContentIsReadAsString() { + fun whenReadFileUpToStopChar_thenPartBeforeStopCharIsReadAsString() { val file = File(fileName) val inputStream = file.inputStream() - val content = inputStream.use { it.readUpToNullChar('-') } + val content = inputStream.use { it.readUpToChar('\'') } + assertEquals(fileContentUpToStopChar, content) + } + + @Test + fun whenReadFileWithoutContainingStopChar_thenFullFileContentIsReadAsString() { + val file = File(fileName) + val inputStream = file.inputStream() + val content = inputStream.use { it.readUpToChar('-') } assertEquals(fileFullContent, content) } From 58f416fbb86649f75f3efdcacf2c48248e83474b Mon Sep 17 00:00:00 2001 From: Anshul Bansal Date: Tue, 9 Apr 2019 07:22:59 +0300 Subject: [PATCH 093/531] BAEL-2800_Copying_a_HashMap_in_Java - types corrected --- .../baeldung/copyinghashmap/CopyHashMap.java | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/core-java-collections-2/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java b/core-java-collections-2/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java index 972f48a3bf..cd81f61b48 100644 --- a/core-java-collections-2/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java +++ b/core-java-collections-2/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java @@ -10,45 +10,45 @@ import org.apache.commons.lang3.SerializationUtils; public class CopyHashMap { - public static HashMap copyUsingConstructor(HashMap originalMap) { - return new HashMap(originalMap); + public static HashMap copyUsingConstructor(HashMap originalMap) { + return new HashMap(originalMap); } - public static HashMap copyUsingClone(HashMap originalMap) { - return (HashMap) originalMap.clone(); + public static HashMap copyUsingClone(HashMap originalMap) { + return (HashMap) originalMap.clone(); } - public static HashMap copyUsingPut(HashMap originalMap) { - HashMap copyMap = new HashMap(); - Set> entries = originalMap.entrySet(); - for(Map.Entry mapEntry: entries) { - copyMap.put((K)mapEntry.getKey(), (V)mapEntry.getValue()); + public static HashMap copyUsingPut(HashMap originalMap) { + HashMap copyMap = new HashMap(); + Set> entries = originalMap.entrySet(); + for(Map.Entry mapEntry: entries) { + copyMap.put(mapEntry.getKey(), mapEntry.getValue()); } return copyMap; } - public static HashMap copyUsingPutAll(HashMap originalMap) { - HashMap copyMap = new HashMap(); + public static HashMap copyUsingPutAll(HashMap originalMap) { + HashMap copyMap = new HashMap(); copyMap.putAll(originalMap); return copyMap; } - public static HashMap copyUsingJava8Stream(HashMap originalMap) { - Set> entries = originalMap.entrySet(); - HashMap copyMap = (HashMap) entries + public static HashMap copyUsingJava8Stream(HashMap originalMap) { + Set> entries = originalMap.entrySet(); + HashMap copyMap = (HashMap) entries .stream() .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); return copyMap; } - public static HashMap shallowCopy(HashMap originalMap) { - return (HashMap) originalMap.clone(); + public static HashMap shallowCopy(HashMap originalMap) { + return (HashMap) originalMap.clone(); } - public static HashMap deepCopy(HashMap originalMap) { + public static HashMap deepCopy(HashMap originalMap) { return SerializationUtils.clone(originalMap); } From b99018c409e07e0a262437ddde81b62bf6dbcb27 Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Tue, 9 Apr 2019 16:26:32 +0530 Subject: [PATCH 094/531] Back-link added --- spring-all/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-all/README.md b/spring-all/README.md index 0d78efdcf2..4fb581325d 100644 --- a/spring-all/README.md +++ b/spring-all/README.md @@ -34,3 +34,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Spring @Primary Annotation](http://www.baeldung.com/spring-primary) - [Spring Events](https://www.baeldung.com/spring-events) - [Spring Null-Safety Annotations](https://www.baeldung.com/spring-null-safety-annotations) +- [Using @Autowired in Abstract Classes](https://www.baeldung.com/spring-autowired-abstract-class) From 322276ff226b593d165a6c2e5413b6a8ab539d66 Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Tue, 9 Apr 2019 16:40:44 +0530 Subject: [PATCH 095/531] Back link added --- rxjava-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/rxjava-2/README.md b/rxjava-2/README.md index d0bdeec684..0f4864e1a0 100644 --- a/rxjava-2/README.md +++ b/rxjava-2/README.md @@ -7,3 +7,4 @@ - [Introduction to RxRelay for RxJava](http://www.baeldung.com/rx-relay) - [Combining RxJava Completables](https://www.baeldung.com/rxjava-completable) - [Converting Synchronous and Asynchronous APIs to Observables using RxJava2](https://www.baeldung.com/rxjava-apis-to-observables) +- [RxJava Hooks](https://www.baeldung.com/rxjava-hooks) From 05d4ffb4272748a7a3174be50d292a418fddfe66 Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Tue, 9 Apr 2019 16:42:48 +0530 Subject: [PATCH 096/531] Back-link added --- core-kotlin-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-kotlin-2/README.md b/core-kotlin-2/README.md index 8d22c4f1a8..3d8b99f7da 100644 --- a/core-kotlin-2/README.md +++ b/core-kotlin-2/README.md @@ -2,3 +2,4 @@ - [Void Type in Kotlin](https://www.baeldung.com/kotlin-void-type) - [How to use Kotlin Range Expressions](https://www.baeldung.com/kotlin-ranges) +- [Creating a Kotlin Range Iterator on a Custom Object](https://www.baeldung.com/kotlin-custom-range-iterator) From 0965d0ae0266f4ee2114c85262b232574370ca3c Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Tue, 9 Apr 2019 16:44:33 +0530 Subject: [PATCH 097/531] Back-link added --- spring-mvc-xml/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-mvc-xml/README.md b/spring-mvc-xml/README.md index 3199118281..117fbb61e2 100644 --- a/spring-mvc-xml/README.md +++ b/spring-mvc-xml/README.md @@ -14,3 +14,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Guide to JavaServer Pages (JSP)](http://www.baeldung.com/jsp) - [Exploring SpringMVC’s Form Tag Library](http://www.baeldung.com/spring-mvc-form-tags) - [web.xml vs Initializer with Spring](http://www.baeldung.com/spring-xml-vs-java-config) +- [A Java Web Application Without a web.xml](https://www.baeldung.com/java-web-app-without-web-xml) From 35e274c821eceb78ccb19757b3dc256c67cad4ef Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Tue, 9 Apr 2019 16:48:29 +0530 Subject: [PATCH 098/531] Back-link added --- persistence-modules/spring-boot-persistence/README.MD | 1 + 1 file changed, 1 insertion(+) diff --git a/persistence-modules/spring-boot-persistence/README.MD b/persistence-modules/spring-boot-persistence/README.MD index 6fe5e6f05f..4c9778c216 100644 --- a/persistence-modules/spring-boot-persistence/README.MD +++ b/persistence-modules/spring-boot-persistence/README.MD @@ -7,3 +7,4 @@ - [Hibernate Field Naming with Spring Boot](https://www.baeldung.com/hibernate-field-naming-spring-boot) - [Integrating Spring Boot with HSQLDB](https://www.baeldung.com/spring-boot-hsqldb) - [Configuring a DataSource Programmatically in Spring Boot](https://www.baeldung.com/spring-boot-configure-data-source-programmatic) +- [Spring Boot with Hibernate](https://www.baeldung.com/spring-boot-hibernate) From 55522bce2a67e5d0a237397b655d677e3bd62337 Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Tue, 9 Apr 2019 16:51:15 +0530 Subject: [PATCH 099/531] Back-link added --- testing-modules/rest-assured/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/testing-modules/rest-assured/README.md b/testing-modules/rest-assured/README.md index 50f36f61eb..44247af795 100644 --- a/testing-modules/rest-assured/README.md +++ b/testing-modules/rest-assured/README.md @@ -1,2 +1,3 @@ ###Relevant Articles: - [A Guide to REST-assured](http://www.baeldung.com/rest-assured-tutorial) +- [Getting and Verifying Response Data with REST-assured](https://www.baeldung.com/rest-assured-response) From b8d0095c50e3d0da986b31655b7c89b9f4c47c48 Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Tue, 9 Apr 2019 16:54:46 +0530 Subject: [PATCH 100/531] Back-link added --- core-kotlin-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-kotlin-2/README.md b/core-kotlin-2/README.md index 3d8b99f7da..20ea190cb4 100644 --- a/core-kotlin-2/README.md +++ b/core-kotlin-2/README.md @@ -3,3 +3,4 @@ - [Void Type in Kotlin](https://www.baeldung.com/kotlin-void-type) - [How to use Kotlin Range Expressions](https://www.baeldung.com/kotlin-ranges) - [Creating a Kotlin Range Iterator on a Custom Object](https://www.baeldung.com/kotlin-custom-range-iterator) +- [Kotlin Scope Functions](https://www.baeldung.com/kotlin-scope-functions) From 6ed87d14b81426233ce54316e9ccbab4413ee97d Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Tue, 9 Apr 2019 16:57:49 +0530 Subject: [PATCH 101/531] Back-link added --- spring-boot-rest/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-boot-rest/README.md b/spring-boot-rest/README.md index 8fbc9527b8..ca1be7330a 100644 --- a/spring-boot-rest/README.md +++ b/spring-boot-rest/README.md @@ -10,3 +10,4 @@ Module for the articles that are part of the Spring REST E-book: 8. [Http Message Converters with the Spring Framework](http://www.baeldung.com/spring-httpmessageconverter-rest) 9. [ETags for REST with Spring](http://www.baeldung.com/etags-for-rest-with-spring) 10. [Testing REST with multiple MIME types](http://www.baeldung.com/testing-rest-api-with-multiple-media-types) +11. [Spring Boot Consuming and Producing JSON](https://www.baeldung.com/spring-boot-json) From 2f14ec07d8dc36eacfb01b8e771a7a786f9fffc0 Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Tue, 9 Apr 2019 16:59:55 +0530 Subject: [PATCH 102/531] Back-link added --- core-kotlin-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-kotlin-2/README.md b/core-kotlin-2/README.md index 20ea190cb4..368646c0d0 100644 --- a/core-kotlin-2/README.md +++ b/core-kotlin-2/README.md @@ -4,3 +4,4 @@ - [How to use Kotlin Range Expressions](https://www.baeldung.com/kotlin-ranges) - [Creating a Kotlin Range Iterator on a Custom Object](https://www.baeldung.com/kotlin-custom-range-iterator) - [Kotlin Scope Functions](https://www.baeldung.com/kotlin-scope-functions) +- [Kotlin Annotations](https://www.baeldung.com/kotlin-annotations) From 5b64febff3ac69a7f6db902888e303e6fc995c39 Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Tue, 9 Apr 2019 17:02:29 +0530 Subject: [PATCH 103/531] Back-link added --- persistence-modules/hibernate5/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/persistence-modules/hibernate5/README.md b/persistence-modules/hibernate5/README.md index 026a5feb86..abe4d843ea 100644 --- a/persistence-modules/hibernate5/README.md +++ b/persistence-modules/hibernate5/README.md @@ -32,3 +32,4 @@ - [Common Hibernate Exceptions](https://www.baeldung.com/hibernate-exceptions) - [Hibernate Aggregate Functions](https://www.baeldung.com/hibernate-aggregate-functions) - [Hibernate Query Plan Cache](https://www.baeldung.com/hibernate-query-plan-cache) +- [TransactionRequiredException Error](https://www.baeldung.com/jpa-transaction-required-exception) From 1df7e57d2da0ebce3e845c39345fa4d97ffc6a61 Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Tue, 9 Apr 2019 17:04:37 +0530 Subject: [PATCH 104/531] Back-link added --- core-java-11/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-11/README.md b/core-java-11/README.md index 3c8b94fa28..f53e32d9b2 100644 --- a/core-java-11/README.md +++ b/core-java-11/README.md @@ -4,3 +4,4 @@ - [Java 11 Local Variable Syntax for Lambda Parameters](https://www.baeldung.com/java-var-lambda-params) - [Java 11 String API Additions](https://www.baeldung.com/java-11-string-api) - [Java 11 Nest Based Access Control](https://www.baeldung.com/java-nest-based-access-control) +- [Guide to jlink](https://www.baeldung.com/jlink) From 1eb50c25fc9bd18f50bab23ca14a24ad01bfa6fe Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Tue, 9 Apr 2019 17:06:07 +0530 Subject: [PATCH 105/531] Back-link added --- core-groovy/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-groovy/README.md b/core-groovy/README.md index ec2fcfa574..af5d306915 100644 --- a/core-groovy/README.md +++ b/core-groovy/README.md @@ -8,3 +8,4 @@ - [Types of Strings in Groovy](https://www.baeldung.com/groovy-strings) - [A Quick Guide to Iterating a Map in Groovy](https://www.baeldung.com/groovy-map-iterating) - [An Introduction to Traits in Groovy](https://www.baeldung.com/groovy-traits) +- [Closures in Groovy](https://www.baeldung.com/groovy-closures) From 6cdccd151d84781a835e6bcf72b0ce97a1019e69 Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Tue, 9 Apr 2019 17:07:38 +0530 Subject: [PATCH 106/531] Back-link added --- core-groovy/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-groovy/README.md b/core-groovy/README.md index af5d306915..d659ff560d 100644 --- a/core-groovy/README.md +++ b/core-groovy/README.md @@ -9,3 +9,4 @@ - [A Quick Guide to Iterating a Map in Groovy](https://www.baeldung.com/groovy-map-iterating) - [An Introduction to Traits in Groovy](https://www.baeldung.com/groovy-traits) - [Closures in Groovy](https://www.baeldung.com/groovy-closures) +- [Finding Elements in Collections in Groovy](https://www.baeldung.com/groovy-collections-find-elements) From 34f76be30457d210bd61c5747a3bff7f81f45261 Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Tue, 9 Apr 2019 17:09:14 +0530 Subject: [PATCH 107/531] Back-link added --- core-java-networking/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-networking/README.md b/core-java-networking/README.md index 40be47fbcc..b3b973ef8e 100644 --- a/core-java-networking/README.md +++ b/core-java-networking/README.md @@ -15,3 +15,4 @@ - [URL Encoding and Decoding in Java](http://www.baeldung.com/java-url-encoding-decoding) - [How to Perform a Simple HTTP Request in Java](http://www.baeldung.com/java-http-request) - [Difference between URL and URI](http://www.baeldung.com/java-url-vs-uri) +- [Read an InputStream using the Java Server Socket](https://www.baeldung.com/java-inputstream-server-socket) From 9e87ba107f4e6f7e851299f8025670ffa709f82a Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Tue, 9 Apr 2019 17:10:31 +0530 Subject: [PATCH 108/531] Back-link added --- persistence-modules/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/persistence-modules/README.md b/persistence-modules/README.md index 87dc9522fd..d3308650a2 100644 --- a/persistence-modules/README.md +++ b/persistence-modules/README.md @@ -11,3 +11,4 @@ - [Pessimistic Locking in JPA](http://www.baeldung.com/jpa-pessimistic-locking) - [Get All Data from a Table with Hibernate](https://www.baeldung.com/hibernate-select-all) - [Spring Data with Reactive Cassandra](https://www.baeldung.com/spring-data-cassandra-reactive) +- [Spring Data JPA – Derived Delete Methods](https://www.baeldung.com/spring-data-jpa-deleteby) From b8d3ada5df44bbf7a4604c2ba3dcf6d011b7ea79 Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Tue, 9 Apr 2019 17:13:14 +0530 Subject: [PATCH 109/531] Back-link added --- kotlin-libraries/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/kotlin-libraries/README.md b/kotlin-libraries/README.md index 5e2526e64e..bf0c12259e 100644 --- a/kotlin-libraries/README.md +++ b/kotlin-libraries/README.md @@ -10,3 +10,4 @@ - [Introduction to Arrow in Kotlin](https://www.baeldung.com/kotlin-arrow) - [Kotlin with Ktor](https://www.baeldung.com/kotlin-ktor) - [REST API With Kotlin and Kovert](https://www.baeldung.com/kotlin-kovert) +- [Kotlin Immutable Collections](https://www.baeldung.com/kotlin-immutable-collections) From 42bb474bd18a569ed0ba7101db0c278fc197dad7 Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Tue, 9 Apr 2019 17:15:42 +0530 Subject: [PATCH 110/531] Back-link added --- kotlin-libraries/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/kotlin-libraries/README.md b/kotlin-libraries/README.md index bf0c12259e..1eb83c3a46 100644 --- a/kotlin-libraries/README.md +++ b/kotlin-libraries/README.md @@ -11,3 +11,4 @@ - [Kotlin with Ktor](https://www.baeldung.com/kotlin-ktor) - [REST API With Kotlin and Kovert](https://www.baeldung.com/kotlin-kovert) - [Kotlin Immutable Collections](https://www.baeldung.com/kotlin-immutable-collections) +- [MockK: A Mocking Library for Kotlin](https://www.baeldung.com/kotlin-mockk) From eaf1d3e35b3acc445e02b4da4b053a394986ff8b Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Tue, 9 Apr 2019 17:17:51 +0530 Subject: [PATCH 111/531] Back-link added --- persistence-modules/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/persistence-modules/README.md b/persistence-modules/README.md index d3308650a2..2fbaf25f2f 100644 --- a/persistence-modules/README.md +++ b/persistence-modules/README.md @@ -12,3 +12,4 @@ - [Get All Data from a Table with Hibernate](https://www.baeldung.com/hibernate-select-all) - [Spring Data with Reactive Cassandra](https://www.baeldung.com/spring-data-cassandra-reactive) - [Spring Data JPA – Derived Delete Methods](https://www.baeldung.com/spring-data-jpa-deleteby) +- [Difference Between save() and saveAndFlush() in Spring Data JPA](https://www.baeldung.com/spring-data-jpa-save-saveandflush) From 0e8774288e574dbcd98c4adc68116847a68de07e Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Tue, 9 Apr 2019 21:11:23 +0800 Subject: [PATCH 112/531] Update README.md --- core-java-9/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core-java-9/README.md b/core-java-9/README.md index 993beae0c8..0f091b23cb 100644 --- a/core-java-9/README.md +++ b/core-java-9/README.md @@ -29,3 +29,5 @@ - [Ahead of Time Compilation (AoT)](https://www.baeldung.com/ahead-of-time-compilation) - [Java 9 Process API Improvements](https://www.baeldung.com/java-9-process-api) - [Guide to java.lang.Process API](https://www.baeldung.com/java-process-api) +- [Java 9 New Features](https://www.baeldung.com/new-java-9) + From e6a032ce1d4cbe5bd8b210ff8c055c8214ed9a49 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Tue, 9 Apr 2019 21:22:17 +0800 Subject: [PATCH 113/531] Update README.md --- core-java-9/README.md | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/core-java-9/README.md b/core-java-9/README.md index 0f091b23cb..8fdc3f6ee2 100644 --- a/core-java-9/README.md +++ b/core-java-9/README.md @@ -5,29 +5,21 @@ [Java 9 New Features](http://www.baeldung.com/new-java-9) ### Relevant Articles: -- [Java 9 Stream API Improvements](http://www.baeldung.com/java-9-stream-api) -- [Java 9 Convenience Factory Methods for Collections](http://www.baeldung.com/java-9-collections-factory-methods) + +- [Java 9 New Features](https://www.baeldung.com/new-java-9) - [New Stream Collectors in Java 9](http://www.baeldung.com/java9-stream-collectors) -- [Java 9 CompletableFuture API Improvements](http://www.baeldung.com/java-9-completablefuture) -- [Introduction to Java 9 StackWalking API](http://www.baeldung.com/java-9-stackwalking-api) - [Introduction to Project Jigsaw](http://www.baeldung.com/project-jigsaw-java-modularity) -- [Java 9 Optional API Additions](http://www.baeldung.com/java-9-optional) -- [Java 9 Reactive Streams](http://www.baeldung.com/java-9-reactive-streams) -- [Java 9 java.util.Objects Additions](http://www.baeldung.com/java-9-objects-new) - [Java 9 Variable Handles Demystified](http://www.baeldung.com/java-variable-handles) - [Exploring the New HTTP Client in Java 9 and 11](http://www.baeldung.com/java-9-http-client) - [Method Handles in Java](http://www.baeldung.com/java-method-handles) - [Introduction to Chronicle Queue](http://www.baeldung.com/java-chronicle-queue) -- [A Guide to Java 9 Modularity](http://www.baeldung.com/java-9-modularity) - [Optional orElse Optional](http://www.baeldung.com/java-optional-or-else-optional) -- [Java 9 java.lang.Module API](http://www.baeldung.com/java-9-module-api) - [Iterate Through a Range of Dates in Java](https://www.baeldung.com/java-iterate-date-range) - [Initialize a HashMap in Java](https://www.baeldung.com/java-initialize-hashmap) -- [Java 9 Platform Logging API](https://www.baeldung.com/java-9-logging-api) - [Immutable Set in Java](https://www.baeldung.com/java-immutable-set) - [Multi-Release Jar Files](https://www.baeldung.com/java-multi-release-jar) - [Ahead of Time Compilation (AoT)](https://www.baeldung.com/ahead-of-time-compilation) - [Java 9 Process API Improvements](https://www.baeldung.com/java-9-process-api) - [Guide to java.lang.Process API](https://www.baeldung.com/java-process-api) -- [Java 9 New Features](https://www.baeldung.com/new-java-9) + From 043f4aa474fea628f0cb48e89a8220ba63ae182d Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Tue, 9 Apr 2019 21:33:48 +0800 Subject: [PATCH 114/531] Update README.md --- core-kotlin-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-kotlin-2/README.md b/core-kotlin-2/README.md index 4ac1c2c7bb..302bcd0a42 100644 --- a/core-kotlin-2/README.md +++ b/core-kotlin-2/README.md @@ -4,3 +4,4 @@ - [How to use Kotlin Range Expressions](https://www.baeldung.com/kotlin-ranges) - [Split a List into Parts in Kotlin](https://www.baeldung.com/kotlin-split-list-into-parts) - [String Comparison in Kotlin](https://www.baeldung.com/kotlin-string-comparison) +- [Kotlin Annotations](https://www.baeldung.com/kotlin-annotations) From 3f651cf862f2a9c733a8c089fb037f9cdef755f0 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Tue, 9 Apr 2019 21:35:04 +0800 Subject: [PATCH 115/531] Update README.md --- spring-boot-rest/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-boot-rest/README.md b/spring-boot-rest/README.md index af372077f0..f257332df6 100644 --- a/spring-boot-rest/README.md +++ b/spring-boot-rest/README.md @@ -11,3 +11,4 @@ Module for the articles that are part of the Spring REST E-book: 9. [ETags for REST with Spring](http://www.baeldung.com/etags-for-rest-with-spring) 10. [Testing REST with multiple MIME types](http://www.baeldung.com/testing-rest-api-with-multiple-media-types) 11. [Testing Web APIs with Postman Collections](https://www.baeldung.com/postman-testing-collections) +12. [Spring Boot Consuming and Producing JSON](https://www.baeldung.com/spring-boot-json) From 59fed13f32a3fa8f61b8ad5c91e568af5b736398 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Tue, 9 Apr 2019 21:37:22 +0800 Subject: [PATCH 116/531] Update README.md --- core-kotlin-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-kotlin-2/README.md b/core-kotlin-2/README.md index 302bcd0a42..1670ca543c 100644 --- a/core-kotlin-2/README.md +++ b/core-kotlin-2/README.md @@ -5,3 +5,4 @@ - [Split a List into Parts in Kotlin](https://www.baeldung.com/kotlin-split-list-into-parts) - [String Comparison in Kotlin](https://www.baeldung.com/kotlin-string-comparison) - [Kotlin Annotations](https://www.baeldung.com/kotlin-annotations) +- [Kotlin Scope Functions](https://www.baeldung.com/kotlin-scope-functions) From 97a66d549867183c730c421fcd37a64bfaba0118 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Tue, 9 Apr 2019 21:38:58 +0800 Subject: [PATCH 117/531] Update README.md --- testing-modules/rest-assured/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/testing-modules/rest-assured/README.md b/testing-modules/rest-assured/README.md index de15515f9d..d44fd08335 100644 --- a/testing-modules/rest-assured/README.md +++ b/testing-modules/rest-assured/README.md @@ -1,3 +1,4 @@ ###Relevant Articles: - [A Guide to REST-assured](http://www.baeldung.com/rest-assured-tutorial) - [REST-assured Support for Spring MockMvc](https://www.baeldung.com/spring-mock-mvc-rest-assured) +- [Getting and Verifying Response Data with REST-assured](https://www.baeldung.com/rest-assured-response) From ea9461efadb486d0689dc194e15d71f8aced0272 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Tue, 9 Apr 2019 21:41:26 +0800 Subject: [PATCH 118/531] Update README.MD --- persistence-modules/spring-boot-persistence/README.MD | 1 + 1 file changed, 1 insertion(+) diff --git a/persistence-modules/spring-boot-persistence/README.MD b/persistence-modules/spring-boot-persistence/README.MD index ee7c2e298e..709f505ea9 100644 --- a/persistence-modules/spring-boot-persistence/README.MD +++ b/persistence-modules/spring-boot-persistence/README.MD @@ -8,3 +8,4 @@ - [Integrating Spring Boot with HSQLDB](https://www.baeldung.com/spring-boot-hsqldb) - [Configuring a DataSource Programmatically in Spring Boot](https://www.baeldung.com/spring-boot-configure-data-source-programmatic) - [Resolving “Failed to Configure a DataSource†Error](https://www.baeldung.com/spring-boot-failed-to-configure-data-source) +- [Spring Boot with Hibernate](https://www.baeldung.com/spring-boot-hibernate) From a2f1202da4b1b56db1232d74e87e3dcd8b8503f2 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Tue, 9 Apr 2019 21:43:51 +0800 Subject: [PATCH 119/531] Update README.md --- spring-mvc-java/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-mvc-java/README.md b/spring-mvc-java/README.md index a7e0798593..3deeb21afc 100644 --- a/spring-mvc-java/README.md +++ b/spring-mvc-java/README.md @@ -31,3 +31,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Using Spring @ResponseStatus to Set HTTP Status Code](http://www.baeldung.com/spring-response-status) - [Spring MVC Tutorial](https://www.baeldung.com/spring-mvc-tutorial) - [Working with Date Parameters in Spring](https://www.baeldung.com/spring-date-parameters) +- [A Java Web Application Without a web.xml](https://www.baeldung.com/java-web-app-without-web-xml) From e19cdb528370e5c94c7bfdf030ec8c457da0c5d4 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Tue, 9 Apr 2019 21:44:36 +0800 Subject: [PATCH 120/531] Update README.md --- spring-mvc-xml/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-mvc-xml/README.md b/spring-mvc-xml/README.md index dbc6125424..216517f52d 100644 --- a/spring-mvc-xml/README.md +++ b/spring-mvc-xml/README.md @@ -14,3 +14,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Guide to JavaServer Pages (JSP)](http://www.baeldung.com/jsp) - [Exploring SpringMVC’s Form Tag Library](http://www.baeldung.com/spring-mvc-form-tags) - [web.xml vs Initializer with Spring](http://www.baeldung.com/spring-xml-vs-java-config) +- [A Java Web Application Without a web.xml](https://www.baeldung.com/java-web-app-without-web-xml) From cee2d25100b54a11a677932cdc61c146968b035c Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Tue, 9 Apr 2019 21:47:32 +0800 Subject: [PATCH 121/531] Update README.md --- core-kotlin-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-kotlin-2/README.md b/core-kotlin-2/README.md index 1670ca543c..2c6b205600 100644 --- a/core-kotlin-2/README.md +++ b/core-kotlin-2/README.md @@ -6,3 +6,4 @@ - [String Comparison in Kotlin](https://www.baeldung.com/kotlin-string-comparison) - [Kotlin Annotations](https://www.baeldung.com/kotlin-annotations) - [Kotlin Scope Functions](https://www.baeldung.com/kotlin-scope-functions) +- [Creating a Kotlin Range Iterator on a Custom Object](https://www.baeldung.com/kotlin-custom-range-iterator) From a95cf305da9dde83258984bddface4fd1b220e62 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Tue, 9 Apr 2019 21:51:30 +0800 Subject: [PATCH 122/531] Update README.md --- rxjava-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/rxjava-2/README.md b/rxjava-2/README.md index d0bdeec684..0f4864e1a0 100644 --- a/rxjava-2/README.md +++ b/rxjava-2/README.md @@ -7,3 +7,4 @@ - [Introduction to RxRelay for RxJava](http://www.baeldung.com/rx-relay) - [Combining RxJava Completables](https://www.baeldung.com/rxjava-completable) - [Converting Synchronous and Asynchronous APIs to Observables using RxJava2](https://www.baeldung.com/rxjava-apis-to-observables) +- [RxJava Hooks](https://www.baeldung.com/rxjava-hooks) From 0740d9b3c99b53d95c58cd40bdb3de30aba750aa Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Tue, 9 Apr 2019 21:53:48 +0800 Subject: [PATCH 123/531] Update README.md --- spring-all/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-all/README.md b/spring-all/README.md index a111d2e542..c4e400d9a3 100644 --- a/spring-all/README.md +++ b/spring-all/README.md @@ -34,3 +34,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Spring Events](https://www.baeldung.com/spring-events) - [Spring Null-Safety Annotations](https://www.baeldung.com/spring-null-safety-annotations) - [Spring JDBC](https://www.baeldung.com/spring-jdbc-jdbctemplate) +- [Using @Autowired in Abstract Classes](https://www.baeldung.com/spring-autowired-abstract-class) From 8a06c29898c34e280ae9ea829b8e47a6639bfcc2 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Tue, 9 Apr 2019 21:56:36 +0800 Subject: [PATCH 124/531] Update README.md --- kotlin-libraries/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/kotlin-libraries/README.md b/kotlin-libraries/README.md index 5e2526e64e..00b87a8715 100644 --- a/kotlin-libraries/README.md +++ b/kotlin-libraries/README.md @@ -10,3 +10,4 @@ - [Introduction to Arrow in Kotlin](https://www.baeldung.com/kotlin-arrow) - [Kotlin with Ktor](https://www.baeldung.com/kotlin-ktor) - [REST API With Kotlin and Kovert](https://www.baeldung.com/kotlin-kovert) +- [MockK: A Mocking Library for Kotlin](https://www.baeldung.com/kotlin-mockk) From f03b8a48c12d0fd8a8d6c7c3393c20a7eca60ad5 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Tue, 9 Apr 2019 21:58:58 +0800 Subject: [PATCH 125/531] Update README.md --- kotlin-libraries/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/kotlin-libraries/README.md b/kotlin-libraries/README.md index 00b87a8715..466b8e92d3 100644 --- a/kotlin-libraries/README.md +++ b/kotlin-libraries/README.md @@ -11,3 +11,4 @@ - [Kotlin with Ktor](https://www.baeldung.com/kotlin-ktor) - [REST API With Kotlin and Kovert](https://www.baeldung.com/kotlin-kovert) - [MockK: A Mocking Library for Kotlin](https://www.baeldung.com/kotlin-mockk) +- [Kotlin Immutable Collections](https://www.baeldung.com/kotlin-immutable-collections) From bbce155a78d28db6d5bf334a01ffce43f309c365 Mon Sep 17 00:00:00 2001 From: "sumit.sg34" Date: Tue, 9 Apr 2019 22:44:45 +0530 Subject: [PATCH 126/531] BAEL-2841 spring data jpa populators --- persistence-modules/spring-data-jpa-2/pom.xml | 56 +++++++++++-------- .../com/baeldung/config/JpaPopulators.java | 33 +++++++++++ .../main/java/com/baeldung/entity/Fruit.java | 2 + .../src/main/resources/fruit-data.json | 14 +++++ .../src/main/resources/fruit-data.xml | 7 +++ .../repository/FruitPopulatorTest.java | 53 ++++++++++++++++++ 6 files changed, 142 insertions(+), 23 deletions(-) create mode 100644 persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/config/JpaPopulators.java create mode 100644 persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.json create mode 100644 persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.xml create mode 100644 persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/repository/FruitPopulatorTest.java diff --git a/persistence-modules/spring-data-jpa-2/pom.xml b/persistence-modules/spring-data-jpa-2/pom.xml index 8e46112659..5080ad9bd3 100644 --- a/persistence-modules/spring-data-jpa-2/pom.xml +++ b/persistence-modules/spring-data-jpa-2/pom.xml @@ -1,30 +1,40 @@ - 4.0.0 + 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 com.baeldung - spring-data-jpa-2 + spring-data-jpa-2 spring-data-jpa - - - parent-boot-2 - com.baeldung - 0.0.1-SNAPSHOT - ../../parent-boot-2 - - - - org.springframework.boot - spring-boot-starter-data-jpa - - - - com.h2database - h2 - - - + + parent-boot-2 + com.baeldung + 0.0.1-SNAPSHOT + ../../parent-boot-2 + + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + + com.h2database + h2 + + + + com.fasterxml.jackson.core + jackson-databind + + + + org.springframework + spring-oxm + + + \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/config/JpaPopulators.java b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/config/JpaPopulators.java new file mode 100644 index 0000000000..cb4b32aabc --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/config/JpaPopulators.java @@ -0,0 +1,33 @@ +package com.baeldung.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; +import org.springframework.data.repository.init.Jackson2RepositoryPopulatorFactoryBean; +import org.springframework.data.repository.init.UnmarshallerRepositoryPopulatorFactoryBean; +import org.springframework.oxm.jaxb.Jaxb2Marshaller; + +import com.baeldung.entity.Fruit; + +@Configuration +public class JpaPopulators { + + @Bean + public Jackson2RepositoryPopulatorFactoryBean getRespositoryPopulator() throws Exception { + Jackson2RepositoryPopulatorFactoryBean factory = new Jackson2RepositoryPopulatorFactoryBean(); + factory.setResources(new Resource[] { (Resource) new ClassPathResource("fruit-data.json") }); + return factory; + } + + @Bean + public UnmarshallerRepositoryPopulatorFactoryBean repositoryPopulator() { + Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); + marshaller.setClassesToBeBound(Fruit.class); + UnmarshallerRepositoryPopulatorFactoryBean factory = new UnmarshallerRepositoryPopulatorFactoryBean(); + factory.setUnmarshaller(marshaller); + factory.setResources(new Resource[] { new ClassPathResource("fruit-data.xml") }); + return factory; + } + +} diff --git a/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/entity/Fruit.java b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/entity/Fruit.java index f82022e67e..d45ac33db8 100644 --- a/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/entity/Fruit.java +++ b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/entity/Fruit.java @@ -2,7 +2,9 @@ package com.baeldung.entity; import javax.persistence.Entity; import javax.persistence.Id; +import javax.xml.bind.annotation.XmlRootElement; +@XmlRootElement @Entity public class Fruit { diff --git a/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.json b/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.json new file mode 100644 index 0000000000..214ea18e4d --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.json @@ -0,0 +1,14 @@ +[ + { + "_class": "com.baeldung.entity.Fruit", + "name": "apple", + "color": "red", + "id": 1 + }, + { + "_class": "com.baeldung.entity.Fruit", + "name": "guava", + "color": "green", + "id": 2 + } +] \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.xml b/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.xml new file mode 100644 index 0000000000..fe6eb71faf --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.xml @@ -0,0 +1,7 @@ + + + + 3 + mango + yellow + diff --git a/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/repository/FruitPopulatorTest.java b/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/repository/FruitPopulatorTest.java new file mode 100644 index 0000000000..8760c69ce8 --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/repository/FruitPopulatorTest.java @@ -0,0 +1,53 @@ +package com.baeldung.repository; + +import static org.junit.Assert.assertEquals; + +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.entity.Fruit; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class FruitPopulatorTest { + + @Autowired + private FruitRepository fruitRepository; + + @Test + public void givenFruitJsonPopulatorThenShouldInsertRecordOnStart() { + + List fruits = fruitRepository.findAll(); + assertEquals("record count is not matching", 3, fruits.size()); + + fruits.forEach(fruit -> { + if (1 == fruit.getId()) { + assertEquals("This is not an apple", "apple", fruit.getName()); + assertEquals("It is not a red colored fruit", "red", fruit.getColor()); + } else if (2 == fruit.getId()) { + assertEquals("This is not a guava", "guava", fruit.getName()); + assertEquals("It is not a green colored fruit", "green", fruit.getColor()); + } + }); + } + + @Test + public void givenFruitXmlPopulatorThenShouldInsertRecordOnStart() { + + List fruits = fruitRepository.findAll(); + assertEquals("record count is not matching", 3, fruits.size()); + + fruits.forEach(fruit -> { + if (3 == fruit.getId()) { + assertEquals("This is not a mango", "mango", fruit.getName()); + assertEquals("It is not a yellow colored fruit", "yellow", fruit.getColor()); + } + }); + } + +} From 9e1bb2b8c8e79d7952bae87743d75d68cd9a24e0 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Wed, 10 Apr 2019 14:16:37 +0800 Subject: [PATCH 127/531] Update README.md --- persistence-modules/spring-data-jpa-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/persistence-modules/spring-data-jpa-2/README.md b/persistence-modules/spring-data-jpa-2/README.md index 295a434d17..387b1157c4 100644 --- a/persistence-modules/spring-data-jpa-2/README.md +++ b/persistence-modules/spring-data-jpa-2/README.md @@ -3,3 +3,4 @@ ## Spring Data JPA Example Project ### Relevant Articles: +[Spring Data JPA – Derived Delete Methods](https://www.baeldung.com/spring-data-jpa-deleteby) From 0b601e8f0134bd16d28e9dab0c12a5cb8797097c Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Wed, 10 Apr 2019 14:16:48 +0800 Subject: [PATCH 128/531] Update README.md --- persistence-modules/spring-data-jpa-2/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/persistence-modules/spring-data-jpa-2/README.md b/persistence-modules/spring-data-jpa-2/README.md index 387b1157c4..41381ab82a 100644 --- a/persistence-modules/spring-data-jpa-2/README.md +++ b/persistence-modules/spring-data-jpa-2/README.md @@ -3,4 +3,4 @@ ## Spring Data JPA Example Project ### Relevant Articles: -[Spring Data JPA – Derived Delete Methods](https://www.baeldung.com/spring-data-jpa-deleteby) +- [Spring Data JPA – Derived Delete Methods](https://www.baeldung.com/spring-data-jpa-deleteby) From ae4654c8bc4ce079d81c5839261166d6c19dcd20 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Wed, 10 Apr 2019 14:21:17 +0800 Subject: [PATCH 129/531] Update README.md --- core-java-networking/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core-java-networking/README.md b/core-java-networking/README.md index e76f28030d..2341520df7 100644 --- a/core-java-networking/README.md +++ b/core-java-networking/README.md @@ -14,4 +14,5 @@ - [A Guide to Java Sockets](http://www.baeldung.com/a-guide-to-java-sockets) - [Guide to Java URL Encoding/Decoding](http://www.baeldung.com/java-url-encoding-decoding) - [Do a Simple HTTP Request in Java](http://www.baeldung.com/java-http-request) -- [Difference between URL and URI](http://www.baeldung.com/java-url-vs-uri) \ No newline at end of file +- [Difference between URL and URI](http://www.baeldung.com/java-url-vs-uri) +- [Read an InputStream using the Java Server Socket](https://www.baeldung.com/java-inputstream-server-socket) From 29602cfa890a1ba5340d7bb782686c6d37997270 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Wed, 10 Apr 2019 14:22:20 +0800 Subject: [PATCH 130/531] Update README.md --- core-groovy/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-groovy/README.md b/core-groovy/README.md index 606a317747..f5c4c260ae 100644 --- a/core-groovy/README.md +++ b/core-groovy/README.md @@ -11,3 +11,4 @@ - [Lists in Groovy](https://www.baeldung.com/groovy-lists) - [Converting a String to a Date in Groovy](https://www.baeldung.com/groovy-string-to-date) - [Guide to I/O in Groovy](https://www.baeldung.com/groovy-io) +- [Finding Elements in Collections in Groovy](https://www.baeldung.com/groovy-collections-find-elements) From 947adea837553c9cedb73b04cb0be1b118344842 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Wed, 10 Apr 2019 14:25:02 +0800 Subject: [PATCH 131/531] Update README.md --- core-groovy/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-groovy/README.md b/core-groovy/README.md index f5c4c260ae..c7d54a4fd8 100644 --- a/core-groovy/README.md +++ b/core-groovy/README.md @@ -12,3 +12,4 @@ - [Converting a String to a Date in Groovy](https://www.baeldung.com/groovy-string-to-date) - [Guide to I/O in Groovy](https://www.baeldung.com/groovy-io) - [Finding Elements in Collections in Groovy](https://www.baeldung.com/groovy-collections-find-elements) +- [Closures in Groovy](https://www.baeldung.com/groovy-closures) From ed38d1660bb9132575254df4fe21757c01efc61c Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Wed, 10 Apr 2019 14:26:51 +0800 Subject: [PATCH 132/531] Update README.md --- core-java-11/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-11/README.md b/core-java-11/README.md index b09649f4f1..a4b0e0e59c 100644 --- a/core-java-11/README.md +++ b/core-java-11/README.md @@ -6,3 +6,4 @@ - [Java 11 Nest Based Access Control](https://www.baeldung.com/java-nest-based-access-control) - [Exploring the New HTTP Client in Java 9 and 11](https://www.baeldung.com/java-9-http-client) - [An Introduction to Epsilon GC: A No-Op Experimental Garbage Collector](https://www.baeldung.com/jvm-epsilon-gc-garbage-collector) +- [Guide to jlink](https://www.baeldung.com/jlink) From 139e2819d7a2d653a76e0fc7fd2248a5f1cabe6e Mon Sep 17 00:00:00 2001 From: Alexander Molochko Date: Wed, 10 Apr 2019 13:08:00 +0300 Subject: [PATCH 133/531] Add readtext example --- .../inputstream/InputStreamToStringTest.kt | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/core-kotlin-2/src/test/kotlin/com/baeldung/inputstream/InputStreamToStringTest.kt b/core-kotlin-2/src/test/kotlin/com/baeldung/inputstream/InputStreamToStringTest.kt index 0a053d61ec..3437ddb68a 100644 --- a/core-kotlin-2/src/test/kotlin/com/baeldung/inputstream/InputStreamToStringTest.kt +++ b/core-kotlin-2/src/test/kotlin/com/baeldung/inputstream/InputStreamToStringTest.kt @@ -10,8 +10,6 @@ class InputStreamToStringTest { private val fileName = "src/test/resources/inputstream2string.txt" private val fileFullContent = "Computer programming can be a hassle\r\n" + "It's like trying to take a defended castle" - private val fileContentUpToStopChar = "Computer programming can be a hassle\r\n" + - "It" @Test fun whenReadFileWithBufferedReader_thenFullFileContentIsReadAsString() { @@ -20,7 +18,19 @@ class InputStreamToStringTest { val content = inputStream.bufferedReader().use(BufferedReader::readText) assertEquals(fileFullContent, content) } - + @Test + fun whenReadFileWithBufferedReaderReadText_thenFullFileContentIsReadAsString() { + val file = File(fileName) + val inputStream = file.inputStream() + val reader = BufferedReader(inputStream.reader()) + var content: String + try { + content = reader.readText() + } finally { + reader.close() + } + assertEquals(fileFullContent, content) + } @Test fun whenReadFileWithBufferedReaderManually_thenFullFileContentIsReadAsString() { val file = File(fileName) @@ -44,8 +54,8 @@ class InputStreamToStringTest { fun whenReadFileUpToStopChar_thenPartBeforeStopCharIsReadAsString() { val file = File(fileName) val inputStream = file.inputStream() - val content = inputStream.use { it.readUpToChar('\'') } - assertEquals(fileContentUpToStopChar, content) + val content = inputStream.use { it.readUpToChar(' ') } + assertEquals("Computer", content) } @Test From 2674f7abff53137b5680ac2d9ecc5c86bbc3e9cb Mon Sep 17 00:00:00 2001 From: mprevisic Date: Sat, 6 Apr 2019 20:45:08 +0200 Subject: [PATCH 134/531] BAEL-1970 minor log message correction --- .../main/java/com/baeldung/component/OtherComponent.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-boot-testing/src/main/java/com/baeldung/component/OtherComponent.java b/spring-boot-testing/src/main/java/com/baeldung/component/OtherComponent.java index 61f5b440c3..97f001a9e5 100644 --- a/spring-boot-testing/src/main/java/com/baeldung/component/OtherComponent.java +++ b/spring-boot-testing/src/main/java/com/baeldung/component/OtherComponent.java @@ -10,10 +10,10 @@ public class OtherComponent { private static final Logger LOG = LoggerFactory.getLogger(OtherComponent.class); public void processData() { - LOG.trace("This is a TRACE log from OtherComponent"); - LOG.debug("This is a DEBUG log from OtherComponent"); - LOG.info("This is an INFO log from OtherComponent"); - LOG.error("This is an ERROR log from OtherComponent"); + LOG.trace("This is a TRACE log from another package"); + LOG.debug("This is a DEBUG log from another package"); + LOG.info("This is an INFO log from another package"); + LOG.error("This is an ERROR log from another package"); } } From 0554797999b0ed045f584451c41b031ca9e06ce7 Mon Sep 17 00:00:00 2001 From: Ekaterina Galkina Date: Wed, 10 Apr 2019 18:47:23 +0500 Subject: [PATCH 135/531] replace --- .../src/main/java/com/baeldung/entity}/Customer.java | 2 +- .../java/com/baeldung/repository}/CustomerRepository.java | 3 ++- .../repository}/CustomerRepositoryIntegrationTest.java | 8 +++----- 3 files changed, 6 insertions(+), 7 deletions(-) rename persistence-modules/{spring-data-jpa/src/main/java/com/baeldung/customer => spring-data-jpa-2/src/main/java/com/baeldung/entity}/Customer.java (95%) rename persistence-modules/{spring-data-jpa/src/main/java/com/baeldung/customer => spring-data-jpa-2/src/main/java/com/baeldung/repository}/CustomerRepository.java (89%) rename persistence-modules/{spring-data-jpa/src/test/java/com/baeldung/customer => spring-data-jpa-2/src/test/java/com/baeldung/repository}/CustomerRepositoryIntegrationTest.java (83%) diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/customer/Customer.java b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/entity/Customer.java similarity index 95% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/customer/Customer.java rename to persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/entity/Customer.java index ed922c3075..efcae73853 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/customer/Customer.java +++ b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/entity/Customer.java @@ -1,4 +1,4 @@ -package com.baeldung.customer; +package com.baeldung.entity; import javax.persistence.Entity; import javax.persistence.GeneratedValue; diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/customer/CustomerRepository.java b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/repository/CustomerRepository.java similarity index 89% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/customer/CustomerRepository.java rename to persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/repository/CustomerRepository.java index c354ccbb58..65b22bbd84 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/customer/CustomerRepository.java +++ b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/repository/CustomerRepository.java @@ -1,5 +1,6 @@ -package com.baeldung.customer; +package com.baeldung.repository; +import com.baeldung.entity.Customer; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; diff --git a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/customer/CustomerRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/repository/CustomerRepositoryIntegrationTest.java similarity index 83% rename from persistence-modules/spring-data-jpa/src/test/java/com/baeldung/customer/CustomerRepositoryIntegrationTest.java rename to persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/repository/CustomerRepositoryIntegrationTest.java index c3bd821f52..5d6457ce30 100644 --- a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/customer/CustomerRepositoryIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/repository/CustomerRepositoryIntegrationTest.java @@ -1,8 +1,6 @@ -package com.baeldung.customer; +package com.baeldung.repository; -import com.baeldung.config.PersistenceConfiguration; -import com.baeldung.config.PersistenceProductConfiguration; -import com.baeldung.config.PersistenceUserConfiguration; +import com.baeldung.entity.Customer; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -17,7 +15,7 @@ import java.util.List; import static org.junit.Assert.assertEquals; -@DataJpaTest(excludeAutoConfiguration = { PersistenceConfiguration.class, PersistenceUserConfiguration.class, PersistenceProductConfiguration.class }) +@DataJpaTest @RunWith(SpringRunner.class) public class CustomerRepositoryIntegrationTest { From 7186d96b12c4906243828b5875a2bc4e10e7121f Mon Sep 17 00:00:00 2001 From: mprevisic Date: Wed, 10 Apr 2019 15:28:37 +0200 Subject: [PATCH 136/531] BAEL-1970 fixed formatting (use spaces instead of tabs) --- ...ltiProfileTestLogLevelIntegrationTest.java | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackMultiProfileTestLogLevelIntegrationTest.java b/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackMultiProfileTestLogLevelIntegrationTest.java index 5192a1f00e..7a1eb4adbe 100644 --- a/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackMultiProfileTestLogLevelIntegrationTest.java +++ b/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackMultiProfileTestLogLevelIntegrationTest.java @@ -22,49 +22,49 @@ import org.springframework.test.context.junit4.SpringRunner; @ActiveProfiles("logback-test2") public class LogbackMultiProfileTestLogLevelIntegrationTest { - @Autowired - private TestRestTemplate restTemplate; + @Autowired + private TestRestTemplate restTemplate; - @Rule - public OutputCapture outputCapture = new OutputCapture(); + @Rule + public OutputCapture outputCapture = new OutputCapture(); - private String baseUrl = "/testLogLevel"; + private String baseUrl = "/testLogLevel"; - @Test - public void givenErrorRootLevelAndTraceLevelForOurPackage_whenCall_thenPrintTraceLogsForOurPackage() { - ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); + @Test + public void givenErrorRootLevelAndTraceLevelForOurPackage_whenCall_thenPrintTraceLogsForOurPackage() { + ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); - assertThat(response.getStatusCode().value()).isEqualTo(200); - assertThatOutputContainsLogForOurPackage("TRACE"); - } + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThatOutputContainsLogForOurPackage("TRACE"); + } - @Test - public void givenErrorRootLevelAndTraceLevelForOurPackage_whenCall_thenNoTraceLogsForOtherPackages() { - ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); + @Test + public void givenErrorRootLevelAndTraceLevelForOurPackage_whenCall_thenNoTraceLogsForOtherPackages() { + ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); - assertThat(response.getStatusCode().value()).isEqualTo(200); - assertThatOutputDoesntContainLogForOtherPackages("TRACE"); - } + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThatOutputDoesntContainLogForOtherPackages("TRACE"); + } - @Test - public void givenErrorRootLevelAndTraceLevelForOurPackage_whenCall_thenPrintErrorLogs() { - ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); + @Test + public void givenErrorRootLevelAndTraceLevelForOurPackage_whenCall_thenPrintErrorLogs() { + ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); - assertThat(response.getStatusCode().value()).isEqualTo(200); - assertThatOutputContainsLogForOurPackage("ERROR"); - assertThatOutputContainsLogForOtherPackages("ERROR"); - } + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThatOutputContainsLogForOurPackage("ERROR"); + assertThatOutputContainsLogForOtherPackages("ERROR"); + } - private void assertThatOutputContainsLogForOurPackage(String level) { - assertThat(outputCapture.toString()).containsPattern("TestLogLevelController.*" + level + ".*"); - } + private void assertThatOutputContainsLogForOurPackage(String level) { + assertThat(outputCapture.toString()).containsPattern("TestLogLevelController.*" + level + ".*"); + } - private void assertThatOutputDoesntContainLogForOtherPackages(String level) { - assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).doesNotContain(level); - } + private void assertThatOutputDoesntContainLogForOtherPackages(String level) { + assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).doesNotContain(level); + } - private void assertThatOutputContainsLogForOtherPackages(String level) { - assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).contains(level); - } + private void assertThatOutputContainsLogForOtherPackages(String level) { + assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).contains(level); + } } From c3bd97f39a67cb38f3adf850b1f88d3642b3ff3b Mon Sep 17 00:00:00 2001 From: mprevisic Date: Wed, 10 Apr 2019 15:52:47 +0200 Subject: [PATCH 137/531] BAEL-1970 fixed formatting in xml files --- .../test/resources/logback-multiprofile.xml | 34 +++++++++---------- .../src/test/resources/logback-test.xml | 22 ++++++------ 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/spring-boot-testing/src/test/resources/logback-multiprofile.xml b/spring-boot-testing/src/test/resources/logback-multiprofile.xml index 3711f1ec71..09ca6e4cac 100644 --- a/spring-boot-testing/src/test/resources/logback-multiprofile.xml +++ b/spring-boot-testing/src/test/resources/logback-multiprofile.xml @@ -1,18 +1,18 @@ - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - - - - - - \ No newline at end of file + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + + + + diff --git a/spring-boot-testing/src/test/resources/logback-test.xml b/spring-boot-testing/src/test/resources/logback-test.xml index 9c6df17024..312af7c2bf 100644 --- a/spring-boot-testing/src/test/resources/logback-test.xml +++ b/spring-boot-testing/src/test/resources/logback-test.xml @@ -1,13 +1,13 @@ - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + From 998e2b7eeb4cd08afb682dfad3955fe06d4018dc Mon Sep 17 00:00:00 2001 From: Anshul Bansal Date: Wed, 10 Apr 2019 16:55:52 +0300 Subject: [PATCH 138/531] BAEL-2800_Copying_a_HashMap_in_Java - module renamed to core-java-collections-map --- .../README.md | 0 .../pom.xml | 4 ++-- .../main/java/com/baeldung/copyinghashmap/CopyHashMap.java | 0 .../java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java | 0 .../src/test/java/com/baeldung/copyinghashmap/Employee.java | 0 pom.xml | 4 ++-- 6 files changed, 4 insertions(+), 4 deletions(-) rename {core-java-collections-2 => core-java-collections-map}/README.md (100%) rename {core-java-collections-2 => core-java-collections-map}/pom.xml (96%) rename {core-java-collections-2 => core-java-collections-map}/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java (100%) rename {core-java-collections-2 => core-java-collections-map}/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java (100%) rename {core-java-collections-2 => core-java-collections-map}/src/test/java/com/baeldung/copyinghashmap/Employee.java (100%) diff --git a/core-java-collections-2/README.md b/core-java-collections-map/README.md similarity index 100% rename from core-java-collections-2/README.md rename to core-java-collections-map/README.md diff --git a/core-java-collections-2/pom.xml b/core-java-collections-map/pom.xml similarity index 96% rename from core-java-collections-2/pom.xml rename to core-java-collections-map/pom.xml index 677e6fd312..8c0aef54bf 100644 --- a/core-java-collections-2/pom.xml +++ b/core-java-collections-map/pom.xml @@ -1,9 +1,9 @@ 4.0.0 - core-java-collections-2 + core-java-collections-map 0.1.0-SNAPSHOT - core-java-collections-2 + core-java-collections-map jar diff --git a/core-java-collections-2/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java b/core-java-collections-map/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java similarity index 100% rename from core-java-collections-2/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java rename to core-java-collections-map/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java diff --git a/core-java-collections-2/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java b/core-java-collections-map/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java similarity index 100% rename from core-java-collections-2/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java rename to core-java-collections-map/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java diff --git a/core-java-collections-2/src/test/java/com/baeldung/copyinghashmap/Employee.java b/core-java-collections-map/src/test/java/com/baeldung/copyinghashmap/Employee.java similarity index 100% rename from core-java-collections-2/src/test/java/com/baeldung/copyinghashmap/Employee.java rename to core-java-collections-map/src/test/java/com/baeldung/copyinghashmap/Employee.java diff --git a/pom.xml b/pom.xml index 1f3901111d..a0b2948752 100644 --- a/pom.xml +++ b/pom.xml @@ -383,7 +383,7 @@ core-java-arrays core-java-collections - core-java-collections-2 + core-java-collections-map core-java-collections-list core-java-concurrency-basic core-java-concurrency-collections @@ -1031,7 +1031,7 @@ core-java-arrays core-java-collections - core-java-collections-2 + core-java-collections-map core-java-collections-list core-java-concurrency-basic core-java-concurrency-collections From 437efd7242b94e4a9570a2ef07e25698272905c0 Mon Sep 17 00:00:00 2001 From: Anshul Bansal Date: Wed, 10 Apr 2019 16:56:53 +0300 Subject: [PATCH 139/531] BAEL-2800_Copying_a_HashMap_in_Java --- .../com/baeldung/copyinghashmap/CopyHashMap.java | 16 ++++++++-------- .../copyinghashmap/CopyHashMapUnitTest.java | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/core-java-collections-map/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java b/core-java-collections-map/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java index cd81f61b48..e1649f593c 100644 --- a/core-java-collections-map/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java +++ b/core-java-collections-map/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java @@ -19,29 +19,29 @@ public class CopyHashMap { } public static HashMap copyUsingPut(HashMap originalMap) { - HashMap copyMap = new HashMap(); + HashMap shallowCopy = new HashMap(); Set> entries = originalMap.entrySet(); for(Map.Entry mapEntry: entries) { - copyMap.put(mapEntry.getKey(), mapEntry.getValue()); + shallowCopy.put(mapEntry.getKey(), mapEntry.getValue()); } - return copyMap; + return shallowCopy; } public static HashMap copyUsingPutAll(HashMap originalMap) { - HashMap copyMap = new HashMap(); - copyMap.putAll(originalMap); + HashMap shallowCopy = new HashMap(); + shallowCopy.putAll(originalMap); - return copyMap; + return shallowCopy; } public static HashMap copyUsingJava8Stream(HashMap originalMap) { Set> entries = originalMap.entrySet(); - HashMap copyMap = (HashMap) entries + HashMap shallowCopy = (HashMap) entries .stream() .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - return copyMap; + return shallowCopy; } public static HashMap shallowCopy(HashMap originalMap) { diff --git a/core-java-collections-map/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java b/core-java-collections-map/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java index c71e17e94e..400696d97a 100644 --- a/core-java-collections-map/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java +++ b/core-java-collections-map/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java @@ -68,9 +68,9 @@ public class CopyHashMapUnitTest { .put("emp1",emp1) .put("emp2",emp2) .build(); - Map mapCopy = ImmutableMap.copyOf(map); + Map shallowCopy = ImmutableMap.copyOf(map); - assertThat(mapCopy).isSameAs(map); + assertThat(shallowCopy).isSameAs(map); } From c685f8d4ff187a7a021907df0dde009267889a56 Mon Sep 17 00:00:00 2001 From: Ger Roza Date: Wed, 10 Apr 2019 17:58:34 -0300 Subject: [PATCH 140/531] fixed spring-cloud context integration tests - part 2: --- .../config/client/SpringContextLiveTest.java} | 11 ++++++---- ...java => SpringContextIntegrationTest.java} | 8 +------ .../src/test/resources/application.properties | 2 ++ .../src/main/resources/application.properties | 1 + .../heroku}/SpringContextIntegrationTest.java | 2 +- .../src/test/resources/application.properties | 2 ++ .../cloud/consul/SpringContextLiveTest.java} | 12 +++++++++-- ...onTest.java => SpringContextLiveTest.java} | 8 ++++++- .../org/baeldung/SpringContextLiveTest.java | 21 +++++++++++++++++++ ...onTest.java => SpringContextLiveTest.java} | 8 ++++++- .../SpringContextIntegrationTest.java | 4 ++-- .../SpringContextIntegrationTest.java | 20 ------------------ 12 files changed, 61 insertions(+), 38 deletions(-) rename spring-cloud/spring-cloud-config/client/src/test/java/{org/baeldung/SpringContextIntegrationTest.java => com/baeldung/spring/cloud/config/client/SpringContextLiveTest.java} (69%) rename spring-cloud/spring-cloud-config/server/src/test/java/com/baeldung/spring/cloud/config/server/{SpringContextLiveTest.java => SpringContextIntegrationTest.java} (79%) create mode 100644 spring-cloud/spring-cloud-config/server/src/test/resources/application.properties rename spring-cloud/spring-cloud-connectors-heroku/src/test/java/{org/baeldung => com/baeldung/spring/cloud/connectors/heroku}/SpringContextIntegrationTest.java (90%) create mode 100644 spring-cloud/spring-cloud-connectors-heroku/src/test/resources/application.properties rename spring-cloud/spring-cloud-consul/src/test/java/{org/baeldung/SpringContextIntegrationTest.java => com/baeldung/spring/cloud/consul/SpringContextLiveTest.java} (74%) rename spring-cloud/spring-cloud-rest/spring-cloud-rest-books-api/src/test/java/org/baeldung/{SpringContextIntegrationTest.java => SpringContextLiveTest.java} (66%) create mode 100644 spring-cloud/spring-cloud-rest/spring-cloud-rest-discovery-server/src/test/java/org/baeldung/SpringContextLiveTest.java rename spring-cloud/spring-cloud-rest/spring-cloud-rest-reviews-api/src/test/java/org/baeldung/{SpringContextIntegrationTest.java => SpringContextLiveTest.java} (66%) rename spring-cloud/{spring-cloud-rest/spring-cloud-rest-discovery-server/src/test/java/org/baeldung => spring-cloud-stream-starters/twitterhdfs/src/test/java/com/baeldung/twitterhdfs/aggregate}/SpringContextIntegrationTest.java (79%) delete mode 100644 spring-cloud/spring-cloud-stream-starters/twitterhdfs/src/test/java/org/baeldung/SpringContextIntegrationTest.java diff --git a/spring-cloud/spring-cloud-config/client/src/test/java/org/baeldung/SpringContextIntegrationTest.java b/spring-cloud/spring-cloud-config/client/src/test/java/com/baeldung/spring/cloud/config/client/SpringContextLiveTest.java similarity index 69% rename from spring-cloud/spring-cloud-config/client/src/test/java/org/baeldung/SpringContextIntegrationTest.java rename to spring-cloud/spring-cloud-config/client/src/test/java/com/baeldung/spring/cloud/config/client/SpringContextLiveTest.java index d727772cf9..3fb43b169d 100644 --- a/spring-cloud/spring-cloud-config/client/src/test/java/org/baeldung/SpringContextIntegrationTest.java +++ b/spring-cloud/spring-cloud-config/client/src/test/java/com/baeldung/spring/cloud/config/client/SpringContextLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung.spring.cloud.config.client; import org.junit.Test; import org.junit.runner.RunWith; @@ -6,12 +6,15 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.web.WebAppConfiguration; -import com.baeldung.spring.cloud.config.client.ConfigClient; - +/** + * + * The app needs the server running on port 8888. Can be started with docker + * + */ @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = ConfigClient.class) @WebAppConfiguration -public class SpringContextIntegrationTest { +public class SpringContextLiveTest { @Test public void contextLoads() { } diff --git a/spring-cloud/spring-cloud-config/server/src/test/java/com/baeldung/spring/cloud/config/server/SpringContextLiveTest.java b/spring-cloud/spring-cloud-config/server/src/test/java/com/baeldung/spring/cloud/config/server/SpringContextIntegrationTest.java similarity index 79% rename from spring-cloud/spring-cloud-config/server/src/test/java/com/baeldung/spring/cloud/config/server/SpringContextLiveTest.java rename to spring-cloud/spring-cloud-config/server/src/test/java/com/baeldung/spring/cloud/config/server/SpringContextIntegrationTest.java index 793b4abb6c..b2c6ef85ea 100644 --- a/spring-cloud/spring-cloud-config/server/src/test/java/com/baeldung/spring/cloud/config/server/SpringContextLiveTest.java +++ b/spring-cloud/spring-cloud-config/server/src/test/java/com/baeldung/spring/cloud/config/server/SpringContextIntegrationTest.java @@ -6,16 +6,10 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.web.WebAppConfiguration; - -/** - * - * The context will load successfully with some properties provided by docker - * - */ @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = ConfigServer.class) @WebAppConfiguration -public class SpringContextLiveTest { +public class SpringContextIntegrationTest { @Test public void whenSpringContextIsBootstrapped_thenNoExceptions() { } diff --git a/spring-cloud/spring-cloud-config/server/src/test/resources/application.properties b/spring-cloud/spring-cloud-config/server/src/test/resources/application.properties new file mode 100644 index 0000000000..67cc81ff67 --- /dev/null +++ b/spring-cloud/spring-cloud-config/server/src/test/resources/application.properties @@ -0,0 +1,2 @@ +### This should be provided by the docker config +spring.cloud.config.server.git.uri=classpath:. diff --git a/spring-cloud/spring-cloud-connectors-heroku/src/main/resources/application.properties b/spring-cloud/spring-cloud-connectors-heroku/src/main/resources/application.properties index d2f1c89dc5..571f325824 100644 --- a/spring-cloud/spring-cloud-connectors-heroku/src/main/resources/application.properties +++ b/spring-cloud/spring-cloud-connectors-heroku/src/main/resources/application.properties @@ -4,5 +4,6 @@ spring.datasource.maxIdle=5 spring.datasource.minIdle=2 spring.datasource.initialSize=5 spring.datasource.removeAbandoned=true +spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect spring.jpa.hibernate.ddl-auto=update \ No newline at end of file diff --git a/spring-cloud/spring-cloud-connectors-heroku/src/test/java/org/baeldung/SpringContextIntegrationTest.java b/spring-cloud/spring-cloud-connectors-heroku/src/test/java/com/baeldung/spring/cloud/connectors/heroku/SpringContextIntegrationTest.java similarity index 90% rename from spring-cloud/spring-cloud-connectors-heroku/src/test/java/org/baeldung/SpringContextIntegrationTest.java rename to spring-cloud/spring-cloud-connectors-heroku/src/test/java/com/baeldung/spring/cloud/connectors/heroku/SpringContextIntegrationTest.java index a705f18bc6..dca4c25c71 100644 --- a/spring-cloud/spring-cloud-connectors-heroku/src/test/java/org/baeldung/SpringContextIntegrationTest.java +++ b/spring-cloud/spring-cloud-connectors-heroku/src/test/java/com/baeldung/spring/cloud/connectors/heroku/SpringContextIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung.spring.cloud.connectors.heroku; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-cloud/spring-cloud-connectors-heroku/src/test/resources/application.properties b/spring-cloud/spring-cloud-connectors-heroku/src/test/resources/application.properties new file mode 100644 index 0000000000..7b139ae07d --- /dev/null +++ b/spring-cloud/spring-cloud-connectors-heroku/src/test/resources/application.properties @@ -0,0 +1,2 @@ +spring.jpa.hibernate.ddl-auto=create +spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect \ No newline at end of file diff --git a/spring-cloud/spring-cloud-consul/src/test/java/org/baeldung/SpringContextIntegrationTest.java b/spring-cloud/spring-cloud-consul/src/test/java/com/baeldung/spring/cloud/consul/SpringContextLiveTest.java similarity index 74% rename from spring-cloud/spring-cloud-consul/src/test/java/org/baeldung/SpringContextIntegrationTest.java rename to spring-cloud/spring-cloud-consul/src/test/java/com/baeldung/spring/cloud/consul/SpringContextLiveTest.java index 6290ccc03e..7c87add43e 100644 --- a/spring-cloud/spring-cloud-consul/src/test/java/org/baeldung/SpringContextIntegrationTest.java +++ b/spring-cloud/spring-cloud-consul/src/test/java/com/baeldung/spring/cloud/consul/SpringContextLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung.spring.cloud.consul; import org.junit.Test; import org.junit.runner.RunWith; @@ -9,10 +9,18 @@ import com.baeldung.spring.cloud.consul.discovery.DiscoveryClientApplication; import com.baeldung.spring.cloud.consul.health.ServiceDiscoveryApplication; import com.baeldung.spring.cloud.consul.properties.DistributedPropertiesApplication; + +/** + * + * This Live test requires: + * * a Consul instance running on port 8500 + * * Consul configured with particular properties (e.g. 'my.prop') + * + */ @RunWith(SpringRunner.class) @SpringBootTest(classes = { DiscoveryClientApplication.class, ServiceDiscoveryApplication.class, DistributedPropertiesApplication.class }) -public class SpringContextIntegrationTest { +public class SpringContextLiveTest { @Test public void whenSpringContextIsBootstrapped_thenNoExceptions() { diff --git a/spring-cloud/spring-cloud-rest/spring-cloud-rest-books-api/src/test/java/org/baeldung/SpringContextIntegrationTest.java b/spring-cloud/spring-cloud-rest/spring-cloud-rest-books-api/src/test/java/org/baeldung/SpringContextLiveTest.java similarity index 66% rename from spring-cloud/spring-cloud-rest/spring-cloud-rest-books-api/src/test/java/org/baeldung/SpringContextIntegrationTest.java rename to spring-cloud/spring-cloud-rest/spring-cloud-rest-books-api/src/test/java/org/baeldung/SpringContextLiveTest.java index 24e758ff82..eb56c16c6a 100644 --- a/spring-cloud/spring-cloud-rest/spring-cloud-rest-books-api/src/test/java/org/baeldung/SpringContextIntegrationTest.java +++ b/spring-cloud/spring-cloud-rest/spring-cloud-rest-books-api/src/test/java/org/baeldung/SpringContextLiveTest.java @@ -5,9 +5,15 @@ import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; +/** + * + * This Live Test requires: + * * A Redis instance running in port 6379 (e.g. using `docker run --name some-redis -p 6379:6379 -d redis`) + * + */ @RunWith(SpringRunner.class) @SpringBootTest(classes = BooksApiApplication.class) -public class SpringContextIntegrationTest { +public class SpringContextLiveTest { @Test public void whenSpringContextIsBootstrapped_thenNoExceptions() { diff --git a/spring-cloud/spring-cloud-rest/spring-cloud-rest-discovery-server/src/test/java/org/baeldung/SpringContextLiveTest.java b/spring-cloud/spring-cloud-rest/spring-cloud-rest-discovery-server/src/test/java/org/baeldung/SpringContextLiveTest.java new file mode 100644 index 0000000000..01266a3bda --- /dev/null +++ b/spring-cloud/spring-cloud-rest/spring-cloud-rest-discovery-server/src/test/java/org/baeldung/SpringContextLiveTest.java @@ -0,0 +1,21 @@ +package org.baeldung; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +/** + * + * This Live Test requires: + * * A Redis instance running in port 6379 (e.g. using `docker run --name some-redis -p 6379:6379 -d redis`) + * + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = SpringCloudRestServerApplication.class) +public class SpringContextLiveTest { + + @Test + public void whenSpringContextIsBootstrapped_thenNoExceptions() { + } +} diff --git a/spring-cloud/spring-cloud-rest/spring-cloud-rest-reviews-api/src/test/java/org/baeldung/SpringContextIntegrationTest.java b/spring-cloud/spring-cloud-rest/spring-cloud-rest-reviews-api/src/test/java/org/baeldung/SpringContextLiveTest.java similarity index 66% rename from spring-cloud/spring-cloud-rest/spring-cloud-rest-reviews-api/src/test/java/org/baeldung/SpringContextIntegrationTest.java rename to spring-cloud/spring-cloud-rest/spring-cloud-rest-reviews-api/src/test/java/org/baeldung/SpringContextLiveTest.java index 07d7db0505..070abd246f 100644 --- a/spring-cloud/spring-cloud-rest/spring-cloud-rest-reviews-api/src/test/java/org/baeldung/SpringContextIntegrationTest.java +++ b/spring-cloud/spring-cloud-rest/spring-cloud-rest-reviews-api/src/test/java/org/baeldung/SpringContextLiveTest.java @@ -5,9 +5,15 @@ import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; +/** + * + * This Live Test requires: + * * A Redis instance running in port 6379 (e.g. using `docker run --name some-redis -p 6379:6379 -d redis`) + * + */ @RunWith(SpringRunner.class) @SpringBootTest(classes = BookReviewsApiApplication.class) -public class SpringContextIntegrationTest { +public class SpringContextLiveTest { @Test public void whenSpringContextIsBootstrapped_thenNoExceptions() { diff --git a/spring-cloud/spring-cloud-rest/spring-cloud-rest-discovery-server/src/test/java/org/baeldung/SpringContextIntegrationTest.java b/spring-cloud/spring-cloud-stream-starters/twitterhdfs/src/test/java/com/baeldung/twitterhdfs/aggregate/SpringContextIntegrationTest.java similarity index 79% rename from spring-cloud/spring-cloud-rest/spring-cloud-rest-discovery-server/src/test/java/org/baeldung/SpringContextIntegrationTest.java rename to spring-cloud/spring-cloud-stream-starters/twitterhdfs/src/test/java/com/baeldung/twitterhdfs/aggregate/SpringContextIntegrationTest.java index e22359a016..b5cef1b5ed 100644 --- a/spring-cloud/spring-cloud-rest/spring-cloud-rest-discovery-server/src/test/java/org/baeldung/SpringContextIntegrationTest.java +++ b/spring-cloud/spring-cloud-stream-starters/twitterhdfs/src/test/java/com/baeldung/twitterhdfs/aggregate/SpringContextIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung.twitterhdfs.aggregate; import org.junit.Test; import org.junit.runner.RunWith; @@ -6,7 +6,7 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) -@SpringBootTest(classes = SpringCloudRestServerApplication.class) +@SpringBootTest(classes = AggregateApp.class) public class SpringContextIntegrationTest { @Test diff --git a/spring-cloud/spring-cloud-stream-starters/twitterhdfs/src/test/java/org/baeldung/SpringContextIntegrationTest.java b/spring-cloud/spring-cloud-stream-starters/twitterhdfs/src/test/java/org/baeldung/SpringContextIntegrationTest.java deleted file mode 100644 index 3d370e7b48..0000000000 --- a/spring-cloud/spring-cloud-stream-starters/twitterhdfs/src/test/java/org/baeldung/SpringContextIntegrationTest.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.baeldung; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -import com.baeldung.twitterhdfs.aggregate.AggregateApp; -import com.baeldung.twitterhdfs.processor.ProcessorApp; -import com.baeldung.twitterhdfs.sink.SinkApp; -import com.baeldung.twitterhdfs.source.SourceApp; - -@RunWith(SpringRunner.class) -@SpringBootTest(classes = {AggregateApp.class, ProcessorApp.class, SinkApp.class, SourceApp.class}) -public class SpringContextIntegrationTest { - - @Test - public void whenSpringContextIsBootstrapped_thenNoExceptions() { - } -} From b2f5d1ec20dda0598e098f77f46b7e2ec38d22f4 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Thu, 11 Apr 2019 14:33:27 +0800 Subject: [PATCH 141/531] Update README.md --- core-java-lang/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core-java-lang/README.md b/core-java-lang/README.md index f8922154a9..e9169a5820 100644 --- a/core-java-lang/README.md +++ b/core-java-lang/README.md @@ -12,7 +12,7 @@ - [Dynamic Proxies in Java](http://www.baeldung.com/java-dynamic-proxies) - [Java Double Brace Initialization](http://www.baeldung.com/java-double-brace-initialization) - [Guide to the Diamond Operator in Java](http://www.baeldung.com/java-diamond-operator) -- [Quick Example - Comparator vs Comparable in Java](http://www.baeldung.com/java-comparator-comparable) +- [Comparator and Comparable in Java](http://www.baeldung.com/java-comparator-comparable) - [The Java continue and break Keywords](http://www.baeldung.com/java-continue-and-break) - [Nested Classes in Java](http://www.baeldung.com/java-nested-classes) - [A Guide to Inner Interfaces in Java](http://www.baeldung.com/java-inner-interfaces) @@ -42,4 +42,3 @@ - [Attaching Values to Java Enum](https://www.baeldung.com/java-enum-values) - [Variable Scope in Java](https://www.baeldung.com/java-variable-scope) - [Java Classes and Objects](https://www.baeldung.com/java-classes-objects) -- [Comparator and Comparable in Java](https://www.baeldung.com/java-comparator-comparable) From 9d63e48997952b23bc3099fecfcfb1efaecf8cf0 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Thu, 11 Apr 2019 14:37:43 +0800 Subject: [PATCH 142/531] Update README.md --- core-java-io/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core-java-io/README.md b/core-java-io/README.md index 1516c54247..ab8c5d8304 100644 --- a/core-java-io/README.md +++ b/core-java-io/README.md @@ -14,7 +14,7 @@ - [File Size in Java](http://www.baeldung.com/java-file-size) - [Comparing getPath(), getAbsolutePath(), and getCanonicalPath() in Java](http://www.baeldung.com/java-path) - [Using Java MappedByteBuffer](http://www.baeldung.com/java-mapped-byte-buffer) -- [Copy a File with Java](http://www.baeldung.com/java-copy-file) +- [How to Copy a File with Java](http://www.baeldung.com/java-copy-file) - [Java – Append Data to a File](http://www.baeldung.com/java-append-to-file) - [FileNotFoundException in Java](http://www.baeldung.com/java-filenotfound-exception) - [How to Read a File in Java](http://www.baeldung.com/reading-file-in-java) @@ -40,4 +40,3 @@ - [How to Write to a CSV File in Java](https://www.baeldung.com/java-csv) - [List Files in a Directory in Java](https://www.baeldung.com/java-list-directory-files) - [Java InputStream to Byte Array and ByteBuffer](https://www.baeldung.com/convert-input-stream-to-array-of-bytes) -- [How to Copy a File with Java](https://www.baeldung.com/java-copy-file) From eb053daeaff9d632571c573751ea4e148d3948f3 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Thu, 11 Apr 2019 14:40:06 +0800 Subject: [PATCH 143/531] Update README.md --- libraries/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/README.md b/libraries/README.md index 8518684316..88cffa22cf 100644 --- a/libraries/README.md +++ b/libraries/README.md @@ -36,7 +36,7 @@ - [Introduction To Docx4J](http://www.baeldung.com/docx4j) - [Introduction to StreamEx](http://www.baeldung.com/streamex) - [Introduction to BouncyCastle with Java](http://www.baeldung.com/java-bouncy-castle) -- [Guide to google-http-client](http://www.baeldung.com/google-http-client) +- [A Guide to Google-Http-Client](http://www.baeldung.com/google-http-client) - [Interact with Google Sheets from Java](http://www.baeldung.com/google-sheets-java-client) - [A Docker Guide for Java](http://www.baeldung.com/docker-java-api) - [Introduction To OpenCSV](http://www.baeldung.com/opencsv) @@ -67,7 +67,6 @@ - [Introduction to Functional Java](https://www.baeldung.com/java-functional-library) - [Intro to Derive4J](https://www.baeldung.com/derive4j) - [A Guide to the Reflections Library](https://www.baeldung.com/reflections-library) -- [A Guide to Google-Http-Client](https://www.baeldung.com/google-http-client) The libraries module contains examples related to small libraries that are relatively easy to use and does not require any separate module of its own. From 4666b9389b7d92aa6c8095e5867dfda1b93aa64e Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Thu, 11 Apr 2019 14:45:24 +0800 Subject: [PATCH 144/531] Update README.md --- libraries/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/README.md b/libraries/README.md index 88cffa22cf..cd5d45dbbe 100644 --- a/libraries/README.md +++ b/libraries/README.md @@ -21,7 +21,7 @@ - [Introduction to PCollections](http://www.baeldung.com/java-pcollections) - [Introduction to Hoverfly in Java](http://www.baeldung.com/hoverfly) - [Introduction to Eclipse Collections](http://www.baeldung.com/eclipse-collections) -- [DistinctBy in Java Stream API](http://www.baeldung.com/java-streams-distinct-by) +- [DistinctBy in the Java Stream API](http://www.baeldung.com/java-streams-distinct-by) - [Introduction to NoException](http://www.baeldung.com/no-exception) - [Introduction to Conflict-Free Replicated Data Types](http://www.baeldung.com/java-conflict-free-replicated-data-types) - [Introduction to javax.measure](http://www.baeldung.com/javax-measure) From 9de7163d2bf1e5be5207c6df1569e202a333bfa8 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Thu, 11 Apr 2019 14:47:08 +0800 Subject: [PATCH 145/531] Update README.md --- libraries/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/README.md b/libraries/README.md index cd5d45dbbe..f6a39daef1 100644 --- a/libraries/README.md +++ b/libraries/README.md @@ -14,7 +14,7 @@ - [Software Transactional Memory in Java Using Multiverse](http://www.baeldung.com/java-multiverse-stm) - [Serenity BDD with Spring and JBehave](http://www.baeldung.com/serenity-spring-jbehave) - [Locality-Sensitive Hashing in Java Using Java-LSH](http://www.baeldung.com/locality-sensitive-hashing) -- [Introduction to Awaitility](http://www.baeldung.com/awaitlity-testing) +- [Introduction to Awaitlity](http://www.baeldung.com/awaitlity-testing) - [Guide to the HyperLogLog Algorithm](http://www.baeldung.com/java-hyperloglog) - [Introduction to Neuroph](http://www.baeldung.com/neuroph) - [Quick Guide to RSS with Rome](http://www.baeldung.com/rome-rss) From 2f660a2c48d1826cd68fd82b68ad23adaf6cf789 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Thu, 11 Apr 2019 14:48:22 +0800 Subject: [PATCH 146/531] Update README.md --- spring-security-sso/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-security-sso/README.md b/spring-security-sso/README.md index 11b5f011d5..d0c1b2f7cf 100644 --- a/spring-security-sso/README.md +++ b/spring-security-sso/README.md @@ -1,2 +1,2 @@ ### Relevant Articles: -- [Simple Single Sign On with Spring Security OAuth2](http://www.baeldung.com/sso-spring-security-oauth2) +- [Simple Single Sign-On with Spring Security OAuth2](http://www.baeldung.com/sso-spring-security-oauth2) From 6bf0bf726b333a8577eea8d9fe5159df0832e6c1 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Thu, 11 Apr 2019 14:53:28 +0800 Subject: [PATCH 147/531] Update README.md --- core-kotlin/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-kotlin/README.md b/core-kotlin/README.md index 73a78eccff..3392db9171 100644 --- a/core-kotlin/README.md +++ b/core-kotlin/README.md @@ -1,7 +1,7 @@ ## Relevant articles: - [Introduction to the Kotlin Language](http://www.baeldung.com/kotlin) -- [A guide to the “when{}†block in Kotlin](http://www.baeldung.com/kotlin-when) +- [Guide to the “when{}†Block in Kotlin](http://www.baeldung.com/kotlin-when) - [Comprehensive Guide to Null Safety in Kotlin](http://www.baeldung.com/kotlin-null-safety) - [Kotlin Java Interoperability](http://www.baeldung.com/kotlin-java-interoperability) - [Difference Between “==†and “===†operators in Kotlin](http://www.baeldung.com/kotlin-equality-operators) From ab86b96000ed13406eb64599ee0723c576192800 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Thu, 11 Apr 2019 14:55:44 +0800 Subject: [PATCH 148/531] Update README.md --- spring-security-mvc-login/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-security-mvc-login/README.md b/spring-security-mvc-login/README.md index c19cbc87a5..983d949cb8 100644 --- a/spring-security-mvc-login/README.md +++ b/spring-security-mvc-login/README.md @@ -10,7 +10,7 @@ The "Learn Spring Security" Classes: http://github.learnspringsecurity.com - [Spring Security Logout](http://www.baeldung.com/spring-security-logout) - [Spring Security Expressions – hasRole Example](http://www.baeldung.com/spring-security-expressions-basic) - [Spring HTTP/HTTPS Channel Security](http://www.baeldung.com/spring-channel-security-https) -- [Spring Security - Customize the 403 Forbidden/Access Denied Page](http://www.baeldung.com/spring-security-custom-access-denied-page) +- [Spring Security – Customize the 403 Forbidden/Access Denied Page](http://www.baeldung.com/spring-security-custom-access-denied-page) - [Spring Security – Redirect to the Previous URL After Login](http://www.baeldung.com/spring-security-redirect-login) - [Spring Security Custom AuthenticationFailureHandler](http://www.baeldung.com/spring-security-custom-authentication-failure-handler) From cf921045ba2a7ce0d4b4d4c11ba23cc2065591f4 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Thu, 11 Apr 2019 14:57:42 +0800 Subject: [PATCH 149/531] Update README.md --- spring-thymeleaf/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-thymeleaf/README.md b/spring-thymeleaf/README.md index f9e7dd90a7..b6824003db 100644 --- a/spring-thymeleaf/README.md +++ b/spring-thymeleaf/README.md @@ -8,7 +8,7 @@ - [Thymeleaf: Custom Layout Dialect](http://www.baeldung.com/thymeleaf-spring-layouts) - [Spring and Thymeleaf 3: Expressions](http://www.baeldung.com/spring-thymeleaf-3-expressions) - [Spring MVC + Thymeleaf 3.0: New Features](http://www.baeldung.com/spring-thymeleaf-3) -- [How to Work with Dates in Thymeleaef](http://www.baeldung.com/dates-in-thymeleaf) +- [How to Work with Dates in Thymeleaf](http://www.baeldung.com/dates-in-thymeleaf) - [How to Create an Executable JAR with Maven](http://www.baeldung.com/executable-jar-with-maven) - [Working with Boolean in Thymeleaf](http://www.baeldung.com/thymeleaf-boolean) - [Working with Fragments in Thymeleaf](http://www.baeldung.com/spring-thymeleaf-fragments) From f8796904392d8a71bce3bc46a97fc9bea7c9205b Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Thu, 11 Apr 2019 14:58:45 +0800 Subject: [PATCH 150/531] Update README.md --- core-java-collections/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-collections/README.md b/core-java-collections/README.md index 1e504ded65..43f5bfc384 100644 --- a/core-java-collections/README.md +++ b/core-java-collections/README.md @@ -3,7 +3,7 @@ ## Core Java Collections Cookbooks and Examples ### Relevant Articles: -- [Java - Combine Multiple Collections](http://www.baeldung.com/java-combine-multiple-collections) +- [Java – Combine Multiple Collections](http://www.baeldung.com/java-combine-multiple-collections) - [HashSet and TreeSet Comparison](http://www.baeldung.com/java-hashset-vs-treeset) - [Collect a Java Stream to an Immutable Collection](http://www.baeldung.com/java-stream-immutable-collection) - [Introduction to the Java ArrayDeque](http://www.baeldung.com/java-array-deque) From 591cb65303689d77eb45d101c8737ca8dcd8f55e Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Thu, 11 Apr 2019 14:59:44 +0800 Subject: [PATCH 151/531] Update README.md --- spring-all/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-all/README.md b/spring-all/README.md index c4e400d9a3..b0805e5477 100644 --- a/spring-all/README.md +++ b/spring-all/README.md @@ -14,7 +14,7 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Properties with Spring and Spring Boot](http://www.baeldung.com/properties-with-spring) - checkout the `org.baeldung.properties` package for all scenarios of properties injection and usage - [Spring Profiles](http://www.baeldung.com/spring-profiles) - [A Spring Custom Annotation for a Better DAO](http://www.baeldung.com/spring-annotation-bean-pre-processor) -- [What's New in Spring 4.3?](http://www.baeldung.com/whats-new-in-spring-4-3) +- [What’s New in Spring 4.3?](http://www.baeldung.com/whats-new-in-spring-4-3) - [Running Setup Data on Startup in Spring](http://www.baeldung.com/running-setup-logic-on-startup-in-spring) - [Quick Guide to Spring Controllers](http://www.baeldung.com/spring-controllers) - [Quick Guide to Spring Bean Scopes](http://www.baeldung.com/spring-bean-scopes) From e052bc3caa8429725ad2635fb0d7ec52d8ac64d7 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Thu, 11 Apr 2019 15:01:03 +0800 Subject: [PATCH 152/531] Update README.md --- jackson/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jackson/README.md b/jackson/README.md index e9cf6f212c..eeb8f1b874 100644 --- a/jackson/README.md +++ b/jackson/README.md @@ -16,7 +16,7 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Jackson – Bidirectional Relationships](http://www.baeldung.com/jackson-bidirectional-relationships-and-infinite-recursion) - [Jackson JSON Tutorial](http://www.baeldung.com/jackson) - [Jackson – Working with Maps and nulls](http://www.baeldung.com/jackson-map-null-values-or-null-key) -- [Jackson – Decide What Fields Get Serialized/Deserializaed](http://www.baeldung.com/jackson-field-serializable-deserializable-or-not) +- [Jackson – Decide What Fields Get Serialized/Deserialized](http://www.baeldung.com/jackson-field-serializable-deserializable-or-not) - [Jackson Annotation Examples](http://www.baeldung.com/jackson-annotations) - [Working with Tree Model Nodes in Jackson](http://www.baeldung.com/jackson-json-node-tree-model) - [Jackson vs Gson](http://www.baeldung.com/jackson-vs-gson) From a6301066ae4147e5eec8c23ed8ca0938f7c2decb Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Thu, 11 Apr 2019 15:02:20 +0800 Subject: [PATCH 153/531] Update README.md --- core-java-io/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-io/README.md b/core-java-io/README.md index ab8c5d8304..9ce39459dd 100644 --- a/core-java-io/README.md +++ b/core-java-io/README.md @@ -6,7 +6,7 @@ - [How to Read a Large File Efficiently with Java](http://www.baeldung.com/java-read-lines-large-file) - [Java InputStream to String](http://www.baeldung.com/convert-input-stream-to-string) - [Java – Write to File](http://www.baeldung.com/java-write-to-file) -- [Java - Convert File to InputStream](http://www.baeldung.com/convert-file-to-input-stream) +- [Java – Convert File to InputStream](http://www.baeldung.com/convert-file-to-input-stream) - [Java Scanner](http://www.baeldung.com/java-scanner) - [Java – Byte Array to Writer](http://www.baeldung.com/java-convert-byte-array-to-writer) - [Java – Directory Size](http://www.baeldung.com/java-folder-size) From 5da1342acd6c59203ea49b09b05c01cec462df71 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Thu, 11 Apr 2019 15:03:01 +0800 Subject: [PATCH 154/531] Update README.md --- spring-security-mvc-ldap/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-security-mvc-ldap/README.md b/spring-security-mvc-ldap/README.md index ac080c138d..6f03143183 100644 --- a/spring-security-mvc-ldap/README.md +++ b/spring-security-mvc-ldap/README.md @@ -5,7 +5,7 @@ The "Learn Spring Security" Classes: http://github.learnspringsecurity.com ### Relevant Article: -- [Spring Security - security none, filters none, access permitAll](http://www.baeldung.com/security-none-filters-none-access-permitAll) +- [Spring Security – security none, filters none, access permitAll](http://www.baeldung.com/security-none-filters-none-access-permitAll) - [Intro to Spring Security LDAP](http://www.baeldung.com/spring-security-ldap) ### Notes From 9c0c02fda35341110921d0160305075bfd745811 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Thu, 11 Apr 2019 15:03:57 +0800 Subject: [PATCH 155/531] Update README.md --- core-java-concurrency-basic/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-concurrency-basic/README.md b/core-java-concurrency-basic/README.md index f33ae08571..6fa702fbe7 100644 --- a/core-java-concurrency-basic/README.md +++ b/core-java-concurrency-basic/README.md @@ -11,7 +11,7 @@ - [Overview of the java.util.concurrent](http://www.baeldung.com/java-util-concurrent) - [Implementing a Runnable vs Extending a Thread](http://www.baeldung.com/java-runnable-vs-extending-thread) - [How to Kill a Java Thread](http://www.baeldung.com/java-thread-stop) -- [ExecutorService - Waiting for Threads to Finish](http://www.baeldung.com/java-executor-wait-for-threads) +- [ExecutorService – Waiting for Threads to Finish](http://www.baeldung.com/java-executor-wait-for-threads) - [wait and notify() Methods in Java](http://www.baeldung.com/java-wait-notify) - [Life Cycle of a Thread in Java](http://www.baeldung.com/java-thread-lifecycle) - [Runnable vs. Callable in Java](http://www.baeldung.com/java-runnable-callable) From 548311068d98009c9f0a3041041d327f91777ea3 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Thu, 11 Apr 2019 15:05:04 +0800 Subject: [PATCH 156/531] Update README.md --- spring-5-security-oauth/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-5-security-oauth/README.md b/spring-5-security-oauth/README.md index 5a444d4784..a5cec370c7 100644 --- a/spring-5-security-oauth/README.md +++ b/spring-5-security-oauth/README.md @@ -1,5 +1,5 @@ ## Relevant articles: -- [Spring Security 5 -OAuth2 Login](http://www.baeldung.com/spring-security-5-oauth2-login) +- [Spring Security 5 – OAuth2 Login](http://www.baeldung.com/spring-security-5-oauth2-login) - [Extracting Principal and Authorities using Spring Security OAuth](https://www.baeldung.com/spring-security-oauth-principal-authorities-extractor) - [Customizing Authorization and Token Requests with Spring Security 5.1 Client](https://www.baeldung.com/spring-security-custom-oauth-requests) From 0f20ec56b720d4a8064c4d3e923aa50613b575da Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Thu, 11 Apr 2019 15:07:22 +0800 Subject: [PATCH 157/531] Update README.md --- logging-modules/logback/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/logging-modules/logback/README.md b/logging-modules/logback/README.md index e69de29bb2..df55492b69 100644 --- a/logging-modules/logback/README.md +++ b/logging-modules/logback/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Get Log Output in JSON](https://www.baeldung.com/java-log-json-output) From 2f3d9065153d4afdc0080e82ba0c88735c4a1f0f Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Thu, 11 Apr 2019 15:08:58 +0800 Subject: [PATCH 158/531] Update README.md --- libraries-server/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries-server/README.md b/libraries-server/README.md index 4baf6c4c1f..dc6bcd0716 100644 --- a/libraries-server/README.md +++ b/libraries-server/README.md @@ -3,7 +3,7 @@ - [Embedded Jetty Server in Java](http://www.baeldung.com/jetty-embedded) - [Introduction to Netty](http://www.baeldung.com/netty) - [Exceptions in Netty](http://www.baeldung.com/netty-exception-handling) -- [Programmatically Create, Configure, and Run a Tomcat Server](http://www.baeldung.com/tomcat-programmatic-setup) +- [Programmatically Create, Configure and Run a Tomcat Server](http://www.baeldung.com/tomcat-programmatic-setup) - [Creating and Configuring Jetty 9 Server in Java](http://www.baeldung.com/jetty-java-programmatic) - [Testing Netty with EmbeddedChannel](http://www.baeldung.com/testing-netty-embedded-channel) - [MQTT Client in Java](https://www.baeldung.com/java-mqtt-client) From be97afaeaaa8115661894eb68322a0796d455f1f Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Thu, 11 Apr 2019 15:10:12 +0800 Subject: [PATCH 159/531] Update README.md --- core-java-lang-oop/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-lang-oop/README.md b/core-java-lang-oop/README.md index 970a8d44b1..c9ee9a9e94 100644 --- a/core-java-lang-oop/README.md +++ b/core-java-lang-oop/README.md @@ -10,7 +10,7 @@ - [How to Make a Deep Copy of an Object in Java](http://www.baeldung.com/java-deep-copy) - [Guide to Inheritance in Java](http://www.baeldung.com/java-inheritance) - [Object Type Casting in Java](http://www.baeldung.com/java-type-casting) -- [The "final" Keyword in Java](http://www.baeldung.com/java-final) +- [The “final†Keyword in Java](http://www.baeldung.com/java-final) - [Type Erasure in Java Explained](http://www.baeldung.com/java-type-erasure) - [Pass-By-Value as a Parameter Passing Mechanism in Java](http://www.baeldung.com/java-pass-by-value-or-pass-by-reference) - [Variable and Method Hiding in Java](http://www.baeldung.com/java-variable-method-hiding) From 73ab68cf0ed7b50fcbc0b874276e4126e22566f3 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Thu, 11 Apr 2019 15:11:12 +0800 Subject: [PATCH 160/531] Update README.md --- rxjava-2/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rxjava-2/README.md b/rxjava-2/README.md index 0f4864e1a0..c255338402 100644 --- a/rxjava-2/README.md +++ b/rxjava-2/README.md @@ -2,7 +2,7 @@ - [RxJava and Error Handling](http://www.baeldung.com/rxjava-error-handling) - [RxJava 2 – Flowable](http://www.baeldung.com/rxjava-2-flowable) -- [RxJava 2 - Completable](http://www.baeldung.com/rxjava-completable) +- [Combining RxJava Completables](http://www.baeldung.com/rxjava-completable) - [RxJava Maybe](http://www.baeldung.com/rxjava-maybe) - [Introduction to RxRelay for RxJava](http://www.baeldung.com/rx-relay) - [Combining RxJava Completables](https://www.baeldung.com/rxjava-completable) From a7b47a977a92bf6f8d8a4f2722cdc92e9137c12b Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Thu, 11 Apr 2019 15:12:10 +0800 Subject: [PATCH 161/531] Update README.md --- persistence-modules/java-jpa/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/persistence-modules/java-jpa/README.md b/persistence-modules/java-jpa/README.md index 336dd4f43f..a95657b1ca 100644 --- a/persistence-modules/java-jpa/README.md +++ b/persistence-modules/java-jpa/README.md @@ -2,7 +2,7 @@ - [A Guide to SqlResultSetMapping](http://www.baeldung.com/jpa-sql-resultset-mapping) - [A Guide to Stored Procedures with JPA](http://www.baeldung.com/jpa-stored-procedures) -- [Fixing the JPA error “java.lang.String cannot be cast to "java.lang.String;â€](https://www.baeldung.com/jpa-error-java-lang-string-cannot-be-cast) +- [Fixing the JPA error “java.lang.String cannot be cast to [Ljava.lang.String;â€](https://www.baeldung.com/jpa-error-java-lang-string-cannot-be-cast) - [JPA Entity Graph](https://www.baeldung.com/jpa-entity-graph) - [JPA 2.2 Support for Java 8 Date/Time Types](https://www.baeldung.com/jpa-java-time) - [Converting Between LocalDate and SQL Date](https://www.baeldung.com/java-convert-localdate-sql-date) From ba2af175e4767e1a8d6f2f699a3cd58ee51c5a7e Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Thu, 11 Apr 2019 15:13:01 +0800 Subject: [PATCH 162/531] Update README.md --- persistence-modules/java-jpa/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/persistence-modules/java-jpa/README.md b/persistence-modules/java-jpa/README.md index a95657b1ca..10dcf2ec2e 100644 --- a/persistence-modules/java-jpa/README.md +++ b/persistence-modules/java-jpa/README.md @@ -2,7 +2,7 @@ - [A Guide to SqlResultSetMapping](http://www.baeldung.com/jpa-sql-resultset-mapping) - [A Guide to Stored Procedures with JPA](http://www.baeldung.com/jpa-stored-procedures) -- [Fixing the JPA error “java.lang.String cannot be cast to [Ljava.lang.String;â€](https://www.baeldung.com/jpa-error-java-lang-string-cannot-be-cast) +- [ Fixing the JPA error “java.lang.String cannot be cast to [Ljava.lang.String;†](https://www.baeldung.com/jpa-error-java-lang-string-cannot-be-cast) - [JPA Entity Graph](https://www.baeldung.com/jpa-entity-graph) - [JPA 2.2 Support for Java 8 Date/Time Types](https://www.baeldung.com/jpa-java-time) - [Converting Between LocalDate and SQL Date](https://www.baeldung.com/java-convert-localdate-sql-date) From 25a109891be94c928386bd5e21188672f8b10a6c Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Thu, 11 Apr 2019 15:13:43 +0800 Subject: [PATCH 163/531] Update README.md --- persistence-modules/java-jpa/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/persistence-modules/java-jpa/README.md b/persistence-modules/java-jpa/README.md index 10dcf2ec2e..5be1015942 100644 --- a/persistence-modules/java-jpa/README.md +++ b/persistence-modules/java-jpa/README.md @@ -2,7 +2,7 @@ - [A Guide to SqlResultSetMapping](http://www.baeldung.com/jpa-sql-resultset-mapping) - [A Guide to Stored Procedures with JPA](http://www.baeldung.com/jpa-stored-procedures) -- [ Fixing the JPA error “java.lang.String cannot be cast to [Ljava.lang.String;†](https://www.baeldung.com/jpa-error-java-lang-string-cannot-be-cast) +- [Fixing the JPA error “java.lang.String cannot be cast to [Ljava.lang.String;â€]](https://www.baeldung.com/jpa-error-java-lang-string-cannot-be-cast) - [JPA Entity Graph](https://www.baeldung.com/jpa-entity-graph) - [JPA 2.2 Support for Java 8 Date/Time Types](https://www.baeldung.com/jpa-java-time) - [Converting Between LocalDate and SQL Date](https://www.baeldung.com/java-convert-localdate-sql-date) From a67f703fd507c794bae8a52bdf97538c348954cd Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Thu, 11 Apr 2019 15:14:38 +0800 Subject: [PATCH 164/531] Update README.md --- blade/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/blade/README.md b/blade/README.md index d823de775f..1f2a00ed3f 100644 --- a/blade/README.md +++ b/blade/README.md @@ -1,5 +1,5 @@ ### Relevant Articles: -- [Blade - A Complete GuideBook](http://www.baeldung.com/blade) +- [Blade – A Complete Guidebook](http://www.baeldung.com/blade) -Run Integration Tests with `mvn integration-test` \ No newline at end of file +Run Integration Tests with `mvn integration-test` From 56a0c85df8354c666ec6d8132464bd8e0c22443e Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Thu, 11 Apr 2019 15:16:18 +0800 Subject: [PATCH 165/531] Update README.md --- testing-modules/rest-testing/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing-modules/rest-testing/README.md b/testing-modules/rest-testing/README.md index 25e036ba5d..391f8012fe 100644 --- a/testing-modules/rest-testing/README.md +++ b/testing-modules/rest-testing/README.md @@ -8,7 +8,7 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles: - [Test a REST API with Java](http://www.baeldung.com/integration-testing-a-rest-api) - [Introduction to WireMock](http://www.baeldung.com/introduction-to-wiremock) -- [Using WireMock Scenarios](http://www.baeldung.com/using-wiremock-scenarios) +- [ Using WireMock Scenarios ](http://www.baeldung.com/using-wiremock-scenarios) - [REST API Testing with Cucumber](http://www.baeldung.com/cucumber-rest-api-testing) - [Testing a REST API with JBehave](http://www.baeldung.com/jbehave-rest-testing) - [REST API Testing with Karate](http://www.baeldung.com/karate-rest-api-testing) From b769c7c7bce933081dce449d74f1350f5ee706ad Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Thu, 11 Apr 2019 15:19:33 +0800 Subject: [PATCH 166/531] Update README.md --- testing-modules/rest-testing/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing-modules/rest-testing/README.md b/testing-modules/rest-testing/README.md index 391f8012fe..a07c8cb256 100644 --- a/testing-modules/rest-testing/README.md +++ b/testing-modules/rest-testing/README.md @@ -8,7 +8,7 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles: - [Test a REST API with Java](http://www.baeldung.com/integration-testing-a-rest-api) - [Introduction to WireMock](http://www.baeldung.com/introduction-to-wiremock) -- [ Using WireMock Scenarios ](http://www.baeldung.com/using-wiremock-scenarios) +- [Using WireMock Scenarios](https://www.baeldung.com/wiremock-scenarios) - [REST API Testing with Cucumber](http://www.baeldung.com/cucumber-rest-api-testing) - [Testing a REST API with JBehave](http://www.baeldung.com/jbehave-rest-testing) - [REST API Testing with Karate](http://www.baeldung.com/karate-rest-api-testing) From 7543d5f3d6ef03c25a1a21880803fcc4b1eff4bd Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Thu, 11 Apr 2019 15:21:41 +0800 Subject: [PATCH 167/531] Update README.md --- patterns/design-patterns/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patterns/design-patterns/README.md b/patterns/design-patterns/README.md index c43ea48505..605fdc0d6e 100644 --- a/patterns/design-patterns/README.md +++ b/patterns/design-patterns/README.md @@ -19,4 +19,4 @@ - [The Command Pattern in Java](http://www.baeldung.com/java-command-pattern) - [Java Constructors vs Static Factory Methods](https://www.baeldung.com/java-constructors-vs-static-factory-methods) - [The Adapter Pattern in Java](https://www.baeldung.com/java-adapter-pattern) -- [Currying in Java](https://baeldung.com/currying-in-java) +- [Currying in Java](https://www.baeldung.com/java-currying) From b6731a5a383289ea73340f3b5d318bcc99db0081 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Thu, 11 Apr 2019 15:24:01 +0800 Subject: [PATCH 168/531] Create README.md --- spring-5-webflux/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 spring-5-webflux/README.md diff --git a/spring-5-webflux/README.md b/spring-5-webflux/README.md new file mode 100644 index 0000000000..1613358b59 --- /dev/null +++ b/spring-5-webflux/README.md @@ -0,0 +1,3 @@ +## Relevant articles: + +- [Spring Boot Reactor Netty Configuration](https://www.baeldung.com/spring-boot-reactor-netty) From 1af848756b45ac3d9a703190a3b054b4567bc8e9 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Thu, 11 Apr 2019 15:25:43 +0800 Subject: [PATCH 169/531] Update README.md --- core-java-jvm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-jvm/README.md b/core-java-jvm/README.md index 529453f3c4..82067ad952 100644 --- a/core-java-jvm/README.md +++ b/core-java-jvm/README.md @@ -3,4 +3,4 @@ ## Core Java JVM Cookbooks and Examples ### Relevant Articles: -- [Method Inlining in the JVM](http://www.baeldung.com/method-inlining-in-the-jvm/) +- [Method Inlining in the JVM](https://www.baeldung.com/jvm-method-inlining) From 9de1ce56e9295efcd067fb9b709ed752fc3bba66 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Thu, 11 Apr 2019 15:27:30 +0800 Subject: [PATCH 170/531] Update README.md --- spring-5-webflux/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-5-webflux/README.md b/spring-5-webflux/README.md index 1613358b59..84c3d5a4ca 100644 --- a/spring-5-webflux/README.md +++ b/spring-5-webflux/README.md @@ -1,3 +1,4 @@ ## Relevant articles: - [Spring Boot Reactor Netty Configuration](https://www.baeldung.com/spring-boot-reactor-netty) +- [How to Return 404 with Spring WebFlux](https://www.baeldung.com/spring-webflux-404) From 584b7b1742933be9f6d833ba6e903c4d4d334837 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Thu, 11 Apr 2019 15:29:03 +0800 Subject: [PATCH 171/531] Create README.md --- java-collections-maps-2/README.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 java-collections-maps-2/README.md diff --git a/java-collections-maps-2/README.md b/java-collections-maps-2/README.md new file mode 100644 index 0000000000..cba13c0739 --- /dev/null +++ b/java-collections-maps-2/README.md @@ -0,0 +1,2 @@ +## Relevant Articles: +- [Map of Primitives in Java] (https://www.baeldung.com/java-map-primitives) From c634b44ed64911ca5ed98a2b0a285f709613571d Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Thu, 11 Apr 2019 15:29:15 +0800 Subject: [PATCH 172/531] Update README.md --- java-collections-maps-2/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java-collections-maps-2/README.md b/java-collections-maps-2/README.md index cba13c0739..8bcafccfe8 100644 --- a/java-collections-maps-2/README.md +++ b/java-collections-maps-2/README.md @@ -1,2 +1,2 @@ ## Relevant Articles: -- [Map of Primitives in Java] (https://www.baeldung.com/java-map-primitives) +- [Map of Primitives in Java](https://www.baeldung.com/java-map-primitives) From 0f216b2568c16026df0366c052cb6b08bb5c976b Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Thu, 11 Apr 2019 15:30:50 +0800 Subject: [PATCH 173/531] Create README.md --- java-dates-2/README.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 java-dates-2/README.md diff --git a/java-dates-2/README.md b/java-dates-2/README.md new file mode 100644 index 0000000000..a6b5c8e574 --- /dev/null +++ b/java-dates-2/README.md @@ -0,0 +1,2 @@ +## Relevant Articles: +- [Converting Between LocalDate and XMLGregorianCalendar](https://www.baeldung.com/java-localdate-to-xmlgregoriancalendar) From d9540eff75f2a525ae6a73c97ba004e7a493d866 Mon Sep 17 00:00:00 2001 From: Anurag Goyal Date: Thu, 11 Apr 2019 14:52:55 +0530 Subject: [PATCH 174/531] changes for review comments --- .../filechannel/FileChannelUnitTest.java | 239 ++++++++---------- 1 file changed, 105 insertions(+), 134 deletions(-) diff --git a/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java b/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java index 37b203241b..d883972369 100644 --- a/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java +++ b/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java @@ -21,10 +21,8 @@ public class FileChannelUnitTest { @Test public void givenFile_whenReadWithFileChannelUsingRandomAccessFile_thenCorrect() throws IOException { - String expected_value = "Hello world"; - String file = "src/test/resources/test_read.in"; - - try (RandomAccessFile reader = new RandomAccessFile(file, "r"); + + try (RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.in", "r"); FileChannel channel = reader.getChannel(); ByteArrayOutputStream out = new ByteArrayOutputStream();) { @@ -34,130 +32,108 @@ public class FileChannelUnitTest { } ByteBuffer buff = ByteBuffer.allocate(bufferSize); - while (channel.read(buff) > 0) { - if (buff.hasArray()) { - out.write(buff.array(), 0, buff.position()); - buff.clear(); - } - } - - assertEquals(expected_value, new String(out.toByteArray(), StandardCharsets.UTF_8)); - } - } - - - @Test - public void givenFile_whenReadWithFileChannelUsingFileInputStream_thenCorrect() throws IOException { - String expected_value = "Hello world"; - String file = "src/test/resources/test_read.in"; - - try (ByteArrayOutputStream out = new ByteArrayOutputStream(); - FileInputStream fin = new FileInputStream(file); - FileChannel channel = fin.getChannel();) { - - int bufferSize = 1024; - if (bufferSize > channel.size()) { - bufferSize = (int) channel.size(); - } - ByteBuffer buff = ByteBuffer.allocate(bufferSize); - - while (channel.read(buff) > 0) { - if (buff.hasArray()) { - out.write(buff.array(), 0, buff.position()); - buff.clear(); - } - } - - assertEquals(expected_value, new String(out.toByteArray(), StandardCharsets.UTF_8)); - - } - } - - - @Test - public void givenFile_whenReadAFileSectionIntoMemoryWithFileChannel_thenCorrect() throws IOException { - String expected_value = "world"; - String file = "src/test/resources/test_read.in"; - - try (RandomAccessFile reader = new RandomAccessFile(file, "r"); - FileChannel channel = reader.getChannel(); - ByteArrayOutputStream out = new ByteArrayOutputStream();) { - - MappedByteBuffer buff = channel.map(FileChannel.MapMode.READ_ONLY, 6, 5); - - if(buff.hasRemaining()) { - byte[] data = new byte[buff.remaining()]; - buff.get(data); - assertEquals(expected_value, new String(data, StandardCharsets.UTF_8)); - - } - - } - } - - - @Test - public void whenWriteWithFileChannelUsingRandomAccessFile_thenCorrect() - throws IOException { - String expected = "Hello world"; - String file = "src/test/resources/test_write_using_filechannel.txt"; - - try (RandomAccessFile writer = new RandomAccessFile(file, "rw"); - FileChannel channel = writer.getChannel();){ - ByteBuffer buff = ByteBuffer.wrap("Hello world".getBytes(StandardCharsets.UTF_8)); - - if (buff.hasRemaining()) { - channel.write(buff); - } - - // verify - RandomAccessFile reader = new RandomAccessFile(file, "r"); - assertEquals(expected, reader.readLine()); - reader.close(); - } - } - - - @Test - public void givenFile_whenWriteAFileUsingLockAFileSectionWithFileChannel_thenCorrect() throws IOException { - String file = "src/test/resources/test_read.in"; - - try (RandomAccessFile reader = new RandomAccessFile(file, "rw"); - FileChannel channel = reader.getChannel(); - FileLock fileLock = channel.tryLock(6, 5, Boolean.FALSE );){ - - - assertNotNull(fileLock); - - }catch(OverlappingFileLockException | IOException ex) { - - - } - - } - - - @Test - public void givenFile_whenReadWithFileChannelGetPosition_thenCorrect() throws IOException { - long expected_value = 11; - String file = "src/test/resources/test_read.in"; - - try (ByteArrayOutputStream out = new ByteArrayOutputStream(); - RandomAccessFile reader = new RandomAccessFile(file, "r"); - FileChannel channel = reader.getChannel();) { - - int bufferSize = 1024; - if (bufferSize > channel.size()) { - bufferSize = (int) channel.size(); - } - ByteBuffer buff = ByteBuffer.allocate(bufferSize); - while (channel.read(buff) > 0) { out.write(buff.array(), 0, buff.position()); buff.clear(); } - assertEquals(expected_value, channel.position()); + assertEquals("Hello world", new String(out.toByteArray(), StandardCharsets.UTF_8)); + } + } + + @Test + public void givenFile_whenReadWithFileChannelUsingFileInputStream_thenCorrect() throws IOException { + + try (ByteArrayOutputStream out = new ByteArrayOutputStream(); + FileInputStream fin = new FileInputStream("src/test/resources/test_read.in"); + FileChannel channel = fin.getChannel();) { + + int bufferSize = 1024; + if (bufferSize > channel.size()) { + bufferSize = (int) channel.size(); + } + ByteBuffer buff = ByteBuffer.allocate(bufferSize); + + while (channel.read(buff) > 0) { + out.write(buff.array(), 0, buff.position()); + buff.clear(); + } + + assertEquals("Hello world", new String(out.toByteArray(), StandardCharsets.UTF_8)); + + } + } + + @Test + public void givenFile_whenReadAFileSectionIntoMemoryWithFileChannel_thenCorrect() throws IOException { + + try (RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.in", "r"); + FileChannel channel = reader.getChannel(); + ByteArrayOutputStream out = new ByteArrayOutputStream();) { + + MappedByteBuffer buff = channel.map(FileChannel.MapMode.READ_ONLY, 6, 5); + + if (buff.hasRemaining()) { + byte[] data = new byte[buff.remaining()]; + buff.get(data); + assertEquals("world", new String(data, StandardCharsets.UTF_8)); + + } + + } + } + + @Test + public void whenWriteWithFileChannelUsingRandomAccessFile_thenCorrect() throws IOException { + String file = "src/test/resources/test_write_using_filechannel.txt"; + try (RandomAccessFile writer = new RandomAccessFile(file, "rw"); + FileChannel channel = writer.getChannel();) { + ByteBuffer buff = ByteBuffer.wrap("Hello world".getBytes(StandardCharsets.UTF_8)); + + if (buff.hasRemaining()) { + channel.write(buff); + } + + // verify + RandomAccessFile reader = new RandomAccessFile(file, "r"); + assertEquals("Hello world", reader.readLine()); + reader.close(); + } + } + + @Test + public void givenFile_whenWriteAFileUsingLockAFileSectionWithFileChannel_thenCorrect() throws IOException { + try (RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.in", "rw"); + FileChannel channel = reader.getChannel(); + FileLock fileLock = channel.tryLock(6, 5, Boolean.FALSE);) { + + assertNotNull(fileLock); + + } catch (OverlappingFileLockException | IOException ex) { + + } + + } + + @Test + public void givenFile_whenReadWithFileChannelGetPosition_thenCorrect() throws IOException { + + try (ByteArrayOutputStream out = new ByteArrayOutputStream(); + RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.in", "r"); + FileChannel channel = reader.getChannel();) { + + int bufferSize = 1024; + if (bufferSize > channel.size()) { + bufferSize = (int) channel.size(); + } + ByteBuffer buff = ByteBuffer.allocate(bufferSize); + + while (channel.read(buff) > 0) { + out.write(buff.array(), 0, buff.position()); + buff.clear(); + } + + assertEquals(11, channel.position()); channel.position(4); assertEquals(4, channel.position()); @@ -165,28 +141,23 @@ public class FileChannelUnitTest { } } - @Test public void whenGetFileSize_thenCorrect() throws IOException { - long expectedSize = 11; - String file = "src/test/resources/test_read.in"; - - try (RandomAccessFile reader = new RandomAccessFile(file, "r"); - FileChannel channel = reader.getChannel();) { + + try (RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.in", "r"); + FileChannel channel = reader.getChannel();) { long imageFileSize = channel.size(); - assertEquals(expectedSize, imageFileSize); + assertEquals(11, imageFileSize); } } @Test public void whenTruncateFile_thenCorrect() throws IOException { - long expectedSize = 5; String input = "this is a test input"; - String file = "src/test/resources/test_truncate.txt"; - FileOutputStream fout = new FileOutputStream(file); + FileOutputStream fout = new FileOutputStream("src/test/resources/test_truncate.txt"); FileChannel channel = fout.getChannel(); ByteBuffer buff = ByteBuffer.wrap(input.getBytes()); @@ -194,7 +165,7 @@ public class FileChannelUnitTest { buff.flip(); channel = channel.truncate(5); - assertEquals(expectedSize, channel.size()); + assertEquals(5, channel.size()); fout.close(); channel.close(); From fece0dc4b8bcbb870c5a524719a30a93529deb7f Mon Sep 17 00:00:00 2001 From: Anurag Goyal Date: Thu, 11 Apr 2019 19:06:41 +0530 Subject: [PATCH 175/531] changes as per review comments --- .../filechannel/FileChannelUnitTest.java | 230 +++++++++--------- 1 file changed, 111 insertions(+), 119 deletions(-) diff --git a/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java b/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java index d883972369..6964ba80e3 100644 --- a/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java +++ b/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java @@ -12,162 +12,154 @@ import java.nio.ByteBuffer; import java.nio.MappedByteBuffer; import java.nio.channels.FileChannel; import java.nio.channels.FileLock; -import java.nio.channels.OverlappingFileLockException; import java.nio.charset.StandardCharsets; import org.junit.Test; public class FileChannelUnitTest { - @Test - public void givenFile_whenReadWithFileChannelUsingRandomAccessFile_thenCorrect() throws IOException { + @Test + public void givenFile_whenReadWithFileChannelUsingRandomAccessFile_thenCorrect() throws IOException { - try (RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.in", "r"); - FileChannel channel = reader.getChannel(); - ByteArrayOutputStream out = new ByteArrayOutputStream();) { + try (RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.in", "r"); + FileChannel channel = reader.getChannel(); + ByteArrayOutputStream out = new ByteArrayOutputStream();) { - int bufferSize = 1024; - if (bufferSize > channel.size()) { - bufferSize = (int) channel.size(); - } - ByteBuffer buff = ByteBuffer.allocate(bufferSize); + int bufferSize = 1024; + if (bufferSize > channel.size()) { + bufferSize = (int) channel.size(); + } + ByteBuffer buff = ByteBuffer.allocate(bufferSize); - while (channel.read(buff) > 0) { - out.write(buff.array(), 0, buff.position()); - buff.clear(); - } + while (channel.read(buff) > 0) { + out.write(buff.array(), 0, buff.position()); + buff.clear(); + } - assertEquals("Hello world", new String(out.toByteArray(), StandardCharsets.UTF_8)); - } - } + String fileContent = new String(out.toByteArray(), StandardCharsets.UTF_8); - @Test - public void givenFile_whenReadWithFileChannelUsingFileInputStream_thenCorrect() throws IOException { + assertEquals("Hello world", fileContent); + } + } - try (ByteArrayOutputStream out = new ByteArrayOutputStream(); - FileInputStream fin = new FileInputStream("src/test/resources/test_read.in"); - FileChannel channel = fin.getChannel();) { + @Test + public void givenFile_whenReadWithFileChannelUsingFileInputStream_thenCorrect() throws IOException { - int bufferSize = 1024; - if (bufferSize > channel.size()) { - bufferSize = (int) channel.size(); - } - ByteBuffer buff = ByteBuffer.allocate(bufferSize); + try (ByteArrayOutputStream out = new ByteArrayOutputStream(); + FileInputStream fin = new FileInputStream("src/test/resources/test_read.in"); + FileChannel channel = fin.getChannel();) { - while (channel.read(buff) > 0) { - out.write(buff.array(), 0, buff.position()); - buff.clear(); - } + int bufferSize = 1024; + if (bufferSize > channel.size()) { + bufferSize = (int) channel.size(); + } + ByteBuffer buff = ByteBuffer.allocate(bufferSize); - assertEquals("Hello world", new String(out.toByteArray(), StandardCharsets.UTF_8)); + while (channel.read(buff) > 0) { + out.write(buff.array(), 0, buff.position()); + buff.clear(); + } + String fileContent = new String(out.toByteArray(), StandardCharsets.UTF_8); - } - } + assertEquals("Hello world", fileContent); + } + } - @Test - public void givenFile_whenReadAFileSectionIntoMemoryWithFileChannel_thenCorrect() throws IOException { + @Test + public void givenFile_whenReadAFileSectionIntoMemoryWithFileChannel_thenCorrect() throws IOException { - try (RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.in", "r"); - FileChannel channel = reader.getChannel(); - ByteArrayOutputStream out = new ByteArrayOutputStream();) { + try (RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.in", "r"); + FileChannel channel = reader.getChannel(); + ByteArrayOutputStream out = new ByteArrayOutputStream();) { - MappedByteBuffer buff = channel.map(FileChannel.MapMode.READ_ONLY, 6, 5); + MappedByteBuffer buff = channel.map(FileChannel.MapMode.READ_ONLY, 6, 5); - if (buff.hasRemaining()) { - byte[] data = new byte[buff.remaining()]; - buff.get(data); - assertEquals("world", new String(data, StandardCharsets.UTF_8)); + if (buff.hasRemaining()) { + byte[] data = new byte[buff.remaining()]; + buff.get(data); + assertEquals("world", new String(data, StandardCharsets.UTF_8)); + } + } + } - } + @Test + public void whenWriteWithFileChannelUsingRandomAccessFile_thenCorrect() throws IOException { + String file = "src/test/resources/test_write_using_filechannel.txt"; + try (RandomAccessFile writer = new RandomAccessFile(file, "rw"); + FileChannel channel = writer.getChannel();) { + ByteBuffer buff = ByteBuffer.wrap("Hello world".getBytes(StandardCharsets.UTF_8)); - } - } + channel.write(buff); - @Test - public void whenWriteWithFileChannelUsingRandomAccessFile_thenCorrect() throws IOException { - String file = "src/test/resources/test_write_using_filechannel.txt"; - try (RandomAccessFile writer = new RandomAccessFile(file, "rw"); - FileChannel channel = writer.getChannel();) { - ByteBuffer buff = ByteBuffer.wrap("Hello world".getBytes(StandardCharsets.UTF_8)); + // now we verify whether the file was written correctly + RandomAccessFile reader = new RandomAccessFile(file, "r"); + assertEquals("Hello world", reader.readLine()); + reader.close(); + } + } - if (buff.hasRemaining()) { - channel.write(buff); - } + @Test + public void givenFile_whenWriteAFileUsingLockAFileSectionWithFileChannel_thenCorrect() throws IOException { + try (RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.in", "rw"); + FileChannel channel = reader.getChannel(); + FileLock fileLock = channel.tryLock(6, 5, Boolean.FALSE);) { - // verify - RandomAccessFile reader = new RandomAccessFile(file, "r"); - assertEquals("Hello world", reader.readLine()); - reader.close(); - } - } + assertNotNull(fileLock); + } + } - @Test - public void givenFile_whenWriteAFileUsingLockAFileSectionWithFileChannel_thenCorrect() throws IOException { - try (RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.in", "rw"); - FileChannel channel = reader.getChannel(); - FileLock fileLock = channel.tryLock(6, 5, Boolean.FALSE);) { + @Test + public void givenFile_whenReadWithFileChannelGetPosition_thenCorrect() throws IOException { - assertNotNull(fileLock); + try (ByteArrayOutputStream out = new ByteArrayOutputStream(); + RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.in", "r"); + FileChannel channel = reader.getChannel();) { - } catch (OverlappingFileLockException | IOException ex) { + int bufferSize = 1024; + if (bufferSize > channel.size()) { + bufferSize = (int) channel.size(); + } + ByteBuffer buff = ByteBuffer.allocate(bufferSize); - } + while (channel.read(buff) > 0) { + out.write(buff.array(), 0, buff.position()); + buff.clear(); + } - } + // the original file is 11 bytes long, so that's where the position pointer should be + assertEquals(11, channel.position()); - @Test - public void givenFile_whenReadWithFileChannelGetPosition_thenCorrect() throws IOException { + channel.position(4); + assertEquals(4, channel.position()); + } + } - try (ByteArrayOutputStream out = new ByteArrayOutputStream(); - RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.in", "r"); - FileChannel channel = reader.getChannel();) { + @Test + public void whenGetFileSize_thenCorrect() throws IOException { - int bufferSize = 1024; - if (bufferSize > channel.size()) { - bufferSize = (int) channel.size(); - } - ByteBuffer buff = ByteBuffer.allocate(bufferSize); + try (RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.in", "r"); + FileChannel channel = reader.getChannel();) { - while (channel.read(buff) > 0) { - out.write(buff.array(), 0, buff.position()); - buff.clear(); - } + // the original file is 11 bytes long, so that's where the position pointer should be + assertEquals(11, channel.size()); + } + } - assertEquals(11, channel.position()); + @Test + public void whenTruncateFile_thenCorrect() throws IOException { + String input = "this is a test input"; - channel.position(4); - assertEquals(4, channel.position()); + FileOutputStream fout = new FileOutputStream("src/test/resources/test_truncate.txt"); + FileChannel channel = fout.getChannel(); - } - } + ByteBuffer buff = ByteBuffer.wrap(input.getBytes()); + channel.write(buff); + buff.flip(); - @Test - public void whenGetFileSize_thenCorrect() throws IOException { + channel = channel.truncate(5); + assertEquals(5, channel.size()); - try (RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.in", "r"); - FileChannel channel = reader.getChannel();) { - - long imageFileSize = channel.size(); - assertEquals(11, imageFileSize); - } - - } - - @Test - public void whenTruncateFile_thenCorrect() throws IOException { - String input = "this is a test input"; - - FileOutputStream fout = new FileOutputStream("src/test/resources/test_truncate.txt"); - FileChannel channel = fout.getChannel(); - - ByteBuffer buff = ByteBuffer.wrap(input.getBytes()); - channel.write(buff); - buff.flip(); - - channel = channel.truncate(5); - assertEquals(5, channel.size()); - - fout.close(); - channel.close(); - } + fout.close(); + channel.close(); + } } From 00d8db4d6c8d4b4ae4181ae3eed2f7987d2768ad Mon Sep 17 00:00:00 2001 From: Dhawal Kapil Date: Thu, 11 Apr 2019 20:14:53 +0530 Subject: [PATCH 176/531] BAEL-14079 Renamed test to conform to *UnitTest.java convention --- .../kotlin/{StringUtilTest.java => StringUtilUnitTest.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename core-kotlin/src/test/java/com/baeldung/kotlin/{StringUtilTest.java => StringUtilUnitTest.java} (94%) diff --git a/core-kotlin/src/test/java/com/baeldung/kotlin/StringUtilTest.java b/core-kotlin/src/test/java/com/baeldung/kotlin/StringUtilUnitTest.java similarity index 94% rename from core-kotlin/src/test/java/com/baeldung/kotlin/StringUtilTest.java rename to core-kotlin/src/test/java/com/baeldung/kotlin/StringUtilUnitTest.java index 3f109b78a2..c7ef18b879 100644 --- a/core-kotlin/src/test/java/com/baeldung/kotlin/StringUtilTest.java +++ b/core-kotlin/src/test/java/com/baeldung/kotlin/StringUtilUnitTest.java @@ -7,7 +7,7 @@ import org.junit.Test; import static com.baeldung.kotlin.Strings.*; -public class StringUtilTest { +public class StringUtilUnitTest { @Test public void shouldEscapeXmlTagsInString() { From 4f5aaa38189ea7239619911f42153b11846e1cdd Mon Sep 17 00:00:00 2001 From: Dhawal Kapil Date: Thu, 11 Apr 2019 20:39:01 +0530 Subject: [PATCH 177/531] BAEL-10891 Renamed tests to *ManualTest because these tests need a running mongo db server --- ...ntegrationTest.java => AccountCrudRepositoryManualTest.java} | 2 +- ...tegrationTest.java => AccountMongoRepositoryManualTest.java} | 2 +- ...egrationTest.java => AccountRxJavaRepositoryManualTest.java} | 2 +- ...rationTest.java => AccountTemplateOperationsManualTest.java} | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename spring-5-data-reactive/src/test/java/com/baeldung/reactive/repository/{AccountCrudRepositoryIntegrationTest.java => AccountCrudRepositoryManualTest.java} (97%) rename spring-5-data-reactive/src/test/java/com/baeldung/reactive/repository/{AccountMongoRepositoryIntegrationTest.java => AccountMongoRepositoryManualTest.java} (97%) rename spring-5-data-reactive/src/test/java/com/baeldung/reactive/repository/{AccountRxJavaRepositoryIntegrationTest.java => AccountRxJavaRepositoryManualTest.java} (97%) rename spring-5-data-reactive/src/test/java/com/baeldung/reactive/template/{AccountTemplateOperationsIntegrationTest.java => AccountTemplateOperationsManualTest.java} (97%) diff --git a/spring-5-data-reactive/src/test/java/com/baeldung/reactive/repository/AccountCrudRepositoryIntegrationTest.java b/spring-5-data-reactive/src/test/java/com/baeldung/reactive/repository/AccountCrudRepositoryManualTest.java similarity index 97% rename from spring-5-data-reactive/src/test/java/com/baeldung/reactive/repository/AccountCrudRepositoryIntegrationTest.java rename to spring-5-data-reactive/src/test/java/com/baeldung/reactive/repository/AccountCrudRepositoryManualTest.java index f425826dce..d4b1d0eeda 100644 --- a/spring-5-data-reactive/src/test/java/com/baeldung/reactive/repository/AccountCrudRepositoryIntegrationTest.java +++ b/spring-5-data-reactive/src/test/java/com/baeldung/reactive/repository/AccountCrudRepositoryManualTest.java @@ -17,7 +17,7 @@ import static org.junit.Assert.assertNotNull; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = Spring5ReactiveApplication.class) -public class AccountCrudRepositoryIntegrationTest { +public class AccountCrudRepositoryManualTest { @Autowired AccountCrudRepository repository; diff --git a/spring-5-data-reactive/src/test/java/com/baeldung/reactive/repository/AccountMongoRepositoryIntegrationTest.java b/spring-5-data-reactive/src/test/java/com/baeldung/reactive/repository/AccountMongoRepositoryManualTest.java similarity index 97% rename from spring-5-data-reactive/src/test/java/com/baeldung/reactive/repository/AccountMongoRepositoryIntegrationTest.java rename to spring-5-data-reactive/src/test/java/com/baeldung/reactive/repository/AccountMongoRepositoryManualTest.java index bfa6a789b2..2ca075aa5e 100644 --- a/spring-5-data-reactive/src/test/java/com/baeldung/reactive/repository/AccountMongoRepositoryIntegrationTest.java +++ b/spring-5-data-reactive/src/test/java/com/baeldung/reactive/repository/AccountMongoRepositoryManualTest.java @@ -19,7 +19,7 @@ import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatc @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = Spring5ReactiveApplication.class) -public class AccountMongoRepositoryIntegrationTest { +public class AccountMongoRepositoryManualTest { @Autowired AccountMongoRepository repository; diff --git a/spring-5-data-reactive/src/test/java/com/baeldung/reactive/repository/AccountRxJavaRepositoryIntegrationTest.java b/spring-5-data-reactive/src/test/java/com/baeldung/reactive/repository/AccountRxJavaRepositoryManualTest.java similarity index 97% rename from spring-5-data-reactive/src/test/java/com/baeldung/reactive/repository/AccountRxJavaRepositoryIntegrationTest.java rename to spring-5-data-reactive/src/test/java/com/baeldung/reactive/repository/AccountRxJavaRepositoryManualTest.java index e9b3eb1c40..d91acd24e2 100644 --- a/spring-5-data-reactive/src/test/java/com/baeldung/reactive/repository/AccountRxJavaRepositoryIntegrationTest.java +++ b/spring-5-data-reactive/src/test/java/com/baeldung/reactive/repository/AccountRxJavaRepositoryManualTest.java @@ -15,7 +15,7 @@ import static org.junit.Assert.assertNotNull; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = Spring5ReactiveApplication.class) -public class AccountRxJavaRepositoryIntegrationTest { +public class AccountRxJavaRepositoryManualTest { @Autowired AccountRxJavaRepository repository; diff --git a/spring-5-data-reactive/src/test/java/com/baeldung/reactive/template/AccountTemplateOperationsIntegrationTest.java b/spring-5-data-reactive/src/test/java/com/baeldung/reactive/template/AccountTemplateOperationsManualTest.java similarity index 97% rename from spring-5-data-reactive/src/test/java/com/baeldung/reactive/template/AccountTemplateOperationsIntegrationTest.java rename to spring-5-data-reactive/src/test/java/com/baeldung/reactive/template/AccountTemplateOperationsManualTest.java index 373da0e393..5fa0e39317 100644 --- a/spring-5-data-reactive/src/test/java/com/baeldung/reactive/template/AccountTemplateOperationsIntegrationTest.java +++ b/spring-5-data-reactive/src/test/java/com/baeldung/reactive/template/AccountTemplateOperationsManualTest.java @@ -16,7 +16,7 @@ import static org.junit.jupiter.api.Assertions.*; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = Spring5ReactiveApplication.class) -public class AccountTemplateOperationsIntegrationTest { +public class AccountTemplateOperationsManualTest { @Autowired AccountTemplateOperations accountTemplate; From 2841688215ab42b8521ec9ebdc58bdf8b2411e83 Mon Sep 17 00:00:00 2001 From: Dhawal Kapil Date: Thu, 11 Apr 2019 20:55:38 +0530 Subject: [PATCH 178/531] BAEL-10891 Moved projects spring-5-data-reactive and spring-amqp-simple from heavy profiles to default-second and integration-lite-second --- pom.xml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 7fb9ca351f..9aa54ad826 100644 --- a/pom.xml +++ b/pom.xml @@ -584,6 +584,7 @@ spring-5 spring-5-webflux + spring-5-data-reactive spring-5-mvc spring-5-reactive spring-5-reactive-client @@ -596,6 +597,7 @@ spring-akka spring-all spring-amqp + spring-amqp-simple spring-aop spring-apache-camel spring-batch @@ -956,9 +958,6 @@ persistence-modules/java-mongodb persistence-modules/jnosql - spring-5-data-reactive - spring-amqp-simple - vaadin @@ -1228,6 +1227,7 @@ spring-4 spring-5 + spring-5-data-reactive spring-5-mvc spring-5-reactive spring-5-reactive-client @@ -1240,6 +1240,7 @@ spring-akka spring-all spring-amqp + spring-amqp-simple spring-aop spring-apache-camel spring-batch @@ -1452,9 +1453,6 @@ persistence-modules/java-mongodb persistence-modules/jnosql - spring-5-data-reactive - spring-amqp-simple - vaadin From 7bb364a2f20c059ff53ec38e0b11e5d2174b0b76 Mon Sep 17 00:00:00 2001 From: "sumit.sg34" Date: Thu, 11 Apr 2019 23:01:50 +0530 Subject: [PATCH 179/531] BAEL-2841 updated test cases and test data --- .../com/baeldung/config/JpaPopulators.java | 66 +++++++------- .../src/main/resources/fruit-data.xml | 14 +-- .../repository/FruitPopulatorTest.java | 91 ++++++++----------- 3 files changed, 78 insertions(+), 93 deletions(-) diff --git a/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/config/JpaPopulators.java b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/config/JpaPopulators.java index cb4b32aabc..0791df85f4 100644 --- a/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/config/JpaPopulators.java +++ b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/config/JpaPopulators.java @@ -1,33 +1,33 @@ -package com.baeldung.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.Resource; -import org.springframework.data.repository.init.Jackson2RepositoryPopulatorFactoryBean; -import org.springframework.data.repository.init.UnmarshallerRepositoryPopulatorFactoryBean; -import org.springframework.oxm.jaxb.Jaxb2Marshaller; - -import com.baeldung.entity.Fruit; - -@Configuration -public class JpaPopulators { - - @Bean - public Jackson2RepositoryPopulatorFactoryBean getRespositoryPopulator() throws Exception { - Jackson2RepositoryPopulatorFactoryBean factory = new Jackson2RepositoryPopulatorFactoryBean(); - factory.setResources(new Resource[] { (Resource) new ClassPathResource("fruit-data.json") }); - return factory; - } - - @Bean - public UnmarshallerRepositoryPopulatorFactoryBean repositoryPopulator() { - Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); - marshaller.setClassesToBeBound(Fruit.class); - UnmarshallerRepositoryPopulatorFactoryBean factory = new UnmarshallerRepositoryPopulatorFactoryBean(); - factory.setUnmarshaller(marshaller); - factory.setResources(new Resource[] { new ClassPathResource("fruit-data.xml") }); - return factory; - } - -} +package com.baeldung.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; +import org.springframework.data.repository.init.Jackson2RepositoryPopulatorFactoryBean; +import org.springframework.data.repository.init.UnmarshallerRepositoryPopulatorFactoryBean; +import org.springframework.oxm.jaxb.Jaxb2Marshaller; + +import com.baeldung.entity.Fruit; + +@Configuration +public class JpaPopulators { + + @Bean + public Jackson2RepositoryPopulatorFactoryBean getRespositoryPopulator() throws Exception { + Jackson2RepositoryPopulatorFactoryBean factory = new Jackson2RepositoryPopulatorFactoryBean(); + factory.setResources(new Resource[] { new ClassPathResource("fruit-data.json") }); + return factory; + } + + @Bean + public UnmarshallerRepositoryPopulatorFactoryBean repositoryPopulator() { + Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); + marshaller.setClassesToBeBound(Fruit.class); + UnmarshallerRepositoryPopulatorFactoryBean factory = new UnmarshallerRepositoryPopulatorFactoryBean(); + factory.setUnmarshaller(marshaller); + factory.setResources(new Resource[] { new ClassPathResource("fruit-data.xml") }); + return factory; + } + +} diff --git a/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.xml b/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.xml index fe6eb71faf..d0101e3f4d 100644 --- a/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.xml +++ b/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.xml @@ -1,7 +1,7 @@ - - - - 3 - mango - yellow - + + + + 1 + apple + red + diff --git a/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/repository/FruitPopulatorTest.java b/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/repository/FruitPopulatorTest.java index 8760c69ce8..29ef52dcef 100644 --- a/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/repository/FruitPopulatorTest.java +++ b/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/repository/FruitPopulatorTest.java @@ -1,53 +1,38 @@ -package com.baeldung.repository; - -import static org.junit.Assert.assertEquals; - -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.entity.Fruit; - -@RunWith(SpringRunner.class) -@SpringBootTest -public class FruitPopulatorTest { - - @Autowired - private FruitRepository fruitRepository; - - @Test - public void givenFruitJsonPopulatorThenShouldInsertRecordOnStart() { - - List fruits = fruitRepository.findAll(); - assertEquals("record count is not matching", 3, fruits.size()); - - fruits.forEach(fruit -> { - if (1 == fruit.getId()) { - assertEquals("This is not an apple", "apple", fruit.getName()); - assertEquals("It is not a red colored fruit", "red", fruit.getColor()); - } else if (2 == fruit.getId()) { - assertEquals("This is not a guava", "guava", fruit.getName()); - assertEquals("It is not a green colored fruit", "green", fruit.getColor()); - } - }); - } - - @Test - public void givenFruitXmlPopulatorThenShouldInsertRecordOnStart() { - - List fruits = fruitRepository.findAll(); - assertEquals("record count is not matching", 3, fruits.size()); - - fruits.forEach(fruit -> { - if (3 == fruit.getId()) { - assertEquals("This is not a mango", "mango", fruit.getName()); - assertEquals("It is not a yellow colored fruit", "yellow", fruit.getColor()); - } - }); - } - -} +package com.baeldung.repository; + +import static org.junit.Assert.assertEquals; + +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.entity.Fruit; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class FruitPopulatorTest { + + @Autowired + private FruitRepository fruitRepository; + + @Test + public void givenFruitJsonPopulatorThenShouldInsertRecordOnStart() { + + List fruits = fruitRepository.findAll(); + assertEquals("record count is not matching", 2, fruits.size()); + + fruits.forEach(fruit -> { + if (1 == fruit.getId()) { + assertEquals("apple", fruit.getName()); + assertEquals("red", fruit.getColor()); + } else if (2 == fruit.getId()) { + assertEquals("guava", fruit.getName()); + assertEquals("green", fruit.getColor()); + } + }); + } +} From b3a1a0cab031b94bbaf9ba3c6222a32b41abb9d9 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 12 Apr 2019 14:12:07 +0800 Subject: [PATCH 180/531] Update README.md --- java-streams/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java-streams/README.md b/java-streams/README.md index e294e5aee1..0c9588c47e 100644 --- a/java-streams/README.md +++ b/java-streams/README.md @@ -8,7 +8,7 @@ - [Java 8 and Infinite Streams](http://www.baeldung.com/java-inifinite-streams) - [Java 8 Stream findFirst() vs. findAny()](http://www.baeldung.com/java-stream-findfirst-vs-findany) - [How to Get the Last Element of a Stream in Java?](http://www.baeldung.com/java-stream-last-element) -- [â€Stream has already been operated upon or closed†Exception in Java](http://www.baeldung.com/java-stream-operated-upon-or-closed-exception) +- [“Stream has already been operated upon or closed†Exception in Java](http://www.baeldung.com/java-stream-operated-upon-or-closed-exception) - [Iterable to Stream in Java](http://www.baeldung.com/java-iterable-to-stream) - [How to Iterate Over a Stream With Indices](http://www.baeldung.com/java-stream-indices) - [Primitive Type Streams in Java 8](http://www.baeldung.com/java-8-primitive-streams) From 7fdf72c7e3606ff2be9dfb40d4f66698ec562d88 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 12 Apr 2019 14:16:47 +0800 Subject: [PATCH 181/531] Update README.MD --- spring-boot/README.MD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot/README.MD b/spring-boot/README.MD index 3b92063d83..b8b51153a7 100644 --- a/spring-boot/README.MD +++ b/spring-boot/README.MD @@ -6,7 +6,7 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [A Guide to Spring in Eclipse STS](http://www.baeldung.com/eclipse-sts-spring) - [The @ServletComponentScan Annotation in Spring Boot](http://www.baeldung.com/spring-servletcomponentscan) - [Intro to Building an Application with Spring Boot](http://www.baeldung.com/intro-to-spring-boot) -- [How to Register a Servlet in a Java](http://www.baeldung.com/register-servlet) +- [How to Register a Servlet in Java](http://www.baeldung.com/register-servlet) - [Guide to Spring WebUtils and ServletRequestUtils](http://www.baeldung.com/spring-webutils-servletrequestutils) - [Using Custom Banners in Spring Boot](http://www.baeldung.com/spring-boot-custom-banners) - [Guide to Internationalization in Spring Boot](http://www.baeldung.com/spring-boot-internationalization) From 09e24782631ee2bac1e0bb33a28fc40a03df2699 Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 12 Apr 2019 14:18:00 +0800 Subject: [PATCH 182/531] Update README.md --- logging-modules/log4j2/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logging-modules/log4j2/README.md b/logging-modules/log4j2/README.md index f365d67ea8..dd326bc7a1 100644 --- a/logging-modules/log4j2/README.md +++ b/logging-modules/log4j2/README.md @@ -4,4 +4,4 @@ - [Log4j 2 and Lambda Expressions](http://www.baeldung.com/log4j-2-lazy-logging) - [Programmatic Configuration with Log4j 2](http://www.baeldung.com/log4j2-programmatic-config) - [Creating a Custom Log4j2 Appender](https://www.baeldung.com/log4j2-custom-appender) -- [Get Log Output in JSON Format](http://www.baeldung.com/java-log-json-output) +- [Get Log Output in JSON](http://www.baeldung.com/java-log-json-output) From d2aa295e0b9d08f567ec07d965db480e5057d47b Mon Sep 17 00:00:00 2001 From: sheryllresulta <48046330+sheryllresulta@users.noreply.github.com> Date: Fri, 12 Apr 2019 14:18:53 +0800 Subject: [PATCH 183/531] Update README.md --- rxjava-2/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/rxjava-2/README.md b/rxjava-2/README.md index c255338402..4182f3fa00 100644 --- a/rxjava-2/README.md +++ b/rxjava-2/README.md @@ -2,7 +2,6 @@ - [RxJava and Error Handling](http://www.baeldung.com/rxjava-error-handling) - [RxJava 2 – Flowable](http://www.baeldung.com/rxjava-2-flowable) -- [Combining RxJava Completables](http://www.baeldung.com/rxjava-completable) - [RxJava Maybe](http://www.baeldung.com/rxjava-maybe) - [Introduction to RxRelay for RxJava](http://www.baeldung.com/rx-relay) - [Combining RxJava Completables](https://www.baeldung.com/rxjava-completable) From 6ae1e85d1361b62f5762129c2664e2fbe822ea25 Mon Sep 17 00:00:00 2001 From: mprevisic Date: Fri, 12 Apr 2019 09:13:59 +0200 Subject: [PATCH 184/531] BAEL-1970 fixed formatting --- .../LogbackTestLogLevelIntegrationTest.java | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackTestLogLevelIntegrationTest.java b/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackTestLogLevelIntegrationTest.java index 5fb40a2f36..af3bafdc2e 100644 --- a/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackTestLogLevelIntegrationTest.java +++ b/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackTestLogLevelIntegrationTest.java @@ -22,49 +22,49 @@ import org.springframework.test.context.junit4.SpringRunner; @ActiveProfiles("logback-test") public class LogbackTestLogLevelIntegrationTest { - @Autowired - private TestRestTemplate restTemplate; + @Autowired + private TestRestTemplate restTemplate; - @Rule - public OutputCapture outputCapture = new OutputCapture(); + @Rule + public OutputCapture outputCapture = new OutputCapture(); - private String baseUrl = "/testLogLevel"; + private String baseUrl = "/testLogLevel"; - @Test - public void givenErrorRootLevelAndDebugLevelForOurPackage_whenCall_thenPrintDebugLogsForOurPackage() { - ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); + @Test + public void givenErrorRootLevelAndDebugLevelForOurPackage_whenCall_thenPrintDebugLogsForOurPackage() { + ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); - assertThat(response.getStatusCode().value()).isEqualTo(200); - assertThatOutputContainsLogForOurPackage("DEBUG"); - } + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThatOutputContainsLogForOurPackage("DEBUG"); + } - @Test - public void givenErrorRootLevelAndDebugLevelForOurPackage_whenCall_thenNoDebugLogsForOtherPackages() { - ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); + @Test + public void givenErrorRootLevelAndDebugLevelForOurPackage_whenCall_thenNoDebugLogsForOtherPackages() { + ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); - assertThat(response.getStatusCode().value()).isEqualTo(200); - assertThatOutputDoesntContainLogForOtherPackages("DEBUG"); - } + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThatOutputDoesntContainLogForOtherPackages("DEBUG"); + } - @Test - public void givenErrorRootLevelAndDebugLevelForOurPackage_whenCall_thenPrintErrorLogs() { - ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); + @Test + public void givenErrorRootLevelAndDebugLevelForOurPackage_whenCall_thenPrintErrorLogs() { + ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); - assertThat(response.getStatusCode().value()).isEqualTo(200); - assertThatOutputContainsLogForOurPackage("ERROR"); - assertThatOutputContainsLogForOtherPackages("ERROR"); - } + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThatOutputContainsLogForOurPackage("ERROR"); + assertThatOutputContainsLogForOtherPackages("ERROR"); + } - private void assertThatOutputContainsLogForOurPackage(String level) { - assertThat(outputCapture.toString()).containsPattern("TestLogLevelController.*" + level + ".*"); - } + private void assertThatOutputContainsLogForOurPackage(String level) { + assertThat(outputCapture.toString()).containsPattern("TestLogLevelController.*" + level + ".*"); + } - private void assertThatOutputDoesntContainLogForOtherPackages(String level) { - assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).doesNotContain(level); - } + private void assertThatOutputDoesntContainLogForOtherPackages(String level) { + assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).doesNotContain(level); + } - private void assertThatOutputContainsLogForOtherPackages(String level) { - assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).contains(level); - } + private void assertThatOutputContainsLogForOtherPackages(String level) { + assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).contains(level); + } } From 00d6406ef9b343c3f64868b657e0350b77194f73 Mon Sep 17 00:00:00 2001 From: DOHA Date: Fri, 12 Apr 2019 16:31:22 +0200 Subject: [PATCH 185/531] add generic constructor examples --- .../java/com/baeldung/generics/Entry.java | 38 ++++++++++ .../com/baeldung/generics/GenericEntry.java | 53 +++++++++++++ .../java/com/baeldung/generics/MapEntry.java | 34 +++++++++ .../java/com/baeldung/generics/Product.java | 50 ++++++++++++ .../java/com/baeldung/generics/Rankable.java | 5 ++ .../generics/GenericConstructorUnitTest.java | 76 +++++++++++++++++++ 6 files changed, 256 insertions(+) create mode 100644 core-java-lang-syntax/src/main/java/com/baeldung/generics/Entry.java create mode 100644 core-java-lang-syntax/src/main/java/com/baeldung/generics/GenericEntry.java create mode 100644 core-java-lang-syntax/src/main/java/com/baeldung/generics/MapEntry.java create mode 100644 core-java-lang-syntax/src/main/java/com/baeldung/generics/Product.java create mode 100644 core-java-lang-syntax/src/main/java/com/baeldung/generics/Rankable.java create mode 100644 core-java-lang-syntax/src/test/java/com/baeldung/generics/GenericConstructorUnitTest.java diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/generics/Entry.java b/core-java-lang-syntax/src/main/java/com/baeldung/generics/Entry.java new file mode 100644 index 0000000000..07759ca9ba --- /dev/null +++ b/core-java-lang-syntax/src/main/java/com/baeldung/generics/Entry.java @@ -0,0 +1,38 @@ +package com.baeldung.generics; + +import java.io.Serializable; + +public class Entry { + private String data; + private int rank; + + // non-generic constructor + public Entry(String data, int rank) { + this.data = data; + this.rank = rank; + } + + // generic constructor + public Entry(E element) { + this.data = element.toString(); + this.rank = element.getRank(); + } + + // getters and setters + public String getData() { + return data; + } + + public void setData(String data) { + this.data = data; + } + + public int getRank() { + return rank; + } + + public void setRank(int rank) { + this.rank = rank; + } + +} diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/generics/GenericEntry.java b/core-java-lang-syntax/src/main/java/com/baeldung/generics/GenericEntry.java new file mode 100644 index 0000000000..27d3a44069 --- /dev/null +++ b/core-java-lang-syntax/src/main/java/com/baeldung/generics/GenericEntry.java @@ -0,0 +1,53 @@ +package com.baeldung.generics; + +import java.io.Serializable; +import java.util.Optional; + +public class GenericEntry { + private T data; + private int rank; + + // non-generic constructor + public GenericEntry(int rank) { + this.rank = rank; + } + + // generic constructor + public GenericEntry(T data, int rank) { + this.data = data; + this.rank = rank; + } + + // generic constructor with different type + public GenericEntry(E element) { + this.data = (T) element; + this.rank = element.getRank(); + } + + // generic constructor with different type and wild card + public GenericEntry(Optional optional) { + if (optional.isPresent()) { + this.data = (T) optional.get(); + this.rank = optional.get() + .getRank(); + } + } + + // getters and setters + public T getData() { + return data; + } + + public void setData(T data) { + this.data = data; + } + + public int getRank() { + return rank; + } + + public void setRank(int rank) { + this.rank = rank; + } + +} diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/generics/MapEntry.java b/core-java-lang-syntax/src/main/java/com/baeldung/generics/MapEntry.java new file mode 100644 index 0000000000..3d626b2fa5 --- /dev/null +++ b/core-java-lang-syntax/src/main/java/com/baeldung/generics/MapEntry.java @@ -0,0 +1,34 @@ +package com.baeldung.generics; + +public class MapEntry { + private K key; + private V value; + + public MapEntry() { + super(); + } + + // generic constructor with two parameters + public MapEntry(K key, V value) { + this.key = key; + this.value = value; + } + + // getters and setters + public K getKey() { + return key; + } + + public void setKey(K key) { + this.key = key; + } + + public V getValue() { + return value; + } + + public void setValue(V value) { + this.value = value; + } + +} diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/generics/Product.java b/core-java-lang-syntax/src/main/java/com/baeldung/generics/Product.java new file mode 100644 index 0000000000..bfc9f63071 --- /dev/null +++ b/core-java-lang-syntax/src/main/java/com/baeldung/generics/Product.java @@ -0,0 +1,50 @@ +package com.baeldung.generics; + +import java.io.Serializable; + +public class Product implements Rankable, Serializable { + private String name; + private double price; + private int sales; + + public Product(String name, double price) { + this.name = name; + this.price = price; + } + + @Override + public int getRank() { + return sales; + } + + @Override + public String toString() { + return "Product [name=" + name + ", price=" + price + ", sales=" + sales + "]"; + } + + // getters and setters + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public double getPrice() { + return price; + } + + public void setPrice(double price) { + this.price = price; + } + + public int getSales() { + return sales; + } + + public void setSales(int sales) { + this.sales = sales; + } + +} diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/generics/Rankable.java b/core-java-lang-syntax/src/main/java/com/baeldung/generics/Rankable.java new file mode 100644 index 0000000000..72bda67d9d --- /dev/null +++ b/core-java-lang-syntax/src/main/java/com/baeldung/generics/Rankable.java @@ -0,0 +1,5 @@ +package com.baeldung.generics; + +public interface Rankable { + public int getRank(); +} diff --git a/core-java-lang-syntax/src/test/java/com/baeldung/generics/GenericConstructorUnitTest.java b/core-java-lang-syntax/src/test/java/com/baeldung/generics/GenericConstructorUnitTest.java new file mode 100644 index 0000000000..60907bbfd3 --- /dev/null +++ b/core-java-lang-syntax/src/test/java/com/baeldung/generics/GenericConstructorUnitTest.java @@ -0,0 +1,76 @@ +package com.baeldung.generics; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import java.io.Serializable; +import java.util.Optional; + +import org.junit.Test; + +public class GenericConstructorUnitTest { + + @Test + public void givenNonGenericConstructor_whenCreateNonGenericEntry_thenOK() { + Entry entry = new Entry("sample", 1); + + assertEquals("sample", entry.getData()); + assertEquals(1, entry.getRank()); + } + + @Test + public void givenGenericConstructor_whenCreateNonGenericEntry_thenOK() { + Product product = new Product("milk", 2.5); + product.setSales(30); + Entry entry = new Entry(product); + + assertEquals(product.toString(), entry.getData()); + assertEquals(30, entry.getRank()); + } + + @Test + public void givenNonGenericConstructor_whenCreateGenericEntry_thenOK() { + GenericEntry entry = new GenericEntry(1); + + assertNull(entry.getData()); + assertEquals(1, entry.getRank()); + } + + @Test + public void givenGenericConstructor_whenCreateGenericEntry_thenOK() { + GenericEntry entry = new GenericEntry("sample", 1); + + assertEquals("sample", entry.getData()); + assertEquals(1, entry.getRank()); + } + + @Test + public void givenGenericConstructorWithDifferentType_whenCreateGenericEntry_thenOK() { + Product product = new Product("milk", 2.5); + product.setSales(30); + GenericEntry entry = new GenericEntry(product); + + assertEquals(product, entry.getData()); + assertEquals(30, entry.getRank()); + } + + @Test + public void givenGenericConstructorWithWildCard_whenCreateGenericEntry_thenOK() { + Product product = new Product("milk", 2.5); + product.setSales(30); + Optional optional = Optional.of(product); + GenericEntry entry = new GenericEntry(optional); + + assertEquals(product, entry.getData()); + assertEquals(30, entry.getRank()); + } + + @Test + public void givenGenericConstructor_whenCreateGenericEntryWithTwoTypes_thenOK() { + MapEntry entry = new MapEntry("sample", 1); + + assertEquals("sample", entry.getKey()); + assertEquals(1, entry.getValue() + .intValue()); + } +} From f6aa400ace250e519aa08abb8ea48fc080bbf3c1 Mon Sep 17 00:00:00 2001 From: Seun Matt Date: Fri, 12 Apr 2019 21:55:27 +0100 Subject: [PATCH 186/531] example code for BAEL-2849 (#6701) * added example code for BAEL-2083 * updated example code for BAEL-2083 * added example code for BAEL-2849 --- .../springboot/SpringBootH2Application.java | 12 +++++ .../h2db/springboot/daos/UserRepository.java | 10 ++++ .../baeldung/h2db/springboot/models/User.java | 54 +++++++++++++++++++ .../src/main/resources/application.properties | 2 +- .../baeldung/SpringBootH2IntegrationTest.java | 50 +++++++++++++++++ 5 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 persistence-modules/spring-boot-h2/spring-boot-h2-database/src/main/java/com/baeldung/h2db/springboot/SpringBootH2Application.java create mode 100644 persistence-modules/spring-boot-h2/spring-boot-h2-database/src/main/java/com/baeldung/h2db/springboot/daos/UserRepository.java create mode 100644 persistence-modules/spring-boot-h2/spring-boot-h2-database/src/main/java/com/baeldung/h2db/springboot/models/User.java create mode 100644 persistence-modules/spring-boot-h2/spring-boot-h2-database/src/test/java/com/baeldung/SpringBootH2IntegrationTest.java diff --git a/persistence-modules/spring-boot-h2/spring-boot-h2-database/src/main/java/com/baeldung/h2db/springboot/SpringBootH2Application.java b/persistence-modules/spring-boot-h2/spring-boot-h2-database/src/main/java/com/baeldung/h2db/springboot/SpringBootH2Application.java new file mode 100644 index 0000000000..378093cfa9 --- /dev/null +++ b/persistence-modules/spring-boot-h2/spring-boot-h2-database/src/main/java/com/baeldung/h2db/springboot/SpringBootH2Application.java @@ -0,0 +1,12 @@ +package com.baeldung.h2db.springboot; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpringBootH2Application { + + public static void main(String... args) { + SpringApplication.run(SpringBootH2Application.class, args); + } +} diff --git a/persistence-modules/spring-boot-h2/spring-boot-h2-database/src/main/java/com/baeldung/h2db/springboot/daos/UserRepository.java b/persistence-modules/spring-boot-h2/spring-boot-h2-database/src/main/java/com/baeldung/h2db/springboot/daos/UserRepository.java new file mode 100644 index 0000000000..35e496e910 --- /dev/null +++ b/persistence-modules/spring-boot-h2/spring-boot-h2-database/src/main/java/com/baeldung/h2db/springboot/daos/UserRepository.java @@ -0,0 +1,10 @@ +package com.baeldung.h2db.springboot.daos; + + + + +import com.baeldung.h2db.springboot.models.User; +import org.springframework.data.repository.CrudRepository; + +public interface UserRepository extends CrudRepository { +} diff --git a/persistence-modules/spring-boot-h2/spring-boot-h2-database/src/main/java/com/baeldung/h2db/springboot/models/User.java b/persistence-modules/spring-boot-h2/spring-boot-h2-database/src/main/java/com/baeldung/h2db/springboot/models/User.java new file mode 100644 index 0000000000..fa3c01c035 --- /dev/null +++ b/persistence-modules/spring-boot-h2/spring-boot-h2-database/src/main/java/com/baeldung/h2db/springboot/models/User.java @@ -0,0 +1,54 @@ +package com.baeldung.h2db.springboot.models; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; + +@Table(name = "users") +@Entity +public class User { + + @Id + @GeneratedValue + private int id; + + private String firstName; + + private String lastName; + + public User() { } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + @Override + public String toString() { + return "User{" + + "id=" + id + + ", firstName='" + firstName + '\'' + + ", lastName='" + lastName + '\'' + + '}'; + } +} diff --git a/persistence-modules/spring-boot-h2/spring-boot-h2-database/src/main/resources/application.properties b/persistence-modules/spring-boot-h2/spring-boot-h2-database/src/main/resources/application.properties index 5e425a3550..109b389b58 100644 --- a/persistence-modules/spring-boot-h2/spring-boot-h2-database/src/main/resources/application.properties +++ b/persistence-modules/spring-boot-h2/spring-boot-h2-database/src/main/resources/application.properties @@ -2,7 +2,7 @@ spring.datasource.url=jdbc:h2:mem:mydb spring.datasource.driverClassName=org.h2.Driver spring.datasource.username=sa spring.datasource.password= -spring.jpa.hibernate.ddl-auto=create +spring.jpa.hibernate.ddl-auto=create-drop spring.h2.console.enabled=true spring.h2.console.path=/h2-console debug=true \ No newline at end of file diff --git a/persistence-modules/spring-boot-h2/spring-boot-h2-database/src/test/java/com/baeldung/SpringBootH2IntegrationTest.java b/persistence-modules/spring-boot-h2/spring-boot-h2-database/src/test/java/com/baeldung/SpringBootH2IntegrationTest.java new file mode 100644 index 0000000000..aecc63c599 --- /dev/null +++ b/persistence-modules/spring-boot-h2/spring-boot-h2-database/src/test/java/com/baeldung/SpringBootH2IntegrationTest.java @@ -0,0 +1,50 @@ +package com.baeldung; + +import com.baeldung.h2db.springboot.SpringBootH2Application; +import com.baeldung.h2db.springboot.daos.UserRepository; +import com.baeldung.h2db.springboot.models.User; +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 java.util.List; + +import static org.junit.Assert.*; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = SpringBootH2Application.class) +public class SpringBootH2IntegrationTest { + + @Autowired + private UserRepository userRepository; + + @Test + public void contextLoads() { } + + @Test + public void givenUserProfile_whenAddUser_thenCreateNewUser() { + User user = new User(); + user.setFirstName("John"); + user.setLastName("Doe"); + userRepository.save(user); + List users = (List) userRepository.findAll(); + assertFalse(users.isEmpty()); + + String firstName = "Aliko"; + String lastName = "Dangote"; + User user1 = userRepository.findById(users.get(0).getId()).get(); + user1.setLastName(lastName); + user1.setFirstName(firstName); + userRepository.save(user1); + + user = userRepository.findById(user.getId()).get(); + assertEquals(user.getFirstName(), firstName); + assertEquals(user.getLastName(), lastName); + + userRepository.deleteById(user.getId()); + assertTrue( ((List) userRepository.findAll()).isEmpty()); + } + +} From 28ae6b644ed8c77c9dd993ae7c180e552b7a0d69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?isa=20=C3=B6lmez?= Date: Fri, 12 Apr 2019 23:59:57 +0300 Subject: [PATCH 187/531] BAEL-2811: Added new code samples (#6711) --- .../baeldung/joins/JpaJoinsIntegrationTest.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/joins/JpaJoinsIntegrationTest.java b/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/joins/JpaJoinsIntegrationTest.java index d807da9845..9b0d23f3e4 100644 --- a/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/joins/JpaJoinsIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/joins/JpaJoinsIntegrationTest.java @@ -4,6 +4,7 @@ import static org.assertj.core.api.Assertions.assertThat; import com.baeldung.joins.model.Department; import com.baeldung.joins.model.Phone; +import java.util.Collection; import java.util.List; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; @@ -79,11 +80,11 @@ public class JpaJoinsIntegrationTest { @Test public void whenCollectionValuedAssociationIsJoined_ThenCanSelect() { - TypedQuery query = entityManager.createQuery("SELECT ph FROM Employee e JOIN e.phones ph ", Phone.class); + TypedQuery query = entityManager.createQuery("SELECT ph FROM Employee e JOIN e.phones ph WHERE ph LIKE '1%'", Phone.class); List resultList = query.getResultList(); - assertThat(resultList).hasSize(3); + assertThat(resultList).hasSize(1); } @Test @@ -122,9 +123,20 @@ public class JpaJoinsIntegrationTest { @Test public void whenLeftAndFetchKeywordsAreSpecified_ThenCreatesOuterFetchJoin() { TypedQuery query = entityManager.createQuery("SELECT d FROM Department d LEFT JOIN FETCH d.employees", Department.class); + List resultList = query.getResultList(); + assertThat(resultList).hasSize(4); assertThat(resultList).extracting("name") .containsOnly("Infra", "Accounting", "Accounting", "Management"); } + + @Test + public void whenCollectionValuedAssociationIsSpecifiedInSelect_ThenReturnsCollections() { + TypedQuery query = entityManager.createQuery("SELECT e.phones FROM Employee e", Collection.class); + + List resultList = query.getResultList(); + + assertThat(resultList).extracting("number").containsOnly("111", "222", "333"); + } } From 9df90567d442fb5b9dc3626db9f63e782521b14e Mon Sep 17 00:00:00 2001 From: Marcos Lopez Gonzalez Date: Sat, 13 Apr 2019 07:10:46 +0200 Subject: [PATCH 188/531] BAEL-2464 - lambdas and final local variables (#6530) * lambdas and final local variables * workarounds when using non-final local variables in lambdas * cleanup * capturing lambdas refactor * lambdas and local variables * added comments to capturing lambdas examples * lambdas variables moved to core-java-lambdas * core-java-lambdas module moved in pom * format --- core-java-lambdas/pom.xml | 19 ++++ .../com/baeldung/lambdas/LambdaVariables.java | 88 +++++++++++++++++++ pom.xml | 1 + 3 files changed, 108 insertions(+) create mode 100644 core-java-lambdas/pom.xml create mode 100644 core-java-lambdas/src/main/java/com/baeldung/lambdas/LambdaVariables.java diff --git a/core-java-lambdas/pom.xml b/core-java-lambdas/pom.xml new file mode 100644 index 0000000000..25538a3524 --- /dev/null +++ b/core-java-lambdas/pom.xml @@ -0,0 +1,19 @@ + + + 4.0.0 + core-java-lambdas + 0.1.0-SNAPSHOT + core-java + jar + + + com.baeldung + parent-java + 0.0.1-SNAPSHOT + ../parent-java + + + + \ No newline at end of file diff --git a/core-java-lambdas/src/main/java/com/baeldung/lambdas/LambdaVariables.java b/core-java-lambdas/src/main/java/com/baeldung/lambdas/LambdaVariables.java new file mode 100644 index 0000000000..5c1201150f --- /dev/null +++ b/core-java-lambdas/src/main/java/com/baeldung/lambdas/LambdaVariables.java @@ -0,0 +1,88 @@ +package com.baeldung.lambdas; + +import java.util.Random; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.function.Supplier; +import java.util.stream.IntStream; + +/** + * Class with examples about working with capturing lambdas. + */ +public class LambdaVariables { + + private volatile boolean run = true; + private int start = 0; + + private ExecutorService executor = Executors.newFixedThreadPool(3); + + public static void main(String[] args) { + new LambdaVariables().localVariableMultithreading(); + } + + Supplier incrementer(int start) { + return () -> start; // can't modify start parameter inside the lambda + } + + Supplier incrementer() { + return () -> start++; + } + + public void localVariableMultithreading() { + boolean run = true; + executor.execute(() -> { + while (run) { + // do operation + } + }); + // commented because it doesn't compile, it's just an example of non-final local variables in lambdas + // run = false; + } + + public void instanceVariableMultithreading() { + executor.execute(() -> { + while (run) { + // do operation + } + }); + + run = false; + } + + /** + * WARNING: always avoid this workaround!! + */ + public void workaroundSingleThread() { + int[] holder = new int[] { 2 }; + IntStream sums = IntStream + .of(1, 2, 3) + .map(val -> val + holder[0]); + + holder[0] = 0; + + System.out.println(sums.sum()); + } + + /** + * WARNING: always avoid this workaround!! + */ + public void workaroundMultithreading() { + int[] holder = new int[] { 2 }; + Runnable runnable = () -> System.out.println(IntStream + .of(1, 2, 3) + .map(val -> val + holder[0]) + .sum()); + + new Thread(runnable).start(); + + // simulating some processing + try { + Thread.sleep(new Random().nextInt(3) * 1000L); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + + holder[0] = 0; + } + +} diff --git a/pom.xml b/pom.xml index bdd8403231..29384aa596 100644 --- a/pom.xml +++ b/pom.xml @@ -381,6 +381,7 @@ core-java-8 core-java-8-2 + core-java-lambdas core-java-arrays From 03a369d153874f5f89ef613691e500e8c83d4ad3 Mon Sep 17 00:00:00 2001 From: mprevisic Date: Sat, 13 Apr 2019 10:36:17 +0200 Subject: [PATCH 189/531] BAEL-1970 fixed logback base.xml path --- spring-boot-testing/src/test/resources/logback-multiprofile.xml | 2 +- spring-boot-testing/src/test/resources/logback-test.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot-testing/src/test/resources/logback-multiprofile.xml b/spring-boot-testing/src/test/resources/logback-multiprofile.xml index 09ca6e4cac..be790234f2 100644 --- a/spring-boot-testing/src/test/resources/logback-multiprofile.xml +++ b/spring-boot-testing/src/test/resources/logback-multiprofile.xml @@ -1,5 +1,5 @@ - + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n diff --git a/spring-boot-testing/src/test/resources/logback-test.xml b/spring-boot-testing/src/test/resources/logback-test.xml index 312af7c2bf..0528aa88f3 100644 --- a/spring-boot-testing/src/test/resources/logback-test.xml +++ b/spring-boot-testing/src/test/resources/logback-test.xml @@ -1,5 +1,5 @@ - + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n From beccf32be8bb458777f8c54b8e3aa4ad999e3301 Mon Sep 17 00:00:00 2001 From: Vivek Date: Sat, 13 Apr 2019 14:18:55 +0530 Subject: [PATCH 190/531] BAEL-2857 Defining a JPA Entity --- .../java/com/baeldung/jpa/entity/Student.java | 75 +++++++++++++++++ .../main/java/com/baeldung/util/Gender.java | 6 ++ .../main/resources/META-INF/persistence.xml | 20 +++++ .../entity/StudentEntityIntegrationTest.java | 83 +++++++++++++++++++ 4 files changed, 184 insertions(+) create mode 100644 persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/entity/Student.java create mode 100644 persistence-modules/java-jpa/src/main/java/com/baeldung/util/Gender.java create mode 100644 persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/entity/StudentEntityIntegrationTest.java diff --git a/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/entity/Student.java b/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/entity/Student.java new file mode 100644 index 0000000000..6eced20779 --- /dev/null +++ b/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/entity/Student.java @@ -0,0 +1,75 @@ +package com.baeldung.jpa.entity; + +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.Transient; + +import com.baeldung.util.Gender; + +@Entity +@Table(name="STUD_NAME") +public class Student { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + @Column(name = "STUD_NAME", length = 50, nullable = false, unique = false) + private String name; + @Transient + private Integer age; + @Temporal(TemporalType.DATE) + private Date birthDate; + @Enumerated(EnumType.STRING) + private Gender gender; + + 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 Integer getAge() { + return age; + } + + public void setAge(Integer age) { + this.age = age; + } + + public Date getBirthDate() { + return birthDate; + } + + public void setBirthDate(Date birthDate) { + this.birthDate = birthDate; + } + + public Gender getGender() { + return gender; + } + + public void setGender(Gender gender) { + this.gender = gender; + } + +} diff --git a/persistence-modules/java-jpa/src/main/java/com/baeldung/util/Gender.java b/persistence-modules/java-jpa/src/main/java/com/baeldung/util/Gender.java new file mode 100644 index 0000000000..13f08d995c --- /dev/null +++ b/persistence-modules/java-jpa/src/main/java/com/baeldung/util/Gender.java @@ -0,0 +1,6 @@ +package com.baeldung.util; + +public enum Gender { + MALE, + FEMALE +} diff --git a/persistence-modules/java-jpa/src/main/resources/META-INF/persistence.xml b/persistence-modules/java-jpa/src/main/resources/META-INF/persistence.xml index 5422afa4a3..2105a80d7d 100644 --- a/persistence-modules/java-jpa/src/main/resources/META-INF/persistence.xml +++ b/persistence-modules/java-jpa/src/main/resources/META-INF/persistence.xml @@ -129,5 +129,25 @@ + + + org.hibernate.jpa.HibernatePersistenceProvider + com.baeldung.jpa.entity.Student + true + + + + + + + + + + + \ No newline at end of file diff --git a/persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/entity/StudentEntityIntegrationTest.java b/persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/entity/StudentEntityIntegrationTest.java new file mode 100644 index 0000000000..2dc5d7c5f2 --- /dev/null +++ b/persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/entity/StudentEntityIntegrationTest.java @@ -0,0 +1,83 @@ +package com.baeldung.jpa.entity; + +import static org.junit.Assert.assertEquals; + +import java.util.Date; +import java.util.List; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Persistence; +import javax.persistence.TypedQuery; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import com.baeldung.util.Gender; + +public class StudentEntityIntegrationTest { + + private EntityManagerFactory emf; + private EntityManager em; + + @Before + public void setup() { + emf = Persistence.createEntityManagerFactory("jpa-entity-definition"); + em = emf.createEntityManager(); + } + + @Test + public void persistStudentThenRetrieveTheDetails() { + Student student = createStudentWithRelevantDetails(); + persist(student); + clearThePersistenceContext(); + List students = getStudentsFromTable(); + checkAssertionsWith(students); + } + + @After + public void destroy() { + if (em != null) { + em.close(); + } + if (emf != null) { + emf.close(); + } + } + + private void clearThePersistenceContext() { + em.clear(); + } + + private void checkAssertionsWith(List students) { + assertEquals(1, students.size()); + Student john = students.get(0); + assertEquals(1L, john.getId().longValue()); + assertEquals(null, john.getAge()); + assertEquals("John", john.getName()); + } + + private List getStudentsFromTable() { + String selectQuery = "SELECT student FROM Student student"; + TypedQuery selectFromStudentTypedQuery = em.createQuery(selectQuery, Student.class); + List students = selectFromStudentTypedQuery.getResultList(); + return students; + } + + private void persist(Student student) { + em.getTransaction().begin(); + em.persist(student); + em.getTransaction().commit(); + } + + private Student createStudentWithRelevantDetails() { + Student student = new Student(); + student.setAge(20); // the 'age' field has been annotated with @Transient + student.setName("John"); + student.setBirthDate(new Date()); + student.setGender(Gender.MALE); + return student; + } + +} From 8271d0ab5a8f7ef6d7906fb4219cf18103a9d76b Mon Sep 17 00:00:00 2001 From: Vivek Date: Sat, 13 Apr 2019 14:37:15 +0530 Subject: [PATCH 191/531] BAEL-2857 Defining a JPA Entity --- .../src/main/java/com/baeldung/jpa/entity/Student.java | 2 +- .../jpa/entity/StudentEntityIntegrationTest.java | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/entity/Student.java b/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/entity/Student.java index 6eced20779..17007fa126 100644 --- a/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/entity/Student.java +++ b/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/entity/Student.java @@ -17,7 +17,7 @@ import javax.persistence.Transient; import com.baeldung.util.Gender; @Entity -@Table(name="STUD_NAME") +@Table(name="STUD") public class Student { @Id diff --git a/persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/entity/StudentEntityIntegrationTest.java b/persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/entity/StudentEntityIntegrationTest.java index 2dc5d7c5f2..fdaaba5439 100644 --- a/persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/entity/StudentEntityIntegrationTest.java +++ b/persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/entity/StudentEntityIntegrationTest.java @@ -2,6 +2,8 @@ package com.baeldung.jpa.entity; import static org.junit.Assert.assertEquals; +import java.time.LocalDate; +import java.time.ZoneId; import java.util.Date; import java.util.List; @@ -75,9 +77,15 @@ public class StudentEntityIntegrationTest { Student student = new Student(); student.setAge(20); // the 'age' field has been annotated with @Transient student.setName("John"); - student.setBirthDate(new Date()); + Date date = getDate(); + student.setBirthDate(date); student.setGender(Gender.MALE); return student; } + private Date getDate() { + LocalDate localDate = LocalDate.of(2008, 7, 20); + return Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); + } + } From fa911245631aa2ee42dbefb07d1c869326f5ae3d Mon Sep 17 00:00:00 2001 From: KevinGilmore Date: Sat, 13 Apr 2019 09:46:01 -0500 Subject: [PATCH 192/531] BAEL-2489: update README (#6716) * BAEL-2246: add link back to article * BAEL-2174: rename core-java-net module to core-java-networking * BAEL-2174: add link back to article * BAEL-2363 BAEL-2337 BAEL-1996 BAEL-2277 add links back to articles * BAEL-2367: add link back to article * BAEL-2335: add link back to article * BAEL-2413: add link back to article * Update README.MD * BAEL-2577: add link back to article * BAEL-2490: add link back to article * BAEL-2471: add link back to article * BAEL-2583: add link back to article * BAEL-2738: add link back to article * BAEL-2711: Add spring-boot-angular module to root pom * BAEL-2544 BAEL-2711 BAEL-2575 BAEL-2657 Add links back to articles * BAEL-2736: Add link back to article * BAEL-2789: Add link back to article * BAEL-2489: add link back to article --- patterns/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/patterns/README.md b/patterns/README.md index b3ece5e52b..f627251aa4 100644 --- a/patterns/README.md +++ b/patterns/README.md @@ -3,3 +3,4 @@ - [Introduction to Intercepting Filter Pattern in Java](http://www.baeldung.com/intercepting-filter-pattern-in-java) - [Introduction to the Null Object Pattern](https://www.baeldung.com/java-null-object-pattern) - [The Dependency Inversion Principle in Java](https://www.baeldung.com/java-dependency-inversion-principle) +- [Avoid Check for Null Statement in Java](https://www.baeldung.com/java-avoid-null-check) From 6b0a96291ed20eff52ceecb9faed81ae9a20bacf Mon Sep 17 00:00:00 2001 From: amit2103 Date: Sat, 13 Apr 2019 23:16:33 +0530 Subject: [PATCH 193/531] [BAEL-14088] - Moved code for RequestBody and ResponseBody annotations article --- .../baeldung}/config/RestClientConfig.java | 4 ++-- ...RestTemplateHeaderModifierInterceptor.java | 2 +- .../com/baeldung/services/ExampleService.java | 0 .../java/com/baeldung/transfer/LoginForm.java | 0 .../baeldung/transfer/ResponseTransfer.java | 0 .../controller}/ExamplePostController.java | 2 +- ...ePostControllerRequestIntegrationTest.java | 18 +++++++++------- ...PostControllerResponseIntegrationTest.java | 21 ++++++++++--------- .../resttemplate/RestTemplateLiveTest.java | 2 +- 9 files changed, 26 insertions(+), 23 deletions(-) rename {spring-rest/src/main/java/com/baeldung/sampleapp => spring-boot-rest/src/main/java/com/baeldung}/config/RestClientConfig.java (85%) rename {spring-rest/src/main/java/com/baeldung/sampleapp => spring-boot-rest/src/main/java/com/baeldung}/interceptors/RestTemplateHeaderModifierInterceptor.java (91%) rename {spring-rest => spring-boot-rest}/src/main/java/com/baeldung/services/ExampleService.java (100%) rename {spring-rest => spring-boot-rest}/src/main/java/com/baeldung/transfer/LoginForm.java (100%) rename {spring-rest => spring-boot-rest}/src/main/java/com/baeldung/transfer/ResponseTransfer.java (100%) rename {spring-rest/src/main/java/com/baeldung/controllers => spring-boot-rest/src/main/java/com/baeldung/web/controller}/ExamplePostController.java (97%) rename {spring-rest => spring-boot-rest}/src/test/java/com/baeldung/controllers/ExamplePostControllerRequestIntegrationTest.java (92%) rename {spring-rest => spring-boot-rest}/src/test/java/com/baeldung/controllers/ExamplePostControllerResponseIntegrationTest.java (92%) rename {spring-rest => spring-boot-rest}/src/test/java/com/baeldung/resttemplate/RestTemplateLiveTest.java (96%) diff --git a/spring-rest/src/main/java/com/baeldung/sampleapp/config/RestClientConfig.java b/spring-boot-rest/src/main/java/com/baeldung/config/RestClientConfig.java similarity index 85% rename from spring-rest/src/main/java/com/baeldung/sampleapp/config/RestClientConfig.java rename to spring-boot-rest/src/main/java/com/baeldung/config/RestClientConfig.java index 8abc368bdb..9d21e0f785 100644 --- a/spring-rest/src/main/java/com/baeldung/sampleapp/config/RestClientConfig.java +++ b/spring-boot-rest/src/main/java/com/baeldung/config/RestClientConfig.java @@ -1,4 +1,4 @@ -package com.baeldung.sampleapp.config; +package com.baeldung.config; import java.util.ArrayList; import java.util.List; @@ -9,7 +9,7 @@ import org.springframework.http.client.ClientHttpRequestInterceptor; import org.springframework.util.CollectionUtils; import org.springframework.web.client.RestTemplate; -import com.baeldung.sampleapp.interceptors.RestTemplateHeaderModifierInterceptor; +import com.baeldung.interceptors.RestTemplateHeaderModifierInterceptor; @Configuration public class RestClientConfig { diff --git a/spring-rest/src/main/java/com/baeldung/sampleapp/interceptors/RestTemplateHeaderModifierInterceptor.java b/spring-boot-rest/src/main/java/com/baeldung/interceptors/RestTemplateHeaderModifierInterceptor.java similarity index 91% rename from spring-rest/src/main/java/com/baeldung/sampleapp/interceptors/RestTemplateHeaderModifierInterceptor.java rename to spring-boot-rest/src/main/java/com/baeldung/interceptors/RestTemplateHeaderModifierInterceptor.java index 519e5ebf0d..9402980926 100644 --- a/spring-rest/src/main/java/com/baeldung/sampleapp/interceptors/RestTemplateHeaderModifierInterceptor.java +++ b/spring-boot-rest/src/main/java/com/baeldung/interceptors/RestTemplateHeaderModifierInterceptor.java @@ -1,4 +1,4 @@ -package com.baeldung.sampleapp.interceptors; +package com.baeldung.interceptors; import java.io.IOException; diff --git a/spring-rest/src/main/java/com/baeldung/services/ExampleService.java b/spring-boot-rest/src/main/java/com/baeldung/services/ExampleService.java similarity index 100% rename from spring-rest/src/main/java/com/baeldung/services/ExampleService.java rename to spring-boot-rest/src/main/java/com/baeldung/services/ExampleService.java diff --git a/spring-rest/src/main/java/com/baeldung/transfer/LoginForm.java b/spring-boot-rest/src/main/java/com/baeldung/transfer/LoginForm.java similarity index 100% rename from spring-rest/src/main/java/com/baeldung/transfer/LoginForm.java rename to spring-boot-rest/src/main/java/com/baeldung/transfer/LoginForm.java diff --git a/spring-rest/src/main/java/com/baeldung/transfer/ResponseTransfer.java b/spring-boot-rest/src/main/java/com/baeldung/transfer/ResponseTransfer.java similarity index 100% rename from spring-rest/src/main/java/com/baeldung/transfer/ResponseTransfer.java rename to spring-boot-rest/src/main/java/com/baeldung/transfer/ResponseTransfer.java diff --git a/spring-rest/src/main/java/com/baeldung/controllers/ExamplePostController.java b/spring-boot-rest/src/main/java/com/baeldung/web/controller/ExamplePostController.java similarity index 97% rename from spring-rest/src/main/java/com/baeldung/controllers/ExamplePostController.java rename to spring-boot-rest/src/main/java/com/baeldung/web/controller/ExamplePostController.java index 93f96756b4..1519d95d4d 100644 --- a/spring-rest/src/main/java/com/baeldung/controllers/ExamplePostController.java +++ b/spring-boot-rest/src/main/java/com/baeldung/web/controller/ExamplePostController.java @@ -1,4 +1,4 @@ -package com.baeldung.controllers; +package com.baeldung.web.controller; import com.baeldung.services.ExampleService; import com.baeldung.transfer.ResponseTransfer; diff --git a/spring-rest/src/test/java/com/baeldung/controllers/ExamplePostControllerRequestIntegrationTest.java b/spring-boot-rest/src/test/java/com/baeldung/controllers/ExamplePostControllerRequestIntegrationTest.java similarity index 92% rename from spring-rest/src/test/java/com/baeldung/controllers/ExamplePostControllerRequestIntegrationTest.java rename to spring-boot-rest/src/test/java/com/baeldung/controllers/ExamplePostControllerRequestIntegrationTest.java index 94b8bf40e7..fc533072c8 100644 --- a/spring-rest/src/test/java/com/baeldung/controllers/ExamplePostControllerRequestIntegrationTest.java +++ b/spring-boot-rest/src/test/java/com/baeldung/controllers/ExamplePostControllerRequestIntegrationTest.java @@ -1,8 +1,10 @@ package com.baeldung.controllers; -import com.baeldung.sampleapp.config.MainApplication; -import com.baeldung.services.ExampleService; -import com.baeldung.transfer.LoginForm; +import static org.mockito.Mockito.when; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -14,13 +16,13 @@ import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; -import static org.mockito.Mockito.when; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import com.baeldung.SpringBootRestApplication; +import com.baeldung.services.ExampleService; +import com.baeldung.transfer.LoginForm; +import com.baeldung.web.controller.ExamplePostController; @RunWith(SpringRunner.class) -@SpringBootTest(classes = MainApplication.class) +@SpringBootTest(classes = SpringBootRestApplication.class) public class ExamplePostControllerRequestIntegrationTest { MockMvc mockMvc; diff --git a/spring-rest/src/test/java/com/baeldung/controllers/ExamplePostControllerResponseIntegrationTest.java b/spring-boot-rest/src/test/java/com/baeldung/controllers/ExamplePostControllerResponseIntegrationTest.java similarity index 92% rename from spring-rest/src/test/java/com/baeldung/controllers/ExamplePostControllerResponseIntegrationTest.java rename to spring-boot-rest/src/test/java/com/baeldung/controllers/ExamplePostControllerResponseIntegrationTest.java index 5743ad450b..cbe21b1d90 100644 --- a/spring-rest/src/test/java/com/baeldung/controllers/ExamplePostControllerResponseIntegrationTest.java +++ b/spring-boot-rest/src/test/java/com/baeldung/controllers/ExamplePostControllerResponseIntegrationTest.java @@ -1,8 +1,11 @@ package com.baeldung.controllers; -import com.baeldung.sampleapp.config.MainApplication; -import com.baeldung.services.ExampleService; -import com.baeldung.transfer.LoginForm; +import static org.mockito.Mockito.when; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -11,18 +14,16 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; 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 static org.mockito.Mockito.when; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import com.baeldung.SpringBootRestApplication; +import com.baeldung.services.ExampleService; +import com.baeldung.transfer.LoginForm; +import com.baeldung.web.controller.ExamplePostController; @RunWith(SpringRunner.class) -@SpringBootTest(classes = MainApplication.class) +@SpringBootTest(classes = SpringBootRestApplication.class) public class ExamplePostControllerResponseIntegrationTest { MockMvc mockMvc; diff --git a/spring-rest/src/test/java/com/baeldung/resttemplate/RestTemplateLiveTest.java b/spring-boot-rest/src/test/java/com/baeldung/resttemplate/RestTemplateLiveTest.java similarity index 96% rename from spring-rest/src/test/java/com/baeldung/resttemplate/RestTemplateLiveTest.java rename to spring-boot-rest/src/test/java/com/baeldung/resttemplate/RestTemplateLiveTest.java index 8db31fd0a7..d0ae521837 100644 --- a/spring-rest/src/test/java/com/baeldung/resttemplate/RestTemplateLiveTest.java +++ b/spring-boot-rest/src/test/java/com/baeldung/resttemplate/RestTemplateLiveTest.java @@ -16,7 +16,7 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.web.client.RestTemplate; -import com.baeldung.sampleapp.config.RestClientConfig; +import com.baeldung.config.RestClientConfig; import com.baeldung.transfer.LoginForm; @RunWith(SpringJUnit4ClassRunner.class) From 789c6695df43af2f9dd76ec3bc9840aa87dc3c85 Mon Sep 17 00:00:00 2001 From: amit2103 Date: Sun, 14 Apr 2019 00:49:30 +0530 Subject: [PATCH 194/531] [BAEL-14089] - Moved code for Entity to DTO article --- spring-boot-rest/pom.xml | 6 ++++++ .../main/java/com/baeldung/SpringBootRestApplication.java | 2 +- .../java/com/baeldung/modelmapper/PostApplication.java | 0 .../modelmapper/controller/PostRestController.java | 0 .../main/java/com/baeldung/modelmapper/dto/PostDto.java | 0 .../main/java/com/baeldung/modelmapper/dto/UserDto.java | 0 .../src/main/java/com/baeldung/modelmapper/model/Post.java | 0 .../java/com/baeldung/modelmapper/model/Preference.java | 0 .../src/main/java/com/baeldung/modelmapper/model/User.java | 0 .../baeldung/modelmapper/repository/PostRepository.java | 0 .../com/baeldung/modelmapper/service/IPostService.java | 0 .../com/baeldung/modelmapper/service/IUserService.java | 0 .../java/com/baeldung/modelmapper/service/PostService.java | 0 .../java/com/baeldung/modelmapper/service/UserService.java | 0 .../java/com/baeldung/SpringContextIntegrationTest.java | 2 +- .../java/com/baeldung/modelmapper/PostDtoUnitTest.java | 0 spring-boot/pom.xml | 7 ------- 17 files changed, 8 insertions(+), 9 deletions(-) rename {spring-boot => spring-boot-rest}/src/main/java/com/baeldung/modelmapper/PostApplication.java (100%) rename {spring-boot => spring-boot-rest}/src/main/java/com/baeldung/modelmapper/controller/PostRestController.java (100%) rename {spring-boot => spring-boot-rest}/src/main/java/com/baeldung/modelmapper/dto/PostDto.java (100%) rename {spring-boot => spring-boot-rest}/src/main/java/com/baeldung/modelmapper/dto/UserDto.java (100%) rename {spring-boot => spring-boot-rest}/src/main/java/com/baeldung/modelmapper/model/Post.java (100%) rename {spring-boot => spring-boot-rest}/src/main/java/com/baeldung/modelmapper/model/Preference.java (100%) rename {spring-boot => spring-boot-rest}/src/main/java/com/baeldung/modelmapper/model/User.java (100%) rename {spring-boot => spring-boot-rest}/src/main/java/com/baeldung/modelmapper/repository/PostRepository.java (100%) rename {spring-boot => spring-boot-rest}/src/main/java/com/baeldung/modelmapper/service/IPostService.java (100%) rename {spring-boot => spring-boot-rest}/src/main/java/com/baeldung/modelmapper/service/IUserService.java (100%) rename {spring-boot => spring-boot-rest}/src/main/java/com/baeldung/modelmapper/service/PostService.java (100%) rename {spring-boot => spring-boot-rest}/src/main/java/com/baeldung/modelmapper/service/UserService.java (100%) rename {spring-boot => spring-boot-rest}/src/test/java/com/baeldung/modelmapper/PostDtoUnitTest.java (100%) diff --git a/spring-boot-rest/pom.xml b/spring-boot-rest/pom.xml index decaccd148..a7ba67d92a 100644 --- a/spring-boot-rest/pom.xml +++ b/spring-boot-rest/pom.xml @@ -63,6 +63,11 @@ htmlunit test + + org.modelmapper + modelmapper + ${modelmapper.version} + @@ -78,5 +83,6 @@ com.baeldung.SpringBootRestApplication 27.0.1-jre 1.4.11.1 + 2.3.2 diff --git a/spring-boot-rest/src/main/java/com/baeldung/SpringBootRestApplication.java b/spring-boot-rest/src/main/java/com/baeldung/SpringBootRestApplication.java index 62aae7619d..d0976d9ddd 100644 --- a/spring-boot-rest/src/main/java/com/baeldung/SpringBootRestApplication.java +++ b/spring-boot-rest/src/main/java/com/baeldung/SpringBootRestApplication.java @@ -3,7 +3,7 @@ package com.baeldung; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -@SpringBootApplication +@SpringBootApplication(scanBasePackages = {"com.baeldung.persistence", "com.baeldung.spring", "com.baeldung.web" }) public class SpringBootRestApplication { public static void main(String[] args) { diff --git a/spring-boot/src/main/java/com/baeldung/modelmapper/PostApplication.java b/spring-boot-rest/src/main/java/com/baeldung/modelmapper/PostApplication.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/modelmapper/PostApplication.java rename to spring-boot-rest/src/main/java/com/baeldung/modelmapper/PostApplication.java diff --git a/spring-boot/src/main/java/com/baeldung/modelmapper/controller/PostRestController.java b/spring-boot-rest/src/main/java/com/baeldung/modelmapper/controller/PostRestController.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/modelmapper/controller/PostRestController.java rename to spring-boot-rest/src/main/java/com/baeldung/modelmapper/controller/PostRestController.java diff --git a/spring-boot/src/main/java/com/baeldung/modelmapper/dto/PostDto.java b/spring-boot-rest/src/main/java/com/baeldung/modelmapper/dto/PostDto.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/modelmapper/dto/PostDto.java rename to spring-boot-rest/src/main/java/com/baeldung/modelmapper/dto/PostDto.java diff --git a/spring-boot/src/main/java/com/baeldung/modelmapper/dto/UserDto.java b/spring-boot-rest/src/main/java/com/baeldung/modelmapper/dto/UserDto.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/modelmapper/dto/UserDto.java rename to spring-boot-rest/src/main/java/com/baeldung/modelmapper/dto/UserDto.java diff --git a/spring-boot/src/main/java/com/baeldung/modelmapper/model/Post.java b/spring-boot-rest/src/main/java/com/baeldung/modelmapper/model/Post.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/modelmapper/model/Post.java rename to spring-boot-rest/src/main/java/com/baeldung/modelmapper/model/Post.java diff --git a/spring-boot/src/main/java/com/baeldung/modelmapper/model/Preference.java b/spring-boot-rest/src/main/java/com/baeldung/modelmapper/model/Preference.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/modelmapper/model/Preference.java rename to spring-boot-rest/src/main/java/com/baeldung/modelmapper/model/Preference.java diff --git a/spring-boot/src/main/java/com/baeldung/modelmapper/model/User.java b/spring-boot-rest/src/main/java/com/baeldung/modelmapper/model/User.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/modelmapper/model/User.java rename to spring-boot-rest/src/main/java/com/baeldung/modelmapper/model/User.java diff --git a/spring-boot/src/main/java/com/baeldung/modelmapper/repository/PostRepository.java b/spring-boot-rest/src/main/java/com/baeldung/modelmapper/repository/PostRepository.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/modelmapper/repository/PostRepository.java rename to spring-boot-rest/src/main/java/com/baeldung/modelmapper/repository/PostRepository.java diff --git a/spring-boot/src/main/java/com/baeldung/modelmapper/service/IPostService.java b/spring-boot-rest/src/main/java/com/baeldung/modelmapper/service/IPostService.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/modelmapper/service/IPostService.java rename to spring-boot-rest/src/main/java/com/baeldung/modelmapper/service/IPostService.java diff --git a/spring-boot/src/main/java/com/baeldung/modelmapper/service/IUserService.java b/spring-boot-rest/src/main/java/com/baeldung/modelmapper/service/IUserService.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/modelmapper/service/IUserService.java rename to spring-boot-rest/src/main/java/com/baeldung/modelmapper/service/IUserService.java diff --git a/spring-boot/src/main/java/com/baeldung/modelmapper/service/PostService.java b/spring-boot-rest/src/main/java/com/baeldung/modelmapper/service/PostService.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/modelmapper/service/PostService.java rename to spring-boot-rest/src/main/java/com/baeldung/modelmapper/service/PostService.java diff --git a/spring-boot/src/main/java/com/baeldung/modelmapper/service/UserService.java b/spring-boot-rest/src/main/java/com/baeldung/modelmapper/service/UserService.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/modelmapper/service/UserService.java rename to spring-boot-rest/src/main/java/com/baeldung/modelmapper/service/UserService.java diff --git a/spring-boot-rest/src/test/java/com/baeldung/SpringContextIntegrationTest.java b/spring-boot-rest/src/test/java/com/baeldung/SpringContextIntegrationTest.java index 25fbc4cc02..3db1ecb462 100644 --- a/spring-boot-rest/src/test/java/com/baeldung/SpringContextIntegrationTest.java +++ b/spring-boot-rest/src/test/java/com/baeldung/SpringContextIntegrationTest.java @@ -6,7 +6,7 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) -@SpringBootTest +@SpringBootTest(classes = {SpringBootRestApplication.class}) public class SpringContextIntegrationTest { @Test diff --git a/spring-boot/src/test/java/com/baeldung/modelmapper/PostDtoUnitTest.java b/spring-boot-rest/src/test/java/com/baeldung/modelmapper/PostDtoUnitTest.java similarity index 100% rename from spring-boot/src/test/java/com/baeldung/modelmapper/PostDtoUnitTest.java rename to spring-boot-rest/src/test/java/com/baeldung/modelmapper/PostDtoUnitTest.java diff --git a/spring-boot/pom.xml b/spring-boot/pom.xml index ed2d8259df..401e0289e8 100644 --- a/spring-boot/pom.xml +++ b/spring-boot/pom.xml @@ -153,12 +153,6 @@ javax.validation validation-api - - - org.modelmapper - modelmapper - ${modelmapper.version} - @@ -256,7 +250,6 @@ 5.2.4 18.0 2.2.4 - 2.3.2 From bcbe5348e428970800323b145f4b35de5127f322 Mon Sep 17 00:00:00 2001 From: amit2103 Date: Sun, 14 Apr 2019 11:32:40 +0530 Subject: [PATCH 195/531] [BAEL-14090] - Moved code for Testing REST API article --- .../java/com/baeldung/rest/GitHubUser.java | 21 +++++++++++++++++++ .../baeldung/rest/GithubBasicLiveTest.java | 2 +- .../java/com/baeldung/rest/RetrieveUtil.java | 21 +++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 spring-boot-rest/src/test/java/com/baeldung/rest/GitHubUser.java rename {testing-modules/rest-testing/src/test/java/org => spring-boot-rest/src/test/java/com}/baeldung/rest/GithubBasicLiveTest.java (98%) create mode 100644 spring-boot-rest/src/test/java/com/baeldung/rest/RetrieveUtil.java diff --git a/spring-boot-rest/src/test/java/com/baeldung/rest/GitHubUser.java b/spring-boot-rest/src/test/java/com/baeldung/rest/GitHubUser.java new file mode 100644 index 0000000000..da5085ab12 --- /dev/null +++ b/spring-boot-rest/src/test/java/com/baeldung/rest/GitHubUser.java @@ -0,0 +1,21 @@ +package com.baeldung.rest; + +public class GitHubUser { + + private String login; + + public GitHubUser() { + super(); + } + + // API + + public String getLogin() { + return login; + } + + public void setLogin(final String login) { + this.login = login; + } + +} diff --git a/testing-modules/rest-testing/src/test/java/org/baeldung/rest/GithubBasicLiveTest.java b/spring-boot-rest/src/test/java/com/baeldung/rest/GithubBasicLiveTest.java similarity index 98% rename from testing-modules/rest-testing/src/test/java/org/baeldung/rest/GithubBasicLiveTest.java rename to spring-boot-rest/src/test/java/com/baeldung/rest/GithubBasicLiveTest.java index acac82c8f4..3082b34421 100644 --- a/testing-modules/rest-testing/src/test/java/org/baeldung/rest/GithubBasicLiveTest.java +++ b/spring-boot-rest/src/test/java/com/baeldung/rest/GithubBasicLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.rest; +package com.baeldung.rest; import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; import static org.hamcrest.Matchers.equalTo; diff --git a/spring-boot-rest/src/test/java/com/baeldung/rest/RetrieveUtil.java b/spring-boot-rest/src/test/java/com/baeldung/rest/RetrieveUtil.java new file mode 100644 index 0000000000..0ec36bc3ae --- /dev/null +++ b/spring-boot-rest/src/test/java/com/baeldung/rest/RetrieveUtil.java @@ -0,0 +1,21 @@ +package com.baeldung.rest; + +import java.io.IOException; + +import org.apache.http.HttpResponse; +import org.apache.http.util.EntityUtils; + +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class RetrieveUtil { + + // API + + public static T retrieveResourceFromResponse(final HttpResponse response, final Class clazz) throws IOException { + final String jsonFromResponse = EntityUtils.toString(response.getEntity()); + final ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + return mapper.readValue(jsonFromResponse, clazz); + } + +} From ce099900562daf46408fc8ed9814c1fbe40f8d61 Mon Sep 17 00:00:00 2001 From: Denis Date: Sun, 14 Apr 2019 08:24:03 +0200 Subject: [PATCH 196/531] BAEL-1931 rename SampleService to SampleClient (#6682) * BAEL-1931 rename SampleService to SampleClient * remove not null assertion * remove fixed method order * disable usage of local kerberos ticket cache --- .../kerberos/client/KerberosClientApp.java | 2 ++ .../{SampleService.java => SampleClient.java} | 4 ++-- ...alTest.java => SampleClientManualTest.java} | 18 +++++++----------- 3 files changed, 11 insertions(+), 13 deletions(-) rename spring-security-sso/spring-security-sso-kerberos/src/main/java/kerberos/client/{SampleService.java => SampleClient.java} (87%) rename spring-security-sso/spring-security-sso-kerberos/src/test/java/kerberos/client/{SampleServiceManualTest.java => SampleClientManualTest.java} (59%) diff --git a/spring-security-sso/spring-security-sso-kerberos/src/main/java/kerberos/client/KerberosClientApp.java b/spring-security-sso/spring-security-sso-kerberos/src/main/java/kerberos/client/KerberosClientApp.java index a353961854..9fb86e7658 100644 --- a/spring-security-sso/spring-security-sso-kerberos/src/main/java/kerberos/client/KerberosClientApp.java +++ b/spring-security-sso/spring-security-sso-kerberos/src/main/java/kerberos/client/KerberosClientApp.java @@ -12,6 +12,8 @@ class KerberosClientApp { System.setProperty("java.security.krb5.conf", Paths.get(".\\krb-test-workdir\\krb5.conf").normalize().toAbsolutePath().toString()); System.setProperty("sun.security.krb5.debug", "true"); + // disable usage of local kerberos ticket cache + System.setProperty("http.use.global.creds", "false"); } public static void main(String[] args) { diff --git a/spring-security-sso/spring-security-sso-kerberos/src/main/java/kerberos/client/SampleService.java b/spring-security-sso/spring-security-sso-kerberos/src/main/java/kerberos/client/SampleClient.java similarity index 87% rename from spring-security-sso/spring-security-sso-kerberos/src/main/java/kerberos/client/SampleService.java rename to spring-security-sso/spring-security-sso-kerberos/src/main/java/kerberos/client/SampleClient.java index 4145cf0c1a..745193e3b0 100644 --- a/spring-security-sso/spring-security-sso-kerberos/src/main/java/kerberos/client/SampleService.java +++ b/spring-security-sso/spring-security-sso-kerberos/src/main/java/kerberos/client/SampleClient.java @@ -5,14 +5,14 @@ import org.springframework.stereotype.Service; import org.springframework.web.client.RestTemplate; @Service -class SampleService { +class SampleClient { @Value("${app.access-url}") private String endpoint; private RestTemplate restTemplate; - public SampleService(RestTemplate restTemplate) { + public SampleClient(RestTemplate restTemplate) { this.restTemplate = restTemplate; } diff --git a/spring-security-sso/spring-security-sso-kerberos/src/test/java/kerberos/client/SampleServiceManualTest.java b/spring-security-sso/spring-security-sso-kerberos/src/test/java/kerberos/client/SampleClientManualTest.java similarity index 59% rename from spring-security-sso/spring-security-sso-kerberos/src/test/java/kerberos/client/SampleServiceManualTest.java rename to spring-security-sso/spring-security-sso-kerberos/src/test/java/kerberos/client/SampleClientManualTest.java index d0d9f0ae4b..fdb1b12531 100644 --- a/spring-security-sso/spring-security-sso-kerberos/src/test/java/kerberos/client/SampleServiceManualTest.java +++ b/spring-security-sso/spring-security-sso-kerberos/src/test/java/kerberos/client/SampleClientManualTest.java @@ -1,6 +1,5 @@ package kerberos.client; -import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -10,7 +9,6 @@ import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestTemplate; import static org.junit.Assert.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; /** @@ -23,21 +21,19 @@ import static org.junit.jupiter.api.Assertions.assertThrows; */ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@FixMethodOrder -public class SampleServiceManualTest { +public class SampleClientManualTest { @Autowired - private SampleService sampleService; + private SampleClient sampleClient; @Test - public void a_givenKerberizedRestTemplate_whenServiceCall_thenSuccess() { - assertNotNull(sampleService); - assertEquals("data from kerberized server", sampleService.getData()); + public void givenKerberizedRestTemplate_whenServiceCall_thenSuccess() { + assertEquals("data from kerberized server", sampleClient.getData()); } @Test - public void b_givenRestTemplate_whenServiceCall_thenFail() { - sampleService.setRestTemplate(new RestTemplate()); - assertThrows(RestClientException.class, sampleService::getData); + public void givenRestTemplate_whenServiceCall_thenFail() { + sampleClient.setRestTemplate(new RestTemplate()); + assertThrows(RestClientException.class, sampleClient::getData); } } \ No newline at end of file From 431670601afc51c2ed84cc58def8dff95bf99651 Mon Sep 17 00:00:00 2001 From: Sushant Date: Sun, 14 Apr 2019 12:21:51 +0300 Subject: [PATCH 197/531] Created new module guava-collections-set --- guava-collections-set/.gitignore | 13 +++++++ guava-collections-set/pom.xml | 37 +++++++++++++++++++ .../baeldung/guava/GuavaMultiSetUnitTest.java | 2 +- 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 guava-collections-set/.gitignore create mode 100644 guava-collections-set/pom.xml rename {guava-collections => guava-collections-set}/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java (99%) diff --git a/guava-collections-set/.gitignore b/guava-collections-set/.gitignore new file mode 100644 index 0000000000..83c05e60c8 --- /dev/null +++ b/guava-collections-set/.gitignore @@ -0,0 +1,13 @@ +*.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/guava-collections-set/pom.xml b/guava-collections-set/pom.xml new file mode 100644 index 0000000000..46dcae492d --- /dev/null +++ b/guava-collections-set/pom.xml @@ -0,0 +1,37 @@ + + 4.0.0 + com.baeldung + guava-collections-set + 0.1.0-SNAPSHOT + guava-collections-set + + + com.baeldung + parent-java + 0.0.1-SNAPSHOT + ../parent-java + + + + + + org.assertj + assertj-core + ${assertj.version} + test + + + + + guava-collections-set + + + + + 27.1-jre + + 3.6.1 + + + diff --git a/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java b/guava-collections-set/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java similarity index 99% rename from guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java rename to guava-collections-set/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java index 47411031b9..e74db29881 100644 --- a/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java +++ b/guava-collections-set/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java @@ -89,4 +89,4 @@ public class GuavaMultiSetUnitTest { bookStore.put("Potter", -1); assertThat(bookStore.containsKey("Potter")).isTrue(); } -} +} \ No newline at end of file From 15cb0aebfcec2893324b79b41d2c8d6ff667a652 Mon Sep 17 00:00:00 2001 From: Ganesh Pagade Date: Sun, 14 Apr 2019 17:42:51 +0530 Subject: [PATCH 198/531] fix spring boot project --- vaadin/pom.xml | 22 +- .../com/baeldung/introduction/VaadinUI.java | 281 ------------------ 2 files changed, 3 insertions(+), 300 deletions(-) delete mode 100644 vaadin/src/main/java/com/baeldung/introduction/VaadinUI.java diff --git a/vaadin/pom.xml b/vaadin/pom.xml index d24b3dff1b..145a6af293 100644 --- a/vaadin/pom.xml +++ b/vaadin/pom.xml @@ -33,22 +33,6 @@ javax.servlet-api provided - - com.vaadin - vaadin-server - - - com.vaadin - vaadin-push - - - com.vaadin - vaadin-client-compiled - - - com.vaadin - vaadin-themes - org.springframework.boot @@ -183,9 +167,9 @@ 3.0.1 - 7.7.10 - 8.0.6 - 10.0.1 + 10.0.11 + 10.0.11 + 10.0.11 9.3.9.v20160517 UTF-8 1.8 diff --git a/vaadin/src/main/java/com/baeldung/introduction/VaadinUI.java b/vaadin/src/main/java/com/baeldung/introduction/VaadinUI.java deleted file mode 100644 index 1b3733ad74..0000000000 --- a/vaadin/src/main/java/com/baeldung/introduction/VaadinUI.java +++ /dev/null @@ -1,281 +0,0 @@ -package com.baeldung.introduction; - -import java.time.Instant; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - -import javax.servlet.annotation.WebServlet; - -import com.vaadin.annotations.Push; -import com.vaadin.annotations.Theme; -import com.vaadin.annotations.VaadinServletConfiguration; -import com.vaadin.data.Validator.InvalidValueException; -import com.vaadin.data.fieldgroup.BeanFieldGroup; -import com.vaadin.data.validator.StringLengthValidator; -import com.vaadin.server.ExternalResource; -import com.vaadin.server.FontAwesome; -import com.vaadin.server.VaadinRequest; -import com.vaadin.server.VaadinServlet; -import com.vaadin.ui.Button; -import com.vaadin.ui.CheckBox; -import com.vaadin.ui.ComboBox; -import com.vaadin.ui.DateField; -import com.vaadin.ui.FormLayout; -import com.vaadin.ui.Grid; -import com.vaadin.ui.GridLayout; -import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.InlineDateField; -import com.vaadin.ui.Label; -import com.vaadin.ui.Link; -import com.vaadin.ui.ListSelect; -import com.vaadin.ui.NativeButton; -import com.vaadin.ui.NativeSelect; -import com.vaadin.ui.Panel; -import com.vaadin.ui.PasswordField; -import com.vaadin.ui.RichTextArea; -import com.vaadin.ui.TextArea; -import com.vaadin.ui.TextField; -import com.vaadin.ui.TwinColSelect; -import com.vaadin.ui.UI; -import com.vaadin.ui.VerticalLayout; - -@SuppressWarnings("serial") -@Push -@Theme("mytheme") -public class VaadinUI extends UI { - - private Label currentTime; - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - protected void init(VaadinRequest vaadinRequest) { - final VerticalLayout verticalLayout = new VerticalLayout(); - verticalLayout.setSpacing(true); - verticalLayout.setMargin(true); - final GridLayout gridLayout = new GridLayout(3, 2); - gridLayout.setSpacing(true); - gridLayout.setMargin(true); - final HorizontalLayout horizontalLayout = new HorizontalLayout(); - horizontalLayout.setSpacing(true); - horizontalLayout.setMargin(true); - final FormLayout formLayout = new FormLayout(); - formLayout.setSpacing(true); - formLayout.setMargin(true); - final GridLayout buttonLayout = new GridLayout(3, 5); - buttonLayout.setMargin(true); - buttonLayout.setSpacing(true); - - final Label label = new Label(); - label.setId("Label"); - label.setValue("Label Value"); - label.setCaption("Label"); - gridLayout.addComponent(label); - - final Link link = new Link("Baeldung", new ExternalResource("http://www.baeldung.com/")); - link.setId("Link"); - link.setTargetName("_blank"); - gridLayout.addComponent(link); - - final TextField textField = new TextField(); - textField.setId("TextField"); - textField.setCaption("TextField:"); - textField.setValue("TextField Value"); - textField.setIcon(FontAwesome.USER); - gridLayout.addComponent(textField); - - final TextArea textArea = new TextArea(); - textArea.setCaption("TextArea"); - textArea.setId("TextArea"); - textArea.setValue("TextArea Value"); - gridLayout.addComponent(textArea); - - final DateField dateField = new DateField("DateField", new Date(0)); - dateField.setId("DateField"); - gridLayout.addComponent(dateField); - - final PasswordField passwordField = new PasswordField(); - passwordField.setId("PasswordField"); - passwordField.setCaption("PasswordField:"); - passwordField.setValue("password"); - gridLayout.addComponent(passwordField); - - final RichTextArea richTextArea = new RichTextArea(); - richTextArea.setCaption("Rich Text Area"); - richTextArea.setValue("

RichTextArea

"); - richTextArea.setSizeFull(); - - Panel richTextPanel = new Panel(); - richTextPanel.setContent(richTextArea); - - final InlineDateField inlineDateField = new InlineDateField(); - inlineDateField.setValue(new Date(0)); - inlineDateField.setCaption("Inline Date Field"); - horizontalLayout.addComponent(inlineDateField); - - Button normalButton = new Button("Normal Button"); - normalButton.setId("NormalButton"); - normalButton.addClickListener(e -> { - label.setValue("CLICK"); - }); - buttonLayout.addComponent(normalButton); - - Button tinyButton = new Button("Tiny Button"); - tinyButton.addStyleName("tiny"); - buttonLayout.addComponent(tinyButton); - - Button smallButton = new Button("Small Button"); - smallButton.addStyleName("small"); - buttonLayout.addComponent(smallButton); - - Button largeButton = new Button("Large Button"); - largeButton.addStyleName("large"); - buttonLayout.addComponent(largeButton); - - Button hugeButton = new Button("Huge Button"); - hugeButton.addStyleName("huge"); - buttonLayout.addComponent(hugeButton); - - Button disabledButton = new Button("Disabled Button"); - disabledButton.setDescription("This button cannot be clicked"); - disabledButton.setEnabled(false); - buttonLayout.addComponent(disabledButton); - - Button dangerButton = new Button("Danger Button"); - dangerButton.addStyleName("danger"); - buttonLayout.addComponent(dangerButton); - - Button friendlyButton = new Button("Friendly Button"); - friendlyButton.addStyleName("friendly"); - buttonLayout.addComponent(friendlyButton); - - Button primaryButton = new Button("Primary Button"); - primaryButton.addStyleName("primary"); - buttonLayout.addComponent(primaryButton); - - NativeButton nativeButton = new NativeButton("Native Button"); - buttonLayout.addComponent(nativeButton); - - Button iconButton = new Button("Icon Button"); - iconButton.setIcon(FontAwesome.ALIGN_LEFT); - buttonLayout.addComponent(iconButton); - - Button borderlessButton = new Button("BorderLess Button"); - borderlessButton.addStyleName("borderless"); - buttonLayout.addComponent(borderlessButton); - - Button linkButton = new Button("Link Button"); - linkButton.addStyleName("link"); - buttonLayout.addComponent(linkButton); - - Button quietButton = new Button("Quiet Button"); - quietButton.addStyleName("quiet"); - buttonLayout.addComponent(quietButton); - - horizontalLayout.addComponent(buttonLayout); - - final CheckBox checkbox = new CheckBox("CheckBox"); - checkbox.setValue(true); - checkbox.addValueChangeListener(e -> checkbox.setValue(!checkbox.getValue())); - formLayout.addComponent(checkbox); - - List numbers = new ArrayList(); - numbers.add("One"); - numbers.add("Ten"); - numbers.add("Eleven"); - ComboBox comboBox = new ComboBox("ComboBox"); - comboBox.addItems(numbers); - formLayout.addComponent(comboBox); - - ListSelect listSelect = new ListSelect("ListSelect"); - listSelect.addItems(numbers); - listSelect.setRows(2); - formLayout.addComponent(listSelect); - - NativeSelect nativeSelect = new NativeSelect("NativeSelect"); - nativeSelect.addItems(numbers); - formLayout.addComponent(nativeSelect); - - TwinColSelect twinColSelect = new TwinColSelect("TwinColSelect"); - twinColSelect.addItems(numbers); - - Grid grid = new Grid("Grid"); - grid.setColumns("Column1", "Column2", "Column3"); - grid.addRow("Item1", "Item2", "Item3"); - grid.addRow("Item4", "Item5", "Item6"); - - Panel panel = new Panel("Panel"); - panel.setContent(grid); - panel.setSizeUndefined(); - - Panel serverPushPanel = new Panel("Server Push"); - FormLayout timeLayout = new FormLayout(); - timeLayout.setSpacing(true); - timeLayout.setMargin(true); - currentTime = new Label("No TIME..."); - timeLayout.addComponent(currentTime); - serverPushPanel.setContent(timeLayout); - serverPushPanel.setSizeUndefined(); - ScheduledExecutorService scheduleExecutor = Executors.newScheduledThreadPool(1); - Runnable task = () -> { - currentTime.setValue("Current Time : " + Instant.now()); - }; - scheduleExecutor.scheduleWithFixedDelay(task, 0, 1, TimeUnit.SECONDS); - - FormLayout dataBindingLayout = new FormLayout(); - dataBindingLayout.setSpacing(true); - dataBindingLayout.setMargin(true); - - BindData bindData = new BindData("BindData"); - BeanFieldGroup beanFieldGroup = new BeanFieldGroup(BindData.class); - beanFieldGroup.setItemDataSource(bindData); - TextField bindedTextField = (TextField) beanFieldGroup.buildAndBind("BindName", "bindName"); - bindedTextField.setWidth("250px"); - dataBindingLayout.addComponent(bindedTextField); - - FormLayout validatorLayout = new FormLayout(); - validatorLayout.setSpacing(true); - validatorLayout.setMargin(true); - - HorizontalLayout textValidatorLayout = new HorizontalLayout(); - textValidatorLayout.setSpacing(true); - textValidatorLayout.setMargin(true); - - TextField stringValidator = new TextField(); - stringValidator.setNullSettingAllowed(true); - stringValidator.setNullRepresentation(""); - stringValidator.addValidator(new StringLengthValidator("String must have 2-5 characters lenght", 2, 5, true)); - stringValidator.setValidationVisible(false); - textValidatorLayout.addComponent(stringValidator); - Button buttonStringValidator = new Button("Validate String"); - buttonStringValidator.addClickListener(e -> { - try { - stringValidator.setValidationVisible(false); - stringValidator.validate(); - } catch (InvalidValueException err) { - stringValidator.setValidationVisible(true); - } - }); - textValidatorLayout.addComponent(buttonStringValidator); - - validatorLayout.addComponent(textValidatorLayout); - verticalLayout.addComponent(gridLayout); - verticalLayout.addComponent(richTextPanel); - verticalLayout.addComponent(horizontalLayout); - verticalLayout.addComponent(formLayout); - verticalLayout.addComponent(twinColSelect); - verticalLayout.addComponent(panel); - verticalLayout.addComponent(serverPushPanel); - verticalLayout.addComponent(dataBindingLayout); - verticalLayout.addComponent(validatorLayout); - setContent(verticalLayout); - } - - @WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true) - @VaadinServletConfiguration(ui = VaadinUI.class, productionMode = false) - public static class MyUIServlet extends VaadinServlet { - } -} From e89f5ace7aaabaf3b932a2a279d4e9942b4289d1 Mon Sep 17 00:00:00 2001 From: Alejandro Gervasio Date: Sun, 14 Apr 2019 11:38:21 -0300 Subject: [PATCH 199/531] BAEL-2840 - Spring Data Web Support (#6672) * Initial Commit * Update UserRepository.java * Update UserControllerIntegrationTest.java * Update UserRepository.java * Update pom.xml --- spring-data-rest/pom.xml | 46 ++++++++++-- .../application/Application.java | 28 +++++++ .../controllers/UserController.java | 47 ++++++++++++ .../application/entities/User.java | 38 ++++++++++ .../repositories/UserRepository.java | 14 ++++ .../test/UserControllerIntegrationTest.java | 74 +++++++++++++++++++ 6 files changed, 242 insertions(+), 5 deletions(-) create mode 100644 spring-data-rest/src/main/java/com/baeldung/springdatawebsupport/application/Application.java create mode 100644 spring-data-rest/src/main/java/com/baeldung/springdatawebsupport/application/controllers/UserController.java create mode 100644 spring-data-rest/src/main/java/com/baeldung/springdatawebsupport/application/entities/User.java create mode 100644 spring-data-rest/src/main/java/com/baeldung/springdatawebsupport/application/repositories/UserRepository.java create mode 100644 spring-data-rest/src/test/java/com/baeldung/springdatawebsupport/application/test/UserControllerIntegrationTest.java diff --git a/spring-data-rest/pom.xml b/spring-data-rest/pom.xml index e563a6a3b5..525c88c9d8 100644 --- a/spring-data-rest/pom.xml +++ b/spring-data-rest/pom.xml @@ -1,9 +1,8 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 spring-data-rest - 1.0 spring-data-rest jar @@ -21,6 +20,10 @@ org.springframework.boot spring-boot-starter
+ + org.springframework.boot + spring-boot-starter-web + org.springframework.boot spring-boot-starter-data-rest @@ -30,12 +33,21 @@ spring-boot-starter-data-jpa - com.h2database - h2 + org.springframework.boot + spring-boot-autoconfigure org.springframework.boot - spring-boot-autoconfigure + spring-boot-starter-test + test + + + com.querydsl + querydsl-apt + + + com.querydsl + querydsl-jpa org.xerial @@ -45,9 +57,33 @@ ${project.artifactId} + + + com.mysema.maven + maven-apt-plugin + 1.0 + + + generate-sources + + process + + + target/generated-sources + com.querydsl.apt.jpa.JPAAnnotationProcessor + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + UTF-8 com.baeldung.SpringDataRestApplication diff --git a/spring-data-rest/src/main/java/com/baeldung/springdatawebsupport/application/Application.java b/spring-data-rest/src/main/java/com/baeldung/springdatawebsupport/application/Application.java new file mode 100644 index 0000000000..fe2f996d37 --- /dev/null +++ b/spring-data-rest/src/main/java/com/baeldung/springdatawebsupport/application/Application.java @@ -0,0 +1,28 @@ +package com.baeldung.springdatawebsupport.application; + +import com.baeldung.springdatawebsupport.application.entities.User; +import com.baeldung.springdatawebsupport.application.repositories.UserRepository; +import java.util.stream.Stream; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + + @Bean + CommandLineRunner initialize(UserRepository userRepository) { + return args -> { + Stream.of("John", "Robert", "Nataly", "Helen", "Mary").forEach(name -> { + User user = new User(name); + userRepository.save(user); + }); + userRepository.findAll().forEach(System.out::println); + }; + } +} diff --git a/spring-data-rest/src/main/java/com/baeldung/springdatawebsupport/application/controllers/UserController.java b/spring-data-rest/src/main/java/com/baeldung/springdatawebsupport/application/controllers/UserController.java new file mode 100644 index 0000000000..8258c3b7aa --- /dev/null +++ b/spring-data-rest/src/main/java/com/baeldung/springdatawebsupport/application/controllers/UserController.java @@ -0,0 +1,47 @@ +package com.baeldung.springdatawebsupport.application.controllers; + +import com.baeldung.springdatawebsupport.application.entities.User; +import com.baeldung.springdatawebsupport.application.repositories.UserRepository; +import com.querydsl.core.types.Predicate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.data.querydsl.binding.QuerydslPredicate; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class UserController { + + private final UserRepository userRepository; + + @Autowired + public UserController(UserRepository userRepository) { + this.userRepository = userRepository; + } + + @GetMapping("/users/{id}") + public User findUserById(@PathVariable("id") User user) { + return user; + } + + @GetMapping("/users") + public Page findAllUsers(Pageable pageable) { + return userRepository.findAll(pageable); + } + + @GetMapping("/sortedusers") + public Page findAllUsersSortedByName() { + Pageable pageable = PageRequest.of(0, 5, Sort.by("name")); + return userRepository.findAll(pageable); + } + + @GetMapping("/filteredusers") + public Iterable getUsersByQuerydslPredicate(@QuerydslPredicate(root = User.class) Predicate predicate) { + return userRepository.findAll(predicate); + } +} diff --git a/spring-data-rest/src/main/java/com/baeldung/springdatawebsupport/application/entities/User.java b/spring-data-rest/src/main/java/com/baeldung/springdatawebsupport/application/entities/User.java new file mode 100644 index 0000000000..e9aaeb119a --- /dev/null +++ b/spring-data-rest/src/main/java/com/baeldung/springdatawebsupport/application/entities/User.java @@ -0,0 +1,38 @@ +package com.baeldung.springdatawebsupport.application.entities; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; + +@Entity +@Table(name = "users") +public class User { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + private final String name; + + public User() { + this.name = ""; + } + + public User(String name) { + this.name = name; + } + + public long getId() { + return id; + } + + public String getName() { + return name; + } + + @Override + public String toString() { + return "User{" + "id=" + id + ", name=" + name + '}'; + } +} diff --git a/spring-data-rest/src/main/java/com/baeldung/springdatawebsupport/application/repositories/UserRepository.java b/spring-data-rest/src/main/java/com/baeldung/springdatawebsupport/application/repositories/UserRepository.java new file mode 100644 index 0000000000..41d7ed9d98 --- /dev/null +++ b/spring-data-rest/src/main/java/com/baeldung/springdatawebsupport/application/repositories/UserRepository.java @@ -0,0 +1,14 @@ +package com.baeldung.springdatawebsupport.application.repositories; + +import com.baeldung.springdatawebsupport.application.entities.User; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.querydsl.QuerydslPredicateExecutor; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface UserRepository extends PagingAndSortingRepository, + QuerydslPredicateExecutor { + +} diff --git a/spring-data-rest/src/test/java/com/baeldung/springdatawebsupport/application/test/UserControllerIntegrationTest.java b/spring-data-rest/src/test/java/com/baeldung/springdatawebsupport/application/test/UserControllerIntegrationTest.java new file mode 100644 index 0000000000..db522b1413 --- /dev/null +++ b/spring-data-rest/src/test/java/com/baeldung/springdatawebsupport/application/test/UserControllerIntegrationTest.java @@ -0,0 +1,74 @@ +package com.baeldung.springdatawebsupport.application.test; + +import com.baeldung.springdatawebsupport.application.controllers.UserController; +import static org.assertj.core.api.Assertions.assertThat; +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.http.MediaType; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import org.springframework.test.web.servlet.result.MockMvcResultMatchers; + +@RunWith(SpringRunner.class) +@SpringBootTest +@AutoConfigureMockMvc +public class UserControllerIntegrationTest { + + @Autowired + private UserController userController; + + @Autowired + private MockMvc mockMvc; + + @Test + public void whenUserControllerInjected_thenNotNull() throws Exception { + assertThat(userController).isNotNull(); + } + + @Test + public void whenGetRequestToUsersEndPointWithIdPathVariable_thenCorrectResponse() throws Exception { + mockMvc.perform(MockMvcRequestBuilders.get("/users/{id}", "1") + .contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(MockMvcResultMatchers.status().isOk()) + .andExpect(MockMvcResultMatchers.jsonPath("$.id").value("1")); + } + + @Test + public void whenGetRequestToUsersEndPoint_thenCorrectResponse() throws Exception { + mockMvc.perform(MockMvcRequestBuilders.get("/users") + .contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(MockMvcResultMatchers.status().isOk()) + .andExpect(MockMvcResultMatchers.jsonPath("$['pageable']['paged']").value("true")); + + } + + @Test + public void whenGetRequestToUserEndPointWithNameRequestParameter_thenCorrectResponse() throws Exception { + mockMvc.perform(MockMvcRequestBuilders.get("/user") + .param("name", "John") + .contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(MockMvcResultMatchers.status().isOk()) + .andExpect(MockMvcResultMatchers.jsonPath("$['content'][0].['name']").value("John")); + } + + @Test + public void whenGetRequestToSorteredUsersEndPoint_thenCorrectResponse() throws Exception { + mockMvc.perform(MockMvcRequestBuilders.get("/sortedusers") + .contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(MockMvcResultMatchers.status().isOk()) + .andExpect(MockMvcResultMatchers.jsonPath("$['sort']['sorted']").value("true")); + } + + @Test + public void whenGetRequestToFilteredUsersEndPoint_thenCorrectResponse() throws Exception { + mockMvc.perform(MockMvcRequestBuilders.get("/filteredusers") + .param("name", "John") + .contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(MockMvcResultMatchers.status().isOk()) + .andExpect(MockMvcResultMatchers.jsonPath("$[0].name").value("John")); + } +} From 93d6d243ac16562b3ff557d8dbeb88ab0ee64ec2 Mon Sep 17 00:00:00 2001 From: "sumit.sg34" Date: Sun, 14 Apr 2019 20:56:40 +0530 Subject: [PATCH 200/531] formatting done : removing tabs --- persistence-modules/spring-data-jpa-2/pom.xml | 61 ++++++++++--------- .../src/main/resources/fruit-data.json | 26 ++++---- .../src/main/resources/fruit-data.xml | 6 +- 3 files changed, 47 insertions(+), 46 deletions(-) diff --git a/persistence-modules/spring-data-jpa-2/pom.xml b/persistence-modules/spring-data-jpa-2/pom.xml index 5080ad9bd3..251007ba6d 100644 --- a/persistence-modules/spring-data-jpa-2/pom.xml +++ b/persistence-modules/spring-data-jpa-2/pom.xml @@ -1,40 +1,41 @@ - 4.0.0 - com.baeldung - spring-data-jpa-2 - spring-data-jpa + 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 - - parent-boot-2 - com.baeldung - 0.0.1-SNAPSHOT - ../../parent-boot-2 - + com.baeldung + spring-data-jpa-2 + spring-data-jpa - - - org.springframework.boot - spring-boot-starter-data-jpa - + + parent-boot-2 + com.baeldung + 0.0.1-SNAPSHOT + ../../parent-boot-2 + - - com.h2database - h2 - + + + org.springframework.boot + spring-boot-starter-data-jpa + - - com.fasterxml.jackson.core - jackson-databind - + + com.h2database + h2 + - - org.springframework - spring-oxm - + + com.fasterxml.jackson.core + jackson-databind + - + + org.springframework + spring-oxm + + + \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.json b/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.json index 214ea18e4d..6dc44e2586 100644 --- a/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.json +++ b/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.json @@ -1,14 +1,14 @@ -[ - { - "_class": "com.baeldung.entity.Fruit", - "name": "apple", - "color": "red", - "id": 1 - }, - { - "_class": "com.baeldung.entity.Fruit", - "name": "guava", - "color": "green", - "id": 2 - } +[ + { + "_class": "com.baeldung.entity.Fruit", + "name": "apple", + "color": "red", + "id": 1 + }, + { + "_class": "com.baeldung.entity.Fruit", + "name": "guava", + "color": "green", + "id": 2 + } ] \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.xml b/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.xml index d0101e3f4d..d87ae28f1e 100644 --- a/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.xml +++ b/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.xml @@ -1,7 +1,7 @@ - 1 - apple - red + 1 + apple + red From 87e2047eb5b83abc9bf69803846fa2f17eaabbab Mon Sep 17 00:00:00 2001 From: Kumar Chandrakant Date: Sun, 14 Apr 2019 22:25:16 +0530 Subject: [PATCH 201/531] Adding source files for the tutorial BAEL-2788 (#6699) * Adding source files for the tutorial BAEL-2788 * Made changes to the code for the review comments --- pom.xml | 6 +- spring-boot-flowable/README.md | 3 + spring-boot-flowable/pom.xml | 58 +++++++++++++++++++ .../main/java/com/baeldung/Application.java | 13 +++++ .../controller/ArticleWorkflowController.java | 32 ++++++++++ .../java/com/baeldung/domain/Approval.java | 24 ++++++++ .../java/com/baeldung/domain/Article.java | 52 +++++++++++++++++ .../service/ArticleWorkflowService.java | 55 ++++++++++++++++++ .../service/PublishArticleService.java | 10 ++++ .../com/baeldung/service/SendMailService.java | 10 ++++ .../src/main/resources/application.properties | 1 + .../processes/article-workflow.bpmn20.xml | 51 ++++++++++++++++ .../processes/ArticleWorkflowUnitTest.java | 40 +++++++++++++ 13 files changed, 354 insertions(+), 1 deletion(-) create mode 100644 spring-boot-flowable/README.md create mode 100644 spring-boot-flowable/pom.xml create mode 100644 spring-boot-flowable/src/main/java/com/baeldung/Application.java create mode 100644 spring-boot-flowable/src/main/java/com/baeldung/controller/ArticleWorkflowController.java create mode 100644 spring-boot-flowable/src/main/java/com/baeldung/domain/Approval.java create mode 100644 spring-boot-flowable/src/main/java/com/baeldung/domain/Article.java create mode 100644 spring-boot-flowable/src/main/java/com/baeldung/service/ArticleWorkflowService.java create mode 100644 spring-boot-flowable/src/main/java/com/baeldung/service/PublishArticleService.java create mode 100644 spring-boot-flowable/src/main/java/com/baeldung/service/SendMailService.java create mode 100644 spring-boot-flowable/src/main/resources/application.properties create mode 100644 spring-boot-flowable/src/main/resources/processes/article-workflow.bpmn20.xml create mode 100644 spring-boot-flowable/src/test/java/com/baeldung/processes/ArticleWorkflowUnitTest.java diff --git a/pom.xml b/pom.xml index d6cee747ec..d57fa1694e 100644 --- a/pom.xml +++ b/pom.xml @@ -540,7 +540,8 @@ software-security/sql-injection-samples tensorflow-java - + spring-boot-flowable + @@ -766,6 +767,7 @@ xstream tensorflow-java + spring-boot-flowable @@ -908,6 +910,8 @@ persistence-modules/spring-data-eclipselink persistence-modules/spring-data-solr persistence-modules/spring-hibernate-5 + + spring-boot-flowable diff --git a/spring-boot-flowable/README.md b/spring-boot-flowable/README.md new file mode 100644 index 0000000000..8fb90d953b --- /dev/null +++ b/spring-boot-flowable/README.md @@ -0,0 +1,3 @@ +### Relevant articles + +- [Introduction to Flowable](http://www.baeldung.com/flowable) diff --git a/spring-boot-flowable/pom.xml b/spring-boot-flowable/pom.xml new file mode 100644 index 0000000000..f9531a1e6a --- /dev/null +++ b/spring-boot-flowable/pom.xml @@ -0,0 +1,58 @@ + + + 4.0.0 + spring-boot-flowable + war + spring-boot-flowable + Spring Boot Flowable Module + + parent-boot-2 + com.baeldung + 0.0.1-SNAPSHOT + ../parent-boot-2 + + + + org.springframework.boot + spring-boot-starter-web + + + com.h2database + h2 + runtime + + + org.flowable + flowable-spring-boot-starter-rest + ${flowable.version} + + + org.flowable + flowable-spring-boot-starter-actuator + ${flowable.version} + + + org.springframework.boot + spring-boot-starter-test + test + + + org.junit.jupiter + junit-jupiter-engine + test + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + 6.4.1 + + \ No newline at end of file diff --git a/spring-boot-flowable/src/main/java/com/baeldung/Application.java b/spring-boot-flowable/src/main/java/com/baeldung/Application.java new file mode 100644 index 0000000000..37dbe7dab8 --- /dev/null +++ b/spring-boot-flowable/src/main/java/com/baeldung/Application.java @@ -0,0 +1,13 @@ +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-flowable/src/main/java/com/baeldung/controller/ArticleWorkflowController.java b/spring-boot-flowable/src/main/java/com/baeldung/controller/ArticleWorkflowController.java new file mode 100644 index 0000000000..3087d30af4 --- /dev/null +++ b/spring-boot-flowable/src/main/java/com/baeldung/controller/ArticleWorkflowController.java @@ -0,0 +1,32 @@ +package com.baeldung.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.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import com.baeldung.domain.Approval; +import com.baeldung.domain.Article; +import com.baeldung.service.ArticleWorkflowService; + +@RestController +public class ArticleWorkflowController { + @Autowired + private ArticleWorkflowService service; + @PostMapping("/submit") + public void submit(@RequestBody Article article) { + service.startProcess(article); + } + @GetMapping("/tasks") + public List
getTasks(@RequestParam String assignee) { + return service.getTasks(assignee); + } + @PostMapping("/review") + public void review(@RequestBody Approval approval) { + service.submitReview(approval); + } +} \ No newline at end of file diff --git a/spring-boot-flowable/src/main/java/com/baeldung/domain/Approval.java b/spring-boot-flowable/src/main/java/com/baeldung/domain/Approval.java new file mode 100644 index 0000000000..b0c9c99437 --- /dev/null +++ b/spring-boot-flowable/src/main/java/com/baeldung/domain/Approval.java @@ -0,0 +1,24 @@ +package com.baeldung.domain; + +public class Approval { + + private String id; + private boolean status; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public boolean isStatus() { + return status; + } + + public void setStatus(boolean status) { + this.status = status; + } + +} diff --git a/spring-boot-flowable/src/main/java/com/baeldung/domain/Article.java b/spring-boot-flowable/src/main/java/com/baeldung/domain/Article.java new file mode 100644 index 0000000000..efa2eb431e --- /dev/null +++ b/spring-boot-flowable/src/main/java/com/baeldung/domain/Article.java @@ -0,0 +1,52 @@ +package com.baeldung.domain; + +public class Article { + + private String id; + private String author; + private String url; + + public Article() { + } + + public Article(String author, String url) { + this.author = author; + this.url = url; + } + + public Article(String id, String author, String url) { + this.id = id; + this.author = author; + this.url = url; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getAuthor() { + return author; + } + + public void setAuthor(String author) { + this.author = author; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + @Override + public String toString() { + return ("[" + this.author + " " + this.url + "]"); + } + +} diff --git a/spring-boot-flowable/src/main/java/com/baeldung/service/ArticleWorkflowService.java b/spring-boot-flowable/src/main/java/com/baeldung/service/ArticleWorkflowService.java new file mode 100644 index 0000000000..b1e2a92354 --- /dev/null +++ b/spring-boot-flowable/src/main/java/com/baeldung/service/ArticleWorkflowService.java @@ -0,0 +1,55 @@ +package com.baeldung.service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import org.flowable.engine.RuntimeService; +import org.flowable.engine.TaskService; +import org.flowable.task.api.Task; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.baeldung.domain.Approval; +import com.baeldung.domain.Article; + +@Service +public class ArticleWorkflowService { + @Autowired + private RuntimeService runtimeService; + @Autowired + private TaskService taskService; + + @Transactional + public void startProcess(Article article) { + Map variables = new HashMap(); + variables.put("author", article.getAuthor()); + variables.put("url", article.getUrl()); + runtimeService.startProcessInstanceByKey("articleReview", variables); + } + + @Transactional + public List
getTasks(String assignee) { + List tasks = taskService.createTaskQuery() + .taskCandidateGroup(assignee) + .list(); + + List
articles = tasks.stream() + .map(task -> { + Map variables = taskService.getVariables(task.getId()); + return new Article( + task.getId(), (String) variables.get("author"), (String) variables.get("url")); + }) + .collect(Collectors.toList()); + return articles; + } + + @Transactional + public void submitReview(Approval approval) { + Map variables = new HashMap(); + variables.put("approved", approval.isStatus()); + taskService.complete(approval.getId(), variables); + } +} \ No newline at end of file diff --git a/spring-boot-flowable/src/main/java/com/baeldung/service/PublishArticleService.java b/spring-boot-flowable/src/main/java/com/baeldung/service/PublishArticleService.java new file mode 100644 index 0000000000..b43f1dccdb --- /dev/null +++ b/spring-boot-flowable/src/main/java/com/baeldung/service/PublishArticleService.java @@ -0,0 +1,10 @@ +package com.baeldung.service; + +import org.flowable.engine.delegate.DelegateExecution; +import org.flowable.engine.delegate.JavaDelegate; + +public class PublishArticleService implements JavaDelegate { + public void execute(DelegateExecution execution) { + System.out.println("Publishing the approved article."); + } +} diff --git a/spring-boot-flowable/src/main/java/com/baeldung/service/SendMailService.java b/spring-boot-flowable/src/main/java/com/baeldung/service/SendMailService.java new file mode 100644 index 0000000000..f80b16748f --- /dev/null +++ b/spring-boot-flowable/src/main/java/com/baeldung/service/SendMailService.java @@ -0,0 +1,10 @@ +package com.baeldung.service; + +import org.flowable.engine.delegate.DelegateExecution; +import org.flowable.engine.delegate.JavaDelegate; + +public class SendMailService implements JavaDelegate { + public void execute(DelegateExecution execution) { + System.out.println("Sending rejection mail to author."); + } +} diff --git a/spring-boot-flowable/src/main/resources/application.properties b/spring-boot-flowable/src/main/resources/application.properties new file mode 100644 index 0000000000..c3afcaa0b5 --- /dev/null +++ b/spring-boot-flowable/src/main/resources/application.properties @@ -0,0 +1 @@ +management.endpoint.flowable.enabled=true \ No newline at end of file diff --git a/spring-boot-flowable/src/main/resources/processes/article-workflow.bpmn20.xml b/spring-boot-flowable/src/main/resources/processes/article-workflow.bpmn20.xml new file mode 100644 index 0000000000..6bf210dcee --- /dev/null +++ b/spring-boot-flowable/src/main/resources/processes/article-workflow.bpmn20.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-boot-flowable/src/test/java/com/baeldung/processes/ArticleWorkflowUnitTest.java b/spring-boot-flowable/src/test/java/com/baeldung/processes/ArticleWorkflowUnitTest.java new file mode 100644 index 0000000000..ef5453623a --- /dev/null +++ b/spring-boot-flowable/src/test/java/com/baeldung/processes/ArticleWorkflowUnitTest.java @@ -0,0 +1,40 @@ +package com.baeldung.processes; + +import static org.junit.Assert.assertEquals; + +import java.util.HashMap; +import java.util.Map; + +import org.flowable.engine.RuntimeService; +import org.flowable.engine.TaskService; +import org.flowable.engine.test.Deployment; +import org.flowable.spring.impl.test.FlowableSpringExtension; +import org.flowable.task.api.Task; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +@ExtendWith(FlowableSpringExtension.class) +@ExtendWith(SpringExtension.class) +public class ArticleWorkflowUnitTest { + @Autowired + private RuntimeService runtimeService; + @Autowired + private TaskService taskService; + @Test + @Deployment(resources = { "processes/article-workflow.bpmn20.xml" }) + void articleApprovalTest() { + Map variables = new HashMap(); + variables.put("author", "test@baeldung.com"); + variables.put("url", "http://baeldung.com/dummy"); + runtimeService.startProcessInstanceByKey("articleReview", variables); + Task task = taskService.createTaskQuery() + .singleResult(); + assertEquals("Review the submitted tutorial", task.getName()); + variables.put("approved", true); + taskService.complete(task.getId(), variables); + assertEquals(0, runtimeService.createProcessInstanceQuery() + .count()); + } +} \ No newline at end of file From bcca8479d5d2d7b315a825d1150eae595cac609b Mon Sep 17 00:00:00 2001 From: amit2103 Date: Sun, 14 Apr 2019 22:37:03 +0530 Subject: [PATCH 202/531] [BAEL-14127] - Moved code to jackson-simple --- jackson-simple/.gitignore | 13 ++ jackson-simple/README.md | 14 ++ jackson-simple/pom.xml | 131 ++++++++++++++++++ jackson-simple/src/main/resources/logback.xml | 19 +++ .../jackson/annotation/AliasBean.java | 0 .../jackson/annotation/BeanWithCreator.java | 0 .../annotation/BeanWithCustomAnnotation.java | 0 .../jackson/annotation/BeanWithFilter.java | 0 .../jackson/annotation/BeanWithGetter.java | 0 .../jackson/annotation/BeanWithIgnore.java | 0 .../jackson/annotation/BeanWithInject.java | 0 .../jackson/annotation/ExtendableBean.java | 0 .../baeldung/jackson/annotation/MyBean.java | 0 .../jackson/annotation/PrivateBean.java | 0 .../baeldung/jackson/annotation/RawBean.java | 0 .../jackson/annotation/UnwrappedUser.java | 0 .../annotation/UserWithIgnoreType.java | 0 .../com/baeldung/jackson/annotation/Zoo.java | 0 .../jackson/bidirection/ItemWithIdentity.java | 21 +++ .../jackson/bidirection/ItemWithIgnore.java | 17 +++ .../jackson/bidirection/ItemWithRef.java | 21 +++ .../jackson/bidirection/UserWithIdentity.java | 28 ++++ .../jackson/bidirection/UserWithIgnore.java | 28 ++++ .../jackson/bidirection/UserWithRef.java | 28 ++++ .../jackson/date/CustomDateDeserializer.java | 36 +++++ .../jackson/date/CustomDateSerializer.java | 29 ++++ .../jackson/date/EventWithFormat.java | 29 ++++ .../jackson/date/EventWithSerializer.java | 31 +++++ .../ItemDeserializerOnClass.java | 41 ++++++ .../java/com/baeldung/jackson/dtos/Item.java | 32 +++++ .../jackson/dtos/ItemWithSerializer.java | 36 +++++ .../java/com/baeldung/jackson/dtos/MyDto.java | 54 ++++++++ .../jackson/dtos/MyDtoFieldNameChanged.java | 0 .../jackson/dtos/MyDtoIncludeNonDefault.java | 0 .../jackson/dtos/MyDtoNoAccessors.java | 0 .../MyDtoNoAccessorsAndFieldVisibility.java | 0 .../jackson/dtos/MyDtoWithFilter.java | 0 .../jackson/dtos/MyDtoWithSpecialField.java | 0 .../jackson/dtos/MyMixInForIgnoreType.java | 0 .../java/com/baeldung/jackson/dtos/User.java | 26 ++++ .../jackson/dtos/ignore/MyDtoIgnoreField.java | 0 .../dtos/ignore/MyDtoIgnoreFieldByName.java | 0 .../jackson/dtos/ignore/MyDtoIgnoreNull.java | 0 .../dtos/withEnum/DistanceEnumWithValue.java | 29 ++++ .../jackson/exception/UserWithRoot.java | 18 +++ .../exception/UserWithRootNamespace.java | 0 .../com/baeldung/jackson/jsonview/Item.java | 36 +++++ .../com/baeldung/jackson/jsonview/Views.java | 9 ++ .../objectmapper/CustomCarDeserializer.java | 0 .../objectmapper/CustomCarSerializer.java | 0 .../JavaReadWriteJsonExampleUnitTest.java | 0 ...izationDeserializationFeatureUnitTest.java | 0 .../jackson/objectmapper/dto/Car.java | 0 .../jackson/objectmapper/dto/Request.java | 0 .../jackson/serialization/ItemSerializer.java | 0 .../serialization/ItemSerializerOnClass.java | 32 +++++ .../serialization/MyDtoNullKeySerializer.java | 0 .../test/JacksonAnnotationUnitTest.java | 0 .../JacksonSerializationIgnoreUnitTest.java | 0 .../test/JacksonSerializationUnitTest.java | 0 jackson-simple/src/test/resources/.gitignore | 13 ++ jackson/README.md | 6 - .../baeldung/jackson/test/UnitTestSuite.java | 2 - pom.xml | 2 + 64 files changed, 773 insertions(+), 8 deletions(-) create mode 100644 jackson-simple/.gitignore create mode 100644 jackson-simple/README.md create mode 100644 jackson-simple/pom.xml create mode 100644 jackson-simple/src/main/resources/logback.xml rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/annotation/AliasBean.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/annotation/BeanWithCreator.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/annotation/BeanWithCustomAnnotation.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/annotation/BeanWithFilter.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/annotation/BeanWithGetter.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/annotation/BeanWithIgnore.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/annotation/BeanWithInject.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/annotation/ExtendableBean.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/annotation/MyBean.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/annotation/PrivateBean.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/annotation/RawBean.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/annotation/UnwrappedUser.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/annotation/UserWithIgnoreType.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/annotation/Zoo.java (100%) create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/bidirection/ItemWithIdentity.java create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/bidirection/ItemWithIgnore.java create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/bidirection/ItemWithRef.java create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/bidirection/UserWithIdentity.java create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/bidirection/UserWithIgnore.java create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/bidirection/UserWithRef.java create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/date/CustomDateDeserializer.java create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/date/CustomDateSerializer.java create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/date/EventWithFormat.java create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/date/EventWithSerializer.java create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/deserialization/ItemDeserializerOnClass.java create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/dtos/Item.java create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/dtos/ItemWithSerializer.java create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/dtos/MyDto.java rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/dtos/MyDtoFieldNameChanged.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/dtos/MyDtoIncludeNonDefault.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/dtos/MyDtoNoAccessors.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/dtos/MyDtoNoAccessorsAndFieldVisibility.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/dtos/MyDtoWithFilter.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/dtos/MyDtoWithSpecialField.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/dtos/MyMixInForIgnoreType.java (100%) create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/dtos/User.java rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreField.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreFieldByName.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreNull.java (100%) create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/dtos/withEnum/DistanceEnumWithValue.java create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/exception/UserWithRoot.java rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/exception/UserWithRootNamespace.java (100%) create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/jsonview/Item.java create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/jsonview/Views.java rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/objectmapper/CustomCarDeserializer.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/objectmapper/CustomCarSerializer.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/objectmapper/JavaReadWriteJsonExampleUnitTest.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/objectmapper/SerializationDeserializationFeatureUnitTest.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/objectmapper/dto/Car.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/objectmapper/dto/Request.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/serialization/ItemSerializer.java (100%) create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/serialization/ItemSerializerOnClass.java rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/serialization/MyDtoNullKeySerializer.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/test/JacksonAnnotationUnitTest.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/test/JacksonSerializationUnitTest.java (100%) create mode 100644 jackson-simple/src/test/resources/.gitignore diff --git a/jackson-simple/.gitignore b/jackson-simple/.gitignore new file mode 100644 index 0000000000..83c05e60c8 --- /dev/null +++ b/jackson-simple/.gitignore @@ -0,0 +1,13 @@ +*.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/jackson-simple/README.md b/jackson-simple/README.md new file mode 100644 index 0000000000..5a43bebb29 --- /dev/null +++ b/jackson-simple/README.md @@ -0,0 +1,14 @@ +========= + +## Jackson Cookbooks and Examples + +###The Course +The "REST With Spring" Classes: http://bit.ly/restwithspring + +### Relevant Articles: +- [Jackson Ignore Properties on Marshalling](http://www.baeldung.com/jackson-ignore-properties-on-serialization) +- [Jackson Unmarshalling json with Unknown Properties](http://www.baeldung.com/jackson-deserialize-json-unknown-properties) +- [Jackson Annotation Examples](http://www.baeldung.com/jackson-annotations) +- [Intro to the Jackson ObjectMapper](http://www.baeldung.com/jackson-object-mapper-tutorial) +- [Ignore Null Fields with Jackson](http://www.baeldung.com/jackson-ignore-null-fields) +- [Jackson – Change Name of Field](http://www.baeldung.com/jackson-name-of-property) \ No newline at end of file diff --git a/jackson-simple/pom.xml b/jackson-simple/pom.xml new file mode 100644 index 0000000000..5023ad87b6 --- /dev/null +++ b/jackson-simple/pom.xml @@ -0,0 +1,131 @@ + + 4.0.0 + jackson-simple + 0.1-SNAPSHOT + jackson-simple + + + com.baeldung + parent-java + 0.0.1-SNAPSHOT + ../parent-java + + + + + + commons-io + commons-io + ${commons-io.version} + + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + ${jackson.version} + + + + org.apache.commons + commons-collections4 + ${commons-collections4.version} + + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + ${jackson.version} + + + + com.fasterxml.jackson.datatype + jackson-datatype-joda + ${jackson.version} + + + + com.fasterxml.jackson.module + jackson-module-jsonSchema + ${jackson.version} + + + + com.fasterxml.jackson.datatype + jackson-datatype-jdk8 + ${jackson.version} + + + + joda-time + joda-time + ${joda-time.version} + + + + com.google.code.gson + gson + ${gson.version} + + + + + + io.rest-assured + json-schema-validator + ${rest-assured.version} + test + + + + io.rest-assured + json-path + ${rest-assured.version} + test + + + + org.assertj + assertj-core + ${assertj.version} + test + + + + + jackson-simple + + + src/main/resources + true + + + + + + + 3.8 + 2.10 + 2.8.5 + 4.2 + + + 3.1.1 + 3.11.0 + + + diff --git a/jackson-simple/src/main/resources/logback.xml b/jackson-simple/src/main/resources/logback.xml new file mode 100644 index 0000000000..56af2d397e --- /dev/null +++ b/jackson-simple/src/main/resources/logback.xml @@ -0,0 +1,19 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + + + + + \ No newline at end of file diff --git a/jackson/src/test/java/com/baeldung/jackson/annotation/AliasBean.java b/jackson-simple/src/test/java/com/baeldung/jackson/annotation/AliasBean.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/annotation/AliasBean.java rename to jackson-simple/src/test/java/com/baeldung/jackson/annotation/AliasBean.java diff --git a/jackson/src/test/java/com/baeldung/jackson/annotation/BeanWithCreator.java b/jackson-simple/src/test/java/com/baeldung/jackson/annotation/BeanWithCreator.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/annotation/BeanWithCreator.java rename to jackson-simple/src/test/java/com/baeldung/jackson/annotation/BeanWithCreator.java diff --git a/jackson/src/test/java/com/baeldung/jackson/annotation/BeanWithCustomAnnotation.java b/jackson-simple/src/test/java/com/baeldung/jackson/annotation/BeanWithCustomAnnotation.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/annotation/BeanWithCustomAnnotation.java rename to jackson-simple/src/test/java/com/baeldung/jackson/annotation/BeanWithCustomAnnotation.java diff --git a/jackson/src/test/java/com/baeldung/jackson/annotation/BeanWithFilter.java b/jackson-simple/src/test/java/com/baeldung/jackson/annotation/BeanWithFilter.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/annotation/BeanWithFilter.java rename to jackson-simple/src/test/java/com/baeldung/jackson/annotation/BeanWithFilter.java diff --git a/jackson/src/test/java/com/baeldung/jackson/annotation/BeanWithGetter.java b/jackson-simple/src/test/java/com/baeldung/jackson/annotation/BeanWithGetter.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/annotation/BeanWithGetter.java rename to jackson-simple/src/test/java/com/baeldung/jackson/annotation/BeanWithGetter.java diff --git a/jackson/src/test/java/com/baeldung/jackson/annotation/BeanWithIgnore.java b/jackson-simple/src/test/java/com/baeldung/jackson/annotation/BeanWithIgnore.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/annotation/BeanWithIgnore.java rename to jackson-simple/src/test/java/com/baeldung/jackson/annotation/BeanWithIgnore.java diff --git a/jackson/src/test/java/com/baeldung/jackson/annotation/BeanWithInject.java b/jackson-simple/src/test/java/com/baeldung/jackson/annotation/BeanWithInject.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/annotation/BeanWithInject.java rename to jackson-simple/src/test/java/com/baeldung/jackson/annotation/BeanWithInject.java diff --git a/jackson/src/test/java/com/baeldung/jackson/annotation/ExtendableBean.java b/jackson-simple/src/test/java/com/baeldung/jackson/annotation/ExtendableBean.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/annotation/ExtendableBean.java rename to jackson-simple/src/test/java/com/baeldung/jackson/annotation/ExtendableBean.java diff --git a/jackson/src/test/java/com/baeldung/jackson/annotation/MyBean.java b/jackson-simple/src/test/java/com/baeldung/jackson/annotation/MyBean.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/annotation/MyBean.java rename to jackson-simple/src/test/java/com/baeldung/jackson/annotation/MyBean.java diff --git a/jackson/src/test/java/com/baeldung/jackson/annotation/PrivateBean.java b/jackson-simple/src/test/java/com/baeldung/jackson/annotation/PrivateBean.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/annotation/PrivateBean.java rename to jackson-simple/src/test/java/com/baeldung/jackson/annotation/PrivateBean.java diff --git a/jackson/src/test/java/com/baeldung/jackson/annotation/RawBean.java b/jackson-simple/src/test/java/com/baeldung/jackson/annotation/RawBean.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/annotation/RawBean.java rename to jackson-simple/src/test/java/com/baeldung/jackson/annotation/RawBean.java diff --git a/jackson/src/test/java/com/baeldung/jackson/annotation/UnwrappedUser.java b/jackson-simple/src/test/java/com/baeldung/jackson/annotation/UnwrappedUser.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/annotation/UnwrappedUser.java rename to jackson-simple/src/test/java/com/baeldung/jackson/annotation/UnwrappedUser.java diff --git a/jackson/src/test/java/com/baeldung/jackson/annotation/UserWithIgnoreType.java b/jackson-simple/src/test/java/com/baeldung/jackson/annotation/UserWithIgnoreType.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/annotation/UserWithIgnoreType.java rename to jackson-simple/src/test/java/com/baeldung/jackson/annotation/UserWithIgnoreType.java diff --git a/jackson/src/test/java/com/baeldung/jackson/annotation/Zoo.java b/jackson-simple/src/test/java/com/baeldung/jackson/annotation/Zoo.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/annotation/Zoo.java rename to jackson-simple/src/test/java/com/baeldung/jackson/annotation/Zoo.java diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/bidirection/ItemWithIdentity.java b/jackson-simple/src/test/java/com/baeldung/jackson/bidirection/ItemWithIdentity.java new file mode 100644 index 0000000000..25de4a8f7a --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/bidirection/ItemWithIdentity.java @@ -0,0 +1,21 @@ +package com.baeldung.jackson.bidirection; + +import com.fasterxml.jackson.annotation.JsonIdentityInfo; +import com.fasterxml.jackson.annotation.ObjectIdGenerators; + +@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id") +public class ItemWithIdentity { + public int id; + public String itemName; + public UserWithIdentity owner; + + public ItemWithIdentity() { + super(); + } + + public ItemWithIdentity(final int id, final String itemName, final UserWithIdentity owner) { + this.id = id; + this.itemName = itemName; + this.owner = owner; + } +} diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/bidirection/ItemWithIgnore.java b/jackson-simple/src/test/java/com/baeldung/jackson/bidirection/ItemWithIgnore.java new file mode 100644 index 0000000000..910ccec174 --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/bidirection/ItemWithIgnore.java @@ -0,0 +1,17 @@ +package com.baeldung.jackson.bidirection; + +public class ItemWithIgnore { + public int id; + public String itemName; + public UserWithIgnore owner; + + public ItemWithIgnore() { + super(); + } + + public ItemWithIgnore(final int id, final String itemName, final UserWithIgnore owner) { + this.id = id; + this.itemName = itemName; + this.owner = owner; + } +} diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/bidirection/ItemWithRef.java b/jackson-simple/src/test/java/com/baeldung/jackson/bidirection/ItemWithRef.java new file mode 100644 index 0000000000..0ca8d721e8 --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/bidirection/ItemWithRef.java @@ -0,0 +1,21 @@ +package com.baeldung.jackson.bidirection; + +import com.fasterxml.jackson.annotation.JsonManagedReference; + +public class ItemWithRef { + public int id; + public String itemName; + + @JsonManagedReference + public UserWithRef owner; + + public ItemWithRef() { + super(); + } + + public ItemWithRef(final int id, final String itemName, final UserWithRef owner) { + this.id = id; + this.itemName = itemName; + this.owner = owner; + } +} diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/bidirection/UserWithIdentity.java b/jackson-simple/src/test/java/com/baeldung/jackson/bidirection/UserWithIdentity.java new file mode 100644 index 0000000000..db83a09389 --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/bidirection/UserWithIdentity.java @@ -0,0 +1,28 @@ +package com.baeldung.jackson.bidirection; + +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonIdentityInfo; +import com.fasterxml.jackson.annotation.ObjectIdGenerators; + +@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id") +public class UserWithIdentity { + public int id; + public String name; + public List userItems; + + public UserWithIdentity() { + super(); + } + + public UserWithIdentity(final int id, final String name) { + this.id = id; + this.name = name; + userItems = new ArrayList(); + } + + public void addItem(final ItemWithIdentity item) { + userItems.add(item); + } +} diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/bidirection/UserWithIgnore.java b/jackson-simple/src/test/java/com/baeldung/jackson/bidirection/UserWithIgnore.java new file mode 100644 index 0000000000..857a373cc5 --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/bidirection/UserWithIgnore.java @@ -0,0 +1,28 @@ +package com.baeldung.jackson.bidirection; + +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonIgnore; + +public class UserWithIgnore { + public int id; + public String name; + + @JsonIgnore + public List userItems; + + public UserWithIgnore() { + super(); + } + + public UserWithIgnore(final int id, final String name) { + this.id = id; + this.name = name; + userItems = new ArrayList(); + } + + public void addItem(final ItemWithIgnore item) { + userItems.add(item); + } +} diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/bidirection/UserWithRef.java b/jackson-simple/src/test/java/com/baeldung/jackson/bidirection/UserWithRef.java new file mode 100644 index 0000000000..3de03fc651 --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/bidirection/UserWithRef.java @@ -0,0 +1,28 @@ +package com.baeldung.jackson.bidirection; + +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonBackReference; + +public class UserWithRef { + public int id; + public String name; + + @JsonBackReference + public List userItems; + + public UserWithRef() { + super(); + } + + public UserWithRef(final int id, final String name) { + this.id = id; + this.name = name; + userItems = new ArrayList(); + } + + public void addItem(final ItemWithRef item) { + userItems.add(item); + } +} diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/date/CustomDateDeserializer.java b/jackson-simple/src/test/java/com/baeldung/jackson/date/CustomDateDeserializer.java new file mode 100644 index 0000000000..90c7d9fbac --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/date/CustomDateDeserializer.java @@ -0,0 +1,36 @@ +package com.baeldung.jackson.date; + +import java.io.IOException; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; + +public class CustomDateDeserializer extends StdDeserializer { + + private static final long serialVersionUID = -5451717385630622729L; + private SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy hh:mm:ss"); + + public CustomDateDeserializer() { + this(null); + } + + public CustomDateDeserializer(final Class vc) { + super(vc); + } + + @Override + public Date deserialize(final JsonParser jsonparser, final DeserializationContext context) throws IOException, JsonProcessingException { + final String date = jsonparser.getText(); + try { + return formatter.parse(date); + } catch (final ParseException e) { + throw new RuntimeException(e); + } + } + +} diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/date/CustomDateSerializer.java b/jackson-simple/src/test/java/com/baeldung/jackson/date/CustomDateSerializer.java new file mode 100644 index 0000000000..d840e1940f --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/date/CustomDateSerializer.java @@ -0,0 +1,29 @@ +package com.baeldung.jackson.date; + +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Date; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; + +public class CustomDateSerializer extends StdSerializer { + + private static final long serialVersionUID = -2894356342227378312L; + private SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy hh:mm:ss"); + + public CustomDateSerializer() { + this(null); + } + + public CustomDateSerializer(final Class t) { + super(t); + } + + @Override + public void serialize(final Date value, final JsonGenerator gen, final SerializerProvider arg2) throws IOException, JsonProcessingException { + gen.writeString(formatter.format(value)); + } +} diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/date/EventWithFormat.java b/jackson-simple/src/test/java/com/baeldung/jackson/date/EventWithFormat.java new file mode 100644 index 0000000000..607e694cef --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/date/EventWithFormat.java @@ -0,0 +1,29 @@ +package com.baeldung.jackson.date; + +import java.util.Date; + +import com.fasterxml.jackson.annotation.JsonFormat; + +public class EventWithFormat { + public String name; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy hh:mm:ss") + public Date eventDate; + + public EventWithFormat() { + super(); + } + + public EventWithFormat(final String name, final Date eventDate) { + this.name = name; + this.eventDate = eventDate; + } + + public Date getEventDate() { + return eventDate; + } + + public String getName() { + return name; + } +} diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/date/EventWithSerializer.java b/jackson-simple/src/test/java/com/baeldung/jackson/date/EventWithSerializer.java new file mode 100644 index 0000000000..c359b5c846 --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/date/EventWithSerializer.java @@ -0,0 +1,31 @@ +package com.baeldung.jackson.date; + +import java.util.Date; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + +public class EventWithSerializer { + public String name; + + @JsonDeserialize(using = CustomDateDeserializer.class) + @JsonSerialize(using = CustomDateSerializer.class) + public Date eventDate; + + public EventWithSerializer() { + super(); + } + + public EventWithSerializer(final String name, final Date eventDate) { + this.name = name; + this.eventDate = eventDate; + } + + public Date getEventDate() { + return eventDate; + } + + public String getName() { + return name; + } +} diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/deserialization/ItemDeserializerOnClass.java b/jackson-simple/src/test/java/com/baeldung/jackson/deserialization/ItemDeserializerOnClass.java new file mode 100644 index 0000000000..eaba9a7173 --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/deserialization/ItemDeserializerOnClass.java @@ -0,0 +1,41 @@ +package com.baeldung.jackson.deserialization; + +import java.io.IOException; + +import com.baeldung.jackson.dtos.ItemWithSerializer; +import com.baeldung.jackson.dtos.User; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.node.IntNode; + +public class ItemDeserializerOnClass extends StdDeserializer { + + private static final long serialVersionUID = 5579141241817332594L; + + public ItemDeserializerOnClass() { + this(null); + } + + public ItemDeserializerOnClass(final Class vc) { + super(vc); + } + + /** + * {"id":1,"itemNr":"theItem","owner":2} + */ + @Override + public ItemWithSerializer deserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { + final JsonNode node = jp.getCodec() + .readTree(jp); + final int id = (Integer) ((IntNode) node.get("id")).numberValue(); + final String itemName = node.get("itemName") + .asText(); + final int userId = (Integer) ((IntNode) node.get("owner")).numberValue(); + + return new ItemWithSerializer(id, itemName, new User(userId, null)); + } + +} \ No newline at end of file diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/dtos/Item.java b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/Item.java new file mode 100644 index 0000000000..6fce2bc88e --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/Item.java @@ -0,0 +1,32 @@ +package com.baeldung.jackson.dtos; + +public class Item { + public int id; + public String itemName; + public User owner; + + public Item() { + super(); + } + + public Item(final int id, final String itemName, final User owner) { + this.id = id; + this.itemName = itemName; + this.owner = owner; + } + + // API + + public int getId() { + return id; + } + + public String getItemName() { + return itemName; + } + + public User getOwner() { + return owner; + } + +} \ No newline at end of file diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/dtos/ItemWithSerializer.java b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/ItemWithSerializer.java new file mode 100644 index 0000000000..aea9aa770d --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/ItemWithSerializer.java @@ -0,0 +1,36 @@ +package com.baeldung.jackson.dtos; + +import com.baeldung.jackson.deserialization.ItemDeserializerOnClass; +import com.baeldung.jackson.serialization.ItemSerializerOnClass; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + +@JsonSerialize(using = ItemSerializerOnClass.class) +@JsonDeserialize(using = ItemDeserializerOnClass.class) +public class ItemWithSerializer { + public final int id; + public final String itemName; + public final User owner; + + public ItemWithSerializer(final int id, final String itemName, final User owner) { + this.id = id; + this.itemName = itemName; + this.owner = owner; + } + + // API + + public int getId() { + return id; + } + + public String getItemName() { + return itemName; + } + + public User getOwner() { + return owner; + } + +} \ No newline at end of file diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/dtos/MyDto.java b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/MyDto.java new file mode 100644 index 0000000000..49cf07baea --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/MyDto.java @@ -0,0 +1,54 @@ +package com.baeldung.jackson.dtos; + +public class MyDto { + + private String stringValue; + private int intValue; + private boolean booleanValue; + + public MyDto() { + super(); + } + + public MyDto(final String stringValue, final int intValue, final boolean booleanValue) { + super(); + + this.stringValue = stringValue; + this.intValue = intValue; + this.booleanValue = booleanValue; + } + + // API + + public String getStringValue() { + return stringValue; + } + + public void setStringValue(final String stringValue) { + this.stringValue = stringValue; + } + + public int getIntValue() { + return intValue; + } + + public void setIntValue(final int intValue) { + this.intValue = intValue; + } + + public boolean isBooleanValue() { + return booleanValue; + } + + public void setBooleanValue(final boolean booleanValue) { + this.booleanValue = booleanValue; + } + + // + + @Override + public String toString() { + return "MyDto [stringValue=" + stringValue + ", intValue=" + intValue + ", booleanValue=" + booleanValue + "]"; + } + +} diff --git a/jackson/src/test/java/com/baeldung/jackson/dtos/MyDtoFieldNameChanged.java b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/MyDtoFieldNameChanged.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/dtos/MyDtoFieldNameChanged.java rename to jackson-simple/src/test/java/com/baeldung/jackson/dtos/MyDtoFieldNameChanged.java diff --git a/jackson/src/test/java/com/baeldung/jackson/dtos/MyDtoIncludeNonDefault.java b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/MyDtoIncludeNonDefault.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/dtos/MyDtoIncludeNonDefault.java rename to jackson-simple/src/test/java/com/baeldung/jackson/dtos/MyDtoIncludeNonDefault.java diff --git a/jackson/src/test/java/com/baeldung/jackson/dtos/MyDtoNoAccessors.java b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/MyDtoNoAccessors.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/dtos/MyDtoNoAccessors.java rename to jackson-simple/src/test/java/com/baeldung/jackson/dtos/MyDtoNoAccessors.java diff --git a/jackson/src/test/java/com/baeldung/jackson/dtos/MyDtoNoAccessorsAndFieldVisibility.java b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/MyDtoNoAccessorsAndFieldVisibility.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/dtos/MyDtoNoAccessorsAndFieldVisibility.java rename to jackson-simple/src/test/java/com/baeldung/jackson/dtos/MyDtoNoAccessorsAndFieldVisibility.java diff --git a/jackson/src/test/java/com/baeldung/jackson/dtos/MyDtoWithFilter.java b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/MyDtoWithFilter.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/dtos/MyDtoWithFilter.java rename to jackson-simple/src/test/java/com/baeldung/jackson/dtos/MyDtoWithFilter.java diff --git a/jackson/src/test/java/com/baeldung/jackson/dtos/MyDtoWithSpecialField.java b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/MyDtoWithSpecialField.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/dtos/MyDtoWithSpecialField.java rename to jackson-simple/src/test/java/com/baeldung/jackson/dtos/MyDtoWithSpecialField.java diff --git a/jackson/src/test/java/com/baeldung/jackson/dtos/MyMixInForIgnoreType.java b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/MyMixInForIgnoreType.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/dtos/MyMixInForIgnoreType.java rename to jackson-simple/src/test/java/com/baeldung/jackson/dtos/MyMixInForIgnoreType.java diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/dtos/User.java b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/User.java new file mode 100644 index 0000000000..2418e8070d --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/User.java @@ -0,0 +1,26 @@ +package com.baeldung.jackson.dtos; + +public class User { + public int id; + public String name; + + public User() { + super(); + } + + public User(final int id, final String name) { + this.id = id; + this.name = name; + } + + // API + + public int getId() { + return id; + } + + public String getName() { + return name; + } + +} \ No newline at end of file diff --git a/jackson/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreField.java b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreField.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreField.java rename to jackson-simple/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreField.java diff --git a/jackson/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreFieldByName.java b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreFieldByName.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreFieldByName.java rename to jackson-simple/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreFieldByName.java diff --git a/jackson/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreNull.java b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreNull.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreNull.java rename to jackson-simple/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreNull.java diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/dtos/withEnum/DistanceEnumWithValue.java b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/withEnum/DistanceEnumWithValue.java new file mode 100644 index 0000000000..69c476d8a5 --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/withEnum/DistanceEnumWithValue.java @@ -0,0 +1,29 @@ +package com.baeldung.jackson.dtos.withEnum; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum DistanceEnumWithValue { + KILOMETER("km", 1000), MILE("miles", 1609.34), METER("meters", 1), INCH("inches", 0.0254), CENTIMETER("cm", 0.01), MILLIMETER("mm", 0.001); + + private String unit; + private final double meters; + + private DistanceEnumWithValue(String unit, double meters) { + this.unit = unit; + this.meters = meters; + } + + @JsonValue + public double getMeters() { + return meters; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + +} \ No newline at end of file diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/exception/UserWithRoot.java b/jackson-simple/src/test/java/com/baeldung/jackson/exception/UserWithRoot.java new file mode 100644 index 0000000000..d879c16e6a --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/exception/UserWithRoot.java @@ -0,0 +1,18 @@ +package com.baeldung.jackson.exception; + +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName(value = "user") +public class UserWithRoot { + public int id; + public String name; + + public UserWithRoot() { + super(); + } + + public UserWithRoot(final int id, final String name) { + this.id = id; + this.name = name; + } +} diff --git a/jackson/src/test/java/com/baeldung/jackson/exception/UserWithRootNamespace.java b/jackson-simple/src/test/java/com/baeldung/jackson/exception/UserWithRootNamespace.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/exception/UserWithRootNamespace.java rename to jackson-simple/src/test/java/com/baeldung/jackson/exception/UserWithRootNamespace.java diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/jsonview/Item.java b/jackson-simple/src/test/java/com/baeldung/jackson/jsonview/Item.java new file mode 100644 index 0000000000..26d20d4847 --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/jsonview/Item.java @@ -0,0 +1,36 @@ +package com.baeldung.jackson.jsonview; + +import com.fasterxml.jackson.annotation.JsonView; + +public class Item { + @JsonView(Views.Public.class) + public int id; + + @JsonView(Views.Public.class) + public String itemName; + + @JsonView(Views.Internal.class) + public String ownerName; + + public Item() { + super(); + } + + public Item(final int id, final String itemName, final String ownerName) { + this.id = id; + this.itemName = itemName; + this.ownerName = ownerName; + } + + public int getId() { + return id; + } + + public String getItemName() { + return itemName; + } + + public String getOwnerName() { + return ownerName; + } +} diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/jsonview/Views.java b/jackson-simple/src/test/java/com/baeldung/jackson/jsonview/Views.java new file mode 100644 index 0000000000..65950b7f9f --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/jsonview/Views.java @@ -0,0 +1,9 @@ +package com.baeldung.jackson.jsonview; + +public class Views { + public static class Public { + } + + public static class Internal extends Public { + } +} diff --git a/jackson/src/test/java/com/baeldung/jackson/objectmapper/CustomCarDeserializer.java b/jackson-simple/src/test/java/com/baeldung/jackson/objectmapper/CustomCarDeserializer.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/objectmapper/CustomCarDeserializer.java rename to jackson-simple/src/test/java/com/baeldung/jackson/objectmapper/CustomCarDeserializer.java diff --git a/jackson/src/test/java/com/baeldung/jackson/objectmapper/CustomCarSerializer.java b/jackson-simple/src/test/java/com/baeldung/jackson/objectmapper/CustomCarSerializer.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/objectmapper/CustomCarSerializer.java rename to jackson-simple/src/test/java/com/baeldung/jackson/objectmapper/CustomCarSerializer.java diff --git a/jackson/src/test/java/com/baeldung/jackson/objectmapper/JavaReadWriteJsonExampleUnitTest.java b/jackson-simple/src/test/java/com/baeldung/jackson/objectmapper/JavaReadWriteJsonExampleUnitTest.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/objectmapper/JavaReadWriteJsonExampleUnitTest.java rename to jackson-simple/src/test/java/com/baeldung/jackson/objectmapper/JavaReadWriteJsonExampleUnitTest.java diff --git a/jackson/src/test/java/com/baeldung/jackson/objectmapper/SerializationDeserializationFeatureUnitTest.java b/jackson-simple/src/test/java/com/baeldung/jackson/objectmapper/SerializationDeserializationFeatureUnitTest.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/objectmapper/SerializationDeserializationFeatureUnitTest.java rename to jackson-simple/src/test/java/com/baeldung/jackson/objectmapper/SerializationDeserializationFeatureUnitTest.java diff --git a/jackson/src/test/java/com/baeldung/jackson/objectmapper/dto/Car.java b/jackson-simple/src/test/java/com/baeldung/jackson/objectmapper/dto/Car.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/objectmapper/dto/Car.java rename to jackson-simple/src/test/java/com/baeldung/jackson/objectmapper/dto/Car.java diff --git a/jackson/src/test/java/com/baeldung/jackson/objectmapper/dto/Request.java b/jackson-simple/src/test/java/com/baeldung/jackson/objectmapper/dto/Request.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/objectmapper/dto/Request.java rename to jackson-simple/src/test/java/com/baeldung/jackson/objectmapper/dto/Request.java diff --git a/jackson/src/test/java/com/baeldung/jackson/serialization/ItemSerializer.java b/jackson-simple/src/test/java/com/baeldung/jackson/serialization/ItemSerializer.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/serialization/ItemSerializer.java rename to jackson-simple/src/test/java/com/baeldung/jackson/serialization/ItemSerializer.java diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/serialization/ItemSerializerOnClass.java b/jackson-simple/src/test/java/com/baeldung/jackson/serialization/ItemSerializerOnClass.java new file mode 100644 index 0000000000..1fdf44e17c --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/serialization/ItemSerializerOnClass.java @@ -0,0 +1,32 @@ +package com.baeldung.jackson.serialization; + +import java.io.IOException; + +import com.baeldung.jackson.dtos.ItemWithSerializer; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; + +public class ItemSerializerOnClass extends StdSerializer { + + private static final long serialVersionUID = -1760959597313610409L; + + public ItemSerializerOnClass() { + this(null); + } + + public ItemSerializerOnClass(final Class t) { + super(t); + } + + @Override + public final void serialize(final ItemWithSerializer value, final JsonGenerator jgen, final SerializerProvider provider) throws IOException, JsonProcessingException { + jgen.writeStartObject(); + jgen.writeNumberField("id", value.id); + jgen.writeStringField("itemName", value.itemName); + jgen.writeNumberField("owner", value.owner.id); + jgen.writeEndObject(); + } + +} \ No newline at end of file diff --git a/jackson/src/test/java/com/baeldung/jackson/serialization/MyDtoNullKeySerializer.java b/jackson-simple/src/test/java/com/baeldung/jackson/serialization/MyDtoNullKeySerializer.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/serialization/MyDtoNullKeySerializer.java rename to jackson-simple/src/test/java/com/baeldung/jackson/serialization/MyDtoNullKeySerializer.java diff --git a/jackson/src/test/java/com/baeldung/jackson/test/JacksonAnnotationUnitTest.java b/jackson-simple/src/test/java/com/baeldung/jackson/test/JacksonAnnotationUnitTest.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/test/JacksonAnnotationUnitTest.java rename to jackson-simple/src/test/java/com/baeldung/jackson/test/JacksonAnnotationUnitTest.java diff --git a/jackson/src/test/java/com/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java b/jackson-simple/src/test/java/com/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java rename to jackson-simple/src/test/java/com/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java diff --git a/jackson/src/test/java/com/baeldung/jackson/test/JacksonSerializationUnitTest.java b/jackson-simple/src/test/java/com/baeldung/jackson/test/JacksonSerializationUnitTest.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/test/JacksonSerializationUnitTest.java rename to jackson-simple/src/test/java/com/baeldung/jackson/test/JacksonSerializationUnitTest.java diff --git a/jackson-simple/src/test/resources/.gitignore b/jackson-simple/src/test/resources/.gitignore new file mode 100644 index 0000000000..83c05e60c8 --- /dev/null +++ b/jackson-simple/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.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/jackson/README.md b/jackson/README.md index eeb8f1b874..794ddc04d9 100644 --- a/jackson/README.md +++ b/jackson/README.md @@ -6,9 +6,7 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles: -- [Jackson Ignore Properties on Marshalling](http://www.baeldung.com/jackson-ignore-properties-on-serialization) - [Jackson – Unmarshall to Collection/Array](http://www.baeldung.com/jackson-collection-array) -- [Jackson Unmarshalling json with Unknown Properties](http://www.baeldung.com/jackson-deserialize-json-unknown-properties) - [Jackson – Custom Serializer](http://www.baeldung.com/jackson-custom-serialization) - [Getting Started with Custom Deserialization in Jackson](http://www.baeldung.com/jackson-deserialization) - [Jackson Exceptions – Problems and Solutions](http://www.baeldung.com/jackson-exception) @@ -17,10 +15,8 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Jackson JSON Tutorial](http://www.baeldung.com/jackson) - [Jackson – Working with Maps and nulls](http://www.baeldung.com/jackson-map-null-values-or-null-key) - [Jackson – Decide What Fields Get Serialized/Deserialized](http://www.baeldung.com/jackson-field-serializable-deserializable-or-not) -- [Jackson Annotation Examples](http://www.baeldung.com/jackson-annotations) - [Working with Tree Model Nodes in Jackson](http://www.baeldung.com/jackson-json-node-tree-model) - [Jackson vs Gson](http://www.baeldung.com/jackson-vs-gson) -- [Intro to the Jackson ObjectMapper](http://www.baeldung.com/jackson-object-mapper-tutorial) - [XML Serialization and Deserialization with Jackson](http://www.baeldung.com/jackson-xml-serialization-and-deserialization) - [More Jackson Annotations](http://www.baeldung.com/jackson-advanced-annotations) - [Inheritance with Jackson](http://www.baeldung.com/jackson-inheritance) @@ -31,9 +27,7 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Jackson – JsonMappingException (No serializer found for class)](http://www.baeldung.com/jackson-jsonmappingexception) - [How To Serialize Enums as JSON Objects with Jackson](http://www.baeldung.com/jackson-serialize-enums) - [Jackson – Marshall String to JsonNode](http://www.baeldung.com/jackson-json-to-jsonnode) -- [Ignore Null Fields with Jackson](http://www.baeldung.com/jackson-ignore-null-fields) - [Jackson – Unmarshall to Collection/Array](http://www.baeldung.com/jackson-collection-array) -- [Jackson – Change Name of Field](http://www.baeldung.com/jackson-name-of-property) - [Serialize Only Fields that meet a Custom Criteria with Jackson](http://www.baeldung.com/jackson-serialize-field-custom-criteria) - [Mapping Nested Values with Jackson](http://www.baeldung.com/jackson-nested-values) - [Convert XML to JSON Using Jackson](https://www.baeldung.com/jackson-convert-xml-json) diff --git a/jackson/src/test/java/com/baeldung/jackson/test/UnitTestSuite.java b/jackson/src/test/java/com/baeldung/jackson/test/UnitTestSuite.java index 6be2f29baa..e783c67f5b 100644 --- a/jackson/src/test/java/com/baeldung/jackson/test/UnitTestSuite.java +++ b/jackson/src/test/java/com/baeldung/jackson/test/UnitTestSuite.java @@ -12,8 +12,6 @@ import org.junit.runners.Suite; ,JacksonDeserializationUnitTest.class ,JacksonDeserializationUnitTest.class ,JacksonPrettyPrintUnitTest.class - ,JacksonSerializationIgnoreUnitTest.class - ,JacksonSerializationUnitTest.class ,SandboxUnitTest.class ,JacksonFieldUnitTest.class }) // @formatter:on diff --git a/pom.xml b/pom.xml index d57fa1694e..0559985fca 100644 --- a/pom.xml +++ b/pom.xml @@ -443,6 +443,7 @@ jackson jackson-2 + jackson-simple java-collections-conversions java-collections-maps java-collections-maps-2 @@ -1101,6 +1102,7 @@ jackson jackson-2 + jackson-simple java-collections-conversions java-collections-maps java-collections-maps-2 From 5a3d6a0c518ebf57910fa677c0d986db590b3118 Mon Sep 17 00:00:00 2001 From: josephine-barboza Date: Sun, 14 Apr 2019 22:56:48 +0530 Subject: [PATCH 203/531] BAEL-2766 Added more asserts to add items to map --- core-groovy/src/test/groovy/com/baeldung/map/MapTest.groovy | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core-groovy/src/test/groovy/com/baeldung/map/MapTest.groovy b/core-groovy/src/test/groovy/com/baeldung/map/MapTest.groovy index 8bd9302412..f1d528207f 100644 --- a/core-groovy/src/test/groovy/com/baeldung/map/MapTest.groovy +++ b/core-groovy/src/test/groovy/com/baeldung/map/MapTest.groovy @@ -31,7 +31,9 @@ class MapTest{ map.putAll(hobbyMap) assertTrue(map == [name:"Jerry", age: 42, city: "New York", hobby:"Singing"]) - + assertTrue(hobbyMap.hobby == "Singing") + assertTrue(hobbyMap[hobbyLiteral] == "Singing") + map.plus([1:20]) // returns new map map << [2:30] @@ -143,4 +145,4 @@ class MapTest{ } -} \ No newline at end of file +} From 4d5d647e712f105151e9c58326ea7132e80a7bed Mon Sep 17 00:00:00 2001 From: amit2103 Date: Sun, 14 Apr 2019 23:34:23 +0530 Subject: [PATCH 204/531] [BAEL-14089] - Removed PostRestApplication main class and adjusted configuration --- spring-boot-rest/pom.xml | 2 +- .../baeldung/SpringBootRestApplication.java | 9 ++++++++- .../baeldung/modelmapper/PostApplication.java | 20 ------------------- .../baeldung/spring/PersistenceConfig.java | 6 +++--- 4 files changed, 12 insertions(+), 25 deletions(-) delete mode 100644 spring-boot-rest/src/main/java/com/baeldung/modelmapper/PostApplication.java diff --git a/spring-boot-rest/pom.xml b/spring-boot-rest/pom.xml index a7ba67d92a..2bf7c0181f 100644 --- a/spring-boot-rest/pom.xml +++ b/spring-boot-rest/pom.xml @@ -83,6 +83,6 @@ com.baeldung.SpringBootRestApplication 27.0.1-jre 1.4.11.1 - 2.3.2 + 2.3.3 diff --git a/spring-boot-rest/src/main/java/com/baeldung/SpringBootRestApplication.java b/spring-boot-rest/src/main/java/com/baeldung/SpringBootRestApplication.java index d0976d9ddd..1c0d0d19e8 100644 --- a/spring-boot-rest/src/main/java/com/baeldung/SpringBootRestApplication.java +++ b/spring-boot-rest/src/main/java/com/baeldung/SpringBootRestApplication.java @@ -1,13 +1,20 @@ package com.baeldung; +import org.modelmapper.ModelMapper; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; -@SpringBootApplication(scanBasePackages = {"com.baeldung.persistence", "com.baeldung.spring", "com.baeldung.web" }) +@SpringBootApplication public class SpringBootRestApplication { public static void main(String[] args) { SpringApplication.run(SpringBootRestApplication.class, args); } + + @Bean + public ModelMapper modelMapper() { + return new ModelMapper(); + } } diff --git a/spring-boot-rest/src/main/java/com/baeldung/modelmapper/PostApplication.java b/spring-boot-rest/src/main/java/com/baeldung/modelmapper/PostApplication.java deleted file mode 100644 index 7684c43648..0000000000 --- a/spring-boot-rest/src/main/java/com/baeldung/modelmapper/PostApplication.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.baeldung.modelmapper; - -import org.modelmapper.ModelMapper; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; - -@SpringBootApplication -public class PostApplication { - - public static void main(String[] args) { - SpringApplication.run(PostApplication.class, args); - } - - @Bean - public ModelMapper modelMapper() { - return new ModelMapper(); - } - -} diff --git a/spring-boot-rest/src/main/java/com/baeldung/spring/PersistenceConfig.java b/spring-boot-rest/src/main/java/com/baeldung/spring/PersistenceConfig.java index 5179c66978..2e967751ad 100644 --- a/spring-boot-rest/src/main/java/com/baeldung/spring/PersistenceConfig.java +++ b/spring-boot-rest/src/main/java/com/baeldung/spring/PersistenceConfig.java @@ -24,8 +24,8 @@ import com.google.common.base.Preconditions; @Configuration @EnableTransactionManagement @PropertySource({ "classpath:persistence-${envTarget:h2}.properties" }) -@ComponentScan({ "com.baeldung.persistence" }) -@EnableJpaRepositories(basePackages = "com.baeldung.persistence.dao") +@ComponentScan(basePackages = { "com.baeldung.persistence", "com.baeldung.modelmapper" }) +@EnableJpaRepositories(basePackages = {"com.baeldung.persistence.dao", "com.baeldung.modelmapper.repository"}) public class PersistenceConfig { @Autowired @@ -39,7 +39,7 @@ public class PersistenceConfig { public LocalContainerEntityManagerFactoryBean entityManagerFactory() { final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource()); - em.setPackagesToScan(new String[] { "com.baeldung.persistence.model" }); + em.setPackagesToScan(new String[] { "com.baeldung.persistence.model", "com.baeldung.modelmapper.model" }); final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); // vendorAdapter.set From 10897b14b87cda2cc87c3ff214b8f3c24aa2095b Mon Sep 17 00:00:00 2001 From: amit2103 Date: Mon, 15 Apr 2019 00:05:03 +0530 Subject: [PATCH 205/531] [BAEL-14088] - Moved interceptop, rest config and live test back to spring-rest module --- .../sampleapp}/config/RestClientConfig.java | 4 +-- ...RestTemplateHeaderModifierInterceptor.java | 2 +- .../java/com/baeldung/transfer/LoginForm.java | 31 +++++++++++++++++++ .../resttemplate/RestTemplateLiveTest.java | 2 +- 4 files changed, 35 insertions(+), 4 deletions(-) rename {spring-boot-rest/src/main/java/com/baeldung => spring-rest/src/main/java/com/baeldung/sampleapp}/config/RestClientConfig.java (85%) rename {spring-boot-rest/src/main/java/com/baeldung => spring-rest/src/main/java/com/baeldung/sampleapp}/interceptors/RestTemplateHeaderModifierInterceptor.java (91%) create mode 100644 spring-rest/src/main/java/com/baeldung/transfer/LoginForm.java rename {spring-boot-rest => spring-rest}/src/test/java/com/baeldung/resttemplate/RestTemplateLiveTest.java (96%) diff --git a/spring-boot-rest/src/main/java/com/baeldung/config/RestClientConfig.java b/spring-rest/src/main/java/com/baeldung/sampleapp/config/RestClientConfig.java similarity index 85% rename from spring-boot-rest/src/main/java/com/baeldung/config/RestClientConfig.java rename to spring-rest/src/main/java/com/baeldung/sampleapp/config/RestClientConfig.java index 9d21e0f785..8abc368bdb 100644 --- a/spring-boot-rest/src/main/java/com/baeldung/config/RestClientConfig.java +++ b/spring-rest/src/main/java/com/baeldung/sampleapp/config/RestClientConfig.java @@ -1,4 +1,4 @@ -package com.baeldung.config; +package com.baeldung.sampleapp.config; import java.util.ArrayList; import java.util.List; @@ -9,7 +9,7 @@ import org.springframework.http.client.ClientHttpRequestInterceptor; import org.springframework.util.CollectionUtils; import org.springframework.web.client.RestTemplate; -import com.baeldung.interceptors.RestTemplateHeaderModifierInterceptor; +import com.baeldung.sampleapp.interceptors.RestTemplateHeaderModifierInterceptor; @Configuration public class RestClientConfig { diff --git a/spring-boot-rest/src/main/java/com/baeldung/interceptors/RestTemplateHeaderModifierInterceptor.java b/spring-rest/src/main/java/com/baeldung/sampleapp/interceptors/RestTemplateHeaderModifierInterceptor.java similarity index 91% rename from spring-boot-rest/src/main/java/com/baeldung/interceptors/RestTemplateHeaderModifierInterceptor.java rename to spring-rest/src/main/java/com/baeldung/sampleapp/interceptors/RestTemplateHeaderModifierInterceptor.java index 9402980926..519e5ebf0d 100644 --- a/spring-boot-rest/src/main/java/com/baeldung/interceptors/RestTemplateHeaderModifierInterceptor.java +++ b/spring-rest/src/main/java/com/baeldung/sampleapp/interceptors/RestTemplateHeaderModifierInterceptor.java @@ -1,4 +1,4 @@ -package com.baeldung.interceptors; +package com.baeldung.sampleapp.interceptors; import java.io.IOException; diff --git a/spring-rest/src/main/java/com/baeldung/transfer/LoginForm.java b/spring-rest/src/main/java/com/baeldung/transfer/LoginForm.java new file mode 100644 index 0000000000..caafcdb500 --- /dev/null +++ b/spring-rest/src/main/java/com/baeldung/transfer/LoginForm.java @@ -0,0 +1,31 @@ +package com.baeldung.transfer; + +public class LoginForm { + private String username; + private String password; + + public LoginForm() { + } + + public LoginForm(String username, String password) { + super(); + this.username = username; + this.password = password; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } +} \ No newline at end of file diff --git a/spring-boot-rest/src/test/java/com/baeldung/resttemplate/RestTemplateLiveTest.java b/spring-rest/src/test/java/com/baeldung/resttemplate/RestTemplateLiveTest.java similarity index 96% rename from spring-boot-rest/src/test/java/com/baeldung/resttemplate/RestTemplateLiveTest.java rename to spring-rest/src/test/java/com/baeldung/resttemplate/RestTemplateLiveTest.java index d0ae521837..8db31fd0a7 100644 --- a/spring-boot-rest/src/test/java/com/baeldung/resttemplate/RestTemplateLiveTest.java +++ b/spring-rest/src/test/java/com/baeldung/resttemplate/RestTemplateLiveTest.java @@ -16,7 +16,7 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.web.client.RestTemplate; -import com.baeldung.config.RestClientConfig; +import com.baeldung.sampleapp.config.RestClientConfig; import com.baeldung.transfer.LoginForm; @RunWith(SpringJUnit4ClassRunner.class) From d0a6c5701a6cadc509d92ede72957a8e170b2994 Mon Sep 17 00:00:00 2001 From: Anshul Bansal Date: Sun, 14 Apr 2019 22:02:14 +0300 Subject: [PATCH 206/531] BAEL-2661 - Groovy def keyword --- core-groovy-2/README.md | 5 + core-groovy-2/pom.xml | 123 ++++++++++++++++++ .../baeldung/defkeyword/DefUnitTest.groovy | 73 +++++++++++ pom.xml | 2 + 4 files changed, 203 insertions(+) create mode 100644 core-groovy-2/README.md create mode 100644 core-groovy-2/pom.xml create mode 100644 core-groovy-2/src/test/groovy/com/baeldung/defkeyword/DefUnitTest.groovy diff --git a/core-groovy-2/README.md b/core-groovy-2/README.md new file mode 100644 index 0000000000..0aed5602ab --- /dev/null +++ b/core-groovy-2/README.md @@ -0,0 +1,5 @@ +# Groovy + +## Relevant articles: + +- [Groovy def Keyword] diff --git a/core-groovy-2/pom.xml b/core-groovy-2/pom.xml new file mode 100644 index 0000000000..68382e613b --- /dev/null +++ b/core-groovy-2/pom.xml @@ -0,0 +1,123 @@ + + + 4.0.0 + core-groovy-2 + 1.0-SNAPSHOT + core-groovy-2 + jar + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + + org.codehaus.groovy + groovy + ${groovy.version} + + + org.codehaus.groovy + groovy-all + ${groovy-all.version} + pom + + + org.codehaus.groovy + groovy-dateutil + ${groovy.version} + + + org.codehaus.groovy + groovy-sql + ${groovy-sql.version} + + + org.junit.platform + junit-platform-runner + ${junit.platform.version} + test + + + org.hsqldb + hsqldb + ${hsqldb.version} + test + + + org.spockframework + spock-core + ${spock-core.version} + test + + + + + + + org.codehaus.gmavenplus + gmavenplus-plugin + ${gmavenplus-plugin.version} + + + + addSources + addTestSources + compile + compileTests + + + + + + maven-failsafe-plugin + ${maven-failsafe-plugin.version} + + + org.junit.platform + junit-platform-surefire-provider + ${junit.platform.version} + + + + + junit5 + + integration-test + verify + + + + **/*Test5.java + + + + + + + + + + + central + http://jcenter.bintray.com + + + + + 1.0.0 + + + + 2.5.6 + 2.5.6 + 2.5.6 + 2.4.0 + 1.1-groovy-2.4 + 1.6 + + + diff --git a/core-groovy-2/src/test/groovy/com/baeldung/defkeyword/DefUnitTest.groovy b/core-groovy-2/src/test/groovy/com/baeldung/defkeyword/DefUnitTest.groovy new file mode 100644 index 0000000000..baab7455a5 --- /dev/null +++ b/core-groovy-2/src/test/groovy/com/baeldung/defkeyword/DefUnitTest.groovy @@ -0,0 +1,73 @@ +package com.baeldung.defkeyword + +import org.codehaus.groovy.runtime.NullObject +import org.codehaus.groovy.runtime.typehandling.GroovyCastException + +import groovy.transform.TypeChecked +import groovy.transform.TypeCheckingMode + +@TypeChecked +class DefUnitTest extends GroovyTestCase { + + def id + def firstName = "Samwell" + def listOfCountries = ['USA', 'UK', 'FRANCE', 'INDIA'] + + @TypeChecked(TypeCheckingMode.SKIP) + def multiply(x, y) { + return x*y + } + + @TypeChecked(TypeCheckingMode.SKIP) + void testDef() { + + def list + assert list.getClass() == org.codehaus.groovy.runtime.NullObject + assert list.is(null) + + list = [1,2,4] + assert list instanceof ArrayList + + int sum = 200 + try { + sum = [12] //GroovyCastException + sum = "nill" //GroovyCastException + } catch(GroovyCastException) { + println "Cannot assign anything other than integer" + } + + def rate + assert rate == null + assert rate.getClass() == org.codehaus.groovy.runtime.NullObject + + rate = 12 + assert rate instanceof Integer + + rate = "Not Available" + assert rate instanceof String + + rate = [1, 4] + assert rate instanceof List + + assert divide(12, 3) instanceof BigDecimal + assert divide(1, 0) instanceof String + + } + + def divide(int x, int y) { + if(y==0) { + return "Should not divide by 0" + } else { + return x/y + } + } + + def greetMsg() { + println "Hello! I am Groovy" + } + + void testDefVsType() { + def int count + assert count instanceof Integer + } +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index bdd8403231..8746f8492b 100644 --- a/pom.xml +++ b/pom.xml @@ -376,6 +376,7 @@ cdi checker-plugin core-groovy + core-groovy-2 @@ -1034,6 +1035,7 @@ cdi checker-plugin core-groovy + core-groovy-2 core-java-8 From 14bf329f9f6f098710809a2acd78977ab5889a3c Mon Sep 17 00:00:00 2001 From: Kevin Wittek Date: Sun, 14 Apr 2019 21:49:50 +0200 Subject: [PATCH 207/531] BAEL-2771 Add String matching example to core-groovy (#6726) --- .../strings/StringMatchingSpec.groovy | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 core-groovy/src/test/groovy/com/baeldung/strings/StringMatchingSpec.groovy diff --git a/core-groovy/src/test/groovy/com/baeldung/strings/StringMatchingSpec.groovy b/core-groovy/src/test/groovy/com/baeldung/strings/StringMatchingSpec.groovy new file mode 100644 index 0000000000..3865bc73fa --- /dev/null +++ b/core-groovy/src/test/groovy/com/baeldung/strings/StringMatchingSpec.groovy @@ -0,0 +1,44 @@ +package com.baeldung.strings + +import spock.lang.Specification + +import java.util.regex.Pattern + +class StringMatchingSpec extends Specification { + + def "pattern operator example"() { + given: "a pattern" + def p = ~'foo' + + expect: + p instanceof Pattern + + and: "you can use slash strings to avoid escaping of blackslash" + def digitPattern = ~/\d*/ + digitPattern.matcher('4711').matches() + } + + def "match operator example"() { + expect: + 'foobar' ==~ /.*oba.*/ + + and: "matching is strict" + !('foobar' ==~ /foo/) + } + + def "find operator example"() { + when: "using the find operator" + def matcher = 'foo and bar, baz and buz' =~ /(\w+) and (\w+)/ + + then: "will find groups" + matcher.size() == 2 + + and: "can access groups using array" + matcher[0][0] == 'foo and bar' + matcher[1][2] == 'buz' + + and: "you can use it as a predicate" + 'foobarbaz' =~ /bar/ + } + +} From 2cc1de2e39034bf9d22e9c88b13f0252a141e254 Mon Sep 17 00:00:00 2001 From: FrancoCorleone Date: Sun, 14 Apr 2019 22:10:01 +0200 Subject: [PATCH 208/531] [BAEL-2842] SQL JOINS (#6718) --- .../core-java-persistence/pom.xml | 18 ++-- .../jdbc/joins/ArticleWithAuthor.java | 41 +++++++++ .../jdbc/joins/ArticleWithAuthorDAO.java | 61 +++++++++++++ .../ArticleWithAuthorDAOIntegrationTest.java | 89 +++++++++++++++++++ 4 files changed, 204 insertions(+), 5 deletions(-) create mode 100644 persistence-modules/core-java-persistence/src/main/java/com/baeldung/jdbc/joins/ArticleWithAuthor.java create mode 100644 persistence-modules/core-java-persistence/src/main/java/com/baeldung/jdbc/joins/ArticleWithAuthorDAO.java create mode 100644 persistence-modules/core-java-persistence/src/test/java/com/baeldung/jdbc/joins/ArticleWithAuthorDAOIntegrationTest.java diff --git a/persistence-modules/core-java-persistence/pom.xml b/persistence-modules/core-java-persistence/pom.xml index a777eeb73f..2ad2083fec 100644 --- a/persistence-modules/core-java-persistence/pom.xml +++ b/persistence-modules/core-java-persistence/pom.xml @@ -6,15 +6,21 @@ 0.1.0-SNAPSHOT core-java-persistence jar - + com.baeldung parent-java 0.0.1-SNAPSHOT ../../parent-java - + + + org.postgresql + postgresql + ${postgresql.version} + test + org.assertj assertj-core @@ -52,7 +58,7 @@ ${springframework.boot.spring-boot-starter.version} - + core-java-persistence @@ -62,8 +68,10 @@ - + + 42.2.5.jre7 + 8.0.15 3.10.0 1.4.197 2.4.0 @@ -72,5 +80,5 @@ 1.5.8.RELEASE 4.3.4.RELEASE - + \ No newline at end of file diff --git a/persistence-modules/core-java-persistence/src/main/java/com/baeldung/jdbc/joins/ArticleWithAuthor.java b/persistence-modules/core-java-persistence/src/main/java/com/baeldung/jdbc/joins/ArticleWithAuthor.java new file mode 100644 index 0000000000..5ce196ee47 --- /dev/null +++ b/persistence-modules/core-java-persistence/src/main/java/com/baeldung/jdbc/joins/ArticleWithAuthor.java @@ -0,0 +1,41 @@ +package com.baeldung.jdbc.joins; + +class ArticleWithAuthor { + + private String title; + + private String authorFirstName; + + private String authorLastName; + + public ArticleWithAuthor(String title, String authorFirstName, String authorLastName) { + this.title = title; + this.authorFirstName = authorFirstName; + this.authorLastName = authorLastName; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getAuthorFirstName() { + return authorFirstName; + } + + public void setAuthorFirstName(String authorFirstName) { + this.authorFirstName = authorFirstName; + } + + public String getAuthorLastName() { + return authorLastName; + } + + public void setAuthorLastName(String authorLastName) { + this.authorLastName = authorLastName; + } + +} diff --git a/persistence-modules/core-java-persistence/src/main/java/com/baeldung/jdbc/joins/ArticleWithAuthorDAO.java b/persistence-modules/core-java-persistence/src/main/java/com/baeldung/jdbc/joins/ArticleWithAuthorDAO.java new file mode 100644 index 0000000000..55f03d99ec --- /dev/null +++ b/persistence-modules/core-java-persistence/src/main/java/com/baeldung/jdbc/joins/ArticleWithAuthorDAO.java @@ -0,0 +1,61 @@ +package com.baeldung.jdbc.joins; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.List; + +class ArticleWithAuthorDAO { + + private static final String QUERY_TEMPLATE = "SELECT ARTICLE.TITLE, AUTHOR.LAST_NAME, AUTHOR.FIRST_NAME FROM ARTICLE %s AUTHOR ON AUTHOR.id=ARTICLE.AUTHOR_ID"; + private final Connection connection; + + ArticleWithAuthorDAO(Connection connection) { + this.connection = connection; + } + + List articleInnerJoinAuthor() { + String query = String.format(QUERY_TEMPLATE, "INNER JOIN"); + return executeQuery(query); + } + + List articleLeftJoinAuthor() { + String query = String.format(QUERY_TEMPLATE, "LEFT JOIN"); + return executeQuery(query); + } + + List articleRightJoinAuthor() { + String query = String.format(QUERY_TEMPLATE, "RIGHT JOIN"); + return executeQuery(query); + } + + List articleFullJoinAuthor() { + String query = String.format(QUERY_TEMPLATE, "FULL JOIN"); + return executeQuery(query); + } + + private List executeQuery(String query) { + try (Statement statement = connection.createStatement()) { + ResultSet resultSet = statement.executeQuery(query); + return mapToList(resultSet); + } catch (SQLException e) { + e.printStackTrace(); + } + return null; + } + + private List mapToList(ResultSet resultSet) throws SQLException { + List list = new ArrayList<>(); + while (resultSet.next()) { + ArticleWithAuthor articleWithAuthor = new ArticleWithAuthor( + resultSet.getString("TITLE"), + resultSet.getString("FIRST_NAME"), + resultSet.getString("LAST_NAME") + ); + list.add(articleWithAuthor); + } + return list; + } +} diff --git a/persistence-modules/core-java-persistence/src/test/java/com/baeldung/jdbc/joins/ArticleWithAuthorDAOIntegrationTest.java b/persistence-modules/core-java-persistence/src/test/java/com/baeldung/jdbc/joins/ArticleWithAuthorDAOIntegrationTest.java new file mode 100644 index 0000000000..5c20b6bf1e --- /dev/null +++ b/persistence-modules/core-java-persistence/src/test/java/com/baeldung/jdbc/joins/ArticleWithAuthorDAOIntegrationTest.java @@ -0,0 +1,89 @@ +package com.baeldung.jdbc.joins; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +public class ArticleWithAuthorDAOIntegrationTest { + private Connection connection; + + private ArticleWithAuthorDAO articleWithAuthorDAO; + + @Before + public void setup() throws ClassNotFoundException, SQLException { + Class.forName("org.postgresql.Driver"); + connection = DriverManager.getConnection("jdbc:postgresql://localhost:5432/myDb", "user", "pass"); + articleWithAuthorDAO = new ArticleWithAuthorDAO(connection); + Statement statement = connection.createStatement(); + String createAuthorSql = "CREATE TABLE IF NOT EXISTS AUTHOR (ID int NOT NULL PRIMARY KEY, FIRST_NAME varchar(255), LAST_NAME varchar(255));"; + String createArticleSql = "CREATE TABLE IF NOT EXISTS ARTICLE (ID int NOT NULL PRIMARY KEY, TITLE varchar(255) NOT NULL, AUTHOR_ID int, FOREIGN KEY(AUTHOR_ID) REFERENCES AUTHOR(ID));"; + statement.execute(createAuthorSql); + statement.execute(createArticleSql); + + insertTestData(statement); + } + + @Test + public void whenQueryWithInnerJoin_thenShouldReturnProperRows() { + List articleWithAuthorList = articleWithAuthorDAO.articleInnerJoinAuthor(); + + assertThat(articleWithAuthorList).hasSize(4); + assertThat(articleWithAuthorList).noneMatch(row -> row.getAuthorFirstName() == null || row.getTitle() == null); + } + + @Test + public void whenQueryWithLeftJoin_thenShouldReturnProperRows() { + List articleWithAuthorList = articleWithAuthorDAO.articleLeftJoinAuthor(); + + assertThat(articleWithAuthorList).hasSize(5); + assertThat(articleWithAuthorList).anyMatch(row -> row.getAuthorFirstName() == null); + } + + @Test + public void whenQueryWithRightJoin_thenShouldReturnProperRows() { + List articleWithAuthorList = articleWithAuthorDAO.articleRightJoinAuthor(); + + assertThat(articleWithAuthorList).hasSize(5); + assertThat(articleWithAuthorList).anyMatch(row -> row.getTitle() == null); + } + + @Test + public void whenQueryWithFullJoin_thenShouldReturnProperRows() { + List articleWithAuthorList = articleWithAuthorDAO.articleFullJoinAuthor(); + + assertThat(articleWithAuthorList).hasSize(6); + assertThat(articleWithAuthorList).anyMatch(row -> row.getTitle() == null); + assertThat(articleWithAuthorList).anyMatch(row -> row.getAuthorFirstName() == null); + } + + @After + public void cleanup() throws SQLException { + connection.createStatement().execute("DROP TABLE ARTICLE"); + connection.createStatement().execute("DROP TABLE AUTHOR"); + connection.close(); + } + + public void insertTestData(Statement statement) throws SQLException { + String insertAuthors = "INSERT INTO AUTHOR VALUES " + + "(1, 'Siena', 'Kerr')," + + "(2, 'Daniele', 'Ferguson')," + + "(3, 'Luciano', 'Wise')," + + "(4, 'Jonas', 'Lugo');"; + String insertArticles = "INSERT INTO ARTICLE VALUES " + + "(1, 'First steps in Java', 1)," + + "(2, 'SpringBoot tutorial', 1)," + + "(3, 'Java 12 insights', null)," + + "(4, 'SQL JOINS', 2)," + + "(5, 'Introduction to Spring Security', 3);"; + statement.execute(insertAuthors); + statement.execute(insertArticles); + } +} From 532c5f28a3bdb3bc0a90fa59b1f8060fa293a5cd Mon Sep 17 00:00:00 2001 From: DOHA Date: Mon, 15 Apr 2019 00:39:36 +0200 Subject: [PATCH 209/531] move generic constructor code --- .../src/main/java/com/baeldung/generics/Entry.java | 0 .../src/main/java/com/baeldung/generics/GenericEntry.java | 0 .../src/main/java/com/baeldung/generics/MapEntry.java | 0 .../src/main/java/com/baeldung/generics/Product.java | 0 .../src/main/java/com/baeldung/generics/Rankable.java | 0 .../java/com/baeldung/generics/GenericConstructorUnitTest.java | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename {core-java-lang-syntax => core-java-lang-oop-2}/src/main/java/com/baeldung/generics/Entry.java (100%) rename {core-java-lang-syntax => core-java-lang-oop-2}/src/main/java/com/baeldung/generics/GenericEntry.java (100%) rename {core-java-lang-syntax => core-java-lang-oop-2}/src/main/java/com/baeldung/generics/MapEntry.java (100%) rename {core-java-lang-syntax => core-java-lang-oop-2}/src/main/java/com/baeldung/generics/Product.java (100%) rename {core-java-lang-syntax => core-java-lang-oop-2}/src/main/java/com/baeldung/generics/Rankable.java (100%) rename {core-java-lang-syntax => core-java-lang-oop-2}/src/test/java/com/baeldung/generics/GenericConstructorUnitTest.java (100%) diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/generics/Entry.java b/core-java-lang-oop-2/src/main/java/com/baeldung/generics/Entry.java similarity index 100% rename from core-java-lang-syntax/src/main/java/com/baeldung/generics/Entry.java rename to core-java-lang-oop-2/src/main/java/com/baeldung/generics/Entry.java diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/generics/GenericEntry.java b/core-java-lang-oop-2/src/main/java/com/baeldung/generics/GenericEntry.java similarity index 100% rename from core-java-lang-syntax/src/main/java/com/baeldung/generics/GenericEntry.java rename to core-java-lang-oop-2/src/main/java/com/baeldung/generics/GenericEntry.java diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/generics/MapEntry.java b/core-java-lang-oop-2/src/main/java/com/baeldung/generics/MapEntry.java similarity index 100% rename from core-java-lang-syntax/src/main/java/com/baeldung/generics/MapEntry.java rename to core-java-lang-oop-2/src/main/java/com/baeldung/generics/MapEntry.java diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/generics/Product.java b/core-java-lang-oop-2/src/main/java/com/baeldung/generics/Product.java similarity index 100% rename from core-java-lang-syntax/src/main/java/com/baeldung/generics/Product.java rename to core-java-lang-oop-2/src/main/java/com/baeldung/generics/Product.java diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/generics/Rankable.java b/core-java-lang-oop-2/src/main/java/com/baeldung/generics/Rankable.java similarity index 100% rename from core-java-lang-syntax/src/main/java/com/baeldung/generics/Rankable.java rename to core-java-lang-oop-2/src/main/java/com/baeldung/generics/Rankable.java diff --git a/core-java-lang-syntax/src/test/java/com/baeldung/generics/GenericConstructorUnitTest.java b/core-java-lang-oop-2/src/test/java/com/baeldung/generics/GenericConstructorUnitTest.java similarity index 100% rename from core-java-lang-syntax/src/test/java/com/baeldung/generics/GenericConstructorUnitTest.java rename to core-java-lang-oop-2/src/test/java/com/baeldung/generics/GenericConstructorUnitTest.java From 3ae6a124f0e36eb3f9aaee982bf63e927ea858c7 Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Mon, 15 Apr 2019 11:04:54 +0400 Subject: [PATCH 210/531] JODA INSTANT to millis --- .../main/java/com/baeldung/convert/ConvertDateTime.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/java-dates/src/main/java/com/baeldung/convert/ConvertDateTime.java b/java-dates/src/main/java/com/baeldung/convert/ConvertDateTime.java index d52dd1b989..d13075e063 100644 --- a/java-dates/src/main/java/com/baeldung/convert/ConvertDateTime.java +++ b/java-dates/src/main/java/com/baeldung/convert/ConvertDateTime.java @@ -1,5 +1,7 @@ package com.baeldung.convert; +import org.joda.time.Instant; + import java.text.ParseException; import java.text.SimpleDateFormat; import java.time.LocalDateTime; @@ -35,9 +37,12 @@ public class ConvertDateTime { } private static void joda() { - org.joda.time.DateTime jodaDateTime = new org.joda.time.DateTime(new Date()); + org.joda.time.DateTime jodaDateTime = new org.joda.time.DateTime(); long delta = jodaDateTime.getMillis(); System.out.println("Joda - Time in milliseconds : " + delta); + + Instant jodaInstant = Instant.now(); + System.out.println("Joda - Instant in milliseconds : " + jodaInstant.getMillis()); } private static void java8() { From 6796ec3af7777ca85d58c22045a54ddbd6b2f2b7 Mon Sep 17 00:00:00 2001 From: dionisPrifti Date: Mon, 15 Apr 2019 18:56:10 +0200 Subject: [PATCH 211/531] BAEL-2810: Finished the examples and unit tests. (#6732) --- .../baeldung/datajpadelete/entity/Book.java | 51 +++++++++++++ .../datajpadelete/entity/Category.java | 60 ++++++++++++++++ .../repository/BookRepository.java | 19 +++++ .../repository/CategoryRepository.java | 9 +++ .../DeleteFromRepositoryUnitTest.java | 72 +++++++++++++++++++ .../DeleteInRelationshipsUnitTest.java | 60 ++++++++++++++++ 6 files changed, 271 insertions(+) create mode 100644 persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/datajpadelete/entity/Book.java create mode 100644 persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/datajpadelete/entity/Category.java create mode 100644 persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/datajpadelete/repository/BookRepository.java create mode 100644 persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/datajpadelete/repository/CategoryRepository.java create mode 100644 persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/datajpadelete/DeleteFromRepositoryUnitTest.java create mode 100644 persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/datajpadelete/DeleteInRelationshipsUnitTest.java diff --git a/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/datajpadelete/entity/Book.java b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/datajpadelete/entity/Book.java new file mode 100644 index 0000000000..deac24548a --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/datajpadelete/entity/Book.java @@ -0,0 +1,51 @@ +package com.baeldung.datajpadelete.entity; + +import javax.persistence.*; + +@Entity +public class Book { + + @Id + @GeneratedValue + private Long id; + private String title; + + @ManyToOne + private Category category; + + public Book() { + } + + public Book(String title) { + this.title = title; + } + + public Book(String title, Category category) { + this.title = title; + this.category = category; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public Category getCategory() { + return category; + } + + public void setCategory(Category category) { + this.category = category; + } +} \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/datajpadelete/entity/Category.java b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/datajpadelete/entity/Category.java new file mode 100644 index 0000000000..16f1a4157f --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/datajpadelete/entity/Category.java @@ -0,0 +1,60 @@ +package com.baeldung.datajpadelete.entity; + +import javax.persistence.*; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +@Entity +public class Category { + + @Id + @GeneratedValue + private Long id; + private String name; + + @OneToMany(mappedBy = "category", cascade = CascadeType.ALL, orphanRemoval = true) + private List books; + + public Category() { + } + + public Category(String name) { + this.name = name; + } + + public Category(String name, Book... books) { + this.name = name; + this.books = Stream.of(books).collect(Collectors.toList()); + this.books.forEach(x -> x.setCategory(this)); + } + + public Category(String name, List books) { + this.name = name; + 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 getBooks() { + return books; + } + + public void setBooks(List books) { + this.books = books; + } +} diff --git a/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/datajpadelete/repository/BookRepository.java b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/datajpadelete/repository/BookRepository.java new file mode 100644 index 0000000000..5d0f45f127 --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/datajpadelete/repository/BookRepository.java @@ -0,0 +1,19 @@ +package com.baeldung.datajpadelete.repository; + +import com.baeldung.datajpadelete.entity.Book; +import org.springframework.data.jpa.repository.Modifying; +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 BookRepository extends CrudRepository { + + long deleteByTitle(String title); + + @Modifying + @Query("delete from Book b where b.title=:title") + void deleteBooks(@Param("title") String title); + +} \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/datajpadelete/repository/CategoryRepository.java b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/datajpadelete/repository/CategoryRepository.java new file mode 100644 index 0000000000..6fe7058a78 --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/datajpadelete/repository/CategoryRepository.java @@ -0,0 +1,9 @@ +package com.baeldung.datajpadelete.repository; + +import com.baeldung.datajpadelete.entity.Category; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface CategoryRepository extends CrudRepository { +} diff --git a/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/datajpadelete/DeleteFromRepositoryUnitTest.java b/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/datajpadelete/DeleteFromRepositoryUnitTest.java new file mode 100644 index 0000000000..9e7e516735 --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/datajpadelete/DeleteFromRepositoryUnitTest.java @@ -0,0 +1,72 @@ +package com.baeldung.datajpadelete; + +import com.baeldung.Application; +import com.baeldung.datajpadelete.entity.Book; +import com.baeldung.datajpadelete.repository.BookRepository; +import org.junit.After; +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.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; + +import static org.assertj.core.api.Assertions.assertThat; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = {Application.class}) +public class DeleteFromRepositoryUnitTest { + + @Autowired + private BookRepository repository; + + Book book1; + Book book2; + + @Before + public void setup() { + book1 = new Book("The Hobbit"); + book2 = new Book("All Quiet on the Western Front"); + + repository.saveAll(Arrays.asList(book1, book2)); + } + + @After + public void teardown() { + repository.deleteAll(); + } + + @Test + public void whenDeleteByIdFromRepository_thenDeletingShouldBeSuccessful() { + repository.deleteById(book1.getId()); + + assertThat(repository.count() == 1).isTrue(); + } + + @Test + public void whenDeleteAllFromRepository_thenRepositoryShouldBeEmpty() { + repository.deleteAll(); + + assertThat(repository.count() == 0).isTrue(); + } + + @Test + @Transactional + public void whenDeleteFromDerivedQuery_thenDeletingShouldBeSuccessful() { + repository.deleteByTitle("The Hobbit"); + + assertThat(repository.count() == 1).isTrue(); + } + + @Test + @Transactional + public void whenDeleteFromCustomQuery_thenDeletingShouldBeSuccessful() { + repository.deleteBooks("The Hobbit"); + + assertThat(repository.count() == 1).isTrue(); + } + +} \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/datajpadelete/DeleteInRelationshipsUnitTest.java b/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/datajpadelete/DeleteInRelationshipsUnitTest.java new file mode 100644 index 0000000000..56de8749b2 --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/datajpadelete/DeleteInRelationshipsUnitTest.java @@ -0,0 +1,60 @@ +package com.baeldung.datajpadelete; + +import com.baeldung.Application; +import com.baeldung.datajpadelete.entity.Book; +import com.baeldung.datajpadelete.entity.Category; +import com.baeldung.datajpadelete.repository.BookRepository; +import com.baeldung.datajpadelete.repository.CategoryRepository; +import org.junit.After; +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.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import static org.assertj.core.api.Assertions.assertThat; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = {Application.class}) +public class DeleteInRelationshipsUnitTest { + + @Autowired + private BookRepository bookRepository; + + @Autowired + private CategoryRepository categoryRepository; + + @Before + public void setup() { + Book book1 = new Book("The Hobbit"); + Category category1 = new Category("Cat1", book1); + categoryRepository.save(category1); + + Book book2 = new Book("All Quiet on the Western Front"); + Category category2 = new Category("Cat2", book2); + categoryRepository.save(category2); + } + + @After + public void teardown() { + bookRepository.deleteAll(); + categoryRepository.deleteAll(); + } + + @Test + public void whenDeletingCategories_thenBooksShouldAlsoBeDeleted() { + categoryRepository.deleteAll(); + + assertThat(bookRepository.count() == 0).isTrue(); + assertThat(categoryRepository.count() == 0).isTrue(); + } + + @Test + public void whenDeletingBooks_thenCategoriesShouldAlsoBeDeleted() { + bookRepository.deleteAll(); + + assertThat(bookRepository.count() == 0).isTrue(); + assertThat(categoryRepository.count() == 2).isTrue(); + } +} \ No newline at end of file From 4ca3d5049dd08cb0793eb51d96979712ee86c2c7 Mon Sep 17 00:00:00 2001 From: nguyennamthai Date: Tue, 16 Apr 2019 01:05:18 +0700 Subject: [PATCH 212/531] Spring Data JPA projections (#6733) --- .../baeldung/projection/model/Address.java | 57 +++++++++++++++++ .../com/baeldung/projection/model/Person.java | 47 ++++++++++++++ .../repository/AddressRepository.java | 11 ++++ .../repository/PersonRepository.java | 14 +++++ .../baeldung/projection/view/AddressView.java | 7 +++ .../baeldung/projection/view/PersonDto.java | 34 ++++++++++ .../baeldung/projection/view/PersonView.java | 12 ++++ .../JpaProjectionIntegrationTest.java | 63 +++++++++++++++++++ .../resources/projection-clean-up-data.sql | 2 + .../test/resources/projection-insert-data.sql | 2 + 10 files changed, 249 insertions(+) create mode 100644 persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/projection/model/Address.java create mode 100644 persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/projection/model/Person.java create mode 100644 persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/projection/repository/AddressRepository.java create mode 100644 persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/projection/repository/PersonRepository.java create mode 100644 persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/projection/view/AddressView.java create mode 100644 persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/projection/view/PersonDto.java create mode 100644 persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/projection/view/PersonView.java create mode 100644 persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/projection/JpaProjectionIntegrationTest.java create mode 100644 persistence-modules/spring-data-jpa-2/src/test/resources/projection-clean-up-data.sql create mode 100644 persistence-modules/spring-data-jpa-2/src/test/resources/projection-insert-data.sql diff --git a/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/projection/model/Address.java b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/projection/model/Address.java new file mode 100644 index 0000000000..0c5a3eac60 --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/projection/model/Address.java @@ -0,0 +1,57 @@ +package com.baeldung.projection.model; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.OneToOne; + +@Entity +public class Address { + @Id + private Long id; + @OneToOne + private Person person; + private String state; + private String city; + private String street; + private String zipCode; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getStreet() { + return street; + } + + public void setStreet(String street) { + this.street = street; + } + + public String getZipCode() { + return zipCode; + } + + public void setZipCode(String zipCode) { + this.zipCode = zipCode; + } +} diff --git a/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/projection/model/Person.java b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/projection/model/Person.java new file mode 100644 index 0000000000..d18bd1c72d --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/projection/model/Person.java @@ -0,0 +1,47 @@ +package com.baeldung.projection.model; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.OneToOne; + +@Entity +public class Person { + @Id + private Long id; + private String firstName; + private String lastName; + @OneToOne(mappedBy = "person") + private Address address; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public Address getAddress() { + return address; + } + + public void setAddress(Address address) { + this.address = address; + } +} diff --git a/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/projection/repository/AddressRepository.java b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/projection/repository/AddressRepository.java new file mode 100644 index 0000000000..c1053f4867 --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/projection/repository/AddressRepository.java @@ -0,0 +1,11 @@ +package com.baeldung.projection.repository; + +import com.baeldung.projection.view.AddressView; +import com.baeldung.projection.model.Address; +import org.springframework.data.repository.Repository; + +import java.util.List; + +public interface AddressRepository extends Repository { + List getAddressByState(String state); +} diff --git a/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/projection/repository/PersonRepository.java b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/projection/repository/PersonRepository.java new file mode 100644 index 0000000000..64bc7471e6 --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/projection/repository/PersonRepository.java @@ -0,0 +1,14 @@ +package com.baeldung.projection.repository; + +import com.baeldung.projection.model.Person; +import com.baeldung.projection.view.PersonDto; +import com.baeldung.projection.view.PersonView; +import org.springframework.data.repository.Repository; + +public interface PersonRepository extends Repository { + PersonView findByLastName(String lastName); + + PersonDto findByFirstName(String firstName); + + T findByLastName(String lastName, Class type); +} diff --git a/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/projection/view/AddressView.java b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/projection/view/AddressView.java new file mode 100644 index 0000000000..7a24a1e9b9 --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/projection/view/AddressView.java @@ -0,0 +1,7 @@ +package com.baeldung.projection.view; + +public interface AddressView { + String getZipCode(); + + PersonView getPerson(); +} diff --git a/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/projection/view/PersonDto.java b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/projection/view/PersonDto.java new file mode 100644 index 0000000000..1fd924450b --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/projection/view/PersonDto.java @@ -0,0 +1,34 @@ +package com.baeldung.projection.view; + +import java.util.Objects; + +public class PersonDto { + private final String firstName; + private final String lastName; + + public PersonDto(String firstName, String lastName) { + this.firstName = firstName; + this.lastName = lastName; + } + + public String getFirstName() { + return firstName; + } + + public String getLastName() { + return lastName; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PersonDto personDto = (PersonDto) o; + return Objects.equals(firstName, personDto.firstName) && Objects.equals(lastName, personDto.lastName); + } + + @Override + public int hashCode() { + return Objects.hash(firstName, lastName); + } +} diff --git a/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/projection/view/PersonView.java b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/projection/view/PersonView.java new file mode 100644 index 0000000000..36777ec26f --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/projection/view/PersonView.java @@ -0,0 +1,12 @@ +package com.baeldung.projection.view; + +import org.springframework.beans.factory.annotation.Value; + +public interface PersonView { + String getFirstName(); + + String getLastName(); + + @Value("#{target.firstName + ' ' + target.lastName}") + String getFullName(); +} diff --git a/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/projection/JpaProjectionIntegrationTest.java b/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/projection/JpaProjectionIntegrationTest.java new file mode 100644 index 0000000000..96eaf4ed07 --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/projection/JpaProjectionIntegrationTest.java @@ -0,0 +1,63 @@ +package com.baeldung.projection; + +import com.baeldung.projection.model.Person; +import com.baeldung.projection.repository.AddressRepository; +import com.baeldung.projection.repository.PersonRepository; +import com.baeldung.projection.view.AddressView; +import com.baeldung.projection.view.PersonDto; +import com.baeldung.projection.view.PersonView; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.test.context.jdbc.Sql; +import org.springframework.test.context.junit4.SpringRunner; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.test.context.jdbc.Sql.ExecutionPhase.AFTER_TEST_METHOD; + +@DataJpaTest +@RunWith(SpringRunner.class) +@Sql(scripts = "/projection-insert-data.sql") +@Sql(scripts = "/projection-clean-up-data.sql", executionPhase = AFTER_TEST_METHOD) +public class JpaProjectionIntegrationTest { + @Autowired + private AddressRepository addressRepository; + + @Autowired + private PersonRepository personRepository; + + @Test + public void whenUsingClosedProjections_thenViewWithRequiredPropertiesIsReturned() { + AddressView addressView = addressRepository.getAddressByState("CA").get(0); + assertThat(addressView.getZipCode()).isEqualTo("90001"); + + PersonView personView = addressView.getPerson(); + assertThat(personView.getFirstName()).isEqualTo("John"); + assertThat(personView.getLastName()).isEqualTo("Doe"); + } + + @Test + public void whenUsingOpenProjections_thenViewWithRequiredPropertiesIsReturned() { + PersonView personView = personRepository.findByLastName("Doe"); + assertThat(personView.getFullName()).isEqualTo("John Doe"); + } + + @Test + public void whenUsingClassBasedProjections_thenDtoWithRequiredPropertiesIsReturned() { + PersonDto personDto = personRepository.findByFirstName("John"); + assertThat(personDto.getFirstName()).isEqualTo("John"); + assertThat(personDto.getLastName()).isEqualTo("Doe"); + } + + @Test + public void whenUsingDynamicProjections_thenObjectWithRequiredPropertiesIsReturned() { + Person person = personRepository.findByLastName("Doe", Person.class); + PersonView personView = personRepository.findByLastName("Doe", PersonView.class); + PersonDto personDto = personRepository.findByLastName("Doe", PersonDto.class); + + assertThat(person.getFirstName()).isEqualTo("John"); + assertThat(personView.getFirstName()).isEqualTo("John"); + assertThat(personDto.getFirstName()).isEqualTo("John"); + } +} diff --git a/persistence-modules/spring-data-jpa-2/src/test/resources/projection-clean-up-data.sql b/persistence-modules/spring-data-jpa-2/src/test/resources/projection-clean-up-data.sql new file mode 100644 index 0000000000..d34f6f0636 --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/test/resources/projection-clean-up-data.sql @@ -0,0 +1,2 @@ +DELETE FROM address; +DELETE FROM person; \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-2/src/test/resources/projection-insert-data.sql b/persistence-modules/spring-data-jpa-2/src/test/resources/projection-insert-data.sql new file mode 100644 index 0000000000..544dcc4b88 --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/test/resources/projection-insert-data.sql @@ -0,0 +1,2 @@ +INSERT INTO person(id,first_name,last_name) VALUES (1,'John','Doe'); +INSERT INTO address(id,person_id,state,city,street,zip_code) VALUES (1,1,'CA', 'Los Angeles', 'Standford Ave', '90001'); \ No newline at end of file From cde706f8c984964b061c3875eaacf405b1c5bd07 Mon Sep 17 00:00:00 2001 From: Marcos Lopez Gonzalez Date: Mon, 15 Apr 2019 20:47:23 +0200 Subject: [PATCH 213/531] root cause finder --- .../baeldung/exceptions/RootCauseFinder.java | 61 +++++++++++++++++++ .../exceptions/RootCauseFinderTest.java | 51 ++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 core-java/src/main/java/com/baeldung/exceptions/RootCauseFinder.java create mode 100644 core-java/src/test/java/com/baeldung/exceptions/RootCauseFinderTest.java diff --git a/core-java/src/main/java/com/baeldung/exceptions/RootCauseFinder.java b/core-java/src/main/java/com/baeldung/exceptions/RootCauseFinder.java new file mode 100644 index 0000000000..a7963c35a8 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/exceptions/RootCauseFinder.java @@ -0,0 +1,61 @@ +package com.baeldung.exceptions; + +import java.util.Objects; + +/** + * Utility class to find root cause exceptions. + */ +public class RootCauseFinder { + + public static Throwable findCauseUsingPlainJava(Throwable throwable) { + Objects.requireNonNull(throwable); + Throwable rootCause = throwable; + while (rootCause.getCause() != null) { + rootCause = rootCause.getCause(); + } + return rootCause; + } + + static class IntParser { + + private IntParser() { + } + + public static int parse(String input) throws InvalidNumber { + if (input == null || input.isEmpty()) { + throw new IllegalArgumentException(); + } + + try { + return new IntParser().stringToInt(input.trim()); + } catch (NaNException ex) { + throw new InvalidNumber(input, ex); + } + } + + private int stringToInt(String numberAsString) throws NaNException { + try { + return Integer.valueOf(numberAsString); + } catch (NumberFormatException ex) { + throw new NaNException(numberAsString, ex); + } + } + + } + + static class InvalidNumber extends Exception { + + InvalidNumber(String input, Throwable thr) { + super("Invalid input for a number: " + input, thr); + } + } + + static class NaNException extends Exception { + + NaNException(String number, Throwable thr) { + super(number + "is not a number", thr); + } + + } + +} diff --git a/core-java/src/test/java/com/baeldung/exceptions/RootCauseFinderTest.java b/core-java/src/test/java/com/baeldung/exceptions/RootCauseFinderTest.java new file mode 100644 index 0000000000..1e58e3f602 --- /dev/null +++ b/core-java/src/test/java/com/baeldung/exceptions/RootCauseFinderTest.java @@ -0,0 +1,51 @@ +package com.baeldung.exceptions; + +import com.google.common.base.Throwables; +import org.apache.commons.lang3.exception.ExceptionUtils; +import org.junit.jupiter.api.Test; + +import static com.baeldung.exceptions.RootCauseFinder.*; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * Tests the {@link RootCauseFinder}. + */ +public class RootCauseFinderTest { + + @Test + public void givenNestedException_whenFindingRootCauseUsingJava_thenRootCauseFound() { + try { + IntParser.parse("text"); + } catch (InvalidNumber ex) { + assertTrue(findCauseUsingPlainJava(ex) instanceof NumberFormatException); + } + } + + @Test + public void givenNonNestedException_whenFindingRootCauseUsingJava_thenRootCauseFound() { + try { + IntParser.parse(null); + } catch (Exception ex) { + assertTrue(findCauseUsingPlainJava(ex) instanceof IllegalArgumentException); + } + } + + @Test + public void givenNestedException_whenFindingRootCauseUsingApacheCommons_thenRootCauseFound() { + try { + IntParser.parse("text"); + } catch (InvalidNumber ex) { + assertTrue(ExceptionUtils.getRootCause(ex) instanceof NumberFormatException); + } + } + + @Test + public void givenNestedException_whenFindingRootCauseUsingGuava_thenRootCauseFound() { + try { + IntParser.parse("text"); + } catch (InvalidNumber ex) { + assertTrue(Throwables.getRootCause(ex) instanceof NumberFormatException); + } + } + +} From 56d2e3c594dbe7c153a6df2c1c9a51c0bb1ef7a6 Mon Sep 17 00:00:00 2001 From: Dave Crane Date: Mon, 15 Apr 2019 21:03:51 +0100 Subject: [PATCH 214/531] corrected test to pull in profile-based config, fixe app cntext startup issues --- .../com/baeldung/boot/config/H2JpaConfig.java | 13 ++++++++----- .../SpringBootProfileIntegrationTest.java | 15 +++++++-------- .../baeldung/config/H2TestProfileJPAConfig.java | 12 +++++++----- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/boot/config/H2JpaConfig.java b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/boot/config/H2JpaConfig.java index 547a905d91..c5c77be56f 100644 --- a/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/boot/config/H2JpaConfig.java +++ b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/boot/config/H2JpaConfig.java @@ -1,13 +1,9 @@ package com.baeldung.boot.config; -import java.util.Properties; - -import javax.persistence.EntityManagerFactory; -import javax.sql.DataSource; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; import org.springframework.context.annotation.PropertySource; import org.springframework.core.env.Environment; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; @@ -17,10 +13,17 @@ import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; import org.springframework.transaction.annotation.EnableTransactionManagement; +import javax.persistence.EntityManagerFactory; +import javax.sql.DataSource; +import java.util.Properties; + @Configuration @EnableJpaRepositories(basePackages = { "com.baeldung.boot.repository", "com.baeldung.repository" }) @PropertySource("classpath:persistence-generic-entity.properties") @EnableTransactionManagement +@Profile("default") //only required to allow H2JpaConfig and H2TestProfileJPAConfig to coexist in same project + //this demo project is showcasing several ways to achieve the same end, and class-level + //Profile annotations are only necessary because the different techniques are sharing a project public class H2JpaConfig { @Autowired diff --git a/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/SpringBootProfileIntegrationTest.java b/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/SpringBootProfileIntegrationTest.java index 0227458987..d7bb44e133 100644 --- a/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/SpringBootProfileIntegrationTest.java +++ b/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/SpringBootProfileIntegrationTest.java @@ -1,8 +1,9 @@ package com.baeldung; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - +import com.baeldung.boot.Application; +import com.baeldung.boot.domain.GenericEntity; +import com.baeldung.boot.repository.GenericEntityRepository; +import com.baeldung.config.H2TestProfileJPAConfig; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -10,13 +11,11 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; -import com.baeldung.boot.Application; -import com.baeldung.boot.config.H2JpaConfig; -import com.baeldung.boot.domain.GenericEntity; -import com.baeldung.boot.repository.GenericEntityRepository; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; @RunWith(SpringRunner.class) -@SpringBootTest(classes = { Application.class, H2JpaConfig.class }) +@SpringBootTest(classes = { Application.class, H2TestProfileJPAConfig.class }) @ActiveProfiles("test") public class SpringBootProfileIntegrationTest { @Autowired diff --git a/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/config/H2TestProfileJPAConfig.java b/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/config/H2TestProfileJPAConfig.java index e0678bcf47..f73000a10e 100644 --- a/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/config/H2TestProfileJPAConfig.java +++ b/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/config/H2TestProfileJPAConfig.java @@ -1,10 +1,5 @@ package com.baeldung.config; -import java.util.Properties; - -import javax.persistence.EntityManagerFactory; -import javax.sql.DataSource; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -17,9 +12,16 @@ import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; import org.springframework.transaction.annotation.EnableTransactionManagement; +import javax.persistence.EntityManagerFactory; +import javax.sql.DataSource; +import java.util.Properties; + @Configuration @EnableJpaRepositories(basePackages = { "com.baeldung.repository", "com.baeldung.boot.repository" }) @EnableTransactionManagement +@Profile("test") //only required to allow H2JpaConfig and H2TestProfileJPAConfig to coexist in same project + //this demo project is showcasing several ways to achieve the same end, and class-level + //Profile annotations are only necessary because the different techniques are sharing a project public class H2TestProfileJPAConfig { @Autowired From 2a2c0a4271ff2d535e866c618e5cbe28f4ccd823 Mon Sep 17 00:00:00 2001 From: Loredana Date: Mon, 15 Apr 2019 23:57:30 +0300 Subject: [PATCH 215/531] update links --- spring-boot-rest/README.md | 25 +++++++++++++++---------- spring-boot/README.MD | 1 - spring-rest/README.md | 1 - testing-modules/rest-testing/README.md | 1 - 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/spring-boot-rest/README.md b/spring-boot-rest/README.md index af372077f0..5b7bbdac60 100644 --- a/spring-boot-rest/README.md +++ b/spring-boot-rest/README.md @@ -1,13 +1,18 @@ Module for the articles that are part of the Spring REST E-book: 1. [Bootstrap a Web Application with Spring 5](https://www.baeldung.com/bootstraping-a-web-application-with-spring-and-java-based-configuration) -2. [Error Handling for REST with Spring](http://www.baeldung.com/exception-handling-for-rest-with-spring) -3. [REST Pagination in Spring](http://www.baeldung.com/rest-api-pagination-in-spring) -4. [Build a REST API with Spring and Java Config](http://www.baeldung.com/building-a-restful-web-service-with-spring-and-java-based-configuration) -5. [HATEOAS for a Spring REST Service](http://www.baeldung.com/rest-api-discoverability-with-spring) -6. [REST API Discoverability and HATEOAS](http://www.baeldung.com/restful-web-service-discoverability) -7. [Versioning a REST API](http://www.baeldung.com/rest-versioning) -8. [Http Message Converters with the Spring Framework](http://www.baeldung.com/spring-httpmessageconverter-rest) -9. [ETags for REST with Spring](http://www.baeldung.com/etags-for-rest-with-spring) -10. [Testing REST with multiple MIME types](http://www.baeldung.com/testing-rest-api-with-multiple-media-types) -11. [Testing Web APIs with Postman Collections](https://www.baeldung.com/postman-testing-collections) +2. [Build a REST API with Spring and Java Config](http://www.baeldung.com/building-a-restful-web-service-with-spring-and-java-based-configuration) +3. [Http Message Converters with the Spring Framework](http://www.baeldung.com/spring-httpmessageconverter-rest) +4. [Spring’s RequestBody and ResponseBody Annotations](https://www.baeldung.com/spring-request-response-body) +5. [Entity To DTO Conversion for a Spring REST API](https://www.baeldung.com/entity-to-and-from-dto-for-a-java-spring-application) +6. [Error Handling for REST with Spring](http://www.baeldung.com/exception-handling-for-rest-with-spring) +7. [REST API Discoverability and HATEOAS](http://www.baeldung.com/restful-web-service-discoverability) +8. +9. [REST Pagination in Spring](http://www.baeldung.com/rest-api-pagination-in-spring) +10. [Test a REST API with Java](http://www.baeldung.com/integration-testing-a-rest-api) + +- [HATEOAS for a Spring REST Service](http://www.baeldung.com/rest-api-discoverability-with-spring) +- [Versioning a REST API](http://www.baeldung.com/rest-versioning) +- [ETags for REST with Spring](http://www.baeldung.com/etags-for-rest-with-spring) +- [Testing REST with multiple MIME types](http://www.baeldung.com/testing-rest-api-with-multiple-media-types) +- [Testing Web APIs with Postman Collections](https://www.baeldung.com/postman-testing-collections) diff --git a/spring-boot/README.MD b/spring-boot/README.MD index 7d270c9c25..86f7a33932 100644 --- a/spring-boot/README.MD +++ b/spring-boot/README.MD @@ -35,5 +35,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Display Auto-Configuration Report in Spring Boot](https://www.baeldung.com/spring-boot-auto-configuration-report) - [Injecting Git Information Into Spring](https://www.baeldung.com/spring-git-information) - [Validation in Spring Boot](https://www.baeldung.com/spring-boot-bean-validation) -- [Entity To DTO Conversion for a Spring REST API](https://www.baeldung.com/entity-to-and-from-dto-for-a-java-spring-application) - [Guide to Creating and Running a Jar File in Java](https://www.baeldung.com/java-create-jar) diff --git a/spring-rest/README.md b/spring-rest/README.md index 9a2c1fd96c..6d3aac3eb8 100644 --- a/spring-rest/README.md +++ b/spring-rest/README.md @@ -20,5 +20,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Using the Spring RestTemplate Interceptor](http://www.baeldung.com/spring-rest-template-interceptor) - [Get and Post Lists of Objects with RestTemplate](http://www.baeldung.com/spring-rest-template-list) - [How to Set a Header on a Response with Spring 5](http://www.baeldung.com/spring-response-header) -- [Spring’s RequestBody and ResponseBody Annotations](https://www.baeldung.com/spring-request-response-body) - [Uploading MultipartFile with Spring RestTemplate](http://www.baeldung.com/spring-rest-template-multipart-upload) diff --git a/testing-modules/rest-testing/README.md b/testing-modules/rest-testing/README.md index 25e036ba5d..a956f852ee 100644 --- a/testing-modules/rest-testing/README.md +++ b/testing-modules/rest-testing/README.md @@ -6,7 +6,6 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles: -- [Test a REST API with Java](http://www.baeldung.com/integration-testing-a-rest-api) - [Introduction to WireMock](http://www.baeldung.com/introduction-to-wiremock) - [Using WireMock Scenarios](http://www.baeldung.com/using-wiremock-scenarios) - [REST API Testing with Cucumber](http://www.baeldung.com/cucumber-rest-api-testing) From c0eb679136b7475b8279a3241b4d77aa30fe00a9 Mon Sep 17 00:00:00 2001 From: Alexander Molochko Date: Tue, 16 Apr 2019 02:10:13 +0300 Subject: [PATCH 216/531] Create Core Kotlin IO module --- core-kotlin-io/.gitignore | 11 +++ core-kotlin-io/README.md | 3 + core-kotlin-io/pom.xml | 78 +++++++++++++++++++ .../inputstream/InputStreamExtension.kt | 0 .../inputstream/InputStreamToStringTest.kt | 0 .../src/test/resources/inputstream2string.txt | 0 6 files changed, 92 insertions(+) create mode 100644 core-kotlin-io/.gitignore create mode 100644 core-kotlin-io/README.md create mode 100644 core-kotlin-io/pom.xml rename {core-kotlin-2 => core-kotlin-io}/src/main/kotlin/com/baeldung/inputstream/InputStreamExtension.kt (100%) rename {core-kotlin-2 => core-kotlin-io}/src/test/kotlin/com/baeldung/inputstream/InputStreamToStringTest.kt (100%) rename {core-kotlin-2 => core-kotlin-io}/src/test/resources/inputstream2string.txt (100%) diff --git a/core-kotlin-io/.gitignore b/core-kotlin-io/.gitignore new file mode 100644 index 0000000000..f521947850 --- /dev/null +++ b/core-kotlin-io/.gitignore @@ -0,0 +1,11 @@ +/bin/ + +#ignore gradle +.gradle/ + + +#ignore build and generated files +build/ +node/ +target/ +out/ diff --git a/core-kotlin-io/README.md b/core-kotlin-io/README.md new file mode 100644 index 0000000000..c085c0653f --- /dev/null +++ b/core-kotlin-io/README.md @@ -0,0 +1,3 @@ +## Relevant articles: + +- [InputStream to String in Kotlin](https://www.baeldung.com/kotlin-inputstream-to-string) diff --git a/core-kotlin-io/pom.xml b/core-kotlin-io/pom.xml new file mode 100644 index 0000000000..2e21079d7f --- /dev/null +++ b/core-kotlin-io/pom.xml @@ -0,0 +1,78 @@ + + + 4.0.0 + core-kotlin-io + core-kotlin-io + jar + + + com.baeldung + parent-kotlin + 1.0.0-SNAPSHOT + ../parent-kotlin + + + + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + ${kotlin.version} + + + org.junit.platform + junit-platform-runner + ${junit.platform.version} + test + + + org.assertj + assertj-core + ${assertj.version} + test + + + org.jetbrains.kotlin + kotlin-test + ${kotlin.version} + test + + + + + + + org.jetbrains.kotlin + kotlin-maven-plugin + ${kotlin.version} + + + compile + compile + + compile + + + + test-compile + test-compile + + test-compile + + + + + 1.8 + + + + + + + 1.2.71 + 1.1.1 + 5.2.0 + 3.10.0 + + + \ No newline at end of file diff --git a/core-kotlin-2/src/main/kotlin/com/baeldung/inputstream/InputStreamExtension.kt b/core-kotlin-io/src/main/kotlin/com/baeldung/inputstream/InputStreamExtension.kt similarity index 100% rename from core-kotlin-2/src/main/kotlin/com/baeldung/inputstream/InputStreamExtension.kt rename to core-kotlin-io/src/main/kotlin/com/baeldung/inputstream/InputStreamExtension.kt diff --git a/core-kotlin-2/src/test/kotlin/com/baeldung/inputstream/InputStreamToStringTest.kt b/core-kotlin-io/src/test/kotlin/com/baeldung/inputstream/InputStreamToStringTest.kt similarity index 100% rename from core-kotlin-2/src/test/kotlin/com/baeldung/inputstream/InputStreamToStringTest.kt rename to core-kotlin-io/src/test/kotlin/com/baeldung/inputstream/InputStreamToStringTest.kt diff --git a/core-kotlin-2/src/test/resources/inputstream2string.txt b/core-kotlin-io/src/test/resources/inputstream2string.txt similarity index 100% rename from core-kotlin-2/src/test/resources/inputstream2string.txt rename to core-kotlin-io/src/test/resources/inputstream2string.txt From 5e6a5ae662180792c2b13ca015cb400b259e759a Mon Sep 17 00:00:00 2001 From: Alexander Molochko Date: Tue, 16 Apr 2019 09:30:26 +0300 Subject: [PATCH 217/531] Add core-kotlin-io to the root pom --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index d57fa1694e..80187ffc6f 100644 --- a/pom.xml +++ b/pom.xml @@ -953,6 +953,7 @@ core-java-concurrency-advanced core-kotlin core-kotlin-2 + core-kotlin-io jenkins/hello-world jws From bbe21ca7e93016f53499cae850cc3b1065074571 Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Tue, 16 Apr 2019 12:19:46 +0400 Subject: [PATCH 218/531] Java 8 Instant --- .../java/com/baeldung/convert/ConvertDateTime.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/java-dates/src/main/java/com/baeldung/convert/ConvertDateTime.java b/java-dates/src/main/java/com/baeldung/convert/ConvertDateTime.java index d13075e063..d5003af746 100644 --- a/java-dates/src/main/java/com/baeldung/convert/ConvertDateTime.java +++ b/java-dates/src/main/java/com/baeldung/convert/ConvertDateTime.java @@ -3,7 +3,6 @@ package com.baeldung.convert; import org.joda.time.Instant; import java.text.ParseException; -import java.text.SimpleDateFormat; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.ZonedDateTime; @@ -12,18 +11,16 @@ import java.util.Date; public class ConvertDateTime { - public static void main(String[] args) throws ParseException { + public static void main(String[] args) { java8(); joda(); - Date date = simpleDateTimeFormatter(); + Date date = coreDate(); calendar(date); } - private static Date simpleDateTimeFormatter() throws ParseException { - SimpleDateFormat sdf = new SimpleDateFormat("dd-M-yyyy hh:mm:ss"); - String dateInString = "22-04-2019 10:20:56"; - Date date = sdf.parse(dateInString); + private static Date coreDate() { + Date date = new Date(); System.out.println("Date - Time in milliseconds : " + date.getTime()); @@ -46,6 +43,8 @@ public class ConvertDateTime { } private static void java8() { + long instantMillis = java.time.Instant.now().toEpochMilli(); + LocalDateTime localDateTime = LocalDateTime.now(); ZoneId id = ZoneId.systemDefault(); ZonedDateTime zdt = ZonedDateTime.of(localDateTime, id); From 2e99f89775e545c9345ee09d7dcfa84f20f66310 Mon Sep 17 00:00:00 2001 From: Anshul Bansal Date: Tue, 16 Apr 2019 12:07:35 +0300 Subject: [PATCH 219/531] BAEL-2661 - Groovy def keyword - variable names --- .../com/baeldung/defkeyword/DefUnitTest.groovy | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/core-groovy-2/src/test/groovy/com/baeldung/defkeyword/DefUnitTest.groovy b/core-groovy-2/src/test/groovy/com/baeldung/defkeyword/DefUnitTest.groovy index baab7455a5..310d97d3fd 100644 --- a/core-groovy-2/src/test/groovy/com/baeldung/defkeyword/DefUnitTest.groovy +++ b/core-groovy-2/src/test/groovy/com/baeldung/defkeyword/DefUnitTest.groovy @@ -19,7 +19,7 @@ class DefUnitTest extends GroovyTestCase { } @TypeChecked(TypeCheckingMode.SKIP) - void testDef() { + void testDefVariableDeclaration() { def list assert list.getClass() == org.codehaus.groovy.runtime.NullObject @@ -27,15 +27,21 @@ class DefUnitTest extends GroovyTestCase { list = [1,2,4] assert list instanceof ArrayList - - int sum = 200 + } + + @TypeChecked(TypeCheckingMode.SKIP) + void testTypeVariables() { + int rate = 200 try { - sum = [12] //GroovyCastException - sum = "nill" //GroovyCastException + rate = [12] //GroovyCastException + rate = "nill" //GroovyCastException } catch(GroovyCastException) { println "Cannot assign anything other than integer" } - + } + + @TypeChecked(TypeCheckingMode.SKIP) + void testDefVariableMultipleAssignment() { def rate assert rate == null assert rate.getClass() == org.codehaus.groovy.runtime.NullObject From 6b00fadcb24e7916148d432c7bdc656c23978e88 Mon Sep 17 00:00:00 2001 From: Dave Crane Date: Tue, 16 Apr 2019 14:01:33 +0100 Subject: [PATCH 220/531] moved spring core to spring 5 parent, all tests still pass --- spring-core/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-core/pom.xml b/spring-core/pom.xml index d348d742e7..814addecdd 100644 --- a/spring-core/pom.xml +++ b/spring-core/pom.xml @@ -10,9 +10,9 @@ com.baeldung - parent-spring-4 + parent-spring-5 0.0.1-SNAPSHOT - ../parent-spring-4 + ../parent-spring-5 From 30111ee51581c7eefb71948527c8231de4c779ad Mon Sep 17 00:00:00 2001 From: Loredana Date: Tue, 16 Apr 2019 22:24:06 +0300 Subject: [PATCH 221/531] move json resttemplate code --- .../web/controller/PersonAPI.java | 38 ++++++++ .../baeldung/resttemplate/web/dto/Person.java | 32 +++++++ .../web/service/PersonService.java | 10 ++ .../web/service/PersonServiceImpl.java | 19 ++++ .../resttemplate/PersonAPILiveTest.java | 96 +++++++++++++++++++ 5 files changed, 195 insertions(+) create mode 100644 spring-resttemplate/src/main/java/org/baeldung/resttemplate/web/controller/PersonAPI.java create mode 100644 spring-resttemplate/src/main/java/org/baeldung/resttemplate/web/dto/Person.java create mode 100644 spring-resttemplate/src/main/java/org/baeldung/resttemplate/web/service/PersonService.java create mode 100644 spring-resttemplate/src/main/java/org/baeldung/resttemplate/web/service/PersonServiceImpl.java create mode 100644 spring-resttemplate/src/test/java/org/baeldung/resttemplate/PersonAPILiveTest.java diff --git a/spring-resttemplate/src/main/java/org/baeldung/resttemplate/web/controller/PersonAPI.java b/spring-resttemplate/src/main/java/org/baeldung/resttemplate/web/controller/PersonAPI.java new file mode 100644 index 0000000000..b1b56ec2f3 --- /dev/null +++ b/spring-resttemplate/src/main/java/org/baeldung/resttemplate/web/controller/PersonAPI.java @@ -0,0 +1,38 @@ +package org.baeldung.resttemplate.web.controller; + +import javax.servlet.http.HttpServletResponse; + +import org.baeldung.resttemplate.web.dto.Person; +import org.baeldung.resttemplate.web.service.PersonService; +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.RestController; +import org.springframework.web.servlet.support.ServletUriComponentsBuilder; + +@RestController +public class PersonAPI { + + @Autowired + private PersonService personService; + + @GetMapping("/") + public String home() { + return "Spring boot is working!"; + } + + @PostMapping(value = "/createPerson", consumes = "application/json", produces = "application/json") + public Person createPerson(@RequestBody Person person) { + return personService.saveUpdatePerson(person); + } + + @PostMapping(value = "/updatePerson", consumes = "application/json", produces = "application/json") + public Person updatePerson(@RequestBody Person person, HttpServletResponse response) { + response.setHeader("Location", ServletUriComponentsBuilder.fromCurrentContextPath() + .path("/findPerson/" + person.getId()) + .toUriString()); + return personService.saveUpdatePerson(person); + } + +} \ No newline at end of file diff --git a/spring-resttemplate/src/main/java/org/baeldung/resttemplate/web/dto/Person.java b/spring-resttemplate/src/main/java/org/baeldung/resttemplate/web/dto/Person.java new file mode 100644 index 0000000000..4b7679638f --- /dev/null +++ b/spring-resttemplate/src/main/java/org/baeldung/resttemplate/web/dto/Person.java @@ -0,0 +1,32 @@ +package org.baeldung.resttemplate.web.dto; + +public class Person { + private Integer id; + private String name; + + public Person() { + + } + + public Person(Integer id, String name) { + this.id = id; + this.name = 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/spring-resttemplate/src/main/java/org/baeldung/resttemplate/web/service/PersonService.java b/spring-resttemplate/src/main/java/org/baeldung/resttemplate/web/service/PersonService.java new file mode 100644 index 0000000000..c5ad39e101 --- /dev/null +++ b/spring-resttemplate/src/main/java/org/baeldung/resttemplate/web/service/PersonService.java @@ -0,0 +1,10 @@ +package org.baeldung.resttemplate.web.service; + +import org.baeldung.resttemplate.web.dto.Person; + +public interface PersonService { + + public Person saveUpdatePerson(Person person); + + public Person findPersonById(Integer id); +} \ No newline at end of file diff --git a/spring-resttemplate/src/main/java/org/baeldung/resttemplate/web/service/PersonServiceImpl.java b/spring-resttemplate/src/main/java/org/baeldung/resttemplate/web/service/PersonServiceImpl.java new file mode 100644 index 0000000000..658e0fade0 --- /dev/null +++ b/spring-resttemplate/src/main/java/org/baeldung/resttemplate/web/service/PersonServiceImpl.java @@ -0,0 +1,19 @@ +package org.baeldung.resttemplate.web.service; + +import org.baeldung.resttemplate.web.dto.Person; +import org.springframework.stereotype.Component; + +@Component +public class PersonServiceImpl implements PersonService { + + @Override + public Person saveUpdatePerson(Person person) { + return person; + } + + @Override + public Person findPersonById(Integer id) { + return new Person(id, "John"); + } + +} diff --git a/spring-resttemplate/src/test/java/org/baeldung/resttemplate/PersonAPILiveTest.java b/spring-resttemplate/src/test/java/org/baeldung/resttemplate/PersonAPILiveTest.java new file mode 100644 index 0000000000..de18f6db09 --- /dev/null +++ b/spring-resttemplate/src/test/java/org/baeldung/resttemplate/PersonAPILiveTest.java @@ -0,0 +1,96 @@ +package org.baeldung.resttemplate; + +import static org.junit.Assert.assertNotNull; + +import java.io.IOException; +import java.net.URI; + +import org.baeldung.resttemplate.web.dto.Person; +import org.json.JSONException; +import org.json.JSONObject; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.web.client.RestTemplate; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = RestTemplateConfigurationApplication.class) +public class PersonAPILiveTest { + + private static String createPersonUrl; + private static String updatePersonUrl; + + private static RestTemplate restTemplate; + + private static HttpHeaders headers; + + private final ObjectMapper objectMapper = new ObjectMapper(); + + private static JSONObject personJsonObject; + + @BeforeClass + public static void runBeforeAllTestMethods() throws JSONException { + createPersonUrl = "http://localhost:8082/spring-rest/createPerson"; + updatePersonUrl = "http://localhost:8082/spring-rest/updatePerson"; + + restTemplate = new RestTemplate(); + + headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + personJsonObject = new JSONObject(); + personJsonObject.put("id", 1); + personJsonObject.put("name", "John"); + } + + @Test + public void givenDataIsJson_whenDataIsPostedByPostForObject_thenResponseBodyIsNotNull() throws IOException { + HttpEntity request = new HttpEntity(personJsonObject.toString(), headers); + String personResultAsJsonStr = restTemplate.postForObject(createPersonUrl, request, String.class); + JsonNode root = objectMapper.readTree(personResultAsJsonStr); + + Person person = restTemplate.postForObject(createPersonUrl, request, Person.class); + + assertNotNull(personResultAsJsonStr); + assertNotNull(root); + assertNotNull(root.path("name") + .asText()); + + assertNotNull(person); + assertNotNull(person.getName()); + } + + @Test + public void givenDataIsJson_whenDataIsPostedByPostForEntity_thenResponseBodyIsNotNull() throws IOException { + HttpEntity request = new HttpEntity(personJsonObject.toString(), headers); + ResponseEntity responseEntityStr = restTemplate.postForEntity(createPersonUrl, request, String.class); + JsonNode root = objectMapper.readTree(responseEntityStr.getBody()); + + ResponseEntity responseEntityPerson = restTemplate.postForEntity(createPersonUrl, request, Person.class); + + assertNotNull(responseEntityStr.getBody()); + assertNotNull(root.path("name") + .asText()); + + assertNotNull(responseEntityPerson.getBody()); + assertNotNull(responseEntityPerson.getBody() + .getName()); + } + + @Test + public void givenDataIsJson_whenDataIsPostedByPostForLocation_thenResponseBodyIsTheLocationHeader() throws JsonProcessingException { + HttpEntity request = new HttpEntity(personJsonObject.toString(), headers); + URI locationHeader = restTemplate.postForLocation(updatePersonUrl, request); + + assertNotNull(locationHeader); + } +} \ No newline at end of file From f391ddf462cfd768ae784f5c5518aed9cb82ca91 Mon Sep 17 00:00:00 2001 From: Ger Roza Date: Tue, 16 Apr 2019 17:13:15 -0300 Subject: [PATCH 222/531] Moved Spring HATEOAS article to spring-boot-rest module --- spring-boot-rest/README.md | 1 + spring-boot-rest/pom.xml | 10 ++ .../baeldung/persistence/model/Customer.java | 2 +- .../baeldung/persistence/model/Order.java | 2 +- .../baeldung/services}/CustomerService.java | 4 +- .../services}/CustomerServiceImpl.java | 5 +- .../com/baeldung/services}/OrderService.java | 4 +- .../baeldung/services}/OrderServiceImpl.java | 7 +- .../web/controller/CustomerController.java | 47 +++++---- .../CustomerControllerIntegrationTest.java | 98 +++++++++++++++++++ spring-security-rest/README.md | 1 - spring-security-rest/pom.xml | 10 -- 12 files changed, 148 insertions(+), 43 deletions(-) rename {spring-security-rest/src/main/java/org => spring-boot-rest/src/main/java/com}/baeldung/persistence/model/Customer.java (97%) rename {spring-security-rest/src/main/java/org => spring-boot-rest/src/main/java/com}/baeldung/persistence/model/Order.java (96%) rename {spring-security-rest/src/main/java/org/baeldung/web/service => spring-boot-rest/src/main/java/com/baeldung/services}/CustomerService.java (64%) rename {spring-security-rest/src/main/java/org/baeldung/web/service => spring-boot-rest/src/main/java/com/baeldung/services}/CustomerServiceImpl.java (92%) rename {spring-security-rest/src/main/java/org/baeldung/web/service => spring-boot-rest/src/main/java/com/baeldung/services}/OrderService.java (70%) rename {spring-security-rest/src/main/java/org/baeldung/web/service => spring-boot-rest/src/main/java/com/baeldung/services}/OrderServiceImpl.java (93%) rename {spring-security-rest/src/main/java/org => spring-boot-rest/src/main/java/com}/baeldung/web/controller/CustomerController.java (64%) create mode 100644 spring-boot-rest/src/test/java/com/baeldung/springhateoas/CustomerControllerIntegrationTest.java diff --git a/spring-boot-rest/README.md b/spring-boot-rest/README.md index 5b7bbdac60..dc0a573c78 100644 --- a/spring-boot-rest/README.md +++ b/spring-boot-rest/README.md @@ -16,3 +16,4 @@ Module for the articles that are part of the Spring REST E-book: - [ETags for REST with Spring](http://www.baeldung.com/etags-for-rest-with-spring) - [Testing REST with multiple MIME types](http://www.baeldung.com/testing-rest-api-with-multiple-media-types) - [Testing Web APIs with Postman Collections](https://www.baeldung.com/postman-testing-collections) +- [An Intro to Spring HATEOAS](http://www.baeldung.com/spring-hateoas-tutorial) \ No newline at end of file diff --git a/spring-boot-rest/pom.xml b/spring-boot-rest/pom.xml index 2bf7c0181f..0616c4243c 100644 --- a/spring-boot-rest/pom.xml +++ b/spring-boot-rest/pom.xml @@ -44,6 +44,16 @@ org.springframework.boot spring-boot-starter-data-jpa + + + + org.springframework.hateoas + spring-hateoas + + + org.springframework.plugin + spring-plugin-core + diff --git a/spring-security-rest/src/main/java/org/baeldung/persistence/model/Customer.java b/spring-boot-rest/src/main/java/com/baeldung/persistence/model/Customer.java similarity index 97% rename from spring-security-rest/src/main/java/org/baeldung/persistence/model/Customer.java rename to spring-boot-rest/src/main/java/com/baeldung/persistence/model/Customer.java index b302ec057a..10da2e10f0 100644 --- a/spring-security-rest/src/main/java/org/baeldung/persistence/model/Customer.java +++ b/spring-boot-rest/src/main/java/com/baeldung/persistence/model/Customer.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.model; +package com.baeldung.persistence.model; import java.util.Map; diff --git a/spring-security-rest/src/main/java/org/baeldung/persistence/model/Order.java b/spring-boot-rest/src/main/java/com/baeldung/persistence/model/Order.java similarity index 96% rename from spring-security-rest/src/main/java/org/baeldung/persistence/model/Order.java rename to spring-boot-rest/src/main/java/com/baeldung/persistence/model/Order.java index ca551423e8..7aea9bce5c 100644 --- a/spring-security-rest/src/main/java/org/baeldung/persistence/model/Order.java +++ b/spring-boot-rest/src/main/java/com/baeldung/persistence/model/Order.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.model; +package com.baeldung.persistence.model; import org.springframework.hateoas.ResourceSupport; diff --git a/spring-security-rest/src/main/java/org/baeldung/web/service/CustomerService.java b/spring-boot-rest/src/main/java/com/baeldung/services/CustomerService.java similarity index 64% rename from spring-security-rest/src/main/java/org/baeldung/web/service/CustomerService.java rename to spring-boot-rest/src/main/java/com/baeldung/services/CustomerService.java index da016af2d5..a5e95e693b 100644 --- a/spring-security-rest/src/main/java/org/baeldung/web/service/CustomerService.java +++ b/spring-boot-rest/src/main/java/com/baeldung/services/CustomerService.java @@ -1,8 +1,8 @@ -package org.baeldung.web.service; +package com.baeldung.services; import java.util.List; -import org.baeldung.persistence.model.Customer; +import com.baeldung.persistence.model.Customer; public interface CustomerService { diff --git a/spring-security-rest/src/main/java/org/baeldung/web/service/CustomerServiceImpl.java b/spring-boot-rest/src/main/java/com/baeldung/services/CustomerServiceImpl.java similarity index 92% rename from spring-security-rest/src/main/java/org/baeldung/web/service/CustomerServiceImpl.java rename to spring-boot-rest/src/main/java/com/baeldung/services/CustomerServiceImpl.java index e179de2554..58030483ec 100644 --- a/spring-security-rest/src/main/java/org/baeldung/web/service/CustomerServiceImpl.java +++ b/spring-boot-rest/src/main/java/com/baeldung/services/CustomerServiceImpl.java @@ -1,12 +1,13 @@ -package org.baeldung.web.service; +package com.baeldung.services; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import org.baeldung.persistence.model.Customer; import org.springframework.stereotype.Service; +import com.baeldung.persistence.model.Customer; + @Service public class CustomerServiceImpl implements CustomerService { diff --git a/spring-security-rest/src/main/java/org/baeldung/web/service/OrderService.java b/spring-boot-rest/src/main/java/com/baeldung/services/OrderService.java similarity index 70% rename from spring-security-rest/src/main/java/org/baeldung/web/service/OrderService.java rename to spring-boot-rest/src/main/java/com/baeldung/services/OrderService.java index 9a23488c50..775701e042 100644 --- a/spring-security-rest/src/main/java/org/baeldung/web/service/OrderService.java +++ b/spring-boot-rest/src/main/java/com/baeldung/services/OrderService.java @@ -1,8 +1,8 @@ -package org.baeldung.web.service; +package com.baeldung.services; import java.util.List; -import org.baeldung.persistence.model.Order; +import com.baeldung.persistence.model.Order; public interface OrderService { diff --git a/spring-security-rest/src/main/java/org/baeldung/web/service/OrderServiceImpl.java b/spring-boot-rest/src/main/java/com/baeldung/services/OrderServiceImpl.java similarity index 93% rename from spring-security-rest/src/main/java/org/baeldung/web/service/OrderServiceImpl.java rename to spring-boot-rest/src/main/java/com/baeldung/services/OrderServiceImpl.java index 0a6d4708a1..fffdf88969 100644 --- a/spring-security-rest/src/main/java/org/baeldung/web/service/OrderServiceImpl.java +++ b/spring-boot-rest/src/main/java/com/baeldung/services/OrderServiceImpl.java @@ -1,14 +1,15 @@ -package org.baeldung.web.service; +package com.baeldung.services; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.baeldung.persistence.model.Customer; -import org.baeldung.persistence.model.Order; import org.springframework.stereotype.Service; +import com.baeldung.persistence.model.Customer; +import com.baeldung.persistence.model.Order; + @Service public class OrderServiceImpl implements OrderService { diff --git a/spring-security-rest/src/main/java/org/baeldung/web/controller/CustomerController.java b/spring-boot-rest/src/main/java/com/baeldung/web/controller/CustomerController.java similarity index 64% rename from spring-security-rest/src/main/java/org/baeldung/web/controller/CustomerController.java rename to spring-boot-rest/src/main/java/com/baeldung/web/controller/CustomerController.java index e1db105d18..91aa9f2144 100644 --- a/spring-security-rest/src/main/java/org/baeldung/web/controller/CustomerController.java +++ b/spring-boot-rest/src/main/java/com/baeldung/web/controller/CustomerController.java @@ -1,24 +1,25 @@ -package org.baeldung.web.controller; +package com.baeldung.web.controller; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; import java.util.List; -import org.baeldung.persistence.model.Customer; -import org.baeldung.persistence.model.Order; -import org.baeldung.web.service.CustomerService; -import org.baeldung.web.service.OrderService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.hateoas.Link; import org.springframework.hateoas.Resources; import org.springframework.hateoas.config.EnableHypermediaSupport; import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; +import com.baeldung.persistence.model.Customer; +import com.baeldung.persistence.model.Order; +import com.baeldung.services.CustomerService; +import com.baeldung.services.OrderService; + @RestController @RequestMapping(value = "/customers") @EnableHypermediaSupport(type = HypermediaType.HAL) @@ -29,45 +30,49 @@ public class CustomerController { @Autowired private OrderService orderService; - @RequestMapping(value = "/{customerId}", method = RequestMethod.GET) + @GetMapping("/{customerId}") public Customer getCustomerById(@PathVariable final String customerId) { return customerService.getCustomerDetail(customerId); } - @RequestMapping(value = "/{customerId}/{orderId}", method = RequestMethod.GET) + @GetMapping("/{customerId}/{orderId}") public Order getOrderById(@PathVariable final String customerId, @PathVariable final String orderId) { return orderService.getOrderByIdForCustomer(customerId, orderId); } - @RequestMapping(value = "/{customerId}/orders", method = RequestMethod.GET , produces = {"application/hal+json"}) + @GetMapping(value = "/{customerId}/orders", produces = { "application/hal+json" }) public Resources getOrdersForCustomer(@PathVariable final String customerId) { final List orders = orderService.getAllOrdersForCustomer(customerId); for (final Order order : orders) { - final Link selfLink = linkTo(methodOn(CustomerController.class).getOrderById(customerId, order.getOrderId())).withSelfRel(); + final Link selfLink = linkTo( + methodOn(CustomerController.class).getOrderById(customerId, order.getOrderId())).withSelfRel(); order.add(selfLink); } - - Link link =linkTo(methodOn(CustomerController.class).getOrdersForCustomer(customerId)).withSelfRel(); - Resources result = new Resources<>(orders,link); + + Link link = linkTo(methodOn(CustomerController.class).getOrdersForCustomer(customerId)).withSelfRel(); + Resources result = new Resources<>(orders, link); return result; } - @RequestMapping(method = RequestMethod.GET, produces = {"application/hal+json"}) + @GetMapping(produces = { "application/hal+json" }) public Resources getAllCustomers() { final List allCustomers = customerService.allCustomers(); - + for (final Customer customer : allCustomers) { String customerId = customer.getCustomerId(); - Link selfLink = linkTo(CustomerController.class).slash(customerId).withSelfRel(); + Link selfLink = linkTo(CustomerController.class).slash(customerId) + .withSelfRel(); customer.add(selfLink); - if (orderService.getAllOrdersForCustomer(customerId).size() > 0) { - final Link ordersLink = linkTo(methodOn(CustomerController.class).getOrdersForCustomer(customerId)).withRel("allOrders"); + if (orderService.getAllOrdersForCustomer(customerId) + .size() > 0) { + final Link ordersLink = linkTo(methodOn(CustomerController.class).getOrdersForCustomer(customerId)) + .withRel("allOrders"); customer.add(ordersLink); } } - - Link link =linkTo(CustomerController.class).withSelfRel(); - Resources result = new Resources<>(allCustomers,link); + + Link link = linkTo(CustomerController.class).withSelfRel(); + Resources result = new Resources<>(allCustomers, link); return result; } diff --git a/spring-boot-rest/src/test/java/com/baeldung/springhateoas/CustomerControllerIntegrationTest.java b/spring-boot-rest/src/test/java/com/baeldung/springhateoas/CustomerControllerIntegrationTest.java new file mode 100644 index 0000000000..b08da6d2cd --- /dev/null +++ b/spring-boot-rest/src/test/java/com/baeldung/springhateoas/CustomerControllerIntegrationTest.java @@ -0,0 +1,98 @@ +package com.baeldung.springhateoas; + +import static org.hamcrest.Matchers.is; +import static org.mockito.BDDMockito.given; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import java.util.Collections; +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.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.hateoas.MediaTypes; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; + +import com.baeldung.persistence.model.Customer; +import com.baeldung.persistence.model.Order; +import com.baeldung.services.CustomerService; +import com.baeldung.services.OrderService; +import com.baeldung.web.controller.CustomerController; + +@RunWith(SpringRunner.class) +@WebMvcTest(CustomerController.class) +public class CustomerControllerIntegrationTest { + + @Autowired + private MockMvc mvc; + + @MockBean + private CustomerService customerService; + + @MockBean + private OrderService orderService; + + private static final String DEFAULT_CUSTOMER_ID = "customer1"; + private static final String DEFAULT_ORDER_ID = "order1"; + + @Test + public void givenExistingCustomer_whenCustomerRequested_thenResourceRetrieved() throws Exception { + given(this.customerService.getCustomerDetail(DEFAULT_CUSTOMER_ID)) + .willReturn(new Customer(DEFAULT_CUSTOMER_ID, "customerJohn", "companyOne")); + + this.mvc.perform(get("/customers/" + DEFAULT_CUSTOMER_ID)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$._links").doesNotExist()) + .andExpect(jsonPath("$.customerId", is(DEFAULT_CUSTOMER_ID))); + } + + @Test + public void givenExistingOrder_whenOrderRequested_thenResourceRetrieved() throws Exception { + given(this.orderService.getOrderByIdForCustomer(DEFAULT_CUSTOMER_ID, DEFAULT_ORDER_ID)) + .willReturn(new Order(DEFAULT_ORDER_ID, 1., 1)); + + this.mvc.perform(get("/customers/" + DEFAULT_CUSTOMER_ID + "/" + DEFAULT_ORDER_ID)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$._links").doesNotExist()) + .andExpect(jsonPath("$.orderId", is(DEFAULT_ORDER_ID))); + } + + @Test + public void givenExistingCustomerWithOrders_whenOrdersRequested_thenHalResourceRetrieved() throws Exception { + Order order1 = new Order(DEFAULT_ORDER_ID, 1., 1); + List orders = Collections.singletonList(order1); + given(this.orderService.getAllOrdersForCustomer(DEFAULT_CUSTOMER_ID)).willReturn(orders); + + this.mvc.perform(get("/customers/" + DEFAULT_CUSTOMER_ID + "/orders").accept(MediaTypes.HAL_JSON_VALUE)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$._embedded.orderList[0]._links.self.href", + is("http://localhost/customers/customer1/order1"))) + .andExpect(jsonPath("$._links.self.href", is("http://localhost/customers/customer1/orders"))); + } + + @Test + public void givenExistingCustomer_whenAllCustomersRequested_thenHalResourceRetrieved() throws Exception { + // customers + Customer retrievedCustomer = new Customer(DEFAULT_CUSTOMER_ID, "customerJohn", "companyOne"); + List customers = Collections.singletonList(retrievedCustomer); + given(this.customerService.allCustomers()).willReturn(customers); + // orders + Order order1 = new Order(DEFAULT_ORDER_ID, 1., 1); + List orders = Collections.singletonList(order1); + given(this.orderService.getAllOrdersForCustomer(DEFAULT_CUSTOMER_ID)).willReturn(orders); + + this.mvc.perform(get("/customers/").accept(MediaTypes.HAL_JSON_VALUE)) + .andExpect(status().isOk()) + .andExpect( + jsonPath("$._embedded.customerList[0]._links.self.href", is("http://localhost/customers/customer1"))) + .andExpect(jsonPath("$._embedded.customerList[0]._links.allOrders.href", + is("http://localhost/customers/customer1/orders"))) + .andExpect(jsonPath("$._links.self.href", is("http://localhost/customers"))); + } + +} diff --git a/spring-security-rest/README.md b/spring-security-rest/README.md index f71eead9ae..f450a514b2 100644 --- a/spring-security-rest/README.md +++ b/spring-security-rest/README.md @@ -11,7 +11,6 @@ The "Learn Spring Security" Classes: http://github.learnspringsecurity.com - [Spring REST Service Security](http://www.baeldung.com/2011/10/31/securing-a-restful-web-service-with-spring-security-3-1-part-3/) - [Setting Up Swagger 2 with a Spring REST API](http://www.baeldung.com/swagger-2-documentation-for-spring-rest-api) - [Custom Error Message Handling for REST API](http://www.baeldung.com/global-error-handler-in-a-spring-rest-api) -- [An Intro to Spring HATEOAS](http://www.baeldung.com/spring-hateoas-tutorial) - [Spring Security Context Propagation with @Async](http://www.baeldung.com/spring-security-async-principal-propagation) - [Servlet 3 Async Support with Spring MVC and Spring Security](http://www.baeldung.com/spring-mvc-async-security) - [Intro to Spring Security Expressions](http://www.baeldung.com/spring-security-expressions) diff --git a/spring-security-rest/pom.xml b/spring-security-rest/pom.xml index 24f1c5807a..b6039ce9d3 100644 --- a/spring-security-rest/pom.xml +++ b/spring-security-rest/pom.xml @@ -84,13 +84,6 @@ ${spring.version} - - - org.springframework.hateoas - spring-hateoas - ${org.springframework.hateoas.version} - - @@ -273,9 +266,6 @@ - - 0.25.0.RELEASE - 3.1.0 1.1.0.Final From 8ba93d8dc62f4ca04d570784dba9fc59114e6e98 Mon Sep 17 00:00:00 2001 From: Kevin Wittek Date: Tue, 16 Apr 2019 23:21:09 +0200 Subject: [PATCH 223/531] BAEL-2771 string matching - Move to new module (#6744) * BAEL-2771 Add String matching example to core-groovy * Move test to new core-groovy-2 module --- .gitignore | 4 + core-groovy-2/README.md | 5 ++ core-groovy-2/pom.xml | 80 +++++++++++++++++++ .../strings/StringMatchingSpec.groovy | 44 ++++++++++ pom.xml | 1 + 5 files changed, 134 insertions(+) create mode 100644 core-groovy-2/README.md create mode 100644 core-groovy-2/pom.xml create mode 100644 core-groovy-2/src/test/groovy/com/baeldung/strings/StringMatchingSpec.groovy diff --git a/.gitignore b/.gitignore index 21586748b7..b981a473f6 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ .idea/ *.iml *.iws +out/ # Mac .DS_Store @@ -27,6 +28,9 @@ log/ target/ +# Gradle +.gradle/ + spring-openid/src/main/resources/application.properties .recommenders/ /spring-hibernate4/nbproject/ diff --git a/core-groovy-2/README.md b/core-groovy-2/README.md new file mode 100644 index 0000000000..9701976142 --- /dev/null +++ b/core-groovy-2/README.md @@ -0,0 +1,5 @@ +# Groovy + +## Relevant articles: + +- [String Matching in Groovy](http://www.baeldung.com/) \ No newline at end of file diff --git a/core-groovy-2/pom.xml b/core-groovy-2/pom.xml new file mode 100644 index 0000000000..bbedbf2157 --- /dev/null +++ b/core-groovy-2/pom.xml @@ -0,0 +1,80 @@ + + + 4.0.0 + core-groovy + 1.0-SNAPSHOT + core-groovy-2 + jar + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + + org.codehaus.groovy + groovy-all + ${groovy-all.version} + pom + + + org.hsqldb + hsqldb + ${hsqldb.version} + test + + + org.spockframework + spock-core + ${spock-core.version} + test + + + + + + + org.codehaus.gmavenplus + gmavenplus-plugin + ${gmavenplus-plugin.version} + + + + compile + compileTests + + + + + + maven-surefire-plugin + 2.20.1 + + false + + **/*Test.java + **/*Spec.java + + + + + + + + + central + http://jcenter.bintray.com + + + + + 2.5.6 + 2.4.0 + 1.3-groovy-2.5 + 1.6.3 + + + diff --git a/core-groovy-2/src/test/groovy/com/baeldung/strings/StringMatchingSpec.groovy b/core-groovy-2/src/test/groovy/com/baeldung/strings/StringMatchingSpec.groovy new file mode 100644 index 0000000000..3865bc73fa --- /dev/null +++ b/core-groovy-2/src/test/groovy/com/baeldung/strings/StringMatchingSpec.groovy @@ -0,0 +1,44 @@ +package com.baeldung.strings + +import spock.lang.Specification + +import java.util.regex.Pattern + +class StringMatchingSpec extends Specification { + + def "pattern operator example"() { + given: "a pattern" + def p = ~'foo' + + expect: + p instanceof Pattern + + and: "you can use slash strings to avoid escaping of blackslash" + def digitPattern = ~/\d*/ + digitPattern.matcher('4711').matches() + } + + def "match operator example"() { + expect: + 'foobar' ==~ /.*oba.*/ + + and: "matching is strict" + !('foobar' ==~ /foo/) + } + + def "find operator example"() { + when: "using the find operator" + def matcher = 'foo and bar, baz and buz' =~ /(\w+) and (\w+)/ + + then: "will find groups" + matcher.size() == 2 + + and: "can access groups using array" + matcher[0][0] == 'foo and bar' + matcher[1][2] == 'buz' + + and: "you can use it as a predicate" + 'foobarbaz' =~ /bar/ + } + +} diff --git a/pom.xml b/pom.xml index 80187ffc6f..ff2fa55410 100644 --- a/pom.xml +++ b/pom.xml @@ -1039,6 +1039,7 @@ cdi checker-plugin core-groovy + core-groovy-2 core-java-8 From 2be225b6fc9d681fc7e3f62dc686a9fea40efeb8 Mon Sep 17 00:00:00 2001 From: Joel Juarez Date: Tue, 16 Apr 2019 22:57:57 -0600 Subject: [PATCH 224/531] added jpa embeddable example (#6636) * [BAEL-12731] - Fixed tests in spring-boot-security module * [BAEL-12731] - Added BcryptPasswordEncoder support * first commit * [BAEL-13322] - Removed noexception module : Code already present in libraries module * added jpa embeddable example * Issue-6604: Upgrade spring cloud to Edgware.SR5 * BAEL-2569 EnvironmentPostProcessor in Spring Boot (#6608) * BAEL-2569 : EnvironmentPostProcessor in Spring Boot * BAEL-2569 add test * BAEL-2569 update test * BAEL-2569 refactoring the class PriceCalculationEnvironmentPostProcessor * BAEL-2569: changes to class PriceCalculationEnvironmentPostProcessor * BAEL-2477 * BAEL-2829: Moving to spring-data-jpa-2 * BAEL-379 A Guide to jBPM with Java (#6619) * BAEL-379 A Guide to jBPM with Java * BAEL-379 * BAEL-379 A Guide to jBPM with Java * BAEL-379 A Guide to jBPM with Java * BAEL-379 A Guide to jBPM with Java * BAEL-379 A Guide to jBPM with Java * BAEL-1959 Classpath contains multiple bindings Updated pom.xml to exclude log4j binding * Fixed or added Context Integration Tests for modules named in ticket * extension function in java * BAEL-2803 (#6640) * added sample code for eval article * BAEL-2803 Sample Code * updated tests, repo method names * moved sources for BAEL-2803 here * removed dependencies introduced by BAEL-2803 * re-added sources * moved code to new module * removed eval article code * BAEL-2736: Update README (#6651) * BAEL-2246: add link back to article * BAEL-2174: rename core-java-net module to core-java-networking * BAEL-2174: add link back to article * BAEL-2363 BAEL-2337 BAEL-1996 BAEL-2277 add links back to articles * BAEL-2367: add link back to article * BAEL-2335: add link back to article * BAEL-2413: add link back to article * Update README.MD * BAEL-2577: add link back to article * BAEL-2490: add link back to article * BAEL-2471: add link back to article * BAEL-2583: add link back to article * BAEL-2738: add link back to article * BAEL-2711: Add spring-boot-angular module to root pom * BAEL-2544 BAEL-2711 BAEL-2575 BAEL-2657 Add links back to articles * BAEL-2736: Add link back to article * BAEL * BAEL-2844 (#6641) * Revering tree update (#6561) * Add files via upload * Add files via upload * Add files via upload * Add files via upload * Add files via upload * corrections * BAEL-2481: Moved to spring-mvc-java * BAEL-2820 Transforming Optional of an Empty String into Empty Optional (#6634) * [BAEL-13311] - Checked modules that don't use our standard parents * BAEL2489:Avoid check for null statements in Java (#6647) * BAEL2489 - Avoid check for null statement in Java * BAEL2489 Avoid check for null statement in Java * BAEL2489 Avoid check for null statement in Java * BAEL2489 Avoid check for null statement in Java * BAEL2489 Avoid check for null statement in Java * BAEL2489 Avoid check for null statement in Java - Removing unused pom changes * BAEL2489 Avoid check for null statement in Java - Removing unused pom changes * Delete pom.xml Removing unused changes in core-java * BAEL2489 Avoid check for null statement in Java - Removing unused pom changes * BAEL2489 Avoid check for null statement in Java - adding ofnullable to Optional example * BAEL-2801 (#6665) * BAEL-2727 Example Code * BAEL-2801 Example code * Change to use parent-boot-2 * fix bean config * [BAEL-13378] - Added modules those were not built * Bael 2826 case insensitive spring data jpa (#6668) * BAEL-2826: Case Insensitive Comparison Spring data jpa * BAEL-2826: Fixing imports * BAEL-2826: Case Insensitive Comparison Spring data jpa * BAEL-2826: Fixing imports * BAEL-2826: Moving code to another repo * BAEL-2826: Moving code to another repo * BAEL-2826 : Refactor * BAEL-2826 : Refactor * BAEL-2826 : Override equals hashcode * [BAEL-13313] - Extract versions into properties * BAEL * BAEL-2859 : Updating to Spring Boot 2.0.6.RELEASE * BAEL-2859 : Updating to Spring Boot 2.0.6.RELEASE * BAEL-1959: Moved to logging-modules/logback * [BAEL-13313] - Fixed PMD violation for string-test-functions module unit test * [BAEL-13313] - Fixed PMD violation for math-test-functions module * [BAEL-13378] - Added submodules in integration profiles also * BAEL-2789: update README (#6676) * BAEL-2246: add link back to article * BAEL-2174: rename core-java-net module to core-java-networking * BAEL-2174: add link back to article * BAEL-2363 BAEL-2337 BAEL-1996 BAEL-2277 add links back to articles * BAEL-2367: add link back to article * BAEL-2335: add link back to article * BAEL-2413: add link back to article * Update README.MD * BAEL-2577: add link back to article * BAEL-2490: add link back to article * BAEL-2471: add link back to article * BAEL-2583: add link back to article * BAEL-2738: add link back to article * BAEL-2711: Add spring-boot-angular module to root pom * BAEL-2544 BAEL-2711 BAEL-2575 BAEL-2657 Add links back to articles * BAEL-2736: Add link back to article * BAEL-2789: Add link back to article * BAEL-2569 (#6679) * BAEL-2569 : EnvironmentPostProcessor in Spring Boot * BAEL-2569 add test * BAEL-2569 update test * BAEL-2569 refactoring the class PriceCalculationEnvironmentPostProcessor * BAEL-2569: changes to class PriceCalculationEnvironmentPostProcessor * BAEL-2569 move code to spring-boot-ops module * [BAEL-13314] - Fix formatting of POMs * BAEL-379 A Guide to jBPM with Java (#6687) * BAEL-379 A Guide to jBPM with Java * BAEL-379 A Guide to jBPM with Java * BAEL-2811: Added sample code for jpa joins (#6691) * added jpa embeddable example * moved embeddable example to spring-data-jpa-2 * moved embeddable example to spring-data-jpa-2 --- .../baeldung/embeddable/model/Company.java | 71 ++++++++++ .../embeddable/model/ContactPerson.java | 38 ++++++ .../repositories/CompanyRepository.java | 18 +++ .../embeddable/EmbeddableIntegrationTest.java | 125 ++++++++++++++++++ 4 files changed, 252 insertions(+) create mode 100644 persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/embeddable/model/Company.java create mode 100644 persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/embeddable/model/ContactPerson.java create mode 100644 persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/embeddable/repositories/CompanyRepository.java create mode 100644 persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/embeddable/EmbeddableIntegrationTest.java diff --git a/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/embeddable/model/Company.java b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/embeddable/model/Company.java new file mode 100644 index 0000000000..203cff1e35 --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/embeddable/model/Company.java @@ -0,0 +1,71 @@ +package com.baeldung.embeddable.model; + +import javax.persistence.AttributeOverride; +import javax.persistence.AttributeOverrides; +import javax.persistence.Column; +import javax.persistence.Embedded; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +@Entity +public class Company { + + @Id + @GeneratedValue + private Integer id; + + private String name; + + private String address; + + private String phone; + + @Embedded + @AttributeOverrides(value = { + @AttributeOverride( name = "firstName", column = @Column(name = "contact_first_name")), + @AttributeOverride( name = "lastName", column = @Column(name = "contact_last_name")), + @AttributeOverride( name = "phone", column = @Column(name = "contact_phone")) + }) + private ContactPerson contactPerson; + + 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 String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public ContactPerson getContactPerson() { + return contactPerson; + } + + public void setContactPerson(ContactPerson contactPerson) { + this.contactPerson = contactPerson; + } +} diff --git a/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/embeddable/model/ContactPerson.java b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/embeddable/model/ContactPerson.java new file mode 100644 index 0000000000..561da80878 --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/embeddable/model/ContactPerson.java @@ -0,0 +1,38 @@ +package com.baeldung.embeddable.model; + +import javax.persistence.Embeddable; + +@Embeddable +public class ContactPerson { + + private String firstName; + + private String lastName; + + private String phone; + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + +} diff --git a/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/embeddable/repositories/CompanyRepository.java b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/embeddable/repositories/CompanyRepository.java new file mode 100644 index 0000000000..f456b15652 --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/embeddable/repositories/CompanyRepository.java @@ -0,0 +1,18 @@ +package com.baeldung.embeddable.repositories; + +import com.baeldung.embeddable.model.Company; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; + +import java.util.List; + +public interface CompanyRepository extends JpaRepository { + + List findByContactPersonFirstName(String firstName); + + @Query("SELECT C FROM Company C WHERE C.contactPerson.firstName = ?1") + List findByContactPersonFirstNameWithJPQL(String firstName); + + @Query(value = "SELECT * FROM company WHERE contact_first_name = ?1", nativeQuery = true) + List findByContactPersonFirstNameWithNativeQuery(String firstName); +} diff --git a/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/embeddable/EmbeddableIntegrationTest.java b/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/embeddable/EmbeddableIntegrationTest.java new file mode 100644 index 0000000000..b4c365a2d9 --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/embeddable/EmbeddableIntegrationTest.java @@ -0,0 +1,125 @@ +package com.baeldung.embeddable; + +import com.baeldung.Application; +import com.baeldung.embeddable.model.Company; +import com.baeldung.embeddable.model.ContactPerson; +import com.baeldung.embeddable.repositories.CompanyRepository; +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 org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +import static org.junit.Assert.assertEquals; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = {Application.class}) +public class EmbeddableIntegrationTest { + + @Autowired + private CompanyRepository companyRepository; + + @Test + @Transactional + public void whenInsertingCompany_thenEmbeddedContactPersonDetailsAreMapped() { + ContactPerson contactPerson = new ContactPerson(); + contactPerson.setFirstName("First"); + contactPerson.setLastName("Last"); + contactPerson.setPhone("123-456-789"); + + Company company = new Company(); + company.setName("Company"); + company.setAddress("1st street"); + company.setPhone("987-654-321"); + company.setContactPerson(contactPerson); + + companyRepository.save(company); + + Company result = companyRepository.getOne(company.getId()); + + assertEquals("Company", result.getName()); + assertEquals("1st street", result.getAddress()); + assertEquals("987-654-321", result.getPhone()); + assertEquals("First", result.getContactPerson().getFirstName()); + assertEquals("Last", result.getContactPerson().getLastName()); + assertEquals("123-456-789", result.getContactPerson().getPhone()); + } + + @Test + @Transactional + public void whenFindingCompanyByContactPersonAttribute_thenCompanyIsReturnedProperly() { + ContactPerson contactPerson = new ContactPerson(); + contactPerson.setFirstName("Name"); + contactPerson.setLastName("Last"); + contactPerson.setPhone("123-456-789"); + + Company company = new Company(); + company.setName("Company"); + company.setAddress("1st street"); + company.setPhone("987-654-321"); + company.setContactPerson(contactPerson); + + companyRepository.save(company); + + List result = companyRepository.findByContactPersonFirstName("Name"); + + assertEquals(1, result.size()); + + result = companyRepository.findByContactPersonFirstName("FirstName"); + + assertEquals(0, result.size()); + } + + @Test + @Transactional + public void whenFindingCompanyByContactPersonAttributeWithJPQL_thenCompanyIsReturnedProperly() { + ContactPerson contactPerson = new ContactPerson(); + contactPerson.setFirstName("@QueryName"); + contactPerson.setLastName("Last"); + contactPerson.setPhone("123-456-789"); + + Company company = new Company(); + company.setName("Company"); + company.setAddress("1st street"); + company.setPhone("987-654-321"); + company.setContactPerson(contactPerson); + + companyRepository.save(company); + + List result = companyRepository.findByContactPersonFirstNameWithJPQL("@QueryName"); + + assertEquals(1, result.size()); + + result = companyRepository.findByContactPersonFirstNameWithJPQL("FirstName"); + + assertEquals(0, result.size()); + } + + @Test + @Transactional + public void whenFindingCompanyByContactPersonAttributeWithNativeQuery_thenCompanyIsReturnedProperly() { + ContactPerson contactPerson = new ContactPerson(); + contactPerson.setFirstName("NativeQueryName"); + contactPerson.setLastName("Last"); + contactPerson.setPhone("123-456-789"); + + Company company = new Company(); + company.setName("Company"); + company.setAddress("1st street"); + company.setPhone("987-654-321"); + company.setContactPerson(contactPerson); + + companyRepository.save(company); + + List result = companyRepository.findByContactPersonFirstNameWithNativeQuery("NativeQueryName"); + + assertEquals(1, result.size()); + + result = companyRepository.findByContactPersonFirstNameWithNativeQuery("FirstName"); + + assertEquals(0, result.size()); + } +} From eff19c7163d6a2d29f2c7f1b3b5d1038454697c7 Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Wed, 17 Apr 2019 11:13:46 +0400 Subject: [PATCH 225/531] create java-dates-2 module --- java-dates-2/pom.xml | 26 +++++++++++++++++++ .../src/main/java}/ConvertDateTime.java | 3 --- 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 java-dates-2/pom.xml rename {java-dates/src/main/java/com/baeldung/convert => java-dates-2/src/main/java}/ConvertDateTime.java (95%) diff --git a/java-dates-2/pom.xml b/java-dates-2/pom.xml new file mode 100644 index 0000000000..427a7adc4b --- /dev/null +++ b/java-dates-2/pom.xml @@ -0,0 +1,26 @@ + + + 4.0.0 + + com.baeldung + java-dates-2 + 1.0-SNAPSHOT + + + + joda-time + joda-time + ${joda-time.version} + + + + +2.10 + +1.8 +1.8 + + + \ No newline at end of file diff --git a/java-dates/src/main/java/com/baeldung/convert/ConvertDateTime.java b/java-dates-2/src/main/java/ConvertDateTime.java similarity index 95% rename from java-dates/src/main/java/com/baeldung/convert/ConvertDateTime.java rename to java-dates-2/src/main/java/ConvertDateTime.java index d5003af746..9f4ac0062b 100644 --- a/java-dates/src/main/java/com/baeldung/convert/ConvertDateTime.java +++ b/java-dates-2/src/main/java/ConvertDateTime.java @@ -1,8 +1,5 @@ -package com.baeldung.convert; - import org.joda.time.Instant; -import java.text.ParseException; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.ZonedDateTime; From 274cd5b4b142407a3e95cb19419b1ac631927a22 Mon Sep 17 00:00:00 2001 From: Anshul Bansal Date: Wed, 17 Apr 2019 11:01:36 +0300 Subject: [PATCH 226/531] BAEL-2661 - Groovy def keyword - conflicts resolved --- core-groovy-2/pom.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core-groovy-2/pom.xml b/core-groovy-2/pom.xml index 69a390a3a0..9819bc4c16 100644 --- a/core-groovy-2/pom.xml +++ b/core-groovy-2/pom.xml @@ -96,6 +96,8 @@ + + maven-surefire-plugin 2.20.1 From f3f4c32f014bb46e212462cbaa5afbc38a94c4b0 Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Wed, 17 Apr 2019 12:05:08 +0400 Subject: [PATCH 227/531] JUnit to output millis --- java-dates-2/pom.xml | 7 +++ .../src/main/java/ConvertDateTime.java | 50 ------------------- .../com/baeldung/convert/ConvertDateTime.java | 45 +++++++++++++++++ .../convert/ConvertDateTimeUnitTest.java | 13 +++++ 4 files changed, 65 insertions(+), 50 deletions(-) delete mode 100644 java-dates-2/src/main/java/ConvertDateTime.java create mode 100644 java-dates-2/src/main/java/com/baeldung/convert/ConvertDateTime.java create mode 100644 java-dates-2/src/test/java/com/baeldung/convert/ConvertDateTimeUnitTest.java diff --git a/java-dates-2/pom.xml b/java-dates-2/pom.xml index 427a7adc4b..3af13eee39 100644 --- a/java-dates-2/pom.xml +++ b/java-dates-2/pom.xml @@ -8,6 +8,13 @@ java-dates-2 1.0-SNAPSHOT + + com.baeldung + parent-java + 0.0.1-SNAPSHOT + ../parent-java + + joda-time diff --git a/java-dates-2/src/main/java/ConvertDateTime.java b/java-dates-2/src/main/java/ConvertDateTime.java deleted file mode 100644 index 9f4ac0062b..0000000000 --- a/java-dates-2/src/main/java/ConvertDateTime.java +++ /dev/null @@ -1,50 +0,0 @@ -import org.joda.time.Instant; - -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.time.ZonedDateTime; -import java.util.Calendar; -import java.util.Date; - -public class ConvertDateTime { - - public static void main(String[] args) { - - java8(); - joda(); - Date date = coreDate(); - calendar(date); - } - - private static Date coreDate() { - Date date = new Date(); - - System.out.println("Date - Time in milliseconds : " + date.getTime()); - - return date; - } - - private static void calendar(Date date) { - Calendar calendar = Calendar.getInstance(); - calendar.setTime(date); - System.out.println("Calender - Time in milliseconds : " + calendar.getTimeInMillis()); - } - - private static void joda() { - org.joda.time.DateTime jodaDateTime = new org.joda.time.DateTime(); - long delta = jodaDateTime.getMillis(); - System.out.println("Joda - Time in milliseconds : " + delta); - - Instant jodaInstant = Instant.now(); - System.out.println("Joda - Instant in milliseconds : " + jodaInstant.getMillis()); - } - - private static void java8() { - long instantMillis = java.time.Instant.now().toEpochMilli(); - - LocalDateTime localDateTime = LocalDateTime.now(); - ZoneId id = ZoneId.systemDefault(); - ZonedDateTime zdt = ZonedDateTime.of(localDateTime, id); - System.out.println("Java 8 - Time in milliseconds : " + zdt.toInstant().toEpochMilli()); - } -} diff --git a/java-dates-2/src/main/java/com/baeldung/convert/ConvertDateTime.java b/java-dates-2/src/main/java/com/baeldung/convert/ConvertDateTime.java new file mode 100644 index 0000000000..b63b26da69 --- /dev/null +++ b/java-dates-2/src/main/java/com/baeldung/convert/ConvertDateTime.java @@ -0,0 +1,45 @@ +package com.baeldung.convert; + +import org.joda.time.Instant; + +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.util.Calendar; +import java.util.Date; + +public class ConvertDateTime { + + public static long coreDate() { + Date date = new Date(); + return date.getTime(); + } + + public static long calendar() { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(new Date()); + return calendar.getTimeInMillis(); + } + + public static long jodaInstant() { + Instant jodaInstant = Instant.now(); + return jodaInstant.getMillis(); + } + + public static long jodaDateTime() { + org.joda.time.DateTime jodaDateTime = new org.joda.time.DateTime(); + return jodaDateTime.getMillis(); + } + + public static long java8Instant() { + return java.time.Instant.now().toEpochMilli(); + } + + public static long java8LocalDateTime() { + + LocalDateTime localDateTime = LocalDateTime.now(); + ZoneId id = ZoneId.systemDefault(); + ZonedDateTime zdt = ZonedDateTime.of(localDateTime, id); + return zdt.toInstant().toEpochMilli(); + } +} diff --git a/java-dates-2/src/test/java/com/baeldung/convert/ConvertDateTimeUnitTest.java b/java-dates-2/src/test/java/com/baeldung/convert/ConvertDateTimeUnitTest.java new file mode 100644 index 0000000000..a2e15461d0 --- /dev/null +++ b/java-dates-2/src/test/java/com/baeldung/convert/ConvertDateTimeUnitTest.java @@ -0,0 +1,13 @@ +package com.baeldung.convert; + +import org.junit.Test; + +public class ConvertDateTimeUnitTest { + + @Test + public void givenLocalDateTime_WhenGetMillis() { + long millis = ConvertDateTime.java8LocalDateTime(); + System.out.println("LocalDateTime in milliseconds : " + millis); + } + +} From 029ab027edb2d30eb620be5d78dc7388c94c2302 Mon Sep 17 00:00:00 2001 From: "sumit.sg34" Date: Wed, 17 Apr 2019 18:52:51 +0530 Subject: [PATCH 228/531] BAEL-2841 updated code to use multiple xml files --- .../main/java/com/baeldung/config/JpaPopulators.java | 10 ++++++---- .../resources/{fruit-data.xml => apple-fruit-data.xml} | 0 .../src/main/resources/guava-fruit-data.xml | 7 +++++++ 3 files changed, 13 insertions(+), 4 deletions(-) rename persistence-modules/spring-data-jpa-2/src/main/resources/{fruit-data.xml => apple-fruit-data.xml} (100%) create mode 100644 persistence-modules/spring-data-jpa-2/src/main/resources/guava-fruit-data.xml diff --git a/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/config/JpaPopulators.java b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/config/JpaPopulators.java index 0791df85f4..24348d31c5 100644 --- a/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/config/JpaPopulators.java +++ b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/config/JpaPopulators.java @@ -22,11 +22,13 @@ public class JpaPopulators { @Bean public UnmarshallerRepositoryPopulatorFactoryBean repositoryPopulator() { - Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); - marshaller.setClassesToBeBound(Fruit.class); + + Jaxb2Marshaller unmarshaller = new Jaxb2Marshaller(); + unmarshaller.setClassesToBeBound(Fruit.class); + UnmarshallerRepositoryPopulatorFactoryBean factory = new UnmarshallerRepositoryPopulatorFactoryBean(); - factory.setUnmarshaller(marshaller); - factory.setResources(new Resource[] { new ClassPathResource("fruit-data.xml") }); + factory.setUnmarshaller(unmarshaller); + factory.setResources(new Resource[] { new ClassPathResource("apple-fruit-data.xml"), new ClassPathResource("guava-fruit-data.xml") }); return factory; } diff --git a/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.xml b/persistence-modules/spring-data-jpa-2/src/main/resources/apple-fruit-data.xml similarity index 100% rename from persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.xml rename to persistence-modules/spring-data-jpa-2/src/main/resources/apple-fruit-data.xml diff --git a/persistence-modules/spring-data-jpa-2/src/main/resources/guava-fruit-data.xml b/persistence-modules/spring-data-jpa-2/src/main/resources/guava-fruit-data.xml new file mode 100644 index 0000000000..ffd75bb4bb --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/main/resources/guava-fruit-data.xml @@ -0,0 +1,7 @@ + + + + 2 + guava + green + From e8d15ceadcffe4f2f92b831eacb5083132c51bbe Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Wed, 17 Apr 2019 21:51:12 +0300 Subject: [PATCH 229/531] Update README.md --- jackson-simple/README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/jackson-simple/README.md b/jackson-simple/README.md index 5a43bebb29..be647e22d5 100644 --- a/jackson-simple/README.md +++ b/jackson-simple/README.md @@ -1,6 +1,5 @@ ========= - -## Jackson Cookbooks and Examples +### Jackson Articles that are also part of the e-book ###The Course The "REST With Spring" Classes: http://bit.ly/restwithspring @@ -11,4 +10,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Jackson Annotation Examples](http://www.baeldung.com/jackson-annotations) - [Intro to the Jackson ObjectMapper](http://www.baeldung.com/jackson-object-mapper-tutorial) - [Ignore Null Fields with Jackson](http://www.baeldung.com/jackson-ignore-null-fields) -- [Jackson – Change Name of Field](http://www.baeldung.com/jackson-name-of-property) \ No newline at end of file +- [Jackson – Change Name of Field](http://www.baeldung.com/jackson-name-of-property) From 2b0d0665ba7b6fb770da96d9ae71263e4ed191f6 Mon Sep 17 00:00:00 2001 From: Seun Matt Date: Thu, 18 Apr 2019 03:29:57 +0100 Subject: [PATCH 230/531] updated the example code with data.sql (#6749) * added example code for BAEL-2083 * updated example code for BAEL-2083 * added example code for BAEL-2849 * updated the example code with data.sql --- .../src/main/resources/data.sql | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 persistence-modules/spring-boot-h2/spring-boot-h2-database/src/main/resources/data.sql diff --git a/persistence-modules/spring-boot-h2/spring-boot-h2-database/src/main/resources/data.sql b/persistence-modules/spring-boot-h2/spring-boot-h2-database/src/main/resources/data.sql new file mode 100644 index 0000000000..2d7b446005 --- /dev/null +++ b/persistence-modules/spring-boot-h2/spring-boot-h2-database/src/main/resources/data.sql @@ -0,0 +1,13 @@ +DROP TABLE IF EXISTS billionaires; + +CREATE TABLE billionaires ( + id INT AUTO_INCREMENT PRIMARY KEY, + first_name VARCHAR(250) NOT NULL, + last_name VARCHAR(250) NOT NULL, + career VARCHAR(250) DEFAULT NULL +); + +INSERT INTO billionaires (first_name, last_name, career) VALUES +('Aliko', 'Dangote', 'Billionaire Industrialist'), +('Bill', 'Gates', 'Billionaire Tech Entrepreneur'), +('Folrunsho', 'Alakija', 'Billionaire Oil Magnate'); \ No newline at end of file From 275a4acaeaba3037913aaaaa9126dda12aa3100d Mon Sep 17 00:00:00 2001 From: Kumar Chandrakant Date: Thu, 18 Apr 2019 11:13:09 +0530 Subject: [PATCH 231/531] Adding source files for article BAEL-1932 (#6746) --- pom.xml | 5 +- spring-security-kerberos/README.md | 10 +++ spring-security-kerberos/pom.xml | 61 +++++++++++++ .../main/java/org/baeldung/Application.java | 13 +++ .../baeldung/config/WebSecurityConfig.java | 87 +++++++++++++++++++ .../security/DummyUserDetailsService.java | 16 ++++ 6 files changed, 191 insertions(+), 1 deletion(-) create mode 100644 spring-security-kerberos/README.md create mode 100644 spring-security-kerberos/pom.xml create mode 100644 spring-security-kerberos/src/main/java/org/baeldung/Application.java create mode 100644 spring-security-kerberos/src/main/java/org/baeldung/config/WebSecurityConfig.java create mode 100644 spring-security-kerberos/src/main/java/org/baeldung/security/DummyUserDetailsService.java diff --git a/pom.xml b/pom.xml index 79dab80c74..b102b5cd30 100644 --- a/pom.xml +++ b/pom.xml @@ -381,7 +381,7 @@ core-java-8 core-java-8-2 - core-java-lambdas + core-java-lambdas core-java-arrays @@ -542,6 +542,7 @@ tensorflow-java spring-boot-flowable + spring-security-kerberos @@ -769,6 +770,7 @@ tensorflow-java spring-boot-flowable + spring-security-kerberos @@ -913,6 +915,7 @@ persistence-modules/spring-hibernate-5 spring-boot-flowable + spring-security-kerberos diff --git a/spring-security-kerberos/README.md b/spring-security-kerberos/README.md new file mode 100644 index 0000000000..0338c2058c --- /dev/null +++ b/spring-security-kerberos/README.md @@ -0,0 +1,10 @@ +## @PreFilter and @PostFilter annotations + +### Build the Project ### + +``` +mvn clean install +``` + +### Relevant Articles: +- [Spring Security – Kerberos](http://www.baeldung.com/xxxxxx) diff --git a/spring-security-kerberos/pom.xml b/spring-security-kerberos/pom.xml new file mode 100644 index 0000000000..35c4ba4926 --- /dev/null +++ b/spring-security-kerberos/pom.xml @@ -0,0 +1,61 @@ + + 4.0.0 + com.baeldung + spring-security-kerberos + 0.1-SNAPSHOT + spring-security-kerberos + war + + parent-boot-1 + com.baeldung + 0.0.1-SNAPSHOT + ../parent-boot-1 + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-security + + + + org.springframework.security.kerberos + spring-security-kerberos-core + 1.0.1.RELEASE + + + org.springframework.security.kerberos + spring-security-kerberos-web + 1.0.1.RELEASE + + + org.springframework.security.kerberos + spring-security-kerberos-client + 1.0.1.RELEASE + + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.security + spring-security-test + test + + + + + + org.apache.maven.plugins + maven-war-plugin + + + + diff --git a/spring-security-kerberos/src/main/java/org/baeldung/Application.java b/spring-security-kerberos/src/main/java/org/baeldung/Application.java new file mode 100644 index 0000000000..39c2b51356 --- /dev/null +++ b/spring-security-kerberos/src/main/java/org/baeldung/Application.java @@ -0,0 +1,13 @@ +package org.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-security-kerberos/src/main/java/org/baeldung/config/WebSecurityConfig.java b/spring-security-kerberos/src/main/java/org/baeldung/config/WebSecurityConfig.java new file mode 100644 index 0000000000..49a1cf0a8e --- /dev/null +++ b/spring-security-kerberos/src/main/java/org/baeldung/config/WebSecurityConfig.java @@ -0,0 +1,87 @@ +package org.baeldung.config; + +import org.baeldung.security.DummyUserDetailsService; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.FileSystemResource; +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.kerberos.authentication.KerberosAuthenticationProvider; +import org.springframework.security.kerberos.authentication.KerberosServiceAuthenticationProvider; +import org.springframework.security.kerberos.authentication.sun.SunJaasKerberosClient; +import org.springframework.security.kerberos.authentication.sun.SunJaasKerberosTicketValidator; +import org.springframework.security.kerberos.web.authentication.SpnegoAuthenticationProcessingFilter; +import org.springframework.security.kerberos.web.authentication.SpnegoEntryPoint; +import org.springframework.security.web.authentication.www.BasicAuthenticationFilter; + +@Configuration +public class WebSecurityConfig extends WebSecurityConfigurerAdapter { + + @Override + protected void configure(HttpSecurity http) throws Exception { + http.authorizeRequests() + .anyRequest() + .authenticated() + .and() + .addFilterBefore(spnegoAuthenticationProcessingFilter(authenticationManagerBean()), BasicAuthenticationFilter.class); + } + + @Override + @Bean + public AuthenticationManager authenticationManagerBean() throws Exception { + return super.authenticationManagerBean(); + } + + @Override + protected void configure(AuthenticationManagerBuilder auth) throws Exception { + auth.authenticationProvider(kerberosAuthenticationProvider()) + .authenticationProvider(kerberosServiceAuthenticationProvider()); + } + + @Bean + public KerberosAuthenticationProvider kerberosAuthenticationProvider() { + KerberosAuthenticationProvider provider = new KerberosAuthenticationProvider(); + SunJaasKerberosClient client = new SunJaasKerberosClient(); + client.setDebug(true); + provider.setKerberosClient(client); + provider.setUserDetailsService(dummyUserDetailsService()); + return provider; + } + + @Bean + public SpnegoEntryPoint spnegoEntryPoint() { + return new SpnegoEntryPoint("/login"); + } + + @Bean + public SpnegoAuthenticationProcessingFilter spnegoAuthenticationProcessingFilter(AuthenticationManager authenticationManager) { + SpnegoAuthenticationProcessingFilter filter = new SpnegoAuthenticationProcessingFilter(); + filter.setAuthenticationManager(authenticationManager); + return filter; + } + + @Bean + public KerberosServiceAuthenticationProvider kerberosServiceAuthenticationProvider() { + KerberosServiceAuthenticationProvider provider = new KerberosServiceAuthenticationProvider(); + provider.setTicketValidator(sunJaasKerberosTicketValidator()); + provider.setUserDetailsService(dummyUserDetailsService()); + return provider; + } + + @Bean + public SunJaasKerberosTicketValidator sunJaasKerberosTicketValidator() { + SunJaasKerberosTicketValidator ticketValidator = new SunJaasKerberosTicketValidator(); + ticketValidator.setServicePrincipal("HTTP/demo.kerberos.bealdung.com@baeldung.com"); + ticketValidator.setKeyTabLocation(new FileSystemResource("baeldung.keytab")); + ticketValidator.setDebug(true); + return ticketValidator; + } + + @Bean + public DummyUserDetailsService dummyUserDetailsService() { + return new DummyUserDetailsService(); + } + +} \ No newline at end of file diff --git a/spring-security-kerberos/src/main/java/org/baeldung/security/DummyUserDetailsService.java b/spring-security-kerberos/src/main/java/org/baeldung/security/DummyUserDetailsService.java new file mode 100644 index 0000000000..10d71fca8f --- /dev/null +++ b/spring-security-kerberos/src/main/java/org/baeldung/security/DummyUserDetailsService.java @@ -0,0 +1,16 @@ +package org.baeldung.security; + +import org.springframework.security.core.authority.AuthorityUtils; +import org.springframework.security.core.userdetails.User; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.core.userdetails.UsernameNotFoundException; + +public class DummyUserDetailsService implements UserDetailsService { + + @Override + public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { + return new User(username, "notUsed", true, true, true, true, AuthorityUtils.createAuthorityList("ROLE_USER")); + } + +} \ No newline at end of file From a249fbaf6299999ce8a0442a24a4cf73b5da50cd Mon Sep 17 00:00:00 2001 From: Krzysztof Majewski Date: Thu, 18 Apr 2019 10:03:19 +0200 Subject: [PATCH 232/531] BAEL-2493 --- pom.xml | 239 +++++++++--------- spring-boot-configuration/.gitignore | 29 +++ spring-boot-configuration/README.MD | 0 spring-boot-configuration/pom.xml | 41 +++ .../SpringBootConfigurationApplication.java | 13 + .../resources/application-tomcat.properties | 23 ++ .../src/main/resources/application.properties | 1 + .../SpringContextIntegrationTest.java | 16 ++ 8 files changed, 244 insertions(+), 118 deletions(-) create mode 100644 spring-boot-configuration/.gitignore create mode 100644 spring-boot-configuration/README.MD create mode 100644 spring-boot-configuration/pom.xml create mode 100644 spring-boot-configuration/src/main/java/com/baeldung/springbootconfiguration/SpringBootConfigurationApplication.java create mode 100644 spring-boot-configuration/src/main/resources/application-tomcat.properties create mode 100644 spring-boot-configuration/src/main/resources/application.properties create mode 100644 spring-boot-configuration/src/test/java/com/baeldung/springbootconfiguration/SpringContextIntegrationTest.java diff --git a/pom.xml b/pom.xml index b102b5cd30..3bfa182d72 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ 1.0.0-SNAPSHOT parent-modules pom - + lombok-custom @@ -233,7 +233,7 @@ ${maven-war-plugin.version} - + com.vackosar.gitflowincrementalbuilder @@ -377,7 +377,7 @@ checker-plugin core-groovy - + core-java-8 core-java-8-2 @@ -404,7 +404,7 @@ core-scala couchbase custom-pmd - + dagger data-structures ddd @@ -412,13 +412,13 @@ disruptor dozer drools - dubbo - + dubbo + ethereum - + feign flyway-cdi-extension - + geotools google-cloud google-web-toolkit @@ -432,12 +432,12 @@ guava-modules guice - + hazelcast helidon httpclient hystrix - + image-processing immutables @@ -485,7 +485,7 @@ kotlin-libraries - + libraries libraries-2 @@ -512,8 +512,8 @@ mustache mybatis - - + + optaplanner orika osgi @@ -523,9 +523,9 @@ performance-tests protobuffer - + persistence-modules - + rabbitmq ratpack @@ -537,17 +537,17 @@ rule-engines rsocket rxjava - rxjava-2 + rxjava-2 software-security/sql-injection-samples - + tensorflow-java spring-boot-flowable spring-security-kerberos - + - + default-second @@ -581,12 +581,12 @@ parent-spring-5 parent-java parent-kotlin - + saas spark-java - + spring-4 - + spring-5 spring-5-webflux spring-5-data-reactive @@ -597,7 +597,7 @@ spring-5-reactive-security spring-5-security spring-5-security-oauth - + spring-activiti spring-akka spring-all @@ -607,7 +607,7 @@ spring-apache-camel spring-batch spring-bom - + spring-boot spring-boot-admin spring-boot-angular @@ -617,6 +617,7 @@ spring-boot-camel spring-boot-client + spring-boot-configuration spring-boot-crud spring-boot-ctx-fluent spring-boot-custom-starter @@ -635,41 +636,41 @@ spring-boot-testing spring-boot-vue spring-boot-libraries - + spring-cloud spring-cloud-bus spring-cloud-data-flow - + spring-core spring-cucumber - + spring-data-rest spring-data-rest-querydsl spring-dispatcher-servlet spring-drools - + spring-ehcache spring-ejb spring-exceptions - + spring-freemarker - + spring-groovy - + spring-integration - + spring-jenkins-pipeline spring-jersey spring-jinq spring-jms spring-jooq - + spring-kafka spring-katharsis - + spring-ldap - + spring-mobile spring-mockito spring-mvc-forms-jsp @@ -681,12 +682,12 @@ spring-mvc-velocity spring-mvc-webflow spring-mvc-xml - + spring-protobuf - + spring-quartz - + spring-reactive-kotlin spring-reactor spring-remoting @@ -702,9 +703,9 @@ spring-security-acl spring-security-angular/server spring-security-cache-control - + spring-security-client - + spring-security-core spring-security-mvc-boot spring-security-mvc-custom @@ -732,50 +733,50 @@ spring-state-machine spring-static-resources spring-swagger-codegen - + spring-thymeleaf - + spring-userservice - + spring-vault spring-vertx - + spring-webflux-amqp - + spring-zuul - + static-analysis stripe structurizr struts-2 - + testing-modules - + twilio Twitter4J - + undertow - + vavr vertx vertx-and-rxjava video-tutorials vraptor - + wicket - + xml xmlunit-2 xstream - + tensorflow-java spring-boot-flowable spring-security-kerberos - + - + spring-context @@ -817,6 +818,7 @@ spring-boot-bootstrap spring-boot-camel spring-boot-client + spring-boot-configuration spring-boot-custom-starter greeter-spring-boot-autoconfigure greeter-spring-boot-sample-app @@ -913,7 +915,7 @@ persistence-modules/spring-data-eclipselink persistence-modules/spring-data-solr persistence-modules/spring-hibernate-5 - + spring-boot-flowable spring-security-kerberos @@ -953,7 +955,7 @@ parent-spring-5 parent-java parent-kotlin - + core-java-concurrency-advanced core-kotlin core-kotlin-2 @@ -967,12 +969,12 @@ persistence-modules/hibernate5 persistence-modules/java-jpa persistence-modules/java-mongodb - persistence-modules/jnosql + persistence-modules/jnosql - vaadin + vaadin - + integration-lite-first @@ -1045,7 +1047,7 @@ core-groovy core-groovy-2 - + core-java-8 core-java-8-2 @@ -1068,7 +1070,7 @@ core-scala couchbase custom-pmd - + dagger data-structures ddd @@ -1076,13 +1078,13 @@ disruptor dozer drools - dubbo - + dubbo + ethereum - + feign flyway-cdi-extension - + geotools google-cloud google-web-toolkit @@ -1096,12 +1098,12 @@ guava-modules guice - + hazelcast helidon httpclient hystrix - + image-processing immutables @@ -1148,7 +1150,7 @@ kotlin-libraries - + libraries libraries-data @@ -1174,8 +1176,8 @@ mustache mybatis - - + + optaplanner orika osgi @@ -1185,9 +1187,9 @@ performance-tests protobuffer - + persistence-modules - + rabbitmq ratpack @@ -1199,8 +1201,8 @@ rule-engines rsocket rxjava - rxjava-2 - + rxjava-2 + @@ -1234,12 +1236,12 @@ parent-spring-5 parent-java parent-kotlin - + saas spark-java - + spring-4 - + spring-5 spring-5-data-reactive spring-5-mvc @@ -1249,7 +1251,7 @@ spring-5-reactive-security spring-5-security spring-5-security-oauth - + spring-activiti spring-akka spring-all @@ -1259,7 +1261,7 @@ spring-apache-camel spring-batch spring-bom - + spring-boot spring-boot-admin spring-boot-angular @@ -1269,6 +1271,7 @@ spring-boot-camel spring-boot-client + spring-boot-configuration spring-boot-crud spring-boot-ctx-fluent spring-boot-custom-starter @@ -1285,41 +1288,41 @@ spring-boot-property-exp spring-boot-security spring-boot-vue - + spring-cloud spring-cloud-bus spring-cloud-data-flow - + spring-core spring-cucumber - + spring-data-rest spring-data-rest-querydsl spring-dispatcher-servlet spring-drools - - spring-ehcache + + spring-ehcache spring-ejb spring-exceptions - + spring-freemarker - + spring-groovy - + spring-integration - + spring-jenkins-pipeline spring-jersey spring-jinq spring-jms spring-jooq - + spring-kafka spring-katharsis - + spring-ldap - + spring-mobile spring-mockito spring-mvc-forms-jsp @@ -1331,12 +1334,12 @@ spring-mvc-velocity spring-mvc-webflow spring-mvc-xml - + spring-protobuf - + spring-quartz - + spring-reactive-kotlin spring-reactor spring-remoting @@ -1349,13 +1352,13 @@ spring-rest-simple spring-resttemplate spring-roo - + spring-security-acl spring-security-angular/server spring-security-cache-control - + spring-security-client - + spring-security-core spring-security-mvc-boot spring-security-mvc-custom @@ -1382,42 +1385,42 @@ spring-state-machine spring-static-resources spring-swagger-codegen - + spring-thymeleaf - + spring-userservice - + spring-vault spring-vertx - + spring-webflux-amqp - + spring-zuul - + static-analysis stripe structurizr struts-2 - + testing-modules - + twilio Twitter4J - + undertow - + vavr vertx vertx-and-rxjava video-tutorials vraptor - + wicket - + xml xmlunit-2 xstream - + @@ -1451,8 +1454,8 @@ parent-spring-5 parent-java parent-kotlin - - core-java + + core-java core-java-concurrency-advanced core-kotlin core-kotlin-2 @@ -1465,9 +1468,9 @@ persistence-modules/hibernate5 persistence-modules/java-jpa persistence-modules/java-mongodb - persistence-modules/jnosql + persistence-modules/jnosql - vaadin + vaadin @@ -1493,15 +1496,15 @@ false false false - + 4.12 1.3 2.21.0 - + 1.7.21 1.1.7 - + 2.21.0 3.7.0 diff --git a/spring-boot-configuration/.gitignore b/spring-boot-configuration/.gitignore new file mode 100644 index 0000000000..153c9335eb --- /dev/null +++ b/spring-boot-configuration/.gitignore @@ -0,0 +1,29 @@ +HELP.md +/target/ +!.mvn/wrapper/maven-wrapper.jar + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +/build/ + +### VS Code ### +.vscode/ diff --git a/spring-boot-configuration/README.MD b/spring-boot-configuration/README.MD new file mode 100644 index 0000000000..e69de29bb2 diff --git a/spring-boot-configuration/pom.xml b/spring-boot-configuration/pom.xml new file mode 100644 index 0000000000..2ecef7bb02 --- /dev/null +++ b/spring-boot-configuration/pom.xml @@ -0,0 +1,41 @@ + + + 4.0.0 + + + parent-boot-2 + com.baeldung + 0.0.1-SNAPSHOT + ../parent-boot-2 + + + com.baeldung + spring-boot-configuration + 0.0.1-SNAPSHOT + spring-boot-configuration + Demo project for Spring Boot configuration + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/spring-boot-configuration/src/main/java/com/baeldung/springbootconfiguration/SpringBootConfigurationApplication.java b/spring-boot-configuration/src/main/java/com/baeldung/springbootconfiguration/SpringBootConfigurationApplication.java new file mode 100644 index 0000000000..b4f5681475 --- /dev/null +++ b/spring-boot-configuration/src/main/java/com/baeldung/springbootconfiguration/SpringBootConfigurationApplication.java @@ -0,0 +1,13 @@ +package com.baeldung.springbootconfiguration; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpringBootConfigurationApplication { + + public static void main(String[] args) { + SpringApplication.run(SpringBootConfigurationApplication.class, args); + } + +} diff --git a/spring-boot-configuration/src/main/resources/application-tomcat.properties b/spring-boot-configuration/src/main/resources/application-tomcat.properties new file mode 100644 index 0000000000..d7c1ba9ac3 --- /dev/null +++ b/spring-boot-configuration/src/main/resources/application-tomcat.properties @@ -0,0 +1,23 @@ +# server configuration +server.port=80 +server.address=127.0.0.1 + +## Error handling configuration +server.error.whitelabel.enabled=true +server.error.path=/user-error +server.error.include-exception=true +server.error.include-stacktrace=always + +## Server connections configuration +server.tomcat.max-threads=200 +server.connection-timeout=5s +server.max-http-header-size=8KB +server.tomcat.max-swallow-size=2MB +server.tomcat.max-http-post-size=2MB + +## Access logs configuration +server.tomcat.accesslog.enabled=true +server.tomcat.accesslog.directory=logs +server.tomcat.accesslog.file-date-format=yyyy-MM-dd +server.tomcat.accesslog.prefix=access_log +server.tomcat.accesslog.suffix=.log diff --git a/spring-boot-configuration/src/main/resources/application.properties b/spring-boot-configuration/src/main/resources/application.properties new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/spring-boot-configuration/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/spring-boot-configuration/src/test/java/com/baeldung/springbootconfiguration/SpringContextIntegrationTest.java b/spring-boot-configuration/src/test/java/com/baeldung/springbootconfiguration/SpringContextIntegrationTest.java new file mode 100644 index 0000000000..d6b2b50a2f --- /dev/null +++ b/spring-boot-configuration/src/test/java/com/baeldung/springbootconfiguration/SpringContextIntegrationTest.java @@ -0,0 +1,16 @@ +package com.baeldung.springbootconfiguration; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class SpringContextIntegrationTest { + + @Test + public void contextLoads() { + } + +} From 637f2e945aaceb5c4b3162660bd45fc0cd6de1b2 Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Thu, 18 Apr 2019 16:05:44 +0400 Subject: [PATCH 233/531] added unit tests --- .../convert/ConvertDateTimeUnitTest.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/java-dates-2/src/test/java/com/baeldung/convert/ConvertDateTimeUnitTest.java b/java-dates-2/src/test/java/com/baeldung/convert/ConvertDateTimeUnitTest.java index a2e15461d0..616566732f 100644 --- a/java-dates-2/src/test/java/com/baeldung/convert/ConvertDateTimeUnitTest.java +++ b/java-dates-2/src/test/java/com/baeldung/convert/ConvertDateTimeUnitTest.java @@ -10,4 +10,33 @@ public class ConvertDateTimeUnitTest { System.out.println("LocalDateTime in milliseconds : " + millis); } + @Test + public void givenJava8Instant_WhenGetMillis() { + long millis = ConvertDateTime.java8Instant(); + System.out.println("Java 8 Instant in milliseconds : " + millis); + } + + @Test + public void givenDate_WhenGetMillis() { + long millis = ConvertDateTime.coreDate(); + System.out.println("Core Date in milliseconds : " + millis); + } + + @Test + public void givenCalendar_WhenGetMillis() { + long millis = ConvertDateTime.calendar(); + System.out.println("Calendar in milliseconds : " + millis); + } + + @Test + public void givenJodaInstant_WhenGetMillis() { + long millis = ConvertDateTime.jodaInstant(); + System.out.println("JODA Instant in milliseconds : " + millis); + } + + @Test + public void givenJODADateTime_WhenGetMillis() { + long millis = ConvertDateTime.jodaDateTime(); + System.out.println("JODA DateTime in milliseconds : " + millis); + } } From 15b053c6a84a6ec00ab8424d8a5401a464bb38a3 Mon Sep 17 00:00:00 2001 From: Ger Roza Date: Thu, 18 Apr 2019 12:34:40 -0300 Subject: [PATCH 234/531] [BAEL-2735] REST-Assured Authentication article (#6753) * Added restassured test using basic auth, form auth and digest. * Added Rest Assured Authentication - OAuth Live Test * Add Authentication with Rest Assured for autoconfigured Form Login * Add OAuth 1 Rest Assured scenario --- testing-modules/rest-assured/pom.xml | 13 ++++ .../BasicAuthenticationLiveTest.java | 38 ++++++++++++ .../BasicPreemtiveAuthenticationLiveTest.java | 56 +++++++++++++++++ .../DigestAuthenticationLiveTest.java | 40 ++++++++++++ .../FormAuthenticationLiveTest.java | 57 +++++++++++++++++ .../FormAutoconfAuthenticationLiveTest.java | 42 +++++++++++++ .../OAuth2AuthenticationLiveTest.java | 61 +++++++++++++++++++ .../OAuthAuthenticationLiveTest.java | 53 ++++++++++++++++ 8 files changed, 360 insertions(+) create mode 100644 testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/BasicAuthenticationLiveTest.java create mode 100644 testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/BasicPreemtiveAuthenticationLiveTest.java create mode 100644 testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/DigestAuthenticationLiveTest.java create mode 100644 testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/FormAuthenticationLiveTest.java create mode 100644 testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/FormAutoconfAuthenticationLiveTest.java create mode 100644 testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/OAuth2AuthenticationLiveTest.java create mode 100644 testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/OAuthAuthenticationLiveTest.java diff --git a/testing-modules/rest-assured/pom.xml b/testing-modules/rest-assured/pom.xml index cd342ccd11..c528a34e21 100644 --- a/testing-modules/rest-assured/pom.xml +++ b/testing-modules/rest-assured/pom.xml @@ -162,6 +162,11 @@ commons-collections ${commons-collections.version} + + + org.springframework.boot + spring-boot-starter-security + @@ -179,6 +184,12 @@ json-schema-validator test + + com.github.scribejava + scribejava-apis + ${scribejava.version} + test + @@ -211,6 +222,8 @@ 3.0.1 3.0.1 + + 2.5.3 diff --git a/testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/BasicAuthenticationLiveTest.java b/testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/BasicAuthenticationLiveTest.java new file mode 100644 index 0000000000..aff765dfa3 --- /dev/null +++ b/testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/BasicAuthenticationLiveTest.java @@ -0,0 +1,38 @@ +package com.baeldung.restassured.authentication; + +import static io.restassured.RestAssured.get; +import static io.restassured.RestAssured.given; + +import org.junit.jupiter.api.Test; +import org.springframework.http.HttpStatus; + +/** + * For this Live Test we need: + * * a running instance of the service located in the spring-security-rest-basic-auth module. + * @see spring-security-rest-basic-auth module + * + */ +public class BasicAuthenticationLiveTest { + + private static final String USER = "user1"; + private static final String PASSWORD = "user1Pass"; + private static final String SVC_URL = "http://localhost:8080/spring-security-rest-basic-auth/api/foos/1"; + + @Test + public void givenNoAuthentication_whenRequestSecuredResource_thenUnauthorizedResponse() { + get(SVC_URL).then() + .assertThat() + .statusCode(HttpStatus.UNAUTHORIZED.value()); + } + + @Test + public void givenBasicAuthentication_whenRequestSecuredResource_thenResourceRetrieved() { + given().auth() + .basic(USER, PASSWORD) + .when() + .get(SVC_URL) + .then() + .assertThat() + .statusCode(HttpStatus.OK.value()); + } +} diff --git a/testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/BasicPreemtiveAuthenticationLiveTest.java b/testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/BasicPreemtiveAuthenticationLiveTest.java new file mode 100644 index 0000000000..02138f22e3 --- /dev/null +++ b/testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/BasicPreemtiveAuthenticationLiveTest.java @@ -0,0 +1,56 @@ +package com.baeldung.restassured.authentication; + +import static io.restassured.RestAssured.get; +import static io.restassured.RestAssured.given; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.is; + +import org.junit.jupiter.api.Test; +import org.springframework.http.HttpStatus; + +/** + * For this Live Test we need: + * * a running instance of the service located in the spring-boot-admin/spring-boot-admin-server module. + * @see spring-boot-admin/spring-boot-admin-server module + * + */ +public class BasicPreemtiveAuthenticationLiveTest { + + private static final String USER = "admin"; + private static final String PASSWORD = "admin"; + private static final String SVC_URL = "http://localhost:8080/api/applications/"; + + @Test + public void givenNoAuthentication_whenRequestSecuredResource_thenUnauthorizedResponse() { + get(SVC_URL).then() + .assertThat() + .statusCode(HttpStatus.OK.value()) + .content(containsString("spring-security-mvc-digest-auth module + * + */ +public class DigestAuthenticationLiveTest { + + private static final String USER = "user1"; + private static final String PASSWORD = "user1Pass"; + private static final String SVC_URL = "http://localhost:8080/spring-security-mvc-digest-auth/homepage.html"; + + @Test + public void givenNoAuthentication_whenRequestSecuredResource_thenUnauthorizedResponse() { + get(SVC_URL).then() + .assertThat() + .statusCode(HttpStatus.UNAUTHORIZED.value()); + } + + @Test + public void givenFormAuthentication_whenRequestSecuredResource_thenResourceRetrieved() { + given().auth() + .digest(USER, PASSWORD) + .when() + .get(SVC_URL) + .then() + .assertThat() + .statusCode(HttpStatus.OK.value()) + .content(containsString("This is the body of the sample view")); + } +} diff --git a/testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/FormAuthenticationLiveTest.java b/testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/FormAuthenticationLiveTest.java new file mode 100644 index 0000000000..66ae9fb162 --- /dev/null +++ b/testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/FormAuthenticationLiveTest.java @@ -0,0 +1,57 @@ +package com.baeldung.restassured.authentication; + +import static io.restassured.RestAssured.get; +import static io.restassured.RestAssured.given; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.isEmptyString; + +import org.junit.jupiter.api.Test; +import org.springframework.http.HttpStatus; + +import io.restassured.authentication.FormAuthConfig; + +/** + * For this Live Test we need: + * * a running instance of the service located in the spring-security-mvc-login module. + * @see spring-security-mvc-login module + * + */ +public class FormAuthenticationLiveTest { + + private static final String USER = "user1"; + private static final String PASSWORD = "user1Pass"; + private static final String SVC_URL = "http://localhost:8080/spring-security-mvc-login/secured"; + + @Test + public void givenNoAuthentication_whenRequestSecuredResource_thenLoginFormResponse() { + get(SVC_URL).then() + .assertThat() + .statusCode(HttpStatus.OK.value()) + .content(containsString("spring-boot-admin/spring-boot-admin-server module + * + */ +public class FormAutoconfAuthenticationLiveTest { + + private static final String USER = "admin"; + private static final String PASSWORD = "admin"; + private static final String SVC_URL = "http://localhost:8080/ger1/api/applications/"; + + @Test + public void givenNoAuthentication_whenRequestSecuredResource_thenUnauthorizedResponse() { + get(SVC_URL).then() + .assertThat() + .statusCode(HttpStatus.OK.value()) + .content(containsString("spring-security-oauth/oauth-authorization-server module + * + * * a running instance of the service located in the spring-security-oauth repo - oauth-resource-server-1 module. + * @see spring-security-oauth/oauth-resource-server-1 module + * + */ +public class OAuth2AuthenticationLiveTest { + + private static final String USER = "john"; + private static final String PASSWORD = "123"; + private static final String CLIENT_ID = "fooClientIdPassword"; + private static final String SECRET = "secret"; + private static final String AUTH_SVC_TOKEN_URL = "http://localhost:8081/spring-security-oauth-server/oauth/token"; + private static final String RESOURCE_SVC_URL = "http://localhost:8082/spring-security-oauth-resource/foos/1"; + + @Test + public void givenNoAuthentication_whenRequestSecuredResource_thenUnauthorizedResponse() { + get(RESOURCE_SVC_URL).then() + .assertThat() + .statusCode(HttpStatus.UNAUTHORIZED.value()); + } + + @Test + public void givenAccessTokenAuthentication_whenRequestSecuredResource_thenResourceRetrieved() { + String accessToken = given().auth() + .basic(CLIENT_ID, SECRET) + .formParam("grant_type", "password") + .formParam("username", USER) + .formParam("password", PASSWORD) + .formParam("scope", "read foo") + .when() + .post(AUTH_SVC_TOKEN_URL) + .then() + .assertThat() + .statusCode(HttpStatus.OK.value()) + .extract() + .path("access_token"); + + given().auth() + .oauth2(accessToken) + .when() + .get(RESOURCE_SVC_URL) + .then() + .assertThat() + .statusCode(HttpStatus.OK.value()) + .body("$", hasKey("id")) + .body("$", hasKey("name")); + } +} diff --git a/testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/OAuthAuthenticationLiveTest.java b/testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/OAuthAuthenticationLiveTest.java new file mode 100644 index 0000000000..c720bc04e4 --- /dev/null +++ b/testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/OAuthAuthenticationLiveTest.java @@ -0,0 +1,53 @@ +package com.baeldung.restassured.authentication; + +import static io.restassured.RestAssured.get; +import static io.restassured.RestAssured.given; +import static org.hamcrest.Matchers.hasKey; + +import org.junit.jupiter.api.Test; +import org.springframework.http.HttpStatus; + +import io.restassured.http.ContentType; + +/** + * For this Live Test we need to obtain a valid Access Token and Token Secret: + * * start spring-mvc-simple application in debug mode + * @see spring-mvc-simple module + * * calling localhost:8080/spring-mvc-simple/twitter/authorization/ using the browser + * * debug the callback function where we can obtain the fields + */ +public class OAuthAuthenticationLiveTest { + + // We can obtain these two from the spring-mvc-simple / TwitterController class + private static final String OAUTH_API_KEY = "PSRszoHhRDVhyo2RIkThEbWko"; + private static final String OAUTH_API_SECRET = "prpJbz03DcGRN46sb4ucdSYtVxG8unUKhcnu3an5ItXbEOuenL"; + private static final String TWITTER_ENDPOINT = "https://api.twitter.com/1.1/account/settings.json"; + /* We can obtain the following by: + * - starting the spring-mvc-simple application + * - calling localhost:8080/spring-mvc-simple/twitter/authorization/ + * - debugging the callback function */ + private static final String ACCESS_TOKEN = "..."; + private static final String TOKEN_SECRET = "..."; + + @Test + public void givenNoAuthentication_whenRequestSecuredResource_thenUnauthorizedResponse() { + get(TWITTER_ENDPOINT).then() + .assertThat() + .statusCode(HttpStatus.BAD_REQUEST.value()); + } + + @Test + public void givenAccessTokenAuthentication_whenRequestSecuredResource_thenResourceIsRequested() { + given().accept(ContentType.JSON) + .auth() + .oauth(OAUTH_API_KEY, OAUTH_API_SECRET, ACCESS_TOKEN, TOKEN_SECRET) + .when() + .get(TWITTER_ENDPOINT) + .then() + .assertThat() + .statusCode(HttpStatus.OK.value()) + .body("$", hasKey("geo_enabled")) + .body("$", hasKey("language")); + } + +} From 12631714658e43f7e4b79ffd3765ed199251f390 Mon Sep 17 00:00:00 2001 From: Kacper Koza Date: Thu, 18 Apr 2019 22:21:35 +0200 Subject: [PATCH 235/531] read src/test/resources --- .../ReadResourceDirectoryTest.java | 42 +++++++++++++++++++ .../src/test/resources/example_resource.txt | 0 2 files changed, 42 insertions(+) create mode 100644 testing-modules/junit-5/src/test/java/com/baeldung/resourcedirectory/ReadResourceDirectoryTest.java create mode 100644 testing-modules/junit-5/src/test/resources/example_resource.txt diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/resourcedirectory/ReadResourceDirectoryTest.java b/testing-modules/junit-5/src/test/java/com/baeldung/resourcedirectory/ReadResourceDirectoryTest.java new file mode 100644 index 0000000000..20951dc7eb --- /dev/null +++ b/testing-modules/junit-5/src/test/java/com/baeldung/resourcedirectory/ReadResourceDirectoryTest.java @@ -0,0 +1,42 @@ +package com.baeldung.resourcedirectory; + +import org.junit.Test; + +import java.io.File; +import java.nio.file.Path; +import java.nio.file.Paths; + +public class ReadResourceDirectoryTest { + + @Test + public void shouldReadResourceAbsolutePathWithFile() { + String path = "src/test/resources"; + + File file = new File(path); + String absolutePath = file.getAbsolutePath(); + + System.out.println(absolutePath); + } + + @Test + public void shouldReadResourceAbsolutePathWithResources() { + String resourceName = "example_resource.txt"; + + ClassLoader classLoader = getClass().getClassLoader(); + File file = new File(classLoader.getResource(resourceName).getFile()); + String absolutePath = file.getAbsolutePath(); + + System.out.println(absolutePath); + } + + @Test + public void shouldReadResourceAbsolutePathWithPaths() { + Path resourceDirectory = Paths.get("src","test","resources"); + + String absolutePath = resourceDirectory.toFile().getAbsolutePath(); + + System.out.println(absolutePath); + } + + +} diff --git a/testing-modules/junit-5/src/test/resources/example_resource.txt b/testing-modules/junit-5/src/test/resources/example_resource.txt new file mode 100644 index 0000000000..e69de29bb2 From d6235c73e623f227ef63ae94565e49b5763f428d Mon Sep 17 00:00:00 2001 From: Kacper Koza Date: Thu, 18 Apr 2019 22:25:17 +0200 Subject: [PATCH 236/531] master --- ...rceDirectoryTest.java => ReadResourceDirectoryUnitTest.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename testing-modules/junit-5/src/test/java/com/baeldung/resourcedirectory/{ReadResourceDirectoryTest.java => ReadResourceDirectoryUnitTest.java} (95%) diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/resourcedirectory/ReadResourceDirectoryTest.java b/testing-modules/junit-5/src/test/java/com/baeldung/resourcedirectory/ReadResourceDirectoryUnitTest.java similarity index 95% rename from testing-modules/junit-5/src/test/java/com/baeldung/resourcedirectory/ReadResourceDirectoryTest.java rename to testing-modules/junit-5/src/test/java/com/baeldung/resourcedirectory/ReadResourceDirectoryUnitTest.java index 20951dc7eb..89a144adfa 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/resourcedirectory/ReadResourceDirectoryTest.java +++ b/testing-modules/junit-5/src/test/java/com/baeldung/resourcedirectory/ReadResourceDirectoryUnitTest.java @@ -6,7 +6,7 @@ import java.io.File; import java.nio.file.Path; import java.nio.file.Paths; -public class ReadResourceDirectoryTest { +public class ReadResourceDirectoryUnitTest { @Test public void shouldReadResourceAbsolutePathWithFile() { From c587c0b5dd0cbbff2687b7915a9aac5472f4678c Mon Sep 17 00:00:00 2001 From: macroscopic64 Date: Fri, 19 Apr 2019 07:04:58 +0530 Subject: [PATCH 237/531] [BAEL-2073] Java 9 Migration Issues and Resolution --- {prejpms => core-java-modules/pre-jpms}/pom.xml | 3 ++- .../pre-jpms}/src/main/java/com/baeldung/prejpms/App.java | 0 .../pre-jpms}/src/main/java/com/baeldung/prejpms/Book.java | 0 .../pre-jpms}/src/main/resources/logback.xml | 0 4 files changed, 2 insertions(+), 1 deletion(-) rename {prejpms => core-java-modules/pre-jpms}/pom.xml (96%) rename {prejpms => core-java-modules/pre-jpms}/src/main/java/com/baeldung/prejpms/App.java (100%) rename {prejpms => core-java-modules/pre-jpms}/src/main/java/com/baeldung/prejpms/Book.java (100%) rename {prejpms => core-java-modules/pre-jpms}/src/main/resources/logback.xml (100%) diff --git a/prejpms/pom.xml b/core-java-modules/pre-jpms/pom.xml similarity index 96% rename from prejpms/pom.xml rename to core-java-modules/pre-jpms/pom.xml index 0f0216682e..169cd21f3e 100644 --- a/prejpms/pom.xml +++ b/core-java-modules/pre-jpms/pom.xml @@ -2,7 +2,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 - prejpms + pre-jpms 0.0.1-SNAPSHOT jar pre-jpms @@ -11,6 +11,7 @@ parent-modules com.baeldung 1.0.0-SNAPSHOT + ../../ diff --git a/prejpms/src/main/java/com/baeldung/prejpms/App.java b/core-java-modules/pre-jpms/src/main/java/com/baeldung/prejpms/App.java similarity index 100% rename from prejpms/src/main/java/com/baeldung/prejpms/App.java rename to core-java-modules/pre-jpms/src/main/java/com/baeldung/prejpms/App.java diff --git a/prejpms/src/main/java/com/baeldung/prejpms/Book.java b/core-java-modules/pre-jpms/src/main/java/com/baeldung/prejpms/Book.java similarity index 100% rename from prejpms/src/main/java/com/baeldung/prejpms/Book.java rename to core-java-modules/pre-jpms/src/main/java/com/baeldung/prejpms/Book.java diff --git a/prejpms/src/main/resources/logback.xml b/core-java-modules/pre-jpms/src/main/resources/logback.xml similarity index 100% rename from prejpms/src/main/resources/logback.xml rename to core-java-modules/pre-jpms/src/main/resources/logback.xml From 062ea56d7ab5ba21a940695cedd18e75d981f35d Mon Sep 17 00:00:00 2001 From: Andrey Shcherbakov Date: Fri, 19 Apr 2019 03:54:24 +0200 Subject: [PATCH 238/531] Move code for BAEL-2833 from core-java-8-2 to core-java-lang-oop-2 (#6755) --- .../src/test/java/com/baeldung/UnitTest.java | 18 ------------------ .../main/java/com/baeldung/anonymous/Book.java | 0 .../main/java/com/baeldung/anonymous/Main.java | 0 3 files changed, 18 deletions(-) delete mode 100644 core-java-8-2/src/test/java/com/baeldung/UnitTest.java rename {core-java-8-2 => core-java-lang-oop-2}/src/main/java/com/baeldung/anonymous/Book.java (100%) rename {core-java-8-2 => core-java-lang-oop-2}/src/main/java/com/baeldung/anonymous/Main.java (100%) diff --git a/core-java-8-2/src/test/java/com/baeldung/UnitTest.java b/core-java-8-2/src/test/java/com/baeldung/UnitTest.java deleted file mode 100644 index 9757901f52..0000000000 --- a/core-java-8-2/src/test/java/com/baeldung/UnitTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.baeldung; - -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -/** - * Unit test for simple App. - */ -public class UnitTest { - /** - * Stub test - */ - @Test - public void givenPreconditions_whenCondition_shouldResult() { - assertTrue(true); - } -} diff --git a/core-java-8-2/src/main/java/com/baeldung/anonymous/Book.java b/core-java-lang-oop-2/src/main/java/com/baeldung/anonymous/Book.java similarity index 100% rename from core-java-8-2/src/main/java/com/baeldung/anonymous/Book.java rename to core-java-lang-oop-2/src/main/java/com/baeldung/anonymous/Book.java diff --git a/core-java-8-2/src/main/java/com/baeldung/anonymous/Main.java b/core-java-lang-oop-2/src/main/java/com/baeldung/anonymous/Main.java similarity index 100% rename from core-java-8-2/src/main/java/com/baeldung/anonymous/Main.java rename to core-java-lang-oop-2/src/main/java/com/baeldung/anonymous/Main.java From d5ee7de5a55cb3269436e01485155f1d005e2bab Mon Sep 17 00:00:00 2001 From: Eric Martin Date: Thu, 18 Apr 2019 21:37:00 -0500 Subject: [PATCH 239/531] Update pom.xml Fixed start-class in pom --- spring-boot-mvc-birt/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-mvc-birt/pom.xml b/spring-boot-mvc-birt/pom.xml index 05d3f3865a..8f41e8410a 100644 --- a/spring-boot-mvc-birt/pom.xml +++ b/spring-boot-mvc-birt/pom.xml @@ -75,7 +75,7 @@ 2.1.1.RELEASE - com.baeldung.springbootmvc.SpringBootMvcApplication + com.baeldung.birt.engine.ReportEngineApplication 1.8 1.8 From f6b1967cbee9604330ff4a2717f6c2b39a048c58 Mon Sep 17 00:00:00 2001 From: Juan Moreno Date: Thu, 18 Apr 2019 23:40:33 -0300 Subject: [PATCH 240/531] BAEL-2655 Sample code (#6731) * Upgraded dependencies * Fixed test in Linux Environment * Added I/O samples * FIX End of line reference, previous version was OS dependent * CHORE Added junit5 dependency * UPGRADE gradle version, UPDATE versions * Deleted emtpy lines --- core-kotlin-2/build.gradle | 22 +++-- .../gradle/wrapper/gradle-wrapper.jar | Bin 54329 -> 55616 bytes .../gradle/wrapper/gradle-wrapper.properties | 2 +- core-kotlin-2/gradlew | 18 +++- core-kotlin-2/gradlew.bat | 18 +++- core-kotlin-2/pom.xml | 33 ++++++-- .../com/baeldung/console/ConsoleIOUnitTest.kt | 79 ++++++++++++++++++ .../org.mockito.plugins.MockMaker | 1 + .../inputstream/InputStreamToStringTest.kt | 5 +- parent-kotlin/pom.xml | 6 +- 10 files changed, 163 insertions(+), 21 deletions(-) create mode 100644 core-kotlin-2/src/test/kotlin/com/baeldung/console/ConsoleIOUnitTest.kt create mode 100644 core-kotlin-2/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker diff --git a/core-kotlin-2/build.gradle b/core-kotlin-2/build.gradle index b058e0ecad..1c52172404 100644 --- a/core-kotlin-2/build.gradle +++ b/core-kotlin-2/build.gradle @@ -5,7 +5,7 @@ version '1.0-SNAPSHOT' buildscript { - ext.kotlin_version = '1.2.41' + ext.kotlin_version = '1.3.30' repositories { mavenCentral() @@ -26,8 +26,6 @@ sourceCompatibility = 1.8 compileKotlin { kotlinOptions.jvmTarget = "1.8" } compileTestKotlin { kotlinOptions.jvmTarget = "1.8" } -kotlin { experimental { coroutines "enable" } } - repositories { mavenCentral() jcenter() @@ -39,10 +37,22 @@ sourceSets { srcDirs 'com/baeldung/ktor' } } +} +test { + useJUnitPlatform() + testLogging { + events "passed", "skipped", "failed" + } } dependencies { - compile "ch.qos.logback:logback-classic:1.2.1" - testCompile group: 'junit', name: 'junit', version: '4.12' -} \ No newline at end of file + implementation "ch.qos.logback:logback-classic:1.2.1" + implementation "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}" + testImplementation 'org.junit.jupiter:junit-jupiter:5.4.2' + testImplementation 'junit:junit:4.12' + testImplementation 'org.assertj:assertj-core:3.12.2' + testImplementation 'org.mockito:mockito-core:2.27.0' + testImplementation "org.jetbrains.kotlin:kotlin-test:${kotlin_version}" + testImplementation "org.jetbrains.kotlin:kotlin-test-junit5:${kotlin_version}" +} diff --git a/core-kotlin-2/gradle/wrapper/gradle-wrapper.jar b/core-kotlin-2/gradle/wrapper/gradle-wrapper.jar index 01b8bf6b1f99cad9213fc495b33ad5bbab8efd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