From 4474ffdc85fac7d17063dd4f648c9b84678d6a09 Mon Sep 17 00:00:00 2001 From: Karsten Silz Date: Sun, 22 Mar 2020 17:48:41 +0000 Subject: [PATCH 001/263] Initial version of the code. --- .../core-java-date-operations-2/README.md | 1 + .../dayofweek/DayOfWeekExtractor.java | 35 +++++++++++++ .../dayofweek/DayOfWeekExtractorUnitTest.java | 52 +++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 core-java-modules/core-java-date-operations-2/src/main/java/com/baeldung/datetime/dayofweek/DayOfWeekExtractor.java create mode 100644 core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/datetime/dayofweek/DayOfWeekExtractorUnitTest.java diff --git a/core-java-modules/core-java-date-operations-2/README.md b/core-java-modules/core-java-date-operations-2/README.md index 728162ca1a..0f57686fe4 100644 --- a/core-java-modules/core-java-date-operations-2/README.md +++ b/core-java-modules/core-java-date-operations-2/README.md @@ -7,4 +7,5 @@ This module contains articles about date operations in Java. - [Checking If Two Java Dates Are on the Same Day](https://www.baeldung.com/java-check-two-dates-on-same-day) - [Converting Java Date to OffsetDateTime](https://www.baeldung.com/java-convert-date-to-offsetdatetime) - [How to Set the JVM Time Zone](https://www.baeldung.com/java-jvm-time-zone) +- [Extracting the Day of the Week](http://inprogress.baeldung.com/wp-admin/post.php?post=184664&action=edit&classic-editor) - [[<-- Prev]](/core-java-modules/core-java-date-operations-1) diff --git a/core-java-modules/core-java-date-operations-2/src/main/java/com/baeldung/datetime/dayofweek/DayOfWeekExtractor.java b/core-java-modules/core-java-date-operations-2/src/main/java/com/baeldung/datetime/dayofweek/DayOfWeekExtractor.java new file mode 100644 index 0000000000..b027790e35 --- /dev/null +++ b/core-java-modules/core-java-date-operations-2/src/main/java/com/baeldung/datetime/dayofweek/DayOfWeekExtractor.java @@ -0,0 +1,35 @@ +package com.baeldung.datetime.dayofweek; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.time.DayOfWeek; +import java.time.LocalDate; +import java.time.format.TextStyle; +import java.util.Calendar; +import java.util.Date; +import java.util.Locale; + +public class DayOfWeekExtractor { + + public static int getDayNumberOld(Date date) { + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + return cal.get(Calendar.DAY_OF_WEEK); + } + + public static String getDayStringOld(Date date, Locale locale ) { + DateFormat formatter = new SimpleDateFormat("EEEE", locale); + return formatter.format(date); + } + + public static int getDayNumberNew(LocalDate date) { + DayOfWeek day = date.getDayOfWeek(); + return day.getValue(); + } + + public static String getDayStringNew(LocalDate date, Locale locale ) { + DayOfWeek day = date.getDayOfWeek(); + return day.getDisplayName(TextStyle.FULL, locale); + } + +} diff --git a/core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/datetime/dayofweek/DayOfWeekExtractorUnitTest.java b/core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/datetime/dayofweek/DayOfWeekExtractorUnitTest.java new file mode 100644 index 0000000000..0dfd50dca2 --- /dev/null +++ b/core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/datetime/dayofweek/DayOfWeekExtractorUnitTest.java @@ -0,0 +1,52 @@ +package com.baeldung.datetime.dayofweek; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.util.Calendar; +import java.util.Locale; + +import org.junit.Test; + +public class DayOfWeekExtractorUnitTest { + + private DateFormat oldDateParser = new SimpleDateFormat("yyyy-MM-dd"); + + @Test + public void givenFeb29_2020_thenOldSaturdayNumber() throws ParseException { + assertThat(DayOfWeekExtractor.getDayNumberOld(oldDateParser.parse("2020-02-29")) == Calendar.SATURDAY); + } + + @Test + public void givenFeb29_2020_and_localeUS_thenOldSaturdayText() throws ParseException { + assertThat("Saturday".equals(DayOfWeekExtractor.getDayStringOld(oldDateParser.parse("2020-02-29"), Locale.US)) ); + } + + @Test + public void givenFeb29_2020_and_localeDE_thenOldSaturdayText() throws ParseException { + assertThat("Samstag".equals(DayOfWeekExtractor.getDayStringOld(oldDateParser.parse("2020-02-29"), Locale.GERMANY)) ); + } + + @Test + public void givenFeb29_2020_thenNewSaturdayNumber() throws ParseException { + assertThat(DayOfWeekExtractor.getDayNumberNew(LocalDate.parse("2020-02-29")) == Calendar.SATURDAY); + } + + @Test + public void givenFeb29_2020_and_localeUS_thenNewSaturdayText() throws ParseException { + assertThat("Saturday".equals(DayOfWeekExtractor.getDayStringOld(oldDateParser.parse("2020-02-29"), Locale.US)) ); + } + + @Test + public void givenFeb29_2020_and_localeDE_thenNewSaturdayText() throws ParseException { + assertThat("Samstag".equals(DayOfWeekExtractor.getDayStringOld(oldDateParser.parse("2020-02-29"), Locale.GERMANY)) ); + } + + +} + + + From b5787f39cd9092dd05e93abbef6fe0e3808b318b Mon Sep 17 00:00:00 2001 From: Karsten Silz Date: Mon, 23 Mar 2020 16:27:23 +0000 Subject: [PATCH 002/263] Addressed PR comment. --- core-java-modules/core-java-date-operations-2/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/core-java-modules/core-java-date-operations-2/README.md b/core-java-modules/core-java-date-operations-2/README.md index 0f57686fe4..728162ca1a 100644 --- a/core-java-modules/core-java-date-operations-2/README.md +++ b/core-java-modules/core-java-date-operations-2/README.md @@ -7,5 +7,4 @@ This module contains articles about date operations in Java. - [Checking If Two Java Dates Are on the Same Day](https://www.baeldung.com/java-check-two-dates-on-same-day) - [Converting Java Date to OffsetDateTime](https://www.baeldung.com/java-convert-date-to-offsetdatetime) - [How to Set the JVM Time Zone](https://www.baeldung.com/java-jvm-time-zone) -- [Extracting the Day of the Week](http://inprogress.baeldung.com/wp-admin/post.php?post=184664&action=edit&classic-editor) - [[<-- Prev]](/core-java-modules/core-java-date-operations-1) From 211d1c98869a976f85caee93e06a83d94f4fdf0c Mon Sep 17 00:00:00 2001 From: akeshri Date: Sun, 28 Jun 2020 22:31:13 +0530 Subject: [PATCH 003/263] Create pom.xml --- hexagonal-architecture/pom.xml | 46 ++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 hexagonal-architecture/pom.xml diff --git a/hexagonal-architecture/pom.xml b/hexagonal-architecture/pom.xml new file mode 100644 index 0000000000..87e599318c --- /dev/null +++ b/hexagonal-architecture/pom.xml @@ -0,0 +1,46 @@ + + 4.0.0 + + com.article + hexagonal-architecture + 0.0.1-SNAPSHOT + jar + + org.springframework.boot + spring-boot-starter-parent + 1.3.1.RELEASE + + + hexagonal-architecture + http://maven.apache.org + + + UTF-8 + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-data-jpa + + + com.h2database + h2 + + + org.springframework.boot + spring-boot-starter-test + test + + + com.fasterxml.jackson.dataformat + jackson-dataformat-csv + + + From 8b8554eb84e9d02e73affde7b302b0a87ccbf1b5 Mon Sep 17 00:00:00 2001 From: akeshri Date: Sun, 28 Jun 2020 22:32:39 +0530 Subject: [PATCH 004/263] Add files via upload --- .../baeldung/hexagonal/architecture/App.java | 18 ++++ .../hexagonal/architecture/ConsoleApp.java | 48 ++++++++++ .../controller/ProductController.java | 52 +++++++++++ .../architecture/dtos/ProductDto.java | 71 +++++++++++++++ .../hexagonal/architecture/model/Product.java | 87 +++++++++++++++++++ .../repository/ProductRepository.java | 14 +++ .../architecture/service/ProductService.java | 21 +++++ .../service/ProductServiceImpl.java | 44 ++++++++++ .../resources/application-batch.properties | 9 ++ .../resources/application-test.properties | 8 ++ .../src/main/resources/application.properties | 8 ++ .../src/main/resources/db/PRODUCT.sql | 9 ++ .../service/ProductServiceTest.java | 43 +++++++++ 13 files changed, 432 insertions(+) create mode 100644 hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/App.java create mode 100644 hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/ConsoleApp.java create mode 100644 hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/controller/ProductController.java create mode 100644 hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/dtos/ProductDto.java create mode 100644 hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/model/Product.java create mode 100644 hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/repository/ProductRepository.java create mode 100644 hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/service/ProductService.java create mode 100644 hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/service/ProductServiceImpl.java create mode 100644 hexagonal-architecture/src/main/resources/application-batch.properties create mode 100644 hexagonal-architecture/src/main/resources/application-test.properties create mode 100644 hexagonal-architecture/src/main/resources/application.properties create mode 100644 hexagonal-architecture/src/main/resources/db/PRODUCT.sql create mode 100644 hexagonal-architecture/src/test/java/com/baeldung/hexagonal/architecture/service/ProductServiceTest.java diff --git a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/App.java b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/App.java new file mode 100644 index 0000000000..3563e3a0ec --- /dev/null +++ b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/App.java @@ -0,0 +1,18 @@ +package com.baeldung.hexagonal.architecture; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * @author AshwiniKeshri + * + */ + +@SpringBootApplication +public class App +{ + public static void main( String[] args ) + { + SpringApplication.run(App.class, args); + } +} diff --git a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/ConsoleApp.java b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/ConsoleApp.java new file mode 100644 index 0000000000..70edb8f9ed --- /dev/null +++ b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/ConsoleApp.java @@ -0,0 +1,48 @@ +package com.baeldung.hexagonal.architecture; + +import java.io.File; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration; +import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration; + +import com.baeldung.hexagonal.architecture.model.Product; +import com.baeldung.hexagonal.architecture.service.ProductService; +import com.fasterxml.jackson.dataformat.csv.CsvMapper; +import com.fasterxml.jackson.dataformat.csv.CsvSchema; + +/** + * @author AshwiniKeshri + * + */ + +@SpringBootApplication(exclude = {EmbeddedServletContainerAutoConfiguration.class,WebMvcAutoConfiguration.class}) +public class ConsoleApp implements CommandLineRunner { + @Autowired + private ProductService productService; + + public static void main(String[] args) { + SpringApplication.run(ConsoleApp.class, args); + } + + @Override + public void run(String... args) throws Exception { + String filePath = ""; + if (args != null && args.length == 2 && "Product".equalsIgnoreCase(args[0]) + && (filePath = args[1]).length() > 0) { + File sourceFile = new File(filePath); + if (sourceFile.exists()) { + CsvMapper mapper = new CsvMapper(); + List products = mapper.readerFor(Product.class).with(CsvSchema.emptySchema().withHeader()) + .readValues(sourceFile).readAll(); + productService.saveAll(products); + } + + } + + } +} diff --git a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/controller/ProductController.java b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/controller/ProductController.java new file mode 100644 index 0000000000..6645c379c2 --- /dev/null +++ b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/controller/ProductController.java @@ -0,0 +1,52 @@ +package com.baeldung.hexagonal.architecture.controller; + +import java.util.List; +import java.util.stream.Collectors; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import com.baeldung.hexagonal.architecture.dtos.ProductDto; +import com.baeldung.hexagonal.architecture.model.Product; +import com.baeldung.hexagonal.architecture.service.ProductService; + +/** + * @author AshwiniKeshri + * + */ + +@RestController +@RequestMapping("api/v1/product") +public class ProductController { + + @Autowired + private ProductService productService; + + @RequestMapping(value = "/all", method = RequestMethod.GET) + public List list() { + return productService.findAll().stream().map(p -> new ProductDto(p)).collect(Collectors.toList()); + } + + @RequestMapping(value = "/{productId}", method = RequestMethod.GET) + public ProductDto get(@PathVariable long productId) { + Product p = productService.findById(productId); + return p != null ? new ProductDto(p) : null; + } + + @RequestMapping(value = "/add", method = RequestMethod.POST) + public ProductDto create(@RequestBody ProductDto product) { + Product p = new Product(); + p.setDescription(product.getDescription()); + p.setName(product.getName()); + p.setPrice(product.getPrice()); + p.setQuantity(product.getQuantity()); + Long id = productService.create(p); + product.setId(id); + return product; + } + +} diff --git a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/dtos/ProductDto.java b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/dtos/ProductDto.java new file mode 100644 index 0000000000..336631fb10 --- /dev/null +++ b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/dtos/ProductDto.java @@ -0,0 +1,71 @@ +package com.baeldung.hexagonal.architecture.dtos; + +import com.baeldung.hexagonal.architecture.model.Product; +/** + * @author AshwiniKeshri + * + */ +public class ProductDto { + + private Long id; + + private String name; + + private Long quantity; + + private Double price; + + private String description; + + public ProductDto() {} + + public ProductDto(Product product) { + this.description = product.getDescription(); + this.id = product.getId(); + this.name = product.getName(); + this.price = product.getPrice(); + this.quantity = product.getQuantity(); + } + + 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 Long getQuantity() { + return quantity; + } + + public void setQuantity(Long quantity) { + this.quantity = quantity; + } + + public Double getPrice() { + return price; + } + + public void setPrice(Double price) { + this.price = price; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + +} diff --git a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/model/Product.java b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/model/Product.java new file mode 100644 index 0000000000..dec4548283 --- /dev/null +++ b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/model/Product.java @@ -0,0 +1,87 @@ +/** + * + */ +package com.baeldung.hexagonal.architecture.model; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; + +/** + * @author AshwiniKeshri + * + */ + +@Entity +@Table(name = "PRODUCT") +public class Product implements Serializable{ + + /** + * + */ + private static final long serialVersionUID = 4000353732860709995L; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + @Column(name="NAME") + private String name; + + @Column(name = "QUANTITY") + private Long quantity; + + @Column(name = "PRICE") + private Double price; + + @Column(name = "DESCRIPTION") + private String description; + + 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 Long getQuantity() { + return quantity; + } + + public void setQuantity(Long quantity) { + this.quantity = quantity > 0 ? quantity : 0; + } + + public Double getPrice() { + return price; + } + + public void setPrice(Double price) { + this.price = price == null ? 0.0 : price; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + + +} diff --git a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/repository/ProductRepository.java b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/repository/ProductRepository.java new file mode 100644 index 0000000000..76c888ab59 --- /dev/null +++ b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/repository/ProductRepository.java @@ -0,0 +1,14 @@ +package com.baeldung.hexagonal.architecture.repository; + +import org.springframework.data.jpa.repository.JpaRepository; + +import com.baeldung.hexagonal.architecture.model.Product; + +/** + * @author AshwiniKeshri + * + */ + +public interface ProductRepository extends JpaRepository{ + +} diff --git a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/service/ProductService.java b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/service/ProductService.java new file mode 100644 index 0000000000..b1d05a7db4 --- /dev/null +++ b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/service/ProductService.java @@ -0,0 +1,21 @@ +package com.baeldung.hexagonal.architecture.service; + +import java.util.List; + +import com.baeldung.hexagonal.architecture.model.Product; + +/** + * @author AshwiniKeshri + * + */ + +public interface ProductService { + + List findAll(); + + Product findById(long id); + + Long create(Product product); + + void saveAll(List products); +} diff --git a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/service/ProductServiceImpl.java b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/service/ProductServiceImpl.java new file mode 100644 index 0000000000..1005b5753d --- /dev/null +++ b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/service/ProductServiceImpl.java @@ -0,0 +1,44 @@ +package com.baeldung.hexagonal.architecture.service; + +import java.util.List; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.baeldung.hexagonal.architecture.model.Product; +import com.baeldung.hexagonal.architecture.repository.ProductRepository; + +/** + * @author AshwiniKeshri + * + */ + +@Service +public class ProductServiceImpl implements ProductService { + + private Logger logger = LoggerFactory.getLogger(ProductServiceImpl.class); + + @Autowired + private ProductRepository productRepository; + + public List findAll() { + return productRepository.findAll(); + } + + public Product findById(long id) { + return productRepository.findOne(id); + } + + public Long create(Product product) { + product = productRepository.saveAndFlush(product); + return product.getId(); + } + + @Override + public void saveAll(List products) { + productRepository.save(products); + } + +} diff --git a/hexagonal-architecture/src/main/resources/application-batch.properties b/hexagonal-architecture/src/main/resources/application-batch.properties new file mode 100644 index 0000000000..8c83d19f74 --- /dev/null +++ b/hexagonal-architecture/src/main/resources/application-batch.properties @@ -0,0 +1,9 @@ +spring.main.web-environment=false +spring.jpa.hibernate.ddl-auto=false; +spring.h2.console.enabled=true +spring.h2.console.path=/h2 + +spring.datasource.url=jdbc:h2:file:~/hexagonal +spring.datasource.username=sa +spring.datasource.password= +spring.datasource.driver-class-name=org.h2.Driver \ No newline at end of file diff --git a/hexagonal-architecture/src/main/resources/application-test.properties b/hexagonal-architecture/src/main/resources/application-test.properties new file mode 100644 index 0000000000..701313a878 --- /dev/null +++ b/hexagonal-architecture/src/main/resources/application-test.properties @@ -0,0 +1,8 @@ +spring.jpa.hibernate.ddl-auto=false; +spring.h2.console.enabled=true +spring.h2.console.path=/h2 + +spring.datasource.url=jdbc:h2:file:~/hexagonal_test +spring.datasource.username=sa +spring.datasource.password= +spring.datasource.driver-class-name=org.h2.Driver \ No newline at end of file diff --git a/hexagonal-architecture/src/main/resources/application.properties b/hexagonal-architecture/src/main/resources/application.properties new file mode 100644 index 0000000000..14c80a1af4 --- /dev/null +++ b/hexagonal-architecture/src/main/resources/application.properties @@ -0,0 +1,8 @@ +spring.jpa.hibernate.ddl-auto=false; +spring.h2.console.enabled=true +spring.h2.console.path=/h2 + +spring.datasource.url=jdbc:h2:file:~/hexagonal +spring.datasource.username=sa +spring.datasource.password= +spring.datasource.driver-class-name=org.h2.Driver \ No newline at end of file diff --git a/hexagonal-architecture/src/main/resources/db/PRODUCT.sql b/hexagonal-architecture/src/main/resources/db/PRODUCT.sql new file mode 100644 index 0000000000..a0fef3a710 --- /dev/null +++ b/hexagonal-architecture/src/main/resources/db/PRODUCT.sql @@ -0,0 +1,9 @@ +CREATE TABLE PRODUCT( + ID INT AUTO_INCREMENT, + NAME VARCHAR(255), + QUANTITY INTEGER, + PRICE DOUBLE, + DESCRIPTION VARCHAR(1000), +); + +INSERT INTO PRODUCT(NAME,QUANTITY,PRICE,DESCRIPTION) VALUES ('iPhone 11 Pro',10,300,'First triple camera system'); \ No newline at end of file diff --git a/hexagonal-architecture/src/test/java/com/baeldung/hexagonal/architecture/service/ProductServiceTest.java b/hexagonal-architecture/src/test/java/com/baeldung/hexagonal/architecture/service/ProductServiceTest.java new file mode 100644 index 0000000000..021fdf1289 --- /dev/null +++ b/hexagonal-architecture/src/test/java/com/baeldung/hexagonal/architecture/service/ProductServiceTest.java @@ -0,0 +1,43 @@ +/** + * + */ +package com.baeldung.hexagonal.architecture.service; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.SpringApplicationConfiguration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.context.annotation.PropertySources; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import com.baeldung.hexagonal.architecture.App; +import com.baeldung.hexagonal.architecture.model.Product; +import com.baeldung.hexagonal.architecture.service.ProductService; + +/** + * @author AshwiniKeshri + * + */ +@RunWith(SpringJUnit4ClassRunner.class) +@SpringApplicationConfiguration(App.class) +@ActiveProfiles(value = "test") +public class ProductServiceTest { + + @Autowired + private ProductService productService; + + @Test + public void testCreateProduct() { + Product product = new Product(); + product.setDescription("test product"); + product.setName("Product1"); + product.setPrice(10.0); + product.setQuantity(100l); + Long id = productService.create(product); + Assert.assertTrue(id >0); + } + +} From 6a1e528bfd049506a31125476268f47ea74f67be Mon Sep 17 00:00:00 2001 From: akeshri Date: Sun, 28 Jun 2020 22:51:35 +0530 Subject: [PATCH 005/263] Create README.md Read me changes --- hexagonal-architecture/README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 hexagonal-architecture/README.md diff --git a/hexagonal-architecture/README.md b/hexagonal-architecture/README.md new file mode 100644 index 0000000000..4dd10368e0 --- /dev/null +++ b/hexagonal-architecture/README.md @@ -0,0 +1,17 @@ +# Hexagonal Architecture +A quick and practical example of Hexagonal Architecture using Spring boot. + +This application is using h2 database,which can be accessible http:/localhost:8080/h2 + +Main Application schema : hexagonal + +Test Application Schema : hexagonal_test + +1. Rest Api : execute [App](https://github.com/akeshri/tutorials/blob/master/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/App.java) + - Get All products : http://localhost:8080/api/v1/product/all + - Get product by id : http://localhost:8080/api/v1/product/{productId} + - Add a product : http://localhost:8080/api/v1/product/add + For more detail refer [ProductController](https://github.com/akeshri/tutorials/blob/master/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/controller/ProductController.java) + +2. Batch processing : We need to configure active profile as batch i.e. -Dspring.profiles.active=batch and execute [ConsoleApp](https://github.com/akeshri/tutorials/blob/master/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/ConsoleApp.java) +3. Test case : [ProductServiceTest](https://github.com/akeshri/tutorials/blob/master/hexagonal-architecture/src/test/java/com/baeldung/hexagonal/architecture/service/ProductServiceTest.java) From 36d37894420227c3e56ff244822b239c268b6db0 Mon Sep 17 00:00:00 2001 From: akeshri Date: Fri, 3 Jul 2020 22:32:44 +0530 Subject: [PATCH 006/263] 1.fixed code format 2. resolved build issue --- hexagonal-architecture/pom.xml | 2 + .../article/hexagonal/architecture/App.java | 16 ++++ .../hexagonal/architecture/ConsoleApp.java | 50 +++++++++++ .../controller/ProductController.java | 54 ++++++++++++ .../architecture/dtos/ProductDto.java | 72 ++++++++++++++++ .../hexagonal/architecture/model/Product.java | 85 +++++++++++++++++++ .../repository/ProductRepository.java | 14 +++ .../architecture/service/ProductService.java | 21 +++++ .../service/ProductServiceImpl.java | 44 ++++++++++ .../service/ProductServiceTest.java | 43 ++++++++++ 10 files changed, 401 insertions(+) create mode 100644 hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/App.java create mode 100644 hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/ConsoleApp.java create mode 100644 hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/controller/ProductController.java create mode 100644 hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/dtos/ProductDto.java create mode 100644 hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/model/Product.java create mode 100644 hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/repository/ProductRepository.java create mode 100644 hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/service/ProductService.java create mode 100644 hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/service/ProductServiceImpl.java create mode 100644 hexagonal-architecture/src/test/java/com/article/hexagonal/architecture/service/ProductServiceTest.java diff --git a/hexagonal-architecture/pom.xml b/hexagonal-architecture/pom.xml index 87e599318c..d014617639 100644 --- a/hexagonal-architecture/pom.xml +++ b/hexagonal-architecture/pom.xml @@ -18,6 +18,8 @@ UTF-8 + 1.8 + 1.8 diff --git a/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/App.java b/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/App.java new file mode 100644 index 0000000000..ebc661bfdb --- /dev/null +++ b/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/App.java @@ -0,0 +1,16 @@ +package com.article.hexagonal.architecture; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * @author AshwiniKeshri + * + */ + +@SpringBootApplication +public class App { + public static void main(String[] args) { + SpringApplication.run(App.class, args); + } +} diff --git a/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/ConsoleApp.java b/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/ConsoleApp.java new file mode 100644 index 0000000000..0024438737 --- /dev/null +++ b/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/ConsoleApp.java @@ -0,0 +1,50 @@ +package com.article.hexagonal.architecture; + +import java.io.File; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration; +import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration; + +import com.article.hexagonal.architecture.model.Product; +import com.article.hexagonal.architecture.service.ProductService; +import com.fasterxml.jackson.dataformat.csv.CsvMapper; +import com.fasterxml.jackson.dataformat.csv.CsvSchema; + +/** + * @author AshwiniKeshri + * + */ + +@SpringBootApplication(exclude = { EmbeddedServletContainerAutoConfiguration.class, WebMvcAutoConfiguration.class }) +public class ConsoleApp implements CommandLineRunner { + @Autowired + private ProductService productService; + + public static void main(String[] args) { + SpringApplication.run(ConsoleApp.class, args); + } + + @Override + public void run(String... args) throws Exception { + String filePath = ""; + if (args != null && args.length == 2 && "Product".equalsIgnoreCase(args[0]) && (filePath = args[1]).length() > 0) { + File sourceFile = new File(filePath); + if (sourceFile.exists()) { + CsvMapper mapper = new CsvMapper(); + List products = mapper.readerFor(Product.class) + .with(CsvSchema.emptySchema() + .withHeader()) + . readValues(sourceFile) + .readAll(); + productService.saveAll(products); + } + + } + + } +} diff --git a/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/controller/ProductController.java b/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/controller/ProductController.java new file mode 100644 index 0000000000..66372980d0 --- /dev/null +++ b/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/controller/ProductController.java @@ -0,0 +1,54 @@ +package com.article.hexagonal.architecture.controller; + +import java.util.List; +import java.util.stream.Collectors; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import com.article.hexagonal.architecture.dtos.ProductDto; +import com.article.hexagonal.architecture.model.Product; +import com.article.hexagonal.architecture.service.ProductService; + +/** + * @author AshwiniKeshri + * + */ + +@RestController +@RequestMapping("api/v1/product") +public class ProductController { + + @Autowired + private ProductService productService; + + @RequestMapping(value = "/all", method = RequestMethod.GET) + public List list() { + productService.findAll().stream().map(x->x.getDescription()) + return null; + //return productService.findAll().stream().map(p -> new ProductDto(p)).collect(Collectors.toList()); + } + + @RequestMapping(value = "/{productId}", method = RequestMethod.GET) + public ProductDto get(@PathVariable long productId) { + Product p = productService.findById(productId); + return p != null ? new ProductDto(p) : null; + } + + @RequestMapping(value = "/add", method = RequestMethod.POST) + public ProductDto create(@RequestBody ProductDto product) { + Product p = new Product(); + p.setDescription(product.getDescription()); + p.setName(product.getName()); + p.setPrice(product.getPrice()); + p.setQuantity(product.getQuantity()); + Long id = productService.create(p); + product.setId(id); + return product; + } + +} diff --git a/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/dtos/ProductDto.java b/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/dtos/ProductDto.java new file mode 100644 index 0000000000..209ae69b0a --- /dev/null +++ b/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/dtos/ProductDto.java @@ -0,0 +1,72 @@ +package com.article.hexagonal.architecture.dtos; + +import com.article.hexagonal.architecture.model.Product; + +/** + * @author AshwiniKeshri + * + */ +public class ProductDto { + + private Long id; + + private String name; + + private Long quantity; + + private Double price; + + private String description; + + public ProductDto() { + } + + public ProductDto(Product product) { + this.description = product.getDescription(); + this.id = product.getId(); + this.name = product.getName(); + this.price = product.getPrice(); + this.quantity = product.getQuantity(); + } + + 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 Long getQuantity() { + return quantity; + } + + public void setQuantity(Long quantity) { + this.quantity = quantity; + } + + public Double getPrice() { + return price; + } + + public void setPrice(Double price) { + this.price = price; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + +} diff --git a/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/model/Product.java b/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/model/Product.java new file mode 100644 index 0000000000..f0f95d4d11 --- /dev/null +++ b/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/model/Product.java @@ -0,0 +1,85 @@ +/** + * + */ +package com.article.hexagonal.architecture.model; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; + +/** + * @author AshwiniKeshri + * + */ + +@Entity +@Table(name = "PRODUCT") +public class Product implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 4000353732860709995L; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + @Column(name = "NAME") + private String name; + + @Column(name = "QUANTITY") + private Long quantity; + + @Column(name = "PRICE") + private Double price; + + @Column(name = "DESCRIPTION") + private String description; + + 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 Long getQuantity() { + return quantity; + } + + public void setQuantity(Long quantity) { + this.quantity = quantity > 0 ? quantity : 0; + } + + public Double getPrice() { + return price; + } + + public void setPrice(Double price) { + this.price = price == null ? 0.0 : price; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + +} diff --git a/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/repository/ProductRepository.java b/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/repository/ProductRepository.java new file mode 100644 index 0000000000..fec151780c --- /dev/null +++ b/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/repository/ProductRepository.java @@ -0,0 +1,14 @@ +package com.article.hexagonal.architecture.repository; + +import org.springframework.data.jpa.repository.JpaRepository; + +import com.article.hexagonal.architecture.model.Product; + +/** + * @author AshwiniKeshri + * + */ + +public interface ProductRepository extends JpaRepository { + +} diff --git a/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/service/ProductService.java b/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/service/ProductService.java new file mode 100644 index 0000000000..5ed1e7de96 --- /dev/null +++ b/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/service/ProductService.java @@ -0,0 +1,21 @@ +package com.article.hexagonal.architecture.service; + +import java.util.List; + +import com.article.hexagonal.architecture.model.Product; + +/** + * @author AshwiniKeshri + * + */ + +public interface ProductService { + + List findAll(); + + Product findById(long id); + + Long create(Product product); + + void saveAll(List products); +} diff --git a/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/service/ProductServiceImpl.java b/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/service/ProductServiceImpl.java new file mode 100644 index 0000000000..ccd1599392 --- /dev/null +++ b/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/service/ProductServiceImpl.java @@ -0,0 +1,44 @@ +package com.article.hexagonal.architecture.service; + +import java.util.List; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.article.hexagonal.architecture.model.Product; +import com.article.hexagonal.architecture.repository.ProductRepository; + +/** + * @author AshwiniKeshri + * + */ + +@Service +public class ProductServiceImpl implements ProductService { + + private Logger logger = LoggerFactory.getLogger(ProductServiceImpl.class); + + @Autowired + private ProductRepository productRepository; + + public List findAll() { + return productRepository.findAll(); + } + + public Product findById(long id) { + return productRepository.findOne(id); + } + + public Long create(Product product) { + product = productRepository.saveAndFlush(product); + return product.getId(); + } + + @Override + public void saveAll(List products) { + productRepository.save(products); + } + +} diff --git a/hexagonal-architecture/src/test/java/com/article/hexagonal/architecture/service/ProductServiceTest.java b/hexagonal-architecture/src/test/java/com/article/hexagonal/architecture/service/ProductServiceTest.java new file mode 100644 index 0000000000..6635fef2da --- /dev/null +++ b/hexagonal-architecture/src/test/java/com/article/hexagonal/architecture/service/ProductServiceTest.java @@ -0,0 +1,43 @@ +/** + * + */ +package com.article.hexagonal.architecture.service; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.SpringApplicationConfiguration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.context.annotation.PropertySources; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import com.article.hexagonal.architecture.App; +import com.article.hexagonal.architecture.model.Product; +import com.article.hexagonal.architecture.service.ProductService; + +/** + * @author AshwiniKeshri + * + */ +@RunWith(SpringJUnit4ClassRunner.class) +@SpringApplicationConfiguration(App.class) +@ActiveProfiles(value = "test") +public class ProductServiceTest { + + @Autowired + private ProductService productService; + + @Test + public void testCreateProduct() { + Product product = new Product(); + product.setDescription("test product"); + product.setName("Product1"); + product.setPrice(10.0); + product.setQuantity(100l); + Long id = productService.create(product); + Assert.assertTrue(id > 0); + } + +} From 18894f5c03049ea18703dda029140227f95e45aa Mon Sep 17 00:00:00 2001 From: akeshri Date: Sat, 4 Jul 2020 00:10:07 +0530 Subject: [PATCH 007/263] remove duplicate code --- .../article/hexagonal/architecture/App.java | 16 ---- .../hexagonal/architecture/ConsoleApp.java | 50 ----------- .../controller/ProductController.java | 54 ------------ .../architecture/dtos/ProductDto.java | 72 ---------------- .../hexagonal/architecture/model/Product.java | 85 ------------------- .../repository/ProductRepository.java | 14 --- .../architecture/service/ProductService.java | 21 ----- .../service/ProductServiceImpl.java | 44 ---------- .../service/ProductServiceTest.java | 43 ---------- 9 files changed, 399 deletions(-) delete mode 100644 hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/App.java delete mode 100644 hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/ConsoleApp.java delete mode 100644 hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/controller/ProductController.java delete mode 100644 hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/dtos/ProductDto.java delete mode 100644 hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/model/Product.java delete mode 100644 hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/repository/ProductRepository.java delete mode 100644 hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/service/ProductService.java delete mode 100644 hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/service/ProductServiceImpl.java delete mode 100644 hexagonal-architecture/src/test/java/com/article/hexagonal/architecture/service/ProductServiceTest.java diff --git a/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/App.java b/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/App.java deleted file mode 100644 index ebc661bfdb..0000000000 --- a/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/App.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.article.hexagonal.architecture; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * @author AshwiniKeshri - * - */ - -@SpringBootApplication -public class App { - public static void main(String[] args) { - SpringApplication.run(App.class, args); - } -} diff --git a/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/ConsoleApp.java b/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/ConsoleApp.java deleted file mode 100644 index 0024438737..0000000000 --- a/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/ConsoleApp.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.article.hexagonal.architecture; - -import java.io.File; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.CommandLineRunner; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration; -import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration; - -import com.article.hexagonal.architecture.model.Product; -import com.article.hexagonal.architecture.service.ProductService; -import com.fasterxml.jackson.dataformat.csv.CsvMapper; -import com.fasterxml.jackson.dataformat.csv.CsvSchema; - -/** - * @author AshwiniKeshri - * - */ - -@SpringBootApplication(exclude = { EmbeddedServletContainerAutoConfiguration.class, WebMvcAutoConfiguration.class }) -public class ConsoleApp implements CommandLineRunner { - @Autowired - private ProductService productService; - - public static void main(String[] args) { - SpringApplication.run(ConsoleApp.class, args); - } - - @Override - public void run(String... args) throws Exception { - String filePath = ""; - if (args != null && args.length == 2 && "Product".equalsIgnoreCase(args[0]) && (filePath = args[1]).length() > 0) { - File sourceFile = new File(filePath); - if (sourceFile.exists()) { - CsvMapper mapper = new CsvMapper(); - List products = mapper.readerFor(Product.class) - .with(CsvSchema.emptySchema() - .withHeader()) - . readValues(sourceFile) - .readAll(); - productService.saveAll(products); - } - - } - - } -} diff --git a/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/controller/ProductController.java b/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/controller/ProductController.java deleted file mode 100644 index 66372980d0..0000000000 --- a/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/controller/ProductController.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.article.hexagonal.architecture.controller; - -import java.util.List; -import java.util.stream.Collectors; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -import com.article.hexagonal.architecture.dtos.ProductDto; -import com.article.hexagonal.architecture.model.Product; -import com.article.hexagonal.architecture.service.ProductService; - -/** - * @author AshwiniKeshri - * - */ - -@RestController -@RequestMapping("api/v1/product") -public class ProductController { - - @Autowired - private ProductService productService; - - @RequestMapping(value = "/all", method = RequestMethod.GET) - public List list() { - productService.findAll().stream().map(x->x.getDescription()) - return null; - //return productService.findAll().stream().map(p -> new ProductDto(p)).collect(Collectors.toList()); - } - - @RequestMapping(value = "/{productId}", method = RequestMethod.GET) - public ProductDto get(@PathVariable long productId) { - Product p = productService.findById(productId); - return p != null ? new ProductDto(p) : null; - } - - @RequestMapping(value = "/add", method = RequestMethod.POST) - public ProductDto create(@RequestBody ProductDto product) { - Product p = new Product(); - p.setDescription(product.getDescription()); - p.setName(product.getName()); - p.setPrice(product.getPrice()); - p.setQuantity(product.getQuantity()); - Long id = productService.create(p); - product.setId(id); - return product; - } - -} diff --git a/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/dtos/ProductDto.java b/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/dtos/ProductDto.java deleted file mode 100644 index 209ae69b0a..0000000000 --- a/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/dtos/ProductDto.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.article.hexagonal.architecture.dtos; - -import com.article.hexagonal.architecture.model.Product; - -/** - * @author AshwiniKeshri - * - */ -public class ProductDto { - - private Long id; - - private String name; - - private Long quantity; - - private Double price; - - private String description; - - public ProductDto() { - } - - public ProductDto(Product product) { - this.description = product.getDescription(); - this.id = product.getId(); - this.name = product.getName(); - this.price = product.getPrice(); - this.quantity = product.getQuantity(); - } - - 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 Long getQuantity() { - return quantity; - } - - public void setQuantity(Long quantity) { - this.quantity = quantity; - } - - public Double getPrice() { - return price; - } - - public void setPrice(Double price) { - this.price = price; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - -} diff --git a/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/model/Product.java b/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/model/Product.java deleted file mode 100644 index f0f95d4d11..0000000000 --- a/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/model/Product.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * - */ -package com.article.hexagonal.architecture.model; - -import java.io.Serializable; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; - -/** - * @author AshwiniKeshri - * - */ - -@Entity -@Table(name = "PRODUCT") -public class Product implements Serializable { - - /** - * - */ - private static final long serialVersionUID = 4000353732860709995L; - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Long id; - - @Column(name = "NAME") - private String name; - - @Column(name = "QUANTITY") - private Long quantity; - - @Column(name = "PRICE") - private Double price; - - @Column(name = "DESCRIPTION") - private String description; - - 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 Long getQuantity() { - return quantity; - } - - public void setQuantity(Long quantity) { - this.quantity = quantity > 0 ? quantity : 0; - } - - public Double getPrice() { - return price; - } - - public void setPrice(Double price) { - this.price = price == null ? 0.0 : price; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - -} diff --git a/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/repository/ProductRepository.java b/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/repository/ProductRepository.java deleted file mode 100644 index fec151780c..0000000000 --- a/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/repository/ProductRepository.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.article.hexagonal.architecture.repository; - -import org.springframework.data.jpa.repository.JpaRepository; - -import com.article.hexagonal.architecture.model.Product; - -/** - * @author AshwiniKeshri - * - */ - -public interface ProductRepository extends JpaRepository { - -} diff --git a/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/service/ProductService.java b/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/service/ProductService.java deleted file mode 100644 index 5ed1e7de96..0000000000 --- a/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/service/ProductService.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.article.hexagonal.architecture.service; - -import java.util.List; - -import com.article.hexagonal.architecture.model.Product; - -/** - * @author AshwiniKeshri - * - */ - -public interface ProductService { - - List findAll(); - - Product findById(long id); - - Long create(Product product); - - void saveAll(List products); -} diff --git a/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/service/ProductServiceImpl.java b/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/service/ProductServiceImpl.java deleted file mode 100644 index ccd1599392..0000000000 --- a/hexagonal-architecture/src/main/java/com/article/hexagonal/architecture/service/ProductServiceImpl.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.article.hexagonal.architecture.service; - -import java.util.List; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.article.hexagonal.architecture.model.Product; -import com.article.hexagonal.architecture.repository.ProductRepository; - -/** - * @author AshwiniKeshri - * - */ - -@Service -public class ProductServiceImpl implements ProductService { - - private Logger logger = LoggerFactory.getLogger(ProductServiceImpl.class); - - @Autowired - private ProductRepository productRepository; - - public List findAll() { - return productRepository.findAll(); - } - - public Product findById(long id) { - return productRepository.findOne(id); - } - - public Long create(Product product) { - product = productRepository.saveAndFlush(product); - return product.getId(); - } - - @Override - public void saveAll(List products) { - productRepository.save(products); - } - -} diff --git a/hexagonal-architecture/src/test/java/com/article/hexagonal/architecture/service/ProductServiceTest.java b/hexagonal-architecture/src/test/java/com/article/hexagonal/architecture/service/ProductServiceTest.java deleted file mode 100644 index 6635fef2da..0000000000 --- a/hexagonal-architecture/src/test/java/com/article/hexagonal/architecture/service/ProductServiceTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * - */ -package com.article.hexagonal.architecture.service; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.SpringApplicationConfiguration; -import org.springframework.context.annotation.PropertySource; -import org.springframework.context.annotation.PropertySources; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import com.article.hexagonal.architecture.App; -import com.article.hexagonal.architecture.model.Product; -import com.article.hexagonal.architecture.service.ProductService; - -/** - * @author AshwiniKeshri - * - */ -@RunWith(SpringJUnit4ClassRunner.class) -@SpringApplicationConfiguration(App.class) -@ActiveProfiles(value = "test") -public class ProductServiceTest { - - @Autowired - private ProductService productService; - - @Test - public void testCreateProduct() { - Product product = new Product(); - product.setDescription("test product"); - product.setName("Product1"); - product.setPrice(10.0); - product.setQuantity(100l); - Long id = productService.create(product); - Assert.assertTrue(id > 0); - } - -} From b59f4d32b4456d3496be6c80e5d66fdaa15eab12 Mon Sep 17 00:00:00 2001 From: akeshri Date: Sun, 5 Jul 2020 21:33:50 +0530 Subject: [PATCH 008/263] fixed code formatting issue --- .../baeldung/hexagonal/architecture/App.java | 6 +- .../hexagonal/architecture/ConsoleApp.java | 42 +++---- .../controller/ProductController.java | 47 ++++---- .../architecture/dtos/ProductDto.java | 103 ++++++++--------- .../hexagonal/architecture/model/Product.java | 104 +++++++++--------- .../repository/ProductRepository.java | 2 +- .../architecture/service/ProductService.java | 14 +-- .../service/ProductServiceImpl.java | 38 +++---- .../service/ProductServiceTest.java | 28 ++--- 9 files changed, 193 insertions(+), 191 deletions(-) diff --git a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/App.java b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/App.java index 3563e3a0ec..29dbec470f 100644 --- a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/App.java +++ b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/App.java @@ -9,10 +9,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; */ @SpringBootApplication -public class App -{ - public static void main( String[] args ) - { +public class App { + public static void main(String[] args) { SpringApplication.run(App.class, args); } } diff --git a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/ConsoleApp.java b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/ConsoleApp.java index 70edb8f9ed..6aef791893 100644 --- a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/ConsoleApp.java +++ b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/ConsoleApp.java @@ -20,29 +20,31 @@ import com.fasterxml.jackson.dataformat.csv.CsvSchema; * */ -@SpringBootApplication(exclude = {EmbeddedServletContainerAutoConfiguration.class,WebMvcAutoConfiguration.class}) +@SpringBootApplication(exclude = { EmbeddedServletContainerAutoConfiguration.class, WebMvcAutoConfiguration.class }) public class ConsoleApp implements CommandLineRunner { - @Autowired - private ProductService productService; + @Autowired + private ProductService productService; - public static void main(String[] args) { - SpringApplication.run(ConsoleApp.class, args); - } + public static void main(String[] args) { + SpringApplication.run(ConsoleApp.class, args); + } - @Override - public void run(String... args) throws Exception { - String filePath = ""; - if (args != null && args.length == 2 && "Product".equalsIgnoreCase(args[0]) - && (filePath = args[1]).length() > 0) { - File sourceFile = new File(filePath); - if (sourceFile.exists()) { - CsvMapper mapper = new CsvMapper(); - List products = mapper.readerFor(Product.class).with(CsvSchema.emptySchema().withHeader()) - .readValues(sourceFile).readAll(); - productService.saveAll(products); - } + @Override + public void run(String... args) throws Exception { + String filePath = ""; + if (args != null && args.length == 2 && "Product".equalsIgnoreCase(args[0]) && (filePath = args[1]).length() > 0) { + File sourceFile = new File(filePath); + if (sourceFile.exists()) { + CsvMapper mapper = new CsvMapper(); + List products = mapper.readerFor(Product.class) + .with(CsvSchema.emptySchema() + .withHeader()) + . readValues(sourceFile) + .readAll(); + productService.saveAll(products); + } - } + } - } + } } diff --git a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/controller/ProductController.java b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/controller/ProductController.java index 6645c379c2..f54d3268df 100644 --- a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/controller/ProductController.java +++ b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/controller/ProductController.java @@ -23,30 +23,33 @@ import com.baeldung.hexagonal.architecture.service.ProductService; @RequestMapping("api/v1/product") public class ProductController { - @Autowired - private ProductService productService; + @Autowired + private ProductService productService; - @RequestMapping(value = "/all", method = RequestMethod.GET) - public List list() { - return productService.findAll().stream().map(p -> new ProductDto(p)).collect(Collectors.toList()); - } + @RequestMapping(value = "/all", method = RequestMethod.GET) + public List list() { + return productService.findAll() + .stream() + .map(p -> new ProductDto(p)) + .collect(Collectors.toList()); + } - @RequestMapping(value = "/{productId}", method = RequestMethod.GET) - public ProductDto get(@PathVariable long productId) { - Product p = productService.findById(productId); - return p != null ? new ProductDto(p) : null; - } + @RequestMapping(value = "/{productId}", method = RequestMethod.GET) + public ProductDto get(@PathVariable long productId) { + Product p = productService.findById(productId); + return p != null ? new ProductDto(p) : null; + } - @RequestMapping(value = "/add", method = RequestMethod.POST) - public ProductDto create(@RequestBody ProductDto product) { - Product p = new Product(); - p.setDescription(product.getDescription()); - p.setName(product.getName()); - p.setPrice(product.getPrice()); - p.setQuantity(product.getQuantity()); - Long id = productService.create(p); - product.setId(id); - return product; - } + @RequestMapping(value = "/add", method = RequestMethod.POST) + public ProductDto create(@RequestBody ProductDto product) { + Product p = new Product(); + p.setDescription(product.getDescription()); + p.setName(product.getName()); + p.setPrice(product.getPrice()); + p.setQuantity(product.getQuantity()); + Long id = productService.create(p); + product.setId(id); + return product; + } } diff --git a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/dtos/ProductDto.java b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/dtos/ProductDto.java index 336631fb10..51692f56aa 100644 --- a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/dtos/ProductDto.java +++ b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/dtos/ProductDto.java @@ -1,71 +1,72 @@ package com.baeldung.hexagonal.architecture.dtos; import com.baeldung.hexagonal.architecture.model.Product; + /** * @author AshwiniKeshri * */ public class ProductDto { - private Long id; - - private String name; - - private Long quantity; - - private Double price; - - private String description; - - public ProductDto() {} - - public ProductDto(Product product) { - this.description = product.getDescription(); - this.id = product.getId(); - this.name = product.getName(); - this.price = product.getPrice(); - this.quantity = product.getQuantity(); - } + private Long id; - public Long getId() { - return id; - } + private String name; - public void setId(Long id) { - this.id = id; - } + private Long quantity; - public String getName() { - return name; - } + private Double price; - public void setName(String name) { - this.name = name; - } + private String description; - public Long getQuantity() { - return quantity; - } + public ProductDto() { + } - public void setQuantity(Long quantity) { - this.quantity = quantity; - } + public ProductDto(Product product) { + this.description = product.getDescription(); + this.id = product.getId(); + this.name = product.getName(); + this.price = product.getPrice(); + this.quantity = product.getQuantity(); + } - public Double getPrice() { - return price; - } + public Long getId() { + return id; + } - public void setPrice(Double price) { - this.price = price; - } + public void setId(Long id) { + this.id = id; + } - public String getDescription() { - return description; - } + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Long getQuantity() { + return quantity; + } + + public void setQuantity(Long quantity) { + this.quantity = quantity; + } + + public Double getPrice() { + return price; + } + + public void setPrice(Double price) { + this.price = price; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } - public void setDescription(String description) { - this.description = description; - } - - } diff --git a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/model/Product.java b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/model/Product.java index dec4548283..697ff68b50 100644 --- a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/model/Product.java +++ b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/model/Product.java @@ -19,69 +19,67 @@ import javax.persistence.Table; @Entity @Table(name = "PRODUCT") -public class Product implements Serializable{ +public class Product implements Serializable { - /** - * - */ - private static final long serialVersionUID = 4000353732860709995L; + /** + * + */ + private static final long serialVersionUID = 4000353732860709995L; - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Long id; - - @Column(name="NAME") - private String name; - - @Column(name = "QUANTITY") - private Long quantity; - - @Column(name = "PRICE") - private Double price; - - @Column(name = "DESCRIPTION") - private String description; + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; - public Long getId() { - return id; - } + @Column(name = "NAME") + private String name; - public void setId(Long id) { - this.id = id; - } + @Column(name = "QUANTITY") + private Long quantity; - public String getName() { - return name; - } + @Column(name = "PRICE") + private Double price; - public void setName(String name) { - this.name = name; - } + @Column(name = "DESCRIPTION") + private String description; - public Long getQuantity() { - return quantity; - } + public Long getId() { + return id; + } - public void setQuantity(Long quantity) { - this.quantity = quantity > 0 ? quantity : 0; - } + public void setId(Long id) { + this.id = id; + } - public Double getPrice() { - return price; - } + public String getName() { + return name; + } - public void setPrice(Double price) { - this.price = price == null ? 0.0 : price; - } + public void setName(String name) { + this.name = name; + } - public String getDescription() { - return description; - } + public Long getQuantity() { + return quantity; + } + + public void setQuantity(Long quantity) { + this.quantity = quantity > 0 ? quantity : 0; + } + + public Double getPrice() { + return price; + } + + public void setPrice(Double price) { + this.price = price == null ? 0.0 : price; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } - public void setDescription(String description) { - this.description = description; - } - - - } diff --git a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/repository/ProductRepository.java b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/repository/ProductRepository.java index 76c888ab59..ec50e86dc3 100644 --- a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/repository/ProductRepository.java +++ b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/repository/ProductRepository.java @@ -9,6 +9,6 @@ import com.baeldung.hexagonal.architecture.model.Product; * */ -public interface ProductRepository extends JpaRepository{ +public interface ProductRepository extends JpaRepository { } diff --git a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/service/ProductService.java b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/service/ProductService.java index b1d05a7db4..4844723140 100644 --- a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/service/ProductService.java +++ b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/service/ProductService.java @@ -11,11 +11,11 @@ import com.baeldung.hexagonal.architecture.model.Product; public interface ProductService { - List findAll(); - - Product findById(long id); - - Long create(Product product); - - void saveAll(List products); + List findAll(); + + Product findById(long id); + + Long create(Product product); + + void saveAll(List products); } diff --git a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/service/ProductServiceImpl.java b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/service/ProductServiceImpl.java index 1005b5753d..e2d182a954 100644 --- a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/service/ProductServiceImpl.java +++ b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/service/ProductServiceImpl.java @@ -18,27 +18,27 @@ import com.baeldung.hexagonal.architecture.repository.ProductRepository; @Service public class ProductServiceImpl implements ProductService { - private Logger logger = LoggerFactory.getLogger(ProductServiceImpl.class); - - @Autowired - private ProductRepository productRepository; - - public List findAll() { - return productRepository.findAll(); - } + private Logger logger = LoggerFactory.getLogger(ProductServiceImpl.class); - public Product findById(long id) { - return productRepository.findOne(id); - } + @Autowired + private ProductRepository productRepository; - public Long create(Product product) { - product = productRepository.saveAndFlush(product); - return product.getId(); - } + public List findAll() { + return productRepository.findAll(); + } - @Override - public void saveAll(List products) { - productRepository.save(products); - } + public Product findById(long id) { + return productRepository.findOne(id); + } + + public Long create(Product product) { + product = productRepository.saveAndFlush(product); + return product.getId(); + } + + @Override + public void saveAll(List products) { + productRepository.save(products); + } } diff --git a/hexagonal-architecture/src/test/java/com/baeldung/hexagonal/architecture/service/ProductServiceTest.java b/hexagonal-architecture/src/test/java/com/baeldung/hexagonal/architecture/service/ProductServiceTest.java index 021fdf1289..748df3c0d0 100644 --- a/hexagonal-architecture/src/test/java/com/baeldung/hexagonal/architecture/service/ProductServiceTest.java +++ b/hexagonal-architecture/src/test/java/com/baeldung/hexagonal/architecture/service/ProductServiceTest.java @@ -25,19 +25,19 @@ import com.baeldung.hexagonal.architecture.service.ProductService; @SpringApplicationConfiguration(App.class) @ActiveProfiles(value = "test") public class ProductServiceTest { - - @Autowired - private ProductService productService; - @Test - public void testCreateProduct() { - Product product = new Product(); - product.setDescription("test product"); - product.setName("Product1"); - product.setPrice(10.0); - product.setQuantity(100l); - Long id = productService.create(product); - Assert.assertTrue(id >0); - } - + @Autowired + private ProductService productService; + + @Test + public void testCreateProduct() { + Product product = new Product(); + product.setDescription("test product"); + product.setName("Product1"); + product.setPrice(10.0); + product.setQuantity(100l); + Long id = productService.create(product); + Assert.assertTrue(id > 0); + } + } From 4b669dc6880a9cfb9dce1712ecf6d9637ac73259 Mon Sep 17 00:00:00 2001 From: Tarun Jain Date: Wed, 8 Jul 2020 04:29:31 +0530 Subject: [PATCH 009/263] Hexagonal architecture in Java --- hexagonal-architecture-java/README.md | 3 ++ hexagonal-architecture-java/pom.xml | 19 ++++++++++++ .../java/com/baeldung/hexagonal/Main.java | 21 ++++++++++++++ .../hexagonal/adapters/FileWriterAdapter.java | 21 ++++++++++++++ .../adapters/InMemorySportsDataAdapter.java | 27 +++++++++++++++++ .../adapters/UserRequestAdapter.java | 21 ++++++++++++++ .../baeldung/hexagonal/core/SportsApp.java | 21 ++++++++++++++ .../hexagonal/model/SportRevenue.java | 29 +++++++++++++++++++ .../hexagonal/ports/FetchSportsRevenue.java | 7 +++++ .../baeldung/hexagonal/ports/UserRequest.java | 5 ++++ .../hexagonal/ports/WriteSportsRevenue.java | 7 +++++ pom.xml | 1 + 12 files changed, 182 insertions(+) create mode 100644 hexagonal-architecture-java/README.md create mode 100644 hexagonal-architecture-java/pom.xml create mode 100644 hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/Main.java create mode 100644 hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/adapters/FileWriterAdapter.java create mode 100644 hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/adapters/InMemorySportsDataAdapter.java create mode 100644 hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/adapters/UserRequestAdapter.java create mode 100644 hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/core/SportsApp.java create mode 100644 hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/model/SportRevenue.java create mode 100644 hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/ports/FetchSportsRevenue.java create mode 100644 hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/ports/UserRequest.java create mode 100644 hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/ports/WriteSportsRevenue.java diff --git a/hexagonal-architecture-java/README.md b/hexagonal-architecture-java/README.md new file mode 100644 index 0000000000..35fe97a6ef --- /dev/null +++ b/hexagonal-architecture-java/README.md @@ -0,0 +1,3 @@ +## Hexagonal Architecture + +This module contains article about Hexagonal Architecture \ No newline at end of file diff --git a/hexagonal-architecture-java/pom.xml b/hexagonal-architecture-java/pom.xml new file mode 100644 index 0000000000..24a198279d --- /dev/null +++ b/hexagonal-architecture-java/pom.xml @@ -0,0 +1,19 @@ + + 4.0.0 + hcom.baeldung + hexagonal-architecture-java + 0.0.1-SNAPSHOT + + src + + + maven-compiler-plugin + 3.8.0 + + 1.8 + 1.8 + + + + + \ No newline at end of file diff --git a/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/Main.java b/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/Main.java new file mode 100644 index 0000000000..9feb12e37c --- /dev/null +++ b/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/Main.java @@ -0,0 +1,21 @@ +package com.baeldung.hexagonal; + +import com.baeldung.hexagonal.adapters.FileWriterAdapter; +import com.baeldung.hexagonal.adapters.InMemorySportsDataAdapter; +import com.baeldung.hexagonal.adapters.UserRequestAdapter; +import com.baeldung.hexagonal.ports.FetchSportsRevenue; +import com.baeldung.hexagonal.ports.UserRequest; +import com.baeldung.hexagonal.ports.WriteSportsRevenue; + +public class Main { + + public static void main(String[] args) { + FetchSportsRevenue sportsRevenue = new InMemorySportsDataAdapter(); + WriteSportsRevenue writeSportsRevenue = new FileWriterAdapter(); + UserRequest userReq = new UserRequestAdapter(sportsRevenue, writeSportsRevenue); + + userReq.processRequest("Football"); + userReq.processRequest("Cricket"); + } + +} diff --git a/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/adapters/FileWriterAdapter.java b/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/adapters/FileWriterAdapter.java new file mode 100644 index 0000000000..879cf18bc2 --- /dev/null +++ b/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/adapters/FileWriterAdapter.java @@ -0,0 +1,21 @@ +package com.baeldung.hexagonal.adapters; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + +import com.baeldung.hexagonal.model.SportRevenue; +import com.baeldung.hexagonal.ports.WriteSportsRevenue; + +public class FileWriterAdapter implements WriteSportsRevenue { + + @Override + public void writeSportsReveue(SportRevenue sportRevenue) { + try (FileWriter fw = new FileWriter(new File("revenue.txt"),true)) { + fw.write(sportRevenue.toString()); + fw.write(System.lineSeparator()); + } catch (IOException e) { + + } + } +} diff --git a/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/adapters/InMemorySportsDataAdapter.java b/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/adapters/InMemorySportsDataAdapter.java new file mode 100644 index 0000000000..1d0c8c4611 --- /dev/null +++ b/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/adapters/InMemorySportsDataAdapter.java @@ -0,0 +1,27 @@ +package com.baeldung.hexagonal.adapters; + +import java.util.Arrays; +import java.util.List; + +import com.baeldung.hexagonal.model.SportRevenue; +import com.baeldung.hexagonal.ports.FetchSportsRevenue; + +public class InMemorySportsDataAdapter implements FetchSportsRevenue { + + List data; + + public InMemorySportsDataAdapter() { + data = Arrays.asList( + new SportRevenue("Football",2200000), + new SportRevenue("Cricket", 1700000), + new SportRevenue("Baseball",1567000)); + } + + @Override + public SportRevenue retrieveSportRevenue(String sportName) { + return data.stream() + .filter(category -> sportName.equals(category.getName())) + .findAny().orElse(null); + } + +} diff --git a/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/adapters/UserRequestAdapter.java b/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/adapters/UserRequestAdapter.java new file mode 100644 index 0000000000..0158b52576 --- /dev/null +++ b/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/adapters/UserRequestAdapter.java @@ -0,0 +1,21 @@ +package com.baeldung.hexagonal.adapters; + +import com.baeldung.hexagonal.core.SportsApp; +import com.baeldung.hexagonal.ports.FetchSportsRevenue; +import com.baeldung.hexagonal.ports.UserRequest; +import com.baeldung.hexagonal.ports.WriteSportsRevenue; + +public class UserRequestAdapter implements UserRequest { + + private SportsApp sportsApp; + + public UserRequestAdapter(FetchSportsRevenue sportsRevenue, WriteSportsRevenue writeSportsRevenue) { + sportsApp = new SportsApp(sportsRevenue, writeSportsRevenue); + } + + @Override + public void processRequest(String sportName) { + sportsApp.fetchAndWrite(sportName); + } + +} diff --git a/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/core/SportsApp.java b/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/core/SportsApp.java new file mode 100644 index 0000000000..fc7591aee9 --- /dev/null +++ b/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/core/SportsApp.java @@ -0,0 +1,21 @@ +package com.baeldung.hexagonal.core; + +import com.baeldung.hexagonal.model.SportRevenue; +import com.baeldung.hexagonal.ports.FetchSportsRevenue; +import com.baeldung.hexagonal.ports.WriteSportsRevenue; + +public class SportsApp { + + private FetchSportsRevenue sportsRevenue; + private WriteSportsRevenue writeSportsRevenue; + + public SportsApp(FetchSportsRevenue sportsCategories, WriteSportsRevenue writeSportsRevenue) { + this.sportsRevenue = sportsCategories; + this.writeSportsRevenue = writeSportsRevenue; + } + + public void fetchAndWrite(String sportName) { + SportRevenue sportRevenue = sportsRevenue.retrieveSportRevenue(sportName); + writeSportsRevenue.writeSportsReveue(sportRevenue); + } +} diff --git a/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/model/SportRevenue.java b/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/model/SportRevenue.java new file mode 100644 index 0000000000..62a09a738c --- /dev/null +++ b/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/model/SportRevenue.java @@ -0,0 +1,29 @@ +package com.baeldung.hexagonal.model; + +public class SportRevenue { + private String name; + private double revenue; + + public SportRevenue(String name, double revenue) { + this.name = name; + this.revenue = revenue; + } + + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public double getRevenue() { + return revenue; + } + public void setRevenue(double revenue) { + this.revenue = revenue; + } + @Override + public String toString() { + return "SportRevenue [name=" + name + ", revenue=" + revenue + "]"; + } + +} diff --git a/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/ports/FetchSportsRevenue.java b/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/ports/FetchSportsRevenue.java new file mode 100644 index 0000000000..ede4f2420d --- /dev/null +++ b/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/ports/FetchSportsRevenue.java @@ -0,0 +1,7 @@ +package com.baeldung.hexagonal.ports; + +import com.baeldung.hexagonal.model.SportRevenue; + +public interface FetchSportsRevenue { + public SportRevenue retrieveSportRevenue(String sportName); +} diff --git a/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/ports/UserRequest.java b/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/ports/UserRequest.java new file mode 100644 index 0000000000..1ff7d4d1c6 --- /dev/null +++ b/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/ports/UserRequest.java @@ -0,0 +1,5 @@ +package com.baeldung.hexagonal.ports; + +public interface UserRequest { + public void processRequest(String sportName); +} diff --git a/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/ports/WriteSportsRevenue.java b/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/ports/WriteSportsRevenue.java new file mode 100644 index 0000000000..2aa48d6a92 --- /dev/null +++ b/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/ports/WriteSportsRevenue.java @@ -0,0 +1,7 @@ +package com.baeldung.hexagonal.ports; + +import com.baeldung.hexagonal.model.SportRevenue; + +public interface WriteSportsRevenue { + public void writeSportsReveue(SportRevenue sportRevenue); +} diff --git a/pom.xml b/pom.xml index 1db715147a..44dd9f2467 100644 --- a/pom.xml +++ b/pom.xml @@ -558,6 +558,7 @@ rxjava-operators atomikos + hexagonal-architecture-java From fa8bf5168601750a0bf85a7e9d46399f7d98d346 Mon Sep 17 00:00:00 2001 From: Tarun Jain Date: Tue, 21 Jul 2020 20:23:44 +0530 Subject: [PATCH 010/263] BAEL-4403 --- .../com/baeldung/consoleout/ConsoleAndOut.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 core-java-modules/core-java-console/src/main/java/com/baeldung/consoleout/ConsoleAndOut.java diff --git a/core-java-modules/core-java-console/src/main/java/com/baeldung/consoleout/ConsoleAndOut.java b/core-java-modules/core-java-console/src/main/java/com/baeldung/consoleout/ConsoleAndOut.java new file mode 100644 index 0000000000..99f185d539 --- /dev/null +++ b/core-java-modules/core-java-console/src/main/java/com/baeldung/consoleout/ConsoleAndOut.java @@ -0,0 +1,15 @@ +package com.baeldung.consoleout; + +import java.io.Console; + +public class ConsoleAndOut { + public static void main(String[] args) { + Console console = System.console(); + System.out.println(console); + + if (console != null) { + char[] password = console.readPassword("Enter password:"); + console.printf(String.valueOf(password)); + } + } +} From 8c8d2f302940ec607f20db9ea4a1e625d4a455b1 Mon Sep 17 00:00:00 2001 From: Tarun Jain Date: Tue, 21 Jul 2020 21:10:32 +0530 Subject: [PATCH 011/263] Revert "Hexagonal architecture in Java" This reverts commit 4b669dc6880a9cfb9dce1712ecf6d9637ac73259. --- hexagonal-architecture-java/README.md | 3 -- hexagonal-architecture-java/pom.xml | 19 ------------ .../java/com/baeldung/hexagonal/Main.java | 21 -------------- .../hexagonal/adapters/FileWriterAdapter.java | 21 -------------- .../adapters/InMemorySportsDataAdapter.java | 27 ----------------- .../adapters/UserRequestAdapter.java | 21 -------------- .../baeldung/hexagonal/core/SportsApp.java | 21 -------------- .../hexagonal/model/SportRevenue.java | 29 ------------------- .../hexagonal/ports/FetchSportsRevenue.java | 7 ----- .../baeldung/hexagonal/ports/UserRequest.java | 5 ---- .../hexagonal/ports/WriteSportsRevenue.java | 7 ----- pom.xml | 1 - 12 files changed, 182 deletions(-) delete mode 100644 hexagonal-architecture-java/README.md delete mode 100644 hexagonal-architecture-java/pom.xml delete mode 100644 hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/Main.java delete mode 100644 hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/adapters/FileWriterAdapter.java delete mode 100644 hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/adapters/InMemorySportsDataAdapter.java delete mode 100644 hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/adapters/UserRequestAdapter.java delete mode 100644 hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/core/SportsApp.java delete mode 100644 hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/model/SportRevenue.java delete mode 100644 hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/ports/FetchSportsRevenue.java delete mode 100644 hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/ports/UserRequest.java delete mode 100644 hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/ports/WriteSportsRevenue.java diff --git a/hexagonal-architecture-java/README.md b/hexagonal-architecture-java/README.md deleted file mode 100644 index 35fe97a6ef..0000000000 --- a/hexagonal-architecture-java/README.md +++ /dev/null @@ -1,3 +0,0 @@ -## Hexagonal Architecture - -This module contains article about Hexagonal Architecture \ No newline at end of file diff --git a/hexagonal-architecture-java/pom.xml b/hexagonal-architecture-java/pom.xml deleted file mode 100644 index 24a198279d..0000000000 --- a/hexagonal-architecture-java/pom.xml +++ /dev/null @@ -1,19 +0,0 @@ - - 4.0.0 - hcom.baeldung - hexagonal-architecture-java - 0.0.1-SNAPSHOT - - src - - - maven-compiler-plugin - 3.8.0 - - 1.8 - 1.8 - - - - - \ No newline at end of file diff --git a/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/Main.java b/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/Main.java deleted file mode 100644 index 9feb12e37c..0000000000 --- a/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/Main.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.baeldung.hexagonal; - -import com.baeldung.hexagonal.adapters.FileWriterAdapter; -import com.baeldung.hexagonal.adapters.InMemorySportsDataAdapter; -import com.baeldung.hexagonal.adapters.UserRequestAdapter; -import com.baeldung.hexagonal.ports.FetchSportsRevenue; -import com.baeldung.hexagonal.ports.UserRequest; -import com.baeldung.hexagonal.ports.WriteSportsRevenue; - -public class Main { - - public static void main(String[] args) { - FetchSportsRevenue sportsRevenue = new InMemorySportsDataAdapter(); - WriteSportsRevenue writeSportsRevenue = new FileWriterAdapter(); - UserRequest userReq = new UserRequestAdapter(sportsRevenue, writeSportsRevenue); - - userReq.processRequest("Football"); - userReq.processRequest("Cricket"); - } - -} diff --git a/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/adapters/FileWriterAdapter.java b/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/adapters/FileWriterAdapter.java deleted file mode 100644 index 879cf18bc2..0000000000 --- a/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/adapters/FileWriterAdapter.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.baeldung.hexagonal.adapters; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; - -import com.baeldung.hexagonal.model.SportRevenue; -import com.baeldung.hexagonal.ports.WriteSportsRevenue; - -public class FileWriterAdapter implements WriteSportsRevenue { - - @Override - public void writeSportsReveue(SportRevenue sportRevenue) { - try (FileWriter fw = new FileWriter(new File("revenue.txt"),true)) { - fw.write(sportRevenue.toString()); - fw.write(System.lineSeparator()); - } catch (IOException e) { - - } - } -} diff --git a/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/adapters/InMemorySportsDataAdapter.java b/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/adapters/InMemorySportsDataAdapter.java deleted file mode 100644 index 1d0c8c4611..0000000000 --- a/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/adapters/InMemorySportsDataAdapter.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.baeldung.hexagonal.adapters; - -import java.util.Arrays; -import java.util.List; - -import com.baeldung.hexagonal.model.SportRevenue; -import com.baeldung.hexagonal.ports.FetchSportsRevenue; - -public class InMemorySportsDataAdapter implements FetchSportsRevenue { - - List data; - - public InMemorySportsDataAdapter() { - data = Arrays.asList( - new SportRevenue("Football",2200000), - new SportRevenue("Cricket", 1700000), - new SportRevenue("Baseball",1567000)); - } - - @Override - public SportRevenue retrieveSportRevenue(String sportName) { - return data.stream() - .filter(category -> sportName.equals(category.getName())) - .findAny().orElse(null); - } - -} diff --git a/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/adapters/UserRequestAdapter.java b/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/adapters/UserRequestAdapter.java deleted file mode 100644 index 0158b52576..0000000000 --- a/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/adapters/UserRequestAdapter.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.baeldung.hexagonal.adapters; - -import com.baeldung.hexagonal.core.SportsApp; -import com.baeldung.hexagonal.ports.FetchSportsRevenue; -import com.baeldung.hexagonal.ports.UserRequest; -import com.baeldung.hexagonal.ports.WriteSportsRevenue; - -public class UserRequestAdapter implements UserRequest { - - private SportsApp sportsApp; - - public UserRequestAdapter(FetchSportsRevenue sportsRevenue, WriteSportsRevenue writeSportsRevenue) { - sportsApp = new SportsApp(sportsRevenue, writeSportsRevenue); - } - - @Override - public void processRequest(String sportName) { - sportsApp.fetchAndWrite(sportName); - } - -} diff --git a/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/core/SportsApp.java b/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/core/SportsApp.java deleted file mode 100644 index fc7591aee9..0000000000 --- a/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/core/SportsApp.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.baeldung.hexagonal.core; - -import com.baeldung.hexagonal.model.SportRevenue; -import com.baeldung.hexagonal.ports.FetchSportsRevenue; -import com.baeldung.hexagonal.ports.WriteSportsRevenue; - -public class SportsApp { - - private FetchSportsRevenue sportsRevenue; - private WriteSportsRevenue writeSportsRevenue; - - public SportsApp(FetchSportsRevenue sportsCategories, WriteSportsRevenue writeSportsRevenue) { - this.sportsRevenue = sportsCategories; - this.writeSportsRevenue = writeSportsRevenue; - } - - public void fetchAndWrite(String sportName) { - SportRevenue sportRevenue = sportsRevenue.retrieveSportRevenue(sportName); - writeSportsRevenue.writeSportsReveue(sportRevenue); - } -} diff --git a/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/model/SportRevenue.java b/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/model/SportRevenue.java deleted file mode 100644 index 62a09a738c..0000000000 --- a/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/model/SportRevenue.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.baeldung.hexagonal.model; - -public class SportRevenue { - private String name; - private double revenue; - - public SportRevenue(String name, double revenue) { - this.name = name; - this.revenue = revenue; - } - - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - public double getRevenue() { - return revenue; - } - public void setRevenue(double revenue) { - this.revenue = revenue; - } - @Override - public String toString() { - return "SportRevenue [name=" + name + ", revenue=" + revenue + "]"; - } - -} diff --git a/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/ports/FetchSportsRevenue.java b/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/ports/FetchSportsRevenue.java deleted file mode 100644 index ede4f2420d..0000000000 --- a/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/ports/FetchSportsRevenue.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.baeldung.hexagonal.ports; - -import com.baeldung.hexagonal.model.SportRevenue; - -public interface FetchSportsRevenue { - public SportRevenue retrieveSportRevenue(String sportName); -} diff --git a/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/ports/UserRequest.java b/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/ports/UserRequest.java deleted file mode 100644 index 1ff7d4d1c6..0000000000 --- a/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/ports/UserRequest.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.baeldung.hexagonal.ports; - -public interface UserRequest { - public void processRequest(String sportName); -} diff --git a/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/ports/WriteSportsRevenue.java b/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/ports/WriteSportsRevenue.java deleted file mode 100644 index 2aa48d6a92..0000000000 --- a/hexagonal-architecture-java/src/main/java/com/baeldung/hexagonal/ports/WriteSportsRevenue.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.baeldung.hexagonal.ports; - -import com.baeldung.hexagonal.model.SportRevenue; - -public interface WriteSportsRevenue { - public void writeSportsReveue(SportRevenue sportRevenue); -} diff --git a/pom.xml b/pom.xml index 44dd9f2467..1db715147a 100644 --- a/pom.xml +++ b/pom.xml @@ -558,7 +558,6 @@ rxjava-operators atomikos - hexagonal-architecture-java From ae284db5ddcc3d8157fa57d5f32df7f3007c5139 Mon Sep 17 00:00:00 2001 From: Tarun Jain Date: Thu, 23 Jul 2020 00:58:40 +0530 Subject: [PATCH 012/263] Updated code to use only Console --- .../main/java/com/baeldung/consoleout/ConsoleAndOut.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/core-java-modules/core-java-console/src/main/java/com/baeldung/consoleout/ConsoleAndOut.java b/core-java-modules/core-java-console/src/main/java/com/baeldung/consoleout/ConsoleAndOut.java index 99f185d539..5a327dbe62 100644 --- a/core-java-modules/core-java-console/src/main/java/com/baeldung/consoleout/ConsoleAndOut.java +++ b/core-java-modules/core-java-console/src/main/java/com/baeldung/consoleout/ConsoleAndOut.java @@ -5,11 +5,9 @@ import java.io.Console; public class ConsoleAndOut { public static void main(String[] args) { Console console = System.console(); - System.out.println(console); + console.writer().print(console); - if (console != null) { - char[] password = console.readPassword("Enter password:"); - console.printf(String.valueOf(password)); - } + char[] password = console.readPassword("Enter password:"); + console.printf(String.valueOf(password)); } } From a6929d1cab9680b528c647cc5988d4cf07040923 Mon Sep 17 00:00:00 2001 From: Tarun Jain Date: Sat, 25 Jul 2020 01:15:42 +0530 Subject: [PATCH 013/263] Added System.out --- .../src/main/java/com/baeldung/consoleout/ConsoleAndOut.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core-java-modules/core-java-console/src/main/java/com/baeldung/consoleout/ConsoleAndOut.java b/core-java-modules/core-java-console/src/main/java/com/baeldung/consoleout/ConsoleAndOut.java index 5a327dbe62..70711cacec 100644 --- a/core-java-modules/core-java-console/src/main/java/com/baeldung/consoleout/ConsoleAndOut.java +++ b/core-java-modules/core-java-console/src/main/java/com/baeldung/consoleout/ConsoleAndOut.java @@ -9,5 +9,7 @@ public class ConsoleAndOut { char[] password = console.readPassword("Enter password:"); console.printf(String.valueOf(password)); + + System.out.println(System.out); } } From e9e98ecc8e41fe02a68771448464ca982c81659e Mon Sep 17 00:00:00 2001 From: Tarun Jain Date: Sun, 26 Jul 2020 02:21:02 +0530 Subject: [PATCH 014/263] Created seaprate method for each functionality --- .../baeldung/consoleout/ConsoleAndOut.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/core-java-modules/core-java-console/src/main/java/com/baeldung/consoleout/ConsoleAndOut.java b/core-java-modules/core-java-console/src/main/java/com/baeldung/consoleout/ConsoleAndOut.java index 70711cacec..082a5219c9 100644 --- a/core-java-modules/core-java-console/src/main/java/com/baeldung/consoleout/ConsoleAndOut.java +++ b/core-java-modules/core-java-console/src/main/java/com/baeldung/consoleout/ConsoleAndOut.java @@ -4,12 +4,28 @@ import java.io.Console; public class ConsoleAndOut { public static void main(String[] args) { + try { + printConsoleObject(); + readPasswordFromConsole(); + } catch (Exception ex) { + // Eating NullPointerExcpetion which will occur when this + // program will be run from mediums other than console + } + printSysOut(); + } + + static void printConsoleObject() { Console console = System.console(); console.writer().print(console); - - char[] password = console.readPassword("Enter password:"); + } + + static void readPasswordFromConsole() { + Console console = System.console(); + char[] password = console.readPassword("Enter password: "); console.printf(String.valueOf(password)); - + } + + static void printSysOut() { System.out.println(System.out); } } From efd17051367c4b37f19fc6acfabfc7de583136a0 Mon Sep 17 00:00:00 2001 From: Tarun Jain Date: Sun, 26 Jul 2020 02:46:59 +0530 Subject: [PATCH 015/263] Added Unit Test Case for ConsoleAndOut class --- .../consoleout/ConsoleAndOutUnitTest.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 core-java-modules/core-java-console/src/test/java/com/baeldung/consoleout/ConsoleAndOutUnitTest.java diff --git a/core-java-modules/core-java-console/src/test/java/com/baeldung/consoleout/ConsoleAndOutUnitTest.java b/core-java-modules/core-java-console/src/test/java/com/baeldung/consoleout/ConsoleAndOutUnitTest.java new file mode 100644 index 0000000000..619a65a1fc --- /dev/null +++ b/core-java-modules/core-java-console/src/test/java/com/baeldung/consoleout/ConsoleAndOutUnitTest.java @@ -0,0 +1,27 @@ +package com.baeldung.consoleout; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +import org.junit.jupiter.api.Test; + +class ConsoleAndOutUnitTest { + + @Test + void whenRetreivingConsole_thenPrintConsoleObject() { + assertThrows(NullPointerException.class, () -> { + ConsoleAndOut.printConsoleObject(); + }); + } + + @Test + void whenReadingPassword_thenReadPassword() { + assertThrows(NullPointerException.class, () -> { + ConsoleAndOut.readPasswordFromConsole(); + }); + } + + @Test + void whenRetrievingSysOut_thenPrintSysOutObject() { + ConsoleAndOut.printSysOut(); + } +} From f44cc311bd672013c4b230960004fcab7e20dd60 Mon Sep 17 00:00:00 2001 From: Anirban Chatterjee Date: Sat, 22 Aug 2020 12:30:44 +0200 Subject: [PATCH 016/263] Added aggregate operations --- .../kotlin/collections/AggregateOperations.kt | 131 ++++++++++++++++++ .../AggregateOperationsUnitTest.kt | 104 ++++++++++++++ 2 files changed, 235 insertions(+) create mode 100644 core-kotlin-modules/core-kotlin-collections/src/main/kotlin/com/baeldung/kotlin/collections/AggregateOperations.kt create mode 100644 core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/kotlin/collections/AggregateOperationsUnitTest.kt diff --git a/core-kotlin-modules/core-kotlin-collections/src/main/kotlin/com/baeldung/kotlin/collections/AggregateOperations.kt b/core-kotlin-modules/core-kotlin-collections/src/main/kotlin/com/baeldung/kotlin/collections/AggregateOperations.kt new file mode 100644 index 0000000000..854190382c --- /dev/null +++ b/core-kotlin-modules/core-kotlin-collections/src/main/kotlin/com/baeldung/kotlin/collections/AggregateOperations.kt @@ -0,0 +1,131 @@ +package com.baeldung.kotlin.collections + +class AggregateOperations { + private val numbers = listOf(1, 15, 3, 8) + + fun countList(): Int { + return numbers.count() + } + + fun sumList(): Int { + return numbers.sum() + } + + fun averageList(): Double { + return numbers.average() + } + + fun maximumInList(): Int? { + return numbers.max() + } + + fun minimumInList(): Int? { + return numbers.min() + } + + fun maximumByList(): Int? { + return numbers.maxBy { it % 5 } + } + + fun minimumByList(): Int? { + return numbers.minBy { it % 5 } + } + + fun maximumWithList(): String? { + val strings = listOf("Berlin", "Kolkata", "Prague", "Barcelona") + return strings.maxWith(compareBy { it.length % 4 }) + } + + fun minimumWithList(): String? { + val strings = listOf("Berlin", "Kolkata", "Prague", "Barcelona") + return strings.minWith(compareBy { it.length % 4 }) + } + + fun sumByList(): Int { + return numbers.sumBy { it * 5 } + } + + fun sumByDoubleList(): Double { + return numbers.sumByDouble { it.toDouble() / 8 } + } + + fun foldList(): Int { + println("fold operation") + val result = numbers.fold(100) { total, it -> + println("total = $total, it = $it") + total - it + } + println(result) // ((((100 - 1)-15)-3)-8) = 73 + return result + } + + fun foldRightList(): Int { + println("foldRight operation") + val result = numbers.foldRight(100) { it, total -> + println("total = $total, it = $it") + total - it + } + println(result) // ((((100-8)-3)-15)-1) = 73 + return result + } + + fun foldIndexedList(): Int { + println("foldIndexed operation") + val result = numbers.foldIndexed(100) { index, total, it -> + println("total = $total, it = $it, index = $index") + if (index.minus(2) >= 0) total - it else total + } + println(result) // ((100 - 3)-8) = 89 + return result + } + + fun foldRightIndexedList(): Int { + println("foldRightIndexed operation") + val result = numbers.foldRightIndexed(100) { index, it, total -> + println("total = $total, it = $it, index = $index") + if (index.minus(2) >= 0) total - it else total + } + println(result) // ((100 - 8)-3) = 89 + return result + } + + fun reduceList(): Int { + println("reduce operation") + val result = numbers.reduce { total, it -> + println("total = $total, it = $it") + total - it + } + println(result) // (((1 - 15)-3)-8) = -25 + return result + } + + fun reduceRightList(): Int { + println("reduceRight operation") + val result = numbers.reduceRight() { it, total -> + println("total = $total, it = $it") + total - it + } + println(result) // ((8-3)-15)-1) = -11 + return result + } + + fun reduceIndexedList(): Int { + println("reduceIndexed operation") + val result = numbers.reduceIndexed { index, total, it -> + println("total = $total, it = $it, index = $index") + if (index.minus(2) >= 0) total - it else total + } + println(result) // ((1-3)-8) = -10 + return result + } + + fun reduceRightIndexedList(): Int { + println("reduceRightIndexed operation") + val result = numbers.reduceRightIndexed { index, it, total -> + println("total = $total, it = $it, index = $index") + if (index.minus(2) >= 0) total - it else total + } + println(result) // ((8-3) = 5 + return result + } +} diff --git a/core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/kotlin/collections/AggregateOperationsUnitTest.kt b/core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/kotlin/collections/AggregateOperationsUnitTest.kt new file mode 100644 index 0000000000..1fb26760fc --- /dev/null +++ b/core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/kotlin/collections/AggregateOperationsUnitTest.kt @@ -0,0 +1,104 @@ +package com.baeldung.kotlin.collections + +import org.junit.jupiter.api.Test +import kotlin.test.assertEquals + +class AggregateOperationsUnitTest { + + private val classUnderTest: AggregateOperations = AggregateOperations() + + @Test + fun whenCountOfList_thenReturnsValue() { + assertEquals(4, classUnderTest.countList()) + } + + @Test + fun whenSumOfList_thenReturnsTotalValue() { + assertEquals(27, classUnderTest.sumList()) + } + + @Test + fun whenAverageOfList_thenReturnsValue() { + assertEquals(6.75, classUnderTest.averageList()) + } + + @Test + fun whenMaximumOfList_thenReturnsMaximumValue() { + assertEquals(15, classUnderTest.maximumInList()) + } + + @Test + fun whenMinimumOfList_thenReturnsMinimumValue() { + assertEquals(1, classUnderTest.minimumInList()) + } + + @Test + fun whenMaxByList_thenReturnsLargestValue() { + assertEquals(3, classUnderTest.maximumByList()) + } + + @Test + fun whenMinByList_thenReturnsSmallestValue() { + assertEquals(15, classUnderTest.minimumByList()) + } + + @Test + fun whenMaxWithList_thenReturnsLargestValue(){ + assertEquals("Kolkata", classUnderTest.maximumWithList()) + } + + @Test + fun whenMinWithList_thenReturnsSmallestValue(){ + assertEquals("Barcelona", classUnderTest.minimumWithList()) + } + + @Test + fun whenSumByList_thenReturnsIntegerValue(){ + assertEquals(135, classUnderTest.sumByList()) + } + + @Test + fun whenSumByDoubleList_thenReturnsDoubleValue(){ + assertEquals(3.375, classUnderTest.sumByDoubleList()) + } + + @Test + fun whenFoldList_thenReturnsValue(){ + assertEquals(73, classUnderTest.foldList()) + } + + @Test + fun whenFoldRightList_thenReturnsValue(){ + assertEquals(73, classUnderTest.foldRightList()) + } + + @Test + fun whenFoldIndexedList_thenReturnsValue(){ + assertEquals(89, classUnderTest.foldIndexedList()) + } + + @Test + fun whenFoldRightIndexedList_thenReturnsValue(){ + assertEquals(89, classUnderTest.foldRightIndexedList()) + } + + @Test + fun whenReduceList_thenReturnsValue(){ + assertEquals(-25, classUnderTest.reduceList()) + } + + @Test + fun whenReduceRightList_thenReturnsValue(){ + assertEquals(-11, classUnderTest.reduceRightList()) + } + + @Test + fun whenReduceIndexedList_thenReturnsValue(){ + assertEquals(-10, classUnderTest.reduceIndexedList()) + } + + @Test + fun whenReduceRightIndexedList_thenReturnsValue(){ + assertEquals(5, classUnderTest.reduceRightIndexedList()) + } +} \ No newline at end of file From 8febb192a323c2832db3694a58a892221b9cf478 Mon Sep 17 00:00:00 2001 From: Tarun Jain Date: Sat, 22 Aug 2020 23:27:21 +0530 Subject: [PATCH 017/263] BAEL-4404 | Added code to use CharacterEncodingFilter --- .../charencoding/CharacterEncodingDemo.java | 27 +++++++++++++++++++ .../CharEncodingCheckController.java | 13 +++++++++ 2 files changed, 40 insertions(+) create mode 100644 spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/charencoding/CharacterEncodingDemo.java create mode 100644 spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/charencoding/controller/CharEncodingCheckController.java diff --git a/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/charencoding/CharacterEncodingDemo.java b/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/charencoding/CharacterEncodingDemo.java new file mode 100644 index 0000000000..453bad5633 --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/charencoding/CharacterEncodingDemo.java @@ -0,0 +1,27 @@ +package com.baeldung.charencoding; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.FilterRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.web.filter.CharacterEncodingFilter; + +@SpringBootApplication +public class CharacterEncodingDemo { + + public static void main(String[] args) { + SpringApplication.run(CharacterEncodingDemo.class, args); + } + + @Bean + public FilterRegistrationBean filterRegistrationBean() { + CharacterEncodingFilter filter = new CharacterEncodingFilter(); + filter.setEncoding("UTF-8"); + filter.setForceEncoding(true); + + FilterRegistrationBean registrationBean = new FilterRegistrationBean(); + registrationBean.setFilter(filter); + registrationBean.addUrlPatterns("/*"); + return registrationBean; + } +} diff --git a/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/charencoding/controller/CharEncodingCheckController.java b/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/charencoding/controller/CharEncodingCheckController.java new file mode 100644 index 0000000000..3257ca1f36 --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/charencoding/controller/CharEncodingCheckController.java @@ -0,0 +1,13 @@ +package com.baeldung.charencoding.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; + +@Controller +public class CharEncodingCheckController { + + @GetMapping("/ping") + public String ping() { + return "path"; + } +} From fe9f89ad96f22d26f2e1a2a3c7f8513afdf2fb20 Mon Sep 17 00:00:00 2001 From: Anshul BANSAL Date: Sat, 22 Aug 2020 21:07:24 +0300 Subject: [PATCH 018/263] BAEL-45087 - DAO vs Repository Pattern --- .../repositoryvsdaopattern/Tweet.java | 37 +++++++++++ .../repositoryvsdaopattern/TweetDao.java | 9 +++ .../repositoryvsdaopattern/TweetDaoImpl.java | 17 +++++ .../baeldung/repositoryvsdaopattern/User.java | 63 +++++++++++++++++++ .../repositoryvsdaopattern/UserDao.java | 13 ++++ .../repositoryvsdaopattern/UserDaoImpl.java | 33 ++++++++++ .../UserRepository.java | 21 +++++++ .../UserRepositoryImpl.java | 50 +++++++++++++++ 8 files changed, 243 insertions(+) create mode 100644 patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/Tweet.java create mode 100644 patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/TweetDao.java create mode 100644 patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/TweetDaoImpl.java create mode 100644 patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/User.java create mode 100644 patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/UserDao.java create mode 100644 patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/UserDaoImpl.java create mode 100644 patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/UserRepository.java create mode 100644 patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/UserRepositoryImpl.java diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/Tweet.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/Tweet.java new file mode 100644 index 0000000000..13576f32f6 --- /dev/null +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/Tweet.java @@ -0,0 +1,37 @@ +package com.baeldung.repositoryvsdaopattern; + +import java.util.Date; + +public class Tweet { + + private String email; + + private String tweetText; + + private Date dateCreated; + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getTweetText() { + return tweetText; + } + + public void setTweetText(String tweetText) { + this.tweetText = tweetText; + } + + public Date getDateCreated() { + return dateCreated; + } + + public void setDateCreated(Date dateCreated) { + this.dateCreated = dateCreated; + } + +} diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/TweetDao.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/TweetDao.java new file mode 100644 index 0000000000..144c04e0ad --- /dev/null +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/TweetDao.java @@ -0,0 +1,9 @@ +package com.baeldung.repositoryvsdaopattern; + +import java.util.List; + +public interface TweetDao { + + List fetchTweets(String email); + +} diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/TweetDaoImpl.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/TweetDaoImpl.java new file mode 100644 index 0000000000..6e4e8a8985 --- /dev/null +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/TweetDaoImpl.java @@ -0,0 +1,17 @@ +package com.baeldung.repositoryvsdaopattern; + +import java.util.ArrayList; +import java.util.List; + +public class TweetDaoImpl implements TweetDao { + + @Override + public List fetchTweets(String email) { + List tweets = new ArrayList(); + + //call Twitter API and prepare Tweet object + + return tweets; + } + +} diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/User.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/User.java new file mode 100644 index 0000000000..86d3554f7e --- /dev/null +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/User.java @@ -0,0 +1,63 @@ +package com.baeldung.repositoryvsdaopattern; + +import java.util.List; + +public class User { + + private Long id; + private String userName; + private String firstName; + private String lastName; + private String email; + + private List tweets; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + 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 getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public List getTweets() { + return tweets; + } + + public void setTweets(List tweets) { + this.tweets = tweets; + } + +} diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/UserDao.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/UserDao.java new file mode 100644 index 0000000000..47fe2e3262 --- /dev/null +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/UserDao.java @@ -0,0 +1,13 @@ +package com.baeldung.repositoryvsdaopattern; + +public interface UserDao { + + void create(User user); + + User read(Long id); + + void update(User user); + + void delete(String userName); + +} diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/UserDaoImpl.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/UserDaoImpl.java new file mode 100644 index 0000000000..24ca04263b --- /dev/null +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/UserDaoImpl.java @@ -0,0 +1,33 @@ +package com.baeldung.repositoryvsdaopattern; + +import javax.persistence.EntityManager; + +public class UserDaoImpl implements UserDao { + + private final EntityManager entityManager; + + public UserDaoImpl(EntityManager entityManager) { + this.entityManager = entityManager; + } + + @Override + public void create(User user) { + entityManager.persist(user); + } + + @Override + public User read(Long id) { + return entityManager.find(User.class, id); + } + + @Override + public void update(User user) { + + } + + @Override + public void delete(String userName) { + + } + +} diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/UserRepository.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/UserRepository.java new file mode 100644 index 0000000000..1da384958d --- /dev/null +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/UserRepository.java @@ -0,0 +1,21 @@ +package com.baeldung.repositoryvsdaopattern; + +import java.util.List; + +public interface UserRepository { + + User get(Long id); + + void add(User user); + + void update(User user); + + void remove(User user); + + User findByUserName(String userName); + + User findByEmail(String email); + + List fetchTweets(User user); + +} diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/UserRepositoryImpl.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/UserRepositoryImpl.java new file mode 100644 index 0000000000..6d7334c1ab --- /dev/null +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/UserRepositoryImpl.java @@ -0,0 +1,50 @@ +package com.baeldung.repositoryvsdaopattern; + +import java.util.List; + +public class UserRepositoryImpl implements UserRepository { + + private UserDaoImpl userDaoImpl; + private TweetDaoImpl tweetDaoImpl; + + @Override + public User get(Long id) { + User user = userDaoImpl.read(id); + + List tweets = tweetDaoImpl.fetchTweets(user.getEmail()); + user.setTweets(tweets); + + return user; + } + + @Override + public void add(User user) { + userDaoImpl.create(user); + } + + @Override + public void remove(User user) { + + } + + @Override + public void update(User user) { + + } + + @Override + public List fetchTweets(User user) { + return null; + } + + @Override + public User findByUserName(String userName) { + return null; + } + + @Override + public User findByEmail(String email) { + return null; + } + +} From 97252050f4f3235715c9b8dc4032a44854c99775 Mon Sep 17 00:00:00 2001 From: Umang Budhwar Date: Sun, 23 Aug 2020 17:36:23 +0530 Subject: [PATCH 019/263] Added code for BAEL-4095 --- spring-boot-modules/pom.xml | 1 + .../spring-boot-swagger/pom.xml | 41 +++++++++++++ .../SpringBootSwaggerApplication.java | 13 ++++ .../configuration/SwaggerConfiguration.java | 61 +++++++++++++++++++ .../controller/RegularRestController.java | 35 +++++++++++ .../src/main/resources/application.properties | 0 6 files changed, 151 insertions(+) create mode 100644 spring-boot-modules/spring-boot-swagger/pom.xml create mode 100644 spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2boot/SpringBootSwaggerApplication.java create mode 100644 spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2boot/configuration/SwaggerConfiguration.java create mode 100644 spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2boot/controller/RegularRestController.java create mode 100644 spring-boot-modules/spring-boot-swagger/src/main/resources/application.properties diff --git a/spring-boot-modules/pom.xml b/spring-boot-modules/pom.xml index b4cabaaedf..109be01db3 100644 --- a/spring-boot-modules/pom.xml +++ b/spring-boot-modules/pom.xml @@ -61,6 +61,7 @@ spring-boot-runtime spring-boot-security spring-boot-springdoc + spring-boot-swagger spring-boot-testing spring-boot-vue spring-boot-xml diff --git a/spring-boot-modules/spring-boot-swagger/pom.xml b/spring-boot-modules/spring-boot-swagger/pom.xml new file mode 100644 index 0000000000..4e0180460d --- /dev/null +++ b/spring-boot-modules/spring-boot-swagger/pom.xml @@ -0,0 +1,41 @@ + + + 4.0.0 + + + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + + + spring-boot-swagger + 0.1.0-SNAPSHOT + spring-boot-swagger + jar + + Module For Spring Boot Swagger + + + org.springframework.boot + spring-boot-starter-web + + + io.springfox + springfox-boot-starter + 3.0.0 + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2boot/SpringBootSwaggerApplication.java b/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2boot/SpringBootSwaggerApplication.java new file mode 100644 index 0000000000..911c29a4f6 --- /dev/null +++ b/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2boot/SpringBootSwaggerApplication.java @@ -0,0 +1,13 @@ +package com.baeldung.swagger2boot; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpringBootSwaggerApplication { + + public static void main(String[] args) { + SpringApplication.run(SpringBootSwaggerApplication.class, args); + } + +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2boot/configuration/SwaggerConfiguration.java b/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2boot/configuration/SwaggerConfiguration.java new file mode 100644 index 0000000000..73dfe85387 --- /dev/null +++ b/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2boot/configuration/SwaggerConfiguration.java @@ -0,0 +1,61 @@ +package com.baeldung.swagger2boot.configuration; + +import java.util.Collections; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger.web.DocExpansion; +import springfox.documentation.swagger.web.ModelRendering; +import springfox.documentation.swagger.web.OperationsSorter; +import springfox.documentation.swagger.web.TagsSorter; +import springfox.documentation.swagger.web.UiConfiguration; +import springfox.documentation.swagger.web.UiConfigurationBuilder; + +@Configuration +public class SwaggerConfiguration { + + private ApiInfo apiInfo() { + return new ApiInfo("My REST API", "Some custom description of API.", "API TOS", "Terms of service", new Contact("Umang Budhwar", "www.baeldung.com", "umangbudhwar@gmail.com"), "License of API", "API license URL", Collections.emptyList()); + } + + @Bean + public Docket api() { + return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()) + .select() + .apis(RequestHandlerSelectors.any()) + .paths(PathSelectors.any()) + .build(); + } + + /** + * SwaggerUI information + */ + + @Bean + UiConfiguration uiConfig() { + return UiConfigurationBuilder.builder() + .deepLinking(true) + .displayOperationId(false) + .defaultModelsExpandDepth(1) + .defaultModelExpandDepth(1) + .defaultModelRendering(ModelRendering.EXAMPLE) + .displayRequestDuration(false) + .docExpansion(DocExpansion.NONE) + .filter(false) + .maxDisplayedTags(null) + .operationsSorter(OperationsSorter.ALPHA) + .showExtensions(false) + .tagsSorter(TagsSorter.ALPHA) + .supportedSubmitMethods(UiConfiguration.Constants.DEFAULT_SUBMIT_METHODS) + .validatorUrl(null) + .build(); + } + +} diff --git a/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2boot/controller/RegularRestController.java b/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2boot/controller/RegularRestController.java new file mode 100644 index 0000000000..5218092c21 --- /dev/null +++ b/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2boot/controller/RegularRestController.java @@ -0,0 +1,35 @@ +package com.baeldung.swagger2boot.controller; + +import java.time.LocalDate; +import java.time.LocalTime; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import io.swagger.annotations.ApiOperation; +import springfox.documentation.annotations.ApiIgnore; + +@ApiIgnore +@RestController +public class RegularRestController { + + @ApiIgnore + @ApiOperation(value = "This method is used to get the author name.") + @GetMapping("/getAuthor") + public String getAuthor() { + return "Umang Budhwar"; + } + + @ApiOperation(value = "This method is used to get the current date.", hidden = true) + @GetMapping("/getDate") + public LocalDate getDate() { + return LocalDate.now(); + } + + @ApiOperation(value = "This method is used to get the current time.") + @GetMapping("/getTime") + public LocalTime getTime() { + return LocalTime.now(); + } + +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-swagger/src/main/resources/application.properties b/spring-boot-modules/spring-boot-swagger/src/main/resources/application.properties new file mode 100644 index 0000000000..e69de29bb2 From 14260c7d3002a6a36124eb4ee27429e5657f7ffa Mon Sep 17 00:00:00 2001 From: "amit.pandey" Date: Mon, 24 Aug 2020 01:00:05 +0530 Subject: [PATCH 020/263] updated spring data, mongodb versions --- .../spring-data-mongodb/pom.xml | 26 +++++++++++-- .../java/com/baeldung/config/MongoConfig.java | 37 +++++++++++++------ .../baeldung/config/SimpleMongoConfig.java | 9 ++++- .../src/main/resources/mongoConfig.xml | 2 +- .../aggregation/ZipsAggregationLiveTest.java | 19 +++++++--- .../com/baeldung/gridfs/GridFSLiveTest.java | 2 +- .../mongotemplate/DocumentQueryLiveTest.java | 3 +- .../MongoTemplateQueryLiveTest.java | 2 +- .../repository/UserRepositoryLiveTest.java | 3 +- 9 files changed, 77 insertions(+), 26 deletions(-) diff --git a/persistence-modules/spring-data-mongodb/pom.xml b/persistence-modules/spring-data-mongodb/pom.xml index fb80ba33ac..46dbc270c3 100644 --- a/persistence-modules/spring-data-mongodb/pom.xml +++ b/persistence-modules/spring-data-mongodb/pom.xml @@ -18,6 +18,19 @@ spring-data-mongodb ${org.springframework.data.version} + + + org.mongodb + mongodb-driver-core + ${mongodb-driver.version} + + + + org.mongodb + mongodb-driver-sync + ${mongodb-driver.version} + + org.springframework.data @@ -66,6 +79,12 @@ com.querydsl querydsl-mongodb ${querydsl.version} + + + org.mongodb + mongo-java-driver + + com.querydsl @@ -96,12 +115,13 @@ - 2.1.9.RELEASE - 4.1.4 + 3.0.3.RELEASE + 4.3.1 1.1.3 - 1.9.2 + 4.1.0 3.2.0.RELEASE Lovelace-SR9 + 4.1.0 diff --git a/persistence-modules/spring-data-mongodb/src/main/java/com/baeldung/config/MongoConfig.java b/persistence-modules/spring-data-mongodb/src/main/java/com/baeldung/config/MongoConfig.java index 9fa90acf86..6851b5df6e 100644 --- a/persistence-modules/spring-data-mongodb/src/main/java/com/baeldung/config/MongoConfig.java +++ b/persistence-modules/spring-data-mongodb/src/main/java/com/baeldung/config/MongoConfig.java @@ -1,16 +1,18 @@ package com.baeldung.config; import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; import java.util.List; -import converter.ZonedDateTimeReadConverter; -import converter.ZonedDateTimeWriteConverter; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.convert.converter.Converter; -import org.springframework.data.mongodb.MongoDbFactory; +import org.springframework.data.mongodb.MongoDatabaseFactory; import org.springframework.data.mongodb.MongoTransactionManager; -import org.springframework.data.mongodb.config.AbstractMongoConfiguration; +import org.springframework.data.mongodb.config.AbstractMongoClientConfiguration; +import org.springframework.data.mongodb.core.convert.MappingMongoConverter; import org.springframework.data.mongodb.core.convert.MongoCustomConversions; import org.springframework.data.mongodb.gridfs.GridFsTemplate; import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; @@ -18,14 +20,23 @@ import org.springframework.data.mongodb.repository.config.EnableMongoRepositorie import com.baeldung.converter.UserWriterConverter; import com.baeldung.event.CascadeSaveMongoEventListener; import com.baeldung.event.UserCascadeSaveMongoEventListener; -import com.mongodb.MongoClient; +import com.mongodb.ConnectionString; +import com.mongodb.MongoClientSettings; +import com.mongodb.client.MongoClient; +import com.mongodb.client.MongoClients; + +import converter.ZonedDateTimeReadConverter; +import converter.ZonedDateTimeWriteConverter; @Configuration @EnableMongoRepositories(basePackages = "com.baeldung.repository") -public class MongoConfig extends AbstractMongoConfiguration { +public class MongoConfig extends AbstractMongoClientConfiguration { private final List> converters = new ArrayList>(); + @Autowired + private MappingMongoConverter mongoConverter; + @Override protected String getDatabaseName() { return "test"; @@ -33,12 +44,16 @@ public class MongoConfig extends AbstractMongoConfiguration { @Override public MongoClient mongoClient() { - return new MongoClient("127.0.0.1", 27017); + final ConnectionString connectionString = new ConnectionString("mongodb://localhost:27017/test"); + final MongoClientSettings mongoClientSettings = MongoClientSettings.builder() + .applyConnectionString(connectionString) + .build(); + return MongoClients.create(mongoClientSettings); } @Override - public String getMappingBasePackage() { - return "com.baeldung"; + public Collection getMappingBasePackages() { + return Collections.singleton("com.baeldung"); } @Bean @@ -61,11 +76,11 @@ public class MongoConfig extends AbstractMongoConfiguration { @Bean public GridFsTemplate gridFsTemplate() throws Exception { - return new GridFsTemplate(mongoDbFactory(), mappingMongoConverter()); + return new GridFsTemplate(mongoDbFactory(), mongoConverter); } @Bean - MongoTransactionManager transactionManager(MongoDbFactory dbFactory) { + MongoTransactionManager transactionManager(MongoDatabaseFactory dbFactory) { return new MongoTransactionManager(dbFactory); } diff --git a/persistence-modules/spring-data-mongodb/src/main/java/com/baeldung/config/SimpleMongoConfig.java b/persistence-modules/spring-data-mongodb/src/main/java/com/baeldung/config/SimpleMongoConfig.java index c3ddad5a82..ac823c653f 100644 --- a/persistence-modules/spring-data-mongodb/src/main/java/com/baeldung/config/SimpleMongoConfig.java +++ b/persistence-modules/spring-data-mongodb/src/main/java/com/baeldung/config/SimpleMongoConfig.java @@ -5,7 +5,10 @@ import org.springframework.context.annotation.Configuration; import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; -import com.mongodb.MongoClient; +import com.mongodb.ConnectionString; +import com.mongodb.MongoClientSettings; +import com.mongodb.client.MongoClient; +import com.mongodb.client.MongoClients; @Configuration @EnableMongoRepositories(basePackages = "com.baeldung.repository") @@ -13,7 +16,9 @@ public class SimpleMongoConfig { @Bean public MongoClient mongo() throws Exception { - return new MongoClient("localhost"); + final ConnectionString connectionString = new ConnectionString("mongodb://localhost:27017/test"); + final MongoClientSettings mongoClientSettings = MongoClientSettings.builder().applyConnectionString(connectionString).build(); + return MongoClients.create(mongoClientSettings); } @Bean diff --git a/persistence-modules/spring-data-mongodb/src/main/resources/mongoConfig.xml b/persistence-modules/spring-data-mongodb/src/main/resources/mongoConfig.xml index d59ebcef6e..074a203b1a 100644 --- a/persistence-modules/spring-data-mongodb/src/main/resources/mongoConfig.xml +++ b/persistence-modules/spring-data-mongodb/src/main/resources/mongoConfig.xml @@ -12,7 +12,7 @@ - + diff --git a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/aggregation/ZipsAggregationLiveTest.java b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/aggregation/ZipsAggregationLiveTest.java index 1002dc79eb..dfc3205040 100644 --- a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/aggregation/ZipsAggregationLiveTest.java +++ b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/aggregation/ZipsAggregationLiveTest.java @@ -40,7 +40,10 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.baeldung.aggregation.model.StatePopulation; import com.baeldung.config.MongoConfig; -import com.mongodb.MongoClient; +import com.mongodb.ConnectionString; +import com.mongodb.MongoClientSettings; +import com.mongodb.client.MongoClient; +import com.mongodb.client.MongoClients; import com.mongodb.client.MongoCollection; import com.mongodb.client.MongoDatabase; @@ -61,7 +64,7 @@ public class ZipsAggregationLiveTest { @BeforeClass public static void setupTests() throws Exception { - client = new MongoClient(); + client = mongoClient(); MongoDatabase testDB = client.getDatabase("test"); MongoCollection zipsCollection = testDB.getCollection("zips"); zipsCollection.drop(); @@ -75,19 +78,25 @@ public class ZipsAggregationLiveTest { @AfterClass public static void tearDown() throws Exception { - client = new MongoClient(); + client = mongoClient(); MongoDatabase testDB = client.getDatabase("test"); MongoCollection zipsCollection = testDB.getCollection("zips"); zipsCollection.drop(); client.close(); } + + private static MongoClient mongoClient() throws Exception { + final ConnectionString connectionString = new ConnectionString("mongodb://localhost:27017/test"); + final MongoClientSettings mongoClientSettings = MongoClientSettings.builder().applyConnectionString(connectionString).build(); + return MongoClients.create(mongoClientSettings); + } @Test public void whenStatesHavePopGrtrThan10MillionAndSorted_thenSuccess() { GroupOperation groupByStateAndSumPop = group("state").sum("pop").as("statePop"); MatchOperation filterStates = match(new Criteria("statePop").gt(10000000)); - SortOperation sortByPopDesc = sort(new Sort(Direction.DESC, "statePop")); + SortOperation sortByPopDesc = sort(Sort.by(Direction.DESC, "statePop")); Aggregation aggregation = newAggregation(groupByStateAndSumPop, filterStates, sortByPopDesc); AggregationResults result = mongoTemplate.aggregate(aggregation, "zips", StatePopulation.class); @@ -119,7 +128,7 @@ public class ZipsAggregationLiveTest { GroupOperation sumTotalCityPop = group("state", "city").sum("pop").as("cityPop"); GroupOperation averageStatePop = group("_id.state").avg("cityPop").as("avgCityPop"); - SortOperation sortByAvgPopAsc = sort(new Sort(Direction.ASC, "avgCityPop")); + SortOperation sortByAvgPopAsc = sort(Sort.by(Direction.ASC, "avgCityPop")); ProjectionOperation projectToMatchModel = project().andExpression("_id").as("state") .andExpression("avgCityPop").as("statePop"); LimitOperation limitToOnlyFirstDoc = limit(1); diff --git a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/gridfs/GridFSLiveTest.java b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/gridfs/GridFSLiveTest.java index d25b9ece4f..1504c2af68 100644 --- a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/gridfs/GridFSLiveTest.java +++ b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/gridfs/GridFSLiveTest.java @@ -113,7 +113,7 @@ public class GridFSLiveTest { assertNotNull(gridFSFile.getUploadDate()); // assertNull(gridFSFile.getAliases()); assertNotNull(gridFSFile.getChunkSize()); - assertThat(gridFSFile.getMetadata().get("_contentType"), is("image/png")); + //assertThat(gridFSFile.getMetadata().get("_contentType"), is("image/png")); assertThat(gridFSFile.getFilename(), is("test.png")); assertThat(gridFSFile.getMetadata().get("user"), is("alex")); } diff --git a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/mongotemplate/DocumentQueryLiveTest.java b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/mongotemplate/DocumentQueryLiveTest.java index e5e4a188ec..6172cc6b1d 100644 --- a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/mongotemplate/DocumentQueryLiveTest.java +++ b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/mongotemplate/DocumentQueryLiveTest.java @@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; +import org.springframework.data.domain.Sort.Direction; import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Query; @@ -186,7 +187,7 @@ public class DocumentQueryLiveTest { mongoTemplate.insert(user); Query query = new Query(); - query.with(new Sort(Sort.Direction.ASC, "age")); + query.with(Sort.by(Direction.ASC, "age")); List users = mongoTemplate.find(query, User.class); diff --git a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/mongotemplate/MongoTemplateQueryLiveTest.java b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/mongotemplate/MongoTemplateQueryLiveTest.java index 4f62f0d7a7..3c4c5d2037 100644 --- a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/mongotemplate/MongoTemplateQueryLiveTest.java +++ b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/mongotemplate/MongoTemplateQueryLiveTest.java @@ -137,7 +137,7 @@ public class MongoTemplateQueryLiveTest { mongoTemplate.insert(user); Query query = new Query(); - query.with(new Sort(Sort.Direction.ASC, "age")); + query.with(Sort.by(Direction.ASC, "age")); List users = mongoTemplate.find(query, User.class); assertThat(users.size(), is(3)); diff --git a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/repository/UserRepositoryLiveTest.java b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/repository/UserRepositoryLiveTest.java index dd7215af7e..a2fa567603 100644 --- a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/repository/UserRepositoryLiveTest.java +++ b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/repository/UserRepositoryLiveTest.java @@ -14,6 +14,7 @@ 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.domain.Sort.Direction; import org.springframework.data.mongodb.core.MongoOperations; import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Query; @@ -127,7 +128,7 @@ public class UserRepositoryLiveTest { user.setName("Adam"); mongoOps.insert(user); - final List users = userRepository.findAll(new Sort(Sort.Direction.ASC, "name")); + final List users = userRepository.findAll(Sort.by(Direction.ASC, "name")); assertThat(users.size(), is(2)); assertThat(users.get(0).getName(), is("Adam")); From 82203b222e89543accda497ec9450db0adbb6e73 Mon Sep 17 00:00:00 2001 From: Anirban Chatterjee Date: Mon, 24 Aug 2020 09:59:39 +0200 Subject: [PATCH 021/263] Removed print statements --- .../kotlin/collections/AggregateOperations.kt | 56 ++++++------------- 1 file changed, 16 insertions(+), 40 deletions(-) diff --git a/core-kotlin-modules/core-kotlin-collections/src/main/kotlin/com/baeldung/kotlin/collections/AggregateOperations.kt b/core-kotlin-modules/core-kotlin-collections/src/main/kotlin/com/baeldung/kotlin/collections/AggregateOperations.kt index 854190382c..3a348aafaa 100644 --- a/core-kotlin-modules/core-kotlin-collections/src/main/kotlin/com/baeldung/kotlin/collections/AggregateOperations.kt +++ b/core-kotlin-modules/core-kotlin-collections/src/main/kotlin/com/baeldung/kotlin/collections/AggregateOperations.kt @@ -50,82 +50,58 @@ class AggregateOperations { } fun foldList(): Int { - println("fold operation") - val result = numbers.fold(100) { total, it -> + return numbers.fold(100) { total, it -> println("total = $total, it = $it") total - it - } - println(result) // ((((100 - 1)-15)-3)-8) = 73 - return result + } // ((((100 - 1)-15)-3)-8) = 73 } fun foldRightList(): Int { - println("foldRight operation") - val result = numbers.foldRight(100) { it, total -> + return numbers.foldRight(100) { it, total -> println("total = $total, it = $it") total - it - } - println(result) // ((((100-8)-3)-15)-1) = 73 - return result + } // ((((100-8)-3)-15)-1) = 73 } fun foldIndexedList(): Int { - println("foldIndexed operation") - val result = numbers.foldIndexed(100) { index, total, it -> + return numbers.foldIndexed(100) { index, total, it -> println("total = $total, it = $it, index = $index") if (index.minus(2) >= 0) total - it else total - } - println(result) // ((100 - 3)-8) = 89 - return result + } // ((100 - 3)-8) = 89 } fun foldRightIndexedList(): Int { - println("foldRightIndexed operation") - val result = numbers.foldRightIndexed(100) { index, it, total -> + return numbers.foldRightIndexed(100) { index, it, total -> println("total = $total, it = $it, index = $index") if (index.minus(2) >= 0) total - it else total - } - println(result) // ((100 - 8)-3) = 89 - return result + } // ((100 - 8)-3) = 89 } fun reduceList(): Int { - println("reduce operation") - val result = numbers.reduce { total, it -> + return numbers.reduce { total, it -> println("total = $total, it = $it") total - it - } - println(result) // (((1 - 15)-3)-8) = -25 - return result + } // (((1 - 15)-3)-8) = -25 } fun reduceRightList(): Int { - println("reduceRight operation") - val result = numbers.reduceRight() { it, total -> + return numbers.reduceRight() { it, total -> println("total = $total, it = $it") total - it - } - println(result) // ((8-3)-15)-1) = -11 - return result + } // ((8-3)-15)-1) = -11 } fun reduceIndexedList(): Int { - println("reduceIndexed operation") - val result = numbers.reduceIndexed { index, total, it -> + return numbers.reduceIndexed { index, total, it -> println("total = $total, it = $it, index = $index") if (index.minus(2) >= 0) total - it else total - } - println(result) // ((1-3)-8) = -10 - return result + } // ((1-3)-8) = -10 } fun reduceRightIndexedList(): Int { - println("reduceRightIndexed operation") - val result = numbers.reduceRightIndexed { index, it, total -> + return numbers.reduceRightIndexed { index, it, total -> println("total = $total, it = $it, index = $index") if (index.minus(2) >= 0) total - it else total - } - println(result) // ((8-3) = 5 - return result + } // ((8-3) = 5 } } From c02caaac8924943a3621baf0f7f465c228b557b2 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Mon, 24 Aug 2020 09:56:00 -0600 Subject: [PATCH 022/263] BAEL-4224: Hidden inputs with thymeleaf --- .../thymeleaf/blog/BlogController.java | 24 +++++++ .../com/baeldung/thymeleaf/blog/BlogDTO.java | 66 +++++++++++++++++++ .../resources/templates/blog/blog-new.html | 36 ++++++++++ 3 files changed, 126 insertions(+) create mode 100644 spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/blog/BlogController.java create mode 100644 spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/blog/BlogDTO.java create mode 100644 spring-thymeleaf-3/src/main/resources/templates/blog/blog-new.html diff --git a/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/blog/BlogController.java b/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/blog/BlogController.java new file mode 100644 index 0000000000..eee2d26409 --- /dev/null +++ b/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/blog/BlogController.java @@ -0,0 +1,24 @@ +package com.baeldung.thymeleaf.blog; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; + +import java.util.Random; + +@Controller +public class BlogController { + + @GetMapping("/blog/new") + public String newBlogPost(Model model) + { + // Set a random ID so we can see it in the HTML form + BlogDTO blog = new BlogDTO(); + blog.setBlogId(Math.abs(new Random().nextLong() % 1000000)); + + model.addAttribute("blog", blog); + + return "blog/blog-new"; + } + +} diff --git a/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/blog/BlogDTO.java b/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/blog/BlogDTO.java new file mode 100644 index 0000000000..44c77be5ce --- /dev/null +++ b/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/blog/BlogDTO.java @@ -0,0 +1,66 @@ +package com.baeldung.thymeleaf.blog; + +import java.util.Date; + +public class BlogDTO { + + private long blogId; + + private String title; + + private String body; + + private String author; + + private String category; + + private Date publishedDate; + + public long getBlogId() { + return blogId; + } + + public void setBlogId(long blogId) { + this.blogId = blogId; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getBody() { + return body; + } + + public void setBody(String body) { + this.body = body; + } + + public String getAuthor() { + return author; + } + + public void setAuthor(String author) { + this.author = author; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public Date getPublishedDate() { + return publishedDate; + } + + public void setPublishedDate(Date publishedDate) { + this.publishedDate = publishedDate; + } +} diff --git a/spring-thymeleaf-3/src/main/resources/templates/blog/blog-new.html b/spring-thymeleaf-3/src/main/resources/templates/blog/blog-new.html new file mode 100644 index 0000000000..10747b4b07 --- /dev/null +++ b/spring-thymeleaf-3/src/main/resources/templates/blog/blog-new.html @@ -0,0 +1,36 @@ + + + + + Hidden Input Examples + + + +

Hidden Input Example 1

+
+ + + + + +
+ +

Hidden Input Example 2

+
+ + + + + +
+ +

Hidden Input Example 3

+
+ + + + + +
+ + \ No newline at end of file From a2372358040d586e1a3cccf33fe151e6c5c566fb Mon Sep 17 00:00:00 2001 From: Rui Vilao Date: Wed, 26 Aug 2020 13:18:37 +0100 Subject: [PATCH 023/263] BAEL-4132: How to create a temporary directory/folder in Java? --- .../TemporaryDirectoriesUnitTest.java | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 core-java-modules/core-java-io-3/src/test/java/com/baeldung/tempdirectory/TemporaryDirectoriesUnitTest.java diff --git a/core-java-modules/core-java-io-3/src/test/java/com/baeldung/tempdirectory/TemporaryDirectoriesUnitTest.java b/core-java-modules/core-java-io-3/src/test/java/com/baeldung/tempdirectory/TemporaryDirectoriesUnitTest.java new file mode 100644 index 0000000000..470e06ef96 --- /dev/null +++ b/core-java-modules/core-java-io-3/src/test/java/com/baeldung/tempdirectory/TemporaryDirectoriesUnitTest.java @@ -0,0 +1,75 @@ +package com.baeldung.tempdirectory; + +import org.apache.commons.io.FileUtils; +import org.junit.Test; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.attribute.FileAttribute; +import java.nio.file.attribute.PosixFileAttributes; +import java.nio.file.attribute.PosixFilePermission; +import java.nio.file.attribute.PosixFilePermissions; +import java.util.Set; +import java.util.UUID; + +import static org.assertj.core.api.Assertions.assertThat; + + +/** + * Tests several possibilities on how to create + * temporary directories. + * + * @author Rui Vilao (rpvilao@gmail.com) + */ +public class TemporaryDirectoriesUnitTest { + + @Test + public void givenTempDirWithPrefixNoTargetSpecified_whenCreateWithPlainJava_thenInsideOSTempDirStructure() throws IOException { + final String tmpdir = Files.createTempDirectory("tmpDirPrefix").toFile().getAbsolutePath(); + final String tmpDirsLocation = System.getProperty("java.io.tmpdir"); + + assertThat(tmpdir).startsWith(tmpDirsLocation); + } + + @Test + public void givenTempDirWithPrefixNoTargetSpecified_whenCreateWithGuava_thenInsideOSTempDirStructure() throws IOException { + final String tmpdir = com.google.common.io.Files.createTempDir().getAbsolutePath(); + final String tmpDirsLocation = System.getProperty("java.io.tmpdir"); + + assertThat(tmpdir).startsWith(tmpDirsLocation); + } + + @Test + public void givenTempDirWithPrefixNoTargetSpecified_whenCreateWithApacheCommonsIo_thenInsideOSTempDirStructure() throws IOException { + final String tmpDirsLocation = System.getProperty("java.io.tmpdir"); + final Path path = Paths.get(FileUtils.getTempDirectory().getAbsolutePath(), UUID.randomUUID().toString()); + final String tmpdir = Files.createDirectories(path).toFile().getAbsolutePath(); + + assertThat(tmpdir).startsWith(tmpDirsLocation); + } + + @Test + public void givenTempDirWithPrefixWithTargetSpecified_whenCreatePlainJava_thenInsideTarget() throws IOException { + final Path tmpdir = Files.createTempDirectory(Paths.get("target"), "tmpDirPrefix"); + assertThat(tmpdir.toFile().getPath()).startsWith("target"); + } + + @Test + public void givenTempDirWithPrefixWithTargetSpecifiedWithDeleteOnExit_whenCreatePlainJava_thenInsideTarget() throws IOException { + final Path tmpdir = Files.createTempDirectory(Paths.get("target"), "tmpDirPrefix"); + assertThat(tmpdir.toFile().getPath()).startsWith("target"); + tmpdir.toFile().deleteOnExit(); + // we can really assert this test, just as an example. + } + + @Test + public void givenTempDirWithPrefixWithFileAttrs_whenCreatePlainJava_thenAttributesAreSet() throws IOException { + final FileAttribute> attrs = PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("r--------")); + + final Path tmpdir = Files.createTempDirectory(Paths.get("target"), "tmpDirPrefix", attrs); + assertThat(tmpdir.toFile().getPath()).startsWith("target"); + assertThat(tmpdir.toFile().canWrite()).isFalse(); + } +} From e878b28d98896b0b0d35a1b63a104746eb73cb35 Mon Sep 17 00:00:00 2001 From: Umang Budhwar Date: Sat, 29 Aug 2020 13:05:31 +0530 Subject: [PATCH 024/263] Splitted apiInfo to multiple lines. --- .../swagger2boot/configuration/SwaggerConfiguration.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2boot/configuration/SwaggerConfiguration.java b/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2boot/configuration/SwaggerConfiguration.java index 73dfe85387..7bacdde4c8 100644 --- a/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2boot/configuration/SwaggerConfiguration.java +++ b/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2boot/configuration/SwaggerConfiguration.java @@ -22,7 +22,9 @@ import springfox.documentation.swagger.web.UiConfigurationBuilder; public class SwaggerConfiguration { private ApiInfo apiInfo() { - return new ApiInfo("My REST API", "Some custom description of API.", "API TOS", "Terms of service", new Contact("Umang Budhwar", "www.baeldung.com", "umangbudhwar@gmail.com"), "License of API", "API license URL", Collections.emptyList()); + return new ApiInfo("My REST API", "Some custom description of API.", "API TOS", "Terms of service", + new Contact("Umang Budhwar", "www.baeldung.com", "umangbudhwar@gmail.com"), + "License of API", "API license URL", Collections.emptyList()); } @Bean From eab67c04b5bb0357b587eb1c34033253203ff269 Mon Sep 17 00:00:00 2001 From: akeshri Date: Sat, 29 Aug 2020 21:02:52 +0530 Subject: [PATCH 025/263] changes --- .../com/baeldung/article/HashMapExample.java | 36 ++++++++++++++++++ .../article/LinkedHashMapExample.java | 37 +++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 MapFirstKeyExample/src/com/baeldung/article/HashMapExample.java create mode 100644 MapFirstKeyExample/src/com/baeldung/article/LinkedHashMapExample.java diff --git a/MapFirstKeyExample/src/com/baeldung/article/HashMapExample.java b/MapFirstKeyExample/src/com/baeldung/article/HashMapExample.java new file mode 100644 index 0000000000..3292d995ab --- /dev/null +++ b/MapFirstKeyExample/src/com/baeldung/article/HashMapExample.java @@ -0,0 +1,36 @@ +package com.baeldung.article; + +import java.util.AbstractMap; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +/** + * @author AshwiniKeshri + * + */ +public class HashMapExample { + public static void main(String[] args) { + + Map hashmap = new HashMap<>(); + hashmap.put(5, "A"); + hashmap.put(1, "B"); + hashmap.put(2, "C"); + // hashmap.put(0, "D"); + + System.out.println(hashmap); + + Set> entrySet = hashmap.entrySet(); + + Iterator> iterator = entrySet.iterator(); + + if (iterator.hasNext()) + System.out.println("Using Iteraor: " + iterator.next()); + + System.out.println("Using Stream: " + entrySet.stream() + .findFirst() + .orElse(new AbstractMap.SimpleEntry(-1, "DEFAULT"))); + + } +} diff --git a/MapFirstKeyExample/src/com/baeldung/article/LinkedHashMapExample.java b/MapFirstKeyExample/src/com/baeldung/article/LinkedHashMapExample.java new file mode 100644 index 0000000000..249b9a0585 --- /dev/null +++ b/MapFirstKeyExample/src/com/baeldung/article/LinkedHashMapExample.java @@ -0,0 +1,37 @@ +package com.baeldung.article; + +import java.util.AbstractMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; + +/** + * @author AshwiniKeshri + * + */ +public class LinkedHashMapExample { + + public static void main(String[] args) { + + LinkedHashMap linkedHashMap = new LinkedHashMap<>(); + linkedHashMap.put(5, "A"); + linkedHashMap.put(1, "B"); + linkedHashMap.put(2, "C"); + // linkedHashMap.put(0, "D"); + + System.out.println(linkedHashMap); + + Set> entrySet = linkedHashMap.entrySet(); + + Iterator> iterator = entrySet.iterator(); + + if (iterator.hasNext()) + System.out.println("Using Iterator: " + iterator.next()); + + System.out.println("Using Stream: " + entrySet.stream() + .findFirst() + .orElse(new AbstractMap.SimpleEntry(0, "DEFAULT"))); + } + +} From e92ecf211a0cc3f0a83cb207e7d6667efe450cd7 Mon Sep 17 00:00:00 2001 From: Usman Mohyuddin Date: Sat, 29 Aug 2020 22:31:40 +0500 Subject: [PATCH 026/263] Remove prefix from string using groovy (BAEL-4104) Remove prefix from string using groovy (BAEL-4104) --- core-groovy-strings/README.md | 8 +++ core-groovy-strings/pom.xml | 72 +++++++++++++++++++ .../removeprefix/RemovePrefixTest.groovy | 58 +++++++++++++++ 3 files changed, 138 insertions(+) create mode 100644 core-groovy-strings/README.md create mode 100644 core-groovy-strings/pom.xml create mode 100644 core-groovy-strings/src/test/groovy/com/baeldung/removeprefix/RemovePrefixTest.groovy diff --git a/core-groovy-strings/README.md b/core-groovy-strings/README.md new file mode 100644 index 0000000000..e3202e2dd0 --- /dev/null +++ b/core-groovy-strings/README.md @@ -0,0 +1,8 @@ +# Core Groovy Strings + +This module contains articles about core Groovy strings concepts + +## Relevant articles: + +- [Remove prefix in Groovy]() +- [[<-- Prev]](/core-groovy-strings) diff --git a/core-groovy-strings/pom.xml b/core-groovy-strings/pom.xml new file mode 100644 index 0000000000..059b53662c --- /dev/null +++ b/core-groovy-strings/pom.xml @@ -0,0 +1,72 @@ + + + com.baeldung + 4.0.0 + core-groovy-strings + 1.0-SNAPSHOT + core-groovy-strings + jar + + + + org.codehaus.groovy + groovy-all + ${groovy.version} + pom + + + org.junit.platform + junit-platform-runner + ${junit.platform.version} + test + + + + + src/main/groovy + src/main/java + + + org.codehaus.groovy + groovy-eclipse-compiler + ${groovy.compiler.version} + true + + + maven-compiler-plugin + ${compiler.plugin.version} + + groovy-eclipse-compiler + ${java.version} + ${java.version} + + + + org.codehaus.groovy + groovy-eclipse-compiler + ${groovy.compiler.version} + + + org.codehaus.groovy + groovy-eclipse-batch + ${groovy.version}-01 + + + + + + + + 1.0.0 + 1.1.3 + 2.5.7 + 2.20.1 + 3.8.0 + 3.3.0-01 + 1.8 + + + \ No newline at end of file diff --git a/core-groovy-strings/src/test/groovy/com/baeldung/removeprefix/RemovePrefixTest.groovy b/core-groovy-strings/src/test/groovy/com/baeldung/removeprefix/RemovePrefixTest.groovy new file mode 100644 index 0000000000..568e5fdde8 --- /dev/null +++ b/core-groovy-strings/src/test/groovy/com/baeldung/removeprefix/RemovePrefixTest.groovy @@ -0,0 +1,58 @@ +package com.baeldung.removeprefix + +import org.junit.Assert +import org.junit.Test + +class RemovePrefixTest { + + + @Test + public void givenWhenCasePrefixIsRemoved_thenReturnTrue() { + def trimPrefix = { + it.startsWith('Groovy') ? it.minus('Groovy') : it + } + + Assert.assertEquals(trimPrefix("GroovyTutorials at Baeldung"), "Tutorials at Baeldung") + } + + @Test + public void givenWhenPrefixIsRemoved_thenReturnTrue() { + + String prefix = "groovy-" + String trimPrefix = "Groovy-Tutorials at Baeldung" + def result; + if(trimPrefix.startsWithIgnoreCase(prefix)) { + result = trimPrefix.substring(prefix.length()) + } + + Assert.assertEquals("Tutorials at Baeldung", result) + } + + @Test + public void givenWhenPrefixIsRemovedUsingRegex_thenReturnTrue() { + + def regex = ~"^([Gg])roovy-" + String trimPrefix = "Groovy-Tutorials at Baeldung" + String result = trimPrefix - regex + + Assert.assertEquals("Tutorials at Baeldung", result) + } + + @Test public void givenWhenPrefixIsRemovedUsingReplaceFirst_thenReturnTrue() { + def regex = ~"^groovy" + String trimPrefix = "groovyTutorials at Baeldung's groovy page" + String result = trimPrefix.replaceFirst(regex, "") + + Assert.assertEquals("Tutorials at Baeldung's groovy page", result) + } + + @Test + public void givenWhenPrefixIsRemovedUsingReplaceAll_thenReturnTrue() { + + String trimPrefix = "groovyTutorials at Baeldung groovy" + String result = trimPrefix.replaceAll(/^groovy/, "") + + Assert.assertEquals("Tutorials at Baeldung groovy", result) + } + +} From c7b2ab3f46cabc6aedc7cf1b4d6c6ebb32ccfc9b Mon Sep 17 00:00:00 2001 From: akeshri Date: Sat, 29 Aug 2020 23:42:56 +0530 Subject: [PATCH 027/263] changes --- .../src/com/baeldung/article/HashMapExample.java | 0 .../src/com/baeldung/article/LinkedHashMapExample.java | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {MapFirstKeyExample => map-first-key-tutorial}/src/com/baeldung/article/HashMapExample.java (100%) rename {MapFirstKeyExample => map-first-key-tutorial}/src/com/baeldung/article/LinkedHashMapExample.java (100%) diff --git a/MapFirstKeyExample/src/com/baeldung/article/HashMapExample.java b/map-first-key-tutorial/src/com/baeldung/article/HashMapExample.java similarity index 100% rename from MapFirstKeyExample/src/com/baeldung/article/HashMapExample.java rename to map-first-key-tutorial/src/com/baeldung/article/HashMapExample.java diff --git a/MapFirstKeyExample/src/com/baeldung/article/LinkedHashMapExample.java b/map-first-key-tutorial/src/com/baeldung/article/LinkedHashMapExample.java similarity index 100% rename from MapFirstKeyExample/src/com/baeldung/article/LinkedHashMapExample.java rename to map-first-key-tutorial/src/com/baeldung/article/LinkedHashMapExample.java From 976862de1a42f9886e66abffd8764b501635bf3b Mon Sep 17 00:00:00 2001 From: akeshri Date: Sat, 29 Aug 2020 23:48:29 +0530 Subject: [PATCH 028/263] changes --- map-first-key-tutorial/README.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 map-first-key-tutorial/README.md diff --git a/map-first-key-tutorial/README.md b/map-first-key-tutorial/README.md new file mode 100644 index 0000000000..13fb71643b --- /dev/null +++ b/map-first-key-tutorial/README.md @@ -0,0 +1,4 @@ +# HashMap - Getting First Key And Value +A example on how to get first key and value from HashMap. + +- JDK 1.8 and above \ No newline at end of file From 531751568cacd590d923b17d1b41940872c46da9 Mon Sep 17 00:00:00 2001 From: Anirban Chatterjee Date: Sun, 30 Aug 2020 13:23:51 +0200 Subject: [PATCH 029/263] Moved to new module --- .../core-kotlin-collections-2/README.md | 7 +++ .../core-kotlin-collections-2/pom.xml | 47 +++++++++++++++++++ .../AggregateOperations.kt | 2 +- .../AggregateOperationsUnitTest.kt | 2 +- core-kotlin-modules/pom.xml | 1 + 5 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 core-kotlin-modules/core-kotlin-collections-2/README.md create mode 100644 core-kotlin-modules/core-kotlin-collections-2/pom.xml rename core-kotlin-modules/{core-kotlin-collections/src/main/kotlin/com/baeldung/kotlin/collections => core-kotlin-collections-2/src/main/kotlin/com.baeldung.aggregate}/AggregateOperations.kt (98%) rename core-kotlin-modules/{core-kotlin-collections/src/test/kotlin/com/baeldung/kotlin/collections => core-kotlin-collections-2/src/test/kotlin/com.baeldung.aggregate}/AggregateOperationsUnitTest.kt (98%) diff --git a/core-kotlin-modules/core-kotlin-collections-2/README.md b/core-kotlin-modules/core-kotlin-collections-2/README.md new file mode 100644 index 0000000000..2dc180b5b3 --- /dev/null +++ b/core-kotlin-modules/core-kotlin-collections-2/README.md @@ -0,0 +1,7 @@ +## Core Kotlin Collections + +This module contains articles about core Kotlin collections. + +### Relevant articles: + + diff --git a/core-kotlin-modules/core-kotlin-collections-2/pom.xml b/core-kotlin-modules/core-kotlin-collections-2/pom.xml new file mode 100644 index 0000000000..be462eed45 --- /dev/null +++ b/core-kotlin-modules/core-kotlin-collections-2/pom.xml @@ -0,0 +1,47 @@ + + + 4.0.0 + core-kotlin-collections-2 + core-kotlin-collections-2 + jar + + + com.baeldung.core-kotlin-modules + core-kotlin-modules + 1.0.0-SNAPSHOT + + + + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + ${kotlin.version} + + + org.apache.commons + commons-math3 + ${commons-math3.version} + + + org.assertj + assertj-core + ${assertj.version} + test + + + org.jetbrains.kotlin + kotlin-test + ${kotlin.version} + test + + + + + 1.3.30 + 3.6.1 + 3.10.0 + + + \ No newline at end of file diff --git a/core-kotlin-modules/core-kotlin-collections/src/main/kotlin/com/baeldung/kotlin/collections/AggregateOperations.kt b/core-kotlin-modules/core-kotlin-collections-2/src/main/kotlin/com.baeldung.aggregate/AggregateOperations.kt similarity index 98% rename from core-kotlin-modules/core-kotlin-collections/src/main/kotlin/com/baeldung/kotlin/collections/AggregateOperations.kt rename to core-kotlin-modules/core-kotlin-collections-2/src/main/kotlin/com.baeldung.aggregate/AggregateOperations.kt index 3a348aafaa..a09e101b59 100644 --- a/core-kotlin-modules/core-kotlin-collections/src/main/kotlin/com/baeldung/kotlin/collections/AggregateOperations.kt +++ b/core-kotlin-modules/core-kotlin-collections-2/src/main/kotlin/com.baeldung.aggregate/AggregateOperations.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin.collections +package com.baeldung.aggregate class AggregateOperations { private val numbers = listOf(1, 15, 3, 8) diff --git a/core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/kotlin/collections/AggregateOperationsUnitTest.kt b/core-kotlin-modules/core-kotlin-collections-2/src/test/kotlin/com.baeldung.aggregate/AggregateOperationsUnitTest.kt similarity index 98% rename from core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/kotlin/collections/AggregateOperationsUnitTest.kt rename to core-kotlin-modules/core-kotlin-collections-2/src/test/kotlin/com.baeldung.aggregate/AggregateOperationsUnitTest.kt index 1fb26760fc..a619759b0a 100644 --- a/core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/kotlin/collections/AggregateOperationsUnitTest.kt +++ b/core-kotlin-modules/core-kotlin-collections-2/src/test/kotlin/com.baeldung.aggregate/AggregateOperationsUnitTest.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin.collections +package com.baeldung.aggregate import org.junit.jupiter.api.Test import kotlin.test.assertEquals diff --git a/core-kotlin-modules/pom.xml b/core-kotlin-modules/pom.xml index 8b626e1c1b..67520a7dee 100644 --- a/core-kotlin-modules/pom.xml +++ b/core-kotlin-modules/pom.xml @@ -21,6 +21,7 @@ core-kotlin-advanced core-kotlin-annotations core-kotlin-collections + core-kotlin-collections-2 core-kotlin-concurrency core-kotlin-date-time core-kotlin-design-patterns From d8d2ecc4b4962ec9811bede5c6689bb6480542a2 Mon Sep 17 00:00:00 2001 From: Meysam Tamkin Date: Sun, 30 Aug 2020 19:59:24 +0430 Subject: [PATCH 030/263] Add some changes --- .../BeforeAfterAllNonStaticTest.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 testing-modules/junit-5/src/main/java/com/baeldung/junit5/nonstatic/BeforeAfterAllNonStaticTest.java diff --git a/testing-modules/junit-5/src/main/java/com/baeldung/junit5/nonstatic/BeforeAfterAllNonStaticTest.java b/testing-modules/junit-5/src/main/java/com/baeldung/junit5/nonstatic/BeforeAfterAllNonStaticTest.java new file mode 100644 index 0000000000..8dbe95ddf8 --- /dev/null +++ b/testing-modules/junit-5/src/main/java/com/baeldung/junit5/nonstatic/BeforeAfterAllNonStaticTest.java @@ -0,0 +1,25 @@ +package com.baeldung.junit5.nonstatic; + +import org.junit.jupiter.api.*; + +@TestInstance(TestInstance.Lifecycle.PER_CLASS) +public class BeforeAfterAllNonStaticTest { + + String input; + Long result; + + @BeforeAll + public void setup() { + input = "77"; + } + + @AfterAll + public void teardown() { + Assertions.assertEquals(77l, result); + } + + @Test + public void testConvertStringToLong() { + result = Long.valueOf(input); + } +} From e0ebf5904faccb404a7e3bc6d8b4eb614b3dc880 Mon Sep 17 00:00:00 2001 From: Sampada <46674082+sampada07@users.noreply.github.com> Date: Mon, 31 Aug 2020 20:41:47 +0530 Subject: [PATCH 031/263] JAVA-84: Move articles out of spring-boot part 1 (#9950) * JAVA-84: Moved 1 article to spring-boot-actuator * JAVA-84: Moved 2 articles to spring-boot-mvc * JAVA-84: README changes for spring-boot module * JAVA-84: Moved classes to com.baeldung pkg to correct compilation issue --- .../{README.MD => README.md} | 1 + .../spring-boot-actuator/pom.xml | 8 ++ .../baeldung/endpoints/info/Application.java | 13 ++++ .../info/TotalUsersInfoContributor.java | 1 - .../com/baeldung/endpoints/info/User.java | 49 ++++++++++++ .../endpoints/info/UserRepository.java | 78 +++++++++++++++++++ .../src/main/resources/application.properties | 8 +- spring-boot-modules/spring-boot-mvc/README.md | 2 + .../SpringBootAnnotatedApp.java | 0 .../SpringBootPlainApp.java | 0 .../components/AttrListener.java | 0 .../components/EchoServlet.java | 0 .../components/HelloFilter.java | 0 .../components/HelloServlet.java | 0 .../InternationalizationApp.java | 0 .../config/MvcConfig.java | 0 .../config/PageController.java | 2 +- .../src/main/resources/messages.properties | 6 +- .../src/main/resources/messages_fr.properties | 6 +- .../resources/static/internationalization.js | 0 .../templates/thymeleaf}/international.html | 0 .../baeldung/SpringContextLiveTest.java | 0 .../baeldung/SpringContextTest.java | 0 ...otWithServletComponentIntegrationTest.java | 26 +++---- ...ithoutServletComponentIntegrationTest.java | 0 spring-boot-modules/spring-boot/README.md | 3 - .../src/main/resources/application.properties | 6 -- .../src/main/resources/messages.properties | 4 - .../src/main/resources/messages_fr.properties | 4 - 29 files changed, 181 insertions(+), 36 deletions(-) rename spring-boot-modules/spring-boot-actuator/{README.MD => README.md} (72%) create mode 100644 spring-boot-modules/spring-boot-actuator/src/main/java/com/baeldung/endpoints/info/Application.java rename spring-boot-modules/{spring-boot => spring-boot-actuator}/src/main/java/com/baeldung/endpoints/info/TotalUsersInfoContributor.java (94%) create mode 100644 spring-boot-modules/spring-boot-actuator/src/main/java/com/baeldung/endpoints/info/User.java create mode 100644 spring-boot-modules/spring-boot-actuator/src/main/java/com/baeldung/endpoints/info/UserRepository.java rename spring-boot-modules/{spring-boot => spring-boot-mvc}/src/main/java/com/baeldung/annotation/servletcomponentscan/SpringBootAnnotatedApp.java (100%) rename spring-boot-modules/{spring-boot => spring-boot-mvc}/src/main/java/com/baeldung/annotation/servletcomponentscan/SpringBootPlainApp.java (100%) rename spring-boot-modules/{spring-boot => spring-boot-mvc}/src/main/java/com/baeldung/annotation/servletcomponentscan/components/AttrListener.java (100%) rename spring-boot-modules/{spring-boot => spring-boot-mvc}/src/main/java/com/baeldung/annotation/servletcomponentscan/components/EchoServlet.java (100%) rename spring-boot-modules/{spring-boot => spring-boot-mvc}/src/main/java/com/baeldung/annotation/servletcomponentscan/components/HelloFilter.java (100%) rename spring-boot-modules/{spring-boot => spring-boot-mvc}/src/main/java/com/baeldung/annotation/servletcomponentscan/components/HelloServlet.java (100%) rename spring-boot-modules/{spring-boot => spring-boot-mvc}/src/main/java/com/baeldung/internationalization/InternationalizationApp.java (100%) rename spring-boot-modules/{spring-boot => spring-boot-mvc}/src/main/java/com/baeldung/internationalization/config/MvcConfig.java (100%) rename spring-boot-modules/{spring-boot => spring-boot-mvc}/src/main/java/com/baeldung/internationalization/config/PageController.java (87%) rename spring-boot-modules/{spring-boot => spring-boot-mvc}/src/main/resources/static/internationalization.js (100%) rename spring-boot-modules/{spring-boot/src/main/resources/templates => spring-boot-mvc/src/main/resources/templates/thymeleaf}/international.html (100%) rename spring-boot-modules/spring-boot-mvc/src/test/java/{org => com}/baeldung/SpringContextLiveTest.java (100%) rename spring-boot-modules/spring-boot-mvc/src/test/java/{org => com}/baeldung/SpringContextTest.java (100%) rename spring-boot-modules/{spring-boot => spring-boot-mvc}/src/test/java/com/baeldung/annotation/servletcomponentscan/SpringBootWithServletComponentIntegrationTest.java (94%) rename spring-boot-modules/{spring-boot => spring-boot-mvc}/src/test/java/com/baeldung/annotation/servletcomponentscan/SpringBootWithoutServletComponentIntegrationTest.java (100%) delete mode 100644 spring-boot-modules/spring-boot/src/main/resources/messages.properties delete mode 100644 spring-boot-modules/spring-boot/src/main/resources/messages_fr.properties diff --git a/spring-boot-modules/spring-boot-actuator/README.MD b/spring-boot-modules/spring-boot-actuator/README.md similarity index 72% rename from spring-boot-modules/spring-boot-actuator/README.MD rename to spring-boot-modules/spring-boot-actuator/README.md index fbb4dfba0f..6f31ee4a5e 100644 --- a/spring-boot-modules/spring-boot-actuator/README.MD +++ b/spring-boot-modules/spring-boot-actuator/README.md @@ -8,3 +8,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles: - [Liveness and Readiness Probes in Spring Boot](https://www.baeldung.com/spring-liveness-readiness-probes) +- [Custom Information in Spring Boot Info Endpoint](https://www.baeldung.com/spring-boot-info-actuator-custom) diff --git a/spring-boot-modules/spring-boot-actuator/pom.xml b/spring-boot-modules/spring-boot-actuator/pom.xml index 701949519e..18da6d3a9a 100644 --- a/spring-boot-modules/spring-boot-actuator/pom.xml +++ b/spring-boot-modules/spring-boot-actuator/pom.xml @@ -24,6 +24,14 @@ org.springframework.boot spring-boot-starter-web
+ + org.springframework.boot + spring-boot-starter-data-jpa + + + com.h2database + h2 + org.springframework.boot diff --git a/spring-boot-modules/spring-boot-actuator/src/main/java/com/baeldung/endpoints/info/Application.java b/spring-boot-modules/spring-boot-actuator/src/main/java/com/baeldung/endpoints/info/Application.java new file mode 100644 index 0000000000..75a7182b3c --- /dev/null +++ b/spring-boot-modules/spring-boot-actuator/src/main/java/com/baeldung/endpoints/info/Application.java @@ -0,0 +1,13 @@ +package com.baeldung.endpoints.info; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + +} diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/endpoints/info/TotalUsersInfoContributor.java b/spring-boot-modules/spring-boot-actuator/src/main/java/com/baeldung/endpoints/info/TotalUsersInfoContributor.java similarity index 94% rename from spring-boot-modules/spring-boot/src/main/java/com/baeldung/endpoints/info/TotalUsersInfoContributor.java rename to spring-boot-modules/spring-boot-actuator/src/main/java/com/baeldung/endpoints/info/TotalUsersInfoContributor.java index c316cabda5..a685660b4f 100644 --- a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/endpoints/info/TotalUsersInfoContributor.java +++ b/spring-boot-modules/spring-boot-actuator/src/main/java/com/baeldung/endpoints/info/TotalUsersInfoContributor.java @@ -3,7 +3,6 @@ package com.baeldung.endpoints.info; import java.util.HashMap; import java.util.Map; -import com.baeldung.repository.UserRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.actuate.info.Info; import org.springframework.boot.actuate.info.InfoContributor; diff --git a/spring-boot-modules/spring-boot-actuator/src/main/java/com/baeldung/endpoints/info/User.java b/spring-boot-modules/spring-boot-actuator/src/main/java/com/baeldung/endpoints/info/User.java new file mode 100644 index 0000000000..db4e69127a --- /dev/null +++ b/spring-boot-modules/spring-boot-actuator/src/main/java/com/baeldung/endpoints/info/User.java @@ -0,0 +1,49 @@ +package com.baeldung.endpoints.info; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; + +@Entity +@Table(name = "users") +public class User { + + @Id + @GeneratedValue + private Integer id; + private String name; + private Integer status; + + public User() { + } + + public User(String name, Integer status) { + this.name = name; + this.status = status; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } +} diff --git a/spring-boot-modules/spring-boot-actuator/src/main/java/com/baeldung/endpoints/info/UserRepository.java b/spring-boot-modules/spring-boot-actuator/src/main/java/com/baeldung/endpoints/info/UserRepository.java new file mode 100644 index 0000000000..8af5ef3988 --- /dev/null +++ b/spring-boot-modules/spring-boot-actuator/src/main/java/com/baeldung/endpoints/info/UserRepository.java @@ -0,0 +1,78 @@ +package com.baeldung.endpoints.info; + +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 org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Repository; + +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + +@Repository("userRepository") +public interface UserRepository extends JpaRepository { + + int countByStatus(int status); + + Optional findOneByName(String name); + + @Async + CompletableFuture findOneByStatus(Integer status); + + @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 \n-- #pageable\n", 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); + +} diff --git a/spring-boot-modules/spring-boot-actuator/src/main/resources/application.properties b/spring-boot-modules/spring-boot-actuator/src/main/resources/application.properties index 27dba985b8..00100d6d97 100644 --- a/spring-boot-modules/spring-boot-actuator/src/main/resources/application.properties +++ b/spring-boot-modules/spring-boot-actuator/src/main/resources/application.properties @@ -2,4 +2,10 @@ management.health.probes.enabled=true management.endpoint.health.show-details=always management.endpoint.health.status.http-mapping.down=500 management.endpoint.health.status.http-mapping.out_of_service=503 -management.endpoint.health.status.http-mapping.warning=500 \ No newline at end of file +management.endpoint.health.status.http-mapping.warning=500 + +## Configuring info endpoint +info.app.name=Spring Sample Application +info.app.description=This is my first spring boot application G1 +info.app.version=1.0.0 +info.java-vendor = ${java.specification.vendor} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-mvc/README.md b/spring-boot-modules/spring-boot-mvc/README.md index 41b98063a6..5e9ecded10 100644 --- a/spring-boot-modules/spring-boot-mvc/README.md +++ b/spring-boot-modules/spring-boot-mvc/README.md @@ -9,4 +9,6 @@ This module contains articles about Spring Web MVC in Spring Boot projects. - [A Controller, Service and DAO Example with Spring Boot and JSF](https://www.baeldung.com/jsf-spring-boot-controller-service-dao) - [Setting Up Swagger 2 with a Spring REST API](https://www.baeldung.com/swagger-2-documentation-for-spring-rest-api) - [Using Spring ResponseEntity to Manipulate the HTTP Response](https://www.baeldung.com/spring-response-entity) +- [The @ServletComponentScan Annotation in Spring Boot](https://www.baeldung.com/spring-servletcomponentscan) +- [Guide to Internationalization in Spring Boot](https://www.baeldung.com/spring-boot-internationalization) - More articles: [[next -->]](/spring-boot-modules/spring-boot-mvc-2) diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/SpringBootAnnotatedApp.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotation/servletcomponentscan/SpringBootAnnotatedApp.java similarity index 100% rename from spring-boot-modules/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/SpringBootAnnotatedApp.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotation/servletcomponentscan/SpringBootAnnotatedApp.java diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/SpringBootPlainApp.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotation/servletcomponentscan/SpringBootPlainApp.java similarity index 100% rename from spring-boot-modules/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/SpringBootPlainApp.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotation/servletcomponentscan/SpringBootPlainApp.java diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/components/AttrListener.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotation/servletcomponentscan/components/AttrListener.java similarity index 100% rename from spring-boot-modules/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/components/AttrListener.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotation/servletcomponentscan/components/AttrListener.java diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/components/EchoServlet.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotation/servletcomponentscan/components/EchoServlet.java similarity index 100% rename from spring-boot-modules/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/components/EchoServlet.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotation/servletcomponentscan/components/EchoServlet.java diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/components/HelloFilter.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotation/servletcomponentscan/components/HelloFilter.java similarity index 100% rename from spring-boot-modules/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/components/HelloFilter.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotation/servletcomponentscan/components/HelloFilter.java diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/components/HelloServlet.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotation/servletcomponentscan/components/HelloServlet.java similarity index 100% rename from spring-boot-modules/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/components/HelloServlet.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotation/servletcomponentscan/components/HelloServlet.java diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/internationalization/InternationalizationApp.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/internationalization/InternationalizationApp.java similarity index 100% rename from spring-boot-modules/spring-boot/src/main/java/com/baeldung/internationalization/InternationalizationApp.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/internationalization/InternationalizationApp.java diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/internationalization/config/MvcConfig.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/internationalization/config/MvcConfig.java similarity index 100% rename from spring-boot-modules/spring-boot/src/main/java/com/baeldung/internationalization/config/MvcConfig.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/internationalization/config/MvcConfig.java diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/internationalization/config/PageController.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/internationalization/config/PageController.java similarity index 87% rename from spring-boot-modules/spring-boot/src/main/java/com/baeldung/internationalization/config/PageController.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/internationalization/config/PageController.java index 96a534b853..efa55b8b33 100644 --- a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/internationalization/config/PageController.java +++ b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/internationalization/config/PageController.java @@ -8,7 +8,7 @@ public class PageController { @GetMapping("/international") public String getInternationalPage() { - return "international"; + return "thymeleaf/international"; } } diff --git a/spring-boot-modules/spring-boot-mvc/src/main/resources/messages.properties b/spring-boot-modules/spring-boot-mvc/src/main/resources/messages.properties index 9794c89651..8f956fe5be 100644 --- a/spring-boot-modules/spring-boot-mvc/src/main/resources/messages.properties +++ b/spring-boot-modules/spring-boot-mvc/src/main/resources/messages.properties @@ -1 +1,5 @@ -email.notempty=Please provide valid email id. \ No newline at end of file +email.notempty=Please provide valid email id. +greeting=Hello! Welcome to our website! +lang.change=Change the language +lang.eng=English +lang.fr=French \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-mvc/src/main/resources/messages_fr.properties b/spring-boot-modules/spring-boot-mvc/src/main/resources/messages_fr.properties index 070f4e0bfc..7ced0d7b0d 100644 --- a/spring-boot-modules/spring-boot-mvc/src/main/resources/messages_fr.properties +++ b/spring-boot-modules/spring-boot-mvc/src/main/resources/messages_fr.properties @@ -1 +1,5 @@ -email.notempty=Veuillez fournir un identifiant de messagerie valide. \ No newline at end of file +email.notempty=Veuillez fournir un identifiant de messagerie valide. +greeting=Bonjour! Bienvenue sur notre site! +lang.change=Changez la langue +lang.eng=Anglais +lang.fr=Francais diff --git a/spring-boot-modules/spring-boot/src/main/resources/static/internationalization.js b/spring-boot-modules/spring-boot-mvc/src/main/resources/static/internationalization.js similarity index 100% rename from spring-boot-modules/spring-boot/src/main/resources/static/internationalization.js rename to spring-boot-modules/spring-boot-mvc/src/main/resources/static/internationalization.js diff --git a/spring-boot-modules/spring-boot/src/main/resources/templates/international.html b/spring-boot-modules/spring-boot-mvc/src/main/resources/templates/thymeleaf/international.html similarity index 100% rename from spring-boot-modules/spring-boot/src/main/resources/templates/international.html rename to spring-boot-modules/spring-boot-mvc/src/main/resources/templates/thymeleaf/international.html diff --git a/spring-boot-modules/spring-boot-mvc/src/test/java/org/baeldung/SpringContextLiveTest.java b/spring-boot-modules/spring-boot-mvc/src/test/java/com/baeldung/SpringContextLiveTest.java similarity index 100% rename from spring-boot-modules/spring-boot-mvc/src/test/java/org/baeldung/SpringContextLiveTest.java rename to spring-boot-modules/spring-boot-mvc/src/test/java/com/baeldung/SpringContextLiveTest.java diff --git a/spring-boot-modules/spring-boot-mvc/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-mvc/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-boot-modules/spring-boot-mvc/src/test/java/org/baeldung/SpringContextTest.java rename to spring-boot-modules/spring-boot-mvc/src/test/java/com/baeldung/SpringContextTest.java diff --git a/spring-boot-modules/spring-boot/src/test/java/com/baeldung/annotation/servletcomponentscan/SpringBootWithServletComponentIntegrationTest.java b/spring-boot-modules/spring-boot-mvc/src/test/java/com/baeldung/annotation/servletcomponentscan/SpringBootWithServletComponentIntegrationTest.java similarity index 94% rename from spring-boot-modules/spring-boot/src/test/java/com/baeldung/annotation/servletcomponentscan/SpringBootWithServletComponentIntegrationTest.java rename to spring-boot-modules/spring-boot-mvc/src/test/java/com/baeldung/annotation/servletcomponentscan/SpringBootWithServletComponentIntegrationTest.java index 8c85934fac..92223892d9 100644 --- a/spring-boot-modules/spring-boot/src/test/java/com/baeldung/annotation/servletcomponentscan/SpringBootWithServletComponentIntegrationTest.java +++ b/spring-boot-modules/spring-boot-mvc/src/test/java/com/baeldung/annotation/servletcomponentscan/SpringBootWithServletComponentIntegrationTest.java @@ -1,23 +1,21 @@ package com.baeldung.annotation.servletcomponentscan; -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.boot.test.web.client.TestRestTemplate; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; - -import javax.servlet.FilterRegistration; -import javax.servlet.ServletContext; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +import javax.servlet.FilterRegistration; +import javax.servlet.ServletContext; + +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.boot.test.web.client.TestRestTemplate; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.junit4.SpringRunner; + @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = SpringBootAnnotatedApp.class) public class SpringBootWithServletComponentIntegrationTest { diff --git a/spring-boot-modules/spring-boot/src/test/java/com/baeldung/annotation/servletcomponentscan/SpringBootWithoutServletComponentIntegrationTest.java b/spring-boot-modules/spring-boot-mvc/src/test/java/com/baeldung/annotation/servletcomponentscan/SpringBootWithoutServletComponentIntegrationTest.java similarity index 100% rename from spring-boot-modules/spring-boot/src/test/java/com/baeldung/annotation/servletcomponentscan/SpringBootWithoutServletComponentIntegrationTest.java rename to spring-boot-modules/spring-boot-mvc/src/test/java/com/baeldung/annotation/servletcomponentscan/SpringBootWithoutServletComponentIntegrationTest.java diff --git a/spring-boot-modules/spring-boot/README.md b/spring-boot-modules/spring-boot/README.md index 510864e339..5a45502fd8 100644 --- a/spring-boot-modules/spring-boot/README.md +++ b/spring-boot-modules/spring-boot/README.md @@ -8,12 +8,9 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles: - [A Guide to Spring in Eclipse STS](https://www.baeldung.com/eclipse-sts-spring) -- [The @ServletComponentScan Annotation in Spring Boot](https://www.baeldung.com/spring-servletcomponentscan) - [How to Register a Servlet in Java](https://www.baeldung.com/register-servlet) - [Guide to Spring WebUtils and ServletRequestUtils](https://www.baeldung.com/spring-webutils-servletrequestutils) -- [Guide to Internationalization in Spring Boot](https://www.baeldung.com/spring-boot-internationalization) - [Dynamic DTO Validation Config Retrieved from the Database](https://www.baeldung.com/spring-dynamic-dto-validation) -- [Custom Information in Spring Boot Info Endpoint](https://www.baeldung.com/spring-boot-info-actuator-custom) - [Guide to Spring Type Conversions](https://www.baeldung.com/spring-type-conversions) - [Spring Boot: Configuring a Main Class](https://www.baeldung.com/spring-boot-main-class) - [A Quick Intro to the SpringBootServletInitializer](https://www.baeldung.com/spring-boot-servlet-initializer) diff --git a/spring-boot-modules/spring-boot/src/main/resources/application.properties b/spring-boot-modules/spring-boot/src/main/resources/application.properties index 44649fc1c0..142e6c8e6f 100644 --- a/spring-boot-modules/spring-boot/src/main/resources/application.properties +++ b/spring-boot-modules/spring-boot/src/main/resources/application.properties @@ -21,12 +21,6 @@ spring.jmx.enabled=true ## for pretty printing of json when endpoints accessed over HTTP http.mappers.jsonPrettyPrint=true -## Configuring info endpoint -info.app.name=Spring Sample Application -info.app.description=This is my first spring boot application G1 -info.app.version=1.0.0 -info.java-vendor = ${java.specification.vendor} - logging.level.org.springframework=INFO #Servlet Configuration diff --git a/spring-boot-modules/spring-boot/src/main/resources/messages.properties b/spring-boot-modules/spring-boot/src/main/resources/messages.properties deleted file mode 100644 index e4dbc44c3f..0000000000 --- a/spring-boot-modules/spring-boot/src/main/resources/messages.properties +++ /dev/null @@ -1,4 +0,0 @@ -greeting=Hello! Welcome to our website! -lang.change=Change the language -lang.eng=English -lang.fr=French \ No newline at end of file diff --git a/spring-boot-modules/spring-boot/src/main/resources/messages_fr.properties b/spring-boot-modules/spring-boot/src/main/resources/messages_fr.properties deleted file mode 100644 index ac5853717d..0000000000 --- a/spring-boot-modules/spring-boot/src/main/resources/messages_fr.properties +++ /dev/null @@ -1,4 +0,0 @@ -greeting=Bonjour! Bienvenue sur notre site! -lang.change=Changez la langue -lang.eng=Anglais -lang.fr=Francais \ No newline at end of file From 25b174930886c60d9b7e9b6a0003b1be4d906aed Mon Sep 17 00:00:00 2001 From: Mona Mohamadinia Date: Mon, 31 Aug 2020 20:13:13 +0430 Subject: [PATCH 032/263] BAEL-4530: A Guide to @DynamicPropertySource in Spring (#9877) * A Guide to @DynamicPropertySource in Spring * Moving to a new module * Reverting the Changes in the original module --- testing-modules/pom.xml | 3 +- testing-modules/spring-testing-2/.gitignore | 3 + testing-modules/spring-testing-2/README.md | 1 + testing-modules/spring-testing-2/pom.xml | 57 +++++++++++++++++++ .../baeldung/dynamicproperties/Article.java | 45 +++++++++++++++ .../dynamicproperties/ArticleRepository.java | 6 ++ .../DynamicPropertiesApplication.java | 12 ++++ .../dynamicproperties/ArticleLiveTest.java | 50 ++++++++++++++++ .../ArticleTestFixtureLiveTest.java | 31 ++++++++++ .../ArticleTraditionalLiveTest.java | 57 +++++++++++++++++++ .../PostgreSQLExtension.java | 31 ++++++++++ .../test/resources/application-pg.properties | 2 + 12 files changed, 297 insertions(+), 1 deletion(-) create mode 100644 testing-modules/spring-testing-2/.gitignore create mode 100644 testing-modules/spring-testing-2/README.md create mode 100644 testing-modules/spring-testing-2/pom.xml create mode 100644 testing-modules/spring-testing-2/src/main/java/com/baeldung/dynamicproperties/Article.java create mode 100644 testing-modules/spring-testing-2/src/main/java/com/baeldung/dynamicproperties/ArticleRepository.java create mode 100644 testing-modules/spring-testing-2/src/main/java/com/baeldung/dynamicproperties/DynamicPropertiesApplication.java create mode 100644 testing-modules/spring-testing-2/src/test/java/com/baeldung/dynamicproperties/ArticleLiveTest.java create mode 100644 testing-modules/spring-testing-2/src/test/java/com/baeldung/dynamicproperties/ArticleTestFixtureLiveTest.java create mode 100644 testing-modules/spring-testing-2/src/test/java/com/baeldung/dynamicproperties/ArticleTraditionalLiveTest.java create mode 100644 testing-modules/spring-testing-2/src/test/java/com/baeldung/dynamicproperties/PostgreSQLExtension.java create mode 100644 testing-modules/spring-testing-2/src/test/resources/application-pg.properties diff --git a/testing-modules/pom.xml b/testing-modules/pom.xml index b467b3c503..f1d30cd7a1 100644 --- a/testing-modules/pom.xml +++ b/testing-modules/pom.xml @@ -31,7 +31,8 @@ rest-assured rest-testing selenium-junit-testng - spring-testing + spring-testing + spring-testing-2 test-containers testing-assertions testng diff --git a/testing-modules/spring-testing-2/.gitignore b/testing-modules/spring-testing-2/.gitignore new file mode 100644 index 0000000000..ffc5bf3bad --- /dev/null +++ b/testing-modules/spring-testing-2/.gitignore @@ -0,0 +1,3 @@ +.idea/** +target/** +*.iml \ No newline at end of file diff --git a/testing-modules/spring-testing-2/README.md b/testing-modules/spring-testing-2/README.md new file mode 100644 index 0000000000..729105e3fd --- /dev/null +++ b/testing-modules/spring-testing-2/README.md @@ -0,0 +1 @@ +## Relevant Articles: diff --git a/testing-modules/spring-testing-2/pom.xml b/testing-modules/spring-testing-2/pom.xml new file mode 100644 index 0000000000..c7ca2804fb --- /dev/null +++ b/testing-modules/spring-testing-2/pom.xml @@ -0,0 +1,57 @@ + + + + 4.0.0 + spring-testing-2 + 0.1-SNAPSHOT + spring-testing-2 + + + com.baeldung + parent-boot-2 + 0.0.1-SNAPSHOT + ../../parent-boot-2 + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + + org.postgresql + postgresql + runtime + + + + + org.testcontainers + postgresql + ${testcontainers.version} + test + + + org.testcontainers + junit-jupiter + ${testcontainers.version} + test + + + + + + 2.1.9.RELEASE + 2.1.9.RELEASE + 1.12.2 + + \ No newline at end of file diff --git a/testing-modules/spring-testing-2/src/main/java/com/baeldung/dynamicproperties/Article.java b/testing-modules/spring-testing-2/src/main/java/com/baeldung/dynamicproperties/Article.java new file mode 100644 index 0000000000..6b6bfb7bd6 --- /dev/null +++ b/testing-modules/spring-testing-2/src/main/java/com/baeldung/dynamicproperties/Article.java @@ -0,0 +1,45 @@ +package com.baeldung.dynamicproperties; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; + +import static javax.persistence.GenerationType.IDENTITY; + +@Entity +@Table(name = "articles") +public class Article { + + @Id + @GeneratedValue(strategy = IDENTITY) + private Long id; + + private String title; + + private String content; + + 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 String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } +} diff --git a/testing-modules/spring-testing-2/src/main/java/com/baeldung/dynamicproperties/ArticleRepository.java b/testing-modules/spring-testing-2/src/main/java/com/baeldung/dynamicproperties/ArticleRepository.java new file mode 100644 index 0000000000..3f3731f6dc --- /dev/null +++ b/testing-modules/spring-testing-2/src/main/java/com/baeldung/dynamicproperties/ArticleRepository.java @@ -0,0 +1,6 @@ +package com.baeldung.dynamicproperties; + +import org.springframework.data.jpa.repository.JpaRepository; + +public interface ArticleRepository extends JpaRepository { +} diff --git a/testing-modules/spring-testing-2/src/main/java/com/baeldung/dynamicproperties/DynamicPropertiesApplication.java b/testing-modules/spring-testing-2/src/main/java/com/baeldung/dynamicproperties/DynamicPropertiesApplication.java new file mode 100644 index 0000000000..d64bd965fc --- /dev/null +++ b/testing-modules/spring-testing-2/src/main/java/com/baeldung/dynamicproperties/DynamicPropertiesApplication.java @@ -0,0 +1,12 @@ +package com.baeldung.dynamicproperties; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class DynamicPropertiesApplication { + + public static void main(String[] args) { + SpringApplication.run(DynamicPropertiesApplication.class, args); + } +} diff --git a/testing-modules/spring-testing-2/src/test/java/com/baeldung/dynamicproperties/ArticleLiveTest.java b/testing-modules/spring-testing-2/src/test/java/com/baeldung/dynamicproperties/ArticleLiveTest.java new file mode 100644 index 0000000000..74c31229bd --- /dev/null +++ b/testing-modules/spring-testing-2/src/test/java/com/baeldung/dynamicproperties/ArticleLiveTest.java @@ -0,0 +1,50 @@ +package com.baeldung.dynamicproperties; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.DynamicPropertyRegistry; +import org.springframework.test.context.DynamicPropertySource; +import org.testcontainers.containers.PostgreSQLContainer; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; + +import static org.assertj.core.api.Assertions.assertThat; + +@SpringBootTest +@Testcontainers +@ActiveProfiles("pg") +public class ArticleLiveTest { + + @Container + static PostgreSQLContainer postgres = new PostgreSQLContainer<>("postgres:11") + .withDatabaseName("prop") + .withUsername("postgres") + .withPassword("pass") + .withExposedPorts(5432); + + @Autowired + private ArticleRepository articleRepository; + + @DynamicPropertySource + static void registerPgProperties(DynamicPropertyRegistry registry) { + registry.add("spring.datasource.url", + () -> String.format("jdbc:postgresql://localhost:%d/prop", postgres.getFirstMappedPort())); + registry.add("spring.datasource.username", () -> "postgres"); + registry.add("spring.datasource.password", () -> "pass"); + } + + @Test + void givenAnArticle_whenPersisted_thenCanBeFoundInTheDb() { + Article article = new Article(); + article.setTitle("A Guide to @DynamicPropertySource in Spring"); + article.setContent("Today's applications..."); + + articleRepository.save(article); + Article persisted = articleRepository.findAll().get(0); + assertThat(persisted.getId()).isNotNull(); + assertThat(persisted.getTitle()).isEqualTo("A Guide to @DynamicPropertySource in Spring"); + assertThat(persisted.getContent()).isEqualTo("Today's applications..."); + } +} diff --git a/testing-modules/spring-testing-2/src/test/java/com/baeldung/dynamicproperties/ArticleTestFixtureLiveTest.java b/testing-modules/spring-testing-2/src/test/java/com/baeldung/dynamicproperties/ArticleTestFixtureLiveTest.java new file mode 100644 index 0000000000..bb3ad28365 --- /dev/null +++ b/testing-modules/spring-testing-2/src/test/java/com/baeldung/dynamicproperties/ArticleTestFixtureLiveTest.java @@ -0,0 +1,31 @@ +package com.baeldung.dynamicproperties; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; + +import static org.assertj.core.api.Assertions.assertThat; + +@SpringBootTest +@ActiveProfiles("pg") +@ExtendWith(PostgreSQLExtension.class) +public class ArticleTestFixtureLiveTest { + + @Autowired + private ArticleRepository articleRepository; + + @Test + void givenAnArticle_whenPersisted_thenShouldBeAbleToReadIt() { + Article article = new Article(); + article.setTitle("A Guide to @DynamicPropertySource in Spring"); + article.setContent("Today's applications..."); + + articleRepository.save(article); + Article persisted = articleRepository.findAll().get(0); + assertThat(persisted.getId()).isNotNull(); + assertThat(persisted.getTitle()).isEqualTo("A Guide to @DynamicPropertySource in Spring"); + assertThat(persisted.getContent()).isEqualTo("Today's applications..."); + } +} diff --git a/testing-modules/spring-testing-2/src/test/java/com/baeldung/dynamicproperties/ArticleTraditionalLiveTest.java b/testing-modules/spring-testing-2/src/test/java/com/baeldung/dynamicproperties/ArticleTraditionalLiveTest.java new file mode 100644 index 0000000000..87234505a9 --- /dev/null +++ b/testing-modules/spring-testing-2/src/test/java/com/baeldung/dynamicproperties/ArticleTraditionalLiveTest.java @@ -0,0 +1,57 @@ +package com.baeldung.dynamicproperties; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +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.testcontainers.containers.PostgreSQLContainer; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; + +import static org.assertj.core.api.Assertions.assertThat; + +@SpringBootTest +@Testcontainers +@ActiveProfiles("pg") +@ContextConfiguration(initializers = ArticleTraditionalLiveTest.EnvInitializer.class) +class ArticleTraditionalLiveTest { + + @Container + static PostgreSQLContainer postgres = new PostgreSQLContainer<>("postgres:11") + .withDatabaseName("prop") + .withUsername("postgres") + .withPassword("pass") + .withExposedPorts(5432); + + static class EnvInitializer implements ApplicationContextInitializer { + + @Override + public void initialize(ConfigurableApplicationContext applicationContext) { + TestPropertyValues.of( + String.format("spring.datasource.url=jdbc:postgresql://localhost:%d/prop", postgres.getFirstMappedPort()), + "spring.datasource.username=postgres", + "spring.datasource.password=pass" + ).applyTo(applicationContext); + } + } + + @Autowired + private ArticleRepository articleRepository; + + @Test + void givenAnArticle_whenPersisted_thenShouldBeAbleToReadIt() { + Article article = new Article(); + article.setTitle("A Guide to @DynamicPropertySource in Spring"); + article.setContent("Today's applications..."); + + articleRepository.save(article); + Article persisted = articleRepository.findAll().get(0); + assertThat(persisted.getId()).isNotNull(); + assertThat(persisted.getTitle()).isEqualTo("A Guide to @DynamicPropertySource in Spring"); + assertThat(persisted.getContent()).isEqualTo("Today's applications..."); + } +} diff --git a/testing-modules/spring-testing-2/src/test/java/com/baeldung/dynamicproperties/PostgreSQLExtension.java b/testing-modules/spring-testing-2/src/test/java/com/baeldung/dynamicproperties/PostgreSQLExtension.java new file mode 100644 index 0000000000..8c08ad67d7 --- /dev/null +++ b/testing-modules/spring-testing-2/src/test/java/com/baeldung/dynamicproperties/PostgreSQLExtension.java @@ -0,0 +1,31 @@ +package com.baeldung.dynamicproperties; + +import org.junit.jupiter.api.extension.AfterAllCallback; +import org.junit.jupiter.api.extension.BeforeAllCallback; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.testcontainers.containers.PostgreSQLContainer; + +public class PostgreSQLExtension implements BeforeAllCallback, AfterAllCallback { + + private PostgreSQLContainer postgres; + + @Override + public void beforeAll(ExtensionContext context) { + postgres = new PostgreSQLContainer<>("postgres:11") + .withDatabaseName("prop") + .withUsername("postgres") + .withPassword("pass") + .withExposedPorts(5432); + + postgres.start(); + String jdbcUrl = String.format("jdbc:postgresql://localhost:%d/prop", postgres.getFirstMappedPort()); + System.setProperty("spring.datasource.url", jdbcUrl); + System.setProperty("spring.datasource.username", "postgres"); + System.setProperty("spring.datasource.password", "pass"); + } + + @Override + public void afterAll(ExtensionContext context) { + postgres.stop(); + } +} diff --git a/testing-modules/spring-testing-2/src/test/resources/application-pg.properties b/testing-modules/spring-testing-2/src/test/resources/application-pg.properties new file mode 100644 index 0000000000..cb7bff1889 --- /dev/null +++ b/testing-modules/spring-testing-2/src/test/resources/application-pg.properties @@ -0,0 +1,2 @@ +spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect +spring.jpa.hibernate.ddl-auto=create-drop \ No newline at end of file From d4d7059add4837bc0b88e750a52cb09d1d447429 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Mon, 31 Aug 2020 10:34:01 -0600 Subject: [PATCH 033/263] Update BlogController.java Update formatting --- .../main/java/com/baeldung/thymeleaf/blog/BlogController.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/blog/BlogController.java b/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/blog/BlogController.java index eee2d26409..dfcfdc1117 100644 --- a/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/blog/BlogController.java +++ b/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/blog/BlogController.java @@ -10,8 +10,7 @@ import java.util.Random; public class BlogController { @GetMapping("/blog/new") - public String newBlogPost(Model model) - { + public String newBlogPost(Model model) { // Set a random ID so we can see it in the HTML form BlogDTO blog = new BlogDTO(); blog.setBlogId(Math.abs(new Random().nextLong() % 1000000)); From d237c52a1f677b0cac7f59ca71bd0fa7a9ff6c95 Mon Sep 17 00:00:00 2001 From: Maiklins Date: Mon, 31 Aug 2020 19:41:46 +0200 Subject: [PATCH 034/263] Java-75 update intro to reactor core (#9953) * Java-75 Update intro to Reactor Core * Java-75 Create package for introduction * Java-75 Update reactor version and align unit test with article Co-authored-by: mikr --- reactor-core/pom.xml | 2 +- .../{ => introduction}/ReactorIntegrationTest.java | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) rename reactor-core/src/test/java/com/baeldung/reactor/{ => introduction}/ReactorIntegrationTest.java (91%) diff --git a/reactor-core/pom.xml b/reactor-core/pom.xml index c9917d14df..317cbde6e2 100644 --- a/reactor-core/pom.xml +++ b/reactor-core/pom.xml @@ -34,7 +34,7 @@
- 3.2.6.RELEASE + 3.3.9.RELEASE 3.6.1 diff --git a/reactor-core/src/test/java/com/baeldung/reactor/ReactorIntegrationTest.java b/reactor-core/src/test/java/com/baeldung/reactor/introduction/ReactorIntegrationTest.java similarity index 91% rename from reactor-core/src/test/java/com/baeldung/reactor/ReactorIntegrationTest.java rename to reactor-core/src/test/java/com/baeldung/reactor/introduction/ReactorIntegrationTest.java index e3060b8e02..a1acffac91 100644 --- a/reactor-core/src/test/java/com/baeldung/reactor/ReactorIntegrationTest.java +++ b/reactor-core/src/test/java/com/baeldung/reactor/introduction/ReactorIntegrationTest.java @@ -1,4 +1,4 @@ -package com.baeldung.reactor; +package com.baeldung.reactor.introduction; import org.junit.Test; import org.reactivestreams.Subscriber; @@ -15,7 +15,7 @@ import static org.assertj.core.api.Assertions.assertThat; public class ReactorIntegrationTest { @Test - public void givenFlux_whenSubscribing_thenStream() throws InterruptedException { + public void givenFlux_whenSubscribing_thenStream() { List elements = new ArrayList<>(); @@ -48,14 +48,12 @@ public class ReactorIntegrationTest { } @Test - public void givenFlux_whenApplyingBackPressure_thenPushElementsInBatches() throws InterruptedException { + public void givenFlux_whenApplyingBackPressure_thenPushElementsInBatches() { List elements = new ArrayList<>(); Flux.just(1, 2, 3, 4) .log() - .map(i -> i * 2) - .onBackpressureBuffer() .subscribe(new Subscriber() { private Subscription s; int onNextAmount; @@ -81,11 +79,10 @@ public class ReactorIntegrationTest { @Override public void onComplete() { - int ham = 2; } }); - assertThat(elements).containsExactly(2, 4, 6, 8); + assertThat(elements).containsExactly(1, 2, 3, 4); } @Test From c6d95556171005b68cc4a6194de97de2cb5406ff Mon Sep 17 00:00:00 2001 From: Anirban Chatterjee Date: Mon, 31 Aug 2020 20:38:06 +0200 Subject: [PATCH 035/263] Refactored package --- .../baeldung/aggregate}/AggregateOperations.kt | 0 .../baeldung/aggregate}/AggregateOperationsUnitTest.kt | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename core-kotlin-modules/core-kotlin-collections-2/src/main/kotlin/{com.baeldung.aggregate => com/baeldung/aggregate}/AggregateOperations.kt (100%) rename core-kotlin-modules/core-kotlin-collections-2/src/test/kotlin/{com.baeldung.aggregate => com/baeldung/aggregate}/AggregateOperationsUnitTest.kt (100%) diff --git a/core-kotlin-modules/core-kotlin-collections-2/src/main/kotlin/com.baeldung.aggregate/AggregateOperations.kt b/core-kotlin-modules/core-kotlin-collections-2/src/main/kotlin/com/baeldung/aggregate/AggregateOperations.kt similarity index 100% rename from core-kotlin-modules/core-kotlin-collections-2/src/main/kotlin/com.baeldung.aggregate/AggregateOperations.kt rename to core-kotlin-modules/core-kotlin-collections-2/src/main/kotlin/com/baeldung/aggregate/AggregateOperations.kt diff --git a/core-kotlin-modules/core-kotlin-collections-2/src/test/kotlin/com.baeldung.aggregate/AggregateOperationsUnitTest.kt b/core-kotlin-modules/core-kotlin-collections-2/src/test/kotlin/com/baeldung/aggregate/AggregateOperationsUnitTest.kt similarity index 100% rename from core-kotlin-modules/core-kotlin-collections-2/src/test/kotlin/com.baeldung.aggregate/AggregateOperationsUnitTest.kt rename to core-kotlin-modules/core-kotlin-collections-2/src/test/kotlin/com/baeldung/aggregate/AggregateOperationsUnitTest.kt From 661027c771768e0d7d1da95d9e893bb8ae41d746 Mon Sep 17 00:00:00 2001 From: Jordan Simpson Date: Mon, 31 Aug 2020 13:42:50 -0500 Subject: [PATCH 036/263] Added code examples for BAEL-4534 --- .../CheckClassExistenceUnitTest.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 core-java-modules/core-java-lang-3/src/test/java/com/baeldung/checkclassexistence/CheckClassExistenceUnitTest.java diff --git a/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/checkclassexistence/CheckClassExistenceUnitTest.java b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/checkclassexistence/CheckClassExistenceUnitTest.java new file mode 100644 index 0000000000..10402af970 --- /dev/null +++ b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/checkclassexistence/CheckClassExistenceUnitTest.java @@ -0,0 +1,33 @@ +package com.baeldung.checkclassexistence; + +import org.junit.Test; + +public class CheckClassExistenceUnitTest { + + public static class InitializingClass { + static { + if (true) //enable throwing of an exception in a static initialization block + throw new RuntimeException(); + } + } + + @Test(expected = ClassNotFoundException.class) //thrown when class does not exist + public void givenNonExistingClass_whenUsingForName_classNotFound() throws ClassNotFoundException { + Class.forName("class.that.does.not.exist"); + } + + @Test + public void givenExistingClass_whenUsingForName_noException() throws ClassNotFoundException { + Class.forName("java.lang.String"); + } + + @Test(expected = ExceptionInInitializerError.class) //thrown when exception occurs inside of a static initialization block + public void givenInitializingClass_whenUsingForName_initializationError() throws ClassNotFoundException { + Class.forName("com.baeldung.checkclassexistence.CheckClassExistenceUnitTest$InitializingClass"); + } + + @Test + public void givenInitializingClass_whenUsingForNameWithoutInitialization_noException() throws ClassNotFoundException { + Class.forName("com.baeldung.checkclassexistence.CheckClassExistenceUnitTest$InitializingClass", false, getClass().getClassLoader()); + } +} From 691a948c5f55d20f98e3d96d5d201f8a098ffd6e Mon Sep 17 00:00:00 2001 From: Sorin Zamfir Date: Mon, 31 Aug 2020 22:53:30 +0300 Subject: [PATCH 037/263] BAEL-4371: Initial commit --- gradle-5/cmd-line-args/build.gradle | 16 ++++++++++++++++ gradle-5/settings.gradle | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 gradle-5/cmd-line-args/build.gradle diff --git a/gradle-5/cmd-line-args/build.gradle b/gradle-5/cmd-line-args/build.gradle new file mode 100644 index 0000000000..aed57d775b --- /dev/null +++ b/gradle-5/cmd-line-args/build.gradle @@ -0,0 +1,16 @@ +apply plugin: "java" +description = "Gradle Command Line Arguments examples" + + + +task propertyTypes(){ + doLast{ + if (project.hasProperty('input')){ + println "This is my property ["+ project.getProperty('input')+"]" + } else { + println "No property was passed" + } + + } +} + diff --git a/gradle-5/settings.gradle b/gradle-5/settings.gradle index 5384d071e7..ede73daf0a 100644 --- a/gradle-5/settings.gradle +++ b/gradle-5/settings.gradle @@ -1,4 +1,5 @@ rootProject.name='gradle-5-articles' include 'java-exec' include 'unused-dependencies' -include 'source-sets' \ No newline at end of file +include 'source-sets' +include 'cmd-line-args' \ No newline at end of file From 026e3c511ef0181dffb883bbe95345f80fca353a Mon Sep 17 00:00:00 2001 From: Ali Dehghani Date: Tue, 1 Sep 2020 04:27:53 +0430 Subject: [PATCH 038/263] Disabling Tomcat URL Stream Factory --- .../cloud/ribbon/retry/RibbonRetryFailureIntegrationTest.java | 2 ++ .../cloud/ribbon/retry/RibbonRetrySuccessIntegrationTest.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/spring-cloud/spring-cloud-ribbon-retry/ribbon-client-service/src/test/java/com/baeldung/spring/cloud/ribbon/retry/RibbonRetryFailureIntegrationTest.java b/spring-cloud/spring-cloud-ribbon-retry/ribbon-client-service/src/test/java/com/baeldung/spring/cloud/ribbon/retry/RibbonRetryFailureIntegrationTest.java index 0f0a1c4255..decb77e7b9 100644 --- a/spring-cloud/spring-cloud-ribbon-retry/ribbon-client-service/src/test/java/com/baeldung/spring/cloud/ribbon/retry/RibbonRetryFailureIntegrationTest.java +++ b/spring-cloud/spring-cloud-ribbon-retry/ribbon-client-service/src/test/java/com/baeldung/spring/cloud/ribbon/retry/RibbonRetryFailureIntegrationTest.java @@ -1,5 +1,6 @@ package com.baeldung.spring.cloud.ribbon.retry; +import org.apache.catalina.webresources.TomcatURLStreamHandlerFactory; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -24,6 +25,7 @@ public class RibbonRetryFailureIntegrationTest { @BeforeAll public static void setup() { + TomcatURLStreamHandlerFactory.disable(); weatherServiceInstance1 = startApp(8021); weatherServiceInstance2 = startApp(8022); } diff --git a/spring-cloud/spring-cloud-ribbon-retry/ribbon-client-service/src/test/java/com/baeldung/spring/cloud/ribbon/retry/RibbonRetrySuccessIntegrationTest.java b/spring-cloud/spring-cloud-ribbon-retry/ribbon-client-service/src/test/java/com/baeldung/spring/cloud/ribbon/retry/RibbonRetrySuccessIntegrationTest.java index 6fdad0f2a9..dc50fe76e6 100644 --- a/spring-cloud/spring-cloud-ribbon-retry/ribbon-client-service/src/test/java/com/baeldung/spring/cloud/ribbon/retry/RibbonRetrySuccessIntegrationTest.java +++ b/spring-cloud/spring-cloud-ribbon-retry/ribbon-client-service/src/test/java/com/baeldung/spring/cloud/ribbon/retry/RibbonRetrySuccessIntegrationTest.java @@ -1,5 +1,6 @@ package com.baeldung.spring.cloud.ribbon.retry; +import org.apache.catalina.webresources.TomcatURLStreamHandlerFactory; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -25,6 +26,7 @@ public class RibbonRetrySuccessIntegrationTest { @BeforeAll public static void setup() { + TomcatURLStreamHandlerFactory.disable(); weatherServiceInstance1 = startApp(8021); weatherServiceInstance2 = startApp(8022); } From 03ac0c0b5d331b1c67fa2af5c0b9e4614d7d5e7f Mon Sep 17 00:00:00 2001 From: Umang Budhwar Date: Tue, 1 Sep 2020 19:13:34 +0530 Subject: [PATCH 039/263] Added two space indent for the line continuation. --- .../configuration/SwaggerConfiguration.java | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2boot/configuration/SwaggerConfiguration.java b/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2boot/configuration/SwaggerConfiguration.java index 7bacdde4c8..4f85d90f5f 100644 --- a/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2boot/configuration/SwaggerConfiguration.java +++ b/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2boot/configuration/SwaggerConfiguration.java @@ -30,10 +30,10 @@ public class SwaggerConfiguration { @Bean public Docket api() { return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()) - .select() - .apis(RequestHandlerSelectors.any()) - .paths(PathSelectors.any()) - .build(); + .select() + .apis(RequestHandlerSelectors.any()) + .paths(PathSelectors.any()) + .build(); } /** @@ -43,21 +43,21 @@ public class SwaggerConfiguration { @Bean UiConfiguration uiConfig() { return UiConfigurationBuilder.builder() - .deepLinking(true) - .displayOperationId(false) - .defaultModelsExpandDepth(1) - .defaultModelExpandDepth(1) - .defaultModelRendering(ModelRendering.EXAMPLE) - .displayRequestDuration(false) - .docExpansion(DocExpansion.NONE) - .filter(false) - .maxDisplayedTags(null) - .operationsSorter(OperationsSorter.ALPHA) - .showExtensions(false) - .tagsSorter(TagsSorter.ALPHA) - .supportedSubmitMethods(UiConfiguration.Constants.DEFAULT_SUBMIT_METHODS) - .validatorUrl(null) - .build(); + .deepLinking(true) + .displayOperationId(false) + .defaultModelsExpandDepth(1) + .defaultModelExpandDepth(1) + .defaultModelRendering(ModelRendering.EXAMPLE) + .displayRequestDuration(false) + .docExpansion(DocExpansion.NONE) + .filter(false) + .maxDisplayedTags(null) + .operationsSorter(OperationsSorter.ALPHA) + .showExtensions(false) + .tagsSorter(TagsSorter.ALPHA) + .supportedSubmitMethods(UiConfiguration.Constants.DEFAULT_SUBMIT_METHODS) + .validatorUrl(null) + .build(); } } From 994e25312b5d770f4aabdf14ac893fdd98b36467 Mon Sep 17 00:00:00 2001 From: Umang Budhwar Date: Tue, 1 Sep 2020 19:28:46 +0530 Subject: [PATCH 040/263] Revert "Added two space indent for the line continuation." This reverts commit 03ac0c0b5d331b1c67fa2af5c0b9e4614d7d5e7f. --- .../configuration/SwaggerConfiguration.java | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2boot/configuration/SwaggerConfiguration.java b/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2boot/configuration/SwaggerConfiguration.java index 4f85d90f5f..7bacdde4c8 100644 --- a/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2boot/configuration/SwaggerConfiguration.java +++ b/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2boot/configuration/SwaggerConfiguration.java @@ -30,10 +30,10 @@ public class SwaggerConfiguration { @Bean public Docket api() { return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()) - .select() - .apis(RequestHandlerSelectors.any()) - .paths(PathSelectors.any()) - .build(); + .select() + .apis(RequestHandlerSelectors.any()) + .paths(PathSelectors.any()) + .build(); } /** @@ -43,21 +43,21 @@ public class SwaggerConfiguration { @Bean UiConfiguration uiConfig() { return UiConfigurationBuilder.builder() - .deepLinking(true) - .displayOperationId(false) - .defaultModelsExpandDepth(1) - .defaultModelExpandDepth(1) - .defaultModelRendering(ModelRendering.EXAMPLE) - .displayRequestDuration(false) - .docExpansion(DocExpansion.NONE) - .filter(false) - .maxDisplayedTags(null) - .operationsSorter(OperationsSorter.ALPHA) - .showExtensions(false) - .tagsSorter(TagsSorter.ALPHA) - .supportedSubmitMethods(UiConfiguration.Constants.DEFAULT_SUBMIT_METHODS) - .validatorUrl(null) - .build(); + .deepLinking(true) + .displayOperationId(false) + .defaultModelsExpandDepth(1) + .defaultModelExpandDepth(1) + .defaultModelRendering(ModelRendering.EXAMPLE) + .displayRequestDuration(false) + .docExpansion(DocExpansion.NONE) + .filter(false) + .maxDisplayedTags(null) + .operationsSorter(OperationsSorter.ALPHA) + .showExtensions(false) + .tagsSorter(TagsSorter.ALPHA) + .supportedSubmitMethods(UiConfiguration.Constants.DEFAULT_SUBMIT_METHODS) + .validatorUrl(null) + .build(); } } From b8bcbeee90aa6b84778909ff94af60b5af78ebe2 Mon Sep 17 00:00:00 2001 From: Umang Budhwar Date: Tue, 1 Sep 2020 19:13:34 +0530 Subject: [PATCH 041/263] Added two space indent for the line continuation. --- .../configuration/SwaggerConfiguration.java | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2boot/configuration/SwaggerConfiguration.java b/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2boot/configuration/SwaggerConfiguration.java index 7bacdde4c8..4f85d90f5f 100644 --- a/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2boot/configuration/SwaggerConfiguration.java +++ b/spring-boot-modules/spring-boot-swagger/src/main/java/com/baeldung/swagger2boot/configuration/SwaggerConfiguration.java @@ -30,10 +30,10 @@ public class SwaggerConfiguration { @Bean public Docket api() { return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()) - .select() - .apis(RequestHandlerSelectors.any()) - .paths(PathSelectors.any()) - .build(); + .select() + .apis(RequestHandlerSelectors.any()) + .paths(PathSelectors.any()) + .build(); } /** @@ -43,21 +43,21 @@ public class SwaggerConfiguration { @Bean UiConfiguration uiConfig() { return UiConfigurationBuilder.builder() - .deepLinking(true) - .displayOperationId(false) - .defaultModelsExpandDepth(1) - .defaultModelExpandDepth(1) - .defaultModelRendering(ModelRendering.EXAMPLE) - .displayRequestDuration(false) - .docExpansion(DocExpansion.NONE) - .filter(false) - .maxDisplayedTags(null) - .operationsSorter(OperationsSorter.ALPHA) - .showExtensions(false) - .tagsSorter(TagsSorter.ALPHA) - .supportedSubmitMethods(UiConfiguration.Constants.DEFAULT_SUBMIT_METHODS) - .validatorUrl(null) - .build(); + .deepLinking(true) + .displayOperationId(false) + .defaultModelsExpandDepth(1) + .defaultModelExpandDepth(1) + .defaultModelRendering(ModelRendering.EXAMPLE) + .displayRequestDuration(false) + .docExpansion(DocExpansion.NONE) + .filter(false) + .maxDisplayedTags(null) + .operationsSorter(OperationsSorter.ALPHA) + .showExtensions(false) + .tagsSorter(TagsSorter.ALPHA) + .supportedSubmitMethods(UiConfiguration.Constants.DEFAULT_SUBMIT_METHODS) + .validatorUrl(null) + .build(); } } From 2dc6089b10eb062009fde17d72d2a0352f3fc70d Mon Sep 17 00:00:00 2001 From: kwoyke Date: Tue, 1 Sep 2020 16:49:22 +0200 Subject: [PATCH 042/263] BAEL-4518: Upgrade jooq version (#9955) --- spring-jooq/pom.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-jooq/pom.xml b/spring-jooq/pom.xml index c07d6278cb..95418645fa 100644 --- a/spring-jooq/pom.xml +++ b/spring-jooq/pom.xml @@ -30,6 +30,7 @@ org.jooq jooq + ${org.jooq.version} @@ -201,7 +202,7 @@ - 3.11.7 + 3.12.4 1.0.0 1.5 1.0.0 From 468217efea75f9cc43f19fb5ca8f4fc2b65785a8 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Tue, 1 Sep 2020 17:19:24 +0200 Subject: [PATCH 043/263] JAVA-2398: Remove redundant config classes import --- .../com/baeldung/swagger2boot/configuration/SpringFoxConfig.java | 1 - 1 file changed, 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/configuration/SpringFoxConfig.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/configuration/SpringFoxConfig.java index b404b0c2f8..5998ffeb2a 100644 --- a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/configuration/SpringFoxConfig.java +++ b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/configuration/SpringFoxConfig.java @@ -22,7 +22,6 @@ import springfox.documentation.swagger.web.UiConfigurationBuilder; import java.util.Collections; @Configuration -@Import({SpringDataRestConfiguration.class, BeanValidatorPluginsConfiguration.class}) public class SpringFoxConfig { private ApiInfo apiInfo() { From 8d2c467e2b4205812fcaaa2140ac0318a657a91f Mon Sep 17 00:00:00 2001 From: majajoksovic Date: Tue, 1 Sep 2020 17:23:00 +0200 Subject: [PATCH 044/263] BAEL-4465 (#9954) * initial commit * fixed indent * removed unused dependencies * some minor code changes and unit tests * fixed file names --- libraries-security/pom.xml | 17 +++-- .../com/baeldung/ssh/apachesshd/SshdDemo.java | 64 +++++++++++++++++++ .../java/com/baeldung/ssh/jsch/JschDemo.java | 52 +++++++++++++++ .../baeldung/ssh/ApacheMinaSshdLiveTest.java | 38 +++++++++++ .../java/com/baeldung/ssh/JSchLiveTest.java | 35 ++++++++++ 5 files changed, 201 insertions(+), 5 deletions(-) create mode 100644 libraries-security/src/main/java/com/baeldung/ssh/apachesshd/SshdDemo.java create mode 100644 libraries-security/src/main/java/com/baeldung/ssh/jsch/JschDemo.java create mode 100644 libraries-security/src/test/java/com/baeldung/ssh/ApacheMinaSshdLiveTest.java create mode 100644 libraries-security/src/test/java/com/baeldung/ssh/JSchLiveTest.java diff --git a/libraries-security/pom.xml b/libraries-security/pom.xml index e02f766141..202b3b8763 100644 --- a/libraries-security/pom.xml +++ b/libraries-security/pom.xml @@ -14,29 +14,24 @@ - org.springframework.boot spring-boot-starter-web - org.springframework.security.oauth spring-security-oauth2 ${spring-boot.version} - org.springframework spring-web - com.github.scribejava scribejava-apis ${scribejava.version} - com.google.crypto.tink tink @@ -72,6 +67,16 @@ jasypt ${jasypt.version} + + com.jcraft + jsch + ${jsch.version} + + + org.apache.sshd + sshd-core + ${apache-mina.version} + @@ -81,6 +86,8 @@ 1.2.2 1.9.2 1.58 + 0.1.55 + 2.5.1 diff --git a/libraries-security/src/main/java/com/baeldung/ssh/apachesshd/SshdDemo.java b/libraries-security/src/main/java/com/baeldung/ssh/apachesshd/SshdDemo.java new file mode 100644 index 0000000000..05d8034040 --- /dev/null +++ b/libraries-security/src/main/java/com/baeldung/ssh/apachesshd/SshdDemo.java @@ -0,0 +1,64 @@ +package com.baeldung.ssh.apachesshd; + +import java.io.ByteArrayOutputStream; +import java.io.OutputStream; +import java.util.EnumSet; +import java.util.concurrent.TimeUnit; + +import org.apache.sshd.client.SshClient; +import org.apache.sshd.client.channel.ClientChannel; +import org.apache.sshd.client.channel.ClientChannelEvent; +import org.apache.sshd.client.session.ClientSession; +import org.apache.sshd.common.channel.Channel; + +public class SshdDemo { + + public static void main(String[] args) throws Exception { + String username = "demo"; + String password = "password"; + String host = "test.rebex.net"; + int port = 22; + long defaultTimeoutSeconds = 10l; + String command = "ls\n"; + + listFolderStructure(username, password, host, port, defaultTimeoutSeconds, command); + } + + public static String listFolderStructure(String username, String password, String host, int port, long defaultTimeoutSeconds, String command) throws Exception { + SshClient client = SshClient.setUpDefaultClient(); + client.start(); + try (ClientSession session = client.connect(username, host, port) + .verify(defaultTimeoutSeconds, TimeUnit.SECONDS) + .getSession()) { + session.addPasswordIdentity(password); + session.auth() + .verify(5L, TimeUnit.SECONDS); + try (ByteArrayOutputStream responseStream = new ByteArrayOutputStream(); + ByteArrayOutputStream errorResponseStream = new ByteArrayOutputStream(); + ClientChannel channel = session.createChannel(Channel.CHANNEL_SHELL)) { + channel.setOut(responseStream); + channel.setErr(errorResponseStream); + try { + channel.open() + .verify(defaultTimeoutSeconds, TimeUnit.SECONDS); + try (OutputStream pipedIn = channel.getInvertedIn()) { + pipedIn.write(command.getBytes()); + pipedIn.flush(); + } + channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), TimeUnit.SECONDS.toMillis(defaultTimeoutSeconds)); + String errorString = new String(errorResponseStream.toByteArray()); + if(!errorString.isEmpty()) { + throw new Exception(errorString); + } + String responseString = new String(responseStream.toByteArray()); + return responseString; + } finally { + channel.close(false); + } + } + } finally { + client.stop(); + } + } + +} diff --git a/libraries-security/src/main/java/com/baeldung/ssh/jsch/JschDemo.java b/libraries-security/src/main/java/com/baeldung/ssh/jsch/JschDemo.java new file mode 100644 index 0000000000..34a40318bb --- /dev/null +++ b/libraries-security/src/main/java/com/baeldung/ssh/jsch/JschDemo.java @@ -0,0 +1,52 @@ +package com.baeldung.ssh.jsch; + +import java.io.ByteArrayOutputStream; + +import com.jcraft.jsch.ChannelExec; +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.Session; + +public class JschDemo { + + public static void main(String args[]) throws Exception { + String username = "demo"; + String password = "password"; + String host = "test.rebex.net"; + int port = 22; + String command = "ls"; + listFolderStructure(username, password, host, port, command); + } + + public static String listFolderStructure(String username, String password, String host, int port, String command) throws Exception { + Session session = null; + ChannelExec channel = null; + String response = null; + try { + session = new JSch().getSession(username, host, port); + session.setPassword(password); + session.setConfig("StrictHostKeyChecking", "no"); + session.connect(); + channel = (ChannelExec) session.openChannel("exec"); + channel.setCommand(command); + ByteArrayOutputStream responseStream = new ByteArrayOutputStream(); + ByteArrayOutputStream errorResponseStream = new ByteArrayOutputStream(); + channel.setOutputStream(responseStream); + channel.setErrStream(errorResponseStream); + channel.connect(); + while (channel.isConnected()) { + Thread.sleep(100); + } + String errorResponse = new String(errorResponseStream.toByteArray()); + response = new String(responseStream.toByteArray()); + if(!errorResponse.isEmpty()) { + throw new Exception(errorResponse); + } + } finally { + if (session != null) + session.disconnect(); + if (channel != null) + channel.disconnect(); + } + return response; + } +} diff --git a/libraries-security/src/test/java/com/baeldung/ssh/ApacheMinaSshdLiveTest.java b/libraries-security/src/test/java/com/baeldung/ssh/ApacheMinaSshdLiveTest.java new file mode 100644 index 0000000000..3cefca05cb --- /dev/null +++ b/libraries-security/src/test/java/com/baeldung/ssh/ApacheMinaSshdLiveTest.java @@ -0,0 +1,38 @@ +package com.baeldung.ssh; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import org.junit.Test; + +import com.baeldung.ssh.apachesshd.SshdDemo; + +public class ApacheMinaSshdLiveTest { + + @Test + public void givenValidCredentials_whenConnectionIsEstablished_thenServerReturnsResponse() throws Exception { + String username = "demo"; + String password = "password"; + String host = "test.rebex.net"; + int port = 22; + long defaultTimeoutSeconds = 10l; + String command = "ls\n"; + String responseString = SshdDemo.listFolderStructure(username, password, host, port, defaultTimeoutSeconds, command); + + assertNotNull(responseString); + } + + @Test(expected = Exception.class) + public void givenInvalidCredentials_whenConnectionAttemptIsMade_thenServerReturnsErrorResponse() throws Exception { + String username = "invalidUsername"; + String password = "password"; + String host = "test.rebex.net"; + int port = 22; + long defaultTimeoutSeconds = 10l; + String command = "ls\n"; + String responseString = SshdDemo.listFolderStructure(username, password, host, port, defaultTimeoutSeconds, command); + + assertNull(responseString); + } + +} diff --git a/libraries-security/src/test/java/com/baeldung/ssh/JSchLiveTest.java b/libraries-security/src/test/java/com/baeldung/ssh/JSchLiveTest.java new file mode 100644 index 0000000000..c95c3c319c --- /dev/null +++ b/libraries-security/src/test/java/com/baeldung/ssh/JSchLiveTest.java @@ -0,0 +1,35 @@ +package com.baeldung.ssh; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import org.junit.Test; + +import com.baeldung.ssh.jsch.JschDemo; + +public class JSchLiveTest { + + @Test + public void givenValidCredentials_whenConnectionIsEstablished_thenServerReturnsResponse() throws Exception { + String username = "demo"; + String password = "password"; + String host = "test.rebex.net"; + int port = 22; + String command = "ls"; + String responseString = JschDemo.listFolderStructure(username, password, host, port, command); + + assertNotNull(responseString); + } + + @Test(expected = Exception.class) + public void givenInvalidCredentials_whenConnectionAttemptIsMade_thenServerReturnsErrorResponse() throws Exception { + String username = "invalidUsername"; + String password = "password"; + String host = "test.rebex.net"; + int port = 22; + String command = "ls"; + String responseString = JschDemo.listFolderStructure(username, password, host, port, command); + + assertNull(responseString); + } +} From d19ac51aaa6e19426e1a43cd1c9eb88f7884850e Mon Sep 17 00:00:00 2001 From: Sorin Zamfir Date: Tue, 1 Sep 2020 18:52:06 +0300 Subject: [PATCH 045/263] BAEL-4371: Finished code samples --- gradle-5/cmd-line-args/build.gradle | 40 ++++++++++++++++--- .../main/java/com/baeldung/cmd/MainClass.java | 10 +++++ 2 files changed, 45 insertions(+), 5 deletions(-) create mode 100644 gradle-5/cmd-line-args/src/main/java/com/baeldung/cmd/MainClass.java diff --git a/gradle-5/cmd-line-args/build.gradle b/gradle-5/cmd-line-args/build.gradle index aed57d775b..57c48e36c3 100644 --- a/gradle-5/cmd-line-args/build.gradle +++ b/gradle-5/cmd-line-args/build.gradle @@ -1,16 +1,46 @@ apply plugin: "java" +apply plugin: "application" description = "Gradle Command Line Arguments examples" +ext.javaMainClass = "com.baeldung.cmd.MainClass" +application { + mainClassName = javaMainClass +} task propertyTypes(){ doLast{ - if (project.hasProperty('input')){ - println "This is my property ["+ project.getProperty('input')+"]" - } else { - println "No property was passed" + project.getProperties().values().each { + println "Project property ["+it+"]" + } + + System.getProperties().each { + println "System property ["+it+"]" } - } } +if (project.hasProperty("args")) { + ext.cmdargs = project.getProperty("args") + ext.cmdargsarray = cmdargs.split() +} else { + ext.cmdargs = "" +} + +task cmdLineJavaExec(type: JavaExec) { + group = "Execution" + description = "Run the main class with JavaExecTask" + classpath = sourceSets.main.runtimeClasspath + main = javaMainClass + args cmdargsarray +} + +ext.cmdarray = ["java", "-classpath", sourceSets.main.runtimeClasspath.getAsPath(), javaMainClass] +cmdarray = (cmdarray << cmdargsarray).flatten() + +task cmdLineExec(type: Exec) { + dependsOn build + group = "Execution" + description = "Run the main class with ExecTask" + commandLine cmdarray +} diff --git a/gradle-5/cmd-line-args/src/main/java/com/baeldung/cmd/MainClass.java b/gradle-5/cmd-line-args/src/main/java/com/baeldung/cmd/MainClass.java new file mode 100644 index 0000000000..f00aa07d72 --- /dev/null +++ b/gradle-5/cmd-line-args/src/main/java/com/baeldung/cmd/MainClass.java @@ -0,0 +1,10 @@ +package com.baeldung.cmd; + +public class MainClass { + public static void main(String[] args) { + System.out.println("Gradle command line arguments example"); + for (String arg : args) { + System.out.println("Got argument [" + arg + "]"); + } + } +} From 9d24bc15986325ca896e62cfd0bfd6f8c5048375 Mon Sep 17 00:00:00 2001 From: Maciej Glowka Date: Tue, 1 Sep 2020 21:15:01 +0200 Subject: [PATCH 046/263] BAEL-4297: example of IllegalMonitorStateException --- .../exceptions/illegalmonitorstate/Data.java | 14 ++++ .../SynchronizedReceiver.java | 35 ++++++++++ .../SynchronizedSender.java | 33 +++++++++ .../UnSynchronizedReceiver.java | 33 +++++++++ .../UnSynchronizedSender.java | 31 ++++++++ .../IllegalMonitorStateExceptionUnitTest.java | 70 +++++++++++++++++++ 6 files changed, 216 insertions(+) create mode 100644 core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/Data.java create mode 100644 core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/SynchronizedReceiver.java create mode 100644 core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/SynchronizedSender.java create mode 100644 core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/UnSynchronizedReceiver.java create mode 100644 core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/UnSynchronizedSender.java create mode 100644 core-java-modules/core-java-exceptions-3/src/test/java/com/baeldung/exceptions/illegalmonitorstate/IllegalMonitorStateExceptionUnitTest.java diff --git a/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/Data.java b/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/Data.java new file mode 100644 index 0000000000..b5867d15e7 --- /dev/null +++ b/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/Data.java @@ -0,0 +1,14 @@ +package com.baeldung.exceptions.illegalmonitorstate; + +public class Data { + private String message; + + public void send(String message) { + this.message = message; + } + + public String receive() { + return message; + } +} + diff --git a/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/SynchronizedReceiver.java b/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/SynchronizedReceiver.java new file mode 100644 index 0000000000..3dffb7b30a --- /dev/null +++ b/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/SynchronizedReceiver.java @@ -0,0 +1,35 @@ +package com.baeldung.exceptions.illegalmonitorstate; + +public class SynchronizedReceiver implements Runnable { + private final Data data; + private String message; + private boolean illegalMonitorStateExceptionOccurred; + + public SynchronizedReceiver(Data data) { + this.data = data; + } + + @Override + public void run() { + synchronized (data) { + try { + data.wait(); + this.message = data.receive(); + } catch (InterruptedException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } catch (IllegalMonitorStateException e) { + e.printStackTrace(); + illegalMonitorStateExceptionOccurred = true; + } + } + } + + public boolean hasIllegalMonitorStateExceptionOccurred() { + return illegalMonitorStateExceptionOccurred; + } + + public String getMessage() { + return message; + } +} diff --git a/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/SynchronizedSender.java b/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/SynchronizedSender.java new file mode 100644 index 0000000000..04bac03e77 --- /dev/null +++ b/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/SynchronizedSender.java @@ -0,0 +1,33 @@ +package com.baeldung.exceptions.illegalmonitorstate; + +public class SynchronizedSender implements Runnable { + private final Data data; + private boolean illegalMonitorStateExceptionOccurred; + + public SynchronizedSender(Data data) { + this.data = data; + } + + @Override + public void run() { + synchronized (data) { + try { + Thread.sleep(1000); + + data.send("test"); + + data.notifyAll(); + } catch (InterruptedException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } catch (IllegalMonitorStateException e) { + e.printStackTrace(); + illegalMonitorStateExceptionOccurred = true; + } + } + } + + public boolean hasIllegalMonitorStateExceptionOccurred() { + return illegalMonitorStateExceptionOccurred; + } +} diff --git a/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/UnSynchronizedReceiver.java b/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/UnSynchronizedReceiver.java new file mode 100644 index 0000000000..a8e8befc4d --- /dev/null +++ b/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/UnSynchronizedReceiver.java @@ -0,0 +1,33 @@ +package com.baeldung.exceptions.illegalmonitorstate; + +public class UnSynchronizedReceiver implements Runnable { + private final Data data; + private String message; + private boolean illegalMonitorStateExceptionOccurred; + + public UnSynchronizedReceiver(Data data) { + this.data = data; + } + + @Override + public void run() { + try { + data.wait(); + this.message = data.receive(); + } catch (InterruptedException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } catch (IllegalMonitorStateException e) { + e.printStackTrace(); + illegalMonitorStateExceptionOccurred = true; + } + } + + public boolean hasIllegalMonitorStateExceptionOccurred() { + return illegalMonitorStateExceptionOccurred; + } + + public String getMessage() { + return message; + } +} diff --git a/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/UnSynchronizedSender.java b/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/UnSynchronizedSender.java new file mode 100644 index 0000000000..eb6fa16649 --- /dev/null +++ b/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/UnSynchronizedSender.java @@ -0,0 +1,31 @@ +package com.baeldung.exceptions.illegalmonitorstate; + +public class UnSynchronizedSender implements Runnable { + private final Data data; + private boolean illegalMonitorStateExceptionOccurred; + + public UnSynchronizedSender(Data data) { + this.data = data; + } + + @Override + public void run() { + try { + Thread.sleep(1000); + + data.send("test"); + + data.notifyAll(); + } catch (InterruptedException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } catch (IllegalMonitorStateException e) { + e.printStackTrace(); + illegalMonitorStateExceptionOccurred = true; + } + } + + public boolean hasIllegalMonitorStateExceptionOccurred() { + return illegalMonitorStateExceptionOccurred; + } +} diff --git a/core-java-modules/core-java-exceptions-3/src/test/java/com/baeldung/exceptions/illegalmonitorstate/IllegalMonitorStateExceptionUnitTest.java b/core-java-modules/core-java-exceptions-3/src/test/java/com/baeldung/exceptions/illegalmonitorstate/IllegalMonitorStateExceptionUnitTest.java new file mode 100644 index 0000000000..800cdc4a7b --- /dev/null +++ b/core-java-modules/core-java-exceptions-3/src/test/java/com/baeldung/exceptions/illegalmonitorstate/IllegalMonitorStateExceptionUnitTest.java @@ -0,0 +1,70 @@ +package com.baeldung.exceptions.illegalmonitorstate; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +public class IllegalMonitorStateExceptionUnitTest { + + @Test + void whenSyncSenderAndSyncReceiverAreUsed_thenIllegalMonitorExceptionShouldNotBeThrown() throws InterruptedException { + Data data = new Data(); + + SynchronizedReceiver receiver = new SynchronizedReceiver(data); + Thread receiverThread = new Thread(receiver, "receiver-thread"); + receiverThread.start(); + + SynchronizedSender sender = new SynchronizedSender(data); + Thread senderThread = new Thread(sender, "sender-thread"); + senderThread.start(); + + senderThread.join(1000); + receiverThread.join(1000); + + assertEquals("test", receiver.getMessage()); + assertFalse(sender.hasIllegalMonitorStateExceptionOccurred()); + assertFalse(receiver.hasIllegalMonitorStateExceptionOccurred()); + } + + @Test + void whenSyncSenderAndUnSyncReceiverAreUsed_thenIllegalMonitorExceptionShouldNotBeThrown() throws InterruptedException { + Data data = new Data(); + + UnSynchronizedReceiver receiver = new UnSynchronizedReceiver(data); + Thread receiverThread = new Thread(receiver, "receiver-thread"); + receiverThread.start(); + + SynchronizedSender sender = new SynchronizedSender(data); + Thread senderThread = new Thread(sender, "sender-thread"); + senderThread.start(); + + + receiverThread.join(1000); + senderThread.join(1000); + + assertNull(receiver.getMessage()); + assertFalse(sender.hasIllegalMonitorStateExceptionOccurred()); + assertTrue(receiver.hasIllegalMonitorStateExceptionOccurred()); + } + + @Test + void whenUnSyncSenderAndSyncReceiverAreUsed_thenIllegalMonitorExceptionShouldBeThrown() throws InterruptedException { + Data data = new Data(); + + SynchronizedReceiver receiver = new SynchronizedReceiver(data); + Thread receiverThread = new Thread(receiver, "receiver-thread"); + receiverThread.start(); + + UnSynchronizedSender sender = new UnSynchronizedSender(data); + Thread senderThread = new Thread(sender, "sender-thread"); + senderThread.start(); + + + receiverThread.join(1000); + senderThread.join(1000); + + assertNull(receiver.getMessage()); + assertFalse(receiver.hasIllegalMonitorStateExceptionOccurred()); + assertTrue(sender.hasIllegalMonitorStateExceptionOccurred()); + } +} From 8d07e8fab96ca4375ae21c953f904d74985b4164 Mon Sep 17 00:00:00 2001 From: Sebastian Luna Date: Wed, 2 Sep 2020 07:46:50 -0500 Subject: [PATCH 047/263] BAEL-4387 Change module --- .../ArrayToListConversionUnitTest.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) rename {java-collections-conversions-2 => core-java-modules/core-java-string-operations-3}/src/test/java/com/baeldung/arrayconversion/ArrayToListConversionUnitTest.java (61%) diff --git a/java-collections-conversions-2/src/test/java/com/baeldung/arrayconversion/ArrayToListConversionUnitTest.java b/core-java-modules/core-java-string-operations-3/src/test/java/com/baeldung/arrayconversion/ArrayToListConversionUnitTest.java similarity index 61% rename from java-collections-conversions-2/src/test/java/com/baeldung/arrayconversion/ArrayToListConversionUnitTest.java rename to core-java-modules/core-java-string-operations-3/src/test/java/com/baeldung/arrayconversion/ArrayToListConversionUnitTest.java index 551661810d..80e7b93b0c 100644 --- a/java-collections-conversions-2/src/test/java/com/baeldung/arrayconversion/ArrayToListConversionUnitTest.java +++ b/core-java-modules/core-java-string-operations-3/src/test/java/com/baeldung/arrayconversion/ArrayToListConversionUnitTest.java @@ -1,21 +1,24 @@ package com.baeldung.arrayconversion; +import org.hamcrest.CoreMatchers; import org.junit.Test; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.assertArrayEquals; + public class ArrayToListConversionUnitTest { @Test(expected = UnsupportedOperationException.class) public void givenAnArray_whenConvertingToList_returnUnmodifiableListUnitTest() { String[] stringArray = new String[] { "A", "B", "C", "D" }; List stringList = Arrays.asList(stringArray); - System.out.println(stringList); stringList.set(0, "E"); - System.out.println(stringList); - System.out.println(Arrays.toString(stringArray)); + assertThat(stringList, CoreMatchers.hasItems("E", "B", "C", "D")); + assertArrayEquals(stringArray, new String[] { "E", "B", "C", "D" }); stringList.add("F"); } @@ -23,10 +26,10 @@ public class ArrayToListConversionUnitTest { public void givenAnArray_whenConvertingToList_returnModifiableListUnitTest() { String[] stringArray = new String[] { "A", "B", "C", "D" }; List stringList = new ArrayList<>(Arrays.asList(stringArray)); - System.out.println(stringList); stringList.set(0, "E"); - System.out.println(stringList); - System.out.println(Arrays.toString(stringArray)); + assertThat(stringList, CoreMatchers.hasItems("E", "B", "C", "D")); + assertArrayEquals(stringArray, new String[] { "A", "B", "C", "D" }); stringList.add("F"); + assertThat(stringList, CoreMatchers.hasItems("E", "B", "C", "D", "F")); } } From c9d080aff4fbda963063d0abf6e5c86c5c524a1a Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Wed, 2 Sep 2020 15:23:35 +0200 Subject: [PATCH 048/263] JAVA-2401: Remove redundant repository config --- spring-boot-modules/spring-boot-mvc/pom.xml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/spring-boot-modules/spring-boot-mvc/pom.xml b/spring-boot-modules/spring-boot-mvc/pom.xml index 39046ee6d9..560ea1cffa 100644 --- a/spring-boot-modules/spring-boot-mvc/pom.xml +++ b/spring-boot-modules/spring-boot-mvc/pom.xml @@ -17,15 +17,6 @@ spring-boot-mvc Module For Spring Boot MVC - - - - jcenter-release - jcenter - http://oss.jfrog.org/artifactory/oss-release-local/ - - - From b27e6a047016b112fc47ab5ac7d6a63e0fe54ab6 Mon Sep 17 00:00:00 2001 From: Jordan Simpson Date: Wed, 2 Sep 2020 09:00:42 -0500 Subject: [PATCH 049/263] Added braces to the if block --- .../checkclassexistence/CheckClassExistenceUnitTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/checkclassexistence/CheckClassExistenceUnitTest.java b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/checkclassexistence/CheckClassExistenceUnitTest.java index 10402af970..2e500b390f 100644 --- a/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/checkclassexistence/CheckClassExistenceUnitTest.java +++ b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/checkclassexistence/CheckClassExistenceUnitTest.java @@ -6,8 +6,9 @@ public class CheckClassExistenceUnitTest { public static class InitializingClass { static { - if (true) //enable throwing of an exception in a static initialization block + if (true) { //enable throwing of an exception in a static initialization block throw new RuntimeException(); + } } } From 473b453a1f0bf2f46d00999a000a0e881df8df1d Mon Sep 17 00:00:00 2001 From: Sampada <46674082+sampada07@users.noreply.github.com> Date: Wed, 2 Sep 2020 21:16:52 +0530 Subject: [PATCH 050/263] BAEL-4441: Custom User Attributes with Keycloak and Spring (#9966) --- .../keycloak/CustomUserAttrController.java | 46 +++++++++++++++++++ .../com/baeldung/keycloak/SecurityConfig.java | 2 +- .../main/resources/templates/userInfo.html | 15 ++++++ 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloak/CustomUserAttrController.java create mode 100644 spring-boot-modules/spring-boot-keycloak/src/main/resources/templates/userInfo.html diff --git a/spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloak/CustomUserAttrController.java b/spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloak/CustomUserAttrController.java new file mode 100644 index 0000000000..1959590e5a --- /dev/null +++ b/spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloak/CustomUserAttrController.java @@ -0,0 +1,46 @@ +package com.baeldung.keycloak; + +import java.security.Principal; +import java.util.Map; + +import org.keycloak.KeycloakPrincipal; +import org.keycloak.KeycloakSecurityContext; +import org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken; +import org.keycloak.representations.IDToken; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; + +@Controller +public class CustomUserAttrController { + + @GetMapping(path = "/users") + public String getUserInfo(Model model) { + + KeycloakAuthenticationToken authentication = (KeycloakAuthenticationToken) SecurityContextHolder.getContext() + .getAuthentication(); + + final Principal principal = (Principal) authentication.getPrincipal(); + + String dob = ""; + + if (principal instanceof KeycloakPrincipal) { + + KeycloakPrincipal kPrincipal = (KeycloakPrincipal) principal; + IDToken token = kPrincipal.getKeycloakSecurityContext() + .getIdToken(); + + Map customClaims = token.getOtherClaims(); + + if (customClaims.containsKey("DOB")) { + dob = String.valueOf(customClaims.get("DOB")); + } + } + + model.addAttribute("username", principal.getName()); + model.addAttribute("dob", dob); + return "userInfo"; + } + +} diff --git a/spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloak/SecurityConfig.java b/spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloak/SecurityConfig.java index 4ecb62b6d4..895ac8c562 100644 --- a/spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloak/SecurityConfig.java +++ b/spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloak/SecurityConfig.java @@ -44,7 +44,7 @@ class SecurityConfig extends KeycloakWebSecurityConfigurerAdapter { protected void configure(HttpSecurity http) throws Exception { super.configure(http); http.authorizeRequests() - .antMatchers("/customers*") + .antMatchers("/customers*", "/users*") .hasRole("user") .anyRequest() .permitAll(); diff --git a/spring-boot-modules/spring-boot-keycloak/src/main/resources/templates/userInfo.html b/spring-boot-modules/spring-boot-keycloak/src/main/resources/templates/userInfo.html new file mode 100644 index 0000000000..1446fe2124 --- /dev/null +++ b/spring-boot-modules/spring-boot-keycloak/src/main/resources/templates/userInfo.html @@ -0,0 +1,15 @@ + + + + + +
+

+ Hello, --name--. +

+

+ Your Date of Birth as per our records is . +

+
+ + From 0a24acf927ce6270a624a684de1601e46faecb6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Dupire?= Date: Wed, 19 Aug 2020 19:44:49 +0200 Subject: [PATCH 051/263] [JAVA-2306] Fix - Added spring-data-jpa-query-2 to modules list --- persistence-modules/pom.xml | 1 + persistence-modules/spring-data-jpa-query-2/pom.xml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/persistence-modules/pom.xml b/persistence-modules/pom.xml index 522c281386..468d50b458 100644 --- a/persistence-modules/pom.xml +++ b/persistence-modules/pom.xml @@ -68,6 +68,7 @@ spring-data-jpa-enterprise spring-data-jpa-filtering spring-data-jpa-query + spring-data-jpa-query-2 spring-data-jpa-repo spring-data-jdbc diff --git a/persistence-modules/spring-data-jpa-query-2/pom.xml b/persistence-modules/spring-data-jpa-query-2/pom.xml index b9e5120543..22cd373c95 100644 --- a/persistence-modules/spring-data-jpa-query-2/pom.xml +++ b/persistence-modules/spring-data-jpa-query-2/pom.xml @@ -3,7 +3,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 - spring-data-jpa-query + spring-data-jpa-query-2 spring-data-jpa-query-2 From 4e4ac650fa6b71fe9139a35b455950ccd00e2eb8 Mon Sep 17 00:00:00 2001 From: fdpro Date: Wed, 19 Aug 2020 20:18:54 +0200 Subject: [PATCH 052/263] [JAVA-2306] Moved articles from spring-persistence-simple * https://www.baeldung.com/the-persistence-layer-with-spring-and-jpa went into spring-jpa-2 * https://www.baeldung.com/hibernate-5-spring went to spring-jpa-2 * https://www.baeldung.com/transaction-configuration-with-jpa-and-spring went to spring-jpa-2 * https://www.baeldung.com/persistence-layer-with-spring-and-hibernate went to spring-jpa-2 * https://www.baeldung.com/simplifying-the-data-access-layer-with-spring-and-java-generics went to spring-jpa-2 * https://www.baeldung.com/the-persistence-layer-with-spring-data-jpa went to spring-data-jpa-repo-2 * https://www.baeldung.com/spring-data-jpa-query went to spring-data-jpa-query-2 * https://www.baeldung.com/spring-jdbc-jdbctemplate moved to spring-jdbc * Removed spring-persistence-simple module as all articles have been moved --- .../{ => spring}/jdbc/BatchProcessing.java | 2 +- .../baeldung/{ => spring}/jdbc/Employee.java | 2 +- .../jdbc/joins/ArticleWithAuthor.java | 2 +- .../jdbc/joins/ArticleWithAuthorDAO.java | 2 +- .../jdbc/BatchProcessingLiveTest.java | 2 +- .../jdbc/JdbcDriverLoadingUnitTest.java | 2 +- .../{ => spring}/jdbc/JdbcLiveTest.java | 2 +- .../{ => spring}/jdbc/ResultSetLiveTest.java | 2 +- .../joins/ArticleWithAuthorDAOLiveTest.java | 2 +- persistence-modules/pom.xml | 3 +- .../baeldung/spring/data/jpa/query}/User.java | 39 +- .../data/jpa/query}/UserRepository.java | 80 +-- .../data/jpa/query}/UserRepositoryCustom.java | 4 +- .../spring-data-jpa-repo-2/pom.xml | 47 ++ .../data/persistence/repository}/Foo.java | 17 +- .../persistence/repository/FooService.java | 15 + .../data/persistence/repository/IFooDAO.java} | 6 +- .../persistence/repository/IFooService.java | 5 + .../repository}/PersistenceConfig.java | 15 +- .../src/main/resources/application.properties | 3 + .../src/main/resources/persistence.properties | 9 + .../src/main/resources/springDataConfig.xml} | 6 +- .../repository/FooServiceIntegrationTest.java | 21 + persistence-modules/spring-jdbc/pom.xml | 41 ++ .../jdbc/CustomSQLErrorCodeTranslator.java | 2 +- .../com/baeldung/spring}/jdbc/Employee.java | 2 +- .../baeldung/spring}/jdbc/EmployeeDAO.java | 2 +- .../spring}/jdbc/EmployeeRowMapper.java | 2 +- .../spring}/jdbc/config/SpringJdbcConfig.java | 10 +- .../src/main/resources/application.properties | 3 + .../src/main/resources/jdbc/schema.sql | 0 .../src/main/resources/jdbc/test-data.sql | 0 .../jdbc/EmployeeDAOIntegrationTest.java | 4 +- persistence-modules/spring-jpa-2/pom.xml | 35 ++ .../hibernate/bootstrap/BarHibernateDAO.java | 0 .../hibernate/bootstrap/HibernateConf.java | 2 +- .../hibernate/bootstrap/HibernateXMLConf.java | 0 .../hibernate/bootstrap/model/TestEntity.java | 0 .../dao/generics}/AbstractHibernateDao.java | 24 +- .../spring/dao/generics}/AbstractJpaDAO.java | 4 +- .../baeldung/spring/dao/generics}/Foo.java | 19 +- .../spring/dao/generics/FooService.java | 21 + .../dao/generics}/GenericHibernateDao.java | 6 +- .../spring/dao/generics}/GenericJpaDao.java | 6 +- .../spring/dao/generics/IFooService.java | 5 + .../spring/dao/generics/IGenericDao.java} | 6 +- .../hibernate/AbstractHibernateDao.java | 56 ++ .../com/baeldung/spring/hibernate/Foo.java | 42 ++ .../baeldung/spring/hibernate}/FooDao.java | 8 +- .../baeldung/spring/hibernate}/IFooDao.java | 8 +- .../jpa/guide}/PersistenceJPAConfig.java | 14 +- .../spring/transaction/FooService.java | 8 + .../src/main/resources/application.properties | 11 + .../resources/hibernate5Configuration.xml | 0 .../main/resources/persistence-h2.properties | 0 .../resources/persistence-jpa-config.xml} | 3 - .../resources/persistence-mysql.properties | 0 .../HibernateBootstrapIntegrationTest.java | 0 .../HibernateXMLBootstrapIntegrationTest.java | 0 .../autogenkey/config/PersistenceConfig.java | 2 +- .../MessageRepositoryJDBCTemplate.java | 2 +- .../MessageRepositorySimpleJDBCInsert.java | 2 +- .../jdbc/autogenkey/GetAutoGenKeyByJDBC.java | 8 +- .../baeldung/{ => spring}/jdbc/Employee.java | 2 +- .../{ => spring}/jdbc/EmployeeDAO.java | 2 +- .../jdbc/EmployeeDAOUnitTest.java | 2 +- .../spring-persistence-simple/.gitignore | 13 - .../spring-persistence-simple/README.md | 25 - .../spring-persistence-simple/pom.xml | 152 ----- .../baeldung/config/PersistenceConfig.java | 110 ---- .../java/com/baeldung/jpa/dao/FooDao.java | 17 - .../persistence/dao/common/AbstractDao.java | 14 - .../persistence/dao/common/IGenericDao.java | 7 - .../com/baeldung/persistence/model/Bar.java | 102 ---- .../persistence/service/FooService.java | 36 -- .../data/persistence/model/Possession.java | 86 --- .../repository/UserRepositoryCustomImpl.java | 52 -- .../data/persistence/service/IFooService.java | 11 - .../service/common/AbstractService.java | 56 -- .../persistence/service/impl/FooService.java | 38 -- .../main/java/com/baeldung/util/IDUtil.java | 33 -- .../src/main/resources/hibernate5Config.xml | 34 -- .../main/resources/jdbc/springJdbc-config.xml | 19 - .../src/main/resources/logback.xml | 19 - .../src/main/resources/stored_procedure.sql | 20 - ...oPaginationPersistenceIntegrationTest.java | 157 ----- .../FooServicePersistenceIntegrationTest.java | 69 --- .../FooServiceSortingIntegrationTest.java | 118 ---- ...eSortingWitNullsManualIntegrationTest.java | 64 -- .../service/FooStoredProceduresLiveTest.java | 123 ---- .../FooTransactionalUnitTest.java | 250 -------- .../PersistenceTransactionalTestConfig.java | 149 ----- .../repository/UserRepositoryCommon.java | 555 ------------------ .../UserRepositoryIntegrationTest.java | 35 -- ...ractServicePersistenceIntegrationTest.java | 256 -------- .../FooServicePersistenceIntegrationTest.java | 77 --- .../src/test/resources/.gitignore | 13 - 97 files changed, 436 insertions(+), 2926 deletions(-) rename persistence-modules/core-java-persistence/src/main/java/com/baeldung/{ => spring}/jdbc/BatchProcessing.java (99%) rename persistence-modules/core-java-persistence/src/main/java/com/baeldung/{ => spring}/jdbc/Employee.java (97%) rename persistence-modules/core-java-persistence/src/main/java/com/baeldung/{ => spring}/jdbc/joins/ArticleWithAuthor.java (96%) rename persistence-modules/core-java-persistence/src/main/java/com/baeldung/{ => spring}/jdbc/joins/ArticleWithAuthorDAO.java (98%) rename persistence-modules/core-java-persistence/src/test/java/com/baeldung/{ => spring}/jdbc/BatchProcessingLiveTest.java (98%) rename persistence-modules/core-java-persistence/src/test/java/com/baeldung/{ => spring}/jdbc/JdbcDriverLoadingUnitTest.java (98%) rename persistence-modules/core-java-persistence/src/test/java/com/baeldung/{ => spring}/jdbc/JdbcLiveTest.java (99%) rename persistence-modules/core-java-persistence/src/test/java/com/baeldung/{ => spring}/jdbc/ResultSetLiveTest.java (99%) rename persistence-modules/core-java-persistence/src/test/java/com/baeldung/{ => spring}/jdbc/joins/ArticleWithAuthorDAOLiveTest.java (99%) rename persistence-modules/{spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/model => spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query}/User.java (89%) rename persistence-modules/{spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository => spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query}/UserRepository.java (65%) rename persistence-modules/{spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository => spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query}/UserRepositoryCustom.java (72%) create mode 100644 persistence-modules/spring-data-jpa-repo-2/pom.xml rename persistence-modules/{spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/model => spring-data-jpa-repo-2/src/main/java/com/baeldung/spring/data/persistence/repository}/Foo.java (85%) create mode 100644 persistence-modules/spring-data-jpa-repo-2/src/main/java/com/baeldung/spring/data/persistence/repository/FooService.java rename persistence-modules/{spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/IFooDao.java => spring-data-jpa-repo-2/src/main/java/com/baeldung/spring/data/persistence/repository/IFooDAO.java} (75%) create mode 100644 persistence-modules/spring-data-jpa-repo-2/src/main/java/com/baeldung/spring/data/persistence/repository/IFooService.java rename persistence-modules/{spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/config => spring-data-jpa-repo-2/src/main/java/com/baeldung/spring/data/persistence/repository}/PersistenceConfig.java (90%) create mode 100644 persistence-modules/spring-data-jpa-repo-2/src/main/resources/application.properties create mode 100644 persistence-modules/spring-data-jpa-repo-2/src/main/resources/persistence.properties rename persistence-modules/{spring-persistence-simple/src/main/resources/springDataJpaRepositoriesConfig.xml => spring-data-jpa-repo-2/src/main/resources/springDataConfig.xml} (82%) create mode 100644 persistence-modules/spring-data-jpa-repo-2/src/test/java/com/baeldung/spring/data/persistence/repository/FooServiceIntegrationTest.java create mode 100644 persistence-modules/spring-jdbc/pom.xml rename persistence-modules/{spring-persistence-simple/src/main/java/com/baeldung => spring-jdbc/src/main/java/com/baeldung/spring}/jdbc/CustomSQLErrorCodeTranslator.java (95%) rename persistence-modules/{spring-persistence-simple/src/main/java/com/baeldung => spring-jdbc/src/main/java/com/baeldung/spring}/jdbc/Employee.java (95%) rename persistence-modules/{spring-persistence-simple/src/main/java/com/baeldung => spring-jdbc/src/main/java/com/baeldung/spring}/jdbc/EmployeeDAO.java (99%) rename persistence-modules/{spring-persistence-simple/src/main/java/com/baeldung => spring-jdbc/src/main/java/com/baeldung/spring}/jdbc/EmployeeRowMapper.java (94%) rename persistence-modules/{spring-persistence-simple/src/main/java/com/baeldung => spring-jdbc/src/main/java/com/baeldung/spring}/jdbc/config/SpringJdbcConfig.java (75%) create mode 100644 persistence-modules/spring-jdbc/src/main/resources/application.properties rename persistence-modules/{spring-persistence-simple => spring-jdbc}/src/main/resources/jdbc/schema.sql (100%) rename persistence-modules/{spring-persistence-simple => spring-jdbc}/src/main/resources/jdbc/test-data.sql (100%) rename persistence-modules/{spring-persistence-simple/src/test/java/com/baeldung => spring-jdbc/src/test/java/com/baeldung/spring}/jdbc/EmployeeDAOIntegrationTest.java (97%) rename persistence-modules/{spring-persistence-simple => spring-jpa-2}/src/main/java/com/baeldung/hibernate/bootstrap/BarHibernateDAO.java (100%) rename persistence-modules/{spring-persistence-simple => spring-jpa-2}/src/main/java/com/baeldung/hibernate/bootstrap/HibernateConf.java (97%) rename persistence-modules/{spring-persistence-simple => spring-jpa-2}/src/main/java/com/baeldung/hibernate/bootstrap/HibernateXMLConf.java (100%) rename persistence-modules/{spring-persistence-simple => spring-jpa-2}/src/main/java/com/baeldung/hibernate/bootstrap/model/TestEntity.java (100%) rename persistence-modules/{spring-persistence-simple/src/main/java/com/baeldung/persistence/dao/common => spring-jpa-2/src/main/java/com/baeldung/spring/dao/generics}/AbstractHibernateDao.java (87%) rename persistence-modules/{spring-persistence-simple/src/main/java/com/baeldung/jpa/dao => spring-jpa-2/src/main/java/com/baeldung/spring/dao/generics}/AbstractJpaDAO.java (96%) rename persistence-modules/{spring-persistence-simple/src/main/java/com/baeldung/persistence/model => spring-jpa-2/src/main/java/com/baeldung/spring/dao/generics}/Foo.java (82%) create mode 100644 persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/dao/generics/FooService.java rename persistence-modules/{spring-persistence-simple/src/main/java/com/baeldung/persistence/dao/common => spring-jpa-2/src/main/java/com/baeldung/spring/dao/generics}/GenericHibernateDao.java (89%) rename persistence-modules/{spring-persistence-simple/src/main/java/com/baeldung/persistence/dao/common => spring-jpa-2/src/main/java/com/baeldung/spring/dao/generics}/GenericJpaDao.java (80%) create mode 100644 persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/dao/generics/IFooService.java rename persistence-modules/{spring-persistence-simple/src/main/java/com/baeldung/persistence/dao/common/IOperations.java => spring-jpa-2/src/main/java/com/baeldung/spring/dao/generics/IGenericDao.java} (64%) create mode 100644 persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/hibernate/AbstractHibernateDao.java create mode 100644 persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/hibernate/Foo.java rename persistence-modules/{spring-persistence-simple/src/main/java/com/baeldung/hibernate/dao => spring-jpa-2/src/main/java/com/baeldung/spring/hibernate}/FooDao.java (55%) rename persistence-modules/{spring-persistence-simple/src/main/java/com/baeldung/jpa/dao => spring-jpa-2/src/main/java/com/baeldung/spring/hibernate}/IFooDao.java (65%) rename persistence-modules/{spring-persistence-simple/src/main/java/com/baeldung/config => spring-jpa-2/src/main/java/com/baeldung/spring/jpa/guide}/PersistenceJPAConfig.java (91%) create mode 100644 persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/transaction/FooService.java create mode 100644 persistence-modules/spring-jpa-2/src/main/resources/application.properties rename persistence-modules/{spring-persistence-simple => spring-jpa-2}/src/main/resources/hibernate5Configuration.xml (100%) rename persistence-modules/{spring-persistence-simple => spring-jpa-2}/src/main/resources/persistence-h2.properties (100%) rename persistence-modules/{spring-persistence-simple/src/main/resources/persistence.xml => spring-jpa-2/src/main/resources/persistence-jpa-config.xml} (89%) rename persistence-modules/{spring-persistence-simple => spring-jpa-2}/src/main/resources/persistence-mysql.properties (100%) rename persistence-modules/{spring-persistence-simple => spring-jpa-2}/src/test/java/com/baeldung/hibernate/bootstrap/HibernateBootstrapIntegrationTest.java (100%) rename persistence-modules/{spring-persistence-simple => spring-jpa-2}/src/test/java/com/baeldung/hibernate/bootstrap/HibernateXMLBootstrapIntegrationTest.java (100%) rename persistence-modules/spring-jpa/src/main/java/com/baeldung/{ => spring}/jdbc/autogenkey/config/PersistenceConfig.java (94%) rename persistence-modules/spring-jpa/src/main/java/com/baeldung/{ => spring}/jdbc/autogenkey/repository/MessageRepositoryJDBCTemplate.java (92%) rename persistence-modules/spring-jpa/src/main/java/com/baeldung/{ => spring}/jdbc/autogenkey/repository/MessageRepositorySimpleJDBCInsert.java (90%) rename persistence-modules/spring-jpa/src/test/java/com/baeldung/{ => spring}/jdbc/autogenkey/GetAutoGenKeyByJDBC.java (79%) rename persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/{ => spring}/jdbc/Employee.java (95%) rename persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/{ => spring}/jdbc/EmployeeDAO.java (98%) rename persistence-modules/spring-persistence-simple-2/src/test/java/com/baeldung/{ => spring}/jdbc/EmployeeDAOUnitTest.java (99%) delete mode 100644 persistence-modules/spring-persistence-simple/.gitignore delete mode 100644 persistence-modules/spring-persistence-simple/README.md delete mode 100644 persistence-modules/spring-persistence-simple/pom.xml delete mode 100644 persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceConfig.java delete mode 100644 persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/jpa/dao/FooDao.java delete mode 100644 persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/persistence/dao/common/AbstractDao.java delete mode 100644 persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/persistence/dao/common/IGenericDao.java delete mode 100644 persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/persistence/model/Bar.java delete mode 100644 persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/persistence/service/FooService.java delete mode 100644 persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/model/Possession.java delete mode 100644 persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/UserRepositoryCustomImpl.java delete mode 100644 persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/service/IFooService.java delete mode 100644 persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/service/common/AbstractService.java delete mode 100644 persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/service/impl/FooService.java delete mode 100644 persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/util/IDUtil.java delete mode 100644 persistence-modules/spring-persistence-simple/src/main/resources/hibernate5Config.xml delete mode 100644 persistence-modules/spring-persistence-simple/src/main/resources/jdbc/springJdbc-config.xml delete mode 100644 persistence-modules/spring-persistence-simple/src/main/resources/logback.xml delete mode 100644 persistence-modules/spring-persistence-simple/src/main/resources/stored_procedure.sql delete mode 100644 persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/FooPaginationPersistenceIntegrationTest.java delete mode 100644 persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java delete mode 100644 persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/FooServiceSortingIntegrationTest.java delete mode 100644 persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/FooServiceSortingWitNullsManualIntegrationTest.java delete mode 100644 persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/FooStoredProceduresLiveTest.java delete mode 100644 persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/transactional/FooTransactionalUnitTest.java delete mode 100644 persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/transactional/PersistenceTransactionalTestConfig.java delete mode 100644 persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/repository/UserRepositoryCommon.java delete mode 100644 persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/repository/UserRepositoryIntegrationTest.java delete mode 100644 persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/service/AbstractServicePersistenceIntegrationTest.java delete mode 100644 persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/service/FooServicePersistenceIntegrationTest.java delete mode 100644 persistence-modules/spring-persistence-simple/src/test/resources/.gitignore diff --git a/persistence-modules/core-java-persistence/src/main/java/com/baeldung/jdbc/BatchProcessing.java b/persistence-modules/core-java-persistence/src/main/java/com/baeldung/spring/jdbc/BatchProcessing.java similarity index 99% rename from persistence-modules/core-java-persistence/src/main/java/com/baeldung/jdbc/BatchProcessing.java rename to persistence-modules/core-java-persistence/src/main/java/com/baeldung/spring/jdbc/BatchProcessing.java index ad6a064c98..51b27ef5f4 100644 --- a/persistence-modules/core-java-persistence/src/main/java/com/baeldung/jdbc/BatchProcessing.java +++ b/persistence-modules/core-java-persistence/src/main/java/com/baeldung/spring/jdbc/BatchProcessing.java @@ -1,4 +1,4 @@ -package com.baeldung.jdbc; +package com.baeldung.spring.jdbc; import java.sql.*; import java.util.UUID; diff --git a/persistence-modules/core-java-persistence/src/main/java/com/baeldung/jdbc/Employee.java b/persistence-modules/core-java-persistence/src/main/java/com/baeldung/spring/jdbc/Employee.java similarity index 97% rename from persistence-modules/core-java-persistence/src/main/java/com/baeldung/jdbc/Employee.java rename to persistence-modules/core-java-persistence/src/main/java/com/baeldung/spring/jdbc/Employee.java index 27aef8b82f..99e5a1ad4a 100644 --- a/persistence-modules/core-java-persistence/src/main/java/com/baeldung/jdbc/Employee.java +++ b/persistence-modules/core-java-persistence/src/main/java/com/baeldung/spring/jdbc/Employee.java @@ -1,4 +1,4 @@ -package com.baeldung.jdbc; +package com.baeldung.spring.jdbc; import java.util.Objects; 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/spring/jdbc/joins/ArticleWithAuthor.java similarity index 96% rename from persistence-modules/core-java-persistence/src/main/java/com/baeldung/jdbc/joins/ArticleWithAuthor.java rename to persistence-modules/core-java-persistence/src/main/java/com/baeldung/spring/jdbc/joins/ArticleWithAuthor.java index 5ce196ee47..bbcbb5871e 100644 --- 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/spring/jdbc/joins/ArticleWithAuthor.java @@ -1,4 +1,4 @@ -package com.baeldung.jdbc.joins; +package com.baeldung.spring.jdbc.joins; class ArticleWithAuthor { 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/spring/jdbc/joins/ArticleWithAuthorDAO.java similarity index 98% rename from persistence-modules/core-java-persistence/src/main/java/com/baeldung/jdbc/joins/ArticleWithAuthorDAO.java rename to persistence-modules/core-java-persistence/src/main/java/com/baeldung/spring/jdbc/joins/ArticleWithAuthorDAO.java index 55f03d99ec..48961b786f 100644 --- 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/spring/jdbc/joins/ArticleWithAuthorDAO.java @@ -1,4 +1,4 @@ -package com.baeldung.jdbc.joins; +package com.baeldung.spring.jdbc.joins; import java.sql.Connection; import java.sql.ResultSet; diff --git a/persistence-modules/core-java-persistence/src/test/java/com/baeldung/jdbc/BatchProcessingLiveTest.java b/persistence-modules/core-java-persistence/src/test/java/com/baeldung/spring/jdbc/BatchProcessingLiveTest.java similarity index 98% rename from persistence-modules/core-java-persistence/src/test/java/com/baeldung/jdbc/BatchProcessingLiveTest.java rename to persistence-modules/core-java-persistence/src/test/java/com/baeldung/spring/jdbc/BatchProcessingLiveTest.java index c905482f55..3cb5e779f5 100644 --- a/persistence-modules/core-java-persistence/src/test/java/com/baeldung/jdbc/BatchProcessingLiveTest.java +++ b/persistence-modules/core-java-persistence/src/test/java/com/baeldung/spring/jdbc/BatchProcessingLiveTest.java @@ -1,4 +1,4 @@ -package com.baeldung.jdbc; +package com.baeldung.spring.jdbc; import org.junit.Before; diff --git a/persistence-modules/core-java-persistence/src/test/java/com/baeldung/jdbc/JdbcDriverLoadingUnitTest.java b/persistence-modules/core-java-persistence/src/test/java/com/baeldung/spring/jdbc/JdbcDriverLoadingUnitTest.java similarity index 98% rename from persistence-modules/core-java-persistence/src/test/java/com/baeldung/jdbc/JdbcDriverLoadingUnitTest.java rename to persistence-modules/core-java-persistence/src/test/java/com/baeldung/spring/jdbc/JdbcDriverLoadingUnitTest.java index 387c050285..937cf1b833 100644 --- a/persistence-modules/core-java-persistence/src/test/java/com/baeldung/jdbc/JdbcDriverLoadingUnitTest.java +++ b/persistence-modules/core-java-persistence/src/test/java/com/baeldung/spring/jdbc/JdbcDriverLoadingUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.jdbc; +package com.baeldung.spring.jdbc; import static org.junit.Assert.*; diff --git a/persistence-modules/core-java-persistence/src/test/java/com/baeldung/jdbc/JdbcLiveTest.java b/persistence-modules/core-java-persistence/src/test/java/com/baeldung/spring/jdbc/JdbcLiveTest.java similarity index 99% rename from persistence-modules/core-java-persistence/src/test/java/com/baeldung/jdbc/JdbcLiveTest.java rename to persistence-modules/core-java-persistence/src/test/java/com/baeldung/spring/jdbc/JdbcLiveTest.java index 81179aade9..c13f94f12a 100644 --- a/persistence-modules/core-java-persistence/src/test/java/com/baeldung/jdbc/JdbcLiveTest.java +++ b/persistence-modules/core-java-persistence/src/test/java/com/baeldung/spring/jdbc/JdbcLiveTest.java @@ -1,4 +1,4 @@ -package com.baeldung.jdbc; +package com.baeldung.spring.jdbc; import org.apache.log4j.Logger; import org.junit.After; diff --git a/persistence-modules/core-java-persistence/src/test/java/com/baeldung/jdbc/ResultSetLiveTest.java b/persistence-modules/core-java-persistence/src/test/java/com/baeldung/spring/jdbc/ResultSetLiveTest.java similarity index 99% rename from persistence-modules/core-java-persistence/src/test/java/com/baeldung/jdbc/ResultSetLiveTest.java rename to persistence-modules/core-java-persistence/src/test/java/com/baeldung/spring/jdbc/ResultSetLiveTest.java index 4e10f8bd43..853e78a68d 100644 --- a/persistence-modules/core-java-persistence/src/test/java/com/baeldung/jdbc/ResultSetLiveTest.java +++ b/persistence-modules/core-java-persistence/src/test/java/com/baeldung/spring/jdbc/ResultSetLiveTest.java @@ -1,4 +1,4 @@ -package com.baeldung.jdbc; +package com.baeldung.spring.jdbc; import static org.junit.Assert.assertEquals; diff --git a/persistence-modules/core-java-persistence/src/test/java/com/baeldung/jdbc/joins/ArticleWithAuthorDAOLiveTest.java b/persistence-modules/core-java-persistence/src/test/java/com/baeldung/spring/jdbc/joins/ArticleWithAuthorDAOLiveTest.java similarity index 99% rename from persistence-modules/core-java-persistence/src/test/java/com/baeldung/jdbc/joins/ArticleWithAuthorDAOLiveTest.java rename to persistence-modules/core-java-persistence/src/test/java/com/baeldung/spring/jdbc/joins/ArticleWithAuthorDAOLiveTest.java index 3f69a0e333..055c7ed9ed 100644 --- a/persistence-modules/core-java-persistence/src/test/java/com/baeldung/jdbc/joins/ArticleWithAuthorDAOLiveTest.java +++ b/persistence-modules/core-java-persistence/src/test/java/com/baeldung/spring/jdbc/joins/ArticleWithAuthorDAOLiveTest.java @@ -1,4 +1,4 @@ -package com.baeldung.jdbc.joins; +package com.baeldung.spring.jdbc.joins; import org.junit.After; import org.junit.Before; diff --git a/persistence-modules/pom.xml b/persistence-modules/pom.xml index 468d50b458..1a5ca8df70 100644 --- a/persistence-modules/pom.xml +++ b/persistence-modules/pom.xml @@ -70,6 +70,7 @@ spring-data-jpa-query spring-data-jpa-query-2 spring-data-jpa-repo + spring-data-jpa-repo-2 spring-data-jdbc @@ -83,8 +84,8 @@ spring-hibernate4 spring-jpa spring-jpa-2 + spring-jdbc - spring-persistence-simple spring-persistence-simple-2 diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/model/User.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/User.java similarity index 89% rename from persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/model/User.java rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/User.java index 1475eccbf0..179dbf2ae7 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/model/User.java +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/User.java @@ -1,4 +1,4 @@ -package com.baeldung.spring.data.persistence.model; +package com.baeldung.spring.data.jpa.query; import javax.persistence.*; import java.time.LocalDate; @@ -8,7 +8,6 @@ import java.util.Objects; @Entity @Table(name = "users") public class User { - @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; @@ -28,9 +27,6 @@ public class User { private Integer status; - @OneToMany - List possessionList; - public User() { super(); } @@ -87,12 +83,20 @@ public class User { return creationDate; } - public List getPossessionList() { - return possessionList; + public LocalDate getLastLoginDate() { + return lastLoginDate; } - public void setPossessionList(List possessionList) { - this.possessionList = possessionList; + public void setLastLoginDate(LocalDate lastLoginDate) { + this.lastLoginDate = lastLoginDate; + } + + public boolean isActive() { + return active; + } + + public void setActive(boolean active) { + this.active = active; } @Override @@ -119,21 +123,4 @@ public class User { public int hashCode() { return Objects.hash(id, name, creationDate, age, email, status); } - - public LocalDate getLastLoginDate() { - return lastLoginDate; - } - - public void setLastLoginDate(LocalDate lastLoginDate) { - this.lastLoginDate = lastLoginDate; - } - - public boolean isActive() { - return active; - } - - public void setActive(boolean active) { - this.active = active; - } - } \ No newline at end of file diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/UserRepository.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/UserRepository.java similarity index 65% rename from persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/UserRepository.java rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/UserRepository.java index a8e3a536c3..6547e0ef66 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/UserRepository.java +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/UserRepository.java @@ -1,6 +1,5 @@ -package com.baeldung.spring.data.persistence.repository; +package com.baeldung.spring.data.jpa.query; -import com.baeldung.spring.data.persistence.model.User; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; @@ -9,51 +8,16 @@ import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import java.time.LocalDate; 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("select u from User u where u.email like '%@gmail.com'") - List findUsersWithGmailAddress(); - @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); @@ -63,6 +27,27 @@ public interface UserRepository extends JpaRepository, UserReposi @Query(value = "SELECT * FROM Users ORDER BY id", countQuery = "SELECT count(*) FROM Users", nativeQuery = true) Page findAllUsersWithPaginationNative(Pageable pageable); + @Query("SELECT u FROM User u WHERE u.status = ?1") + User findUserByStatus(Integer status); + + @Query("SELECT u FROM User u WHERE u.status = ?1 and u.name = ?2") + User findUserByStatusAndName(Integer status, String name); + + @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 = :status and u.name = :name") + User findUserByStatusAndNameNamedParams(@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(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(value = "SELECT u FROM User u WHERE u.name IN :names") + List findUserByNameList(@Param("names") Collection names); + @Modifying @Query("update User u set u.status = :status where u.name = :name") int updateUserSetStatusForName(@Param("status") Integer status, @Param("name") String name); @@ -74,25 +59,4 @@ public interface UserRepository extends JpaRepository, UserReposi @Query(value = "INSERT INTO Users (name, age, email, status, active) VALUES (:name, :age, :email, :status, :active)", nativeQuery = true) @Modifying void insertUser(@Param("name") String name, @Param("age") Integer age, @Param("email") String email, @Param("status") Integer status, @Param("active") boolean active); - - @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); - - void deleteAllByCreationDateAfter(LocalDate date); - - @Modifying(clearAutomatically = true, flushAutomatically = true) - @Query("update User u set u.active = false where u.lastLoginDate < :date") - void deactivateUsersNotLoggedInSince(@Param("date") LocalDate date); - - @Modifying(clearAutomatically = true, flushAutomatically = true) - @Query("delete User u where u.active = false") - int deleteDeactivatedUsers(); - - @Modifying(clearAutomatically = true, flushAutomatically = true) - @Query(value = "alter table USERS add column deleted int(1) not null default 0", nativeQuery = true) - void addDeletedColumn(); } diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/UserRepositoryCustom.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/UserRepositoryCustom.java similarity index 72% rename from persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/UserRepositoryCustom.java rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/UserRepositoryCustom.java index 77e661bbbe..a3e53528f7 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/UserRepositoryCustom.java +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/UserRepositoryCustom.java @@ -1,6 +1,4 @@ -package com.baeldung.spring.data.persistence.repository; - -import com.baeldung.spring.data.persistence.model.User; +package com.baeldung.spring.data.jpa.query; import java.util.Collection; import java.util.List; diff --git a/persistence-modules/spring-data-jpa-repo-2/pom.xml b/persistence-modules/spring-data-jpa-repo-2/pom.xml new file mode 100644 index 0000000000..855b441074 --- /dev/null +++ b/persistence-modules/spring-data-jpa-repo-2/pom.xml @@ -0,0 +1,47 @@ + + + 4.0.0 + + + com.baeldung + parent-boot-2 + 0.0.1-SNAPSHOT + ../../parent-boot-2 + + + spring-data-jpa-repo-2 + spring-data-jpa-repo-2 + + + + + javax.persistence + javax.persistence-api + + + org.springframework.data + spring-data-jpa + + + org.springframework.boot + spring-boot-starter-data-jpa + + + com.h2database + h2 + + + + + com.google.guava + guava + ${guava.version} + + + + + 29.0-jre + + \ No newline at end of file diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/model/Foo.java b/persistence-modules/spring-data-jpa-repo-2/src/main/java/com/baeldung/spring/data/persistence/repository/Foo.java similarity index 85% rename from persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/model/Foo.java rename to persistence-modules/spring-data-jpa-repo-2/src/main/java/com/baeldung/spring/data/persistence/repository/Foo.java index 64bfe203d0..6833c4c556 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/model/Foo.java +++ b/persistence-modules/spring-data-jpa-repo-2/src/main/java/com/baeldung/spring/data/persistence/repository/Foo.java @@ -1,16 +1,10 @@ -package com.baeldung.spring.data.persistence.model; +package com.baeldung.spring.data.persistence.repository; +import javax.persistence.*; import java.io.Serializable; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; - @Entity public class Foo implements Serializable { - @Id @GeneratedValue(strategy = GenerationType.AUTO) private long id; @@ -28,8 +22,6 @@ public class Foo implements Serializable { this.name = name; } - // API - public long getId() { return id; } @@ -46,8 +38,6 @@ public class Foo implements Serializable { this.name = name; } - // - @Override public int hashCode() { final int prime = 31; @@ -79,5 +69,4 @@ public class Foo implements Serializable { builder.append("Foo [name=").append(name).append("]"); return builder.toString(); } - -} +} \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-repo-2/src/main/java/com/baeldung/spring/data/persistence/repository/FooService.java b/persistence-modules/spring-data-jpa-repo-2/src/main/java/com/baeldung/spring/data/persistence/repository/FooService.java new file mode 100644 index 0000000000..cb09a92b82 --- /dev/null +++ b/persistence-modules/spring-data-jpa-repo-2/src/main/java/com/baeldung/spring/data/persistence/repository/FooService.java @@ -0,0 +1,15 @@ +package com.baeldung.spring.data.persistence.repository; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class FooService implements IFooService { + @Autowired + private IFooDAO dao; + + @Override + public Foo create(Foo foo) { + return dao.save(foo); + } +} diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/IFooDao.java b/persistence-modules/spring-data-jpa-repo-2/src/main/java/com/baeldung/spring/data/persistence/repository/IFooDAO.java similarity index 75% rename from persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/IFooDao.java rename to persistence-modules/spring-data-jpa-repo-2/src/main/java/com/baeldung/spring/data/persistence/repository/IFooDAO.java index 0b750e37e1..20a81e7bfa 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/IFooDao.java +++ b/persistence-modules/spring-data-jpa-repo-2/src/main/java/com/baeldung/spring/data/persistence/repository/IFooDAO.java @@ -1,13 +1,13 @@ package com.baeldung.spring.data.persistence.repository; -import com.baeldung.spring.data.persistence.model.Foo; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -public interface IFooDao extends JpaRepository { +public interface IFooDAO extends JpaRepository { + + Foo findByName(String name); @Query("SELECT f FROM Foo f WHERE LOWER(f.name) = LOWER(:name)") Foo retrieveByName(@Param("name") String name); - } diff --git a/persistence-modules/spring-data-jpa-repo-2/src/main/java/com/baeldung/spring/data/persistence/repository/IFooService.java b/persistence-modules/spring-data-jpa-repo-2/src/main/java/com/baeldung/spring/data/persistence/repository/IFooService.java new file mode 100644 index 0000000000..8ce6a2d1ae --- /dev/null +++ b/persistence-modules/spring-data-jpa-repo-2/src/main/java/com/baeldung/spring/data/persistence/repository/IFooService.java @@ -0,0 +1,5 @@ +package com.baeldung.spring.data.persistence.repository; + +public interface IFooService { + Foo create(Foo foo); +} \ No newline at end of file diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/config/PersistenceConfig.java b/persistence-modules/spring-data-jpa-repo-2/src/main/java/com/baeldung/spring/data/persistence/repository/PersistenceConfig.java similarity index 90% rename from persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/config/PersistenceConfig.java rename to persistence-modules/spring-data-jpa-repo-2/src/main/java/com/baeldung/spring/data/persistence/repository/PersistenceConfig.java index 604923d615..f73ea94658 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/config/PersistenceConfig.java +++ b/persistence-modules/spring-data-jpa-repo-2/src/main/java/com/baeldung/spring/data/persistence/repository/PersistenceConfig.java @@ -1,4 +1,4 @@ -package com.baeldung.spring.data.persistence.config; +package com.baeldung.spring.data.persistence.repository; import com.google.common.base.Preconditions; import org.springframework.beans.factory.annotation.Autowired; @@ -20,11 +20,11 @@ import javax.sql.DataSource; import java.util.Properties; @Configuration +@PropertySource("classpath:persistence.properties") +@ComponentScan("com.baeldung.spring.data.persistence.repository") +//@ImportResource("classpath*:*springDataConfig.xml") @EnableTransactionManagement -@PropertySource({ "classpath:persistence-${envTarget:h2}.properties" }) -@ComponentScan({ "com.baeldung.spring.data.persistence" }) -//@ImportResource("classpath*:*springDataJpaRepositoriesConfig.xml") -@EnableJpaRepositories("com.baeldung.spring.data.persistence.repository") +@EnableJpaRepositories(basePackages = "com.baeldung.spring.data.persistence.repository") public class PersistenceConfig { @Autowired @@ -38,7 +38,7 @@ public class PersistenceConfig { public LocalContainerEntityManagerFactoryBean entityManagerFactory() { final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource()); - em.setPackagesToScan("com.baeldung.spring.data.persistence.model"); + em.setPackagesToScan("com.baeldung.spring.data.persistence.repository"); final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); em.setJpaVendorAdapter(vendorAdapter); @@ -78,5 +78,4 @@ public class PersistenceConfig { return hibernateProperties; } - -} \ No newline at end of file +} diff --git a/persistence-modules/spring-data-jpa-repo-2/src/main/resources/application.properties b/persistence-modules/spring-data-jpa-repo-2/src/main/resources/application.properties new file mode 100644 index 0000000000..cb1eab9443 --- /dev/null +++ b/persistence-modules/spring-data-jpa-repo-2/src/main/resources/application.properties @@ -0,0 +1,3 @@ +spring.datasource.url=jdbc:h2:mem:db;DB_CLOSE_DELAY=-1 +spring.datasource.username=sa +spring.datasource.password=sa \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-repo-2/src/main/resources/persistence.properties b/persistence-modules/spring-data-jpa-repo-2/src/main/resources/persistence.properties new file mode 100644 index 0000000000..339859a6e8 --- /dev/null +++ b/persistence-modules/spring-data-jpa-repo-2/src/main/resources/persistence.properties @@ -0,0 +1,9 @@ +# jdbc.X +jdbc.driverClassName=org.h2.Driver +jdbc.url=jdbc:h2:mem:db;DB_CLOSE_DELAY=-1 +jdbc.user=sa +jdbc.pass= + +# hibernate.X +hibernate.hbm2ddl.auto=create-drop +hibernate.dialect=org.hibernate.dialect.H2Dialect diff --git a/persistence-modules/spring-persistence-simple/src/main/resources/springDataJpaRepositoriesConfig.xml b/persistence-modules/spring-data-jpa-repo-2/src/main/resources/springDataConfig.xml similarity index 82% rename from persistence-modules/spring-persistence-simple/src/main/resources/springDataJpaRepositoriesConfig.xml rename to persistence-modules/spring-data-jpa-repo-2/src/main/resources/springDataConfig.xml index 91778a17af..b2616d9eae 100644 --- a/persistence-modules/spring-persistence-simple/src/main/resources/springDataJpaRepositoriesConfig.xml +++ b/persistence-modules/spring-data-jpa-repo-2/src/main/resources/springDataConfig.xml @@ -2,12 +2,10 @@ - - \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-repo-2/src/test/java/com/baeldung/spring/data/persistence/repository/FooServiceIntegrationTest.java b/persistence-modules/spring-data-jpa-repo-2/src/test/java/com/baeldung/spring/data/persistence/repository/FooServiceIntegrationTest.java new file mode 100644 index 0000000000..141844fa11 --- /dev/null +++ b/persistence-modules/spring-data-jpa-repo-2/src/test/java/com/baeldung/spring/data/persistence/repository/FooServiceIntegrationTest.java @@ -0,0 +1,21 @@ +package com.baeldung.spring.data.persistence.repository; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.dao.DataIntegrityViolationException; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@ContextConfiguration(classes = PersistenceConfig.class) +public class FooServiceIntegrationTest { + + @Autowired + private IFooService service; + + @Test(expected = DataIntegrityViolationException.class) + public final void whenInvalidEntityIsCreated_thenDataException() { + service.create(new Foo()); + } +} diff --git a/persistence-modules/spring-jdbc/pom.xml b/persistence-modules/spring-jdbc/pom.xml new file mode 100644 index 0000000000..4ac5239318 --- /dev/null +++ b/persistence-modules/spring-jdbc/pom.xml @@ -0,0 +1,41 @@ + + + 4.0.0 + + + com.baeldung + parent-boot-2 + 0.0.1-SNAPSHOT + ../../parent-boot-2 + + + spring-jdbc + spring-jdbc + + + + org.springframework.data + spring-data-jdbc + ${spring-data-jdbc.version} + + + org.springframework.boot + spring-boot-starter-jdbc + + + com.h2database + h2 + + + mysql + mysql-connector-java + runtime + + + + + 2.0.3.RELEASE + + \ No newline at end of file diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/jdbc/CustomSQLErrorCodeTranslator.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/CustomSQLErrorCodeTranslator.java similarity index 95% rename from persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/jdbc/CustomSQLErrorCodeTranslator.java rename to persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/CustomSQLErrorCodeTranslator.java index 48ddfb04b1..aa0ffde00c 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/jdbc/CustomSQLErrorCodeTranslator.java +++ b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/CustomSQLErrorCodeTranslator.java @@ -1,4 +1,4 @@ -package com.baeldung.jdbc; +package com.baeldung.spring.jdbc; import java.sql.SQLException; diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/jdbc/Employee.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/Employee.java similarity index 95% rename from persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/jdbc/Employee.java rename to persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/Employee.java index a43eb265c7..84780e30da 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/jdbc/Employee.java +++ b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/Employee.java @@ -1,4 +1,4 @@ -package com.baeldung.jdbc; +package com.baeldung.spring.jdbc; public class Employee { private int id; diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/jdbc/EmployeeDAO.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/EmployeeDAO.java similarity index 99% rename from persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/jdbc/EmployeeDAO.java rename to persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/EmployeeDAO.java index eef085f386..a6d0fe2f3b 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/jdbc/EmployeeDAO.java +++ b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/EmployeeDAO.java @@ -1,4 +1,4 @@ -package com.baeldung.jdbc; +package com.baeldung.spring.jdbc; import java.sql.PreparedStatement; import java.sql.SQLException; diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/jdbc/EmployeeRowMapper.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/EmployeeRowMapper.java similarity index 94% rename from persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/jdbc/EmployeeRowMapper.java rename to persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/EmployeeRowMapper.java index d09cd45dbc..bf55d6160d 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/jdbc/EmployeeRowMapper.java +++ b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/EmployeeRowMapper.java @@ -1,4 +1,4 @@ -package com.baeldung.jdbc; +package com.baeldung.spring.jdbc; import java.sql.ResultSet; import java.sql.SQLException; diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/jdbc/config/SpringJdbcConfig.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/config/SpringJdbcConfig.java similarity index 75% rename from persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/jdbc/config/SpringJdbcConfig.java rename to persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/config/SpringJdbcConfig.java index ddc24e439f..d7eb039637 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/jdbc/config/SpringJdbcConfig.java +++ b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/config/SpringJdbcConfig.java @@ -1,4 +1,4 @@ -package com.baeldung.jdbc.config; +package com.baeldung.spring.jdbc.config; import javax.sql.DataSource; @@ -10,12 +10,16 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; @Configuration -@ComponentScan("com.baeldung.jdbc") +@ComponentScan("com.baeldung.spring.jdbc") public class SpringJdbcConfig { @Bean public DataSource dataSource() { - return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2).addScript("classpath:jdbc/schema.sql").addScript("classpath:jdbc/test-data.sql").build(); + return new EmbeddedDatabaseBuilder() + .setType(EmbeddedDatabaseType.H2) + .addScript("classpath:jdbc/schema.sql") + .addScript("classpath:jdbc/test-data.sql") + .build(); } // @Bean diff --git a/persistence-modules/spring-jdbc/src/main/resources/application.properties b/persistence-modules/spring-jdbc/src/main/resources/application.properties new file mode 100644 index 0000000000..2f09a522ba --- /dev/null +++ b/persistence-modules/spring-jdbc/src/main/resources/application.properties @@ -0,0 +1,3 @@ +spring.datasource.url=jdbc:mysql://localhost:3306/springjdbc +spring.datasource.username=guest_user +spring.datasource.password=guest_password \ No newline at end of file diff --git a/persistence-modules/spring-persistence-simple/src/main/resources/jdbc/schema.sql b/persistence-modules/spring-jdbc/src/main/resources/jdbc/schema.sql similarity index 100% rename from persistence-modules/spring-persistence-simple/src/main/resources/jdbc/schema.sql rename to persistence-modules/spring-jdbc/src/main/resources/jdbc/schema.sql diff --git a/persistence-modules/spring-persistence-simple/src/main/resources/jdbc/test-data.sql b/persistence-modules/spring-jdbc/src/main/resources/jdbc/test-data.sql similarity index 100% rename from persistence-modules/spring-persistence-simple/src/main/resources/jdbc/test-data.sql rename to persistence-modules/spring-jdbc/src/main/resources/jdbc/test-data.sql diff --git a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/jdbc/EmployeeDAOIntegrationTest.java b/persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/EmployeeDAOIntegrationTest.java similarity index 97% rename from persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/jdbc/EmployeeDAOIntegrationTest.java rename to persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/EmployeeDAOIntegrationTest.java index 453656098a..10f47402be 100644 --- a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/jdbc/EmployeeDAOIntegrationTest.java +++ b/persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/EmployeeDAOIntegrationTest.java @@ -1,9 +1,9 @@ -package com.baeldung.jdbc; +package com.baeldung.spring.jdbc; import java.util.ArrayList; import java.util.List; -import com.baeldung.jdbc.config.SpringJdbcConfig; +import com.baeldung.spring.jdbc.config.SpringJdbcConfig; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/persistence-modules/spring-jpa-2/pom.xml b/persistence-modules/spring-jpa-2/pom.xml index 08a1f0c6a3..1c21f6b98d 100644 --- a/persistence-modules/spring-jpa-2/pom.xml +++ b/persistence-modules/spring-jpa-2/pom.xml @@ -15,6 +15,17 @@ + + org.springframework.boot + spring-boot-starter + ${spring-boot.version} + + + org.springframework.boot + spring-boot-starter-data-jpa + ${spring-boot.version} + + org.springframework spring-orm @@ -43,8 +54,25 @@ h2 ${h2.version} + + org.apache.tomcat + tomcat-dbcp + ${tomcat-dbcp.version} + + + + + com.google.guava + guava + ${guava.version} + + + org.springframework.boot + spring-boot-starter-test + ${spring-boot.version} + org.springframework spring-test @@ -57,6 +85,13 @@ 5.1.5.RELEASE + + + 9.0.0.M26 + + + 21.0 + 2.2.6.RELEASE \ No newline at end of file diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/hibernate/bootstrap/BarHibernateDAO.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/hibernate/bootstrap/BarHibernateDAO.java similarity index 100% rename from persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/hibernate/bootstrap/BarHibernateDAO.java rename to persistence-modules/spring-jpa-2/src/main/java/com/baeldung/hibernate/bootstrap/BarHibernateDAO.java diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/hibernate/bootstrap/HibernateConf.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/hibernate/bootstrap/HibernateConf.java similarity index 97% rename from persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/hibernate/bootstrap/HibernateConf.java rename to persistence-modules/spring-jpa-2/src/main/java/com/baeldung/hibernate/bootstrap/HibernateConf.java index 150e3778af..da23803d76 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/hibernate/bootstrap/HibernateConf.java +++ b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/hibernate/bootstrap/HibernateConf.java @@ -51,7 +51,7 @@ public class HibernateConf { return transactionManager; } - private final Properties hibernateProperties() { + private 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")); diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/hibernate/bootstrap/HibernateXMLConf.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/hibernate/bootstrap/HibernateXMLConf.java similarity index 100% rename from persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/hibernate/bootstrap/HibernateXMLConf.java rename to persistence-modules/spring-jpa-2/src/main/java/com/baeldung/hibernate/bootstrap/HibernateXMLConf.java diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/hibernate/bootstrap/model/TestEntity.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/hibernate/bootstrap/model/TestEntity.java similarity index 100% rename from persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/hibernate/bootstrap/model/TestEntity.java rename to persistence-modules/spring-jpa-2/src/main/java/com/baeldung/hibernate/bootstrap/model/TestEntity.java diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/persistence/dao/common/AbstractHibernateDao.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/dao/generics/AbstractHibernateDao.java similarity index 87% rename from persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/persistence/dao/common/AbstractHibernateDao.java rename to persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/dao/generics/AbstractHibernateDao.java index e406f896dc..bd78fe647d 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/persistence/dao/common/AbstractHibernateDao.java +++ b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/dao/generics/AbstractHibernateDao.java @@ -1,52 +1,49 @@ -package com.baeldung.persistence.dao.common; - -import java.io.Serializable; -import java.util.List; +package com.baeldung.spring.dao.generics; +import com.google.common.base.Preconditions; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.springframework.beans.factory.annotation.Autowired; -import com.google.common.base.Preconditions; +import java.io.Serializable; +import java.util.List; @SuppressWarnings("unchecked") -public abstract class AbstractHibernateDao extends AbstractDao implements IOperations { +public abstract class AbstractHibernateDao { + private Class clazz; @Autowired protected SessionFactory sessionFactory; - // API + public void setClazz(final Class clazzToSet) { + clazz = Preconditions.checkNotNull(clazzToSet); + } - @Override + // API public T findOne(final long id) { return (T) getCurrentSession().get(clazz, id); } - @Override public List findAll() { return getCurrentSession().createQuery("from " + clazz.getName()).list(); } - @Override public T create(final T entity) { Preconditions.checkNotNull(entity); getCurrentSession().saveOrUpdate(entity); return entity; } - @Override public T update(final T entity) { Preconditions.checkNotNull(entity); return (T) getCurrentSession().merge(entity); } - @Override public void delete(final T entity) { Preconditions.checkNotNull(entity); getCurrentSession().delete(entity); } - @Override public void deleteById(final long entityId) { final T entity = findOne(entityId); Preconditions.checkState(entity != null); @@ -56,5 +53,4 @@ public abstract class AbstractHibernateDao extends Abstr protected Session getCurrentSession() { return sessionFactory.getCurrentSession(); } - } \ No newline at end of file diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/jpa/dao/AbstractJpaDAO.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/dao/generics/AbstractJpaDAO.java similarity index 96% rename from persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/jpa/dao/AbstractJpaDAO.java rename to persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/dao/generics/AbstractJpaDAO.java index a6542c5cb1..e68a9281a0 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/jpa/dao/AbstractJpaDAO.java +++ b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/dao/generics/AbstractJpaDAO.java @@ -1,4 +1,4 @@ -package com.baeldung.jpa.dao; +package com.baeldung.spring.dao.generics; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; @@ -6,7 +6,6 @@ import java.io.Serializable; import java.util.List; public abstract class AbstractJpaDAO { - private Class clazz; @PersistenceContext(unitName = "entityManagerFactory") @@ -42,5 +41,4 @@ public abstract class AbstractJpaDAO { final T entity = findOne(entityId); delete(entity); } - } \ No newline at end of file diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/persistence/model/Foo.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/dao/generics/Foo.java similarity index 82% rename from persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/persistence/model/Foo.java rename to persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/dao/generics/Foo.java index 009876f8cb..7849abb25f 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/persistence/model/Foo.java +++ b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/dao/generics/Foo.java @@ -1,21 +1,10 @@ -package com.baeldung.persistence.model; - -import java.io.Serializable; - -import javax.persistence.Cacheable; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.NamedNativeQueries; -import javax.persistence.NamedNativeQuery; +package com.baeldung.spring.dao.generics; import org.hibernate.annotations.CacheConcurrencyStrategy; +import javax.persistence.*; +import java.io.Serializable; + @Entity @Cacheable @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE) diff --git a/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/dao/generics/FooService.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/dao/generics/FooService.java new file mode 100644 index 0000000000..4c2014c717 --- /dev/null +++ b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/dao/generics/FooService.java @@ -0,0 +1,21 @@ +package com.baeldung.spring.dao.generics; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class FooService implements IFooService { + + IGenericDao dao; + + @Autowired + public void setDao(IGenericDao daoToSet) { + dao = daoToSet; + dao.setClazz(Foo.class); + } + + @Override + public Foo retrieveByName(String name) { + return null; + } +} diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/persistence/dao/common/GenericHibernateDao.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/dao/generics/GenericHibernateDao.java similarity index 89% rename from persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/persistence/dao/common/GenericHibernateDao.java rename to persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/dao/generics/GenericHibernateDao.java index 18b16fa033..619a144176 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/persistence/dao/common/GenericHibernateDao.java +++ b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/dao/generics/GenericHibernateDao.java @@ -1,11 +1,11 @@ -package com.baeldung.persistence.dao.common; - -import java.io.Serializable; +package com.baeldung.spring.dao.generics; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Repository; +import java.io.Serializable; + @Repository @Scope(BeanDefinition.SCOPE_PROTOTYPE) public class GenericHibernateDao extends AbstractHibernateDao implements IGenericDao { diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/persistence/dao/common/GenericJpaDao.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/dao/generics/GenericJpaDao.java similarity index 80% rename from persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/persistence/dao/common/GenericJpaDao.java rename to persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/dao/generics/GenericJpaDao.java index d4da194f4d..cf89b05f96 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/persistence/dao/common/GenericJpaDao.java +++ b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/dao/generics/GenericJpaDao.java @@ -1,12 +1,10 @@ -package com.baeldung.persistence.dao.common; - -import java.io.Serializable; +package com.baeldung.spring.dao.generics; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Repository; -import com.baeldung.jpa.dao.AbstractJpaDAO; +import java.io.Serializable; @Repository @Scope(BeanDefinition.SCOPE_PROTOTYPE) diff --git a/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/dao/generics/IFooService.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/dao/generics/IFooService.java new file mode 100644 index 0000000000..2d525de405 --- /dev/null +++ b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/dao/generics/IFooService.java @@ -0,0 +1,5 @@ +package com.baeldung.spring.dao.generics; + +public interface IFooService { + Foo retrieveByName(String name); +} diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/persistence/dao/common/IOperations.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/dao/generics/IGenericDao.java similarity index 64% rename from persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/persistence/dao/common/IOperations.java rename to persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/dao/generics/IGenericDao.java index 34c5e0f616..3fd7baf63f 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/persistence/dao/common/IOperations.java +++ b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/dao/generics/IGenericDao.java @@ -1,9 +1,10 @@ -package com.baeldung.persistence.dao.common; +package com.baeldung.spring.dao.generics; import java.io.Serializable; import java.util.List; -public interface IOperations { +public interface IGenericDao { + void setClazz(Class< T > clazzToSet); T findOne(final long id); @@ -16,5 +17,4 @@ public interface IOperations { void delete(final T entity); void deleteById(final long entityId); - } diff --git a/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/hibernate/AbstractHibernateDao.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/hibernate/AbstractHibernateDao.java new file mode 100644 index 0000000000..c0a99e92c8 --- /dev/null +++ b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/hibernate/AbstractHibernateDao.java @@ -0,0 +1,56 @@ +package com.baeldung.spring.hibernate; + +import com.google.common.base.Preconditions; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.springframework.beans.factory.annotation.Autowired; + +import java.io.Serializable; +import java.util.List; + +@SuppressWarnings("unchecked") +public abstract class AbstractHibernateDao { + private Class clazz; + + @Autowired + protected SessionFactory sessionFactory; + + protected final void setClazz(final Class clazzToSet) { + clazz = Preconditions.checkNotNull(clazzToSet); + } + + // API + public T findOne(final long id) { + return (T) getCurrentSession().get(clazz, id); + } + + public List findAll() { + return getCurrentSession().createQuery("from " + clazz.getName()).list(); + } + + public T create(final T entity) { + Preconditions.checkNotNull(entity); + getCurrentSession().saveOrUpdate(entity); + return entity; + } + + public T update(final T entity) { + Preconditions.checkNotNull(entity); + return (T) getCurrentSession().merge(entity); + } + + public void delete(final T entity) { + Preconditions.checkNotNull(entity); + getCurrentSession().delete(entity); + } + + public void deleteById(final long entityId) { + final T entity = findOne(entityId); + Preconditions.checkState(entity != null); + delete(entity); + } + + protected Session getCurrentSession() { + return sessionFactory.getCurrentSession(); + } +} \ No newline at end of file diff --git a/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/hibernate/Foo.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/hibernate/Foo.java new file mode 100644 index 0000000000..f92b510071 --- /dev/null +++ b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/hibernate/Foo.java @@ -0,0 +1,42 @@ +package com.baeldung.spring.hibernate; + +import javax.persistence.*; +import java.io.Serializable; + +@Entity +public class Foo implements Serializable { + private static final long serialVersionUID = 1L; + + public Foo() { + super(); + } + + public Foo(final String name) { + super(); + + this.name = name; + } + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "ID") + private Long id; + @Column(name = "NAME") + private String name; + + public Long getId() { + return id; + } + + public void setId(final Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } +} diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/hibernate/dao/FooDao.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/hibernate/FooDao.java similarity index 55% rename from persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/hibernate/dao/FooDao.java rename to persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/hibernate/FooDao.java index 67c10fe7fe..d5495d4eb1 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/hibernate/dao/FooDao.java +++ b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/hibernate/FooDao.java @@ -1,14 +1,9 @@ -package com.baeldung.hibernate.dao; +package com.baeldung.spring.hibernate; -import com.baeldung.persistence.model.Foo; import org.springframework.stereotype.Repository; -import com.baeldung.jpa.dao.IFooDao; -import com.baeldung.persistence.dao.common.AbstractHibernateDao; - @Repository public class FooDao extends AbstractHibernateDao implements IFooDao { - public FooDao() { super(); @@ -16,5 +11,4 @@ public class FooDao extends AbstractHibernateDao implements IFooDao { } // API - } diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/jpa/dao/IFooDao.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/hibernate/IFooDao.java similarity index 65% rename from persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/jpa/dao/IFooDao.java rename to persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/hibernate/IFooDao.java index 8140c56edd..d397163be5 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/jpa/dao/IFooDao.java +++ b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/hibernate/IFooDao.java @@ -1,21 +1,15 @@ -package com.baeldung.jpa.dao; +package com.baeldung.spring.hibernate; import java.util.List; -import com.baeldung.persistence.model.Foo; - public interface IFooDao { - Foo findOne(long id); List findAll(); - Foo create(Foo entity); - Foo update(Foo entity); void delete(Foo entity); void deleteById(long entityId); - } diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceJPAConfig.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/jpa/guide/PersistenceJPAConfig.java similarity index 91% rename from persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceJPAConfig.java rename to persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/jpa/guide/PersistenceJPAConfig.java index e8a2aefd6b..497d735c10 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceJPAConfig.java +++ b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/jpa/guide/PersistenceJPAConfig.java @@ -1,9 +1,8 @@ -package com.baeldung.config; +package com.baeldung.spring.jpa.guide; import com.google.common.base.Preconditions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; import org.springframework.core.env.Environment; @@ -21,17 +20,12 @@ import java.util.Properties; @Configuration @EnableTransactionManagement -@PropertySource({ "classpath:persistence-h2.properties" }) -@ComponentScan({ "com.baeldung.persistence","com.baeldung.jpa.dao" }) +@PropertySource("classpath:persistence-h2.properties") public class PersistenceJPAConfig { @Autowired private Environment env; - public PersistenceJPAConfig() { - super(); - } - // beans @Bean @@ -75,9 +69,7 @@ public class PersistenceJPAConfig { hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); hibernateProperties.setProperty("hibernate.cache.use_second_level_cache", "false"); - - + return hibernateProperties; } - } \ No newline at end of file diff --git a/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/transaction/FooService.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/transaction/FooService.java new file mode 100644 index 0000000000..407d8e3394 --- /dev/null +++ b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/transaction/FooService.java @@ -0,0 +1,8 @@ +package com.baeldung.spring.transaction; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Transactional +public class FooService {} \ No newline at end of file diff --git a/persistence-modules/spring-jpa-2/src/main/resources/application.properties b/persistence-modules/spring-jpa-2/src/main/resources/application.properties new file mode 100644 index 0000000000..0270c1683e --- /dev/null +++ b/persistence-modules/spring-jpa-2/src/main/resources/application.properties @@ -0,0 +1,11 @@ +# H2 +spring.datasource.driver-class-name=org.h2.Driver +spring.datasource.username=sa +spring.datasource.password= +spring.datasource.url=jdbc:h2:mem:db;DB_CLOSE_DELAY=-1 + +# MySQL +#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver +#spring.datasource.username=mysqluser +#spring.datasource.password=mysqlpass +#spring.datasource.url=jdbc:mysql://localhost:3306/myDb?createDatabaseIfNotExist=true diff --git a/persistence-modules/spring-persistence-simple/src/main/resources/hibernate5Configuration.xml b/persistence-modules/spring-jpa-2/src/main/resources/hibernate5Configuration.xml similarity index 100% rename from persistence-modules/spring-persistence-simple/src/main/resources/hibernate5Configuration.xml rename to persistence-modules/spring-jpa-2/src/main/resources/hibernate5Configuration.xml diff --git a/persistence-modules/spring-persistence-simple/src/main/resources/persistence-h2.properties b/persistence-modules/spring-jpa-2/src/main/resources/persistence-h2.properties similarity index 100% rename from persistence-modules/spring-persistence-simple/src/main/resources/persistence-h2.properties rename to persistence-modules/spring-jpa-2/src/main/resources/persistence-h2.properties diff --git a/persistence-modules/spring-persistence-simple/src/main/resources/persistence.xml b/persistence-modules/spring-jpa-2/src/main/resources/persistence-jpa-config.xml similarity index 89% rename from persistence-modules/spring-persistence-simple/src/main/resources/persistence.xml rename to persistence-modules/spring-jpa-2/src/main/resources/persistence-jpa-config.xml index 57687c306d..54774442c6 100644 --- a/persistence-modules/spring-persistence-simple/src/main/resources/persistence.xml +++ b/persistence-modules/spring-jpa-2/src/main/resources/persistence-jpa-config.xml @@ -6,7 +6,6 @@ http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd" > - @@ -14,8 +13,6 @@ - diff --git a/persistence-modules/spring-persistence-simple/src/main/resources/persistence-mysql.properties b/persistence-modules/spring-jpa-2/src/main/resources/persistence-mysql.properties similarity index 100% rename from persistence-modules/spring-persistence-simple/src/main/resources/persistence-mysql.properties rename to persistence-modules/spring-jpa-2/src/main/resources/persistence-mysql.properties diff --git a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/hibernate/bootstrap/HibernateBootstrapIntegrationTest.java b/persistence-modules/spring-jpa-2/src/test/java/com/baeldung/hibernate/bootstrap/HibernateBootstrapIntegrationTest.java similarity index 100% rename from persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/hibernate/bootstrap/HibernateBootstrapIntegrationTest.java rename to persistence-modules/spring-jpa-2/src/test/java/com/baeldung/hibernate/bootstrap/HibernateBootstrapIntegrationTest.java diff --git a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/hibernate/bootstrap/HibernateXMLBootstrapIntegrationTest.java b/persistence-modules/spring-jpa-2/src/test/java/com/baeldung/hibernate/bootstrap/HibernateXMLBootstrapIntegrationTest.java similarity index 100% rename from persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/hibernate/bootstrap/HibernateXMLBootstrapIntegrationTest.java rename to persistence-modules/spring-jpa-2/src/test/java/com/baeldung/hibernate/bootstrap/HibernateXMLBootstrapIntegrationTest.java diff --git a/persistence-modules/spring-jpa/src/main/java/com/baeldung/jdbc/autogenkey/config/PersistenceConfig.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/spring/jdbc/autogenkey/config/PersistenceConfig.java similarity index 94% rename from persistence-modules/spring-jpa/src/main/java/com/baeldung/jdbc/autogenkey/config/PersistenceConfig.java rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/spring/jdbc/autogenkey/config/PersistenceConfig.java index 99f50abf4c..d1f8864357 100644 --- a/persistence-modules/spring-jpa/src/main/java/com/baeldung/jdbc/autogenkey/config/PersistenceConfig.java +++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/spring/jdbc/autogenkey/config/PersistenceConfig.java @@ -1,4 +1,4 @@ -package com.baeldung.jdbc.autogenkey.config; +package com.baeldung.spring.jdbc.autogenkey.config; import javax.sql.DataSource; diff --git a/persistence-modules/spring-jpa/src/main/java/com/baeldung/jdbc/autogenkey/repository/MessageRepositoryJDBCTemplate.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/spring/jdbc/autogenkey/repository/MessageRepositoryJDBCTemplate.java similarity index 92% rename from persistence-modules/spring-jpa/src/main/java/com/baeldung/jdbc/autogenkey/repository/MessageRepositoryJDBCTemplate.java rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/spring/jdbc/autogenkey/repository/MessageRepositoryJDBCTemplate.java index cf0dbe4681..0f47473bd7 100644 --- a/persistence-modules/spring-jpa/src/main/java/com/baeldung/jdbc/autogenkey/repository/MessageRepositoryJDBCTemplate.java +++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/spring/jdbc/autogenkey/repository/MessageRepositoryJDBCTemplate.java @@ -1,4 +1,4 @@ -package com.baeldung.jdbc.autogenkey.repository; +package com.baeldung.spring.jdbc.autogenkey.repository; import java.sql.PreparedStatement; diff --git a/persistence-modules/spring-jpa/src/main/java/com/baeldung/jdbc/autogenkey/repository/MessageRepositorySimpleJDBCInsert.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/spring/jdbc/autogenkey/repository/MessageRepositorySimpleJDBCInsert.java similarity index 90% rename from persistence-modules/spring-jpa/src/main/java/com/baeldung/jdbc/autogenkey/repository/MessageRepositorySimpleJDBCInsert.java rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/spring/jdbc/autogenkey/repository/MessageRepositorySimpleJDBCInsert.java index 022ea29ed6..247fbf28c2 100644 --- a/persistence-modules/spring-jpa/src/main/java/com/baeldung/jdbc/autogenkey/repository/MessageRepositorySimpleJDBCInsert.java +++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/spring/jdbc/autogenkey/repository/MessageRepositorySimpleJDBCInsert.java @@ -1,4 +1,4 @@ -package com.baeldung.jdbc.autogenkey.repository; +package com.baeldung.spring.jdbc.autogenkey.repository; import java.util.HashMap; import java.util.Map; diff --git a/persistence-modules/spring-jpa/src/test/java/com/baeldung/jdbc/autogenkey/GetAutoGenKeyByJDBC.java b/persistence-modules/spring-jpa/src/test/java/com/baeldung/spring/jdbc/autogenkey/GetAutoGenKeyByJDBC.java similarity index 79% rename from persistence-modules/spring-jpa/src/test/java/com/baeldung/jdbc/autogenkey/GetAutoGenKeyByJDBC.java rename to persistence-modules/spring-jpa/src/test/java/com/baeldung/spring/jdbc/autogenkey/GetAutoGenKeyByJDBC.java index aa4d061997..f0ad853c2a 100644 --- a/persistence-modules/spring-jpa/src/test/java/com/baeldung/jdbc/autogenkey/GetAutoGenKeyByJDBC.java +++ b/persistence-modules/spring-jpa/src/test/java/com/baeldung/spring/jdbc/autogenkey/GetAutoGenKeyByJDBC.java @@ -1,4 +1,4 @@ -package com.baeldung.jdbc.autogenkey; +package com.baeldung.spring.jdbc.autogenkey; import static org.junit.Assert.assertEquals; @@ -9,14 +9,14 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.test.context.junit4.SpringRunner; -import com.baeldung.jdbc.autogenkey.repository.MessageRepositoryJDBCTemplate; -import com.baeldung.jdbc.autogenkey.repository.MessageRepositorySimpleJDBCInsert; +import com.baeldung.spring.jdbc.autogenkey.repository.MessageRepositoryJDBCTemplate; +import com.baeldung.spring.jdbc.autogenkey.repository.MessageRepositorySimpleJDBCInsert; @RunWith(SpringRunner.class) public class GetAutoGenKeyByJDBC { @Configuration - @ComponentScan(basePackages = { "com.baeldung.jdbc.autogenkey" }) + @ComponentScan(basePackages = {"com.baeldung.spring.jdbc.autogenkey"}) public static class SpringConfig { } diff --git a/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/Employee.java b/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/spring/jdbc/Employee.java similarity index 95% rename from persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/Employee.java rename to persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/spring/jdbc/Employee.java index bd6fe0fb15..adc2255ca4 100644 --- a/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/Employee.java +++ b/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/spring/jdbc/Employee.java @@ -1,4 +1,4 @@ -package com.baeldung.jdbc; +package com.baeldung.spring.jdbc; public class Employee { private int id; diff --git a/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/EmployeeDAO.java b/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/spring/jdbc/EmployeeDAO.java similarity index 98% rename from persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/EmployeeDAO.java rename to persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/spring/jdbc/EmployeeDAO.java index 2ea42381eb..6e2ad9682d 100644 --- a/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/EmployeeDAO.java +++ b/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/spring/jdbc/EmployeeDAO.java @@ -1,4 +1,4 @@ -package com.baeldung.jdbc; +package com.baeldung.spring.jdbc; import java.util.ArrayList; import java.util.Collections; diff --git a/persistence-modules/spring-persistence-simple-2/src/test/java/com/baeldung/jdbc/EmployeeDAOUnitTest.java b/persistence-modules/spring-persistence-simple-2/src/test/java/com/baeldung/spring/jdbc/EmployeeDAOUnitTest.java similarity index 99% rename from persistence-modules/spring-persistence-simple-2/src/test/java/com/baeldung/jdbc/EmployeeDAOUnitTest.java rename to persistence-modules/spring-persistence-simple-2/src/test/java/com/baeldung/spring/jdbc/EmployeeDAOUnitTest.java index 369725bafd..bbc688293b 100644 --- a/persistence-modules/spring-persistence-simple-2/src/test/java/com/baeldung/jdbc/EmployeeDAOUnitTest.java +++ b/persistence-modules/spring-persistence-simple-2/src/test/java/com/baeldung/spring/jdbc/EmployeeDAOUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.jdbc; +package com.baeldung.spring.jdbc; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/persistence-modules/spring-persistence-simple/.gitignore b/persistence-modules/spring-persistence-simple/.gitignore deleted file mode 100644 index 83c05e60c8..0000000000 --- a/persistence-modules/spring-persistence-simple/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -*.class - -#folders# -/target -/neoDb* -/data -/src/main/webapp/WEB-INF/classes -*/META-INF/* - -# Packaged files # -*.jar -*.war -*.ear \ No newline at end of file diff --git a/persistence-modules/spring-persistence-simple/README.md b/persistence-modules/spring-persistence-simple/README.md deleted file mode 100644 index d665433eef..0000000000 --- a/persistence-modules/spring-persistence-simple/README.md +++ /dev/null @@ -1,25 +0,0 @@ -========= - -## Spring Persistence Example Project - - -### Relevant Articles: -- [A Guide to JPA with Spring](https://www.baeldung.com/the-persistence-layer-with-spring-and-jpa) -- [Bootstrapping Hibernate 5 with Spring](http://www.baeldung.com/hibernate-5-spring) -- [The DAO with Spring and Hibernate](https://www.baeldung.com/persistence-layer-with-spring-and-hibernate) -- [Simplify the DAO with Spring and Java Generics](https://www.baeldung.com/simplifying-the-data-access-layer-with-spring-and-java-generics) -- [Transactions with Spring and JPA](https://www.baeldung.com/transaction-configuration-with-jpa-and-spring) -- [Introduction to Spring Data JPA](http://www.baeldung.com/the-persistence-layer-with-spring-data-jpa) -- [Spring Data JPA @Query](http://www.baeldung.com/spring-data-jpa-query) -- [Spring JDBC](https://www.baeldung.com/spring-jdbc-jdbctemplate) -- [Transaction Propagation and Isolation in Spring @Transactional](https://www.baeldung.com/spring-transactional-propagation-isolation) - -### Eclipse Config -After importing the project into Eclipse, you may see the following error: -"No persistence xml file found in project" - -This can be ignored: -- Project -> Properties -> Java Persistance -> JPA -> Error/Warnings -> Select Ignore on "No persistence xml file found in project" -Or: -- Eclipse -> Preferences - Validation - disable the "Build" execution of the JPA Validator - diff --git a/persistence-modules/spring-persistence-simple/pom.xml b/persistence-modules/spring-persistence-simple/pom.xml deleted file mode 100644 index 7318ec55bd..0000000000 --- a/persistence-modules/spring-persistence-simple/pom.xml +++ /dev/null @@ -1,152 +0,0 @@ - - - 4.0.0 - spring-persistence-simple - 0.1-SNAPSHOT - spring-persistence-simple - - - com.baeldung - persistence-modules - 1.0.0-SNAPSHOT - - - - - - org.springframework - spring-orm - ${org.springframework.version} - - - org.springframework - spring-context - ${org.springframework.version} - - - org.springframework - spring-aspects - ${org.springframework.version} - - - - org.hibernate - hibernate-core - ${hibernate.version} - - - javax.transaction - jta - ${jta.version} - - - org.hibernate - hibernate-entitymanager - ${hibernate.version} - - - mysql - mysql-connector-java - ${mysql-connector-java.version} - runtime - - - org.springframework.data - spring-data-jpa - ${spring-data-jpa.version} - - - com.h2database - h2 - ${h2.version} - - - - org.apache.tomcat - tomcat-dbcp - ${tomcat-dbcp.version} - - - - - - com.google.guava - guava - ${guava.version} - - - org.assertj - assertj-core - ${assertj.version} - - - - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - test - - - - org.springframework - spring-test - ${org.springframework.version} - test - - - com.querydsl - querydsl-jpa - ${querydsl.version} - - - com.querydsl - querydsl-apt - ${querydsl.version} - - - - - - - com.mysema.maven - apt-maven-plugin - ${apt-maven-plugin.version} - - - generate-sources - - process - - - target/generated-sources - com.querydsl.apt.jpa.JPAAnnotationProcessor - - - - - - - - - - 5.2.6.RELEASE - - - 5.4.13.Final - 8.0.19 - 1.4.200 - 2.2.7.RELEASE - 9.0.0.M26 - 1.1 - 4.2.1 - - - 21.0 - 3.8.0 - 1.1.3 - - - \ No newline at end of file diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceConfig.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceConfig.java deleted file mode 100644 index cdddbaa787..0000000000 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceConfig.java +++ /dev/null @@ -1,110 +0,0 @@ -package com.baeldung.config; - -import com.baeldung.persistence.service.FooService; -import com.google.common.base.Preconditions; -import org.apache.tomcat.dbcp.dbcp2.BasicDataSource; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; -import org.springframework.core.env.Environment; -import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; -import org.springframework.data.jpa.repository.config.EnableJpaAuditing; -import org.springframework.orm.hibernate5.HibernateTransactionManager; -import org.springframework.orm.hibernate5.LocalSessionFactoryBean; -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 -@EnableTransactionManagement -@EnableJpaAuditing -@PropertySource({ "classpath:persistence-mysql.properties" }) -@ComponentScan(basePackages = { "com.baeldung.persistence.dao", "com.baeldung.jpa.dao" }) -public class PersistenceConfig { - - @Autowired - private Environment env; - - public PersistenceConfig() { - super(); - } - - @Bean - public LocalSessionFactoryBean sessionFactory() { - final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); - sessionFactory.setDataSource(restDataSource()); - sessionFactory.setPackagesToScan("com.baeldung.persistence.model"); - sessionFactory.setHibernateProperties(hibernateProperties()); - - return sessionFactory; - } - - @Bean - public LocalContainerEntityManagerFactoryBean entityManagerFactory() { - final LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean(); - emf.setDataSource(restDataSource()); - emf.setPackagesToScan("com.baeldung.persistence.model"); - - final JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); - emf.setJpaVendorAdapter(vendorAdapter); - emf.setJpaProperties(hibernateProperties()); - - return emf; - } - - @Bean - public DataSource restDataSource() { - final BasicDataSource dataSource = new BasicDataSource(); - 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 hibernateTransactionManager() { - final HibernateTransactionManager transactionManager = new HibernateTransactionManager(); - transactionManager.setSessionFactory(sessionFactory().getObject()); - return transactionManager; - } - - @Bean - public PlatformTransactionManager jpaTransactionManager() { - final JpaTransactionManager transactionManager = new JpaTransactionManager(); - transactionManager.setEntityManagerFactory(entityManagerFactory().getObject()); - return transactionManager; - } - - @Bean - public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { - return new PersistenceExceptionTranslationPostProcessor(); - } - - @Bean - public FooService fooService() { - return new FooService(); - } - - private 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"); - - // 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-persistence-simple/src/main/java/com/baeldung/jpa/dao/FooDao.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/jpa/dao/FooDao.java deleted file mode 100644 index e79a44a0c2..0000000000 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/jpa/dao/FooDao.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.baeldung.jpa.dao; - -import com.baeldung.persistence.model.Foo; -import org.springframework.stereotype.Repository; - -@Repository -public class FooDao extends AbstractJpaDAO implements IFooDao { - - public FooDao() { - super(); - - setClazz(Foo.class); - } - - // API - -} diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/persistence/dao/common/AbstractDao.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/persistence/dao/common/AbstractDao.java deleted file mode 100644 index 5a6c76a93a..0000000000 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/persistence/dao/common/AbstractDao.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.baeldung.persistence.dao.common; - -import java.io.Serializable; - -import com.google.common.base.Preconditions; - -public abstract class AbstractDao implements IOperations { - - protected Class clazz; - - protected final void setClazz(final Class clazzToSet) { - clazz = Preconditions.checkNotNull(clazzToSet); - } -} diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/persistence/dao/common/IGenericDao.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/persistence/dao/common/IGenericDao.java deleted file mode 100644 index 8d8af18394..0000000000 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/persistence/dao/common/IGenericDao.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.baeldung.persistence.dao.common; - -import java.io.Serializable; - -public interface IGenericDao extends IOperations { - // -} diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/persistence/model/Bar.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/persistence/model/Bar.java deleted file mode 100644 index 5a88ecc6cf..0000000000 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/persistence/model/Bar.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.baeldung.persistence.model; - -import java.io.Serializable; -import java.util.List; - -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.OneToMany; -import javax.persistence.OrderBy; - -@Entity -public class Bar implements Serializable { - private static final long serialVersionUID = 1L; - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private long id; - - @Column(nullable = false) - private String name; - - @OneToMany(mappedBy = "bar", fetch = FetchType.EAGER, cascade = CascadeType.ALL) - @OrderBy("name ASC") - List fooList; - - public Bar() { - super(); - } - - public Bar(final String name) { - super(); - - this.name = name; - } - - // API - - public long getId() { - return id; - } - - public void setId(final long id) { - - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(final String name) { - this.name = name; - } - - public List getFooList() { - return fooList; - } - - public void setFooList(final List fooList) { - this.fooList = fooList; - } - - // - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - final Bar other = (Bar) obj; - 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("Bar [name=").append(name).append("]"); - return builder.toString(); - } - -} diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/persistence/service/FooService.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/persistence/service/FooService.java deleted file mode 100644 index efe9743670..0000000000 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/persistence/service/FooService.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.baeldung.persistence.service; - -import java.util.List; - -import com.baeldung.jpa.dao.IFooDao; -import com.baeldung.persistence.model.Foo; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -@Service -@Transactional -public class FooService { - - @Autowired - private IFooDao dao; - - public FooService() { - super(); - } - - // API - - public void create(final Foo entity) { - dao.create(entity); - } - - public Foo findOne(final long id) { - return dao.findOne(id); - } - - public List findAll() { - return dao.findAll(); - } - -} diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/model/Possession.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/model/Possession.java deleted file mode 100644 index 44ca9fc62e..0000000000 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/model/Possession.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.baeldung.spring.data.persistence.model; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; - -@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-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/UserRepositoryCustomImpl.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/UserRepositoryCustomImpl.java deleted file mode 100644 index 366b2c54d0..0000000000 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/UserRepositoryCustomImpl.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.baeldung.spring.data.persistence.repository; - -import com.baeldung.spring.data.persistence.model.User; - -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; -import javax.persistence.criteria.*; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -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(); - } - - @Override - public List findAllUsersByPredicates(Collection> predicates) { - List allUsers = entityManager.createQuery("select u from User u", User.class).getResultList(); - Stream allUsersStream = allUsers.stream(); - for (java.util.function.Predicate predicate : predicates) { - allUsersStream = allUsersStream.filter(predicate); - } - - return allUsersStream.collect(Collectors.toList()); - } - -} diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/service/IFooService.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/service/IFooService.java deleted file mode 100644 index 00e7ac01e4..0000000000 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/service/IFooService.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.baeldung.spring.data.persistence.service; - -import com.baeldung.spring.data.persistence.model.Foo; - -import com.baeldung.persistence.dao.common.IOperations; - -public interface IFooService extends IOperations { - - Foo retrieveByName(String name); - -} diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/service/common/AbstractService.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/service/common/AbstractService.java deleted file mode 100644 index 61c7d6fcaa..0000000000 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/service/common/AbstractService.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.baeldung.spring.data.persistence.service.common; - -import java.io.Serializable; -import java.util.List; - -import org.springframework.data.repository.PagingAndSortingRepository; -import org.springframework.transaction.annotation.Transactional; - -import com.baeldung.persistence.dao.common.IOperations; -import com.google.common.collect.Lists; - -@Transactional -public abstract class AbstractService implements IOperations { - - // read - one - - @Override - @Transactional(readOnly = true) - public T findOne(final long id) { - return getDao().findById(id).orElse(null); - } - - // read - all - - @Override - @Transactional(readOnly = true) - public List findAll() { - return Lists.newArrayList(getDao().findAll()); - } - - // write - - @Override - public T create(final T entity) { - return getDao().save(entity); - } - - @Override - public T update(final T entity) { - return getDao().save(entity); - } - - @Override - public void delete(T entity) { - getDao().delete(entity); - } - - @Override - public void deleteById(long entityId) { - T entity = findOne(entityId); - delete(entity); - } - - protected abstract PagingAndSortingRepository getDao(); - -} diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/service/impl/FooService.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/service/impl/FooService.java deleted file mode 100644 index c1406b8602..0000000000 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/service/impl/FooService.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.baeldung.spring.data.persistence.service.impl; - - -import com.baeldung.spring.data.persistence.model.Foo; -import com.baeldung.spring.data.persistence.repository.IFooDao; -import com.baeldung.spring.data.persistence.service.IFooService; -import com.baeldung.spring.data.persistence.service.common.AbstractService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.repository.PagingAndSortingRepository; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -@Service -@Transactional -public class FooService extends AbstractService implements IFooService { - - @Autowired - private IFooDao dao; - - public FooService() { - super(); - } - - // API - - @Override - protected PagingAndSortingRepository getDao() { - return dao; - } - - // custom methods - - @Override - public Foo retrieveByName(final String name) { - return dao.retrieveByName(name); - } - -} diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/util/IDUtil.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/util/IDUtil.java deleted file mode 100644 index 45e72e046d..0000000000 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/util/IDUtil.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.baeldung.util; - -import java.util.Random; - -public final class IDUtil { - - private IDUtil() { - throw new AssertionError(); - } - - // API - - public static String randomPositiveLongAsString() { - return Long.toString(randomPositiveLong()); - } - - public static String randomNegativeLongAsString() { - return Long.toString(randomNegativeLong()); - } - - public static long randomPositiveLong() { - long id = new Random().nextLong() * 10000; - id = (id < 0) ? (-1 * id) : id; - return id; - } - - private static long randomNegativeLong() { - long id = new Random().nextLong() * 10000; - id = (id > 0) ? (-1 * id) : id; - return id; - } - -} diff --git a/persistence-modules/spring-persistence-simple/src/main/resources/hibernate5Config.xml b/persistence-modules/spring-persistence-simple/src/main/resources/hibernate5Config.xml deleted file mode 100644 index 55546a862a..0000000000 --- a/persistence-modules/spring-persistence-simple/src/main/resources/hibernate5Config.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - ${hibernate.hbm2ddl.auto} - ${hibernate.dialect} - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/persistence-modules/spring-persistence-simple/src/main/resources/jdbc/springJdbc-config.xml b/persistence-modules/spring-persistence-simple/src/main/resources/jdbc/springJdbc-config.xml deleted file mode 100644 index e3d7452eb1..0000000000 --- a/persistence-modules/spring-persistence-simple/src/main/resources/jdbc/springJdbc-config.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/persistence-modules/spring-persistence-simple/src/main/resources/logback.xml b/persistence-modules/spring-persistence-simple/src/main/resources/logback.xml deleted file mode 100644 index ec0dc2469a..0000000000 --- a/persistence-modules/spring-persistence-simple/src/main/resources/logback.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - web - %date [%thread] %-5level %logger{36} - %message%n - - - - - - - - - - - - - - \ No newline at end of file diff --git a/persistence-modules/spring-persistence-simple/src/main/resources/stored_procedure.sql b/persistence-modules/spring-persistence-simple/src/main/resources/stored_procedure.sql deleted file mode 100644 index 9cedb75c37..0000000000 --- a/persistence-modules/spring-persistence-simple/src/main/resources/stored_procedure.sql +++ /dev/null @@ -1,20 +0,0 @@ -DELIMITER // - CREATE PROCEDURE GetFoosByName(IN fooName VARCHAR(255)) - LANGUAGE SQL - DETERMINISTIC - SQL SECURITY DEFINER - BEGIN - SELECT * FROM foo WHERE name = fooName; - END // -DELIMITER ; - - -DELIMITER // - CREATE PROCEDURE GetAllFoos() - LANGUAGE SQL - DETERMINISTIC - SQL SECURITY DEFINER - BEGIN - SELECT * FROM foo; - END // -DELIMITER ; \ No newline at end of file diff --git a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/FooPaginationPersistenceIntegrationTest.java b/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/FooPaginationPersistenceIntegrationTest.java deleted file mode 100644 index fbda459d65..0000000000 --- a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/FooPaginationPersistenceIntegrationTest.java +++ /dev/null @@ -1,157 +0,0 @@ -package com.baeldung.persistence.service; - -import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.Matchers.lessThan; -import static org.junit.Assert.assertThat; - -import java.util.List; - -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; -import javax.persistence.Query; -import javax.persistence.TypedQuery; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; - -import com.baeldung.config.PersistenceJPAConfig; -import com.baeldung.persistence.model.Foo; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { PersistenceJPAConfig.class }, loader = AnnotationConfigContextLoader.class) -@DirtiesContext -public class FooPaginationPersistenceIntegrationTest { - - @PersistenceContext - private EntityManager entityManager; - - @Autowired - private FooService fooService; - - @Before - public final void before() { - final int minimalNumberOfEntities = 25; - if (fooService.findAll().size() <= minimalNumberOfEntities) { - for (int i = 0; i < minimalNumberOfEntities; i++) { - fooService.create(new Foo(randomAlphabetic(6))); - } - } - } - - // tests - - @Test - public final void whenContextIsBootstrapped_thenNoExceptions() { - // - } - - @SuppressWarnings("unchecked") - @Test - public final void givenEntitiesExist_whenRetrievingFirstPage_thenCorrect() { - final int pageSize = 10; - - final Query query = entityManager.createQuery("From Foo"); - configurePagination(query, 1, pageSize); - - // When - final List fooList = query.getResultList(); - - // Then - assertThat(fooList, hasSize(pageSize)); - } - - @SuppressWarnings("unchecked") - @Test - public final void givenEntitiesExist_whenRetrievingLastPage_thenCorrect() { - final int pageSize = 10; - final Query queryTotal = entityManager.createQuery("Select count(f.id) from Foo f"); - final long countResult = (long) queryTotal.getSingleResult(); - - final Query query = entityManager.createQuery("Select f from Foo as f order by f.id"); - final int lastPage = (int) ((countResult / pageSize) + 1); - configurePagination(query, lastPage, pageSize); - final List fooList = query.getResultList(); - - // Then - assertThat(fooList, hasSize(lessThan(pageSize + 1))); - } - - @SuppressWarnings("unchecked") - @Test - public final void givenEntitiesExist_whenRetrievingPage_thenCorrect() { - final int pageSize = 10; - - final Query queryIds = entityManager.createQuery("Select f.id from Foo f order by f.name"); - final List fooIds = queryIds.getResultList(); - - final Query query = entityManager.createQuery("Select f from Foo as f where f.id in :ids"); - query.setParameter("ids", fooIds.subList(0, pageSize)); - - final List fooList = query.getResultList(); - - // Then - assertThat(fooList, hasSize(pageSize)); - } - - @Test - public final void givenEntitiesExist_whenRetrievingPageViaCriteria_thenCorrect() { - final int pageSize = 10; - final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); - final CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(Foo.class); - final Root from = criteriaQuery.from(Foo.class); - final CriteriaQuery select = criteriaQuery.select(from); - final TypedQuery typedQuery = entityManager.createQuery(select); - typedQuery.setFirstResult(0); - typedQuery.setMaxResults(pageSize); - final List fooList = typedQuery.getResultList(); - - // Then - assertThat(fooList, hasSize(pageSize)); - } - - @Test - public final void givenEntitiesExist_whenRetrievingPageViaCriteria_thenNoExceptions() { - int pageNumber = 1; - final int pageSize = 10; - final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); - - final CriteriaQuery countQuery = criteriaBuilder.createQuery(Long.class); - countQuery.select(criteriaBuilder.count(countQuery.from(Foo.class))); - final Long count = entityManager.createQuery(countQuery).getSingleResult(); - - final CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(Foo.class); - final Root from = criteriaQuery.from(Foo.class); - final CriteriaQuery select = criteriaQuery.select(from); - - TypedQuery typedQuery; - while (pageNumber < count.intValue()) { - typedQuery = entityManager.createQuery(select); - typedQuery.setFirstResult(pageNumber - 1); - typedQuery.setMaxResults(pageSize); - System.out.println("Current page: " + typedQuery.getResultList()); - pageNumber += pageSize; - } - - } - - // UTIL - - final int determineLastPage(final int pageSize, final long countResult) { - return (int) (countResult / pageSize) + 1; - } - - final void configurePagination(final Query query, final int pageNumber, final int pageSize) { - query.setFirstResult((pageNumber - 1) * pageSize); - query.setMaxResults(pageSize); - } - -} diff --git a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java b/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java deleted file mode 100644 index f4b70a7fde..0000000000 --- a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.baeldung.persistence.service; - -import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; - -import com.baeldung.config.PersistenceJPAConfig; -import com.baeldung.persistence.model.Foo; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.dao.DataAccessException; -import org.springframework.dao.DataIntegrityViolationException; -import org.springframework.dao.InvalidDataAccessApiUsageException; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { PersistenceJPAConfig.class }, loader = AnnotationConfigContextLoader.class) -@DirtiesContext -public class FooServicePersistenceIntegrationTest { - - @Autowired - private FooService service; - - // tests - - @Test - public final void whenContextIsBootstrapped_thenNoExceptions() { - // - } - - @Test - public final void whenEntityIsCreated_thenNoExceptions() { - service.create(new Foo(randomAlphabetic(6))); - } - - @Test(expected = DataIntegrityViolationException.class) - public final void whenInvalidEntityIsCreated_thenDataException() { - service.create(new Foo(randomAlphabetic(2048))); - } - - @Test(expected = DataIntegrityViolationException.class) - public final void whenEntityWithLongNameIsCreated_thenDataException() { - service.create(new Foo(randomAlphabetic(2048))); - } - - @Test(expected = InvalidDataAccessApiUsageException.class) - public final void whenSameEntityIsCreatedTwice_thenDataException() { - final Foo entity = new Foo(randomAlphabetic(8)); - service.create(entity); - service.create(entity); - } - - @Test(expected = DataAccessException.class) - public final void temp_whenInvalidEntityIsCreated_thenDataException() { - service.create(new Foo(randomAlphabetic(2048))); - } - - @Test - public final void whenEntityIsCreated_thenFound() { - final Foo fooEntity = new Foo("abc"); - service.create(fooEntity); - final Foo found = service.findOne(fooEntity.getId()); - Assert.assertNotNull(found); - } - -} diff --git a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/FooServiceSortingIntegrationTest.java b/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/FooServiceSortingIntegrationTest.java deleted file mode 100644 index c3db45ab41..0000000000 --- a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/FooServiceSortingIntegrationTest.java +++ /dev/null @@ -1,118 +0,0 @@ -package com.baeldung.persistence.service; - -import java.util.List; - -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; -import javax.persistence.Query; -import javax.persistence.TypedQuery; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; - -import com.baeldung.config.PersistenceJPAConfig; -import com.baeldung.persistence.model.Bar; -import com.baeldung.persistence.model.Foo; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { PersistenceJPAConfig.class }, loader = AnnotationConfigContextLoader.class) -@DirtiesContext -@SuppressWarnings("unchecked") -public class FooServiceSortingIntegrationTest { - - @PersistenceContext - private EntityManager entityManager; - - // tests - - @Test - public final void whenSortingByOneAttributeDefaultOrder_thenPrintSortedResult() { - final String jql = "Select f from Foo as f order by f.id"; - final Query sortQuery = entityManager.createQuery(jql); - final List fooList = sortQuery.getResultList(); - for (final Foo foo : fooList) { - System.out.println("Name:" + foo.getName() + "-------Id:" + foo.getId()); - } - } - - @Test - public final void whenSortingByOneAttributeSetOrder_thenSortedPrintResult() { - final String jql = "Select f from Foo as f order by f.id desc"; - final Query sortQuery = entityManager.createQuery(jql); - final List fooList = sortQuery.getResultList(); - for (final Foo foo : fooList) { - System.out.println("Name:" + foo.getName() + "-------Id:" + foo.getId()); - } - } - - @Test - public final void whenSortingByTwoAttributes_thenPrintSortedResult() { - final String jql = "Select f from Foo as f order by f.name asc, f.id desc"; - final Query sortQuery = entityManager.createQuery(jql); - final List fooList = sortQuery.getResultList(); - for (final Foo foo : fooList) { - System.out.println("Name:" + foo.getName() + "-------Id:" + foo.getId()); - } - } - - @Test - public final void whenSortingFooByBar_thenBarsSorted() { - final String jql = "Select f from Foo as f order by f.name, f.bar.id"; - final Query barJoinQuery = entityManager.createQuery(jql); - final List fooList = barJoinQuery.getResultList(); - for (final Foo foo : fooList) { - System.out.println("Name:" + foo.getName()); - if (foo.getBar() != null) { - System.out.print("-------BarId:" + foo.getBar().getId()); - } - } - } - - @Test - public final void whenSortinfBar_thenPrintBarsSortedWithFoos() { - final String jql = "Select b from Bar as b order by b.id"; - final Query barQuery = entityManager.createQuery(jql); - final List barList = barQuery.getResultList(); - for (final Bar bar : barList) { - System.out.println("Bar Id:" + bar.getId()); - for (final Foo foo : bar.getFooList()) { - System.out.println("FooName:" + foo.getName()); - } - } - } - - @Test - public final void whenSortingFooWithCriteria_thenPrintSortedFoos() { - final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); - final CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(Foo.class); - final Root from = criteriaQuery.from(Foo.class); - final CriteriaQuery select = criteriaQuery.select(from); - criteriaQuery.orderBy(criteriaBuilder.asc(from.get("name"))); - final TypedQuery typedQuery = entityManager.createQuery(select); - final List fooList = typedQuery.getResultList(); - for (final Foo foo : fooList) { - System.out.println("Name:" + foo.getName() + "--------Id:" + foo.getId()); - } - } - - @Test - public final void whenSortingFooWithCriteriaAndMultipleAttributes_thenPrintSortedFoos() { - final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); - final CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(Foo.class); - final Root from = criteriaQuery.from(Foo.class); - final CriteriaQuery select = criteriaQuery.select(from); - criteriaQuery.orderBy(criteriaBuilder.asc(from.get("name")), criteriaBuilder.desc(from.get("id"))); - final TypedQuery typedQuery = entityManager.createQuery(select); - final List fooList = typedQuery.getResultList(); - for (final Foo foo : fooList) { - System.out.println("Name:" + foo.getName() + "-------Id:" + foo.getId()); - } - } - -} diff --git a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/FooServiceSortingWitNullsManualIntegrationTest.java b/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/FooServiceSortingWitNullsManualIntegrationTest.java deleted file mode 100644 index 103321fc64..0000000000 --- a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/FooServiceSortingWitNullsManualIntegrationTest.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.baeldung.persistence.service; - -import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; -import static org.junit.Assert.assertNull; - -import java.util.List; - -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; -import javax.persistence.Query; - -import com.baeldung.config.PersistenceJPAConfig; -import com.baeldung.persistence.model.Foo; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { PersistenceJPAConfig.class }, loader = AnnotationConfigContextLoader.class) -@DirtiesContext -public class FooServiceSortingWitNullsManualIntegrationTest { - - @PersistenceContext - private EntityManager entityManager; - - @Autowired - private FooService service; - - // tests - - @SuppressWarnings("unchecked") - @Test - public final void whenSortingByStringNullLast_thenLastNull() { - service.create(new Foo()); - service.create(new Foo(randomAlphabetic(6))); - - final String jql = "Select f from Foo as f order by f.name desc NULLS LAST"; - final Query sortQuery = entityManager.createQuery(jql); - final List fooList = sortQuery.getResultList(); - assertNull(fooList.get(fooList.toArray().length - 1).getName()); - for (final Foo foo : fooList) { - System.out.println("Name:" + foo.getName()); - } - } - - @SuppressWarnings("unchecked") - @Test - public final void whenSortingByStringNullFirst_thenFirstNull() { - service.create(new Foo()); - - final String jql = "Select f from Foo as f order by f.name desc NULLS FIRST"; - final Query sortQuery = entityManager.createQuery(jql); - final List fooList = sortQuery.getResultList(); - assertNull(fooList.get(0).getName()); - for (final Foo foo : fooList) { - System.out.println("Name:" + foo.getName()); - } - } - -} diff --git a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/FooStoredProceduresLiveTest.java b/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/FooStoredProceduresLiveTest.java deleted file mode 100644 index 32a94ea3cb..0000000000 --- a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/FooStoredProceduresLiveTest.java +++ /dev/null @@ -1,123 +0,0 @@ -package com.baeldung.persistence.service; - -import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; -import static org.junit.Assert.assertEquals; - -import java.util.List; - -import com.baeldung.config.PersistenceConfig; -import com.baeldung.persistence.model.Foo; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.exception.SQLGrammarException; -import org.hibernate.query.NativeQuery; -import org.hibernate.query.Query; -import org.junit.After; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) -public class FooStoredProceduresLiveTest { - - private static final Logger LOGGER = LoggerFactory.getLogger(FooStoredProceduresLiveTest.class); - - @Autowired - private SessionFactory sessionFactory; - - @Autowired - private FooService fooService; - - private Session session; - - @Before - public final void before() { - session = sessionFactory.openSession(); - Assume.assumeTrue(getAllFoosExists()); - Assume.assumeTrue(getFoosByNameExists()); - } - - private boolean getFoosByNameExists() { - try { - @SuppressWarnings("unchecked") - NativeQuery sqlQuery = session.createSQLQuery("CALL GetAllFoos()").addEntity(Foo.class); - sqlQuery.list(); - return true; - } catch (SQLGrammarException e) { - LOGGER.error("WARNING : GetFoosByName() Procedure is may be missing ", e); - return false; - } - } - - private boolean getAllFoosExists() { - try { - @SuppressWarnings("unchecked") - NativeQuery sqlQuery = session.createSQLQuery("CALL GetAllFoos()").addEntity(Foo.class); - sqlQuery.list(); - return true; - } catch (SQLGrammarException e) { - LOGGER.error("WARNING : GetAllFoos() Procedure is may be missing ", e); - return false; - } - } - - @After - public final void after() { - session.close(); - } - - @Test - public final void getAllFoosUsingStoredProcedures() { - - fooService.create(new Foo(randomAlphabetic(6))); - - // Stored procedure getAllFoos using createSQLQuery - @SuppressWarnings("unchecked") - NativeQuery sqlQuery = session.createSQLQuery("CALL GetAllFoos()").addEntity(Foo.class); - List allFoos = sqlQuery.list(); - for (Foo foo : allFoos) { - LOGGER.info("getAllFoos() SQL Query result : {}", foo.getName()); - } - assertEquals(allFoos.size(), fooService.findAll().size()); - - // Stored procedure getAllFoos using a Named Query - @SuppressWarnings("unchecked") - Query namedQuery = session.getNamedQuery("callGetAllFoos"); - List allFoos2 = namedQuery.list(); - for (Foo foo : allFoos2) { - LOGGER.info("getAllFoos() NamedQuery result : {}", foo.getName()); - } - assertEquals(allFoos2.size(), fooService.findAll().size()); - } - - @Test - public final void getFoosByNameUsingStoredProcedures() { - - fooService.create(new Foo("NewFooName")); - - // Stored procedure getFoosByName using createSQLQuery() - @SuppressWarnings("unchecked") - Query sqlQuery = session.createSQLQuery("CALL GetFoosByName(:fooName)").addEntity(Foo.class).setParameter("fooName", "NewFooName"); - List allFoosByName = sqlQuery.list(); - for (Foo foo : allFoosByName) { - LOGGER.info("getFoosByName() using SQL Query : found => {}", foo.toString()); - } - - // Stored procedure getFoosByName using getNamedQuery() - @SuppressWarnings("unchecked") - Query namedQuery = session.getNamedQuery("callGetFoosByName").setParameter("fooName", "NewFooName"); - List allFoosByName2 = namedQuery.list(); - for (Foo foo : allFoosByName2) { - LOGGER.info("getFoosByName() using Native Query : found => {}", foo.toString()); - } - - } -} diff --git a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/transactional/FooTransactionalUnitTest.java b/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/transactional/FooTransactionalUnitTest.java deleted file mode 100644 index 6f2a499bc5..0000000000 --- a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/transactional/FooTransactionalUnitTest.java +++ /dev/null @@ -1,250 +0,0 @@ -package com.baeldung.persistence.service.transactional; - -import com.baeldung.persistence.model.Foo; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; -import org.junit.After; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Repository; -import org.springframework.stereotype.Service; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; -import org.springframework.transaction.IllegalTransactionStateException; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.support.TransactionTemplate; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { PersistenceTransactionalTestConfig.class }, loader = AnnotationConfigContextLoader.class) -@DirtiesContext -public class FooTransactionalUnitTest { - - static abstract class BasicFooDao { - @PersistenceContext private EntityManager entityManager; - - public Foo findOne(final long id) { - return entityManager.find(Foo.class, id); - } - - public Foo create(final Foo entity) { - entityManager.persist(entity); - return entity; - } - } - - @Repository - static class RequiredTransactionalFooDao extends BasicFooDao { - @Override - @Transactional(propagation = Propagation.REQUIRED) - public Foo create(Foo entity) { - return super.create(entity); - } - } - - @Repository - static class RequiresNewTransactionalFooDao extends BasicFooDao { - @Override - @Transactional(propagation = Propagation.REQUIRES_NEW) - public Foo create(Foo entity) { - return super.create(entity); - } - } - - @Repository - static class SupportTransactionalFooDao extends BasicFooDao { - @Override - @Transactional(propagation = Propagation.SUPPORTS) - public Foo create(Foo entity) { - return super.create(entity); - } - } - - @Repository - static class MandatoryTransactionalFooDao extends BasicFooDao { - @Override - @Transactional(propagation = Propagation.MANDATORY) - public Foo create(Foo entity) { - return super.create(entity); - } - } - - @Repository - static class SupportTransactionalFooService { - @Transactional(propagation = Propagation.SUPPORTS) - public Foo identity(Foo entity) { - return entity; - } - } - - @Service - static class MandatoryTransactionalFooService { - @Transactional(propagation = Propagation.MANDATORY) - public Foo identity(Foo entity) { - return entity; - } - } - - @Service - static class NotSupportedTransactionalFooService { - @Transactional(propagation = Propagation.NOT_SUPPORTED) - public Foo identity(Foo entity) { - return entity; - } - } - - @Service - static class NeverTransactionalFooService { - @Transactional(propagation = Propagation.NEVER) - public Foo identity(Foo entity) { - return entity; - } - } - - @Autowired private TransactionTemplate transactionTemplate; - - @Autowired private RequiredTransactionalFooDao requiredTransactionalFooDao; - - @Autowired private RequiresNewTransactionalFooDao requiresNewTransactionalFooDao; - - @Autowired private SupportTransactionalFooDao supportTransactionalFooDao; - - @Autowired private MandatoryTransactionalFooDao mandatoryTransactionalFooDao; - - @Autowired private MandatoryTransactionalFooService mandatoryTransactionalFooService; - - @Autowired private NeverTransactionalFooService neverTransactionalFooService; - - @Autowired private NotSupportedTransactionalFooService notSupportedTransactionalFooService; - - @Autowired private SupportTransactionalFooService supportTransactionalFooService; - - @After - public void tearDown(){ - PersistenceTransactionalTestConfig.clearSpy(); - } - - @Test - public void givenRequiredWithNoActiveTransaction_whenCallCreate_thenExpect1NewAnd0Suspend() { - requiredTransactionalFooDao.create(new Foo("baeldung")); - PersistenceTransactionalTestConfig.TransactionSynchronizationAdapterSpy transactionSpy = PersistenceTransactionalTestConfig.getSpy(); - Assert.assertEquals(0, transactionSpy.getSuspend()); - Assert.assertEquals(1, transactionSpy.getCreate()); - } - - - - @Test - public void givenRequiresNewWithNoActiveTransaction_whenCallCreate_thenExpect1NewAnd0Suspend() { - requiresNewTransactionalFooDao.create(new Foo("baeldung")); - PersistenceTransactionalTestConfig.TransactionSynchronizationAdapterSpy transactionSpy = PersistenceTransactionalTestConfig.getSpy(); - Assert.assertEquals(0, transactionSpy.getSuspend()); - Assert.assertEquals(1, transactionSpy.getCreate()); - } - - @Test - public void givenSupportWithNoActiveTransaction_whenCallService_thenExpect0NewAnd0Suspend() { - supportTransactionalFooService.identity(new Foo("baeldung")); - PersistenceTransactionalTestConfig.TransactionSynchronizationAdapterSpy transactionSpy = PersistenceTransactionalTestConfig.getSpy(); - Assert.assertEquals(0, transactionSpy.getSuspend()); - Assert.assertEquals(0, transactionSpy.getCreate()); - } - - @Test(expected = IllegalTransactionStateException.class) - public void givenMandatoryWithNoActiveTransaction_whenCallService_thenExpectIllegalTransactionStateExceptionWith0NewAnd0Suspend() { - mandatoryTransactionalFooService.identity(new Foo("baeldung")); - PersistenceTransactionalTestConfig.TransactionSynchronizationAdapterSpy transactionSpy = PersistenceTransactionalTestConfig.getSpy(); - Assert.assertEquals(0, transactionSpy.getSuspend()); - Assert.assertEquals(0, transactionSpy.getCreate()); - } - - @Test - public void givenNotSupportWithNoActiveTransaction_whenCallService_thenExpect0NewAnd0Suspend() { - notSupportedTransactionalFooService.identity(new Foo("baeldung")); - PersistenceTransactionalTestConfig.TransactionSynchronizationAdapterSpy transactionSpy = PersistenceTransactionalTestConfig.getSpy(); - Assert.assertEquals(0, transactionSpy.getSuspend()); - Assert.assertEquals(0, transactionSpy.getCreate()); - } - - @Test - public void givenNeverWithNoActiveTransaction_whenCallService_thenExpect0NewAnd0Suspend() { - neverTransactionalFooService.identity(new Foo("baeldung")); - PersistenceTransactionalTestConfig.TransactionSynchronizationAdapterSpy transactionSpy = PersistenceTransactionalTestConfig.getSpy(); - Assert.assertEquals(0, transactionSpy.getSuspend()); - Assert.assertEquals(0, transactionSpy.getCreate()); - } - - @Test - public void givenRequiredWithActiveTransaction_whenCallCreate_thenExpect0NewAnd0Suspend() { - transactionTemplate.execute(status -> { - Foo foo = new Foo("baeldung"); - return requiredTransactionalFooDao.create(foo); - }); - PersistenceTransactionalTestConfig.TransactionSynchronizationAdapterSpy transactionSpy = PersistenceTransactionalTestConfig.getSpy(); - Assert.assertEquals(0, transactionSpy.getSuspend()); - Assert.assertEquals(1, transactionSpy.getCreate()); - } - - @Test - public void givenRequiresNewWithActiveTransaction_whenCallCreate_thenExpect1NewAnd1Suspend() { - transactionTemplate.execute(status -> { - Foo foo = new Foo("baeldung"); - return requiresNewTransactionalFooDao.create(foo); - }); - PersistenceTransactionalTestConfig.TransactionSynchronizationAdapterSpy transactionSpy = PersistenceTransactionalTestConfig.getSpy(); - Assert.assertEquals(1, transactionSpy.getSuspend()); - Assert.assertEquals(2, transactionSpy.getCreate()); - } - - @Test - public void givenSupportWithActiveTransaction_whenCallCreate_thenExpect0NewAnd0Suspend() { - transactionTemplate.execute(status -> { - Foo foo = new Foo("baeldung"); - return supportTransactionalFooDao.create(foo); - }); - PersistenceTransactionalTestConfig.TransactionSynchronizationAdapterSpy transactionSpy = PersistenceTransactionalTestConfig.getSpy(); - Assert.assertEquals(0, transactionSpy.getSuspend()); - Assert.assertEquals(1, transactionSpy.getCreate()); - } - - @Test - public void givenMandatoryWithActiveTransaction_whenCallCreate_thenExpect0NewAnd0Suspend() { - - transactionTemplate.execute(status -> { - Foo foo = new Foo("baeldung"); - return mandatoryTransactionalFooDao.create(foo); - }); - - PersistenceTransactionalTestConfig.TransactionSynchronizationAdapterSpy transactionSpy = PersistenceTransactionalTestConfig.getSpy(); - Assert.assertEquals(0, transactionSpy.getSuspend()); - Assert.assertEquals(1, transactionSpy.getCreate()); - } - - @Test - public void givenNotSupportWithActiveTransaction_whenCallCreate_thenExpect0NewAnd1Suspend() { - transactionTemplate.execute(status -> { - Foo foo = new Foo("baeldung"); - return notSupportedTransactionalFooService.identity(foo); - }); - - PersistenceTransactionalTestConfig.TransactionSynchronizationAdapterSpy transactionSpy = PersistenceTransactionalTestConfig.getSpy(); - Assert.assertEquals(1, transactionSpy.getSuspend()); - Assert.assertEquals(1, transactionSpy.getCreate()); - } - - @Test(expected = IllegalTransactionStateException.class) - public void givenNeverWithActiveTransaction_whenCallCreate_thenExpectIllegalTransactionStateExceptionWith0NewAnd0Suspend() { - transactionTemplate.execute(status -> { - Foo foo = new Foo("baeldung"); - return neverTransactionalFooService.identity(foo); - }); - PersistenceTransactionalTestConfig.TransactionSynchronizationAdapterSpy transactionSpy = PersistenceTransactionalTestConfig.getSpy(); - Assert.assertEquals(0, transactionSpy.getSuspend()); - Assert.assertEquals(1, transactionSpy.getCreate()); - } - -} diff --git a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/transactional/PersistenceTransactionalTestConfig.java b/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/transactional/PersistenceTransactionalTestConfig.java deleted file mode 100644 index 72031a2232..0000000000 --- a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/transactional/PersistenceTransactionalTestConfig.java +++ /dev/null @@ -1,149 +0,0 @@ -package com.baeldung.persistence.service.transactional; - -import com.google.common.base.Preconditions; -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.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; -import org.springframework.core.env.Environment; -import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; -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.TransactionDefinition; -import org.springframework.transaction.annotation.EnableTransactionManagement; -import org.springframework.transaction.support.DefaultTransactionStatus; -import org.springframework.transaction.support.TransactionSynchronizationAdapter; -import org.springframework.transaction.support.TransactionSynchronizationManager; -import org.springframework.transaction.support.TransactionTemplate; - -@Configuration -@EnableTransactionManagement -@PropertySource({ "classpath:persistence-h2.properties" }) -@ComponentScan({ "com.baeldung.persistence","com.baeldung.jpa.dao" }) -@EnableJpaRepositories(basePackages = "com.baeldung.jpa.dao") -public class PersistenceTransactionalTestConfig { - - public static class TransactionSynchronizationAdapterSpy extends TransactionSynchronizationAdapter { - private int create, suspend; - - public int getSuspend() { - return suspend; - } - - public int getCreate() { - return create; - } - - public void create() { - create++; - } - - @Override - public void suspend() { - suspend++; - super.suspend(); - } - } - - - public static class JpaTransactionManagerSpy extends JpaTransactionManager { - @Override - protected void prepareSynchronization(DefaultTransactionStatus status, TransactionDefinition definition) { - super.prepareSynchronization(status, definition); - if (status.isNewTransaction()) { - if ( adapterSpyThreadLocal.get() == null ){ - TransactionSynchronizationAdapterSpy spy = new TransactionSynchronizationAdapterSpy(); - TransactionSynchronizationManager.registerSynchronization(spy); - adapterSpyThreadLocal.set(spy); - } - adapterSpyThreadLocal.get().create(); - } - } - } - - private static ThreadLocal adapterSpyThreadLocal = new ThreadLocal<>(); - - @Autowired - private Environment env; - - public PersistenceTransactionalTestConfig() { - super(); - } - - public static TransactionSynchronizationAdapterSpy getSpy(){ - if ( adapterSpyThreadLocal.get() == null ) - return new TransactionSynchronizationAdapterSpy(); - return adapterSpyThreadLocal.get(); - } - - public static void clearSpy(){ - adapterSpyThreadLocal.set(null); - } - - // beans - - @Bean - public LocalContainerEntityManagerFactoryBean entityManagerFactory() { - final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); - em.setDataSource(dataSource()); - em.setPackagesToScan(new String[] { "com.baeldung.persistence.model" }); - - final JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); - em.setJpaVendorAdapter(vendorAdapter); - em.setJpaProperties(additionalProperties()); - - return em; - } - - @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 EntityManagerFactory emf) { - final JpaTransactionManagerSpy transactionManager = new JpaTransactionManagerSpy(); - transactionManager.setEntityManagerFactory(emf); - return transactionManager; - } - - @Bean - public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { - return new PersistenceExceptionTranslationPostProcessor(); - } - - final Properties additionalProperties() { - 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.cache.use_second_level_cache", "false"); - return hibernateProperties; - } - - - @Bean - public TransactionTemplate transactionTemplate(PlatformTransactionManager transactionManager){ - TransactionTemplate template = new TransactionTemplate(transactionManager); - template.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); - return template; - } - - -} \ No newline at end of file diff --git a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/repository/UserRepositoryCommon.java b/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/repository/UserRepositoryCommon.java deleted file mode 100644 index 13b5b4357d..0000000000 --- a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/repository/UserRepositoryCommon.java +++ /dev/null @@ -1,555 +0,0 @@ -package com.baeldung.spring.data.persistence.repository; - -import com.baeldung.spring.data.persistence.config.PersistenceConfig; -import com.baeldung.spring.data.persistence.model.User; -import org.junit.After; -import org.junit.Test; -import org.junit.runner.RunWith; -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.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; -import org.springframework.transaction.annotation.Transactional; - -import javax.persistence.EntityManager; -import javax.persistence.Query; -import java.time.LocalDate; -import java.util.*; -import java.util.function.Predicate; -import java.util.stream.Stream; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.*; - - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) -@DirtiesContext -public 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; - @Autowired - private EntityManager entityManager; - - @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, LocalDate.now(), USER_EMAIL, ACTIVE_STATUS)); - userRepository.save(new User(USER_NAME_PETER, LocalDate.now(), USER_EMAIL2, ACTIVE_STATUS)); - userRepository.save(new User("SAMPLE", LocalDate.now(), USER_EMAIL3, INACTIVE_STATUS)); - - List usersSortByName = userRepository.findAll(Sort.by(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, LocalDate.now(), USER_EMAIL, ACTIVE_STATUS)); - userRepository.save(new User(USER_NAME_PETER, LocalDate.now(), USER_EMAIL2, ACTIVE_STATUS)); - userRepository.save(new User("SAMPLE", LocalDate.now(), USER_EMAIL3, INACTIVE_STATUS)); - - userRepository.findAll(Sort.by(Sort.Direction.ASC, "name")); - - List usersSortByNameLength = userRepository.findAll(Sort.by("LENGTH(name)")); - - assertThat(usersSortByNameLength.get(0) - .getName()).isEqualTo(USER_NAME_ADAM); - } - - @Test - public void givenUsersInDB_WhenFindAllSortWithFunctionQueryAnnotationJPQL_ThenReturnUsersSorted() { - userRepository.save(new User(USER_NAME_ADAM, LocalDate.now(), USER_EMAIL, ACTIVE_STATUS)); - userRepository.save(new User(USER_NAME_PETER, LocalDate.now(), USER_EMAIL2, ACTIVE_STATUS)); - userRepository.save(new User("SAMPLE", LocalDate.now(), USER_EMAIL3, INACTIVE_STATUS)); - - userRepository.findAllUsers(Sort.by("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, LocalDate.now(), USER_EMAIL, ACTIVE_STATUS)); - userRepository.save(new User(USER_NAME_PETER, LocalDate.now(), USER_EMAIL2, ACTIVE_STATUS)); - userRepository.save(new User("SAMPLE", LocalDate.now(), USER_EMAIL3, INACTIVE_STATUS)); - userRepository.save(new User("SAMPLE1", LocalDate.now(), USER_EMAIL4, INACTIVE_STATUS)); - userRepository.save(new User("SAMPLE2", LocalDate.now(), USER_EMAIL5, INACTIVE_STATUS)); - userRepository.save(new User("SAMPLE3", LocalDate.now(), USER_EMAIL6, INACTIVE_STATUS)); - - Page usersPage = userRepository.findAllUsersWithPagination(PageRequest.of(1, 3)); - - assertThat(usersPage.getContent() - .get(0) - .getName()).isEqualTo("SAMPLE1"); - } - - @Test - public void givenUsersInDB_WhenFindAllWithPageRequestQueryAnnotationNative_ThenReturnPageOfUsers() { - userRepository.save(new User(USER_NAME_ADAM, LocalDate.now(), USER_EMAIL, ACTIVE_STATUS)); - userRepository.save(new User(USER_NAME_PETER, LocalDate.now(), USER_EMAIL2, ACTIVE_STATUS)); - userRepository.save(new User("SAMPLE", LocalDate.now(), USER_EMAIL3, INACTIVE_STATUS)); - userRepository.save(new User("SAMPLE1", LocalDate.now(), USER_EMAIL4, INACTIVE_STATUS)); - userRepository.save(new User("SAMPLE2", LocalDate.now(), USER_EMAIL5, INACTIVE_STATUS)); - userRepository.save(new User("SAMPLE3", LocalDate.now(), USER_EMAIL6, INACTIVE_STATUS)); - - Page usersSortByNameLength = userRepository.findAllUsersWithPaginationNative(PageRequest.of(1, 3)); - - assertThat(usersSortByNameLength.getContent() - .get(0) - .getName()).isEqualTo(USER_NAME_PETER); - } - - @Test - @Transactional - public void givenUsersInDB_WhenUpdateStatusForNameModifyingQueryAnnotationJPQL_ThenModifyMatchingUsers() { - userRepository.save(new User("SAMPLE", LocalDate.now(), USER_EMAIL, ACTIVE_STATUS)); - userRepository.save(new User("SAMPLE1", LocalDate.now(), USER_EMAIL2, ACTIVE_STATUS)); - userRepository.save(new User("SAMPLE", LocalDate.now(), USER_EMAIL3, ACTIVE_STATUS)); - userRepository.save(new User("SAMPLE3", LocalDate.now(), 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, USER_EMAIL, ACTIVE_STATUS, true); - userRepository.insertUser(USER_NAME_PETER, 1, USER_EMAIL2, ACTIVE_STATUS, true); - - 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); - } - - - @Test - @Transactional - public void givenTwoUsers_whenFindByNameUsr01_ThenUserUsr01() { - User usr01 = new User("usr01", LocalDate.now(), "usr01@baeldung.com", 1); - User usr02 = new User("usr02", LocalDate.now(), "usr02@baeldung.com", 1); - - userRepository.save(usr01); - userRepository.save(usr02); - - try (Stream users = userRepository.findAllByName("usr01")) { - assertTrue(users.allMatch(usr -> usr.equals(usr01))); - } - } - - @Test - @Transactional - public void givenTwoUsers_whenFindByNameUsr00_ThenNoUsers() { - User usr01 = new User("usr01", LocalDate.now(), "usr01@baeldung.com", 1); - User usr02 = new User("usr02", LocalDate.now(), "usr02@baeldung.com", 1); - - userRepository.save(usr01); - userRepository.save(usr02); - - try (Stream users = userRepository.findAllByName("usr00")) { - assertEquals(0, users.count()); - } - } - - @Test - public void givenTwoUsers_whenFindUsersWithGmailAddress_ThenUserUsr02() { - User usr01 = new User("usr01", LocalDate.now(), "usr01@baeldung.com", 1); - User usr02 = new User("usr02", LocalDate.now(), "usr02@gmail.com", 1); - - userRepository.save(usr01); - userRepository.save(usr02); - - System.out.println(TimeZone.getDefault()); - - List users = userRepository.findUsersWithGmailAddress(); - assertEquals(1, users.size()); - assertEquals(usr02, users.get(0)); - } - - @Test - @Transactional - public void givenTwoUsers_whenDeleteAllByCreationDateAfter_ThenOneUserRemains() { - User usr01 = new User("usr01", LocalDate.of(2018, 1, 1), "usr01@baeldung.com", 1); - User usr02 = new User("usr02", LocalDate.of(2018, 6, 1), "usr02@baeldung.com", 1); - - userRepository.save(usr01); - userRepository.save(usr02); - - userRepository.deleteAllByCreationDateAfter(LocalDate.of(2018, 5, 1)); - - List users = userRepository.findAll(); - - assertEquals(1, users.size()); - assertEquals(usr01, users.get(0)); - } - - @Test - public void givenTwoUsers_whenFindAllUsersByPredicates_ThenUserUsr01() { - User usr01 = new User("usr01", LocalDate.of(2018, 1, 1), "usr01@baeldung.com", 1); - User usr02 = new User("usr02", LocalDate.of(2018, 6, 1), "usr02@baeldung.org", 1); - - userRepository.save(usr01); - userRepository.save(usr02); - - List> predicates = new ArrayList<>(); - predicates.add(usr -> usr.getCreationDate().isAfter(LocalDate.of(2017, 12, 31))); - predicates.add(usr -> usr.getEmail().endsWith(".com")); - - List users = userRepository.findAllUsersByPredicates(predicates); - - assertEquals(1, users.size()); - assertEquals(usr01, users.get(0)); - } - - @Test - @Transactional - public void givenTwoUsers_whenDeactivateUsersNotLoggedInSince_ThenUserUsr02Deactivated() { - User usr01 = new User("usr01", LocalDate.of(2018, 1, 1), "usr01@baeldung.com", 1); - usr01.setLastLoginDate(LocalDate.now()); - User usr02 = new User("usr02", LocalDate.of(2018, 6, 1), "usr02@baeldung.org", 1); - usr02.setLastLoginDate(LocalDate.of(2018, 7, 20)); - - userRepository.save(usr01); - userRepository.save(usr02); - - userRepository.deactivateUsersNotLoggedInSince(LocalDate.of(2018, 8, 1)); - - List users = userRepository.findAllUsers(Sort.by(Sort.Order.asc("name"))); - assertTrue(users.get(0).isActive()); - assertFalse(users.get(1).isActive()); - } - - @Test - @Transactional - public void givenTwoUsers_whenDeleteDeactivatedUsers_ThenUserUsr02Deleted() { - User usr01 = new User("usr01", LocalDate.of(2018, 1, 1), "usr01@baeldung.com", 1); - usr01.setLastLoginDate(LocalDate.now()); - User usr02 = new User("usr02", LocalDate.of(2018, 6, 1), "usr02@baeldung.com", 0); - usr02.setLastLoginDate(LocalDate.of(2018, 7, 20)); - usr02.setActive(false); - - userRepository.save(usr01); - userRepository.save(usr02); - - int deletedUsersCount = userRepository.deleteDeactivatedUsers(); - - List users = userRepository.findAll(); - assertEquals(1, users.size()); - assertEquals(usr01, users.get(0)); - assertEquals(1, deletedUsersCount); - } - - @Test - @Transactional - public void givenTwoUsers_whenAddDeletedColumn_ThenUsersHaveDeletedColumn() { - User usr01 = new User("usr01", LocalDate.of(2018, 1, 1), "usr01@baeldung.com", 1); - usr01.setLastLoginDate(LocalDate.now()); - User usr02 = new User("usr02", LocalDate.of(2018, 6, 1), "usr02@baeldung.org", 1); - usr02.setLastLoginDate(LocalDate.of(2018, 7, 20)); - usr02.setActive(false); - - userRepository.save(usr01); - userRepository.save(usr02); - - userRepository.addDeletedColumn(); - - Query nativeQuery = entityManager.createNativeQuery("select deleted from USERS where NAME = 'usr01'"); - assertEquals(0, nativeQuery.getResultList().get(0)); - } - - @After - public void cleanUp() { - userRepository.deleteAll(); - } -} diff --git a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/repository/UserRepositoryIntegrationTest.java b/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/repository/UserRepositoryIntegrationTest.java deleted file mode 100644 index c76e345fdd..0000000000 --- a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/repository/UserRepositoryIntegrationTest.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.baeldung.spring.data.persistence.repository; - -import com.baeldung.spring.data.persistence.config.PersistenceConfig; -import com.baeldung.spring.data.persistence.model.User; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; -import org.springframework.transaction.annotation.Transactional; - -import java.time.LocalDate; - -import static org.assertj.core.api.Assertions.assertThat; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) -@DirtiesContext -public class UserRepositoryIntegrationTest extends UserRepositoryCommon { - - @Test - @Transactional - public void givenUsersInDBWhenUpdateStatusForNameModifyingQueryAnnotationNativeThenModifyMatchingUsers() { - userRepository.save(new User("SAMPLE", LocalDate.now(), USER_EMAIL, ACTIVE_STATUS)); - userRepository.save(new User("SAMPLE1", LocalDate.now(), USER_EMAIL2, ACTIVE_STATUS)); - userRepository.save(new User("SAMPLE", LocalDate.now(), USER_EMAIL3, ACTIVE_STATUS)); - userRepository.save(new User("SAMPLE3", LocalDate.now(), USER_EMAIL4, ACTIVE_STATUS)); - userRepository.flush(); - - int updatedUsersSize = userRepository.updateUserSetStatusForNameNative(INACTIVE_STATUS, "SAMPLE"); - - assertThat(updatedUsersSize).isEqualTo(2); - } -} diff --git a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/service/AbstractServicePersistenceIntegrationTest.java b/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/service/AbstractServicePersistenceIntegrationTest.java deleted file mode 100644 index 2bccada9fe..0000000000 --- a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/service/AbstractServicePersistenceIntegrationTest.java +++ /dev/null @@ -1,256 +0,0 @@ -package com.baeldung.spring.data.persistence.service; - -import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; -import static org.hamcrest.Matchers.hasItem; -import static org.hamcrest.Matchers.not; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; - -import java.io.Serializable; -import java.util.List; - -import com.baeldung.spring.data.persistence.model.Foo; -import com.baeldung.util.IDUtil; -import org.hamcrest.Matchers; -import org.junit.Ignore; -import org.junit.Test; -import org.springframework.dao.DataAccessException; - -import com.baeldung.persistence.dao.common.IOperations; - -public abstract class AbstractServicePersistenceIntegrationTest { - - // tests - - // find - one - - @Test - /**/public final void givenResourceDoesNotExist_whenResourceIsRetrieved_thenNoResourceIsReceived() { - // When - final Foo createdResource = getApi().findOne(IDUtil.randomPositiveLong()); - - // Then - assertNull(createdResource); - } - - @Test - public void givenResourceExists_whenResourceIsRetrieved_thenNoExceptions() { - final Foo existingResource = persistNewEntity(); - getApi().findOne(existingResource.getId()); - } - - @Test - public void givenResourceDoesNotExist_whenResourceIsRetrieved_thenNoExceptions() { - getApi().findOne(IDUtil.randomPositiveLong()); - } - - @Test - public void givenResourceExists_whenResourceIsRetrieved_thenTheResultIsNotNull() { - final Foo existingResource = persistNewEntity(); - final Foo retrievedResource = getApi().findOne(existingResource.getId()); - assertNotNull(retrievedResource); - } - - @Test - public void givenResourceExists_whenResourceIsRetrieved_thenResourceIsRetrievedCorrectly() { - final Foo existingResource = persistNewEntity(); - final Foo retrievedResource = getApi().findOne(existingResource.getId()); - assertEquals(existingResource, retrievedResource); - } - - // find - one - by name - - // find - all - - @Test - /**/public void whenAllResourcesAreRetrieved_thenNoExceptions() { - getApi().findAll(); - } - - @Test - /**/public void whenAllResourcesAreRetrieved_thenTheResultIsNotNull() { - final List resources = getApi().findAll(); - - assertNotNull(resources); - } - - @Test - /**/public void givenAtLeastOneResourceExists_whenAllResourcesAreRetrieved_thenRetrievedResourcesAreNotEmpty() { - persistNewEntity(); - - // When - final List allResources = getApi().findAll(); - - // Then - assertThat(allResources, not(Matchers. empty())); - } - - @Test - /**/public void givenAnResourceExists_whenAllResourcesAreRetrieved_thenTheExistingResourceIsIndeedAmongThem() { - final Foo existingResource = persistNewEntity(); - - final List resources = getApi().findAll(); - - assertThat(resources, hasItem(existingResource)); - } - - @Test - /**/public void whenAllResourcesAreRetrieved_thenResourcesHaveIds() { - persistNewEntity(); - - // When - final List allResources = getApi().findAll(); - - // Then - for (final Foo resource : allResources) { - assertNotNull(resource.getId()); - } - } - - // create - - @Test(expected = RuntimeException.class) - /**/public void whenNullResourceIsCreated_thenException() { - getApi().create(null); - } - - @Test - /**/public void whenResourceIsCreated_thenNoExceptions() { - persistNewEntity(); - } - - @Test - /**/public void whenResourceIsCreated_thenResourceIsRetrievable() { - final Foo existingResource = persistNewEntity(); - - assertNotNull(getApi().findOne(existingResource.getId())); - } - - @Test - /**/public void whenResourceIsCreated_thenSavedResourceIsEqualToOriginalResource() { - final Foo originalResource = createNewEntity(); - final Foo savedResource = getApi().create(originalResource); - - assertEquals(originalResource, savedResource); - } - - @Test(expected = RuntimeException.class) - public void whenResourceWithFailedConstraintsIsCreated_thenException() { - final Foo invalidResource = createNewEntity(); - invalidate(invalidResource); - - getApi().create(invalidResource); - } - - /** - * -- specific to the persistence engine - */ - @Test(expected = DataAccessException.class) - @Ignore("Hibernate simply ignores the id silently and still saved (tracking this)") - public void whenResourceWithIdIsCreated_thenDataAccessException() { - final Foo resourceWithId = createNewEntity(); - resourceWithId.setId(IDUtil.randomPositiveLong()); - - getApi().create(resourceWithId); - } - - // update - - @Test(expected = RuntimeException.class) - /**/public void whenNullResourceIsUpdated_thenException() { - getApi().update(null); - } - - @Test - /**/public void givenResourceExists_whenResourceIsUpdated_thenNoExceptions() { - // Given - final Foo existingResource = persistNewEntity(); - - // When - getApi().update(existingResource); - } - - /** - * - can also be the ConstraintViolationException which now occurs on the update operation will not be translated; as a consequence, it will be a TransactionSystemException - */ - @Test(expected = RuntimeException.class) - public void whenResourceIsUpdatedWithFailedConstraints_thenException() { - final Foo existingResource = persistNewEntity(); - invalidate(existingResource); - - getApi().update(existingResource); - } - - @Test - /**/public void givenResourceExists_whenResourceIsUpdated_thenUpdatesArePersisted() { - // Given - final Foo existingResource = persistNewEntity(); - - // When - change(existingResource); - getApi().update(existingResource); - - final Foo updatedResource = getApi().findOne(existingResource.getId()); - - // Then - assertEquals(existingResource, updatedResource); - } - - // delete - - // @Test(expected = RuntimeException.class) - // public void givenResourceDoesNotExists_whenResourceIsDeleted_thenException() { - // // When - // getApi().delete(IDUtil.randomPositiveLong()); - // } - // - // @Test(expected = RuntimeException.class) - // public void whenResourceIsDeletedByNegativeId_thenException() { - // // When - // getApi().delete(IDUtil.randomNegativeLong()); - // } - // - // @Test - // public void givenResourceExists_whenResourceIsDeleted_thenNoExceptions() { - // // Given - // final Foo existingResource = persistNewEntity(); - // - // // When - // getApi().delete(existingResource.getId()); - // } - // - // @Test - // /**/public final void givenResourceExists_whenResourceIsDeleted_thenResourceNoLongerExists() { - // // Given - // final Foo existingResource = persistNewEntity(); - // - // // When - // getApi().delete(existingResource.getId()); - // - // // Then - // assertNull(getApi().findOne(existingResource.getId())); - // } - - // template method - - protected Foo createNewEntity() { - return new Foo(randomAlphabetic(6)); - } - - protected abstract IOperations getApi(); - - private final void invalidate(final Foo entity) { - entity.setName(null); - } - - private final void change(final Foo entity) { - entity.setName(randomAlphabetic(6)); - } - - protected Foo persistNewEntity() { - return getApi().create(createNewEntity()); - } - -} diff --git a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/service/FooServicePersistenceIntegrationTest.java b/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/service/FooServicePersistenceIntegrationTest.java deleted file mode 100644 index 8f628c5615..0000000000 --- a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/service/FooServicePersistenceIntegrationTest.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.baeldung.spring.data.persistence.service; - -import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; -import static org.junit.Assert.assertNotNull; - -import com.baeldung.spring.data.persistence.model.Foo; -import com.baeldung.spring.data.persistence.config.PersistenceConfig; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.dao.DataIntegrityViolationException; -import org.springframework.dao.InvalidDataAccessApiUsageException; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; - -import com.baeldung.persistence.dao.common.IOperations; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) -public class FooServicePersistenceIntegrationTest extends AbstractServicePersistenceIntegrationTest { - - @Autowired - private IFooService service; - - // tests - - @Test - public final void whenContextIsBootstrapped_thenNoExceptions() { - // - } - - @Test - public final void whenEntityIsCreated_thenNoExceptions() { - service.create(new Foo(randomAlphabetic(6))); - } - - @Test(expected = DataIntegrityViolationException.class) - public final void whenInvalidEntityIsCreated_thenDataException() { - service.create(new Foo()); - } - - @Test(expected = DataIntegrityViolationException.class) - public final void whenEntityWithLongNameIsCreated_thenDataException() { - service.create(new Foo(randomAlphabetic(2048))); - } - - // custom Query method - - @Test - public final void givenUsingCustomQuery_whenRetrievingEntity_thenFound() { - final String name = randomAlphabetic(6); - service.create(new Foo(name)); - - final Foo retrievedByName = service.retrieveByName(name); - assertNotNull(retrievedByName); - } - - // work in progress - - @Test(expected = InvalidDataAccessApiUsageException.class) - @Ignore("Right now, persist has saveOrUpdate semantics, so this will no longer fail") - public final void whenSameEntityIsCreatedTwice_thenDataException() { - final Foo entity = new Foo(randomAlphabetic(8)); - service.create(entity); - service.create(entity); - } - - // API - - @Override - protected final IOperations getApi() { - return service; - } - -} diff --git a/persistence-modules/spring-persistence-simple/src/test/resources/.gitignore b/persistence-modules/spring-persistence-simple/src/test/resources/.gitignore deleted file mode 100644 index 83c05e60c8..0000000000 --- a/persistence-modules/spring-persistence-simple/src/test/resources/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -*.class - -#folders# -/target -/neoDb* -/data -/src/main/webapp/WEB-INF/classes -*/META-INF/* - -# Packaged files # -*.jar -*.war -*.ear \ No newline at end of file From eb4c3064512dd995d4ea0fe414ef564531df600d Mon Sep 17 00:00:00 2001 From: fdpro Date: Sun, 30 Aug 2020 15:59:35 +0200 Subject: [PATCH 053/263] [JAVA-2306] Moved articles from spring-persistence-simple-2 * https://www.baeldung.com/spring-jdbctemplate-testing went to spring-jdbc * https://www.baeldung.com/spring-jdbctemplate-in-list went to spring-jdbc * https://www.baeldung.com/spring-mock-jndi-datasource went to spring-persistence-simple * Deleted spring-persistence-simple-2 module as all articles have been moved --- persistence-modules/pom.xml | 2 +- .../guide}/CustomSQLErrorCodeTranslator.java | 2 +- .../jdbc/{ => template/guide}/Employee.java | 2 +- .../{ => template/guide}/EmployeeDAO.java | 2 +- .../guide}/EmployeeRowMapper.java | 2 +- .../guide}/config/SpringJdbcConfig.java | 6 +- .../jdbc/template/inclause/Employee.java | 42 ++++++++++++++ .../jdbc/template/inclause}/EmployeeDAO.java | 28 ++++------ .../jdbc/template/testing}/Employee.java | 2 +- .../jdbc/template/testing/EmployeeDAO.java | 19 +++++++ .../template/guide}/application.properties | 0 .../spring/jdbc/template/guide}/schema.sql | 0 .../spring/jdbc/template/guide}/test-data.sql | 0 .../spring/jdbc/template/inclause/schema.sql | 7 +++ .../jdbc/template/inclause/test-data.sql | 7 +++ .../spring/jdbc/template/testing/schema.sql | 7 +++ .../jdbc/template/testing/test-data.sql | 7 +++ .../guide}/EmployeeDAOIntegrationTest.java | 6 +- .../inclause}/EmployeeDAOUnitTest.java | 45 +++------------ .../template/testing/EmployeeDAOUnitTest.java | 56 +++++++++++++++++++ .../spring-persistence-simple-2/README.md | 6 -- .../src/main/resources/jdbc/schema.sql | 6 -- .../src/main/resources/jdbc/test-data.sql | 4 -- .../spring-persistence-simple/.gitignore | 13 +++++ .../spring-persistence-simple/README.md | 25 +++++++++ .../pom.xml | 11 ++-- .../datasource/mock}/datasource.properties | 0 .../src/main/resources/jndi.properties | 2 +- .../datasource/mock}/SimpleJNDIUnitTest.java | 2 +- .../SimpleNamingContextBuilderManualTest.java | 2 +- 30 files changed, 224 insertions(+), 89 deletions(-) rename persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/{ => template/guide}/CustomSQLErrorCodeTranslator.java (93%) rename persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/{ => template/guide}/Employee.java (93%) rename persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/{ => template/guide}/EmployeeDAO.java (99%) rename persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/{ => template/guide}/EmployeeRowMapper.java (92%) rename persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/{ => template/guide}/config/SpringJdbcConfig.java (82%) create mode 100644 persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/inclause/Employee.java rename persistence-modules/{spring-persistence-simple-2/src/main/java/com/baeldung/spring/jdbc => spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/inclause}/EmployeeDAO.java (88%) rename persistence-modules/{spring-persistence-simple-2/src/main/java/com/baeldung/spring/jdbc => spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/testing}/Employee.java (93%) create mode 100644 persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/testing/EmployeeDAO.java rename persistence-modules/spring-jdbc/src/main/resources/{ => com/baeldung/spring/jdbc/template/guide}/application.properties (100%) rename persistence-modules/spring-jdbc/src/main/resources/{jdbc => com/baeldung/spring/jdbc/template/guide}/schema.sql (100%) rename persistence-modules/spring-jdbc/src/main/resources/{jdbc => com/baeldung/spring/jdbc/template/guide}/test-data.sql (100%) create mode 100644 persistence-modules/spring-jdbc/src/main/resources/com/baeldung/spring/jdbc/template/inclause/schema.sql create mode 100644 persistence-modules/spring-jdbc/src/main/resources/com/baeldung/spring/jdbc/template/inclause/test-data.sql create mode 100644 persistence-modules/spring-jdbc/src/main/resources/com/baeldung/spring/jdbc/template/testing/schema.sql create mode 100644 persistence-modules/spring-jdbc/src/main/resources/com/baeldung/spring/jdbc/template/testing/test-data.sql rename persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/{ => template/guide}/EmployeeDAOIntegrationTest.java (94%) rename persistence-modules/{spring-persistence-simple-2/src/test/java/com/baeldung/spring/jdbc => spring-jdbc/src/test/java/com/baeldung/spring/jdbc/template/inclause}/EmployeeDAOUnitTest.java (69%) create mode 100644 persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/template/testing/EmployeeDAOUnitTest.java delete mode 100644 persistence-modules/spring-persistence-simple-2/README.md delete mode 100644 persistence-modules/spring-persistence-simple-2/src/main/resources/jdbc/schema.sql delete mode 100644 persistence-modules/spring-persistence-simple-2/src/main/resources/jdbc/test-data.sql create mode 100644 persistence-modules/spring-persistence-simple/.gitignore create mode 100644 persistence-modules/spring-persistence-simple/README.md rename persistence-modules/{spring-persistence-simple-2 => spring-persistence-simple}/pom.xml (91%) rename persistence-modules/{spring-persistence-simple-2/src/main/resources/jndi => spring-persistence-simple/src/main/resources/com/baeldung/spring/jndi/datasource/mock}/datasource.properties (100%) rename persistence-modules/{spring-persistence-simple-2 => spring-persistence-simple}/src/main/resources/jndi.properties (69%) rename persistence-modules/{spring-persistence-simple-2/src/test/java/com/baeldung/jndi/datasource => spring-persistence-simple/src/test/java/com/baeldung/spring/jndi/datasource/mock}/SimpleJNDIUnitTest.java (95%) rename persistence-modules/{spring-persistence-simple-2/src/test/java/com/baeldung/jndi/datasource => spring-persistence-simple/src/test/java/com/baeldung/spring/jndi/datasource/mock}/SimpleNamingContextBuilderManualTest.java (96%) diff --git a/persistence-modules/pom.xml b/persistence-modules/pom.xml index 1a5ca8df70..4e46c9204b 100644 --- a/persistence-modules/pom.xml +++ b/persistence-modules/pom.xml @@ -86,7 +86,7 @@ spring-jpa-2 spring-jdbc - spring-persistence-simple-2 + spring-persistence-simple diff --git a/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/CustomSQLErrorCodeTranslator.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/guide/CustomSQLErrorCodeTranslator.java similarity index 93% rename from persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/CustomSQLErrorCodeTranslator.java rename to persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/guide/CustomSQLErrorCodeTranslator.java index aa0ffde00c..9beed9f9df 100644 --- a/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/CustomSQLErrorCodeTranslator.java +++ b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/guide/CustomSQLErrorCodeTranslator.java @@ -1,4 +1,4 @@ -package com.baeldung.spring.jdbc; +package com.baeldung.spring.jdbc.template.guide; import java.sql.SQLException; diff --git a/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/Employee.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/guide/Employee.java similarity index 93% rename from persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/Employee.java rename to persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/guide/Employee.java index 84780e30da..32ca9ad0d3 100644 --- a/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/Employee.java +++ b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/guide/Employee.java @@ -1,4 +1,4 @@ -package com.baeldung.spring.jdbc; +package com.baeldung.spring.jdbc.template.guide; public class Employee { private int id; diff --git a/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/EmployeeDAO.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/guide/EmployeeDAO.java similarity index 99% rename from persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/EmployeeDAO.java rename to persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/guide/EmployeeDAO.java index a6d0fe2f3b..11ecd84000 100644 --- a/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/EmployeeDAO.java +++ b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/guide/EmployeeDAO.java @@ -1,4 +1,4 @@ -package com.baeldung.spring.jdbc; +package com.baeldung.spring.jdbc.template.guide; import java.sql.PreparedStatement; import java.sql.SQLException; diff --git a/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/EmployeeRowMapper.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/guide/EmployeeRowMapper.java similarity index 92% rename from persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/EmployeeRowMapper.java rename to persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/guide/EmployeeRowMapper.java index bf55d6160d..f4ea5ac7b6 100644 --- a/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/EmployeeRowMapper.java +++ b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/guide/EmployeeRowMapper.java @@ -1,4 +1,4 @@ -package com.baeldung.spring.jdbc; +package com.baeldung.spring.jdbc.template.guide; import java.sql.ResultSet; import java.sql.SQLException; diff --git a/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/config/SpringJdbcConfig.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/guide/config/SpringJdbcConfig.java similarity index 82% rename from persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/config/SpringJdbcConfig.java rename to persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/guide/config/SpringJdbcConfig.java index d7eb039637..0e81babd9a 100644 --- a/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/config/SpringJdbcConfig.java +++ b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/guide/config/SpringJdbcConfig.java @@ -1,4 +1,4 @@ -package com.baeldung.spring.jdbc.config; +package com.baeldung.spring.jdbc.template.guide.config; import javax.sql.DataSource; @@ -17,8 +17,8 @@ public class SpringJdbcConfig { public DataSource dataSource() { return new EmbeddedDatabaseBuilder() .setType(EmbeddedDatabaseType.H2) - .addScript("classpath:jdbc/schema.sql") - .addScript("classpath:jdbc/test-data.sql") + .addScript("classpath:com/baeldung/spring/jdbc/template/guide/schema.sql") + .addScript("classpath:com/baeldung/spring/jdbc/template/guide/test-data.sql") .build(); } diff --git a/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/inclause/Employee.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/inclause/Employee.java new file mode 100644 index 0000000000..c771033649 --- /dev/null +++ b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/inclause/Employee.java @@ -0,0 +1,42 @@ +package com.baeldung.spring.jdbc.template.inclause; + +public class Employee { + private int id; + + private String firstName; + + private String lastName; + + + public Employee(int id, String firstName, String lastName) { + this.id = id; + this.firstName = firstName; + this.lastName = lastName; + } + + public int getId() { + return id; + } + + public void setId(final int id) { + this.id = id; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(final String lastName) { + this.lastName = lastName; + } + + +} diff --git a/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/spring/jdbc/EmployeeDAO.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/inclause/EmployeeDAO.java similarity index 88% rename from persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/spring/jdbc/EmployeeDAO.java rename to persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/inclause/EmployeeDAO.java index 6e2ad9682d..38b4a58355 100644 --- a/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/spring/jdbc/EmployeeDAO.java +++ b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/inclause/EmployeeDAO.java @@ -1,10 +1,4 @@ -package com.baeldung.spring.jdbc; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import javax.sql.DataSource; +package com.baeldung.spring.jdbc.template.inclause; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; @@ -12,6 +6,11 @@ import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; import org.springframework.jdbc.core.namedparam.SqlParameterSource; import org.springframework.stereotype.Repository; +import javax.sql.DataSource; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + @Repository public class EmployeeDAO { private JdbcTemplate jdbcTemplate; @@ -22,15 +21,11 @@ public class EmployeeDAO { namedJdbcTemplate = new NamedParameterJdbcTemplate(dataSource); } - public int getCountOfEmployees() { - return jdbcTemplate.queryForObject("SELECT COUNT(*) FROM EMPLOYEE", Integer.class); - } - public List getEmployeesFromIdListNamed(List ids) { SqlParameterSource parameters = new MapSqlParameterSource("ids", ids); List employees = namedJdbcTemplate.query( - "SELECT * FROM EMPLOYEE WHERE id IN (:ids)", - parameters, + "SELECT * FROM EMPLOYEE WHERE id IN (:ids)", + parameters, (rs, rowNum) -> new Employee(rs.getInt("id"), rs.getString("first_name"), rs.getString("last_name"))); return employees; @@ -39,8 +34,8 @@ public class EmployeeDAO { public List getEmployeesFromIdList(List ids) { String inSql = String.join(",", Collections.nCopies(ids.size(), "?")); List employees = jdbcTemplate.query( - String.format("SELECT * FROM EMPLOYEE WHERE id IN (%s)", inSql), - ids.toArray(), + String.format("SELECT * FROM EMPLOYEE WHERE id IN (%s)", inSql), + ids.toArray(), (rs, rowNum) -> new Employee(rs.getInt("id"), rs.getString("first_name"), rs.getString("last_name"))); return employees; @@ -56,12 +51,11 @@ public class EmployeeDAO { jdbcTemplate.batchUpdate("INSERT INTO employee_tmp VALUES(?)", employeeIds); List employees = jdbcTemplate.query( - "SELECT * FROM EMPLOYEE WHERE id IN (SELECT id FROM employee_tmp)", + "SELECT * FROM EMPLOYEE WHERE id IN (SELECT id FROM employee_tmp)", (rs, rowNum) -> new Employee(rs.getInt("id"), rs.getString("first_name"), rs.getString("last_name"))); jdbcTemplate.update("DELETE FROM employee_tmp"); return employees; } - } diff --git a/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/spring/jdbc/Employee.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/testing/Employee.java similarity index 93% rename from persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/spring/jdbc/Employee.java rename to persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/testing/Employee.java index adc2255ca4..80be897827 100644 --- a/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/spring/jdbc/Employee.java +++ b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/testing/Employee.java @@ -1,4 +1,4 @@ -package com.baeldung.spring.jdbc; +package com.baeldung.spring.jdbc.template.testing; public class Employee { private int id; diff --git a/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/testing/EmployeeDAO.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/testing/EmployeeDAO.java new file mode 100644 index 0000000000..64b146fd47 --- /dev/null +++ b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/testing/EmployeeDAO.java @@ -0,0 +1,19 @@ +package com.baeldung.spring.jdbc.template.testing; + +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Repository; + +import javax.sql.DataSource; + +@Repository +public class EmployeeDAO { + private JdbcTemplate jdbcTemplate; + + public void setDataSource(DataSource dataSource) { + jdbcTemplate = new JdbcTemplate(dataSource); + } + + public int getCountOfEmployees() { + return jdbcTemplate.queryForObject("SELECT COUNT(*) FROM EMPLOYEE", Integer.class); + } +} \ No newline at end of file diff --git a/persistence-modules/spring-jdbc/src/main/resources/application.properties b/persistence-modules/spring-jdbc/src/main/resources/com/baeldung/spring/jdbc/template/guide/application.properties similarity index 100% rename from persistence-modules/spring-jdbc/src/main/resources/application.properties rename to persistence-modules/spring-jdbc/src/main/resources/com/baeldung/spring/jdbc/template/guide/application.properties diff --git a/persistence-modules/spring-jdbc/src/main/resources/jdbc/schema.sql b/persistence-modules/spring-jdbc/src/main/resources/com/baeldung/spring/jdbc/template/guide/schema.sql similarity index 100% rename from persistence-modules/spring-jdbc/src/main/resources/jdbc/schema.sql rename to persistence-modules/spring-jdbc/src/main/resources/com/baeldung/spring/jdbc/template/guide/schema.sql diff --git a/persistence-modules/spring-jdbc/src/main/resources/jdbc/test-data.sql b/persistence-modules/spring-jdbc/src/main/resources/com/baeldung/spring/jdbc/template/guide/test-data.sql similarity index 100% rename from persistence-modules/spring-jdbc/src/main/resources/jdbc/test-data.sql rename to persistence-modules/spring-jdbc/src/main/resources/com/baeldung/spring/jdbc/template/guide/test-data.sql diff --git a/persistence-modules/spring-jdbc/src/main/resources/com/baeldung/spring/jdbc/template/inclause/schema.sql b/persistence-modules/spring-jdbc/src/main/resources/com/baeldung/spring/jdbc/template/inclause/schema.sql new file mode 100644 index 0000000000..ef4460e267 --- /dev/null +++ b/persistence-modules/spring-jdbc/src/main/resources/com/baeldung/spring/jdbc/template/inclause/schema.sql @@ -0,0 +1,7 @@ +CREATE TABLE EMPLOYEE +( + ID int NOT NULL PRIMARY KEY, + FIRST_NAME varchar(255), + LAST_NAME varchar(255), + ADDRESS varchar(255) +); \ No newline at end of file diff --git a/persistence-modules/spring-jdbc/src/main/resources/com/baeldung/spring/jdbc/template/inclause/test-data.sql b/persistence-modules/spring-jdbc/src/main/resources/com/baeldung/spring/jdbc/template/inclause/test-data.sql new file mode 100644 index 0000000000..b9ef8fec25 --- /dev/null +++ b/persistence-modules/spring-jdbc/src/main/resources/com/baeldung/spring/jdbc/template/inclause/test-data.sql @@ -0,0 +1,7 @@ +INSERT INTO EMPLOYEE VALUES (1, 'James', 'Gosling', 'Canada'); + +INSERT INTO EMPLOYEE VALUES (2, 'Donald', 'Knuth', 'USA'); + +INSERT INTO EMPLOYEE VALUES (3, 'Linus', 'Torvalds', 'Finland'); + +INSERT INTO EMPLOYEE VALUES (4, 'Dennis', 'Ritchie', 'USA'); \ No newline at end of file diff --git a/persistence-modules/spring-jdbc/src/main/resources/com/baeldung/spring/jdbc/template/testing/schema.sql b/persistence-modules/spring-jdbc/src/main/resources/com/baeldung/spring/jdbc/template/testing/schema.sql new file mode 100644 index 0000000000..ef4460e267 --- /dev/null +++ b/persistence-modules/spring-jdbc/src/main/resources/com/baeldung/spring/jdbc/template/testing/schema.sql @@ -0,0 +1,7 @@ +CREATE TABLE EMPLOYEE +( + ID int NOT NULL PRIMARY KEY, + FIRST_NAME varchar(255), + LAST_NAME varchar(255), + ADDRESS varchar(255) +); \ No newline at end of file diff --git a/persistence-modules/spring-jdbc/src/main/resources/com/baeldung/spring/jdbc/template/testing/test-data.sql b/persistence-modules/spring-jdbc/src/main/resources/com/baeldung/spring/jdbc/template/testing/test-data.sql new file mode 100644 index 0000000000..b9ef8fec25 --- /dev/null +++ b/persistence-modules/spring-jdbc/src/main/resources/com/baeldung/spring/jdbc/template/testing/test-data.sql @@ -0,0 +1,7 @@ +INSERT INTO EMPLOYEE VALUES (1, 'James', 'Gosling', 'Canada'); + +INSERT INTO EMPLOYEE VALUES (2, 'Donald', 'Knuth', 'USA'); + +INSERT INTO EMPLOYEE VALUES (3, 'Linus', 'Torvalds', 'Finland'); + +INSERT INTO EMPLOYEE VALUES (4, 'Dennis', 'Ritchie', 'USA'); \ No newline at end of file diff --git a/persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/EmployeeDAOIntegrationTest.java b/persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/template/guide/EmployeeDAOIntegrationTest.java similarity index 94% rename from persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/EmployeeDAOIntegrationTest.java rename to persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/template/guide/EmployeeDAOIntegrationTest.java index 10f47402be..c29d5c4534 100644 --- a/persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/EmployeeDAOIntegrationTest.java +++ b/persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/template/guide/EmployeeDAOIntegrationTest.java @@ -1,9 +1,11 @@ -package com.baeldung.spring.jdbc; +package com.baeldung.spring.jdbc.template.guide; import java.util.ArrayList; import java.util.List; -import com.baeldung.spring.jdbc.config.SpringJdbcConfig; +import com.baeldung.spring.jdbc.template.guide.Employee; +import com.baeldung.spring.jdbc.template.guide.EmployeeDAO; +import com.baeldung.spring.jdbc.template.guide.config.SpringJdbcConfig; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/persistence-modules/spring-persistence-simple-2/src/test/java/com/baeldung/spring/jdbc/EmployeeDAOUnitTest.java b/persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/template/inclause/EmployeeDAOUnitTest.java similarity index 69% rename from persistence-modules/spring-persistence-simple-2/src/test/java/com/baeldung/spring/jdbc/EmployeeDAOUnitTest.java rename to persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/template/inclause/EmployeeDAOUnitTest.java index bbc688293b..d9a858302b 100644 --- a/persistence-modules/spring-persistence-simple-2/src/test/java/com/baeldung/spring/jdbc/EmployeeDAOUnitTest.java +++ b/persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/template/inclause/EmployeeDAOUnitTest.java @@ -1,22 +1,19 @@ -package com.baeldung.spring.jdbc; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import java.util.ArrayList; -import java.util.List; - -import javax.sql.DataSource; +package com.baeldung.spring.jdbc.template.inclause; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; -import org.springframework.test.util.ReflectionTestUtils; + +import javax.sql.DataSource; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; @RunWith(MockitoJUnitRunner.class) @@ -30,33 +27,9 @@ public class EmployeeDAOUnitTest { public void setup() { dataSource = new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2) .generateUniqueName(true) - .addScript("classpath:jdbc/schema.sql") - .addScript("classpath:jdbc/test-data.sql") + .addScript("classpath:com/baeldung/spring/jdbc/template/inclause/schema.sql") + .addScript("classpath:com/baeldung/spring/jdbc/template/inclause/test-data.sql") .build(); - - } - - @Test - public void whenMockJdbcTemplate_thenReturnCorrectEmployeeCount() { - EmployeeDAO employeeDAO = new EmployeeDAO(); - ReflectionTestUtils.setField(employeeDAO, "jdbcTemplate", jdbcTemplate); - Mockito.when(jdbcTemplate.queryForObject("SELECT COUNT(*) FROM EMPLOYEE", Integer.class)) - .thenReturn(4); - - assertEquals(4, employeeDAO.getCountOfEmployees()); - - Mockito.when(jdbcTemplate.queryForObject(Mockito.anyString(), Mockito.eq(Integer.class))) - .thenReturn(3); - - assertEquals(3, employeeDAO.getCountOfEmployees()); - } - - @Test - public void whenInjectInMemoryDataSource_thenReturnCorrectEmployeeCount() { - EmployeeDAO employeeDAO = new EmployeeDAO(); - employeeDAO.setDataSource(dataSource); - - assertEquals(4, employeeDAO.getCountOfEmployees()); } @Test diff --git a/persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/template/testing/EmployeeDAOUnitTest.java b/persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/template/testing/EmployeeDAOUnitTest.java new file mode 100644 index 0000000000..3609300c2d --- /dev/null +++ b/persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/template/testing/EmployeeDAOUnitTest.java @@ -0,0 +1,56 @@ +package com.baeldung.spring.jdbc.template.testing; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.MockitoJUnitRunner; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; +import org.springframework.test.util.ReflectionTestUtils; + +import javax.sql.DataSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +@RunWith(MockitoJUnitRunner.class) +public class EmployeeDAOUnitTest { + @Mock + JdbcTemplate jdbcTemplate; + + DataSource dataSource; + + @Before + public void setup() { + dataSource = new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2) + .generateUniqueName(true) + .addScript("classpath:com/baeldung/spring/jdbc/template/testing/schema.sql") + .addScript("classpath:com/baeldung/spring/jdbc/template/testing/test-data.sql") + .build(); + } + + @Test + public void whenMockJdbcTemplate_thenReturnCorrectEmployeeCount() { + EmployeeDAO employeeDAO = new EmployeeDAO(); + ReflectionTestUtils.setField(employeeDAO, "jdbcTemplate", jdbcTemplate); + Mockito.when(jdbcTemplate.queryForObject("SELECT COUNT(*) FROM EMPLOYEE", Integer.class)) + .thenReturn(4); + + assertEquals(4, employeeDAO.getCountOfEmployees()); + + Mockito.when(jdbcTemplate.queryForObject(Mockito.anyString(), Mockito.eq(Integer.class))) + .thenReturn(3); + + assertEquals(3, employeeDAO.getCountOfEmployees()); + } + + @Test + public void whenInjectInMemoryDataSource_thenReturnCorrectEmployeeCount() { + EmployeeDAO employeeDAO = new EmployeeDAO(); + employeeDAO.setDataSource(dataSource); + + assertEquals(4, employeeDAO.getCountOfEmployees()); + } +} diff --git a/persistence-modules/spring-persistence-simple-2/README.md b/persistence-modules/spring-persistence-simple-2/README.md deleted file mode 100644 index d80c7efc57..0000000000 --- a/persistence-modules/spring-persistence-simple-2/README.md +++ /dev/null @@ -1,6 +0,0 @@ -### Relevant Articles: - -- [Spring JdbcTemplate Unit Testing](https://www.baeldung.com/spring-jdbctemplate-testing) -- [Using a List of Values in a JdbcTemplate IN Clause](https://www.baeldung.com/spring-jdbctemplate-in-list) -- [Transactional Annotations: Spring vs. JTA](https://www.baeldung.com/spring-vs-jta-transactional) -- [Test a Mock JNDI Datasource with Spring](https://www.baeldung.com/spring-mock-jndi-datasource) diff --git a/persistence-modules/spring-persistence-simple-2/src/main/resources/jdbc/schema.sql b/persistence-modules/spring-persistence-simple-2/src/main/resources/jdbc/schema.sql deleted file mode 100644 index be102431ca..0000000000 --- a/persistence-modules/spring-persistence-simple-2/src/main/resources/jdbc/schema.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE TABLE EMPLOYEE -( - ID int NOT NULL PRIMARY KEY, - FIRST_NAME varchar(255), - LAST_NAME varchar(255) -); \ No newline at end of file diff --git a/persistence-modules/spring-persistence-simple-2/src/main/resources/jdbc/test-data.sql b/persistence-modules/spring-persistence-simple-2/src/main/resources/jdbc/test-data.sql deleted file mode 100644 index 5421c09849..0000000000 --- a/persistence-modules/spring-persistence-simple-2/src/main/resources/jdbc/test-data.sql +++ /dev/null @@ -1,4 +0,0 @@ -INSERT INTO EMPLOYEE VALUES (1, 'James', 'Gosling'); -INSERT INTO EMPLOYEE VALUES (2, 'Donald', 'Knuth'); -INSERT INTO EMPLOYEE VALUES (3, 'Linus', 'Torvalds'); -INSERT INTO EMPLOYEE VALUES (4, 'Dennis', 'Ritchie'); \ No newline at end of file diff --git a/persistence-modules/spring-persistence-simple/.gitignore b/persistence-modules/spring-persistence-simple/.gitignore new file mode 100644 index 0000000000..83c05e60c8 --- /dev/null +++ b/persistence-modules/spring-persistence-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/persistence-modules/spring-persistence-simple/README.md b/persistence-modules/spring-persistence-simple/README.md new file mode 100644 index 0000000000..d665433eef --- /dev/null +++ b/persistence-modules/spring-persistence-simple/README.md @@ -0,0 +1,25 @@ +========= + +## Spring Persistence Example Project + + +### Relevant Articles: +- [A Guide to JPA with Spring](https://www.baeldung.com/the-persistence-layer-with-spring-and-jpa) +- [Bootstrapping Hibernate 5 with Spring](http://www.baeldung.com/hibernate-5-spring) +- [The DAO with Spring and Hibernate](https://www.baeldung.com/persistence-layer-with-spring-and-hibernate) +- [Simplify the DAO with Spring and Java Generics](https://www.baeldung.com/simplifying-the-data-access-layer-with-spring-and-java-generics) +- [Transactions with Spring and JPA](https://www.baeldung.com/transaction-configuration-with-jpa-and-spring) +- [Introduction to Spring Data JPA](http://www.baeldung.com/the-persistence-layer-with-spring-data-jpa) +- [Spring Data JPA @Query](http://www.baeldung.com/spring-data-jpa-query) +- [Spring JDBC](https://www.baeldung.com/spring-jdbc-jdbctemplate) +- [Transaction Propagation and Isolation in Spring @Transactional](https://www.baeldung.com/spring-transactional-propagation-isolation) + +### Eclipse Config +After importing the project into Eclipse, you may see the following error: +"No persistence xml file found in project" + +This can be ignored: +- Project -> Properties -> Java Persistance -> JPA -> Error/Warnings -> Select Ignore on "No persistence xml file found in project" +Or: +- Eclipse -> Preferences - Validation - disable the "Build" execution of the JPA Validator + diff --git a/persistence-modules/spring-persistence-simple-2/pom.xml b/persistence-modules/spring-persistence-simple/pom.xml similarity index 91% rename from persistence-modules/spring-persistence-simple-2/pom.xml rename to persistence-modules/spring-persistence-simple/pom.xml index b8f3b384a2..6ca0f3f025 100644 --- a/persistence-modules/spring-persistence-simple-2/pom.xml +++ b/persistence-modules/spring-persistence-simple/pom.xml @@ -2,9 +2,9 @@ 4.0.0 - spring-persistence-simple-2 + spring-persistence-simple 0.1-SNAPSHOT - spring-persistence-simple-2 + spring-persistence-simple com.baeldung @@ -32,7 +32,7 @@ ${h2.version} test - + com.github.h-thurow @@ -48,9 +48,9 @@ test - org.mockito + org.mockito mockito-core - ${mockito.version} + ${mockito.version} test @@ -65,5 +65,4 @@ 3.3.3
- \ No newline at end of file diff --git a/persistence-modules/spring-persistence-simple-2/src/main/resources/jndi/datasource.properties b/persistence-modules/spring-persistence-simple/src/main/resources/com/baeldung/spring/jndi/datasource/mock/datasource.properties similarity index 100% rename from persistence-modules/spring-persistence-simple-2/src/main/resources/jndi/datasource.properties rename to persistence-modules/spring-persistence-simple/src/main/resources/com/baeldung/spring/jndi/datasource/mock/datasource.properties diff --git a/persistence-modules/spring-persistence-simple-2/src/main/resources/jndi.properties b/persistence-modules/spring-persistence-simple/src/main/resources/jndi.properties similarity index 69% rename from persistence-modules/spring-persistence-simple-2/src/main/resources/jndi.properties rename to persistence-modules/spring-persistence-simple/src/main/resources/jndi.properties index d976f16c02..4ab5b3ba8b 100644 --- a/persistence-modules/spring-persistence-simple-2/src/main/resources/jndi.properties +++ b/persistence-modules/spring-persistence-simple/src/main/resources/jndi.properties @@ -3,4 +3,4 @@ org.osjava.sj.jndi.shared=true org.osjava.sj.delimiter=. jndi.syntax.separator=/ org.osjava.sj.space=java:/comp/env -org.osjava.sj.root=src/main/resources/jndi +org.osjava.sj.root=src/main/resources/com/baeldung/spring/jndi/datasource/mock diff --git a/persistence-modules/spring-persistence-simple-2/src/test/java/com/baeldung/jndi/datasource/SimpleJNDIUnitTest.java b/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/jndi/datasource/mock/SimpleJNDIUnitTest.java similarity index 95% rename from persistence-modules/spring-persistence-simple-2/src/test/java/com/baeldung/jndi/datasource/SimpleJNDIUnitTest.java rename to persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/jndi/datasource/mock/SimpleJNDIUnitTest.java index 37f33b1192..6576962609 100644 --- a/persistence-modules/spring-persistence-simple-2/src/test/java/com/baeldung/jndi/datasource/SimpleJNDIUnitTest.java +++ b/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/jndi/datasource/mock/SimpleJNDIUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.jndi.datasource; +package com.baeldung.spring.jndi.datasource.mock; import static org.junit.Assert.assertEquals; diff --git a/persistence-modules/spring-persistence-simple-2/src/test/java/com/baeldung/jndi/datasource/SimpleNamingContextBuilderManualTest.java b/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/jndi/datasource/mock/SimpleNamingContextBuilderManualTest.java similarity index 96% rename from persistence-modules/spring-persistence-simple-2/src/test/java/com/baeldung/jndi/datasource/SimpleNamingContextBuilderManualTest.java rename to persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/jndi/datasource/mock/SimpleNamingContextBuilderManualTest.java index ac33be1c6f..f4c3e012f9 100644 --- a/persistence-modules/spring-persistence-simple-2/src/test/java/com/baeldung/jndi/datasource/SimpleNamingContextBuilderManualTest.java +++ b/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/jndi/datasource/mock/SimpleNamingContextBuilderManualTest.java @@ -1,4 +1,4 @@ -package com.baeldung.jndi.datasource; +package com.baeldung.spring.jndi.datasource.mock; import static org.junit.Assert.assertNotNull; From 910bda6ef1215e1e8933ccbbe2de0a4b5bd1f1e5 Mon Sep 17 00:00:00 2001 From: fdpro Date: Mon, 31 Aug 2020 15:46:07 +0200 Subject: [PATCH 054/263] [JAVA-2306] Fixed READMEs * spring-jpa-2 * spring-data-jpa-repo-2 * spring-data-jpa-query-2 * spring-jdbc * spring-persistence-simple --- persistence-modules/spring-data-jpa-query-2/README.md | 1 + persistence-modules/spring-data-jpa-query/README.md | 1 - persistence-modules/spring-data-jpa-repo-2/README.md | 5 +++++ persistence-modules/spring-data-jpa-repo/README.md | 1 + persistence-modules/spring-jdbc/README.md | 6 ++++++ persistence-modules/spring-jpa-2/README.md | 5 +++++ persistence-modules/spring-persistence-simple/README.md | 9 +-------- 7 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 persistence-modules/spring-data-jpa-repo-2/README.md create mode 100644 persistence-modules/spring-jdbc/README.md diff --git a/persistence-modules/spring-data-jpa-query-2/README.md b/persistence-modules/spring-data-jpa-query-2/README.md index a4d657d4c6..1cb3d54da9 100644 --- a/persistence-modules/spring-data-jpa-query-2/README.md +++ b/persistence-modules/spring-data-jpa-query-2/README.md @@ -4,6 +4,7 @@ This module contains articles about querying data using Spring Data JPA ### Relevant Articles: - [Use Criteria Queries in a Spring Data Application](https://www.baeldung.com/spring-data-criteria-queries) +- [Query Entities by Dates and Times with Spring Data JPA](https://www.baeldung.com/spring-data-jpa-query-by-date) - More articles: [[<-- prev]](../spring-data-jpa-query) ### Eclipse Config diff --git a/persistence-modules/spring-data-jpa-query/README.md b/persistence-modules/spring-data-jpa-query/README.md index 34e397394b..27443c2026 100644 --- a/persistence-modules/spring-data-jpa-query/README.md +++ b/persistence-modules/spring-data-jpa-query/README.md @@ -3,7 +3,6 @@ This module contains articles about querying data using Spring Data JPA ### Relevant Articles: -- [Query Entities by Dates and Times with Spring Data JPA](https://www.baeldung.com/spring-data-jpa-query-by-date) - [The Exists Query in Spring Data](https://www.baeldung.com/spring-data-exists-query) - [Customizing the Result of JPA Queries with Aggregation Functions](https://www.baeldung.com/jpa-queries-custom-result-with-aggregation-functions) - [Limiting Query Results with JPA and Spring Data JPA](https://www.baeldung.com/jpa-limit-query-results) diff --git a/persistence-modules/spring-data-jpa-repo-2/README.md b/persistence-modules/spring-data-jpa-repo-2/README.md new file mode 100644 index 0000000000..de5188c1ad --- /dev/null +++ b/persistence-modules/spring-data-jpa-repo-2/README.md @@ -0,0 +1,5 @@ +## Spring Data JPA - Repositories + +### Relevant Articles: +- [Introduction to Spring Data JPA](https://www.baeldung.com/the-persistence-layer-with-spring-data-jpa) +- More articles: [[<-- prev]](/spring-data-jpa-repo/) \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-repo/README.md b/persistence-modules/spring-data-jpa-repo/README.md index 284a7ac2b5..1a95340a97 100644 --- a/persistence-modules/spring-data-jpa-repo/README.md +++ b/persistence-modules/spring-data-jpa-repo/README.md @@ -11,6 +11,7 @@ This module contains articles about repositories in Spring Data JPA - [Spring Data Composable Repositories](https://www.baeldung.com/spring-data-composable-repositories) - [Spring Data JPA Repository Populators](https://www.baeldung.com/spring-data-jpa-repository-populators) - [Calling Stored Procedures from Spring Data JPA Repositories](https://www.baeldung.com/spring-data-jpa-stored-procedures) +- More articles: [[--> next]](/spring-data-jpa-repo-2/) ### Eclipse Config After importing the project into Eclipse, you may see the following error: diff --git a/persistence-modules/spring-jdbc/README.md b/persistence-modules/spring-jdbc/README.md new file mode 100644 index 0000000000..58d7bdec43 --- /dev/null +++ b/persistence-modules/spring-jdbc/README.md @@ -0,0 +1,6 @@ +## Spring JDBC + +### Relevant Articles: +- [Spring JDBC Template](https://www.baeldung.com/spring-jdbc-jdbctemplate) +- [Spring JDBC Template Testing](https://www.baeldung.com/spring-jdbctemplate-testing) +- [Spring JDBC Template In Clause](https://www.baeldung.com/spring-jdbctemplate-in-list) \ No newline at end of file diff --git a/persistence-modules/spring-jpa-2/README.md b/persistence-modules/spring-jpa-2/README.md index b1786f49bd..fe661c2f28 100644 --- a/persistence-modules/spring-jpa-2/README.md +++ b/persistence-modules/spring-jpa-2/README.md @@ -2,4 +2,9 @@ ### Relevant Articles: - [Many-To-Many Relationship in JPA](https://www.baeldung.com/jpa-many-to-many) +- [A Guide to JPA with Spring](https://www.baeldung.com/the-persistence-layer-with-spring-and-jpa) +- [Bootstrapping Hibernate 5 with Spring](https://www.baeldung.com/hibernate-5-spring) +- [Transactions with Spring and JPA](https://www.baeldung.com/transaction-configuration-with-jpa-and-spring) +- [The DAO with Spring and Hibernate](https://www.baeldung.com/persistence-layer-with-spring-and-hibernate) +- [Simplify the DAO with Spring and Java Generics](https://www.baeldung.com/simplifying-the-data-access-layer-with-spring-and-java-generics) - More articles: [[<-- prev]](/spring-jpa) \ No newline at end of file diff --git a/persistence-modules/spring-persistence-simple/README.md b/persistence-modules/spring-persistence-simple/README.md index d665433eef..3239ec993b 100644 --- a/persistence-modules/spring-persistence-simple/README.md +++ b/persistence-modules/spring-persistence-simple/README.md @@ -4,15 +4,8 @@ ### Relevant Articles: -- [A Guide to JPA with Spring](https://www.baeldung.com/the-persistence-layer-with-spring-and-jpa) -- [Bootstrapping Hibernate 5 with Spring](http://www.baeldung.com/hibernate-5-spring) -- [The DAO with Spring and Hibernate](https://www.baeldung.com/persistence-layer-with-spring-and-hibernate) -- [Simplify the DAO with Spring and Java Generics](https://www.baeldung.com/simplifying-the-data-access-layer-with-spring-and-java-generics) -- [Transactions with Spring and JPA](https://www.baeldung.com/transaction-configuration-with-jpa-and-spring) -- [Introduction to Spring Data JPA](http://www.baeldung.com/the-persistence-layer-with-spring-data-jpa) -- [Spring Data JPA @Query](http://www.baeldung.com/spring-data-jpa-query) -- [Spring JDBC](https://www.baeldung.com/spring-jdbc-jdbctemplate) - [Transaction Propagation and Isolation in Spring @Transactional](https://www.baeldung.com/spring-transactional-propagation-isolation) +- [Mock JNDI Datasource](https://www.baeldung.com/spring-mock-jndi-datasource) ### Eclipse Config After importing the project into Eclipse, you may see the following error: From 3b41d6352dafe7dc2788fb32d37adb6df803f486 Mon Sep 17 00:00:00 2001 From: fdpro Date: Mon, 31 Aug 2020 16:29:31 +0200 Subject: [PATCH 055/263] [JAVA-2306] Moved last article to spring-jdbc --- .../spring/jdbc/autogenkey/config/PersistenceConfig.java | 2 +- .../autogenkey/repository/MessageRepositoryJDBCTemplate.java | 0 .../repository/MessageRepositorySimpleJDBCInsert.java | 0 .../com/baeldung/spring/jdbc/autogenkey}/autogenkey-schema.sql | 0 .../baeldung/spring/jdbc/autogenkey/GetAutoGenKeyByJDBC.java | 2 +- 5 files changed, 2 insertions(+), 2 deletions(-) rename persistence-modules/{spring-jpa => spring-jdbc}/src/main/java/com/baeldung/spring/jdbc/autogenkey/config/PersistenceConfig.java (90%) rename persistence-modules/{spring-jpa => spring-jdbc}/src/main/java/com/baeldung/spring/jdbc/autogenkey/repository/MessageRepositoryJDBCTemplate.java (100%) rename persistence-modules/{spring-jpa => spring-jdbc}/src/main/java/com/baeldung/spring/jdbc/autogenkey/repository/MessageRepositorySimpleJDBCInsert.java (100%) rename persistence-modules/{spring-jpa/src/main/resources => spring-jdbc/src/main/resources/com/baeldung/spring/jdbc/autogenkey}/autogenkey-schema.sql (100%) rename persistence-modules/{spring-jpa => spring-jdbc}/src/test/java/com/baeldung/spring/jdbc/autogenkey/GetAutoGenKeyByJDBC.java (93%) diff --git a/persistence-modules/spring-jpa/src/main/java/com/baeldung/spring/jdbc/autogenkey/config/PersistenceConfig.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/autogenkey/config/PersistenceConfig.java similarity index 90% rename from persistence-modules/spring-jpa/src/main/java/com/baeldung/spring/jdbc/autogenkey/config/PersistenceConfig.java rename to persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/autogenkey/config/PersistenceConfig.java index d1f8864357..6d36ac709f 100644 --- a/persistence-modules/spring-jpa/src/main/java/com/baeldung/spring/jdbc/autogenkey/config/PersistenceConfig.java +++ b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/autogenkey/config/PersistenceConfig.java @@ -16,7 +16,7 @@ public class PersistenceConfig { public DataSource dataSource(Environment env) { return new EmbeddedDatabaseBuilder() .setType(EmbeddedDatabaseType.H2) - .addScript("autogenkey-schema.sql") + .addScript("com/baeldung/spring/jdbc/autogenkey/autogenkey-schema.sql") .build(); } diff --git a/persistence-modules/spring-jpa/src/main/java/com/baeldung/spring/jdbc/autogenkey/repository/MessageRepositoryJDBCTemplate.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/autogenkey/repository/MessageRepositoryJDBCTemplate.java similarity index 100% rename from persistence-modules/spring-jpa/src/main/java/com/baeldung/spring/jdbc/autogenkey/repository/MessageRepositoryJDBCTemplate.java rename to persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/autogenkey/repository/MessageRepositoryJDBCTemplate.java diff --git a/persistence-modules/spring-jpa/src/main/java/com/baeldung/spring/jdbc/autogenkey/repository/MessageRepositorySimpleJDBCInsert.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/autogenkey/repository/MessageRepositorySimpleJDBCInsert.java similarity index 100% rename from persistence-modules/spring-jpa/src/main/java/com/baeldung/spring/jdbc/autogenkey/repository/MessageRepositorySimpleJDBCInsert.java rename to persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/autogenkey/repository/MessageRepositorySimpleJDBCInsert.java diff --git a/persistence-modules/spring-jpa/src/main/resources/autogenkey-schema.sql b/persistence-modules/spring-jdbc/src/main/resources/com/baeldung/spring/jdbc/autogenkey/autogenkey-schema.sql similarity index 100% rename from persistence-modules/spring-jpa/src/main/resources/autogenkey-schema.sql rename to persistence-modules/spring-jdbc/src/main/resources/com/baeldung/spring/jdbc/autogenkey/autogenkey-schema.sql diff --git a/persistence-modules/spring-jpa/src/test/java/com/baeldung/spring/jdbc/autogenkey/GetAutoGenKeyByJDBC.java b/persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/autogenkey/GetAutoGenKeyByJDBC.java similarity index 93% rename from persistence-modules/spring-jpa/src/test/java/com/baeldung/spring/jdbc/autogenkey/GetAutoGenKeyByJDBC.java rename to persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/autogenkey/GetAutoGenKeyByJDBC.java index f0ad853c2a..86a23ecc3e 100644 --- a/persistence-modules/spring-jpa/src/test/java/com/baeldung/spring/jdbc/autogenkey/GetAutoGenKeyByJDBC.java +++ b/persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/autogenkey/GetAutoGenKeyByJDBC.java @@ -7,6 +7,7 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; import org.springframework.test.context.junit4.SpringRunner; import com.baeldung.spring.jdbc.autogenkey.repository.MessageRepositoryJDBCTemplate; @@ -35,7 +36,6 @@ public class GetAutoGenKeyByJDBC { String loadedMessage = messageRepositoryJDBCTemplate.getMessageById(key); assertEquals(MESSAGE_CONTENT, loadedMessage); - } @Test From 16f3fdd81b66fd5ccb1689b5c7d185dc2fe23b36 Mon Sep 17 00:00:00 2001 From: fdpro Date: Tue, 1 Sep 2020 20:05:04 +0200 Subject: [PATCH 056/263] [JAVA-2306] Added .sdkmanrc to .gitignore --- .gitignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index fe56746dfd..88c5e49808 100644 --- a/.gitignore +++ b/.gitignore @@ -87,4 +87,7 @@ transaction.log apache-cxf/cxf-aegis/baeldung.xml testing-modules/report-*.json -libraries-2/*.db \ No newline at end of file +libraries-2/*.db + +# SDKMan +.sdkmanrc From 285890231d8a206eed1db8d0b9a16779f5f3654e Mon Sep 17 00:00:00 2001 From: fdpro Date: Tue, 1 Sep 2020 20:15:58 +0200 Subject: [PATCH 057/263] [JAVA-2306] Removed unnecessary Bar field in Foo class --- .../java/com/baeldung/spring/dao/generics/Foo.java | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/dao/generics/Foo.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/dao/generics/Foo.java index 7849abb25f..33284d9b8e 100644 --- a/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/dao/generics/Foo.java +++ b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/dao/generics/Foo.java @@ -30,18 +30,6 @@ public class Foo implements Serializable { @Column(name = "NAME") private String name; - @ManyToOne(targetEntity = Bar.class, fetch = FetchType.EAGER) - @JoinColumn(name = "BAR_ID") - private Bar bar; - - public Bar getBar() { - return bar; - } - - public void setBar(final Bar bar) { - this.bar = bar; - } - public Long getId() { return id; } @@ -89,5 +77,4 @@ public class Foo implements Serializable { builder.append("Foo [name=").append(name).append("]"); return builder.toString(); } - } From 3fd89261458d9f3dad82047428d2df583b2d0a8a Mon Sep 17 00:00:00 2001 From: Maciej Glowka Date: Wed, 2 Sep 2020 23:56:02 +0200 Subject: [PATCH 058/263] BAEL-4297: fixed unsynchronized classes naming, added slf4j logging --- .../illegalmonitorstate/SynchronizedReceiver.java | 8 ++++++-- .../illegalmonitorstate/SynchronizedSender.java | 8 ++++++-- ...izedReceiver.java => UnsynchronizedReceiver.java} | 12 ++++++++---- ...hronizedSender.java => UnsynchronizedSender.java} | 12 ++++++++---- .../IllegalMonitorStateExceptionUnitTest.java | 4 ++-- 5 files changed, 30 insertions(+), 14 deletions(-) rename core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/{UnSynchronizedReceiver.java => UnsynchronizedReceiver.java} (66%) rename core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/{UnSynchronizedSender.java => UnsynchronizedSender.java} (64%) diff --git a/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/SynchronizedReceiver.java b/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/SynchronizedReceiver.java index 3dffb7b30a..ff6b926cdc 100644 --- a/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/SynchronizedReceiver.java +++ b/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/SynchronizedReceiver.java @@ -1,6 +1,10 @@ package com.baeldung.exceptions.illegalmonitorstate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class SynchronizedReceiver implements Runnable { + private static Logger log = LoggerFactory.getLogger(SynchronizedReceiver.class); private final Data data; private String message; private boolean illegalMonitorStateExceptionOccurred; @@ -16,10 +20,10 @@ public class SynchronizedReceiver implements Runnable { data.wait(); this.message = data.receive(); } catch (InterruptedException e) { - e.printStackTrace(); + log.error("thread was interrupted", e); Thread.currentThread().interrupt(); } catch (IllegalMonitorStateException e) { - e.printStackTrace(); + log.error("illegal monitor state exception occurred", e); illegalMonitorStateExceptionOccurred = true; } } diff --git a/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/SynchronizedSender.java b/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/SynchronizedSender.java index 04bac03e77..1618bc8efa 100644 --- a/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/SynchronizedSender.java +++ b/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/SynchronizedSender.java @@ -1,6 +1,10 @@ package com.baeldung.exceptions.illegalmonitorstate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class SynchronizedSender implements Runnable { + private static Logger log = LoggerFactory.getLogger(SynchronizedSender.class); private final Data data; private boolean illegalMonitorStateExceptionOccurred; @@ -18,10 +22,10 @@ public class SynchronizedSender implements Runnable { data.notifyAll(); } catch (InterruptedException e) { - e.printStackTrace(); + log.error("thread was interrupted", e); Thread.currentThread().interrupt(); } catch (IllegalMonitorStateException e) { - e.printStackTrace(); + log.error("illegal monitor state exception occurred", e); illegalMonitorStateExceptionOccurred = true; } } diff --git a/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/UnSynchronizedReceiver.java b/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/UnsynchronizedReceiver.java similarity index 66% rename from core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/UnSynchronizedReceiver.java rename to core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/UnsynchronizedReceiver.java index a8e8befc4d..3a0b72e6cd 100644 --- a/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/UnSynchronizedReceiver.java +++ b/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/UnsynchronizedReceiver.java @@ -1,11 +1,15 @@ package com.baeldung.exceptions.illegalmonitorstate; -public class UnSynchronizedReceiver implements Runnable { +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class UnsynchronizedReceiver implements Runnable { + private static Logger log = LoggerFactory.getLogger(UnsynchronizedReceiver.class); private final Data data; private String message; private boolean illegalMonitorStateExceptionOccurred; - public UnSynchronizedReceiver(Data data) { + public UnsynchronizedReceiver(Data data) { this.data = data; } @@ -15,10 +19,10 @@ public class UnSynchronizedReceiver implements Runnable { data.wait(); this.message = data.receive(); } catch (InterruptedException e) { - e.printStackTrace(); + log.error("thread was interrupted", e); Thread.currentThread().interrupt(); } catch (IllegalMonitorStateException e) { - e.printStackTrace(); + log.error("illegal monitor state exception occurred", e); illegalMonitorStateExceptionOccurred = true; } } diff --git a/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/UnSynchronizedSender.java b/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/UnsynchronizedSender.java similarity index 64% rename from core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/UnSynchronizedSender.java rename to core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/UnsynchronizedSender.java index eb6fa16649..7f15418bfa 100644 --- a/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/UnSynchronizedSender.java +++ b/core-java-modules/core-java-exceptions-3/src/main/java/com/baeldung/exceptions/illegalmonitorstate/UnsynchronizedSender.java @@ -1,10 +1,14 @@ package com.baeldung.exceptions.illegalmonitorstate; -public class UnSynchronizedSender implements Runnable { +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class UnsynchronizedSender implements Runnable { + private static Logger log = LoggerFactory.getLogger(UnsynchronizedSender.class); private final Data data; private boolean illegalMonitorStateExceptionOccurred; - public UnSynchronizedSender(Data data) { + public UnsynchronizedSender(Data data) { this.data = data; } @@ -17,10 +21,10 @@ public class UnSynchronizedSender implements Runnable { data.notifyAll(); } catch (InterruptedException e) { - e.printStackTrace(); + log.error("thread was interrupted", e); Thread.currentThread().interrupt(); } catch (IllegalMonitorStateException e) { - e.printStackTrace(); + log.error("illegal monitor state exception occurred", e); illegalMonitorStateExceptionOccurred = true; } } diff --git a/core-java-modules/core-java-exceptions-3/src/test/java/com/baeldung/exceptions/illegalmonitorstate/IllegalMonitorStateExceptionUnitTest.java b/core-java-modules/core-java-exceptions-3/src/test/java/com/baeldung/exceptions/illegalmonitorstate/IllegalMonitorStateExceptionUnitTest.java index 800cdc4a7b..a729facdbd 100644 --- a/core-java-modules/core-java-exceptions-3/src/test/java/com/baeldung/exceptions/illegalmonitorstate/IllegalMonitorStateExceptionUnitTest.java +++ b/core-java-modules/core-java-exceptions-3/src/test/java/com/baeldung/exceptions/illegalmonitorstate/IllegalMonitorStateExceptionUnitTest.java @@ -30,7 +30,7 @@ public class IllegalMonitorStateExceptionUnitTest { void whenSyncSenderAndUnSyncReceiverAreUsed_thenIllegalMonitorExceptionShouldNotBeThrown() throws InterruptedException { Data data = new Data(); - UnSynchronizedReceiver receiver = new UnSynchronizedReceiver(data); + UnsynchronizedReceiver receiver = new UnsynchronizedReceiver(data); Thread receiverThread = new Thread(receiver, "receiver-thread"); receiverThread.start(); @@ -55,7 +55,7 @@ public class IllegalMonitorStateExceptionUnitTest { Thread receiverThread = new Thread(receiver, "receiver-thread"); receiverThread.start(); - UnSynchronizedSender sender = new UnSynchronizedSender(data); + UnsynchronizedSender sender = new UnsynchronizedSender(data); Thread senderThread = new Thread(sender, "sender-thread"); senderThread.start(); From 3146226399b94c536a51e6f87bbe21099b185f23 Mon Sep 17 00:00:00 2001 From: Meysam Tamkin Date: Thu, 3 Sep 2020 10:16:45 +0430 Subject: [PATCH 059/263] Fix it some changes --- ...icTest.java => BeforeAndAfterAnnotationsUnitTest.java} | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) rename testing-modules/junit-5/src/main/java/com/baeldung/junit5/nonstatic/{BeforeAfterAllNonStaticTest.java => BeforeAndAfterAnnotationsUnitTest.java} (70%) diff --git a/testing-modules/junit-5/src/main/java/com/baeldung/junit5/nonstatic/BeforeAfterAllNonStaticTest.java b/testing-modules/junit-5/src/main/java/com/baeldung/junit5/nonstatic/BeforeAndAfterAnnotationsUnitTest.java similarity index 70% rename from testing-modules/junit-5/src/main/java/com/baeldung/junit5/nonstatic/BeforeAfterAllNonStaticTest.java rename to testing-modules/junit-5/src/main/java/com/baeldung/junit5/nonstatic/BeforeAndAfterAnnotationsUnitTest.java index 8dbe95ddf8..1bfea8447b 100644 --- a/testing-modules/junit-5/src/main/java/com/baeldung/junit5/nonstatic/BeforeAfterAllNonStaticTest.java +++ b/testing-modules/junit-5/src/main/java/com/baeldung/junit5/nonstatic/BeforeAndAfterAnnotationsUnitTest.java @@ -3,7 +3,7 @@ package com.baeldung.junit5.nonstatic; import org.junit.jupiter.api.*; @TestInstance(TestInstance.Lifecycle.PER_CLASS) -public class BeforeAfterAllNonStaticTest { +public class BeforeAndAfterAnnotationsUnitTest { String input; Long result; @@ -15,11 +15,13 @@ public class BeforeAfterAllNonStaticTest { @AfterAll public void teardown() { - Assertions.assertEquals(77l, result); + input = null; + result = null; } @Test - public void testConvertStringToLong() { + public void whenConvertStringToLong_thenResultShouldBeLong() { result = Long.valueOf(input); + Assertions.assertEquals(77l, result); } } From 1d5b20e70589e7311ebfdf353e8ca232a7c1f3ea Mon Sep 17 00:00:00 2001 From: Sorin Zamfir Date: Thu, 3 Sep 2020 15:46:48 +0300 Subject: [PATCH 060/263] BAEL-4371: Simplified examples --- gradle-5/cmd-line-args/build.gradle | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/gradle-5/cmd-line-args/build.gradle b/gradle-5/cmd-line-args/build.gradle index 57c48e36c3..5399db4815 100644 --- a/gradle-5/cmd-line-args/build.gradle +++ b/gradle-5/cmd-line-args/build.gradle @@ -10,21 +10,17 @@ application { task propertyTypes(){ doLast{ - project.getProperties().values().each { - println "Project property ["+it+"]" - } - - System.getProperties().each { - println "System property ["+it+"]" + if (project.hasProperty("args")) { + println "Our input argument with project property ["+project.getProperty("args")+"]" } + println "Our input argument with system property ["+System.getProperty("args")+"]" } } if (project.hasProperty("args")) { ext.cmdargs = project.getProperty("args") - ext.cmdargsarray = cmdargs.split() } else { - ext.cmdargs = "" + ext.cmdargs = "ls" } task cmdLineJavaExec(type: JavaExec) { @@ -32,15 +28,11 @@ task cmdLineJavaExec(type: JavaExec) { description = "Run the main class with JavaExecTask" classpath = sourceSets.main.runtimeClasspath main = javaMainClass - args cmdargsarray + args cmdargs.split() } -ext.cmdarray = ["java", "-classpath", sourceSets.main.runtimeClasspath.getAsPath(), javaMainClass] -cmdarray = (cmdarray << cmdargsarray).flatten() - task cmdLineExec(type: Exec) { - dependsOn build group = "Execution" - description = "Run the main class with ExecTask" - commandLine cmdarray + description = "Run the an external program with ExecTask" + commandLine cmdargs.split() } From 5b20bb3d2a4608a4523827f2bfc85159bae454ef Mon Sep 17 00:00:00 2001 From: Marco Denisi Date: Thu, 3 Sep 2020 16:59:07 +0200 Subject: [PATCH 061/263] BAEL-3619 - add swagger samples --- .../openapi-3-date-format.yaml | 36 +++++++++++++++++++ .../openapi-3-date-pattern.yaml | 36 +++++++++++++++++++ .../openapi-3-datetime-format.yaml | 36 +++++++++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 spring-rest-http/src/main/resources/openapi-dates-definitions/openapi-3-date-format.yaml create mode 100644 spring-rest-http/src/main/resources/openapi-dates-definitions/openapi-3-date-pattern.yaml create mode 100644 spring-rest-http/src/main/resources/openapi-dates-definitions/openapi-3-datetime-format.yaml diff --git a/spring-rest-http/src/main/resources/openapi-dates-definitions/openapi-3-date-format.yaml b/spring-rest-http/src/main/resources/openapi-dates-definitions/openapi-3-date-format.yaml new file mode 100644 index 0000000000..7ee581d3d8 --- /dev/null +++ b/spring-rest-http/src/main/resources/openapi-dates-definitions/openapi-3-date-format.yaml @@ -0,0 +1,36 @@ +openapi: 3.0.1 +info: + title: API Title + description: This is a sample API. + version: 1.0.0 +servers: + - url: https://host/ +paths: + /users: + get: + summary: Get Users + operationId: getUsers + responses: + 200: + description: Valid input + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/User' +components: + schemas: + User: + type: object + properties: + id: + type: integer + format: int64 + createdAt: + type: string + format: date + description: Creation date + example: "2021-01-30" + username: + type: string \ No newline at end of file diff --git a/spring-rest-http/src/main/resources/openapi-dates-definitions/openapi-3-date-pattern.yaml b/spring-rest-http/src/main/resources/openapi-dates-definitions/openapi-3-date-pattern.yaml new file mode 100644 index 0000000000..ffba36f3da --- /dev/null +++ b/spring-rest-http/src/main/resources/openapi-dates-definitions/openapi-3-date-pattern.yaml @@ -0,0 +1,36 @@ +openapi: 3.0.1 +info: + title: API Title + description: This is a sample API. + version: 1.0.0 +servers: + - url: https://host/ +paths: + /users: + get: + summary: Get Users + operationId: getUsers + responses: + 200: + description: Valid input + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/User' +components: + schemas: + User: + type: object + properties: + id: + type: integer + format: int64 + customDate: + type: string + pattern: '^\d{4}(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])$' + description: Custom date + example: "20210130" + username: + type: string \ No newline at end of file diff --git a/spring-rest-http/src/main/resources/openapi-dates-definitions/openapi-3-datetime-format.yaml b/spring-rest-http/src/main/resources/openapi-dates-definitions/openapi-3-datetime-format.yaml new file mode 100644 index 0000000000..8bf4ddd2dc --- /dev/null +++ b/spring-rest-http/src/main/resources/openapi-dates-definitions/openapi-3-datetime-format.yaml @@ -0,0 +1,36 @@ +openapi: 3.0.1 +info: + title: API Title + description: This is a sample API. + version: 1.0.0 +servers: + - url: https://host/ +paths: + /users: + get: + summary: Get Users + operationId: getUsers + responses: + 200: + description: Valid input + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/User' +components: + schemas: + User: + type: object + properties: + id: + type: integer + format: int64 + createdAt: + type: string + format: date-time + description: Creation date and time + example: "2021-01-30T08:30:00Z" + username: + type: string \ No newline at end of file From 53360080dbb38bc7ee81f6fff8e573f766b6ec66 Mon Sep 17 00:00:00 2001 From: Sebastian Luna Date: Thu, 3 Sep 2020 20:49:20 -0500 Subject: [PATCH 062/263] BAEL-4387 Change Module --- .../baeldung/arrayconversion/ArrayToListConversionUnitTest.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {core-java-modules/core-java-string-operations-3 => java-collections-conversions-2}/src/test/java/com/baeldung/arrayconversion/ArrayToListConversionUnitTest.java (100%) diff --git a/core-java-modules/core-java-string-operations-3/src/test/java/com/baeldung/arrayconversion/ArrayToListConversionUnitTest.java b/java-collections-conversions-2/src/test/java/com/baeldung/arrayconversion/ArrayToListConversionUnitTest.java similarity index 100% rename from core-java-modules/core-java-string-operations-3/src/test/java/com/baeldung/arrayconversion/ArrayToListConversionUnitTest.java rename to java-collections-conversions-2/src/test/java/com/baeldung/arrayconversion/ArrayToListConversionUnitTest.java From 68b732beb0103af02a3d5a40aa041a7bfb05a5f1 Mon Sep 17 00:00:00 2001 From: fdpro Date: Sat, 5 Sep 2020 14:59:15 +0200 Subject: [PATCH 063/263] [JAVA-2306] Fixes after Loredana's review * Brought back UserRepositoryCustomImpl.java * Added link to https://www.baeldung.com/spring-data-jpa-query in spring-data-jpa-query-2 README * Migrated code for https://www.baeldung.com/spring-data-jpa-query-by-date * Migrated https://www.baeldung.com/spring-vs-jta-transactional to spring-persistence-simple --- .../spring-data-jpa-query-2/README.md | 1 + .../jpa/query/UserRepositoryCustomImpl.java | 48 +++++++++++++++++++ .../data/jpa/query/datetime/Application.java} | 25 +++++----- .../data/jpa/query/datetime}/Article.java | 2 +- .../query/datetime}/ArticleRepository.java | 4 +- .../src/main/resources/import_entities.sql | 0 .../ArticleRepositoryIntegrationTest.java | 16 +++---- .../spring-persistence-simple/README.md | 1 + .../spring-persistence-simple/pom.xml | 29 +++++++++++ .../baeldung/spring/transactional}/Car.java | 2 +- .../spring/transactional}/CarRepository.java | 3 +- .../spring/transactional}/CarService.java | 4 +- .../spring/transactional}/RentalService.java | 4 +- 13 files changed, 105 insertions(+), 34 deletions(-) create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/UserRepositoryCustomImpl.java rename persistence-modules/{spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/TransactionalCompareApplication.java => spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/datetime/Application.java} (55%) rename persistence-modules/{spring-data-jpa-query/src/main/java/com/baeldung/boot/domain => spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/datetime}/Article.java (88%) rename persistence-modules/{spring-data-jpa-query/src/main/java/com/baeldung/boot/daos => spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/datetime}/ArticleRepository.java (90%) rename persistence-modules/{spring-data-jpa-query => spring-data-jpa-query-2}/src/main/resources/import_entities.sql (100%) rename persistence-modules/{spring-data-jpa-query/src/test/java/com/baeldung/boot/daos => spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/datetime}/ArticleRepositoryIntegrationTest.java (96%) rename persistence-modules/{spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/entity => spring-persistence-simple/src/main/java/com/baeldung/spring/transactional}/Car.java (95%) rename persistence-modules/{spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/repository => spring-persistence-simple/src/main/java/com/baeldung/spring/transactional}/CarRepository.java (55%) rename persistence-modules/{spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/service => spring-persistence-simple/src/main/java/com/baeldung/spring/transactional}/CarService.java (83%) rename persistence-modules/{spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/service => spring-persistence-simple/src/main/java/com/baeldung/spring/transactional}/RentalService.java (75%) diff --git a/persistence-modules/spring-data-jpa-query-2/README.md b/persistence-modules/spring-data-jpa-query-2/README.md index 1cb3d54da9..fdb4ce3db7 100644 --- a/persistence-modules/spring-data-jpa-query-2/README.md +++ b/persistence-modules/spring-data-jpa-query-2/README.md @@ -3,6 +3,7 @@ This module contains articles about querying data using Spring Data JPA ### Relevant Articles: +- [Spring Data JPA @Query Annotation](https://www.baeldung.com/spring-data-jpa-query) - [Use Criteria Queries in a Spring Data Application](https://www.baeldung.com/spring-data-criteria-queries) - [Query Entities by Dates and Times with Spring Data JPA](https://www.baeldung.com/spring-data-jpa-query-by-date) - More articles: [[<-- prev]](../spring-data-jpa-query) diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/UserRepositoryCustomImpl.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/UserRepositoryCustomImpl.java new file mode 100644 index 0000000000..033f61fdd3 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/UserRepositoryCustomImpl.java @@ -0,0 +1,48 @@ +package com.baeldung.spring.data.jpa.query; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.persistence.criteria.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +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(); + } + + @Override + public List findAllUsersByPredicates(Collection> predicates) { + List allUsers = entityManager.createQuery("select u from User u", User.class).getResultList(); + Stream allUsersStream = allUsers.stream(); + for (java.util.function.Predicate predicate : predicates) { + allUsersStream = allUsersStream.filter(predicate); + } + + return allUsersStream.collect(Collectors.toList()); + } +} diff --git a/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/TransactionalCompareApplication.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/datetime/Application.java similarity index 55% rename from persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/TransactionalCompareApplication.java rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/datetime/Application.java index 7fee55be8a..81e5a2f790 100644 --- a/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/TransactionalCompareApplication.java +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/datetime/Application.java @@ -1,12 +1,13 @@ -package com.baeldung.spring.transactional; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -class TransactionalCompareApplication { - - public static void main(String[] args) { - SpringApplication.run(TransactionalCompareApplication.class, args); - } -} +package com.baeldung.spring.data.jpa.query.datetime; + +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/persistence-modules/spring-data-jpa-query/src/main/java/com/baeldung/boot/domain/Article.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/datetime/Article.java similarity index 88% rename from persistence-modules/spring-data-jpa-query/src/main/java/com/baeldung/boot/domain/Article.java rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/datetime/Article.java index de4dbed1a0..bb0e4e88df 100644 --- a/persistence-modules/spring-data-jpa-query/src/main/java/com/baeldung/boot/domain/Article.java +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/datetime/Article.java @@ -1,4 +1,4 @@ -package com.baeldung.boot.domain; +package com.baeldung.spring.data.jpa.query.datetime; import javax.persistence.*; import java.util.Date; diff --git a/persistence-modules/spring-data-jpa-query/src/main/java/com/baeldung/boot/daos/ArticleRepository.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/datetime/ArticleRepository.java similarity index 90% rename from persistence-modules/spring-data-jpa-query/src/main/java/com/baeldung/boot/daos/ArticleRepository.java rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/datetime/ArticleRepository.java index 73397ad42e..9ec14884f4 100644 --- a/persistence-modules/spring-data-jpa-query/src/main/java/com/baeldung/boot/daos/ArticleRepository.java +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/datetime/ArticleRepository.java @@ -1,11 +1,9 @@ -package com.baeldung.boot.daos; +package com.baeldung.spring.data.jpa.query.datetime; 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-query/src/main/resources/import_entities.sql b/persistence-modules/spring-data-jpa-query-2/src/main/resources/import_entities.sql similarity index 100% rename from persistence-modules/spring-data-jpa-query/src/main/resources/import_entities.sql rename to persistence-modules/spring-data-jpa-query-2/src/main/resources/import_entities.sql diff --git a/persistence-modules/spring-data-jpa-query/src/test/java/com/baeldung/boot/daos/ArticleRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/datetime/ArticleRepositoryIntegrationTest.java similarity index 96% rename from persistence-modules/spring-data-jpa-query/src/test/java/com/baeldung/boot/daos/ArticleRepositoryIntegrationTest.java rename to persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/datetime/ArticleRepositoryIntegrationTest.java index 20fc3cbeaf..38fd804195 100644 --- a/persistence-modules/spring-data-jpa-query/src/test/java/com/baeldung/boot/daos/ArticleRepositoryIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/datetime/ArticleRepositoryIntegrationTest.java @@ -1,11 +1,4 @@ -package com.baeldung.boot.daos; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.text.SimpleDateFormat; -import java.util.Arrays; -import java.util.List; +package com.baeldung.spring.data.jpa.query.datetime; import org.junit.Test; import org.junit.runner.RunWith; @@ -13,7 +6,12 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.test.context.junit4.SpringRunner; -import com.baeldung.boot.domain.Article; +import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.List; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; @RunWith(SpringRunner.class) @DataJpaTest(properties="spring.datasource.data=classpath:import_entities.sql") diff --git a/persistence-modules/spring-persistence-simple/README.md b/persistence-modules/spring-persistence-simple/README.md index 3239ec993b..baa9107f4e 100644 --- a/persistence-modules/spring-persistence-simple/README.md +++ b/persistence-modules/spring-persistence-simple/README.md @@ -5,6 +5,7 @@ ### Relevant Articles: - [Transaction Propagation and Isolation in Spring @Transactional](https://www.baeldung.com/spring-transactional-propagation-isolation) +- [JTA Transaction with Spring](https://www.baeldung.com/spring-vs-jta-transactional) - [Mock JNDI Datasource](https://www.baeldung.com/spring-mock-jndi-datasource) ### Eclipse Config diff --git a/persistence-modules/spring-persistence-simple/pom.xml b/persistence-modules/spring-persistence-simple/pom.xml index 6ca0f3f025..a069f70994 100644 --- a/persistence-modules/spring-persistence-simple/pom.xml +++ b/persistence-modules/spring-persistence-simple/pom.xml @@ -26,6 +26,31 @@ + + javax.persistence + javax.persistence-api + ${persistence-api.version} + + + org.springframework.data + spring-data-jpa + ${spring-data-jpa.version} + + + javax.transaction + javax.transaction-api + ${transaction-api.version} + + + org.springframework + spring-tx + ${org.springframework.version} + + + org.springframework.boot + spring-boot-starter + ${spring-boot-starter.version} + com.h2database h2 @@ -58,7 +83,11 @@ 5.2.4.RELEASE + 2.3.3.RELEASE + 2.2 + 1.3 + 2.2.7.RELEASE 1.4.200 0.23.0 diff --git a/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/entity/Car.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/transactional/Car.java similarity index 95% rename from persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/entity/Car.java rename to persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/transactional/Car.java index 1219111ffa..cb0dc21f7d 100644 --- a/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/entity/Car.java +++ b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/transactional/Car.java @@ -1,4 +1,4 @@ -package com.baeldung.spring.transactional.entity; +package com.baeldung.spring.transactional; import javax.persistence.Entity; import javax.persistence.GeneratedValue; diff --git a/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/repository/CarRepository.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/transactional/CarRepository.java similarity index 55% rename from persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/repository/CarRepository.java rename to persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/transactional/CarRepository.java index f8ecc8f550..ca82954751 100644 --- a/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/repository/CarRepository.java +++ b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/transactional/CarRepository.java @@ -1,6 +1,5 @@ -package com.baeldung.spring.transactional.repository; +package com.baeldung.spring.transactional; -import com.baeldung.spring.transactional.entity.Car; import org.springframework.data.jpa.repository.JpaRepository; public interface CarRepository extends JpaRepository { diff --git a/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/service/CarService.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/transactional/CarService.java similarity index 83% rename from persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/service/CarService.java rename to persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/transactional/CarService.java index 0821ddb02b..00396d191a 100644 --- a/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/service/CarService.java +++ b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/transactional/CarService.java @@ -1,7 +1,5 @@ -package com.baeldung.spring.transactional.service; +package com.baeldung.spring.transactional; -import com.baeldung.spring.transactional.entity.Car; -import com.baeldung.spring.transactional.repository.CarRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Isolation; diff --git a/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/service/RentalService.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/transactional/RentalService.java similarity index 75% rename from persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/service/RentalService.java rename to persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/transactional/RentalService.java index 0aa0815a98..468ac2e53d 100644 --- a/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/service/RentalService.java +++ b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/transactional/RentalService.java @@ -1,7 +1,5 @@ -package com.baeldung.spring.transactional.service; +package com.baeldung.spring.transactional; -import com.baeldung.spring.transactional.entity.Car; -import com.baeldung.spring.transactional.repository.CarRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; From a7dc3199ad223524a76a56a000fbfb9dacf9967f Mon Sep 17 00:00:00 2001 From: Karsten Silz Date: Sat, 5 Sep 2020 18:46:57 +0100 Subject: [PATCH 064/263] BAEL-3326, "Optimizing JSON Schema for production use": Added domain classes and JUnit tests. --- json/pom.xml | 5 + .../baeldung/jsonoptimization/Customer.java | 123 ++ .../CustomerDeserializer.java | 44 + .../jsonoptimization/CustomerNoNull.java | 36 + .../jsonoptimization/CustomerSerializer.java | 34 + .../jsonoptimization/CustomerShortNames.java | 138 +++ .../CustomerShortNamesNoNull.java | 38 + .../jsonoptimization/CustomerSlim.java | 74 ++ .../JsonOptimizationUnitTest.java | 145 +++ .../json_optimization_mock_data.json | 1000 +++++++++++++++++ 10 files changed, 1637 insertions(+) create mode 100644 json/src/main/java/com/baeldung/jsonoptimization/Customer.java create mode 100644 json/src/main/java/com/baeldung/jsonoptimization/CustomerDeserializer.java create mode 100644 json/src/main/java/com/baeldung/jsonoptimization/CustomerNoNull.java create mode 100644 json/src/main/java/com/baeldung/jsonoptimization/CustomerSerializer.java create mode 100644 json/src/main/java/com/baeldung/jsonoptimization/CustomerShortNames.java create mode 100644 json/src/main/java/com/baeldung/jsonoptimization/CustomerShortNamesNoNull.java create mode 100644 json/src/main/java/com/baeldung/jsonoptimization/CustomerSlim.java create mode 100644 json/src/test/java/com/baeldung/jsonoptimization/JsonOptimizationUnitTest.java create mode 100644 json/src/test/resources/json_optimization_mock_data.json diff --git a/json/pom.xml b/json/pom.xml index bd901b526e..99fcfed362 100644 --- a/json/pom.xml +++ b/json/pom.xml @@ -45,6 +45,11 @@ jackson-databind ${jackson.version} + + com.fasterxml.jackson.core + jackson-annotations + ${jackson.version} + javax.json.bind javax.json.bind-api diff --git a/json/src/main/java/com/baeldung/jsonoptimization/Customer.java b/json/src/main/java/com/baeldung/jsonoptimization/Customer.java new file mode 100644 index 0000000000..81a74971ea --- /dev/null +++ b/json/src/main/java/com/baeldung/jsonoptimization/Customer.java @@ -0,0 +1,123 @@ +package com.baeldung.jsonoptimization; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Objects; + +import com.fasterxml.jackson.databind.ObjectMapper; + +public class Customer { + + private long id; + private String firstName; + private String lastName; + private String street; + private String postalCode; + private String city; + private String state; + private String phoneNumber; + private String email; + + 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 String getStreet() { + return street; + } + + public void setStreet(String street) { + this.street = street; + } + + public String getPostalCode() { + return postalCode; + } + + public void setPostalCode(String postalCode) { + this.postalCode = postalCode; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getPhoneNumber() { + return phoneNumber; + } + + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + @Override + public int hashCode() { + return Objects.hash(city, email, firstName, id, lastName, phoneNumber, postalCode, state, street); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof Customer)) { + return false; + } + Customer other = (Customer) obj; + return Objects.equals(city, other.city) && Objects.equals(email, other.email) && Objects.equals(firstName, other.firstName) && id == other.id && Objects.equals(lastName, other.lastName) && Objects.equals(phoneNumber, other.phoneNumber) + && Objects.equals(postalCode, other.postalCode) && Objects.equals(state, other.state) && Objects.equals(street, other.street); + } + + @Override + public String toString() { + return "Customer [id=" + id + ", firstName=" + firstName + ", lastName=" + lastName + ", street=" + street + ", postalCode=" + postalCode + ", city=" + city + ", state=" + state + ", phoneNumber=" + phoneNumber + ", email=" + email + "]"; + } + + public static Customer[] fromMockFile() throws IOException { + ObjectMapper objectMapper = new ObjectMapper(); + InputStream jsonFile = new FileInputStream("src/test/resources/json_optimization_mock_data.json"); + Customer[] feedback = objectMapper.readValue(jsonFile, Customer[].class); + return feedback; + } +} diff --git a/json/src/main/java/com/baeldung/jsonoptimization/CustomerDeserializer.java b/json/src/main/java/com/baeldung/jsonoptimization/CustomerDeserializer.java new file mode 100644 index 0000000000..1f478ed446 --- /dev/null +++ b/json/src/main/java/com/baeldung/jsonoptimization/CustomerDeserializer.java @@ -0,0 +1,44 @@ +package com.baeldung.jsonoptimization; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.ObjectCodec; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; + +public class CustomerDeserializer extends StdDeserializer { + private static final long serialVersionUID = 1L; + + public CustomerDeserializer() { + this(null); + } + + public CustomerDeserializer(Class t) { + super(t); + } + + @Override + public Customer deserialize(JsonParser parser, DeserializationContext deserializer) throws IOException { + Customer feedback = new Customer(); + ObjectCodec codec = parser.getCodec(); + JsonNode node = codec.readTree(parser); + + feedback.setId(node.get(0).asLong()); + feedback.setFirstName(node.get(1).asText()); + feedback.setLastName(node.get(2).asText()); + feedback.setStreet(node.get(3).asText()); + feedback.setPostalCode(node.get(4).asText()); + feedback.setCity(node.get(5).asText()); + feedback.setState(node.get(6).asText()); + JsonNode phoneNumber = node.get(7); + feedback.setPhoneNumber(phoneNumber.isNull() ? null : phoneNumber.asText()); + JsonNode email = node.get(8); + feedback.setEmail(email.isNull() ? null : email.asText()); + return feedback; + } +} diff --git a/json/src/main/java/com/baeldung/jsonoptimization/CustomerNoNull.java b/json/src/main/java/com/baeldung/jsonoptimization/CustomerNoNull.java new file mode 100644 index 0000000000..1ee76f762a --- /dev/null +++ b/json/src/main/java/com/baeldung/jsonoptimization/CustomerNoNull.java @@ -0,0 +1,36 @@ +package com.baeldung.jsonoptimization; + +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CustomerNoNull extends Customer { + + @Override + public String toString() { + return "CustomerNoNull [toString()=" + super.toString() + "]"; + } + + public static CustomerNoNull[] fromCustomers(Customer[] customers) { + CustomerNoNull[] feedback = new CustomerNoNull[customers.length]; + + for(int i = 0; i < customers.length; i++) { + Customer aCustomer = customers[i]; + CustomerNoNull newOne = new CustomerNoNull(); + + newOne.setId(aCustomer.getId()); + newOne.setFirstName(aCustomer.getFirstName()); + newOne.setLastName(aCustomer.getLastName()); + newOne.setStreet(aCustomer.getStreet()); + newOne.setCity(aCustomer.getCity()); + newOne.setPostalCode(aCustomer.getPostalCode()); + newOne.setState(aCustomer.getState()); + newOne.setPhoneNumber(aCustomer.getPhoneNumber()); + newOne.setEmail(aCustomer.getEmail()); + + feedback[i] = newOne; + } + + return feedback; + } + +} diff --git a/json/src/main/java/com/baeldung/jsonoptimization/CustomerSerializer.java b/json/src/main/java/com/baeldung/jsonoptimization/CustomerSerializer.java new file mode 100644 index 0000000000..7e58010640 --- /dev/null +++ b/json/src/main/java/com/baeldung/jsonoptimization/CustomerSerializer.java @@ -0,0 +1,34 @@ +package com.baeldung.jsonoptimization; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; + +public class CustomerSerializer extends StdSerializer { + private static final long serialVersionUID = 1L; + + public CustomerSerializer() { + this(null); + } + + public CustomerSerializer(Class t) { + super(t); + } + + @Override + public void serialize(Customer customer, JsonGenerator jsonGenerator, SerializerProvider serializer) throws IOException { + jsonGenerator.writeStartArray(); + jsonGenerator.writeNumber(customer.getId()); + jsonGenerator.writeString(customer.getFirstName()); + jsonGenerator.writeString(customer.getLastName()); + jsonGenerator.writeString(customer.getStreet()); + jsonGenerator.writeString(customer.getPostalCode()); + jsonGenerator.writeString(customer.getCity()); + jsonGenerator.writeString(customer.getState()); + jsonGenerator.writeString(customer.getPhoneNumber()); + jsonGenerator.writeString(customer.getEmail()); + jsonGenerator.writeEndArray(); + } +} diff --git a/json/src/main/java/com/baeldung/jsonoptimization/CustomerShortNames.java b/json/src/main/java/com/baeldung/jsonoptimization/CustomerShortNames.java new file mode 100644 index 0000000000..ffa10f786d --- /dev/null +++ b/json/src/main/java/com/baeldung/jsonoptimization/CustomerShortNames.java @@ -0,0 +1,138 @@ +package com.baeldung.jsonoptimization; + +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonGetter; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +public class CustomerShortNames { + + private long id; + + @JsonProperty("f") + private String firstName; + + @JsonProperty("l") + private String lastName; + + @JsonProperty("s") + private String street; + + @JsonProperty("p") + private String postalCode; + + @JsonProperty("c") + private String city; + + @JsonProperty("a") + private String state; + + @JsonProperty("o") + private String phoneNumber; + + @JsonProperty("e") + private String email; + + 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 String getStreet() { + return street; + } + public void setStreet(String street) { + this.street = street; + } + public String getPostalCode() { + return postalCode; + } + public void setPostalCode(String postalCode) { + this.postalCode = postalCode; + } + public String getCity() { + return city; + } + public void setCity(String city) { + this.city = city; + } + public String getState() { + return state; + } + public void setState(String state) { + this.state = state; + } + public String getPhoneNumber() { + return phoneNumber; + } + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + } + public String getEmail() { + return email; + } + public void setEmail(String email) { + this.email = email; + } + + @Override + public int hashCode() { + return Objects.hash(city, email, firstName, id, lastName, phoneNumber, postalCode, state, street); + } + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof CustomerShortNames)) { + return false; + } + CustomerShortNames other = (CustomerShortNames) obj; + return Objects.equals(city, other.city) && Objects.equals(email, other.email) && Objects.equals(firstName, other.firstName) && id == other.id && Objects.equals(lastName, other.lastName) && Objects.equals(phoneNumber, other.phoneNumber) + && Objects.equals(postalCode, other.postalCode) && Objects.equals(state, other.state) && Objects.equals(street, other.street); + } + + @Override + public String toString() { + return "CustomerWithShorterAttributes [id=" + id + ", firstName=" + firstName + ", lastName=" + lastName + ", street=" + street + ", postalCode=" + postalCode + ", city=" + city + ", state=" + state + ", phoneNumber=" + phoneNumber + ", email=" + email + + "]"; + } + + public static CustomerShortNames[] fromCustomers(Customer[] customers) { + CustomerShortNames[] feedback = new CustomerShortNames[customers.length]; + + for(int i = 0; i < customers.length; i++) { + Customer aCustomer = customers[i]; + CustomerShortNames newOne = new CustomerShortNames(); + + newOne.setId(aCustomer.getId()); + newOne.setFirstName(aCustomer.getFirstName()); + newOne.setLastName(aCustomer.getLastName()); + newOne.setStreet(aCustomer.getStreet()); + newOne.setCity(aCustomer.getCity()); + newOne.setPostalCode(aCustomer.getPostalCode()); + newOne.setState(aCustomer.getState()); + newOne.setPhoneNumber(aCustomer.getPhoneNumber()); + newOne.setEmail(aCustomer.getEmail()); + + feedback[i] = newOne; + } + + return feedback; + } + +} diff --git a/json/src/main/java/com/baeldung/jsonoptimization/CustomerShortNamesNoNull.java b/json/src/main/java/com/baeldung/jsonoptimization/CustomerShortNamesNoNull.java new file mode 100644 index 0000000000..d3e9648a98 --- /dev/null +++ b/json/src/main/java/com/baeldung/jsonoptimization/CustomerShortNamesNoNull.java @@ -0,0 +1,38 @@ +package com.baeldung.jsonoptimization; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CustomerShortNamesNoNull extends CustomerShortNames { + + + @Override + public String toString() { + return "CustomerShortNamesNoNull [toString()=" + super.toString() + "]"; + } + + public static CustomerShortNamesNoNull[] fromCustomers(Customer[] customers) { + CustomerShortNamesNoNull[] feedback = new CustomerShortNamesNoNull[customers.length]; + + for(int i = 0; i < customers.length; i++) { + Customer aCustomer = customers[i]; + CustomerShortNamesNoNull newOne = new CustomerShortNamesNoNull(); + + newOne.setId(aCustomer.getId()); + newOne.setFirstName(aCustomer.getFirstName()); + newOne.setLastName(aCustomer.getLastName()); + newOne.setStreet(aCustomer.getStreet()); + newOne.setCity(aCustomer.getCity()); + newOne.setPostalCode(aCustomer.getPostalCode()); + newOne.setState(aCustomer.getState()); + newOne.setPhoneNumber(aCustomer.getPhoneNumber()); + newOne.setEmail(aCustomer.getEmail()); + + feedback[i] = newOne; + } + + return feedback; + } + +} diff --git a/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlim.java b/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlim.java new file mode 100644 index 0000000000..cdfaa4e329 --- /dev/null +++ b/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlim.java @@ -0,0 +1,74 @@ +package com.baeldung.jsonoptimization; + +import java.util.Objects; + +public class CustomerSlim { + private long id; + private String name; + private String address; + + 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 String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + @Override + public int hashCode() { + return Objects.hash(address, id, name); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof CustomerSlim)) { + return false; + } + CustomerSlim other = (CustomerSlim) obj; + return Objects.equals(address, other.address) && id == other.id && Objects.equals(name, other.name); + } + + @Override + public String toString() { + return "CustomerSlim [id=" + id + ", name=" + name + ", address=" + address + "]"; + } + + public static CustomerSlim[] fromCustomers(Customer[] customers) { + CustomerSlim[] feedback = new CustomerSlim[customers.length]; + + for(int i = 0; i < customers.length; i++) { + Customer aCustomer = customers[i]; + CustomerSlim newOne = new CustomerSlim(); + + newOne.setId(aCustomer.getId()); + newOne.setName(aCustomer.getFirstName() + " " + aCustomer.getLastName()); + newOne.setAddress(aCustomer.getStreet() + ", " + aCustomer.getCity() + " " + aCustomer.getState() + " " + aCustomer.getPostalCode()); + + feedback[i] = newOne; + } + + return feedback; + } + + +} diff --git a/json/src/test/java/com/baeldung/jsonoptimization/JsonOptimizationUnitTest.java b/json/src/test/java/com/baeldung/jsonoptimization/JsonOptimizationUnitTest.java new file mode 100644 index 0000000000..e754978cd5 --- /dev/null +++ b/json/src/test/java/com/baeldung/jsonoptimization/JsonOptimizationUnitTest.java @@ -0,0 +1,145 @@ +package com.baeldung.jsonoptimization; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.text.DecimalFormat; +import java.util.zip.GZIPOutputStream; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.Version; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectWriter; +import com.fasterxml.jackson.databind.module.SimpleModule; + +class JsonOptimizationUnitTest { + private static final String TEST_LABEL_DEFAULT_JSON = "Default JSON"; + private static final String TEST_LABEL_DEFAULT_JSON_NO_NULL = "Default JSON without null"; + private static final String TEST_LABEL_SHORTER_ATTRIBUTE_NAMES = "Shorter Attribute Names"; + private static final String TEST_LABEL_SHORTER_ATTRIBUTE_NAMES_NO_NULL = "Shorter Attribute Names without null"; + private static final String TEST_LABEL_CUSTOM_SERIALIZER = "Custom Serializer"; + private static final String TEST_LABEL_SLIM_CUSTOMER = "Slim customer"; + private static DecimalFormat LENGTH_FORMATTER = new DecimalFormat("###,###,###"); + private static Customer[] customers; + private ObjectMapper mapper; + + @BeforeAll + static void setUpOnce() throws Exception { + customers = Customer.fromMockFile(); + } + + @BeforeEach + void setUp() { + mapper = new ObjectMapper(); + } + + @Test + void testSetUp() { + assertEquals(1000, customers.length, "There should be a 1000 customers"); + } + + @Test + void testDefaultJson() throws IOException { + printBanner(TEST_LABEL_DEFAULT_JSON); + byte[] plainJson = createPlainJson(TEST_LABEL_DEFAULT_JSON, customers); + compressJson(TEST_LABEL_DEFAULT_JSON, plainJson); + } + + @Test + void testDefaultNoNull() throws IOException { + printBanner(TEST_LABEL_DEFAULT_JSON_NO_NULL); + CustomerNoNull[] defaultNoNull = CustomerNoNull.fromCustomers(customers); + byte[] plainJson = createPlainJson(TEST_LABEL_DEFAULT_JSON_NO_NULL, defaultNoNull); + compressJson(TEST_LABEL_DEFAULT_JSON_NO_NULL, plainJson); + } + + @Test + void testShorterAttributes() throws IOException { + printBanner(TEST_LABEL_SHORTER_ATTRIBUTE_NAMES); + CustomerShortNames[] shorterOnes = CustomerShortNames.fromCustomers(customers); + byte[] shorterJson = createPlainJson(TEST_LABEL_SHORTER_ATTRIBUTE_NAMES, shorterOnes); + compressJson(TEST_LABEL_SHORTER_ATTRIBUTE_NAMES, shorterJson); + } + + @Test + void testShorterAttributesNoNull() throws IOException { + printBanner(TEST_LABEL_SHORTER_ATTRIBUTE_NAMES_NO_NULL); + CustomerShortNamesNoNull[] shorterOnesNoNull = CustomerShortNamesNoNull.fromCustomers(customers); + byte[] shorterJson = createPlainJson(TEST_LABEL_SHORTER_ATTRIBUTE_NAMES_NO_NULL, shorterOnesNoNull); + compressJson(TEST_LABEL_SHORTER_ATTRIBUTE_NAMES_NO_NULL, shorterJson); + } + + @Test + void testSlim() throws IOException { + printBanner(TEST_LABEL_SLIM_CUSTOMER); + CustomerSlim[] slimOnes = CustomerSlim.fromCustomers(customers); + byte[] slimJson = createPlainJson(TEST_LABEL_SLIM_CUSTOMER, slimOnes); + compressJson(TEST_LABEL_SLIM_CUSTOMER, slimJson); + } + + @Test + void testCustomSerializer() throws IOException { + printBanner(TEST_LABEL_CUSTOM_SERIALIZER); + + SimpleModule serializer = new SimpleModule("CustomCustomerSerializer", new Version(1, 0, 0, null, null, null)); + serializer.addSerializer(Customer.class, new CustomerSerializer()); + mapper.registerModule(serializer); + + SimpleModule deserializer = new SimpleModule("CustomCustomerDeserializer", new Version(1, 0, 0, null, null, null)); + deserializer.addDeserializer(Customer.class, new CustomerDeserializer()); + mapper.registerModule(deserializer); + + byte[] plainJson = createPlainJson(TEST_LABEL_CUSTOM_SERIALIZER, customers); + compressJson(TEST_LABEL_CUSTOM_SERIALIZER, plainJson); + } + + private void printBanner(String name) { + System.out.println(); + System.out.println("************************************************"); + System.out.println("Testing " + name); + System.out.println(); + } + + void compressJson(String label, byte[] plainJson) throws IOException { + ByteArrayOutputStream outpuStream = new ByteArrayOutputStream(); + GZIPOutputStream gzipStream = new GZIPOutputStream(outpuStream); + gzipStream.write(plainJson); + gzipStream.close(); + byte[] gzippedJson = outpuStream.toByteArray(); + System.out.println(label + " GZIPped length: " + LENGTH_FORMATTER.format(gzippedJson.length)); + assertTrue(plainJson.length > gzippedJson.length, label + " should be longer than GZIPped data"); + } + + private byte[] createPlainJson(String label, Object[] customers) throws IOException { + System.out.println(label + " sample: "); + ObjectWriter prettyWritter = mapper.writerWithDefaultPrettyPrinter(); + System.out.println(prettyWritter.writeValueAsString(customers[0])); + + byte[] feedback = mapper.writeValueAsBytes(customers); + System.out.println(label + " length: " + LENGTH_FORMATTER.format(feedback.length)); + assertTrue(feedback.length > 1, label + " should be there"); + + String prefix = label.replaceAll(" ", "-") + .toLowerCase(); + File tempFile = File.createTempFile("jon-optimization-" + prefix, ".json"); + FileOutputStream fos = new FileOutputStream(tempFile); + fos.write(feedback); + fos.close(); + System.out.println(label + " file: " + tempFile.toString()); + + Object[] restoredOnes = mapper.readValue(feedback, customers.getClass()); + assertArrayEquals(TEST_LABEL_DEFAULT_JSON + ": restoring from JSON should work", customers, restoredOnes); + + return feedback; + } + +} diff --git a/json/src/test/resources/json_optimization_mock_data.json b/json/src/test/resources/json_optimization_mock_data.json new file mode 100644 index 0000000000..e09517cf61 --- /dev/null +++ b/json/src/test/resources/json_optimization_mock_data.json @@ -0,0 +1,1000 @@ +[{"id":1,"firstName":"Horatius","lastName":"Strognell","street":"4848 New Castle Point","postalCode":"33432","city":"Boca Raton","state":"FL","phoneNumber":"561-824-9105","email":"hstrognell0@dailymail.co.uk"}, +{"id":2,"firstName":"Kerri","lastName":"Arend","street":"4 Welch Pass","postalCode":"60669","city":"Chicago","state":"IL","phoneNumber":"312-303-5993"}, +{"id":3,"firstName":"Silvano","lastName":"Bartholomaus","street":"2491 Arkansas Center","postalCode":"30195","city":"Duluth","state":"GA","email":"sbartholomaus2@prlog.org"}, +{"id":4,"firstName":"Venita","lastName":"Burgoine","street":"63894 Sage Park","postalCode":"67215","city":"Wichita","state":"KS","email":"vburgoine3@telegraph.co.uk"}, +{"id":5,"firstName":"Meghan","lastName":"Westover","street":"76 Pleasure Way","postalCode":"77388","city":"Spring","state":"TX","phoneNumber":"832-926-0689","email":"mwestover4@cnn.com"}, +{"id":6,"firstName":"Mia","lastName":"Baversor","street":"50 Sommers Road","postalCode":"43204","city":"Columbus","state":"OH","email":"mbaversor5@wsj.com"}, +{"id":7,"firstName":"Winna","lastName":"Buggy","street":"05 Jenna Street","postalCode":"68144","city":"Omaha","state":"NE","phoneNumber":"402-740-7818"}, +{"id":8,"firstName":"Antonin","lastName":"Autrie","street":"9 Fieldstone Terrace","postalCode":"85754","city":"Tucson","state":"AZ"}, +{"id":9,"firstName":"Maddi","lastName":"Ollerearnshaw","street":"061 Crowley Trail","postalCode":"48335","city":"Farmington","state":"MI","phoneNumber":"248-709-8128"}, +{"id":10,"firstName":"Fawnia","lastName":"Cristofaro","street":"92571 Kinsman Alley","postalCode":"77271","city":"Houston","state":"TX","email":"fcristofaro9@ox.ac.uk"}, +{"id":11,"firstName":"Zachariah","lastName":"Rouby","street":"2439 Hudson Circle","postalCode":"25313","city":"Charleston","state":"WV","phoneNumber":"304-587-5444"}, +{"id":12,"firstName":"Brier","lastName":"Benech","street":"3144 Sutteridge Place","postalCode":"20380","city":"Washington","state":"DC","phoneNumber":"202-740-8851","email":"bbenechb@zdnet.com"}, +{"id":13,"firstName":"Merry","lastName":"Leming","street":"419 Kropf Terrace","postalCode":"45440","city":"Dayton","state":"OH","email":"mlemingc@ow.ly"}, +{"id":14,"firstName":"Audrey","lastName":"Dilleston","street":"61 Melrose Trail","postalCode":"97306","city":"Salem","state":"OR","phoneNumber":"503-480-6254"}, +{"id":15,"firstName":"De witt","lastName":"Kedge","street":"819 Kingsford Point","postalCode":"84135","city":"Salt Lake City","state":"UT"}, +{"id":16,"firstName":"Charita","lastName":"de Clerc","street":"42 Loftsgordon Hill","postalCode":"28289","city":"Charlotte","state":"NC","phoneNumber":"704-532-8850","email":"cdeclercf@comsenz.com"}, +{"id":17,"firstName":"Edgard","lastName":"Bloore","street":"1659 Donald Trail","postalCode":"20051","city":"Washington","state":"DC"}, +{"id":18,"firstName":"Kristi","lastName":"Richichi","street":"11306 Longview Hill","postalCode":"75372","city":"Dallas","state":"TX","email":"krichichih@cloudflare.com"}, +{"id":19,"firstName":"Denna","lastName":"Cornford","street":"4 Gale Junction","postalCode":"10014","city":"New York City","state":"NY","phoneNumber":"646-273-3067","email":"dcornfordi@ebay.co.uk"}, +{"id":20,"firstName":"Randall","lastName":"McQuaid","street":"55712 Stone Corner Circle","postalCode":"10203","city":"New York City","state":"NY","email":"rmcquaidj@facebook.com"}, +{"id":21,"firstName":"Kirbie","lastName":"Walczak","street":"9 Coleman Road","postalCode":"99252","city":"Spokane","state":"WA","email":"kwalczakk@spotify.com"}, +{"id":22,"firstName":"Zedekiah","lastName":"Westby","street":"9 Victoria Road","postalCode":"22093","city":"Ashburn","state":"VA","phoneNumber":"571-642-0111","email":"zwestbyl@ox.ac.uk"}, +{"id":23,"firstName":"Corri","lastName":"Snar","street":"4 Service Terrace","postalCode":"68517","city":"Lincoln","state":"NE","email":"csnarm@tinyurl.com"}, +{"id":24,"firstName":"Manny","lastName":"Marchington","street":"942 Westend Center","postalCode":"22119","city":"Merrifield","state":"VA","email":"mmarchingtonn@opensource.org"}, +{"id":25,"firstName":"Ashla","lastName":"Grigoroni","street":"755 Lerdahl Parkway","postalCode":"55423","city":"Minneapolis","state":"MN","phoneNumber":"612-797-7928","email":"agrigoronio@cam.ac.uk"}, +{"id":26,"firstName":"Rita","lastName":"Sharratt","street":"710 Buena Vista Avenue","postalCode":"40576","city":"Lexington","state":"KY","phoneNumber":"859-727-0697"}, +{"id":27,"firstName":"Karrie","lastName":"Crathorne","street":"02 Loeprich Place","postalCode":"39505","city":"Gulfport","state":"MS"}, +{"id":28,"firstName":"Lothario","lastName":"Merck","street":"46 Golden Leaf Park","postalCode":"35205","city":"Birmingham","state":"AL"}, +{"id":29,"firstName":"Renault","lastName":"Banister","street":"7 Garrison Plaza","postalCode":"85072","city":"Phoenix","state":"AZ"}, +{"id":30,"firstName":"Wanda","lastName":"Burkart","street":"10 Mendota Place","postalCode":"48258","city":"Detroit","state":"MI","phoneNumber":"248-870-5185","email":"wburkartt@wikipedia.org"}, +{"id":31,"firstName":"Maggy","lastName":"Timby","street":"37 Crest Line Center","postalCode":"50305","city":"Des Moines","state":"IA","email":"mtimbyu@cnbc.com"}, +{"id":32,"firstName":"Chet","lastName":"Origan","street":"767 Bashford Lane","postalCode":"30919","city":"Augusta","state":"GA","email":"coriganv@behance.net"}, +{"id":33,"firstName":"Jammie","lastName":"Aslie","street":"7174 Hoffman Circle","postalCode":"23464","city":"Virginia Beach","state":"VA"}, +{"id":34,"firstName":"Dill","lastName":"Kingdon","street":"75 Corben Crossing","postalCode":"33013","city":"Hialeah","state":"FL","email":"dkingdonx@ibm.com"}, +{"id":35,"firstName":"Berenice","lastName":"Blodget","street":"8 Eliot Junction","postalCode":"93907","city":"Salinas","state":"CA","email":"bblodgety@blogs.com"}, +{"id":36,"firstName":"Kimberley","lastName":"Streatley","street":"56 Welch Center","postalCode":"77070","city":"Houston","state":"TX"}, +{"id":37,"firstName":"Warde","lastName":"Woodwind","street":"773 Gerald Park","postalCode":"35295","city":"Birmingham","state":"AL","email":"wwoodwind10@wsj.com"}, +{"id":38,"firstName":"Husain","lastName":"Christofe","street":"35118 Forest Dale Avenue","postalCode":"10175","city":"New York City","state":"NY","phoneNumber":"212-611-7995","email":"hchristofe11@seesaa.net"}, +{"id":39,"firstName":"Gertrud","lastName":"Defraine","street":"568 Walton Way","postalCode":"37405","city":"Chattanooga","state":"TN","phoneNumber":"423-125-5719","email":"gdefraine12@xrea.com"}, +{"id":40,"firstName":"Yulma","lastName":"Ramshay","street":"9976 Iowa Drive","postalCode":"87121","city":"Albuquerque","state":"NM","phoneNumber":"505-914-5281"}, +{"id":41,"firstName":"Bride","lastName":"Amsberger","street":"3 Service Lane","postalCode":"28272","city":"Charlotte","state":"NC","email":"bamsberger14@forbes.com"}, +{"id":42,"firstName":"Kaiser","lastName":"Froud","street":"7 Starling Lane","postalCode":"99507","city":"Anchorage","state":"AK","email":"kfroud15@cloudflare.com"}, +{"id":43,"firstName":"Leona","lastName":"Sciusscietto","street":"06392 East Lane","postalCode":"60193","city":"Schaumburg","state":"IL","phoneNumber":"630-981-3986","email":"lsciusscietto16@mit.edu"}, +{"id":44,"firstName":"Sibel","lastName":"Ripsher","street":"8672 Bayside Road","postalCode":"32511","city":"Pensacola","state":"FL","phoneNumber":"850-975-6365","email":"sripsher17@sitemeter.com"}, +{"id":45,"firstName":"Megen","lastName":"Dymond","street":"0547 Harper Place","postalCode":"28220","city":"Charlotte","state":"NC","phoneNumber":"704-632-5850"}, +{"id":46,"firstName":"Vitoria","lastName":"Niese","street":"365 Colorado Plaza","postalCode":"15279","city":"Pittsburgh","state":"PA","phoneNumber":"412-864-8563"}, +{"id":47,"firstName":"Cherianne","lastName":"Daveran","street":"5 Esch Parkway","postalCode":"36104","city":"Montgomery","state":"AL","email":"cdaveran1a@ft.com"}, +{"id":48,"firstName":"Harriott","lastName":"Mallam","street":"9 Monterey Place","postalCode":"20215","city":"Washington","state":"DC","phoneNumber":"202-727-0645"}, +{"id":49,"firstName":"Jozef","lastName":"Stranger","street":"07 Warner Drive","postalCode":"84199","city":"Salt Lake City","state":"UT","phoneNumber":"801-741-5946"}, +{"id":50,"firstName":"Teena","lastName":"Broggio","street":"287 Luster Park","postalCode":"78285","city":"San Antonio","state":"TX","phoneNumber":"210-482-0822","email":"tbroggio1d@craigslist.org"}, +{"id":51,"firstName":"Robin","lastName":"Membry","street":"0736 Forest Dale Crossing","postalCode":"45408","city":"Dayton","state":"OH","phoneNumber":"937-335-4964","email":"rmembry1e@toplist.cz"}, +{"id":52,"firstName":"Holly","lastName":"Lowcock","street":"819 Aberg Pass","postalCode":"28815","city":"Asheville","state":"NC","email":"hlowcock1f@bbc.co.uk"}, +{"id":53,"firstName":"Shandee","lastName":"Blowick","street":"81600 Moose Lane","postalCode":"46867","city":"Fort Wayne","state":"IN","phoneNumber":"260-904-5622"}, +{"id":54,"firstName":"Chaim","lastName":"Stilliard","street":"91 Spohn Court","postalCode":"28305","city":"Fayetteville","state":"NC","phoneNumber":"910-721-3938"}, +{"id":55,"firstName":"Maximilien","lastName":"Purkis","street":"66997 Algoma Park","postalCode":"10150","city":"New York City","state":"NY","phoneNumber":"212-824-3363","email":"mpurkis1i@unblog.fr"}, +{"id":56,"firstName":"Ferguson","lastName":"Whiles","street":"0550 Bowman Street","postalCode":"33142","city":"Miami","state":"FL","phoneNumber":"786-416-2947","email":"fwhiles1j@artisteer.com"}, +{"id":57,"firstName":"Elena","lastName":"Poyle","street":"54 Warner Court","postalCode":"28055","city":"Gastonia","state":"NC","email":"epoyle1k@tripod.com"}, +{"id":58,"firstName":"Carney","lastName":"Pengilly","street":"050 Welch Junction","postalCode":"76147","city":"Fort Worth","state":"TX","phoneNumber":"817-525-7801","email":"cpengilly1l@yellowpages.com"}, +{"id":59,"firstName":"Krispin","lastName":"Pouck","street":"03554 Twin Pines Point","postalCode":"55551","city":"Young America","state":"MN","email":"kpouck1m@nymag.com"}, +{"id":60,"firstName":"Kylie","lastName":"Osmar","street":"7 Milwaukee Plaza","postalCode":"45228","city":"Cincinnati","state":"OH","phoneNumber":"513-940-5020","email":"kosmar1n@storify.com"}, +{"id":61,"firstName":"Trudi","lastName":"Standrin","street":"526 Onsgard Park","postalCode":"12237","city":"Albany","state":"NY","email":"tstandrin1o@sfgate.com"}, +{"id":62,"firstName":"Frank","lastName":"Belt","street":"52 Stang Lane","postalCode":"27455","city":"Greensboro","state":"NC"}, +{"id":63,"firstName":"Nerita","lastName":"Daulton","street":"03 Sutherland Court","postalCode":"55417","city":"Minneapolis","state":"MN","phoneNumber":"651-796-2028"}, +{"id":64,"firstName":"Urbanus","lastName":"Camm","street":"6802 Weeping Birch Circle","postalCode":"92115","city":"San Diego","state":"CA","email":"ucamm1r@ucoz.com"}, +{"id":65,"firstName":"Perry","lastName":"Struther","street":"63916 Corry Alley","postalCode":"28805","city":"Asheville","state":"NC","phoneNumber":"828-821-0824","email":"pstruther1s@nih.gov"}, +{"id":66,"firstName":"Zorina","lastName":"Uc","street":"99 Merry Circle","postalCode":"37250","city":"Nashville","state":"TN","phoneNumber":"615-364-4726","email":"zuc1t@cbc.ca"}, +{"id":67,"firstName":"Ajay","lastName":"Rediers","street":"6872 Armistice Lane","postalCode":"92812","city":"Anaheim","state":"CA","phoneNumber":"714-845-0143"}, +{"id":68,"firstName":"Brendis","lastName":"Goor","street":"94 Mccormick Place","postalCode":"77346","city":"Humble","state":"TX","phoneNumber":"713-910-5956"}, +{"id":69,"firstName":"Barbey","lastName":"Konneke","street":"75613 Miller Trail","postalCode":"30328","city":"Atlanta","state":"GA","phoneNumber":"770-208-1453"}, +{"id":70,"firstName":"Adlai","lastName":"Colly","street":"4446 Loftsgordon Place","postalCode":"40576","city":"Lexington","state":"KY","email":"acolly1x@phpbb.com"}, +{"id":71,"firstName":"Libby","lastName":"Wherton","street":"9313 Buell Road","postalCode":"70116","city":"New Orleans","state":"LA","email":"lwherton1y@flickr.com"}, +{"id":72,"firstName":"Niko","lastName":"Stockell","street":"61 Havey Park","postalCode":"10034","city":"New York City","state":"NY","phoneNumber":"646-814-6395","email":"nstockell1z@xrea.com"}, +{"id":73,"firstName":"Phillip","lastName":"Dadley","street":"14534 Victoria Street","postalCode":"33906","city":"Fort Myers","state":"FL","email":"pdadley20@studiopress.com"}, +{"id":74,"firstName":"Leann","lastName":"Hebburn","street":"9 Center Place","postalCode":"84140","city":"Salt Lake City","state":"UT","email":"lhebburn21@1688.com"}, +{"id":75,"firstName":"Raynor","lastName":"Gernier","street":"5923 Gale Plaza","postalCode":"79118","city":"Amarillo","state":"TX"}, +{"id":76,"firstName":"Elmore","lastName":"Frankton","street":"770 Wayridge Crossing","postalCode":"14619","city":"Rochester","state":"NY"}, +{"id":77,"firstName":"Teresina","lastName":"Rives","street":"51261 Sycamore Terrace","postalCode":"63180","city":"Saint Louis","state":"MO","email":"trives24@cbsnews.com"}, +{"id":78,"firstName":"Pancho","lastName":"Thebeaud","street":"72 Pierstorff Way","postalCode":"33705","city":"Saint Petersburg","state":"FL","phoneNumber":"813-335-3556"}, +{"id":79,"firstName":"Deanne","lastName":"Crighton","street":"95 Duke Plaza","postalCode":"71151","city":"Shreveport","state":"LA","phoneNumber":"318-218-7196","email":"dcrighton26@sphinn.com"}, +{"id":80,"firstName":"Brucie","lastName":"Bury","street":"8948 Knutson Lane","postalCode":"93740","city":"Fresno","state":"CA","email":"bbury27@twitter.com"}, +{"id":81,"firstName":"Joleen","lastName":"Flack","street":"8007 Morningstar Street","postalCode":"33283","city":"Miami","state":"FL","phoneNumber":"305-459-0365"}, +{"id":82,"firstName":"Antonino","lastName":"Matelyunas","street":"2585 Gale Road","postalCode":"20591","city":"Washington","state":"DC","phoneNumber":"202-780-3589"}, +{"id":83,"firstName":"Vinnie","lastName":"Syne","street":"6 Fallview Pass","postalCode":"20231","city":"Washington","state":"DC","phoneNumber":"202-648-5977","email":"vsyne2a@etsy.com"}, +{"id":84,"firstName":"Sig","lastName":"Guillotin","street":"6 Buell Lane","postalCode":"46015","city":"Anderson","state":"IN","phoneNumber":"765-948-7663","email":"sguillotin2b@cisco.com"}, +{"id":85,"firstName":"Gabriel","lastName":"Vasyukhichev","street":"25801 Grasskamp Junction","postalCode":"45408","city":"Dayton","state":"OH","email":"gvasyukhichev2c@mac.com"}, +{"id":86,"firstName":"Casie","lastName":"Burgill","street":"0 Dapin Alley","postalCode":"37410","city":"Chattanooga","state":"TN"}, +{"id":87,"firstName":"Kristan","lastName":"Chalice","street":"5118 Calypso Junction","postalCode":"78721","city":"Austin","state":"TX","phoneNumber":"512-831-2347"}, +{"id":88,"firstName":"Brear","lastName":"Pruckner","street":"2 Corscot Street","postalCode":"53790","city":"Madison","state":"WI"}, +{"id":89,"firstName":"Estella","lastName":"Orpyne","street":"293 Hansons Plaza","postalCode":"55579","city":"Maple Plain","state":"MN","phoneNumber":"952-666-6951","email":"eorpyne2g@examiner.com"}, +{"id":90,"firstName":"Conroy","lastName":"de Banke","street":"40636 Farmco Park","postalCode":"30316","city":"Atlanta","state":"GA","phoneNumber":"404-199-0073","email":"cdebanke2h@prweb.com"}, +{"id":91,"firstName":"Elmira","lastName":"Bracken","street":"10 Macpherson Place","postalCode":"85099","city":"Phoenix","state":"AZ","phoneNumber":"602-991-7768","email":"ebracken2i@sourceforge.net"}, +{"id":92,"firstName":"Carlota","lastName":"Vasilechko","street":"33 American Ash Point","postalCode":"75507","city":"Texarkana","state":"TX","phoneNumber":"903-312-0610","email":"cvasilechko2j@nba.com"}, +{"id":93,"firstName":"Jamesy","lastName":"Valentelli","street":"59634 Charing Cross Trail","postalCode":"31416","city":"Savannah","state":"GA","phoneNumber":"912-657-6729","email":"jvalentelli2k@nifty.com"}, +{"id":94,"firstName":"Hildagarde","lastName":"Sandels","street":"1 Lotheville Lane","postalCode":"32277","city":"Jacksonville","state":"FL","phoneNumber":"904-981-2753","email":"hsandels2l@a8.net"}, +{"id":95,"firstName":"Kip","lastName":"Cranidge","street":"2 South Road","postalCode":"19160","city":"Philadelphia","state":"PA"}, +{"id":96,"firstName":"Tobit","lastName":"Jarrette","street":"777 Mallard Trail","postalCode":"49444","city":"Muskegon","state":"MI","phoneNumber":"231-706-1988"}, +{"id":97,"firstName":"Tibold","lastName":"Michie","street":"87796 Nevada Junction","postalCode":"22093","city":"Ashburn","state":"VA","phoneNumber":"571-188-4893","email":"tmichie2o@mapy.cz"}, +{"id":98,"firstName":"Maximo","lastName":"Ifill","street":"8307 Tony Point","postalCode":"22225","city":"Arlington","state":"VA","phoneNumber":"571-404-1412"}, +{"id":99,"firstName":"Patti","lastName":"Autry","street":"901 Iowa Crossing","postalCode":"55551","city":"Young America","state":"MN","phoneNumber":"952-772-9107","email":"pautry2q@scientificamerican.com"}, +{"id":100,"firstName":"Cathe","lastName":"Jost","street":"4400 Menomonie Road","postalCode":"21211","city":"Baltimore","state":"MD","phoneNumber":"410-800-4683","email":"cjost2r@tuttocitta.it"}, +{"id":101,"firstName":"Byron","lastName":"Maddams","street":"10729 Oak Trail","postalCode":"78255","city":"San Antonio","state":"TX","phoneNumber":"830-263-4129"}, +{"id":102,"firstName":"Sosanna","lastName":"Paley","street":"82207 Park Meadow Court","postalCode":"77010","city":"Houston","state":"TX","phoneNumber":"832-740-8766","email":"spaley2t@salon.com"}, +{"id":103,"firstName":"Elysia","lastName":"Skerratt","street":"88708 Cambridge Drive","postalCode":"31217","city":"Macon","state":"GA","phoneNumber":"478-265-6579","email":"eskerratt2u@japanpost.jp"}, +{"id":104,"firstName":"Nealson","lastName":"Sieur","street":"1286 Elmside Plaza","postalCode":"20904","city":"Silver Spring","state":"MD"}, +{"id":105,"firstName":"Yasmeen","lastName":"Bazire","street":"91904 Elmside Point","postalCode":"73167","city":"Oklahoma City","state":"OK"}, +{"id":106,"firstName":"Mandy","lastName":"Ewart","street":"91 Norway Maple Street","postalCode":"21239","city":"Baltimore","state":"MD","email":"mewart2x@weebly.com"}, +{"id":107,"firstName":"Chlo","lastName":"Keedy","street":"560 Oak Valley Avenue","postalCode":"20420","city":"Washington","state":"DC"}, +{"id":108,"firstName":"Benedicta","lastName":"Dinneen","street":"9 Cottonwood Circle","postalCode":"60686","city":"Chicago","state":"IL","email":"bdinneen2z@nydailynews.com"}, +{"id":109,"firstName":"Nanon","lastName":"Corsar","street":"40001 Barby Drive","postalCode":"95818","city":"Sacramento","state":"CA","email":"ncorsar30@house.gov"}, +{"id":110,"firstName":"Babette","lastName":"Scarsbrick","street":"96095 Loomis Terrace","postalCode":"94622","city":"Oakland","state":"CA","email":"bscarsbrick31@smugmug.com"}, +{"id":111,"firstName":"Cornall","lastName":"Christauffour","street":"9 Springview Alley","postalCode":"84170","city":"Salt Lake City","state":"UT","phoneNumber":"801-935-1246","email":"cchristauffour32@booking.com"}, +{"id":112,"firstName":"Micki","lastName":"Labell","street":"77729 Heath Place","postalCode":"25336","city":"Charleston","state":"WV"}, +{"id":113,"firstName":"Marissa","lastName":"Bricksey","street":"1 Jackson Pass","postalCode":"11470","city":"Jamaica","state":"NY","phoneNumber":"917-552-4280"}, +{"id":114,"firstName":"Alex","lastName":"Lyptrade","street":"74 Bunting Circle","postalCode":"40591","city":"Lexington","state":"KY","phoneNumber":"859-177-0753"}, +{"id":115,"firstName":"Tove","lastName":"Bielfeldt","street":"95 Mallard Hill","postalCode":"70894","city":"Baton Rouge","state":"LA","email":"tbielfeldt36@goo.gl"}, +{"id":116,"firstName":"Rodrigo","lastName":"Chestle","street":"53625 1st Junction","postalCode":"43635","city":"Toledo","state":"OH","phoneNumber":"419-928-0953","email":"rchestle37@princeton.edu"}, +{"id":117,"firstName":"Ulrike","lastName":"Kendle","street":"0 Cardinal Alley","postalCode":"80925","city":"Colorado Springs","state":"CO","phoneNumber":"719-796-1992","email":"ukendle38@naver.com"}, +{"id":118,"firstName":"Sandor","lastName":"Warwick","street":"8 Spaight Crossing","postalCode":"92030","city":"Escondido","state":"CA","email":"swarwick39@about.com"}, +{"id":119,"firstName":"Selina","lastName":"Slowcock","street":"7 7th Circle","postalCode":"50335","city":"Des Moines","state":"IA","phoneNumber":"515-865-9809"}, +{"id":120,"firstName":"Maxine","lastName":"Placstone","street":"42056 Sycamore Plaza","postalCode":"20244","city":"Washington","state":"DC"}, +{"id":121,"firstName":"Ardine","lastName":"Reven","street":"10634 Nancy Way","postalCode":"10175","city":"New York City","state":"NY","email":"areven3c@diigo.com"}, +{"id":122,"firstName":"Dilan","lastName":"Widdows","street":"37 Park Meadow Way","postalCode":"68144","city":"Omaha","state":"NE","phoneNumber":"402-383-9020"}, +{"id":123,"firstName":"Kevina","lastName":"Praten","street":"8531 Elmside Point","postalCode":"27610","city":"Raleigh","state":"NC","email":"kpraten3e@craigslist.org"}, +{"id":124,"firstName":"Sherman","lastName":"Jurczak","street":"8281 Acker Alley","postalCode":"07522","city":"Paterson","state":"NJ","email":"sjurczak3f@github.com"}, +{"id":125,"firstName":"Beckie","lastName":"Disney","street":"3 Butterfield Drive","postalCode":"49518","city":"Grand Rapids","state":"MI","phoneNumber":"616-493-1284","email":"bdisney3g@china.com.cn"}, +{"id":126,"firstName":"Blaine","lastName":"Leak","street":"369 Norway Maple Lane","postalCode":"03804","city":"Portsmouth","state":"NH","email":"bleak3h@lulu.com"}, +{"id":127,"firstName":"Dare","lastName":"Marney","street":"50 Lake View Alley","postalCode":"06505","city":"New Haven","state":"CT","phoneNumber":"203-876-6938","email":"dmarney3i@delicious.com"}, +{"id":128,"firstName":"Darby","lastName":"Sackler","street":"841 Ridgeview Trail","postalCode":"80279","city":"Denver","state":"CO"}, +{"id":129,"firstName":"Aurilia","lastName":"Seabrocke","street":"670 Schmedeman Road","postalCode":"11254","city":"Brooklyn","state":"NY","email":"aseabrocke3k@engadget.com"}, +{"id":130,"firstName":"Griz","lastName":"Riccioppo","street":"2204 Moland Circle","postalCode":"45218","city":"Cincinnati","state":"OH","email":"griccioppo3l@cisco.com"}, +{"id":131,"firstName":"Zahara","lastName":"Quinion","street":"4979 Mallory Circle","postalCode":"24515","city":"Lynchburg","state":"VA","email":"zquinion3m@sfgate.com"}, +{"id":132,"firstName":"Holly-anne","lastName":"Fontel","street":"60752 Hallows Circle","postalCode":"76705","city":"Waco","state":"TX","phoneNumber":"254-822-2565","email":"hfontel3n@exblog.jp"}, +{"id":133,"firstName":"Johannes","lastName":"Lemonby","street":"3 Grover Terrace","postalCode":"25709","city":"Huntington","state":"WV","phoneNumber":"304-342-4911","email":"jlemonby3o@woothemes.com"}, +{"id":134,"firstName":"Melvin","lastName":"Kain","street":"16 Pond Junction","postalCode":"85215","city":"Mesa","state":"AZ","phoneNumber":"602-146-3701"}, +{"id":135,"firstName":"Letta","lastName":"Smelley","street":"537 Helena Circle","postalCode":"22119","city":"Merrifield","state":"VA","phoneNumber":"571-472-5640"}, +{"id":136,"firstName":"Clerc","lastName":"Mc Ilwrick","street":"7050 Northfield Street","postalCode":"90050","city":"Los Angeles","state":"CA","email":"cmcilwrick3r@abc.net.au"}, +{"id":137,"firstName":"Abba","lastName":"Sutherns","street":"8087 Monterey Lane","postalCode":"83757","city":"Boise","state":"ID","phoneNumber":"208-110-3153","email":"asutherns3s@dropbox.com"}, +{"id":138,"firstName":"Karola","lastName":"Symper","street":"4596 Clyde Gallagher Road","postalCode":"28815","city":"Asheville","state":"NC","email":"ksymper3t@parallels.com"}, +{"id":139,"firstName":"Jessamyn","lastName":"Deacock","street":"19557 Bobwhite Way","postalCode":"19725","city":"Newark","state":"DE","phoneNumber":"302-174-2938"}, +{"id":140,"firstName":"Iggy","lastName":"Impey","street":"8 Brown Place","postalCode":"27499","city":"Greensboro","state":"NC"}, +{"id":141,"firstName":"Kary","lastName":"Mably","street":"75 Porter Avenue","postalCode":"70174","city":"New Orleans","state":"LA","email":"kmably3w@miibeian.gov.cn"}, +{"id":142,"firstName":"Ciel","lastName":"Tidbold","street":"54 Mitchell Lane","postalCode":"90055","city":"Los Angeles","state":"CA"}, +{"id":143,"firstName":"Dyana","lastName":"Orcott","street":"2 Kinsman Street","postalCode":"90005","city":"Los Angeles","state":"CA","phoneNumber":"310-366-6987"}, +{"id":144,"firstName":"Damien","lastName":"Haking","street":"2 Elmside Point","postalCode":"62705","city":"Springfield","state":"IL","email":"dhaking3z@drupal.org"}, +{"id":145,"firstName":"Ricardo","lastName":"Bille","street":"3 Mesta Hill","postalCode":"98411","city":"Tacoma","state":"WA","email":"rbille40@ebay.co.uk"}, +{"id":146,"firstName":"Carlene","lastName":"Roget","street":"8 Granby Avenue","postalCode":"35225","city":"Birmingham","state":"AL","phoneNumber":"205-762-4907","email":"croget41@statcounter.com"}, +{"id":147,"firstName":"Sharlene","lastName":"Antusch","street":"02445 Stang Parkway","postalCode":"55480","city":"Minneapolis","state":"MN","email":"santusch42@mtv.com"}, +{"id":148,"firstName":"Goober","lastName":"Danielczyk","street":"474 Union Court","postalCode":"70505","city":"Lafayette","state":"LA","phoneNumber":"337-779-0312","email":"gdanielczyk43@dion.ne.jp"}, +{"id":149,"firstName":"Janette","lastName":"Mauro","street":"1231 Commercial Crossing","postalCode":"97201","city":"Portland","state":"OR","phoneNumber":"971-423-7259"}, +{"id":150,"firstName":"Melinda","lastName":"Shitliffe","street":"244 Derek Drive","postalCode":"23208","city":"Richmond","state":"VA","phoneNumber":"804-864-5845"}, +{"id":151,"firstName":"Constance","lastName":"Fardon","street":"3 Lien Point","postalCode":"89105","city":"Las Vegas","state":"NV"}, +{"id":152,"firstName":"Tedd","lastName":"Storey","street":"2551 Luster Point","postalCode":"19151","city":"Philadelphia","state":"PA","phoneNumber":"215-622-9273","email":"tstorey47@google.com.au"}, +{"id":153,"firstName":"Brigitte","lastName":"Slograve","street":"8130 Waubesa Hill","postalCode":"11499","city":"Jamaica","state":"NY","email":"bslograve48@yandex.ru"}, +{"id":154,"firstName":"Ralph","lastName":"Comberbeach","street":"88140 Anderson Avenue","postalCode":"90076","city":"Los Angeles","state":"CA"}, +{"id":155,"firstName":"Deloria","lastName":"Thomazet","street":"666 Center Crossing","postalCode":"38119","city":"Memphis","state":"TN","phoneNumber":"615-840-7916"}, +{"id":156,"firstName":"Fidel","lastName":"MacClay","street":"01 Fairfield Point","postalCode":"24034","city":"Roanoke","state":"VA","email":"fmacclay4b@sitemeter.com"}, +{"id":157,"firstName":"Amalee","lastName":"Menzies","street":"6 Judy Drive","postalCode":"84605","city":"Provo","state":"UT"}, +{"id":158,"firstName":"Ansel","lastName":"Jory","street":"3 Nobel Park","postalCode":"32505","city":"Pensacola","state":"FL","phoneNumber":"850-394-8201"}, +{"id":159,"firstName":"Teodor","lastName":"Longhorn","street":"563 Sutherland Avenue","postalCode":"98008","city":"Bellevue","state":"WA"}, +{"id":160,"firstName":"Margarita","lastName":"Rewcassell","street":"64711 Beilfuss Point","postalCode":"79764","city":"Odessa","state":"TX","phoneNumber":"432-413-2196"}, +{"id":161,"firstName":"Tarra","lastName":"Albro","street":"2 Graceland Way","postalCode":"78405","city":"Corpus Christi","state":"TX"}, +{"id":162,"firstName":"Whitaker","lastName":"Brizell","street":"6 Luster Place","postalCode":"33694","city":"Tampa","state":"FL","email":"wbrizell4h@naver.com"}, +{"id":163,"firstName":"Gauthier","lastName":"Getsham","street":"0820 Duke Plaza","postalCode":"28263","city":"Charlotte","state":"NC","phoneNumber":"704-510-2908"}, +{"id":164,"firstName":"Thane","lastName":"Discombe","street":"56809 Aberg Street","postalCode":"63167","city":"Saint Louis","state":"MO"}, +{"id":165,"firstName":"Felicia","lastName":"Barthrup","street":"904 Stuart Junction","postalCode":"32220","city":"Jacksonville","state":"FL"}, +{"id":166,"firstName":"Emeline","lastName":"Jobes","street":"2670 Prairieview Plaza","postalCode":"10120","city":"New York City","state":"NY","email":"ejobes4l@newyorker.com"}, +{"id":167,"firstName":"Felicle","lastName":"Bowie","street":"9715 Lighthouse Bay Parkway","postalCode":"11210","city":"Brooklyn","state":"NY","email":"fbowie4m@auda.org.au"}, +{"id":168,"firstName":"Clare","lastName":"Miskelly","street":"8 Towne Trail","postalCode":"44555","city":"Youngstown","state":"OH"}, +{"id":169,"firstName":"Mort","lastName":"Danat","street":"6833 Shoshone Lane","postalCode":"12255","city":"Albany","state":"NY","phoneNumber":"518-967-9791","email":"mdanat4o@privacy.gov.au"}, +{"id":170,"firstName":"Ailey","lastName":"Scatchar","street":"3 Northfield Point","postalCode":"76505","city":"Temple","state":"TX"}, +{"id":171,"firstName":"Kevina","lastName":"Darwent","street":"8165 Reinke Alley","postalCode":"94132","city":"San Francisco","state":"CA","email":"kdarwent4q@artisteer.com"}, +{"id":172,"firstName":"My","lastName":"Buston","street":"715 Saint Paul Center","postalCode":"31416","city":"Savannah","state":"GA","phoneNumber":"912-281-8654"}, +{"id":173,"firstName":"Emera","lastName":"Lingner","street":"943 Eastlawn Hill","postalCode":"90605","city":"Whittier","state":"CA"}, +{"id":174,"firstName":"Drucie","lastName":"Byer","street":"988 4th Court","postalCode":"06816","city":"Danbury","state":"CT","email":"dbyer4t@xinhuanet.com"}, +{"id":175,"firstName":"Modestine","lastName":"Madeley","street":"1 Delaware Terrace","postalCode":"80126","city":"Littleton","state":"CO"}, +{"id":176,"firstName":"Selie","lastName":"O'Mohun","street":"42 Monument Trail","postalCode":"55590","city":"Monticello","state":"MN","phoneNumber":"763-384-5166"}, +{"id":177,"firstName":"Shayla","lastName":"Pesselt","street":"7 Pawling Center","postalCode":"20099","city":"Washington","state":"DC","phoneNumber":"202-816-7300","email":"spesselt4w@posterous.com"}, +{"id":178,"firstName":"Raeann","lastName":"Layland","street":"06548 Longview Alley","postalCode":"77005","city":"Houston","state":"TX","phoneNumber":"214-899-1257","email":"rlayland4x@pcworld.com"}, +{"id":179,"firstName":"Dael","lastName":"Christaeas","street":"375 Northfield Street","postalCode":"23509","city":"Norfolk","state":"VA","phoneNumber":"757-391-2798","email":"dchristaeas4y@sciencedaily.com"}, +{"id":180,"firstName":"Nicolas","lastName":"Baxill","street":"9 Autumn Leaf Terrace","postalCode":"77005","city":"Houston","state":"TX","email":"nbaxill4z@edublogs.org"}, +{"id":181,"firstName":"Onida","lastName":"Pengilly","street":"61 Commercial Junction","postalCode":"24029","city":"Roanoke","state":"VA","email":"opengilly50@slideshare.net"}, +{"id":182,"firstName":"Muffin","lastName":"Thrasher","street":"1 Morning Hill","postalCode":"64082","city":"Lees Summit","state":"MO"}, +{"id":183,"firstName":"Ignaz","lastName":"McLugish","street":"3936 Columbus Point","postalCode":"35263","city":"Birmingham","state":"AL"}, +{"id":184,"firstName":"Guillaume","lastName":"Gillings","street":"75541 Sheridan Center","postalCode":"68510","city":"Lincoln","state":"NE","email":"ggillings53@unblog.fr"}, +{"id":185,"firstName":"Kalli","lastName":"Branche","street":"33740 Manitowish Court","postalCode":"96805","city":"Honolulu","state":"HI"}, +{"id":186,"firstName":"Winthrop","lastName":"Barszczewski","street":"9 Luster Terrace","postalCode":"60158","city":"Carol Stream","state":"IL","phoneNumber":"309-633-3125","email":"wbarszczewski55@eventbrite.com"}, +{"id":187,"firstName":"Renaud","lastName":"Nitto","street":"1 Crownhardt Place","postalCode":"10310","city":"Staten Island","state":"NY","phoneNumber":"914-568-4524","email":"rnitto56@typepad.com"}, +{"id":188,"firstName":"Pollyanna","lastName":"Wherrett","street":"31380 Upham Street","postalCode":"76134","city":"Fort Worth","state":"TX","phoneNumber":"817-198-3301","email":"pwherrett57@bluehost.com"}, +{"id":189,"firstName":"Lilly","lastName":"Gatchell","street":"7 Elka Road","postalCode":"94064","city":"Redwood City","state":"CA","email":"lgatchell58@patch.com"}, +{"id":190,"firstName":"Leopold","lastName":"Leavey","street":"9 Darwin Crossing","postalCode":"20268","city":"Washington","state":"DC","phoneNumber":"202-964-5932","email":"lleavey59@aol.com"}, +{"id":191,"firstName":"Byram","lastName":"Stuckes","street":"782 Northport Alley","postalCode":"55436","city":"Minneapolis","state":"MN"}, +{"id":192,"firstName":"Cull","lastName":"Whiterod","street":"2586 Banding Terrace","postalCode":"80249","city":"Denver","state":"CO","email":"cwhiterod5b@skype.com"}, +{"id":193,"firstName":"Gretel","lastName":"Tacey","street":"6382 Fremont Avenue","postalCode":"25305","city":"Charleston","state":"WV"}, +{"id":194,"firstName":"Tudor","lastName":"Piff","street":"0 Monterey Circle","postalCode":"00214","city":"Portsmouth","state":"NH","email":"tpiff5d@eepurl.com"}, +{"id":195,"firstName":"Julienne","lastName":"Adshed","street":"91839 Lawn Avenue","postalCode":"92519","city":"Riverside","state":"CA"}, +{"id":196,"firstName":"Arnold","lastName":"Fearns","street":"7 West Trail","postalCode":"35242","city":"Birmingham","state":"AL","email":"afearns5f@bravesites.com"}, +{"id":197,"firstName":"Dunc","lastName":"Khoter","street":"048 Clove Lane","postalCode":"89505","city":"Reno","state":"NV","phoneNumber":"775-120-9532","email":"dkhoter5g@bbb.org"}, +{"id":198,"firstName":"Stevana","lastName":"Lush","street":"6 Dovetail Plaza","postalCode":"79945","city":"El Paso","state":"TX","email":"slush5h@economist.com"}, +{"id":199,"firstName":"Iggy","lastName":"Verryan","street":"5 Sommers Road","postalCode":"34114","city":"Naples","state":"FL","phoneNumber":"239-205-8767"}, +{"id":200,"firstName":"Breena","lastName":"Rubbert","street":"5 Kensington Crossing","postalCode":"90510","city":"Torrance","state":"CA","email":"brubbert5j@phpbb.com"}, +{"id":201,"firstName":"Jervis","lastName":"Doree","street":"2947 Center Plaza","postalCode":"70160","city":"New Orleans","state":"LA","phoneNumber":"504-278-7497","email":"jdoree5k@shutterfly.com"}, +{"id":202,"firstName":"Odelia","lastName":"Lidierth","street":"36699 Aberg Park","postalCode":"62764","city":"Springfield","state":"IL"}, +{"id":203,"firstName":"Ree","lastName":"Lammerding","street":"3542 Lerdahl Court","postalCode":"88558","city":"El Paso","state":"TX","phoneNumber":"915-384-9334","email":"rlammerding5m@msu.edu"}, +{"id":204,"firstName":"Davy","lastName":"Orniz","street":"49 Graedel Parkway","postalCode":"48295","city":"Detroit","state":"MI","email":"dorniz5n@examiner.com"}, +{"id":205,"firstName":"Syd","lastName":"Buckoke","street":"70 Pepper Wood Alley","postalCode":"74156","city":"Tulsa","state":"OK","phoneNumber":"918-604-5799"}, +{"id":206,"firstName":"Ginger","lastName":"Calkin","street":"7 Thompson Trail","postalCode":"71115","city":"Shreveport","state":"LA","phoneNumber":"318-650-6046"}, +{"id":207,"firstName":"Anissa","lastName":"Ivashinnikov","street":"61905 Chive Circle","postalCode":"40745","city":"London","state":"KY","email":"aivashinnikov5q@google.cn"}, +{"id":208,"firstName":"Vikky","lastName":"Kesley","street":"1 Grayhawk Street","postalCode":"06538","city":"New Haven","state":"CT","phoneNumber":"203-944-7163"}, +{"id":209,"firstName":"Alisha","lastName":"Lampke","street":"26940 Kensington Park","postalCode":"55446","city":"Minneapolis","state":"MN","phoneNumber":"612-814-9814","email":"alampke5s@apple.com"}, +{"id":210,"firstName":"Davidde","lastName":"Phlipon","street":"2044 Ruskin Road","postalCode":"07188","city":"Newark","state":"NJ","email":"dphlipon5t@shareasale.com"}, +{"id":211,"firstName":"Joly","lastName":"Crottagh","street":"532 Dawn Plaza","postalCode":"85083","city":"Phoenix","state":"AZ","phoneNumber":"602-533-4064"}, +{"id":212,"firstName":"Aggie","lastName":"Niesing","street":"3 Tony Drive","postalCode":"57110","city":"Sioux Falls","state":"SD","email":"aniesing5v@pbs.org"}, +{"id":213,"firstName":"Daron","lastName":"Baudassi","street":"2411 Melvin Court","postalCode":"40581","city":"Lexington","state":"KY","phoneNumber":"859-754-2542","email":"dbaudassi5w@joomla.org"}, +{"id":214,"firstName":"Thadeus","lastName":"Kleiser","street":"1394 Warner Street","postalCode":"87592","city":"Santa Fe","state":"NM","email":"tkleiser5x@bloomberg.com"}, +{"id":215,"firstName":"Terri","lastName":"Perrat","street":"0080 Upham Plaza","postalCode":"52245","city":"Iowa City","state":"IA"}, +{"id":216,"firstName":"Marlena","lastName":"Gatchell","street":"60888 Annamark Street","postalCode":"90060","city":"Los Angeles","state":"CA","phoneNumber":"323-121-6985","email":"mgatchell5z@ibm.com"}, +{"id":217,"firstName":"Locke","lastName":"Orcott","street":"459 Warner Lane","postalCode":"45020","city":"Hamilton","state":"OH","phoneNumber":"937-115-3187"}, +{"id":218,"firstName":"Wilmer","lastName":"Bewick","street":"0 Ohio Center","postalCode":"98166","city":"Seattle","state":"WA","phoneNumber":"253-805-8855","email":"wbewick61@seesaa.net"}, +{"id":219,"firstName":"Marena","lastName":"MacShirrie","street":"607 Badeau Circle","postalCode":"98008","city":"Bellevue","state":"WA","email":"mmacshirrie62@wikia.com"}, +{"id":220,"firstName":"Nathanial","lastName":"Sexty","street":"43 Basil Place","postalCode":"85020","city":"Phoenix","state":"AZ"}, +{"id":221,"firstName":"Wadsworth","lastName":"Iacovuzzi","street":"9610 Donald Crossing","postalCode":"88530","city":"El Paso","state":"TX","phoneNumber":"915-889-7936","email":"wiacovuzzi64@prnewswire.com"}, +{"id":222,"firstName":"Sutton","lastName":"Stych","street":"9 Brentwood Terrace","postalCode":"20546","city":"Washington","state":"DC","phoneNumber":"202-538-6355","email":"sstych65@wikimedia.org"}, +{"id":223,"firstName":"Gaspar","lastName":"Wabey","street":"3061 Bluejay Terrace","postalCode":"10110","city":"New York City","state":"NY","phoneNumber":"917-939-0802","email":"gwabey66@technorati.com"}, +{"id":224,"firstName":"Herminia","lastName":"Guyot","street":"91 Express Drive","postalCode":"85715","city":"Tucson","state":"AZ","phoneNumber":"520-777-1670","email":"hguyot67@admin.ch"}, +{"id":225,"firstName":"Udale","lastName":"Beurich","street":"675 Karstens Crossing","postalCode":"46852","city":"Fort Wayne","state":"IN","phoneNumber":"260-580-8627","email":"ubeurich68@bigcartel.com"}, +{"id":226,"firstName":"Kerrie","lastName":"Girauld","street":"56132 Charing Cross Court","postalCode":"71137","city":"Shreveport","state":"LA","email":"kgirauld69@nationalgeographic.com"}, +{"id":227,"firstName":"Irvin","lastName":"Nix","street":"0676 Aberg Terrace","postalCode":"97075","city":"Beaverton","state":"OR","email":"inix6a@xing.com"}, +{"id":228,"firstName":"Corene","lastName":"Spencock","street":"90 Meadow Ridge Drive","postalCode":"73173","city":"Oklahoma City","state":"OK","phoneNumber":"405-577-1312","email":"cspencock6b@shinystat.com"}, +{"id":229,"firstName":"Christos","lastName":"McIlreavy","street":"673 Jana Trail","postalCode":"23471","city":"Virginia Beach","state":"VA","email":"cmcilreavy6c@mayoclinic.com"}, +{"id":230,"firstName":"Bennett","lastName":"Melding","street":"4 Cardinal Lane","postalCode":"55448","city":"Minneapolis","state":"MN","email":"bmelding6d@t-online.de"}, +{"id":231,"firstName":"Winny","lastName":"de Leon","street":"941 Scoville Place","postalCode":"94611","city":"Oakland","state":"CA","phoneNumber":"510-230-4168","email":"wdeleon6e@dell.com"}, +{"id":232,"firstName":"Nike","lastName":"Iacobassi","street":"956 Service Junction","postalCode":"71914","city":"Hot Springs National Park","state":"AR","phoneNumber":"501-266-4142"}, +{"id":233,"firstName":"Gillan","lastName":"Baumann","street":"11 8th Alley","postalCode":"31190","city":"Atlanta","state":"GA","phoneNumber":"404-703-5154","email":"gbaumann6g@edublogs.org"}, +{"id":234,"firstName":"Brandtr","lastName":"Gadman","street":"5 Marquette Hill","postalCode":"32511","city":"Pensacola","state":"FL","phoneNumber":"850-834-0058","email":"bgadman6h@marriott.com"}, +{"id":235,"firstName":"Kenn","lastName":"Cage","street":"3759 Spohn Point","postalCode":"94126","city":"San Francisco","state":"CA","email":"kcage6i@earthlink.net"}, +{"id":236,"firstName":"Butch","lastName":"Causby","street":"02 Basil Crossing","postalCode":"10110","city":"New York City","state":"NY","phoneNumber":"212-190-1702","email":"bcausby6j@scribd.com"}, +{"id":237,"firstName":"Haleigh","lastName":"Parsonson","street":"8 Ruskin Trail","postalCode":"87201","city":"Albuquerque","state":"NM","phoneNumber":"505-987-1352"}, +{"id":238,"firstName":"Bartel","lastName":"Ruppeli","street":"7538 Red Cloud Center","postalCode":"37410","city":"Chattanooga","state":"TN","phoneNumber":"423-804-1016","email":"bruppeli6l@etsy.com"}, +{"id":239,"firstName":"Gretchen","lastName":"Le feaver","street":"7 Orin Way","postalCode":"98042","city":"Kent","state":"WA","phoneNumber":"253-205-3092","email":"glefeaver6m@mayoclinic.com"}, +{"id":240,"firstName":"Trumaine","lastName":"Dearden","street":"1 Vernon Trail","postalCode":"06127","city":"West Hartford","state":"CT","phoneNumber":"860-939-3865","email":"tdearden6n@goo.gl"}, +{"id":241,"firstName":"Aggie","lastName":"Dubs","street":"3601 Walton Trail","postalCode":"62764","city":"Springfield","state":"IL","phoneNumber":"217-834-6059","email":"adubs6o@cbsnews.com"}, +{"id":242,"firstName":"Shelly","lastName":"Skechley","street":"16 Morning Lane","postalCode":"60567","city":"Naperville","state":"IL","email":"sskechley6p@technorati.com"}, +{"id":243,"firstName":"Karin","lastName":"Fausch","street":"7532 Eggendart Way","postalCode":"19810","city":"Wilmington","state":"DE","phoneNumber":"302-548-2991"}, +{"id":244,"firstName":"Sal","lastName":"Harrow","street":"2632 Lien Way","postalCode":"33982","city":"Punta Gorda","state":"FL","phoneNumber":"941-904-5187","email":"sharrow6r@joomla.org"}, +{"id":245,"firstName":"Albie","lastName":"Strelitzki","street":"8436 Eggendart Terrace","postalCode":"49505","city":"Grand Rapids","state":"MI","email":"astrelitzki6s@google.com.br"}, +{"id":246,"firstName":"Augy","lastName":"Usherwood","street":"9078 Clemons Street","postalCode":"80915","city":"Colorado Springs","state":"CO","email":"ausherwood6t@wikimedia.org"}, +{"id":247,"firstName":"Solomon","lastName":"D'eathe","street":"778 Rockefeller Parkway","postalCode":"84199","city":"Salt Lake City","state":"UT"}, +{"id":248,"firstName":"Talya","lastName":"Joseff","street":"14 Graedel Court","postalCode":"99220","city":"Spokane","state":"WA","email":"tjoseff6v@amazon.de"}, +{"id":249,"firstName":"Anatol","lastName":"Self","street":"2 Stoughton Junction","postalCode":"85255","city":"Scottsdale","state":"AZ"}, +{"id":250,"firstName":"Elinore","lastName":"Bruhnke","street":"3 Bashford Alley","postalCode":"17105","city":"Harrisburg","state":"PA","email":"ebruhnke6x@usnews.com"}, +{"id":251,"firstName":"Stanfield","lastName":"Jagiello","street":"0804 Amoth Road","postalCode":"20067","city":"Washington","state":"DC"}, +{"id":252,"firstName":"Isak","lastName":"Venour","street":"04 Orin Court","postalCode":"78210","city":"San Antonio","state":"TX","email":"ivenour6z@springer.com"}, +{"id":253,"firstName":"Abigale","lastName":"Woolgar","street":"74 Porter Terrace","postalCode":"62705","city":"Springfield","state":"IL"}, +{"id":254,"firstName":"Phylys","lastName":"Casperri","street":"07 Delaware Street","postalCode":"33069","city":"Pompano Beach","state":"FL","phoneNumber":"954-224-4577"}, +{"id":255,"firstName":"Melania","lastName":"Fee","street":"194 Luster Point","postalCode":"70154","city":"New Orleans","state":"LA","phoneNumber":"504-168-6959","email":"mfee72@comsenz.com"}, +{"id":256,"firstName":"Joli","lastName":"Colquite","street":"9 Bayside Court","postalCode":"27425","city":"Greensboro","state":"NC","email":"jcolquite73@comcast.net"}, +{"id":257,"firstName":"Rahel","lastName":"Late","street":"2 Meadow Ridge Alley","postalCode":"32204","city":"Jacksonville","state":"FL"}, +{"id":258,"firstName":"Carny","lastName":"Fewell","street":"21826 Cardinal Pass","postalCode":"98140","city":"Seattle","state":"WA"}, +{"id":259,"firstName":"Lesly","lastName":"Vanyatin","street":"7730 South Court","postalCode":"25356","city":"Charleston","state":"WV","email":"lvanyatin76@histats.com"}, +{"id":260,"firstName":"Fianna","lastName":"Thomason","street":"2576 Holmberg Trail","postalCode":"27710","city":"Durham","state":"NC"}, +{"id":261,"firstName":"Bobinette","lastName":"Gowdridge","street":"6780 Superior Place","postalCode":"37605","city":"Johnson City","state":"TN","phoneNumber":"423-490-4990","email":"bgowdridge78@icio.us"}, +{"id":262,"firstName":"Karmen","lastName":"Megson","street":"34 Messerschmidt Point","postalCode":"97229","city":"Portland","state":"OR","email":"kmegson79@apache.org"}, +{"id":263,"firstName":"Thaddeus","lastName":"Padilla","street":"42 Corben Road","postalCode":"90010","city":"Los Angeles","state":"CA","phoneNumber":"213-659-3136","email":"tpadilla7a@hud.gov"}, +{"id":264,"firstName":"Hanna","lastName":"Baswall","street":"9 Old Shore Lane","postalCode":"53710","city":"Madison","state":"WI","email":"hbaswall7b@ezinearticles.com"}, +{"id":265,"firstName":"Tania","lastName":"McMorland","street":"4333 Commercial Point","postalCode":"45408","city":"Dayton","state":"OH"}, +{"id":266,"firstName":"Gifford","lastName":"Arne","street":"0 Drewry Point","postalCode":"24048","city":"Roanoke","state":"VA","email":"garne7d@samsung.com"}, +{"id":267,"firstName":"Tomasina","lastName":"Linch","street":"64992 Maple Wood Point","postalCode":"98447","city":"Tacoma","state":"WA","email":"tlinch7e@theglobeandmail.com"}, +{"id":268,"firstName":"Merrick","lastName":"Garvan","street":"7220 Melody Trail","postalCode":"90005","city":"Los Angeles","state":"CA","email":"mgarvan7f@mozilla.org"}, +{"id":269,"firstName":"Carmita","lastName":"Sailes","street":"3 Bay Lane","postalCode":"55428","city":"Minneapolis","state":"MN","email":"csailes7g@devhub.com"}, +{"id":270,"firstName":"Lesly","lastName":"Eslemont","street":"93302 Mcbride Terrace","postalCode":"19810","city":"Wilmington","state":"DE","email":"leslemont7h@wunderground.com"}, +{"id":271,"firstName":"Adelaida","lastName":"Keggins","street":"4 Birchwood Pass","postalCode":"97405","city":"Eugene","state":"OR","phoneNumber":"541-387-1319"}, +{"id":272,"firstName":"Peadar","lastName":"Forte","street":"1 Montana Center","postalCode":"32505","city":"Pensacola","state":"FL","email":"pforte7j@xing.com"}, +{"id":273,"firstName":"Godfrey","lastName":"Swatland","street":"477 Maple Wood Road","postalCode":"93034","city":"Oxnard","state":"CA","phoneNumber":"805-267-0614","email":"gswatland7k@photobucket.com"}, +{"id":274,"firstName":"Marten","lastName":"Jelleman","street":"57 Pennsylvania Plaza","postalCode":"20057","city":"Washington","state":"DC","email":"mjelleman7l@phoca.cz"}, +{"id":275,"firstName":"Sharity","lastName":"Keady","street":"753 Sauthoff Place","postalCode":"77505","city":"Pasadena","state":"TX"}, +{"id":276,"firstName":"Gabbie","lastName":"Pally","street":"45 Fallview Park","postalCode":"97255","city":"Portland","state":"OR","phoneNumber":"971-412-2293","email":"gpally7n@dyndns.org"}, +{"id":277,"firstName":"Betsy","lastName":"Rhelton","street":"9 Jackson Road","postalCode":"85040","city":"Phoenix","state":"AZ"}, +{"id":278,"firstName":"Patty","lastName":"Schooling","street":"4 Moulton Point","postalCode":"25705","city":"Huntington","state":"WV","phoneNumber":"304-908-8211","email":"pschooling7p@parallels.com"}, +{"id":279,"firstName":"Katlin","lastName":"O'Hallagan","street":"8418 Petterle Plaza","postalCode":"60636","city":"Chicago","state":"IL","email":"kohallagan7q@hao123.com"}, +{"id":280,"firstName":"Anne","lastName":"Wealleans","street":"3 Sachtjen Court","postalCode":"48609","city":"Saginaw","state":"MI"}, +{"id":281,"firstName":"Flory","lastName":"Pley","street":"6322 Golf View Court","postalCode":"19104","city":"Philadelphia","state":"PA"}, +{"id":282,"firstName":"Maryellen","lastName":"Baszkiewicz","street":"54165 Hanson Trail","postalCode":"93726","city":"Fresno","state":"CA","phoneNumber":"209-198-4916","email":"mbaszkiewicz7t@google.com.br"}, +{"id":283,"firstName":"Moyna","lastName":"Caddens","street":"17 Melrose Lane","postalCode":"11236","city":"Brooklyn","state":"NY","phoneNumber":"917-518-3987","email":"mcaddens7u@amazon.co.uk"}, +{"id":284,"firstName":"Lawton","lastName":"Ramiro","street":"2 Muir Park","postalCode":"48092","city":"Warren","state":"MI","phoneNumber":"810-472-5208","email":"lramiro7v@senate.gov"}, +{"id":285,"firstName":"Agnella","lastName":"Phelip","street":"24566 Colorado Pass","postalCode":"84145","city":"Salt Lake City","state":"UT","phoneNumber":"801-709-8696","email":"aphelip7w@woothemes.com"}, +{"id":286,"firstName":"Tracee","lastName":"Tighe","street":"41013 Cascade Lane","postalCode":"02142","city":"Cambridge","state":"MA"}, +{"id":287,"firstName":"Shelden","lastName":"Sowrey","street":"87 Glacier Hill Court","postalCode":"55557","city":"Young America","state":"MN","email":"ssowrey7y@sfgate.com"}, +{"id":288,"firstName":"Letizia","lastName":"Sallery","street":"65052 Shasta Court","postalCode":"44905","city":"Mansfield","state":"OH","phoneNumber":"419-752-9141"}, +{"id":289,"firstName":"Hilly","lastName":"Oyley","street":"7 Waywood Trail","postalCode":"30323","city":"Atlanta","state":"GA","email":"hoyley80@upenn.edu"}, +{"id":290,"firstName":"Sabra","lastName":"Grigoryev","street":"856 Michigan Trail","postalCode":"33705","city":"Saint Petersburg","state":"FL"}, +{"id":291,"firstName":"Nathanil","lastName":"Bodham","street":"536 Ridgeview Way","postalCode":"79984","city":"El Paso","state":"TX","email":"nbodham82@wikimedia.org"}, +{"id":292,"firstName":"Niven","lastName":"Hartzenberg","street":"5 Carpenter Hill","postalCode":"73167","city":"Oklahoma City","state":"OK","email":"nhartzenberg83@bandcamp.com"}, +{"id":293,"firstName":"Rachael","lastName":"Birdsall","street":"61484 Mendota Point","postalCode":"90410","city":"Santa Monica","state":"CA","email":"rbirdsall84@gmpg.org"}, +{"id":294,"firstName":"Gypsy","lastName":"Rallin","street":"4 Spohn Drive","postalCode":"77346","city":"Humble","state":"TX","phoneNumber":"713-508-2912","email":"grallin85@privacy.gov.au"}, +{"id":295,"firstName":"Skye","lastName":"Arsey","street":"49126 Maryland Lane","postalCode":"02119","city":"Boston","state":"MA"}, +{"id":296,"firstName":"Karalee","lastName":"Biddiss","street":"0327 Coleman Lane","postalCode":"10203","city":"New York City","state":"NY","email":"kbiddiss87@studiopress.com"}, +{"id":297,"firstName":"Russ","lastName":"O' Mahony","street":"7831 Caliangt Avenue","postalCode":"37665","city":"Kingsport","state":"TN","phoneNumber":"423-292-1177","email":"romahony88@umich.edu"}, +{"id":298,"firstName":"Gerianne","lastName":"Morfey","street":"1 Jay Hill","postalCode":"97229","city":"Portland","state":"OR","email":"gmorfey89@techcrunch.com"}, +{"id":299,"firstName":"Griz","lastName":"Vellacott","street":"44 Parkside Court","postalCode":"64149","city":"Kansas City","state":"MO","phoneNumber":"816-120-1692"}, +{"id":300,"firstName":"Parker","lastName":"Mantz","street":"3 Arkansas Lane","postalCode":"90005","city":"Los Angeles","state":"CA","email":"pmantz8b@va.gov"}, +{"id":301,"firstName":"Drugi","lastName":"Acaster","street":"426 Hagan Park","postalCode":"20599","city":"Washington","state":"DC","email":"dacaster8c@ihg.com"}, +{"id":302,"firstName":"Peder","lastName":"Monget","street":"9 Wayridge Parkway","postalCode":"92862","city":"Orange","state":"CA","phoneNumber":"714-532-0867","email":"pmonget8d@biblegateway.com"}, +{"id":303,"firstName":"Zilvia","lastName":"Grocutt","street":"1 Stuart Circle","postalCode":"34642","city":"Seminole","state":"FL"}, +{"id":304,"firstName":"Clyve","lastName":"Gunby","street":"75 Dunning Junction","postalCode":"79977","city":"El Paso","state":"TX","email":"cgunby8f@microsoft.com"}, +{"id":305,"firstName":"Zacharias","lastName":"Tomasini","street":"48488 Thackeray Way","postalCode":"40210","city":"Louisville","state":"KY","email":"ztomasini8g@harvard.edu"}, +{"id":306,"firstName":"Ferdinand","lastName":"McGuinley","street":"30366 Kipling Drive","postalCode":"23208","city":"Richmond","state":"VA","email":"fmcguinley8h@archive.org"}, +{"id":307,"firstName":"Ebonee","lastName":"Brumfitt","street":"18765 Division Terrace","postalCode":"30033","city":"Decatur","state":"GA","phoneNumber":"404-684-8364","email":"ebrumfitt8i@sourceforge.net"}, +{"id":308,"firstName":"Christy","lastName":"Cuniam","street":"6 Homewood Road","postalCode":"78744","city":"Austin","state":"TX","phoneNumber":"361-677-9833","email":"ccuniam8j@51.la"}, +{"id":309,"firstName":"Emelen","lastName":"Casin","street":"91 Thompson Plaza","postalCode":"33954","city":"Port Charlotte","state":"FL","email":"ecasin8k@webnode.com"}, +{"id":310,"firstName":"Babara","lastName":"Robberecht","street":"603 Oak Terrace","postalCode":"37450","city":"Chattanooga","state":"TN","email":"brobberecht8l@cargocollective.com"}, +{"id":311,"firstName":"Cesar","lastName":"Whitecross","street":"024 Oxford Junction","postalCode":"20226","city":"Washington","state":"DC","phoneNumber":"202-772-2936"}, +{"id":312,"firstName":"Frieda","lastName":"Sliman","street":"4 Beilfuss Hill","postalCode":"23324","city":"Chesapeake","state":"VA","email":"fsliman8n@bigcartel.com"}, +{"id":313,"firstName":"Dylan","lastName":"Paige","street":"26 Gina Parkway","postalCode":"55448","city":"Minneapolis","state":"MN","email":"dpaige8o@trellian.com"}, +{"id":314,"firstName":"Waring","lastName":"Labon","street":"2843 Spenser Center","postalCode":"49444","city":"Muskegon","state":"MI","phoneNumber":"231-274-0766","email":"wlabon8p@ucla.edu"}, +{"id":315,"firstName":"Conny","lastName":"Duinkerk","street":"65 Lunder Circle","postalCode":"45426","city":"Dayton","state":"OH","email":"cduinkerk8q@economist.com"}, +{"id":316,"firstName":"Nessie","lastName":"Stucksbury","street":"91449 Browning Drive","postalCode":"25705","city":"Huntington","state":"WV","phoneNumber":"304-182-0766"}, +{"id":317,"firstName":"Corrine","lastName":"Kohlert","street":"00706 Carioca Plaza","postalCode":"45223","city":"Cincinnati","state":"OH","email":"ckohlert8s@wunderground.com"}, +{"id":318,"firstName":"Horatio","lastName":"Greengrass","street":"0 Cascade Park","postalCode":"79905","city":"El Paso","state":"TX","email":"hgreengrass8t@ameblo.jp"}, +{"id":319,"firstName":"Jana","lastName":"McLae","street":"919 Esch Place","postalCode":"55428","city":"Minneapolis","state":"MN","email":"jmclae8u@nytimes.com"}, +{"id":320,"firstName":"Maressa","lastName":"Rehor","street":"55 Talisman Junction","postalCode":"90505","city":"Torrance","state":"CA","email":"mrehor8v@vinaora.com"}, +{"id":321,"firstName":"Filide","lastName":"Riehm","street":"0 Karstens Lane","postalCode":"95054","city":"Santa Clara","state":"CA"}, +{"id":322,"firstName":"Bunnie","lastName":"Mumbey","street":"9369 Bayside Circle","postalCode":"46216","city":"Indianapolis","state":"IN","email":"bmumbey8x@scribd.com"}, +{"id":323,"firstName":"Maxi","lastName":"Jentgens","street":"2970 Rowland Circle","postalCode":"84189","city":"Salt Lake City","state":"UT","phoneNumber":"801-423-8854","email":"mjentgens8y@ihg.com"}, +{"id":324,"firstName":"Florri","lastName":"Okenden","street":"2180 Cody Point","postalCode":"70187","city":"New Orleans","state":"LA","phoneNumber":"504-913-1989","email":"fokenden8z@networksolutions.com"}, +{"id":325,"firstName":"Imogen","lastName":"Grisard","street":"8 Westerfield Avenue","postalCode":"92668","city":"Orange","state":"CA","email":"igrisard90@tamu.edu"}, +{"id":326,"firstName":"Edwina","lastName":"Montes","street":"92 Carpenter Avenue","postalCode":"97216","city":"Portland","state":"OR","phoneNumber":"503-544-7296","email":"emontes91@reference.com"}, +{"id":327,"firstName":"Renelle","lastName":"MacCambridge","street":"77 Talmadge Circle","postalCode":"08638","city":"Trenton","state":"NJ","phoneNumber":"609-150-9438","email":"rmaccambridge92@springer.com"}, +{"id":328,"firstName":"Sterne","lastName":"Taberner","street":"642 6th Terrace","postalCode":"10120","city":"New York City","state":"NY","email":"staberner93@miibeian.gov.cn"}, +{"id":329,"firstName":"Garvy","lastName":"Pankethman","street":"8618 Kennedy Terrace","postalCode":"79405","city":"Lubbock","state":"TX","phoneNumber":"806-470-8784","email":"gpankethman94@free.fr"}, +{"id":330,"firstName":"Nathanil","lastName":"Holston","street":"27247 Eliot Avenue","postalCode":"31190","city":"Atlanta","state":"GA","email":"nholston95@drupal.org"}, +{"id":331,"firstName":"Caresse","lastName":"Kilty","street":"514 Manufacturers Pass","postalCode":"76205","city":"Denton","state":"TX","email":"ckilty96@umich.edu"}, +{"id":332,"firstName":"Arlinda","lastName":"Brenstuhl","street":"2 Sunnyside Avenue","postalCode":"55470","city":"Minneapolis","state":"MN","email":"abrenstuhl97@wisc.edu"}, +{"id":333,"firstName":"Darcy","lastName":"Dunne","street":"3 Badeau Park","postalCode":"91328","city":"Northridge","state":"CA"}, +{"id":334,"firstName":"Malva","lastName":"Grew","street":"2242 Huxley Hill","postalCode":"68510","city":"Lincoln","state":"NE","email":"mgrew99@com.com"}, +{"id":335,"firstName":"Sukey","lastName":"Winspur","street":"475 Melvin Way","postalCode":"68524","city":"Lincoln","state":"NE","phoneNumber":"402-816-9401"}, +{"id":336,"firstName":"Beth","lastName":"O'Dougherty","street":"450 Eastlawn Park","postalCode":"93591","city":"Palmdale","state":"CA","phoneNumber":"661-845-8781"}, +{"id":337,"firstName":"Cortney","lastName":"Meers","street":"9 Chive Drive","postalCode":"93762","city":"Fresno","state":"CA","email":"cmeers9c@diigo.com"}, +{"id":338,"firstName":"Geralda","lastName":"Brocket","street":"0686 La Follette Avenue","postalCode":"80126","city":"Littleton","state":"CO","phoneNumber":"720-641-1371","email":"gbrocket9d@youku.com"}, +{"id":339,"firstName":"Lishe","lastName":"Maliphant","street":"5 Erie Plaza","postalCode":"63169","city":"Saint Louis","state":"MO","email":"lmaliphant9e@sfgate.com"}, +{"id":340,"firstName":"Brod","lastName":"Dobrovsky","street":"9 Gateway Park","postalCode":"79405","city":"Lubbock","state":"TX"}, +{"id":341,"firstName":"Philippe","lastName":"Argile","street":"4 Red Cloud Plaza","postalCode":"49444","city":"Muskegon","state":"MI","phoneNumber":"231-633-5495"}, +{"id":342,"firstName":"Sadye","lastName":"Sally","street":"07 Mendota Terrace","postalCode":"75507","city":"Texarkana","state":"TX","email":"ssally9h@e-recht24.de"}, +{"id":343,"firstName":"Napoleon","lastName":"Piggott","street":"3968 Roxbury Point","postalCode":"35905","city":"Gadsden","state":"AL","email":"npiggott9i@cnbc.com"}, +{"id":344,"firstName":"Jere","lastName":"Larn","street":"5086 Dahle Crossing","postalCode":"39534","city":"Biloxi","state":"MS","email":"jlarn9j@twitter.com"}, +{"id":345,"firstName":"Bevon","lastName":"Stidson","street":"7 Armistice Court","postalCode":"23436","city":"Suffolk","state":"VA","email":"bstidson9k@alexa.com"}, +{"id":346,"firstName":"Drugi","lastName":"Ewbach","street":"6032 5th Avenue","postalCode":"02208","city":"Boston","state":"MA","email":"dewbach9l@techcrunch.com"}, +{"id":347,"firstName":"Milka","lastName":"Caizley","street":"7 Anderson Junction","postalCode":"37228","city":"Nashville","state":"TN","phoneNumber":"615-305-6985","email":"mcaizley9m@cyberchimps.com"}, +{"id":348,"firstName":"Wilton","lastName":"Biagi","street":"80833 6th Crossing","postalCode":"40215","city":"Louisville","state":"KY","email":"wbiagi9n@vinaora.com"}, +{"id":349,"firstName":"Dilly","lastName":"Spradbrow","street":"5 Harbort Street","postalCode":"45419","city":"Dayton","state":"OH","email":"dspradbrow9o@marketwatch.com"}, +{"id":350,"firstName":"Gan","lastName":"Gookey","street":"8387 Bultman Terrace","postalCode":"75241","city":"Dallas","state":"TX"}, +{"id":351,"firstName":"Nanon","lastName":"Mulrenan","street":"47257 Reindahl Drive","postalCode":"22119","city":"Merrifield","state":"VA","phoneNumber":"571-637-8154","email":"nmulrenan9q@godaddy.com"}, +{"id":352,"firstName":"Frederique","lastName":"Watkiss","street":"61 Heath Pass","postalCode":"70124","city":"New Orleans","state":"LA","phoneNumber":"504-891-7051"}, +{"id":353,"firstName":"Sinclare","lastName":"MacCurlye","street":"514 Meadow Ridge Place","postalCode":"97240","city":"Portland","state":"OR","phoneNumber":"971-190-5174","email":"smaccurlye9s@google.ru"}, +{"id":354,"firstName":"Jessie","lastName":"Newlands","street":"80509 Northland Pass","postalCode":"33111","city":"Miami","state":"FL","phoneNumber":"786-557-9193"}, +{"id":355,"firstName":"Jamaal","lastName":"Molder","street":"90 Mcbride Trail","postalCode":"78764","city":"Austin","state":"TX","phoneNumber":"512-320-8728"}, +{"id":356,"firstName":"Benni","lastName":"Sherel","street":"7 Springs Road","postalCode":"15235","city":"Pittsburgh","state":"PA","email":"bsherel9v@hostgator.com"}, +{"id":357,"firstName":"Dene","lastName":"Brigge","street":"8560 Sutteridge Parkway","postalCode":"32412","city":"Panama City","state":"FL"}, +{"id":358,"firstName":"Timoteo","lastName":"Iban","street":"52858 Oak Valley Hill","postalCode":"93750","city":"Fresno","state":"CA","email":"tiban9x@europa.eu"}, +{"id":359,"firstName":"Dar","lastName":"Quillinane","street":"2 Carberry Junction","postalCode":"66276","city":"Shawnee Mission","state":"KS","phoneNumber":"913-977-7562","email":"dquillinane9y@msn.com"}, +{"id":360,"firstName":"Claudian","lastName":"Tinson","street":"445 Novick Avenue","postalCode":"79968","city":"El Paso","state":"TX","email":"ctinson9z@google.cn"}, +{"id":361,"firstName":"Clarice","lastName":"Deneve","street":"94 Meadow Ridge Road","postalCode":"37131","city":"Murfreesboro","state":"TN","phoneNumber":"615-780-7667"}, +{"id":362,"firstName":"Hilary","lastName":"Bithell","street":"20 Russell Trail","postalCode":"81010","city":"Pueblo","state":"CO","email":"hbithella1@list-manage.com"}, +{"id":363,"firstName":"Mathew","lastName":"Scrivin","street":"4 Elgar Point","postalCode":"90081","city":"Los Angeles","state":"CA","phoneNumber":"213-898-6650","email":"mscrivina2@about.me"}, +{"id":364,"firstName":"Idell","lastName":"Rambadt","street":"6 Cherokee Hill","postalCode":"90840","city":"Long Beach","state":"CA","email":"irambadta3@ustream.tv"}, +{"id":365,"firstName":"Nealon","lastName":"Schoolfield","street":"1 Northland Point","postalCode":"74133","city":"Tulsa","state":"OK"}, +{"id":366,"firstName":"Gregorius","lastName":"Bartot","street":"24636 Eagle Crest Crossing","postalCode":"32215","city":"Jacksonville","state":"FL","email":"gbartota5@blogger.com"}, +{"id":367,"firstName":"Inessa","lastName":"Hullin","street":"559 Bartillon Trail","postalCode":"33142","city":"Miami","state":"FL","phoneNumber":"305-381-6621","email":"ihullina6@pcworld.com"}, +{"id":368,"firstName":"Andie","lastName":"Bampford","street":"5204 Meadow Valley Street","postalCode":"92825","city":"Anaheim","state":"CA","email":"abampforda7@sun.com"}, +{"id":369,"firstName":"Duane","lastName":"MacShirrie","street":"5077 Kings Parkway","postalCode":"92725","city":"Santa Ana","state":"CA","email":"dmacshirriea8@rambler.ru"}, +{"id":370,"firstName":"Sydel","lastName":"Deerr","street":"1 Commercial Road","postalCode":"30356","city":"Atlanta","state":"GA","phoneNumber":"404-209-0194","email":"sdeerra9@phpbb.com"}, +{"id":371,"firstName":"Mel","lastName":"Miles","street":"28164 Melody Plaza","postalCode":"90847","city":"Long Beach","state":"CA","phoneNumber":"562-932-1172"}, +{"id":372,"firstName":"Jone","lastName":"Drinkel","street":"946 Reindahl Point","postalCode":"48604","city":"Saginaw","state":"MI","phoneNumber":"989-547-0653"}, +{"id":373,"firstName":"Marcellus","lastName":"MacGilmartin","street":"10568 Westerfield Way","postalCode":"32868","city":"Orlando","state":"FL","phoneNumber":"407-874-6188","email":"mmacgilmartinac@fotki.com"}, +{"id":374,"firstName":"Bret","lastName":"Hardan","street":"9 Hayes Crossing","postalCode":"32309","city":"Tallahassee","state":"FL","email":"bhardanad@mit.edu"}, +{"id":375,"firstName":"Heddie","lastName":"Cesaric","street":"502 Cody Crossing","postalCode":"95397","city":"Modesto","state":"CA"}, +{"id":376,"firstName":"Tansy","lastName":"Maeer","street":"526 Messerschmidt Court","postalCode":"94089","city":"Sunnyvale","state":"CA","email":"tmaeeraf@arizona.edu"}, +{"id":377,"firstName":"Waverly","lastName":"West-Frimley","street":"02 Quincy Trail","postalCode":"20575","city":"Washington","state":"DC","phoneNumber":"202-493-3304","email":"wwestfrimleyag@ft.com"}, +{"id":378,"firstName":"Dido","lastName":"de Clercq","street":"7 Norway Maple Center","postalCode":"84125","city":"Salt Lake City","state":"UT","email":"ddeclercqah@trellian.com"}, +{"id":379,"firstName":"Vic","lastName":"Samuels","street":"2 Kipling Drive","postalCode":"31190","city":"Atlanta","state":"GA","email":"vsamuelsai@goo.gl"}, +{"id":380,"firstName":"Jeno","lastName":"Freiburger","street":"431 Golden Leaf Parkway","postalCode":"32610","city":"Gainesville","state":"FL","email":"jfreiburgeraj@theguardian.com"}, +{"id":381,"firstName":"Christine","lastName":"Basketter","street":"4 Lotheville Terrace","postalCode":"39305","city":"Meridian","state":"MS","phoneNumber":"601-702-1546"}, +{"id":382,"firstName":"Karry","lastName":"Corsan","street":"09189 Lakeland Point","postalCode":"27409","city":"Greensboro","state":"NC","phoneNumber":"336-445-0006","email":"kcorsanal@usgs.gov"}, +{"id":383,"firstName":"Barri","lastName":"Brinsden","street":"53 Shelley Drive","postalCode":"35225","city":"Birmingham","state":"AL","email":"bbrinsdenam@1und1.de"}, +{"id":384,"firstName":"Hyacintha","lastName":"Boddam","street":"45 Sugar Circle","postalCode":"10160","city":"New York City","state":"NY","phoneNumber":"212-794-6062"}, +{"id":385,"firstName":"Brande","lastName":"Remnant","street":"283 Stone Corner Road","postalCode":"31904","city":"Columbus","state":"GA","phoneNumber":"706-211-4851","email":"bremnantao@people.com.cn"}, +{"id":386,"firstName":"Tally","lastName":"Bygraves","street":"54833 Northport Pass","postalCode":"85072","city":"Phoenix","state":"AZ","email":"tbygravesap@jigsy.com"}, +{"id":387,"firstName":"Garfield","lastName":"Pressnell","street":"63077 Hudson Court","postalCode":"30061","city":"Marietta","state":"GA","email":"gpressnellaq@archive.org"}, +{"id":388,"firstName":"Romonda","lastName":"Stiggles","street":"17 Russell Parkway","postalCode":"32627","city":"Gainesville","state":"FL","phoneNumber":"352-600-9676"}, +{"id":389,"firstName":"Dedie","lastName":"Ralling","street":"8 Judy Plaza","postalCode":"94137","city":"San Francisco","state":"CA","email":"drallingas@wikia.com"}, +{"id":390,"firstName":"Maddi","lastName":"Cornau","street":"5 Oriole Way","postalCode":"92105","city":"San Diego","state":"CA","phoneNumber":"619-388-6359","email":"mcornauat@adobe.com"}, +{"id":391,"firstName":"Zeke","lastName":"Jennery","street":"65332 Sommers Avenue","postalCode":"48206","city":"Detroit","state":"MI","email":"zjenneryau@elegantthemes.com"}, +{"id":392,"firstName":"Danya","lastName":"Fairlaw","street":"343 Logan Alley","postalCode":"33111","city":"Miami","state":"FL","email":"dfairlawav@irs.gov"}, +{"id":393,"firstName":"Rabi","lastName":"Petheridge","street":"7 Monica Alley","postalCode":"64054","city":"Independence","state":"MO","phoneNumber":"816-501-9452"}, +{"id":394,"firstName":"Ebba","lastName":"Skellen","street":"2655 Iowa Terrace","postalCode":"63150","city":"Saint Louis","state":"MO","phoneNumber":"314-695-7831","email":"eskellenax@nbcnews.com"}, +{"id":395,"firstName":"Marie-ann","lastName":"Glaysher","street":"4 Lakewood Hill","postalCode":"12247","city":"Albany","state":"NY","phoneNumber":"518-634-2425"}, +{"id":396,"firstName":"Arne","lastName":"Quincey","street":"162 Redwing Way","postalCode":"83711","city":"Boise","state":"ID"}, +{"id":397,"firstName":"Clarita","lastName":"Okroy","street":"05 Delaware Way","postalCode":"45218","city":"Cincinnati","state":"OH","email":"cokroyb0@stumbleupon.com"}, +{"id":398,"firstName":"Renault","lastName":"Weighell","street":"498 Dovetail Place","postalCode":"79710","city":"Midland","state":"TX","phoneNumber":"432-955-1408"}, +{"id":399,"firstName":"Roderich","lastName":"Mankor","street":"07 Dayton Way","postalCode":"92160","city":"San Diego","state":"CA"}, +{"id":400,"firstName":"Arv","lastName":"Sunnex","street":"89 Ronald Regan Terrace","postalCode":"91109","city":"Pasadena","state":"CA","email":"asunnexb3@vkontakte.ru"}, +{"id":401,"firstName":"Sonia","lastName":"Cowperthwaite","street":"77 Dennis Point","postalCode":"16550","city":"Erie","state":"PA"}, +{"id":402,"firstName":"Buddie","lastName":"Goscomb","street":"85675 Eastlawn Pass","postalCode":"20535","city":"Washington","state":"DC"}, +{"id":403,"firstName":"Brandi","lastName":"Swaine","street":"39961 Del Mar Lane","postalCode":"39705","city":"Columbus","state":"MS","phoneNumber":"662-306-2164","email":"bswaineb6@miibeian.gov.cn"}, +{"id":404,"firstName":"Jenny","lastName":"Cabbell","street":"743 Fordem Center","postalCode":"78285","city":"San Antonio","state":"TX","phoneNumber":"210-491-9874","email":"jcabbellb7@techcrunch.com"}, +{"id":405,"firstName":"Vincent","lastName":"People","street":"83 Tennessee Way","postalCode":"77293","city":"Houston","state":"TX","phoneNumber":"281-261-1928","email":"vpeopleb8@github.io"}, +{"id":406,"firstName":"Reinald","lastName":"Roles","street":"2 Division Road","postalCode":"53785","city":"Madison","state":"WI","phoneNumber":"608-568-7958","email":"rrolesb9@google.fr"}, +{"id":407,"firstName":"Kale","lastName":"Wanek","street":"7 Crescent Oaks Terrace","postalCode":"46852","city":"Fort Wayne","state":"IN","phoneNumber":"260-844-9669","email":"kwanekba@scribd.com"}, +{"id":408,"firstName":"Charisse","lastName":"Perse","street":"94449 Gateway Street","postalCode":"91117","city":"Pasadena","state":"CA","email":"cpersebb@ycombinator.com"}, +{"id":409,"firstName":"Konstantin","lastName":"Aslum","street":"08 Kings Trail","postalCode":"80328","city":"Boulder","state":"CO","email":"kaslumbc@opera.com"}, +{"id":410,"firstName":"Tyson","lastName":"O'Hartigan","street":"75122 Crowley Place","postalCode":"95173","city":"San Jose","state":"CA","phoneNumber":"408-879-0901","email":"tohartiganbd@devhub.com"}, +{"id":411,"firstName":"Fallon","lastName":"Haysman","street":"477 High Crossing Place","postalCode":"23293","city":"Richmond","state":"VA"}, +{"id":412,"firstName":"Svend","lastName":"Scarlet","street":"2856 Merrick Circle","postalCode":"90087","city":"Los Angeles","state":"CA","email":"sscarletbf@clickbank.net"}, +{"id":413,"firstName":"Gabey","lastName":"Colter","street":"7 2nd Alley","postalCode":"90610","city":"Whittier","state":"CA"}, +{"id":414,"firstName":"Hart","lastName":"Densell","street":"2687 Elka Alley","postalCode":"99599","city":"Anchorage","state":"AK","phoneNumber":"907-286-6079"}, +{"id":415,"firstName":"Claresta","lastName":"Folger","street":"5 Amoth Alley","postalCode":"27116","city":"Winston Salem","state":"NC"}, +{"id":416,"firstName":"Rica","lastName":"Lightowlers","street":"54303 Mayer Drive","postalCode":"61825","city":"Champaign","state":"IL","email":"rlightowlersbj@so-net.ne.jp"}, +{"id":417,"firstName":"Paula","lastName":"Treadaway","street":"8 Anniversary Road","postalCode":"20456","city":"Washington","state":"DC"}, +{"id":418,"firstName":"Francoise","lastName":"Gooderick","street":"13 Knutson Lane","postalCode":"33325","city":"Fort Lauderdale","state":"FL","email":"fgooderickbl@dedecms.com"}, +{"id":419,"firstName":"Ferdy","lastName":"Nannizzi","street":"578 Esker Trail","postalCode":"25321","city":"Charleston","state":"WV","email":"fnannizzibm@rambler.ru"}, +{"id":420,"firstName":"Dody","lastName":"Gettone","street":"9 Veith Court","postalCode":"62711","city":"Springfield","state":"IL"}, +{"id":421,"firstName":"Ronna","lastName":"Godleman","street":"6 Jenna Trail","postalCode":"22301","city":"Alexandria","state":"VA","email":"rgodlemanbo@hexun.com"}, +{"id":422,"firstName":"Adey","lastName":"Waith","street":"2 Mayer Avenue","postalCode":"12325","city":"Schenectady","state":"NY"}, +{"id":423,"firstName":"Stanislaw","lastName":"Garahan","street":"660 Merry Avenue","postalCode":"62723","city":"Springfield","state":"IL","phoneNumber":"217-587-6734"}, +{"id":424,"firstName":"Westley","lastName":"Knowles","street":"67430 Lakeland Circle","postalCode":"53263","city":"Milwaukee","state":"WI","email":"wknowlesbr@msu.edu"}, +{"id":425,"firstName":"Dion","lastName":"Jamson","street":"696 Birchwood Circle","postalCode":"80015","city":"Aurora","state":"CO","phoneNumber":"720-486-4494"}, +{"id":426,"firstName":"Glynis","lastName":"Bourhill","street":"091 Harper Park","postalCode":"40250","city":"Louisville","state":"KY"}, +{"id":427,"firstName":"Massimo","lastName":"Briand","street":"37 Northview Junction","postalCode":"75507","city":"Texarkana","state":"TX","email":"mbriandbu@etsy.com"}, +{"id":428,"firstName":"Tremayne","lastName":"Cadore","street":"6721 Anthes Point","postalCode":"94605","city":"Oakland","state":"CA","email":"tcadorebv@mozilla.com"}, +{"id":429,"firstName":"Lea","lastName":"Wildman","street":"52 Dixon Point","postalCode":"50310","city":"Des Moines","state":"IA","phoneNumber":"515-536-2096"}, +{"id":430,"firstName":"Ambur","lastName":"Oxlade","street":"356 Porter Center","postalCode":"44485","city":"Warren","state":"OH"}, +{"id":431,"firstName":"Jyoti","lastName":"Gillet","street":"13 Del Mar Parkway","postalCode":"81505","city":"Grand Junction","state":"CO","phoneNumber":"970-598-0357"}, +{"id":432,"firstName":"Sascha","lastName":"Stanyan","street":"77289 Blue Bill Park Alley","postalCode":"06120","city":"Hartford","state":"CT","email":"sstanyanbz@geocities.jp"}, +{"id":433,"firstName":"Spenser","lastName":"Harry","street":"2021 Oak Place","postalCode":"32835","city":"Orlando","state":"FL","email":"sharryc0@privacy.gov.au"}, +{"id":434,"firstName":"Clim","lastName":"Penrose","street":"8 Warrior Road","postalCode":"15255","city":"Pittsburgh","state":"PA","email":"cpenrosec1@blogtalkradio.com"}, +{"id":435,"firstName":"Jewell","lastName":"McKinnon","street":"4 Delladonna Street","postalCode":"36114","city":"Montgomery","state":"AL","email":"jmckinnonc2@tinypic.com"}, +{"id":436,"firstName":"Estrellita","lastName":"Amburgy","street":"5538 Tennessee Plaza","postalCode":"17121","city":"Harrisburg","state":"PA","phoneNumber":"717-274-8930","email":"eamburgyc3@forbes.com"}, +{"id":437,"firstName":"Sarah","lastName":"Fears","street":"61 Springs Park","postalCode":"93034","city":"Oxnard","state":"CA","email":"sfearsc4@wisc.edu"}, +{"id":438,"firstName":"Nixie","lastName":"Peddie","street":"7 Armistice Way","postalCode":"10155","city":"New York City","state":"NY","email":"npeddiec5@free.fr"}, +{"id":439,"firstName":"Ardisj","lastName":"Rohmer","street":"726 Crowley Point","postalCode":"93399","city":"Bakersfield","state":"CA","email":"arohmerc6@google.nl"}, +{"id":440,"firstName":"Wallie","lastName":"Johanssen","street":"9555 Jana Park","postalCode":"28410","city":"Wilmington","state":"NC","phoneNumber":"910-160-4520","email":"wjohanssenc7@boston.com"}, +{"id":441,"firstName":"Allan","lastName":"Jodlkowski","street":"31585 Kedzie Park","postalCode":"89150","city":"Las Vegas","state":"NV","phoneNumber":"702-782-3289","email":"ajodlkowskic8@sogou.com"}, +{"id":442,"firstName":"Harris","lastName":"Cadden","street":"96829 Fieldstone Park","postalCode":"16565","city":"Erie","state":"PA","phoneNumber":"814-745-1099"}, +{"id":443,"firstName":"Nigel","lastName":"Girardengo","street":"24703 Red Cloud Road","postalCode":"90310","city":"Inglewood","state":"CA","email":"ngirardengoca@ow.ly"}, +{"id":444,"firstName":"Aila","lastName":"Tinniswood","street":"62812 Stephen Parkway","postalCode":"13205","city":"Syracuse","state":"NY","phoneNumber":"315-847-2259","email":"atinniswoodcb@google.com.br"}, +{"id":445,"firstName":"Genni","lastName":"Geockle","street":"81 Bobwhite Plaza","postalCode":"93721","city":"Fresno","state":"CA","email":"ggeocklecc@furl.net"}, +{"id":446,"firstName":"Madison","lastName":"Brikner","street":"166 Coolidge Trail","postalCode":"07208","city":"Elizabeth","state":"NJ","email":"mbriknercd@myspace.com"}, +{"id":447,"firstName":"Akim","lastName":"Gotthard.sf","street":"0017 Heffernan Parkway","postalCode":"71914","city":"Hot Springs National Park","state":"AR","email":"agotthardsfce@google.com.au"}, +{"id":448,"firstName":"Andria","lastName":"Cardello","street":"1089 Stang Road","postalCode":"96835","city":"Honolulu","state":"HI","phoneNumber":"808-372-6528"}, +{"id":449,"firstName":"Laureen","lastName":"Crawshaw","street":"13 Manitowish Avenue","postalCode":"23504","city":"Norfolk","state":"VA","phoneNumber":"757-220-4043"}, +{"id":450,"firstName":"Henderson","lastName":"Parmley","street":"3408 Superior Street","postalCode":"28410","city":"Wilmington","state":"NC","email":"hparmleych@diigo.com"}, +{"id":451,"firstName":"Henri","lastName":"Arnley","street":"54 Knutson Park","postalCode":"11470","city":"Jamaica","state":"NY","phoneNumber":"718-365-7389"}, +{"id":452,"firstName":"Phil","lastName":"Trunkfield","street":"07 Arizona Way","postalCode":"85030","city":"Phoenix","state":"AZ","email":"ptrunkfieldcj@cisco.com"}, +{"id":453,"firstName":"Chery","lastName":"Nangle","street":"03 Merrick Way","postalCode":"88569","city":"El Paso","state":"TX","phoneNumber":"915-959-5535","email":"cnangleck@tumblr.com"}, +{"id":454,"firstName":"Leora","lastName":"Fields","street":"0260 Eastlawn Lane","postalCode":"85311","city":"Glendale","state":"AZ","email":"lfieldscl@nyu.edu"}, +{"id":455,"firstName":"Ronnica","lastName":"Pocknoll","street":"786 Hovde Plaza","postalCode":"78410","city":"Corpus Christi","state":"TX","email":"rpocknollcm@unesco.org"}, +{"id":456,"firstName":"Valida","lastName":"Romayn","street":"1108 Hudson Drive","postalCode":"34615","city":"Clearwater","state":"FL","email":"vromayncn@usatoday.com"}, +{"id":457,"firstName":"Randee","lastName":"Strowther","street":"441 Cordelia Point","postalCode":"27710","city":"Durham","state":"NC","phoneNumber":"919-463-1516","email":"rstrowtherco@trellian.com"}, +{"id":458,"firstName":"Ansell","lastName":"Blacklock","street":"9393 Kedzie Point","postalCode":"75358","city":"Dallas","state":"TX","phoneNumber":"214-949-3912"}, +{"id":459,"firstName":"Bailie","lastName":"Wing","street":"79459 Buhler Way","postalCode":"15279","city":"Pittsburgh","state":"PA","phoneNumber":"412-431-5446"}, +{"id":460,"firstName":"Leesa","lastName":"Wellbeloved","street":"4553 Dakota Circle","postalCode":"40215","city":"Louisville","state":"KY","phoneNumber":"502-145-8496","email":"lwellbelovedcr@go.com"}, +{"id":461,"firstName":"Sarge","lastName":"Tocknell","street":"9884 North Alley","postalCode":"80249","city":"Denver","state":"CO","phoneNumber":"303-603-8315","email":"stocknellcs@artisteer.com"}, +{"id":462,"firstName":"Loralyn","lastName":"Grimolbie","street":"3620 Clyde Gallagher Junction","postalCode":"91103","city":"Pasadena","state":"CA","email":"lgrimolbiect@purevolume.com"}, +{"id":463,"firstName":"Ki","lastName":"Youdell","street":"3 Gina Center","postalCode":"81005","city":"Pueblo","state":"CO"}, +{"id":464,"firstName":"Katerine","lastName":"Herreros","street":"70 Westend Place","postalCode":"57105","city":"Sioux Falls","state":"SD"}, +{"id":465,"firstName":"Frasquito","lastName":"Nockolds","street":"21 Dwight Park","postalCode":"11236","city":"Brooklyn","state":"NY","phoneNumber":"917-761-0549"}, +{"id":466,"firstName":"Krystalle","lastName":"Brierly","street":"7797 Forest Dale Lane","postalCode":"90410","city":"Santa Monica","state":"CA","email":"kbrierlycx@simplemachines.org"}, +{"id":467,"firstName":"Tobin","lastName":"Guillford","street":"501 Messerschmidt Alley","postalCode":"98195","city":"Seattle","state":"WA","phoneNumber":"206-862-7413","email":"tguillfordcy@fastcompany.com"}, +{"id":468,"firstName":"Lorita","lastName":"Sikorski","street":"83 Corscot Junction","postalCode":"44905","city":"Mansfield","state":"OH","phoneNumber":"419-278-2324","email":"lsikorskicz@intel.com"}, +{"id":469,"firstName":"Hermon","lastName":"Chomley","street":"696 Talisman Lane","postalCode":"35290","city":"Birmingham","state":"AL"}, +{"id":470,"firstName":"Karolina","lastName":"Andrault","street":"49738 Maple Wood Place","postalCode":"99709","city":"Fairbanks","state":"AK","phoneNumber":"907-337-1698","email":"kandraultd1@bloglines.com"}, +{"id":471,"firstName":"Lev","lastName":"Pankhurst.","street":"442 Pennsylvania Crossing","postalCode":"23605","city":"Newport News","state":"VA","phoneNumber":"757-832-3631"}, +{"id":472,"firstName":"Bianca","lastName":"Garfath","street":"7 Forest Run Center","postalCode":"71914","city":"Hot Springs National Park","state":"AR","email":"bgarfathd3@youku.com"}, +{"id":473,"firstName":"Walden","lastName":"Van der Linde","street":"6 Namekagon Parkway","postalCode":"70187","city":"New Orleans","state":"LA","email":"wvanderlinded4@netscape.com"}, +{"id":474,"firstName":"Alexandra","lastName":"Vasyukhin","street":"471 School Alley","postalCode":"80910","city":"Colorado Springs","state":"CO","email":"avasyukhind5@samsung.com"}, +{"id":475,"firstName":"Perry","lastName":"Spere","street":"33 Autumn Leaf Street","postalCode":"79994","city":"El Paso","state":"TX","email":"pspered6@tamu.edu"}, +{"id":476,"firstName":"Cristobal","lastName":"Afonso","street":"5 Lake View Way","postalCode":"19136","city":"Philadelphia","state":"PA","email":"cafonsod7@themeforest.net"}, +{"id":477,"firstName":"Sebastien","lastName":"Annets","street":"4229 Bowman Trail","postalCode":"43699","city":"Toledo","state":"OH","phoneNumber":"419-981-8630","email":"sannetsd8@guardian.co.uk"}, +{"id":478,"firstName":"Prentice","lastName":"Desorts","street":"54 Mendota Drive","postalCode":"31196","city":"Atlanta","state":"GA","phoneNumber":"404-235-6736","email":"pdesortsd9@who.int"}, +{"id":479,"firstName":"Rubin","lastName":"Dunkerk","street":"035 Myrtle Park","postalCode":"94297","city":"Sacramento","state":"CA","phoneNumber":"916-658-2157","email":"rdunkerkda@columbia.edu"}, +{"id":480,"firstName":"Jesselyn","lastName":"Bidnall","street":"2353 Norway Maple Court","postalCode":"07522","city":"Paterson","state":"NJ","email":"jbidnalldb@4shared.com"}, +{"id":481,"firstName":"Arleta","lastName":"Massy","street":"2 Bluejay Lane","postalCode":"10310","city":"Staten Island","state":"NY"}, +{"id":482,"firstName":"Trescha","lastName":"Joncic","street":"052 Summit Way","postalCode":"13217","city":"Syracuse","state":"NY"}, +{"id":483,"firstName":"Joshuah","lastName":"Galbreth","street":"16 Elka Place","postalCode":"08922","city":"New Brunswick","state":"NJ","email":"jgalbrethde@rambler.ru"}, +{"id":484,"firstName":"Clywd","lastName":"Henlon","street":"26 Thackeray Pass","postalCode":"90040","city":"Los Angeles","state":"CA","email":"chenlondf@unesco.org"}, +{"id":485,"firstName":"Glenda","lastName":"Grayley","street":"6326 Ohio Plaza","postalCode":"91411","city":"Van Nuys","state":"CA"}, +{"id":486,"firstName":"Glynda","lastName":"Stokell","street":"6 Schmedeman Court","postalCode":"60641","city":"Chicago","state":"IL","email":"gstokelldh@ted.com"}, +{"id":487,"firstName":"Kath","lastName":"Harrap","street":"43769 Barby Plaza","postalCode":"32304","city":"Tallahassee","state":"FL","email":"kharrapdi@cargocollective.com"}, +{"id":488,"firstName":"Dickie","lastName":"Domotor","street":"2954 Toban Lane","postalCode":"98133","city":"Seattle","state":"WA","email":"ddomotordj@hhs.gov"}, +{"id":489,"firstName":"Ceciley","lastName":"Hitzke","street":"9102 Westport Pass","postalCode":"40618","city":"Frankfort","state":"KY","phoneNumber":"502-545-5506","email":"chitzkedk@newsvine.com"}, +{"id":490,"firstName":"Adler","lastName":"Webb-Bowen","street":"5 Hanover Street","postalCode":"32123","city":"Daytona Beach","state":"FL"}, +{"id":491,"firstName":"Fergus","lastName":"Domerq","street":"06 Hansons Road","postalCode":"58106","city":"Fargo","state":"ND","phoneNumber":"701-656-3778"}, +{"id":492,"firstName":"Kimbra","lastName":"Petherick","street":"867 Mayer Drive","postalCode":"39236","city":"Jackson","state":"MS"}, +{"id":493,"firstName":"Geneva","lastName":"Hobgen","street":"74 Vernon Parkway","postalCode":"53710","city":"Madison","state":"WI","email":"ghobgendo@google.de"}, +{"id":494,"firstName":"Jillane","lastName":"Skitral","street":"9747 Ruskin Point","postalCode":"22405","city":"Fredericksburg","state":"VA","email":"jskitraldp@mysql.com"}, +{"id":495,"firstName":"Carolin","lastName":"Pimblotte","street":"8 Union Way","postalCode":"75358","city":"Dallas","state":"TX","phoneNumber":"214-109-7114","email":"cpimblottedq@cargocollective.com"}, +{"id":496,"firstName":"Wandis","lastName":"Andreasson","street":"3 Nancy Parkway","postalCode":"70033","city":"Metairie","state":"LA","email":"wandreassondr@topsy.com"}, +{"id":497,"firstName":"Baily","lastName":"Dalliston","street":"602 Melrose Way","postalCode":"25331","city":"Charleston","state":"WV","email":"bdallistonds@storify.com"}, +{"id":498,"firstName":"Kissie","lastName":"Lammiman","street":"4 Memorial Terrace","postalCode":"06510","city":"New Haven","state":"CT","phoneNumber":"203-724-3731","email":"klammimandt@barnesandnoble.com"}, +{"id":499,"firstName":"Cloris","lastName":"Dorning","street":"4 Lien Road","postalCode":"37235","city":"Nashville","state":"TN","email":"cdorningdu@unesco.org"}, +{"id":500,"firstName":"Jemimah","lastName":"Juppe","street":"979 Tennessee Pass","postalCode":"85305","city":"Glendale","state":"AZ"}, +{"id":501,"firstName":"Fanchette","lastName":"Marlor","street":"90 Waywood Circle","postalCode":"44511","city":"Youngstown","state":"OH","email":"fmarlordw@is.gd"}, +{"id":502,"firstName":"Carmelle","lastName":"Stillmann","street":"9124 Sachtjen Way","postalCode":"74184","city":"Tulsa","state":"OK","email":"cstillmanndx@telegraph.co.uk"}, +{"id":503,"firstName":"Joelle","lastName":"Mumford","street":"5 Susan Point","postalCode":"28410","city":"Wilmington","state":"NC","email":"jmumforddy@yellowbook.com"}, +{"id":504,"firstName":"Vicky","lastName":"Danzelman","street":"472 Pond Junction","postalCode":"11220","city":"Brooklyn","state":"NY","email":"vdanzelmandz@stumbleupon.com"}, +{"id":505,"firstName":"Baudoin","lastName":"Grenshiels","street":"4703 Tony Circle","postalCode":"76198","city":"Fort Worth","state":"TX","email":"bgrenshielse0@devhub.com"}, +{"id":506,"firstName":"Rosetta","lastName":"Wennington","street":"3 Kensington Crossing","postalCode":"14619","city":"Rochester","state":"NY"}, +{"id":507,"firstName":"Eudora","lastName":"Murtell","street":"97 Mockingbird Circle","postalCode":"92867","city":"Orange","state":"CA","phoneNumber":"949-899-3967"}, +{"id":508,"firstName":"Sonnie","lastName":"Hawkin","street":"76669 Green Ridge Crossing","postalCode":"79491","city":"Lubbock","state":"TX","email":"shawkine3@wikia.com"}, +{"id":509,"firstName":"Ulysses","lastName":"Uman","street":"4 Fieldstone Circle","postalCode":"32128","city":"Daytona Beach","state":"FL","phoneNumber":"386-761-6071","email":"uumane4@multiply.com"}, +{"id":510,"firstName":"Alidia","lastName":"Kowalski","street":"3915 Harper Plaza","postalCode":"75221","city":"Dallas","state":"TX","email":"akowalskie5@simplemachines.org"}, +{"id":511,"firstName":"Willis","lastName":"Jeaneau","street":"8 Northport Center","postalCode":"37939","city":"Knoxville","state":"TN","phoneNumber":"865-336-2729","email":"wjeaneaue6@furl.net"}, +{"id":512,"firstName":"Clement","lastName":"Taudevin","street":"25062 Amoth Pass","postalCode":"31914","city":"Columbus","state":"GA","email":"ctaudevine7@mapquest.com"}, +{"id":513,"firstName":"Tally","lastName":"Arnatt","street":"5745 Nancy Terrace","postalCode":"95054","city":"Santa Clara","state":"CA","email":"tarnatte8@umich.edu"}, +{"id":514,"firstName":"Eldon","lastName":"Munnings","street":"17 Dayton Parkway","postalCode":"27690","city":"Raleigh","state":"NC","email":"emunningse9@gmpg.org"}, +{"id":515,"firstName":"Duffie","lastName":"Sibary","street":"840 Springview Avenue","postalCode":"48275","city":"Detroit","state":"MI","email":"dsibaryea@livejournal.com"}, +{"id":516,"firstName":"Winny","lastName":"Dobell","street":"0426 Lindbergh Street","postalCode":"81015","city":"Pueblo","state":"CO","phoneNumber":"719-882-3553","email":"wdobelleb@bizjournals.com"}, +{"id":517,"firstName":"Pancho","lastName":"Pointon","street":"79 Clyde Gallagher Park","postalCode":"97306","city":"Salem","state":"OR","phoneNumber":"503-151-2205"}, +{"id":518,"firstName":"Elston","lastName":"Warwicker","street":"96 Schmedeman Park","postalCode":"44705","city":"Canton","state":"OH","email":"ewarwickered@arstechnica.com"}, +{"id":519,"firstName":"Nicolle","lastName":"Shellcross","street":"23982 Cambridge Parkway","postalCode":"80940","city":"Colorado Springs","state":"CO","email":"nshellcrossee@hibu.com"}, +{"id":520,"firstName":"Bethanne","lastName":"Briggdale","street":"026 Portage Circle","postalCode":"43215","city":"Columbus","state":"OH","phoneNumber":"513-925-3139","email":"bbriggdaleef@flickr.com"}, +{"id":521,"firstName":"Elsey","lastName":"McCorry","street":"781 International Parkway","postalCode":"94286","city":"Sacramento","state":"CA","phoneNumber":"916-879-2104","email":"emccorryeg@sakura.ne.jp"}, +{"id":522,"firstName":"Abran","lastName":"Vasyuchov","street":"64 Grim Place","postalCode":"44177","city":"Cleveland","state":"OH"}, +{"id":523,"firstName":"Rhoda","lastName":"Grieveson","street":"50687 Towne Pass","postalCode":"11220","city":"Brooklyn","state":"NY","email":"rgrievesonei@mit.edu"}, +{"id":524,"firstName":"Florette","lastName":"Eke","street":"85057 Anzinger Lane","postalCode":"66225","city":"Shawnee Mission","state":"KS","phoneNumber":"913-299-0032","email":"fekeej@fema.gov"}, +{"id":525,"firstName":"Sheff","lastName":"Baigrie","street":"80366 Lawn Hill","postalCode":"02203","city":"Boston","state":"MA","phoneNumber":"617-556-4978","email":"sbaigrieek@aboutads.info"}, +{"id":526,"firstName":"Clarisse","lastName":"Hubbuck","street":"435 Truax Trail","postalCode":"02458","city":"Newton","state":"MA","phoneNumber":"781-641-2937"}, +{"id":527,"firstName":"Gilberte","lastName":"Yanele","street":"413 Glacier Hill Park","postalCode":"90610","city":"Whittier","state":"CA","phoneNumber":"562-451-1686","email":"gyaneleem@dot.gov"}, +{"id":528,"firstName":"Lefty","lastName":"Dufore","street":"957 Straubel Street","postalCode":"35220","city":"Birmingham","state":"AL","email":"lduforeen@slideshare.net"}, +{"id":529,"firstName":"Saul","lastName":"Shepperd","street":"44805 Sunnyside Place","postalCode":"32627","city":"Gainesville","state":"FL","phoneNumber":"352-904-7271"}, +{"id":530,"firstName":"Hadrian","lastName":"Cockhill","street":"479 Mayer Way","postalCode":"22119","city":"Merrifield","state":"VA","email":"hcockhillep@xrea.com"}, +{"id":531,"firstName":"Amalia","lastName":"Geare","street":"63075 Glendale Trail","postalCode":"90065","city":"Los Angeles","state":"CA","email":"ageareeq@vistaprint.com"}, +{"id":532,"firstName":"Adan","lastName":"Ibbeson","street":"5 Cambridge Lane","postalCode":"73142","city":"Oklahoma City","state":"OK"}, +{"id":533,"firstName":"Nicol","lastName":"Garbutt","street":"3 8th Street","postalCode":"50393","city":"Des Moines","state":"IA","phoneNumber":"515-946-8077"}, +{"id":534,"firstName":"Lilas","lastName":"Estcot","street":"1927 Mitchell Avenue","postalCode":"75185","city":"Mesquite","state":"TX","email":"lestcotet@ezinearticles.com"}, +{"id":535,"firstName":"Valina","lastName":"Dellenbrok","street":"1 Victoria Hill","postalCode":"45249","city":"Cincinnati","state":"OH","phoneNumber":"513-958-5055","email":"vdellenbrokeu@upenn.edu"}, +{"id":536,"firstName":"Gwen","lastName":"Harwell","street":"64275 Bartelt Terrace","postalCode":"93721","city":"Fresno","state":"CA"}, +{"id":537,"firstName":"Adriena","lastName":"Lochead","street":"0088 Hintze Point","postalCode":"43231","city":"Columbus","state":"OH","phoneNumber":"614-506-5616","email":"alocheadew@paypal.com"}, +{"id":538,"firstName":"Jacobo","lastName":"Jills","street":"809 Anderson Park","postalCode":"55557","city":"Young America","state":"MN","phoneNumber":"952-580-6574","email":"jjillsex@xing.com"}, +{"id":539,"firstName":"Saree","lastName":"Jeanequin","street":"0212 Clyde Gallagher Alley","postalCode":"32891","city":"Orlando","state":"FL","email":"sjeanequiney@who.int"}, +{"id":540,"firstName":"Kin","lastName":"Dewar","street":"3 Emmet Center","postalCode":"20244","city":"Washington","state":"DC","email":"kdewarez@discovery.com"}, +{"id":541,"firstName":"Kaleena","lastName":"Godfray","street":"4350 Eliot Parkway","postalCode":"76134","city":"Fort Worth","state":"TX","phoneNumber":"817-332-6412","email":"kgodfrayf0@webmd.com"}, +{"id":542,"firstName":"Wallace","lastName":"Poytres","street":"78157 Dovetail Crossing","postalCode":"14683","city":"Rochester","state":"NY","email":"wpoytresf1@springer.com"}, +{"id":543,"firstName":"Dur","lastName":"Burgise","street":"2 Weeping Birch Court","postalCode":"89130","city":"Las Vegas","state":"NV"}, +{"id":544,"firstName":"Sheridan","lastName":"Gardiner","street":"26 Gateway Crossing","postalCode":"64193","city":"Kansas City","state":"MO","phoneNumber":"816-647-4434","email":"sgardinerf3@jugem.jp"}, +{"id":545,"firstName":"Nickolaus","lastName":"Thomassen","street":"130 Anderson Drive","postalCode":"33330","city":"Fort Lauderdale","state":"FL","phoneNumber":"954-339-0290"}, +{"id":546,"firstName":"Boris","lastName":"Cortez","street":"55 Center Court","postalCode":"10184","city":"New York City","state":"NY","phoneNumber":"212-549-8414","email":"bcortezf5@mail.ru"}, +{"id":547,"firstName":"Candra","lastName":"Codner","street":"24078 Superior Point","postalCode":"93715","city":"Fresno","state":"CA","phoneNumber":"209-495-8135"}, +{"id":548,"firstName":"Ashton","lastName":"Hugin","street":"33 Fuller Place","postalCode":"63143","city":"Saint Louis","state":"MO"}, +{"id":549,"firstName":"Miguelita","lastName":"Lanceley","street":"34877 Arizona Street","postalCode":"80045","city":"Aurora","state":"CO","email":"mlanceleyf8@trellian.com"}, +{"id":550,"firstName":"Law","lastName":"Skim","street":"1795 Farmco Street","postalCode":"28230","city":"Charlotte","state":"NC","email":"lskimf9@bravesites.com"}, +{"id":551,"firstName":"Carlita","lastName":"Kindall","street":"7 Scofield Road","postalCode":"93709","city":"Fresno","state":"CA","email":"ckindallfa@zimbio.com"}, +{"id":552,"firstName":"Mehetabel","lastName":"Stawell","street":"648 Upham Plaza","postalCode":"75277","city":"Dallas","state":"TX","phoneNumber":"214-597-5958","email":"mstawellfb@ehow.com"}, +{"id":553,"firstName":"Charlena","lastName":"MacAlpyne","street":"2 Village Terrace","postalCode":"33758","city":"Clearwater","state":"FL","phoneNumber":"813-452-9764","email":"cmacalpynefc@xinhuanet.com"}, +{"id":554,"firstName":"Gayel","lastName":"Litel","street":"34782 Birchwood Road","postalCode":"46406","city":"Gary","state":"IN","phoneNumber":"219-156-8377","email":"glitelfd@alibaba.com"}, +{"id":555,"firstName":"Prisca","lastName":"Kanzler","street":"67 Miller Terrace","postalCode":"08619","city":"Trenton","state":"NJ","phoneNumber":"609-352-4487"}, +{"id":556,"firstName":"Marlowe","lastName":"Idenden","street":"396 Beilfuss Park","postalCode":"74103","city":"Tulsa","state":"OK","phoneNumber":"918-254-3102"}, +{"id":557,"firstName":"Ashley","lastName":"Skule","street":"2327 Valley Edge Terrace","postalCode":"93794","city":"Fresno","state":"CA","phoneNumber":"559-558-9123"}, +{"id":558,"firstName":"Trista","lastName":"Naptine","street":"646 Dahle Court","postalCode":"06538","city":"New Haven","state":"CT","phoneNumber":"203-257-3017","email":"tnaptinefh@hugedomains.com"}, +{"id":559,"firstName":"Hasheem","lastName":"Ottery","street":"004 Clemons Street","postalCode":"28815","city":"Asheville","state":"NC","phoneNumber":"828-768-3824","email":"hotteryfi@gmpg.org"}, +{"id":560,"firstName":"Alisa","lastName":"Bernhardt","street":"49 Cody Center","postalCode":"84120","city":"Salt Lake City","state":"UT","phoneNumber":"801-808-4005","email":"abernhardtfj@census.gov"}, +{"id":561,"firstName":"Isadora","lastName":"Hatchett","street":"78644 Hoepker Junction","postalCode":"77015","city":"Houston","state":"TX","email":"ihatchettfk@spiegel.de"}, +{"id":562,"firstName":"Valdemar","lastName":"Stithe","street":"75 East Street","postalCode":"48206","city":"Detroit","state":"MI","email":"vstithefl@marriott.com"}, +{"id":563,"firstName":"Elden","lastName":"Rebert","street":"2 Florence Place","postalCode":"65110","city":"Jefferson City","state":"MO","phoneNumber":"573-753-8030"}, +{"id":564,"firstName":"Stormie","lastName":"Trewartha","street":"59 Shoshone Lane","postalCode":"19136","city":"Philadelphia","state":"PA","phoneNumber":"215-466-6832"}, +{"id":565,"firstName":"Bernhard","lastName":"Boulsher","street":"50888 Dwight Drive","postalCode":"02114","city":"Boston","state":"MA","email":"bboulsherfo@zdnet.com"}, +{"id":566,"firstName":"Twyla","lastName":"Yerrill","street":"526 Clove Terrace","postalCode":"40745","city":"London","state":"KY","email":"tyerrillfp@smugmug.com"}, +{"id":567,"firstName":"Sullivan","lastName":"Dudeney","street":"953 Swallow Crossing","postalCode":"19160","city":"Philadelphia","state":"PA","email":"sdudeneyfq@kickstarter.com"}, +{"id":568,"firstName":"Estell","lastName":"Kiggel","street":"8170 Rusk Alley","postalCode":"20442","city":"Washington","state":"DC","phoneNumber":"202-645-5828","email":"ekiggelfr@imgur.com"}, +{"id":569,"firstName":"Jonis","lastName":"Pymer","street":"21296 International Pass","postalCode":"77844","city":"College Station","state":"TX","email":"jpymerfs@nymag.com"}, +{"id":570,"firstName":"Linea","lastName":"Cranmor","street":"2541 Thackeray Hill","postalCode":"31210","city":"Macon","state":"GA"}, +{"id":571,"firstName":"Starlin","lastName":"Reven","street":"7692 Mifflin Hill","postalCode":"66611","city":"Topeka","state":"KS","email":"srevenfu@nba.com"}, +{"id":572,"firstName":"Augusta","lastName":"Heustice","street":"947 Ramsey Lane","postalCode":"10292","city":"New York City","state":"NY","phoneNumber":"212-194-3346","email":"aheusticefv@cloudflare.com"}, +{"id":573,"firstName":"Glen","lastName":"O'Mailey","street":"90 6th Court","postalCode":"33982","city":"Punta Gorda","state":"FL","phoneNumber":"941-381-2231"}, +{"id":574,"firstName":"Astrix","lastName":"Bister","street":"505 Artisan Crossing","postalCode":"23324","city":"Chesapeake","state":"VA","phoneNumber":"757-469-4444","email":"abisterfx@uol.com.br"}, +{"id":575,"firstName":"Shaw","lastName":"Lidbetter","street":"70 New Castle Trail","postalCode":"10474","city":"Bronx","state":"NY","phoneNumber":"917-917-9173"}, +{"id":576,"firstName":"Yovonnda","lastName":"Wych","street":"97472 Derek Drive","postalCode":"90410","city":"Santa Monica","state":"CA","email":"ywychfz@symantec.com"}, +{"id":577,"firstName":"Harcourt","lastName":"Faier","street":"056 Northridge Street","postalCode":"16510","city":"Erie","state":"PA","email":"hfaierg0@cloudflare.com"}, +{"id":578,"firstName":"Archibold","lastName":"Kos","street":"6 Forster Park","postalCode":"63104","city":"Saint Louis","state":"MO","phoneNumber":"314-967-5566","email":"akosg1@soup.io"}, +{"id":579,"firstName":"Nataniel","lastName":"Beldom","street":"1 Sullivan Street","postalCode":"02453","city":"Waltham","state":"MA","email":"nbeldomg2@alibaba.com"}, +{"id":580,"firstName":"Felisha","lastName":"Bamfield","street":"970 Washington Avenue","postalCode":"12305","city":"Schenectady","state":"NY","email":"fbamfieldg3@jimdo.com"}, +{"id":581,"firstName":"Colly","lastName":"Rugge","street":"8 Golf Course Avenue","postalCode":"55172","city":"Saint Paul","state":"MN","phoneNumber":"651-450-9347","email":"cruggeg4@tmall.com"}, +{"id":582,"firstName":"Patti","lastName":"Maddrell","street":"0483 Coolidge Drive","postalCode":"74193","city":"Tulsa","state":"OK"}, +{"id":583,"firstName":"Antin","lastName":"Gabbetis","street":"93510 Clemons Drive","postalCode":"68583","city":"Lincoln","state":"NE","email":"agabbetisg6@java.com"}, +{"id":584,"firstName":"Bree","lastName":"Million","street":"3 Columbus Avenue","postalCode":"61614","city":"Peoria","state":"IL","phoneNumber":"309-360-1909","email":"bmilliong7@gnu.org"}, +{"id":585,"firstName":"Taber","lastName":"Lorait","street":"4 Melrose Way","postalCode":"62764","city":"Springfield","state":"IL","phoneNumber":"217-436-2021","email":"tloraitg8@cargocollective.com"}, +{"id":586,"firstName":"Roley","lastName":"Di Carlo","street":"981 Bowman Center","postalCode":"87505","city":"Santa Fe","state":"NM"}, +{"id":587,"firstName":"Seline","lastName":"Oxenham","street":"65051 Forest Run Center","postalCode":"94064","city":"Redwood City","state":"CA","email":"soxenhamga@fastcompany.com"}, +{"id":588,"firstName":"Costa","lastName":"Tomblin","street":"7 Arapahoe Alley","postalCode":"33315","city":"Fort Lauderdale","state":"FL","phoneNumber":"954-239-1335"}, +{"id":589,"firstName":"Opalina","lastName":"Cake","street":"88 Commercial Avenue","postalCode":"40215","city":"Louisville","state":"KY","email":"ocakegc@examiner.com"}, +{"id":590,"firstName":"Suzanne","lastName":"Giuroni","street":"73 Twin Pines Terrace","postalCode":"99260","city":"Spokane","state":"WA"}, +{"id":591,"firstName":"Faustine","lastName":"Croysdale","street":"01 Delladonna Point","postalCode":"48295","city":"Detroit","state":"MI"}, +{"id":592,"firstName":"Sheffie","lastName":"Aldine","street":"4 Hansons Junction","postalCode":"74108","city":"Tulsa","state":"OK"}, +{"id":593,"firstName":"Bret","lastName":"Birrane","street":"745 Mayer Junction","postalCode":"77030","city":"Houston","state":"TX","phoneNumber":"832-374-7571","email":"bbirranegg@opera.com"}, +{"id":594,"firstName":"Lennard","lastName":"Mowbury","street":"5 Dwight Road","postalCode":"94522","city":"Concord","state":"CA","email":"lmowburygh@1und1.de"}, +{"id":595,"firstName":"Albie","lastName":"Pert","street":"23705 Fieldstone Plaza","postalCode":"08922","city":"New Brunswick","state":"NJ","phoneNumber":"732-587-7312","email":"apertgi@netlog.com"}, +{"id":596,"firstName":"Stevie","lastName":"Pressnell","street":"0077 Ronald Regan Point","postalCode":"85020","city":"Phoenix","state":"AZ","phoneNumber":"623-991-0482","email":"spressnellgj@skype.com"}, +{"id":597,"firstName":"Eddy","lastName":"McIlreavy","street":"04 Luster Lane","postalCode":"94126","city":"San Francisco","state":"CA"}, +{"id":598,"firstName":"Webb","lastName":"Titterell","street":"94323 Kedzie Alley","postalCode":"91505","city":"Burbank","state":"CA","phoneNumber":"818-220-9105","email":"wtitterellgl@bandcamp.com"}, +{"id":599,"firstName":"Jeffrey","lastName":"Benito","street":"7487 Scott Lane","postalCode":"11470","city":"Jamaica","state":"NY","phoneNumber":"917-379-2592","email":"jbenitogm@deviantart.com"}, +{"id":600,"firstName":"Nollie","lastName":"Arsey","street":"7282 Summerview Plaza","postalCode":"55811","city":"Duluth","state":"MN","email":"narseygn@imageshack.us"}, +{"id":601,"firstName":"Petra","lastName":"Turpey","street":"43920 Evergreen Junction","postalCode":"77255","city":"Houston","state":"TX","phoneNumber":"713-446-0144"}, +{"id":602,"firstName":"Harwilll","lastName":"Lashbrook","street":"8063 Grasskamp Parkway","postalCode":"27621","city":"Raleigh","state":"NC","phoneNumber":"919-142-9887","email":"hlashbrookgp@seattletimes.com"}, +{"id":603,"firstName":"Tedman","lastName":"Steinor","street":"80230 Hanson Hill","postalCode":"47134","city":"Jeffersonville","state":"IN","email":"tsteinorgq@dmoz.org"}, +{"id":604,"firstName":"Georgette","lastName":"Tupper","street":"37 Lillian Avenue","postalCode":"33543","city":"Zephyrhills","state":"FL","phoneNumber":"813-743-2425","email":"gtuppergr@qq.com"}, +{"id":605,"firstName":"Torrance","lastName":"Welsh","street":"95802 Doe Crossing Crossing","postalCode":"13217","city":"Syracuse","state":"NY","phoneNumber":"315-145-4503","email":"twelshgs@imgur.com"}, +{"id":606,"firstName":"Silvie","lastName":"Souster","street":"52827 Fuller Place","postalCode":"99709","city":"Fairbanks","state":"AK"}, +{"id":607,"firstName":"Pauline","lastName":"Dulwitch","street":"8 Aberg Drive","postalCode":"17105","city":"Harrisburg","state":"PA","phoneNumber":"717-228-4960","email":"pdulwitchgu@aboutads.info"}, +{"id":608,"firstName":"Roberta","lastName":"Castanie","street":"182 Mosinee Avenue","postalCode":"75185","city":"Mesquite","state":"TX"}, +{"id":609,"firstName":"Percival","lastName":"Kristoffersen","street":"4 Del Mar Park","postalCode":"48335","city":"Farmington","state":"MI","phoneNumber":"248-438-1650","email":"pkristoffersengw@chron.com"}, +{"id":610,"firstName":"Caryl","lastName":"Boame","street":"094 Springview Avenue","postalCode":"78255","city":"San Antonio","state":"TX","email":"cboamegx@example.com"}, +{"id":611,"firstName":"Steve","lastName":"Simakov","street":"323 Brickson Park Trail","postalCode":"32244","city":"Jacksonville","state":"FL","phoneNumber":"904-468-9377","email":"ssimakovgy@angelfire.com"}, +{"id":612,"firstName":"Carl","lastName":"Tumayan","street":"93854 Clyde Gallagher Circle","postalCode":"98447","city":"Tacoma","state":"WA","email":"ctumayangz@1und1.de"}, +{"id":613,"firstName":"Gayle","lastName":"Blaker","street":"5930 Grasskamp Drive","postalCode":"12262","city":"Albany","state":"NY","email":"gblakerh0@spiegel.de"}, +{"id":614,"firstName":"Darrick","lastName":"Harefoot","street":"359 Waywood Trail","postalCode":"20189","city":"Dulles","state":"VA"}, +{"id":615,"firstName":"Sayer","lastName":"Eversfield","street":"86 Park Meadow Crossing","postalCode":"53263","city":"Milwaukee","state":"WI","email":"seversfieldh2@multiply.com"}, +{"id":616,"firstName":"Loralyn","lastName":"Poyner","street":"28530 Magdeline Crossing","postalCode":"84125","city":"Salt Lake City","state":"UT","phoneNumber":"801-363-2593"}, +{"id":617,"firstName":"Petrina","lastName":"Ridewood","street":"91782 Oriole Parkway","postalCode":"80235","city":"Denver","state":"CO","phoneNumber":"720-131-3660","email":"pridewoodh4@walmart.com"}, +{"id":618,"firstName":"Leroi","lastName":"Marde","street":"7992 Prairieview Junction","postalCode":"02142","city":"Cambridge","state":"MA","phoneNumber":"781-623-9420","email":"lmardeh5@oracle.com"}, +{"id":619,"firstName":"Brannon","lastName":"Janata","street":"79706 Wayridge Alley","postalCode":"24515","city":"Lynchburg","state":"VA","phoneNumber":"434-255-0721"}, +{"id":620,"firstName":"Berry","lastName":"Joska","street":"301 6th Alley","postalCode":"10150","city":"New York City","state":"NY","email":"bjoskah7@360.cn"}, +{"id":621,"firstName":"Blinnie","lastName":"Basten","street":"047 Canary Parkway","postalCode":"30343","city":"Atlanta","state":"GA","phoneNumber":"404-794-2760"}, +{"id":622,"firstName":"Inesita","lastName":"Abbitt","street":"8 Sachtjen Plaza","postalCode":"60681","city":"Chicago","state":"IL"}, +{"id":623,"firstName":"Nickie","lastName":"Ellicombe","street":"1067 Ridge Oak Terrace","postalCode":"38131","city":"Memphis","state":"TN","phoneNumber":"901-695-3826","email":"nellicombeha@imgur.com"}, +{"id":624,"firstName":"Barney","lastName":"Sheeres","street":"1 Rutledge Avenue","postalCode":"29208","city":"Columbia","state":"SC","phoneNumber":"803-166-1398"}, +{"id":625,"firstName":"Ogdan","lastName":"Lelievre","street":"27 Weeping Birch Plaza","postalCode":"27264","city":"High Point","state":"NC","phoneNumber":"336-416-3966","email":"olelievrehc@exblog.jp"}, +{"id":626,"firstName":"Zora","lastName":"Exter","street":"7 Ronald Regan Pass","postalCode":"33673","city":"Tampa","state":"FL"}, +{"id":627,"firstName":"Travus","lastName":"Jaulme","street":"3159 Montana Circle","postalCode":"79176","city":"Amarillo","state":"TX","phoneNumber":"806-894-9411"}, +{"id":628,"firstName":"Krishna","lastName":"Beckingham","street":"58 Fair Oaks Lane","postalCode":"30311","city":"Atlanta","state":"GA","email":"kbeckinghamhf@usnews.com"}, +{"id":629,"firstName":"Bartolomeo","lastName":"Bosanko","street":"753 Victoria Place","postalCode":"79699","city":"Abilene","state":"TX","phoneNumber":"325-223-9615","email":"bbosankohg@merriam-webster.com"}, +{"id":630,"firstName":"Umberto","lastName":"McGinly","street":"30 Upham Parkway","postalCode":"80945","city":"Colorado Springs","state":"CO","email":"umcginlyhh@cdc.gov"}, +{"id":631,"firstName":"Launce","lastName":"Fatkin","street":"03246 Esch Place","postalCode":"53779","city":"Madison","state":"WI","phoneNumber":"608-916-7032","email":"lfatkinhi@blogs.com"}, +{"id":632,"firstName":"Simone","lastName":"Soars","street":"9969 Forest Run Crossing","postalCode":"90101","city":"Los Angeles","state":"CA","phoneNumber":"213-282-8462"}, +{"id":633,"firstName":"Clerissa","lastName":"Leason","street":"59731 Mayfield Street","postalCode":"89510","city":"Reno","state":"NV"}, +{"id":634,"firstName":"Rutter","lastName":"Sultan","street":"697 Spenser Way","postalCode":"77245","city":"Houston","state":"TX"}, +{"id":635,"firstName":"Shannon","lastName":"De Carteret","street":"2 Grover Avenue","postalCode":"92717","city":"Irvine","state":"CA","phoneNumber":"714-410-2360","email":"sdecarterethm@simplemachines.org"}, +{"id":636,"firstName":"Sawyere","lastName":"Cardno","street":"428 Golf Course Drive","postalCode":"33111","city":"Miami","state":"FL"}, +{"id":637,"firstName":"Paulie","lastName":"Bucktharp","street":"5398 Sugar Park","postalCode":"10039","city":"New York City","state":"NY","phoneNumber":"646-197-4123","email":"pbucktharpho@businessweek.com"}, +{"id":638,"firstName":"Kippy","lastName":"Guisler","street":"2161 Claremont Trail","postalCode":"20546","city":"Washington","state":"DC","phoneNumber":"202-138-6171","email":"kguislerhp@ox.ac.uk"}, +{"id":639,"firstName":"Yoshiko","lastName":"Tolson","street":"2 Glendale Court","postalCode":"27415","city":"Greensboro","state":"NC","email":"ytolsonhq@example.com"}, +{"id":640,"firstName":"Page","lastName":"Chillingsworth","street":"8 Loomis Drive","postalCode":"55470","city":"Minneapolis","state":"MN","email":"pchillingsworthhr@wunderground.com"}, +{"id":641,"firstName":"Jillana","lastName":"O'Siaghail","street":"13517 Del Mar Road","postalCode":"29215","city":"Columbia","state":"SC","phoneNumber":"803-420-8597","email":"josiaghailhs@reuters.com"}, +{"id":642,"firstName":"Phedra","lastName":"Bagnold","street":"7059 Hallows Street","postalCode":"55470","city":"Minneapolis","state":"MN","email":"pbagnoldht@howstuffworks.com"}, +{"id":643,"firstName":"Bellina","lastName":"Gouldie","street":"7567 Bultman Way","postalCode":"88514","city":"El Paso","state":"TX","email":"bgouldiehu@salon.com"}, +{"id":644,"firstName":"Devi","lastName":"Bohden","street":"68833 Northview Hill","postalCode":"84115","city":"Salt Lake City","state":"UT"}, +{"id":645,"firstName":"Peggi","lastName":"Gobert","street":"667 Sauthoff Hill","postalCode":"44710","city":"Canton","state":"OH","email":"pgoberthw@mapy.cz"}, +{"id":646,"firstName":"Madelina","lastName":"Gurys","street":"70 Del Sol Trail","postalCode":"20420","city":"Washington","state":"DC","phoneNumber":"202-747-9276","email":"mguryshx@hibu.com"}, +{"id":647,"firstName":"Ikey","lastName":"Aubri","street":"76 Sutteridge Hill","postalCode":"36205","city":"Anniston","state":"AL","phoneNumber":"256-945-5095","email":"iaubrihy@mayoclinic.com"}, +{"id":648,"firstName":"Ginevra","lastName":"Duffitt","street":"25 Eagan Circle","postalCode":"31217","city":"Macon","state":"GA"}, +{"id":649,"firstName":"Cissiee","lastName":"Gozzard","street":"40240 Lillian Park","postalCode":"60609","city":"Chicago","state":"IL","email":"cgozzardi0@columbia.edu"}, +{"id":650,"firstName":"Sonny","lastName":"Jobern","street":"8 Green Trail","postalCode":"77065","city":"Houston","state":"TX","email":"sjoberni1@ucoz.com"}, +{"id":651,"firstName":"Mitch","lastName":"Guidera","street":"0 Dorton Junction","postalCode":"35210","city":"Birmingham","state":"AL","phoneNumber":"205-224-0177"}, +{"id":652,"firstName":"Dorey","lastName":"Marks","street":"81562 Maywood Crossing","postalCode":"71208","city":"Monroe","state":"LA","phoneNumber":"318-492-5487"}, +{"id":653,"firstName":"Pavla","lastName":"Conneely","street":"4007 Mifflin Lane","postalCode":"20456","city":"Washington","state":"DC"}, +{"id":654,"firstName":"Kym","lastName":"Gecks","street":"72638 Namekagon Plaza","postalCode":"61656","city":"Peoria","state":"IL","email":"kgecksi5@nature.com"}, +{"id":655,"firstName":"Prudence","lastName":"Peert","street":"91 Tomscot Parkway","postalCode":"32209","city":"Jacksonville","state":"FL","phoneNumber":"904-277-2945","email":"ppeerti6@usa.gov"}, +{"id":656,"firstName":"Elston","lastName":"Paolo","street":"4 Jenna Crossing","postalCode":"95155","city":"San Jose","state":"CA","email":"epaoloi7@umn.edu"}, +{"id":657,"firstName":"Indira","lastName":"Splaven","street":"8853 Vermont Drive","postalCode":"38188","city":"Memphis","state":"TN","phoneNumber":"901-706-3908","email":"isplaveni8@fda.gov"}, +{"id":658,"firstName":"Paul","lastName":"Mc Meekin","street":"56 Vidon Drive","postalCode":"08695","city":"Trenton","state":"NJ","phoneNumber":"609-361-1580"}, +{"id":659,"firstName":"Hadley","lastName":"Windmill","street":"31384 Evergreen Point","postalCode":"16550","city":"Erie","state":"PA","email":"hwindmillia@yale.edu"}, +{"id":660,"firstName":"Jay","lastName":"Yesichev","street":"675 Starling Pass","postalCode":"89150","city":"Las Vegas","state":"NV"}, +{"id":661,"firstName":"Ranna","lastName":"Dowtry","street":"303 Nevada Pass","postalCode":"48550","city":"Flint","state":"MI","phoneNumber":"810-164-4521","email":"rdowtryic@amazon.co.jp"}, +{"id":662,"firstName":"Annabel","lastName":"Pellamont","street":"277 Merrick Crossing","postalCode":"36605","city":"Mobile","state":"AL","phoneNumber":"251-595-3594","email":"apellamontid@reverbnation.com"}, +{"id":663,"firstName":"Kaitlynn","lastName":"Tracey","street":"612 Magdeline Road","postalCode":"97296","city":"Portland","state":"OR","email":"ktraceyie@ycombinator.com"}, +{"id":664,"firstName":"Matthiew","lastName":"Jills","street":"65 Walton Circle","postalCode":"93750","city":"Fresno","state":"CA","email":"mjillsif@addthis.com"}, +{"id":665,"firstName":"Bartlet","lastName":"Roe","street":"51573 Mandrake Park","postalCode":"02109","city":"Boston","state":"MA","phoneNumber":"617-460-5377","email":"broeig@nasa.gov"}, +{"id":666,"firstName":"Ban","lastName":"Knotton","street":"174 Westridge Parkway","postalCode":"32405","city":"Panama City","state":"FL","phoneNumber":"850-939-6502","email":"bknottonih@businesswire.com"}, +{"id":667,"firstName":"Cordelie","lastName":"O'Dee","street":"1733 Linden Avenue","postalCode":"80940","city":"Colorado Springs","state":"CO","phoneNumber":"719-966-3402","email":"codeeii@amazonaws.com"}, +{"id":668,"firstName":"Hardy","lastName":"Lob","street":"4 Bultman Road","postalCode":"75074","city":"Plano","state":"TX","email":"hlobij@dropbox.com"}, +{"id":669,"firstName":"Rosabelle","lastName":"Tonner","street":"1 Holy Cross Trail","postalCode":"36670","city":"Mobile","state":"AL","phoneNumber":"251-606-9437","email":"rtonnerik@google.ru"}, +{"id":670,"firstName":"Bernardina","lastName":"Mardy","street":"65 Myrtle Center","postalCode":"96845","city":"Honolulu","state":"HI","email":"bmardyil@wordpress.com"}, +{"id":671,"firstName":"Hynda","lastName":"Soldner","street":"88 Hazelcrest Drive","postalCode":"55470","city":"Minneapolis","state":"MN","email":"hsoldnerim@webeden.co.uk"}, +{"id":672,"firstName":"Quinn","lastName":"Templeton","street":"5 Village Way","postalCode":"19131","city":"Philadelphia","state":"PA","email":"qtempletonin@diigo.com"}, +{"id":673,"firstName":"Torrence","lastName":"Askwith","street":"1 Namekagon Point","postalCode":"31410","city":"Savannah","state":"GA","phoneNumber":"912-552-5239","email":"taskwithio@people.com.cn"}, +{"id":674,"firstName":"Bonnie","lastName":"Robilliard","street":"731 Johnson Lane","postalCode":"24515","city":"Lynchburg","state":"VA","phoneNumber":"434-382-5496"}, +{"id":675,"firstName":"Daphna","lastName":"D'Souza","street":"1549 Loftsgordon Center","postalCode":"91406","city":"Van Nuys","state":"CA","phoneNumber":"818-773-9088"}, +{"id":676,"firstName":"Palm","lastName":"Gandrich","street":"9 4th Pass","postalCode":"87121","city":"Albuquerque","state":"NM","phoneNumber":"505-815-5555"}, +{"id":677,"firstName":"Danie","lastName":"Gaydon","street":"382 Bayside Junction","postalCode":"55441","city":"Minneapolis","state":"MN","phoneNumber":"952-744-9400","email":"dgaydonis@seesaa.net"}, +{"id":678,"firstName":"Tabatha","lastName":"Caddock","street":"3858 Mccormick Road","postalCode":"53779","city":"Madison","state":"WI","phoneNumber":"608-996-7653","email":"tcaddockit@gizmodo.com"}, +{"id":679,"firstName":"Sergent","lastName":"Cade","street":"7 Riverside Crossing","postalCode":"13505","city":"Utica","state":"NY","email":"scadeiu@google.co.uk"}, +{"id":680,"firstName":"Shina","lastName":"Dumphry","street":"483 Del Mar Terrace","postalCode":"73109","city":"Oklahoma City","state":"OK","phoneNumber":"405-261-3364","email":"sdumphryiv@mediafire.com"}, +{"id":681,"firstName":"Aaron","lastName":"O'Neal","street":"669 Crowley Road","postalCode":"87140","city":"Albuquerque","state":"NM","phoneNumber":"505-451-6591","email":"aonealiw@npr.org"}, +{"id":682,"firstName":"Cynthea","lastName":"Wippermann","street":"109 Kinsman Parkway","postalCode":"06606","city":"Bridgeport","state":"CT","phoneNumber":"203-799-4552"}, +{"id":683,"firstName":"Stoddard","lastName":"Hullett","street":"06200 Mesta Park","postalCode":"78769","city":"Austin","state":"TX","phoneNumber":"512-190-7003"}, +{"id":684,"firstName":"Margit","lastName":"Comusso","street":"54 Springs Center","postalCode":"33737","city":"Saint Petersburg","state":"FL","phoneNumber":"727-144-3743","email":"mcomussoiz@drupal.org"}, +{"id":685,"firstName":"Dur","lastName":"Manns","street":"464 Park Meadow Road","postalCode":"90015","city":"Los Angeles","state":"CA","email":"dmannsj0@nymag.com"}, +{"id":686,"firstName":"Hollie","lastName":"Aldersey","street":"12195 Mallory Court","postalCode":"21405","city":"Annapolis","state":"MD","email":"halderseyj1@businessinsider.com"}, +{"id":687,"firstName":"Ralina","lastName":"Crepin","street":"13313 Clyde Gallagher Way","postalCode":"78285","city":"San Antonio","state":"TX"}, +{"id":688,"firstName":"Lyell","lastName":"Graveston","street":"20 Talisman Crossing","postalCode":"27157","city":"Winston Salem","state":"NC","phoneNumber":"336-638-3366","email":"lgravestonj3@webmd.com"}, +{"id":689,"firstName":"Anny","lastName":"Potell","street":"0 Ludington Circle","postalCode":"32803","city":"Orlando","state":"FL","email":"apotellj4@microsoft.com"}, +{"id":690,"firstName":"Harriot","lastName":"Klimpke","street":"8 Southridge Alley","postalCode":"22047","city":"Falls Church","state":"VA","phoneNumber":"571-470-2688","email":"hklimpkej5@slashdot.org"}, +{"id":691,"firstName":"Stacia","lastName":"Stainsby","street":"78 Mcbride Avenue","postalCode":"46862","city":"Fort Wayne","state":"IN"}, +{"id":692,"firstName":"Zacharia","lastName":"Willmont","street":"24 Everett Center","postalCode":"73135","city":"Oklahoma City","state":"OK","phoneNumber":"405-167-0584","email":"zwillmontj7@tuttocitta.it"}, +{"id":693,"firstName":"Dorelia","lastName":"Flexman","street":"0 Hauk Crossing","postalCode":"95298","city":"Stockton","state":"CA","phoneNumber":"209-759-3308"}, +{"id":694,"firstName":"Rubi","lastName":"Karran","street":"586 Eggendart Pass","postalCode":"64082","city":"Lees Summit","state":"MO","email":"rkarranj9@yahoo.com"}, +{"id":695,"firstName":"Edlin","lastName":"Davidsen","street":"5646 Arrowood Park","postalCode":"20591","city":"Washington","state":"DC","phoneNumber":"202-800-5817","email":"edavidsenja@purevolume.com"}, +{"id":696,"firstName":"Oralle","lastName":"Coneybeare","street":"0 Lakewood Parkway","postalCode":"08695","city":"Trenton","state":"NJ","email":"oconeybearejb@booking.com"}, +{"id":697,"firstName":"Scotti","lastName":"Cereceres","street":"2 Golf Hill","postalCode":"38119","city":"Memphis","state":"TN"}, +{"id":698,"firstName":"Hermione","lastName":"Mingotti","street":"14 Shoshone Alley","postalCode":"44511","city":"Youngstown","state":"OH","phoneNumber":"330-505-0585"}, +{"id":699,"firstName":"Janka","lastName":"Merredy","street":"877 Reinke Park","postalCode":"45233","city":"Cincinnati","state":"OH","email":"jmerredyje@furl.net"}, +{"id":700,"firstName":"Phillida","lastName":"Gannicleff","street":"48778 Sheridan Center","postalCode":"99210","city":"Spokane","state":"WA","email":"pgannicleffjf@github.io"}, +{"id":701,"firstName":"Bryn","lastName":"Shury","street":"82609 Surrey Road","postalCode":"78240","city":"San Antonio","state":"TX","phoneNumber":"210-361-9404","email":"bshuryjg@arstechnica.com"}, +{"id":702,"firstName":"Bobbe","lastName":"Yurocjhin","street":"54904 Southridge Parkway","postalCode":"33633","city":"Tampa","state":"FL","email":"byurocjhinjh@tumblr.com"}, +{"id":703,"firstName":"Noell","lastName":"Trewman","street":"63703 Fair Oaks Point","postalCode":"91520","city":"Burbank","state":"CA"}, +{"id":704,"firstName":"Adelind","lastName":"Marr","street":"68 Lotheville Park","postalCode":"02912","city":"Providence","state":"RI","email":"amarrjj@hexun.com"}, +{"id":705,"firstName":"Arabelle","lastName":"Oultram","street":"7927 Waxwing Place","postalCode":"77085","city":"Houston","state":"TX","email":"aoultramjk@diigo.com"}, +{"id":706,"firstName":"Derril","lastName":"Whylie","street":"1 Summerview Terrace","postalCode":"91606","city":"North Hollywood","state":"CA","phoneNumber":"323-244-3266","email":"dwhyliejl@auda.org.au"}, +{"id":707,"firstName":"Isadore","lastName":"Airth","street":"08897 Hauk Court","postalCode":"73104","city":"Oklahoma City","state":"OK","phoneNumber":"405-488-1807"}, +{"id":708,"firstName":"Barbara","lastName":"Feast","street":"420 Bayside Circle","postalCode":"63136","city":"Saint Louis","state":"MO","phoneNumber":"314-919-9094"}, +{"id":709,"firstName":"Engracia","lastName":"Laxtonne","street":"189 Oneill Center","postalCode":"22047","city":"Falls Church","state":"VA","email":"elaxtonnejo@addthis.com"}, +{"id":710,"firstName":"Dorice","lastName":"Dearle","street":"655 Union Way","postalCode":"47705","city":"Evansville","state":"IN","phoneNumber":"812-812-8795","email":"ddearlejp@mail.ru"}, +{"id":711,"firstName":"Crissie","lastName":"Leall","street":"1 1st Drive","postalCode":"36689","city":"Mobile","state":"AL","phoneNumber":"251-112-1542","email":"clealljq@nyu.edu"}, +{"id":712,"firstName":"Rica","lastName":"Wilshin","street":"0 Miller Way","postalCode":"79705","city":"Midland","state":"TX","phoneNumber":"432-935-1867"}, +{"id":713,"firstName":"Annie","lastName":"Thorns","street":"297 Thompson Park","postalCode":"32412","city":"Panama City","state":"FL","phoneNumber":"850-594-4049"}, +{"id":714,"firstName":"Lilah","lastName":"Beining","street":"1566 American Ash Avenue","postalCode":"25326","city":"Charleston","state":"WV","email":"lbeiningjt@mayoclinic.com"}, +{"id":715,"firstName":"Leeann","lastName":"Dorant","street":"5530 Mcguire Alley","postalCode":"93407","city":"San Luis Obispo","state":"CA","email":"ldorantju@homestead.com"}, +{"id":716,"firstName":"Elinor","lastName":"James","street":"2 Waxwing Terrace","postalCode":"88579","city":"El Paso","state":"TX","email":"ejamesjv@europa.eu"}, +{"id":717,"firstName":"Novelia","lastName":"Durman","street":"7 Hermina Junction","postalCode":"77050","city":"Houston","state":"TX","email":"ndurmanjw@fc2.com"}, +{"id":718,"firstName":"Sharai","lastName":"Pickervance","street":"739 Lien Junction","postalCode":"73167","city":"Oklahoma City","state":"OK","email":"spickervancejx@independent.co.uk"}, +{"id":719,"firstName":"Gilberte","lastName":"Stilling","street":"29950 Annamark Trail","postalCode":"89178","city":"Las Vegas","state":"NV","phoneNumber":"702-604-4240","email":"gstillingjy@feedburner.com"}, +{"id":720,"firstName":"Rosabelle","lastName":"Guinan","street":"13078 Sutherland Center","postalCode":"83757","city":"Boise","state":"ID","phoneNumber":"208-792-6705"}, +{"id":721,"firstName":"Karin","lastName":"Ackermann","street":"3 Susan Hill","postalCode":"48919","city":"Lansing","state":"MI","phoneNumber":"517-579-7811","email":"kackermannk0@csmonitor.com"}, +{"id":722,"firstName":"Reeta","lastName":"Attwell","street":"96 Alpine Junction","postalCode":"66622","city":"Topeka","state":"KS"}, +{"id":723,"firstName":"Dru","lastName":"Linck","street":"37 Wayridge Place","postalCode":"49505","city":"Grand Rapids","state":"MI","phoneNumber":"616-197-1837"}, +{"id":724,"firstName":"Frances","lastName":"Collingridge","street":"273 Ludington Crossing","postalCode":"77255","city":"Houston","state":"TX"}, +{"id":725,"firstName":"Wilmette","lastName":"Haimes","street":"8408 Shopko Circle","postalCode":"98907","city":"Yakima","state":"WA","phoneNumber":"509-821-5948"}, +{"id":726,"firstName":"Isahella","lastName":"Rubrow","street":"25 Melby Crossing","postalCode":"59105","city":"Billings","state":"MT","email":"irubrowk5@edublogs.org"}, +{"id":727,"firstName":"Walden","lastName":"Sappson","street":"1 3rd Hill","postalCode":"60435","city":"Joliet","state":"IL","email":"wsappsonk6@ameblo.jp"}, +{"id":728,"firstName":"Blondie","lastName":"Godehard.sf","street":"4606 Caliangt Circle","postalCode":"20709","city":"Laurel","state":"MD"}, +{"id":729,"firstName":"Dion","lastName":"Wingeatt","street":"098 Ridgeview Alley","postalCode":"78769","city":"Austin","state":"TX","phoneNumber":"512-948-4113","email":"dwingeattk8@clickbank.net"}, +{"id":730,"firstName":"Antoni","lastName":"Tibbles","street":"9 Muir Court","postalCode":"25313","city":"Charleston","state":"WV","phoneNumber":"304-298-6149","email":"atibblesk9@usa.gov"}, +{"id":731,"firstName":"Quinn","lastName":"McKevin","street":"063 Washington Parkway","postalCode":"55470","city":"Minneapolis","state":"MN","phoneNumber":"612-140-1997"}, +{"id":732,"firstName":"Rita","lastName":"Hallam","street":"4 Chive Court","postalCode":"85025","city":"Phoenix","state":"AZ","email":"rhallamkb@list-manage.com"}, +{"id":733,"firstName":"Cliff","lastName":"McCrum","street":"30841 Scoville Street","postalCode":"38150","city":"Memphis","state":"TN","phoneNumber":"901-983-7713","email":"cmccrumkc@yellowpages.com"}, +{"id":734,"firstName":"Allyson","lastName":"Petkov","street":"057 Grover Trail","postalCode":"55487","city":"Minneapolis","state":"MN","phoneNumber":"612-706-7185"}, +{"id":735,"firstName":"Tanney","lastName":"Cicccitti","street":"84959 Calypso Way","postalCode":"66629","city":"Topeka","state":"KS","phoneNumber":"785-516-0753","email":"tcicccittike@netscape.com"}, +{"id":736,"firstName":"Brendin","lastName":"Behnke","street":"3057 Browning Parkway","postalCode":"38181","city":"Memphis","state":"TN","email":"bbehnkekf@answers.com"}, +{"id":737,"firstName":"Sydelle","lastName":"Lestor","street":"6 Old Shore Way","postalCode":"73167","city":"Oklahoma City","state":"OK"}, +{"id":738,"firstName":"Nilson","lastName":"Nelthorp","street":"5 Gerald Trail","postalCode":"60567","city":"Naperville","state":"IL","phoneNumber":"630-718-5304","email":"nnelthorpkh@scribd.com"}, +{"id":739,"firstName":"Randy","lastName":"Boller","street":"64 Roth Junction","postalCode":"95354","city":"Modesto","state":"CA","phoneNumber":"209-795-8532","email":"rbollerki@nature.com"}, +{"id":740,"firstName":"Vicki","lastName":"De Vaan","street":"08 Mariners Cove Terrace","postalCode":"62776","city":"Springfield","state":"IL","email":"vdevaankj@disqus.com"}, +{"id":741,"firstName":"Romain","lastName":"Castri","street":"7 Atwood Road","postalCode":"02905","city":"Providence","state":"RI","phoneNumber":"401-865-9950","email":"rcastrikk@google.com.br"}, +{"id":742,"firstName":"Adlai","lastName":"Keppel","street":"6 Farragut Circle","postalCode":"76705","city":"Waco","state":"TX","phoneNumber":"254-852-6322"}, +{"id":743,"firstName":"Arlyne","lastName":"Whalley","street":"6 Esker Terrace","postalCode":"83727","city":"Boise","state":"ID","email":"awhalleykm@amazon.co.uk"}, +{"id":744,"firstName":"Alistair","lastName":"Jennins","street":"6 Loeprich Center","postalCode":"21684","city":"Ridgely","state":"MD","phoneNumber":"410-494-2201","email":"ajenninskn@sciencedaily.com"}, +{"id":745,"firstName":"Farr","lastName":"Steer","street":"8569 Eliot Lane","postalCode":"93381","city":"Bakersfield","state":"CA","phoneNumber":"661-416-1609","email":"fsteerko@usgs.gov"}, +{"id":746,"firstName":"Analise","lastName":"Balasini","street":"8901 Lyons Parkway","postalCode":"23242","city":"Richmond","state":"VA","email":"abalasinikp@imgur.com"}, +{"id":747,"firstName":"Gilbert","lastName":"Lockton","street":"3 Leroy Court","postalCode":"49018","city":"Battle Creek","state":"MI","email":"glocktonkq@google.nl"}, +{"id":748,"firstName":"Hamlen","lastName":"Massie","street":"469 Mallory Drive","postalCode":"77250","city":"Houston","state":"TX","email":"hmassiekr@admin.ch"}, +{"id":749,"firstName":"Ebony","lastName":"Loker","street":"21173 Raven Point","postalCode":"21265","city":"Baltimore","state":"MD"}, +{"id":750,"firstName":"Kristina","lastName":"Deeble","street":"479 Warner Park","postalCode":"92013","city":"Carlsbad","state":"CA","phoneNumber":"760-377-7198","email":"kdeeblekt@ezinearticles.com"}, +{"id":751,"firstName":"Jabez","lastName":"Mummery","street":"1 East Point","postalCode":"52809","city":"Davenport","state":"IA","email":"jmummeryku@sfgate.com"}, +{"id":752,"firstName":"Perrine","lastName":"Aldwinckle","street":"98 Montana Avenue","postalCode":"85030","city":"Phoenix","state":"AZ","phoneNumber":"602-224-2810","email":"paldwincklekv@eepurl.com"}, +{"id":753,"firstName":"Humfried","lastName":"Pendleton","street":"843 Swallow Park","postalCode":"89115","city":"Las Vegas","state":"NV","phoneNumber":"702-524-6047"}, +{"id":754,"firstName":"Dario","lastName":"Chesshire","street":"638 Westport Place","postalCode":"96845","city":"Honolulu","state":"HI","phoneNumber":"808-718-1386"}, +{"id":755,"firstName":"Cherianne","lastName":"Hearfield","street":"15 Quincy Street","postalCode":"14233","city":"Buffalo","state":"NY","email":"chearfieldky@technorati.com"}, +{"id":756,"firstName":"Jemima","lastName":"Oxnam","street":"22276 Maple Street","postalCode":"92165","city":"San Diego","state":"CA","email":"joxnamkz@addtoany.com"}, +{"id":757,"firstName":"Tedmund","lastName":"Chandler","street":"81 Katie Point","postalCode":"44310","city":"Akron","state":"OH","phoneNumber":"330-336-2279","email":"tchandlerl0@webeden.co.uk"}, +{"id":758,"firstName":"Tobie","lastName":"Risley","street":"82996 Reindahl Junction","postalCode":"17140","city":"Harrisburg","state":"PA","phoneNumber":"717-272-9110","email":"trisleyl1@youtu.be"}, +{"id":759,"firstName":"Tomi","lastName":"Crevagh","street":"91791 Buhler Park","postalCode":"33715","city":"Saint Petersburg","state":"FL"}, +{"id":760,"firstName":"Luce","lastName":"Gwatkin","street":"424 Lunder Crossing","postalCode":"31416","city":"Savannah","state":"GA"}, +{"id":761,"firstName":"Vinita","lastName":"Hannon","street":"90 Claremont Trail","postalCode":"39236","city":"Jackson","state":"MS"}, +{"id":762,"firstName":"Ruby","lastName":"O'Cosgra","street":"304 Dayton Avenue","postalCode":"07188","city":"Newark","state":"NJ"}, +{"id":763,"firstName":"Amandi","lastName":"Vasiltsov","street":"98188 Killdeer Alley","postalCode":"93399","city":"Bakersfield","state":"CA","email":"avasiltsovl6@smh.com.au"}, +{"id":764,"firstName":"Juliana","lastName":"Goldspink","street":"93 Maryland Terrace","postalCode":"06705","city":"Waterbury","state":"CT","email":"jgoldspinkl7@guardian.co.uk"}, +{"id":765,"firstName":"Giorgi","lastName":"Yakovl","street":"24240 Shasta Drive","postalCode":"46814","city":"Fort Wayne","state":"IN","phoneNumber":"260-754-5907"}, +{"id":766,"firstName":"Aleksandr","lastName":"Justun","street":"06 Fulton Terrace","postalCode":"85025","city":"Phoenix","state":"AZ"}, +{"id":767,"firstName":"Cornela","lastName":"Grindell","street":"1 Hazelcrest Lane","postalCode":"53285","city":"Milwaukee","state":"WI"}, +{"id":768,"firstName":"Liv","lastName":"Madrell","street":"623 Cordelia Terrace","postalCode":"17105","city":"Harrisburg","state":"PA","email":"lmadrelllb@1688.com"}, +{"id":769,"firstName":"Konstance","lastName":"Rosebotham","street":"8930 Utah Terrace","postalCode":"20029","city":"Washington","state":"DC","email":"krosebothamlc@studiopress.com"}, +{"id":770,"firstName":"Theo","lastName":"Scotland","street":"454 Hintze Park","postalCode":"45238","city":"Cincinnati","state":"OH"}, +{"id":771,"firstName":"Trefor","lastName":"Rein","street":"9 Redwing Plaza","postalCode":"22184","city":"Vienna","state":"VA","email":"treinle@barnesandnoble.com"}, +{"id":772,"firstName":"Angelina","lastName":"Bromehead","street":"62477 Walton Circle","postalCode":"14683","city":"Rochester","state":"NY","email":"abromeheadlf@php.net"}, +{"id":773,"firstName":"Thornie","lastName":"Ivanishin","street":"0 Sunbrook Court","postalCode":"34665","city":"Pinellas Park","state":"FL","email":"tivanishinlg@aol.com"}, +{"id":774,"firstName":"Dyana","lastName":"McNickle","street":"2696 Lakewood Gardens Pass","postalCode":"20456","city":"Washington","state":"DC","phoneNumber":"202-653-8740"}, +{"id":775,"firstName":"Humfried","lastName":"Suero","street":"643 Pearson Junction","postalCode":"28410","city":"Wilmington","state":"NC"}, +{"id":776,"firstName":"Jessamine","lastName":"Stockings","street":"739 Moose Street","postalCode":"94137","city":"San Francisco","state":"CA","phoneNumber":"415-641-0091","email":"jstockingslj@skype.com"}, +{"id":777,"firstName":"Laryssa","lastName":"Grahl","street":"0538 Bultman Point","postalCode":"81505","city":"Grand Junction","state":"CO"}, +{"id":778,"firstName":"Susan","lastName":"Stonnell","street":"7 Dennis Parkway","postalCode":"67215","city":"Wichita","state":"KS","phoneNumber":"316-966-3243","email":"sstonnellll@nps.gov"}, +{"id":779,"firstName":"Melinde","lastName":"Segoe","street":"9 Dottie Place","postalCode":"19125","city":"Philadelphia","state":"PA","phoneNumber":"215-119-3801"}, +{"id":780,"firstName":"Skip","lastName":"Sedgebeer","street":"1 Eliot Drive","postalCode":"20005","city":"Washington","state":"DC","email":"ssedgebeerln@blogtalkradio.com"}, +{"id":781,"firstName":"Annabel","lastName":"Schusterl","street":"6094 Talisman Lane","postalCode":"68510","city":"Lincoln","state":"NE","phoneNumber":"402-355-7934","email":"aschusterllo@cargocollective.com"}, +{"id":782,"firstName":"Emiline","lastName":"Whittlesey","street":"5 Claremont Lane","postalCode":"77040","city":"Houston","state":"TX","phoneNumber":"832-835-1321","email":"ewhittleseylp@geocities.com"}, +{"id":783,"firstName":"Frasquito","lastName":"Loukes","street":"47 Merchant Pass","postalCode":"27499","city":"Greensboro","state":"NC","phoneNumber":"336-265-5719","email":"floukeslq@google.it"}, +{"id":784,"firstName":"Jerald","lastName":"Fairholm","street":"5939 Mariners Cove Road","postalCode":"76598","city":"Gatesville","state":"TX","email":"jfairholmlr@smh.com.au"}, +{"id":785,"firstName":"Melisent","lastName":"Strange","street":"50 Glendale Trail","postalCode":"10606","city":"White Plains","state":"NY"}, +{"id":786,"firstName":"Aaron","lastName":"Mixter","street":"14347 Darwin Place","postalCode":"33124","city":"Miami","state":"FL","phoneNumber":"786-244-1856","email":"amixterlt@dmoz.org"}, +{"id":787,"firstName":"Margy","lastName":"Falla","street":"5 Caliangt Trail","postalCode":"40287","city":"Louisville","state":"KY","email":"mfallalu@booking.com"}, +{"id":788,"firstName":"Malinde","lastName":"Ashdown","street":"97234 Anniversary Hill","postalCode":"06152","city":"Hartford","state":"CT","phoneNumber":"860-140-7408","email":"mashdownlv@economist.com"}, +{"id":789,"firstName":"Carolynn","lastName":"Dulany","street":"33 Melby Road","postalCode":"74116","city":"Tulsa","state":"OK","phoneNumber":"918-140-7039","email":"cdulanylw@yelp.com"}, +{"id":790,"firstName":"Kissee","lastName":"Escale","street":"1470 Hanson Parkway","postalCode":"92812","city":"Anaheim","state":"CA","phoneNumber":"714-466-6376"}, +{"id":791,"firstName":"Rebeka","lastName":"Moralee","street":"898 Oak Street","postalCode":"34108","city":"Naples","state":"FL","email":"rmoraleely@shutterfly.com"}, +{"id":792,"firstName":"Cort","lastName":"Arter","street":"35039 Menomonie Way","postalCode":"50936","city":"Des Moines","state":"IA","email":"carterlz@surveymonkey.com"}, +{"id":793,"firstName":"Kirsteni","lastName":"Heady","street":"473 Lawn Street","postalCode":"32092","city":"Saint Augustine","state":"FL","phoneNumber":"904-424-3526","email":"kheadym0@usda.gov"}, +{"id":794,"firstName":"Ettie","lastName":"Overil","street":"1085 Waubesa Lane","postalCode":"18105","city":"Allentown","state":"PA"}, +{"id":795,"firstName":"Evey","lastName":"Tesimon","street":"9 Cordelia Place","postalCode":"55127","city":"Saint Paul","state":"MN"}, +{"id":796,"firstName":"Hersh","lastName":"Lebond","street":"5265 Bartelt Park","postalCode":"34282","city":"Bradenton","state":"FL","phoneNumber":"941-114-7090"}, +{"id":797,"firstName":"Hendrika","lastName":"Govan","street":"27747 La Follette Avenue","postalCode":"21229","city":"Baltimore","state":"MD","email":"hgovanm4@cam.ac.uk"}, +{"id":798,"firstName":"Renado","lastName":"Hambly","street":"5211 Schmedeman Drive","postalCode":"68105","city":"Omaha","state":"NE","phoneNumber":"402-183-0376","email":"rhamblym5@netlog.com"}, +{"id":799,"firstName":"Brewer","lastName":"Boyn","street":"3161 Novick Lane","postalCode":"77055","city":"Houston","state":"TX","email":"bboynm6@google.it"}, +{"id":800,"firstName":"Patrick","lastName":"Speck","street":"57052 Ronald Regan Way","postalCode":"30306","city":"Atlanta","state":"GA","phoneNumber":"770-764-6971","email":"pspeckm7@live.com"}, +{"id":801,"firstName":"Skipper","lastName":"Conybear","street":"75 Autumn Leaf Alley","postalCode":"79968","city":"El Paso","state":"TX","phoneNumber":"915-705-5594","email":"sconybearm8@jimdo.com"}, +{"id":802,"firstName":"Elmore","lastName":"Quilty","street":"027 Warbler Court","postalCode":"35210","city":"Birmingham","state":"AL","email":"equiltym9@ebay.co.uk"}, +{"id":803,"firstName":"Estella","lastName":"Jorck","street":"52695 Holy Cross Trail","postalCode":"47134","city":"Jeffersonville","state":"IN","email":"ejorckma@bluehost.com"}, +{"id":804,"firstName":"Scotti","lastName":"Goodale","street":"7551 Dottie Pass","postalCode":"77713","city":"Beaumont","state":"TX","email":"sgoodalemb@nba.com"}, +{"id":805,"firstName":"Catha","lastName":"Shekle","street":"38839 Derek Terrace","postalCode":"62718","city":"Springfield","state":"IL","email":"csheklemc@tmall.com"}, +{"id":806,"firstName":"Clemens","lastName":"Chuter","street":"015 Charing Cross Pass","postalCode":"30306","city":"Atlanta","state":"GA"}, +{"id":807,"firstName":"Kiley","lastName":"Vasiltsov","street":"8 Reindahl Hill","postalCode":"33432","city":"Boca Raton","state":"FL","email":"kvasiltsovme@google.nl"}, +{"id":808,"firstName":"Korrie","lastName":"McGauhy","street":"188 Golf Lane","postalCode":"89110","city":"Las Vegas","state":"NV","phoneNumber":"702-647-1620","email":"kmcgauhymf@goodreads.com"}, +{"id":809,"firstName":"Giustina","lastName":"Hentze","street":"62244 Roth Way","postalCode":"48604","city":"Saginaw","state":"MI","email":"ghentzemg@pcworld.com"}, +{"id":810,"firstName":"Emilia","lastName":"Virgoe","street":"13910 Alpine Lane","postalCode":"33994","city":"Fort Myers","state":"FL","phoneNumber":"239-993-2041","email":"evirgoemh@mediafire.com"}, +{"id":811,"firstName":"Gordan","lastName":"Trimming","street":"38168 Transport Avenue","postalCode":"38131","city":"Memphis","state":"TN","email":"gtrimmingmi@spiegel.de"}, +{"id":812,"firstName":"Tadeo","lastName":"Vannoort","street":"41476 Pond Alley","postalCode":"20851","city":"Rockville","state":"MD","phoneNumber":"240-432-6489","email":"tvannoortmj@privacy.gov.au"}, +{"id":813,"firstName":"Joseito","lastName":"Viant","street":"1390 Kropf Court","postalCode":"04109","city":"Portland","state":"ME"}, +{"id":814,"firstName":"Blake","lastName":"Tailby","street":"5 Bultman Terrace","postalCode":"31914","city":"Columbus","state":"GA"}, +{"id":815,"firstName":"Cynthie","lastName":"Victor","street":"64 Hoard Avenue","postalCode":"46221","city":"Indianapolis","state":"IN","phoneNumber":"317-836-2511","email":"cvictormm@bizjournals.com"}, +{"id":816,"firstName":"Kristoforo","lastName":"Luckman","street":"019 Ohio Avenue","postalCode":"58505","city":"Bismarck","state":"ND","phoneNumber":"701-921-3472"}, +{"id":817,"firstName":"Celinka","lastName":"Brakewell","street":"5702 Tennessee Pass","postalCode":"92612","city":"Irvine","state":"CA","phoneNumber":"714-584-5599","email":"cbrakewellmo@house.gov"}, +{"id":818,"firstName":"Analiese","lastName":"Debenham","street":"7 Straubel Pass","postalCode":"31704","city":"Albany","state":"GA","phoneNumber":"229-600-4384","email":"adebenhammp@dell.com"}, +{"id":819,"firstName":"Sebastiano","lastName":"Eskriett","street":"0 Northridge Pass","postalCode":"34114","city":"Naples","state":"FL","phoneNumber":"239-651-1326","email":"seskriettmq@berkeley.edu"}, +{"id":820,"firstName":"Jermaine","lastName":"Donisthorpe","street":"69319 Hollow Ridge Park","postalCode":"62794","city":"Springfield","state":"IL","phoneNumber":"217-510-3030","email":"jdonisthorpemr@istockphoto.com"}, +{"id":821,"firstName":"Tera","lastName":"Smalecombe","street":"646 Oakridge Avenue","postalCode":"43699","city":"Toledo","state":"OH","email":"tsmalecombems@tripod.com"}, +{"id":822,"firstName":"Issie","lastName":"Cohane","street":"79078 Fair Oaks Circle","postalCode":"40233","city":"Louisville","state":"KY","email":"icohanemt@wired.com"}, +{"id":823,"firstName":"Nanete","lastName":"Erb","street":"02 Truax Place","postalCode":"88563","city":"El Paso","state":"TX","phoneNumber":"915-234-2792"}, +{"id":824,"firstName":"Benetta","lastName":"Roger","street":"822 Fallview Alley","postalCode":"33625","city":"Tampa","state":"FL","phoneNumber":"813-715-8911","email":"brogermv@ca.gov"}, +{"id":825,"firstName":"Sascha","lastName":"Hillyatt","street":"06 Fisk Plaza","postalCode":"11407","city":"Jamaica","state":"NY"}, +{"id":826,"firstName":"Britt","lastName":"Gilderoy","street":"64312 Delaware Place","postalCode":"89135","city":"Las Vegas","state":"NV"}, +{"id":827,"firstName":"Sterne","lastName":"Frissell","street":"69121 Sycamore Way","postalCode":"06912","city":"Stamford","state":"CT"}, +{"id":828,"firstName":"Lonny","lastName":"Petersen","street":"6 Golf Course Crossing","postalCode":"32627","city":"Gainesville","state":"FL","phoneNumber":"352-245-3289","email":"lpetersenmz@msu.edu"}, +{"id":829,"firstName":"Maridel","lastName":"Clunie","street":"0312 Dryden Street","postalCode":"80328","city":"Boulder","state":"CO","phoneNumber":"303-848-1116","email":"mclunien0@china.com.cn"}, +{"id":830,"firstName":"Annabal","lastName":"Pruckner","street":"98481 Anhalt Pass","postalCode":"30340","city":"Atlanta","state":"GA","email":"aprucknern1@bandcamp.com"}, +{"id":831,"firstName":"Carin","lastName":"Ambrois","street":"7982 Vahlen Road","postalCode":"85010","city":"Phoenix","state":"AZ"}, +{"id":832,"firstName":"Consuela","lastName":"Grubey","street":"1 Lillian Circle","postalCode":"89714","city":"Carson City","state":"NV","email":"cgrubeyn3@google.pl"}, +{"id":833,"firstName":"Friedrick","lastName":"Ventom","street":"703 Almo Crossing","postalCode":"43215","city":"Columbus","state":"OH"}, +{"id":834,"firstName":"Shalom","lastName":"Rosten","street":"4460 Parkside Road","postalCode":"37215","city":"Nashville","state":"TN","email":"srostenn5@e-recht24.de"}, +{"id":835,"firstName":"Sofia","lastName":"Pottie","street":"89885 Golf Course Junction","postalCode":"27635","city":"Raleigh","state":"NC","email":"spottien6@weather.com"}, +{"id":836,"firstName":"Ed","lastName":"Cecely","street":"38576 Gina Trail","postalCode":"85305","city":"Glendale","state":"AZ","email":"ececelyn7@friendfeed.com"}, +{"id":837,"firstName":"Ruthann","lastName":"Bignold","street":"202 Monterey Alley","postalCode":"19104","city":"Philadelphia","state":"PA","phoneNumber":"610-892-3949"}, +{"id":838,"firstName":"Vonnie","lastName":"Leeming","street":"5 Farmco Center","postalCode":"18706","city":"Wilkes Barre","state":"PA"}, +{"id":839,"firstName":"Diandra","lastName":"Gredden","street":"68178 Parkside Hill","postalCode":"89120","city":"Las Vegas","state":"NV","phoneNumber":"702-952-4026"}, +{"id":840,"firstName":"Donny","lastName":"Bruckent","street":"6 Dapin Way","postalCode":"98127","city":"Seattle","state":"WA","email":"dbruckentnb@stumbleupon.com"}, +{"id":841,"firstName":"Mill","lastName":"Finlay","street":"9 Meadow Valley Terrace","postalCode":"94405","city":"San Mateo","state":"CA","email":"mfinlaync@hibu.com"}, +{"id":842,"firstName":"Garv","lastName":"Feldberger","street":"5916 Marquette Lane","postalCode":"98127","city":"Seattle","state":"WA"}, +{"id":843,"firstName":"Micheal","lastName":"Favela","street":"41587 Dunning Road","postalCode":"47712","city":"Evansville","state":"IN"}, +{"id":844,"firstName":"Shannon","lastName":"Alvaro","street":"86377 Becker Avenue","postalCode":"33315","city":"Fort Lauderdale","state":"FL","phoneNumber":"954-661-6648","email":"salvaronf@usa.gov"}, +{"id":845,"firstName":"Corenda","lastName":"Aldcorn","street":"19 Bowman Court","postalCode":"67220","city":"Wichita","state":"KS","phoneNumber":"316-835-1638","email":"caldcornng@ebay.com"}, +{"id":846,"firstName":"Alvy","lastName":"Mahood","street":"0814 Spohn Hill","postalCode":"50347","city":"Des Moines","state":"IA","phoneNumber":"515-865-3669","email":"amahoodnh@toplist.cz"}, +{"id":847,"firstName":"Alexandr","lastName":"Stut","street":"8672 Anderson Court","postalCode":"78410","city":"Corpus Christi","state":"TX"}, +{"id":848,"firstName":"Gale","lastName":"Chaperling","street":"78873 Bellgrove Alley","postalCode":"10009","city":"New York City","state":"NY","phoneNumber":"212-978-6798","email":"gchaperlingnj@livejournal.com"}, +{"id":849,"firstName":"Eunice","lastName":"Dadson","street":"340 Dwight Hill","postalCode":"52809","city":"Davenport","state":"IA","phoneNumber":"563-787-9869","email":"edadsonnk@businessinsider.com"}, +{"id":850,"firstName":"Florentia","lastName":"Camin","street":"68733 Orin Point","postalCode":"46867","city":"Fort Wayne","state":"IN","phoneNumber":"260-920-3928","email":"fcaminnl@technorati.com"}, +{"id":851,"firstName":"Norina","lastName":"Vannacci","street":"585 Karstens Circle","postalCode":"45233","city":"Cincinnati","state":"OH"}, +{"id":852,"firstName":"Syd","lastName":"Gianolo","street":"99755 Arrowood Hill","postalCode":"33673","city":"Tampa","state":"FL","phoneNumber":"813-878-8150","email":"sgianolonn@uol.com.br"}, +{"id":853,"firstName":"Timofei","lastName":"Serle","street":"1081 Cascade Park","postalCode":"94257","city":"Sacramento","state":"CA","email":"tserleno@behance.net"}, +{"id":854,"firstName":"Moina","lastName":"Ciobutaro","street":"502 Stone Corner Circle","postalCode":"33018","city":"Hialeah","state":"FL","email":"mciobutaronp@ycombinator.com"}, +{"id":855,"firstName":"Nikolaos","lastName":"Gavaghan","street":"47136 Golf Junction","postalCode":"97255","city":"Portland","state":"OR"}, +{"id":856,"firstName":"Gallard","lastName":"Jenks","street":"2 Carioca Terrace","postalCode":"35263","city":"Birmingham","state":"AL","email":"gjenksnr@blogtalkradio.com"}, +{"id":857,"firstName":"Dare","lastName":"Nielson","street":"3 Carberry Hill","postalCode":"48604","city":"Saginaw","state":"MI","phoneNumber":"989-211-0944"}, +{"id":858,"firstName":"Cecilius","lastName":"Fasse","street":"1 Novick Street","postalCode":"68583","city":"Lincoln","state":"NE","phoneNumber":"402-342-4624","email":"cfassent@zimbio.com"}, +{"id":859,"firstName":"Kevon","lastName":"Doxsey","street":"152 Warrior Pass","postalCode":"91616","city":"North Hollywood","state":"CA","phoneNumber":"213-339-9582"}, +{"id":860,"firstName":"Matti","lastName":"Gras","street":"4567 Bunting Way","postalCode":"94544","city":"Hayward","state":"CA"}, +{"id":861,"firstName":"Nathan","lastName":"Longfut","street":"3178 Mockingbird Alley","postalCode":"97255","city":"Portland","state":"OR","phoneNumber":"971-206-3004"}, +{"id":862,"firstName":"Willetta","lastName":"Fitzpayn","street":"87 Alpine Drive","postalCode":"48604","city":"Saginaw","state":"MI","phoneNumber":"989-698-7578","email":"wfitzpaynnx@geocities.jp"}, +{"id":863,"firstName":"Emanuel","lastName":"Jikylls","street":"42 Heffernan Court","postalCode":"33884","city":"Winter Haven","state":"FL","email":"ejikyllsny@biglobe.ne.jp"}, +{"id":864,"firstName":"Lenard","lastName":"Nore","street":"7 Nevada Avenue","postalCode":"77343","city":"Huntsville","state":"TX","phoneNumber":"936-267-6742","email":"lnorenz@netscape.com"}, +{"id":865,"firstName":"Jeanine","lastName":"MacTurlough","street":"26343 Gale Crossing","postalCode":"53779","city":"Madison","state":"WI","phoneNumber":"608-865-6630","email":"jmacturlougho0@scientificamerican.com"}, +{"id":866,"firstName":"Jaquenetta","lastName":"Dorn","street":"3963 Novick Way","postalCode":"19495","city":"Valley Forge","state":"PA","email":"jdorno1@about.com"}, +{"id":867,"firstName":"Amity","lastName":"Titterrell","street":"3216 Lindbergh Court","postalCode":"90071","city":"Los Angeles","state":"CA","phoneNumber":"626-416-1494","email":"atitterrello2@psu.edu"}, +{"id":868,"firstName":"Rafaelia","lastName":"Melly","street":"6 Westridge Center","postalCode":"61825","city":"Champaign","state":"IL","email":"rmellyo3@ovh.net"}, +{"id":869,"firstName":"Cordi","lastName":"Martinovsky","street":"38 Forest Dale Terrace","postalCode":"50362","city":"Des Moines","state":"IA","email":"cmartinovskyo4@tuttocitta.it"}, +{"id":870,"firstName":"Humfrid","lastName":"Varne","street":"858 Farwell Street","postalCode":"06127","city":"West Hartford","state":"CT","email":"hvarneo5@yolasite.com"}, +{"id":871,"firstName":"Ford","lastName":"Pinchback","street":"363 Lien Pass","postalCode":"20599","city":"Washington","state":"DC","email":"fpinchbacko6@nytimes.com"}, +{"id":872,"firstName":"Maible","lastName":"Haresign","street":"809 Monica Point","postalCode":"28230","city":"Charlotte","state":"NC"}, +{"id":873,"firstName":"Rozamond","lastName":"Challis","street":"312 Mcbride Plaza","postalCode":"77266","city":"Houston","state":"TX","email":"rchalliso8@google.ca"}, +{"id":874,"firstName":"Myrah","lastName":"Menendez","street":"21 Garrison Plaza","postalCode":"23208","city":"Richmond","state":"VA","email":"mmenendezo9@msn.com"}, +{"id":875,"firstName":"Roberto","lastName":"Lamb","street":"3339 Cottonwood Pass","postalCode":"43699","city":"Toledo","state":"OH","phoneNumber":"419-633-9671"}, +{"id":876,"firstName":"Foster","lastName":"Delyth","street":"91500 Carpenter Point","postalCode":"79928","city":"El Paso","state":"TX","phoneNumber":"915-782-9005"}, +{"id":877,"firstName":"Nicholle","lastName":"Pickring","street":"8083 Talmadge Lane","postalCode":"14624","city":"Rochester","state":"NY","email":"npickringoc@tuttocitta.it"}, +{"id":878,"firstName":"Theodosia","lastName":"Bayliss","street":"6 Marcy Parkway","postalCode":"33954","city":"Port Charlotte","state":"FL"}, +{"id":879,"firstName":"Araldo","lastName":"Dowzell","street":"8376 Carpenter Court","postalCode":"71151","city":"Shreveport","state":"LA","email":"adowzelloe@army.mil"}, +{"id":880,"firstName":"Hugues","lastName":"McColgan","street":"990 Southridge Point","postalCode":"93591","city":"Palmdale","state":"CA","phoneNumber":"661-978-2646","email":"hmccolganof@netvibes.com"}, +{"id":881,"firstName":"Annissa","lastName":"Mordue","street":"62114 Ludington Lane","postalCode":"30911","city":"Augusta","state":"GA","phoneNumber":"706-152-3967","email":"amordueog@tripod.com"}, +{"id":882,"firstName":"Tierney","lastName":"Claughton","street":"3 Twin Pines Trail","postalCode":"88563","city":"El Paso","state":"TX","phoneNumber":"915-784-7980"}, +{"id":883,"firstName":"Rey","lastName":"Fleckno","street":"49 Oakridge Point","postalCode":"27605","city":"Raleigh","state":"NC"}, +{"id":884,"firstName":"Stacee","lastName":"Rewcastle","street":"19 Glendale Point","postalCode":"78278","city":"San Antonio","state":"TX","phoneNumber":"210-454-3087","email":"srewcastleoj@ustream.tv"}, +{"id":885,"firstName":"Delano","lastName":"Bragger","street":"0 Hoffman Center","postalCode":"47725","city":"Evansville","state":"IN","email":"dbraggerok@ifeng.com"}, +{"id":886,"firstName":"Redford","lastName":"Bare","street":"801 Garrison Court","postalCode":"08638","city":"Trenton","state":"NJ"}, +{"id":887,"firstName":"Grantham","lastName":"Arlidge","street":"69 Shelley Parkway","postalCode":"34210","city":"Bradenton","state":"FL","email":"garlidgeom@google.nl"}, +{"id":888,"firstName":"Debbie","lastName":"Tommaseo","street":"295 Crowley Alley","postalCode":"98516","city":"Olympia","state":"WA","email":"dtommaseoon@xrea.com"}, +{"id":889,"firstName":"Ragnar","lastName":"O' Byrne","street":"88163 Manitowish Terrace","postalCode":"20260","city":"Washington","state":"DC","phoneNumber":"202-982-3050","email":"robyrneoo@ft.com"}, +{"id":890,"firstName":"Leopold","lastName":"Woodington","street":"44 Vera Pass","postalCode":"24009","city":"Roanoke","state":"VA","email":"lwoodingtonop@engadget.com"}, +{"id":891,"firstName":"Farrah","lastName":"Conniam","street":"2078 Bunting Parkway","postalCode":"68134","city":"Omaha","state":"NE","email":"fconniamoq@github.com"}, +{"id":892,"firstName":"Augustus","lastName":"Morrish","street":"430 Sauthoff Plaza","postalCode":"27710","city":"Durham","state":"NC","phoneNumber":"919-266-8155","email":"amorrishor@naver.com"}, +{"id":893,"firstName":"Cassaundra","lastName":"Deaves","street":"32 Clarendon Way","postalCode":"40266","city":"Louisville","state":"KY","phoneNumber":"502-138-7158"}, +{"id":894,"firstName":"Glynn","lastName":"Shewan","street":"989 Susan Avenue","postalCode":"95194","city":"San Jose","state":"CA","email":"gshewanot@reuters.com"}, +{"id":895,"firstName":"Neils","lastName":"Niesing","street":"488 Jana Road","postalCode":"48232","city":"Detroit","state":"MI","email":"nniesingou@cafepress.com"}, +{"id":896,"firstName":"Alix","lastName":"Cleeton","street":"8 Merrick Crossing","postalCode":"18018","city":"Bethlehem","state":"PA","email":"acleetonov@ask.com"}, +{"id":897,"firstName":"Kyrstin","lastName":"Alejandro","street":"45487 Carey Way","postalCode":"37919","city":"Knoxville","state":"TN","email":"kalejandroow@scribd.com"}, +{"id":898,"firstName":"Waylin","lastName":"De Caroli","street":"9237 Ludington Plaza","postalCode":"77554","city":"Galveston","state":"TX","email":"wdecaroliox@washingtonpost.com"}, +{"id":899,"firstName":"Lian","lastName":"Brade","street":"704 Lotheville Drive","postalCode":"24014","city":"Roanoke","state":"VA","phoneNumber":"540-712-7147"}, +{"id":900,"firstName":"Griz","lastName":"Elgie","street":"435 Northridge Point","postalCode":"93399","city":"Bakersfield","state":"CA","email":"gelgieoz@hao123.com"}, +{"id":901,"firstName":"Georgeanna","lastName":"Gilberthorpe","street":"6 Tomscot Park","postalCode":"37931","city":"Knoxville","state":"TN","phoneNumber":"865-664-6191","email":"ggilberthorpep0@typepad.com"}, +{"id":902,"firstName":"Korrie","lastName":"Goldstraw","street":"00 Lindbergh Plaza","postalCode":"14225","city":"Buffalo","state":"NY","email":"kgoldstrawp1@yellowbook.com"}, +{"id":903,"firstName":"Hervey","lastName":"Wyse","street":"27 Buell Road","postalCode":"75044","city":"Garland","state":"TX","phoneNumber":"972-243-9031","email":"hwysep2@deliciousdays.com"}, +{"id":904,"firstName":"Georgeta","lastName":"Buckam","street":"0 Continental Hill","postalCode":"65810","city":"Springfield","state":"MO","phoneNumber":"417-682-2553","email":"gbuckamp3@java.com"}, +{"id":905,"firstName":"Hussein","lastName":"Jacson","street":"478 Vermont Court","postalCode":"95354","city":"Modesto","state":"CA","phoneNumber":"209-714-7362","email":"hjacsonp4@squarespace.com"}, +{"id":906,"firstName":"Chrysler","lastName":"Heddy","street":"913 Steensland Parkway","postalCode":"20709","city":"Laurel","state":"MD","phoneNumber":"410-691-9748"}, +{"id":907,"firstName":"Jourdan","lastName":"Frise","street":"35 Erie Point","postalCode":"94245","city":"Sacramento","state":"CA","email":"jfrisep6@eepurl.com"}, +{"id":908,"firstName":"Roxie","lastName":"Gimber","street":"9237 Vermont Pass","postalCode":"88553","city":"El Paso","state":"TX","email":"rgimberp7@mayoclinic.com"}, +{"id":909,"firstName":"Jenilee","lastName":"MacNab","street":"23 Union Alley","postalCode":"29579","city":"Myrtle Beach","state":"SC","email":"jmacnabp8@mit.edu"}, +{"id":910,"firstName":"Lola","lastName":"Bier","street":"371 Bartillon Avenue","postalCode":"71105","city":"Shreveport","state":"LA","phoneNumber":"318-818-1659","email":"lbierp9@goo.gl"}, +{"id":911,"firstName":"Fayina","lastName":"Brosel","street":"3255 Macpherson Pass","postalCode":"55166","city":"Saint Paul","state":"MN","email":"fbroselpa@rakuten.co.jp"}, +{"id":912,"firstName":"Ellerey","lastName":"Darell","street":"735 Leroy Road","postalCode":"07544","city":"Paterson","state":"NJ"}, +{"id":913,"firstName":"Lorianne","lastName":"McLanachan","street":"22 Alpine Point","postalCode":"77293","city":"Houston","state":"TX","email":"lmclanachanpc@dmoz.org"}, +{"id":914,"firstName":"Merrill","lastName":"Searson","street":"8447 Namekagon Hill","postalCode":"55114","city":"Saint Paul","state":"MN","phoneNumber":"651-567-8380","email":"msearsonpd@census.gov"}, +{"id":915,"firstName":"Nisse","lastName":"Larive","street":"976 Forest Dale Way","postalCode":"10004","city":"New York City","state":"NY","phoneNumber":"347-192-6897","email":"nlarivepe@drupal.org"}, +{"id":916,"firstName":"Cazzie","lastName":"Brenard","street":"647 Gulseth Plaza","postalCode":"02283","city":"Boston","state":"MA","phoneNumber":"781-248-3572","email":"cbrenardpf@uiuc.edu"}, +{"id":917,"firstName":"Gael","lastName":"Ramirez","street":"161 Basil Terrace","postalCode":"93786","city":"Fresno","state":"CA","phoneNumber":"559-692-2653","email":"gramirezpg@ucoz.ru"}, +{"id":918,"firstName":"Culver","lastName":"Le Brun","street":"73906 Muir Terrace","postalCode":"95973","city":"Chico","state":"CA","email":"clebrunph@jigsy.com"}, +{"id":919,"firstName":"Bordie","lastName":"Muskett","street":"27 Nobel Trail","postalCode":"20599","city":"Washington","state":"DC","phoneNumber":"202-872-5253"}, +{"id":920,"firstName":"Riccardo","lastName":"Miskin","street":"778 Eagan Place","postalCode":"55407","city":"Minneapolis","state":"MN","email":"rmiskinpj@slideshare.net"}, +{"id":921,"firstName":"Cristabel","lastName":"Gowlett","street":"5 Quincy Lane","postalCode":"62525","city":"Decatur","state":"IL","email":"cgowlettpk@cafepress.com"}, +{"id":922,"firstName":"Crawford","lastName":"Huby","street":"6 Gina Lane","postalCode":"94913","city":"San Rafael","state":"CA","phoneNumber":"415-133-8552","email":"chubypl@jugem.jp"}, +{"id":923,"firstName":"Cherish","lastName":"Mutch","street":"8 Oak Valley Lane","postalCode":"20719","city":"Bowie","state":"MD","phoneNumber":"240-982-9087"}, +{"id":924,"firstName":"Jerrie","lastName":"Latek","street":"9462 Moulton Terrace","postalCode":"52809","city":"Davenport","state":"IA","phoneNumber":"563-687-6664","email":"jlatekpn@gov.uk"}, +{"id":925,"firstName":"Lacey","lastName":"Maris","street":"1 Carpenter Hill","postalCode":"61605","city":"Peoria","state":"IL","phoneNumber":"309-570-3216"}, +{"id":926,"firstName":"Daffy","lastName":"Binion","street":"8 Milwaukee Parkway","postalCode":"33129","city":"Miami","state":"FL","phoneNumber":"305-579-9009"}, +{"id":927,"firstName":"Melita","lastName":"Valde","street":"629 Packers Crossing","postalCode":"06140","city":"Hartford","state":"CT","phoneNumber":"860-747-5927","email":"mvaldepq@storify.com"}, +{"id":928,"firstName":"Cherlyn","lastName":"Rosenshine","street":"764 Pepper Wood Place","postalCode":"72204","city":"Little Rock","state":"AR","phoneNumber":"501-823-8134"}, +{"id":929,"firstName":"Morty","lastName":"Stanger","street":"3286 Charing Cross Court","postalCode":"08603","city":"Trenton","state":"NJ","email":"mstangerps@yellowpages.com"}, +{"id":930,"firstName":"Bernete","lastName":"Hirth","street":"83 Granby Center","postalCode":"95194","city":"San Jose","state":"CA","phoneNumber":"408-738-2333","email":"bhirthpt@people.com.cn"}, +{"id":931,"firstName":"Elena","lastName":"Wace","street":"98 Grover Trail","postalCode":"33742","city":"Saint Petersburg","state":"FL","phoneNumber":"727-883-2239","email":"ewacepu@merriam-webster.com"}, +{"id":932,"firstName":"Giselbert","lastName":"Sisland","street":"2214 Sheridan Pass","postalCode":"40225","city":"Louisville","state":"KY"}, +{"id":933,"firstName":"Herb","lastName":"Voyce","street":"628 Basil Pass","postalCode":"21265","city":"Baltimore","state":"MD"}, +{"id":934,"firstName":"Vina","lastName":"Antonetti","street":"6 Springview Terrace","postalCode":"20430","city":"Washington","state":"DC","phoneNumber":"202-955-4578"}, +{"id":935,"firstName":"Bard","lastName":"De Avenell","street":"2775 Clarendon Avenue","postalCode":"53215","city":"Milwaukee","state":"WI"}, +{"id":936,"firstName":"Briana","lastName":"Pinshon","street":"43 Del Sol Street","postalCode":"33615","city":"Tampa","state":"FL","email":"bpinshonpz@java.com"}, +{"id":937,"firstName":"Hilly","lastName":"Aysh","street":"37 Doe Crossing Terrace","postalCode":"23705","city":"Portsmouth","state":"VA","phoneNumber":"757-992-8124"}, +{"id":938,"firstName":"Marylin","lastName":"Ciotto","street":"3957 Browning Pass","postalCode":"94807","city":"Richmond","state":"CA"}, +{"id":939,"firstName":"Cam","lastName":"Kurth","street":"155 Walton Point","postalCode":"92867","city":"Orange","state":"CA","phoneNumber":"949-955-2248"}, +{"id":940,"firstName":"Rawley","lastName":"Bickle","street":"54 Macpherson Point","postalCode":"93762","city":"Fresno","state":"CA","phoneNumber":"559-331-2187","email":"rbickleq3@delicious.com"}, +{"id":941,"firstName":"Merlina","lastName":"Dunster","street":"70557 Toban Trail","postalCode":"20005","city":"Washington","state":"DC","phoneNumber":"202-999-8731"}, +{"id":942,"firstName":"Kennie","lastName":"MacCoughan","street":"04566 Browning Parkway","postalCode":"75507","city":"Texarkana","state":"TX","phoneNumber":"903-622-7509","email":"kmaccoughanq5@reuters.com"}, +{"id":943,"firstName":"Jase","lastName":"Cholomin","street":"21497 Blaine Road","postalCode":"33777","city":"Largo","state":"FL","email":"jcholominq6@cocolog-nifty.com"}, +{"id":944,"firstName":"Cirstoforo","lastName":"Billingsley","street":"1306 Summer Ridge Court","postalCode":"02124","city":"Boston","state":"MA","email":"cbillingsleyq7@google.es"}, +{"id":945,"firstName":"Berkly","lastName":"Lawles","street":"80400 Milwaukee Way","postalCode":"64082","city":"Lees Summit","state":"MO","email":"blawlesq8@jiathis.com"}, +{"id":946,"firstName":"Otha","lastName":"Key","street":"59639 Center Circle","postalCode":"35405","city":"Tuscaloosa","state":"AL","email":"okeyq9@deliciousdays.com"}, +{"id":947,"firstName":"Anselma","lastName":"Debow","street":"5 Spohn Parkway","postalCode":"80241","city":"Denver","state":"CO","email":"adebowqa@yelp.com"}, +{"id":948,"firstName":"Auria","lastName":"Beric","street":"5 Anderson Way","postalCode":"20022","city":"Washington","state":"DC","email":"abericqb@a8.net"}, +{"id":949,"firstName":"Eirena","lastName":"Caswall","street":"4648 Fulton Street","postalCode":"64054","city":"Independence","state":"MO","phoneNumber":"816-406-0779","email":"ecaswallqc@i2i.jp"}, +{"id":950,"firstName":"Tracy","lastName":"Sperwell","street":"4 Heath Drive","postalCode":"91499","city":"Van Nuys","state":"CA"}, +{"id":951,"firstName":"Cherilyn","lastName":"Faint","street":"814 Anniversary Lane","postalCode":"24503","city":"Lynchburg","state":"VA","phoneNumber":"434-722-2344","email":"cfaintqe@amazon.de"}, +{"id":952,"firstName":"Sela","lastName":"Darcey","street":"002 Walton Hill","postalCode":"78703","city":"Austin","state":"TX","email":"sdarceyqf@lycos.com"}, +{"id":953,"firstName":"Freddie","lastName":"Klagge","street":"842 Schlimgen Road","postalCode":"29905","city":"Beaufort","state":"SC","email":"fklaggeqg@1und1.de"}, +{"id":954,"firstName":"Eunice","lastName":"Walrond","street":"4 Mifflin Terrace","postalCode":"68117","city":"Omaha","state":"NE","email":"ewalrondqh@arstechnica.com"}, +{"id":955,"firstName":"Adelbert","lastName":"Meuse","street":"971 Doe Crossing Court","postalCode":"27157","city":"Winston Salem","state":"NC"}, +{"id":956,"firstName":"Caitlin","lastName":"Windham","street":"29 Cordelia Alley","postalCode":"76210","city":"Denton","state":"TX","phoneNumber":"214-498-2801","email":"cwindhamqj@trellian.com"}, +{"id":957,"firstName":"Jere","lastName":"Presho","street":"7 Monica Plaza","postalCode":"75710","city":"Tyler","state":"TX","email":"jpreshoqk@e-recht24.de"}, +{"id":958,"firstName":"Lonny","lastName":"Cotter","street":"5686 Rutledge Place","postalCode":"40596","city":"Lexington","state":"KY","email":"lcotterql@last.fm"}, +{"id":959,"firstName":"Sarah","lastName":"Earnshaw","street":"69 Prentice Point","postalCode":"60669","city":"Chicago","state":"IL","email":"searnshawqm@ycombinator.com"}, +{"id":960,"firstName":"Claire","lastName":"Minette","street":"3145 Butterfield Terrace","postalCode":"43204","city":"Columbus","state":"OH","phoneNumber":"614-157-5341","email":"cminetteqn@upenn.edu"}, +{"id":961,"firstName":"Traci","lastName":"Farnes","street":"2 Service Circle","postalCode":"06905","city":"Stamford","state":"CT","phoneNumber":"203-311-5859","email":"tfarnesqo@merriam-webster.com"}, +{"id":962,"firstName":"Storm","lastName":"de Werk","street":"9 Jenifer Alley","postalCode":"98121","city":"Seattle","state":"WA","phoneNumber":"425-172-3688"}, +{"id":963,"firstName":"Neile","lastName":"Mackrill","street":"5046 Schurz Point","postalCode":"28299","city":"Charlotte","state":"NC"}, +{"id":964,"firstName":"Temple","lastName":"Howlings","street":"8831 Randy Street","postalCode":"71161","city":"Shreveport","state":"LA","phoneNumber":"318-859-6319","email":"thowlingsqr@smugmug.com"}, +{"id":965,"firstName":"Roda","lastName":"Drissell","street":"16621 Mandrake Lane","postalCode":"78744","city":"Austin","state":"TX","email":"rdrissellqs@mayoclinic.com"}, +{"id":966,"firstName":"Francoise","lastName":"Lawman","street":"7 Calypso Point","postalCode":"14614","city":"Rochester","state":"NY","phoneNumber":"585-995-3882"}, +{"id":967,"firstName":"Helen","lastName":"Kigelman","street":"613 Manley Plaza","postalCode":"01905","city":"Lynn","state":"MA","email":"hkigelmanqu@shutterfly.com"}, +{"id":968,"firstName":"Dudley","lastName":"Cansdall","street":"153 Schmedeman Place","postalCode":"93715","city":"Fresno","state":"CA","email":"dcansdallqv@naver.com"}, +{"id":969,"firstName":"Shelby","lastName":"Fayers","street":"94681 Knutson Point","postalCode":"10039","city":"New York City","state":"NY"}, +{"id":970,"firstName":"Sileas","lastName":"Jalland","street":"2199 Buhler Circle","postalCode":"10029","city":"New York City","state":"NY","phoneNumber":"917-902-1667","email":"sjallandqx@rakuten.co.jp"}, +{"id":971,"firstName":"Zeke","lastName":"Duffett","street":"5 Coolidge Park","postalCode":"37995","city":"Knoxville","state":"TN","phoneNumber":"865-814-8540","email":"zduffettqy@wikispaces.com"}, +{"id":972,"firstName":"Tabby","lastName":"Mathieu","street":"78 Donald Circle","postalCode":"55114","city":"Saint Paul","state":"MN","email":"tmathieuqz@rediff.com"}, +{"id":973,"firstName":"Zsa zsa","lastName":"Knights","street":"208 Kingsford Park","postalCode":"15250","city":"Pittsburgh","state":"PA","phoneNumber":"412-652-8956","email":"zknightsr0@privacy.gov.au"}, +{"id":974,"firstName":"Tildi","lastName":"Knewstub","street":"8572 Gina Hill","postalCode":"32909","city":"Palm Bay","state":"FL","email":"tknewstubr1@archive.org"}, +{"id":975,"firstName":"Eric","lastName":"Wharrier","street":"9 Marcy Alley","postalCode":"38126","city":"Memphis","state":"TN","phoneNumber":"901-378-1545","email":"ewharrierr2@people.com.cn"}, +{"id":976,"firstName":"Jilleen","lastName":"Durgan","street":"7 Lien Plaza","postalCode":"75241","city":"Dallas","state":"TX","email":"jdurganr3@google.pl"}, +{"id":977,"firstName":"Ingeberg","lastName":"Whipp","street":"489 Bartillon Street","postalCode":"22205","city":"Arlington","state":"VA","phoneNumber":"703-356-7728","email":"iwhippr4@un.org"}, +{"id":978,"firstName":"Drake","lastName":"McCreagh","street":"735 Mcguire Lane","postalCode":"20530","city":"Washington","state":"DC","email":"dmccreaghr5@mediafire.com"}, +{"id":979,"firstName":"Byron","lastName":"Eades","street":"931 Hollow Ridge Avenue","postalCode":"23285","city":"Richmond","state":"VA","phoneNumber":"804-728-5669","email":"beadesr6@npr.org"}, +{"id":980,"firstName":"Free","lastName":"Tungate","street":"7037 Ramsey Crossing","postalCode":"64153","city":"Kansas City","state":"MO","email":"ftungater7@macromedia.com"}, +{"id":981,"firstName":"Augustus","lastName":"Benardet","street":"398 Bultman Circle","postalCode":"70165","city":"New Orleans","state":"LA"}, +{"id":982,"firstName":"Sanders","lastName":"Sullens","street":"75785 Westend Terrace","postalCode":"43656","city":"Toledo","state":"OH","phoneNumber":"419-314-1134"}, +{"id":983,"firstName":"Ynes","lastName":"Troup","street":"328 Schurz Trail","postalCode":"98907","city":"Yakima","state":"WA","phoneNumber":"509-696-5645"}, +{"id":984,"firstName":"Siana","lastName":"Bernath","street":"968 Sommers Lane","postalCode":"55487","city":"Minneapolis","state":"MN","phoneNumber":"612-351-3016"}, +{"id":985,"firstName":"Ellary","lastName":"Enders","street":"2 Charing Cross Court","postalCode":"06505","city":"New Haven","state":"CT","phoneNumber":"203-608-5058"}, +{"id":986,"firstName":"Mariann","lastName":"Damerell","street":"885 Pennsylvania Crossing","postalCode":"15220","city":"Pittsburgh","state":"PA","phoneNumber":"412-667-1349","email":"mdamerellrd@moonfruit.com"}, +{"id":987,"firstName":"Timotheus","lastName":"Muncer","street":"293 Hoepker Center","postalCode":"32405","city":"Panama City","state":"FL","phoneNumber":"850-740-2501","email":"tmuncerre@ifeng.com"}, +{"id":988,"firstName":"Hermina","lastName":"Tetsall","street":"9354 Nobel Road","postalCode":"55585","city":"Monticello","state":"MN","phoneNumber":"763-292-3970","email":"htetsallrf@wsj.com"}, +{"id":989,"firstName":"Dorelia","lastName":"Howship","street":"747 Namekagon Way","postalCode":"14269","city":"Buffalo","state":"NY","phoneNumber":"716-470-3584","email":"dhowshiprg@un.org"}, +{"id":990,"firstName":"Peggy","lastName":"Coutts","street":"34 Village Green Road","postalCode":"19131","city":"Philadelphia","state":"PA"}, +{"id":991,"firstName":"Dacey","lastName":"Inglefield","street":"05227 Buell Avenue","postalCode":"45414","city":"Dayton","state":"OH"}, +{"id":992,"firstName":"Hollyanne","lastName":"Hobbema","street":"684 La Follette Drive","postalCode":"45218","city":"Cincinnati","state":"OH","phoneNumber":"513-346-0258"}, +{"id":993,"firstName":"Freedman","lastName":"Whorlow","street":"291 Maywood Pass","postalCode":"48098","city":"Troy","state":"MI","phoneNumber":"248-890-5937"}, +{"id":994,"firstName":"Karine","lastName":"Gerring","street":"163 Graceland Street","postalCode":"95397","city":"Modesto","state":"CA"}, +{"id":995,"firstName":"Sonya","lastName":"Giercke","street":"1801 Rowland Junction","postalCode":"66215","city":"Shawnee Mission","state":"KS","email":"sgierckerm@mapquest.com"}, +{"id":996,"firstName":"Fabiano","lastName":"O'Hear","street":"87555 Sunnyside Plaza","postalCode":"33330","city":"Fort Lauderdale","state":"FL","email":"fohearrn@china.com.cn"}, +{"id":997,"firstName":"Lelia","lastName":"Gillman","street":"29838 Eagan Junction","postalCode":"78783","city":"Austin","state":"TX","phoneNumber":"512-515-1461","email":"lgillmanro@amazon.co.jp"}, +{"id":998,"firstName":"Ophelie","lastName":"Richardet","street":"9 Bay Point","postalCode":"94042","city":"Mountain View","state":"CA"}, +{"id":999,"firstName":"Batholomew","lastName":"Janzen","street":"9 Rigney Alley","postalCode":"95113","city":"San Jose","state":"CA"}, +{"id":1000,"firstName":"Kirstyn","lastName":"Bixley","street":"2 Cascade Trail","postalCode":"80015","city":"Aurora","state":"CO","phoneNumber":"303-339-2309","email":"kbixleyrr@i2i.jp"}] \ No newline at end of file From fb4041073bc3bd9e154f2def47b4bbcf70b9b2bd Mon Sep 17 00:00:00 2001 From: Karsten Silz Date: Sat, 5 Sep 2020 18:48:35 +0100 Subject: [PATCH 065/263] BAEL-3326, "Optimizing JSON Schema for production use": Optimized imports and formatted source. --- .../baeldung/jsonoptimization/Customer.java | 2 +- .../CustomerDeserializer.java | 32 +++++----- .../jsonoptimization/CustomerNoNull.java | 16 ++--- .../jsonoptimization/CustomerSerializer.java | 8 +-- .../jsonoptimization/CustomerShortNames.java | 58 ++++++++++++------- .../CustomerShortNamesNoNull.java | 18 +++--- .../jsonoptimization/CustomerSlim.java | 13 ++--- 7 files changed, 82 insertions(+), 65 deletions(-) diff --git a/json/src/main/java/com/baeldung/jsonoptimization/Customer.java b/json/src/main/java/com/baeldung/jsonoptimization/Customer.java index 81a74971ea..85451731e9 100644 --- a/json/src/main/java/com/baeldung/jsonoptimization/Customer.java +++ b/json/src/main/java/com/baeldung/jsonoptimization/Customer.java @@ -116,7 +116,7 @@ public class Customer { public static Customer[] fromMockFile() throws IOException { ObjectMapper objectMapper = new ObjectMapper(); - InputStream jsonFile = new FileInputStream("src/test/resources/json_optimization_mock_data.json"); + InputStream jsonFile = new FileInputStream("src/test/resources/json_optimization_mock_data.json"); Customer[] feedback = objectMapper.readValue(jsonFile, Customer[].class); return feedback; } diff --git a/json/src/main/java/com/baeldung/jsonoptimization/CustomerDeserializer.java b/json/src/main/java/com/baeldung/jsonoptimization/CustomerDeserializer.java index 1f478ed446..04ab15556a 100644 --- a/json/src/main/java/com/baeldung/jsonoptimization/CustomerDeserializer.java +++ b/json/src/main/java/com/baeldung/jsonoptimization/CustomerDeserializer.java @@ -2,39 +2,43 @@ package com.baeldung.jsonoptimization; import java.io.IOException; -import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.ObjectCodec; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.fasterxml.jackson.databind.ser.std.StdSerializer; -public class CustomerDeserializer extends StdDeserializer { +public class CustomerDeserializer extends StdDeserializer { private static final long serialVersionUID = 1L; public CustomerDeserializer() { this(null); } - + public CustomerDeserializer(Class t) { super(t); } - + @Override public Customer deserialize(JsonParser parser, DeserializationContext deserializer) throws IOException { Customer feedback = new Customer(); ObjectCodec codec = parser.getCodec(); JsonNode node = codec.readTree(parser); - - feedback.setId(node.get(0).asLong()); - feedback.setFirstName(node.get(1).asText()); - feedback.setLastName(node.get(2).asText()); - feedback.setStreet(node.get(3).asText()); - feedback.setPostalCode(node.get(4).asText()); - feedback.setCity(node.get(5).asText()); - feedback.setState(node.get(6).asText()); + + feedback.setId(node.get(0) + .asLong()); + feedback.setFirstName(node.get(1) + .asText()); + feedback.setLastName(node.get(2) + .asText()); + feedback.setStreet(node.get(3) + .asText()); + feedback.setPostalCode(node.get(4) + .asText()); + feedback.setCity(node.get(5) + .asText()); + feedback.setState(node.get(6) + .asText()); JsonNode phoneNumber = node.get(7); feedback.setPhoneNumber(phoneNumber.isNull() ? null : phoneNumber.asText()); JsonNode email = node.get(8); diff --git a/json/src/main/java/com/baeldung/jsonoptimization/CustomerNoNull.java b/json/src/main/java/com/baeldung/jsonoptimization/CustomerNoNull.java index 1ee76f762a..62cf526f78 100644 --- a/json/src/main/java/com/baeldung/jsonoptimization/CustomerNoNull.java +++ b/json/src/main/java/com/baeldung/jsonoptimization/CustomerNoNull.java @@ -4,19 +4,19 @@ import com.fasterxml.jackson.annotation.JsonInclude; @JsonInclude(JsonInclude.Include.NON_NULL) public class CustomerNoNull extends Customer { - + @Override public String toString() { return "CustomerNoNull [toString()=" + super.toString() + "]"; } public static CustomerNoNull[] fromCustomers(Customer[] customers) { - CustomerNoNull[] feedback = new CustomerNoNull[customers.length]; - - for(int i = 0; i < customers.length; i++) { + CustomerNoNull[] feedback = new CustomerNoNull[customers.length]; + + for (int i = 0; i < customers.length; i++) { Customer aCustomer = customers[i]; CustomerNoNull newOne = new CustomerNoNull(); - + newOne.setId(aCustomer.getId()); newOne.setFirstName(aCustomer.getFirstName()); newOne.setLastName(aCustomer.getLastName()); @@ -26,11 +26,11 @@ public class CustomerNoNull extends Customer { newOne.setState(aCustomer.getState()); newOne.setPhoneNumber(aCustomer.getPhoneNumber()); newOne.setEmail(aCustomer.getEmail()); - + feedback[i] = newOne; } - + return feedback; } - + } diff --git a/json/src/main/java/com/baeldung/jsonoptimization/CustomerSerializer.java b/json/src/main/java/com/baeldung/jsonoptimization/CustomerSerializer.java index 7e58010640..0f631ee85b 100644 --- a/json/src/main/java/com/baeldung/jsonoptimization/CustomerSerializer.java +++ b/json/src/main/java/com/baeldung/jsonoptimization/CustomerSerializer.java @@ -6,21 +6,21 @@ import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.ser.std.StdSerializer; -public class CustomerSerializer extends StdSerializer { +public class CustomerSerializer extends StdSerializer { private static final long serialVersionUID = 1L; public CustomerSerializer() { this(null); } - + public CustomerSerializer(Class t) { super(t); } - + @Override public void serialize(Customer customer, JsonGenerator jsonGenerator, SerializerProvider serializer) throws IOException { jsonGenerator.writeStartArray(); - jsonGenerator.writeNumber(customer.getId()); + jsonGenerator.writeNumber(customer.getId()); jsonGenerator.writeString(customer.getFirstName()); jsonGenerator.writeString(customer.getLastName()); jsonGenerator.writeString(customer.getStreet()); diff --git a/json/src/main/java/com/baeldung/jsonoptimization/CustomerShortNames.java b/json/src/main/java/com/baeldung/jsonoptimization/CustomerShortNames.java index ffa10f786d..2a47a4bbac 100644 --- a/json/src/main/java/com/baeldung/jsonoptimization/CustomerShortNames.java +++ b/json/src/main/java/com/baeldung/jsonoptimization/CustomerShortNames.java @@ -2,97 +2,113 @@ package com.baeldung.jsonoptimization; import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonGetter; -import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; public class CustomerShortNames { private long id; - + @JsonProperty("f") private String firstName; - + @JsonProperty("l") private String lastName; - + @JsonProperty("s") private String street; - + @JsonProperty("p") private String postalCode; - + @JsonProperty("c") private String city; - + @JsonProperty("a") private String state; - + @JsonProperty("o") private String phoneNumber; - + @JsonProperty("e") private String email; - + 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 String getStreet() { return street; } + public void setStreet(String street) { this.street = street; } + public String getPostalCode() { return postalCode; } + public void setPostalCode(String postalCode) { this.postalCode = postalCode; } + public String getCity() { return city; } + public void setCity(String city) { this.city = city; } + public String getState() { return state; } + public void setState(String state) { this.state = state; } + public String getPhoneNumber() { return phoneNumber; } + public void setPhoneNumber(String phoneNumber) { this.phoneNumber = phoneNumber; } + public String getEmail() { return email; } + public void setEmail(String email) { this.email = email; } - + @Override public int hashCode() { return Objects.hash(city, email, firstName, id, lastName, phoneNumber, postalCode, state, street); } + @Override public boolean equals(Object obj) { if (this == obj) { @@ -105,20 +121,20 @@ public class CustomerShortNames { return Objects.equals(city, other.city) && Objects.equals(email, other.email) && Objects.equals(firstName, other.firstName) && id == other.id && Objects.equals(lastName, other.lastName) && Objects.equals(phoneNumber, other.phoneNumber) && Objects.equals(postalCode, other.postalCode) && Objects.equals(state, other.state) && Objects.equals(street, other.street); } - + @Override public String toString() { return "CustomerWithShorterAttributes [id=" + id + ", firstName=" + firstName + ", lastName=" + lastName + ", street=" + street + ", postalCode=" + postalCode + ", city=" + city + ", state=" + state + ", phoneNumber=" + phoneNumber + ", email=" + email + "]"; - } + } public static CustomerShortNames[] fromCustomers(Customer[] customers) { - CustomerShortNames[] feedback = new CustomerShortNames[customers.length]; - - for(int i = 0; i < customers.length; i++) { + CustomerShortNames[] feedback = new CustomerShortNames[customers.length]; + + for (int i = 0; i < customers.length; i++) { Customer aCustomer = customers[i]; CustomerShortNames newOne = new CustomerShortNames(); - + newOne.setId(aCustomer.getId()); newOne.setFirstName(aCustomer.getFirstName()); newOne.setLastName(aCustomer.getLastName()); @@ -128,11 +144,11 @@ public class CustomerShortNames { newOne.setState(aCustomer.getState()); newOne.setPhoneNumber(aCustomer.getPhoneNumber()); newOne.setEmail(aCustomer.getEmail()); - + feedback[i] = newOne; } - + return feedback; } - + } diff --git a/json/src/main/java/com/baeldung/jsonoptimization/CustomerShortNamesNoNull.java b/json/src/main/java/com/baeldung/jsonoptimization/CustomerShortNamesNoNull.java index d3e9648a98..1b62fb2c06 100644 --- a/json/src/main/java/com/baeldung/jsonoptimization/CustomerShortNamesNoNull.java +++ b/json/src/main/java/com/baeldung/jsonoptimization/CustomerShortNamesNoNull.java @@ -1,24 +1,22 @@ package com.baeldung.jsonoptimization; import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; @JsonInclude(JsonInclude.Include.NON_NULL) public class CustomerShortNamesNoNull extends CustomerShortNames { - - + @Override public String toString() { return "CustomerShortNamesNoNull [toString()=" + super.toString() + "]"; } - + public static CustomerShortNamesNoNull[] fromCustomers(Customer[] customers) { - CustomerShortNamesNoNull[] feedback = new CustomerShortNamesNoNull[customers.length]; - - for(int i = 0; i < customers.length; i++) { + CustomerShortNamesNoNull[] feedback = new CustomerShortNamesNoNull[customers.length]; + + for (int i = 0; i < customers.length; i++) { Customer aCustomer = customers[i]; CustomerShortNamesNoNull newOne = new CustomerShortNamesNoNull(); - + newOne.setId(aCustomer.getId()); newOne.setFirstName(aCustomer.getFirstName()); newOne.setLastName(aCustomer.getLastName()); @@ -28,10 +26,10 @@ public class CustomerShortNamesNoNull extends CustomerShortNames { newOne.setState(aCustomer.getState()); newOne.setPhoneNumber(aCustomer.getPhoneNumber()); newOne.setEmail(aCustomer.getEmail()); - + feedback[i] = newOne; } - + return feedback; } diff --git a/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlim.java b/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlim.java index cdfaa4e329..e2ef4664cf 100644 --- a/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlim.java +++ b/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlim.java @@ -54,21 +54,20 @@ public class CustomerSlim { } public static CustomerSlim[] fromCustomers(Customer[] customers) { - CustomerSlim[] feedback = new CustomerSlim[customers.length]; - - for(int i = 0; i < customers.length; i++) { + CustomerSlim[] feedback = new CustomerSlim[customers.length]; + + for (int i = 0; i < customers.length; i++) { Customer aCustomer = customers[i]; CustomerSlim newOne = new CustomerSlim(); - + newOne.setId(aCustomer.getId()); newOne.setName(aCustomer.getFirstName() + " " + aCustomer.getLastName()); newOne.setAddress(aCustomer.getStreet() + ", " + aCustomer.getCity() + " " + aCustomer.getState() + " " + aCustomer.getPostalCode()); - + feedback[i] = newOne; } - + return feedback; } - } From 1ab520e63a4c148f16a76c890632e6ea9c802a75 Mon Sep 17 00:00:00 2001 From: Karsten Silz Date: Sat, 5 Sep 2020 18:48:35 +0100 Subject: [PATCH 066/263] BAEL-3326, "Optimizing JSON Schema for production use": Optimized imports and formatted source. --- .../baeldung/jsonoptimization/Customer.java | 2 +- .../CustomerDeserializer.java | 32 +++++----- .../jsonoptimization/CustomerNoNull.java | 16 ++--- .../jsonoptimization/CustomerSerializer.java | 8 +-- .../jsonoptimization/CustomerShortNames.java | 58 ++++++++++++------- .../CustomerShortNamesNoNull.java | 18 +++--- .../jsonoptimization/CustomerSlim.java | 13 ++--- .../JsonOptimizationUnitTest.java | 9 ++- 8 files changed, 86 insertions(+), 70 deletions(-) diff --git a/json/src/main/java/com/baeldung/jsonoptimization/Customer.java b/json/src/main/java/com/baeldung/jsonoptimization/Customer.java index 81a74971ea..85451731e9 100644 --- a/json/src/main/java/com/baeldung/jsonoptimization/Customer.java +++ b/json/src/main/java/com/baeldung/jsonoptimization/Customer.java @@ -116,7 +116,7 @@ public class Customer { public static Customer[] fromMockFile() throws IOException { ObjectMapper objectMapper = new ObjectMapper(); - InputStream jsonFile = new FileInputStream("src/test/resources/json_optimization_mock_data.json"); + InputStream jsonFile = new FileInputStream("src/test/resources/json_optimization_mock_data.json"); Customer[] feedback = objectMapper.readValue(jsonFile, Customer[].class); return feedback; } diff --git a/json/src/main/java/com/baeldung/jsonoptimization/CustomerDeserializer.java b/json/src/main/java/com/baeldung/jsonoptimization/CustomerDeserializer.java index 1f478ed446..04ab15556a 100644 --- a/json/src/main/java/com/baeldung/jsonoptimization/CustomerDeserializer.java +++ b/json/src/main/java/com/baeldung/jsonoptimization/CustomerDeserializer.java @@ -2,39 +2,43 @@ package com.baeldung.jsonoptimization; import java.io.IOException; -import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.ObjectCodec; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.fasterxml.jackson.databind.ser.std.StdSerializer; -public class CustomerDeserializer extends StdDeserializer { +public class CustomerDeserializer extends StdDeserializer { private static final long serialVersionUID = 1L; public CustomerDeserializer() { this(null); } - + public CustomerDeserializer(Class t) { super(t); } - + @Override public Customer deserialize(JsonParser parser, DeserializationContext deserializer) throws IOException { Customer feedback = new Customer(); ObjectCodec codec = parser.getCodec(); JsonNode node = codec.readTree(parser); - - feedback.setId(node.get(0).asLong()); - feedback.setFirstName(node.get(1).asText()); - feedback.setLastName(node.get(2).asText()); - feedback.setStreet(node.get(3).asText()); - feedback.setPostalCode(node.get(4).asText()); - feedback.setCity(node.get(5).asText()); - feedback.setState(node.get(6).asText()); + + feedback.setId(node.get(0) + .asLong()); + feedback.setFirstName(node.get(1) + .asText()); + feedback.setLastName(node.get(2) + .asText()); + feedback.setStreet(node.get(3) + .asText()); + feedback.setPostalCode(node.get(4) + .asText()); + feedback.setCity(node.get(5) + .asText()); + feedback.setState(node.get(6) + .asText()); JsonNode phoneNumber = node.get(7); feedback.setPhoneNumber(phoneNumber.isNull() ? null : phoneNumber.asText()); JsonNode email = node.get(8); diff --git a/json/src/main/java/com/baeldung/jsonoptimization/CustomerNoNull.java b/json/src/main/java/com/baeldung/jsonoptimization/CustomerNoNull.java index 1ee76f762a..62cf526f78 100644 --- a/json/src/main/java/com/baeldung/jsonoptimization/CustomerNoNull.java +++ b/json/src/main/java/com/baeldung/jsonoptimization/CustomerNoNull.java @@ -4,19 +4,19 @@ import com.fasterxml.jackson.annotation.JsonInclude; @JsonInclude(JsonInclude.Include.NON_NULL) public class CustomerNoNull extends Customer { - + @Override public String toString() { return "CustomerNoNull [toString()=" + super.toString() + "]"; } public static CustomerNoNull[] fromCustomers(Customer[] customers) { - CustomerNoNull[] feedback = new CustomerNoNull[customers.length]; - - for(int i = 0; i < customers.length; i++) { + CustomerNoNull[] feedback = new CustomerNoNull[customers.length]; + + for (int i = 0; i < customers.length; i++) { Customer aCustomer = customers[i]; CustomerNoNull newOne = new CustomerNoNull(); - + newOne.setId(aCustomer.getId()); newOne.setFirstName(aCustomer.getFirstName()); newOne.setLastName(aCustomer.getLastName()); @@ -26,11 +26,11 @@ public class CustomerNoNull extends Customer { newOne.setState(aCustomer.getState()); newOne.setPhoneNumber(aCustomer.getPhoneNumber()); newOne.setEmail(aCustomer.getEmail()); - + feedback[i] = newOne; } - + return feedback; } - + } diff --git a/json/src/main/java/com/baeldung/jsonoptimization/CustomerSerializer.java b/json/src/main/java/com/baeldung/jsonoptimization/CustomerSerializer.java index 7e58010640..0f631ee85b 100644 --- a/json/src/main/java/com/baeldung/jsonoptimization/CustomerSerializer.java +++ b/json/src/main/java/com/baeldung/jsonoptimization/CustomerSerializer.java @@ -6,21 +6,21 @@ import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.ser.std.StdSerializer; -public class CustomerSerializer extends StdSerializer { +public class CustomerSerializer extends StdSerializer { private static final long serialVersionUID = 1L; public CustomerSerializer() { this(null); } - + public CustomerSerializer(Class t) { super(t); } - + @Override public void serialize(Customer customer, JsonGenerator jsonGenerator, SerializerProvider serializer) throws IOException { jsonGenerator.writeStartArray(); - jsonGenerator.writeNumber(customer.getId()); + jsonGenerator.writeNumber(customer.getId()); jsonGenerator.writeString(customer.getFirstName()); jsonGenerator.writeString(customer.getLastName()); jsonGenerator.writeString(customer.getStreet()); diff --git a/json/src/main/java/com/baeldung/jsonoptimization/CustomerShortNames.java b/json/src/main/java/com/baeldung/jsonoptimization/CustomerShortNames.java index ffa10f786d..2a47a4bbac 100644 --- a/json/src/main/java/com/baeldung/jsonoptimization/CustomerShortNames.java +++ b/json/src/main/java/com/baeldung/jsonoptimization/CustomerShortNames.java @@ -2,97 +2,113 @@ package com.baeldung.jsonoptimization; import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonGetter; -import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; public class CustomerShortNames { private long id; - + @JsonProperty("f") private String firstName; - + @JsonProperty("l") private String lastName; - + @JsonProperty("s") private String street; - + @JsonProperty("p") private String postalCode; - + @JsonProperty("c") private String city; - + @JsonProperty("a") private String state; - + @JsonProperty("o") private String phoneNumber; - + @JsonProperty("e") private String email; - + 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 String getStreet() { return street; } + public void setStreet(String street) { this.street = street; } + public String getPostalCode() { return postalCode; } + public void setPostalCode(String postalCode) { this.postalCode = postalCode; } + public String getCity() { return city; } + public void setCity(String city) { this.city = city; } + public String getState() { return state; } + public void setState(String state) { this.state = state; } + public String getPhoneNumber() { return phoneNumber; } + public void setPhoneNumber(String phoneNumber) { this.phoneNumber = phoneNumber; } + public String getEmail() { return email; } + public void setEmail(String email) { this.email = email; } - + @Override public int hashCode() { return Objects.hash(city, email, firstName, id, lastName, phoneNumber, postalCode, state, street); } + @Override public boolean equals(Object obj) { if (this == obj) { @@ -105,20 +121,20 @@ public class CustomerShortNames { return Objects.equals(city, other.city) && Objects.equals(email, other.email) && Objects.equals(firstName, other.firstName) && id == other.id && Objects.equals(lastName, other.lastName) && Objects.equals(phoneNumber, other.phoneNumber) && Objects.equals(postalCode, other.postalCode) && Objects.equals(state, other.state) && Objects.equals(street, other.street); } - + @Override public String toString() { return "CustomerWithShorterAttributes [id=" + id + ", firstName=" + firstName + ", lastName=" + lastName + ", street=" + street + ", postalCode=" + postalCode + ", city=" + city + ", state=" + state + ", phoneNumber=" + phoneNumber + ", email=" + email + "]"; - } + } public static CustomerShortNames[] fromCustomers(Customer[] customers) { - CustomerShortNames[] feedback = new CustomerShortNames[customers.length]; - - for(int i = 0; i < customers.length; i++) { + CustomerShortNames[] feedback = new CustomerShortNames[customers.length]; + + for (int i = 0; i < customers.length; i++) { Customer aCustomer = customers[i]; CustomerShortNames newOne = new CustomerShortNames(); - + newOne.setId(aCustomer.getId()); newOne.setFirstName(aCustomer.getFirstName()); newOne.setLastName(aCustomer.getLastName()); @@ -128,11 +144,11 @@ public class CustomerShortNames { newOne.setState(aCustomer.getState()); newOne.setPhoneNumber(aCustomer.getPhoneNumber()); newOne.setEmail(aCustomer.getEmail()); - + feedback[i] = newOne; } - + return feedback; } - + } diff --git a/json/src/main/java/com/baeldung/jsonoptimization/CustomerShortNamesNoNull.java b/json/src/main/java/com/baeldung/jsonoptimization/CustomerShortNamesNoNull.java index d3e9648a98..1b62fb2c06 100644 --- a/json/src/main/java/com/baeldung/jsonoptimization/CustomerShortNamesNoNull.java +++ b/json/src/main/java/com/baeldung/jsonoptimization/CustomerShortNamesNoNull.java @@ -1,24 +1,22 @@ package com.baeldung.jsonoptimization; import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; @JsonInclude(JsonInclude.Include.NON_NULL) public class CustomerShortNamesNoNull extends CustomerShortNames { - - + @Override public String toString() { return "CustomerShortNamesNoNull [toString()=" + super.toString() + "]"; } - + public static CustomerShortNamesNoNull[] fromCustomers(Customer[] customers) { - CustomerShortNamesNoNull[] feedback = new CustomerShortNamesNoNull[customers.length]; - - for(int i = 0; i < customers.length; i++) { + CustomerShortNamesNoNull[] feedback = new CustomerShortNamesNoNull[customers.length]; + + for (int i = 0; i < customers.length; i++) { Customer aCustomer = customers[i]; CustomerShortNamesNoNull newOne = new CustomerShortNamesNoNull(); - + newOne.setId(aCustomer.getId()); newOne.setFirstName(aCustomer.getFirstName()); newOne.setLastName(aCustomer.getLastName()); @@ -28,10 +26,10 @@ public class CustomerShortNamesNoNull extends CustomerShortNames { newOne.setState(aCustomer.getState()); newOne.setPhoneNumber(aCustomer.getPhoneNumber()); newOne.setEmail(aCustomer.getEmail()); - + feedback[i] = newOne; } - + return feedback; } diff --git a/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlim.java b/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlim.java index cdfaa4e329..e2ef4664cf 100644 --- a/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlim.java +++ b/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlim.java @@ -54,21 +54,20 @@ public class CustomerSlim { } public static CustomerSlim[] fromCustomers(Customer[] customers) { - CustomerSlim[] feedback = new CustomerSlim[customers.length]; - - for(int i = 0; i < customers.length; i++) { + CustomerSlim[] feedback = new CustomerSlim[customers.length]; + + for (int i = 0; i < customers.length; i++) { Customer aCustomer = customers[i]; CustomerSlim newOne = new CustomerSlim(); - + newOne.setId(aCustomer.getId()); newOne.setName(aCustomer.getFirstName() + " " + aCustomer.getLastName()); newOne.setAddress(aCustomer.getStreet() + ", " + aCustomer.getCity() + " " + aCustomer.getState() + " " + aCustomer.getPostalCode()); - + feedback[i] = newOne; } - + return feedback; } - } diff --git a/json/src/test/java/com/baeldung/jsonoptimization/JsonOptimizationUnitTest.java b/json/src/test/java/com/baeldung/jsonoptimization/JsonOptimizationUnitTest.java index e754978cd5..a1dbe08fed 100644 --- a/json/src/test/java/com/baeldung/jsonoptimization/JsonOptimizationUnitTest.java +++ b/json/src/test/java/com/baeldung/jsonoptimization/JsonOptimizationUnitTest.java @@ -15,7 +15,6 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.Version; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectWriter; @@ -77,7 +76,7 @@ class JsonOptimizationUnitTest { byte[] shorterJson = createPlainJson(TEST_LABEL_SHORTER_ATTRIBUTE_NAMES_NO_NULL, shorterOnesNoNull); compressJson(TEST_LABEL_SHORTER_ATTRIBUTE_NAMES_NO_NULL, shorterJson); } - + @Test void testSlim() throws IOException { printBanner(TEST_LABEL_SLIM_CUSTOMER); @@ -89,11 +88,11 @@ class JsonOptimizationUnitTest { @Test void testCustomSerializer() throws IOException { printBanner(TEST_LABEL_CUSTOM_SERIALIZER); - + SimpleModule serializer = new SimpleModule("CustomCustomerSerializer", new Version(1, 0, 0, null, null, null)); serializer.addSerializer(Customer.class, new CustomerSerializer()); mapper.registerModule(serializer); - + SimpleModule deserializer = new SimpleModule("CustomCustomerDeserializer", new Version(1, 0, 0, null, null, null)); deserializer.addDeserializer(Customer.class, new CustomerDeserializer()); mapper.registerModule(deserializer); @@ -135,7 +134,7 @@ class JsonOptimizationUnitTest { fos.write(feedback); fos.close(); System.out.println(label + " file: " + tempFile.toString()); - + Object[] restoredOnes = mapper.readValue(feedback, customers.getClass()); assertArrayEquals(TEST_LABEL_DEFAULT_JSON + ": restoring from JSON should work", customers, restoredOnes); From 777aa4b4ea5da91cb0ca78132bbe33c7adc1c2b8 Mon Sep 17 00:00:00 2001 From: "amit.pandey" Date: Sun, 6 Sep 2020 00:31:09 +0530 Subject: [PATCH 067/263] updated spring-data-mongo and used compatible mongo version --- persistence-modules/spring-data-mongodb/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/persistence-modules/spring-data-mongodb/pom.xml b/persistence-modules/spring-data-mongodb/pom.xml index 46dbc270c3..ec7aa14c36 100644 --- a/persistence-modules/spring-data-mongodb/pom.xml +++ b/persistence-modules/spring-data-mongodb/pom.xml @@ -121,7 +121,7 @@ 4.1.0 3.2.0.RELEASE Lovelace-SR9 - 4.1.0 + 4.0.5 From 8415ee8096e64e7b7a57fb0fe85d17024a4d6884 Mon Sep 17 00:00:00 2001 From: Usman Mohyuddin Date: Sun, 6 Sep 2020 00:07:33 +0500 Subject: [PATCH 068/263] update the test names as whenX_thenY update the test names as whenX_thenY --- .../com/baeldung/removeprefix/RemovePrefixTest.groovy | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core-groovy-strings/src/test/groovy/com/baeldung/removeprefix/RemovePrefixTest.groovy b/core-groovy-strings/src/test/groovy/com/baeldung/removeprefix/RemovePrefixTest.groovy index 568e5fdde8..aa9e65d98d 100644 --- a/core-groovy-strings/src/test/groovy/com/baeldung/removeprefix/RemovePrefixTest.groovy +++ b/core-groovy-strings/src/test/groovy/com/baeldung/removeprefix/RemovePrefixTest.groovy @@ -7,7 +7,7 @@ class RemovePrefixTest { @Test - public void givenWhenCasePrefixIsRemoved_thenReturnTrue() { + public void whenCasePrefixIsRemoved_thenReturnTrue() { def trimPrefix = { it.startsWith('Groovy') ? it.minus('Groovy') : it } @@ -16,7 +16,7 @@ class RemovePrefixTest { } @Test - public void givenWhenPrefixIsRemoved_thenReturnTrue() { + public void whenPrefixIsRemovedWithIgnoreCase_thenReturnTrue() { String prefix = "groovy-" String trimPrefix = "Groovy-Tutorials at Baeldung" @@ -29,7 +29,7 @@ class RemovePrefixTest { } @Test - public void givenWhenPrefixIsRemovedUsingRegex_thenReturnTrue() { + public void whenPrefixIsRemovedUsingRegex_thenReturnTrue() { def regex = ~"^([Gg])roovy-" String trimPrefix = "Groovy-Tutorials at Baeldung" @@ -38,7 +38,7 @@ class RemovePrefixTest { Assert.assertEquals("Tutorials at Baeldung", result) } - @Test public void givenWhenPrefixIsRemovedUsingReplaceFirst_thenReturnTrue() { + @Test public void whenPrefixIsRemovedUsingReplaceFirst_thenReturnTrue() { def regex = ~"^groovy" String trimPrefix = "groovyTutorials at Baeldung's groovy page" String result = trimPrefix.replaceFirst(regex, "") @@ -47,7 +47,7 @@ class RemovePrefixTest { } @Test - public void givenWhenPrefixIsRemovedUsingReplaceAll_thenReturnTrue() { + public void whenPrefixIsRemovedUsingReplaceAll_thenReturnTrue() { String trimPrefix = "groovyTutorials at Baeldung groovy" String result = trimPrefix.replaceAll(/^groovy/, "") From 9d326b55bc5436251c917ecb2c6ddb05493dc2ae Mon Sep 17 00:00:00 2001 From: Karsten Silz Date: Sun, 6 Sep 2020 13:23:34 +0100 Subject: [PATCH 069/263] BAEL-3326, "Optimizing JSON Schema for production use": More code for slim customer. --- .../CustomerDeserializer.java | 1 + .../jsonoptimization/CustomerShortNames.java | 1 + .../CustomerSlimDeserializer.java | 37 +++++++++ .../CustomerSlimSerializer.java | 28 +++++++ .../CustomerSlimShortNames.java | 81 +++++++++++++++++++ .../JsonOptimizationUnitTest.java | 57 ++++++++----- 6 files changed, 187 insertions(+), 18 deletions(-) create mode 100644 json/src/main/java/com/baeldung/jsonoptimization/CustomerSlimDeserializer.java create mode 100644 json/src/main/java/com/baeldung/jsonoptimization/CustomerSlimSerializer.java create mode 100644 json/src/main/java/com/baeldung/jsonoptimization/CustomerSlimShortNames.java diff --git a/json/src/main/java/com/baeldung/jsonoptimization/CustomerDeserializer.java b/json/src/main/java/com/baeldung/jsonoptimization/CustomerDeserializer.java index 04ab15556a..1815c5f202 100644 --- a/json/src/main/java/com/baeldung/jsonoptimization/CustomerDeserializer.java +++ b/json/src/main/java/com/baeldung/jsonoptimization/CustomerDeserializer.java @@ -43,6 +43,7 @@ public class CustomerDeserializer extends StdDeserializer { feedback.setPhoneNumber(phoneNumber.isNull() ? null : phoneNumber.asText()); JsonNode email = node.get(8); feedback.setEmail(email.isNull() ? null : email.asText()); + return feedback; } } diff --git a/json/src/main/java/com/baeldung/jsonoptimization/CustomerShortNames.java b/json/src/main/java/com/baeldung/jsonoptimization/CustomerShortNames.java index 2a47a4bbac..b94fbb1033 100644 --- a/json/src/main/java/com/baeldung/jsonoptimization/CustomerShortNames.java +++ b/json/src/main/java/com/baeldung/jsonoptimization/CustomerShortNames.java @@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; public class CustomerShortNames { + @JsonProperty("i") private long id; @JsonProperty("f") diff --git a/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlimDeserializer.java b/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlimDeserializer.java new file mode 100644 index 0000000000..9da7b7c873 --- /dev/null +++ b/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlimDeserializer.java @@ -0,0 +1,37 @@ +package com.baeldung.jsonoptimization; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.ObjectCodec; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; + +public class CustomerSlimDeserializer extends StdDeserializer { + private static final long serialVersionUID = 1L; + + public CustomerSlimDeserializer() { + this(null); + } + + public CustomerSlimDeserializer(Class t) { + super(t); + } + + @Override + public CustomerSlim deserialize(JsonParser parser, DeserializationContext deserializer) throws IOException { + CustomerSlim feedback = new CustomerSlim(); + ObjectCodec codec = parser.getCodec(); + JsonNode node = codec.readTree(parser); + + feedback.setId(node.get(0) + .asLong()); + feedback.setName(node.get(1) + .asText()); + feedback.setAddress(node.get(2) + .asText()); + + return feedback; + } +} diff --git a/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlimSerializer.java b/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlimSerializer.java new file mode 100644 index 0000000000..520c541da6 --- /dev/null +++ b/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlimSerializer.java @@ -0,0 +1,28 @@ +package com.baeldung.jsonoptimization; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; + +public class CustomerSlimSerializer extends StdSerializer { + private static final long serialVersionUID = 1L; + + public CustomerSlimSerializer() { + this(null); + } + + public CustomerSlimSerializer(Class t) { + super(t); + } + + @Override + public void serialize(CustomerSlim customer, JsonGenerator jsonGenerator, SerializerProvider serializer) throws IOException { + jsonGenerator.writeStartArray(); + jsonGenerator.writeNumber(customer.getId()); + jsonGenerator.writeString(customer.getName()); + jsonGenerator.writeString(customer.getAddress()); + jsonGenerator.writeEndArray(); + } +} diff --git a/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlimShortNames.java b/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlimShortNames.java new file mode 100644 index 0000000000..7bb20a7453 --- /dev/null +++ b/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlimShortNames.java @@ -0,0 +1,81 @@ +package com.baeldung.jsonoptimization; + +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class CustomerSlimShortNames { + + @JsonProperty("i") + private long id; + + @JsonProperty("n") + private String name; + + @JsonProperty("a") + private String address; + + 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 String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + @Override + public int hashCode() { + return Objects.hash(address, id, name); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof CustomerSlimShortNames)) { + return false; + } + CustomerSlimShortNames other = (CustomerSlimShortNames) obj; + return Objects.equals(address, other.address) && id == other.id && Objects.equals(name, other.name); + } + + @Override + public String toString() { + return "CustomerSlim [id=" + id + ", name=" + name + ", address=" + address + "]"; + } + + public static CustomerSlimShortNames[] fromCustomers(Customer[] customers) { + CustomerSlimShortNames[] feedback = new CustomerSlimShortNames[customers.length]; + + for (int i = 0; i < customers.length; i++) { + Customer aCustomer = customers[i]; + CustomerSlimShortNames newOne = new CustomerSlimShortNames(); + + newOne.setId(aCustomer.getId()); + newOne.setName(aCustomer.getFirstName() + " " + aCustomer.getLastName()); + newOne.setAddress(aCustomer.getStreet() + ", " + aCustomer.getCity() + " " + aCustomer.getState() + " " + aCustomer.getPostalCode()); + + feedback[i] = newOne; + } + + return feedback; + } + +} diff --git a/json/src/test/java/com/baeldung/jsonoptimization/JsonOptimizationUnitTest.java b/json/src/test/java/com/baeldung/jsonoptimization/JsonOptimizationUnitTest.java index a1dbe08fed..dd5703543f 100644 --- a/json/src/test/java/com/baeldung/jsonoptimization/JsonOptimizationUnitTest.java +++ b/json/src/test/java/com/baeldung/jsonoptimization/JsonOptimizationUnitTest.java @@ -23,10 +23,12 @@ import com.fasterxml.jackson.databind.module.SimpleModule; class JsonOptimizationUnitTest { private static final String TEST_LABEL_DEFAULT_JSON = "Default JSON"; private static final String TEST_LABEL_DEFAULT_JSON_NO_NULL = "Default JSON without null"; - private static final String TEST_LABEL_SHORTER_ATTRIBUTE_NAMES = "Shorter Attribute Names"; - private static final String TEST_LABEL_SHORTER_ATTRIBUTE_NAMES_NO_NULL = "Shorter Attribute Names without null"; - private static final String TEST_LABEL_CUSTOM_SERIALIZER = "Custom Serializer"; + private static final String TEST_LABEL_SHORT_NAMES = "Shorter attribute names"; + private static final String TEST_LABEL_SHORT_NAMES_NO_NULL = "Shorter attribute names without null"; + private static final String TEST_LABEL_CUSTOM_SERIALIZER = "Custom serializer"; + private static final String TEST_LABEL_SLIM_CUSTOM_SERIALIZER = "Slim custom serializer"; private static final String TEST_LABEL_SLIM_CUSTOMER = "Slim customer"; + private static final String TEST_LABEL_SLIM_CUSTOMER_SHORT_NAMES = "Slim customer with shorter attribute names"; private static DecimalFormat LENGTH_FORMATTER = new DecimalFormat("###,###,###"); private static Customer[] customers; private ObjectMapper mapper; @@ -62,19 +64,19 @@ class JsonOptimizationUnitTest { } @Test - void testShorterAttributes() throws IOException { - printBanner(TEST_LABEL_SHORTER_ATTRIBUTE_NAMES); + void testShortNames() throws IOException { + printBanner(TEST_LABEL_SHORT_NAMES); CustomerShortNames[] shorterOnes = CustomerShortNames.fromCustomers(customers); - byte[] shorterJson = createPlainJson(TEST_LABEL_SHORTER_ATTRIBUTE_NAMES, shorterOnes); - compressJson(TEST_LABEL_SHORTER_ATTRIBUTE_NAMES, shorterJson); + byte[] shorterJson = createPlainJson(TEST_LABEL_SHORT_NAMES, shorterOnes); + compressJson(TEST_LABEL_SHORT_NAMES, shorterJson); } @Test - void testShorterAttributesNoNull() throws IOException { - printBanner(TEST_LABEL_SHORTER_ATTRIBUTE_NAMES_NO_NULL); + void testShortNamesNoNull() throws IOException { + printBanner(TEST_LABEL_SHORT_NAMES_NO_NULL); CustomerShortNamesNoNull[] shorterOnesNoNull = CustomerShortNamesNoNull.fromCustomers(customers); - byte[] shorterJson = createPlainJson(TEST_LABEL_SHORTER_ATTRIBUTE_NAMES_NO_NULL, shorterOnesNoNull); - compressJson(TEST_LABEL_SHORTER_ATTRIBUTE_NAMES_NO_NULL, shorterJson); + byte[] shorterJson = createPlainJson(TEST_LABEL_SHORT_NAMES_NO_NULL, shorterOnesNoNull); + compressJson(TEST_LABEL_SHORT_NAMES_NO_NULL, shorterJson); } @Test @@ -85,21 +87,40 @@ class JsonOptimizationUnitTest { compressJson(TEST_LABEL_SLIM_CUSTOMER, slimJson); } + @Test + void testSlimShortNames() throws IOException { + printBanner(TEST_LABEL_SLIM_CUSTOMER_SHORT_NAMES); + CustomerSlimShortNames[] slimOnes = CustomerSlimShortNames.fromCustomers(customers); + byte[] slimJson = createPlainJson(TEST_LABEL_SLIM_CUSTOMER_SHORT_NAMES, slimOnes); + compressJson(TEST_LABEL_SLIM_CUSTOMER_SHORT_NAMES, slimJson); + } + @Test void testCustomSerializer() throws IOException { printBanner(TEST_LABEL_CUSTOM_SERIALIZER); - - SimpleModule serializer = new SimpleModule("CustomCustomerSerializer", new Version(1, 0, 0, null, null, null)); + + SimpleModule serializer = new SimpleModule("CustomDeSerializer", new Version(1, 0, 0, null, null, null)); serializer.addSerializer(Customer.class, new CustomerSerializer()); + serializer.addDeserializer(Customer.class, new CustomerDeserializer()); mapper.registerModule(serializer); - - SimpleModule deserializer = new SimpleModule("CustomCustomerDeserializer", new Version(1, 0, 0, null, null, null)); - deserializer.addDeserializer(Customer.class, new CustomerDeserializer()); - mapper.registerModule(deserializer); - + byte[] plainJson = createPlainJson(TEST_LABEL_CUSTOM_SERIALIZER, customers); compressJson(TEST_LABEL_CUSTOM_SERIALIZER, plainJson); } + + @Test + void testSlimCustomSerializer() throws IOException { + printBanner(TEST_LABEL_SLIM_CUSTOM_SERIALIZER); + + SimpleModule serializer = new SimpleModule("SlimCustomDeSerializer", new Version(1, 0, 0, null, null, null)); + serializer.addSerializer(CustomerSlim.class, new CustomerSlimSerializer()); + serializer.addDeserializer(CustomerSlim.class, new CustomerSlimDeserializer()); + mapper.registerModule(serializer); + + CustomerSlim[] slimOnes = CustomerSlim.fromCustomers(customers); + byte[] plainJson = createPlainJson(TEST_LABEL_SLIM_CUSTOM_SERIALIZER, slimOnes); + compressJson(TEST_LABEL_SLIM_CUSTOM_SERIALIZER, plainJson); + } private void printBanner(String name) { System.out.println(); From 2c78247c95f456fd4ecb8ea197615f002327d922 Mon Sep 17 00:00:00 2001 From: Karsten Silz Date: Sun, 6 Sep 2020 13:48:39 +0100 Subject: [PATCH 070/263] BAEL-3326, "Optimizing JSON Schema for production use": Added percentages, fixed formatting. --- .../jsonoptimization/CustomerDeserializer.java | 2 +- .../CustomerSlimDeserializer.java | 2 +- .../jsonoptimization/CustomerSlimShortNames.java | 6 +++--- .../JsonOptimizationUnitTest.java | 16 +++++++++++----- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/json/src/main/java/com/baeldung/jsonoptimization/CustomerDeserializer.java b/json/src/main/java/com/baeldung/jsonoptimization/CustomerDeserializer.java index 1815c5f202..16b66311ad 100644 --- a/json/src/main/java/com/baeldung/jsonoptimization/CustomerDeserializer.java +++ b/json/src/main/java/com/baeldung/jsonoptimization/CustomerDeserializer.java @@ -43,7 +43,7 @@ public class CustomerDeserializer extends StdDeserializer { feedback.setPhoneNumber(phoneNumber.isNull() ? null : phoneNumber.asText()); JsonNode email = node.get(8); feedback.setEmail(email.isNull() ? null : email.asText()); - + return feedback; } } diff --git a/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlimDeserializer.java b/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlimDeserializer.java index 9da7b7c873..296ee6fdf6 100644 --- a/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlimDeserializer.java +++ b/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlimDeserializer.java @@ -31,7 +31,7 @@ public class CustomerSlimDeserializer extends StdDeserializer { .asText()); feedback.setAddress(node.get(2) .asText()); - + return feedback; } } diff --git a/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlimShortNames.java b/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlimShortNames.java index 7bb20a7453..bf00e847ac 100644 --- a/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlimShortNames.java +++ b/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlimShortNames.java @@ -5,13 +5,13 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; public class CustomerSlimShortNames { - + @JsonProperty("i") private long id; - + @JsonProperty("n") private String name; - + @JsonProperty("a") private String address; diff --git a/json/src/test/java/com/baeldung/jsonoptimization/JsonOptimizationUnitTest.java b/json/src/test/java/com/baeldung/jsonoptimization/JsonOptimizationUnitTest.java index dd5703543f..2573b34414 100644 --- a/json/src/test/java/com/baeldung/jsonoptimization/JsonOptimizationUnitTest.java +++ b/json/src/test/java/com/baeldung/jsonoptimization/JsonOptimizationUnitTest.java @@ -32,10 +32,14 @@ class JsonOptimizationUnitTest { private static DecimalFormat LENGTH_FORMATTER = new DecimalFormat("###,###,###"); private static Customer[] customers; private ObjectMapper mapper; + private static int defaultJsonLength; @BeforeAll static void setUpOnce() throws Exception { customers = Customer.fromMockFile(); + ObjectMapper oneTimeMapper = new ObjectMapper(); + byte[] feedback = oneTimeMapper.writeValueAsBytes(customers); + defaultJsonLength = feedback.length; } @BeforeEach @@ -98,16 +102,16 @@ class JsonOptimizationUnitTest { @Test void testCustomSerializer() throws IOException { printBanner(TEST_LABEL_CUSTOM_SERIALIZER); - + SimpleModule serializer = new SimpleModule("CustomDeSerializer", new Version(1, 0, 0, null, null, null)); serializer.addSerializer(Customer.class, new CustomerSerializer()); serializer.addDeserializer(Customer.class, new CustomerDeserializer()); mapper.registerModule(serializer); - + byte[] plainJson = createPlainJson(TEST_LABEL_CUSTOM_SERIALIZER, customers); compressJson(TEST_LABEL_CUSTOM_SERIALIZER, plainJson); } - + @Test void testSlimCustomSerializer() throws IOException { printBanner(TEST_LABEL_SLIM_CUSTOM_SERIALIZER); @@ -135,7 +139,8 @@ class JsonOptimizationUnitTest { gzipStream.write(plainJson); gzipStream.close(); byte[] gzippedJson = outpuStream.toByteArray(); - System.out.println(label + " GZIPped length: " + LENGTH_FORMATTER.format(gzippedJson.length)); + int percent = gzippedJson.length * 100 / defaultJsonLength; + System.out.println(label + " GZIPped length: " + LENGTH_FORMATTER.format(gzippedJson.length / 1024) + "kB (" + percent + "%)"); assertTrue(plainJson.length > gzippedJson.length, label + " should be longer than GZIPped data"); } @@ -145,7 +150,8 @@ class JsonOptimizationUnitTest { System.out.println(prettyWritter.writeValueAsString(customers[0])); byte[] feedback = mapper.writeValueAsBytes(customers); - System.out.println(label + " length: " + LENGTH_FORMATTER.format(feedback.length)); + int percent = feedback.length * 100 / defaultJsonLength; + System.out.println(label + " length: " + LENGTH_FORMATTER.format(feedback.length / 1024) + "kB (" + percent + "%)"); assertTrue(feedback.length > 1, label + " should be there"); String prefix = label.replaceAll(" ", "-") From 09e0e958bca4cb749c9608294f1a9ef447685a14 Mon Sep 17 00:00:00 2001 From: Karsten Silz Date: Sun, 6 Sep 2020 13:49:24 +0100 Subject: [PATCH 071/263] BAEL-3326, "Optimizing JSON Schema for production use" Percentages now rounded. --- .../jsonoptimization/JsonOptimizationUnitTest.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/json/src/test/java/com/baeldung/jsonoptimization/JsonOptimizationUnitTest.java b/json/src/test/java/com/baeldung/jsonoptimization/JsonOptimizationUnitTest.java index 2573b34414..e9bd044869 100644 --- a/json/src/test/java/com/baeldung/jsonoptimization/JsonOptimizationUnitTest.java +++ b/json/src/test/java/com/baeldung/jsonoptimization/JsonOptimizationUnitTest.java @@ -29,7 +29,8 @@ class JsonOptimizationUnitTest { private static final String TEST_LABEL_SLIM_CUSTOM_SERIALIZER = "Slim custom serializer"; private static final String TEST_LABEL_SLIM_CUSTOMER = "Slim customer"; private static final String TEST_LABEL_SLIM_CUSTOMER_SHORT_NAMES = "Slim customer with shorter attribute names"; - private static DecimalFormat LENGTH_FORMATTER = new DecimalFormat("###,###,###"); + private static DecimalFormat LENGTH_FORMATTER = new DecimalFormat("###,###"); + private static DecimalFormat PERCENT_FORMATTER = new DecimalFormat("###"); private static Customer[] customers; private ObjectMapper mapper; private static int defaultJsonLength; @@ -139,8 +140,9 @@ class JsonOptimizationUnitTest { gzipStream.write(plainJson); gzipStream.close(); byte[] gzippedJson = outpuStream.toByteArray(); - int percent = gzippedJson.length * 100 / defaultJsonLength; - System.out.println(label + " GZIPped length: " + LENGTH_FORMATTER.format(gzippedJson.length / 1024) + "kB (" + percent + "%)"); + double percent = Math.round(gzippedJson.length * 100d / defaultJsonLength); + System.out.println(label + " GZIPped length: " + LENGTH_FORMATTER.format(gzippedJson.length / 1024) + + "kB (" + PERCENT_FORMATTER.format(percent) + "%)"); assertTrue(plainJson.length > gzippedJson.length, label + " should be longer than GZIPped data"); } @@ -150,8 +152,9 @@ class JsonOptimizationUnitTest { System.out.println(prettyWritter.writeValueAsString(customers[0])); byte[] feedback = mapper.writeValueAsBytes(customers); - int percent = feedback.length * 100 / defaultJsonLength; - System.out.println(label + " length: " + LENGTH_FORMATTER.format(feedback.length / 1024) + "kB (" + percent + "%)"); + double percent = Math.round(feedback.length * 100d / defaultJsonLength); + System.out.println(label + " length: " + LENGTH_FORMATTER.format(feedback.length / 1024) + + "kB (" + PERCENT_FORMATTER.format(percent) + "%)"); assertTrue(feedback.length > 1, label + " should be there"); String prefix = label.replaceAll(" ", "-") From be8c51e3e0b585afbb72cb365045722bc8a5cb35 Mon Sep 17 00:00:00 2001 From: "amit.pandey" Date: Sun, 6 Sep 2020 20:05:15 +0530 Subject: [PATCH 072/263] removed unwanted dependency from pom --- persistence-modules/spring-data-mongodb/pom.xml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/persistence-modules/spring-data-mongodb/pom.xml b/persistence-modules/spring-data-mongodb/pom.xml index ec7aa14c36..fdcaf1d49b 100644 --- a/persistence-modules/spring-data-mongodb/pom.xml +++ b/persistence-modules/spring-data-mongodb/pom.xml @@ -19,12 +19,6 @@ ${org.springframework.data.version} - - org.mongodb - mongodb-driver-core - ${mongodb-driver.version} - - org.mongodb mongodb-driver-sync From 1927bb1b460752245b26b441a637138e0eebaaa2 Mon Sep 17 00:00:00 2001 From: developerDiv <34768329+developerDiv@users.noreply.github.com> Date: Sun, 6 Sep 2020 16:27:59 +0100 Subject: [PATCH 073/263] BAEL-4287 - Rolling Back Migrations with Flyway (#9910) * First commit - Flyway Undo * Simplify migrations Move to own package --- .../db/undo/V1_0__create_book_table.sql | 6 +++ .../db/undo/V2_0__drop_table_book.sql | 1 + .../FlywayUndoMigrationIntegrationTest.java | 39 +++++++++++++++++++ .../flywayundo/FlywayUndoTestConfig.java | 21 ++++++++++ 4 files changed, 67 insertions(+) create mode 100644 persistence-modules/flyway/src/main/resources/db/undo/V1_0__create_book_table.sql create mode 100644 persistence-modules/flyway/src/main/resources/db/undo/V2_0__drop_table_book.sql create mode 100644 persistence-modules/flyway/src/test/java/com/baeldung/flywayundo/FlywayUndoMigrationIntegrationTest.java create mode 100644 persistence-modules/flyway/src/test/java/com/baeldung/flywayundo/FlywayUndoTestConfig.java diff --git a/persistence-modules/flyway/src/main/resources/db/undo/V1_0__create_book_table.sql b/persistence-modules/flyway/src/main/resources/db/undo/V1_0__create_book_table.sql new file mode 100644 index 0000000000..105da7a0c0 --- /dev/null +++ b/persistence-modules/flyway/src/main/resources/db/undo/V1_0__create_book_table.sql @@ -0,0 +1,6 @@ +create table book ( + id numeric, + title varchar(128), + author varchar(256), + constraint pk_book primary key (id) +); \ No newline at end of file diff --git a/persistence-modules/flyway/src/main/resources/db/undo/V2_0__drop_table_book.sql b/persistence-modules/flyway/src/main/resources/db/undo/V2_0__drop_table_book.sql new file mode 100644 index 0000000000..cd800b00b7 --- /dev/null +++ b/persistence-modules/flyway/src/main/resources/db/undo/V2_0__drop_table_book.sql @@ -0,0 +1 @@ +drop table book; \ No newline at end of file diff --git a/persistence-modules/flyway/src/test/java/com/baeldung/flywayundo/FlywayUndoMigrationIntegrationTest.java b/persistence-modules/flyway/src/test/java/com/baeldung/flywayundo/FlywayUndoMigrationIntegrationTest.java new file mode 100644 index 0000000000..03004baf60 --- /dev/null +++ b/persistence-modules/flyway/src/test/java/com/baeldung/flywayundo/FlywayUndoMigrationIntegrationTest.java @@ -0,0 +1,39 @@ +package com.baeldung.flywayundo; + +import org.flywaydb.core.Flyway; +import org.flywaydb.core.api.MigrationInfo; +import org.flywaydb.core.api.MigrationState; +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.ContextConfiguration; +import org.springframework.test.context.junit4.SpringRunner; + +import javax.sql.DataSource; + +import static org.assertj.core.api.Assertions.assertThat; + +@RunWith(SpringRunner.class) +@ContextConfiguration(classes = FlywayUndoTestConfig.class) +@SpringBootTest +public class FlywayUndoMigrationIntegrationTest { + + @Autowired + private DataSource dataSource; + + @Test + public void givenMigrationsExist_whenApplyMigrations_migrationsAreSuccessful() { + Flyway flyway = Flyway.configure() + .dataSource(dataSource) + .schemas("undo") + .locations("db/undo") + .load(); + + flyway.migrate(); + + for (MigrationInfo info : flyway.info().all()) { + assertThat(info.getState()).isEqualTo(MigrationState.SUCCESS); + } + } +} diff --git a/persistence-modules/flyway/src/test/java/com/baeldung/flywayundo/FlywayUndoTestConfig.java b/persistence-modules/flyway/src/test/java/com/baeldung/flywayundo/FlywayUndoTestConfig.java new file mode 100644 index 0000000000..5f00626179 --- /dev/null +++ b/persistence-modules/flyway/src/test/java/com/baeldung/flywayundo/FlywayUndoTestConfig.java @@ -0,0 +1,21 @@ +package com.baeldung.flywayundo; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; + +import javax.sql.DataSource; + +@Configuration +public class FlywayUndoTestConfig { + + @Bean + public DataSource createDatasource() { + EmbeddedDatabaseBuilder dbBuilder = new EmbeddedDatabaseBuilder(); + return dbBuilder.setType(EmbeddedDatabaseType.H2) + .setName("DATABASE") + .build(); + } + +} From b7328395a3d893b309dc6d5eda4c877b93242c0d Mon Sep 17 00:00:00 2001 From: Harihar Das Date: Sun, 6 Sep 2020 18:33:35 +0200 Subject: [PATCH 074/263] generated gradle wrapper files --- gradle-wrapper/gradle/wrapper/README.md | 35 ++++ .../gradle/wrapper/gradle-wrapper.properties | 5 + gradle-wrapper/gradlew | 183 ++++++++++++++++++ gradle-wrapper/gradlew.bat | 103 ++++++++++ 4 files changed, 326 insertions(+) create mode 100644 gradle-wrapper/gradle/wrapper/README.md create mode 100644 gradle-wrapper/gradle/wrapper/gradle-wrapper.properties create mode 100755 gradle-wrapper/gradlew create mode 100644 gradle-wrapper/gradlew.bat diff --git a/gradle-wrapper/gradle/wrapper/README.md b/gradle-wrapper/gradle/wrapper/README.md new file mode 100644 index 0000000000..892f7a23cb --- /dev/null +++ b/gradle-wrapper/gradle/wrapper/README.md @@ -0,0 +1,35 @@ +The files in this project were generated using gradle wrapper command. +`gradle wrapper` + +To test, download this project on your machine and run the following: +`./wrapper tasks` + +This should generate output similar to: +``` +> Task :tasks + +------------------------------------------------------------ +Tasks runnable from root project +------------------------------------------------------------ + +Build Setup tasks +----------------- +init - Initializes a new Gradle build. +wrapper - Generates Gradle wrapper files. + +Help tasks +---------- +buildEnvironment - Displays all buildscript dependencies declared in root project 'gradle-wrapper'. +components - Displays the components produced by root project 'gradle-wrapper'. [incubating] +dependencies - Displays all dependencies declared in root project 'gradle-wrapper'. +dependencyInsight - Displays the insight into a specific dependency in root project 'gradle-wrapper'. +dependentComponents - Displays the dependent components of components in root project 'gradle-wrapper'. [incubating] +help - Displays a help message. +model - Displays the configuration model of root project 'gradle-wrapper'. [incubating] +outgoingVariants - Displays the outgoing variants of root project 'gradle-wrapper'. +projects - Displays the sub-projects of root project 'gradle-wrapper'. +properties - Displays the properties of root project 'gradle-wrapper'. +tasks - Displays the tasks runnable from root project 'gradle-wrapper'. + +To see all tasks and more detail, run gradlew tasks --all +``` \ No newline at end of file diff --git a/gradle-wrapper/gradle/wrapper/gradle-wrapper.properties b/gradle-wrapper/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000000..a4b4429748 --- /dev/null +++ b/gradle-wrapper/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradle-wrapper/gradlew b/gradle-wrapper/gradlew new file mode 100755 index 0000000000..2fe81a7d95 --- /dev/null +++ b/gradle-wrapper/gradlew @@ -0,0 +1,183 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=`expr $i + 1` + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +exec "$JAVACMD" "$@" diff --git a/gradle-wrapper/gradlew.bat b/gradle-wrapper/gradlew.bat new file mode 100644 index 0000000000..9109989e3c --- /dev/null +++ b/gradle-wrapper/gradlew.bat @@ -0,0 +1,103 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega From 74efd2530ef142902a10b44431d6981d789f577c Mon Sep 17 00:00:00 2001 From: fanatixan Date: Mon, 7 Sep 2020 04:13:25 +0200 Subject: [PATCH 075/263] added code snippets for bael-4554 (#9979) --- .../mockito/whenvsdomethods/Employee.java | 11 +++ .../IAmOnHolidayException.java | 5 ++ .../WhenVsDoMethodsUnitTest.java | 90 +++++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 testing-modules/mockito-2/src/main/java/com/baeldung/mockito/whenvsdomethods/Employee.java create mode 100644 testing-modules/mockito-2/src/main/java/com/baeldung/mockito/whenvsdomethods/IAmOnHolidayException.java create mode 100644 testing-modules/mockito-2/src/test/java/com/baeldung/mockito/whenvsdomethods/WhenVsDoMethodsUnitTest.java diff --git a/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/whenvsdomethods/Employee.java b/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/whenvsdomethods/Employee.java new file mode 100644 index 0000000000..4bbd2843f2 --- /dev/null +++ b/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/whenvsdomethods/Employee.java @@ -0,0 +1,11 @@ +package com.baeldung.mockito.whenvsdomethods; + +import java.time.DayOfWeek; + +public interface Employee { + + String greet(); + + void work(DayOfWeek day); + +} diff --git a/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/whenvsdomethods/IAmOnHolidayException.java b/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/whenvsdomethods/IAmOnHolidayException.java new file mode 100644 index 0000000000..24276ba958 --- /dev/null +++ b/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/whenvsdomethods/IAmOnHolidayException.java @@ -0,0 +1,5 @@ +package com.baeldung.mockito.whenvsdomethods; + +public class IAmOnHolidayException extends RuntimeException { + +} diff --git a/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/whenvsdomethods/WhenVsDoMethodsUnitTest.java b/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/whenvsdomethods/WhenVsDoMethodsUnitTest.java new file mode 100644 index 0000000000..8c2b86daf1 --- /dev/null +++ b/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/whenvsdomethods/WhenVsDoMethodsUnitTest.java @@ -0,0 +1,90 @@ +package com.baeldung.mockito.whenvsdomethods; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.willThrow; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.when; + +import java.time.DayOfWeek; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.function.Executable; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +public class WhenVsDoMethodsUnitTest { + + @Mock + private Employee employee; + + @BeforeEach + void setup() { + MockitoAnnotations.initMocks(this); + } + + @Test + void givenNonVoidMethod_callingWhen_shouldConfigureBehavior() { + // given + when(employee.greet()).thenReturn("Hello"); + + // when + String greeting = employee.greet(); + + // then + assertThat(greeting, is("Hello")); + } + + @Test + void givenNonVoidMethod_callingDoReturn_shouldConfigureBehavior() { + // given + doReturn("Hello").when(employee).greet(); + + // when + String greeting = employee.greet(); + + // then + assertThat(greeting, is("Hello")); + } + + @Test + void givenVoidMethod_callingDoThrow_shouldConfigureBehavior() { + // given + doThrow(new IAmOnHolidayException()).when(employee).work(DayOfWeek.SUNDAY); + + // when + Executable workCall = () -> employee.work(DayOfWeek.SUNDAY); + + // then + assertThrows(IAmOnHolidayException.class, workCall); + } + + @Test + void givenNonVoidMethod_callingGiven_shouldConfigureBehavior() { + // given + given(employee.greet()).willReturn("Hello"); + + // when + String greeting = employee.greet(); + + // then + assertThat(greeting, is("Hello")); + } + + @Test + void givenVoidMethod_callingWillThrow_shouldConfigureBehavior() { + // given + willThrow(new IAmOnHolidayException()).given(employee).work(DayOfWeek.SUNDAY); + + // when + Executable workCall = () -> employee.work(DayOfWeek.SUNDAY); + + // then + assertThrows(IAmOnHolidayException.class, workCall); + } + +} From 8278cc272a86dd4d9f8eb438d809c8aac3e17f30 Mon Sep 17 00:00:00 2001 From: majajoksovic Date: Mon, 7 Sep 2020 04:19:12 +0200 Subject: [PATCH 076/263] added braces (#9972) --- .../src/main/java/com/baeldung/ssh/apachesshd/SshdDemo.java | 2 +- .../src/main/java/com/baeldung/ssh/jsch/JschDemo.java | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libraries-security/src/main/java/com/baeldung/ssh/apachesshd/SshdDemo.java b/libraries-security/src/main/java/com/baeldung/ssh/apachesshd/SshdDemo.java index 05d8034040..8a394640c7 100644 --- a/libraries-security/src/main/java/com/baeldung/ssh/apachesshd/SshdDemo.java +++ b/libraries-security/src/main/java/com/baeldung/ssh/apachesshd/SshdDemo.java @@ -32,7 +32,7 @@ public class SshdDemo { .getSession()) { session.addPasswordIdentity(password); session.auth() - .verify(5L, TimeUnit.SECONDS); + .verify(defaultTimeoutSeconds, TimeUnit.SECONDS); try (ByteArrayOutputStream responseStream = new ByteArrayOutputStream(); ByteArrayOutputStream errorResponseStream = new ByteArrayOutputStream(); ClientChannel channel = session.createChannel(Channel.CHANNEL_SHELL)) { diff --git a/libraries-security/src/main/java/com/baeldung/ssh/jsch/JschDemo.java b/libraries-security/src/main/java/com/baeldung/ssh/jsch/JschDemo.java index 34a40318bb..8a6567bfee 100644 --- a/libraries-security/src/main/java/com/baeldung/ssh/jsch/JschDemo.java +++ b/libraries-security/src/main/java/com/baeldung/ssh/jsch/JschDemo.java @@ -42,10 +42,12 @@ public class JschDemo { throw new Exception(errorResponse); } } finally { - if (session != null) + if (session != null) { session.disconnect(); - if (channel != null) + } + if (channel != null) { channel.disconnect(); + } } return response; } From d994a5bdbf1353382cccc88a7fc2db51bbd8268f Mon Sep 17 00:00:00 2001 From: Meysam Tamkin Date: Mon, 7 Sep 2020 13:35:07 +0430 Subject: [PATCH 077/263] Fix it some changes --- .../junit5/nonstatic/BeforeAndAfterAnnotationsUnitTest.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename testing-modules/junit-5/src/{main => test}/java/com/baeldung/junit5/nonstatic/BeforeAndAfterAnnotationsUnitTest.java (100%) diff --git a/testing-modules/junit-5/src/main/java/com/baeldung/junit5/nonstatic/BeforeAndAfterAnnotationsUnitTest.java b/testing-modules/junit-5/src/test/java/com/baeldung/junit5/nonstatic/BeforeAndAfterAnnotationsUnitTest.java similarity index 100% rename from testing-modules/junit-5/src/main/java/com/baeldung/junit5/nonstatic/BeforeAndAfterAnnotationsUnitTest.java rename to testing-modules/junit-5/src/test/java/com/baeldung/junit5/nonstatic/BeforeAndAfterAnnotationsUnitTest.java From 56f09fa1d58d9b3ff3906218e481bc27b2e5c8b8 Mon Sep 17 00:00:00 2001 From: Karsten Silz Date: Mon, 7 Sep 2020 10:31:03 +0100 Subject: [PATCH 078/263] BAEL-3326, "Optimizing JSON Schema for production use" Replaced per-class omission of null values with Jackson setting. --- .../jsonoptimization/CustomerNoNull.java | 36 ----------------- .../CustomerShortNamesNoNull.java | 36 ----------------- .../JsonOptimizationUnitTest.java | 40 +++++++++++-------- 3 files changed, 24 insertions(+), 88 deletions(-) delete mode 100644 json/src/main/java/com/baeldung/jsonoptimization/CustomerNoNull.java delete mode 100644 json/src/main/java/com/baeldung/jsonoptimization/CustomerShortNamesNoNull.java diff --git a/json/src/main/java/com/baeldung/jsonoptimization/CustomerNoNull.java b/json/src/main/java/com/baeldung/jsonoptimization/CustomerNoNull.java deleted file mode 100644 index 62cf526f78..0000000000 --- a/json/src/main/java/com/baeldung/jsonoptimization/CustomerNoNull.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.baeldung.jsonoptimization; - -import com.fasterxml.jackson.annotation.JsonInclude; - -@JsonInclude(JsonInclude.Include.NON_NULL) -public class CustomerNoNull extends Customer { - - @Override - public String toString() { - return "CustomerNoNull [toString()=" + super.toString() + "]"; - } - - public static CustomerNoNull[] fromCustomers(Customer[] customers) { - CustomerNoNull[] feedback = new CustomerNoNull[customers.length]; - - for (int i = 0; i < customers.length; i++) { - Customer aCustomer = customers[i]; - CustomerNoNull newOne = new CustomerNoNull(); - - newOne.setId(aCustomer.getId()); - newOne.setFirstName(aCustomer.getFirstName()); - newOne.setLastName(aCustomer.getLastName()); - newOne.setStreet(aCustomer.getStreet()); - newOne.setCity(aCustomer.getCity()); - newOne.setPostalCode(aCustomer.getPostalCode()); - newOne.setState(aCustomer.getState()); - newOne.setPhoneNumber(aCustomer.getPhoneNumber()); - newOne.setEmail(aCustomer.getEmail()); - - feedback[i] = newOne; - } - - return feedback; - } - -} diff --git a/json/src/main/java/com/baeldung/jsonoptimization/CustomerShortNamesNoNull.java b/json/src/main/java/com/baeldung/jsonoptimization/CustomerShortNamesNoNull.java deleted file mode 100644 index 1b62fb2c06..0000000000 --- a/json/src/main/java/com/baeldung/jsonoptimization/CustomerShortNamesNoNull.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.baeldung.jsonoptimization; - -import com.fasterxml.jackson.annotation.JsonInclude; - -@JsonInclude(JsonInclude.Include.NON_NULL) -public class CustomerShortNamesNoNull extends CustomerShortNames { - - @Override - public String toString() { - return "CustomerShortNamesNoNull [toString()=" + super.toString() + "]"; - } - - public static CustomerShortNamesNoNull[] fromCustomers(Customer[] customers) { - CustomerShortNamesNoNull[] feedback = new CustomerShortNamesNoNull[customers.length]; - - for (int i = 0; i < customers.length; i++) { - Customer aCustomer = customers[i]; - CustomerShortNamesNoNull newOne = new CustomerShortNamesNoNull(); - - newOne.setId(aCustomer.getId()); - newOne.setFirstName(aCustomer.getFirstName()); - newOne.setLastName(aCustomer.getLastName()); - newOne.setStreet(aCustomer.getStreet()); - newOne.setCity(aCustomer.getCity()); - newOne.setPostalCode(aCustomer.getPostalCode()); - newOne.setState(aCustomer.getState()); - newOne.setPhoneNumber(aCustomer.getPhoneNumber()); - newOne.setEmail(aCustomer.getEmail()); - - feedback[i] = newOne; - } - - return feedback; - } - -} diff --git a/json/src/test/java/com/baeldung/jsonoptimization/JsonOptimizationUnitTest.java b/json/src/test/java/com/baeldung/jsonoptimization/JsonOptimizationUnitTest.java index e9bd044869..5734518fad 100644 --- a/json/src/test/java/com/baeldung/jsonoptimization/JsonOptimizationUnitTest.java +++ b/json/src/test/java/com/baeldung/jsonoptimization/JsonOptimizationUnitTest.java @@ -15,6 +15,7 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.core.Version; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectWriter; @@ -23,14 +24,14 @@ import com.fasterxml.jackson.databind.module.SimpleModule; class JsonOptimizationUnitTest { private static final String TEST_LABEL_DEFAULT_JSON = "Default JSON"; private static final String TEST_LABEL_DEFAULT_JSON_NO_NULL = "Default JSON without null"; - private static final String TEST_LABEL_SHORT_NAMES = "Shorter attribute names"; - private static final String TEST_LABEL_SHORT_NAMES_NO_NULL = "Shorter attribute names without null"; + private static final String TEST_LABEL_SHORT_NAMES = "Shorter field names"; + private static final String TEST_LABEL_SHORT_NAMES_NO_NULL = "Shorter field names without null"; private static final String TEST_LABEL_CUSTOM_SERIALIZER = "Custom serializer"; private static final String TEST_LABEL_SLIM_CUSTOM_SERIALIZER = "Slim custom serializer"; private static final String TEST_LABEL_SLIM_CUSTOMER = "Slim customer"; - private static final String TEST_LABEL_SLIM_CUSTOMER_SHORT_NAMES = "Slim customer with shorter attribute names"; - private static DecimalFormat LENGTH_FORMATTER = new DecimalFormat("###,###"); - private static DecimalFormat PERCENT_FORMATTER = new DecimalFormat("###"); + private static final String TEST_LABEL_SLIM_CUSTOMER_SHORT_NAMES = "Slim customer with shorter field names"; + private static DecimalFormat LENGTH_FORMATTER = new DecimalFormat("###,###.0"); + private static DecimalFormat PERCENT_FORMATTER = new DecimalFormat("###.0"); private static Customer[] customers; private ObjectMapper mapper; private static int defaultJsonLength; @@ -41,6 +42,9 @@ class JsonOptimizationUnitTest { ObjectMapper oneTimeMapper = new ObjectMapper(); byte[] feedback = oneTimeMapper.writeValueAsBytes(customers); defaultJsonLength = feedback.length; + System.out.println(); + System.out.println("Default JSON length: " + defaultJsonLength); + System.out.println(); } @BeforeEach @@ -63,8 +67,8 @@ class JsonOptimizationUnitTest { @Test void testDefaultNoNull() throws IOException { printBanner(TEST_LABEL_DEFAULT_JSON_NO_NULL); - CustomerNoNull[] defaultNoNull = CustomerNoNull.fromCustomers(customers); - byte[] plainJson = createPlainJson(TEST_LABEL_DEFAULT_JSON_NO_NULL, defaultNoNull); + mapper.setSerializationInclusion(Include.NON_NULL); + byte[] plainJson = createPlainJson(TEST_LABEL_DEFAULT_JSON_NO_NULL, customers); compressJson(TEST_LABEL_DEFAULT_JSON_NO_NULL, plainJson); } @@ -79,8 +83,9 @@ class JsonOptimizationUnitTest { @Test void testShortNamesNoNull() throws IOException { printBanner(TEST_LABEL_SHORT_NAMES_NO_NULL); - CustomerShortNamesNoNull[] shorterOnesNoNull = CustomerShortNamesNoNull.fromCustomers(customers); - byte[] shorterJson = createPlainJson(TEST_LABEL_SHORT_NAMES_NO_NULL, shorterOnesNoNull); + CustomerShortNames[] shorterOnes = CustomerShortNames.fromCustomers(customers); + mapper.setSerializationInclusion(Include.NON_NULL); + byte[] shorterJson = createPlainJson(TEST_LABEL_SHORT_NAMES_NO_NULL, shorterOnes); compressJson(TEST_LABEL_SHORT_NAMES_NO_NULL, shorterJson); } @@ -135,13 +140,15 @@ class JsonOptimizationUnitTest { } void compressJson(String label, byte[] plainJson) throws IOException { - ByteArrayOutputStream outpuStream = new ByteArrayOutputStream(); - GZIPOutputStream gzipStream = new GZIPOutputStream(outpuStream); + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + GZIPOutputStream gzipStream = new GZIPOutputStream(outputStream); gzipStream.write(plainJson); gzipStream.close(); - byte[] gzippedJson = outpuStream.toByteArray(); - double percent = Math.round(gzippedJson.length * 100d / defaultJsonLength); - System.out.println(label + " GZIPped length: " + LENGTH_FORMATTER.format(gzippedJson.length / 1024) + outputStream.close(); + byte[] gzippedJson = outputStream.toByteArray(); + double length = gzippedJson.length / 1024d; + double percent = gzippedJson.length * 100d / defaultJsonLength; + System.out.println(label + " GZIPped length: " + LENGTH_FORMATTER.format(length) + "kB (" + PERCENT_FORMATTER.format(percent) + "%)"); assertTrue(plainJson.length > gzippedJson.length, label + " should be longer than GZIPped data"); } @@ -152,8 +159,9 @@ class JsonOptimizationUnitTest { System.out.println(prettyWritter.writeValueAsString(customers[0])); byte[] feedback = mapper.writeValueAsBytes(customers); - double percent = Math.round(feedback.length * 100d / defaultJsonLength); - System.out.println(label + " length: " + LENGTH_FORMATTER.format(feedback.length / 1024) + double length = feedback.length / 1024d; + double percent = feedback.length * 100d / defaultJsonLength; + System.out.println(label + " length: " + LENGTH_FORMATTER.format(length) + "kB (" + PERCENT_FORMATTER.format(percent) + "%)"); assertTrue(feedback.length > 1, label + " should be there"); From 8695b88a3ea901cdf982f6171a3067e1fb1b4e51 Mon Sep 17 00:00:00 2001 From: Karsten Silz Date: Mon, 7 Sep 2020 12:22:18 +0100 Subject: [PATCH 079/263] BAEL-3326, "Optimizing JSON Schema for production use": Added article to README.md. --- json/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/json/README.md b/json/README.md index 0e50dcfddb..cfee611f4a 100644 --- a/json/README.md +++ b/json/README.md @@ -13,3 +13,4 @@ This module contains articles about JSON. - [Get a Value by Key in a JSONArray](https://www.baeldung.com/java-jsonarray-get-value-by-key) - [Iterating Over an Instance of org.json.JSONObject](https://www.baeldung.com/jsonobject-iteration) - [Escape JSON String in Java](https://www.baeldung.com/java-json-escaping) +- [Reducing JSON Data Size](https://www.baeldung.com/reducing-json-data-size) From f5b4367c1cc0e9802806e966e488a37552a0bf11 Mon Sep 17 00:00:00 2001 From: Loredana Date: Mon, 7 Sep 2020 14:53:22 +0300 Subject: [PATCH 080/263] formatting, remove unneeded dependency --- persistence-modules/spring-data-mongodb/pom.xml | 9 --------- .../src/main/java/com/baeldung/config/MongoConfig.java | 2 +- .../baeldung/transaction/MongoTransactionalLiveTest.java | 2 -- 3 files changed, 1 insertion(+), 12 deletions(-) diff --git a/persistence-modules/spring-data-mongodb/pom.xml b/persistence-modules/spring-data-mongodb/pom.xml index fdcaf1d49b..60e59f5186 100644 --- a/persistence-modules/spring-data-mongodb/pom.xml +++ b/persistence-modules/spring-data-mongodb/pom.xml @@ -24,14 +24,6 @@ mongodb-driver-sync ${mongodb-driver.version} - - - - org.springframework.data - spring-data-releasetrain - ${spring-releasetrain} - pom - org.mongodb @@ -114,7 +106,6 @@ 1.1.3 4.1.0 3.2.0.RELEASE - Lovelace-SR9 4.0.5 diff --git a/persistence-modules/spring-data-mongodb/src/main/java/com/baeldung/config/MongoConfig.java b/persistence-modules/spring-data-mongodb/src/main/java/com/baeldung/config/MongoConfig.java index 6851b5df6e..8036bbbca2 100644 --- a/persistence-modules/spring-data-mongodb/src/main/java/com/baeldung/config/MongoConfig.java +++ b/persistence-modules/spring-data-mongodb/src/main/java/com/baeldung/config/MongoConfig.java @@ -81,7 +81,7 @@ public class MongoConfig extends AbstractMongoClientConfiguration { @Bean MongoTransactionManager transactionManager(MongoDatabaseFactory dbFactory) { - return new MongoTransactionManager(dbFactory); + return new MongoTransactionManager(dbFactory); } } diff --git a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/transaction/MongoTransactionalLiveTest.java b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/transaction/MongoTransactionalLiveTest.java index 6cd9657006..d92296beab 100644 --- a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/transaction/MongoTransactionalLiveTest.java +++ b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/transaction/MongoTransactionalLiveTest.java @@ -2,7 +2,6 @@ package com.baeldung.transaction; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; import java.util.List; @@ -22,7 +21,6 @@ import org.springframework.transaction.annotation.Transactional; import com.baeldung.config.MongoConfig; import com.baeldung.model.User; import com.baeldung.repository.UserRepository; -import com.mongodb.MongoCommandException; /** * From 9c5ed84bd40e660a3a9be21a6f2352f68f49ad31 Mon Sep 17 00:00:00 2001 From: Sampada <46674082+sampada07@users.noreply.github.com> Date: Mon, 7 Sep 2020 21:15:50 +0530 Subject: [PATCH 081/263] JAVA-2422: Merge spring-groovy into spring-boot-groovy (#9970) * JAVA-2422: Moved article to spring-boot-groovy * JAVA-2422: removed module spring-groovy * JAVA-2422: Moved spring-boot-groovy inside spring-boot-modules module * JAVA-2422: Added entry to spring-boot-module's pom * JAVA-2422: main pom changes for module movements * JAVA-2422: Renamed test as it needs the app up and running * JAVA-2422: Renamed test to live as it needs App to be running --- pom.xml | 8 +-- spring-boot-groovy/README.md | 3 - spring-boot-modules/pom.xml | 1 + .../spring-boot-groovy/README.md | 9 +++ .../spring-boot-groovy}/pom.xml | 4 +- .../SpringBootGroovyApplication.groovy | 0 .../controller/TodoController.groovy | 0 .../springwithgroovy/entity/Todo.groovy | 0 .../repository/TodoRepository.groovy | 0 .../service/TodoService.groovy | 0 .../service/impl/TodoServiceImpl.groovy | 0 .../com/baeldung}/groovyconfig/BandsBean.java | 2 +- .../groovyconfig/GroovyBeanConfig.groovy | 2 +- .../groovyconfig/JavaBeanConfig.java | 2 +- .../groovyconfig/JavaPersonBean.java | 2 +- .../java/com/baeldung}/spring_groovy/App.java | 2 +- .../baeldung}/spring_groovy/TestConfig.java | 2 +- .../src/main/resources/application.properties | 0 .../main/resources/groovyContextConfig.groovy | 0 .../src/main/resources/logback.xml | 0 .../src/main/resources/xml-bean-config.xml | 2 +- .../springwithgroovy/TodoAppLiveTest.groovy | 7 +- .../GroovyConfigurationUnitTest.java | 7 +- .../JavaConfigurationUnitTest.java | 5 +- .../XmlConfigurationUnitTest.java | 4 +- .../baeldung}/spring_groovy/AppUnitTest.java | 2 +- spring-groovy/.gitignore | 7 -- spring-groovy/README.md | 7 -- spring-groovy/pom.xml | 67 ------------------- 29 files changed, 39 insertions(+), 106 deletions(-) delete mode 100644 spring-boot-groovy/README.md create mode 100644 spring-boot-modules/spring-boot-groovy/README.md rename {spring-boot-groovy => spring-boot-modules/spring-boot-groovy}/pom.xml (94%) rename {spring-boot-groovy => spring-boot-modules/spring-boot-groovy}/src/main/groovy/com/baeldung/springwithgroovy/SpringBootGroovyApplication.groovy (100%) rename {spring-boot-groovy => spring-boot-modules/spring-boot-groovy}/src/main/groovy/com/baeldung/springwithgroovy/controller/TodoController.groovy (100%) rename {spring-boot-groovy => spring-boot-modules/spring-boot-groovy}/src/main/groovy/com/baeldung/springwithgroovy/entity/Todo.groovy (100%) rename {spring-boot-groovy => spring-boot-modules/spring-boot-groovy}/src/main/groovy/com/baeldung/springwithgroovy/repository/TodoRepository.groovy (100%) rename {spring-boot-groovy => spring-boot-modules/spring-boot-groovy}/src/main/groovy/com/baeldung/springwithgroovy/service/TodoService.groovy (100%) rename {spring-boot-groovy => spring-boot-modules/spring-boot-groovy}/src/main/groovy/com/baeldung/springwithgroovy/service/impl/TodoServiceImpl.groovy (100%) rename {spring-groovy/src/main/java/com/baeldug => spring-boot-modules/spring-boot-groovy/src/main/java/com/baeldung}/groovyconfig/BandsBean.java (89%) rename {spring-groovy/src/main/java/com/baeldug => spring-boot-modules/spring-boot-groovy/src/main/java/com/baeldung}/groovyconfig/GroovyBeanConfig.groovy (90%) rename {spring-groovy/src/main/java/com/baeldug => spring-boot-modules/spring-boot-groovy/src/main/java/com/baeldung}/groovyconfig/JavaBeanConfig.java (93%) rename {spring-groovy/src/main/java/com/baeldug => spring-boot-modules/spring-boot-groovy/src/main/java/com/baeldung}/groovyconfig/JavaPersonBean.java (96%) rename {spring-groovy/src/main/java/com/baeldug => spring-boot-modules/spring-boot-groovy/src/main/java/com/baeldung}/spring_groovy/App.java (80%) rename {spring-groovy/src/main/java/com/baeldug => spring-boot-modules/spring-boot-groovy/src/main/java/com/baeldung}/spring_groovy/TestConfig.java (71%) rename {spring-boot-groovy => spring-boot-modules/spring-boot-groovy}/src/main/resources/application.properties (100%) rename {spring-groovy => spring-boot-modules/spring-boot-groovy}/src/main/resources/groovyContextConfig.groovy (100%) rename {spring-groovy => spring-boot-modules/spring-boot-groovy}/src/main/resources/logback.xml (100%) rename {spring-groovy => spring-boot-modules/spring-boot-groovy}/src/main/resources/xml-bean-config.xml (87%) rename spring-boot-groovy/src/test/groovy/com/baeldung/springwithgroovy/TodoAppUnitTest.groovy => spring-boot-modules/spring-boot-groovy/src/test/groovy/com/baeldung/springwithgroovy/TodoAppLiveTest.groovy (93%) rename {spring-groovy/src/test/java/com/baeldug => spring-boot-modules/spring-boot-groovy/src/test/java/com/baeldung}/groovyconfig/GroovyConfigurationUnitTest.java (90%) rename {spring-groovy/src/test/java/com/baeldug => spring-boot-modules/spring-boot-groovy/src/test/java/com/baeldung}/groovyconfig/JavaConfigurationUnitTest.java (82%) rename {spring-groovy/src/test/java/com/baeldug => spring-boot-modules/spring-boot-groovy/src/test/java/com/baeldung}/groovyconfig/XmlConfigurationUnitTest.java (88%) rename {spring-groovy/src/test/java/com/baeldug => spring-boot-modules/spring-boot-groovy/src/test/java/com/baeldung}/spring_groovy/AppUnitTest.java (94%) delete mode 100644 spring-groovy/.gitignore delete mode 100644 spring-groovy/README.md delete mode 100644 spring-groovy/pom.xml diff --git a/pom.xml b/pom.xml index ffdfe4cffa..a2e09c0f91 100644 --- a/pom.xml +++ b/pom.xml @@ -655,9 +655,7 @@ spring-ejb spring-exceptions - spring-freemarker - - spring-groovy + spring-freemarker spring-integration @@ -1159,9 +1157,7 @@ spring-ejb spring-exceptions - spring-freemarker - - spring-groovy + spring-freemarker spring-integration diff --git a/spring-boot-groovy/README.md b/spring-boot-groovy/README.md deleted file mode 100644 index d2472a11d0..0000000000 --- a/spring-boot-groovy/README.md +++ /dev/null @@ -1,3 +0,0 @@ -### Relevant Articles: - -- [Building a Simple Web Application with Spring Boot and Groovy](https://www.baeldung.com/spring-boot-groovy-web-app) diff --git a/spring-boot-modules/pom.xml b/spring-boot-modules/pom.xml index 109be01db3..527f7dcad8 100644 --- a/spring-boot-modules/pom.xml +++ b/spring-boot-modules/pom.xml @@ -41,6 +41,7 @@ spring-boot-environment spring-boot-exceptions spring-boot-flowable + spring-boot-groovy spring-boot-jasypt spring-boot-keycloak diff --git a/spring-boot-modules/spring-boot-groovy/README.md b/spring-boot-modules/spring-boot-groovy/README.md new file mode 100644 index 0000000000..73edafb9c0 --- /dev/null +++ b/spring-boot-modules/spring-boot-groovy/README.md @@ -0,0 +1,9 @@ +## Spring Boot Groovy + +This module contains articles about Spring with Groovy + + +### Relevant Articles: + +- [Building a Simple Web Application with Spring Boot and Groovy](https://www.baeldung.com/spring-boot-groovy-web-app) +- [Groovy Bean Definitions](https://www.baeldung.com/spring-groovy-beans) \ No newline at end of file diff --git a/spring-boot-groovy/pom.xml b/spring-boot-modules/spring-boot-groovy/pom.xml similarity index 94% rename from spring-boot-groovy/pom.xml rename to spring-boot-modules/spring-boot-groovy/pom.xml index 9ea8d7b2a9..3392532081 100644 --- a/spring-boot-groovy/pom.xml +++ b/spring-boot-modules/spring-boot-groovy/pom.xml @@ -14,7 +14,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 @@ -72,7 +72,7 @@ - com.baeldung.app.SpringBootGroovyApplication + com.baeldung.springwithgroovy.SpringBootGroovyApplication diff --git a/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/SpringBootGroovyApplication.groovy b/spring-boot-modules/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/SpringBootGroovyApplication.groovy similarity index 100% rename from spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/SpringBootGroovyApplication.groovy rename to spring-boot-modules/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/SpringBootGroovyApplication.groovy diff --git a/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/controller/TodoController.groovy b/spring-boot-modules/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/controller/TodoController.groovy similarity index 100% rename from spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/controller/TodoController.groovy rename to spring-boot-modules/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/controller/TodoController.groovy diff --git a/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/entity/Todo.groovy b/spring-boot-modules/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/entity/Todo.groovy similarity index 100% rename from spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/entity/Todo.groovy rename to spring-boot-modules/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/entity/Todo.groovy diff --git a/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/repository/TodoRepository.groovy b/spring-boot-modules/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/repository/TodoRepository.groovy similarity index 100% rename from spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/repository/TodoRepository.groovy rename to spring-boot-modules/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/repository/TodoRepository.groovy diff --git a/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/service/TodoService.groovy b/spring-boot-modules/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/service/TodoService.groovy similarity index 100% rename from spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/service/TodoService.groovy rename to spring-boot-modules/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/service/TodoService.groovy diff --git a/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/service/impl/TodoServiceImpl.groovy b/spring-boot-modules/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/service/impl/TodoServiceImpl.groovy similarity index 100% rename from spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/service/impl/TodoServiceImpl.groovy rename to spring-boot-modules/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/service/impl/TodoServiceImpl.groovy diff --git a/spring-groovy/src/main/java/com/baeldug/groovyconfig/BandsBean.java b/spring-boot-modules/spring-boot-groovy/src/main/java/com/baeldung/groovyconfig/BandsBean.java similarity index 89% rename from spring-groovy/src/main/java/com/baeldug/groovyconfig/BandsBean.java rename to spring-boot-modules/spring-boot-groovy/src/main/java/com/baeldung/groovyconfig/BandsBean.java index 1deba5d2f6..29f143c66c 100644 --- a/spring-groovy/src/main/java/com/baeldug/groovyconfig/BandsBean.java +++ b/spring-boot-modules/spring-boot-groovy/src/main/java/com/baeldung/groovyconfig/BandsBean.java @@ -1,4 +1,4 @@ -package com.baeldug.groovyconfig; +package com.baeldung.groovyconfig; import java.util.ArrayList; import java.util.List; diff --git a/spring-groovy/src/main/java/com/baeldug/groovyconfig/GroovyBeanConfig.groovy b/spring-boot-modules/spring-boot-groovy/src/main/java/com/baeldung/groovyconfig/GroovyBeanConfig.groovy similarity index 90% rename from spring-groovy/src/main/java/com/baeldug/groovyconfig/GroovyBeanConfig.groovy rename to spring-boot-modules/spring-boot-groovy/src/main/java/com/baeldung/groovyconfig/GroovyBeanConfig.groovy index 32a6fedff0..3237226877 100644 --- a/spring-groovy/src/main/java/com/baeldug/groovyconfig/GroovyBeanConfig.groovy +++ b/spring-boot-modules/spring-boot-groovy/src/main/java/com/baeldung/groovyconfig/GroovyBeanConfig.groovy @@ -1,4 +1,4 @@ -package com.baeldug.groovyconfig; +package com.baeldung.groovyconfig; beans { javaPesronBean(JavaPersonBean) { diff --git a/spring-groovy/src/main/java/com/baeldug/groovyconfig/JavaBeanConfig.java b/spring-boot-modules/spring-boot-groovy/src/main/java/com/baeldung/groovyconfig/JavaBeanConfig.java similarity index 93% rename from spring-groovy/src/main/java/com/baeldug/groovyconfig/JavaBeanConfig.java rename to spring-boot-modules/spring-boot-groovy/src/main/java/com/baeldung/groovyconfig/JavaBeanConfig.java index 7c4238ae28..64926f606b 100644 --- a/spring-groovy/src/main/java/com/baeldug/groovyconfig/JavaBeanConfig.java +++ b/spring-boot-modules/spring-boot-groovy/src/main/java/com/baeldung/groovyconfig/JavaBeanConfig.java @@ -1,4 +1,4 @@ -package com.baeldug.groovyconfig; +package com.baeldung.groovyconfig; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-groovy/src/main/java/com/baeldug/groovyconfig/JavaPersonBean.java b/spring-boot-modules/spring-boot-groovy/src/main/java/com/baeldung/groovyconfig/JavaPersonBean.java similarity index 96% rename from spring-groovy/src/main/java/com/baeldug/groovyconfig/JavaPersonBean.java rename to spring-boot-modules/spring-boot-groovy/src/main/java/com/baeldung/groovyconfig/JavaPersonBean.java index db988d4abf..da0b92451e 100644 --- a/spring-groovy/src/main/java/com/baeldug/groovyconfig/JavaPersonBean.java +++ b/spring-boot-modules/spring-boot-groovy/src/main/java/com/baeldung/groovyconfig/JavaPersonBean.java @@ -1,4 +1,4 @@ -package com.baeldug.groovyconfig; +package com.baeldung.groovyconfig; public class JavaPersonBean { diff --git a/spring-groovy/src/main/java/com/baeldug/spring_groovy/App.java b/spring-boot-modules/spring-boot-groovy/src/main/java/com/baeldung/spring_groovy/App.java similarity index 80% rename from spring-groovy/src/main/java/com/baeldug/spring_groovy/App.java rename to spring-boot-modules/spring-boot-groovy/src/main/java/com/baeldung/spring_groovy/App.java index 1df6681c42..2465683c5f 100644 --- a/spring-groovy/src/main/java/com/baeldug/spring_groovy/App.java +++ b/spring-boot-modules/spring-boot-groovy/src/main/java/com/baeldung/spring_groovy/App.java @@ -1,4 +1,4 @@ -package com.baeldug.spring_groovy; +package com.baeldung.spring_groovy; /** * Hello world! diff --git a/spring-groovy/src/main/java/com/baeldug/spring_groovy/TestConfig.java b/spring-boot-modules/spring-boot-groovy/src/main/java/com/baeldung/spring_groovy/TestConfig.java similarity index 71% rename from spring-groovy/src/main/java/com/baeldug/spring_groovy/TestConfig.java rename to spring-boot-modules/spring-boot-groovy/src/main/java/com/baeldung/spring_groovy/TestConfig.java index 474216de4e..04ff38c475 100644 --- a/spring-groovy/src/main/java/com/baeldug/spring_groovy/TestConfig.java +++ b/spring-boot-modules/spring-boot-groovy/src/main/java/com/baeldung/spring_groovy/TestConfig.java @@ -1,4 +1,4 @@ -package com.baeldug.spring_groovy; +package com.baeldung.spring_groovy; import org.springframework.stereotype.Component; diff --git a/spring-boot-groovy/src/main/resources/application.properties b/spring-boot-modules/spring-boot-groovy/src/main/resources/application.properties similarity index 100% rename from spring-boot-groovy/src/main/resources/application.properties rename to spring-boot-modules/spring-boot-groovy/src/main/resources/application.properties diff --git a/spring-groovy/src/main/resources/groovyContextConfig.groovy b/spring-boot-modules/spring-boot-groovy/src/main/resources/groovyContextConfig.groovy similarity index 100% rename from spring-groovy/src/main/resources/groovyContextConfig.groovy rename to spring-boot-modules/spring-boot-groovy/src/main/resources/groovyContextConfig.groovy diff --git a/spring-groovy/src/main/resources/logback.xml b/spring-boot-modules/spring-boot-groovy/src/main/resources/logback.xml similarity index 100% rename from spring-groovy/src/main/resources/logback.xml rename to spring-boot-modules/spring-boot-groovy/src/main/resources/logback.xml diff --git a/spring-groovy/src/main/resources/xml-bean-config.xml b/spring-boot-modules/spring-boot-groovy/src/main/resources/xml-bean-config.xml similarity index 87% rename from spring-groovy/src/main/resources/xml-bean-config.xml rename to spring-boot-modules/spring-boot-groovy/src/main/resources/xml-bean-config.xml index 3b880bbd70..b26f28f7b1 100644 --- a/spring-groovy/src/main/resources/xml-bean-config.xml +++ b/spring-boot-modules/spring-boot-groovy/src/main/resources/xml-bean-config.xml @@ -2,7 +2,7 @@ - + diff --git a/spring-boot-groovy/src/test/groovy/com/baeldung/springwithgroovy/TodoAppUnitTest.groovy b/spring-boot-modules/spring-boot-groovy/src/test/groovy/com/baeldung/springwithgroovy/TodoAppLiveTest.groovy similarity index 93% rename from spring-boot-groovy/src/test/groovy/com/baeldung/springwithgroovy/TodoAppUnitTest.groovy rename to spring-boot-modules/spring-boot-groovy/src/test/groovy/com/baeldung/springwithgroovy/TodoAppLiveTest.groovy index bf8b0ff27f..6ae6ffcd73 100644 --- a/spring-boot-groovy/src/test/groovy/com/baeldung/springwithgroovy/TodoAppUnitTest.groovy +++ b/spring-boot-modules/spring-boot-groovy/src/test/groovy/com/baeldung/springwithgroovy/TodoAppLiveTest.groovy @@ -17,8 +17,11 @@ import com.baeldung.springwithgroovy.entity.Todo import io.restassured.RestAssured import io.restassured.response.Response -class TodoAppUnitTest { - static API_ROOT = 'http://localhost:8081/todo' +// This test requires the com.baeldung.springwithgroovy.SpringBootGroovyApplication to be up +// For that, run the maven build - spring-boot:run on the module + +class TodoAppLiveTest { + static API_ROOT = 'http://localhost:8080/todo' static readingTodoId static writingTodoId diff --git a/spring-groovy/src/test/java/com/baeldug/groovyconfig/GroovyConfigurationUnitTest.java b/spring-boot-modules/spring-boot-groovy/src/test/java/com/baeldung/groovyconfig/GroovyConfigurationUnitTest.java similarity index 90% rename from spring-groovy/src/test/java/com/baeldug/groovyconfig/GroovyConfigurationUnitTest.java rename to spring-boot-modules/spring-boot-groovy/src/test/java/com/baeldung/groovyconfig/GroovyConfigurationUnitTest.java index dbefba5ba5..bd46ded977 100644 --- a/spring-groovy/src/test/java/com/baeldug/groovyconfig/GroovyConfigurationUnitTest.java +++ b/spring-boot-modules/spring-boot-groovy/src/test/java/com/baeldung/groovyconfig/GroovyConfigurationUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldug.groovyconfig; +package com.baeldung.groovyconfig; import static org.junit.Assert.assertEquals; @@ -7,10 +7,13 @@ import java.io.File; import org.junit.Test; import org.springframework.context.support.GenericGroovyApplicationContext; +import com.baeldung.groovyconfig.BandsBean; +import com.baeldung.groovyconfig.JavaPersonBean; + public class GroovyConfigurationUnitTest { private static final String FILE_NAME = "GroovyBeanConfig.groovy"; - private static final String FILE_PATH = "src/main/java/com/baeldug/groovyconfig/"; + private static final String FILE_PATH = "src/main/java/com/baeldung/groovyconfig/"; @Test public void whenGroovyConfig_thenCorrectPerson() throws Exception { diff --git a/spring-groovy/src/test/java/com/baeldug/groovyconfig/JavaConfigurationUnitTest.java b/spring-boot-modules/spring-boot-groovy/src/test/java/com/baeldung/groovyconfig/JavaConfigurationUnitTest.java similarity index 82% rename from spring-groovy/src/test/java/com/baeldug/groovyconfig/JavaConfigurationUnitTest.java rename to spring-boot-modules/spring-boot-groovy/src/test/java/com/baeldung/groovyconfig/JavaConfigurationUnitTest.java index c1e16f1b62..2ab1998853 100644 --- a/spring-groovy/src/test/java/com/baeldug/groovyconfig/JavaConfigurationUnitTest.java +++ b/spring-boot-modules/spring-boot-groovy/src/test/java/com/baeldung/groovyconfig/JavaConfigurationUnitTest.java @@ -1,10 +1,13 @@ -package com.baeldug.groovyconfig; +package com.baeldung.groovyconfig; import static org.junit.Assert.assertEquals; import org.junit.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import com.baeldung.groovyconfig.JavaBeanConfig; +import com.baeldung.groovyconfig.JavaPersonBean; + public class JavaConfigurationUnitTest { @Test diff --git a/spring-groovy/src/test/java/com/baeldug/groovyconfig/XmlConfigurationUnitTest.java b/spring-boot-modules/spring-boot-groovy/src/test/java/com/baeldung/groovyconfig/XmlConfigurationUnitTest.java similarity index 88% rename from spring-groovy/src/test/java/com/baeldug/groovyconfig/XmlConfigurationUnitTest.java rename to spring-boot-modules/spring-boot-groovy/src/test/java/com/baeldung/groovyconfig/XmlConfigurationUnitTest.java index b8d341ee39..aa9f3bd8f7 100644 --- a/spring-groovy/src/test/java/com/baeldug/groovyconfig/XmlConfigurationUnitTest.java +++ b/spring-boot-modules/spring-boot-groovy/src/test/java/com/baeldung/groovyconfig/XmlConfigurationUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldug.groovyconfig; +package com.baeldung.groovyconfig; import static org.junit.Assert.*; @@ -6,6 +6,8 @@ import org.junit.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; +import com.baeldung.groovyconfig.JavaPersonBean; + public class XmlConfigurationUnitTest { @Test diff --git a/spring-groovy/src/test/java/com/baeldug/spring_groovy/AppUnitTest.java b/spring-boot-modules/spring-boot-groovy/src/test/java/com/baeldung/spring_groovy/AppUnitTest.java similarity index 94% rename from spring-groovy/src/test/java/com/baeldug/spring_groovy/AppUnitTest.java rename to spring-boot-modules/spring-boot-groovy/src/test/java/com/baeldung/spring_groovy/AppUnitTest.java index 3d8fa3e2d8..9702e98ab8 100644 --- a/spring-groovy/src/test/java/com/baeldug/spring_groovy/AppUnitTest.java +++ b/spring-boot-modules/spring-boot-groovy/src/test/java/com/baeldung/spring_groovy/AppUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldug.spring_groovy; +package com.baeldung.spring_groovy; import junit.framework.Test; import junit.framework.TestCase; diff --git a/spring-groovy/.gitignore b/spring-groovy/.gitignore deleted file mode 100644 index c17c227305..0000000000 --- a/spring-groovy/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -/target/ -/project/ -.classpath -.settings -.eclipse -.idea -.project diff --git a/spring-groovy/README.md b/spring-groovy/README.md deleted file mode 100644 index c3bb5636ba..0000000000 --- a/spring-groovy/README.md +++ /dev/null @@ -1,7 +0,0 @@ -## Spring Groovy - -This module contains articles about Spring with Groovy - -## Relevant Articles: - -- [Groovy Bean Definitions](https://www.baeldung.com/spring-groovy-beans) diff --git a/spring-groovy/pom.xml b/spring-groovy/pom.xml deleted file mode 100644 index ef5613adf6..0000000000 --- a/spring-groovy/pom.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - 4.0.0 - com.baeldug - spring-groovy - 0.0.1-SNAPSHOT - spring-groovy - jar - http://maven.apache.org - - - com.baeldung - parent-spring-4 - 0.0.1-SNAPSHOT - ../parent-spring-4 - - - - - org.springframework.integration - spring-integration-groovy - ${spring-integration-groovy.version} - - - org.codehaus.groovy - groovy-all - ${groovy-all.version} - - - - - - - maven-compiler-plugin - ${maven-compiler-plugin.version} - - groovy-eclipse-compiler - true - ${java.version} - ${java.version} - ${project.build.sourceEncoding} - - - - org.codehaus.groovy - groovy-eclipse-compiler - ${groovy-eclipse-compiler.version} - - - org.codehaus.groovy - groovy-eclipse-batch - ${groovy-eclipse-batch.version} - - - - - - - - 2.9.2-01 - 2.4.3-01 - 4.3.7.RELEASE - 2.4.12 - - - From 30e4e277e0c6de6c1b43a507787e20fe4858924b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Dupire?= Date: Mon, 7 Sep 2020 18:02:25 +0200 Subject: [PATCH 082/263] [JAVA-2427] Migrated spring-drools to parent-spring-5 (#9964) * [JAVA-2427] Migrated spring-drools to parent-spring-5 * [JAVA-2427] Added spring dependencies so that they all have the last version --- spring-drools/pom.xml | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/spring-drools/pom.xml b/spring-drools/pom.xml index 5adef4b2a9..8b105158ec 100644 --- a/spring-drools/pom.xml +++ b/spring-drools/pom.xml @@ -8,8 +8,9 @@ com.baeldung - parent-modules - 1.0.0-SNAPSHOT + parent-spring-5 + 0.0.1-SNAPSHOT + ../parent-spring-5 @@ -40,17 +41,40 @@ kie-spring ${drools-version} + + org.springframework + spring-beans + ${spring.version} + + + org.springframework + spring-context + ${spring.version} + + + org.springframework + spring-aop + ${spring.version} + + + org.springframework + spring-expression + ${spring.version} + + + org.springframework + spring-tx + ${spring.version} + org.springframework spring-test - ${spring-framework.version} + ${spring.version} test 7.0.0.Final - 4.3.3.RELEASE - \ No newline at end of file From b7813034ea4b1d9eaf218f2dfbfda67097c50970 Mon Sep 17 00:00:00 2001 From: fdpro Date: Tue, 8 Sep 2020 11:26:57 +0200 Subject: [PATCH 083/263] [JAVA-2540] Deactivate frontend-maven-plugin when using default-first or default-second profile --- .../spring-security-web-react/pom.xml | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/spring-security-modules/spring-security-web-react/pom.xml b/spring-security-modules/spring-security-web-react/pom.xml index d0ca6f8c8d..459793f496 100644 --- a/spring-security-modules/spring-security-web-react/pom.xml +++ b/spring-security-modules/spring-security-web-react/pom.xml @@ -163,6 +163,63 @@ + + + default-first + + + + + com.github.eirslett + frontend-maven-plugin + + + + install node and npm + none + + + npm install + none + + + npm run build + none + + + + + + + + default-second + + + + + com.github.eirslett + frontend-maven-plugin + + + + install node and npm + none + + + npm install + none + + + npm run build + none + + + + + + + + 4.3.6.RELEASE From 98bdb5df3650304912a8731e925a5a4c91bf148c Mon Sep 17 00:00:00 2001 From: fdpro Date: Tue, 8 Sep 2020 11:53:26 +0200 Subject: [PATCH 084/263] [JAVA-2429] Migrated spring-data-solr module to parent-boot-5 --- persistence-modules/spring-data-solr/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/persistence-modules/spring-data-solr/pom.xml b/persistence-modules/spring-data-solr/pom.xml index 9d96c75082..5386c4f9e1 100644 --- a/persistence-modules/spring-data-solr/pom.xml +++ b/persistence-modules/spring-data-solr/pom.xml @@ -8,9 +8,9 @@ com.baeldung - parent-spring-4 + parent-spring-5 0.0.1-SNAPSHOT - ../../parent-spring-4 + ../../parent-spring-5 From 760d54eb438820d73cfe99d7db03a4c9a346717b Mon Sep 17 00:00:00 2001 From: fdpro Date: Tue, 8 Sep 2020 11:48:05 +0200 Subject: [PATCH 085/263] [JAVA-2430] Migrated spring-data-cassandra to parent-boot-5 --- .../spring-data-cassandra/pom.xml | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/persistence-modules/spring-data-cassandra/pom.xml b/persistence-modules/spring-data-cassandra/pom.xml index 0f0aae4ebf..b44324dc46 100644 --- a/persistence-modules/spring-data-cassandra/pom.xml +++ b/persistence-modules/spring-data-cassandra/pom.xml @@ -8,9 +8,9 @@ com.baeldung - parent-spring-4 + parent-spring-5 0.0.1-SNAPSHOT - ../../parent-spring-4 + ../../parent-spring-5 @@ -30,6 +30,31 @@ + + org.springframework + spring-beans + ${spring.version} + + + org.springframework + spring-context + ${spring.version} + + + org.springframework + spring-aop + ${spring.version} + + + org.springframework + spring-expression + ${spring.version} + + + org.springframework + spring-tx + ${spring.version} + org.springframework spring-test From 924517d16369041874fe5feaf9468b2f31e2400d Mon Sep 17 00:00:00 2001 From: Ricardo Caldas Date: Tue, 8 Sep 2020 12:11:29 -0300 Subject: [PATCH 086/263] BAEL-2503 Add a new section in Lombok builder article --- .../builder/RequiredFieldAnnotation.java | 19 ++++++++++++++++++ .../lombok/builder/RequiredFieldOverload.java | 20 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 lombok/src/main/java/com/baeldung/lombok/builder/RequiredFieldAnnotation.java create mode 100644 lombok/src/main/java/com/baeldung/lombok/builder/RequiredFieldOverload.java diff --git a/lombok/src/main/java/com/baeldung/lombok/builder/RequiredFieldAnnotation.java b/lombok/src/main/java/com/baeldung/lombok/builder/RequiredFieldAnnotation.java new file mode 100644 index 0000000000..f09f59baea --- /dev/null +++ b/lombok/src/main/java/com/baeldung/lombok/builder/RequiredFieldAnnotation.java @@ -0,0 +1,19 @@ +package com.baeldung.lombok.builder; + +import lombok.Builder; +import lombok.NonNull; + +@Builder(builderMethodName = "hiddenBuilder") +public class RequiredFieldAnnotation { + @NonNull + private String name; + private String description; + + public static RequiredFieldAnnotationBuilder builder(String name) { + return hiddenBuilder().name(name); + } + + public void example() { + RequiredFieldAnnotation.builder("NameField").description("Field Description").build(); + } +} diff --git a/lombok/src/main/java/com/baeldung/lombok/builder/RequiredFieldOverload.java b/lombok/src/main/java/com/baeldung/lombok/builder/RequiredFieldOverload.java new file mode 100644 index 0000000000..6b123e3cbe --- /dev/null +++ b/lombok/src/main/java/com/baeldung/lombok/builder/RequiredFieldOverload.java @@ -0,0 +1,20 @@ +package com.baeldung.lombok.builder; + +import lombok.Builder; +import lombok.NonNull; + +@Builder +public class RequiredFieldOverload { + @NonNull + private String name; + private String description; + + public static RequiredFieldOverloadBuilder builder(String name) { + return new RequiredFieldOverloadBuilder().name(name); + } + + public void example() { + RequiredFieldAnnotation.builder("NameField").description("Field Description").build(); + } + +} From b331b1779ffbc6fdb004333d212f314c4a2c993d Mon Sep 17 00:00:00 2001 From: akeshri Date: Tue, 8 Sep 2020 21:04:43 +0530 Subject: [PATCH 087/263] first pair code --- .../mapfirstpair/MapFirstPairService.java | 17 +++ .../mapfirstpair/MapFirstPairServiceImpl.java | 40 ++++++ .../MapFirstPairServiceUnitTest.java | 125 ++++++++++++++++++ hexagonal-architecture/README.md | 17 --- hexagonal-architecture/pom.xml | 48 ------- .../baeldung/hexagonal/architecture/App.java | 16 --- .../hexagonal/architecture/ConsoleApp.java | 50 ------- .../controller/ProductController.java | 55 -------- .../architecture/dtos/ProductDto.java | 72 ---------- .../hexagonal/architecture/model/Product.java | 85 ------------ .../repository/ProductRepository.java | 14 -- .../architecture/service/ProductService.java | 21 --- .../service/ProductServiceImpl.java | 44 ------ .../resources/application-batch.properties | 9 -- .../resources/application-test.properties | 8 -- .../src/main/resources/application.properties | 8 -- .../src/main/resources/db/PRODUCT.sql | 9 -- .../service/ProductServiceTest.java | 43 ------ 18 files changed, 182 insertions(+), 499 deletions(-) create mode 100644 core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/mapfirstpair/MapFirstPairService.java create mode 100644 core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/mapfirstpair/MapFirstPairServiceImpl.java create mode 100644 core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/mapfirstpair/MapFirstPairServiceUnitTest.java delete mode 100644 hexagonal-architecture/README.md delete mode 100644 hexagonal-architecture/pom.xml delete mode 100644 hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/App.java delete mode 100644 hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/ConsoleApp.java delete mode 100644 hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/controller/ProductController.java delete mode 100644 hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/dtos/ProductDto.java delete mode 100644 hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/model/Product.java delete mode 100644 hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/repository/ProductRepository.java delete mode 100644 hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/service/ProductService.java delete mode 100644 hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/service/ProductServiceImpl.java delete mode 100644 hexagonal-architecture/src/main/resources/application-batch.properties delete mode 100644 hexagonal-architecture/src/main/resources/application-test.properties delete mode 100644 hexagonal-architecture/src/main/resources/application.properties delete mode 100644 hexagonal-architecture/src/main/resources/db/PRODUCT.sql delete mode 100644 hexagonal-architecture/src/test/java/com/baeldung/hexagonal/architecture/service/ProductServiceTest.java diff --git a/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/mapfirstpair/MapFirstPairService.java b/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/mapfirstpair/MapFirstPairService.java new file mode 100644 index 0000000000..5d3c4fac32 --- /dev/null +++ b/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/mapfirstpair/MapFirstPairService.java @@ -0,0 +1,17 @@ +/** + * + */ +package com.baeldung.collections.mapfirstpair; + +import java.util.Map; + +/** + * @author ASHWINI + * + */ +public interface MapFirstPairService { + + Map.Entry getFirstPairUsingIterator(Map map); + + Map.Entry getFirstPairUsingStream(Map map); +} diff --git a/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/mapfirstpair/MapFirstPairServiceImpl.java b/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/mapfirstpair/MapFirstPairServiceImpl.java new file mode 100644 index 0000000000..aff6430216 --- /dev/null +++ b/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/mapfirstpair/MapFirstPairServiceImpl.java @@ -0,0 +1,40 @@ +/** + * + */ +package com.baeldung.collections.mapfirstpair; + +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +/** + * @author ASHWINI + * + */ +public class MapFirstPairServiceImpl implements MapFirstPairService { + + public Map.Entry getFirstPairUsingIterator(Map map) { + if (map == null || map.size() == 0) + return null; + + Iterator> iterator = map.entrySet() + .iterator(); + + if (iterator.hasNext()) + return iterator.next(); + + return null; + } + + public Map.Entry getFirstPairUsingStream(Map map) { + if (map == null || map.size() == 0) + return null; + + Set> entrySet = map.entrySet(); + + return entrySet.stream() + .findFirst() + .get(); + } + +} \ No newline at end of file diff --git a/core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/mapfirstpair/MapFirstPairServiceUnitTest.java b/core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/mapfirstpair/MapFirstPairServiceUnitTest.java new file mode 100644 index 0000000000..56e293ffc5 --- /dev/null +++ b/core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/mapfirstpair/MapFirstPairServiceUnitTest.java @@ -0,0 +1,125 @@ +package com.baeldung.collections.mapfirstpair; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +import java.util.AbstractMap; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +public class MapFirstPairServiceUnitTest { + + private MapFirstPairService mapFirstPairService; + + @Before + public void Setup() { + + mapFirstPairService = new MapFirstPairServiceImpl(); + } + + private void populateMapValues(Map map) { + if (map != null) { + map.put(5, "A"); + map.put(1, "B"); + map.put(2, "C"); + } + } + + @Test + public void whenUsingIteratorForHashMap() { + Map hashMap = new HashMap<>(); + populateMapValues(hashMap); + + Map.Entry actualValue = mapFirstPairService.getFirstPairUsingIterator(hashMap); + Map.Entry expectedValue = new AbstractMap.SimpleEntry(1, "B"); + Map.Entry pairInsertedFirst = new AbstractMap.SimpleEntry(5, "A"); + + assertEquals(expectedValue, actualValue); + assertNotEquals(pairInsertedFirst, actualValue); + } + + @Test + public void whenUsingStreamForHashMap() { + Map hashMap = new HashMap<>(); + populateMapValues(hashMap); + Map.Entry actualValue = mapFirstPairService.getFirstPairUsingStream(hashMap); + Map.Entry expectedValue = new AbstractMap.SimpleEntry(1, "B"); + Map.Entry pairInsertedFirst = new AbstractMap.SimpleEntry(5, "A"); + + assertEquals(expectedValue, actualValue); + assertNotEquals(pairInsertedFirst, actualValue); + } + + @Test + public void whenUsingIteratorForLinkedHashMap() { + Map linkedHashMap = new LinkedHashMap<>(); + populateMapValues(linkedHashMap); + Map.Entry actualValue = mapFirstPairService.getFirstPairUsingIterator(linkedHashMap); + Map.Entry expectedValue = new AbstractMap.SimpleEntry(5, "A"); + + assertEquals(expectedValue, actualValue); + } + + @Test + public void whenUsingStreamForLinkedHashMap() { + Map linkedHashMap = new LinkedHashMap<>(); + populateMapValues(linkedHashMap); + + Map.Entry actualValue = mapFirstPairService.getFirstPairUsingStream(linkedHashMap); + Map.Entry expectedValue = new AbstractMap.SimpleEntry(5, "A"); + + assertEquals(expectedValue, actualValue); + } + + @Test + public void whenAddedAnElementInHashMap_thenFirstPairChangedUsingIterator() { + Map hashMap = new HashMap<>(); + populateMapValues(hashMap); + + hashMap.put(0, "D"); + Map.Entry actualValue = mapFirstPairService.getFirstPairUsingIterator(hashMap); + Map.Entry expectedValue = new AbstractMap.SimpleEntry(0, "D"); + + assertEquals(expectedValue, actualValue); + } + + @Test + public void whenAddedAnElementInHashMap_thenFirstPairChangedUsingStream() { + Map hashMap = new HashMap<>(); + populateMapValues(hashMap); + + hashMap.put(0, "D"); + Map.Entry actualValue = mapFirstPairService.getFirstPairUsingStream(hashMap); + Map.Entry expectedValue = new AbstractMap.SimpleEntry(0, "D"); + + assertEquals(expectedValue, actualValue); + } + + @Test + public void whenAddedAnElementInLinkedHashMap_thenFirstPairRemainUnchangedUsingIterator() { + Map linkedHashMap = new LinkedHashMap<>(); + populateMapValues(linkedHashMap); + + linkedHashMap.put(0, "D"); + Map.Entry actualValue = mapFirstPairService.getFirstPairUsingIterator(linkedHashMap); + Map.Entry expectedValue = new AbstractMap.SimpleEntry(5, "A"); + + assertEquals(expectedValue, actualValue); + } + + @Test + public void whenAddedAnElementInLinkedHashMap_thenFirstPairRemainUnchangedUsingStream() { + Map linkedHashMap = new LinkedHashMap<>(); + populateMapValues(linkedHashMap); + + linkedHashMap.put(0, "D"); + Map.Entry actualValue = mapFirstPairService.getFirstPairUsingStream(linkedHashMap); + Map.Entry expectedValue = new AbstractMap.SimpleEntry(5, "A"); + + assertEquals(expectedValue, actualValue); + } +} diff --git a/hexagonal-architecture/README.md b/hexagonal-architecture/README.md deleted file mode 100644 index 4dd10368e0..0000000000 --- a/hexagonal-architecture/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# Hexagonal Architecture -A quick and practical example of Hexagonal Architecture using Spring boot. - -This application is using h2 database,which can be accessible http:/localhost:8080/h2 - -Main Application schema : hexagonal - -Test Application Schema : hexagonal_test - -1. Rest Api : execute [App](https://github.com/akeshri/tutorials/blob/master/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/App.java) - - Get All products : http://localhost:8080/api/v1/product/all - - Get product by id : http://localhost:8080/api/v1/product/{productId} - - Add a product : http://localhost:8080/api/v1/product/add - For more detail refer [ProductController](https://github.com/akeshri/tutorials/blob/master/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/controller/ProductController.java) - -2. Batch processing : We need to configure active profile as batch i.e. -Dspring.profiles.active=batch and execute [ConsoleApp](https://github.com/akeshri/tutorials/blob/master/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/ConsoleApp.java) -3. Test case : [ProductServiceTest](https://github.com/akeshri/tutorials/blob/master/hexagonal-architecture/src/test/java/com/baeldung/hexagonal/architecture/service/ProductServiceTest.java) diff --git a/hexagonal-architecture/pom.xml b/hexagonal-architecture/pom.xml deleted file mode 100644 index d014617639..0000000000 --- a/hexagonal-architecture/pom.xml +++ /dev/null @@ -1,48 +0,0 @@ - - 4.0.0 - - com.article - hexagonal-architecture - 0.0.1-SNAPSHOT - jar - - org.springframework.boot - spring-boot-starter-parent - 1.3.1.RELEASE - - - hexagonal-architecture - http://maven.apache.org - - - UTF-8 - 1.8 - 1.8 - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-data-jpa - - - com.h2database - h2 - - - org.springframework.boot - spring-boot-starter-test - test - - - com.fasterxml.jackson.dataformat - jackson-dataformat-csv - - - diff --git a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/App.java b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/App.java deleted file mode 100644 index 29dbec470f..0000000000 --- a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/App.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.baeldung.hexagonal.architecture; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * @author AshwiniKeshri - * - */ - -@SpringBootApplication -public class App { - public static void main(String[] args) { - SpringApplication.run(App.class, args); - } -} diff --git a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/ConsoleApp.java b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/ConsoleApp.java deleted file mode 100644 index 6aef791893..0000000000 --- a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/ConsoleApp.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.baeldung.hexagonal.architecture; - -import java.io.File; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.CommandLineRunner; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration; -import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration; - -import com.baeldung.hexagonal.architecture.model.Product; -import com.baeldung.hexagonal.architecture.service.ProductService; -import com.fasterxml.jackson.dataformat.csv.CsvMapper; -import com.fasterxml.jackson.dataformat.csv.CsvSchema; - -/** - * @author AshwiniKeshri - * - */ - -@SpringBootApplication(exclude = { EmbeddedServletContainerAutoConfiguration.class, WebMvcAutoConfiguration.class }) -public class ConsoleApp implements CommandLineRunner { - @Autowired - private ProductService productService; - - public static void main(String[] args) { - SpringApplication.run(ConsoleApp.class, args); - } - - @Override - public void run(String... args) throws Exception { - String filePath = ""; - if (args != null && args.length == 2 && "Product".equalsIgnoreCase(args[0]) && (filePath = args[1]).length() > 0) { - File sourceFile = new File(filePath); - if (sourceFile.exists()) { - CsvMapper mapper = new CsvMapper(); - List products = mapper.readerFor(Product.class) - .with(CsvSchema.emptySchema() - .withHeader()) - . readValues(sourceFile) - .readAll(); - productService.saveAll(products); - } - - } - - } -} diff --git a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/controller/ProductController.java b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/controller/ProductController.java deleted file mode 100644 index f54d3268df..0000000000 --- a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/controller/ProductController.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.baeldung.hexagonal.architecture.controller; - -import java.util.List; -import java.util.stream.Collectors; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -import com.baeldung.hexagonal.architecture.dtos.ProductDto; -import com.baeldung.hexagonal.architecture.model.Product; -import com.baeldung.hexagonal.architecture.service.ProductService; - -/** - * @author AshwiniKeshri - * - */ - -@RestController -@RequestMapping("api/v1/product") -public class ProductController { - - @Autowired - private ProductService productService; - - @RequestMapping(value = "/all", method = RequestMethod.GET) - public List list() { - return productService.findAll() - .stream() - .map(p -> new ProductDto(p)) - .collect(Collectors.toList()); - } - - @RequestMapping(value = "/{productId}", method = RequestMethod.GET) - public ProductDto get(@PathVariable long productId) { - Product p = productService.findById(productId); - return p != null ? new ProductDto(p) : null; - } - - @RequestMapping(value = "/add", method = RequestMethod.POST) - public ProductDto create(@RequestBody ProductDto product) { - Product p = new Product(); - p.setDescription(product.getDescription()); - p.setName(product.getName()); - p.setPrice(product.getPrice()); - p.setQuantity(product.getQuantity()); - Long id = productService.create(p); - product.setId(id); - return product; - } - -} diff --git a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/dtos/ProductDto.java b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/dtos/ProductDto.java deleted file mode 100644 index 51692f56aa..0000000000 --- a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/dtos/ProductDto.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.baeldung.hexagonal.architecture.dtos; - -import com.baeldung.hexagonal.architecture.model.Product; - -/** - * @author AshwiniKeshri - * - */ -public class ProductDto { - - private Long id; - - private String name; - - private Long quantity; - - private Double price; - - private String description; - - public ProductDto() { - } - - public ProductDto(Product product) { - this.description = product.getDescription(); - this.id = product.getId(); - this.name = product.getName(); - this.price = product.getPrice(); - this.quantity = product.getQuantity(); - } - - 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 Long getQuantity() { - return quantity; - } - - public void setQuantity(Long quantity) { - this.quantity = quantity; - } - - public Double getPrice() { - return price; - } - - public void setPrice(Double price) { - this.price = price; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - -} diff --git a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/model/Product.java b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/model/Product.java deleted file mode 100644 index 697ff68b50..0000000000 --- a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/model/Product.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * - */ -package com.baeldung.hexagonal.architecture.model; - -import java.io.Serializable; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; - -/** - * @author AshwiniKeshri - * - */ - -@Entity -@Table(name = "PRODUCT") -public class Product implements Serializable { - - /** - * - */ - private static final long serialVersionUID = 4000353732860709995L; - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Long id; - - @Column(name = "NAME") - private String name; - - @Column(name = "QUANTITY") - private Long quantity; - - @Column(name = "PRICE") - private Double price; - - @Column(name = "DESCRIPTION") - private String description; - - 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 Long getQuantity() { - return quantity; - } - - public void setQuantity(Long quantity) { - this.quantity = quantity > 0 ? quantity : 0; - } - - public Double getPrice() { - return price; - } - - public void setPrice(Double price) { - this.price = price == null ? 0.0 : price; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - -} diff --git a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/repository/ProductRepository.java b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/repository/ProductRepository.java deleted file mode 100644 index ec50e86dc3..0000000000 --- a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/repository/ProductRepository.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.baeldung.hexagonal.architecture.repository; - -import org.springframework.data.jpa.repository.JpaRepository; - -import com.baeldung.hexagonal.architecture.model.Product; - -/** - * @author AshwiniKeshri - * - */ - -public interface ProductRepository extends JpaRepository { - -} diff --git a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/service/ProductService.java b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/service/ProductService.java deleted file mode 100644 index 4844723140..0000000000 --- a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/service/ProductService.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.baeldung.hexagonal.architecture.service; - -import java.util.List; - -import com.baeldung.hexagonal.architecture.model.Product; - -/** - * @author AshwiniKeshri - * - */ - -public interface ProductService { - - List findAll(); - - Product findById(long id); - - Long create(Product product); - - void saveAll(List products); -} diff --git a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/service/ProductServiceImpl.java b/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/service/ProductServiceImpl.java deleted file mode 100644 index e2d182a954..0000000000 --- a/hexagonal-architecture/src/main/java/com/baeldung/hexagonal/architecture/service/ProductServiceImpl.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.baeldung.hexagonal.architecture.service; - -import java.util.List; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.baeldung.hexagonal.architecture.model.Product; -import com.baeldung.hexagonal.architecture.repository.ProductRepository; - -/** - * @author AshwiniKeshri - * - */ - -@Service -public class ProductServiceImpl implements ProductService { - - private Logger logger = LoggerFactory.getLogger(ProductServiceImpl.class); - - @Autowired - private ProductRepository productRepository; - - public List findAll() { - return productRepository.findAll(); - } - - public Product findById(long id) { - return productRepository.findOne(id); - } - - public Long create(Product product) { - product = productRepository.saveAndFlush(product); - return product.getId(); - } - - @Override - public void saveAll(List products) { - productRepository.save(products); - } - -} diff --git a/hexagonal-architecture/src/main/resources/application-batch.properties b/hexagonal-architecture/src/main/resources/application-batch.properties deleted file mode 100644 index 8c83d19f74..0000000000 --- a/hexagonal-architecture/src/main/resources/application-batch.properties +++ /dev/null @@ -1,9 +0,0 @@ -spring.main.web-environment=false -spring.jpa.hibernate.ddl-auto=false; -spring.h2.console.enabled=true -spring.h2.console.path=/h2 - -spring.datasource.url=jdbc:h2:file:~/hexagonal -spring.datasource.username=sa -spring.datasource.password= -spring.datasource.driver-class-name=org.h2.Driver \ No newline at end of file diff --git a/hexagonal-architecture/src/main/resources/application-test.properties b/hexagonal-architecture/src/main/resources/application-test.properties deleted file mode 100644 index 701313a878..0000000000 --- a/hexagonal-architecture/src/main/resources/application-test.properties +++ /dev/null @@ -1,8 +0,0 @@ -spring.jpa.hibernate.ddl-auto=false; -spring.h2.console.enabled=true -spring.h2.console.path=/h2 - -spring.datasource.url=jdbc:h2:file:~/hexagonal_test -spring.datasource.username=sa -spring.datasource.password= -spring.datasource.driver-class-name=org.h2.Driver \ No newline at end of file diff --git a/hexagonal-architecture/src/main/resources/application.properties b/hexagonal-architecture/src/main/resources/application.properties deleted file mode 100644 index 14c80a1af4..0000000000 --- a/hexagonal-architecture/src/main/resources/application.properties +++ /dev/null @@ -1,8 +0,0 @@ -spring.jpa.hibernate.ddl-auto=false; -spring.h2.console.enabled=true -spring.h2.console.path=/h2 - -spring.datasource.url=jdbc:h2:file:~/hexagonal -spring.datasource.username=sa -spring.datasource.password= -spring.datasource.driver-class-name=org.h2.Driver \ No newline at end of file diff --git a/hexagonal-architecture/src/main/resources/db/PRODUCT.sql b/hexagonal-architecture/src/main/resources/db/PRODUCT.sql deleted file mode 100644 index a0fef3a710..0000000000 --- a/hexagonal-architecture/src/main/resources/db/PRODUCT.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE PRODUCT( - ID INT AUTO_INCREMENT, - NAME VARCHAR(255), - QUANTITY INTEGER, - PRICE DOUBLE, - DESCRIPTION VARCHAR(1000), -); - -INSERT INTO PRODUCT(NAME,QUANTITY,PRICE,DESCRIPTION) VALUES ('iPhone 11 Pro',10,300,'First triple camera system'); \ No newline at end of file diff --git a/hexagonal-architecture/src/test/java/com/baeldung/hexagonal/architecture/service/ProductServiceTest.java b/hexagonal-architecture/src/test/java/com/baeldung/hexagonal/architecture/service/ProductServiceTest.java deleted file mode 100644 index 748df3c0d0..0000000000 --- a/hexagonal-architecture/src/test/java/com/baeldung/hexagonal/architecture/service/ProductServiceTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * - */ -package com.baeldung.hexagonal.architecture.service; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.SpringApplicationConfiguration; -import org.springframework.context.annotation.PropertySource; -import org.springframework.context.annotation.PropertySources; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import com.baeldung.hexagonal.architecture.App; -import com.baeldung.hexagonal.architecture.model.Product; -import com.baeldung.hexagonal.architecture.service.ProductService; - -/** - * @author AshwiniKeshri - * - */ -@RunWith(SpringJUnit4ClassRunner.class) -@SpringApplicationConfiguration(App.class) -@ActiveProfiles(value = "test") -public class ProductServiceTest { - - @Autowired - private ProductService productService; - - @Test - public void testCreateProduct() { - Product product = new Product(); - product.setDescription("test product"); - product.setName("Product1"); - product.setPrice(10.0); - product.setQuantity(100l); - Long id = productService.create(product); - Assert.assertTrue(id > 0); - } - -} From 64b7dec1b0c761e322c304a1176ecdc8b38579ab Mon Sep 17 00:00:00 2001 From: akeshri Date: Tue, 8 Sep 2020 21:14:28 +0530 Subject: [PATCH 088/263] changes --- map-first-key-tutorial/README.md | 4 -- .../com/baeldung/article/HashMapExample.java | 36 ------------------ .../article/LinkedHashMapExample.java | 37 ------------------- 3 files changed, 77 deletions(-) delete mode 100644 map-first-key-tutorial/README.md delete mode 100644 map-first-key-tutorial/src/com/baeldung/article/HashMapExample.java delete mode 100644 map-first-key-tutorial/src/com/baeldung/article/LinkedHashMapExample.java diff --git a/map-first-key-tutorial/README.md b/map-first-key-tutorial/README.md deleted file mode 100644 index 13fb71643b..0000000000 --- a/map-first-key-tutorial/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# HashMap - Getting First Key And Value -A example on how to get first key and value from HashMap. - -- JDK 1.8 and above \ No newline at end of file diff --git a/map-first-key-tutorial/src/com/baeldung/article/HashMapExample.java b/map-first-key-tutorial/src/com/baeldung/article/HashMapExample.java deleted file mode 100644 index 3292d995ab..0000000000 --- a/map-first-key-tutorial/src/com/baeldung/article/HashMapExample.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.baeldung.article; - -import java.util.AbstractMap; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -/** - * @author AshwiniKeshri - * - */ -public class HashMapExample { - public static void main(String[] args) { - - Map hashmap = new HashMap<>(); - hashmap.put(5, "A"); - hashmap.put(1, "B"); - hashmap.put(2, "C"); - // hashmap.put(0, "D"); - - System.out.println(hashmap); - - Set> entrySet = hashmap.entrySet(); - - Iterator> iterator = entrySet.iterator(); - - if (iterator.hasNext()) - System.out.println("Using Iteraor: " + iterator.next()); - - System.out.println("Using Stream: " + entrySet.stream() - .findFirst() - .orElse(new AbstractMap.SimpleEntry(-1, "DEFAULT"))); - - } -} diff --git a/map-first-key-tutorial/src/com/baeldung/article/LinkedHashMapExample.java b/map-first-key-tutorial/src/com/baeldung/article/LinkedHashMapExample.java deleted file mode 100644 index 249b9a0585..0000000000 --- a/map-first-key-tutorial/src/com/baeldung/article/LinkedHashMapExample.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.baeldung.article; - -import java.util.AbstractMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Set; - -/** - * @author AshwiniKeshri - * - */ -public class LinkedHashMapExample { - - public static void main(String[] args) { - - LinkedHashMap linkedHashMap = new LinkedHashMap<>(); - linkedHashMap.put(5, "A"); - linkedHashMap.put(1, "B"); - linkedHashMap.put(2, "C"); - // linkedHashMap.put(0, "D"); - - System.out.println(linkedHashMap); - - Set> entrySet = linkedHashMap.entrySet(); - - Iterator> iterator = entrySet.iterator(); - - if (iterator.hasNext()) - System.out.println("Using Iterator: " + iterator.next()); - - System.out.println("Using Stream: " + entrySet.stream() - .findFirst() - .orElse(new AbstractMap.SimpleEntry(0, "DEFAULT"))); - } - -} From 0748a7534ff97866d1418f45eb0783db476439d7 Mon Sep 17 00:00:00 2001 From: Mona Mohamadinia Date: Tue, 8 Sep 2020 21:09:16 +0430 Subject: [PATCH 089/263] Non-Local Returns (#9934) --- .../main/kotlin/com/baeldung/inline/Inline.kt | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/inline/Inline.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/inline/Inline.kt index 3b179642ba..aaa6616ed1 100644 --- a/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/inline/Inline.kt +++ b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/inline/Inline.kt @@ -22,6 +22,30 @@ fun main() { numbers.each { println(random * it) } // capturing the random variable } +fun namedFunction(): Int { + return 42 +} + +fun anonymous(): () -> Int { + return fun(): Int { + return 42 + } +} + +inline fun List.eachIndexed(f: (Int, T) -> Unit) { + for (i in indices) { + f(i, this[i]) + } +} + +fun List.indexOf(x: T): Int { + eachIndexed { index, value -> + if (value == x) return index + } + + return -1 +} + /** * Generates a random number. */ From ece4d65065f96f074e21c3ab59fbf6258fc9f6b9 Mon Sep 17 00:00:00 2001 From: akeshri Date: Wed, 9 Sep 2020 09:34:10 +0530 Subject: [PATCH 090/263] changes --- .../mapfirstpair/MapFirstPairExample.java | 42 +++++++++++++++ .../mapfirstpair/MapFirstPairService.java | 17 ------ .../mapfirstpair/MapFirstPairServiceImpl.java | 40 -------------- ...nitTest.java => MapFirstPairUnitTest.java} | 54 ++++++++----------- 4 files changed, 65 insertions(+), 88 deletions(-) create mode 100644 core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/mapfirstpair/MapFirstPairExample.java delete mode 100644 core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/mapfirstpair/MapFirstPairService.java delete mode 100644 core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/mapfirstpair/MapFirstPairServiceImpl.java rename core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/mapfirstpair/{MapFirstPairServiceUnitTest.java => MapFirstPairUnitTest.java} (61%) diff --git a/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/mapfirstpair/MapFirstPairExample.java b/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/mapfirstpair/MapFirstPairExample.java new file mode 100644 index 0000000000..8e5fc296d4 --- /dev/null +++ b/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/mapfirstpair/MapFirstPairExample.java @@ -0,0 +1,42 @@ +package com.baeldung.collections.mapfirstpair; + +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +public class MapFirstPairExample { + + public Map.Entry getFirstPairUsingIterator(Map map) { + if (map == null || map.size() == 0) + return null; + + Iterator> iterator = map.entrySet() + .iterator(); + + if (iterator.hasNext()) + return iterator.next(); + + return null; + } + + public Map.Entry getFirstPairUsingStream(Map map) { + if (map == null || map.size() == 0) + return null; + + Set> entrySet = map.entrySet(); + + return entrySet.stream() + .findFirst() + .get(); + } + + public Map populateMapValues(Map map) { + if (map != null) { + map.put(5, "A"); + map.put(1, "B"); + map.put(2, "C"); + } + return map; + } + +} \ No newline at end of file diff --git a/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/mapfirstpair/MapFirstPairService.java b/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/mapfirstpair/MapFirstPairService.java deleted file mode 100644 index 5d3c4fac32..0000000000 --- a/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/mapfirstpair/MapFirstPairService.java +++ /dev/null @@ -1,17 +0,0 @@ -/** - * - */ -package com.baeldung.collections.mapfirstpair; - -import java.util.Map; - -/** - * @author ASHWINI - * - */ -public interface MapFirstPairService { - - Map.Entry getFirstPairUsingIterator(Map map); - - Map.Entry getFirstPairUsingStream(Map map); -} diff --git a/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/mapfirstpair/MapFirstPairServiceImpl.java b/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/mapfirstpair/MapFirstPairServiceImpl.java deleted file mode 100644 index aff6430216..0000000000 --- a/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/mapfirstpair/MapFirstPairServiceImpl.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * - */ -package com.baeldung.collections.mapfirstpair; - -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -/** - * @author ASHWINI - * - */ -public class MapFirstPairServiceImpl implements MapFirstPairService { - - public Map.Entry getFirstPairUsingIterator(Map map) { - if (map == null || map.size() == 0) - return null; - - Iterator> iterator = map.entrySet() - .iterator(); - - if (iterator.hasNext()) - return iterator.next(); - - return null; - } - - public Map.Entry getFirstPairUsingStream(Map map) { - if (map == null || map.size() == 0) - return null; - - Set> entrySet = map.entrySet(); - - return entrySet.stream() - .findFirst() - .get(); - } - -} \ No newline at end of file diff --git a/core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/mapfirstpair/MapFirstPairServiceUnitTest.java b/core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/mapfirstpair/MapFirstPairUnitTest.java similarity index 61% rename from core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/mapfirstpair/MapFirstPairServiceUnitTest.java rename to core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/mapfirstpair/MapFirstPairUnitTest.java index 56e293ffc5..c8198bcc02 100644 --- a/core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/mapfirstpair/MapFirstPairServiceUnitTest.java +++ b/core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/mapfirstpair/MapFirstPairUnitTest.java @@ -11,30 +11,22 @@ import java.util.Map; import org.junit.Before; import org.junit.Test; -public class MapFirstPairServiceUnitTest { +public class MapFirstPairUnitTest { - private MapFirstPairService mapFirstPairService; + private MapFirstPairExample mapFirstPairExample; @Before public void Setup() { - mapFirstPairService = new MapFirstPairServiceImpl(); - } - - private void populateMapValues(Map map) { - if (map != null) { - map.put(5, "A"); - map.put(1, "B"); - map.put(2, "C"); - } + mapFirstPairExample = new MapFirstPairExample(); } @Test - public void whenUsingIteratorForHashMap() { + public void whenUsingIteratorForHashMap_thenFirstPairWhichWasNotInsertedFirst() { Map hashMap = new HashMap<>(); - populateMapValues(hashMap); + hashMap = mapFirstPairExample.populateMapValues(hashMap); - Map.Entry actualValue = mapFirstPairService.getFirstPairUsingIterator(hashMap); + Map.Entry actualValue = mapFirstPairExample.getFirstPairUsingIterator(hashMap); Map.Entry expectedValue = new AbstractMap.SimpleEntry(1, "B"); Map.Entry pairInsertedFirst = new AbstractMap.SimpleEntry(5, "A"); @@ -43,10 +35,10 @@ public class MapFirstPairServiceUnitTest { } @Test - public void whenUsingStreamForHashMap() { + public void whenUsingStreamForHashMap_thenFirstPairWhichWasNotInsertedFirst() { Map hashMap = new HashMap<>(); - populateMapValues(hashMap); - Map.Entry actualValue = mapFirstPairService.getFirstPairUsingStream(hashMap); + hashMap = mapFirstPairExample.populateMapValues(hashMap); + Map.Entry actualValue = mapFirstPairExample.getFirstPairUsingStream(hashMap); Map.Entry expectedValue = new AbstractMap.SimpleEntry(1, "B"); Map.Entry pairInsertedFirst = new AbstractMap.SimpleEntry(5, "A"); @@ -55,21 +47,21 @@ public class MapFirstPairServiceUnitTest { } @Test - public void whenUsingIteratorForLinkedHashMap() { + public void whenUsingIteratorForLinkedHashMap_thenFirstPairWhichWasInsertedFirst() { Map linkedHashMap = new LinkedHashMap<>(); - populateMapValues(linkedHashMap); - Map.Entry actualValue = mapFirstPairService.getFirstPairUsingIterator(linkedHashMap); + linkedHashMap = mapFirstPairExample.populateMapValues(linkedHashMap); + Map.Entry actualValue = mapFirstPairExample.getFirstPairUsingIterator(linkedHashMap); Map.Entry expectedValue = new AbstractMap.SimpleEntry(5, "A"); assertEquals(expectedValue, actualValue); } @Test - public void whenUsingStreamForLinkedHashMap() { + public void whenUsingStreamForLinkedHashMap_thenFirstPairWhichWasInsertedFirst() { Map linkedHashMap = new LinkedHashMap<>(); - populateMapValues(linkedHashMap); + linkedHashMap = mapFirstPairExample.populateMapValues(linkedHashMap); - Map.Entry actualValue = mapFirstPairService.getFirstPairUsingStream(linkedHashMap); + Map.Entry actualValue = mapFirstPairExample.getFirstPairUsingStream(linkedHashMap); Map.Entry expectedValue = new AbstractMap.SimpleEntry(5, "A"); assertEquals(expectedValue, actualValue); @@ -78,10 +70,10 @@ public class MapFirstPairServiceUnitTest { @Test public void whenAddedAnElementInHashMap_thenFirstPairChangedUsingIterator() { Map hashMap = new HashMap<>(); - populateMapValues(hashMap); + hashMap = mapFirstPairExample.populateMapValues(hashMap); hashMap.put(0, "D"); - Map.Entry actualValue = mapFirstPairService.getFirstPairUsingIterator(hashMap); + Map.Entry actualValue = mapFirstPairExample.getFirstPairUsingIterator(hashMap); Map.Entry expectedValue = new AbstractMap.SimpleEntry(0, "D"); assertEquals(expectedValue, actualValue); @@ -90,10 +82,10 @@ public class MapFirstPairServiceUnitTest { @Test public void whenAddedAnElementInHashMap_thenFirstPairChangedUsingStream() { Map hashMap = new HashMap<>(); - populateMapValues(hashMap); + hashMap = mapFirstPairExample.populateMapValues(hashMap); hashMap.put(0, "D"); - Map.Entry actualValue = mapFirstPairService.getFirstPairUsingStream(hashMap); + Map.Entry actualValue = mapFirstPairExample.getFirstPairUsingStream(hashMap); Map.Entry expectedValue = new AbstractMap.SimpleEntry(0, "D"); assertEquals(expectedValue, actualValue); @@ -102,10 +94,10 @@ public class MapFirstPairServiceUnitTest { @Test public void whenAddedAnElementInLinkedHashMap_thenFirstPairRemainUnchangedUsingIterator() { Map linkedHashMap = new LinkedHashMap<>(); - populateMapValues(linkedHashMap); + linkedHashMap = mapFirstPairExample.populateMapValues(linkedHashMap); linkedHashMap.put(0, "D"); - Map.Entry actualValue = mapFirstPairService.getFirstPairUsingIterator(linkedHashMap); + Map.Entry actualValue = mapFirstPairExample.getFirstPairUsingIterator(linkedHashMap); Map.Entry expectedValue = new AbstractMap.SimpleEntry(5, "A"); assertEquals(expectedValue, actualValue); @@ -114,10 +106,10 @@ public class MapFirstPairServiceUnitTest { @Test public void whenAddedAnElementInLinkedHashMap_thenFirstPairRemainUnchangedUsingStream() { Map linkedHashMap = new LinkedHashMap<>(); - populateMapValues(linkedHashMap); + linkedHashMap = mapFirstPairExample.populateMapValues(linkedHashMap); linkedHashMap.put(0, "D"); - Map.Entry actualValue = mapFirstPairService.getFirstPairUsingStream(linkedHashMap); + Map.Entry actualValue = mapFirstPairExample.getFirstPairUsingStream(linkedHashMap); Map.Entry expectedValue = new AbstractMap.SimpleEntry(5, "A"); assertEquals(expectedValue, actualValue); From 1876f16449519f8240b1519a0f62e555a78b9e25 Mon Sep 17 00:00:00 2001 From: fdpro Date: Wed, 9 Sep 2020 10:02:27 +0200 Subject: [PATCH 091/263] [JAVA-2433] Inherited from parent-spring-5 --- .../spring-security-web-digest-auth/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-security-modules/spring-security-web-digest-auth/pom.xml b/spring-security-modules/spring-security-web-digest-auth/pom.xml index 2579a11f97..39433c1295 100644 --- a/spring-security-modules/spring-security-web-digest-auth/pom.xml +++ b/spring-security-modules/spring-security-web-digest-auth/pom.xml @@ -9,9 +9,9 @@ com.baeldung - parent-spring-4 + parent-spring-5 0.0.1-SNAPSHOT - ../../parent-spring-4 + ../../parent-spring-5 From 1624cd3387f6a2f02d59d7fd75d72d0cee4d4470 Mon Sep 17 00:00:00 2001 From: Jordan Simpson Date: Wed, 9 Sep 2020 08:18:38 -0500 Subject: [PATCH 092/263] Update core-java-modules/core-java-lang-3/src/test/java/com/baeldung/checkclassexistence/CheckClassExistenceUnitTest.java Co-authored-by: KevinGilmore --- .../checkclassexistence/CheckClassExistenceUnitTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/checkclassexistence/CheckClassExistenceUnitTest.java b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/checkclassexistence/CheckClassExistenceUnitTest.java index 2e500b390f..04c1ad0115 100644 --- a/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/checkclassexistence/CheckClassExistenceUnitTest.java +++ b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/checkclassexistence/CheckClassExistenceUnitTest.java @@ -13,7 +13,7 @@ public class CheckClassExistenceUnitTest { } @Test(expected = ClassNotFoundException.class) //thrown when class does not exist - public void givenNonExistingClass_whenUsingForName_classNotFound() throws ClassNotFoundException { + public void givenNonExistingClass_whenUsingForName_thenClassNotFound() throws ClassNotFoundException { Class.forName("class.that.does.not.exist"); } From 576d3c5f425ae49caf9f5f0eb255bd70ef0a05c5 Mon Sep 17 00:00:00 2001 From: Jordan Simpson Date: Wed, 9 Sep 2020 08:18:46 -0500 Subject: [PATCH 093/263] Update core-java-modules/core-java-lang-3/src/test/java/com/baeldung/checkclassexistence/CheckClassExistenceUnitTest.java Co-authored-by: KevinGilmore --- .../checkclassexistence/CheckClassExistenceUnitTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/checkclassexistence/CheckClassExistenceUnitTest.java b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/checkclassexistence/CheckClassExistenceUnitTest.java index 04c1ad0115..aef7e686b5 100644 --- a/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/checkclassexistence/CheckClassExistenceUnitTest.java +++ b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/checkclassexistence/CheckClassExistenceUnitTest.java @@ -18,7 +18,7 @@ public class CheckClassExistenceUnitTest { } @Test - public void givenExistingClass_whenUsingForName_noException() throws ClassNotFoundException { + public void givenExistingClass_whenUsingForName_thenNoException() throws ClassNotFoundException { Class.forName("java.lang.String"); } From 10efba315d22e7d69e8ee1b775b753a94d54d95c Mon Sep 17 00:00:00 2001 From: Jordan Simpson Date: Wed, 9 Sep 2020 08:18:51 -0500 Subject: [PATCH 094/263] Update core-java-modules/core-java-lang-3/src/test/java/com/baeldung/checkclassexistence/CheckClassExistenceUnitTest.java Co-authored-by: KevinGilmore --- .../checkclassexistence/CheckClassExistenceUnitTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/checkclassexistence/CheckClassExistenceUnitTest.java b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/checkclassexistence/CheckClassExistenceUnitTest.java index aef7e686b5..cf455a6e35 100644 --- a/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/checkclassexistence/CheckClassExistenceUnitTest.java +++ b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/checkclassexistence/CheckClassExistenceUnitTest.java @@ -23,7 +23,7 @@ public class CheckClassExistenceUnitTest { } @Test(expected = ExceptionInInitializerError.class) //thrown when exception occurs inside of a static initialization block - public void givenInitializingClass_whenUsingForName_initializationError() throws ClassNotFoundException { + public void givenInitializingClass_whenUsingForName_thenInitializationError() throws ClassNotFoundException { Class.forName("com.baeldung.checkclassexistence.CheckClassExistenceUnitTest$InitializingClass"); } From cf15c1b002d0aa5ff917f6f906631298ac424e05 Mon Sep 17 00:00:00 2001 From: Jordan Simpson Date: Wed, 9 Sep 2020 08:18:57 -0500 Subject: [PATCH 095/263] Update core-java-modules/core-java-lang-3/src/test/java/com/baeldung/checkclassexistence/CheckClassExistenceUnitTest.java Co-authored-by: KevinGilmore --- .../checkclassexistence/CheckClassExistenceUnitTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/checkclassexistence/CheckClassExistenceUnitTest.java b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/checkclassexistence/CheckClassExistenceUnitTest.java index cf455a6e35..b565f9de31 100644 --- a/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/checkclassexistence/CheckClassExistenceUnitTest.java +++ b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/checkclassexistence/CheckClassExistenceUnitTest.java @@ -28,7 +28,7 @@ public class CheckClassExistenceUnitTest { } @Test - public void givenInitializingClass_whenUsingForNameWithoutInitialization_noException() throws ClassNotFoundException { + public void givenInitializingClass_whenUsingForNameWithoutInitialization_thenNoException() throws ClassNotFoundException { Class.forName("com.baeldung.checkclassexistence.CheckClassExistenceUnitTest$InitializingClass", false, getClass().getClassLoader()); } } From 99381e0b1528cfe703b30de3d38eea7aaa839df5 Mon Sep 17 00:00:00 2001 From: kwoyke Date: Wed, 9 Sep 2020 18:35:31 +0200 Subject: [PATCH 096/263] BAEL-4588: Update Guide To Java 8 Optional (#9995) * BAEL-4588: Fix maven-shade-plugin version * BAEL-4588: Add empty core-java-11-2 module structure * BAEL-4588: Move Guide To Java 8 Optional to core-java-11-2 * BAEL-4588: Add Java 10 orElseThrow() example --- core-java-modules/core-java-11-2/README.md | 7 +++ core-java-modules/core-java-11-2/pom.xml | 48 +++++++++++++++++++ .../java/com/baeldung/optional/Modem.java | 0 .../java/com/baeldung/optional/Person.java | 0 .../optional/OptionalChainingUnitTest.java | 4 +- .../baeldung/optional/OptionalUnitTest.java | 10 +++- core-java-modules/core-java-11/pom.xml | 2 +- .../core-java-optional/README.md | 1 - 8 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 core-java-modules/core-java-11-2/README.md create mode 100644 core-java-modules/core-java-11-2/pom.xml rename core-java-modules/{core-java-optional => core-java-11-2}/src/main/java/com/baeldung/optional/Modem.java (100%) rename core-java-modules/{core-java-optional => core-java-11-2}/src/main/java/com/baeldung/optional/Person.java (100%) rename core-java-modules/{core-java-optional => core-java-11-2}/src/test/java/com/baeldung/optional/OptionalChainingUnitTest.java (96%) rename core-java-modules/{core-java-optional => core-java-11-2}/src/test/java/com/baeldung/optional/OptionalUnitTest.java (96%) diff --git a/core-java-modules/core-java-11-2/README.md b/core-java-modules/core-java-11-2/README.md new file mode 100644 index 0000000000..f65a043819 --- /dev/null +++ b/core-java-modules/core-java-11-2/README.md @@ -0,0 +1,7 @@ +## Core Java 11 + +This module contains articles about Java 11 core features + +### Relevant articles +- [Guide to Java 8 Optional](https://www.baeldung.com/java-optional) + diff --git a/core-java-modules/core-java-11-2/pom.xml b/core-java-modules/core-java-11-2/pom.xml new file mode 100644 index 0000000000..d20b0f23f0 --- /dev/null +++ b/core-java-modules/core-java-11-2/pom.xml @@ -0,0 +1,48 @@ + + + 4.0.0 + core-java-11-2 + 0.1.0-SNAPSHOT + core-java-11-2 + jar + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + ../.. + + + + + org.assertj + assertj-core + ${assertj.version} + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${maven.compiler.source.version} + ${maven.compiler.target.version} + + + + + + + 11 + 11 + 3.17.2 + + + diff --git a/core-java-modules/core-java-optional/src/main/java/com/baeldung/optional/Modem.java b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/optional/Modem.java similarity index 100% rename from core-java-modules/core-java-optional/src/main/java/com/baeldung/optional/Modem.java rename to core-java-modules/core-java-11-2/src/main/java/com/baeldung/optional/Modem.java diff --git a/core-java-modules/core-java-optional/src/main/java/com/baeldung/optional/Person.java b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/optional/Person.java similarity index 100% rename from core-java-modules/core-java-optional/src/main/java/com/baeldung/optional/Person.java rename to core-java-modules/core-java-11-2/src/main/java/com/baeldung/optional/Person.java diff --git a/core-java-modules/core-java-optional/src/test/java/com/baeldung/optional/OptionalChainingUnitTest.java b/core-java-modules/core-java-11-2/src/test/java/com/baeldung/optional/OptionalChainingUnitTest.java similarity index 96% rename from core-java-modules/core-java-optional/src/test/java/com/baeldung/optional/OptionalChainingUnitTest.java rename to core-java-modules/core-java-11-2/src/test/java/com/baeldung/optional/OptionalChainingUnitTest.java index 9ef156501b..65b9e22f44 100644 --- a/core-java-modules/core-java-optional/src/test/java/com/baeldung/optional/OptionalChainingUnitTest.java +++ b/core-java-modules/core-java-11-2/src/test/java/com/baeldung/optional/OptionalChainingUnitTest.java @@ -7,7 +7,9 @@ import java.util.Optional; import java.util.function.Supplier; import java.util.stream.Stream; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; public class OptionalChainingUnitTest { diff --git a/core-java-modules/core-java-optional/src/test/java/com/baeldung/optional/OptionalUnitTest.java b/core-java-modules/core-java-11-2/src/test/java/com/baeldung/optional/OptionalUnitTest.java similarity index 96% rename from core-java-modules/core-java-optional/src/test/java/com/baeldung/optional/OptionalUnitTest.java rename to core-java-modules/core-java-11-2/src/test/java/com/baeldung/optional/OptionalUnitTest.java index de16e9b635..1b0a2d4445 100644 --- a/core-java-modules/core-java-optional/src/test/java/com/baeldung/optional/OptionalUnitTest.java +++ b/core-java-modules/core-java-11-2/src/test/java/com/baeldung/optional/OptionalUnitTest.java @@ -9,7 +9,9 @@ import java.util.List; import java.util.NoSuchElementException; import java.util.Optional; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; public class OptionalUnitTest { @@ -262,6 +264,12 @@ public class OptionalUnitTest { .orElseThrow(IllegalArgumentException::new); } + @Test(expected = NoSuchElementException.class) + public void whenNoArgOrElseThrowWorks_thenCorrect() { + String nullName = null; + String name = Optional.ofNullable(nullName).orElseThrow(); + } + public String getMyDefault() { LOG.debug("Getting default value..."); return "Default Value"; diff --git a/core-java-modules/core-java-11/pom.xml b/core-java-modules/core-java-11/pom.xml index bbc4219eaa..2f7f5a6bcf 100644 --- a/core-java-modules/core-java-11/pom.xml +++ b/core-java-modules/core-java-11/pom.xml @@ -107,7 +107,7 @@ benchmarks 1.22 10.0.0 - 10.0.0 + 3.2.4 diff --git a/core-java-modules/core-java-optional/README.md b/core-java-modules/core-java-optional/README.md index d9d2fe813b..6c83003ea2 100644 --- a/core-java-modules/core-java-optional/README.md +++ b/core-java-modules/core-java-optional/README.md @@ -4,7 +4,6 @@ This module contains articles about Java Optional. ### Relevant Articles: - [Java Optional as Return Type](https://www.baeldung.com/java-optional-return) -- [Guide to Java 8 Optional](https://www.baeldung.com/java-optional) - [Java Optional – orElse() vs orElseGet()](https://www.baeldung.com/java-optional-or-else-vs-or-else-get) - [Transforming an Empty String into an Empty Optional](https://www.baeldung.com/java-empty-string-to-empty-optional) - [Filtering a Stream of Optionals in Java](https://www.baeldung.com/java-filter-stream-of-optional) From ae5ee571b9c7528f70e47dc7d12b038376032fc2 Mon Sep 17 00:00:00 2001 From: mikr Date: Thu, 10 Sep 2020 01:08:03 +0200 Subject: [PATCH 097/263] Java-2394 Create default and integration profile for JDK-9 and above modules --- .../{AppTest.java => AppUnitTest.java} | 6 +- core-java-modules/core-java-11/pom.xml | 2 +- ...ingAPITest.java => StringAPIUnitTest.java} | 2 +- .../{PersonTest.java => PersonUnitTest.java} | 2 +- core-java-modules/core-java-9/pom.xml | 11 +++ ...esTest.java => MethodHandlesUnitTest.java} | 2 +- ...> TimestampToStringConverterUnitTest.java} | 2 +- .../consumermodule/pom.xml | 2 +- .../decoupling-pattern1/servicemodule/pom.xml | 3 +- .../providermodule/pom.xml | 2 +- .../decoupling-pattern2/servicemodule/pom.xml | 3 +- ...a => CurrentDirectoryFetcherUnitTest.java} | 2 +- .../multimodulemavenproject/daomodule/pom.xml | 4 + .../entitymodule/pom.xml | 4 + .../mainappmodule/pom.xml | 4 + .../userdaomodule/pom.xml | 4 + core-java-modules/pom.xml | 20 ---- pom.xml | 98 +++++++++++++++++++ 18 files changed, 140 insertions(+), 33 deletions(-) rename core-java-modules/core-java-10/src/test/java/com/baeldung/{AppTest.java => AppUnitTest.java} (82%) rename core-java-modules/core-java-12/src/test/java/com/baeldung/string/{StringAPITest.java => StringAPIUnitTest.java} (97%) rename core-java-modules/core-java-14/src/test/java/com/baeldung/java14/record/{PersonTest.java => PersonUnitTest.java} (99%) rename core-java-modules/core-java-9/src/test/java/com/baeldung/java9/methodhandles/{MethodHandlesTest.java => MethodHandlesUnitTest.java} (99%) rename core-java-modules/core-java-datetime-string/src/test/java/com/baeldung/timestamp/{TimestampToStringConverterTest.java => TimestampToStringConverterUnitTest.java} (92%) rename core-java-modules/core-java-os/src/test/java/com/baeldung/core/pwd/{CurrentDirectoryFetcherTest.java => CurrentDirectoryFetcherUnitTest.java} (95%) diff --git a/core-java-modules/core-java-10/src/test/java/com/baeldung/AppTest.java b/core-java-modules/core-java-10/src/test/java/com/baeldung/AppUnitTest.java similarity index 82% rename from core-java-modules/core-java-10/src/test/java/com/baeldung/AppTest.java rename to core-java-modules/core-java-10/src/test/java/com/baeldung/AppUnitTest.java index c9f61455bd..73eb8e661a 100644 --- a/core-java-modules/core-java-10/src/test/java/com/baeldung/AppTest.java +++ b/core-java-modules/core-java-10/src/test/java/com/baeldung/AppUnitTest.java @@ -7,7 +7,7 @@ import junit.framework.TestSuite; /** * Unit test for simple App. */ -public class AppTest +public class AppUnitTest extends TestCase { /** @@ -15,7 +15,7 @@ public class AppTest * * @param testName name of the test case */ - public AppTest( String testName ) + public AppUnitTest(String testName ) { super( testName ); } @@ -25,7 +25,7 @@ public class AppTest */ public static Test suite() { - return new TestSuite( AppTest.class ); + return new TestSuite( AppUnitTest.class ); } /** diff --git a/core-java-modules/core-java-11/pom.xml b/core-java-modules/core-java-11/pom.xml index bbc4219eaa..2f7f5a6bcf 100644 --- a/core-java-modules/core-java-11/pom.xml +++ b/core-java-modules/core-java-11/pom.xml @@ -107,7 +107,7 @@ benchmarks 1.22 10.0.0 - 10.0.0 + 3.2.4 diff --git a/core-java-modules/core-java-12/src/test/java/com/baeldung/string/StringAPITest.java b/core-java-modules/core-java-12/src/test/java/com/baeldung/string/StringAPIUnitTest.java similarity index 97% rename from core-java-modules/core-java-12/src/test/java/com/baeldung/string/StringAPITest.java rename to core-java-modules/core-java-12/src/test/java/com/baeldung/string/StringAPIUnitTest.java index 3d80a36bf6..e5f21bb25f 100644 --- a/core-java-modules/core-java-12/src/test/java/com/baeldung/string/StringAPITest.java +++ b/core-java-modules/core-java-12/src/test/java/com/baeldung/string/StringAPIUnitTest.java @@ -5,7 +5,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import org.junit.Test; -public class StringAPITest { +public class StringAPIUnitTest { @Test public void whenPositiveArgument_thenReturnIndentedString() { diff --git a/core-java-modules/core-java-14/src/test/java/com/baeldung/java14/record/PersonTest.java b/core-java-modules/core-java-14/src/test/java/com/baeldung/java14/record/PersonUnitTest.java similarity index 99% rename from core-java-modules/core-java-14/src/test/java/com/baeldung/java14/record/PersonTest.java rename to core-java-modules/core-java-14/src/test/java/com/baeldung/java14/record/PersonUnitTest.java index 9bed3dab8f..594ced56cd 100644 --- a/core-java-modules/core-java-14/src/test/java/com/baeldung/java14/record/PersonTest.java +++ b/core-java-modules/core-java-14/src/test/java/com/baeldung/java14/record/PersonUnitTest.java @@ -7,7 +7,7 @@ import static org.junit.Assert.assertTrue; import org.junit.Test; -public class PersonTest { +public class PersonUnitTest { @Test public void givenSameNameAndAddress_whenEquals_thenPersonsEqual() { diff --git a/core-java-modules/core-java-9/pom.xml b/core-java-modules/core-java-9/pom.xml index 0669d6f597..d7894934b1 100644 --- a/core-java-modules/core-java-9/pom.xml +++ b/core-java-modules/core-java-9/pom.xml @@ -44,6 +44,16 @@ commons-collections4 ${commons-collections4.version} + + org.apache.commons + commons-lang3 + 3.11 + + + commons-io + commons-io + 2.7 + @@ -77,6 +87,7 @@ 1.9 25.1-jre 4.1 + 3.2.2 diff --git a/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/methodhandles/MethodHandlesTest.java b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/methodhandles/MethodHandlesUnitTest.java similarity index 99% rename from core-java-modules/core-java-9/src/test/java/com/baeldung/java9/methodhandles/MethodHandlesTest.java rename to core-java-modules/core-java-9/src/test/java/com/baeldung/java9/methodhandles/MethodHandlesUnitTest.java index 7646755358..7aa74a490f 100644 --- a/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/methodhandles/MethodHandlesTest.java +++ b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/methodhandles/MethodHandlesUnitTest.java @@ -17,7 +17,7 @@ import org.junit.Test; /** * Test case for the {@link MethodHandles} API */ -public class MethodHandlesTest { +public class MethodHandlesUnitTest { @Test public void givenConcatMethodHandle_whenInvoked_thenCorrectlyConcatenated() throws Throwable { diff --git a/core-java-modules/core-java-datetime-string/src/test/java/com/baeldung/timestamp/TimestampToStringConverterTest.java b/core-java-modules/core-java-datetime-string/src/test/java/com/baeldung/timestamp/TimestampToStringConverterUnitTest.java similarity index 92% rename from core-java-modules/core-java-datetime-string/src/test/java/com/baeldung/timestamp/TimestampToStringConverterTest.java rename to core-java-modules/core-java-datetime-string/src/test/java/com/baeldung/timestamp/TimestampToStringConverterUnitTest.java index b25ff2edb3..b928047a9a 100644 --- a/core-java-modules/core-java-datetime-string/src/test/java/com/baeldung/timestamp/TimestampToStringConverterTest.java +++ b/core-java-modules/core-java-datetime-string/src/test/java/com/baeldung/timestamp/TimestampToStringConverterUnitTest.java @@ -6,7 +6,7 @@ import org.junit.jupiter.api.Test; import java.sql.Timestamp; import java.time.format.DateTimeFormatter; -public class TimestampToStringConverterTest { +public class TimestampToStringConverterUnitTest { @Test public void givenDatePattern_whenFormatting_thenResultingStringIsCorrect() { diff --git a/core-java-modules/core-java-jpms/decoupling-pattern1/consumermodule/pom.xml b/core-java-modules/core-java-jpms/decoupling-pattern1/consumermodule/pom.xml index fe6689dcc3..fb6d2b1065 100644 --- a/core-java-modules/core-java-jpms/decoupling-pattern1/consumermodule/pom.xml +++ b/core-java-modules/core-java-jpms/decoupling-pattern1/consumermodule/pom.xml @@ -17,7 +17,7 @@ com.baeldung.servicemodule - servicemodule + servicemodule1 ${servicemodule.version} diff --git a/core-java-modules/core-java-jpms/decoupling-pattern1/servicemodule/pom.xml b/core-java-modules/core-java-jpms/decoupling-pattern1/servicemodule/pom.xml index c2da228ce6..4c811ea866 100644 --- a/core-java-modules/core-java-jpms/decoupling-pattern1/servicemodule/pom.xml +++ b/core-java-modules/core-java-jpms/decoupling-pattern1/servicemodule/pom.xml @@ -4,7 +4,8 @@ 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 - servicemodule + com.baeldung.servicemodule + servicemodule1 jar diff --git a/core-java-modules/core-java-jpms/decoupling-pattern2/providermodule/pom.xml b/core-java-modules/core-java-jpms/decoupling-pattern2/providermodule/pom.xml index 3e8d5c0c39..1e29df7053 100644 --- a/core-java-modules/core-java-jpms/decoupling-pattern2/providermodule/pom.xml +++ b/core-java-modules/core-java-jpms/decoupling-pattern2/providermodule/pom.xml @@ -17,7 +17,7 @@ com.baeldung.servicemodule - servicemodule + servicemodule2 ${servicemodule.version} diff --git a/core-java-modules/core-java-jpms/decoupling-pattern2/servicemodule/pom.xml b/core-java-modules/core-java-jpms/decoupling-pattern2/servicemodule/pom.xml index 51d64998df..9a687c9ae7 100644 --- a/core-java-modules/core-java-jpms/decoupling-pattern2/servicemodule/pom.xml +++ b/core-java-modules/core-java-jpms/decoupling-pattern2/servicemodule/pom.xml @@ -4,7 +4,8 @@ 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 - servicemodule + com.baeldung.servicemodule + servicemodule2 1.0 diff --git a/core-java-modules/core-java-os/src/test/java/com/baeldung/core/pwd/CurrentDirectoryFetcherTest.java b/core-java-modules/core-java-os/src/test/java/com/baeldung/core/pwd/CurrentDirectoryFetcherUnitTest.java similarity index 95% rename from core-java-modules/core-java-os/src/test/java/com/baeldung/core/pwd/CurrentDirectoryFetcherTest.java rename to core-java-modules/core-java-os/src/test/java/com/baeldung/core/pwd/CurrentDirectoryFetcherUnitTest.java index dbaad211d9..c92049816f 100644 --- a/core-java-modules/core-java-os/src/test/java/com/baeldung/core/pwd/CurrentDirectoryFetcherTest.java +++ b/core-java-modules/core-java-os/src/test/java/com/baeldung/core/pwd/CurrentDirectoryFetcherUnitTest.java @@ -4,7 +4,7 @@ import static org.junit.Assert.assertTrue; import org.junit.Test; -public class CurrentDirectoryFetcherTest { +public class CurrentDirectoryFetcherUnitTest { private static final String CURRENT_DIR = "core-java-os"; diff --git a/core-java-modules/multimodulemavenproject/daomodule/pom.xml b/core-java-modules/multimodulemavenproject/daomodule/pom.xml index 15f1215d89..56c2d70d24 100644 --- a/core-java-modules/multimodulemavenproject/daomodule/pom.xml +++ b/core-java-modules/multimodulemavenproject/daomodule/pom.xml @@ -20,6 +20,10 @@ org.apache.maven.plugins maven-compiler-plugin + + ${maven.compiler.source} + ${maven.compiler.target} + diff --git a/core-java-modules/multimodulemavenproject/entitymodule/pom.xml b/core-java-modules/multimodulemavenproject/entitymodule/pom.xml index 3e5a478299..00ad56b3ab 100644 --- a/core-java-modules/multimodulemavenproject/entitymodule/pom.xml +++ b/core-java-modules/multimodulemavenproject/entitymodule/pom.xml @@ -20,6 +20,10 @@ org.apache.maven.plugins maven-compiler-plugin + + ${maven.compiler.source} + ${maven.compiler.target} + diff --git a/core-java-modules/multimodulemavenproject/mainappmodule/pom.xml b/core-java-modules/multimodulemavenproject/mainappmodule/pom.xml index 196e58a419..a9fe04b108 100644 --- a/core-java-modules/multimodulemavenproject/mainappmodule/pom.xml +++ b/core-java-modules/multimodulemavenproject/mainappmodule/pom.xml @@ -38,6 +38,10 @@ org.apache.maven.plugins maven-compiler-plugin + + ${maven.compiler.source} + ${maven.compiler.target} + diff --git a/core-java-modules/multimodulemavenproject/userdaomodule/pom.xml b/core-java-modules/multimodulemavenproject/userdaomodule/pom.xml index f4a7e5c8f8..150c10b68f 100644 --- a/core-java-modules/multimodulemavenproject/userdaomodule/pom.xml +++ b/core-java-modules/multimodulemavenproject/userdaomodule/pom.xml @@ -33,6 +33,10 @@ org.apache.maven.plugins maven-compiler-plugin + + ${maven.compiler.source} + ${maven.compiler.target} + diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index 36fca8de93..a6aecef741 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -18,20 +18,9 @@ core-java - - - - - core-java-8 core-java-8-2 - - - - - - core-java-annotations core-java-arrays-sorting @@ -51,7 +40,6 @@ core-java-collections-maps core-java-collections-maps-2 core-java-collections-maps-3 - core-java-concurrency-2 core-java-concurrency-advanced @@ -65,10 +53,7 @@ core-java-8-datetime-2 - core-java-date-operations-2 - - core-java-8-datetime core-java-exceptions @@ -85,7 +70,6 @@ core-java-jar core-java-jndi - core-java-jvm core-java-jvm-2 @@ -113,7 +97,6 @@ core-java-nio-2 core-java-optional - core-java-perf @@ -138,9 +121,6 @@ core-java-sun core-java-regex - - - pre-jpms diff --git a/pom.xml b/pom.xml index ffdfe4cffa..6d5c810784 100644 --- a/pom.xml +++ b/pom.xml @@ -1340,6 +1340,104 @@ + + default-jdk9-and-above + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + 3 + true + + SpringContextTest + **/*UnitTest + + + **/*IntegrationTest.java + **/*IntTest.java + **/*LongRunningUnitTest.java + **/*ManualTest.java + **/JdbcTest.java + **/*LiveTest.java + + + + + + + + + core-java-modules/core-java-9 + core-java-modules/core-java-9-improvements + + + core-java-modules/core-java-9-streams + core-java-modules/core-java-10 + + + + + core-java-modules/core-java-collections-set + + + + core-java-modules/core-java-jpms + + + core-java-modules/multimodulemavenproject + + + + + + integration-jdk9-and-above + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + **/*ManualTest.java + **/*LiveTest.java + + + **/*IntegrationTest.java + **/*IntTest.java + + + + + + + + core-java-modules/core-java-9 + core-java-modules/core-java-9-improvements + + + core-java-modules/core-java-9-streams + core-java-modules/core-java-10 + + + + + core-java-modules/core-java-collections-set + + + + core-java-modules/core-java-jpms + + + core-java-modules/multimodulemavenproject + + + From bc36751276ff2f2d9224cd180887b9e53ca95a16 Mon Sep 17 00:00:00 2001 From: Anshul BANSAL Date: Sat, 12 Sep 2020 06:30:35 +0300 Subject: [PATCH 098/263] BAEL-4507 - UserSocialMedia class added --- .../baeldung/repositoryvsdaopattern/User.java | 12 ------------ .../UserRepositoryImpl.java | 5 +++-- .../repositoryvsdaopattern/UserSocialMedia.java | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 14 deletions(-) create mode 100644 patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/UserSocialMedia.java diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/User.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/User.java index 86d3554f7e..8cd4fd0a00 100644 --- a/patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/User.java +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/User.java @@ -1,7 +1,5 @@ package com.baeldung.repositoryvsdaopattern; -import java.util.List; - public class User { private Long id; @@ -10,8 +8,6 @@ public class User { private String lastName; private String email; - private List tweets; - public Long getId() { return id; } @@ -51,13 +47,5 @@ public class User { public void setEmail(String email) { this.email = email; } - - public List getTweets() { - return tweets; - } - - public void setTweets(List tweets) { - this.tweets = tweets; - } } diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/UserRepositoryImpl.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/UserRepositoryImpl.java index 6d7334c1ab..806b44e9d5 100644 --- a/patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/UserRepositoryImpl.java +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/UserRepositoryImpl.java @@ -9,7 +9,7 @@ public class UserRepositoryImpl implements UserRepository { @Override public User get(Long id) { - User user = userDaoImpl.read(id); + UserSocialMedia user = (UserSocialMedia) userDaoImpl.read(id); List tweets = tweetDaoImpl.fetchTweets(user.getEmail()); user.setTweets(tweets); @@ -34,7 +34,8 @@ public class UserRepositoryImpl implements UserRepository { @Override public List fetchTweets(User user) { - return null; + return tweetDaoImpl.fetchTweets(user.getEmail()); + } @Override diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/UserSocialMedia.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/UserSocialMedia.java new file mode 100644 index 0000000000..bf729620af --- /dev/null +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/repositoryvsdaopattern/UserSocialMedia.java @@ -0,0 +1,17 @@ +package com.baeldung.repositoryvsdaopattern; + +import java.util.List; + +public class UserSocialMedia extends User { + + private List tweets; + + public List getTweets() { + return tweets; + } + + public void setTweets(List tweets) { + this.tweets = tweets; + } + +} From 2f918653634e0c3a10b425118496cc54d8a7c05b Mon Sep 17 00:00:00 2001 From: akeshri Date: Thu, 10 Sep 2020 09:26:24 +0530 Subject: [PATCH 099/263] changes --- .../mapfirstpair/MapFirstPairExample.java | 42 ------------ .../mapfirstpair/MapFirstPairUnitTest.java | 68 +++++++++++++------ 2 files changed, 47 insertions(+), 63 deletions(-) delete mode 100644 core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/mapfirstpair/MapFirstPairExample.java diff --git a/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/mapfirstpair/MapFirstPairExample.java b/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/mapfirstpair/MapFirstPairExample.java deleted file mode 100644 index 8e5fc296d4..0000000000 --- a/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/mapfirstpair/MapFirstPairExample.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.baeldung.collections.mapfirstpair; - -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -public class MapFirstPairExample { - - public Map.Entry getFirstPairUsingIterator(Map map) { - if (map == null || map.size() == 0) - return null; - - Iterator> iterator = map.entrySet() - .iterator(); - - if (iterator.hasNext()) - return iterator.next(); - - return null; - } - - public Map.Entry getFirstPairUsingStream(Map map) { - if (map == null || map.size() == 0) - return null; - - Set> entrySet = map.entrySet(); - - return entrySet.stream() - .findFirst() - .get(); - } - - public Map populateMapValues(Map map) { - if (map != null) { - map.put(5, "A"); - map.put(1, "B"); - map.put(2, "C"); - } - return map; - } - -} \ No newline at end of file diff --git a/core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/mapfirstpair/MapFirstPairUnitTest.java b/core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/mapfirstpair/MapFirstPairUnitTest.java index c8198bcc02..b25e0932d8 100644 --- a/core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/mapfirstpair/MapFirstPairUnitTest.java +++ b/core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/mapfirstpair/MapFirstPairUnitTest.java @@ -5,28 +5,54 @@ import static org.junit.Assert.assertNotEquals; import java.util.AbstractMap; import java.util.HashMap; +import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; +import java.util.Set; -import org.junit.Before; import org.junit.Test; public class MapFirstPairUnitTest { - private MapFirstPairExample mapFirstPairExample; + private Map.Entry getFirstPairUsingIterator(Map map) { + if (map == null || map.size() == 0) + return null; - @Before - public void Setup() { + Iterator> iterator = map.entrySet() + .iterator(); - mapFirstPairExample = new MapFirstPairExample(); + if (iterator.hasNext()) + return iterator.next(); + + return null; + } + + private Map.Entry getFirstPairUsingStream(Map map) { + if (map == null || map.size() == 0) + return null; + + Set> entrySet = map.entrySet(); + + return entrySet.stream() + .findFirst() + .get(); + } + + private Map populateMapValues(Map map) { + if (map != null) { + map.put(5, "A"); + map.put(1, "B"); + map.put(2, "C"); + } + return map; } @Test public void whenUsingIteratorForHashMap_thenFirstPairWhichWasNotInsertedFirst() { Map hashMap = new HashMap<>(); - hashMap = mapFirstPairExample.populateMapValues(hashMap); + hashMap = populateMapValues(hashMap); - Map.Entry actualValue = mapFirstPairExample.getFirstPairUsingIterator(hashMap); + Map.Entry actualValue = getFirstPairUsingIterator(hashMap); Map.Entry expectedValue = new AbstractMap.SimpleEntry(1, "B"); Map.Entry pairInsertedFirst = new AbstractMap.SimpleEntry(5, "A"); @@ -37,8 +63,8 @@ public class MapFirstPairUnitTest { @Test public void whenUsingStreamForHashMap_thenFirstPairWhichWasNotInsertedFirst() { Map hashMap = new HashMap<>(); - hashMap = mapFirstPairExample.populateMapValues(hashMap); - Map.Entry actualValue = mapFirstPairExample.getFirstPairUsingStream(hashMap); + hashMap = populateMapValues(hashMap); + Map.Entry actualValue = getFirstPairUsingStream(hashMap); Map.Entry expectedValue = new AbstractMap.SimpleEntry(1, "B"); Map.Entry pairInsertedFirst = new AbstractMap.SimpleEntry(5, "A"); @@ -49,8 +75,8 @@ public class MapFirstPairUnitTest { @Test public void whenUsingIteratorForLinkedHashMap_thenFirstPairWhichWasInsertedFirst() { Map linkedHashMap = new LinkedHashMap<>(); - linkedHashMap = mapFirstPairExample.populateMapValues(linkedHashMap); - Map.Entry actualValue = mapFirstPairExample.getFirstPairUsingIterator(linkedHashMap); + linkedHashMap = populateMapValues(linkedHashMap); + Map.Entry actualValue = getFirstPairUsingIterator(linkedHashMap); Map.Entry expectedValue = new AbstractMap.SimpleEntry(5, "A"); assertEquals(expectedValue, actualValue); @@ -59,9 +85,9 @@ public class MapFirstPairUnitTest { @Test public void whenUsingStreamForLinkedHashMap_thenFirstPairWhichWasInsertedFirst() { Map linkedHashMap = new LinkedHashMap<>(); - linkedHashMap = mapFirstPairExample.populateMapValues(linkedHashMap); + linkedHashMap = populateMapValues(linkedHashMap); - Map.Entry actualValue = mapFirstPairExample.getFirstPairUsingStream(linkedHashMap); + Map.Entry actualValue = getFirstPairUsingStream(linkedHashMap); Map.Entry expectedValue = new AbstractMap.SimpleEntry(5, "A"); assertEquals(expectedValue, actualValue); @@ -70,10 +96,10 @@ public class MapFirstPairUnitTest { @Test public void whenAddedAnElementInHashMap_thenFirstPairChangedUsingIterator() { Map hashMap = new HashMap<>(); - hashMap = mapFirstPairExample.populateMapValues(hashMap); + hashMap = populateMapValues(hashMap); hashMap.put(0, "D"); - Map.Entry actualValue = mapFirstPairExample.getFirstPairUsingIterator(hashMap); + Map.Entry actualValue = getFirstPairUsingIterator(hashMap); Map.Entry expectedValue = new AbstractMap.SimpleEntry(0, "D"); assertEquals(expectedValue, actualValue); @@ -82,10 +108,10 @@ public class MapFirstPairUnitTest { @Test public void whenAddedAnElementInHashMap_thenFirstPairChangedUsingStream() { Map hashMap = new HashMap<>(); - hashMap = mapFirstPairExample.populateMapValues(hashMap); + hashMap = populateMapValues(hashMap); hashMap.put(0, "D"); - Map.Entry actualValue = mapFirstPairExample.getFirstPairUsingStream(hashMap); + Map.Entry actualValue = getFirstPairUsingStream(hashMap); Map.Entry expectedValue = new AbstractMap.SimpleEntry(0, "D"); assertEquals(expectedValue, actualValue); @@ -94,10 +120,10 @@ public class MapFirstPairUnitTest { @Test public void whenAddedAnElementInLinkedHashMap_thenFirstPairRemainUnchangedUsingIterator() { Map linkedHashMap = new LinkedHashMap<>(); - linkedHashMap = mapFirstPairExample.populateMapValues(linkedHashMap); + linkedHashMap = populateMapValues(linkedHashMap); linkedHashMap.put(0, "D"); - Map.Entry actualValue = mapFirstPairExample.getFirstPairUsingIterator(linkedHashMap); + Map.Entry actualValue = getFirstPairUsingIterator(linkedHashMap); Map.Entry expectedValue = new AbstractMap.SimpleEntry(5, "A"); assertEquals(expectedValue, actualValue); @@ -106,10 +132,10 @@ public class MapFirstPairUnitTest { @Test public void whenAddedAnElementInLinkedHashMap_thenFirstPairRemainUnchangedUsingStream() { Map linkedHashMap = new LinkedHashMap<>(); - linkedHashMap = mapFirstPairExample.populateMapValues(linkedHashMap); + linkedHashMap = populateMapValues(linkedHashMap); linkedHashMap.put(0, "D"); - Map.Entry actualValue = mapFirstPairExample.getFirstPairUsingStream(linkedHashMap); + Map.Entry actualValue = getFirstPairUsingStream(linkedHashMap); Map.Entry expectedValue = new AbstractMap.SimpleEntry(5, "A"); assertEquals(expectedValue, actualValue); From 1873207445bf0ea371055e1ca2f97d883badf6cc Mon Sep 17 00:00:00 2001 From: fdpro Date: Thu, 10 Sep 2020 11:47:44 +0200 Subject: [PATCH 100/263] [JAVA-2540] Migrated unit test to integration test as it bootsraps and calls a REST API --- ...eSpecUnitTest.java => HelloResourceSpecIntegrationTest.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename restx/src/test/java/restx/demo/rest/{HelloResourceSpecUnitTest.java => HelloResourceSpecIntegrationTest.java} (91%) diff --git a/restx/src/test/java/restx/demo/rest/HelloResourceSpecUnitTest.java b/restx/src/test/java/restx/demo/rest/HelloResourceSpecIntegrationTest.java similarity index 91% rename from restx/src/test/java/restx/demo/rest/HelloResourceSpecUnitTest.java rename to restx/src/test/java/restx/demo/rest/HelloResourceSpecIntegrationTest.java index f67e4565b3..6ff1a7aad4 100644 --- a/restx/src/test/java/restx/demo/rest/HelloResourceSpecUnitTest.java +++ b/restx/src/test/java/restx/demo/rest/HelloResourceSpecIntegrationTest.java @@ -7,7 +7,7 @@ import restx.tests.RestxSpecTestsRunner; @RunWith(RestxSpecTestsRunner.class) @FindSpecsIn("specs/hello") -public class HelloResourceSpecUnitTest { +public class HelloResourceSpecIntegrationTest { /** * Useless, thanks to both @RunWith(RestxSpecTestsRunner.class) & @FindSpecsIn() From 19f754618ab43d2ee0ce3261292f883806620c67 Mon Sep 17 00:00:00 2001 From: fdpro Date: Thu, 10 Sep 2020 12:22:23 +0200 Subject: [PATCH 101/263] [JAVA-1662] Migrated maven-surefire-plugin version to 2.22.2 --- logging-modules/flogger/pom.xml | 1 + logging-modules/log-mdc/pom.xml | 11 ++++++++++- logging-modules/log4j/pom.xml | 4 ++-- logging-modules/log4j2/pom.xml | 4 ++-- logging-modules/logback/pom.xml | 4 ++-- logging-modules/pom.xml | 11 ++++++++++- 6 files changed, 27 insertions(+), 8 deletions(-) diff --git a/logging-modules/flogger/pom.xml b/logging-modules/flogger/pom.xml index f553a4a961..e9189c8460 100644 --- a/logging-modules/flogger/pom.xml +++ b/logging-modules/flogger/pom.xml @@ -9,6 +9,7 @@ com.baeldung logging-modules 1.0.0-SNAPSHOT + ../pom.xml diff --git a/logging-modules/log-mdc/pom.xml b/logging-modules/log-mdc/pom.xml index bc4800ea37..bc018690f9 100644 --- a/logging-modules/log-mdc/pom.xml +++ b/logging-modules/log-mdc/pom.xml @@ -79,6 +79,8 @@ + logging-service + @@ -93,7 +95,14 @@ - logging-service + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + diff --git a/logging-modules/log4j/pom.xml b/logging-modules/log4j/pom.xml index cc0996a45a..15cd2d530f 100644 --- a/logging-modules/log4j/pom.xml +++ b/logging-modules/log4j/pom.xml @@ -9,9 +9,9 @@ com.baeldung - parent-modules + logging-modules 1.0.0-SNAPSHOT - ../../ + ../pom.xml diff --git a/logging-modules/log4j2/pom.xml b/logging-modules/log4j2/pom.xml index 03a4fd8ab0..e09cbd5d33 100644 --- a/logging-modules/log4j2/pom.xml +++ b/logging-modules/log4j2/pom.xml @@ -7,9 +7,9 @@ com.baeldung - parent-modules + logging-modules 1.0.0-SNAPSHOT - ../../ + ../pom.xml diff --git a/logging-modules/logback/pom.xml b/logging-modules/logback/pom.xml index ee430949df..9f5a3ef294 100644 --- a/logging-modules/logback/pom.xml +++ b/logging-modules/logback/pom.xml @@ -9,9 +9,9 @@ com.baeldung - parent-modules + logging-modules 1.0.0-SNAPSHOT - ../../ + ../pom.xml diff --git a/logging-modules/pom.xml b/logging-modules/pom.xml index b9a1fe77c6..ad78fd20b9 100644 --- a/logging-modules/pom.xml +++ b/logging-modules/pom.xml @@ -10,7 +10,7 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT - .. + ../pom.xml @@ -21,4 +21,13 @@ flogger + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + + From 1fd989f4a8f731a2312838af839a5588cb1e4ab1 Mon Sep 17 00:00:00 2001 From: fdpro Date: Thu, 10 Sep 2020 12:26:56 +0200 Subject: [PATCH 102/263] [JAVA-1662] Upgraded junit-jupiter version to 5.6.2 --- logging-modules/log-mdc/pom.xml | 3 ++- logging-modules/pom.xml | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/logging-modules/log-mdc/pom.xml b/logging-modules/log-mdc/pom.xml index bc018690f9..5e2155fde9 100644 --- a/logging-modules/log-mdc/pom.xml +++ b/logging-modules/log-mdc/pom.xml @@ -80,7 +80,7 @@ logging-service - + @@ -109,6 +109,7 @@ 2.7 3.3.6 3.3.0.Final + 5.6.2 diff --git a/logging-modules/pom.xml b/logging-modules/pom.xml index ad78fd20b9..b5354c7c23 100644 --- a/logging-modules/pom.xml +++ b/logging-modules/pom.xml @@ -30,4 +30,8 @@ + + + 5.6.2 + From fe9e6fc55867c516c07024fd56a134f1be085a68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Dupire?= Date: Thu, 10 Sep 2020 17:21:30 +0200 Subject: [PATCH 103/263] [JAVA-2435] Migrate spring-security-web-sockets to parent-sprint-5 (#10000) * [JAVA-2435] Inherited from parent-boot-5 * [JAVA-2435] Upgraded version of spring-security as well --- spring-security-modules/spring-security-web-sockets/pom.xml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spring-security-modules/spring-security-web-sockets/pom.xml b/spring-security-modules/spring-security-web-sockets/pom.xml index 3a3ec47af5..4aecf296b4 100644 --- a/spring-security-modules/spring-security-web-sockets/pom.xml +++ b/spring-security-modules/spring-security-web-sockets/pom.xml @@ -10,9 +10,9 @@ com.baeldung - parent-spring-4 + parent-spring-5 0.0.1-SNAPSHOT - ../../parent-spring-4 + ../../parent-spring-5 @@ -182,7 +182,6 @@ 5.2.10.Final - 4.2.3.RELEASE 1.11.3.RELEASE 1.2.3 1.5.10.RELEASE From b03fdd2c4b4be0cc5cfa5bbb6eb8d6c892c04924 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Dupire?= Date: Thu, 10 Sep 2020 17:25:13 +0200 Subject: [PATCH 104/263] [JAVA-2434] Inherited from parent-spring-5 (#9994) * [JAVA-2434] Inherited from parent-spring-5 * [JAVA-2434] Upgraded spring-security dependencies as well --- .../spring-security-web-react/pom.xml | 28 ++++++++----------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/spring-security-modules/spring-security-web-react/pom.xml b/spring-security-modules/spring-security-web-react/pom.xml index 459793f496..663c7d76c3 100644 --- a/spring-security-modules/spring-security-web-react/pom.xml +++ b/spring-security-modules/spring-security-web-react/pom.xml @@ -9,9 +9,9 @@ com.baeldung - parent-spring-4 + parent-spring-5 0.0.1-SNAPSHOT - ../../parent-spring-4 + ../../parent-spring-5 @@ -21,17 +21,17 @@ org.springframework.security spring-security-web - ${org.springframework.security.version} + ${spring-security.version} org.springframework.security spring-security-config - ${org.springframework.security.version} + ${spring-security.version} org.springframework.security spring-security-taglibs - ${org.springframework.security.version} + ${spring-security.version} @@ -39,33 +39,33 @@ org.springframework spring-core - ${org.springframework.version} + ${spring.version} org.springframework spring-context - ${org.springframework.version} + ${spring.version} org.springframework spring-beans - ${org.springframework.version} + ${spring.version} org.springframework spring-aop - ${org.springframework.version} + ${spring.version} org.springframework spring-web - ${org.springframework.version} + ${spring.version} org.springframework spring-webmvc - ${org.springframework.version} + ${spring.version} @@ -221,10 +221,6 @@ - - 4.3.6.RELEASE - 4.2.1.RELEASE - 19.0 @@ -236,7 +232,5 @@ v8.11.3 6.1.0 - - \ No newline at end of file From 0acc6a25e1fca42328baf803b024ebe57e354f56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Dupire?= Date: Thu, 10 Sep 2020 17:27:24 +0200 Subject: [PATCH 105/263] [JAVA-2306] Fixed failing integration test (#9999) --- .../spring/jdbc/template/guide/config/SpringJdbcConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/guide/config/SpringJdbcConfig.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/guide/config/SpringJdbcConfig.java index 0e81babd9a..7cffe5342a 100644 --- a/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/guide/config/SpringJdbcConfig.java +++ b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/guide/config/SpringJdbcConfig.java @@ -10,7 +10,7 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; @Configuration -@ComponentScan("com.baeldung.spring.jdbc") +@ComponentScan("com.baeldung.spring.jdbc.template.guide") public class SpringJdbcConfig { @Bean From 64d5c717cb769ebfda351b2a82f682291d1d42bd Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Thu, 10 Sep 2020 22:43:55 +0530 Subject: [PATCH 106/263] JAVA-2412: Update "Spring Template Engine" article --- spring-mvc-basics-2/pom.xml | 4 ++-- .../baeldung/spring/configuration/EmailConfiguration.java | 4 ++-- .../spring/configuration/ThymeleafConfiguration.java | 6 +++--- .../java/com/baeldung/spring/mail/EmailServiceImpl.java | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/spring-mvc-basics-2/pom.xml b/spring-mvc-basics-2/pom.xml index 026ddf8e72..6bcb1e90e5 100644 --- a/spring-mvc-basics-2/pom.xml +++ b/spring-mvc-basics-2/pom.xml @@ -69,7 +69,7 @@ org.thymeleaf - thymeleaf-spring4 + thymeleaf-spring5 ${org.thymeleaf-version} @@ -164,7 +164,7 @@ 6.0.10.Final enter-location-of-server 1.3.2 - 3.0.7.RELEASE + 3.0.11.RELEASE 2.4.12 2.3.27-incubating 1.2.5 diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/EmailConfiguration.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/EmailConfiguration.java index 1bbbc51304..4bd692f609 100644 --- a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/EmailConfiguration.java +++ b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/EmailConfiguration.java @@ -11,8 +11,8 @@ import org.springframework.mail.javamail.JavaMailSender; import org.springframework.mail.javamail.JavaMailSenderImpl; import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer; import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver; -import org.thymeleaf.spring4.SpringTemplateEngine; -import org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver; +import org.thymeleaf.spring5.SpringTemplateEngine; +import org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver; @Configuration @ComponentScan(basePackages = { "com.baeldung.spring.mail" }) diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/ThymeleafConfiguration.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/ThymeleafConfiguration.java index 257dbc718a..2f025c1ad2 100644 --- a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/ThymeleafConfiguration.java +++ b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/ThymeleafConfiguration.java @@ -4,9 +4,9 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.thymeleaf.spring4.SpringTemplateEngine; -import org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver; -import org.thymeleaf.spring4.view.ThymeleafViewResolver; +import org.thymeleaf.spring5.SpringTemplateEngine; +import org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver; +import org.thymeleaf.spring5.view.ThymeleafViewResolver; @Configuration @EnableWebMvc diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/mail/EmailServiceImpl.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/mail/EmailServiceImpl.java index cbcb8f4e34..1eb7a5f8b4 100644 --- a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/mail/EmailServiceImpl.java +++ b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/mail/EmailServiceImpl.java @@ -19,7 +19,7 @@ import org.springframework.stereotype.Service; import org.springframework.ui.freemarker.FreeMarkerTemplateUtils; import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer; import org.thymeleaf.context.Context; -import org.thymeleaf.spring4.SpringTemplateEngine; +import org.thymeleaf.spring5.SpringTemplateEngine; import freemarker.template.Template; import freemarker.template.TemplateException; From 2ccba495c562bfc2736448c6009d654210b5796a Mon Sep 17 00:00:00 2001 From: Loredana Date: Thu, 10 Sep 2020 20:19:19 +0300 Subject: [PATCH 107/263] fix package --- .../src/main/java/com/baeldung/optionalpathvars/Article.java | 2 +- .../baeldung/optionalpathvars/ArticleViewerController.java | 4 ++-- .../optionalpathvars/ArticleViewerWithMapParamController.java | 4 ++-- .../ArticleViewerWithOptionalParamController.java | 4 ++-- .../ArticleViewerWithRequiredAttributeController.java | 4 ++-- .../ArticleViewerWithTwoSeparateMethodsController.java | 4 ++-- .../ArticleViewerControllerIntegrationTest.java | 2 +- ...ticleViewerControllerWithOptionalParamIntegrationTest.java | 2 +- ...eViewerControllerWithRequiredAttributeIntegrationTest.java | 2 +- .../ArticleViewerWithMapParamIntegrationTest.java | 2 +- .../ArticleViewerWithTwoSeparateMethodsIntegrationTest.java | 2 +- 11 files changed, 16 insertions(+), 16 deletions(-) diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/Article.java b/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/Article.java index f6675295ed..5a9f406b56 100644 --- a/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/Article.java +++ b/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/Article.java @@ -1,4 +1,4 @@ -package com.baeldung.controller.optionalpathvars; +package com.baeldung.optionalpathvars; public class Article { diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerController.java b/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerController.java index 14b16e148b..1876798bd6 100644 --- a/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerController.java +++ b/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerController.java @@ -1,6 +1,6 @@ -package com.baeldung.controller.optionalpathvars; +package com.baeldung.optionalpathvars; -import static com.baeldung.controller.optionalpathvars.Article.DEFAULT_ARTICLE; +import static com.baeldung.optionalpathvars.Article.DEFAULT_ARTICLE; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithMapParamController.java b/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithMapParamController.java index 50744b6067..c989ddfa52 100644 --- a/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithMapParamController.java +++ b/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithMapParamController.java @@ -1,6 +1,6 @@ -package com.baeldung.controller.optionalpathvars; +package com.baeldung.optionalpathvars; -import static com.baeldung.controller.optionalpathvars.Article.DEFAULT_ARTICLE; +import static com.baeldung.optionalpathvars.Article.DEFAULT_ARTICLE; import java.util.Map; diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithOptionalParamController.java b/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithOptionalParamController.java index ff645fbcc7..75e35bf799 100644 --- a/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithOptionalParamController.java +++ b/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithOptionalParamController.java @@ -1,6 +1,6 @@ -package com.baeldung.controller.optionalpathvars; +package com.baeldung.optionalpathvars; -import static com.baeldung.controller.optionalpathvars.Article.DEFAULT_ARTICLE; +import static com.baeldung.optionalpathvars.Article.DEFAULT_ARTICLE; import java.util.Optional; diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithRequiredAttributeController.java b/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithRequiredAttributeController.java index 8cd1539391..7548747f05 100644 --- a/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithRequiredAttributeController.java +++ b/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithRequiredAttributeController.java @@ -1,6 +1,6 @@ -package com.baeldung.controller.optionalpathvars; +package com.baeldung.optionalpathvars; -import static com.baeldung.controller.optionalpathvars.Article.DEFAULT_ARTICLE; +import static com.baeldung.optionalpathvars.Article.DEFAULT_ARTICLE; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithTwoSeparateMethodsController.java b/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithTwoSeparateMethodsController.java index 0ea401a589..beb520c1b4 100644 --- a/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithTwoSeparateMethodsController.java +++ b/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithTwoSeparateMethodsController.java @@ -1,6 +1,6 @@ -package com.baeldung.controller.optionalpathvars; +package com.baeldung.optionalpathvars; -import static com.baeldung.controller.optionalpathvars.Article.DEFAULT_ARTICLE; +import static com.baeldung.optionalpathvars.Article.DEFAULT_ARTICLE; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerControllerIntegrationTest.java b/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerControllerIntegrationTest.java index 173ac165c3..0e2313c2ac 100644 --- a/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerControllerIntegrationTest.java +++ b/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerControllerIntegrationTest.java @@ -1,4 +1,4 @@ -package com.baeldung.controller.optionalpathvars; +package com.baeldung.optionalpathvars; import org.junit.Before; import org.junit.Test; diff --git a/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerControllerWithOptionalParamIntegrationTest.java b/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerControllerWithOptionalParamIntegrationTest.java index 1fadfb7038..094995ba67 100644 --- a/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerControllerWithOptionalParamIntegrationTest.java +++ b/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerControllerWithOptionalParamIntegrationTest.java @@ -1,4 +1,4 @@ -package com.baeldung.controller.optionalpathvars; +package com.baeldung.optionalpathvars; import org.junit.Before; import org.junit.Test; diff --git a/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerControllerWithRequiredAttributeIntegrationTest.java b/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerControllerWithRequiredAttributeIntegrationTest.java index 00d620ef9a..a4b12c7163 100644 --- a/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerControllerWithRequiredAttributeIntegrationTest.java +++ b/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerControllerWithRequiredAttributeIntegrationTest.java @@ -1,4 +1,4 @@ -package com.baeldung.controller.optionalpathvars; +package com.baeldung.optionalpathvars; import org.junit.Before; import org.junit.Test; diff --git a/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerWithMapParamIntegrationTest.java b/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerWithMapParamIntegrationTest.java index f7fff714a9..044a1c8bce 100644 --- a/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerWithMapParamIntegrationTest.java +++ b/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerWithMapParamIntegrationTest.java @@ -1,4 +1,4 @@ -package com.baeldung.controller.optionalpathvars; +package com.baeldung.optionalpathvars; import org.junit.Before; import org.junit.Test; diff --git a/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerWithTwoSeparateMethodsIntegrationTest.java b/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerWithTwoSeparateMethodsIntegrationTest.java index b4e4c9ade5..1ca926277d 100644 --- a/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerWithTwoSeparateMethodsIntegrationTest.java +++ b/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerWithTwoSeparateMethodsIntegrationTest.java @@ -1,4 +1,4 @@ -package com.baeldung.controller.optionalpathvars; +package com.baeldung.optionalpathvars; import org.junit.Before; import org.junit.Test; From c2ac81100963b02f318de566bfb0d7aaaf389151 Mon Sep 17 00:00:00 2001 From: Ashley Frieze Date: Sat, 29 Aug 2020 00:07:53 +0100 Subject: [PATCH 108/263] BAEL-3998-Aws Lambda with Hibernate --- aws-lambda/lambda/pom.xml | 100 ++++++++++++++++ .../sam-templates/template-implicit.yaml | 0 .../template-inline-swagger.yaml | 0 .../baeldung/lambda/LambdaMethodHandler.java | 0 .../baeldung/lambda/LambdaRequestHandler.java | 0 .../lambda/LambdaRequestStreamHandler.java | 0 .../lambda/apigateway/APIDemoHandler.java | 0 .../lambda/apigateway/model/Person.java | 0 .../lambda/dynamodb/SavePersonHandler.java | 0 .../lambda/dynamodb/bean/PersonRequest.java | 0 .../lambda/dynamodb/bean/PersonResponse.java | 0 .../src/main/resources/logback.xml | 0 aws-lambda/pom.xml | 90 ++------------- aws-lambda/shipping-tracker/.gitignore | 1 + .../shipping-tracker/ShippingFunction/pom.xml | 73 ++++++++++++ .../com/baeldung/lambda/shipping/App.java | 108 ++++++++++++++++++ .../com/baeldung/lambda/shipping/Checkin.java | 28 +++++ .../baeldung/lambda/shipping/Consignment.java | 77 +++++++++++++ .../com/baeldung/lambda/shipping/Item.java | 38 ++++++ .../baeldung/lambda/shipping/ShippingDao.java | 25 ++++ .../lambda/shipping/ShippingService.java | 62 ++++++++++ aws-lambda/shipping-tracker/template.yaml | 47 ++++++++ 22 files changed, 566 insertions(+), 83 deletions(-) create mode 100644 aws-lambda/lambda/pom.xml rename aws-lambda/{ => lambda}/sam-templates/template-implicit.yaml (100%) rename aws-lambda/{ => lambda}/sam-templates/template-inline-swagger.yaml (100%) rename aws-lambda/{ => lambda}/src/main/java/com/baeldung/lambda/LambdaMethodHandler.java (100%) rename aws-lambda/{ => lambda}/src/main/java/com/baeldung/lambda/LambdaRequestHandler.java (100%) rename aws-lambda/{ => lambda}/src/main/java/com/baeldung/lambda/LambdaRequestStreamHandler.java (100%) rename aws-lambda/{ => lambda}/src/main/java/com/baeldung/lambda/apigateway/APIDemoHandler.java (100%) rename aws-lambda/{ => lambda}/src/main/java/com/baeldung/lambda/apigateway/model/Person.java (100%) rename aws-lambda/{ => lambda}/src/main/java/com/baeldung/lambda/dynamodb/SavePersonHandler.java (100%) rename aws-lambda/{ => lambda}/src/main/java/com/baeldung/lambda/dynamodb/bean/PersonRequest.java (100%) rename aws-lambda/{ => lambda}/src/main/java/com/baeldung/lambda/dynamodb/bean/PersonResponse.java (100%) rename aws-lambda/{ => lambda}/src/main/resources/logback.xml (100%) create mode 100644 aws-lambda/shipping-tracker/.gitignore create mode 100644 aws-lambda/shipping-tracker/ShippingFunction/pom.xml create mode 100644 aws-lambda/shipping-tracker/ShippingFunction/src/main/java/com/baeldung/lambda/shipping/App.java create mode 100644 aws-lambda/shipping-tracker/ShippingFunction/src/main/java/com/baeldung/lambda/shipping/Checkin.java create mode 100644 aws-lambda/shipping-tracker/ShippingFunction/src/main/java/com/baeldung/lambda/shipping/Consignment.java create mode 100644 aws-lambda/shipping-tracker/ShippingFunction/src/main/java/com/baeldung/lambda/shipping/Item.java create mode 100644 aws-lambda/shipping-tracker/ShippingFunction/src/main/java/com/baeldung/lambda/shipping/ShippingDao.java create mode 100644 aws-lambda/shipping-tracker/ShippingFunction/src/main/java/com/baeldung/lambda/shipping/ShippingService.java create mode 100644 aws-lambda/shipping-tracker/template.yaml diff --git a/aws-lambda/lambda/pom.xml b/aws-lambda/lambda/pom.xml new file mode 100644 index 0000000000..2d903aabc5 --- /dev/null +++ b/aws-lambda/lambda/pom.xml @@ -0,0 +1,100 @@ + + + 4.0.0 + aws-lambda-examples + 0.1.0-SNAPSHOT + aws-lambda-examples + jar + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + ../../ + + + + + com.amazonaws + aws-java-sdk-dynamodb + ${aws-java-sdk.version} + + + com.amazonaws + aws-java-sdk-core + ${aws-java-sdk.version} + + + com.amazonaws + aws-lambda-java-core + ${aws-lambda-java-core.version} + + + commons-logging + commons-logging + + + + + com.amazonaws + aws-lambda-java-events + ${aws-lambda-java-events.version} + + + commons-logging + commons-logging + + + + + com.google.code.gson + gson + ${gson.version} + + + commons-io + commons-io + ${commons-io.version} + + + com.googlecode.json-simple + json-simple + ${json-simple.version} + + + + + + + org.apache.maven.plugins + maven-shade-plugin + ${maven-shade-plugin.version} + + false + + + + package + + shade + + + + + + + + + 1.1.1 + 2.5 + 1.3.0 + 1.2.0 + 2.8.2 + 1.11.241 + 3.0.0 + + + diff --git a/aws-lambda/sam-templates/template-implicit.yaml b/aws-lambda/lambda/sam-templates/template-implicit.yaml similarity index 100% rename from aws-lambda/sam-templates/template-implicit.yaml rename to aws-lambda/lambda/sam-templates/template-implicit.yaml diff --git a/aws-lambda/sam-templates/template-inline-swagger.yaml b/aws-lambda/lambda/sam-templates/template-inline-swagger.yaml similarity index 100% rename from aws-lambda/sam-templates/template-inline-swagger.yaml rename to aws-lambda/lambda/sam-templates/template-inline-swagger.yaml diff --git a/aws-lambda/src/main/java/com/baeldung/lambda/LambdaMethodHandler.java b/aws-lambda/lambda/src/main/java/com/baeldung/lambda/LambdaMethodHandler.java similarity index 100% rename from aws-lambda/src/main/java/com/baeldung/lambda/LambdaMethodHandler.java rename to aws-lambda/lambda/src/main/java/com/baeldung/lambda/LambdaMethodHandler.java diff --git a/aws-lambda/src/main/java/com/baeldung/lambda/LambdaRequestHandler.java b/aws-lambda/lambda/src/main/java/com/baeldung/lambda/LambdaRequestHandler.java similarity index 100% rename from aws-lambda/src/main/java/com/baeldung/lambda/LambdaRequestHandler.java rename to aws-lambda/lambda/src/main/java/com/baeldung/lambda/LambdaRequestHandler.java diff --git a/aws-lambda/src/main/java/com/baeldung/lambda/LambdaRequestStreamHandler.java b/aws-lambda/lambda/src/main/java/com/baeldung/lambda/LambdaRequestStreamHandler.java similarity index 100% rename from aws-lambda/src/main/java/com/baeldung/lambda/LambdaRequestStreamHandler.java rename to aws-lambda/lambda/src/main/java/com/baeldung/lambda/LambdaRequestStreamHandler.java diff --git a/aws-lambda/src/main/java/com/baeldung/lambda/apigateway/APIDemoHandler.java b/aws-lambda/lambda/src/main/java/com/baeldung/lambda/apigateway/APIDemoHandler.java similarity index 100% rename from aws-lambda/src/main/java/com/baeldung/lambda/apigateway/APIDemoHandler.java rename to aws-lambda/lambda/src/main/java/com/baeldung/lambda/apigateway/APIDemoHandler.java diff --git a/aws-lambda/src/main/java/com/baeldung/lambda/apigateway/model/Person.java b/aws-lambda/lambda/src/main/java/com/baeldung/lambda/apigateway/model/Person.java similarity index 100% rename from aws-lambda/src/main/java/com/baeldung/lambda/apigateway/model/Person.java rename to aws-lambda/lambda/src/main/java/com/baeldung/lambda/apigateway/model/Person.java diff --git a/aws-lambda/src/main/java/com/baeldung/lambda/dynamodb/SavePersonHandler.java b/aws-lambda/lambda/src/main/java/com/baeldung/lambda/dynamodb/SavePersonHandler.java similarity index 100% rename from aws-lambda/src/main/java/com/baeldung/lambda/dynamodb/SavePersonHandler.java rename to aws-lambda/lambda/src/main/java/com/baeldung/lambda/dynamodb/SavePersonHandler.java diff --git a/aws-lambda/src/main/java/com/baeldung/lambda/dynamodb/bean/PersonRequest.java b/aws-lambda/lambda/src/main/java/com/baeldung/lambda/dynamodb/bean/PersonRequest.java similarity index 100% rename from aws-lambda/src/main/java/com/baeldung/lambda/dynamodb/bean/PersonRequest.java rename to aws-lambda/lambda/src/main/java/com/baeldung/lambda/dynamodb/bean/PersonRequest.java diff --git a/aws-lambda/src/main/java/com/baeldung/lambda/dynamodb/bean/PersonResponse.java b/aws-lambda/lambda/src/main/java/com/baeldung/lambda/dynamodb/bean/PersonResponse.java similarity index 100% rename from aws-lambda/src/main/java/com/baeldung/lambda/dynamodb/bean/PersonResponse.java rename to aws-lambda/lambda/src/main/java/com/baeldung/lambda/dynamodb/bean/PersonResponse.java diff --git a/aws-lambda/src/main/resources/logback.xml b/aws-lambda/lambda/src/main/resources/logback.xml similarity index 100% rename from aws-lambda/src/main/resources/logback.xml rename to aws-lambda/lambda/src/main/resources/logback.xml diff --git a/aws-lambda/pom.xml b/aws-lambda/pom.xml index e1d2c7df27..116fc801aa 100644 --- a/aws-lambda/pom.xml +++ b/aws-lambda/pom.xml @@ -5,95 +5,19 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 aws-lambda - 0.1.0-SNAPSHOT aws-lambda - jar + pom com.baeldung parent-modules 1.0.0-SNAPSHOT + ../ - - - com.amazonaws - aws-java-sdk-dynamodb - ${aws-java-sdk.version} - - - com.amazonaws - aws-java-sdk-core - ${aws-java-sdk.version} - - - com.amazonaws - aws-lambda-java-core - ${aws-lambda-java-core.version} - - - commons-logging - commons-logging - - - - - com.amazonaws - aws-lambda-java-events - ${aws-lambda-java-events.version} - - - commons-logging - commons-logging - - - - - com.google.code.gson - gson - ${gson.version} - - - commons-io - commons-io - ${commons-io.version} - - - com.googlecode.json-simple - json-simple - ${json-simple.version} - - + + lambda + shipping-tracker/ShippingFunction + - - - - org.apache.maven.plugins - maven-shade-plugin - ${maven-shade-plugin.version} - - false - - - - package - - shade - - - - - - - - - 1.1.1 - 2.5 - 1.3.0 - 1.2.0 - 2.8.2 - 1.11.241 - 3.0.0 - - - \ No newline at end of file + diff --git a/aws-lambda/shipping-tracker/.gitignore b/aws-lambda/shipping-tracker/.gitignore new file mode 100644 index 0000000000..9984c2e554 --- /dev/null +++ b/aws-lambda/shipping-tracker/.gitignore @@ -0,0 +1 @@ +.aws-sam/ diff --git a/aws-lambda/shipping-tracker/ShippingFunction/pom.xml b/aws-lambda/shipping-tracker/ShippingFunction/pom.xml new file mode 100644 index 0000000000..ac39c9ea54 --- /dev/null +++ b/aws-lambda/shipping-tracker/ShippingFunction/pom.xml @@ -0,0 +1,73 @@ + + 4.0.0 + com.baeldung + ShippingFunction + 1.0 + jar + Shipping Tracker Lambda Function + + 1.8 + 1.8 + 5.4.21.Final + + + + + com.amazonaws + aws-lambda-java-core + 1.2.0 + + + com.amazonaws + aws-lambda-java-events + 3.1.0 + + + com.fasterxml.jackson.core + jackson-databind + 2.11.2 + + + junit + junit + 4.12 + test + + + org.hibernate + hibernate-core + ${hibernate.version} + + + org.hibernate + hibernate-hikaricp + ${hibernate.version} + + + org.postgresql + postgresql + 42.2.16 + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.1.1 + + + + + package + + shade + + + + + + + diff --git a/aws-lambda/shipping-tracker/ShippingFunction/src/main/java/com/baeldung/lambda/shipping/App.java b/aws-lambda/shipping-tracker/ShippingFunction/src/main/java/com/baeldung/lambda/shipping/App.java new file mode 100644 index 0000000000..719725598c --- /dev/null +++ b/aws-lambda/shipping-tracker/ShippingFunction/src/main/java/com/baeldung/lambda/shipping/App.java @@ -0,0 +1,108 @@ +package com.baeldung.lambda.shipping; + +import com.amazonaws.services.lambda.runtime.Context; +import com.amazonaws.services.lambda.runtime.RequestHandler; +import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent; +import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.hibernate.SessionFactory; +import org.hibernate.boot.MetadataSources; +import org.hibernate.boot.registry.StandardServiceRegistry; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; + +import java.util.HashMap; +import java.util.Map; + +import static org.hibernate.cfg.AvailableSettings.*; +import static org.hibernate.cfg.AvailableSettings.PASS; + +/** + * Handler for requests to Lambda function. + */ +public class App implements RequestHandler { +private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); + + public APIGatewayProxyResponseEvent handleRequest(APIGatewayProxyRequestEvent input, Context context) { + try (SessionFactory sessionFactory = createSessionFactory()) { + ShippingService service = new ShippingService(sessionFactory, new ShippingDao()); + return routeRequest(input, service); + } + } + + private APIGatewayProxyResponseEvent routeRequest(APIGatewayProxyRequestEvent input, ShippingService service) { + Map headers = new HashMap<>(); + headers.put("Content-Type", "application/json"); + headers.put("X-Custom-Header", "application/json"); + + Object result = "OK"; + + switch (input.getResource()) { + case "/consignment": + result = service.createConsignment( + fromJson(input.getBody(), Consignment.class)); + break; + case "/consignment/{id}": + result = service.view(input.getPathParameters().get("id")); + break; + case "/consignment/{id}/item": + service.addItem(input.getPathParameters().get("id"), + fromJson(input.getBody(), Item.class)); + break; + case "/consignment/{id}/checkin": + service.checkIn(input.getPathParameters().get("id"), + fromJson(input.getBody(), Checkin.class)); + break; + } + + return new APIGatewayProxyResponseEvent() + .withHeaders(headers) + .withStatusCode(200) + .withBody(toJson(result)); + } + + private static String toJson(T object) { + try { + return OBJECT_MAPPER.writeValueAsString(object); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + } + + private static T fromJson(String json, Class type) { + try { + return OBJECT_MAPPER.readValue(json, type); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + } + + private static SessionFactory createSessionFactory() { + Map settings = new HashMap<>(); + settings.put(URL, System.getenv("DB_URL")); + settings.put(DIALECT, "org.hibernate.dialect.PostgreSQLDialect"); + settings.put(DEFAULT_SCHEMA, "shipping"); + settings.put(DRIVER, "org.postgresql.Driver"); + settings.put(USER, System.getenv("DB_USER")); + settings.put(PASS, System.getenv("DB_PASSWORD")); + settings.put("hibernate.hikari.connectionTimeout", "20000"); + settings.put("hibernate.hikari.minimumIdle", "1"); + settings.put("hibernate.hikari.maximumPoolSize", "2"); + settings.put("hibernate.hikari.idleTimeout", "30000"); + +// commented out as we only need them on first use +// settings.put(HBM2DDL_AUTO, "create-only"); +// settings.put(HBM2DDL_DATABASE_ACTION, "create"); + + StandardServiceRegistry registry = new StandardServiceRegistryBuilder() + .applySettings(settings) + .build(); + + return new MetadataSources(registry) + .addAnnotatedClass(Consignment.class) + .addAnnotatedClass(Item.class) + .addAnnotatedClass(Checkin.class) + .buildMetadata() + .buildSessionFactory(); + } +} diff --git a/aws-lambda/shipping-tracker/ShippingFunction/src/main/java/com/baeldung/lambda/shipping/Checkin.java b/aws-lambda/shipping-tracker/ShippingFunction/src/main/java/com/baeldung/lambda/shipping/Checkin.java new file mode 100644 index 0000000000..93e6404749 --- /dev/null +++ b/aws-lambda/shipping-tracker/ShippingFunction/src/main/java/com/baeldung/lambda/shipping/Checkin.java @@ -0,0 +1,28 @@ +package com.baeldung.lambda.shipping; + +import javax.persistence.Column; +import javax.persistence.Embeddable; + +@Embeddable +public class Checkin { + private String timeStamp; + private String location; + + @Column(name = "timestamp") + public String getTimeStamp() { + return timeStamp; + } + + public void setTimeStamp(String timeStamp) { + this.timeStamp = timeStamp; + } + + @Column(name = "location") + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } +} diff --git a/aws-lambda/shipping-tracker/ShippingFunction/src/main/java/com/baeldung/lambda/shipping/Consignment.java b/aws-lambda/shipping-tracker/ShippingFunction/src/main/java/com/baeldung/lambda/shipping/Consignment.java new file mode 100644 index 0000000000..1a2371b37f --- /dev/null +++ b/aws-lambda/shipping-tracker/ShippingFunction/src/main/java/com/baeldung/lambda/shipping/Consignment.java @@ -0,0 +1,77 @@ +package com.baeldung.lambda.shipping; + +import javax.persistence.*; +import java.util.ArrayList; +import java.util.List; + +import static javax.persistence.FetchType.EAGER; + +@Entity(name = "consignment") +@Table(name = "consignment") +public class Consignment { + private String id; + private String source; + private String destination; + private boolean isDelivered; + private List items = new ArrayList<>(); + private List checkins = new ArrayList<>(); + + @Id + @Column(name = "consignment_id") + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @Column(name = "source") + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + @Column(name = "destination") + public String getDestination() { + return destination; + } + + public void setDestination(String destination) { + this.destination = destination; + } + + @Column(name = "delivered", columnDefinition = "boolean") + public boolean isDelivered() { + return isDelivered; + } + + public void setDelivered(boolean delivered) { + isDelivered = delivered; + } + + @ElementCollection(fetch = EAGER) + @CollectionTable(name = "consignment_item", joinColumns = @JoinColumn(name = "consignment_id")) + @OrderColumn(name = "item_index") + public List getItems() { + return items; + } + + public void setItems(List items) { + this.items = items; + } + + @ElementCollection(fetch = EAGER) + @CollectionTable(name = "consignment_checkin", joinColumns = @JoinColumn(name = "consignment_id")) + @OrderColumn(name = "checkin_index") + public List getCheckins() { + return checkins; + } + + public void setCheckins(List checkins) { + this.checkins = checkins; + } +} diff --git a/aws-lambda/shipping-tracker/ShippingFunction/src/main/java/com/baeldung/lambda/shipping/Item.java b/aws-lambda/shipping-tracker/ShippingFunction/src/main/java/com/baeldung/lambda/shipping/Item.java new file mode 100644 index 0000000000..de6194e180 --- /dev/null +++ b/aws-lambda/shipping-tracker/ShippingFunction/src/main/java/com/baeldung/lambda/shipping/Item.java @@ -0,0 +1,38 @@ +package com.baeldung.lambda.shipping; + +import javax.persistence.Column; +import javax.persistence.Embeddable; + +@Embeddable +public class Item { + private String location; + private String description; + private String timeStamp; + + @Column(name = "location") + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } + + @Column(name = "description") + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @Column(name = "timestamp") + public String getTimeStamp() { + return timeStamp; + } + + public void setTimeStamp(String timeStamp) { + this.timeStamp = timeStamp; + } +} diff --git a/aws-lambda/shipping-tracker/ShippingFunction/src/main/java/com/baeldung/lambda/shipping/ShippingDao.java b/aws-lambda/shipping-tracker/ShippingFunction/src/main/java/com/baeldung/lambda/shipping/ShippingDao.java new file mode 100644 index 0000000000..369dc33935 --- /dev/null +++ b/aws-lambda/shipping-tracker/ShippingFunction/src/main/java/com/baeldung/lambda/shipping/ShippingDao.java @@ -0,0 +1,25 @@ +package com.baeldung.lambda.shipping; + +import org.hibernate.Session; +import org.hibernate.Transaction; + +import java.util.Optional; + +public class ShippingDao { + /** + * Save a consignment to the database + * @param consignment the consignment to save + */ + public void save(Session session, Consignment consignment) { + Transaction transaction = session.beginTransaction(); + session.save(consignment); + transaction.commit(); + } + + /** + * Find a consignment in the database by id + */ + public Optional find(Session session, String id) { + return Optional.ofNullable(session.get(Consignment.class, id)); + } +} diff --git a/aws-lambda/shipping-tracker/ShippingFunction/src/main/java/com/baeldung/lambda/shipping/ShippingService.java b/aws-lambda/shipping-tracker/ShippingFunction/src/main/java/com/baeldung/lambda/shipping/ShippingService.java new file mode 100644 index 0000000000..4c951068ea --- /dev/null +++ b/aws-lambda/shipping-tracker/ShippingFunction/src/main/java/com/baeldung/lambda/shipping/ShippingService.java @@ -0,0 +1,62 @@ +package com.baeldung.lambda.shipping; + +import org.hibernate.Session; +import org.hibernate.SessionFactory; + +import java.util.Comparator; +import java.util.UUID; + +public class ShippingService { + private SessionFactory sessionFactory; + private ShippingDao shippingDao; + + public ShippingService(SessionFactory sessionFactory, ShippingDao shippingDao) { + this.sessionFactory = sessionFactory; + this.shippingDao = shippingDao; + } + + public String createConsignment(Consignment consignment) { + try (Session session = sessionFactory.openSession()) { + consignment.setDelivered(false); + consignment.setId(UUID.randomUUID().toString()); + shippingDao.save(session, consignment); + return consignment.getId(); + } + } + + public void addItem(String consignmentId, Item item) { + try (Session session = sessionFactory.openSession()) { + shippingDao.find(session, consignmentId) + .ifPresent(consignment -> addItem(session, consignment, item)); + } + } + + private void addItem(Session session, Consignment consignment, Item item) { + consignment.getItems() + .add(item); + shippingDao.save(session, consignment); + } + + public void checkIn(String consignmentId, Checkin checkin) { + try (Session session = sessionFactory.openSession()) { + shippingDao.find(session, consignmentId) + .ifPresent(consignment -> checkIn(session, consignment, checkin)); + } + } + + private void checkIn(Session session, Consignment consignment, Checkin checkin) { + consignment.getCheckins().add(checkin); + consignment.getCheckins().sort(Comparator.comparing(Checkin::getTimeStamp)); + if (checkin.getLocation().equals(consignment.getDestination())) { + consignment.setDelivered(true); + } + shippingDao.save(session, consignment); + } + + public Consignment view(String consignmentId) { + try (Session session = sessionFactory.openSession()) { + return shippingDao.find(session, consignmentId) + .orElseGet(Consignment::new); + } + } +} diff --git a/aws-lambda/shipping-tracker/template.yaml b/aws-lambda/shipping-tracker/template.yaml new file mode 100644 index 0000000000..ec75c51ba1 --- /dev/null +++ b/aws-lambda/shipping-tracker/template.yaml @@ -0,0 +1,47 @@ +AWSTemplateFormatVersion: '2010-09-09' +Transform: AWS::Serverless-2016-10-31 +Description: > + shipping-tracker + + Sample SAM Template for shipping-tracker + +# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst +Globals: + Function: + Timeout: 20 + +Resources: + ShippingFunction: + Type: AWS::Serverless::Function + Properties: + CodeUri: ShippingFunction + Handler: com.baeldung.lambda.shipping.App::handleRequest + Runtime: java8 + MemorySize: 512 + Environment: + Variables: + DB_URL: jdbc:postgresql://postgres/postgres + DB_USER: postgres + DB_PASSWORD: password + Events: + CreateConsignment: + Type: Api + Properties: + Path: /consignment + Method: post + AddItem: + Type: Api + Properties: + Path: /consignment/{id}/item + Method: post + CheckIn: + Type: Api + Properties: + Path: /consignment/{id}/checkin + Method: post + ViewConsignment: + Type: Api + Properties: + Path: /consignment/{id} + Method: get + From fdc36375ff380dac6d98451c185205eac3507b6b Mon Sep 17 00:00:00 2001 From: Maiklins Date: Thu, 10 Sep 2020 19:26:04 +0200 Subject: [PATCH 109/263] Java-2602 Check spring-websockets PR (#10002) Co-authored-by: mikr --- .../{resources/chat.html => index.html} | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) rename spring-websockets/src/main/webapp/{resources/chat.html => index.html} (85%) diff --git a/spring-websockets/src/main/webapp/resources/chat.html b/spring-websockets/src/main/webapp/index.html similarity index 85% rename from spring-websockets/src/main/webapp/resources/chat.html rename to spring-websockets/src/main/webapp/index.html index 17c8494dd8..2bf36d59f5 100644 --- a/spring-websockets/src/main/webapp/resources/chat.html +++ b/spring-websockets/src/main/webapp/index.html @@ -2,63 +2,63 @@ Chat WebSocket - - + + From 43fb479c815a010c983560885f8b713eefd4347f Mon Sep 17 00:00:00 2001 From: Usman Mohyuddin Date: Thu, 10 Sep 2020 22:39:44 +0500 Subject: [PATCH 110/263] update the PR with removal of README file and update pom.xml files according to comments --- core-groovy-strings/README.md | 8 -- core-groovy-strings/pom.xml | 114 +++++++++++++----- .../removeprefix/RemovePrefixTest.groovy | 37 ++++-- pom.xml | 2 + 4 files changed, 108 insertions(+), 53 deletions(-) delete mode 100644 core-groovy-strings/README.md diff --git a/core-groovy-strings/README.md b/core-groovy-strings/README.md deleted file mode 100644 index e3202e2dd0..0000000000 --- a/core-groovy-strings/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# Core Groovy Strings - -This module contains articles about core Groovy strings concepts - -## Relevant articles: - -- [Remove prefix in Groovy]() -- [[<-- Prev]](/core-groovy-strings) diff --git a/core-groovy-strings/pom.xml b/core-groovy-strings/pom.xml index 059b53662c..1144d748ee 100644 --- a/core-groovy-strings/pom.xml +++ b/core-groovy-strings/pom.xml @@ -3,70 +3,120 @@ xmlns="http://maven.apache.org/POM/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"> - com.baeldung 4.0.0 core-groovy-strings 1.0-SNAPSHOT core-groovy-strings jar - + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + org.codehaus.groovy - groovy-all + 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 + - src/main/groovy - src/main/java - org.codehaus.groovy - groovy-eclipse-compiler - ${groovy.compiler.version} - true + org.codehaus.gmavenplus + gmavenplus-plugin + ${gmavenplus-plugin.version} + + + + addSources + addTestSources + compile + compileTests + + + - maven-compiler-plugin - ${compiler.plugin.version} - - groovy-eclipse-compiler - ${java.version} - ${java.version} - + maven-failsafe-plugin + ${maven-failsafe-plugin.version} - org.codehaus.groovy - groovy-eclipse-compiler - ${groovy.compiler.version} - - - org.codehaus.groovy - groovy-eclipse-batch - ${groovy.version}-01 + org.junit.platform + junit-platform-surefire-provider + ${junit.platform.version} + + + junit5 + + integration-test + verify + + + + **/*Test5.java + + + + - + + + + central + https://jcenter.bintray.com + + + 1.0.0 - 1.1.3 - 2.5.7 - 2.20.1 - 3.8.0 - 3.3.0-01 - 1.8 + 2.5.6 + 2.5.6 + 2.5.6 + 2.4.0 + 1.1-groovy-2.4 + 1.6 - + \ No newline at end of file diff --git a/core-groovy-strings/src/test/groovy/com/baeldung/removeprefix/RemovePrefixTest.groovy b/core-groovy-strings/src/test/groovy/com/baeldung/removeprefix/RemovePrefixTest.groovy index aa9e65d98d..4cdcb4ddfa 100644 --- a/core-groovy-strings/src/test/groovy/com/baeldung/removeprefix/RemovePrefixTest.groovy +++ b/core-groovy-strings/src/test/groovy/com/baeldung/removeprefix/RemovePrefixTest.groovy @@ -9,23 +9,28 @@ class RemovePrefixTest { @Test public void whenCasePrefixIsRemoved_thenReturnTrue() { def trimPrefix = { - it.startsWith('Groovy') ? it.minus('Groovy') : it + it.startsWith('Groovy-') ? it.minus('Groovy-') : it } + + def actual = trimPrefix("Groovy-Tutorials at Baeldung") + def expected = "Tutorials at Baeldung" - Assert.assertEquals(trimPrefix("GroovyTutorials at Baeldung"), "Tutorials at Baeldung") + Assert.assertEquals(expected, actual) } @Test - public void whenPrefixIsRemovedWithIgnoreCase_thenReturnTrue() { + public void whenPrefixIsRemoved_thenReturnTrue() { String prefix = "groovy-" String trimPrefix = "Groovy-Tutorials at Baeldung" - def result; + def actual; if(trimPrefix.startsWithIgnoreCase(prefix)) { - result = trimPrefix.substring(prefix.length()) + actual = trimPrefix.substring(prefix.length()) } + + def expected = "Tutorials at Baeldung" - Assert.assertEquals("Tutorials at Baeldung", result) + Assert.assertEquals(expected, actual) } @Test @@ -33,26 +38,32 @@ class RemovePrefixTest { def regex = ~"^([Gg])roovy-" String trimPrefix = "Groovy-Tutorials at Baeldung" - String result = trimPrefix - regex + String actual = trimPrefix - regex + + def expected = "Tutorials at Baeldung" - Assert.assertEquals("Tutorials at Baeldung", result) + Assert.assertEquals(expected, actual) } @Test public void whenPrefixIsRemovedUsingReplaceFirst_thenReturnTrue() { def regex = ~"^groovy" String trimPrefix = "groovyTutorials at Baeldung's groovy page" - String result = trimPrefix.replaceFirst(regex, "") + String actual = trimPrefix.replaceFirst(regex, "") - Assert.assertEquals("Tutorials at Baeldung's groovy page", result) + def expected = "Tutorials at Baeldung's groovy page" + + Assert.assertEquals(expected, actual) } @Test public void whenPrefixIsRemovedUsingReplaceAll_thenReturnTrue() { String trimPrefix = "groovyTutorials at Baeldung groovy" - String result = trimPrefix.replaceAll(/^groovy/, "") + String actual = trimPrefix.replaceAll(/^groovy/, "") + + def expected = "Tutorials at Baeldung groovy" - Assert.assertEquals("Tutorials at Baeldung groovy", result) + Assert.assertEquals(expected, actual) } -} +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index ffdfe4cffa..f43318bcaa 100644 --- a/pom.xml +++ b/pom.xml @@ -383,6 +383,7 @@ core-groovy core-groovy-2 core-groovy-collections + core-groovy-strings core-java-modules core-kotlin-modules @@ -898,6 +899,7 @@ core-groovy core-groovy-2 core-groovy-collections + core-groovy-strings core-java-modules core-kotlin-modules From 56cbfb1c6f7a6c60653f5c9f00a3c3c6a06645d9 Mon Sep 17 00:00:00 2001 From: Ricardo Caldas Date: Thu, 10 Sep 2020 17:16:46 -0300 Subject: [PATCH 111/263] BAEL-2503 Add a new section in Lombok builder article --- .../builder/RequiredFieldAnnotation.java | 16 +++++++------- .../lombok/builder/RequiredFieldOverload.java | 20 ------------------ .../builder/RequiredFieldAnnotationTest.java | 21 +++++++++++++++++++ 3 files changed, 28 insertions(+), 29 deletions(-) delete mode 100644 lombok/src/main/java/com/baeldung/lombok/builder/RequiredFieldOverload.java create mode 100644 lombok/src/test/java/com/baeldung/lombok/builder/RequiredFieldAnnotationTest.java diff --git a/lombok/src/main/java/com/baeldung/lombok/builder/RequiredFieldAnnotation.java b/lombok/src/main/java/com/baeldung/lombok/builder/RequiredFieldAnnotation.java index f09f59baea..8781101613 100644 --- a/lombok/src/main/java/com/baeldung/lombok/builder/RequiredFieldAnnotation.java +++ b/lombok/src/main/java/com/baeldung/lombok/builder/RequiredFieldAnnotation.java @@ -1,19 +1,17 @@ package com.baeldung.lombok.builder; import lombok.Builder; +import lombok.Getter; import lombok.NonNull; -@Builder(builderMethodName = "hiddenBuilder") +@Builder(builderMethodName = "internalBuilder") +@Getter public class RequiredFieldAnnotation { - @NonNull - private String name; - private String description; + + @NonNull String name; + String description; public static RequiredFieldAnnotationBuilder builder(String name) { - return hiddenBuilder().name(name); - } - - public void example() { - RequiredFieldAnnotation.builder("NameField").description("Field Description").build(); + return internalBuilder().name(name); } } diff --git a/lombok/src/main/java/com/baeldung/lombok/builder/RequiredFieldOverload.java b/lombok/src/main/java/com/baeldung/lombok/builder/RequiredFieldOverload.java deleted file mode 100644 index 6b123e3cbe..0000000000 --- a/lombok/src/main/java/com/baeldung/lombok/builder/RequiredFieldOverload.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.baeldung.lombok.builder; - -import lombok.Builder; -import lombok.NonNull; - -@Builder -public class RequiredFieldOverload { - @NonNull - private String name; - private String description; - - public static RequiredFieldOverloadBuilder builder(String name) { - return new RequiredFieldOverloadBuilder().name(name); - } - - public void example() { - RequiredFieldAnnotation.builder("NameField").description("Field Description").build(); - } - -} diff --git a/lombok/src/test/java/com/baeldung/lombok/builder/RequiredFieldAnnotationTest.java b/lombok/src/test/java/com/baeldung/lombok/builder/RequiredFieldAnnotationTest.java new file mode 100644 index 0000000000..9d347327d4 --- /dev/null +++ b/lombok/src/test/java/com/baeldung/lombok/builder/RequiredFieldAnnotationTest.java @@ -0,0 +1,21 @@ +package com.baeldung.lombok.builder; + +import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; + +import static org.junit.jupiter.api.Assertions.*; + +public class RequiredFieldAnnotationTest { + RequiredFieldAnnotation requiredFieldTest; + + @BeforeEach + void setUp() { + requiredFieldTest = RequiredFieldAnnotation.builder("NameField").description("Field Description").build(); + } + + @Test + public void givenBuilderWithRequiredParameter_thenParameterIsPresent() { + assertEquals(requiredFieldTest.getName(), "NameField"); + } + +} \ No newline at end of file From 751aa761594c834efae0f2074ac4fd1175706b6a Mon Sep 17 00:00:00 2001 From: Kai Yuan Date: Fri, 11 Sep 2020 01:08:12 +0200 Subject: [PATCH 112/263] [BAEL-4583] Improvement- Java Period --- .../com/baeldung/date/DateDiffUnitTest.java | 63 +++++++++++++------ 1 file changed, 43 insertions(+), 20 deletions(-) diff --git a/core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/date/DateDiffUnitTest.java b/core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/date/DateDiffUnitTest.java index 226556d4bb..9a0779ccac 100644 --- a/core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/date/DateDiffUnitTest.java +++ b/core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/date/DateDiffUnitTest.java @@ -1,6 +1,8 @@ package com.baeldung.date; -import static org.junit.Assert.assertEquals; +import org.joda.time.Days; +import org.joda.time.Minutes; +import org.junit.Test; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -16,7 +18,7 @@ import java.util.Locale; import java.util.TimeZone; import java.util.concurrent.TimeUnit; -import org.junit.Test; +import static org.junit.Assert.*; public class DateDiffUnitTest { @@ -29,18 +31,39 @@ public class DateDiffUnitTest { long diffInMillies = Math.abs(secondDate.getTime() - firstDate.getTime()); long diff = TimeUnit.DAYS.convert(diffInMillies, TimeUnit.MILLISECONDS); - assertEquals(diff, 6); + assertEquals(6, diff); } @Test - public void givenTwoDatesInJava8_whenDifferentiating_thenWeGetSix() { - LocalDate now = LocalDate.now(); - LocalDate sixDaysBehind = now.minusDays(6); + public void givenTwoDatesInJava8_whenUsingPeriodGetDays_thenWorks() { + LocalDate aDate = LocalDate.of(2020, 9, 11); + LocalDate sixDaysBehind = aDate.minusDays(6); - Period period = Period.between(now, sixDaysBehind); + Period period = Period.between(aDate, sixDaysBehind); int diff = Math.abs(period.getDays()); - assertEquals(diff, 6); + assertEquals(6, diff); + } + + @Test + public void givenTwoDatesInJava8_whenUsingPeriodGetDays_thenDoesNotWork() { + LocalDate aDate = LocalDate.of(2020, 9, 11); + LocalDate sixtyDaysBehind = aDate.minusDays(60); + Period period = Period.between(aDate, sixtyDaysBehind); + int diff = Math.abs(period.getDays()); + //not equals + assertNotEquals(60, diff); + } + + @Test + public void givenTwoDatesInJava8_whenUsingPeriod_thenWeGet0Year1Month29Days() { + LocalDate aDate = LocalDate.of(2020, 9, 11); + LocalDate sixtyDaysBehind = aDate.minusDays(60); + Period period = Period.between(aDate, sixtyDaysBehind); + int years = Math.abs(period.getYears()); + int months = Math.abs(period.getMonths()); + int days = Math.abs(period.getDays()); + assertArrayEquals(new int[] { 0, 1, 29 }, new int[] { years, months, days }); } @Test @@ -51,7 +74,7 @@ public class DateDiffUnitTest { Duration duration = Duration.between(now, sixMinutesBehind); long diff = Math.abs(duration.toMinutes()); - assertEquals(diff, 6); + assertEquals(6, diff); } @Test @@ -61,7 +84,7 @@ public class DateDiffUnitTest { long diff = ChronoUnit.SECONDS.between(now, tenSecondsLater); - assertEquals(diff, 10); + assertEquals(10, diff); } @Test @@ -69,9 +92,9 @@ public class DateDiffUnitTest { LocalDateTime ldt = LocalDateTime.now(); ZonedDateTime now = ldt.atZone(ZoneId.of("America/Montreal")); ZonedDateTime sixDaysBehind = now.withZoneSameInstant(ZoneId.of("Asia/Singapore")) - .minusDays(6); + .minusDays(6); long diff = ChronoUnit.DAYS.between(sixDaysBehind, now); - assertEquals(diff, 6); + assertEquals(6, diff); } @Test @@ -81,7 +104,7 @@ public class DateDiffUnitTest { long diff = now.until(tenSecondsLater, ChronoUnit.SECONDS); - assertEquals(diff, 10); + assertEquals(10, diff); } @Test @@ -89,10 +112,9 @@ public class DateDiffUnitTest { org.joda.time.LocalDate now = org.joda.time.LocalDate.now(); org.joda.time.LocalDate sixDaysBehind = now.minusDays(6); - org.joda.time.Period period = new org.joda.time.Period(now, sixDaysBehind); - long diff = Math.abs(period.getDays()); + long diff = Math.abs(Days.daysBetween(now, sixDaysBehind).getDays()); - assertEquals(diff, 6); + assertEquals(6, diff); } @Test @@ -100,8 +122,9 @@ public class DateDiffUnitTest { org.joda.time.LocalDateTime now = org.joda.time.LocalDateTime.now(); org.joda.time.LocalDateTime sixMinutesBehind = now.minusMinutes(6); - org.joda.time.Period period = new org.joda.time.Period(now, sixMinutesBehind); - long diff = Math.abs(period.getDays()); + long diff = Math.abs(Minutes.minutesBetween(now, sixMinutesBehind).getMinutes()); + assertEquals(6, diff); + } @Test @@ -111,6 +134,6 @@ public class DateDiffUnitTest { long diff = Math.abs(now.numDaysFrom(sixDaysBehind)); - assertEquals(diff, 6); + assertEquals(6, diff); } -} \ No newline at end of file +} From 4893af40f61ce902ea60a897a55e586661fb3972 Mon Sep 17 00:00:00 2001 From: Sebastian Luna Date: Thu, 10 Sep 2020 19:55:56 -0500 Subject: [PATCH 113/263] BAEL-4387 Add AssertJ assertions --- java-collections-conversions-2/pom.xml | 6 ++++++ .../ArrayToListConversionUnitTest.java | 14 +++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/java-collections-conversions-2/pom.xml b/java-collections-conversions-2/pom.xml index 0f7cdadeb2..23f20276a3 100644 --- a/java-collections-conversions-2/pom.xml +++ b/java-collections-conversions-2/pom.xml @@ -15,6 +15,12 @@ + + org.assertj + assertj-core + 3.17.2 + test + org.apache.commons commons-lang3 diff --git a/java-collections-conversions-2/src/test/java/com/baeldung/arrayconversion/ArrayToListConversionUnitTest.java b/java-collections-conversions-2/src/test/java/com/baeldung/arrayconversion/ArrayToListConversionUnitTest.java index 80e7b93b0c..565c938d48 100644 --- a/java-collections-conversions-2/src/test/java/com/baeldung/arrayconversion/ArrayToListConversionUnitTest.java +++ b/java-collections-conversions-2/src/test/java/com/baeldung/arrayconversion/ArrayToListConversionUnitTest.java @@ -1,5 +1,6 @@ package com.baeldung.arrayconversion; +import org.assertj.core.api.ListAssert; import org.hamcrest.CoreMatchers; import org.junit.Test; @@ -7,8 +8,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertArrayEquals; +import static org.assertj.core.api.Assertions.assertThat; public class ArrayToListConversionUnitTest { @@ -17,8 +17,8 @@ public class ArrayToListConversionUnitTest { String[] stringArray = new String[] { "A", "B", "C", "D" }; List stringList = Arrays.asList(stringArray); stringList.set(0, "E"); - assertThat(stringList, CoreMatchers.hasItems("E", "B", "C", "D")); - assertArrayEquals(stringArray, new String[] { "E", "B", "C", "D" }); + assertThat(stringList).containsExactly("E", "B", "C", "D"); + assertThat(stringArray).containsExactly("E", "B", "C", "D"); stringList.add("F"); } @@ -27,9 +27,9 @@ public class ArrayToListConversionUnitTest { String[] stringArray = new String[] { "A", "B", "C", "D" }; List stringList = new ArrayList<>(Arrays.asList(stringArray)); stringList.set(0, "E"); - assertThat(stringList, CoreMatchers.hasItems("E", "B", "C", "D")); - assertArrayEquals(stringArray, new String[] { "A", "B", "C", "D" }); + assertThat(stringList).containsExactly("E", "B", "C", "D"); + assertThat(stringArray).containsExactly("A", "B", "C", "D"); stringList.add("F"); - assertThat(stringList, CoreMatchers.hasItems("E", "B", "C", "D", "F")); + assertThat(stringList).containsExactly("E", "B", "C", "D", "F"); } } From c3cd93fcdbdd4033dda418c8ac0bad89aacedb63 Mon Sep 17 00:00:00 2001 From: kwoyke Date: Fri, 11 Sep 2020 14:49:02 +0200 Subject: [PATCH 114/263] JAVA-2563: Upgrade Spring Boot version to 2.3.3.RELEASE (#9985) * JAVA-2563: Upgrade Spring Boot version to 2.3.3.RELEASE * JAVA-2563: Downgrade spring-cloud-connectors-heroku to Spring Boot 2.2.6.RELEASE * JAVA-2563: Add joda-time version * JAVA-2563: Add spring-boot-starter-validation dependency * JAVA-2563: Add spring-boot-starter-validation dependency * JAVA-2563: Add spring-boot-starter-validation dependency * JAVA-2563: Add spring-boot-starter-validation dependency * JAVA-2563: Add spring-boot-starter-validation dependency * JAVA-2563: Use MongoClients factory instead of MongoClient directly * JAVA-2563: Downgrade spring-5-data-reactive to Spring Boot 2.2.6.RELEASE * JAVA-2563: Switch back to default bootstrap mode for JPA * JAVA-2563: Add spring-boot-starter-validation dependency * JAVA-2563: Switch from ServerHttpRequest to ServerWebExchange interface * JAVA-2563: Use OutputCaptureRule instead of OutputCapture * JAVA-2563: Add spring-boot-starter-validation dependency * JAVA-2563: Add spring-boot-starter-validation dependency * JAVA-2563: Add spring-boot-starter-validation dependency * JAVA-2563: Fix Jackson dependency * JAVA-2563: Fix ManualEmbeddedMongoDbIntegrationTest * JAVA-2563: Replace validation-api with spring-boot-starter-validation * JAVA-2563: Fix usage of deprecated getErrorAttributes method * JAVA-2563: Downgrade spring-data-cassandra-reactive to Spring Boot 2.2.6.RELEASE * JAVA-2563: Set spring.datasource.generate-unique-name to false in spring-session-jdbc --- ddd/pom.xml | 4 +++ jmeter/pom.xml | 4 +++ parent-boot-2/pom.xml | 2 +- persistence-modules/r2dbc/pom.xml | 4 +++ .../ManualEmbeddedMongoDbIntegrationTest.java | 25 ++++++++++--------- .../spring-data-cassandra-reactive/pom.xml | 1 + .../src/main/resources/application.properties | 2 +- spring-5-data-reactive/pom.xml | 1 + spring-5-reactive-2/pom.xml | 4 +++ .../authresolver/CustomWebSecurityConfig.java | 9 ++++--- .../errorhandling/GlobalErrorAttributes.java | 10 +++----- .../GlobalErrorWebExceptionHandler.java | 3 ++- .../spring-boot-angular/pom.xml | 4 +++ .../spring-boot-autoconfiguration/pom.xml | 4 +++ spring-boot-modules/spring-boot-crud/pom.xml | 4 +++ spring-boot-modules/spring-boot-mvc-2/pom.xml | 5 ++++ .../spring-boot-properties/pom.xml | 4 +++ .../spring-boot-runtime/pom.xml | 5 ++++ .../spring-boot-springdoc/pom.xml | 4 +++ .../spring-boot-testing/pom.xml | 4 +++ ...ltiProfileTestLogLevelIntegrationTest.java | 4 +-- .../LogbackTestLogLevelIntegrationTest.java | 4 +-- ...estLogLevelWithProfileIntegrationTest.java | 4 +-- spring-boot-modules/spring-boot/pom.xml | 9 +++---- .../spring-cloud-connectors-heroku/pom.xml | 1 + spring-cloud/spring-cloud-vault/pom.xml | 4 +++ spring-jenkins-pipeline/pom.xml | 4 +++ spring-mvc-basics-3/pom.xml | 5 ++++ spring-mvc-basics/pom.xml | 4 +++ spring-mvc-java/pom.xml | 6 ----- spring-rest-hal-browser/pom.xml | 4 +++ spring-rest-http/pom.xml | 4 +++ .../src/main/resources/application.properties | 1 + spring-thymeleaf-2/pom.xml | 4 +++ spring-thymeleaf-3/pom.xml | 4 +++ testing-modules/rest-assured/pom.xml | 1 + 36 files changed, 124 insertions(+), 42 deletions(-) diff --git a/ddd/pom.xml b/ddd/pom.xml index 9f960502a3..a67719f8a6 100644 --- a/ddd/pom.xml +++ b/ddd/pom.xml @@ -78,6 +78,10 @@ org.springframework.boot spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-validation + org.springframework.boot spring-boot-starter-test diff --git a/jmeter/pom.xml b/jmeter/pom.xml index 945210edd7..e2830baef5 100644 --- a/jmeter/pom.xml +++ b/jmeter/pom.xml @@ -23,6 +23,10 @@ org.springframework.boot spring-boot-starter-data-rest + + org.springframework.boot + spring-boot-starter-validation + org.springframework.boot spring-boot-starter-test diff --git a/parent-boot-2/pom.xml b/parent-boot-2/pom.xml index ed0f327b8c..dab9f015b3 100644 --- a/parent-boot-2/pom.xml +++ b/parent-boot-2/pom.xml @@ -82,7 +82,7 @@ 3.3.0 1.0.22.RELEASE - 2.2.6.RELEASE + 2.3.3.RELEASE 1.9.1 diff --git a/persistence-modules/r2dbc/pom.xml b/persistence-modules/r2dbc/pom.xml index 2da81cba06..119d0547e3 100644 --- a/persistence-modules/r2dbc/pom.xml +++ b/persistence-modules/r2dbc/pom.xml @@ -21,6 +21,10 @@ org.springframework.boot spring-boot-starter-webflux + + org.springframework.boot + spring-boot-starter-validation + org.springframework.boot diff --git a/persistence-modules/spring-boot-persistence-mongodb/src/test/java/com/baeldung/mongodb/ManualEmbeddedMongoDbIntegrationTest.java b/persistence-modules/spring-boot-persistence-mongodb/src/test/java/com/baeldung/mongodb/ManualEmbeddedMongoDbIntegrationTest.java index c49b99ed99..21cf56172e 100644 --- a/persistence-modules/spring-boot-persistence-mongodb/src/test/java/com/baeldung/mongodb/ManualEmbeddedMongoDbIntegrationTest.java +++ b/persistence-modules/spring-boot-persistence-mongodb/src/test/java/com/baeldung/mongodb/ManualEmbeddedMongoDbIntegrationTest.java @@ -1,18 +1,8 @@ package com.baeldung.mongodb; -import static org.assertj.core.api.Assertions.assertThat; - -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.springframework.data.mongodb.core.MongoTemplate; -import org.springframework.util.SocketUtils; - import com.mongodb.BasicDBObjectBuilder; import com.mongodb.DBObject; -import com.mongodb.MongoClient; - +import com.mongodb.client.MongoClients; import de.flapdoodle.embed.mongo.MongodExecutable; import de.flapdoodle.embed.mongo.MongodStarter; import de.flapdoodle.embed.mongo.config.IMongodConfig; @@ -20,8 +10,19 @@ import de.flapdoodle.embed.mongo.config.MongodConfigBuilder; import de.flapdoodle.embed.mongo.config.Net; import de.flapdoodle.embed.mongo.distribution.Version; import de.flapdoodle.embed.process.runtime.Network; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.data.mongodb.core.MongoTemplate; +import org.springframework.util.SocketUtils; + +import static org.assertj.core.api.Assertions.assertThat; class ManualEmbeddedMongoDbIntegrationTest { + + private static final String CONNECTION_STRING = "mongodb://%s:%d"; + private MongodExecutable mongodExecutable; private MongoTemplate mongoTemplate; @@ -42,7 +43,7 @@ class ManualEmbeddedMongoDbIntegrationTest { MongodStarter starter = MongodStarter.getDefaultInstance(); mongodExecutable = starter.prepare(mongodConfig); mongodExecutable.start(); - mongoTemplate = new MongoTemplate(new MongoClient(ip, randomPort), "test"); + mongoTemplate = new MongoTemplate(MongoClients.create(String.format(CONNECTION_STRING, ip, randomPort)),"test"); } @DisplayName("Given object When save object using MongoDB template Then object can be found") diff --git a/persistence-modules/spring-data-cassandra-reactive/pom.xml b/persistence-modules/spring-data-cassandra-reactive/pom.xml index 70a5f556e2..16486bf380 100644 --- a/persistence-modules/spring-data-cassandra-reactive/pom.xml +++ b/persistence-modules/spring-data-cassandra-reactive/pom.xml @@ -51,6 +51,7 @@ + 2.2.6.RELEASE 3.11.2.0 diff --git a/software-security/sql-injection-samples/src/main/resources/application.properties b/software-security/sql-injection-samples/src/main/resources/application.properties index 8b13789179..953384eac4 100644 --- a/software-security/sql-injection-samples/src/main/resources/application.properties +++ b/software-security/sql-injection-samples/src/main/resources/application.properties @@ -1 +1 @@ - +spring.data.jpa.repositories.bootstrap-mode=default diff --git a/spring-5-data-reactive/pom.xml b/spring-5-data-reactive/pom.xml index aeaf6daf1a..396f7f5959 100644 --- a/spring-5-data-reactive/pom.xml +++ b/spring-5-data-reactive/pom.xml @@ -224,6 +224,7 @@ 1.4.200 1.5.23 3.3.1.RELEASE + 2.2.6.RELEASE diff --git a/spring-5-reactive-2/pom.xml b/spring-5-reactive-2/pom.xml index 4cb85d879e..093be0f03c 100644 --- a/spring-5-reactive-2/pom.xml +++ b/spring-5-reactive-2/pom.xml @@ -20,6 +20,10 @@ org.springframework.boot spring-boot-starter-webflux + + org.springframework.boot + spring-boot-starter-validation + org.springframework.boot spring-boot-starter-security diff --git a/spring-5-reactive-security/src/main/java/com/baeldung/reactive/authresolver/CustomWebSecurityConfig.java b/spring-5-reactive-security/src/main/java/com/baeldung/reactive/authresolver/CustomWebSecurityConfig.java index d07a991089..dc5eab3dd5 100644 --- a/spring-5-reactive-security/src/main/java/com/baeldung/reactive/authresolver/CustomWebSecurityConfig.java +++ b/spring-5-reactive-security/src/main/java/com/baeldung/reactive/authresolver/CustomWebSecurityConfig.java @@ -2,7 +2,6 @@ package com.baeldung.reactive.authresolver; import java.util.Collections; import org.springframework.context.annotation.Bean; -import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.security.authentication.ReactiveAuthenticationManager; import org.springframework.security.authentication.ReactiveAuthenticationManagerResolver; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; @@ -15,6 +14,7 @@ import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.security.web.server.SecurityWebFilterChain; import org.springframework.security.web.server.authentication.AuthenticationWebFilter; +import org.springframework.web.server.ServerWebExchange; import reactor.core.publisher.Mono; @EnableWebFluxSecurity @@ -38,9 +38,10 @@ public class CustomWebSecurityConfig { return new AuthenticationWebFilter(resolver()); } - public ReactiveAuthenticationManagerResolver resolver() { - return request -> { - if (request + public ReactiveAuthenticationManagerResolver resolver() { + return exchange -> { + if (exchange + .getRequest() .getPath() .subPath(0) .value() diff --git a/spring-5-reactive/src/main/java/com/baeldung/reactive/errorhandling/GlobalErrorAttributes.java b/spring-5-reactive/src/main/java/com/baeldung/reactive/errorhandling/GlobalErrorAttributes.java index a50651ced7..5885ac50d0 100644 --- a/spring-5-reactive/src/main/java/com/baeldung/reactive/errorhandling/GlobalErrorAttributes.java +++ b/spring-5-reactive/src/main/java/com/baeldung/reactive/errorhandling/GlobalErrorAttributes.java @@ -2,6 +2,8 @@ package com.baeldung.reactive.errorhandling; import java.util.Map; + +import org.springframework.boot.web.error.ErrorAttributeOptions; import org.springframework.boot.web.reactive.error.DefaultErrorAttributes; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Component; @@ -13,13 +15,9 @@ public class GlobalErrorAttributes extends DefaultErrorAttributes{ private HttpStatus status = HttpStatus.BAD_REQUEST; private String message = "please provide a name"; - public GlobalErrorAttributes() { - super(false); - } - @Override - public Map getErrorAttributes(ServerRequest request, boolean includeStackTrace) { - Map map = super.getErrorAttributes(request, includeStackTrace); + public Map getErrorAttributes(ServerRequest request, ErrorAttributeOptions options) { + Map map = super.getErrorAttributes(request, options); map.put("status", getStatus()); map.put("message", getMessage()); return map; diff --git a/spring-5-reactive/src/main/java/com/baeldung/reactive/errorhandling/GlobalErrorWebExceptionHandler.java b/spring-5-reactive/src/main/java/com/baeldung/reactive/errorhandling/GlobalErrorWebExceptionHandler.java index 09bccb0d5e..051e4b8df5 100644 --- a/spring-5-reactive/src/main/java/com/baeldung/reactive/errorhandling/GlobalErrorWebExceptionHandler.java +++ b/spring-5-reactive/src/main/java/com/baeldung/reactive/errorhandling/GlobalErrorWebExceptionHandler.java @@ -4,6 +4,7 @@ package com.baeldung.reactive.errorhandling; import java.util.Map; import org.springframework.boot.autoconfigure.web.ResourceProperties; import org.springframework.boot.autoconfigure.web.reactive.error.AbstractErrorWebExceptionHandler; +import org.springframework.boot.web.error.ErrorAttributeOptions; import org.springframework.boot.web.reactive.error.ErrorAttributes; import org.springframework.context.ApplicationContext; import org.springframework.core.annotation.Order; @@ -37,7 +38,7 @@ public class GlobalErrorWebExceptionHandler extends AbstractErrorWebExceptionHan private Mono renderErrorResponse(final ServerRequest request) { - final Map errorPropertiesMap = getErrorAttributes(request, false); + final Map errorPropertiesMap = getErrorAttributes(request, ErrorAttributeOptions.defaults()); return ServerResponse.status(HttpStatus.BAD_REQUEST) .contentType(MediaType.APPLICATION_JSON_UTF8) diff --git a/spring-boot-modules/spring-boot-angular/pom.xml b/spring-boot-modules/spring-boot-angular/pom.xml index 4b3ac27834..ac63d21bb8 100644 --- a/spring-boot-modules/spring-boot-angular/pom.xml +++ b/spring-boot-modules/spring-boot-angular/pom.xml @@ -26,6 +26,10 @@ org.springframework.boot spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-validation + com.h2database h2 diff --git a/spring-boot-modules/spring-boot-autoconfiguration/pom.xml b/spring-boot-modules/spring-boot-autoconfiguration/pom.xml index 5709d1d796..269d87bbb9 100644 --- a/spring-boot-modules/spring-boot-autoconfiguration/pom.xml +++ b/spring-boot-modules/spring-boot-autoconfiguration/pom.xml @@ -26,6 +26,10 @@ org.springframework.boot spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-validation + org.springframework.boot spring-boot-starter-data-jpa diff --git a/spring-boot-modules/spring-boot-crud/pom.xml b/spring-boot-modules/spring-boot-crud/pom.xml index a4be360b0f..cf1bfe6da0 100644 --- a/spring-boot-modules/spring-boot-crud/pom.xml +++ b/spring-boot-modules/spring-boot-crud/pom.xml @@ -20,6 +20,10 @@ org.springframework.boot spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-validation + org.springframework.boot spring-boot-starter-thymeleaf diff --git a/spring-boot-modules/spring-boot-mvc-2/pom.xml b/spring-boot-modules/spring-boot-mvc-2/pom.xml index 0b9213a7ea..580224cfd0 100644 --- a/spring-boot-modules/spring-boot-mvc-2/pom.xml +++ b/spring-boot-modules/spring-boot-mvc-2/pom.xml @@ -23,6 +23,11 @@ spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-validation + + org.springframework.boot spring-boot-devtools diff --git a/spring-boot-modules/spring-boot-properties/pom.xml b/spring-boot-modules/spring-boot-properties/pom.xml index a5594ee2de..cfdc71b8d6 100644 --- a/spring-boot-modules/spring-boot-properties/pom.xml +++ b/spring-boot-modules/spring-boot-properties/pom.xml @@ -27,6 +27,10 @@ org.springframework.boot spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-validation + org.springframework.boot spring-boot-starter-actuator diff --git a/spring-boot-modules/spring-boot-runtime/pom.xml b/spring-boot-modules/spring-boot-runtime/pom.xml index d3966beb65..ce6fa7ea93 100644 --- a/spring-boot-modules/spring-boot-runtime/pom.xml +++ b/spring-boot-modules/spring-boot-runtime/pom.xml @@ -29,6 +29,11 @@ spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-validation + + org.springframework.boot spring-boot-starter-thymeleaf diff --git a/spring-boot-modules/spring-boot-springdoc/pom.xml b/spring-boot-modules/spring-boot-springdoc/pom.xml index 3e8d5175f7..ed272200da 100644 --- a/spring-boot-modules/spring-boot-springdoc/pom.xml +++ b/spring-boot-modules/spring-boot-springdoc/pom.xml @@ -24,6 +24,10 @@ org.springframework.boot spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-validation + org.springframework.boot spring-boot-starter-data-jpa diff --git a/spring-boot-modules/spring-boot-testing/pom.xml b/spring-boot-modules/spring-boot-testing/pom.xml index bd5ef901dd..5bf626f165 100644 --- a/spring-boot-modules/spring-boot-testing/pom.xml +++ b/spring-boot-modules/spring-boot-testing/pom.xml @@ -26,6 +26,10 @@ org.springframework.boot spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-validation + org.springframework.boot spring-boot-starter-tomcat diff --git a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackMultiProfileTestLogLevelIntegrationTest.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackMultiProfileTestLogLevelIntegrationTest.java index ffe99672be..b3d80a7d8b 100644 --- a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackMultiProfileTestLogLevelIntegrationTest.java +++ b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackMultiProfileTestLogLevelIntegrationTest.java @@ -8,7 +8,7 @@ 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.system.OutputCaptureRule; import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.http.ResponseEntity; import org.springframework.test.annotation.DirtiesContext; @@ -29,7 +29,7 @@ public class LogbackMultiProfileTestLogLevelIntegrationTest { private TestRestTemplate restTemplate; @Rule - public OutputCapture outputCapture = new OutputCapture(); + public OutputCaptureRule outputCapture = new OutputCaptureRule(); private String baseUrl = "/testLogLevel"; diff --git a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackTestLogLevelIntegrationTest.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackTestLogLevelIntegrationTest.java index cbd22e8087..f60a5e0ee3 100644 --- a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackTestLogLevelIntegrationTest.java +++ b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackTestLogLevelIntegrationTest.java @@ -8,7 +8,7 @@ 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.system.OutputCaptureRule; import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.http.ResponseEntity; import org.springframework.test.annotation.DirtiesContext; @@ -29,7 +29,7 @@ public class LogbackTestLogLevelIntegrationTest { private TestRestTemplate restTemplate; @Rule - public OutputCapture outputCapture = new OutputCapture(); + public OutputCaptureRule outputCapture = new OutputCaptureRule(); private String baseUrl = "/testLogLevel"; diff --git a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/testloglevel/TestLogLevelWithProfileIntegrationTest.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/testloglevel/TestLogLevelWithProfileIntegrationTest.java index 571b826b80..e59b673a1c 100644 --- a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/testloglevel/TestLogLevelWithProfileIntegrationTest.java +++ b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/testloglevel/TestLogLevelWithProfileIntegrationTest.java @@ -8,7 +8,7 @@ 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.system.OutputCaptureRule; import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.http.ResponseEntity; import org.springframework.test.annotation.DirtiesContext; @@ -29,7 +29,7 @@ public class TestLogLevelWithProfileIntegrationTest { private TestRestTemplate restTemplate; @Rule - public OutputCapture outputCapture = new OutputCapture(); + public OutputCaptureRule outputCapture = new OutputCaptureRule(); private String baseUrl = "/testLogLevel"; diff --git a/spring-boot-modules/spring-boot/pom.xml b/spring-boot-modules/spring-boot/pom.xml index 5efcffdf03..c1f1ea3072 100644 --- a/spring-boot-modules/spring-boot/pom.xml +++ b/spring-boot-modules/spring-boot/pom.xml @@ -27,6 +27,10 @@ org.springframework.boot spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-validation + org.springframework.boot spring-boot-starter-data-jpa @@ -98,11 +102,6 @@ rome ${rome.version} - - - javax.validation - validation-api - diff --git a/spring-cloud/spring-cloud-connectors-heroku/pom.xml b/spring-cloud/spring-cloud-connectors-heroku/pom.xml index c09a282197..7d85e07bb8 100644 --- a/spring-cloud/spring-cloud-connectors-heroku/pom.xml +++ b/spring-cloud/spring-cloud-connectors-heroku/pom.xml @@ -60,6 +60,7 @@ + 2.2.6.RELEASE Hoxton.SR4 42.2.10 1.10.10 diff --git a/spring-cloud/spring-cloud-vault/pom.xml b/spring-cloud/spring-cloud-vault/pom.xml index a5a29d9024..d9ae6b515f 100644 --- a/spring-cloud/spring-cloud-vault/pom.xml +++ b/spring-cloud/spring-cloud-vault/pom.xml @@ -62,6 +62,10 @@ org.springframework.boot spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-validation + org.springframework.boot spring-boot-starter-data-jpa diff --git a/spring-jenkins-pipeline/pom.xml b/spring-jenkins-pipeline/pom.xml index 38d4ed15de..152e107409 100644 --- a/spring-jenkins-pipeline/pom.xml +++ b/spring-jenkins-pipeline/pom.xml @@ -24,6 +24,10 @@ org.springframework.boot spring-boot-starter-data-rest + + org.springframework.boot + spring-boot-starter-validation + org.springframework.boot spring-boot-starter-test diff --git a/spring-mvc-basics-3/pom.xml b/spring-mvc-basics-3/pom.xml index 1dea8f9e93..a929337b25 100644 --- a/spring-mvc-basics-3/pom.xml +++ b/spring-mvc-basics-3/pom.xml @@ -21,6 +21,11 @@ spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-validation + + org.springframework.boot spring-boot-starter-test diff --git a/spring-mvc-basics/pom.xml b/spring-mvc-basics/pom.xml index 159dda955f..d212bc425a 100644 --- a/spring-mvc-basics/pom.xml +++ b/spring-mvc-basics/pom.xml @@ -20,6 +20,10 @@ org.springframework.boot spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-validation + org.apache.tomcat.embed diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index 9e3457aa8a..a45e9c8521 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -42,12 +42,6 @@ tomcat-embed-jasper provided - - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - net.sourceforge.htmlunit diff --git a/spring-rest-hal-browser/pom.xml b/spring-rest-hal-browser/pom.xml index 7b629dba44..c8066b89a4 100644 --- a/spring-rest-hal-browser/pom.xml +++ b/spring-rest-hal-browser/pom.xml @@ -20,6 +20,10 @@ org.springframework.boot spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-validation + org.springframework.boot diff --git a/spring-rest-http/pom.xml b/spring-rest-http/pom.xml index 32d2804220..18b7e0af05 100644 --- a/spring-rest-http/pom.xml +++ b/spring-rest-http/pom.xml @@ -20,6 +20,10 @@ org.springframework.boot spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-validation + org.springframework spring-oxm diff --git a/spring-session/spring-session-jdbc/src/main/resources/application.properties b/spring-session/spring-session-jdbc/src/main/resources/application.properties index 119638de31..bb9dd24590 100644 --- a/spring-session/spring-session-jdbc/src/main/resources/application.properties +++ b/spring-session/spring-session-jdbc/src/main/resources/application.properties @@ -1,3 +1,4 @@ +spring.datasource.generate-unique-name=false spring.session.store-type=jdbc spring.h2.console.enabled=true spring.h2.console.path=/h2-console \ No newline at end of file diff --git a/spring-thymeleaf-2/pom.xml b/spring-thymeleaf-2/pom.xml index 24c159dab9..43f36d9887 100644 --- a/spring-thymeleaf-2/pom.xml +++ b/spring-thymeleaf-2/pom.xml @@ -18,6 +18,10 @@ org.springframework.boot spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-validation + org.springframework.boot spring-boot-starter-thymeleaf diff --git a/spring-thymeleaf-3/pom.xml b/spring-thymeleaf-3/pom.xml index 7677e50d79..7c58115d11 100644 --- a/spring-thymeleaf-3/pom.xml +++ b/spring-thymeleaf-3/pom.xml @@ -18,6 +18,10 @@ org.springframework.boot spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-validation + org.springframework.boot spring-boot-starter-thymeleaf diff --git a/testing-modules/rest-assured/pom.xml b/testing-modules/rest-assured/pom.xml index 0b027312d6..eeb5389f49 100644 --- a/testing-modules/rest-assured/pom.xml +++ b/testing-modules/rest-assured/pom.xml @@ -102,6 +102,7 @@ joda-time joda-time + ${joda-time.version} From ebf5019635ff6745b4947b42e1ba26798f626b6e Mon Sep 17 00:00:00 2001 From: kwoyke Date: Sat, 12 Sep 2020 09:44:47 +0200 Subject: [PATCH 115/263] BAEL-4589: Update Guide to Java 8's Collectors (#10009) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * BAEL-4589: Move Guide to Java 8’s Collectors to core-java-11-2 * BAEL-4589: Add Java 10 unmodifiable* collectors examples --- core-java-modules/core-java-11-2/README.md | 1 + core-java-modules/core-java-11-2/pom.xml | 6 +++ .../collectors/Java8CollectorsUnitTest.java | 50 +++++++++++-------- .../core-java-streams-3/README.md | 1 - 4 files changed, 35 insertions(+), 23 deletions(-) rename core-java-modules/{core-java-streams-3/src/test/java/com/baeldung/streams => core-java-11-2/src/test/java/com/baeldung}/collectors/Java8CollectorsUnitTest.java (87%) diff --git a/core-java-modules/core-java-11-2/README.md b/core-java-modules/core-java-11-2/README.md index f65a043819..d77bf748a8 100644 --- a/core-java-modules/core-java-11-2/README.md +++ b/core-java-modules/core-java-11-2/README.md @@ -4,4 +4,5 @@ This module contains articles about Java 11 core features ### Relevant articles - [Guide to Java 8 Optional](https://www.baeldung.com/java-optional) +- [Guide to Java 8’s Collectors](https://www.baeldung.com/java-8-collectors) diff --git a/core-java-modules/core-java-11-2/pom.xml b/core-java-modules/core-java-11-2/pom.xml index d20b0f23f0..e2b129ae00 100644 --- a/core-java-modules/core-java-11-2/pom.xml +++ b/core-java-modules/core-java-11-2/pom.xml @@ -17,6 +17,11 @@ + + com.google.guava + guava + ${guava.version} + org.assertj assertj-core @@ -42,6 +47,7 @@ 11 11 + 29.0-jre 3.17.2 diff --git a/core-java-modules/core-java-streams-3/src/test/java/com/baeldung/streams/collectors/Java8CollectorsUnitTest.java b/core-java-modules/core-java-11-2/src/test/java/com/baeldung/collectors/Java8CollectorsUnitTest.java similarity index 87% rename from core-java-modules/core-java-streams-3/src/test/java/com/baeldung/streams/collectors/Java8CollectorsUnitTest.java rename to core-java-modules/core-java-11-2/src/test/java/com/baeldung/collectors/Java8CollectorsUnitTest.java index 6afc9f4182..7990b1fdb7 100644 --- a/core-java-modules/core-java-streams-3/src/test/java/com/baeldung/streams/collectors/Java8CollectorsUnitTest.java +++ b/core-java-modules/core-java-11-2/src/test/java/com/baeldung/collectors/Java8CollectorsUnitTest.java @@ -1,18 +1,11 @@ -package com.baeldung.streams.collectors; +package com.baeldung.collectors; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import org.junit.Test; -import java.util.Arrays; -import java.util.Comparator; -import java.util.DoubleSummaryStatistics; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; +import java.util.*; import java.util.function.BiConsumer; import java.util.function.BinaryOperator; import java.util.function.Function; @@ -20,19 +13,7 @@ import java.util.function.Supplier; import java.util.stream.Collector; import static com.google.common.collect.Sets.newHashSet; -import static java.util.stream.Collectors.averagingDouble; -import static java.util.stream.Collectors.collectingAndThen; -import static java.util.stream.Collectors.counting; -import static java.util.stream.Collectors.groupingBy; -import static java.util.stream.Collectors.joining; -import static java.util.stream.Collectors.maxBy; -import static java.util.stream.Collectors.partitioningBy; -import static java.util.stream.Collectors.summarizingDouble; -import static java.util.stream.Collectors.summingDouble; -import static java.util.stream.Collectors.toCollection; -import static java.util.stream.Collectors.toList; -import static java.util.stream.Collectors.toMap; -import static java.util.stream.Collectors.toSet; +import static java.util.stream.Collectors.*; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -48,6 +29,14 @@ public class Java8CollectorsUnitTest { assertThat(result).containsAll(givenList); } + @Test + public void whenCollectingToUnmodifiableList_shouldCollectToUnmodifiableList() { + final List result = givenList.stream().collect(toUnmodifiableList()); + + assertThatThrownBy(() -> result.add("foo")) + .isInstanceOf(UnsupportedOperationException.class); + } + @Test public void whenCollectingToSet_shouldCollectToSet() throws Exception { final Set result = givenList.stream().collect(toSet()); @@ -55,6 +44,14 @@ public class Java8CollectorsUnitTest { assertThat(result).containsAll(givenList); } + @Test + public void whenCollectingToUnmodifiableSet_shouldCollectToUnmodifiableSet() { + final Set result = givenList.stream().collect(toUnmodifiableSet()); + + assertThatThrownBy(() -> result.add("foo")) + .isInstanceOf(UnsupportedOperationException.class); + } + @Test public void givenContainsDuplicateElements_whenCollectingToSet_shouldAddDuplicateElementsOnlyOnce() throws Exception { final Set result = listWithDuplicates.stream().collect(toSet()); @@ -84,6 +81,15 @@ public class Java8CollectorsUnitTest { assertThat(result).containsEntry("a", 1).containsEntry("bb", 2).containsEntry("ccc", 3).containsEntry("dd", 2); } + @Test + public void whenCollectingToUnmodifiableMap_shouldCollectToUnmodifiableMap() { + final Map result = givenList.stream() + .collect(toUnmodifiableMap(Function.identity(), String::length)); + + assertThatThrownBy(() -> result.put("foo", 3)) + .isInstanceOf(UnsupportedOperationException.class); + } + @Test public void whenCollectingToMapwWithDuplicates_shouldCollectToMapMergingTheIdenticalItems() throws Exception { final Map result = listWithDuplicates.stream().collect( diff --git a/core-java-modules/core-java-streams-3/README.md b/core-java-modules/core-java-streams-3/README.md index 65713aa04f..9adde005e6 100644 --- a/core-java-modules/core-java-streams-3/README.md +++ b/core-java-modules/core-java-streams-3/README.md @@ -6,7 +6,6 @@ This module contains articles about the Stream API in Java. - [The Difference Between map() and flatMap()](https://www.baeldung.com/java-difference-map-and-flatmap) - [How to Use if/else Logic in Java 8 Streams](https://www.baeldung.com/java-8-streams-if-else-logic) - [The Difference Between Collection.stream().forEach() and Collection.forEach()](https://www.baeldung.com/java-collection-stream-foreach) -- [Guide to Java 8’s Collectors](https://www.baeldung.com/java-8-collectors) - [Primitive Type Streams in Java 8](https://www.baeldung.com/java-8-primitive-streams) - [Debugging Java 8 Streams with IntelliJ](https://www.baeldung.com/intellij-debugging-java-streams) - [Add BigDecimals using the Stream API](https://www.baeldung.com/java-stream-add-bigdecimals) From 8f19db031e2f999d9dde8b3b9c587e2ed6c3dcf6 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sat, 12 Sep 2020 17:54:33 +0530 Subject: [PATCH 116/263] JAVA-2411: Update spring-thymeleaf module and articles --- spring-thymeleaf/pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-thymeleaf/pom.xml b/spring-thymeleaf/pom.xml index c37c66a36d..30f77dd73e 100644 --- a/spring-thymeleaf/pom.xml +++ b/spring-thymeleaf/pom.xml @@ -145,10 +145,10 @@ - 2.0.9.RELEASE - 3.0.9.RELEASE - 3.0.1.RELEASE - 2.3.0 + 2.3.2.RELEASE + 3.0.11.RELEASE + 3.0.4.RELEASE + 2.4.1 2.0.1.Final 6.0.11.Final From d910807be21a6973092f1b91738154033c6b7a24 Mon Sep 17 00:00:00 2001 From: Sorin Zamfir Date: Sat, 12 Sep 2020 18:59:15 +0300 Subject: [PATCH 117/263] Update gradle-5/cmd-line-args/build.gradle Co-authored-by: KevinGilmore --- gradle-5/cmd-line-args/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle-5/cmd-line-args/build.gradle b/gradle-5/cmd-line-args/build.gradle index 5399db4815..15c9288024 100644 --- a/gradle-5/cmd-line-args/build.gradle +++ b/gradle-5/cmd-line-args/build.gradle @@ -33,6 +33,6 @@ task cmdLineJavaExec(type: JavaExec) { task cmdLineExec(type: Exec) { group = "Execution" - description = "Run the an external program with ExecTask" + description = "Run an external program with ExecTask" commandLine cmdargs.split() } From 972ff966996282d8bfc4bf34dcf03592a53ea58c Mon Sep 17 00:00:00 2001 From: kwoyke Date: Sat, 12 Sep 2020 19:08:22 +0200 Subject: [PATCH 118/263] BAEL-4587: Update Guide to Java Reflection (#9997) * BAEL-4587: Migrate Guide to Java Reflection to core-java-11-2 * BAEL-4587: Replace deprecated isAccessible method with canAccess --- core-java-modules/core-java-11-2/README.md | 2 +- .../java/com/baeldung}/reflection/Animal.java | 2 +- .../java/com/baeldung}/reflection/Bird.java | 2 +- .../baeldung}/reflection/DynamicGreeter.java | 2 +- .../java/com/baeldung}/reflection/Eating.java | 2 +- .../java/com/baeldung}/reflection/Goat.java | 2 +- .../com/baeldung}/reflection/Greeter.java | 2 +- .../reflection/GreetingAnnotation.java | 2 +- .../com/baeldung}/reflection/Greetings.java | 2 +- .../com/baeldung}/reflection/Locomotion.java | 2 +- .../com/baeldung}/reflection/Operations.java | 2 +- .../java/com/baeldung}/reflection/Person.java | 2 +- .../reflection/OperationsUnitTest.java | 2 +- .../reflection/ReflectionUnitTest.java | 73 +++++++++---------- .../core-java-reflection/README.MD | 1 - 15 files changed, 46 insertions(+), 54 deletions(-) rename core-java-modules/{core-java-reflection/src/main/java/com/baeldung/reflection/java => core-java-11-2/src/main/java/com/baeldung}/reflection/Animal.java (90%) rename core-java-modules/{core-java-reflection/src/main/java/com/baeldung/reflection/java => core-java-11-2/src/main/java/com/baeldung}/reflection/Bird.java (93%) rename core-java-modules/{core-java-reflection/src/main/java/com/baeldung/reflection/java => core-java-11-2/src/main/java/com/baeldung}/reflection/DynamicGreeter.java (91%) rename core-java-modules/{core-java-reflection/src/main/java/com/baeldung/reflection/java => core-java-11-2/src/main/java/com/baeldung}/reflection/Eating.java (55%) rename core-java-modules/{core-java-reflection/src/main/java/com/baeldung/reflection/java => core-java-11-2/src/main/java/com/baeldung}/reflection/Goat.java (90%) rename core-java-modules/{core-java-reflection/src/main/java/com/baeldung/reflection/java => core-java-11-2/src/main/java/com/baeldung}/reflection/Greeter.java (83%) rename core-java-modules/{core-java-reflection/src/main/java/com/baeldung/reflection/java => core-java-11-2/src/main/java/com/baeldung}/reflection/GreetingAnnotation.java (98%) rename core-java-modules/{core-java-reflection/src/main/java/com/baeldung/reflection/java => core-java-11-2/src/main/java/com/baeldung}/reflection/Greetings.java (61%) rename core-java-modules/{core-java-reflection/src/main/java/com/baeldung/reflection/java => core-java-11-2/src/main/java/com/baeldung}/reflection/Locomotion.java (61%) rename core-java-modules/{core-java-reflection/src/main/java/com/baeldung/reflection/java => core-java-11-2/src/main/java/com/baeldung}/reflection/Operations.java (90%) rename core-java-modules/{core-java-reflection/src/main/java/com/baeldung/reflection/java => core-java-11-2/src/main/java/com/baeldung}/reflection/Person.java (65%) rename core-java-modules/{core-java-reflection/src/test/java/com/baeldung/reflection/java => core-java-11-2/src/test/java/com/baeldung}/reflection/OperationsUnitTest.java (98%) rename core-java-modules/{core-java-reflection/src/test/java/com/baeldung/reflection/java => core-java-11-2/src/test/java/com/baeldung}/reflection/ReflectionUnitTest.java (77%) diff --git a/core-java-modules/core-java-11-2/README.md b/core-java-modules/core-java-11-2/README.md index d77bf748a8..834f310fce 100644 --- a/core-java-modules/core-java-11-2/README.md +++ b/core-java-modules/core-java-11-2/README.md @@ -4,5 +4,5 @@ This module contains articles about Java 11 core features ### Relevant articles - [Guide to Java 8 Optional](https://www.baeldung.com/java-optional) +- [Guide to Java Reflection](http://www.baeldung.com/java-reflection) - [Guide to Java 8’s Collectors](https://www.baeldung.com/java-8-collectors) - diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/java/reflection/Animal.java b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/reflection/Animal.java similarity index 90% rename from core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/java/reflection/Animal.java rename to core-java-modules/core-java-11-2/src/main/java/com/baeldung/reflection/Animal.java index 3f36243c29..364246ae64 100644 --- a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/java/reflection/Animal.java +++ b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/reflection/Animal.java @@ -1,4 +1,4 @@ -package com.baeldung.java.reflection; +package com.baeldung.reflection; public abstract class Animal implements Eating { diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/java/reflection/Bird.java b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/reflection/Bird.java similarity index 93% rename from core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/java/reflection/Bird.java rename to core-java-modules/core-java-11-2/src/main/java/com/baeldung/reflection/Bird.java index bd6f13094c..f5bb0f9b19 100644 --- a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/java/reflection/Bird.java +++ b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/reflection/Bird.java @@ -1,4 +1,4 @@ -package com.baeldung.java.reflection; +package com.baeldung.reflection; public class Bird extends Animal { private boolean walks; diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/java/reflection/DynamicGreeter.java b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/reflection/DynamicGreeter.java similarity index 91% rename from core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/java/reflection/DynamicGreeter.java rename to core-java-modules/core-java-11-2/src/main/java/com/baeldung/reflection/DynamicGreeter.java index 3776ef82e2..b7ff083daf 100644 --- a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/java/reflection/DynamicGreeter.java +++ b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/reflection/DynamicGreeter.java @@ -1,4 +1,4 @@ -package com.baeldung.java.reflection; +package com.baeldung.reflection; import java.lang.annotation.Annotation; diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/java/reflection/Eating.java b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/reflection/Eating.java similarity index 55% rename from core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/java/reflection/Eating.java rename to core-java-modules/core-java-11-2/src/main/java/com/baeldung/reflection/Eating.java index 479425cad4..c959becf00 100644 --- a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/java/reflection/Eating.java +++ b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/reflection/Eating.java @@ -1,4 +1,4 @@ -package com.baeldung.java.reflection; +package com.baeldung.reflection; public interface Eating { String eats(); diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/java/reflection/Goat.java b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/reflection/Goat.java similarity index 90% rename from core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/java/reflection/Goat.java rename to core-java-modules/core-java-11-2/src/main/java/com/baeldung/reflection/Goat.java index 503717ae5e..086d09d543 100644 --- a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/java/reflection/Goat.java +++ b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/reflection/Goat.java @@ -1,4 +1,4 @@ -package com.baeldung.java.reflection; +package com.baeldung.reflection; public class Goat extends Animal implements Locomotion { diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/java/reflection/Greeter.java b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/reflection/Greeter.java similarity index 83% rename from core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/java/reflection/Greeter.java rename to core-java-modules/core-java-11-2/src/main/java/com/baeldung/reflection/Greeter.java index 57aefdd169..d06a719312 100644 --- a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/java/reflection/Greeter.java +++ b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/reflection/Greeter.java @@ -1,4 +1,4 @@ -package com.baeldung.java.reflection; +package com.baeldung.reflection; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/java/reflection/GreetingAnnotation.java b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/reflection/GreetingAnnotation.java similarity index 98% rename from core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/java/reflection/GreetingAnnotation.java rename to core-java-modules/core-java-11-2/src/main/java/com/baeldung/reflection/GreetingAnnotation.java index 601306f5d2..f23c407c52 100644 --- a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/java/reflection/GreetingAnnotation.java +++ b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/reflection/GreetingAnnotation.java @@ -1,4 +1,4 @@ -package com.baeldung.java.reflection; +package com.baeldung.reflection; import java.lang.annotation.Annotation; import java.lang.reflect.Field; diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/java/reflection/Greetings.java b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/reflection/Greetings.java similarity index 61% rename from core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/java/reflection/Greetings.java rename to core-java-modules/core-java-11-2/src/main/java/com/baeldung/reflection/Greetings.java index 4f3a20c3b9..fc6dfe949b 100644 --- a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/java/reflection/Greetings.java +++ b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/reflection/Greetings.java @@ -1,4 +1,4 @@ -package com.baeldung.java.reflection; +package com.baeldung.reflection; @Greeter(greet="Good morning") public class Greetings { diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/java/reflection/Locomotion.java b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/reflection/Locomotion.java similarity index 61% rename from core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/java/reflection/Locomotion.java rename to core-java-modules/core-java-11-2/src/main/java/com/baeldung/reflection/Locomotion.java index 047c00cb13..230fd9a466 100644 --- a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/java/reflection/Locomotion.java +++ b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/reflection/Locomotion.java @@ -1,4 +1,4 @@ -package com.baeldung.java.reflection; +package com.baeldung.reflection; public interface Locomotion { String getLocomotion(); diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/java/reflection/Operations.java b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/reflection/Operations.java similarity index 90% rename from core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/java/reflection/Operations.java rename to core-java-modules/core-java-11-2/src/main/java/com/baeldung/reflection/Operations.java index da4b479b02..5264378524 100644 --- a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/java/reflection/Operations.java +++ b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/reflection/Operations.java @@ -1,4 +1,4 @@ -package com.baeldung.java.reflection; +package com.baeldung.reflection; public class Operations { diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/java/reflection/Person.java b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/reflection/Person.java similarity index 65% rename from core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/java/reflection/Person.java rename to core-java-modules/core-java-11-2/src/main/java/com/baeldung/reflection/Person.java index f3d7f9f001..1a1fafef93 100644 --- a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/java/reflection/Person.java +++ b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/reflection/Person.java @@ -1,4 +1,4 @@ -package com.baeldung.java.reflection; +package com.baeldung.reflection; public class Person { private String name; diff --git a/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/java/reflection/OperationsUnitTest.java b/core-java-modules/core-java-11-2/src/test/java/com/baeldung/reflection/OperationsUnitTest.java similarity index 98% rename from core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/java/reflection/OperationsUnitTest.java rename to core-java-modules/core-java-11-2/src/test/java/com/baeldung/reflection/OperationsUnitTest.java index 217910bffd..7584d5da94 100644 --- a/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/java/reflection/OperationsUnitTest.java +++ b/core-java-modules/core-java-11-2/src/test/java/com/baeldung/reflection/OperationsUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.java.reflection; +package com.baeldung.reflection; import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertFalse; diff --git a/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/java/reflection/ReflectionUnitTest.java b/core-java-modules/core-java-11-2/src/test/java/com/baeldung/reflection/ReflectionUnitTest.java similarity index 77% rename from core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/java/reflection/ReflectionUnitTest.java rename to core-java-modules/core-java-11-2/src/test/java/com/baeldung/reflection/ReflectionUnitTest.java index a791d64874..c73fa5f8e0 100644 --- a/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/java/reflection/ReflectionUnitTest.java +++ b/core-java-modules/core-java-11-2/src/test/java/com/baeldung/reflection/ReflectionUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.java.reflection; +package com.baeldung.reflection; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -32,23 +32,23 @@ public class ReflectionUnitTest { final Class clazz = goat.getClass(); assertEquals("Goat", clazz.getSimpleName()); - assertEquals("com.baeldung.java.reflection.Goat", clazz.getName()); - assertEquals("com.baeldung.java.reflection.Goat", clazz.getCanonicalName()); + assertEquals("com.baeldung.reflection.Goat", clazz.getName()); + assertEquals("com.baeldung.reflection.Goat", clazz.getCanonicalName()); } @Test public void givenClassName_whenCreatesObject_thenCorrect() throws ClassNotFoundException { - final Class clazz = Class.forName("com.baeldung.java.reflection.Goat"); + final Class clazz = Class.forName("com.baeldung.reflection.Goat"); assertEquals("Goat", clazz.getSimpleName()); - assertEquals("com.baeldung.java.reflection.Goat", clazz.getName()); - assertEquals("com.baeldung.java.reflection.Goat", clazz.getCanonicalName()); + assertEquals("com.baeldung.reflection.Goat", clazz.getName()); + assertEquals("com.baeldung.reflection.Goat", clazz.getCanonicalName()); } @Test public void givenClass_whenRecognisesModifiers_thenCorrect() throws ClassNotFoundException { - final Class goatClass = Class.forName("com.baeldung.java.reflection.Goat"); - final Class animalClass = Class.forName("com.baeldung.java.reflection.Animal"); + final Class goatClass = Class.forName("com.baeldung.reflection.Goat"); + final Class animalClass = Class.forName("com.baeldung.reflection.Animal"); final int goatMods = goatClass.getModifiers(); final int animalMods = animalClass.getModifiers(); @@ -63,7 +63,7 @@ public class ReflectionUnitTest { final Class goatClass = goat.getClass(); final Package pkg = goatClass.getPackage(); - assertEquals("com.baeldung.java.reflection", pkg.getName()); + assertEquals("com.baeldung.reflection", pkg.getName()); } @Test @@ -81,8 +81,8 @@ public class ReflectionUnitTest { @Test public void givenClass_whenGetsImplementedInterfaces_thenCorrect() throws ClassNotFoundException { - final Class goatClass = Class.forName("com.baeldung.java.reflection.Goat"); - final Class animalClass = Class.forName("com.baeldung.java.reflection.Animal"); + final Class goatClass = Class.forName("com.baeldung.reflection.Goat"); + final Class animalClass = Class.forName("com.baeldung.reflection.Animal"); final Class[] goatInterfaces = goatClass.getInterfaces(); final Class[] animalInterfaces = animalClass.getInterfaces(); @@ -94,16 +94,16 @@ public class ReflectionUnitTest { @Test public void givenClass_whenGetsConstructor_thenCorrect() throws ClassNotFoundException { - final Class goatClass = Class.forName("com.baeldung.java.reflection.Goat"); + final Class goatClass = Class.forName("com.baeldung.reflection.Goat"); final Constructor[] constructors = goatClass.getConstructors(); assertEquals(1, constructors.length); - assertEquals("com.baeldung.java.reflection.Goat", constructors[0].getName()); + assertEquals("com.baeldung.reflection.Goat", constructors[0].getName()); } @Test public void givenClass_whenGetsFields_thenCorrect() throws ClassNotFoundException { - final Class animalClass = Class.forName("com.baeldung.java.reflection.Animal"); + final Class animalClass = Class.forName("com.baeldung.reflection.Animal"); final Field[] fields = animalClass.getDeclaredFields(); final List actualFields = getFieldNames(fields); @@ -114,7 +114,7 @@ public class ReflectionUnitTest { @Test public void givenClass_whenGetsMethods_thenCorrect() throws ClassNotFoundException { - final Class animalClass = Class.forName("com.baeldung.java.reflection.Animal"); + final Class animalClass = Class.forName("com.baeldung.reflection.Animal"); final Method[] methods = animalClass.getDeclaredMethods(); final List actualMethods = getMethodNames(methods); @@ -124,7 +124,7 @@ public class ReflectionUnitTest { @Test public void givenClass_whenGetsAllConstructors_thenCorrect() throws ClassNotFoundException { - final Class birdClass = Class.forName("com.baeldung.java.reflection.Bird"); + final Class birdClass = Class.forName("com.baeldung.reflection.Bird"); final Constructor[] constructors = birdClass.getConstructors(); assertEquals(3, constructors.length); @@ -132,7 +132,7 @@ public class ReflectionUnitTest { @Test public void givenClass_whenGetsEachConstructorByParamTypes_thenCorrect() throws Exception { - final Class birdClass = Class.forName("com.baeldung.java.reflection.Bird"); + final Class birdClass = Class.forName("com.baeldung.reflection.Bird"); birdClass.getConstructor(); birdClass.getConstructor(String.class); birdClass.getConstructor(String.class, boolean.class); @@ -140,7 +140,7 @@ public class ReflectionUnitTest { @Test public void givenClass_whenInstantiatesObjectsAtRuntime_thenCorrect() throws Exception { - final Class birdClass = Class.forName("com.baeldung.java.reflection.Bird"); + final Class birdClass = Class.forName("com.baeldung.reflection.Bird"); final Constructor cons1 = birdClass.getConstructor(); final Constructor cons2 = birdClass.getConstructor(String.class); @@ -159,7 +159,7 @@ public class ReflectionUnitTest { @Test public void givenClass_whenGetsPublicFields_thenCorrect() throws ClassNotFoundException { - final Class birdClass = Class.forName("com.baeldung.java.reflection.Bird"); + final Class birdClass = Class.forName("com.baeldung.reflection.Bird"); final Field[] fields = birdClass.getFields(); assertEquals(1, fields.length); assertEquals("CATEGORY", fields[0].getName()); @@ -168,7 +168,7 @@ public class ReflectionUnitTest { @Test public void givenClass_whenGetsPublicFieldByName_thenCorrect() throws Exception { - final Class birdClass = Class.forName("com.baeldung.java.reflection.Bird"); + final Class birdClass = Class.forName("com.baeldung.reflection.Bird"); final Field field = birdClass.getField("CATEGORY"); assertEquals("CATEGORY", field.getName()); @@ -176,7 +176,7 @@ public class ReflectionUnitTest { @Test public void givenClass_whenGetsDeclaredFields_thenCorrect() throws ClassNotFoundException { - final Class birdClass = Class.forName("com.baeldung.java.reflection.Bird"); + final Class birdClass = Class.forName("com.baeldung.reflection.Bird"); final Field[] fields = birdClass.getDeclaredFields(); assertEquals(1, fields.length); assertEquals("walks", fields[0].getName()); @@ -184,7 +184,7 @@ public class ReflectionUnitTest { @Test public void givenClass_whenGetsFieldsByName_thenCorrect() throws Exception { - final Class birdClass = Class.forName("com.baeldung.java.reflection.Bird"); + final Class birdClass = Class.forName("com.baeldung.reflection.Bird"); final Field field = birdClass.getDeclaredField("walks"); assertEquals("walks", field.getName()); @@ -192,14 +192,14 @@ public class ReflectionUnitTest { @Test public void givenClassField_whenGetsType_thenCorrect() throws Exception { - final Field field = Class.forName("com.baeldung.java.reflection.Bird").getDeclaredField("walks"); + final Field field = Class.forName("com.baeldung.reflection.Bird").getDeclaredField("walks"); final Class fieldClass = field.getType(); assertEquals("boolean", fieldClass.getSimpleName()); } @Test public void givenClassField_whenSetsAndGetsValue_thenCorrect() throws Exception { - final Class birdClass = Class.forName("com.baeldung.java.reflection.Bird"); + final Class birdClass = Class.forName("com.baeldung.reflection.Bird"); final Bird bird = (Bird) birdClass.getConstructor().newInstance(); final Field field = birdClass.getDeclaredField("walks"); field.setAccessible(true); @@ -216,7 +216,7 @@ public class ReflectionUnitTest { @Test public void givenClassField_whenGetsAndSetsWithNull_thenCorrect() throws Exception { - final Class birdClass = Class.forName("com.baeldung.java.reflection.Bird"); + final Class birdClass = Class.forName("com.baeldung.reflection.Bird"); final Field field = birdClass.getField("CATEGORY"); field.setAccessible(true); @@ -225,7 +225,7 @@ public class ReflectionUnitTest { @Test public void givenClass_whenGetsAllPublicMethods_thenCorrect() throws ClassNotFoundException { - final Class birdClass = Class.forName("com.baeldung.java.reflection.Bird"); + final Class birdClass = Class.forName("com.baeldung.reflection.Bird"); final Method[] methods = birdClass.getMethods(); final List methodNames = getMethodNames(methods); @@ -235,7 +235,7 @@ public class ReflectionUnitTest { @Test public void givenClass_whenGetsOnlyDeclaredMethods_thenCorrect() throws ClassNotFoundException { - final Class birdClass = Class.forName("com.baeldung.java.reflection.Bird"); + final Class birdClass = Class.forName("com.baeldung.reflection.Bird"); final List actualMethodNames = getMethodNames(birdClass.getDeclaredMethods()); final List expectedMethodNames = Arrays.asList("setWalks", "walks", "getSound", "eats"); @@ -248,24 +248,17 @@ public class ReflectionUnitTest { @Test public void givenMethodName_whenGetsMethod_thenCorrect() throws Exception { - final Class birdClass = Class.forName("com.baeldung.java.reflection.Bird"); - final Method walksMethod = birdClass.getDeclaredMethod("walks"); - final Method setWalksMethod = birdClass.getDeclaredMethod("setWalks", boolean.class); - - assertFalse(walksMethod.isAccessible()); - assertFalse(setWalksMethod.isAccessible()); - - walksMethod.setAccessible(true); - setWalksMethod.setAccessible(true); - - assertTrue(walksMethod.isAccessible()); - assertTrue(setWalksMethod.isAccessible()); + final Bird bird = new Bird(); + final Method walksMethod = bird.getClass().getDeclaredMethod("walks"); + final Method setWalksMethod = bird.getClass().getDeclaredMethod("setWalks", boolean.class); + assertTrue(walksMethod.canAccess(bird)); + assertTrue(setWalksMethod.canAccess(bird)); } @Test public void givenMethod_whenInvokes_thenCorrect() throws Exception { - final Class birdClass = Class.forName("com.baeldung.java.reflection.Bird"); + final Class birdClass = Class.forName("com.baeldung.reflection.Bird"); final Bird bird = (Bird) birdClass.getConstructor().newInstance(); final Method setWalksMethod = birdClass.getDeclaredMethod("setWalks", boolean.class); final Method walksMethod = birdClass.getDeclaredMethod("walks"); diff --git a/core-java-modules/core-java-reflection/README.MD b/core-java-modules/core-java-reflection/README.MD index 5d8c54414b..62d8719981 100644 --- a/core-java-modules/core-java-reflection/README.MD +++ b/core-java-modules/core-java-reflection/README.MD @@ -3,7 +3,6 @@ - [Void Type in Java](https://www.baeldung.com/java-void-type) - [Retrieve Fields from a Java Class Using Reflection](https://www.baeldung.com/java-reflection-class-fields) - [Method Parameter Reflection in Java](http://www.baeldung.com/java-parameter-reflection) -- [Guide to Java Reflection](http://www.baeldung.com/java-reflection) - [Call Methods at Runtime Using Java Reflection](http://www.baeldung.com/java-method-reflection) - [Changing Annotation Parameters At Runtime](http://www.baeldung.com/java-reflection-change-annotation-params) - [Dynamic Proxies in Java](http://www.baeldung.com/java-dynamic-proxies) From 2096c22d436935fb843b102a9ed553951c5c62c1 Mon Sep 17 00:00:00 2001 From: Gang Wu Date: Sat, 12 Sep 2020 16:50:40 -0600 Subject: [PATCH 119/263] BAEL-4453 Reversing a Linked List in Java --- .../linkedlist/LinkedListReversal.java | 30 ++++++++++ .../algorithms/linkedlist/ListNode.java | 28 +++++++++ .../LinkedListReversalUnitTest.java | 59 +++++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/linkedlist/LinkedListReversal.java create mode 100644 algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/linkedlist/ListNode.java create mode 100644 algorithms-miscellaneous-6/src/test/java/com/baeldung/algorithms/linkedlist/LinkedListReversalUnitTest.java diff --git a/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/linkedlist/LinkedListReversal.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/linkedlist/LinkedListReversal.java new file mode 100644 index 0000000000..93402133ff --- /dev/null +++ b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/linkedlist/LinkedListReversal.java @@ -0,0 +1,30 @@ +package com.baeldung.algorithms.linkedlist; + +public class LinkedListReversal { + + ListNode reverseList(ListNode head) { + ListNode previous = null; + ListNode current = head; + while (current != null) { + ListNode nextElement = current.getNext(); + current.setNext(previous); + previous = current; + current = nextElement; + } + return previous; + } + + ListNode reverseListRecursive(ListNode head) { + if (head == null) { + return null; + } + if (head.getNext() == null) { + return head; + } + ListNode node = reverseListRecursive(head.getNext()); + head.getNext().setNext(head); + head.setNext(null); + return node; + } + +} diff --git a/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/linkedlist/ListNode.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/linkedlist/ListNode.java new file mode 100644 index 0000000000..de2e93a65c --- /dev/null +++ b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/linkedlist/ListNode.java @@ -0,0 +1,28 @@ +package com.baeldung.algorithms.linkedlist; + +public class ListNode { + + private int data; + private ListNode next; + + ListNode(int data) { + this.data = data; + this.next = null; + } + + public int getData() { + return data; + } + + public ListNode getNext() { + return next; + } + + public void setData(int data) { + this.data = data; + } + + public void setNext(ListNode next) { + this.next = next; + } +} diff --git a/algorithms-miscellaneous-6/src/test/java/com/baeldung/algorithms/linkedlist/LinkedListReversalUnitTest.java b/algorithms-miscellaneous-6/src/test/java/com/baeldung/algorithms/linkedlist/LinkedListReversalUnitTest.java new file mode 100644 index 0000000000..0940677959 --- /dev/null +++ b/algorithms-miscellaneous-6/src/test/java/com/baeldung/algorithms/linkedlist/LinkedListReversalUnitTest.java @@ -0,0 +1,59 @@ +package com.baeldung.algorithms.linkedlist; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +public class LinkedListReversalUnitTest { + @Test + public void givenLinkedList_whenIterativeReverse_thenOutputCorrectResult() { + ListNode head = constructLinkedList(); + ListNode node = head; + for (int i = 1; i <= 5; i++) { + assertNotNull(node); + assertEquals(i, node.getData()); + node = node.getNext(); + } + LinkedListReversal reversal = new LinkedListReversal(); + node = reversal.reverseList(head); + for (int i = 5; i >= 1; i--) { + assertNotNull(node); + assertEquals(i, node.getData()); + node = node.getNext(); + } + } + + @Test + public void givenLinkedList_whenRecursiveReverse_thenOutputCorrectResult() { + ListNode head = constructLinkedList(); + ListNode node = head; + for (int i = 1; i <= 5; i++) { + assertNotNull(node); + assertEquals(i, node.getData()); + node = node.getNext(); + } + LinkedListReversal reversal = new LinkedListReversal(); + node = reversal.reverseListRecursive(head); + for (int i = 5; i >= 1; i--) { + assertNotNull(node); + assertEquals(i, node.getData()); + node = node.getNext(); + } + } + + private ListNode constructLinkedList() { + ListNode head = null; + ListNode tail = null; + for (int i = 1; i <= 5; i++) { + ListNode node = new ListNode(i); + if (head == null) { + head = node; + } else { + tail.setNext(node); + } + tail = node; + } + return head; + } +} From 1b55f0a27e96ec5ff35aca2ee3636788d5f11f3d Mon Sep 17 00:00:00 2001 From: Harihar Das Date: Sun, 13 Sep 2020 10:54:49 +0200 Subject: [PATCH 120/263] Make gradle-wrapper a subdrirectory of gradle --- .../gradle-wrapper}/gradle/wrapper/README.md | 0 .../gradle-wrapper}/gradle/wrapper/gradle-wrapper.properties | 0 {gradle-wrapper => gradle/gradle-wrapper}/gradlew | 0 {gradle-wrapper => gradle/gradle-wrapper}/gradlew.bat | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename {gradle-wrapper => gradle/gradle-wrapper}/gradle/wrapper/README.md (100%) rename {gradle-wrapper => gradle/gradle-wrapper}/gradle/wrapper/gradle-wrapper.properties (100%) rename {gradle-wrapper => gradle/gradle-wrapper}/gradlew (100%) rename {gradle-wrapper => gradle/gradle-wrapper}/gradlew.bat (100%) diff --git a/gradle-wrapper/gradle/wrapper/README.md b/gradle/gradle-wrapper/gradle/wrapper/README.md similarity index 100% rename from gradle-wrapper/gradle/wrapper/README.md rename to gradle/gradle-wrapper/gradle/wrapper/README.md diff --git a/gradle-wrapper/gradle/wrapper/gradle-wrapper.properties b/gradle/gradle-wrapper/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from gradle-wrapper/gradle/wrapper/gradle-wrapper.properties rename to gradle/gradle-wrapper/gradle/wrapper/gradle-wrapper.properties diff --git a/gradle-wrapper/gradlew b/gradle/gradle-wrapper/gradlew similarity index 100% rename from gradle-wrapper/gradlew rename to gradle/gradle-wrapper/gradlew diff --git a/gradle-wrapper/gradlew.bat b/gradle/gradle-wrapper/gradlew.bat similarity index 100% rename from gradle-wrapper/gradlew.bat rename to gradle/gradle-wrapper/gradlew.bat From e756edec9296c722114e77b4bbe09d61f5f53fde Mon Sep 17 00:00:00 2001 From: "amit.pandey" Date: Sun, 13 Sep 2020 21:05:10 +0530 Subject: [PATCH 121/263] add modules in parent pom build --- maven-modules/maven-plugins/pom.xml | 5 +++++ spring-cloud/pom.xml | 1 + 2 files changed, 6 insertions(+) diff --git a/maven-modules/maven-plugins/pom.xml b/maven-modules/maven-plugins/pom.xml index 43bcf1f422..4877f00a92 100644 --- a/maven-modules/maven-plugins/pom.xml +++ b/maven-modules/maven-plugins/pom.xml @@ -14,6 +14,11 @@ ../.. + + + maven-enforcer + + diff --git a/spring-cloud/pom.xml b/spring-cloud/pom.xml index 99fde0daf4..ee7b80ffc1 100644 --- a/spring-cloud/pom.xml +++ b/spring-cloud/pom.xml @@ -43,6 +43,7 @@ spring-cloud-ribbon-retry spring-cloud-circuit-breaker spring-cloud-eureka-self-preservation + From ed7ce4ce3469944b48c40de45364f32d56fc135d Mon Sep 17 00:00:00 2001 From: gupta-ashu01 <30566001+gupta-ashu01@users.noreply.github.com> Date: Sun, 13 Sep 2020 22:35:45 +0530 Subject: [PATCH 122/263] BAEL-4567 (#10007) * BAEL-4567 BAEL-4567 * Add files via upload * Add files via upload * Delete SendMailWithAttachment.java * Update pom.xml * Formatting fixes --- .../core-java-networking-2/pom.xml | 6 ++ .../MailWithAttachmentService.java | 83 +++++++++++++++++++ .../MailWithAttachmentServiceLiveTest.java | 48 +++++++++++ 3 files changed, 137 insertions(+) create mode 100644 core-java-modules/core-java-networking-2/src/main/java/com/baeldung/mail/mailwithattachment/MailWithAttachmentService.java create mode 100644 core-java-modules/core-java-networking-2/src/test/java/com/baeldung/mail/mailwithattachment/MailWithAttachmentServiceLiveTest.java diff --git a/core-java-modules/core-java-networking-2/pom.xml b/core-java-modules/core-java-networking-2/pom.xml index d79320eaef..89a98bbf8b 100644 --- a/core-java-modules/core-java-networking-2/pom.xml +++ b/core-java-modules/core-java-networking-2/pom.xml @@ -35,6 +35,12 @@ async-http-client ${async-http-client.version} + + com.icegreen + greenmail + 1.5.8 + test + diff --git a/core-java-modules/core-java-networking-2/src/main/java/com/baeldung/mail/mailwithattachment/MailWithAttachmentService.java b/core-java-modules/core-java-networking-2/src/main/java/com/baeldung/mail/mailwithattachment/MailWithAttachmentService.java new file mode 100644 index 0000000000..7d4dc57f10 --- /dev/null +++ b/core-java-modules/core-java-networking-2/src/main/java/com/baeldung/mail/mailwithattachment/MailWithAttachmentService.java @@ -0,0 +1,83 @@ +package com.baeldung.mail.mailwithattachment; + +import java.io.File; +import java.io.IOException; +import java.util.Properties; +import javax.mail.BodyPart; +import javax.mail.Message; +import javax.mail.MessagingException; +import javax.mail.Multipart; +import javax.mail.PasswordAuthentication; +import javax.mail.Session; +import javax.mail.Transport; +import javax.mail.internet.AddressException; +import javax.mail.internet.InternetAddress; +import javax.mail.internet.MimeBodyPart; +import javax.mail.internet.MimeMessage; +import javax.mail.internet.MimeMultipart; + +public class MailWithAttachmentService { + + private String username = ""; + private String password = ""; + private String host = ""; + private String port = ""; + + MailWithAttachmentService() { + } + + MailWithAttachmentService(String username, String password, String host, String port) { + this.username = username; + this.password = password; + this.host = host; + this.port = port; + } + + public Session getSession() { + Properties props = new Properties(); + props.put("mail.smtp.auth", "true"); + props.put("mail.smtp.starttls.enable", "true"); + props.put("mail.smtp.host", this.host); + props.put("mail.smtp.port", this.port); + + Session session = Session.getInstance(props, new javax.mail.Authenticator() { + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(username, password); + } + }); + return session; + } + + public Message createMail(Session session) throws AddressException, MessagingException, IOException { + Message message = new MimeMessage(session); + message.setFrom(new InternetAddress("mail@gmail.com")); + message.setRecipients(Message.RecipientType.TO, InternetAddress.parse("mail@gmail.com")); + message.setSubject("Testing Subject"); + + BodyPart messageBodyPart = new MimeBodyPart(); + messageBodyPart.setText("This is message body"); + + Multipart multipart = new MimeMultipart(); + multipart.addBodyPart(messageBodyPart); + + MimeBodyPart attachmentPart = new MimeBodyPart(); + MimeBodyPart attachmentPart2 = new MimeBodyPart(); + + attachmentPart.attachFile(new File("C:\\Document1.txt")); + attachmentPart2.attachFile(new File("C:\\Document2.txt")); + + multipart.addBodyPart(attachmentPart); + multipart.addBodyPart(attachmentPart2); + + message.setContent(multipart); + + return message; + } + + public void sendMail(Session session) throws MessagingException, IOException { + + Message message = createMail(session); + Transport.send(message); + } + +} \ No newline at end of file diff --git a/core-java-modules/core-java-networking-2/src/test/java/com/baeldung/mail/mailwithattachment/MailWithAttachmentServiceLiveTest.java b/core-java-modules/core-java-networking-2/src/test/java/com/baeldung/mail/mailwithattachment/MailWithAttachmentServiceLiveTest.java new file mode 100644 index 0000000000..ef82657ab5 --- /dev/null +++ b/core-java-modules/core-java-networking-2/src/test/java/com/baeldung/mail/mailwithattachment/MailWithAttachmentServiceLiveTest.java @@ -0,0 +1,48 @@ +package com.baeldung.mail.mailwithattachment; + +import static org.junit.Assert.*; +import javax.annotation.Resource; +import javax.mail.Session; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import com.baeldung.mail.mailwithattachment.MailWithAttachmentService; +import com.icegreen.greenmail.util.GreenMail; +import com.icegreen.greenmail.util.ServerSetupTest; + +public class MailWithAttachmentServiceLiveTest { + + @Resource + private MailWithAttachmentService emailService; + private GreenMail greenMail; + + @Before + public void startMailServer() { + emailService = new MailWithAttachmentService(); + greenMail = new GreenMail(ServerSetupTest.SMTP); + greenMail.start(); + } + + @After + public void stopMailServer() { + greenMail.stop(); + emailService = null; + } + + @Test + public void canSendMail() { + try { + Session testSession = greenMail.getSmtp() + .createSession(); + emailService.sendMail(testSession); + assertEquals(1, greenMail.getReceivedMessages().length); + + } catch (Exception e) { + e.printStackTrace(); + } + + } + +} From fb115abd62fede31a07c8a9630dadeb2c2e4b2ed Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Sun, 13 Sep 2020 20:29:43 +0200 Subject: [PATCH 123/263] JAVA-2400: Fix EmailAnnotationPlugin implementation --- .../baeldung/swagger2boot/plugin/EmailAnnotationPlugin.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/plugin/EmailAnnotationPlugin.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/plugin/EmailAnnotationPlugin.java index 22ca144fb4..59a7c97080 100644 --- a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/plugin/EmailAnnotationPlugin.java +++ b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/plugin/EmailAnnotationPlugin.java @@ -10,6 +10,7 @@ import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; import springfox.bean.validators.plugins.Validators; +import springfox.documentation.builders.StringElementFacetBuilder; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spi.schema.ModelPropertyBuilderPlugin; import springfox.documentation.spi.schema.contexts.ModelPropertyContext; @@ -30,8 +31,9 @@ public class EmailAnnotationPlugin implements ModelPropertyBuilderPlugin { public void apply(ModelPropertyContext context) { Optional email = annotationFromBean(context, Email.class); if (email.isPresent()) { - context.getBuilder().pattern(email.get().regexp()); - context.getBuilder().example("email@email.com"); + context.getSpecificationBuilder().facetBuilder(StringElementFacetBuilder.class) + .pattern(email.get().regexp()); + context.getSpecificationBuilder().example("email@email.com"); } } From 57b66fa5788ff711f92716540f87205a1af38f80 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Sun, 13 Sep 2020 21:40:14 +0200 Subject: [PATCH 124/263] JAVA-2404: Fix Spring MVC and Security config --- .../java/com/baeldung/spring/WebConfig.java | 2 +- .../src/main/webapp/WEB-INF/web.xml | 28 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/spring-security-modules/spring-security-web-rest/src/main/java/com/baeldung/spring/WebConfig.java b/spring-security-modules/spring-security-web-rest/src/main/java/com/baeldung/spring/WebConfig.java index 84b211a9bd..76e9abdbdb 100644 --- a/spring-security-modules/spring-security-web-rest/src/main/java/com/baeldung/spring/WebConfig.java +++ b/spring-security-modules/spring-security-web-rest/src/main/java/com/baeldung/spring/WebConfig.java @@ -12,7 +12,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.view.InternalResourceViewResolver; @Configuration -@ComponentScan("com.baeldung.web") +@ComponentScan("com.baeldung") @EnableWebMvc @EnableAsync public class WebConfig implements WebMvcConfigurer { diff --git a/spring-security-modules/spring-security-web-rest/src/main/webapp/WEB-INF/web.xml b/spring-security-modules/spring-security-web-rest/src/main/webapp/WEB-INF/web.xml index 663c17bc56..6321277c5b 100644 --- a/spring-security-modules/spring-security-web-rest/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-modules/spring-security-web-rest/src/main/webapp/WEB-INF/web.xml @@ -20,9 +20,9 @@ com.baeldung.spring - - org.springframework.web.context.ContextLoaderListener - + + + @@ -40,17 +40,17 @@ - - springSecurityFilterChain - org.springframework.web.filter.DelegatingFilterProxy - true - - - springSecurityFilterChain - /* - REQUEST - ASYNC - + + + + + + + + + + + From 4e081b4fb65a03ccfa100f8f329e2e202e7b1b78 Mon Sep 17 00:00:00 2001 From: michaelisvy Date: Mon, 14 Sep 2020 08:16:56 +0800 Subject: [PATCH 125/263] added advanced Spring Retry example and removed Spring Retry xml config --- .../com/baeldung/springretry/AppConfig.java | 5 +- .../com/baeldung/springretry/MyService.java | 11 +++- .../baeldung/springretry/MyServiceImpl.java | 16 ++++++ .../src/main/resources/retryConfig.properties | 2 + .../src/main/resources/retryadvice.xml | 50 ------------------- .../SpringRetryIntegrationTest.java | 10 ++++ 6 files changed, 40 insertions(+), 54 deletions(-) create mode 100644 spring-scheduling/src/main/resources/retryConfig.properties delete mode 100644 spring-scheduling/src/main/resources/retryadvice.xml diff --git a/spring-scheduling/src/main/java/com/baeldung/springretry/AppConfig.java b/spring-scheduling/src/main/java/com/baeldung/springretry/AppConfig.java index e79beb370b..2ca9104e89 100644 --- a/spring-scheduling/src/main/java/com/baeldung/springretry/AppConfig.java +++ b/spring-scheduling/src/main/java/com/baeldung/springretry/AppConfig.java @@ -3,6 +3,7 @@ package com.baeldung.springretry; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; import org.springframework.retry.annotation.EnableRetry; import org.springframework.retry.backoff.FixedBackOffPolicy; import org.springframework.retry.policy.SimpleRetryPolicy; @@ -11,9 +12,7 @@ import org.springframework.retry.support.RetryTemplate; @Configuration @ComponentScan(basePackages = "com.baeldung.springretry") @EnableRetry -// Uncomment this two lines if we need XML configuration -// @EnableAspectJAutoProxy -// @ImportResource("classpath:/retryadvice.xml") +@PropertySource("classpath:retryConfig.properties") public class AppConfig { @Bean diff --git a/spring-scheduling/src/main/java/com/baeldung/springretry/MyService.java b/spring-scheduling/src/main/java/com/baeldung/springretry/MyService.java index 409bf25845..40e2c419fc 100644 --- a/spring-scheduling/src/main/java/com/baeldung/springretry/MyService.java +++ b/spring-scheduling/src/main/java/com/baeldung/springretry/MyService.java @@ -2,18 +2,27 @@ package com.baeldung.springretry; import java.sql.SQLException; +import org.springframework.context.annotation.PropertySource; import org.springframework.retry.annotation.Backoff; import org.springframework.retry.annotation.Recover; import org.springframework.retry.annotation.Retryable; + public interface MyService { @Retryable void retryService(); - @Retryable(value = { SQLException.class }, maxAttempts = 2, backoff = @Backoff(delay = 5000)) + @Retryable(value = SQLException.class) void retryServiceWithRecovery(String sql) throws SQLException; + @Retryable(value = { SQLException.class }, maxAttempts = 2, backoff = @Backoff(delay = 100)) + void retryServiceWithCustomization(String sql) throws SQLException; + + @Retryable( value = SQLException.class, maxAttemptsExpression = "${retry.maxAttempts}", + backoff = @Backoff(delayExpression = "${retry.maxDelay}")) + void retryServiceWithExternalConfiguration(String sql) throws SQLException; + @Recover void recover(SQLException e, String sql); diff --git a/spring-scheduling/src/main/java/com/baeldung/springretry/MyServiceImpl.java b/spring-scheduling/src/main/java/com/baeldung/springretry/MyServiceImpl.java index 3e4b5ed00d..7eb4328a47 100644 --- a/spring-scheduling/src/main/java/com/baeldung/springretry/MyServiceImpl.java +++ b/spring-scheduling/src/main/java/com/baeldung/springretry/MyServiceImpl.java @@ -26,6 +26,22 @@ public class MyServiceImpl implements MyService { } } + @Override + public void retryServiceWithCustomization(String sql) throws SQLException { + if (StringUtils.isEmpty(sql)) { + logger.info("throw SQLException in method retryServiceWithCustomization()"); + throw new SQLException(); + } + } + + @Override + public void retryServiceWithExternalConfiguration(String sql) throws SQLException { + if (StringUtils.isEmpty(sql)) { + logger.info("throw SQLException in method retryServiceWithExternalConfiguration()"); + throw new SQLException(); + } + } + @Override public void recover(SQLException e, String sql) { logger.info("In recover method"); diff --git a/spring-scheduling/src/main/resources/retryConfig.properties b/spring-scheduling/src/main/resources/retryConfig.properties new file mode 100644 index 0000000000..7cc360adc6 --- /dev/null +++ b/spring-scheduling/src/main/resources/retryConfig.properties @@ -0,0 +1,2 @@ +retry.maxAttempts=2 +retry.maxDelay=100 \ No newline at end of file diff --git a/spring-scheduling/src/main/resources/retryadvice.xml b/spring-scheduling/src/main/resources/retryadvice.xml deleted file mode 100644 index 8de7801a58..0000000000 --- a/spring-scheduling/src/main/resources/retryadvice.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Initial sleep interval value, default 300 ms - - - - - The maximum value of the backoff period in milliseconds. - - - - - The value to increment the exp seed with for each retry attempt. - - - - - \ No newline at end of file diff --git a/spring-scheduling/src/test/java/com/baeldung/springretry/SpringRetryIntegrationTest.java b/spring-scheduling/src/test/java/com/baeldung/springretry/SpringRetryIntegrationTest.java index 2e5fb75482..33ce2fff74 100644 --- a/spring-scheduling/src/test/java/com/baeldung/springretry/SpringRetryIntegrationTest.java +++ b/spring-scheduling/src/test/java/com/baeldung/springretry/SpringRetryIntegrationTest.java @@ -30,6 +30,16 @@ public class SpringRetryIntegrationTest { myService.retryServiceWithRecovery(null); } + @Test + public void givenRetryServiceWithCustomization_whenCallWithException_thenRetryRecover() throws SQLException { + myService.retryServiceWithCustomization(null); + } + + @Test + public void givenRetryServiceWithExternalConfiguration_whenCallWithException_thenRetryRecover() throws SQLException { + myService.retryServiceWithExternalConfiguration(null); + } + @Test(expected = RuntimeException.class) public void givenTemplateRetryService_whenCallWithException_thenRetry() { retryTemplate.execute(arg0 -> { From bd9ac72a7cc8bef1583c6f7761b3ce5dcf8fdc7b Mon Sep 17 00:00:00 2001 From: kwoyke Date: Mon, 14 Sep 2020 11:24:29 +0200 Subject: [PATCH 126/263] BAEL-3712: Fix entities names (#10028) --- .../multipledb/dao/user/PossessionRepository.java | 4 ++-- .../multipledb/dao/user/UserRepository.java | 4 ++-- .../{PossessionMultipleDB.java => Possession.java} | 8 ++++---- .../model/user/{UserMultipleDB.java => User.java} | 12 ++++++------ .../multipledb/JpaMultipleDBIntegrationTest.java | 14 +++++++------- 5 files changed, 21 insertions(+), 21 deletions(-) rename persistence-modules/spring-data-jpa-enterprise/src/main/java/com/baeldung/multipledb/model/user/{PossessionMultipleDB.java => Possession.java} (89%) rename persistence-modules/spring-data-jpa-enterprise/src/main/java/com/baeldung/multipledb/model/user/{UserMultipleDB.java => User.java} (82%) diff --git a/persistence-modules/spring-data-jpa-enterprise/src/main/java/com/baeldung/multipledb/dao/user/PossessionRepository.java b/persistence-modules/spring-data-jpa-enterprise/src/main/java/com/baeldung/multipledb/dao/user/PossessionRepository.java index ae37fde20d..a5ceee5b1a 100644 --- a/persistence-modules/spring-data-jpa-enterprise/src/main/java/com/baeldung/multipledb/dao/user/PossessionRepository.java +++ b/persistence-modules/spring-data-jpa-enterprise/src/main/java/com/baeldung/multipledb/dao/user/PossessionRepository.java @@ -2,8 +2,8 @@ package com.baeldung.multipledb.dao.user; import org.springframework.data.jpa.repository.JpaRepository; -import com.baeldung.multipledb.model.user.PossessionMultipleDB; +import com.baeldung.multipledb.model.user.Possession; -public interface PossessionRepository extends JpaRepository { +public interface PossessionRepository extends JpaRepository { } diff --git a/persistence-modules/spring-data-jpa-enterprise/src/main/java/com/baeldung/multipledb/dao/user/UserRepository.java b/persistence-modules/spring-data-jpa-enterprise/src/main/java/com/baeldung/multipledb/dao/user/UserRepository.java index 267a61a93f..d3109bd311 100644 --- a/persistence-modules/spring-data-jpa-enterprise/src/main/java/com/baeldung/multipledb/dao/user/UserRepository.java +++ b/persistence-modules/spring-data-jpa-enterprise/src/main/java/com/baeldung/multipledb/dao/user/UserRepository.java @@ -2,7 +2,7 @@ package com.baeldung.multipledb.dao.user; import org.springframework.data.jpa.repository.JpaRepository; -import com.baeldung.multipledb.model.user.UserMultipleDB; +import com.baeldung.multipledb.model.user.User; -public interface UserRepository extends JpaRepository { +public interface UserRepository extends JpaRepository { } \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-enterprise/src/main/java/com/baeldung/multipledb/model/user/PossessionMultipleDB.java b/persistence-modules/spring-data-jpa-enterprise/src/main/java/com/baeldung/multipledb/model/user/Possession.java similarity index 89% rename from persistence-modules/spring-data-jpa-enterprise/src/main/java/com/baeldung/multipledb/model/user/PossessionMultipleDB.java rename to persistence-modules/spring-data-jpa-enterprise/src/main/java/com/baeldung/multipledb/model/user/Possession.java index a6a3c88bd0..af646ffd04 100644 --- a/persistence-modules/spring-data-jpa-enterprise/src/main/java/com/baeldung/multipledb/model/user/PossessionMultipleDB.java +++ b/persistence-modules/spring-data-jpa-enterprise/src/main/java/com/baeldung/multipledb/model/user/Possession.java @@ -4,7 +4,7 @@ import javax.persistence.*; @Entity @Table -public class PossessionMultipleDB { +public class Possession { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @@ -12,11 +12,11 @@ public class PossessionMultipleDB { private String name; - public PossessionMultipleDB() { + public Possession() { super(); } - public PossessionMultipleDB(final String name) { + public Possession(final String name) { super(); this.name = name; @@ -58,7 +58,7 @@ public class PossessionMultipleDB { if (getClass() != obj.getClass()) { return false; } - final PossessionMultipleDB other = (PossessionMultipleDB) obj; + final Possession other = (Possession) obj; if (id != other.id) { return false; } diff --git a/persistence-modules/spring-data-jpa-enterprise/src/main/java/com/baeldung/multipledb/model/user/UserMultipleDB.java b/persistence-modules/spring-data-jpa-enterprise/src/main/java/com/baeldung/multipledb/model/user/User.java similarity index 82% rename from persistence-modules/spring-data-jpa-enterprise/src/main/java/com/baeldung/multipledb/model/user/UserMultipleDB.java rename to persistence-modules/spring-data-jpa-enterprise/src/main/java/com/baeldung/multipledb/model/user/User.java index c7cd07f7a1..1985c543d3 100644 --- a/persistence-modules/spring-data-jpa-enterprise/src/main/java/com/baeldung/multipledb/model/user/UserMultipleDB.java +++ b/persistence-modules/spring-data-jpa-enterprise/src/main/java/com/baeldung/multipledb/model/user/User.java @@ -6,7 +6,7 @@ import java.util.List; @Entity @Table(name = "users") -public class UserMultipleDB { +public class User { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @@ -18,13 +18,13 @@ public class UserMultipleDB { private Integer status; @OneToMany - List possessionList; + List possessionList; - public UserMultipleDB() { + public User() { super(); } - public UserMultipleDB(String name, String email, Integer status) { + public User(String name, String email, Integer status) { this.name = name; this.email = email; this.status = status; @@ -70,11 +70,11 @@ public class UserMultipleDB { this.age = age; } - public List getPossessionList() { + public List getPossessionList() { return possessionList; } - public void setPossessionList(List possessionList) { + public void setPossessionList(List possessionList) { this.possessionList = possessionList; } diff --git a/persistence-modules/spring-data-jpa-enterprise/src/test/java/com/baeldung/multipledb/JpaMultipleDBIntegrationTest.java b/persistence-modules/spring-data-jpa-enterprise/src/test/java/com/baeldung/multipledb/JpaMultipleDBIntegrationTest.java index a1f4a3fa2c..fb363e2ab3 100644 --- a/persistence-modules/spring-data-jpa-enterprise/src/test/java/com/baeldung/multipledb/JpaMultipleDBIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-enterprise/src/test/java/com/baeldung/multipledb/JpaMultipleDBIntegrationTest.java @@ -20,8 +20,8 @@ import com.baeldung.multipledb.dao.product.ProductRepository; import com.baeldung.multipledb.dao.user.PossessionRepository; import com.baeldung.multipledb.dao.user.UserRepository; import com.baeldung.multipledb.model.product.Product; -import com.baeldung.multipledb.model.user.PossessionMultipleDB; -import com.baeldung.multipledb.model.user.UserMultipleDB; +import com.baeldung.multipledb.model.user.Possession; +import com.baeldung.multipledb.model.user.User; @RunWith(SpringRunner.class) @SpringBootTest(classes=MultipleDbApplication.class) @@ -42,15 +42,15 @@ public class JpaMultipleDBIntegrationTest { @Test @Transactional("userTransactionManager") public void whenCreatingUser_thenCreated() { - UserMultipleDB user = new UserMultipleDB(); + User user = new User(); user.setName("John"); user.setEmail("john@test.com"); user.setAge(20); - PossessionMultipleDB p = new PossessionMultipleDB("sample"); + Possession p = new Possession("sample"); p = possessionRepository.save(p); user.setPossessionList(Collections.singletonList(p)); user = userRepository.save(user); - final Optional result = userRepository.findById(user.getId()); + final Optional result = userRepository.findById(user.getId()); assertTrue(result.isPresent()); System.out.println(result.get().getPossessionList()); assertEquals(1, result.get().getPossessionList().size()); @@ -59,14 +59,14 @@ public class JpaMultipleDBIntegrationTest { @Test @Transactional("userTransactionManager") public void whenCreatingUsersWithSameEmail_thenRollback() { - UserMultipleDB user1 = new UserMultipleDB(); + User user1 = new User(); user1.setName("John"); user1.setEmail("john@test.com"); user1.setAge(20); user1 = userRepository.save(user1); assertTrue(userRepository.findById(user1.getId()).isPresent()); - UserMultipleDB user2 = new UserMultipleDB(); + User user2 = new User(); user2.setName("Tom"); user2.setEmail("john@test.com"); user2.setAge(10); From 5d1439378863657b54591ade01ef11e51d0ab313 Mon Sep 17 00:00:00 2001 From: mikr Date: Mon, 14 Sep 2020 12:21:57 +0200 Subject: [PATCH 127/263] Java-2136 Update Jackson version in main pom --- pom.xml | 3 +-- spring-dispatcher-servlet/pom.xml | 5 ----- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index a2e09c0f91..49c9fd9413 100644 --- a/pom.xml +++ b/pom.xml @@ -1389,9 +1389,8 @@ 3.1.0 1.2 2.3.1 - 1.9.13 1.2 - 2.9.8 + 2.11.1 1.3 1.2.0 5.2.0 diff --git a/spring-dispatcher-servlet/pom.xml b/spring-dispatcher-servlet/pom.xml index 46e40722f1..21324e6757 100644 --- a/spring-dispatcher-servlet/pom.xml +++ b/spring-dispatcher-servlet/pom.xml @@ -40,11 +40,6 @@ javax.servlet.jsp-api ${javax.servlet.jsp-api.version} - - org.codehaus.jackson - jackson-mapper-asl - ${jackson-mapper-asl.version} - javax.servlet jstl From 6927cc7237978851c174ea1e3daec27d32ffe254 Mon Sep 17 00:00:00 2001 From: mikr Date: Mon, 14 Sep 2020 13:11:59 +0200 Subject: [PATCH 128/263] Java-2136 Use Jackson version from main pom in all other applicable modules --- json-2/pom.xml | 4 ++-- libraries-data-2/pom.xml | 2 +- libraries-http-2/pom.xml | 2 +- libraries-http/pom.xml | 2 +- metrics/pom.xml | 6 +++--- persistence-modules/hibernate-libraries/pom.xml | 1 - spring-5-mvc/pom.xml | 1 - .../spring-openapi-generator-api-client/pom.xml | 6 +++--- testing-modules/mockito-2/pom.xml | 1 - 9 files changed, 11 insertions(+), 14 deletions(-) diff --git a/json-2/pom.xml b/json-2/pom.xml index f0215a375f..53091d6245 100644 --- a/json-2/pom.xml +++ b/json-2/pom.xml @@ -53,12 +53,12 @@ com.fasterxml.jackson.core jackson-annotations - 2.11.0 + ${jackson.version} com.fasterxml.jackson.core jackson-databind - 2.11.0 + ${jackson.version} com.io-informatics.oss diff --git a/libraries-data-2/pom.xml b/libraries-data-2/pom.xml index 26d8651cdd..0154823cca 100644 --- a/libraries-data-2/pom.xml +++ b/libraries-data-2/pom.xml @@ -168,7 +168,7 @@ 0.1.0 1.0.3 9.1.5.Final - 2.9.8 + 4.3.8.RELEASE 4.0.0 1.1.0 diff --git a/libraries-http-2/pom.xml b/libraries-http-2/pom.xml index 73fe6c66bd..3c0af51131 100644 --- a/libraries-http-2/pom.xml +++ b/libraries-http-2/pom.xml @@ -72,7 +72,7 @@ 3.14.2 2.8.5 3.14.2 - 2.9.8 + 1.0.3 9.4.19.v20190610 2.2.11 diff --git a/libraries-http/pom.xml b/libraries-http/pom.xml index cbc74ce132..74e00a7291 100644 --- a/libraries-http/pom.xml +++ b/libraries-http/pom.xml @@ -118,7 +118,7 @@ 2.8.5 4.5.3 - 2.9.8 + 3.6.2 3.14.2 1.23.0 diff --git a/metrics/pom.xml b/metrics/pom.xml index 92699c3fb8..07adf15936 100644 --- a/metrics/pom.xml +++ b/metrics/pom.xml @@ -66,12 +66,12 @@ com.fasterxml.jackson.core jackson-databind - ${fasterxml.jackson.version} + ${jackson.version} com.fasterxml.jackson.dataformat jackson-dataformat-smile - ${fasterxml.jackson.version} + ${jackson.version} @@ -93,7 +93,7 @@ 3.1.0 0.12.17 0.12.0.RELEASE - 2.9.1 + 2.0.7.RELEASE 3.11.1 1.1.0 diff --git a/persistence-modules/hibernate-libraries/pom.xml b/persistence-modules/hibernate-libraries/pom.xml index 808c47133c..f67309cf43 100644 --- a/persistence-modules/hibernate-libraries/pom.xml +++ b/persistence-modules/hibernate-libraries/pom.xml @@ -170,7 +170,6 @@ 29.0-jre 2.9.7 5.4.14.Final - 2.10.3 3.27.0-GA 2.3.1 2.0.0 diff --git a/spring-5-mvc/pom.xml b/spring-5-mvc/pom.xml index fd9868ad66..0bb69d8057 100644 --- a/spring-5-mvc/pom.xml +++ b/spring-5-mvc/pom.xml @@ -173,7 +173,6 @@ 2.9.0 - 2.9.9 1.2.71 4.5.8 com.baeldung.Spring5Application diff --git a/spring-swagger-codegen/spring-openapi-generator-api-client/pom.xml b/spring-swagger-codegen/spring-openapi-generator-api-client/pom.xml index 7c6de543ae..3074849e4c 100644 --- a/spring-swagger-codegen/spring-openapi-generator-api-client/pom.xml +++ b/spring-swagger-codegen/spring-openapi-generator-api-client/pom.xml @@ -90,7 +90,7 @@ com.fasterxml.jackson.core jackson-databind - ${jackson-databind-version} + ${jackson-version} com.fasterxml.jackson.jaxrs @@ -264,8 +264,8 @@ 1.5.22 4.3.9.RELEASE - 2.10.1 - 2.10.1 + 2.11.1 + 0.2.1 2.9.10 1.0.0 diff --git a/testing-modules/mockito-2/pom.xml b/testing-modules/mockito-2/pom.xml index 340af89c82..055debe615 100644 --- a/testing-modules/mockito-2/pom.xml +++ b/testing-modules/mockito-2/pom.xml @@ -30,7 +30,6 @@ 2.21.0 - 2.10.3 From c4396dd1bd453128dc0e83de26742c83415533e1 Mon Sep 17 00:00:00 2001 From: mikr Date: Mon, 14 Sep 2020 16:30:00 +0200 Subject: [PATCH 129/263] Java-2797 Cleanup maven-java-11/multimodule-maven-project --- .../entitymodule/pom.xml | 22 ---------- .../main/java/com/baeldung/entity/User.java | 19 --------- .../src/main/java/module-info.java | 3 -- .../mainappmodule/pom.xml | 41 ------------------- .../com/baeldung/mainapp/Application.java | 19 --------- .../src/main/java/module-info.java | 6 --- pom.xml | 2 - 7 files changed, 112 deletions(-) delete mode 100644 maven-java-11/multimodule-maven-project/entitymodule/pom.xml delete mode 100644 maven-java-11/multimodule-maven-project/entitymodule/src/main/java/com/baeldung/entity/User.java delete mode 100644 maven-java-11/multimodule-maven-project/entitymodule/src/main/java/module-info.java delete mode 100644 maven-java-11/multimodule-maven-project/mainappmodule/pom.xml delete mode 100644 maven-java-11/multimodule-maven-project/mainappmodule/src/main/java/com/baeldung/mainapp/Application.java delete mode 100644 maven-java-11/multimodule-maven-project/mainappmodule/src/main/java/module-info.java diff --git a/maven-java-11/multimodule-maven-project/entitymodule/pom.xml b/maven-java-11/multimodule-maven-project/entitymodule/pom.xml deleted file mode 100644 index 228619ed74..0000000000 --- a/maven-java-11/multimodule-maven-project/entitymodule/pom.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - 4.0.0 - com.baeldung.entitymodule - entitymodule - 1.0 - entitymodule - jar - - - com.baeldung.multimodule-maven-project - multimodule-maven-project - 1.0 - - - - 11 - 11 - - - diff --git a/maven-java-11/multimodule-maven-project/entitymodule/src/main/java/com/baeldung/entity/User.java b/maven-java-11/multimodule-maven-project/entitymodule/src/main/java/com/baeldung/entity/User.java deleted file mode 100644 index 22022a2e6d..0000000000 --- a/maven-java-11/multimodule-maven-project/entitymodule/src/main/java/com/baeldung/entity/User.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.baeldung.entity; - -public class User { - - private final String name; - - public User(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - @Override - public String toString() { - return "User{" + "name=" + name + '}'; - } -} diff --git a/maven-java-11/multimodule-maven-project/entitymodule/src/main/java/module-info.java b/maven-java-11/multimodule-maven-project/entitymodule/src/main/java/module-info.java deleted file mode 100644 index 67a3097352..0000000000 --- a/maven-java-11/multimodule-maven-project/entitymodule/src/main/java/module-info.java +++ /dev/null @@ -1,3 +0,0 @@ -module com.baeldung.entity { - exports com.baeldung.entity; -} diff --git a/maven-java-11/multimodule-maven-project/mainappmodule/pom.xml b/maven-java-11/multimodule-maven-project/mainappmodule/pom.xml deleted file mode 100644 index 1f4493c34c..0000000000 --- a/maven-java-11/multimodule-maven-project/mainappmodule/pom.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - 4.0.0 - com.baeldung.mainappmodule - mainappmodule - 1.0 - mainappmodule - jar - - - com.baeldung.multimodule-maven-project - multimodule-maven-project - 1.0 - - - - - com.baeldung.entitymodule - entitymodule - ${entitymodule.version} - - - com.baeldung.daomodule - daomodule - ${daomodule.version} - - - com.baeldung.userdaomodule - userdaomodule - ${userdaomodule.version} - - - - - 1.0 - 1.0 - 1.0 - - - diff --git a/maven-java-11/multimodule-maven-project/mainappmodule/src/main/java/com/baeldung/mainapp/Application.java b/maven-java-11/multimodule-maven-project/mainappmodule/src/main/java/com/baeldung/mainapp/Application.java deleted file mode 100644 index 0c0df7461b..0000000000 --- a/maven-java-11/multimodule-maven-project/mainappmodule/src/main/java/com/baeldung/mainapp/Application.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.baeldung.mainapp; - -import com.baeldung.dao.Dao; -import com.baeldung.entity.User; -import com.baeldung.userdao.UserDao; -import java.util.HashMap; -import java.util.Map; - -public class Application { - - public static void main(String[] args) { - Map users = new HashMap<>(); - users.put(1, new User("Julie")); - users.put(2, new User("David")); - Dao userDao = new UserDao(users); - userDao.findAll().forEach(System.out::println); - } - -} diff --git a/maven-java-11/multimodule-maven-project/mainappmodule/src/main/java/module-info.java b/maven-java-11/multimodule-maven-project/mainappmodule/src/main/java/module-info.java deleted file mode 100644 index c688fcf7de..0000000000 --- a/maven-java-11/multimodule-maven-project/mainappmodule/src/main/java/module-info.java +++ /dev/null @@ -1,6 +0,0 @@ -module com.baeldung.mainapp { - requires com.baeldung.entity; - requires com.baeldung.userdao; - requires com.baeldung.dao; - uses com.baeldung.dao.Dao; -} diff --git a/pom.xml b/pom.xml index a2e09c0f91..fe67bc835b 100644 --- a/pom.xml +++ b/pom.xml @@ -508,7 +508,6 @@ maven-modules maven-archetype - maven-polyglot mesos-marathon @@ -1019,7 +1018,6 @@ maven-modules maven-archetype - maven-polyglot mesos-marathon From 540e719c11bdd91c8e686785d495140778bef83e Mon Sep 17 00:00:00 2001 From: Amit Pandey Date: Mon, 14 Sep 2020 21:51:24 +0530 Subject: [PATCH 130/263] moved spring-security-web-jsonview module to spring-security-core (#10015) * moved spring-security-web-jsonview module to spring-security-core * removed deleted module from project build --- spring-security-modules/pom.xml | 1 - .../spring-security-core/README.md | 1 + .../java/com/baeldung/filterresponse/App.java | 13 ++ .../filterresponse/config}/AppConfig.java | 6 +- .../SecurityJsonViewControllerAdvice.java | 11 +- .../controller/ItemsController.java | 12 +- .../filterresponse}/controller/View.java | 5 +- .../baeldung/filterresponse}/model/Item.java | 4 +- ...SpringSecurityJsonViewIntegrationTest.java | 4 +- .../spring-security-web-jsonview/.gitignore | 13 -- .../spring-security-web-jsonview/README.md | 7 - .../spring-security-web-jsonview/pom.xml | 206 ------------------ .../java/com/baeldung/AppInitializer.java | 33 --- .../src/main/resources/logback.xml | 19 -- .../java/com/baeldung/SpringContextTest.java | 17 -- 15 files changed, 34 insertions(+), 318 deletions(-) create mode 100644 spring-security-modules/spring-security-core/src/main/java/com/baeldung/filterresponse/App.java rename spring-security-modules/{spring-security-web-jsonview/src/main/java/com/baeldung/spring => spring-security-core/src/main/java/com/baeldung/filterresponse/config}/AppConfig.java (95%) rename spring-security-modules/{spring-security-web-jsonview/src/main/java/com/baeldung/spring => spring-security-core/src/main/java/com/baeldung/filterresponse/config}/SecurityJsonViewControllerAdvice.java (95%) rename spring-security-modules/{spring-security-web-jsonview/src/main/java/com/baeldung => spring-security-core/src/main/java/com/baeldung/filterresponse}/controller/ItemsController.java (68%) rename spring-security-modules/{spring-security-web-jsonview/src/main/java/com/baeldung => spring-security-core/src/main/java/com/baeldung/filterresponse}/controller/View.java (76%) rename spring-security-modules/{spring-security-web-jsonview/src/main/java/com/baeldung => spring-security-core/src/main/java/com/baeldung/filterresponse}/model/Item.java (85%) rename spring-security-modules/{spring-security-web-jsonview/src/test/java/com/baeldung/security => spring-security-core/src/test/java/com/baeldung/filterresponse}/SpringSecurityJsonViewIntegrationTest.java (97%) delete mode 100644 spring-security-modules/spring-security-web-jsonview/.gitignore delete mode 100644 spring-security-modules/spring-security-web-jsonview/README.md delete mode 100644 spring-security-modules/spring-security-web-jsonview/pom.xml delete mode 100644 spring-security-modules/spring-security-web-jsonview/src/main/java/com/baeldung/AppInitializer.java delete mode 100644 spring-security-modules/spring-security-web-jsonview/src/main/resources/logback.xml delete mode 100644 spring-security-modules/spring-security-web-jsonview/src/test/java/com/baeldung/SpringContextTest.java diff --git a/spring-security-modules/pom.xml b/spring-security-modules/pom.xml index b68138964b..d5c0c0dd6e 100644 --- a/spring-security-modules/pom.xml +++ b/spring-security-modules/pom.xml @@ -24,7 +24,6 @@ spring-security-web-boot-2 spring-security-web-mvc-custom spring-security-web-digest-auth - spring-security-web-jsonview spring-security-ldap spring-security-web-login spring-security-web-persisted-remember-me diff --git a/spring-security-modules/spring-security-core/README.md b/spring-security-modules/spring-security-core/README.md index f28b3abb2b..9f8e4dda53 100644 --- a/spring-security-modules/spring-security-core/README.md +++ b/spring-security-modules/spring-security-core/README.md @@ -9,6 +9,7 @@ This module contains articles about core Spring Security - [Overview and Need for DelegatingFilterProxy in Spring](https://www.baeldung.com/spring-delegating-filter-proxy) - [Deny Access on Missing @PreAuthorize to Spring Controller Methods](https://www.baeldung.com/spring-deny-access) - [Spring Security: Check If a User Has a Role in Java](https://www.baeldung.com/spring-security-check-user-role) +- [Filtering Jackson JSON Output Based on Spring Security Role](https://www.baeldung.com/spring-security-role-filter-json) ### Build the Project diff --git a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/filterresponse/App.java b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/filterresponse/App.java new file mode 100644 index 0000000000..a5389e93d3 --- /dev/null +++ b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/filterresponse/App.java @@ -0,0 +1,13 @@ +package com.baeldung.filterresponse; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class App { + + public static void main(String[] args) { + SpringApplication.run(App.class, args); + } + +} diff --git a/spring-security-modules/spring-security-web-jsonview/src/main/java/com/baeldung/spring/AppConfig.java b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/filterresponse/config/AppConfig.java similarity index 95% rename from spring-security-modules/spring-security-web-jsonview/src/main/java/com/baeldung/spring/AppConfig.java rename to spring-security-modules/spring-security-core/src/main/java/com/baeldung/filterresponse/config/AppConfig.java index 10b2d2447e..8ff6000129 100644 --- a/spring-security-modules/spring-security-web-jsonview/src/main/java/com/baeldung/spring/AppConfig.java +++ b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/filterresponse/config/AppConfig.java @@ -1,4 +1,4 @@ -package com.baeldung.spring; +package com.baeldung.filterresponse.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -12,12 +12,10 @@ import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import java.util.Arrays; - @Configuration @EnableWebMvc @EnableWebSecurity -@ComponentScan("com.baeldung") +@ComponentScan("com.baeldung.filterresponse") public class AppConfig extends WebSecurityConfigurerAdapter implements WebMvcConfigurer { @Override diff --git a/spring-security-modules/spring-security-web-jsonview/src/main/java/com/baeldung/spring/SecurityJsonViewControllerAdvice.java b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/filterresponse/config/SecurityJsonViewControllerAdvice.java similarity index 95% rename from spring-security-modules/spring-security-web-jsonview/src/main/java/com/baeldung/spring/SecurityJsonViewControllerAdvice.java rename to spring-security-modules/spring-security-core/src/main/java/com/baeldung/filterresponse/config/SecurityJsonViewControllerAdvice.java index d6d022a110..d0ba0adcf5 100644 --- a/spring-security-modules/spring-security-web-jsonview/src/main/java/com/baeldung/spring/SecurityJsonViewControllerAdvice.java +++ b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/filterresponse/config/SecurityJsonViewControllerAdvice.java @@ -1,6 +1,9 @@ -package com.baeldung.spring; +package com.baeldung.filterresponse.config; + +import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; -import com.baeldung.controller.View; import org.springframework.core.MethodParameter; import org.springframework.http.MediaType; import org.springframework.http.converter.json.MappingJacksonValue; @@ -11,9 +14,7 @@ import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.servlet.mvc.method.annotation.AbstractMappingJacksonResponseBodyAdvice; -import java.util.Collection; -import java.util.List; -import java.util.stream.Collectors; +import com.baeldung.filterresponse.controller.View; @RestControllerAdvice public class SecurityJsonViewControllerAdvice extends AbstractMappingJacksonResponseBodyAdvice { diff --git a/spring-security-modules/spring-security-web-jsonview/src/main/java/com/baeldung/controller/ItemsController.java b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/filterresponse/controller/ItemsController.java similarity index 68% rename from spring-security-modules/spring-security-web-jsonview/src/main/java/com/baeldung/controller/ItemsController.java rename to spring-security-modules/spring-security-core/src/main/java/com/baeldung/filterresponse/controller/ItemsController.java index 16268a239b..f5fd4ee7f1 100644 --- a/spring-security-modules/spring-security-web-jsonview/src/main/java/com/baeldung/controller/ItemsController.java +++ b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/filterresponse/controller/ItemsController.java @@ -1,14 +1,12 @@ -package com.baeldung.controller; +package com.baeldung.filterresponse.controller; + +import java.util.Arrays; +import java.util.Collection; -import com.baeldung.model.Item; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; +import com.baeldung.filterresponse.model.Item; @RestController public class ItemsController { diff --git a/spring-security-modules/spring-security-web-jsonview/src/main/java/com/baeldung/controller/View.java b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/filterresponse/controller/View.java similarity index 76% rename from spring-security-modules/spring-security-web-jsonview/src/main/java/com/baeldung/controller/View.java rename to spring-security-modules/spring-security-core/src/main/java/com/baeldung/filterresponse/controller/View.java index 10ae50adef..3099807578 100644 --- a/spring-security-modules/spring-security-web-jsonview/src/main/java/com/baeldung/controller/View.java +++ b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/filterresponse/controller/View.java @@ -1,10 +1,11 @@ -package com.baeldung.controller; +package com.baeldung.filterresponse.controller; -import com.baeldung.spring.AppConfig.Role; import java.util.HashMap; import java.util.Map; +import com.baeldung.filterresponse.config.AppConfig.Role; + public class View { public static final Map MAPPING = new HashMap<>(); diff --git a/spring-security-modules/spring-security-web-jsonview/src/main/java/com/baeldung/model/Item.java b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/filterresponse/model/Item.java similarity index 85% rename from spring-security-modules/spring-security-web-jsonview/src/main/java/com/baeldung/model/Item.java rename to spring-security-modules/spring-security-core/src/main/java/com/baeldung/filterresponse/model/Item.java index 002ee73e4f..9ebdc6bad0 100644 --- a/spring-security-modules/spring-security-web-jsonview/src/main/java/com/baeldung/model/Item.java +++ b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/filterresponse/model/Item.java @@ -1,6 +1,6 @@ -package com.baeldung.model; +package com.baeldung.filterresponse.model; -import com.baeldung.controller.View; +import com.baeldung.filterresponse.controller.View; import com.fasterxml.jackson.annotation.JsonView; public class Item { diff --git a/spring-security-modules/spring-security-web-jsonview/src/test/java/com/baeldung/security/SpringSecurityJsonViewIntegrationTest.java b/spring-security-modules/spring-security-core/src/test/java/com/baeldung/filterresponse/SpringSecurityJsonViewIntegrationTest.java similarity index 97% rename from spring-security-modules/spring-security-web-jsonview/src/test/java/com/baeldung/security/SpringSecurityJsonViewIntegrationTest.java rename to spring-security-modules/spring-security-core/src/test/java/com/baeldung/filterresponse/SpringSecurityJsonViewIntegrationTest.java index 626c8cb497..fc821b5175 100644 --- a/spring-security-modules/spring-security-web-jsonview/src/test/java/com/baeldung/security/SpringSecurityJsonViewIntegrationTest.java +++ b/spring-security-modules/spring-security-core/src/test/java/com/baeldung/filterresponse/SpringSecurityJsonViewIntegrationTest.java @@ -1,6 +1,6 @@ -package com.baeldung.security; +package com.baeldung.filterresponse; -import com.baeldung.spring.AppConfig; +import com.baeldung.filterresponse.config.AppConfig; import org.hamcrest.BaseMatcher; import org.hamcrest.Description; import org.junit.Before; diff --git a/spring-security-modules/spring-security-web-jsonview/.gitignore b/spring-security-modules/spring-security-web-jsonview/.gitignore deleted file mode 100644 index 83c05e60c8..0000000000 --- a/spring-security-modules/spring-security-web-jsonview/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -*.class - -#folders# -/target -/neoDb* -/data -/src/main/webapp/WEB-INF/classes -*/META-INF/* - -# Packaged files # -*.jar -*.war -*.ear \ No newline at end of file diff --git a/spring-security-modules/spring-security-web-jsonview/README.md b/spring-security-modules/spring-security-web-jsonview/README.md deleted file mode 100644 index 83f8106df9..0000000000 --- a/spring-security-modules/spring-security-web-jsonview/README.md +++ /dev/null @@ -1,7 +0,0 @@ -## Spring Security Web Json View - -This module contains articles about Spring Security with JSON - -### Relevant Articles: - -- [Filtering Jackson JSON Output Based on Spring Security Role](https://www.baeldung.com/spring-security-role-filter-json) diff --git a/spring-security-modules/spring-security-web-jsonview/pom.xml b/spring-security-modules/spring-security-web-jsonview/pom.xml deleted file mode 100644 index 0d1b0b09db..0000000000 --- a/spring-security-modules/spring-security-web-jsonview/pom.xml +++ /dev/null @@ -1,206 +0,0 @@ - - - 4.0.0 - spring-security-web-jsonview - 0.1-SNAPSHOT - spring-security-web-jsonview - war - - - com.baeldung - parent-spring-5 - 0.0.1-SNAPSHOT - ../../parent-spring-5 - - - - - com.fasterxml.jackson.core - jackson-core - ${jackson.version} - - - com.fasterxml.jackson.core - jackson-annotations - ${jackson.version} - - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - - - - - - org.springframework.security - spring-security-web - ${spring-security.version} - - - org.springframework.security - spring-security-config - ${spring-security.version} - - - org.springframework.security - spring-security-taglibs - ${spring-security.version} - - - - - - org.springframework - spring-core - ${spring.version} - - - commons-logging - commons-logging - - - - - org.springframework - spring-context - ${spring.version} - - - org.springframework - spring-jdbc - ${spring.version} - - - org.springframework - spring-beans - ${spring.version} - - - org.springframework - spring-aop - ${spring.version} - - - org.springframework - spring-tx - ${spring.version} - - - org.springframework - spring-expression - ${spring.version} - - - - org.springframework - spring-web - ${spring.version} - - - org.springframework - spring-webmvc - ${spring.version} - - - - - - javax.servlet - javax.servlet-api - ${javax.servlet-api.version} - provided - - - - javax.servlet - jstl - ${jstl.version} - runtime - - - - - - org.springframework - spring-test - ${spring.version} - test - - - org.springframework.security - spring-security-test - ${spring-security.version} - test - - - com.jayway.jsonpath - json-path - ${json-path.version} - test - - - - - spring-security-mvc-jsonview - - - src/main/resources - true - - - - - org.apache.maven.plugins - maven-war-plugin - ${maven-war-plugin.version} - - - default-war - prepare-package - - false - - - - - - - org.codehaus.cargo - cargo-maven2-plugin - ${cargo-maven2-plugin.version} - - - - ${project.build.directory}/${project.name}.war - war - - / - - - - - 2400000 - tomcat8x - embedded - - - - - - - 8084 - - - - - - - - - 1.6.1 - 2.4.0 - - - \ No newline at end of file diff --git a/spring-security-modules/spring-security-web-jsonview/src/main/java/com/baeldung/AppInitializer.java b/spring-security-modules/spring-security-web-jsonview/src/main/java/com/baeldung/AppInitializer.java deleted file mode 100644 index 4f38d190eb..0000000000 --- a/spring-security-modules/spring-security-web-jsonview/src/main/java/com/baeldung/AppInitializer.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.baeldung; - -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.ServletRegistration; - -import org.springframework.web.WebApplicationInitializer; -import org.springframework.web.context.ContextLoaderListener; -import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; -import org.springframework.web.context.support.GenericWebApplicationContext; -import org.springframework.web.filter.DelegatingFilterProxy; -import org.springframework.web.servlet.DispatcherServlet; - -public class AppInitializer implements WebApplicationInitializer { - - @Override - public void onStartup(final ServletContext sc) throws ServletException { - - AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext(); - - root.scan("com.baeldung"); - sc.addListener(new ContextLoaderListener(root)); - - ServletRegistration.Dynamic appServlet = sc.addServlet("mvc", new DispatcherServlet(new GenericWebApplicationContext())); - appServlet.setLoadOnStartup(1); - appServlet.addMapping("/"); - - sc.addFilter("securityFilter", new DelegatingFilterProxy("springSecurityFilterChain")) - .addMappingForUrlPatterns(null, false, "/*"); - - } - -} diff --git a/spring-security-modules/spring-security-web-jsonview/src/main/resources/logback.xml b/spring-security-modules/spring-security-web-jsonview/src/main/resources/logback.xml deleted file mode 100644 index 56af2d397e..0000000000 --- a/spring-security-modules/spring-security-web-jsonview/src/main/resources/logback.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - - - - - - - \ No newline at end of file diff --git a/spring-security-modules/spring-security-web-jsonview/src/test/java/com/baeldung/SpringContextTest.java b/spring-security-modules/spring-security-web-jsonview/src/test/java/com/baeldung/SpringContextTest.java deleted file mode 100644 index b1a3de714e..0000000000 --- a/spring-security-modules/spring-security-web-jsonview/src/test/java/com/baeldung/SpringContextTest.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.baeldung; - -import com.baeldung.spring.AppConfig; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.web.WebAppConfiguration; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = AppConfig.class) -@WebAppConfiguration -public class SpringContextTest { - @Test - public void whenSpringContextIsBootstrapped_thenNoExceptions() { - } -} From 3563524c09e51720fe60f845581063b392ef0323 Mon Sep 17 00:00:00 2001 From: Amit Pandey Date: Mon, 14 Sep 2020 21:53:09 +0530 Subject: [PATCH 131/263] moved spring-rest-hal-browser to spring-data-rest module (#10019) * moved spring-rest-hal-browser to spring-data-rest module * removed module from build --- pom.xml | 2 - spring-data-rest/README.md | 1 + spring-data-rest/pom.xml | 9 +++ .../java/com/baeldung/halbrowser}/App.java | 2 +- .../baeldung/halbrowser}/config/DBLoader.java | 11 ++-- .../halbrowser}/config/RestConfig.java | 2 +- .../halbrowser}/data/BookRepository.java | 6 +- .../com/baeldung/halbrowser}/model/Book.java | 2 +- spring-rest-hal-browser/README.md | 6 -- spring-rest-hal-browser/pom.xml | 62 ------------------- .../src/main/resources/application.properties | 0 .../src/main/resources/logback.xml | 13 ---- 12 files changed, 22 insertions(+), 94 deletions(-) rename {spring-rest-hal-browser/src/main/java/com/baeldung => spring-data-rest/src/main/java/com/baeldung/halbrowser}/App.java (88%) rename {spring-rest-hal-browser/src/main/java/com/baeldung => spring-data-rest/src/main/java/com/baeldung/halbrowser}/config/DBLoader.java (95%) rename {spring-rest-hal-browser/src/main/java/com/baeldung => spring-data-rest/src/main/java/com/baeldung/halbrowser}/config/RestConfig.java (95%) rename {spring-rest-hal-browser/src/main/java/com/baeldung => spring-data-rest/src/main/java/com/baeldung/halbrowser}/data/BookRepository.java (86%) rename {spring-rest-hal-browser/src/main/java/com/baeldung => spring-data-rest/src/main/java/com/baeldung/halbrowser}/model/Book.java (97%) delete mode 100644 spring-rest-hal-browser/README.md delete mode 100644 spring-rest-hal-browser/pom.xml delete mode 100644 spring-rest-hal-browser/src/main/resources/application.properties delete mode 100644 spring-rest-hal-browser/src/main/resources/logback.xml diff --git a/pom.xml b/pom.xml index a2e09c0f91..9406d2e180 100644 --- a/pom.xml +++ b/pom.xml @@ -697,7 +697,6 @@ spring-remoting spring-rest-angular spring-rest-compress - spring-rest-hal-browser spring-rest-http spring-rest-http-2 spring-rest-query-language @@ -1200,7 +1199,6 @@ spring-remoting spring-rest-angular spring-rest-compress - spring-rest-hal-browser spring-rest-http spring-rest-query-language spring-rest-shell diff --git a/spring-data-rest/README.md b/spring-data-rest/README.md index bae2fe8eaf..ab1991b08f 100644 --- a/spring-data-rest/README.md +++ b/spring-data-rest/README.md @@ -12,6 +12,7 @@ This module contains articles about Spring Data REST - [Customizing HTTP Endpoints in Spring Data REST](https://www.baeldung.com/spring-data-rest-customize-http-endpoints) - [Spring Boot with SQLite](https://www.baeldung.com/spring-boot-sqlite) - [Spring Data Web Support](https://www.baeldung.com/spring-data-web-support) +- [Spring REST and HAL Browser](https://www.baeldung.com/spring-rest-hal) ### The Course The "REST With Spring" Classes: http://bit.ly/restwithspring diff --git a/spring-data-rest/pom.xml b/spring-data-rest/pom.xml index 741d146fbf..63a42857f4 100644 --- a/spring-data-rest/pom.xml +++ b/spring-data-rest/pom.xml @@ -32,6 +32,15 @@ org.springframework.boot spring-boot-starter-data-jpa + + + org.springframework.data + spring-data-rest-hal-browser + + + org.springframework.boot + spring-boot-starter-validation + org.springframework.boot spring-boot-autoconfigure diff --git a/spring-rest-hal-browser/src/main/java/com/baeldung/App.java b/spring-data-rest/src/main/java/com/baeldung/halbrowser/App.java similarity index 88% rename from spring-rest-hal-browser/src/main/java/com/baeldung/App.java rename to spring-data-rest/src/main/java/com/baeldung/halbrowser/App.java index 14b6c201d5..6421b7ac33 100644 --- a/spring-rest-hal-browser/src/main/java/com/baeldung/App.java +++ b/spring-data-rest/src/main/java/com/baeldung/halbrowser/App.java @@ -1,4 +1,4 @@ -package com.baeldung; +package com.baeldung.halbrowser; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-rest-hal-browser/src/main/java/com/baeldung/config/DBLoader.java b/spring-data-rest/src/main/java/com/baeldung/halbrowser/config/DBLoader.java similarity index 95% rename from spring-rest-hal-browser/src/main/java/com/baeldung/config/DBLoader.java rename to spring-data-rest/src/main/java/com/baeldung/halbrowser/config/DBLoader.java index 7251ef0e8c..3cd059ce63 100644 --- a/spring-rest-hal-browser/src/main/java/com/baeldung/config/DBLoader.java +++ b/spring-data-rest/src/main/java/com/baeldung/halbrowser/config/DBLoader.java @@ -1,14 +1,15 @@ -package com.baeldung.config; +package com.baeldung.halbrowser.config; + +import java.util.Random; +import java.util.stream.IntStream; -import com.baeldung.data.BookRepository; -import com.baeldung.model.Book; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationRunner; import org.springframework.stereotype.Component; -import java.util.Random; -import java.util.stream.IntStream; +import com.baeldung.halbrowser.data.BookRepository; +import com.baeldung.halbrowser.model.Book; @Component public class DBLoader implements ApplicationRunner { diff --git a/spring-rest-hal-browser/src/main/java/com/baeldung/config/RestConfig.java b/spring-data-rest/src/main/java/com/baeldung/halbrowser/config/RestConfig.java similarity index 95% rename from spring-rest-hal-browser/src/main/java/com/baeldung/config/RestConfig.java rename to spring-data-rest/src/main/java/com/baeldung/halbrowser/config/RestConfig.java index 858371facc..73f7e0f26a 100644 --- a/spring-rest-hal-browser/src/main/java/com/baeldung/config/RestConfig.java +++ b/spring-data-rest/src/main/java/com/baeldung/halbrowser/config/RestConfig.java @@ -1,4 +1,4 @@ -package com.baeldung.config; +package com.baeldung.halbrowser.config; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; diff --git a/spring-rest-hal-browser/src/main/java/com/baeldung/data/BookRepository.java b/spring-data-rest/src/main/java/com/baeldung/halbrowser/data/BookRepository.java similarity index 86% rename from spring-rest-hal-browser/src/main/java/com/baeldung/data/BookRepository.java rename to spring-data-rest/src/main/java/com/baeldung/halbrowser/data/BookRepository.java index d8e35974b1..375f6886ef 100644 --- a/spring-rest-hal-browser/src/main/java/com/baeldung/data/BookRepository.java +++ b/spring-data-rest/src/main/java/com/baeldung/halbrowser/data/BookRepository.java @@ -1,14 +1,14 @@ -package com.baeldung.data; +package com.baeldung.halbrowser.data; -import com.baeldung.model.Book; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.data.repository.query.Param; import org.springframework.data.rest.core.annotation.RestResource; import org.springframework.stereotype.Repository; +import com.baeldung.halbrowser.model.Book; + @Repository public interface BookRepository extends PagingAndSortingRepository { diff --git a/spring-rest-hal-browser/src/main/java/com/baeldung/model/Book.java b/spring-data-rest/src/main/java/com/baeldung/halbrowser/model/Book.java similarity index 97% rename from spring-rest-hal-browser/src/main/java/com/baeldung/model/Book.java rename to spring-data-rest/src/main/java/com/baeldung/halbrowser/model/Book.java index b1dc1b41f3..06056df525 100644 --- a/spring-rest-hal-browser/src/main/java/com/baeldung/model/Book.java +++ b/spring-data-rest/src/main/java/com/baeldung/halbrowser/model/Book.java @@ -1,4 +1,4 @@ -package com.baeldung.model; +package com.baeldung.halbrowser.model; import javax.persistence.*; import javax.validation.constraints.NotNull; diff --git a/spring-rest-hal-browser/README.md b/spring-rest-hal-browser/README.md deleted file mode 100644 index 90337aad1a..0000000000 --- a/spring-rest-hal-browser/README.md +++ /dev/null @@ -1,6 +0,0 @@ -## Spring REST HAL Browser - -This module contains articles about Spring REST with the HAL browser - -### Relevant Articles: -- [Spring REST and HAL Browser](https://www.baeldung.com/spring-rest-hal) diff --git a/spring-rest-hal-browser/pom.xml b/spring-rest-hal-browser/pom.xml deleted file mode 100644 index c8066b89a4..0000000000 --- a/spring-rest-hal-browser/pom.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - 4.0.0 - spring-rest-hal-browser - 1.0-SNAPSHOT - spring-rest-hal-browser - - - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../parent-boot-2 - - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-validation - - - - org.springframework.boot - spring-boot-starter-data-jpa - - - - org.springframework.data - spring-data-rest-hal-browser - - - - com.h2database - h2 - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - ${source.version} - ${target.version} - - - - - - - 1.8 - 1.8 - - - \ No newline at end of file diff --git a/spring-rest-hal-browser/src/main/resources/application.properties b/spring-rest-hal-browser/src/main/resources/application.properties deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/spring-rest-hal-browser/src/main/resources/logback.xml b/spring-rest-hal-browser/src/main/resources/logback.xml deleted file mode 100644 index 7d900d8ea8..0000000000 --- a/spring-rest-hal-browser/src/main/resources/logback.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file From 12b3067cd20d09ed8f5753111c9bd23e29e50a98 Mon Sep 17 00:00:00 2001 From: AmitB Date: Tue, 15 Sep 2020 10:14:25 +0530 Subject: [PATCH 132/263] [BAEL-4495] Performance of removeAll() in a HashSet (#10011) * [BAEL-4495] Performance of removeAll() in a HashSet * [BAEL-4495] Add unit test for hashset removeAll() * [BAEL-4495] Update test methods to camelCase --- .../HashSetBenchmark.java | 86 +++++++++++++++++++ .../collections/hashset/HashSetUnitTest.java | 33 +++++++ 2 files changed, 119 insertions(+) create mode 100644 core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/removeallperformance/HashSetBenchmark.java create mode 100644 core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/hashset/HashSetUnitTest.java diff --git a/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/removeallperformance/HashSetBenchmark.java b/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/removeallperformance/HashSetBenchmark.java new file mode 100644 index 0000000000..8ce58c865e --- /dev/null +++ b/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/removeallperformance/HashSetBenchmark.java @@ -0,0 +1,86 @@ +package com.baeldung.collections.removeallperformance; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import org.apache.commons.lang3.RandomStringUtils; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Level; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.Warmup; +import org.openjdk.jmh.runner.Runner; +import org.openjdk.jmh.runner.options.Options; +import org.openjdk.jmh.runner.options.OptionsBuilder; + +import com.baeldung.collections.containsperformance.Employee; + +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.NANOSECONDS) +@Warmup(iterations = 5) +public class HashSetBenchmark { + + @State(Scope.Thread) + public static class MyState { + private Set employeeSet1 = new HashSet<>(); + private List employeeList1 = new ArrayList<>(); + private Set employeeSet2 = new HashSet<>(); + private List employeeList2 = new ArrayList<>(); + + private long set1Size = 60000; + private long list1Size = 50000; + private long set2Size = 50000; + private long list2Size = 60000; + + @Setup(Level.Trial) + public void setUp() { + + for (long i = 0; i < set1Size; i++) { + employeeSet1.add(new Employee(i, RandomStringUtils.random(7, true, false))); + } + + for (long i = 0; i < list1Size; i++) { + employeeList1.add(new Employee(i, RandomStringUtils.random(7, true, false))); + } + + for (long i = 0; i < set2Size; i++) { + employeeSet2.add(new Employee(i, RandomStringUtils.random(7, true, false))); + } + + for (long i = 0; i < list2Size; i++) { + employeeList2.add(new Employee(i, RandomStringUtils.random(7, true, false))); + } + + } + + } + + @Benchmark + public boolean given_SizeOfHashsetGreaterThanSizeOfCollection_When_RemoveAllFromHashSet_Then_GoodPerformance(MyState state) { + return state.employeeSet1.removeAll(state.employeeList1); + } + + @Benchmark + public boolean given_SizeOfHashsetSmallerThanSizeOfCollection_When_RemoveAllFromHashSet_Then_BadPerformance(MyState state) { + return state.employeeSet2.removeAll(state.employeeList2); + } + + public static void main(String[] args) throws Exception { + Options options = new OptionsBuilder().include(HashSetBenchmark.class.getSimpleName()) + .threads(1) + .forks(1) + .shouldFailOnError(true) + .shouldDoGC(true) + .jvmArgs("-server") + .build(); + new Runner(options).run(); + } + +} \ No newline at end of file diff --git a/core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/hashset/HashSetUnitTest.java b/core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/hashset/HashSetUnitTest.java new file mode 100644 index 0000000000..1c23538675 --- /dev/null +++ b/core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/hashset/HashSetUnitTest.java @@ -0,0 +1,33 @@ +package com.baeldung.collections.hashset; + +import static org.junit.jupiter.api.Assertions.*; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import org.junit.jupiter.api.Test; + +class HashSetUnitTest { + + @Test + void whenRemoveAllFromHashset_thenRemovesAllElementsFromHashsetThatArePresentInCollection() { + Set set = new HashSet<>(); + Collection collection = new ArrayList<>(); + set.add(1); + set.add(2); + set.add(3); + set.add(4); + collection.add(1); + collection.add(3); + + set.removeAll(collection); + + assertEquals(2, set.size()); + Integer[] actualElements = new Integer[set.size()]; + Integer[] expectedElements = new Integer[] { 2, 4 }; + assertArrayEquals(expectedElements, set.toArray(actualElements)); + } + +} From 0976c32038f17c07e0b2b2066c93a7017ebaf990 Mon Sep 17 00:00:00 2001 From: Reza Ebrahimpour Date: Tue, 15 Sep 2020 11:12:24 +0430 Subject: [PATCH 133/263] BAEL-4488 Create AvailableCiphers --- .../com/baeldung/cipher/AvailableCiphers.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 core-java-modules/core-java-security-2/src/main/java/com/baeldung/cipher/AvailableCiphers.java diff --git a/core-java-modules/core-java-security-2/src/main/java/com/baeldung/cipher/AvailableCiphers.java b/core-java-modules/core-java-security-2/src/main/java/com/baeldung/cipher/AvailableCiphers.java new file mode 100644 index 0000000000..f73433ffd2 --- /dev/null +++ b/core-java-modules/core-java-security-2/src/main/java/com/baeldung/cipher/AvailableCiphers.java @@ -0,0 +1,32 @@ +package com.baeldung.cipher; + +import java.security.Provider; +import java.security.Security; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +public class AvailableCiphers { + public static void main(String[] args) { + printAllCiphers(); + printCompatibleCiphers(); + } + + private static void printAllCiphers() { + for (Provider provider : Security.getProviders()) { + for (Provider.Service service : provider.getServices()) { + System.out.println(service.getAlgorithm()); + } + } + } + + private static void printCompatibleCiphers() { + List algorithms = Arrays.stream(Security.getProviders()) + .flatMap(provider -> provider.getServices().stream()) + .filter(service -> "Cipher".equals(service.getType())) + .map(Provider.Service::getAlgorithm) + .collect(Collectors.toList()); + + algorithms.forEach(System.out::println); + } +} From 27aa7c4cad3d469a1bfbb96d36e2bd5acdcd2161 Mon Sep 17 00:00:00 2001 From: mikr Date: Tue, 15 Sep 2020 10:16:09 +0200 Subject: [PATCH 134/263] Java-2136 Fix Unit tests + remove unnecessary println --- jackson-modules/jackson-custom-conversions/pom.xml | 7 +++++++ .../deserialization/CustomDeserializationUnitTest.java | 7 ++----- .../serialization/CustomSerializationUnitTest.java | 3 --- .../skipfields/IgnoreFieldsWithFilterUnitTest.java | 2 -- .../baeldung/skipfields/JacksonDynamicIgnoreUnitTest.java | 8 -------- 5 files changed, 9 insertions(+), 18 deletions(-) diff --git a/jackson-modules/jackson-custom-conversions/pom.xml b/jackson-modules/jackson-custom-conversions/pom.xml index c319891da9..78894bb403 100644 --- a/jackson-modules/jackson-custom-conversions/pom.xml +++ b/jackson-modules/jackson-custom-conversions/pom.xml @@ -23,6 +23,13 @@ jackson-datatype-joda ${jackson.version} + + com.fasterxml.jackson.core + jackson-core + 2.10.1 + + + diff --git a/jackson-modules/jackson-custom-conversions/src/test/java/com/baeldung/deserialization/CustomDeserializationUnitTest.java b/jackson-modules/jackson-custom-conversions/src/test/java/com/baeldung/deserialization/CustomDeserializationUnitTest.java index f2a2502c3e..17016149a2 100644 --- a/jackson-modules/jackson-custom-conversions/src/test/java/com/baeldung/deserialization/CustomDeserializationUnitTest.java +++ b/jackson-modules/jackson-custom-conversions/src/test/java/com/baeldung/deserialization/CustomDeserializationUnitTest.java @@ -60,8 +60,6 @@ public class CustomDeserializationUnitTest { String converted = objectMapper.writeValueAsString(now); // restore an instance of ZonedDateTime from String ZonedDateTime restored = objectMapper.readValue(converted, ZonedDateTime.class); - System.out.println("serialized: " + now); - System.out.println("restored: " + restored); assertThat(now, is(not(restored))); } @@ -70,15 +68,14 @@ public class CustomDeserializationUnitTest { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.findAndRegisterModules(); objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); + objectMapper.enable(SerializationFeature.WRITE_DATES_WITH_ZONE_ID); objectMapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE); // construct a new instance of ZonedDateTime ZonedDateTime now = ZonedDateTime.now(ZoneId.of("Europe/Berlin")); String converted = objectMapper.writeValueAsString(now); // restore an instance of ZonedDateTime from String ZonedDateTime restored = objectMapper.readValue(converted, ZonedDateTime.class); - System.out.println("serialized: " + now); - System.out.println("restored: " + restored); - assertThat(now, is(restored)); + assertThat(restored, is(now)); } } diff --git a/jackson-modules/jackson-custom-conversions/src/test/java/com/baeldung/serialization/CustomSerializationUnitTest.java b/jackson-modules/jackson-custom-conversions/src/test/java/com/baeldung/serialization/CustomSerializationUnitTest.java index 6cb4019fa2..9c46a86fd8 100644 --- a/jackson-modules/jackson-custom-conversions/src/test/java/com/baeldung/serialization/CustomSerializationUnitTest.java +++ b/jackson-modules/jackson-custom-conversions/src/test/java/com/baeldung/serialization/CustomSerializationUnitTest.java @@ -24,7 +24,6 @@ public class CustomSerializationUnitTest { public final void whenSerializing_thenNoExceptions() throws JsonGenerationException, JsonMappingException, IOException { final Item myItem = new Item(1, "theItem", new User(2, "theUser")); final String serialized = new ObjectMapper().writeValueAsString(myItem); - System.out.println(serialized); } @Test @@ -38,7 +37,6 @@ public class CustomSerializationUnitTest { mapper.registerModule(simpleModule); final String serialized = mapper.writeValueAsString(myItem); - System.out.println(serialized); } @Test @@ -46,7 +44,6 @@ public class CustomSerializationUnitTest { final ItemWithSerializer myItem = new ItemWithSerializer(1, "theItem", new User(2, "theUser")); final String serialized = new ObjectMapper().writeValueAsString(myItem); - System.out.println(serialized); } } diff --git a/jackson-modules/jackson-custom-conversions/src/test/java/com/baeldung/skipfields/IgnoreFieldsWithFilterUnitTest.java b/jackson-modules/jackson-custom-conversions/src/test/java/com/baeldung/skipfields/IgnoreFieldsWithFilterUnitTest.java index e71f31bc6a..ec753019b2 100644 --- a/jackson-modules/jackson-custom-conversions/src/test/java/com/baeldung/skipfields/IgnoreFieldsWithFilterUnitTest.java +++ b/jackson-modules/jackson-custom-conversions/src/test/java/com/baeldung/skipfields/IgnoreFieldsWithFilterUnitTest.java @@ -37,7 +37,6 @@ public class IgnoreFieldsWithFilterUnitTest { assertThat(dtoAsString, not(containsString("intValue"))); assertThat(dtoAsString, containsString("booleanValue")); assertThat(dtoAsString, containsString("stringValue")); - System.out.println(dtoAsString); } @Test @@ -83,7 +82,6 @@ public class IgnoreFieldsWithFilterUnitTest { assertThat(dtoAsString, not(containsString("intValue"))); assertThat(dtoAsString, containsString("booleanValue")); assertThat(dtoAsString, containsString("stringValue")); - System.out.println(dtoAsString); } } diff --git a/jackson-modules/jackson-custom-conversions/src/test/java/com/baeldung/skipfields/JacksonDynamicIgnoreUnitTest.java b/jackson-modules/jackson-custom-conversions/src/test/java/com/baeldung/skipfields/JacksonDynamicIgnoreUnitTest.java index 6ba14f7476..2fd59e2a82 100644 --- a/jackson-modules/jackson-custom-conversions/src/test/java/com/baeldung/skipfields/JacksonDynamicIgnoreUnitTest.java +++ b/jackson-modules/jackson-custom-conversions/src/test/java/com/baeldung/skipfields/JacksonDynamicIgnoreUnitTest.java @@ -51,8 +51,6 @@ public class JacksonDynamicIgnoreUnitTest { assertTrue(result.contains("john")); assertTrue(result.contains("address")); assertTrue(result.contains("usa")); - - System.out.println("Not Hidden = " + result); } @Test @@ -65,8 +63,6 @@ public class JacksonDynamicIgnoreUnitTest { assertTrue(result.contains("john")); assertFalse(result.contains("address")); assertFalse(result.contains("usa")); - - System.out.println("Address Hidden = " + result); } @Test @@ -76,8 +72,6 @@ public class JacksonDynamicIgnoreUnitTest { final String result = mapper.writeValueAsString(person); assertTrue(result.length() == 0); - - System.out.println("All Hidden = " + result); } @Test @@ -90,7 +84,5 @@ public class JacksonDynamicIgnoreUnitTest { final Person p3 = new Person("adam", ad3, false); final String result = mapper.writeValueAsString(Arrays.asList(p1, p2, p3)); - - System.out.println(result); } } From 4f148739678917085f9319c036e5f7b29ae0d2d5 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Tue, 15 Sep 2020 10:28:34 +0200 Subject: [PATCH 135/263] JAVA-2599: Update OS specific unit tests --- core-java-modules/core-java-io-3/README.md | 1 + .../emptiness/DirectoryEmptinessUnitTest.java | 5 +++-- .../TemporaryDirectoriesUnitTest.java | 15 +++++++++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/core-java-modules/core-java-io-3/README.md b/core-java-modules/core-java-io-3/README.md index c4eacdf27a..06a2a5a0fc 100644 --- a/core-java-modules/core-java-io-3/README.md +++ b/core-java-modules/core-java-io-3/README.md @@ -9,4 +9,5 @@ This module contains articles about core Java input and output (IO) - [Check If a File or Directory Exists in Java](https://www.baeldung.com/java-file-directory-exists) - [Copy a Directory in Java](https://www.baeldung.com/java-copy-directory) - [Java Files Open Options](https://www.baeldung.com/java-file-options) +- [Creating Temporary Directories in Java](https://www.baeldung.com/java-temp-directories) - [[<-- Prev]](/core-java-modules/core-java-io-2) diff --git a/core-java-modules/core-java-io-3/src/test/java/com/baeldung/emptiness/DirectoryEmptinessUnitTest.java b/core-java-modules/core-java-io-3/src/test/java/com/baeldung/emptiness/DirectoryEmptinessUnitTest.java index a44aea1383..7f7936494f 100644 --- a/core-java-modules/core-java-io-3/src/test/java/com/baeldung/emptiness/DirectoryEmptinessUnitTest.java +++ b/core-java-modules/core-java-io-3/src/test/java/com/baeldung/emptiness/DirectoryEmptinessUnitTest.java @@ -4,6 +4,7 @@ import org.junit.Test; import java.io.File; import java.io.IOException; +import java.net.URISyntaxException; import java.nio.file.DirectoryStream; import java.nio.file.Files; import java.nio.file.Path; @@ -20,8 +21,8 @@ public class DirectoryEmptinessUnitTest { } @Test - public void givenPath_whenNotDirectory_thenReturnsFalse() throws IOException { - Path aFile = Paths.get(getClass().getResource("/notDir.txt").getPath()); + public void givenPath_whenNotDirectory_thenReturnsFalse() throws IOException, URISyntaxException { + Path aFile = Paths.get(getClass().getResource("/notDir.txt").toURI()); assertThat(isEmpty(aFile)).isFalse(); } diff --git a/core-java-modules/core-java-io-3/src/test/java/com/baeldung/tempdirectory/TemporaryDirectoriesUnitTest.java b/core-java-modules/core-java-io-3/src/test/java/com/baeldung/tempdirectory/TemporaryDirectoriesUnitTest.java index 470e06ef96..5cf7d88cd6 100644 --- a/core-java-modules/core-java-io-3/src/test/java/com/baeldung/tempdirectory/TemporaryDirectoriesUnitTest.java +++ b/core-java-modules/core-java-io-3/src/test/java/com/baeldung/tempdirectory/TemporaryDirectoriesUnitTest.java @@ -4,6 +4,7 @@ import org.apache.commons.io.FileUtils; import org.junit.Test; import java.io.IOException; +import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -66,10 +67,16 @@ public class TemporaryDirectoriesUnitTest { @Test public void givenTempDirWithPrefixWithFileAttrs_whenCreatePlainJava_thenAttributesAreSet() throws IOException { - final FileAttribute> attrs = PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("r--------")); + boolean isPosix = FileSystems.getDefault().supportedFileAttributeViews().contains("posix"); - final Path tmpdir = Files.createTempDirectory(Paths.get("target"), "tmpDirPrefix", attrs); - assertThat(tmpdir.toFile().getPath()).startsWith("target"); - assertThat(tmpdir.toFile().canWrite()).isFalse(); + if(!isPosix){ + System.out.println("You must be under a Posix Compliant Filesystem to run this test."); + } else { + final FileAttribute> attrs = PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("r--------")); + + final Path tmpdir = Files.createTempDirectory(Paths.get("target"), "tmpDirPrefix", attrs); + assertThat(tmpdir.toFile().getPath()).startsWith("target"); + assertThat(tmpdir.toFile().canWrite()).isFalse(); + } } } From 5121313f65903725a7e883d0ac9cb6f98cd9d16a Mon Sep 17 00:00:00 2001 From: mikr Date: Tue, 15 Sep 2020 11:08:35 +0200 Subject: [PATCH 136/263] Java-2136 Correctly configure netty server --- .../reactive/security/SpringSecurity5Application.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/spring-5-reactive-security/src/main/java/com/baeldung/reactive/security/SpringSecurity5Application.java b/spring-5-reactive-security/src/main/java/com/baeldung/reactive/security/SpringSecurity5Application.java index 325923f577..d315bf8238 100644 --- a/spring-5-reactive-security/src/main/java/com/baeldung/reactive/security/SpringSecurity5Application.java +++ b/spring-5-reactive-security/src/main/java/com/baeldung/reactive/security/SpringSecurity5Application.java @@ -28,9 +28,7 @@ public class SpringSecurity5Application { HttpHandler handler = WebHttpHandlerBuilder.applicationContext(context) .build(); ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler); - HttpServer httpServer = HttpServer.create(); - httpServer.host("localhost"); - httpServer.port(8080); + HttpServer httpServer = HttpServer.create().host("localhost").port(8080); return httpServer.handle(adapter).bindNow(); } From 40ebac5142a360131df2fb1f26bee8cb0b542511 Mon Sep 17 00:00:00 2001 From: Usman Mohyuddin Date: Tue, 15 Sep 2020 15:09:35 +0500 Subject: [PATCH 137/263] Split the @Test annotation in new line --- .../groovy/com/baeldung/removeprefix/RemovePrefixTest.groovy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core-groovy-strings/src/test/groovy/com/baeldung/removeprefix/RemovePrefixTest.groovy b/core-groovy-strings/src/test/groovy/com/baeldung/removeprefix/RemovePrefixTest.groovy index 4cdcb4ddfa..61b81fe1b2 100644 --- a/core-groovy-strings/src/test/groovy/com/baeldung/removeprefix/RemovePrefixTest.groovy +++ b/core-groovy-strings/src/test/groovy/com/baeldung/removeprefix/RemovePrefixTest.groovy @@ -45,7 +45,8 @@ class RemovePrefixTest { Assert.assertEquals(expected, actual) } - @Test public void whenPrefixIsRemovedUsingReplaceFirst_thenReturnTrue() { + @Test + public void whenPrefixIsRemovedUsingReplaceFirst_thenReturnTrue() { def regex = ~"^groovy" String trimPrefix = "groovyTutorials at Baeldung's groovy page" String actual = trimPrefix.replaceFirst(regex, "") From 51c2e22324186f7b17b141635dc66a685014ec95 Mon Sep 17 00:00:00 2001 From: Tarun Jain Date: Tue, 15 Sep 2020 20:32:07 +0530 Subject: [PATCH 138/263] Formatted code --- .../charencoding/CharacterEncodingDemo.java | 28 +++++++++---------- .../CharEncodingCheckController.java | 10 +++---- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/charencoding/CharacterEncodingDemo.java b/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/charencoding/CharacterEncodingDemo.java index 453bad5633..fb02789258 100644 --- a/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/charencoding/CharacterEncodingDemo.java +++ b/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/charencoding/CharacterEncodingDemo.java @@ -9,19 +9,19 @@ import org.springframework.web.filter.CharacterEncodingFilter; @SpringBootApplication public class CharacterEncodingDemo { - public static void main(String[] args) { - SpringApplication.run(CharacterEncodingDemo.class, args); - } + public static void main(String[] args) { + SpringApplication.run(CharacterEncodingDemo.class, args); + } - @Bean - public FilterRegistrationBean filterRegistrationBean() { - CharacterEncodingFilter filter = new CharacterEncodingFilter(); - filter.setEncoding("UTF-8"); - filter.setForceEncoding(true); - - FilterRegistrationBean registrationBean = new FilterRegistrationBean(); - registrationBean.setFilter(filter); - registrationBean.addUrlPatterns("/*"); - return registrationBean; - } + @Bean + public FilterRegistrationBean filterRegistrationBean() { + CharacterEncodingFilter filter = new CharacterEncodingFilter(); + filter.setEncoding("UTF-8"); + filter.setForceEncoding(true); + + FilterRegistrationBean registrationBean = new FilterRegistrationBean(); + registrationBean.setFilter(filter); + registrationBean.addUrlPatterns("/*"); + return registrationBean; + } } diff --git a/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/charencoding/controller/CharEncodingCheckController.java b/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/charencoding/controller/CharEncodingCheckController.java index 3257ca1f36..e1767f941e 100644 --- a/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/charencoding/controller/CharEncodingCheckController.java +++ b/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/charencoding/controller/CharEncodingCheckController.java @@ -5,9 +5,9 @@ import org.springframework.web.bind.annotation.GetMapping; @Controller public class CharEncodingCheckController { - - @GetMapping("/ping") - public String ping() { - return "path"; - } + + @GetMapping("/ping") + public String ping() { + return "path"; + } } From 4ae6ecbb39a37dde248f4d81521ba9d22dd044dc Mon Sep 17 00:00:00 2001 From: kwoyke Date: Tue, 15 Sep 2020 20:33:11 +0200 Subject: [PATCH 139/263] BAEL-4595: Upgrade to hazelcast-jet 4.2 (#10035) --- hazelcast/pom.xml | 10 +++----- .../hazelcast/cluster/NativeClient.java | 18 ++++++------- .../hazelcast/cluster/ServerNode.java | 10 ++++---- .../baeldung/hazelcast/jet/WordCounter.java | 25 ++++++++----------- .../hazelcast/jet/WordCounterUnitTest.java | 6 ++--- 5 files changed, 30 insertions(+), 39 deletions(-) diff --git a/hazelcast/pom.xml b/hazelcast/pom.xml index 287542be33..69444308a3 100644 --- a/hazelcast/pom.xml +++ b/hazelcast/pom.xml @@ -1,8 +1,8 @@ + xmlns="http://maven.apache.org/POM/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 hazelcast 0.0.1-SNAPSHOT @@ -15,7 +15,6 @@ - com.hazelcast.jet hazelcast-jet @@ -34,8 +33,7 @@ - - 0.6 + 4.2 \ No newline at end of file diff --git a/hazelcast/src/main/java/com/baeldung/hazelcast/cluster/NativeClient.java b/hazelcast/src/main/java/com/baeldung/hazelcast/cluster/NativeClient.java index 697e362289..3e58897401 100644 --- a/hazelcast/src/main/java/com/baeldung/hazelcast/cluster/NativeClient.java +++ b/hazelcast/src/main/java/com/baeldung/hazelcast/cluster/NativeClient.java @@ -1,24 +1,20 @@ package com.baeldung.hazelcast.cluster; -import java.util.Map.Entry; - import com.hazelcast.client.HazelcastClient; import com.hazelcast.client.config.ClientConfig; -import com.hazelcast.config.GroupConfig; import com.hazelcast.core.HazelcastInstance; -import com.hazelcast.core.IMap; + +import java.util.Map; public class NativeClient { - public static void main(String[] args) throws InterruptedException { + public static void main(String[] args) { ClientConfig config = new ClientConfig(); - GroupConfig groupConfig = config.getGroupConfig(); - groupConfig.setName("dev"); - groupConfig.setPassword("dev-pass"); + config.setClusterName("dev"); HazelcastInstance hazelcastInstanceClient = HazelcastClient.newHazelcastClient(config); - IMap map = hazelcastInstanceClient.getMap("data"); - for (Entry entry : map.entrySet()) { - System.out.println(String.format("Key: %d, Value: %s", entry.getKey(), entry.getValue())); + Map map = hazelcastInstanceClient.getMap("data"); + for (Map.Entry entry : map.entrySet()) { + System.out.printf("Key: %d, Value: %s%n", entry.getKey(), entry.getValue()); } } } diff --git a/hazelcast/src/main/java/com/baeldung/hazelcast/cluster/ServerNode.java b/hazelcast/src/main/java/com/baeldung/hazelcast/cluster/ServerNode.java index 36028834a4..7c903e961a 100644 --- a/hazelcast/src/main/java/com/baeldung/hazelcast/cluster/ServerNode.java +++ b/hazelcast/src/main/java/com/baeldung/hazelcast/cluster/ServerNode.java @@ -1,19 +1,19 @@ package com.baeldung.hazelcast.cluster; -import java.util.Map; - import com.hazelcast.core.Hazelcast; import com.hazelcast.core.HazelcastInstance; -import com.hazelcast.core.IdGenerator; +import com.hazelcast.flakeidgen.FlakeIdGenerator; + +import java.util.Map; public class ServerNode { public static void main(String[] args) { HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance(); Map map = hazelcastInstance.getMap("data"); - IdGenerator idGenerator = hazelcastInstance.getIdGenerator("newid"); + FlakeIdGenerator idGenerator = hazelcastInstance.getFlakeIdGenerator("newid"); for (int i = 0; i < 10; i++) { - map.put(idGenerator.newId(), "message" + 1); + map.put(idGenerator.newId(), "message" + i); } } } diff --git a/hazelcast/src/main/java/com/baeldung/hazelcast/jet/WordCounter.java b/hazelcast/src/main/java/com/baeldung/hazelcast/jet/WordCounter.java index 971986bcae..5d10650f89 100644 --- a/hazelcast/src/main/java/com/baeldung/hazelcast/jet/WordCounter.java +++ b/hazelcast/src/main/java/com/baeldung/hazelcast/jet/WordCounter.java @@ -1,33 +1,31 @@ package com.baeldung.hazelcast.jet; -import java.util.List; -import java.util.Map; - -import static com.hazelcast.jet.Traversers.traverseArray; -import static com.hazelcast.jet.aggregate.AggregateOperations.counting; -import static com.hazelcast.jet.function.DistributedFunctions.wholeItem; - import com.hazelcast.jet.Jet; import com.hazelcast.jet.JetInstance; import com.hazelcast.jet.pipeline.Pipeline; import com.hazelcast.jet.pipeline.Sinks; import com.hazelcast.jet.pipeline.Sources; +import java.util.List; +import java.util.Map; + +import static com.hazelcast.function.Functions.wholeItem; +import static com.hazelcast.jet.Traversers.traverseArray; +import static com.hazelcast.jet.aggregate.AggregateOperations.counting; + public class WordCounter { private static final String LIST_NAME = "textList"; - private static final String MAP_NAME = "countMap"; private Pipeline createPipeLine() { Pipeline p = Pipeline.create(); - p.drawFrom(Sources. list(LIST_NAME)) - .flatMap(word -> traverseArray(word.toLowerCase() - .split("\\W+"))) + p.readFrom(Sources.list(LIST_NAME)) + .flatMap(word -> traverseArray(word.toLowerCase().split("\\W+"))) .filter(word -> !word.isEmpty()) .groupingKey(wholeItem()) .aggregate(counting()) - .drainTo(Sinks.map(MAP_NAME)); + .writeTo(Sinks.map(MAP_NAME)); return p; } @@ -38,8 +36,7 @@ public class WordCounter { List textList = jet.getList(LIST_NAME); textList.addAll(sentences); Pipeline p = createPipeLine(); - jet.newJob(p) - .join(); + jet.newJob(p).join(); Map counts = jet.getMap(MAP_NAME); count = counts.get(word); } finally { diff --git a/hazelcast/src/test/java/com/baeldung/hazelcast/jet/WordCounterUnitTest.java b/hazelcast/src/test/java/com/baeldung/hazelcast/jet/WordCounterUnitTest.java index 95596b3860..7a60cd9a01 100644 --- a/hazelcast/src/test/java/com/baeldung/hazelcast/jet/WordCounterUnitTest.java +++ b/hazelcast/src/test/java/com/baeldung/hazelcast/jet/WordCounterUnitTest.java @@ -1,11 +1,11 @@ package com.baeldung.hazelcast.jet; -import static org.junit.Assert.assertTrue; +import org.junit.Test; import java.util.ArrayList; import java.util.List; -import org.junit.Test; +import static org.junit.Assert.assertEquals; public class WordCounterUnitTest { @@ -15,7 +15,7 @@ public class WordCounterUnitTest { sentences.add("The first second was alright, but the second second was tough."); WordCounter wordCounter = new WordCounter(); long countSecond = wordCounter.countWord(sentences, "second"); - assertTrue(countSecond == 3); + assertEquals(3, countSecond); } } From 989acd5ed7859c29eb62aabae1255918707a587b Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Wed, 16 Sep 2020 10:11:58 +0200 Subject: [PATCH 140/263] JAVA-2599: Handle Windows specific exception in the ExistenceUnitTest --- .../baeldung/existence/ExistenceUnitTest.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/core-java-modules/core-java-io-3/src/test/java/com/baeldung/existence/ExistenceUnitTest.java b/core-java-modules/core-java-io-3/src/test/java/com/baeldung/existence/ExistenceUnitTest.java index c52e46e8c1..747ae85b65 100644 --- a/core-java-modules/core-java-io-3/src/test/java/com/baeldung/existence/ExistenceUnitTest.java +++ b/core-java-modules/core-java-io-3/src/test/java/com/baeldung/existence/ExistenceUnitTest.java @@ -4,10 +4,7 @@ import org.junit.Test; import java.io.File; import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.LinkOption; -import java.nio.file.Path; -import java.nio.file.Paths; +import java.nio.file.*; import java.util.concurrent.ThreadLocalRandom; import static org.junit.Assert.assertFalse; @@ -47,8 +44,18 @@ public class ExistenceUnitTest { public void givenSymbolicLink_whenTargetDoesNotExists_thenFollowOrNotBasedOnTheOptions() throws IOException { Path target = Files.createTempFile("baeldung", "target"); Path symbol = Paths.get("test-link-" + ThreadLocalRandom.current().nextInt()); + Path symbolicLink = null; + + try { + symbolicLink = Files.createSymbolicLink(symbol, target); + } catch (FileSystemException ex) { + System.out.println("Your OS security policy prevents the current user from creating symbolic links.\n" + + "Most probably you're running Windows with UAC.\n" + + "If this is the case, please see - https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/create-symbolic-links\n" + + "You must change your security settings to run this test under Windows."); + return; + } - Path symbolicLink = Files.createSymbolicLink(symbol, target); assertTrue(Files.exists(symbolicLink)); assertTrue(Files.isSymbolicLink(symbolicLink)); assertFalse(Files.isSymbolicLink(target)); From 5cc62d43a36a1b484bd99871aebd5d833ee36090 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 16 Sep 2020 22:40:09 +0800 Subject: [PATCH 141/263] Update README.md --- spring-cloud/spring-cloud-consul/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-cloud/spring-cloud-consul/README.md b/spring-cloud/spring-cloud-consul/README.md index 47dc39f0d5..e587572ffa 100644 --- a/spring-cloud/spring-cloud-consul/README.md +++ b/spring-cloud/spring-cloud-consul/README.md @@ -1,3 +1,4 @@ ### Relevant Articles: - [A Quick Guide to Spring Cloud Consul](http://www.baeldung.com/spring-cloud-consul) +- [Leadership Election With Consul](https://www.baeldung.com/consul-leadership-election) From c30abba25f0e1c335c8bfe08aa7c5f9468e0316e Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 16 Sep 2020 22:41:20 +0800 Subject: [PATCH 142/263] Update README.md --- spring-boot-modules/spring-boot-actuator/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-boot-modules/spring-boot-actuator/README.md b/spring-boot-modules/spring-boot-actuator/README.md index 6f31ee4a5e..3e8ef3411b 100644 --- a/spring-boot-modules/spring-boot-actuator/README.md +++ b/spring-boot-modules/spring-boot-actuator/README.md @@ -9,3 +9,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Liveness and Readiness Probes in Spring Boot](https://www.baeldung.com/spring-liveness-readiness-probes) - [Custom Information in Spring Boot Info Endpoint](https://www.baeldung.com/spring-boot-info-actuator-custom) +- [Health Indicators in Spring Boot](https://www.baeldung.com/spring-boot-health-indicators) From 9de2a7e7788418cc4824e6c71a69dde6747b9486 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 16 Sep 2020 22:42:16 +0800 Subject: [PATCH 143/263] Update README.md --- spring-boot-modules/spring-boot-properties-3/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-properties-3/README.md b/spring-boot-modules/spring-boot-properties-3/README.md index d89f825c86..df272be7f4 100644 --- a/spring-boot-modules/spring-boot-properties-3/README.md +++ b/spring-boot-modules/spring-boot-properties-3/README.md @@ -6,4 +6,4 @@ ### Relevant Articles: - [How to Define a Map in YAML for a POJO?](https://www.baeldung.com/yaml-map-pojo) - +- [Using application.yml vs application.properties in Spring Boot](https://www.baeldung.com/spring-boot-yaml-vs-properties) From 29577bd7773b9a46ed1560c2c12d8f5bf65a2095 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 16 Sep 2020 22:43:16 +0800 Subject: [PATCH 144/263] Update README.md --- core-java-modules/core-java-io-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-io-3/README.md b/core-java-modules/core-java-io-3/README.md index 06a2a5a0fc..4b1a14ab3e 100644 --- a/core-java-modules/core-java-io-3/README.md +++ b/core-java-modules/core-java-io-3/README.md @@ -10,4 +10,5 @@ This module contains articles about core Java input and output (IO) - [Copy a Directory in Java](https://www.baeldung.com/java-copy-directory) - [Java Files Open Options](https://www.baeldung.com/java-file-options) - [Creating Temporary Directories in Java](https://www.baeldung.com/java-temp-directories) +- [Reading a Line at a Given Line Number From a File in Java](https://www.baeldung.com/java-read-line-at-number) - [[<-- Prev]](/core-java-modules/core-java-io-2) From 9c64b62ad6227f20286f5cfe15b26db0580a70c6 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 16 Sep 2020 22:44:40 +0800 Subject: [PATCH 145/263] Update README.md --- spring-boot-modules/spring-boot-mvc-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-boot-modules/spring-boot-mvc-3/README.md b/spring-boot-modules/spring-boot-mvc-3/README.md index 0562224337..6627bd8eea 100644 --- a/spring-boot-modules/spring-boot-mvc-3/README.md +++ b/spring-boot-modules/spring-boot-mvc-3/README.md @@ -6,4 +6,5 @@ This module contains articles about Spring Web MVC in Spring Boot projects. - [Circular View Path Error](https://www.baeldung.com/spring-circular-view-path-error) - [Download an Image or a File with Spring MVC](https://www.baeldung.com/spring-controller-return-image-file) +- [Spring MVC Async vs Spring WebFlux](https://www.baeldung.com/spring-mvc-async-vs-webflux) - More articles: [[prev -->]](/spring-boot-modules/spring-boot-mvc-2) From ee277ad5db39c020cdc6950068280a8babb94e3e Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 16 Sep 2020 22:44:58 +0800 Subject: [PATCH 146/263] 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 55ab0b8af4..9f9a12f997 100644 --- a/spring-5-webflux/README.md +++ b/spring-5-webflux/README.md @@ -8,3 +8,4 @@ This module contains articles about Spring 5 WebFlux - [How to Return 404 with Spring WebFlux](https://www.baeldung.com/spring-webflux-404) - [Spring WebClient Requests with Parameters](https://www.baeldung.com/webflux-webclient-parameters) - [RSocket Using Spring Boot](https://www.baeldung.com/spring-boot-rsocket) +- [Spring MVC Async vs Spring WebFlux](https://www.baeldung.com/spring-mvc-async-vs-webflux) From 35fb40162c1f110d8d54c7e266e4ffb0f8beedba Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 16 Sep 2020 22:46:47 +0800 Subject: [PATCH 147/263] Update README.md --- spring-rest-http-2/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-rest-http-2/README.md b/spring-rest-http-2/README.md index 74ec59e0b5..97cdc2d068 100644 --- a/spring-rest-http-2/README.md +++ b/spring-rest-http-2/README.md @@ -7,4 +7,4 @@ The "REST With Spring 2" Classes: http://bit.ly/restwithspring ### Relevant Articles: - +- [How to Turn Off Swagger-ui in Production](https://www.baeldung.com/swagger-ui-turn-off-in-production) From 647b0e9171155402037e7d07c5b5327224d5db31 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 16 Sep 2020 22:47:55 +0800 Subject: [PATCH 148/263] Update README.md --- libraries-testing/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries-testing/README.md b/libraries-testing/README.md index 43d7673e2d..447f3f32b9 100644 --- a/libraries-testing/README.md +++ b/libraries-testing/README.md @@ -12,3 +12,4 @@ This module contains articles about test libraries. - [Introduction to Hoverfly in Java](https://www.baeldung.com/hoverfly) - [Testing with Hamcrest](https://www.baeldung.com/java-junit-hamcrest-guide) - [Introduction To DBUnit](https://www.baeldung.com/java-dbunit) +- [Introduction to ArchUnit](https://www.baeldung.com/java-archunit-intro) From c79db10648fc596c485ec4abe62d0eb887967371 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 16 Sep 2020 22:51:52 +0800 Subject: [PATCH 149/263] Update README.md --- core-java-modules/core-java-lang-math-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-lang-math-2/README.md b/core-java-modules/core-java-lang-math-2/README.md index 09039f6ed0..69ee00b5a5 100644 --- a/core-java-modules/core-java-lang-math-2/README.md +++ b/core-java-modules/core-java-lang-math-2/README.md @@ -13,4 +13,5 @@ - [Convert Latitude and Longitude to a 2D Point in Java](https://www.baeldung.com/java-convert-latitude-longitude) - [Debugging with Eclipse](https://www.baeldung.com/eclipse-debugging) - [Matrix Multiplication in Java](https://www.baeldung.com/java-matrix-multiplication) +- [Largest Power of 2 That Is Less Than the Given Number](https://www.baeldung.com/java-largest-power-of-2-less-than-number) - More articles: [[<-- Prev]](/core-java-modules/core-java-lang-math) From c221c2fa0bdd2526e64e7773c5eac637909abccc Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 16 Sep 2020 22:52:52 +0800 Subject: [PATCH 150/263] Update README.md --- core-java-modules/core-java-exceptions-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-exceptions-3/README.md b/core-java-modules/core-java-exceptions-3/README.md index e6c7eda881..1b2db24bdc 100644 --- a/core-java-modules/core-java-exceptions-3/README.md +++ b/core-java-modules/core-java-exceptions-3/README.md @@ -1,3 +1,4 @@ ### Relevant Articles: - [NoSuchMethodError in Java](https://www.baeldung.com/java-nosuchmethod-error) +- [IllegalArgumentException or NullPointerException for a Null Parameter?](https://www.baeldung.com/java-illegalargumentexception-or-nullpointerexception) From ede8e77f7ab04f42ee0dec9c5e6a873615141967 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 16 Sep 2020 22:53:49 +0800 Subject: [PATCH 151/263] Update README.md --- quarkus/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/quarkus/README.md b/quarkus/README.md index 3ff08c6f9e..94b71dd954 100644 --- a/quarkus/README.md +++ b/quarkus/README.md @@ -1,3 +1,4 @@ ## Relevant Articles: - [Guide to QuarkusIO](https://www.baeldung.com/quarkus-io) +- [Testing Quarkus Applications](https://www.baeldung.com/java-quarkus-testing) From a6f195dab69b21df2b5e131978811f131c178430 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 16 Sep 2020 22:55:08 +0800 Subject: [PATCH 152/263] Create README.md --- gradle-5/source-sets/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 gradle-5/source-sets/README.md diff --git a/gradle-5/source-sets/README.md b/gradle-5/source-sets/README.md new file mode 100644 index 0000000000..19fe1e1fae --- /dev/null +++ b/gradle-5/source-sets/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Gradle Source Sets](https://www.baeldung.com/gradle-source-sets) From 258f1be8ac1028d3d9c76530e3ca894ad1dcc0e8 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 16 Sep 2020 22:56:33 +0800 Subject: [PATCH 153/263] Update README.md --- core-java-modules/core-java-arrays-guides/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-arrays-guides/README.md b/core-java-modules/core-java-arrays-guides/README.md index 621443e4a9..934833b31b 100644 --- a/core-java-modules/core-java-arrays-guides/README.md +++ b/core-java-modules/core-java-arrays-guides/README.md @@ -6,3 +6,4 @@ This module contains complete guides about arrays in Java - [Arrays in Java: A Reference Guide](https://www.baeldung.com/java-arrays-guide) - [Guide to the java.util.Arrays Class](https://www.baeldung.com/java-util-arrays) - [What is \[Ljava.lang.Object;?](https://www.baeldung.com/java-tostring-array) +- [Guide to ArrayStoreException](https://www.baeldung.com/java-arraystoreexception) From 1d9cf597d8bbf31bc11f6fda449b3bc410e60414 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 16 Sep 2020 22:57:59 +0800 Subject: [PATCH 154/263] Update README.md --- testing-modules/testing-assertions/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/testing-modules/testing-assertions/README.md b/testing-modules/testing-assertions/README.md index 08e2e66062..ea238af599 100644 --- a/testing-modules/testing-assertions/README.md +++ b/testing-modules/testing-assertions/README.md @@ -1,3 +1,4 @@ ### Relevant Articles: - [Asserting Log Messages With JUnit](https://www.baeldung.com/junit-asserting-logs) +- [Assert Two Lists for Equality Ignoring Order in Java](https://www.baeldung.com/java-assert-lists-equality-ignore-order) From d04fadfb9bc2bcadaa1a96b2a932f6b5ae5cd95a Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 16 Sep 2020 22:59:27 +0800 Subject: [PATCH 155/263] Update README.md --- spring-boot-modules/spring-boot-autoconfiguration/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-autoconfiguration/README.md b/spring-boot-modules/spring-boot-autoconfiguration/README.md index d1b5fde7ed..881c88467b 100644 --- a/spring-boot-modules/spring-boot-autoconfiguration/README.md +++ b/spring-boot-modules/spring-boot-autoconfiguration/README.md @@ -10,4 +10,5 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Create a Custom Auto-Configuration with Spring Boot](https://www.baeldung.com/spring-boot-custom-auto-configuration) - [Guide to ApplicationContextRunner in Spring Boot](https://www.baeldung.com/spring-boot-context-runner) - [A Guide to Spring Boot Configuration Metadata](https://www.baeldung.com/spring-boot-configuration-metadata) -- [Display Auto-Configuration Report in Spring Boot](https://www.baeldung.com/spring-boot-auto-configuration-report) \ No newline at end of file +- [Display Auto-Configuration Report in Spring Boot](https://www.baeldung.com/spring-boot-auto-configuration-report) +- [The Spring @ConditionalOnProperty Annotation](https://www.baeldung.com/spring-conditionalonproperty) From f9cd2c38078c720a8229d7a9b2b22ae61b18fc33 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 16 Sep 2020 23:01:10 +0800 Subject: [PATCH 156/263] Update README.md --- testing-modules/spring-testing-2/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/testing-modules/spring-testing-2/README.md b/testing-modules/spring-testing-2/README.md index 729105e3fd..702a02ff27 100644 --- a/testing-modules/spring-testing-2/README.md +++ b/testing-modules/spring-testing-2/README.md @@ -1 +1,3 @@ ## Relevant Articles: + +- [Guide to @DynamicPropertySource in Spring](https://www.baeldung.com/spring-dynamicpropertysource) From 459dc06432a68423cb2f9685110c0864180095f0 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 16 Sep 2020 23:34:14 +0800 Subject: [PATCH 157/263] Update README.md --- spring-thymeleaf-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-thymeleaf-3/README.md b/spring-thymeleaf-3/README.md index 34bd1b4b35..8bb8861daf 100644 --- a/spring-thymeleaf-3/README.md +++ b/spring-thymeleaf-3/README.md @@ -8,3 +8,4 @@ This module contains articles about Spring with Thymeleaf - [Formatting Currencies in Spring Using Thymeleaf](https://www.baeldung.com/spring-thymeleaf-currencies) - [Working with Select and Option in Thymeleaf](https://www.baeldung.com/thymeleaf-select-option) - [Conditional CSS Classes in Thymeleaf](https://www.baeldung.com/spring-mvc-thymeleaf-conditional-css-classes) +- [Using Hidden Inputs with Spring and Thymeleaf](https://www.baeldung.com/spring-thymeleaf-hidden-inputs) From b7ec39842bd155d4c1f94b9111e1050b94387981 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 16 Sep 2020 23:37:50 +0800 Subject: [PATCH 158/263] Create README.md --- spring-boot-modules/spring-boot-swagger/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 spring-boot-modules/spring-boot-swagger/README.md diff --git a/spring-boot-modules/spring-boot-swagger/README.md b/spring-boot-modules/spring-boot-swagger/README.md new file mode 100644 index 0000000000..1038031210 --- /dev/null +++ b/spring-boot-modules/spring-boot-swagger/README.md @@ -0,0 +1,3 @@ +## Relevant Articles: + +- [Hiding Endpoints From Swagger Documentation in Spring Boot](https://www.baeldung.com/spring-swagger-hiding-endpoints) From 35c25daa18843cd16a81bcc9c3282408fb6db419 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 16 Sep 2020 23:39:49 +0800 Subject: [PATCH 159/263] Update README.md --- spring-boot-modules/spring-boot-keycloak/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-boot-modules/spring-boot-keycloak/README.md b/spring-boot-modules/spring-boot-keycloak/README.md index 2dfe3fc331..74fbbb6f09 100644 --- a/spring-boot-modules/spring-boot-keycloak/README.md +++ b/spring-boot-modules/spring-boot-keycloak/README.md @@ -4,3 +4,4 @@ This module contains articles about Keycloak in Spring Boot projects. ## Relevant articles: - [A Quick Guide to Using Keycloak with Spring Boot](https://www.baeldung.com/spring-boot-keycloak) +- [Custom User Attributes with Keycloak](https://www.baeldung.com/keycloak-custom-user-attributes) From 5c0391cf68d07994ed35d86441e9de893c6e7ddb Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 16 Sep 2020 23:42:36 +0800 Subject: [PATCH 160/263] Update README.md --- core-java-modules/core-java-exceptions-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-exceptions-3/README.md b/core-java-modules/core-java-exceptions-3/README.md index 1b2db24bdc..4e3dd22bb8 100644 --- a/core-java-modules/core-java-exceptions-3/README.md +++ b/core-java-modules/core-java-exceptions-3/README.md @@ -2,3 +2,4 @@ - [NoSuchMethodError in Java](https://www.baeldung.com/java-nosuchmethod-error) - [IllegalArgumentException or NullPointerException for a Null Parameter?](https://www.baeldung.com/java-illegalargumentexception-or-nullpointerexception) +- [IllegalMonitorStateException in Java](https://www.baeldung.com/java-illegalmonitorstateexception) From 4d84d35754ae4d9e30911fd0ceb8e06f81310863 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 16 Sep 2020 23:44:29 +0800 Subject: [PATCH 161/263] Update README.md --- spring-rest-http/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-rest-http/README.md b/spring-rest-http/README.md index bb4cfd829d..2271858f0a 100644 --- a/spring-rest-http/README.md +++ b/spring-rest-http/README.md @@ -14,3 +14,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Guide to DeferredResult in Spring](https://www.baeldung.com/spring-deferred-result) - [Using JSON Patch in Spring REST APIs](https://www.baeldung.com/spring-rest-json-patch) - [OpenAPI JSON Objects as Query Parameters](https://www.baeldung.com/openapi-json-query-parameters) +- [Dates in OpenAPI Files](https://www.baeldung.com/openapi-dates) From 1cf9a48f688f4f13f0a38b2708896a0754329c1c Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 16 Sep 2020 23:45:40 +0800 Subject: [PATCH 162/263] Update README.MD --- persistence-modules/flyway/README.MD | 1 + 1 file changed, 1 insertion(+) diff --git a/persistence-modules/flyway/README.MD b/persistence-modules/flyway/README.MD index daeb9012b5..bd5f9bbe03 100644 --- a/persistence-modules/flyway/README.MD +++ b/persistence-modules/flyway/README.MD @@ -1,3 +1,4 @@ ### Relevant Articles: - [Database Migrations with Flyway](http://www.baeldung.com/database-migrations-with-flyway) - [A Guide to Flyway Callbacks](http://www.baeldung.com/flyway-callbacks) +- [Rolling Back Migrations with Flyway](https://www.baeldung.com/flyway-roll-back) From ce9e9a605e453609a9d6db9447d7335b6d9026b1 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 16 Sep 2020 23:47:15 +0800 Subject: [PATCH 163/263] Update README.md --- libraries-security/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries-security/README.md b/libraries-security/README.md index 5ec85a15e9..1a0e16a776 100644 --- a/libraries-security/README.md +++ b/libraries-security/README.md @@ -11,3 +11,4 @@ This module contains articles about security libraries. - [Intro to Jasypt](https://www.baeldung.com/jasypt) - [Digital Signatures in Java](https://www.baeldung.com/java-digital-signature) - [How to Read PEM File to Get Public and Private Keys](https://www.baeldung.com/java-read-pem-file-keys) +- [SSH Connection With Java](https://www.baeldung.com/java-ssh-connection) From 5ae7a913cf4c9879a5ce8ba9b1f112c2f029da34 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 16 Sep 2020 23:48:50 +0800 Subject: [PATCH 164/263] Update README.md --- testing-modules/mockito-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/testing-modules/mockito-2/README.md b/testing-modules/mockito-2/README.md index 9ca5a38e2e..c7b62182b5 100644 --- a/testing-modules/mockito-2/README.md +++ b/testing-modules/mockito-2/README.md @@ -8,3 +8,4 @@ - [Introduction to Mockito’s AdditionalAnswers](https://www.baeldung.com/mockito-additionalanswers) - [Mockito – Using Spies](https://www.baeldung.com/mockito-spy) - [Using Mockito ArgumentCaptor](https://www.baeldung.com/mockito-argumentcaptor) +- [Difference Between when() and doXxx() Methods in Mockito](https://www.baeldung.com/java-mockito-when-vs-do) From fce5fac0c44524d321b4bb8d37c74fb1b32762ae Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 16 Sep 2020 23:50:34 +0800 Subject: [PATCH 165/263] Update README.md --- patterns/design-patterns-architectural/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/patterns/design-patterns-architectural/README.md b/patterns/design-patterns-architectural/README.md index fbe4221752..5b6011c159 100644 --- a/patterns/design-patterns-architectural/README.md +++ b/patterns/design-patterns-architectural/README.md @@ -1,3 +1,4 @@ ### Relevant Articles: - [Service Locator Pattern](https://www.baeldung.com/java-service-locator-pattern) - [The DAO Pattern in Java](https://www.baeldung.com/java-dao-pattern) +- [DAO vs Repository Patterns](https://www.baeldung.com/java-dao-vs-repository) From d5ada37cc7d1c04175fe4e5ce8489186ed79b2c3 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 16 Sep 2020 23:54:01 +0800 Subject: [PATCH 166/263] Update README.md --- aws-lambda/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/aws-lambda/README.md b/aws-lambda/README.md index 2fbdaace10..759c9dd506 100644 --- a/aws-lambda/README.md +++ b/aws-lambda/README.md @@ -5,3 +5,4 @@ This module contains articles about AWS Lambda ### Relevant Articles: - [Using AWS Lambda with API Gateway](https://www.baeldung.com/aws-lambda-api-gateway) - [Introduction to AWS Serverless Application Model](https://www.baeldung.com/aws-serverless) +- [How to Implement Hibernate in an AWS Lambda Function in Java](https://www.baeldung.com/java-aws-lambda-hibernate) From d30ba2c8f04284063ddec1e74b75b6c84d091d3e Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 16 Sep 2020 23:55:27 +0800 Subject: [PATCH 167/263] Create README.md --- gradle-5/cmd-line-args/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 gradle-5/cmd-line-args/README.md diff --git a/gradle-5/cmd-line-args/README.md b/gradle-5/cmd-line-args/README.md new file mode 100644 index 0000000000..de797c8588 --- /dev/null +++ b/gradle-5/cmd-line-args/README.md @@ -0,0 +1,3 @@ +## Relevant Articles: + +- [Passing Command Line Arguments in Gradle](https://www.baeldung.com/gradle-command-line-arguments) From a61f3c9b54907b8024d5f837179d951306699181 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 16 Sep 2020 23:56:46 +0800 Subject: [PATCH 168/263] Update README.md --- core-java-modules/core-java-lang-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-lang-3/README.md b/core-java-modules/core-java-lang-3/README.md index 0fa08ef397..121d30f20f 100644 --- a/core-java-modules/core-java-lang-3/README.md +++ b/core-java-modules/core-java-lang-3/README.md @@ -5,4 +5,5 @@ This module contains articles about core features in the Java language - [Class.isInstance vs Class.isAssignableFrom](https://www.baeldung.com/java-isinstance-isassignablefrom) - [Converting a Java String Into a Boolean](https://www.baeldung.com/java-string-to-boolean) - [When are Static Variables Initialized in Java?](https://www.baeldung.com/java-static-variables-initialization) +- [Checking if a Class Exists in Java](https://www.baeldung.com/java-check-class-exists) - [[<-- Prev]](/core-java-modules/core-java-lang-2) From 2cc967c01c535e59b42cf7f939fa2eed7bab878f Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 17 Sep 2020 00:09:56 +0800 Subject: [PATCH 169/263] Update README.md --- core-kotlin-modules/core-kotlin-collections-2/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core-kotlin-modules/core-kotlin-collections-2/README.md b/core-kotlin-modules/core-kotlin-collections-2/README.md index 2dc180b5b3..64062ee704 100644 --- a/core-kotlin-modules/core-kotlin-collections-2/README.md +++ b/core-kotlin-modules/core-kotlin-collections-2/README.md @@ -2,6 +2,6 @@ This module contains articles about core Kotlin collections. -### Relevant articles: - +## Relevant articles: +- [Aggregate Operations in Kotlin](https://www.baeldung.com/kotlin/aggregate-operations) From 8928164d224ca352b6db2a87e5bc092d9d86a62f Mon Sep 17 00:00:00 2001 From: kwoyke Date: Wed, 16 Sep 2020 20:53:28 +0200 Subject: [PATCH 170/263] BAEL-4595: Update hazelcast.xml config file (#10039) * BAEL-4595: Upgrade to hazelcast-jet 4.2 * BAEL-4595: Update hazelcast.xml config file --- hazelcast/src/main/resources/hazelcast.xml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/hazelcast/src/main/resources/hazelcast.xml b/hazelcast/src/main/resources/hazelcast.xml index f29dc532b8..889e65801b 100644 --- a/hazelcast/src/main/resources/hazelcast.xml +++ b/hazelcast/src/main/resources/hazelcast.xml @@ -1,16 +1,16 @@ - + 5701 - - - - machine1 - localhost - + + + machine1 + localhost + \ No newline at end of file From 4ce6b34c063d33a52ec7695c2d9e321403b24833 Mon Sep 17 00:00:00 2001 From: Kai Yuan Date: Fri, 11 Sep 2020 01:08:12 +0200 Subject: [PATCH 171/263] [BAEL-4583] Improvement- Java Period --- .../com/baeldung/date/DateDiffUnitTest.java | 63 +++++++++++++------ 1 file changed, 43 insertions(+), 20 deletions(-) diff --git a/core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/date/DateDiffUnitTest.java b/core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/date/DateDiffUnitTest.java index 226556d4bb..9a0779ccac 100644 --- a/core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/date/DateDiffUnitTest.java +++ b/core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/date/DateDiffUnitTest.java @@ -1,6 +1,8 @@ package com.baeldung.date; -import static org.junit.Assert.assertEquals; +import org.joda.time.Days; +import org.joda.time.Minutes; +import org.junit.Test; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -16,7 +18,7 @@ import java.util.Locale; import java.util.TimeZone; import java.util.concurrent.TimeUnit; -import org.junit.Test; +import static org.junit.Assert.*; public class DateDiffUnitTest { @@ -29,18 +31,39 @@ public class DateDiffUnitTest { long diffInMillies = Math.abs(secondDate.getTime() - firstDate.getTime()); long diff = TimeUnit.DAYS.convert(diffInMillies, TimeUnit.MILLISECONDS); - assertEquals(diff, 6); + assertEquals(6, diff); } @Test - public void givenTwoDatesInJava8_whenDifferentiating_thenWeGetSix() { - LocalDate now = LocalDate.now(); - LocalDate sixDaysBehind = now.minusDays(6); + public void givenTwoDatesInJava8_whenUsingPeriodGetDays_thenWorks() { + LocalDate aDate = LocalDate.of(2020, 9, 11); + LocalDate sixDaysBehind = aDate.minusDays(6); - Period period = Period.between(now, sixDaysBehind); + Period period = Period.between(aDate, sixDaysBehind); int diff = Math.abs(period.getDays()); - assertEquals(diff, 6); + assertEquals(6, diff); + } + + @Test + public void givenTwoDatesInJava8_whenUsingPeriodGetDays_thenDoesNotWork() { + LocalDate aDate = LocalDate.of(2020, 9, 11); + LocalDate sixtyDaysBehind = aDate.minusDays(60); + Period period = Period.between(aDate, sixtyDaysBehind); + int diff = Math.abs(period.getDays()); + //not equals + assertNotEquals(60, diff); + } + + @Test + public void givenTwoDatesInJava8_whenUsingPeriod_thenWeGet0Year1Month29Days() { + LocalDate aDate = LocalDate.of(2020, 9, 11); + LocalDate sixtyDaysBehind = aDate.minusDays(60); + Period period = Period.between(aDate, sixtyDaysBehind); + int years = Math.abs(period.getYears()); + int months = Math.abs(period.getMonths()); + int days = Math.abs(period.getDays()); + assertArrayEquals(new int[] { 0, 1, 29 }, new int[] { years, months, days }); } @Test @@ -51,7 +74,7 @@ public class DateDiffUnitTest { Duration duration = Duration.between(now, sixMinutesBehind); long diff = Math.abs(duration.toMinutes()); - assertEquals(diff, 6); + assertEquals(6, diff); } @Test @@ -61,7 +84,7 @@ public class DateDiffUnitTest { long diff = ChronoUnit.SECONDS.between(now, tenSecondsLater); - assertEquals(diff, 10); + assertEquals(10, diff); } @Test @@ -69,9 +92,9 @@ public class DateDiffUnitTest { LocalDateTime ldt = LocalDateTime.now(); ZonedDateTime now = ldt.atZone(ZoneId.of("America/Montreal")); ZonedDateTime sixDaysBehind = now.withZoneSameInstant(ZoneId.of("Asia/Singapore")) - .minusDays(6); + .minusDays(6); long diff = ChronoUnit.DAYS.between(sixDaysBehind, now); - assertEquals(diff, 6); + assertEquals(6, diff); } @Test @@ -81,7 +104,7 @@ public class DateDiffUnitTest { long diff = now.until(tenSecondsLater, ChronoUnit.SECONDS); - assertEquals(diff, 10); + assertEquals(10, diff); } @Test @@ -89,10 +112,9 @@ public class DateDiffUnitTest { org.joda.time.LocalDate now = org.joda.time.LocalDate.now(); org.joda.time.LocalDate sixDaysBehind = now.minusDays(6); - org.joda.time.Period period = new org.joda.time.Period(now, sixDaysBehind); - long diff = Math.abs(period.getDays()); + long diff = Math.abs(Days.daysBetween(now, sixDaysBehind).getDays()); - assertEquals(diff, 6); + assertEquals(6, diff); } @Test @@ -100,8 +122,9 @@ public class DateDiffUnitTest { org.joda.time.LocalDateTime now = org.joda.time.LocalDateTime.now(); org.joda.time.LocalDateTime sixMinutesBehind = now.minusMinutes(6); - org.joda.time.Period period = new org.joda.time.Period(now, sixMinutesBehind); - long diff = Math.abs(period.getDays()); + long diff = Math.abs(Minutes.minutesBetween(now, sixMinutesBehind).getMinutes()); + assertEquals(6, diff); + } @Test @@ -111,6 +134,6 @@ public class DateDiffUnitTest { long diff = Math.abs(now.numDaysFrom(sixDaysBehind)); - assertEquals(diff, 6); + assertEquals(6, diff); } -} \ No newline at end of file +} From 1509fa5ddc5b26a9148ec3a7476c2ebee2b353db Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Wed, 16 Sep 2020 22:20:32 +0200 Subject: [PATCH 172/263] JAVA-2904: Fix README.MD files extension --- core-java-modules/core-java-reflection/{README.MD => README.md} | 0 core-java-modules/pre-jpms/{README.MD => README.md} | 0 drools/{README.MD => README.md} | 0 libraries-primitive/{README.MD => README.md} | 0 persistence-modules/flyway-repair/{README.MD => README.md} | 0 persistence-modules/flyway/{README.MD => README.md} | 0 .../spring-boot-persistence/{README.MD => README.md} | 0 persistence-modules/spring-data-dynamodb/{README.MD => README.md} | 0 raml/{README.MD => README.md} | 0 spring-boot-modules/spring-boot-client/{README.MD => README.md} | 0 .../spring-boot-exceptions/{README.MD => README.md} | 0 spring-cloud-data-flow/apache-spark-job/{README.MD => README.md} | 0 spring-cloud-data-flow/batch-job/{README.MD => README.md} | 0 .../spring-cloud-data-flow-etl/{README.MD => README.md} | 0 .../{README.MD => README.md} | 0 spring-cloud/spring-cloud-functions/{README.MD => README.md} | 0 spring-cloud/spring-cloud-hystrix/{README.MD => README.md} | 0 17 files changed, 0 insertions(+), 0 deletions(-) rename core-java-modules/core-java-reflection/{README.MD => README.md} (100%) rename core-java-modules/pre-jpms/{README.MD => README.md} (100%) rename drools/{README.MD => README.md} (100%) rename libraries-primitive/{README.MD => README.md} (100%) rename persistence-modules/flyway-repair/{README.MD => README.md} (100%) rename persistence-modules/flyway/{README.MD => README.md} (100%) rename persistence-modules/spring-boot-persistence/{README.MD => README.md} (100%) rename persistence-modules/spring-data-dynamodb/{README.MD => README.md} (100%) rename raml/{README.MD => README.md} (100%) rename spring-boot-modules/spring-boot-client/{README.MD => README.md} (100%) rename spring-boot-modules/spring-boot-exceptions/{README.MD => README.md} (100%) rename spring-cloud-data-flow/apache-spark-job/{README.MD => README.md} (100%) rename spring-cloud-data-flow/batch-job/{README.MD => README.md} (100%) rename spring-cloud-data-flow/spring-cloud-data-flow-etl/{README.MD => README.md} (100%) rename spring-cloud-data-flow/spring-cloud-data-flow-stream-processing/{README.MD => README.md} (100%) rename spring-cloud/spring-cloud-functions/{README.MD => README.md} (100%) rename spring-cloud/spring-cloud-hystrix/{README.MD => README.md} (100%) diff --git a/core-java-modules/core-java-reflection/README.MD b/core-java-modules/core-java-reflection/README.md similarity index 100% rename from core-java-modules/core-java-reflection/README.MD rename to core-java-modules/core-java-reflection/README.md diff --git a/core-java-modules/pre-jpms/README.MD b/core-java-modules/pre-jpms/README.md similarity index 100% rename from core-java-modules/pre-jpms/README.MD rename to core-java-modules/pre-jpms/README.md diff --git a/drools/README.MD b/drools/README.md similarity index 100% rename from drools/README.MD rename to drools/README.md diff --git a/libraries-primitive/README.MD b/libraries-primitive/README.md similarity index 100% rename from libraries-primitive/README.MD rename to libraries-primitive/README.md diff --git a/persistence-modules/flyway-repair/README.MD b/persistence-modules/flyway-repair/README.md similarity index 100% rename from persistence-modules/flyway-repair/README.MD rename to persistence-modules/flyway-repair/README.md diff --git a/persistence-modules/flyway/README.MD b/persistence-modules/flyway/README.md similarity index 100% rename from persistence-modules/flyway/README.MD rename to persistence-modules/flyway/README.md diff --git a/persistence-modules/spring-boot-persistence/README.MD b/persistence-modules/spring-boot-persistence/README.md similarity index 100% rename from persistence-modules/spring-boot-persistence/README.MD rename to persistence-modules/spring-boot-persistence/README.md diff --git a/persistence-modules/spring-data-dynamodb/README.MD b/persistence-modules/spring-data-dynamodb/README.md similarity index 100% rename from persistence-modules/spring-data-dynamodb/README.MD rename to persistence-modules/spring-data-dynamodb/README.md diff --git a/raml/README.MD b/raml/README.md similarity index 100% rename from raml/README.MD rename to raml/README.md diff --git a/spring-boot-modules/spring-boot-client/README.MD b/spring-boot-modules/spring-boot-client/README.md similarity index 100% rename from spring-boot-modules/spring-boot-client/README.MD rename to spring-boot-modules/spring-boot-client/README.md diff --git a/spring-boot-modules/spring-boot-exceptions/README.MD b/spring-boot-modules/spring-boot-exceptions/README.md similarity index 100% rename from spring-boot-modules/spring-boot-exceptions/README.MD rename to spring-boot-modules/spring-boot-exceptions/README.md diff --git a/spring-cloud-data-flow/apache-spark-job/README.MD b/spring-cloud-data-flow/apache-spark-job/README.md similarity index 100% rename from spring-cloud-data-flow/apache-spark-job/README.MD rename to spring-cloud-data-flow/apache-spark-job/README.md diff --git a/spring-cloud-data-flow/batch-job/README.MD b/spring-cloud-data-flow/batch-job/README.md similarity index 100% rename from spring-cloud-data-flow/batch-job/README.MD rename to spring-cloud-data-flow/batch-job/README.md diff --git a/spring-cloud-data-flow/spring-cloud-data-flow-etl/README.MD b/spring-cloud-data-flow/spring-cloud-data-flow-etl/README.md similarity index 100% rename from spring-cloud-data-flow/spring-cloud-data-flow-etl/README.MD rename to spring-cloud-data-flow/spring-cloud-data-flow-etl/README.md diff --git a/spring-cloud-data-flow/spring-cloud-data-flow-stream-processing/README.MD b/spring-cloud-data-flow/spring-cloud-data-flow-stream-processing/README.md similarity index 100% rename from spring-cloud-data-flow/spring-cloud-data-flow-stream-processing/README.MD rename to spring-cloud-data-flow/spring-cloud-data-flow-stream-processing/README.md diff --git a/spring-cloud/spring-cloud-functions/README.MD b/spring-cloud/spring-cloud-functions/README.md similarity index 100% rename from spring-cloud/spring-cloud-functions/README.MD rename to spring-cloud/spring-cloud-functions/README.md diff --git a/spring-cloud/spring-cloud-hystrix/README.MD b/spring-cloud/spring-cloud-hystrix/README.md similarity index 100% rename from spring-cloud/spring-cloud-hystrix/README.MD rename to spring-cloud/spring-cloud-hystrix/README.md From 60b28c767bde255195c10c779259b1527a4c6d33 Mon Sep 17 00:00:00 2001 From: nguyennamthai Date: Thu, 17 Sep 2020 09:24:28 +0700 Subject: [PATCH 173/263] BAEL-3569: Jersey RESTful Web Services with Spring Security OAuth2 (#9949) * BAEL-3569 Jersey REST service with Spring Security OAuth * BAEL-3569 Fix indentation spaces --- spring-5-security-oauth/pom.xml | 6 +- .../baeldung/jersey/JerseyApplication.java | 13 ++++ .../com/baeldung/jersey/JerseyResource.java | 30 ++++++++ .../java/com/baeldung/jersey/RestConfig.java | 11 +++ .../com/baeldung/jersey/SecurityConfig.java | 21 ++++++ .../resources/jersey-application.properties | 3 + .../jersey/JerseyResourceUnitTest.java | 72 +++++++++++++++++++ 7 files changed, 155 insertions(+), 1 deletion(-) create mode 100644 spring-5-security-oauth/src/main/java/com/baeldung/jersey/JerseyApplication.java create mode 100644 spring-5-security-oauth/src/main/java/com/baeldung/jersey/JerseyResource.java create mode 100644 spring-5-security-oauth/src/main/java/com/baeldung/jersey/RestConfig.java create mode 100644 spring-5-security-oauth/src/main/java/com/baeldung/jersey/SecurityConfig.java create mode 100644 spring-5-security-oauth/src/main/resources/jersey-application.properties create mode 100644 spring-5-security-oauth/src/test/java/com/baeldung/jersey/JerseyResourceUnitTest.java diff --git a/spring-5-security-oauth/pom.xml b/spring-5-security-oauth/pom.xml index 325aacea86..19aaa576c8 100644 --- a/spring-5-security-oauth/pom.xml +++ b/spring-5-security-oauth/pom.xml @@ -32,6 +32,10 @@ org.thymeleaf.extras thymeleaf-extras-springsecurity5 + + org.springframework.boot + spring-boot-starter-jersey + @@ -63,7 +67,7 @@ test - + com.baeldung.oauth2.SpringOAuthApplication diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/jersey/JerseyApplication.java b/spring-5-security-oauth/src/main/java/com/baeldung/jersey/JerseyApplication.java new file mode 100644 index 0000000000..6388c10bb3 --- /dev/null +++ b/spring-5-security-oauth/src/main/java/com/baeldung/jersey/JerseyApplication.java @@ -0,0 +1,13 @@ +package com.baeldung.jersey; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.PropertySource; + +@SpringBootApplication +@PropertySource("classpath:jersey-application.properties") +public class JerseyApplication { + public static void main(String[] args) { + SpringApplication.run(JerseyApplication.class, args); + } +} diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/jersey/JerseyResource.java b/spring-5-security-oauth/src/main/java/com/baeldung/jersey/JerseyResource.java new file mode 100644 index 0000000000..8968fefbf4 --- /dev/null +++ b/spring-5-security-oauth/src/main/java/com/baeldung/jersey/JerseyResource.java @@ -0,0 +1,30 @@ +package com.baeldung.jersey; + +import org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken; +import org.springframework.security.oauth2.core.OAuth2AuthenticatedPrincipal; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.SecurityContext; + +@Path("/") +public class JerseyResource { + @GET + @Path("login") + @Produces(MediaType.TEXT_HTML) + public String login() { + return "Log in with GitHub"; + } + + @GET + @Produces(MediaType.TEXT_PLAIN) + public String home(@Context SecurityContext securityContext) { + OAuth2AuthenticationToken authenticationToken = (OAuth2AuthenticationToken) securityContext.getUserPrincipal(); + OAuth2AuthenticatedPrincipal authenticatedPrincipal = authenticationToken.getPrincipal(); + String userName = authenticatedPrincipal.getAttribute("login"); + return "Hello " + userName; + } +} diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/jersey/RestConfig.java b/spring-5-security-oauth/src/main/java/com/baeldung/jersey/RestConfig.java new file mode 100644 index 0000000000..306677f261 --- /dev/null +++ b/spring-5-security-oauth/src/main/java/com/baeldung/jersey/RestConfig.java @@ -0,0 +1,11 @@ +package com.baeldung.jersey; + +import org.glassfish.jersey.server.ResourceConfig; +import org.springframework.stereotype.Component; + +@Component +public class RestConfig extends ResourceConfig { + public RestConfig() { + register(JerseyResource.class); + } +} diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/jersey/SecurityConfig.java b/spring-5-security-oauth/src/main/java/com/baeldung/jersey/SecurityConfig.java new file mode 100644 index 0000000000..5644856695 --- /dev/null +++ b/spring-5-security-oauth/src/main/java/com/baeldung/jersey/SecurityConfig.java @@ -0,0 +1,21 @@ +package com.baeldung.jersey; + +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; + +@Configuration +public class SecurityConfig extends WebSecurityConfigurerAdapter { + @Override + protected void configure(HttpSecurity http) throws Exception { + http + .authorizeRequests() + .antMatchers("/login") + .permitAll() + .anyRequest() + .authenticated() + .and() + .oauth2Login() + .loginPage("/login"); + } +} diff --git a/spring-5-security-oauth/src/main/resources/jersey-application.properties b/spring-5-security-oauth/src/main/resources/jersey-application.properties new file mode 100644 index 0000000000..516b24eb67 --- /dev/null +++ b/spring-5-security-oauth/src/main/resources/jersey-application.properties @@ -0,0 +1,3 @@ +server.port=8083 +spring.security.oauth2.client.registration.github.client-id= +spring.security.oauth2.client.registration.github.client-secret= \ No newline at end of file diff --git a/spring-5-security-oauth/src/test/java/com/baeldung/jersey/JerseyResourceUnitTest.java b/spring-5-security-oauth/src/test/java/com/baeldung/jersey/JerseyResourceUnitTest.java new file mode 100644 index 0000000000..e6cc3be213 --- /dev/null +++ b/spring-5-security-oauth/src/test/java/com/baeldung/jersey/JerseyResourceUnitTest.java @@ -0,0 +1,72 @@ +package com.baeldung.jersey; + +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.boot.test.web.client.TestRestTemplate; +import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; + +import java.net.URI; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; +import static org.springframework.http.MediaType.TEXT_HTML; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = RANDOM_PORT) +@TestPropertySource(properties = "spring.security.oauth2.client.registration.github.client-id:test-id") +public class JerseyResourceUnitTest { + @Autowired + private TestRestTemplate restTemplate; + + @LocalServerPort + private int port; + + private String basePath; + + @Before + public void setup() { + basePath = "http://localhost:" + port + "/"; + } + + @Test + public void whenUserIsUnauthenticated_thenTheyAreRedirectedToLoginPage() { + ResponseEntity response = restTemplate.getForEntity(basePath, Object.class); + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.FOUND); + assertThat(response.getBody()).isNull(); + + URI redirectLocation = response.getHeaders().getLocation(); + assertThat(redirectLocation).isNotNull(); + assertThat(redirectLocation.toString()).isEqualTo(basePath + "login"); + } + + @Test + public void whenUserAttemptsToLogin_thenAuthorizationPathIsReturned() { + ResponseEntity response = restTemplate.getForEntity(basePath + "login", String.class); + assertThat(response.getHeaders().getContentType()).isEqualTo(TEXT_HTML); + assertThat(response.getBody()).isEqualTo("Log in with GitHub"); + } + + @Test + public void whenUserAccessesAuthorizationEndpoint_thenTheyAresRedirectedToProvider() { + ResponseEntity response = restTemplate.getForEntity(basePath + "oauth2/authorization/github", String.class); + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.FOUND); + assertThat(response.getBody()).isNull(); + + URI redirectLocation = response.getHeaders().getLocation(); + assertThat(redirectLocation).isNotNull(); + assertThat(redirectLocation.getHost()).isEqualTo("github.com"); + assertThat(redirectLocation.getPath()).isEqualTo("/login/oauth/authorize"); + + String redirectionQuery = redirectLocation.getQuery(); + assertThat(redirectionQuery.contains("response_type=code")); + assertThat(redirectionQuery.contains("client_id=test-id")); + assertThat(redirectionQuery.contains("scope=read:user")); + } +} From 15ba49d0f40a7d498cee38829d8b9d97cda178a2 Mon Sep 17 00:00:00 2001 From: Reza Ebrahimpour Date: Thu, 17 Sep 2020 10:25:37 +0430 Subject: [PATCH 174/263] BAEL-4488 Convert class with main to UnitTest class --- .../cipher/AvailableCiphersUnitTest.java} | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) rename core-java-modules/core-java-security-2/src/{main/java/com/baeldung/cipher/AvailableCiphers.java => test/java/com/baeldung/cipher/AvailableCiphersUnitTest.java} (57%) diff --git a/core-java-modules/core-java-security-2/src/main/java/com/baeldung/cipher/AvailableCiphers.java b/core-java-modules/core-java-security-2/src/test/java/com/baeldung/cipher/AvailableCiphersUnitTest.java similarity index 57% rename from core-java-modules/core-java-security-2/src/main/java/com/baeldung/cipher/AvailableCiphers.java rename to core-java-modules/core-java-security-2/src/test/java/com/baeldung/cipher/AvailableCiphersUnitTest.java index f73433ffd2..48aaa5fb67 100644 --- a/core-java-modules/core-java-security-2/src/main/java/com/baeldung/cipher/AvailableCiphers.java +++ b/core-java-modules/core-java-security-2/src/test/java/com/baeldung/cipher/AvailableCiphersUnitTest.java @@ -1,32 +1,35 @@ package com.baeldung.cipher; +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.security.Provider; import java.security.Security; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; -public class AvailableCiphers { - public static void main(String[] args) { - printAllCiphers(); - printCompatibleCiphers(); - } +public class AvailableCiphersUnitTest { + private final Logger logger = LoggerFactory.getLogger(AvailableCiphersUnitTest.class); - private static void printAllCiphers() { + @Test + public void whenGetServices_thenGetAllCipherAlgorithms() { for (Provider provider : Security.getProviders()) { for (Provider.Service service : provider.getServices()) { - System.out.println(service.getAlgorithm()); + logger.info(service.getAlgorithm()); } } } - private static void printCompatibleCiphers() { + @Test + public void whenGetServicesWithFilter_thenGetAllCompatibleCipherAlgorithms() { List algorithms = Arrays.stream(Security.getProviders()) .flatMap(provider -> provider.getServices().stream()) .filter(service -> "Cipher".equals(service.getType())) .map(Provider.Service::getAlgorithm) .collect(Collectors.toList()); - algorithms.forEach(System.out::println); + algorithms.forEach(logger::info); } } From 0d3dafd25cce4ce11e248fff89c540685ebcf9bc Mon Sep 17 00:00:00 2001 From: Adrian Maghear Date: Thu, 17 Sep 2020 08:37:41 +0200 Subject: [PATCH 175/263] [BAEL-4471] reduce number of parallel tests --- quarkus/pom.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/quarkus/pom.xml b/quarkus/pom.xml index 67356abdef..7fdf1557fb 100644 --- a/quarkus/pom.xml +++ b/quarkus/pom.xml @@ -99,6 +99,8 @@ maven-surefire-plugin ${surefire-plugin.version} + 1 + true org.jboss.logmanager.LogManager From 6cbf1e87c5282415780c95fdb82ca4b8f48ed857 Mon Sep 17 00:00:00 2001 From: Rutuja Joshi <67615932+rutujavjoshi@users.noreply.github.com> Date: Thu, 17 Sep 2020 22:02:51 +0530 Subject: [PATCH 176/263] BAEL-4201 - Initial Commit (#9957) * BAEL-4201 - Initial commit * BAEL-4201 - Initial Commit * Update UserAccountController.java removed the additional brackets * Update UserAccountValidationTest.java Updated the tests * Bael - 4201 - recommit for github issue fix For 'This commit does not belong to any branch on this repository' - delete and recommitting controller * Bael - 4201 - recommit for github issue fix For 'This commit does not belong to any branch on this repository' - delete and recommitting test * Bael - 4201 - add for github issue fix For 'This commit does not belong to any branch on this repository' - adding controller again * Bael - 4201 - add for github issue fix For 'This commit does not belong to any branch on this repository' - adding test again * BAEL-4201: Initial Commit * Update UserAccountUnitTest.java * BAEL-4201: updated to fix the commit issue * BAEL-4201 - temporary deleting Deleting to fix branch issue * BAEL-4201 - commiting test again * BAEL-4201 Fixing build issues * BAEL-4201 Github commit issue * BAEL-4201 Github commit issue - webapp folder * BAEL-4201 - commiting test after view upload * Bael- 4201 ThymeLeaf related issues * Bael- 4201 ThymeLeaf related issues * Bael- 4201 ThymeLeaf related issues * Bael- 4201 ThymeLeaf related issues - added html * Bael- 4201 ThymeLeaf issue ; updated suffix- html * Bael - 4201 white label issue * Bael - 4201 white label issue * BAEL-4201 : moving html to templates * BAEL-4201 - moving to templates * BAEL-4201 - moving to templates * BAEL-4201 - review related updates * BAEL-4201 - review related updates * BAEL-4201 - review related updates * BAEL-4201 - review related updates * BAEL-4201 - review related updates * BAEL-4201 - review related updates * BAEL-4201 - review related updates * BAEL-4201 - added the spring-boot-starter-validation dependency --- spring-boot-modules/spring-boot-mvc-3/pom.xml | 6 +- .../springvalidation/ServletInitializer.java | 12 +++ .../SpringValidationApplication.java | 13 +++ .../controller/UserAccountController.java | 44 ++++++++++ .../springvalidation/domain/UserAccount.java | 80 +++++++++++++++++++ .../springvalidation/domain/UserAddress.java | 17 ++++ .../interfaces/AdvanceInfo.java | 6 ++ .../interfaces/BasicInfo.java | 6 ++ .../src/main/resources/application.properties | 2 + .../src/main/resources/templates/error.html | 10 +++ .../src/main/resources/templates/success.html | 10 +++ .../springvalidation/UserAccountUnitTest.java | 57 +++++++++++++ 12 files changed, 262 insertions(+), 1 deletion(-) create mode 100644 spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/springvalidation/ServletInitializer.java create mode 100644 spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/springvalidation/SpringValidationApplication.java create mode 100644 spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/springvalidation/controller/UserAccountController.java create mode 100644 spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/springvalidation/domain/UserAccount.java create mode 100644 spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/springvalidation/domain/UserAddress.java create mode 100644 spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/springvalidation/interfaces/AdvanceInfo.java create mode 100644 spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/springvalidation/interfaces/BasicInfo.java create mode 100644 spring-boot-modules/spring-boot-mvc-3/src/main/resources/application.properties create mode 100644 spring-boot-modules/spring-boot-mvc-3/src/main/resources/templates/error.html create mode 100644 spring-boot-modules/spring-boot-mvc-3/src/main/resources/templates/success.html create mode 100644 spring-boot-modules/spring-boot-mvc-3/src/test/java/com/baeldung/springvalidation/UserAccountUnitTest.java diff --git a/spring-boot-modules/spring-boot-mvc-3/pom.xml b/spring-boot-modules/spring-boot-mvc-3/pom.xml index 31c43461d2..1290b0432f 100644 --- a/spring-boot-modules/spring-boot-mvc-3/pom.xml +++ b/spring-boot-modules/spring-boot-mvc-3/pom.xml @@ -22,6 +22,10 @@ org.springframework.boot spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-validation + org.springframework.boot spring-boot-starter-thymeleaf @@ -37,4 +41,4 @@ 2.7 - \ No newline at end of file + diff --git a/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/springvalidation/ServletInitializer.java b/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/springvalidation/ServletInitializer.java new file mode 100644 index 0000000000..f365582999 --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/springvalidation/ServletInitializer.java @@ -0,0 +1,12 @@ +package com.baeldung.springvalidation; + +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; + +public class ServletInitializer extends SpringBootServletInitializer { + + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { + return application.sources(SpringValidationApplication.class); + } +} diff --git a/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/springvalidation/SpringValidationApplication.java b/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/springvalidation/SpringValidationApplication.java new file mode 100644 index 0000000000..ccfe990ce7 --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/springvalidation/SpringValidationApplication.java @@ -0,0 +1,13 @@ +package com.baeldung.springvalidation; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpringValidationApplication { + + public static void main(String[] args) { + SpringApplication.run(SpringValidationApplication.class, args); + } + +} diff --git a/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/springvalidation/controller/UserAccountController.java b/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/springvalidation/controller/UserAccountController.java new file mode 100644 index 0000000000..48de7b35d0 --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/springvalidation/controller/UserAccountController.java @@ -0,0 +1,44 @@ +package com.baeldung.springvalidation.controller; + +import javax.validation.Valid; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.ui.ModelMap; +import org.springframework.validation.BindingResult; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +import com.baeldung.springvalidation.domain.UserAccount; +import com.baeldung.springvalidation.interfaces.BasicInfo; + +@Controller +public class UserAccountController { + + @GetMapping("/getUserForm") + public String showUserForm(Model theModel) { + UserAccount theUser = new UserAccount(); + theModel.addAttribute("useraccount", theUser); + return "userHome"; + } + + @RequestMapping(value = "/saveBasicInfo", method = RequestMethod.POST) + public String saveBasicInfo(@Valid @ModelAttribute("useraccount") UserAccount useraccount, BindingResult result, ModelMap model) { + if (result.hasErrors()) { + return "error"; + } + return "success"; + } + + @RequestMapping(value = "/saveBasicInfoStep1", method = RequestMethod.POST) + public String saveBasicInfoStep1(@Validated(BasicInfo.class) @ModelAttribute("useraccount") UserAccount useraccount, BindingResult result, ModelMap model) { + if (result.hasErrors()) { + return "error"; + } + return "success"; + } + +} diff --git a/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/springvalidation/domain/UserAccount.java b/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/springvalidation/domain/UserAccount.java new file mode 100644 index 0000000000..fd5437fe5e --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/springvalidation/domain/UserAccount.java @@ -0,0 +1,80 @@ +package com.baeldung.springvalidation.domain; + +import javax.validation.Valid; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +import com.baeldung.springvalidation.interfaces.AdvanceInfo; +import com.baeldung.springvalidation.interfaces.BasicInfo; + +public class UserAccount { + + @NotNull(groups = BasicInfo.class) + @Size(min = 4, max = 15, groups = BasicInfo.class) + private String password; + + @NotBlank(groups = BasicInfo.class) + private String name; + + @Min(value = 18, message = "Age should not be less than 18", groups = AdvanceInfo.class) + private int age; + + @NotBlank(groups = AdvanceInfo.class) + private String phone; + + @Valid + @NotNull(groups = AdvanceInfo.class) + private UserAddress useraddress; + + public UserAddress getUseraddress() { + return useraddress; + } + + public void setUseraddress(UserAddress useraddress) { + this.useraddress = useraddress; + } + + public UserAccount() { + + } + + public UserAccount(String email, String password, String name, int age) { + this.password = password; + this.name = name; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + +} diff --git a/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/springvalidation/domain/UserAddress.java b/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/springvalidation/domain/UserAddress.java new file mode 100644 index 0000000000..9aa9656eed --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/springvalidation/domain/UserAddress.java @@ -0,0 +1,17 @@ +package com.baeldung.springvalidation.domain; + +import javax.validation.constraints.NotBlank; +public class UserAddress { + + @NotBlank + private String countryCode; + + public String getCountryCode() { + return countryCode; + } + + public void setCountryCode(String countryCode) { + this.countryCode = countryCode; + } + +} diff --git a/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/springvalidation/interfaces/AdvanceInfo.java b/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/springvalidation/interfaces/AdvanceInfo.java new file mode 100644 index 0000000000..dd0c7c69d0 --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/springvalidation/interfaces/AdvanceInfo.java @@ -0,0 +1,6 @@ +package com.baeldung.springvalidation.interfaces; + +public interface AdvanceInfo { + // validation group marker interface + +} diff --git a/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/springvalidation/interfaces/BasicInfo.java b/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/springvalidation/interfaces/BasicInfo.java new file mode 100644 index 0000000000..95d2b5e6a2 --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/springvalidation/interfaces/BasicInfo.java @@ -0,0 +1,6 @@ +package com.baeldung.springvalidation.interfaces; + +public interface BasicInfo { + // validation group marker interface + +} diff --git a/spring-boot-modules/spring-boot-mvc-3/src/main/resources/application.properties b/spring-boot-modules/spring-boot-mvc-3/src/main/resources/application.properties new file mode 100644 index 0000000000..89390eaace --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc-3/src/main/resources/application.properties @@ -0,0 +1,2 @@ +spring.mvc.view.prefix=/WEB-INF/views/ +spring.mvc.view.suffix=.html diff --git a/spring-boot-modules/spring-boot-mvc-3/src/main/resources/templates/error.html b/spring-boot-modules/spring-boot-mvc-3/src/main/resources/templates/error.html new file mode 100644 index 0000000000..341cc73603 --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc-3/src/main/resources/templates/error.html @@ -0,0 +1,10 @@ + + + +SpringValidation + + + +

Error!!!

+ + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-mvc-3/src/main/resources/templates/success.html b/spring-boot-modules/spring-boot-mvc-3/src/main/resources/templates/success.html new file mode 100644 index 0000000000..b422152153 --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc-3/src/main/resources/templates/success.html @@ -0,0 +1,10 @@ + + + +SpringValidation + + + +

SUCCESS!!!

+ + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-mvc-3/src/test/java/com/baeldung/springvalidation/UserAccountUnitTest.java b/spring-boot-modules/spring-boot-mvc-3/src/test/java/com/baeldung/springvalidation/UserAccountUnitTest.java new file mode 100644 index 0000000000..507321bf8e --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc-3/src/test/java/com/baeldung/springvalidation/UserAccountUnitTest.java @@ -0,0 +1,57 @@ +package com.baeldung.springvalidation; + +import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view; + +import org.junit.jupiter.api.Test; +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.web.servlet.MockMvc; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; + +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@AutoConfigureMockMvc +public class UserAccountUnitTest { + + @Autowired + private MockMvc mockMvc; + + @Test + public void givenSaveBasicInfo_whenCorrectInput_thenSuccess() throws Exception { + this.mockMvc.perform(MockMvcRequestBuilders.post("/saveBasicInfo") + .accept(MediaType.TEXT_HTML) + .param("name", "test123") + .param("password", "pass")) + .andExpect(view().name("success")) + .andExpect(status().isOk()) + .andDo(print()); + } + + @Test + public void givenSaveBasicInfoStep1_whenCorrectInput_thenSuccess() throws Exception { + this.mockMvc.perform(MockMvcRequestBuilders.post("/saveBasicInfoStep1") + .accept(MediaType.TEXT_HTML) + .param("name", "test123") + .param("password", "pass")) + .andExpect(view().name("success")) + .andExpect(status().isOk()) + .andDo(print()); + } + + @Test + public void givenSaveBasicInfoStep1_whenIncorrectInput_thenError() throws Exception { + this.mockMvc.perform(MockMvcRequestBuilders.post("/saveBasicInfoStep1") + .accept(MediaType.TEXT_HTML)) + // .param("name", "test123") + // .param("password", "pass")) + .andExpect(model().errorCount(2)) + // .andExpect(view().name("error")) + .andExpect(status().isOk()) + .andDo(print()); + } + +} From 4c39bcd6be91c5da7901d54e0cb4d5227d54da19 Mon Sep 17 00:00:00 2001 From: kwoyke Date: Thu, 17 Sep 2020 19:57:53 +0200 Subject: [PATCH 177/263] BAEL-4610: Add {noop} example security config (#10046) --- ...InMemoryNoOpAuthWebSecurityConfigurer.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 spring-5-security/src/main/java/com/baeldung/inmemory/InMemoryNoOpAuthWebSecurityConfigurer.java diff --git a/spring-5-security/src/main/java/com/baeldung/inmemory/InMemoryNoOpAuthWebSecurityConfigurer.java b/spring-5-security/src/main/java/com/baeldung/inmemory/InMemoryNoOpAuthWebSecurityConfigurer.java new file mode 100644 index 0000000000..4b6494f666 --- /dev/null +++ b/spring-5-security/src/main/java/com/baeldung/inmemory/InMemoryNoOpAuthWebSecurityConfigurer.java @@ -0,0 +1,29 @@ +package com.baeldung.inmemory; + +import org.springframework.context.annotation.Configuration; +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; + +//@Configuration +public class InMemoryNoOpAuthWebSecurityConfigurer extends WebSecurityConfigurerAdapter { + + @Override + protected void configure(AuthenticationManagerBuilder auth) throws Exception { + auth.inMemoryAuthentication() + .withUser("spring") + .password("{noop}secret") + .roles("USER"); + } + + @Override + protected void configure(HttpSecurity http) throws Exception { + http.authorizeRequests() + .antMatchers("/private/**") + .authenticated() + .antMatchers("/public/**") + .permitAll() + .and() + .httpBasic(); + } +} From f6adcd0cb3260807a55341744fb87e547432900a Mon Sep 17 00:00:00 2001 From: Jonathan Cook Date: Thu, 17 Sep 2020 23:22:49 +0200 Subject: [PATCH 178/263] BAEL-4437 - System Rules (#10047) Co-authored-by: Jonathan Cook --- testing-modules/pom.xml | 3 +- testing-modules/testing-libraries-2/pom.xml | 43 ++++++++++++++++++ ...ClearSystemPropertiesWithRuleUnitTest.java | 19 ++++++++ .../ProvidesSystemPropertyUnitTest.java | 26 +++++++++++ ...rovidesSystemPropertyWithRuleUnitTest.java | 44 +++++++++++++++++++ .../systemrules/SystemErrPrintlnUnitTest.java | 24 ++++++++++ .../SystemErrPrintlnWithRuleUnitTest.java | 25 +++++++++++ .../systemrules/SystemExitUnitTest.java | 23 ++++++++++ .../SystemExitWithRuleUnitTest.java | 22 ++++++++++ .../systemrules/SystemInUnitTest.java | 27 ++++++++++++ .../systemrules/SystemInWithRuleUnitTest.java | 31 +++++++++++++ .../src/test/resources/test.properties | 2 + 12 files changed, 288 insertions(+), 1 deletion(-) create mode 100644 testing-modules/testing-libraries-2/pom.xml create mode 100644 testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/ClearSystemPropertiesWithRuleUnitTest.java create mode 100644 testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/ProvidesSystemPropertyUnitTest.java create mode 100644 testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/ProvidesSystemPropertyWithRuleUnitTest.java create mode 100644 testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/SystemErrPrintlnUnitTest.java create mode 100644 testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/SystemErrPrintlnWithRuleUnitTest.java create mode 100644 testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/SystemExitUnitTest.java create mode 100644 testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/SystemExitWithRuleUnitTest.java create mode 100644 testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/SystemInUnitTest.java create mode 100644 testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/SystemInWithRuleUnitTest.java create mode 100644 testing-modules/testing-libraries-2/src/test/resources/test.properties diff --git a/testing-modules/pom.xml b/testing-modules/pom.xml index f1d30cd7a1..0416423239 100644 --- a/testing-modules/pom.xml +++ b/testing-modules/pom.xml @@ -41,7 +41,8 @@ junit-5-advanced xmlunit-2 junit-4 - testing-libraries + testing-libraries + testing-libraries-2 powermock diff --git a/testing-modules/testing-libraries-2/pom.xml b/testing-modules/testing-libraries-2/pom.xml new file mode 100644 index 0000000000..282583c882 --- /dev/null +++ b/testing-modules/testing-libraries-2/pom.xml @@ -0,0 +1,43 @@ + + 4.0.0 + testing-libraries-2 + testing-libraries-2 + + + com.baeldung + testing-modules + 1.0.0-SNAPSHOT + + + + + com.github.stefanbirkner + system-rules + ${system-rules.version} + test + + + com.github.stefanbirkner + system-lambda + ${system-lambda.version} + test + + + + + testing-libraries + + + src/test/resources + true + + + + + + 1.19.0 + 1.0.0 + + diff --git a/testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/ClearSystemPropertiesWithRuleUnitTest.java b/testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/ClearSystemPropertiesWithRuleUnitTest.java new file mode 100644 index 0000000000..699b40bad9 --- /dev/null +++ b/testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/ClearSystemPropertiesWithRuleUnitTest.java @@ -0,0 +1,19 @@ +package com.baeldung.systemrules; + +import static org.junit.Assert.assertNull; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.contrib.java.lang.system.ClearSystemProperties; + +public class ClearSystemPropertiesWithRuleUnitTest { + + @Rule + public final ClearSystemProperties userNameIsClearedRule = new ClearSystemProperties("user.name"); + + @Test + public void givenClearUsernameProperty_whenGetUserName_thenNull() { + assertNull(System.getProperty("user.name")); + } + +} diff --git a/testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/ProvidesSystemPropertyUnitTest.java b/testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/ProvidesSystemPropertyUnitTest.java new file mode 100644 index 0000000000..361a338508 --- /dev/null +++ b/testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/ProvidesSystemPropertyUnitTest.java @@ -0,0 +1,26 @@ +package com.baeldung.systemrules; + +import static com.github.stefanbirkner.systemlambda.SystemLambda.restoreSystemProperties; +import static org.junit.Assert.assertEquals; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +class ProvidesSystemPropertyUnitTest { + + @BeforeAll + static void setUpBeforeClass() throws Exception { + System.setProperty("log_dir", "/tmp/baeldung/logs"); + } + + @Test + void givenSetSystemProperty_whenGetLogDir_thenLogDirIsProvidedSuccessfully() throws Exception { + restoreSystemProperties(() -> { + System.setProperty("log_dir", "test/resources"); + assertEquals("log_dir should be provided", "test/resources", System.getProperty("log_dir")); + }); + + assertEquals("log_dir should be provided", "/tmp/baeldung/logs", System.getProperty("log_dir")); + } + +} diff --git a/testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/ProvidesSystemPropertyWithRuleUnitTest.java b/testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/ProvidesSystemPropertyWithRuleUnitTest.java new file mode 100644 index 0000000000..3a90592a0d --- /dev/null +++ b/testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/ProvidesSystemPropertyWithRuleUnitTest.java @@ -0,0 +1,44 @@ +package com.baeldung.systemrules; + +import static org.junit.Assert.assertEquals; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Rule; +import org.junit.Test; +import org.junit.contrib.java.lang.system.ProvideSystemProperty; + +public class ProvidesSystemPropertyWithRuleUnitTest { + + @Rule + public final ProvideSystemProperty providesSystemPropertyRule = new ProvideSystemProperty("log_dir", "test/resources").and("another_property", "another_value"); + + @Rule + public final ProvideSystemProperty providesSystemPropertyFromFileRule = ProvideSystemProperty.fromResource("/test.properties"); + + @BeforeClass + public static void setUpBeforeClass() { + setLogs(); + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + System.out.println(System.getProperty("log_dir")); + } + + @Test + public void givenProvideSystemProperty_whenGetLogDir_thenLogDirIsProvidedSuccessfully() { + assertEquals("log_dir should be provided", "test/resources", System.getProperty("log_dir")); + } + + @Test + public void givenProvideSystemPropertyFromFile_whenGetName_thenNameIsProvidedSuccessfully() { + assertEquals("name should be provided", "baeldung", System.getProperty("name")); + assertEquals("version should be provided", "1.0", System.getProperty("version")); + } + + private static void setLogs() { + System.setProperty("log_dir", "/tmp/baeldung/logs"); + } + +} diff --git a/testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/SystemErrPrintlnUnitTest.java b/testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/SystemErrPrintlnUnitTest.java new file mode 100644 index 0000000000..3345ddae8a --- /dev/null +++ b/testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/SystemErrPrintlnUnitTest.java @@ -0,0 +1,24 @@ +package com.baeldung.systemrules; + +import static com.github.stefanbirkner.systemlambda.SystemLambda.tapSystemErr; + +import org.junit.Assert; +import org.junit.jupiter.api.Test; + +class SystemErrPrintlnUnitTest { + + @Test + void givenTapSystemErr_whenInvokePrintln_thenOutputIsReturnedSuccessfully() throws Exception { + + String text = tapSystemErr(() -> { + printError("An error occurred Baeldung Readers!!"); + }); + + Assert.assertEquals("An error occurred Baeldung Readers!!", text.trim()); + } + + private void printError(String output) { + System.err.println(output); + } + +} diff --git a/testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/SystemErrPrintlnWithRuleUnitTest.java b/testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/SystemErrPrintlnWithRuleUnitTest.java new file mode 100644 index 0000000000..7994f91063 --- /dev/null +++ b/testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/SystemErrPrintlnWithRuleUnitTest.java @@ -0,0 +1,25 @@ +package com.baeldung.systemrules; + +import org.junit.Assert; +import org.junit.Rule; +import org.junit.Test; +import org.junit.contrib.java.lang.system.SystemErrRule; + +public class SystemErrPrintlnWithRuleUnitTest { + + @Rule + public final SystemErrRule systemErrRule = new SystemErrRule().enableLog(); + + @Test + public void givenSystemErrRule_whenInvokePrintln_thenLogSuccess() { + printError("An Error occurred Baeldung Readers!!"); + + Assert.assertEquals("An Error occurred Baeldung Readers!!", systemErrRule.getLog() + .trim()); + } + + private void printError(String output) { + System.err.println(output); + } + +} diff --git a/testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/SystemExitUnitTest.java b/testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/SystemExitUnitTest.java new file mode 100644 index 0000000000..1e2548e714 --- /dev/null +++ b/testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/SystemExitUnitTest.java @@ -0,0 +1,23 @@ +package com.baeldung.systemrules; + +import static org.junit.Assert.assertEquals; + +import static com.github.stefanbirkner.systemlambda.SystemLambda.catchSystemExit; + +import org.junit.jupiter.api.Test; + +class SystemExitUnitTest { + + @Test + void givenCatchSystemExit_whenAppCallsSystemExit_thenStatusIsReturnedSuccessfully() throws Exception { + int statusCode = catchSystemExit(() -> { + exit(); + }); + assertEquals("status code should be 1:", 1, statusCode); + } + + private void exit() { + System.exit(1); + } + +} diff --git a/testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/SystemExitWithRuleUnitTest.java b/testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/SystemExitWithRuleUnitTest.java new file mode 100644 index 0000000000..471aab1989 --- /dev/null +++ b/testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/SystemExitWithRuleUnitTest.java @@ -0,0 +1,22 @@ +package com.baeldung.systemrules; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.contrib.java.lang.system.ExpectedSystemExit; + +public class SystemExitWithRuleUnitTest { + + @Rule + public final ExpectedSystemExit exitRule = ExpectedSystemExit.none(); + + @Test + public void givenSystemExitRule_whenAppCallsSystemExit_thenExitRuleWorkssAsExpected() { + exitRule.expectSystemExitWithStatus(1); + exit(); + } + + private void exit() { + System.exit(1); + } + +} diff --git a/testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/SystemInUnitTest.java b/testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/SystemInUnitTest.java new file mode 100644 index 0000000000..96badb59d4 --- /dev/null +++ b/testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/SystemInUnitTest.java @@ -0,0 +1,27 @@ +package com.baeldung.systemrules; + +import static com.github.stefanbirkner.systemlambda.SystemLambda.withTextFromSystemIn; +import static org.junit.Assert.assertEquals; + +import java.util.Scanner; + +import org.junit.jupiter.api.Test; + +class SystemInUnitTest { + + @Test + void givenTwoNames_whenSystemInMock_thenNamesJoinedTogether() throws Exception { + withTextFromSystemIn("Jonathan", "Cook").execute(() -> { + assertEquals("Names should be concatenated", "Jonathan Cook", getFullname()); + }); + } + + private String getFullname() { + try (Scanner scanner = new Scanner(System.in)) { + String firstName = scanner.next(); + String surname = scanner.next(); + return String.join(" ", firstName, surname); + } + } + +} diff --git a/testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/SystemInWithRuleUnitTest.java b/testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/SystemInWithRuleUnitTest.java new file mode 100644 index 0000000000..5730e2f592 --- /dev/null +++ b/testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/SystemInWithRuleUnitTest.java @@ -0,0 +1,31 @@ +package com.baeldung.systemrules; + +import static org.junit.Assert.assertEquals; + +import java.util.Scanner; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.contrib.java.lang.system.TextFromStandardInputStream; +import static org.junit.contrib.java.lang.system.TextFromStandardInputStream.emptyStandardInputStream; + +public class SystemInWithRuleUnitTest { + + @Rule + public final TextFromStandardInputStream systemInMock = emptyStandardInputStream(); + + @Test + public void givenTwoNames_whenSystemInMock_thenNamesJoinedTogether() { + systemInMock.provideLines("Jonathan", "Cook"); + assertEquals("Names should be concatenated", "Jonathan Cook", getFullname()); + } + + private String getFullname() { + try (Scanner scanner = new Scanner(System.in)) { + String firstName = scanner.next(); + String surname = scanner.next(); + return String.join(" ", firstName, surname); + } + } + +} diff --git a/testing-modules/testing-libraries-2/src/test/resources/test.properties b/testing-modules/testing-libraries-2/src/test/resources/test.properties new file mode 100644 index 0000000000..144847cdb0 --- /dev/null +++ b/testing-modules/testing-libraries-2/src/test/resources/test.properties @@ -0,0 +1,2 @@ +name=baeldung +version=1.0 \ No newline at end of file From 7c482a8e6f53cead43e8c6addd794159d2bb9f0b Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Fri, 18 Sep 2020 22:40:10 +0200 Subject: [PATCH 179/263] JAVA-2975: Clean up the pom.xml in spring-boot-exceptions --- .../spring-boot-exceptions/pom.xml | 72 +------------------ 1 file changed, 1 insertion(+), 71 deletions(-) diff --git a/spring-boot-modules/spring-boot-exceptions/pom.xml b/spring-boot-modules/spring-boot-exceptions/pom.xml index 4b9d787b61..1bfe8e6751 100644 --- a/spring-boot-modules/spring-boot-exceptions/pom.xml +++ b/spring-boot-modules/spring-boot-exceptions/pom.xml @@ -14,15 +14,7 @@ jar spring-boot-exceptions - Demo project for working with Spring Boot exceptions - - - - org.springframework.boot - spring-boot-starter - ${spring-boot.version} - - + Demo project for working with Spring Boot exceptions spring-boot-exceptions @@ -32,68 +24,6 @@ true - - - - - org.apache.maven.plugins - maven-war-plugin - - - - org.apache.maven.plugins - maven-resources-plugin - - - @ - - false - - - - - - - autoconfiguration - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration-test - - test - - - - **/*LiveTest.java - **/*IntegrationTest.java - **/*IntTest.java - - - **/AutoconfigurationTest.java - - - - - - - json - - - - - - - - - - - com.baeldung.intro.App - 2.2.3.RELEASE - From bca4b6bca5536884a4586589daeea587b61481dd Mon Sep 17 00:00:00 2001 From: mikr Date: Sat, 19 Sep 2020 13:20:07 +0200 Subject: [PATCH 180/263] Java-82 Update pom with reference to JAVA-2824 for failing tests --- pom.xml | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/pom.xml b/pom.xml index 6d5c810784..c460c080d8 100644 --- a/pom.xml +++ b/pom.xml @@ -1374,23 +1374,23 @@ core-java-modules/core-java-9 core-java-modules/core-java-9-improvements - - + + core-java-modules/core-java-9-streams core-java-modules/core-java-10 - - - - + + + + core-java-modules/core-java-collections-set - - - + + + core-java-modules/core-java-jpms - - + + core-java-modules/multimodulemavenproject - + @@ -1419,23 +1419,23 @@ core-java-modules/core-java-9 core-java-modules/core-java-9-improvements - - + + core-java-modules/core-java-9-streams core-java-modules/core-java-10 - - - - + + + + core-java-modules/core-java-collections-set - - - + + + core-java-modules/core-java-jpms - - + + core-java-modules/multimodulemavenproject - + From 23e39f4244414b15defde5bfc620383101187241 Mon Sep 17 00:00:00 2001 From: mikr Date: Sat, 19 Sep 2020 13:51:05 +0200 Subject: [PATCH 181/263] Java-82 Fix test --- apache-libraries/pom.xml | 5 +++++ jackson-modules/jackson-custom-conversions/pom.xml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/apache-libraries/pom.xml b/apache-libraries/pom.xml index 9f800f1e0b..15404676cc 100644 --- a/apache-libraries/pom.xml +++ b/apache-libraries/pom.xml @@ -129,6 +129,11 @@ zookeeper ${zookeeper.version}
+ + com.fasterxml.jackson.core + jackson-core + ${jackson.version} + com.fasterxml.jackson.core jackson-databind diff --git a/jackson-modules/jackson-custom-conversions/pom.xml b/jackson-modules/jackson-custom-conversions/pom.xml index 78894bb403..f58b25781c 100644 --- a/jackson-modules/jackson-custom-conversions/pom.xml +++ b/jackson-modules/jackson-custom-conversions/pom.xml @@ -26,7 +26,7 @@ com.fasterxml.jackson.core jackson-core - 2.10.1 + ${jackson.version} From 8971f2dca29f863c3929aa69bd1f8b3bff5df20e Mon Sep 17 00:00:00 2001 From: Azhwani <13301425+azhwani@users.noreply.github.com> Date: Sat, 19 Sep 2020 14:52:49 +0100 Subject: [PATCH 182/263] BAEL-4327: JSON Parameters with Spring MVC (#10036) * first commit * update commit Co-authored-by: azhwani <> --- .../jsonparams/config/JsonParamsConfig.java | 36 ++++++++++ .../jsonparams/config/JsonParamsInit.java | 29 ++++++++ .../controller/ProductController.java | 57 +++++++++++++++ .../baeldung/jsonparams/model/Product.java | 37 ++++++++++ .../propertyeditor/ProductEditor.java | 34 +++++++++ .../jsonparams/JsonParamsIntegrationTest.java | 71 +++++++++++++++++++ 6 files changed, 264 insertions(+) create mode 100644 spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/config/JsonParamsConfig.java create mode 100644 spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/config/JsonParamsInit.java create mode 100644 spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/controller/ProductController.java create mode 100644 spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/model/Product.java create mode 100644 spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/propertyeditor/ProductEditor.java create mode 100644 spring-mvc-basics-4/src/test/java/com/baeldung/jsonparams/JsonParamsIntegrationTest.java diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/config/JsonParamsConfig.java b/spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/config/JsonParamsConfig.java new file mode 100644 index 0000000000..f2049554ab --- /dev/null +++ b/spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/config/JsonParamsConfig.java @@ -0,0 +1,36 @@ +package com.baeldung.jsonparams.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.ViewResolver; +import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import org.springframework.web.servlet.view.InternalResourceViewResolver; + +import com.fasterxml.jackson.databind.ObjectMapper; + +@Configuration +@EnableWebMvc +@ComponentScan(basePackages = { "com.baeldung.jsonparams" }) +public class JsonParamsConfig implements WebMvcConfigurer { + @Override + public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) { + configurer.enable(); + } + + @Bean + public ViewResolver viewResolver() { + InternalResourceViewResolver bean = new InternalResourceViewResolver(); + bean.setPrefix("/WEB-INF/"); + bean.setSuffix(".jsp"); + return bean; + } + + @Bean + public ObjectMapper objectMapper() { + return new ObjectMapper(); + } + +} diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/config/JsonParamsInit.java b/spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/config/JsonParamsInit.java new file mode 100644 index 0000000000..6db2a92350 --- /dev/null +++ b/spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/config/JsonParamsInit.java @@ -0,0 +1,29 @@ +package com.baeldung.jsonparams.config; + +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.ServletRegistration; + +import org.springframework.web.context.ContextLoaderListener; +import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; +import org.springframework.web.servlet.DispatcherServlet; + +public class JsonParamsInit // implements WebApplicationInitializer +{ + + //uncomment to run the product controller example + //@Override + public void onStartup(ServletContext sc) throws ServletException { + AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext(); + root.register(JsonParamsConfig.class); + root.setServletContext(sc); + sc.addListener(new ContextLoaderListener(root)); + + DispatcherServlet dv = new DispatcherServlet(root); + + ServletRegistration.Dynamic appServlet = sc.addServlet("jsonparams-mvc", dv); + appServlet.setLoadOnStartup(1); + appServlet.addMapping("/"); + } + +} diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/controller/ProductController.java b/spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/controller/ProductController.java new file mode 100644 index 0000000000..e4e2ce085d --- /dev/null +++ b/spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/controller/ProductController.java @@ -0,0 +1,57 @@ +package com.baeldung.jsonparams.controller; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.WebDataBinder; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.InitBinder; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; + +import com.baeldung.jsonparams.model.Product; +import com.baeldung.jsonparams.propertyeditor.ProductEditor; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +@Controller +@RequestMapping("/products") +public class ProductController { + + private ObjectMapper objectMapper; + + @Autowired + public void setObjectMapper(ObjectMapper objectMapper) { + this.objectMapper = objectMapper; + } + + @InitBinder + public void initBinder(WebDataBinder binder) { + binder.registerCustomEditor(Product.class, new ProductEditor(objectMapper)); + } + + @PostMapping("/create") + @ResponseBody + public Product createProduct(@RequestBody Product product) { + // custom logic + return product; + } + + @GetMapping("/get") + @ResponseBody + public Product getProduct(@RequestParam String product) throws JsonMappingException, JsonProcessingException { + final Product prod = objectMapper.readValue(product, Product.class); + return prod; + } + + @GetMapping("/get2") + @ResponseBody + public Product get2Product(@RequestParam Product product) { + // custom logic + return product; + } + +} diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/model/Product.java b/spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/model/Product.java new file mode 100644 index 0000000000..b0baf0aa57 --- /dev/null +++ b/spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/model/Product.java @@ -0,0 +1,37 @@ +package com.baeldung.jsonparams.model; + +public class Product { + + private int id; + private String name; + private double price; + + public Product() { + + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String nom) { + this.name = nom; + } + + public double getPrice() { + return price; + } + + public void setPrice(double price) { + this.price = price; + } + +} diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/propertyeditor/ProductEditor.java b/spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/propertyeditor/ProductEditor.java new file mode 100644 index 0000000000..11766118cd --- /dev/null +++ b/spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/propertyeditor/ProductEditor.java @@ -0,0 +1,34 @@ +package com.baeldung.jsonparams.propertyeditor; + +import java.beans.PropertyEditorSupport; + +import org.springframework.util.StringUtils; + +import com.baeldung.jsonparams.model.Product; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class ProductEditor extends PropertyEditorSupport { + + private ObjectMapper objectMapper; + + public ProductEditor(ObjectMapper objectMapper) { + this.objectMapper = objectMapper; + } + + @Override + public void setAsText(String text) throws IllegalArgumentException { + if (StringUtils.isEmpty(text)) { + setValue(null); + } else { + Product prod = new Product(); + try { + prod = objectMapper.readValue(text, Product.class); + } catch (JsonProcessingException e) { + throw new IllegalArgumentException(e); + } + setValue(prod); + } + } + +} diff --git a/spring-mvc-basics-4/src/test/java/com/baeldung/jsonparams/JsonParamsIntegrationTest.java b/spring-mvc-basics-4/src/test/java/com/baeldung/jsonparams/JsonParamsIntegrationTest.java new file mode 100644 index 0000000000..bceadc4896 --- /dev/null +++ b/spring-mvc-basics-4/src/test/java/com/baeldung/jsonparams/JsonParamsIntegrationTest.java @@ -0,0 +1,71 @@ +package com.baeldung.jsonparams; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.web.AnnotationConfigWebContextLoader; +import org.springframework.test.context.web.WebAppConfiguration; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.context.WebApplicationContext; + +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import com.baeldung.jsonparams.config.JsonParamsConfig; + +@RunWith(SpringJUnit4ClassRunner.class) +@WebAppConfiguration +@ContextConfiguration(classes = { JsonParamsConfig.class }, loader = AnnotationConfigWebContextLoader.class) +public class JsonParamsIntegrationTest { + + private MockMvc mockMvc; + + @Autowired + private WebApplicationContext wac; + + @Before + public void setUp() { + this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac) + .build(); + } + + @Test + public void whenJsonIsPassedWithPost_thenResponseOK() throws Exception { + + this.mockMvc.perform(post("/products/create").accept(MediaType.APPLICATION_JSON) + .contentType(MediaType.APPLICATION_JSON) + .content("{\"id\": 1,\"name\": \"Asus Zenbook\",\"price\": 800}")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.id").value("1")) + .andExpect(jsonPath("$.name").value("Asus Zenbook")); + + } + + @Test + public void whenJsonIsPassedWithGet_thenResponseOK() throws Exception { + + this.mockMvc.perform(get("/products/get").contentType(MediaType.APPLICATION_JSON) + .queryParam("product", "{\"id\": 2,\"name\": \"HP EliteBook\",\"price\": 700}")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.id").value("2")) + .andExpect(jsonPath("$.name").value("HP EliteBook")); + + } + + @Test + public void whenJsonIsPassedWithGet2_thenResponseOK() throws Exception { + + this.mockMvc.perform(get("/products/get2").contentType(MediaType.APPLICATION_JSON) + .queryParam("product", "{\"id\": 3,\"name\": \"Dell G5 15\",\"price\": 1200}")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.id").value("3")) + .andExpect(jsonPath("$.name").value("Dell G5 15")); + + } + +} From 1cd9875381b282aff23c40473f03754e20302d1f Mon Sep 17 00:00:00 2001 From: KevinGilmore Date: Sat, 19 Sep 2020 10:40:37 -0500 Subject: [PATCH 183/263] BAEL-3569: Update README (#10053) * BAEL-3336 BAEL-3058 add links * BAEL-3319: add link * BAEL-3284: add link * BAEL-3198: add link to article * BAEL-3479: add link to article * BAEL-3485: add article link * SCALA-38: move to new package and add link back to article * SCALA-38: add imports back into unit test * BAEL-3908: add link back to article * BAEL-2893 BAEL-3927 add link back to article * BAEL-3569: update README --- spring-5-security-oauth/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-5-security-oauth/README.md b/spring-5-security-oauth/README.md index 43cab33598..35e64da639 100644 --- a/spring-5-security-oauth/README.md +++ b/spring-5-security-oauth/README.md @@ -7,3 +7,4 @@ This module contains articles about Spring 5 OAuth Security - [Spring Security 5 – OAuth2 Login](https://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) +- [Social Login with Spring Security in a Jersey Application](https://www.baeldung.com/spring-security-social-login-jersey) From f1348339529b20f6d61b3cc9442db89faaafcee7 Mon Sep 17 00:00:00 2001 From: Umang Budhwar Date: Sat, 19 Sep 2020 21:49:13 +0530 Subject: [PATCH 184/263] Refactored code to use generic methods and use streams. (#10052) --- .../check/staticmethods/StaticUtility.java | 19 ++++++++++++ .../staticmethods/StaticUtilityUnitTest.java | 30 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 core-java-modules/core-java-reflection-2/src/main/java/com/baeldung/reflection/check/staticmethods/StaticUtility.java create mode 100644 core-java-modules/core-java-reflection-2/src/test/java/com/baeldung/reflection/check/staticmethods/StaticUtilityUnitTest.java diff --git a/core-java-modules/core-java-reflection-2/src/main/java/com/baeldung/reflection/check/staticmethods/StaticUtility.java b/core-java-modules/core-java-reflection-2/src/main/java/com/baeldung/reflection/check/staticmethods/StaticUtility.java new file mode 100644 index 0000000000..5afb9b79c4 --- /dev/null +++ b/core-java-modules/core-java-reflection-2/src/main/java/com/baeldung/reflection/check/staticmethods/StaticUtility.java @@ -0,0 +1,19 @@ +package com.baeldung.reflection.check.staticmethods; + +import java.time.LocalDate; +import java.time.LocalTime; + +public class StaticUtility { + + public static String getAuthorName() { + return "Umang Budhwar"; + } + + public static LocalDate getLocalDate() { + return LocalDate.now(); + } + + public static LocalTime getLocalTime() { + return LocalTime.now(); + } +} diff --git a/core-java-modules/core-java-reflection-2/src/test/java/com/baeldung/reflection/check/staticmethods/StaticUtilityUnitTest.java b/core-java-modules/core-java-reflection-2/src/test/java/com/baeldung/reflection/check/staticmethods/StaticUtilityUnitTest.java new file mode 100644 index 0000000000..a4540407d5 --- /dev/null +++ b/core-java-modules/core-java-reflection-2/src/test/java/com/baeldung/reflection/check/staticmethods/StaticUtilityUnitTest.java @@ -0,0 +1,30 @@ +package com.baeldung.reflection.check.staticmethods; + +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class StaticUtilityUnitTest { + + @Test + void whenCheckStaticMethod_ThenSuccess() throws Exception { + Method method = StaticUtility.class.getMethod("getAuthorName", null); + Assertions.assertTrue(Modifier.isStatic(method.getModifiers())); + } + + @Test + void whenCheckAllStaticMethods_thenSuccess() { + List methodList = Arrays.asList(StaticUtility.class.getMethods()) + .stream() + .filter(method -> Modifier.isStatic(method.getModifiers())) + .collect(Collectors.toList()); + Assertions.assertEquals(3, methodList.size()); + } + +} From 3626b5c85857e735b1aa2dade5fd687eaf0ec3ef Mon Sep 17 00:00:00 2001 From: Tarun Jain Date: Sun, 20 Sep 2020 01:20:58 +0530 Subject: [PATCH 185/263] BAEL-4404 | Added test class to verify the beahvior --- .../CharEncodingCheckControllerTest.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 spring-boot-modules/spring-boot-mvc-3/src/test/java/com/baeldung/charencoding/controller/CharEncodingCheckControllerTest.java diff --git a/spring-boot-modules/spring-boot-mvc-3/src/test/java/com/baeldung/charencoding/controller/CharEncodingCheckControllerTest.java b/spring-boot-modules/spring-boot-mvc-3/src/test/java/com/baeldung/charencoding/controller/CharEncodingCheckControllerTest.java new file mode 100644 index 0000000000..25f257eced --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc-3/src/test/java/com/baeldung/charencoding/controller/CharEncodingCheckControllerTest.java @@ -0,0 +1,34 @@ +package com.baeldung.charencoding.controller; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; + +import java.io.IOException; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.junit.jupiter.api.Test; +import org.springframework.web.filter.CharacterEncodingFilter; + +class CharEncodingCheckControllerTest { + + @Test + void whenCharEncodingFilter_thenVerifyEncoding() throws ServletException, IOException { + HttpServletRequest request = mock(HttpServletRequest.class); + HttpServletResponse response = mock(HttpServletResponse.class); + FilterChain chain = mock(FilterChain.class); + + CharacterEncodingFilter filter = new CharacterEncodingFilter(); + filter.setEncoding("UTF-8"); + filter.setForceEncoding(true); + + filter.doFilter(request, response, chain); + + verify(request).setCharacterEncoding("UTF-8"); + verify(response).setCharacterEncoding("UTF-8"); + } + +} From cb8bae53a250fec6a431b75c73d49df41335d74b Mon Sep 17 00:00:00 2001 From: Ricardo Caldas Date: Sat, 19 Sep 2020 19:58:33 -0300 Subject: [PATCH 186/263] Add a new section in Lombok builder article - Minor Fixes --- .../lombok/builder/RequiredFieldAnnotation.java | 3 ++- ...est.java => RequiredFieldAnnotationUnitTest.java} | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) rename lombok/src/test/java/com/baeldung/lombok/builder/{RequiredFieldAnnotationTest.java => RequiredFieldAnnotationUnitTest.java} (58%) diff --git a/lombok/src/main/java/com/baeldung/lombok/builder/RequiredFieldAnnotation.java b/lombok/src/main/java/com/baeldung/lombok/builder/RequiredFieldAnnotation.java index 8781101613..e2d171b1b0 100644 --- a/lombok/src/main/java/com/baeldung/lombok/builder/RequiredFieldAnnotation.java +++ b/lombok/src/main/java/com/baeldung/lombok/builder/RequiredFieldAnnotation.java @@ -8,7 +8,8 @@ import lombok.NonNull; @Getter public class RequiredFieldAnnotation { - @NonNull String name; + @NonNull + String name; String description; public static RequiredFieldAnnotationBuilder builder(String name) { diff --git a/lombok/src/test/java/com/baeldung/lombok/builder/RequiredFieldAnnotationTest.java b/lombok/src/test/java/com/baeldung/lombok/builder/RequiredFieldAnnotationUnitTest.java similarity index 58% rename from lombok/src/test/java/com/baeldung/lombok/builder/RequiredFieldAnnotationTest.java rename to lombok/src/test/java/com/baeldung/lombok/builder/RequiredFieldAnnotationUnitTest.java index 9d347327d4..ee5c3b19aa 100644 --- a/lombok/src/test/java/com/baeldung/lombok/builder/RequiredFieldAnnotationTest.java +++ b/lombok/src/test/java/com/baeldung/lombok/builder/RequiredFieldAnnotationUnitTest.java @@ -1,21 +1,21 @@ package com.baeldung.lombok.builder; +import org.junit.Before; import org.junit.Test; -import org.junit.jupiter.api.BeforeEach; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; -public class RequiredFieldAnnotationTest { +public class RequiredFieldAnnotationUnitTest { RequiredFieldAnnotation requiredFieldTest; - @BeforeEach - void setUp() { + @Before + public void setUp() { requiredFieldTest = RequiredFieldAnnotation.builder("NameField").description("Field Description").build(); } @Test public void givenBuilderWithRequiredParameter_thenParameterIsPresent() { - assertEquals(requiredFieldTest.getName(), "NameField"); + assertEquals("NameField", requiredFieldTest.getName()); } } \ No newline at end of file From c4d98a65967f8ada147e327116a177e2c86ac945 Mon Sep 17 00:00:00 2001 From: akeshri Date: Sun, 20 Sep 2020 15:25:29 +0530 Subject: [PATCH 187/263] changes --- .../collections/mapfirstpair/MapFirstPairUnitTest.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/mapfirstpair/MapFirstPairUnitTest.java b/core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/mapfirstpair/MapFirstPairUnitTest.java index b25e0932d8..8272e7323a 100644 --- a/core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/mapfirstpair/MapFirstPairUnitTest.java +++ b/core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/mapfirstpair/MapFirstPairUnitTest.java @@ -15,21 +15,24 @@ import org.junit.Test; public class MapFirstPairUnitTest { private Map.Entry getFirstPairUsingIterator(Map map) { - if (map == null || map.size() == 0) + if (map == null || map.size() == 0) { return null; + } Iterator> iterator = map.entrySet() .iterator(); - if (iterator.hasNext()) + if (iterator.hasNext()) { return iterator.next(); + } return null; } private Map.Entry getFirstPairUsingStream(Map map) { - if (map == null || map.size() == 0) + if (map == null || map.size() == 0) { return null; + } Set> entrySet = map.entrySet(); From 4503d5c3f7eba623a416be58c523ed5f6bd972fa Mon Sep 17 00:00:00 2001 From: Cristian Rosu Date: Sun, 20 Sep 2020 19:57:43 +0300 Subject: [PATCH 188/263] BAEL-4415 get a list of trusted certificates in Java --- .../certificates/CertificatesUnitTest.java | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 core-java-modules/core-java-security-2/src/test/java/certificates/CertificatesUnitTest.java diff --git a/core-java-modules/core-java-security-2/src/test/java/certificates/CertificatesUnitTest.java b/core-java-modules/core-java-security-2/src/test/java/certificates/CertificatesUnitTest.java new file mode 100644 index 0000000000..a631df086b --- /dev/null +++ b/core-java-modules/core-java-security-2/src/test/java/certificates/CertificatesUnitTest.java @@ -0,0 +1,94 @@ +package certificates; + +import org.junit.jupiter.api.Test; + +import javax.net.ssl.TrustManager; +import javax.net.ssl.TrustManagerFactory; +import javax.net.ssl.X509TrustManager; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.cert.Certificate; +import java.security.cert.CertificateException; +import java.security.cert.PKIXParameters; +import java.security.cert.TrustAnchor; +import java.security.cert.X509Certificate; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Enumeration; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +public class CertificatesUnitTest { + + private static final String GODADDY_CA_ALIAS = "godaddyrootg2ca [jdk]"; + + @Test + public void whenLoadingCacertsKeyStore_thenCertificatesArePresent() throws Exception { + KeyStore keyStore = loadKeyStore(); + PKIXParameters params = new PKIXParameters(keyStore); + + Set trustAnchors = params.getTrustAnchors(); + List certificates = trustAnchors.stream() + .map(TrustAnchor::getTrustedCert) + .collect(Collectors.toList()); + + assertFalse(certificates.isEmpty()); + } + + @Test + public void whenLoadingDefaultKeyStore_thenCertificatesArePresent() throws Exception { + TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); + trustManagerFactory.init((KeyStore)null); + + List trustManagers = Arrays.asList(trustManagerFactory.getTrustManagers()); + List certificates = trustManagers.stream() + .filter(X509TrustManager.class::isInstance) + .map(X509TrustManager.class::cast) + .map(trustManager -> Arrays.asList(trustManager.getAcceptedIssuers())) + .flatMap(Collection::stream) + .collect(Collectors.toList()); + + assertFalse(certificates.isEmpty()); + } + + @Test + public void whenLoadingKeyStore_thenGoDaddyCALabelIsPresent() throws Exception { + KeyStore keyStore = loadKeyStore(); + + Enumeration aliasEnumeration = keyStore.aliases(); + List aliases = Collections.list(aliasEnumeration); + + assertTrue(aliases.contains(GODADDY_CA_ALIAS)); + } + + @Test + public void whenLoadingKeyStore_thenGoDaddyCertificateIsPresent() throws Exception { + KeyStore keyStore = loadKeyStore(); + + Certificate goDaddyCertificate = keyStore.getCertificate(GODADDY_CA_ALIAS); + + assertNotNull(goDaddyCertificate); + } + + private KeyStore loadKeyStore() throws CertificateException, NoSuchAlgorithmException, IOException, KeyStoreException { + String relativeCacertsPath = "/lib/security/cacerts".replace("/", File.separator); + String filename = System.getProperty("java.home") + relativeCacertsPath; + FileInputStream is = new FileInputStream(filename); + + KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType()); + String password = "changeit"; + keystore.load(is, password.toCharArray()); + + return keystore; + } +} From 5d29ae5bbd34949076a332fae458199c995f8530 Mon Sep 17 00:00:00 2001 From: azhwani <> Date: Mon, 21 Sep 2020 11:16:03 +0100 Subject: [PATCH 189/263] first commit --- .../lastmodifiedfile/LastModifiedFileApp.java | 61 ++++++++++++++++ .../LastModifiedFileAppUnitTest.java | 72 +++++++++++++++++++ 2 files changed, 133 insertions(+) create mode 100644 core-java-modules/core-java-io-3/src/main/java/com/baeldung/lastmodifiedfile/LastModifiedFileApp.java create mode 100644 core-java-modules/core-java-io-3/src/test/java/com/baeldung/lastmodifiedfile/LastModifiedFileAppUnitTest.java diff --git a/core-java-modules/core-java-io-3/src/main/java/com/baeldung/lastmodifiedfile/LastModifiedFileApp.java b/core-java-modules/core-java-io-3/src/main/java/com/baeldung/lastmodifiedfile/LastModifiedFileApp.java new file mode 100644 index 0000000000..d2aace184f --- /dev/null +++ b/core-java-modules/core-java-io-3/src/main/java/com/baeldung/lastmodifiedfile/LastModifiedFileApp.java @@ -0,0 +1,61 @@ +package com.baeldung.lastmodifiedfile; + +import java.io.File; +import java.io.FileFilter; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.Optional; + +import org.apache.commons.io.comparator.LastModifiedFileComparator; +import org.apache.commons.io.filefilter.FileFilterUtils; + +public class LastModifiedFileApp { + + public static File findUsingIOApi(String sdir) { + File dir = new File(sdir); + if (dir.isDirectory()) { + Optional opFile = Arrays.stream(dir.listFiles(File::isFile)) + .max((f1, f2) -> Long.compare(f1.lastModified(), f2.lastModified())); + + if (opFile.isPresent()) { + return opFile.get(); + } + } + + return null; + } + + public static Path findUsingNIOApi(String sdir) throws IOException { + Path dir = Paths.get(sdir); + if (Files.isDirectory(dir)) { + Optional opPath = Files.list(dir) + .filter(p -> !Files.isDirectory(p)) + .sorted((p1, p2) -> Long.valueOf(p2.toFile().lastModified()) + .compareTo(p1.toFile().lastModified())) + .findFirst(); + + if (opPath.isPresent()) { + return opPath.get(); + } + } + + return null; + } + + public static File findUsingCommonsIO(String sdir) { + File dir = new File(sdir); + if (dir.isDirectory()) { + File[] dirFiles = dir.listFiles((FileFilter) FileFilterUtils.fileFileFilter()); + if (dirFiles != null && dirFiles.length > 0) { + Arrays.sort(dirFiles, LastModifiedFileComparator.LASTMODIFIED_REVERSE); + return dirFiles[0]; + } + } + + return null; + } + +} diff --git a/core-java-modules/core-java-io-3/src/test/java/com/baeldung/lastmodifiedfile/LastModifiedFileAppUnitTest.java b/core-java-modules/core-java-io-3/src/test/java/com/baeldung/lastmodifiedfile/LastModifiedFileAppUnitTest.java new file mode 100644 index 0000000000..4e1f7719a9 --- /dev/null +++ b/core-java-modules/core-java-io-3/src/test/java/com/baeldung/lastmodifiedfile/LastModifiedFileAppUnitTest.java @@ -0,0 +1,72 @@ +package com.baeldung.lastmodifiedfile; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.apache.commons.io.FileUtils; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +public class LastModifiedFileAppUnitTest { + + private final static String SOURCEDIRECTORY = "src/test/resources/lastmodfiles"; + + @BeforeAll + public static void setUpFiles() throws IOException, InterruptedException { + File srcDir = new File(SOURCEDIRECTORY); + if (!srcDir.exists()) { + srcDir.mkdir(); + } + + FileUtils.cleanDirectory(srcDir); + + File file01 = new File(SOURCEDIRECTORY + "/file01.txt"); + file01.createNewFile(); + + Thread.sleep(2000); + + File file02 = new File(SOURCEDIRECTORY + "/file02.txt"); + file02.createNewFile(); + + Thread.sleep(2000); + + File file03 = new File(SOURCEDIRECTORY + "/file03.txt"); + file03.createNewFile(); + + Thread.sleep(2000); + + Files.write(Paths.get(SOURCEDIRECTORY + "/file02.txt"), "Hello File02".getBytes()); + + } + + @Test + public void givenDirectory_whenUsingIoApi_thenFindLastModfile() throws IOException { + File lastModFile = LastModifiedFileApp.findUsingIOApi(SOURCEDIRECTORY); + + assertThat(lastModFile).isNotNull(); + assertThat(lastModFile.getName()).isEqualTo("file02.txt"); + } + + @Test + public void givenDirectory_whenUsingNioApi_thenFindLastModfile() throws IOException { + Path lastModPath = LastModifiedFileApp.findUsingNIOApi(SOURCEDIRECTORY); + + assertThat(lastModPath).isNotNull(); + assertThat(lastModPath.toFile() + .getName()).isEqualTo("file02.txt"); + } + + @Test + public void givenDirectory_whenUsingApacheCommons_thenFindLastModfile() throws IOException { + File lastModFile = LastModifiedFileApp.findUsingCommonsIO(SOURCEDIRECTORY); + + assertThat(lastModFile).isNotNull(); + assertThat(lastModFile.getName()).isEqualTo("file02.txt"); + } + +} \ No newline at end of file From fd9e75c6e22bfb0666d3e1bf7dfdaf380f151d74 Mon Sep 17 00:00:00 2001 From: Reza Ebrahimpour Date: Mon, 21 Sep 2020 21:48:18 +0330 Subject: [PATCH 190/263] BAEL-4488 Fix indents --- .../com/baeldung/cipher/AvailableCiphersUnitTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core-java-modules/core-java-security-2/src/test/java/com/baeldung/cipher/AvailableCiphersUnitTest.java b/core-java-modules/core-java-security-2/src/test/java/com/baeldung/cipher/AvailableCiphersUnitTest.java index 48aaa5fb67..fa38aca272 100644 --- a/core-java-modules/core-java-security-2/src/test/java/com/baeldung/cipher/AvailableCiphersUnitTest.java +++ b/core-java-modules/core-java-security-2/src/test/java/com/baeldung/cipher/AvailableCiphersUnitTest.java @@ -25,10 +25,10 @@ public class AvailableCiphersUnitTest { @Test public void whenGetServicesWithFilter_thenGetAllCompatibleCipherAlgorithms() { List algorithms = Arrays.stream(Security.getProviders()) - .flatMap(provider -> provider.getServices().stream()) - .filter(service -> "Cipher".equals(service.getType())) - .map(Provider.Service::getAlgorithm) - .collect(Collectors.toList()); + .flatMap(provider -> provider.getServices().stream()) + .filter(service -> "Cipher".equals(service.getType())) + .map(Provider.Service::getAlgorithm) + .collect(Collectors.toList()); algorithms.forEach(logger::info); } From dda9d0fb67378372101a026ba2d0657044337d3a Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Mon, 21 Sep 2020 20:53:16 +0200 Subject: [PATCH 191/263] JAVA-2901: Fix failing int tests in spring-mvc-basics-4 --- .../src/main/java/com/baeldung/controller/config/WebConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/controller/config/WebConfig.java b/spring-mvc-basics-4/src/main/java/com/baeldung/controller/config/WebConfig.java index 6e79ac0aad..364f042ac7 100644 --- a/spring-mvc-basics-4/src/main/java/com/baeldung/controller/config/WebConfig.java +++ b/spring-mvc-basics-4/src/main/java/com/baeldung/controller/config/WebConfig.java @@ -11,7 +11,7 @@ import org.springframework.web.servlet.view.InternalResourceViewResolver; @Configuration @EnableWebMvc -@ComponentScan(basePackages = { "com.baeldung.controller.controller", "com.baeldung.controller", "com.baeldung.controller.config" }) +@ComponentScan(basePackages = { "com.baeldung.controller", "com.baeldung.optionalpathvars" }) public class WebConfig implements WebMvcConfigurer { @Override public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) { From d51a8319c6f4946346666367ad6d5177114a7efb Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Mon, 21 Sep 2020 21:15:03 +0200 Subject: [PATCH 192/263] JAVA-2977: Get rid of the unused spring*boot* properties --- testing-modules/spring-testing-2/pom.xml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/testing-modules/spring-testing-2/pom.xml b/testing-modules/spring-testing-2/pom.xml index c7ca2804fb..807b84c676 100644 --- a/testing-modules/spring-testing-2/pom.xml +++ b/testing-modules/spring-testing-2/pom.xml @@ -27,6 +27,12 @@ spring-boot-starter-data-jpa + + com.h2database + h2 + ${h2.version} + + org.postgresql postgresql @@ -50,8 +56,6 @@ - 2.1.9.RELEASE - 2.1.9.RELEASE 1.12.2 \ No newline at end of file From 025791611ca8b731415629d18f2b21d539472a9f Mon Sep 17 00:00:00 2001 From: Karsten Silz Date: Mon, 21 Sep 2020 20:31:14 +0100 Subject: [PATCH 193/263] Added feedback from pull request. --- json/README.md | 1 - .../JsonOptimizationUnitTest.java | 64 +++++++++---------- 2 files changed, 31 insertions(+), 34 deletions(-) diff --git a/json/README.md b/json/README.md index cfee611f4a..0e50dcfddb 100644 --- a/json/README.md +++ b/json/README.md @@ -13,4 +13,3 @@ This module contains articles about JSON. - [Get a Value by Key in a JSONArray](https://www.baeldung.com/java-jsonarray-get-value-by-key) - [Iterating Over an Instance of org.json.JSONObject](https://www.baeldung.com/jsonobject-iteration) - [Escape JSON String in Java](https://www.baeldung.com/java-json-escaping) -- [Reducing JSON Data Size](https://www.baeldung.com/reducing-json-data-size) diff --git a/json/src/test/java/com/baeldung/jsonoptimization/JsonOptimizationUnitTest.java b/json/src/test/java/com/baeldung/jsonoptimization/JsonOptimizationUnitTest.java index 5734518fad..7a56a68fe2 100644 --- a/json/src/test/java/com/baeldung/jsonoptimization/JsonOptimizationUnitTest.java +++ b/json/src/test/java/com/baeldung/jsonoptimization/JsonOptimizationUnitTest.java @@ -22,11 +22,11 @@ import com.fasterxml.jackson.databind.ObjectWriter; import com.fasterxml.jackson.databind.module.SimpleModule; class JsonOptimizationUnitTest { - private static final String TEST_LABEL_DEFAULT_JSON = "Default JSON"; + private static final String TEST_LABEL_JACKSON_DEFAULT_OPTIONS = "Default JSON"; private static final String TEST_LABEL_DEFAULT_JSON_NO_NULL = "Default JSON without null"; - private static final String TEST_LABEL_SHORT_NAMES = "Shorter field names"; - private static final String TEST_LABEL_SHORT_NAMES_NO_NULL = "Shorter field names without null"; - private static final String TEST_LABEL_CUSTOM_SERIALIZER = "Custom serializer"; + private static final String TEST_LABEL_SHORTER_FIELD_NAMES = "Shorter field names"; + private static final String TEST_LABEL_SHORTER_FIELD_NAMES_AND_NO_NULL = "Shorter field names without null"; + private static final String TEST_LABEL_SERIALIZING_TO_ARRAY = "Custom serializer"; private static final String TEST_LABEL_SLIM_CUSTOM_SERIALIZER = "Slim custom serializer"; private static final String TEST_LABEL_SLIM_CUSTOMER = "Slim customer"; private static final String TEST_LABEL_SLIM_CUSTOMER_SHORT_NAMES = "Slim customer with shorter field names"; @@ -53,82 +53,80 @@ class JsonOptimizationUnitTest { } @Test - void testSetUp() { + void whenSetUp_ThenOneThousandCustomers() { assertEquals(1000, customers.length, "There should be a 1000 customers"); } @Test - void testDefaultJson() throws IOException { - printBanner(TEST_LABEL_DEFAULT_JSON); - byte[] plainJson = createPlainJson(TEST_LABEL_DEFAULT_JSON, customers); - compressJson(TEST_LABEL_DEFAULT_JSON, plainJson); + void whenJacksonDefaultOptions_thenValid() throws IOException { + printBanner(TEST_LABEL_JACKSON_DEFAULT_OPTIONS); + byte[] plainJson = createJsonAndVerify(TEST_LABEL_JACKSON_DEFAULT_OPTIONS, customers); + compressJson(TEST_LABEL_JACKSON_DEFAULT_OPTIONS, plainJson); } @Test - void testDefaultNoNull() throws IOException { + void whenExcludingNull_thenValid() throws IOException { printBanner(TEST_LABEL_DEFAULT_JSON_NO_NULL); mapper.setSerializationInclusion(Include.NON_NULL); - byte[] plainJson = createPlainJson(TEST_LABEL_DEFAULT_JSON_NO_NULL, customers); + byte[] plainJson = createJsonAndVerify(TEST_LABEL_DEFAULT_JSON_NO_NULL, customers); compressJson(TEST_LABEL_DEFAULT_JSON_NO_NULL, plainJson); } @Test - void testShortNames() throws IOException { - printBanner(TEST_LABEL_SHORT_NAMES); + void whenShorterFieldNames_thenValid() throws IOException { + printBanner(TEST_LABEL_SHORTER_FIELD_NAMES); CustomerShortNames[] shorterOnes = CustomerShortNames.fromCustomers(customers); - byte[] shorterJson = createPlainJson(TEST_LABEL_SHORT_NAMES, shorterOnes); - compressJson(TEST_LABEL_SHORT_NAMES, shorterJson); + byte[] shorterJson = createJsonAndVerify(TEST_LABEL_SHORTER_FIELD_NAMES, shorterOnes); + compressJson(TEST_LABEL_SHORTER_FIELD_NAMES, shorterJson); } @Test - void testShortNamesNoNull() throws IOException { - printBanner(TEST_LABEL_SHORT_NAMES_NO_NULL); + void whenShorterFieldNamesAndExcludingNull_thenValid() throws IOException { + printBanner(TEST_LABEL_SHORTER_FIELD_NAMES_AND_NO_NULL); CustomerShortNames[] shorterOnes = CustomerShortNames.fromCustomers(customers); mapper.setSerializationInclusion(Include.NON_NULL); - byte[] shorterJson = createPlainJson(TEST_LABEL_SHORT_NAMES_NO_NULL, shorterOnes); - compressJson(TEST_LABEL_SHORT_NAMES_NO_NULL, shorterJson); + byte[] shorterJson = createJsonAndVerify(TEST_LABEL_SHORTER_FIELD_NAMES_AND_NO_NULL, shorterOnes); + compressJson(TEST_LABEL_SHORTER_FIELD_NAMES_AND_NO_NULL, shorterJson); } @Test - void testSlim() throws IOException { + void whenSlimCustomer_thenValid() throws IOException { printBanner(TEST_LABEL_SLIM_CUSTOMER); CustomerSlim[] slimOnes = CustomerSlim.fromCustomers(customers); - byte[] slimJson = createPlainJson(TEST_LABEL_SLIM_CUSTOMER, slimOnes); + byte[] slimJson = createJsonAndVerify(TEST_LABEL_SLIM_CUSTOMER, slimOnes); compressJson(TEST_LABEL_SLIM_CUSTOMER, slimJson); } @Test - void testSlimShortNames() throws IOException { + void whenSlimCustomerAndShorterFieldNames_thenValid() throws IOException { printBanner(TEST_LABEL_SLIM_CUSTOMER_SHORT_NAMES); CustomerSlimShortNames[] slimOnes = CustomerSlimShortNames.fromCustomers(customers); - byte[] slimJson = createPlainJson(TEST_LABEL_SLIM_CUSTOMER_SHORT_NAMES, slimOnes); + byte[] slimJson = createJsonAndVerify(TEST_LABEL_SLIM_CUSTOMER_SHORT_NAMES, slimOnes); compressJson(TEST_LABEL_SLIM_CUSTOMER_SHORT_NAMES, slimJson); } @Test - void testCustomSerializer() throws IOException { - printBanner(TEST_LABEL_CUSTOM_SERIALIZER); - + void whenSerializingToArray_thenValid() throws IOException { + printBanner(TEST_LABEL_SERIALIZING_TO_ARRAY); SimpleModule serializer = new SimpleModule("CustomDeSerializer", new Version(1, 0, 0, null, null, null)); serializer.addSerializer(Customer.class, new CustomerSerializer()); serializer.addDeserializer(Customer.class, new CustomerDeserializer()); mapper.registerModule(serializer); - byte[] plainJson = createPlainJson(TEST_LABEL_CUSTOM_SERIALIZER, customers); - compressJson(TEST_LABEL_CUSTOM_SERIALIZER, plainJson); + byte[] plainJson = createJsonAndVerify(TEST_LABEL_SERIALIZING_TO_ARRAY, customers); + compressJson(TEST_LABEL_SERIALIZING_TO_ARRAY, plainJson); } @Test - void testSlimCustomSerializer() throws IOException { + void whenSerializingToArrayAndSlimCustomer_thenValid() throws IOException { printBanner(TEST_LABEL_SLIM_CUSTOM_SERIALIZER); - SimpleModule serializer = new SimpleModule("SlimCustomDeSerializer", new Version(1, 0, 0, null, null, null)); serializer.addSerializer(CustomerSlim.class, new CustomerSlimSerializer()); serializer.addDeserializer(CustomerSlim.class, new CustomerSlimDeserializer()); mapper.registerModule(serializer); CustomerSlim[] slimOnes = CustomerSlim.fromCustomers(customers); - byte[] plainJson = createPlainJson(TEST_LABEL_SLIM_CUSTOM_SERIALIZER, slimOnes); + byte[] plainJson = createJsonAndVerify(TEST_LABEL_SLIM_CUSTOM_SERIALIZER, slimOnes); compressJson(TEST_LABEL_SLIM_CUSTOM_SERIALIZER, plainJson); } @@ -153,7 +151,7 @@ class JsonOptimizationUnitTest { assertTrue(plainJson.length > gzippedJson.length, label + " should be longer than GZIPped data"); } - private byte[] createPlainJson(String label, Object[] customers) throws IOException { + private byte[] createJsonAndVerify(String label, Object[] customers) throws IOException { System.out.println(label + " sample: "); ObjectWriter prettyWritter = mapper.writerWithDefaultPrettyPrinter(); System.out.println(prettyWritter.writeValueAsString(customers[0])); @@ -174,7 +172,7 @@ class JsonOptimizationUnitTest { System.out.println(label + " file: " + tempFile.toString()); Object[] restoredOnes = mapper.readValue(feedback, customers.getClass()); - assertArrayEquals(TEST_LABEL_DEFAULT_JSON + ": restoring from JSON should work", customers, restoredOnes); + assertArrayEquals(TEST_LABEL_JACKSON_DEFAULT_OPTIONS + ": restoring from JSON should work", customers, restoredOnes); return feedback; } From 65833e0a6b058151c6d6e98159a0f8e9974b03e3 Mon Sep 17 00:00:00 2001 From: Karsten Silz Date: Mon, 21 Sep 2020 20:38:46 +0100 Subject: [PATCH 194/263] Moved code from "json" module. --- json-2/pom.xml | 37 + .../baeldung/jsonoptimization/Customer.java | 123 ++ .../CustomerDeserializer.java | 49 + .../jsonoptimization/CustomerSerializer.java | 34 + .../jsonoptimization/CustomerShortNames.java | 155 +++ .../jsonoptimization/CustomerSlim.java | 73 ++ .../CustomerSlimDeserializer.java | 37 + .../CustomerSlimSerializer.java | 28 + .../CustomerSlimShortNames.java | 81 ++ .../JsonOptimizationUnitTest.java | 180 +++ .../json_optimization_mock_data.json | 1000 +++++++++++++++++ 11 files changed, 1797 insertions(+) create mode 100644 json-2/src/main/java/com/baeldung/jsonoptimization/Customer.java create mode 100644 json-2/src/main/java/com/baeldung/jsonoptimization/CustomerDeserializer.java create mode 100644 json-2/src/main/java/com/baeldung/jsonoptimization/CustomerSerializer.java create mode 100644 json-2/src/main/java/com/baeldung/jsonoptimization/CustomerShortNames.java create mode 100644 json-2/src/main/java/com/baeldung/jsonoptimization/CustomerSlim.java create mode 100644 json-2/src/main/java/com/baeldung/jsonoptimization/CustomerSlimDeserializer.java create mode 100644 json-2/src/main/java/com/baeldung/jsonoptimization/CustomerSlimSerializer.java create mode 100644 json-2/src/main/java/com/baeldung/jsonoptimization/CustomerSlimShortNames.java create mode 100644 json-2/src/test/java/com/baeldung/jsonoptimization/JsonOptimizationUnitTest.java create mode 100644 json-2/src/test/resources/json_optimization_mock_data.json diff --git a/json-2/pom.xml b/json-2/pom.xml index f0215a375f..c5f11754f4 100644 --- a/json-2/pom.xml +++ b/json-2/pom.xml @@ -116,4 +116,41 @@ 1.9.2 3.9 + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + org.apache.maven.plugins + + + maven-pmd-plugin + + + [3.13.0,) + + + check + + + + + + + + + + + + + diff --git a/json-2/src/main/java/com/baeldung/jsonoptimization/Customer.java b/json-2/src/main/java/com/baeldung/jsonoptimization/Customer.java new file mode 100644 index 0000000000..85451731e9 --- /dev/null +++ b/json-2/src/main/java/com/baeldung/jsonoptimization/Customer.java @@ -0,0 +1,123 @@ +package com.baeldung.jsonoptimization; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Objects; + +import com.fasterxml.jackson.databind.ObjectMapper; + +public class Customer { + + private long id; + private String firstName; + private String lastName; + private String street; + private String postalCode; + private String city; + private String state; + private String phoneNumber; + private String email; + + 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 String getStreet() { + return street; + } + + public void setStreet(String street) { + this.street = street; + } + + public String getPostalCode() { + return postalCode; + } + + public void setPostalCode(String postalCode) { + this.postalCode = postalCode; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getPhoneNumber() { + return phoneNumber; + } + + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + @Override + public int hashCode() { + return Objects.hash(city, email, firstName, id, lastName, phoneNumber, postalCode, state, street); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof Customer)) { + return false; + } + Customer other = (Customer) obj; + return Objects.equals(city, other.city) && Objects.equals(email, other.email) && Objects.equals(firstName, other.firstName) && id == other.id && Objects.equals(lastName, other.lastName) && Objects.equals(phoneNumber, other.phoneNumber) + && Objects.equals(postalCode, other.postalCode) && Objects.equals(state, other.state) && Objects.equals(street, other.street); + } + + @Override + public String toString() { + return "Customer [id=" + id + ", firstName=" + firstName + ", lastName=" + lastName + ", street=" + street + ", postalCode=" + postalCode + ", city=" + city + ", state=" + state + ", phoneNumber=" + phoneNumber + ", email=" + email + "]"; + } + + public static Customer[] fromMockFile() throws IOException { + ObjectMapper objectMapper = new ObjectMapper(); + InputStream jsonFile = new FileInputStream("src/test/resources/json_optimization_mock_data.json"); + Customer[] feedback = objectMapper.readValue(jsonFile, Customer[].class); + return feedback; + } +} diff --git a/json-2/src/main/java/com/baeldung/jsonoptimization/CustomerDeserializer.java b/json-2/src/main/java/com/baeldung/jsonoptimization/CustomerDeserializer.java new file mode 100644 index 0000000000..16b66311ad --- /dev/null +++ b/json-2/src/main/java/com/baeldung/jsonoptimization/CustomerDeserializer.java @@ -0,0 +1,49 @@ +package com.baeldung.jsonoptimization; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.ObjectCodec; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; + +public class CustomerDeserializer extends StdDeserializer { + private static final long serialVersionUID = 1L; + + public CustomerDeserializer() { + this(null); + } + + public CustomerDeserializer(Class t) { + super(t); + } + + @Override + public Customer deserialize(JsonParser parser, DeserializationContext deserializer) throws IOException { + Customer feedback = new Customer(); + ObjectCodec codec = parser.getCodec(); + JsonNode node = codec.readTree(parser); + + feedback.setId(node.get(0) + .asLong()); + feedback.setFirstName(node.get(1) + .asText()); + feedback.setLastName(node.get(2) + .asText()); + feedback.setStreet(node.get(3) + .asText()); + feedback.setPostalCode(node.get(4) + .asText()); + feedback.setCity(node.get(5) + .asText()); + feedback.setState(node.get(6) + .asText()); + JsonNode phoneNumber = node.get(7); + feedback.setPhoneNumber(phoneNumber.isNull() ? null : phoneNumber.asText()); + JsonNode email = node.get(8); + feedback.setEmail(email.isNull() ? null : email.asText()); + + return feedback; + } +} diff --git a/json-2/src/main/java/com/baeldung/jsonoptimization/CustomerSerializer.java b/json-2/src/main/java/com/baeldung/jsonoptimization/CustomerSerializer.java new file mode 100644 index 0000000000..0f631ee85b --- /dev/null +++ b/json-2/src/main/java/com/baeldung/jsonoptimization/CustomerSerializer.java @@ -0,0 +1,34 @@ +package com.baeldung.jsonoptimization; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; + +public class CustomerSerializer extends StdSerializer { + private static final long serialVersionUID = 1L; + + public CustomerSerializer() { + this(null); + } + + public CustomerSerializer(Class t) { + super(t); + } + + @Override + public void serialize(Customer customer, JsonGenerator jsonGenerator, SerializerProvider serializer) throws IOException { + jsonGenerator.writeStartArray(); + jsonGenerator.writeNumber(customer.getId()); + jsonGenerator.writeString(customer.getFirstName()); + jsonGenerator.writeString(customer.getLastName()); + jsonGenerator.writeString(customer.getStreet()); + jsonGenerator.writeString(customer.getPostalCode()); + jsonGenerator.writeString(customer.getCity()); + jsonGenerator.writeString(customer.getState()); + jsonGenerator.writeString(customer.getPhoneNumber()); + jsonGenerator.writeString(customer.getEmail()); + jsonGenerator.writeEndArray(); + } +} diff --git a/json-2/src/main/java/com/baeldung/jsonoptimization/CustomerShortNames.java b/json-2/src/main/java/com/baeldung/jsonoptimization/CustomerShortNames.java new file mode 100644 index 0000000000..b94fbb1033 --- /dev/null +++ b/json-2/src/main/java/com/baeldung/jsonoptimization/CustomerShortNames.java @@ -0,0 +1,155 @@ +package com.baeldung.jsonoptimization; + +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class CustomerShortNames { + + @JsonProperty("i") + private long id; + + @JsonProperty("f") + private String firstName; + + @JsonProperty("l") + private String lastName; + + @JsonProperty("s") + private String street; + + @JsonProperty("p") + private String postalCode; + + @JsonProperty("c") + private String city; + + @JsonProperty("a") + private String state; + + @JsonProperty("o") + private String phoneNumber; + + @JsonProperty("e") + private String email; + + 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 String getStreet() { + return street; + } + + public void setStreet(String street) { + this.street = street; + } + + public String getPostalCode() { + return postalCode; + } + + public void setPostalCode(String postalCode) { + this.postalCode = postalCode; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getPhoneNumber() { + return phoneNumber; + } + + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + @Override + public int hashCode() { + return Objects.hash(city, email, firstName, id, lastName, phoneNumber, postalCode, state, street); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof CustomerShortNames)) { + return false; + } + CustomerShortNames other = (CustomerShortNames) obj; + return Objects.equals(city, other.city) && Objects.equals(email, other.email) && Objects.equals(firstName, other.firstName) && id == other.id && Objects.equals(lastName, other.lastName) && Objects.equals(phoneNumber, other.phoneNumber) + && Objects.equals(postalCode, other.postalCode) && Objects.equals(state, other.state) && Objects.equals(street, other.street); + } + + @Override + public String toString() { + return "CustomerWithShorterAttributes [id=" + id + ", firstName=" + firstName + ", lastName=" + lastName + ", street=" + street + ", postalCode=" + postalCode + ", city=" + city + ", state=" + state + ", phoneNumber=" + phoneNumber + ", email=" + email + + "]"; + } + + public static CustomerShortNames[] fromCustomers(Customer[] customers) { + CustomerShortNames[] feedback = new CustomerShortNames[customers.length]; + + for (int i = 0; i < customers.length; i++) { + Customer aCustomer = customers[i]; + CustomerShortNames newOne = new CustomerShortNames(); + + newOne.setId(aCustomer.getId()); + newOne.setFirstName(aCustomer.getFirstName()); + newOne.setLastName(aCustomer.getLastName()); + newOne.setStreet(aCustomer.getStreet()); + newOne.setCity(aCustomer.getCity()); + newOne.setPostalCode(aCustomer.getPostalCode()); + newOne.setState(aCustomer.getState()); + newOne.setPhoneNumber(aCustomer.getPhoneNumber()); + newOne.setEmail(aCustomer.getEmail()); + + feedback[i] = newOne; + } + + return feedback; + } + +} diff --git a/json-2/src/main/java/com/baeldung/jsonoptimization/CustomerSlim.java b/json-2/src/main/java/com/baeldung/jsonoptimization/CustomerSlim.java new file mode 100644 index 0000000000..e2ef4664cf --- /dev/null +++ b/json-2/src/main/java/com/baeldung/jsonoptimization/CustomerSlim.java @@ -0,0 +1,73 @@ +package com.baeldung.jsonoptimization; + +import java.util.Objects; + +public class CustomerSlim { + private long id; + private String name; + private String address; + + 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 String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + @Override + public int hashCode() { + return Objects.hash(address, id, name); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof CustomerSlim)) { + return false; + } + CustomerSlim other = (CustomerSlim) obj; + return Objects.equals(address, other.address) && id == other.id && Objects.equals(name, other.name); + } + + @Override + public String toString() { + return "CustomerSlim [id=" + id + ", name=" + name + ", address=" + address + "]"; + } + + public static CustomerSlim[] fromCustomers(Customer[] customers) { + CustomerSlim[] feedback = new CustomerSlim[customers.length]; + + for (int i = 0; i < customers.length; i++) { + Customer aCustomer = customers[i]; + CustomerSlim newOne = new CustomerSlim(); + + newOne.setId(aCustomer.getId()); + newOne.setName(aCustomer.getFirstName() + " " + aCustomer.getLastName()); + newOne.setAddress(aCustomer.getStreet() + ", " + aCustomer.getCity() + " " + aCustomer.getState() + " " + aCustomer.getPostalCode()); + + feedback[i] = newOne; + } + + return feedback; + } + +} diff --git a/json-2/src/main/java/com/baeldung/jsonoptimization/CustomerSlimDeserializer.java b/json-2/src/main/java/com/baeldung/jsonoptimization/CustomerSlimDeserializer.java new file mode 100644 index 0000000000..296ee6fdf6 --- /dev/null +++ b/json-2/src/main/java/com/baeldung/jsonoptimization/CustomerSlimDeserializer.java @@ -0,0 +1,37 @@ +package com.baeldung.jsonoptimization; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.ObjectCodec; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; + +public class CustomerSlimDeserializer extends StdDeserializer { + private static final long serialVersionUID = 1L; + + public CustomerSlimDeserializer() { + this(null); + } + + public CustomerSlimDeserializer(Class t) { + super(t); + } + + @Override + public CustomerSlim deserialize(JsonParser parser, DeserializationContext deserializer) throws IOException { + CustomerSlim feedback = new CustomerSlim(); + ObjectCodec codec = parser.getCodec(); + JsonNode node = codec.readTree(parser); + + feedback.setId(node.get(0) + .asLong()); + feedback.setName(node.get(1) + .asText()); + feedback.setAddress(node.get(2) + .asText()); + + return feedback; + } +} diff --git a/json-2/src/main/java/com/baeldung/jsonoptimization/CustomerSlimSerializer.java b/json-2/src/main/java/com/baeldung/jsonoptimization/CustomerSlimSerializer.java new file mode 100644 index 0000000000..520c541da6 --- /dev/null +++ b/json-2/src/main/java/com/baeldung/jsonoptimization/CustomerSlimSerializer.java @@ -0,0 +1,28 @@ +package com.baeldung.jsonoptimization; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; + +public class CustomerSlimSerializer extends StdSerializer { + private static final long serialVersionUID = 1L; + + public CustomerSlimSerializer() { + this(null); + } + + public CustomerSlimSerializer(Class t) { + super(t); + } + + @Override + public void serialize(CustomerSlim customer, JsonGenerator jsonGenerator, SerializerProvider serializer) throws IOException { + jsonGenerator.writeStartArray(); + jsonGenerator.writeNumber(customer.getId()); + jsonGenerator.writeString(customer.getName()); + jsonGenerator.writeString(customer.getAddress()); + jsonGenerator.writeEndArray(); + } +} diff --git a/json-2/src/main/java/com/baeldung/jsonoptimization/CustomerSlimShortNames.java b/json-2/src/main/java/com/baeldung/jsonoptimization/CustomerSlimShortNames.java new file mode 100644 index 0000000000..bf00e847ac --- /dev/null +++ b/json-2/src/main/java/com/baeldung/jsonoptimization/CustomerSlimShortNames.java @@ -0,0 +1,81 @@ +package com.baeldung.jsonoptimization; + +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class CustomerSlimShortNames { + + @JsonProperty("i") + private long id; + + @JsonProperty("n") + private String name; + + @JsonProperty("a") + private String address; + + 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 String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + @Override + public int hashCode() { + return Objects.hash(address, id, name); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof CustomerSlimShortNames)) { + return false; + } + CustomerSlimShortNames other = (CustomerSlimShortNames) obj; + return Objects.equals(address, other.address) && id == other.id && Objects.equals(name, other.name); + } + + @Override + public String toString() { + return "CustomerSlim [id=" + id + ", name=" + name + ", address=" + address + "]"; + } + + public static CustomerSlimShortNames[] fromCustomers(Customer[] customers) { + CustomerSlimShortNames[] feedback = new CustomerSlimShortNames[customers.length]; + + for (int i = 0; i < customers.length; i++) { + Customer aCustomer = customers[i]; + CustomerSlimShortNames newOne = new CustomerSlimShortNames(); + + newOne.setId(aCustomer.getId()); + newOne.setName(aCustomer.getFirstName() + " " + aCustomer.getLastName()); + newOne.setAddress(aCustomer.getStreet() + ", " + aCustomer.getCity() + " " + aCustomer.getState() + " " + aCustomer.getPostalCode()); + + feedback[i] = newOne; + } + + return feedback; + } + +} diff --git a/json-2/src/test/java/com/baeldung/jsonoptimization/JsonOptimizationUnitTest.java b/json-2/src/test/java/com/baeldung/jsonoptimization/JsonOptimizationUnitTest.java new file mode 100644 index 0000000000..7a56a68fe2 --- /dev/null +++ b/json-2/src/test/java/com/baeldung/jsonoptimization/JsonOptimizationUnitTest.java @@ -0,0 +1,180 @@ +package com.baeldung.jsonoptimization; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.text.DecimalFormat; +import java.util.zip.GZIPOutputStream; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.core.Version; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectWriter; +import com.fasterxml.jackson.databind.module.SimpleModule; + +class JsonOptimizationUnitTest { + private static final String TEST_LABEL_JACKSON_DEFAULT_OPTIONS = "Default JSON"; + private static final String TEST_LABEL_DEFAULT_JSON_NO_NULL = "Default JSON without null"; + private static final String TEST_LABEL_SHORTER_FIELD_NAMES = "Shorter field names"; + private static final String TEST_LABEL_SHORTER_FIELD_NAMES_AND_NO_NULL = "Shorter field names without null"; + private static final String TEST_LABEL_SERIALIZING_TO_ARRAY = "Custom serializer"; + private static final String TEST_LABEL_SLIM_CUSTOM_SERIALIZER = "Slim custom serializer"; + private static final String TEST_LABEL_SLIM_CUSTOMER = "Slim customer"; + private static final String TEST_LABEL_SLIM_CUSTOMER_SHORT_NAMES = "Slim customer with shorter field names"; + private static DecimalFormat LENGTH_FORMATTER = new DecimalFormat("###,###.0"); + private static DecimalFormat PERCENT_FORMATTER = new DecimalFormat("###.0"); + private static Customer[] customers; + private ObjectMapper mapper; + private static int defaultJsonLength; + + @BeforeAll + static void setUpOnce() throws Exception { + customers = Customer.fromMockFile(); + ObjectMapper oneTimeMapper = new ObjectMapper(); + byte[] feedback = oneTimeMapper.writeValueAsBytes(customers); + defaultJsonLength = feedback.length; + System.out.println(); + System.out.println("Default JSON length: " + defaultJsonLength); + System.out.println(); + } + + @BeforeEach + void setUp() { + mapper = new ObjectMapper(); + } + + @Test + void whenSetUp_ThenOneThousandCustomers() { + assertEquals(1000, customers.length, "There should be a 1000 customers"); + } + + @Test + void whenJacksonDefaultOptions_thenValid() throws IOException { + printBanner(TEST_LABEL_JACKSON_DEFAULT_OPTIONS); + byte[] plainJson = createJsonAndVerify(TEST_LABEL_JACKSON_DEFAULT_OPTIONS, customers); + compressJson(TEST_LABEL_JACKSON_DEFAULT_OPTIONS, plainJson); + } + + @Test + void whenExcludingNull_thenValid() throws IOException { + printBanner(TEST_LABEL_DEFAULT_JSON_NO_NULL); + mapper.setSerializationInclusion(Include.NON_NULL); + byte[] plainJson = createJsonAndVerify(TEST_LABEL_DEFAULT_JSON_NO_NULL, customers); + compressJson(TEST_LABEL_DEFAULT_JSON_NO_NULL, plainJson); + } + + @Test + void whenShorterFieldNames_thenValid() throws IOException { + printBanner(TEST_LABEL_SHORTER_FIELD_NAMES); + CustomerShortNames[] shorterOnes = CustomerShortNames.fromCustomers(customers); + byte[] shorterJson = createJsonAndVerify(TEST_LABEL_SHORTER_FIELD_NAMES, shorterOnes); + compressJson(TEST_LABEL_SHORTER_FIELD_NAMES, shorterJson); + } + + @Test + void whenShorterFieldNamesAndExcludingNull_thenValid() throws IOException { + printBanner(TEST_LABEL_SHORTER_FIELD_NAMES_AND_NO_NULL); + CustomerShortNames[] shorterOnes = CustomerShortNames.fromCustomers(customers); + mapper.setSerializationInclusion(Include.NON_NULL); + byte[] shorterJson = createJsonAndVerify(TEST_LABEL_SHORTER_FIELD_NAMES_AND_NO_NULL, shorterOnes); + compressJson(TEST_LABEL_SHORTER_FIELD_NAMES_AND_NO_NULL, shorterJson); + } + + @Test + void whenSlimCustomer_thenValid() throws IOException { + printBanner(TEST_LABEL_SLIM_CUSTOMER); + CustomerSlim[] slimOnes = CustomerSlim.fromCustomers(customers); + byte[] slimJson = createJsonAndVerify(TEST_LABEL_SLIM_CUSTOMER, slimOnes); + compressJson(TEST_LABEL_SLIM_CUSTOMER, slimJson); + } + + @Test + void whenSlimCustomerAndShorterFieldNames_thenValid() throws IOException { + printBanner(TEST_LABEL_SLIM_CUSTOMER_SHORT_NAMES); + CustomerSlimShortNames[] slimOnes = CustomerSlimShortNames.fromCustomers(customers); + byte[] slimJson = createJsonAndVerify(TEST_LABEL_SLIM_CUSTOMER_SHORT_NAMES, slimOnes); + compressJson(TEST_LABEL_SLIM_CUSTOMER_SHORT_NAMES, slimJson); + } + + @Test + void whenSerializingToArray_thenValid() throws IOException { + printBanner(TEST_LABEL_SERIALIZING_TO_ARRAY); + SimpleModule serializer = new SimpleModule("CustomDeSerializer", new Version(1, 0, 0, null, null, null)); + serializer.addSerializer(Customer.class, new CustomerSerializer()); + serializer.addDeserializer(Customer.class, new CustomerDeserializer()); + mapper.registerModule(serializer); + + byte[] plainJson = createJsonAndVerify(TEST_LABEL_SERIALIZING_TO_ARRAY, customers); + compressJson(TEST_LABEL_SERIALIZING_TO_ARRAY, plainJson); + } + + @Test + void whenSerializingToArrayAndSlimCustomer_thenValid() throws IOException { + printBanner(TEST_LABEL_SLIM_CUSTOM_SERIALIZER); + SimpleModule serializer = new SimpleModule("SlimCustomDeSerializer", new Version(1, 0, 0, null, null, null)); + serializer.addSerializer(CustomerSlim.class, new CustomerSlimSerializer()); + serializer.addDeserializer(CustomerSlim.class, new CustomerSlimDeserializer()); + mapper.registerModule(serializer); + + CustomerSlim[] slimOnes = CustomerSlim.fromCustomers(customers); + byte[] plainJson = createJsonAndVerify(TEST_LABEL_SLIM_CUSTOM_SERIALIZER, slimOnes); + compressJson(TEST_LABEL_SLIM_CUSTOM_SERIALIZER, plainJson); + } + + private void printBanner(String name) { + System.out.println(); + System.out.println("************************************************"); + System.out.println("Testing " + name); + System.out.println(); + } + + void compressJson(String label, byte[] plainJson) throws IOException { + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + GZIPOutputStream gzipStream = new GZIPOutputStream(outputStream); + gzipStream.write(plainJson); + gzipStream.close(); + outputStream.close(); + byte[] gzippedJson = outputStream.toByteArray(); + double length = gzippedJson.length / 1024d; + double percent = gzippedJson.length * 100d / defaultJsonLength; + System.out.println(label + " GZIPped length: " + LENGTH_FORMATTER.format(length) + + "kB (" + PERCENT_FORMATTER.format(percent) + "%)"); + assertTrue(plainJson.length > gzippedJson.length, label + " should be longer than GZIPped data"); + } + + private byte[] createJsonAndVerify(String label, Object[] customers) throws IOException { + System.out.println(label + " sample: "); + ObjectWriter prettyWritter = mapper.writerWithDefaultPrettyPrinter(); + System.out.println(prettyWritter.writeValueAsString(customers[0])); + + byte[] feedback = mapper.writeValueAsBytes(customers); + double length = feedback.length / 1024d; + double percent = feedback.length * 100d / defaultJsonLength; + System.out.println(label + " length: " + LENGTH_FORMATTER.format(length) + + "kB (" + PERCENT_FORMATTER.format(percent) + "%)"); + assertTrue(feedback.length > 1, label + " should be there"); + + String prefix = label.replaceAll(" ", "-") + .toLowerCase(); + File tempFile = File.createTempFile("jon-optimization-" + prefix, ".json"); + FileOutputStream fos = new FileOutputStream(tempFile); + fos.write(feedback); + fos.close(); + System.out.println(label + " file: " + tempFile.toString()); + + Object[] restoredOnes = mapper.readValue(feedback, customers.getClass()); + assertArrayEquals(TEST_LABEL_JACKSON_DEFAULT_OPTIONS + ": restoring from JSON should work", customers, restoredOnes); + + return feedback; + } + +} diff --git a/json-2/src/test/resources/json_optimization_mock_data.json b/json-2/src/test/resources/json_optimization_mock_data.json new file mode 100644 index 0000000000..e09517cf61 --- /dev/null +++ b/json-2/src/test/resources/json_optimization_mock_data.json @@ -0,0 +1,1000 @@ +[{"id":1,"firstName":"Horatius","lastName":"Strognell","street":"4848 New Castle Point","postalCode":"33432","city":"Boca Raton","state":"FL","phoneNumber":"561-824-9105","email":"hstrognell0@dailymail.co.uk"}, +{"id":2,"firstName":"Kerri","lastName":"Arend","street":"4 Welch Pass","postalCode":"60669","city":"Chicago","state":"IL","phoneNumber":"312-303-5993"}, +{"id":3,"firstName":"Silvano","lastName":"Bartholomaus","street":"2491 Arkansas Center","postalCode":"30195","city":"Duluth","state":"GA","email":"sbartholomaus2@prlog.org"}, +{"id":4,"firstName":"Venita","lastName":"Burgoine","street":"63894 Sage Park","postalCode":"67215","city":"Wichita","state":"KS","email":"vburgoine3@telegraph.co.uk"}, +{"id":5,"firstName":"Meghan","lastName":"Westover","street":"76 Pleasure Way","postalCode":"77388","city":"Spring","state":"TX","phoneNumber":"832-926-0689","email":"mwestover4@cnn.com"}, +{"id":6,"firstName":"Mia","lastName":"Baversor","street":"50 Sommers Road","postalCode":"43204","city":"Columbus","state":"OH","email":"mbaversor5@wsj.com"}, +{"id":7,"firstName":"Winna","lastName":"Buggy","street":"05 Jenna Street","postalCode":"68144","city":"Omaha","state":"NE","phoneNumber":"402-740-7818"}, +{"id":8,"firstName":"Antonin","lastName":"Autrie","street":"9 Fieldstone Terrace","postalCode":"85754","city":"Tucson","state":"AZ"}, +{"id":9,"firstName":"Maddi","lastName":"Ollerearnshaw","street":"061 Crowley Trail","postalCode":"48335","city":"Farmington","state":"MI","phoneNumber":"248-709-8128"}, +{"id":10,"firstName":"Fawnia","lastName":"Cristofaro","street":"92571 Kinsman Alley","postalCode":"77271","city":"Houston","state":"TX","email":"fcristofaro9@ox.ac.uk"}, +{"id":11,"firstName":"Zachariah","lastName":"Rouby","street":"2439 Hudson Circle","postalCode":"25313","city":"Charleston","state":"WV","phoneNumber":"304-587-5444"}, +{"id":12,"firstName":"Brier","lastName":"Benech","street":"3144 Sutteridge Place","postalCode":"20380","city":"Washington","state":"DC","phoneNumber":"202-740-8851","email":"bbenechb@zdnet.com"}, +{"id":13,"firstName":"Merry","lastName":"Leming","street":"419 Kropf Terrace","postalCode":"45440","city":"Dayton","state":"OH","email":"mlemingc@ow.ly"}, +{"id":14,"firstName":"Audrey","lastName":"Dilleston","street":"61 Melrose Trail","postalCode":"97306","city":"Salem","state":"OR","phoneNumber":"503-480-6254"}, +{"id":15,"firstName":"De witt","lastName":"Kedge","street":"819 Kingsford Point","postalCode":"84135","city":"Salt Lake City","state":"UT"}, +{"id":16,"firstName":"Charita","lastName":"de Clerc","street":"42 Loftsgordon Hill","postalCode":"28289","city":"Charlotte","state":"NC","phoneNumber":"704-532-8850","email":"cdeclercf@comsenz.com"}, +{"id":17,"firstName":"Edgard","lastName":"Bloore","street":"1659 Donald Trail","postalCode":"20051","city":"Washington","state":"DC"}, +{"id":18,"firstName":"Kristi","lastName":"Richichi","street":"11306 Longview Hill","postalCode":"75372","city":"Dallas","state":"TX","email":"krichichih@cloudflare.com"}, +{"id":19,"firstName":"Denna","lastName":"Cornford","street":"4 Gale Junction","postalCode":"10014","city":"New York City","state":"NY","phoneNumber":"646-273-3067","email":"dcornfordi@ebay.co.uk"}, +{"id":20,"firstName":"Randall","lastName":"McQuaid","street":"55712 Stone Corner Circle","postalCode":"10203","city":"New York City","state":"NY","email":"rmcquaidj@facebook.com"}, +{"id":21,"firstName":"Kirbie","lastName":"Walczak","street":"9 Coleman Road","postalCode":"99252","city":"Spokane","state":"WA","email":"kwalczakk@spotify.com"}, +{"id":22,"firstName":"Zedekiah","lastName":"Westby","street":"9 Victoria Road","postalCode":"22093","city":"Ashburn","state":"VA","phoneNumber":"571-642-0111","email":"zwestbyl@ox.ac.uk"}, +{"id":23,"firstName":"Corri","lastName":"Snar","street":"4 Service Terrace","postalCode":"68517","city":"Lincoln","state":"NE","email":"csnarm@tinyurl.com"}, +{"id":24,"firstName":"Manny","lastName":"Marchington","street":"942 Westend Center","postalCode":"22119","city":"Merrifield","state":"VA","email":"mmarchingtonn@opensource.org"}, +{"id":25,"firstName":"Ashla","lastName":"Grigoroni","street":"755 Lerdahl Parkway","postalCode":"55423","city":"Minneapolis","state":"MN","phoneNumber":"612-797-7928","email":"agrigoronio@cam.ac.uk"}, +{"id":26,"firstName":"Rita","lastName":"Sharratt","street":"710 Buena Vista Avenue","postalCode":"40576","city":"Lexington","state":"KY","phoneNumber":"859-727-0697"}, +{"id":27,"firstName":"Karrie","lastName":"Crathorne","street":"02 Loeprich Place","postalCode":"39505","city":"Gulfport","state":"MS"}, +{"id":28,"firstName":"Lothario","lastName":"Merck","street":"46 Golden Leaf Park","postalCode":"35205","city":"Birmingham","state":"AL"}, +{"id":29,"firstName":"Renault","lastName":"Banister","street":"7 Garrison Plaza","postalCode":"85072","city":"Phoenix","state":"AZ"}, +{"id":30,"firstName":"Wanda","lastName":"Burkart","street":"10 Mendota Place","postalCode":"48258","city":"Detroit","state":"MI","phoneNumber":"248-870-5185","email":"wburkartt@wikipedia.org"}, +{"id":31,"firstName":"Maggy","lastName":"Timby","street":"37 Crest Line Center","postalCode":"50305","city":"Des Moines","state":"IA","email":"mtimbyu@cnbc.com"}, +{"id":32,"firstName":"Chet","lastName":"Origan","street":"767 Bashford Lane","postalCode":"30919","city":"Augusta","state":"GA","email":"coriganv@behance.net"}, +{"id":33,"firstName":"Jammie","lastName":"Aslie","street":"7174 Hoffman Circle","postalCode":"23464","city":"Virginia Beach","state":"VA"}, +{"id":34,"firstName":"Dill","lastName":"Kingdon","street":"75 Corben Crossing","postalCode":"33013","city":"Hialeah","state":"FL","email":"dkingdonx@ibm.com"}, +{"id":35,"firstName":"Berenice","lastName":"Blodget","street":"8 Eliot Junction","postalCode":"93907","city":"Salinas","state":"CA","email":"bblodgety@blogs.com"}, +{"id":36,"firstName":"Kimberley","lastName":"Streatley","street":"56 Welch Center","postalCode":"77070","city":"Houston","state":"TX"}, +{"id":37,"firstName":"Warde","lastName":"Woodwind","street":"773 Gerald Park","postalCode":"35295","city":"Birmingham","state":"AL","email":"wwoodwind10@wsj.com"}, +{"id":38,"firstName":"Husain","lastName":"Christofe","street":"35118 Forest Dale Avenue","postalCode":"10175","city":"New York City","state":"NY","phoneNumber":"212-611-7995","email":"hchristofe11@seesaa.net"}, +{"id":39,"firstName":"Gertrud","lastName":"Defraine","street":"568 Walton Way","postalCode":"37405","city":"Chattanooga","state":"TN","phoneNumber":"423-125-5719","email":"gdefraine12@xrea.com"}, +{"id":40,"firstName":"Yulma","lastName":"Ramshay","street":"9976 Iowa Drive","postalCode":"87121","city":"Albuquerque","state":"NM","phoneNumber":"505-914-5281"}, +{"id":41,"firstName":"Bride","lastName":"Amsberger","street":"3 Service Lane","postalCode":"28272","city":"Charlotte","state":"NC","email":"bamsberger14@forbes.com"}, +{"id":42,"firstName":"Kaiser","lastName":"Froud","street":"7 Starling Lane","postalCode":"99507","city":"Anchorage","state":"AK","email":"kfroud15@cloudflare.com"}, +{"id":43,"firstName":"Leona","lastName":"Sciusscietto","street":"06392 East Lane","postalCode":"60193","city":"Schaumburg","state":"IL","phoneNumber":"630-981-3986","email":"lsciusscietto16@mit.edu"}, +{"id":44,"firstName":"Sibel","lastName":"Ripsher","street":"8672 Bayside Road","postalCode":"32511","city":"Pensacola","state":"FL","phoneNumber":"850-975-6365","email":"sripsher17@sitemeter.com"}, +{"id":45,"firstName":"Megen","lastName":"Dymond","street":"0547 Harper Place","postalCode":"28220","city":"Charlotte","state":"NC","phoneNumber":"704-632-5850"}, +{"id":46,"firstName":"Vitoria","lastName":"Niese","street":"365 Colorado Plaza","postalCode":"15279","city":"Pittsburgh","state":"PA","phoneNumber":"412-864-8563"}, +{"id":47,"firstName":"Cherianne","lastName":"Daveran","street":"5 Esch Parkway","postalCode":"36104","city":"Montgomery","state":"AL","email":"cdaveran1a@ft.com"}, +{"id":48,"firstName":"Harriott","lastName":"Mallam","street":"9 Monterey Place","postalCode":"20215","city":"Washington","state":"DC","phoneNumber":"202-727-0645"}, +{"id":49,"firstName":"Jozef","lastName":"Stranger","street":"07 Warner Drive","postalCode":"84199","city":"Salt Lake City","state":"UT","phoneNumber":"801-741-5946"}, +{"id":50,"firstName":"Teena","lastName":"Broggio","street":"287 Luster Park","postalCode":"78285","city":"San Antonio","state":"TX","phoneNumber":"210-482-0822","email":"tbroggio1d@craigslist.org"}, +{"id":51,"firstName":"Robin","lastName":"Membry","street":"0736 Forest Dale Crossing","postalCode":"45408","city":"Dayton","state":"OH","phoneNumber":"937-335-4964","email":"rmembry1e@toplist.cz"}, +{"id":52,"firstName":"Holly","lastName":"Lowcock","street":"819 Aberg Pass","postalCode":"28815","city":"Asheville","state":"NC","email":"hlowcock1f@bbc.co.uk"}, +{"id":53,"firstName":"Shandee","lastName":"Blowick","street":"81600 Moose Lane","postalCode":"46867","city":"Fort Wayne","state":"IN","phoneNumber":"260-904-5622"}, +{"id":54,"firstName":"Chaim","lastName":"Stilliard","street":"91 Spohn Court","postalCode":"28305","city":"Fayetteville","state":"NC","phoneNumber":"910-721-3938"}, +{"id":55,"firstName":"Maximilien","lastName":"Purkis","street":"66997 Algoma Park","postalCode":"10150","city":"New York City","state":"NY","phoneNumber":"212-824-3363","email":"mpurkis1i@unblog.fr"}, +{"id":56,"firstName":"Ferguson","lastName":"Whiles","street":"0550 Bowman Street","postalCode":"33142","city":"Miami","state":"FL","phoneNumber":"786-416-2947","email":"fwhiles1j@artisteer.com"}, +{"id":57,"firstName":"Elena","lastName":"Poyle","street":"54 Warner Court","postalCode":"28055","city":"Gastonia","state":"NC","email":"epoyle1k@tripod.com"}, +{"id":58,"firstName":"Carney","lastName":"Pengilly","street":"050 Welch Junction","postalCode":"76147","city":"Fort Worth","state":"TX","phoneNumber":"817-525-7801","email":"cpengilly1l@yellowpages.com"}, +{"id":59,"firstName":"Krispin","lastName":"Pouck","street":"03554 Twin Pines Point","postalCode":"55551","city":"Young America","state":"MN","email":"kpouck1m@nymag.com"}, +{"id":60,"firstName":"Kylie","lastName":"Osmar","street":"7 Milwaukee Plaza","postalCode":"45228","city":"Cincinnati","state":"OH","phoneNumber":"513-940-5020","email":"kosmar1n@storify.com"}, +{"id":61,"firstName":"Trudi","lastName":"Standrin","street":"526 Onsgard Park","postalCode":"12237","city":"Albany","state":"NY","email":"tstandrin1o@sfgate.com"}, +{"id":62,"firstName":"Frank","lastName":"Belt","street":"52 Stang Lane","postalCode":"27455","city":"Greensboro","state":"NC"}, +{"id":63,"firstName":"Nerita","lastName":"Daulton","street":"03 Sutherland Court","postalCode":"55417","city":"Minneapolis","state":"MN","phoneNumber":"651-796-2028"}, +{"id":64,"firstName":"Urbanus","lastName":"Camm","street":"6802 Weeping Birch Circle","postalCode":"92115","city":"San Diego","state":"CA","email":"ucamm1r@ucoz.com"}, +{"id":65,"firstName":"Perry","lastName":"Struther","street":"63916 Corry Alley","postalCode":"28805","city":"Asheville","state":"NC","phoneNumber":"828-821-0824","email":"pstruther1s@nih.gov"}, +{"id":66,"firstName":"Zorina","lastName":"Uc","street":"99 Merry Circle","postalCode":"37250","city":"Nashville","state":"TN","phoneNumber":"615-364-4726","email":"zuc1t@cbc.ca"}, +{"id":67,"firstName":"Ajay","lastName":"Rediers","street":"6872 Armistice Lane","postalCode":"92812","city":"Anaheim","state":"CA","phoneNumber":"714-845-0143"}, +{"id":68,"firstName":"Brendis","lastName":"Goor","street":"94 Mccormick Place","postalCode":"77346","city":"Humble","state":"TX","phoneNumber":"713-910-5956"}, +{"id":69,"firstName":"Barbey","lastName":"Konneke","street":"75613 Miller Trail","postalCode":"30328","city":"Atlanta","state":"GA","phoneNumber":"770-208-1453"}, +{"id":70,"firstName":"Adlai","lastName":"Colly","street":"4446 Loftsgordon Place","postalCode":"40576","city":"Lexington","state":"KY","email":"acolly1x@phpbb.com"}, +{"id":71,"firstName":"Libby","lastName":"Wherton","street":"9313 Buell Road","postalCode":"70116","city":"New Orleans","state":"LA","email":"lwherton1y@flickr.com"}, +{"id":72,"firstName":"Niko","lastName":"Stockell","street":"61 Havey Park","postalCode":"10034","city":"New York City","state":"NY","phoneNumber":"646-814-6395","email":"nstockell1z@xrea.com"}, +{"id":73,"firstName":"Phillip","lastName":"Dadley","street":"14534 Victoria Street","postalCode":"33906","city":"Fort Myers","state":"FL","email":"pdadley20@studiopress.com"}, +{"id":74,"firstName":"Leann","lastName":"Hebburn","street":"9 Center Place","postalCode":"84140","city":"Salt Lake City","state":"UT","email":"lhebburn21@1688.com"}, +{"id":75,"firstName":"Raynor","lastName":"Gernier","street":"5923 Gale Plaza","postalCode":"79118","city":"Amarillo","state":"TX"}, +{"id":76,"firstName":"Elmore","lastName":"Frankton","street":"770 Wayridge Crossing","postalCode":"14619","city":"Rochester","state":"NY"}, +{"id":77,"firstName":"Teresina","lastName":"Rives","street":"51261 Sycamore Terrace","postalCode":"63180","city":"Saint Louis","state":"MO","email":"trives24@cbsnews.com"}, +{"id":78,"firstName":"Pancho","lastName":"Thebeaud","street":"72 Pierstorff Way","postalCode":"33705","city":"Saint Petersburg","state":"FL","phoneNumber":"813-335-3556"}, +{"id":79,"firstName":"Deanne","lastName":"Crighton","street":"95 Duke Plaza","postalCode":"71151","city":"Shreveport","state":"LA","phoneNumber":"318-218-7196","email":"dcrighton26@sphinn.com"}, +{"id":80,"firstName":"Brucie","lastName":"Bury","street":"8948 Knutson Lane","postalCode":"93740","city":"Fresno","state":"CA","email":"bbury27@twitter.com"}, +{"id":81,"firstName":"Joleen","lastName":"Flack","street":"8007 Morningstar Street","postalCode":"33283","city":"Miami","state":"FL","phoneNumber":"305-459-0365"}, +{"id":82,"firstName":"Antonino","lastName":"Matelyunas","street":"2585 Gale Road","postalCode":"20591","city":"Washington","state":"DC","phoneNumber":"202-780-3589"}, +{"id":83,"firstName":"Vinnie","lastName":"Syne","street":"6 Fallview Pass","postalCode":"20231","city":"Washington","state":"DC","phoneNumber":"202-648-5977","email":"vsyne2a@etsy.com"}, +{"id":84,"firstName":"Sig","lastName":"Guillotin","street":"6 Buell Lane","postalCode":"46015","city":"Anderson","state":"IN","phoneNumber":"765-948-7663","email":"sguillotin2b@cisco.com"}, +{"id":85,"firstName":"Gabriel","lastName":"Vasyukhichev","street":"25801 Grasskamp Junction","postalCode":"45408","city":"Dayton","state":"OH","email":"gvasyukhichev2c@mac.com"}, +{"id":86,"firstName":"Casie","lastName":"Burgill","street":"0 Dapin Alley","postalCode":"37410","city":"Chattanooga","state":"TN"}, +{"id":87,"firstName":"Kristan","lastName":"Chalice","street":"5118 Calypso Junction","postalCode":"78721","city":"Austin","state":"TX","phoneNumber":"512-831-2347"}, +{"id":88,"firstName":"Brear","lastName":"Pruckner","street":"2 Corscot Street","postalCode":"53790","city":"Madison","state":"WI"}, +{"id":89,"firstName":"Estella","lastName":"Orpyne","street":"293 Hansons Plaza","postalCode":"55579","city":"Maple Plain","state":"MN","phoneNumber":"952-666-6951","email":"eorpyne2g@examiner.com"}, +{"id":90,"firstName":"Conroy","lastName":"de Banke","street":"40636 Farmco Park","postalCode":"30316","city":"Atlanta","state":"GA","phoneNumber":"404-199-0073","email":"cdebanke2h@prweb.com"}, +{"id":91,"firstName":"Elmira","lastName":"Bracken","street":"10 Macpherson Place","postalCode":"85099","city":"Phoenix","state":"AZ","phoneNumber":"602-991-7768","email":"ebracken2i@sourceforge.net"}, +{"id":92,"firstName":"Carlota","lastName":"Vasilechko","street":"33 American Ash Point","postalCode":"75507","city":"Texarkana","state":"TX","phoneNumber":"903-312-0610","email":"cvasilechko2j@nba.com"}, +{"id":93,"firstName":"Jamesy","lastName":"Valentelli","street":"59634 Charing Cross Trail","postalCode":"31416","city":"Savannah","state":"GA","phoneNumber":"912-657-6729","email":"jvalentelli2k@nifty.com"}, +{"id":94,"firstName":"Hildagarde","lastName":"Sandels","street":"1 Lotheville Lane","postalCode":"32277","city":"Jacksonville","state":"FL","phoneNumber":"904-981-2753","email":"hsandels2l@a8.net"}, +{"id":95,"firstName":"Kip","lastName":"Cranidge","street":"2 South Road","postalCode":"19160","city":"Philadelphia","state":"PA"}, +{"id":96,"firstName":"Tobit","lastName":"Jarrette","street":"777 Mallard Trail","postalCode":"49444","city":"Muskegon","state":"MI","phoneNumber":"231-706-1988"}, +{"id":97,"firstName":"Tibold","lastName":"Michie","street":"87796 Nevada Junction","postalCode":"22093","city":"Ashburn","state":"VA","phoneNumber":"571-188-4893","email":"tmichie2o@mapy.cz"}, +{"id":98,"firstName":"Maximo","lastName":"Ifill","street":"8307 Tony Point","postalCode":"22225","city":"Arlington","state":"VA","phoneNumber":"571-404-1412"}, +{"id":99,"firstName":"Patti","lastName":"Autry","street":"901 Iowa Crossing","postalCode":"55551","city":"Young America","state":"MN","phoneNumber":"952-772-9107","email":"pautry2q@scientificamerican.com"}, +{"id":100,"firstName":"Cathe","lastName":"Jost","street":"4400 Menomonie Road","postalCode":"21211","city":"Baltimore","state":"MD","phoneNumber":"410-800-4683","email":"cjost2r@tuttocitta.it"}, +{"id":101,"firstName":"Byron","lastName":"Maddams","street":"10729 Oak Trail","postalCode":"78255","city":"San Antonio","state":"TX","phoneNumber":"830-263-4129"}, +{"id":102,"firstName":"Sosanna","lastName":"Paley","street":"82207 Park Meadow Court","postalCode":"77010","city":"Houston","state":"TX","phoneNumber":"832-740-8766","email":"spaley2t@salon.com"}, +{"id":103,"firstName":"Elysia","lastName":"Skerratt","street":"88708 Cambridge Drive","postalCode":"31217","city":"Macon","state":"GA","phoneNumber":"478-265-6579","email":"eskerratt2u@japanpost.jp"}, +{"id":104,"firstName":"Nealson","lastName":"Sieur","street":"1286 Elmside Plaza","postalCode":"20904","city":"Silver Spring","state":"MD"}, +{"id":105,"firstName":"Yasmeen","lastName":"Bazire","street":"91904 Elmside Point","postalCode":"73167","city":"Oklahoma City","state":"OK"}, +{"id":106,"firstName":"Mandy","lastName":"Ewart","street":"91 Norway Maple Street","postalCode":"21239","city":"Baltimore","state":"MD","email":"mewart2x@weebly.com"}, +{"id":107,"firstName":"Chlo","lastName":"Keedy","street":"560 Oak Valley Avenue","postalCode":"20420","city":"Washington","state":"DC"}, +{"id":108,"firstName":"Benedicta","lastName":"Dinneen","street":"9 Cottonwood Circle","postalCode":"60686","city":"Chicago","state":"IL","email":"bdinneen2z@nydailynews.com"}, +{"id":109,"firstName":"Nanon","lastName":"Corsar","street":"40001 Barby Drive","postalCode":"95818","city":"Sacramento","state":"CA","email":"ncorsar30@house.gov"}, +{"id":110,"firstName":"Babette","lastName":"Scarsbrick","street":"96095 Loomis Terrace","postalCode":"94622","city":"Oakland","state":"CA","email":"bscarsbrick31@smugmug.com"}, +{"id":111,"firstName":"Cornall","lastName":"Christauffour","street":"9 Springview Alley","postalCode":"84170","city":"Salt Lake City","state":"UT","phoneNumber":"801-935-1246","email":"cchristauffour32@booking.com"}, +{"id":112,"firstName":"Micki","lastName":"Labell","street":"77729 Heath Place","postalCode":"25336","city":"Charleston","state":"WV"}, +{"id":113,"firstName":"Marissa","lastName":"Bricksey","street":"1 Jackson Pass","postalCode":"11470","city":"Jamaica","state":"NY","phoneNumber":"917-552-4280"}, +{"id":114,"firstName":"Alex","lastName":"Lyptrade","street":"74 Bunting Circle","postalCode":"40591","city":"Lexington","state":"KY","phoneNumber":"859-177-0753"}, +{"id":115,"firstName":"Tove","lastName":"Bielfeldt","street":"95 Mallard Hill","postalCode":"70894","city":"Baton Rouge","state":"LA","email":"tbielfeldt36@goo.gl"}, +{"id":116,"firstName":"Rodrigo","lastName":"Chestle","street":"53625 1st Junction","postalCode":"43635","city":"Toledo","state":"OH","phoneNumber":"419-928-0953","email":"rchestle37@princeton.edu"}, +{"id":117,"firstName":"Ulrike","lastName":"Kendle","street":"0 Cardinal Alley","postalCode":"80925","city":"Colorado Springs","state":"CO","phoneNumber":"719-796-1992","email":"ukendle38@naver.com"}, +{"id":118,"firstName":"Sandor","lastName":"Warwick","street":"8 Spaight Crossing","postalCode":"92030","city":"Escondido","state":"CA","email":"swarwick39@about.com"}, +{"id":119,"firstName":"Selina","lastName":"Slowcock","street":"7 7th Circle","postalCode":"50335","city":"Des Moines","state":"IA","phoneNumber":"515-865-9809"}, +{"id":120,"firstName":"Maxine","lastName":"Placstone","street":"42056 Sycamore Plaza","postalCode":"20244","city":"Washington","state":"DC"}, +{"id":121,"firstName":"Ardine","lastName":"Reven","street":"10634 Nancy Way","postalCode":"10175","city":"New York City","state":"NY","email":"areven3c@diigo.com"}, +{"id":122,"firstName":"Dilan","lastName":"Widdows","street":"37 Park Meadow Way","postalCode":"68144","city":"Omaha","state":"NE","phoneNumber":"402-383-9020"}, +{"id":123,"firstName":"Kevina","lastName":"Praten","street":"8531 Elmside Point","postalCode":"27610","city":"Raleigh","state":"NC","email":"kpraten3e@craigslist.org"}, +{"id":124,"firstName":"Sherman","lastName":"Jurczak","street":"8281 Acker Alley","postalCode":"07522","city":"Paterson","state":"NJ","email":"sjurczak3f@github.com"}, +{"id":125,"firstName":"Beckie","lastName":"Disney","street":"3 Butterfield Drive","postalCode":"49518","city":"Grand Rapids","state":"MI","phoneNumber":"616-493-1284","email":"bdisney3g@china.com.cn"}, +{"id":126,"firstName":"Blaine","lastName":"Leak","street":"369 Norway Maple Lane","postalCode":"03804","city":"Portsmouth","state":"NH","email":"bleak3h@lulu.com"}, +{"id":127,"firstName":"Dare","lastName":"Marney","street":"50 Lake View Alley","postalCode":"06505","city":"New Haven","state":"CT","phoneNumber":"203-876-6938","email":"dmarney3i@delicious.com"}, +{"id":128,"firstName":"Darby","lastName":"Sackler","street":"841 Ridgeview Trail","postalCode":"80279","city":"Denver","state":"CO"}, +{"id":129,"firstName":"Aurilia","lastName":"Seabrocke","street":"670 Schmedeman Road","postalCode":"11254","city":"Brooklyn","state":"NY","email":"aseabrocke3k@engadget.com"}, +{"id":130,"firstName":"Griz","lastName":"Riccioppo","street":"2204 Moland Circle","postalCode":"45218","city":"Cincinnati","state":"OH","email":"griccioppo3l@cisco.com"}, +{"id":131,"firstName":"Zahara","lastName":"Quinion","street":"4979 Mallory Circle","postalCode":"24515","city":"Lynchburg","state":"VA","email":"zquinion3m@sfgate.com"}, +{"id":132,"firstName":"Holly-anne","lastName":"Fontel","street":"60752 Hallows Circle","postalCode":"76705","city":"Waco","state":"TX","phoneNumber":"254-822-2565","email":"hfontel3n@exblog.jp"}, +{"id":133,"firstName":"Johannes","lastName":"Lemonby","street":"3 Grover Terrace","postalCode":"25709","city":"Huntington","state":"WV","phoneNumber":"304-342-4911","email":"jlemonby3o@woothemes.com"}, +{"id":134,"firstName":"Melvin","lastName":"Kain","street":"16 Pond Junction","postalCode":"85215","city":"Mesa","state":"AZ","phoneNumber":"602-146-3701"}, +{"id":135,"firstName":"Letta","lastName":"Smelley","street":"537 Helena Circle","postalCode":"22119","city":"Merrifield","state":"VA","phoneNumber":"571-472-5640"}, +{"id":136,"firstName":"Clerc","lastName":"Mc Ilwrick","street":"7050 Northfield Street","postalCode":"90050","city":"Los Angeles","state":"CA","email":"cmcilwrick3r@abc.net.au"}, +{"id":137,"firstName":"Abba","lastName":"Sutherns","street":"8087 Monterey Lane","postalCode":"83757","city":"Boise","state":"ID","phoneNumber":"208-110-3153","email":"asutherns3s@dropbox.com"}, +{"id":138,"firstName":"Karola","lastName":"Symper","street":"4596 Clyde Gallagher Road","postalCode":"28815","city":"Asheville","state":"NC","email":"ksymper3t@parallels.com"}, +{"id":139,"firstName":"Jessamyn","lastName":"Deacock","street":"19557 Bobwhite Way","postalCode":"19725","city":"Newark","state":"DE","phoneNumber":"302-174-2938"}, +{"id":140,"firstName":"Iggy","lastName":"Impey","street":"8 Brown Place","postalCode":"27499","city":"Greensboro","state":"NC"}, +{"id":141,"firstName":"Kary","lastName":"Mably","street":"75 Porter Avenue","postalCode":"70174","city":"New Orleans","state":"LA","email":"kmably3w@miibeian.gov.cn"}, +{"id":142,"firstName":"Ciel","lastName":"Tidbold","street":"54 Mitchell Lane","postalCode":"90055","city":"Los Angeles","state":"CA"}, +{"id":143,"firstName":"Dyana","lastName":"Orcott","street":"2 Kinsman Street","postalCode":"90005","city":"Los Angeles","state":"CA","phoneNumber":"310-366-6987"}, +{"id":144,"firstName":"Damien","lastName":"Haking","street":"2 Elmside Point","postalCode":"62705","city":"Springfield","state":"IL","email":"dhaking3z@drupal.org"}, +{"id":145,"firstName":"Ricardo","lastName":"Bille","street":"3 Mesta Hill","postalCode":"98411","city":"Tacoma","state":"WA","email":"rbille40@ebay.co.uk"}, +{"id":146,"firstName":"Carlene","lastName":"Roget","street":"8 Granby Avenue","postalCode":"35225","city":"Birmingham","state":"AL","phoneNumber":"205-762-4907","email":"croget41@statcounter.com"}, +{"id":147,"firstName":"Sharlene","lastName":"Antusch","street":"02445 Stang Parkway","postalCode":"55480","city":"Minneapolis","state":"MN","email":"santusch42@mtv.com"}, +{"id":148,"firstName":"Goober","lastName":"Danielczyk","street":"474 Union Court","postalCode":"70505","city":"Lafayette","state":"LA","phoneNumber":"337-779-0312","email":"gdanielczyk43@dion.ne.jp"}, +{"id":149,"firstName":"Janette","lastName":"Mauro","street":"1231 Commercial Crossing","postalCode":"97201","city":"Portland","state":"OR","phoneNumber":"971-423-7259"}, +{"id":150,"firstName":"Melinda","lastName":"Shitliffe","street":"244 Derek Drive","postalCode":"23208","city":"Richmond","state":"VA","phoneNumber":"804-864-5845"}, +{"id":151,"firstName":"Constance","lastName":"Fardon","street":"3 Lien Point","postalCode":"89105","city":"Las Vegas","state":"NV"}, +{"id":152,"firstName":"Tedd","lastName":"Storey","street":"2551 Luster Point","postalCode":"19151","city":"Philadelphia","state":"PA","phoneNumber":"215-622-9273","email":"tstorey47@google.com.au"}, +{"id":153,"firstName":"Brigitte","lastName":"Slograve","street":"8130 Waubesa Hill","postalCode":"11499","city":"Jamaica","state":"NY","email":"bslograve48@yandex.ru"}, +{"id":154,"firstName":"Ralph","lastName":"Comberbeach","street":"88140 Anderson Avenue","postalCode":"90076","city":"Los Angeles","state":"CA"}, +{"id":155,"firstName":"Deloria","lastName":"Thomazet","street":"666 Center Crossing","postalCode":"38119","city":"Memphis","state":"TN","phoneNumber":"615-840-7916"}, +{"id":156,"firstName":"Fidel","lastName":"MacClay","street":"01 Fairfield Point","postalCode":"24034","city":"Roanoke","state":"VA","email":"fmacclay4b@sitemeter.com"}, +{"id":157,"firstName":"Amalee","lastName":"Menzies","street":"6 Judy Drive","postalCode":"84605","city":"Provo","state":"UT"}, +{"id":158,"firstName":"Ansel","lastName":"Jory","street":"3 Nobel Park","postalCode":"32505","city":"Pensacola","state":"FL","phoneNumber":"850-394-8201"}, +{"id":159,"firstName":"Teodor","lastName":"Longhorn","street":"563 Sutherland Avenue","postalCode":"98008","city":"Bellevue","state":"WA"}, +{"id":160,"firstName":"Margarita","lastName":"Rewcassell","street":"64711 Beilfuss Point","postalCode":"79764","city":"Odessa","state":"TX","phoneNumber":"432-413-2196"}, +{"id":161,"firstName":"Tarra","lastName":"Albro","street":"2 Graceland Way","postalCode":"78405","city":"Corpus Christi","state":"TX"}, +{"id":162,"firstName":"Whitaker","lastName":"Brizell","street":"6 Luster Place","postalCode":"33694","city":"Tampa","state":"FL","email":"wbrizell4h@naver.com"}, +{"id":163,"firstName":"Gauthier","lastName":"Getsham","street":"0820 Duke Plaza","postalCode":"28263","city":"Charlotte","state":"NC","phoneNumber":"704-510-2908"}, +{"id":164,"firstName":"Thane","lastName":"Discombe","street":"56809 Aberg Street","postalCode":"63167","city":"Saint Louis","state":"MO"}, +{"id":165,"firstName":"Felicia","lastName":"Barthrup","street":"904 Stuart Junction","postalCode":"32220","city":"Jacksonville","state":"FL"}, +{"id":166,"firstName":"Emeline","lastName":"Jobes","street":"2670 Prairieview Plaza","postalCode":"10120","city":"New York City","state":"NY","email":"ejobes4l@newyorker.com"}, +{"id":167,"firstName":"Felicle","lastName":"Bowie","street":"9715 Lighthouse Bay Parkway","postalCode":"11210","city":"Brooklyn","state":"NY","email":"fbowie4m@auda.org.au"}, +{"id":168,"firstName":"Clare","lastName":"Miskelly","street":"8 Towne Trail","postalCode":"44555","city":"Youngstown","state":"OH"}, +{"id":169,"firstName":"Mort","lastName":"Danat","street":"6833 Shoshone Lane","postalCode":"12255","city":"Albany","state":"NY","phoneNumber":"518-967-9791","email":"mdanat4o@privacy.gov.au"}, +{"id":170,"firstName":"Ailey","lastName":"Scatchar","street":"3 Northfield Point","postalCode":"76505","city":"Temple","state":"TX"}, +{"id":171,"firstName":"Kevina","lastName":"Darwent","street":"8165 Reinke Alley","postalCode":"94132","city":"San Francisco","state":"CA","email":"kdarwent4q@artisteer.com"}, +{"id":172,"firstName":"My","lastName":"Buston","street":"715 Saint Paul Center","postalCode":"31416","city":"Savannah","state":"GA","phoneNumber":"912-281-8654"}, +{"id":173,"firstName":"Emera","lastName":"Lingner","street":"943 Eastlawn Hill","postalCode":"90605","city":"Whittier","state":"CA"}, +{"id":174,"firstName":"Drucie","lastName":"Byer","street":"988 4th Court","postalCode":"06816","city":"Danbury","state":"CT","email":"dbyer4t@xinhuanet.com"}, +{"id":175,"firstName":"Modestine","lastName":"Madeley","street":"1 Delaware Terrace","postalCode":"80126","city":"Littleton","state":"CO"}, +{"id":176,"firstName":"Selie","lastName":"O'Mohun","street":"42 Monument Trail","postalCode":"55590","city":"Monticello","state":"MN","phoneNumber":"763-384-5166"}, +{"id":177,"firstName":"Shayla","lastName":"Pesselt","street":"7 Pawling Center","postalCode":"20099","city":"Washington","state":"DC","phoneNumber":"202-816-7300","email":"spesselt4w@posterous.com"}, +{"id":178,"firstName":"Raeann","lastName":"Layland","street":"06548 Longview Alley","postalCode":"77005","city":"Houston","state":"TX","phoneNumber":"214-899-1257","email":"rlayland4x@pcworld.com"}, +{"id":179,"firstName":"Dael","lastName":"Christaeas","street":"375 Northfield Street","postalCode":"23509","city":"Norfolk","state":"VA","phoneNumber":"757-391-2798","email":"dchristaeas4y@sciencedaily.com"}, +{"id":180,"firstName":"Nicolas","lastName":"Baxill","street":"9 Autumn Leaf Terrace","postalCode":"77005","city":"Houston","state":"TX","email":"nbaxill4z@edublogs.org"}, +{"id":181,"firstName":"Onida","lastName":"Pengilly","street":"61 Commercial Junction","postalCode":"24029","city":"Roanoke","state":"VA","email":"opengilly50@slideshare.net"}, +{"id":182,"firstName":"Muffin","lastName":"Thrasher","street":"1 Morning Hill","postalCode":"64082","city":"Lees Summit","state":"MO"}, +{"id":183,"firstName":"Ignaz","lastName":"McLugish","street":"3936 Columbus Point","postalCode":"35263","city":"Birmingham","state":"AL"}, +{"id":184,"firstName":"Guillaume","lastName":"Gillings","street":"75541 Sheridan Center","postalCode":"68510","city":"Lincoln","state":"NE","email":"ggillings53@unblog.fr"}, +{"id":185,"firstName":"Kalli","lastName":"Branche","street":"33740 Manitowish Court","postalCode":"96805","city":"Honolulu","state":"HI"}, +{"id":186,"firstName":"Winthrop","lastName":"Barszczewski","street":"9 Luster Terrace","postalCode":"60158","city":"Carol Stream","state":"IL","phoneNumber":"309-633-3125","email":"wbarszczewski55@eventbrite.com"}, +{"id":187,"firstName":"Renaud","lastName":"Nitto","street":"1 Crownhardt Place","postalCode":"10310","city":"Staten Island","state":"NY","phoneNumber":"914-568-4524","email":"rnitto56@typepad.com"}, +{"id":188,"firstName":"Pollyanna","lastName":"Wherrett","street":"31380 Upham Street","postalCode":"76134","city":"Fort Worth","state":"TX","phoneNumber":"817-198-3301","email":"pwherrett57@bluehost.com"}, +{"id":189,"firstName":"Lilly","lastName":"Gatchell","street":"7 Elka Road","postalCode":"94064","city":"Redwood City","state":"CA","email":"lgatchell58@patch.com"}, +{"id":190,"firstName":"Leopold","lastName":"Leavey","street":"9 Darwin Crossing","postalCode":"20268","city":"Washington","state":"DC","phoneNumber":"202-964-5932","email":"lleavey59@aol.com"}, +{"id":191,"firstName":"Byram","lastName":"Stuckes","street":"782 Northport Alley","postalCode":"55436","city":"Minneapolis","state":"MN"}, +{"id":192,"firstName":"Cull","lastName":"Whiterod","street":"2586 Banding Terrace","postalCode":"80249","city":"Denver","state":"CO","email":"cwhiterod5b@skype.com"}, +{"id":193,"firstName":"Gretel","lastName":"Tacey","street":"6382 Fremont Avenue","postalCode":"25305","city":"Charleston","state":"WV"}, +{"id":194,"firstName":"Tudor","lastName":"Piff","street":"0 Monterey Circle","postalCode":"00214","city":"Portsmouth","state":"NH","email":"tpiff5d@eepurl.com"}, +{"id":195,"firstName":"Julienne","lastName":"Adshed","street":"91839 Lawn Avenue","postalCode":"92519","city":"Riverside","state":"CA"}, +{"id":196,"firstName":"Arnold","lastName":"Fearns","street":"7 West Trail","postalCode":"35242","city":"Birmingham","state":"AL","email":"afearns5f@bravesites.com"}, +{"id":197,"firstName":"Dunc","lastName":"Khoter","street":"048 Clove Lane","postalCode":"89505","city":"Reno","state":"NV","phoneNumber":"775-120-9532","email":"dkhoter5g@bbb.org"}, +{"id":198,"firstName":"Stevana","lastName":"Lush","street":"6 Dovetail Plaza","postalCode":"79945","city":"El Paso","state":"TX","email":"slush5h@economist.com"}, +{"id":199,"firstName":"Iggy","lastName":"Verryan","street":"5 Sommers Road","postalCode":"34114","city":"Naples","state":"FL","phoneNumber":"239-205-8767"}, +{"id":200,"firstName":"Breena","lastName":"Rubbert","street":"5 Kensington Crossing","postalCode":"90510","city":"Torrance","state":"CA","email":"brubbert5j@phpbb.com"}, +{"id":201,"firstName":"Jervis","lastName":"Doree","street":"2947 Center Plaza","postalCode":"70160","city":"New Orleans","state":"LA","phoneNumber":"504-278-7497","email":"jdoree5k@shutterfly.com"}, +{"id":202,"firstName":"Odelia","lastName":"Lidierth","street":"36699 Aberg Park","postalCode":"62764","city":"Springfield","state":"IL"}, +{"id":203,"firstName":"Ree","lastName":"Lammerding","street":"3542 Lerdahl Court","postalCode":"88558","city":"El Paso","state":"TX","phoneNumber":"915-384-9334","email":"rlammerding5m@msu.edu"}, +{"id":204,"firstName":"Davy","lastName":"Orniz","street":"49 Graedel Parkway","postalCode":"48295","city":"Detroit","state":"MI","email":"dorniz5n@examiner.com"}, +{"id":205,"firstName":"Syd","lastName":"Buckoke","street":"70 Pepper Wood Alley","postalCode":"74156","city":"Tulsa","state":"OK","phoneNumber":"918-604-5799"}, +{"id":206,"firstName":"Ginger","lastName":"Calkin","street":"7 Thompson Trail","postalCode":"71115","city":"Shreveport","state":"LA","phoneNumber":"318-650-6046"}, +{"id":207,"firstName":"Anissa","lastName":"Ivashinnikov","street":"61905 Chive Circle","postalCode":"40745","city":"London","state":"KY","email":"aivashinnikov5q@google.cn"}, +{"id":208,"firstName":"Vikky","lastName":"Kesley","street":"1 Grayhawk Street","postalCode":"06538","city":"New Haven","state":"CT","phoneNumber":"203-944-7163"}, +{"id":209,"firstName":"Alisha","lastName":"Lampke","street":"26940 Kensington Park","postalCode":"55446","city":"Minneapolis","state":"MN","phoneNumber":"612-814-9814","email":"alampke5s@apple.com"}, +{"id":210,"firstName":"Davidde","lastName":"Phlipon","street":"2044 Ruskin Road","postalCode":"07188","city":"Newark","state":"NJ","email":"dphlipon5t@shareasale.com"}, +{"id":211,"firstName":"Joly","lastName":"Crottagh","street":"532 Dawn Plaza","postalCode":"85083","city":"Phoenix","state":"AZ","phoneNumber":"602-533-4064"}, +{"id":212,"firstName":"Aggie","lastName":"Niesing","street":"3 Tony Drive","postalCode":"57110","city":"Sioux Falls","state":"SD","email":"aniesing5v@pbs.org"}, +{"id":213,"firstName":"Daron","lastName":"Baudassi","street":"2411 Melvin Court","postalCode":"40581","city":"Lexington","state":"KY","phoneNumber":"859-754-2542","email":"dbaudassi5w@joomla.org"}, +{"id":214,"firstName":"Thadeus","lastName":"Kleiser","street":"1394 Warner Street","postalCode":"87592","city":"Santa Fe","state":"NM","email":"tkleiser5x@bloomberg.com"}, +{"id":215,"firstName":"Terri","lastName":"Perrat","street":"0080 Upham Plaza","postalCode":"52245","city":"Iowa City","state":"IA"}, +{"id":216,"firstName":"Marlena","lastName":"Gatchell","street":"60888 Annamark Street","postalCode":"90060","city":"Los Angeles","state":"CA","phoneNumber":"323-121-6985","email":"mgatchell5z@ibm.com"}, +{"id":217,"firstName":"Locke","lastName":"Orcott","street":"459 Warner Lane","postalCode":"45020","city":"Hamilton","state":"OH","phoneNumber":"937-115-3187"}, +{"id":218,"firstName":"Wilmer","lastName":"Bewick","street":"0 Ohio Center","postalCode":"98166","city":"Seattle","state":"WA","phoneNumber":"253-805-8855","email":"wbewick61@seesaa.net"}, +{"id":219,"firstName":"Marena","lastName":"MacShirrie","street":"607 Badeau Circle","postalCode":"98008","city":"Bellevue","state":"WA","email":"mmacshirrie62@wikia.com"}, +{"id":220,"firstName":"Nathanial","lastName":"Sexty","street":"43 Basil Place","postalCode":"85020","city":"Phoenix","state":"AZ"}, +{"id":221,"firstName":"Wadsworth","lastName":"Iacovuzzi","street":"9610 Donald Crossing","postalCode":"88530","city":"El Paso","state":"TX","phoneNumber":"915-889-7936","email":"wiacovuzzi64@prnewswire.com"}, +{"id":222,"firstName":"Sutton","lastName":"Stych","street":"9 Brentwood Terrace","postalCode":"20546","city":"Washington","state":"DC","phoneNumber":"202-538-6355","email":"sstych65@wikimedia.org"}, +{"id":223,"firstName":"Gaspar","lastName":"Wabey","street":"3061 Bluejay Terrace","postalCode":"10110","city":"New York City","state":"NY","phoneNumber":"917-939-0802","email":"gwabey66@technorati.com"}, +{"id":224,"firstName":"Herminia","lastName":"Guyot","street":"91 Express Drive","postalCode":"85715","city":"Tucson","state":"AZ","phoneNumber":"520-777-1670","email":"hguyot67@admin.ch"}, +{"id":225,"firstName":"Udale","lastName":"Beurich","street":"675 Karstens Crossing","postalCode":"46852","city":"Fort Wayne","state":"IN","phoneNumber":"260-580-8627","email":"ubeurich68@bigcartel.com"}, +{"id":226,"firstName":"Kerrie","lastName":"Girauld","street":"56132 Charing Cross Court","postalCode":"71137","city":"Shreveport","state":"LA","email":"kgirauld69@nationalgeographic.com"}, +{"id":227,"firstName":"Irvin","lastName":"Nix","street":"0676 Aberg Terrace","postalCode":"97075","city":"Beaverton","state":"OR","email":"inix6a@xing.com"}, +{"id":228,"firstName":"Corene","lastName":"Spencock","street":"90 Meadow Ridge Drive","postalCode":"73173","city":"Oklahoma City","state":"OK","phoneNumber":"405-577-1312","email":"cspencock6b@shinystat.com"}, +{"id":229,"firstName":"Christos","lastName":"McIlreavy","street":"673 Jana Trail","postalCode":"23471","city":"Virginia Beach","state":"VA","email":"cmcilreavy6c@mayoclinic.com"}, +{"id":230,"firstName":"Bennett","lastName":"Melding","street":"4 Cardinal Lane","postalCode":"55448","city":"Minneapolis","state":"MN","email":"bmelding6d@t-online.de"}, +{"id":231,"firstName":"Winny","lastName":"de Leon","street":"941 Scoville Place","postalCode":"94611","city":"Oakland","state":"CA","phoneNumber":"510-230-4168","email":"wdeleon6e@dell.com"}, +{"id":232,"firstName":"Nike","lastName":"Iacobassi","street":"956 Service Junction","postalCode":"71914","city":"Hot Springs National Park","state":"AR","phoneNumber":"501-266-4142"}, +{"id":233,"firstName":"Gillan","lastName":"Baumann","street":"11 8th Alley","postalCode":"31190","city":"Atlanta","state":"GA","phoneNumber":"404-703-5154","email":"gbaumann6g@edublogs.org"}, +{"id":234,"firstName":"Brandtr","lastName":"Gadman","street":"5 Marquette Hill","postalCode":"32511","city":"Pensacola","state":"FL","phoneNumber":"850-834-0058","email":"bgadman6h@marriott.com"}, +{"id":235,"firstName":"Kenn","lastName":"Cage","street":"3759 Spohn Point","postalCode":"94126","city":"San Francisco","state":"CA","email":"kcage6i@earthlink.net"}, +{"id":236,"firstName":"Butch","lastName":"Causby","street":"02 Basil Crossing","postalCode":"10110","city":"New York City","state":"NY","phoneNumber":"212-190-1702","email":"bcausby6j@scribd.com"}, +{"id":237,"firstName":"Haleigh","lastName":"Parsonson","street":"8 Ruskin Trail","postalCode":"87201","city":"Albuquerque","state":"NM","phoneNumber":"505-987-1352"}, +{"id":238,"firstName":"Bartel","lastName":"Ruppeli","street":"7538 Red Cloud Center","postalCode":"37410","city":"Chattanooga","state":"TN","phoneNumber":"423-804-1016","email":"bruppeli6l@etsy.com"}, +{"id":239,"firstName":"Gretchen","lastName":"Le feaver","street":"7 Orin Way","postalCode":"98042","city":"Kent","state":"WA","phoneNumber":"253-205-3092","email":"glefeaver6m@mayoclinic.com"}, +{"id":240,"firstName":"Trumaine","lastName":"Dearden","street":"1 Vernon Trail","postalCode":"06127","city":"West Hartford","state":"CT","phoneNumber":"860-939-3865","email":"tdearden6n@goo.gl"}, +{"id":241,"firstName":"Aggie","lastName":"Dubs","street":"3601 Walton Trail","postalCode":"62764","city":"Springfield","state":"IL","phoneNumber":"217-834-6059","email":"adubs6o@cbsnews.com"}, +{"id":242,"firstName":"Shelly","lastName":"Skechley","street":"16 Morning Lane","postalCode":"60567","city":"Naperville","state":"IL","email":"sskechley6p@technorati.com"}, +{"id":243,"firstName":"Karin","lastName":"Fausch","street":"7532 Eggendart Way","postalCode":"19810","city":"Wilmington","state":"DE","phoneNumber":"302-548-2991"}, +{"id":244,"firstName":"Sal","lastName":"Harrow","street":"2632 Lien Way","postalCode":"33982","city":"Punta Gorda","state":"FL","phoneNumber":"941-904-5187","email":"sharrow6r@joomla.org"}, +{"id":245,"firstName":"Albie","lastName":"Strelitzki","street":"8436 Eggendart Terrace","postalCode":"49505","city":"Grand Rapids","state":"MI","email":"astrelitzki6s@google.com.br"}, +{"id":246,"firstName":"Augy","lastName":"Usherwood","street":"9078 Clemons Street","postalCode":"80915","city":"Colorado Springs","state":"CO","email":"ausherwood6t@wikimedia.org"}, +{"id":247,"firstName":"Solomon","lastName":"D'eathe","street":"778 Rockefeller Parkway","postalCode":"84199","city":"Salt Lake City","state":"UT"}, +{"id":248,"firstName":"Talya","lastName":"Joseff","street":"14 Graedel Court","postalCode":"99220","city":"Spokane","state":"WA","email":"tjoseff6v@amazon.de"}, +{"id":249,"firstName":"Anatol","lastName":"Self","street":"2 Stoughton Junction","postalCode":"85255","city":"Scottsdale","state":"AZ"}, +{"id":250,"firstName":"Elinore","lastName":"Bruhnke","street":"3 Bashford Alley","postalCode":"17105","city":"Harrisburg","state":"PA","email":"ebruhnke6x@usnews.com"}, +{"id":251,"firstName":"Stanfield","lastName":"Jagiello","street":"0804 Amoth Road","postalCode":"20067","city":"Washington","state":"DC"}, +{"id":252,"firstName":"Isak","lastName":"Venour","street":"04 Orin Court","postalCode":"78210","city":"San Antonio","state":"TX","email":"ivenour6z@springer.com"}, +{"id":253,"firstName":"Abigale","lastName":"Woolgar","street":"74 Porter Terrace","postalCode":"62705","city":"Springfield","state":"IL"}, +{"id":254,"firstName":"Phylys","lastName":"Casperri","street":"07 Delaware Street","postalCode":"33069","city":"Pompano Beach","state":"FL","phoneNumber":"954-224-4577"}, +{"id":255,"firstName":"Melania","lastName":"Fee","street":"194 Luster Point","postalCode":"70154","city":"New Orleans","state":"LA","phoneNumber":"504-168-6959","email":"mfee72@comsenz.com"}, +{"id":256,"firstName":"Joli","lastName":"Colquite","street":"9 Bayside Court","postalCode":"27425","city":"Greensboro","state":"NC","email":"jcolquite73@comcast.net"}, +{"id":257,"firstName":"Rahel","lastName":"Late","street":"2 Meadow Ridge Alley","postalCode":"32204","city":"Jacksonville","state":"FL"}, +{"id":258,"firstName":"Carny","lastName":"Fewell","street":"21826 Cardinal Pass","postalCode":"98140","city":"Seattle","state":"WA"}, +{"id":259,"firstName":"Lesly","lastName":"Vanyatin","street":"7730 South Court","postalCode":"25356","city":"Charleston","state":"WV","email":"lvanyatin76@histats.com"}, +{"id":260,"firstName":"Fianna","lastName":"Thomason","street":"2576 Holmberg Trail","postalCode":"27710","city":"Durham","state":"NC"}, +{"id":261,"firstName":"Bobinette","lastName":"Gowdridge","street":"6780 Superior Place","postalCode":"37605","city":"Johnson City","state":"TN","phoneNumber":"423-490-4990","email":"bgowdridge78@icio.us"}, +{"id":262,"firstName":"Karmen","lastName":"Megson","street":"34 Messerschmidt Point","postalCode":"97229","city":"Portland","state":"OR","email":"kmegson79@apache.org"}, +{"id":263,"firstName":"Thaddeus","lastName":"Padilla","street":"42 Corben Road","postalCode":"90010","city":"Los Angeles","state":"CA","phoneNumber":"213-659-3136","email":"tpadilla7a@hud.gov"}, +{"id":264,"firstName":"Hanna","lastName":"Baswall","street":"9 Old Shore Lane","postalCode":"53710","city":"Madison","state":"WI","email":"hbaswall7b@ezinearticles.com"}, +{"id":265,"firstName":"Tania","lastName":"McMorland","street":"4333 Commercial Point","postalCode":"45408","city":"Dayton","state":"OH"}, +{"id":266,"firstName":"Gifford","lastName":"Arne","street":"0 Drewry Point","postalCode":"24048","city":"Roanoke","state":"VA","email":"garne7d@samsung.com"}, +{"id":267,"firstName":"Tomasina","lastName":"Linch","street":"64992 Maple Wood Point","postalCode":"98447","city":"Tacoma","state":"WA","email":"tlinch7e@theglobeandmail.com"}, +{"id":268,"firstName":"Merrick","lastName":"Garvan","street":"7220 Melody Trail","postalCode":"90005","city":"Los Angeles","state":"CA","email":"mgarvan7f@mozilla.org"}, +{"id":269,"firstName":"Carmita","lastName":"Sailes","street":"3 Bay Lane","postalCode":"55428","city":"Minneapolis","state":"MN","email":"csailes7g@devhub.com"}, +{"id":270,"firstName":"Lesly","lastName":"Eslemont","street":"93302 Mcbride Terrace","postalCode":"19810","city":"Wilmington","state":"DE","email":"leslemont7h@wunderground.com"}, +{"id":271,"firstName":"Adelaida","lastName":"Keggins","street":"4 Birchwood Pass","postalCode":"97405","city":"Eugene","state":"OR","phoneNumber":"541-387-1319"}, +{"id":272,"firstName":"Peadar","lastName":"Forte","street":"1 Montana Center","postalCode":"32505","city":"Pensacola","state":"FL","email":"pforte7j@xing.com"}, +{"id":273,"firstName":"Godfrey","lastName":"Swatland","street":"477 Maple Wood Road","postalCode":"93034","city":"Oxnard","state":"CA","phoneNumber":"805-267-0614","email":"gswatland7k@photobucket.com"}, +{"id":274,"firstName":"Marten","lastName":"Jelleman","street":"57 Pennsylvania Plaza","postalCode":"20057","city":"Washington","state":"DC","email":"mjelleman7l@phoca.cz"}, +{"id":275,"firstName":"Sharity","lastName":"Keady","street":"753 Sauthoff Place","postalCode":"77505","city":"Pasadena","state":"TX"}, +{"id":276,"firstName":"Gabbie","lastName":"Pally","street":"45 Fallview Park","postalCode":"97255","city":"Portland","state":"OR","phoneNumber":"971-412-2293","email":"gpally7n@dyndns.org"}, +{"id":277,"firstName":"Betsy","lastName":"Rhelton","street":"9 Jackson Road","postalCode":"85040","city":"Phoenix","state":"AZ"}, +{"id":278,"firstName":"Patty","lastName":"Schooling","street":"4 Moulton Point","postalCode":"25705","city":"Huntington","state":"WV","phoneNumber":"304-908-8211","email":"pschooling7p@parallels.com"}, +{"id":279,"firstName":"Katlin","lastName":"O'Hallagan","street":"8418 Petterle Plaza","postalCode":"60636","city":"Chicago","state":"IL","email":"kohallagan7q@hao123.com"}, +{"id":280,"firstName":"Anne","lastName":"Wealleans","street":"3 Sachtjen Court","postalCode":"48609","city":"Saginaw","state":"MI"}, +{"id":281,"firstName":"Flory","lastName":"Pley","street":"6322 Golf View Court","postalCode":"19104","city":"Philadelphia","state":"PA"}, +{"id":282,"firstName":"Maryellen","lastName":"Baszkiewicz","street":"54165 Hanson Trail","postalCode":"93726","city":"Fresno","state":"CA","phoneNumber":"209-198-4916","email":"mbaszkiewicz7t@google.com.br"}, +{"id":283,"firstName":"Moyna","lastName":"Caddens","street":"17 Melrose Lane","postalCode":"11236","city":"Brooklyn","state":"NY","phoneNumber":"917-518-3987","email":"mcaddens7u@amazon.co.uk"}, +{"id":284,"firstName":"Lawton","lastName":"Ramiro","street":"2 Muir Park","postalCode":"48092","city":"Warren","state":"MI","phoneNumber":"810-472-5208","email":"lramiro7v@senate.gov"}, +{"id":285,"firstName":"Agnella","lastName":"Phelip","street":"24566 Colorado Pass","postalCode":"84145","city":"Salt Lake City","state":"UT","phoneNumber":"801-709-8696","email":"aphelip7w@woothemes.com"}, +{"id":286,"firstName":"Tracee","lastName":"Tighe","street":"41013 Cascade Lane","postalCode":"02142","city":"Cambridge","state":"MA"}, +{"id":287,"firstName":"Shelden","lastName":"Sowrey","street":"87 Glacier Hill Court","postalCode":"55557","city":"Young America","state":"MN","email":"ssowrey7y@sfgate.com"}, +{"id":288,"firstName":"Letizia","lastName":"Sallery","street":"65052 Shasta Court","postalCode":"44905","city":"Mansfield","state":"OH","phoneNumber":"419-752-9141"}, +{"id":289,"firstName":"Hilly","lastName":"Oyley","street":"7 Waywood Trail","postalCode":"30323","city":"Atlanta","state":"GA","email":"hoyley80@upenn.edu"}, +{"id":290,"firstName":"Sabra","lastName":"Grigoryev","street":"856 Michigan Trail","postalCode":"33705","city":"Saint Petersburg","state":"FL"}, +{"id":291,"firstName":"Nathanil","lastName":"Bodham","street":"536 Ridgeview Way","postalCode":"79984","city":"El Paso","state":"TX","email":"nbodham82@wikimedia.org"}, +{"id":292,"firstName":"Niven","lastName":"Hartzenberg","street":"5 Carpenter Hill","postalCode":"73167","city":"Oklahoma City","state":"OK","email":"nhartzenberg83@bandcamp.com"}, +{"id":293,"firstName":"Rachael","lastName":"Birdsall","street":"61484 Mendota Point","postalCode":"90410","city":"Santa Monica","state":"CA","email":"rbirdsall84@gmpg.org"}, +{"id":294,"firstName":"Gypsy","lastName":"Rallin","street":"4 Spohn Drive","postalCode":"77346","city":"Humble","state":"TX","phoneNumber":"713-508-2912","email":"grallin85@privacy.gov.au"}, +{"id":295,"firstName":"Skye","lastName":"Arsey","street":"49126 Maryland Lane","postalCode":"02119","city":"Boston","state":"MA"}, +{"id":296,"firstName":"Karalee","lastName":"Biddiss","street":"0327 Coleman Lane","postalCode":"10203","city":"New York City","state":"NY","email":"kbiddiss87@studiopress.com"}, +{"id":297,"firstName":"Russ","lastName":"O' Mahony","street":"7831 Caliangt Avenue","postalCode":"37665","city":"Kingsport","state":"TN","phoneNumber":"423-292-1177","email":"romahony88@umich.edu"}, +{"id":298,"firstName":"Gerianne","lastName":"Morfey","street":"1 Jay Hill","postalCode":"97229","city":"Portland","state":"OR","email":"gmorfey89@techcrunch.com"}, +{"id":299,"firstName":"Griz","lastName":"Vellacott","street":"44 Parkside Court","postalCode":"64149","city":"Kansas City","state":"MO","phoneNumber":"816-120-1692"}, +{"id":300,"firstName":"Parker","lastName":"Mantz","street":"3 Arkansas Lane","postalCode":"90005","city":"Los Angeles","state":"CA","email":"pmantz8b@va.gov"}, +{"id":301,"firstName":"Drugi","lastName":"Acaster","street":"426 Hagan Park","postalCode":"20599","city":"Washington","state":"DC","email":"dacaster8c@ihg.com"}, +{"id":302,"firstName":"Peder","lastName":"Monget","street":"9 Wayridge Parkway","postalCode":"92862","city":"Orange","state":"CA","phoneNumber":"714-532-0867","email":"pmonget8d@biblegateway.com"}, +{"id":303,"firstName":"Zilvia","lastName":"Grocutt","street":"1 Stuart Circle","postalCode":"34642","city":"Seminole","state":"FL"}, +{"id":304,"firstName":"Clyve","lastName":"Gunby","street":"75 Dunning Junction","postalCode":"79977","city":"El Paso","state":"TX","email":"cgunby8f@microsoft.com"}, +{"id":305,"firstName":"Zacharias","lastName":"Tomasini","street":"48488 Thackeray Way","postalCode":"40210","city":"Louisville","state":"KY","email":"ztomasini8g@harvard.edu"}, +{"id":306,"firstName":"Ferdinand","lastName":"McGuinley","street":"30366 Kipling Drive","postalCode":"23208","city":"Richmond","state":"VA","email":"fmcguinley8h@archive.org"}, +{"id":307,"firstName":"Ebonee","lastName":"Brumfitt","street":"18765 Division Terrace","postalCode":"30033","city":"Decatur","state":"GA","phoneNumber":"404-684-8364","email":"ebrumfitt8i@sourceforge.net"}, +{"id":308,"firstName":"Christy","lastName":"Cuniam","street":"6 Homewood Road","postalCode":"78744","city":"Austin","state":"TX","phoneNumber":"361-677-9833","email":"ccuniam8j@51.la"}, +{"id":309,"firstName":"Emelen","lastName":"Casin","street":"91 Thompson Plaza","postalCode":"33954","city":"Port Charlotte","state":"FL","email":"ecasin8k@webnode.com"}, +{"id":310,"firstName":"Babara","lastName":"Robberecht","street":"603 Oak Terrace","postalCode":"37450","city":"Chattanooga","state":"TN","email":"brobberecht8l@cargocollective.com"}, +{"id":311,"firstName":"Cesar","lastName":"Whitecross","street":"024 Oxford Junction","postalCode":"20226","city":"Washington","state":"DC","phoneNumber":"202-772-2936"}, +{"id":312,"firstName":"Frieda","lastName":"Sliman","street":"4 Beilfuss Hill","postalCode":"23324","city":"Chesapeake","state":"VA","email":"fsliman8n@bigcartel.com"}, +{"id":313,"firstName":"Dylan","lastName":"Paige","street":"26 Gina Parkway","postalCode":"55448","city":"Minneapolis","state":"MN","email":"dpaige8o@trellian.com"}, +{"id":314,"firstName":"Waring","lastName":"Labon","street":"2843 Spenser Center","postalCode":"49444","city":"Muskegon","state":"MI","phoneNumber":"231-274-0766","email":"wlabon8p@ucla.edu"}, +{"id":315,"firstName":"Conny","lastName":"Duinkerk","street":"65 Lunder Circle","postalCode":"45426","city":"Dayton","state":"OH","email":"cduinkerk8q@economist.com"}, +{"id":316,"firstName":"Nessie","lastName":"Stucksbury","street":"91449 Browning Drive","postalCode":"25705","city":"Huntington","state":"WV","phoneNumber":"304-182-0766"}, +{"id":317,"firstName":"Corrine","lastName":"Kohlert","street":"00706 Carioca Plaza","postalCode":"45223","city":"Cincinnati","state":"OH","email":"ckohlert8s@wunderground.com"}, +{"id":318,"firstName":"Horatio","lastName":"Greengrass","street":"0 Cascade Park","postalCode":"79905","city":"El Paso","state":"TX","email":"hgreengrass8t@ameblo.jp"}, +{"id":319,"firstName":"Jana","lastName":"McLae","street":"919 Esch Place","postalCode":"55428","city":"Minneapolis","state":"MN","email":"jmclae8u@nytimes.com"}, +{"id":320,"firstName":"Maressa","lastName":"Rehor","street":"55 Talisman Junction","postalCode":"90505","city":"Torrance","state":"CA","email":"mrehor8v@vinaora.com"}, +{"id":321,"firstName":"Filide","lastName":"Riehm","street":"0 Karstens Lane","postalCode":"95054","city":"Santa Clara","state":"CA"}, +{"id":322,"firstName":"Bunnie","lastName":"Mumbey","street":"9369 Bayside Circle","postalCode":"46216","city":"Indianapolis","state":"IN","email":"bmumbey8x@scribd.com"}, +{"id":323,"firstName":"Maxi","lastName":"Jentgens","street":"2970 Rowland Circle","postalCode":"84189","city":"Salt Lake City","state":"UT","phoneNumber":"801-423-8854","email":"mjentgens8y@ihg.com"}, +{"id":324,"firstName":"Florri","lastName":"Okenden","street":"2180 Cody Point","postalCode":"70187","city":"New Orleans","state":"LA","phoneNumber":"504-913-1989","email":"fokenden8z@networksolutions.com"}, +{"id":325,"firstName":"Imogen","lastName":"Grisard","street":"8 Westerfield Avenue","postalCode":"92668","city":"Orange","state":"CA","email":"igrisard90@tamu.edu"}, +{"id":326,"firstName":"Edwina","lastName":"Montes","street":"92 Carpenter Avenue","postalCode":"97216","city":"Portland","state":"OR","phoneNumber":"503-544-7296","email":"emontes91@reference.com"}, +{"id":327,"firstName":"Renelle","lastName":"MacCambridge","street":"77 Talmadge Circle","postalCode":"08638","city":"Trenton","state":"NJ","phoneNumber":"609-150-9438","email":"rmaccambridge92@springer.com"}, +{"id":328,"firstName":"Sterne","lastName":"Taberner","street":"642 6th Terrace","postalCode":"10120","city":"New York City","state":"NY","email":"staberner93@miibeian.gov.cn"}, +{"id":329,"firstName":"Garvy","lastName":"Pankethman","street":"8618 Kennedy Terrace","postalCode":"79405","city":"Lubbock","state":"TX","phoneNumber":"806-470-8784","email":"gpankethman94@free.fr"}, +{"id":330,"firstName":"Nathanil","lastName":"Holston","street":"27247 Eliot Avenue","postalCode":"31190","city":"Atlanta","state":"GA","email":"nholston95@drupal.org"}, +{"id":331,"firstName":"Caresse","lastName":"Kilty","street":"514 Manufacturers Pass","postalCode":"76205","city":"Denton","state":"TX","email":"ckilty96@umich.edu"}, +{"id":332,"firstName":"Arlinda","lastName":"Brenstuhl","street":"2 Sunnyside Avenue","postalCode":"55470","city":"Minneapolis","state":"MN","email":"abrenstuhl97@wisc.edu"}, +{"id":333,"firstName":"Darcy","lastName":"Dunne","street":"3 Badeau Park","postalCode":"91328","city":"Northridge","state":"CA"}, +{"id":334,"firstName":"Malva","lastName":"Grew","street":"2242 Huxley Hill","postalCode":"68510","city":"Lincoln","state":"NE","email":"mgrew99@com.com"}, +{"id":335,"firstName":"Sukey","lastName":"Winspur","street":"475 Melvin Way","postalCode":"68524","city":"Lincoln","state":"NE","phoneNumber":"402-816-9401"}, +{"id":336,"firstName":"Beth","lastName":"O'Dougherty","street":"450 Eastlawn Park","postalCode":"93591","city":"Palmdale","state":"CA","phoneNumber":"661-845-8781"}, +{"id":337,"firstName":"Cortney","lastName":"Meers","street":"9 Chive Drive","postalCode":"93762","city":"Fresno","state":"CA","email":"cmeers9c@diigo.com"}, +{"id":338,"firstName":"Geralda","lastName":"Brocket","street":"0686 La Follette Avenue","postalCode":"80126","city":"Littleton","state":"CO","phoneNumber":"720-641-1371","email":"gbrocket9d@youku.com"}, +{"id":339,"firstName":"Lishe","lastName":"Maliphant","street":"5 Erie Plaza","postalCode":"63169","city":"Saint Louis","state":"MO","email":"lmaliphant9e@sfgate.com"}, +{"id":340,"firstName":"Brod","lastName":"Dobrovsky","street":"9 Gateway Park","postalCode":"79405","city":"Lubbock","state":"TX"}, +{"id":341,"firstName":"Philippe","lastName":"Argile","street":"4 Red Cloud Plaza","postalCode":"49444","city":"Muskegon","state":"MI","phoneNumber":"231-633-5495"}, +{"id":342,"firstName":"Sadye","lastName":"Sally","street":"07 Mendota Terrace","postalCode":"75507","city":"Texarkana","state":"TX","email":"ssally9h@e-recht24.de"}, +{"id":343,"firstName":"Napoleon","lastName":"Piggott","street":"3968 Roxbury Point","postalCode":"35905","city":"Gadsden","state":"AL","email":"npiggott9i@cnbc.com"}, +{"id":344,"firstName":"Jere","lastName":"Larn","street":"5086 Dahle Crossing","postalCode":"39534","city":"Biloxi","state":"MS","email":"jlarn9j@twitter.com"}, +{"id":345,"firstName":"Bevon","lastName":"Stidson","street":"7 Armistice Court","postalCode":"23436","city":"Suffolk","state":"VA","email":"bstidson9k@alexa.com"}, +{"id":346,"firstName":"Drugi","lastName":"Ewbach","street":"6032 5th Avenue","postalCode":"02208","city":"Boston","state":"MA","email":"dewbach9l@techcrunch.com"}, +{"id":347,"firstName":"Milka","lastName":"Caizley","street":"7 Anderson Junction","postalCode":"37228","city":"Nashville","state":"TN","phoneNumber":"615-305-6985","email":"mcaizley9m@cyberchimps.com"}, +{"id":348,"firstName":"Wilton","lastName":"Biagi","street":"80833 6th Crossing","postalCode":"40215","city":"Louisville","state":"KY","email":"wbiagi9n@vinaora.com"}, +{"id":349,"firstName":"Dilly","lastName":"Spradbrow","street":"5 Harbort Street","postalCode":"45419","city":"Dayton","state":"OH","email":"dspradbrow9o@marketwatch.com"}, +{"id":350,"firstName":"Gan","lastName":"Gookey","street":"8387 Bultman Terrace","postalCode":"75241","city":"Dallas","state":"TX"}, +{"id":351,"firstName":"Nanon","lastName":"Mulrenan","street":"47257 Reindahl Drive","postalCode":"22119","city":"Merrifield","state":"VA","phoneNumber":"571-637-8154","email":"nmulrenan9q@godaddy.com"}, +{"id":352,"firstName":"Frederique","lastName":"Watkiss","street":"61 Heath Pass","postalCode":"70124","city":"New Orleans","state":"LA","phoneNumber":"504-891-7051"}, +{"id":353,"firstName":"Sinclare","lastName":"MacCurlye","street":"514 Meadow Ridge Place","postalCode":"97240","city":"Portland","state":"OR","phoneNumber":"971-190-5174","email":"smaccurlye9s@google.ru"}, +{"id":354,"firstName":"Jessie","lastName":"Newlands","street":"80509 Northland Pass","postalCode":"33111","city":"Miami","state":"FL","phoneNumber":"786-557-9193"}, +{"id":355,"firstName":"Jamaal","lastName":"Molder","street":"90 Mcbride Trail","postalCode":"78764","city":"Austin","state":"TX","phoneNumber":"512-320-8728"}, +{"id":356,"firstName":"Benni","lastName":"Sherel","street":"7 Springs Road","postalCode":"15235","city":"Pittsburgh","state":"PA","email":"bsherel9v@hostgator.com"}, +{"id":357,"firstName":"Dene","lastName":"Brigge","street":"8560 Sutteridge Parkway","postalCode":"32412","city":"Panama City","state":"FL"}, +{"id":358,"firstName":"Timoteo","lastName":"Iban","street":"52858 Oak Valley Hill","postalCode":"93750","city":"Fresno","state":"CA","email":"tiban9x@europa.eu"}, +{"id":359,"firstName":"Dar","lastName":"Quillinane","street":"2 Carberry Junction","postalCode":"66276","city":"Shawnee Mission","state":"KS","phoneNumber":"913-977-7562","email":"dquillinane9y@msn.com"}, +{"id":360,"firstName":"Claudian","lastName":"Tinson","street":"445 Novick Avenue","postalCode":"79968","city":"El Paso","state":"TX","email":"ctinson9z@google.cn"}, +{"id":361,"firstName":"Clarice","lastName":"Deneve","street":"94 Meadow Ridge Road","postalCode":"37131","city":"Murfreesboro","state":"TN","phoneNumber":"615-780-7667"}, +{"id":362,"firstName":"Hilary","lastName":"Bithell","street":"20 Russell Trail","postalCode":"81010","city":"Pueblo","state":"CO","email":"hbithella1@list-manage.com"}, +{"id":363,"firstName":"Mathew","lastName":"Scrivin","street":"4 Elgar Point","postalCode":"90081","city":"Los Angeles","state":"CA","phoneNumber":"213-898-6650","email":"mscrivina2@about.me"}, +{"id":364,"firstName":"Idell","lastName":"Rambadt","street":"6 Cherokee Hill","postalCode":"90840","city":"Long Beach","state":"CA","email":"irambadta3@ustream.tv"}, +{"id":365,"firstName":"Nealon","lastName":"Schoolfield","street":"1 Northland Point","postalCode":"74133","city":"Tulsa","state":"OK"}, +{"id":366,"firstName":"Gregorius","lastName":"Bartot","street":"24636 Eagle Crest Crossing","postalCode":"32215","city":"Jacksonville","state":"FL","email":"gbartota5@blogger.com"}, +{"id":367,"firstName":"Inessa","lastName":"Hullin","street":"559 Bartillon Trail","postalCode":"33142","city":"Miami","state":"FL","phoneNumber":"305-381-6621","email":"ihullina6@pcworld.com"}, +{"id":368,"firstName":"Andie","lastName":"Bampford","street":"5204 Meadow Valley Street","postalCode":"92825","city":"Anaheim","state":"CA","email":"abampforda7@sun.com"}, +{"id":369,"firstName":"Duane","lastName":"MacShirrie","street":"5077 Kings Parkway","postalCode":"92725","city":"Santa Ana","state":"CA","email":"dmacshirriea8@rambler.ru"}, +{"id":370,"firstName":"Sydel","lastName":"Deerr","street":"1 Commercial Road","postalCode":"30356","city":"Atlanta","state":"GA","phoneNumber":"404-209-0194","email":"sdeerra9@phpbb.com"}, +{"id":371,"firstName":"Mel","lastName":"Miles","street":"28164 Melody Plaza","postalCode":"90847","city":"Long Beach","state":"CA","phoneNumber":"562-932-1172"}, +{"id":372,"firstName":"Jone","lastName":"Drinkel","street":"946 Reindahl Point","postalCode":"48604","city":"Saginaw","state":"MI","phoneNumber":"989-547-0653"}, +{"id":373,"firstName":"Marcellus","lastName":"MacGilmartin","street":"10568 Westerfield Way","postalCode":"32868","city":"Orlando","state":"FL","phoneNumber":"407-874-6188","email":"mmacgilmartinac@fotki.com"}, +{"id":374,"firstName":"Bret","lastName":"Hardan","street":"9 Hayes Crossing","postalCode":"32309","city":"Tallahassee","state":"FL","email":"bhardanad@mit.edu"}, +{"id":375,"firstName":"Heddie","lastName":"Cesaric","street":"502 Cody Crossing","postalCode":"95397","city":"Modesto","state":"CA"}, +{"id":376,"firstName":"Tansy","lastName":"Maeer","street":"526 Messerschmidt Court","postalCode":"94089","city":"Sunnyvale","state":"CA","email":"tmaeeraf@arizona.edu"}, +{"id":377,"firstName":"Waverly","lastName":"West-Frimley","street":"02 Quincy Trail","postalCode":"20575","city":"Washington","state":"DC","phoneNumber":"202-493-3304","email":"wwestfrimleyag@ft.com"}, +{"id":378,"firstName":"Dido","lastName":"de Clercq","street":"7 Norway Maple Center","postalCode":"84125","city":"Salt Lake City","state":"UT","email":"ddeclercqah@trellian.com"}, +{"id":379,"firstName":"Vic","lastName":"Samuels","street":"2 Kipling Drive","postalCode":"31190","city":"Atlanta","state":"GA","email":"vsamuelsai@goo.gl"}, +{"id":380,"firstName":"Jeno","lastName":"Freiburger","street":"431 Golden Leaf Parkway","postalCode":"32610","city":"Gainesville","state":"FL","email":"jfreiburgeraj@theguardian.com"}, +{"id":381,"firstName":"Christine","lastName":"Basketter","street":"4 Lotheville Terrace","postalCode":"39305","city":"Meridian","state":"MS","phoneNumber":"601-702-1546"}, +{"id":382,"firstName":"Karry","lastName":"Corsan","street":"09189 Lakeland Point","postalCode":"27409","city":"Greensboro","state":"NC","phoneNumber":"336-445-0006","email":"kcorsanal@usgs.gov"}, +{"id":383,"firstName":"Barri","lastName":"Brinsden","street":"53 Shelley Drive","postalCode":"35225","city":"Birmingham","state":"AL","email":"bbrinsdenam@1und1.de"}, +{"id":384,"firstName":"Hyacintha","lastName":"Boddam","street":"45 Sugar Circle","postalCode":"10160","city":"New York City","state":"NY","phoneNumber":"212-794-6062"}, +{"id":385,"firstName":"Brande","lastName":"Remnant","street":"283 Stone Corner Road","postalCode":"31904","city":"Columbus","state":"GA","phoneNumber":"706-211-4851","email":"bremnantao@people.com.cn"}, +{"id":386,"firstName":"Tally","lastName":"Bygraves","street":"54833 Northport Pass","postalCode":"85072","city":"Phoenix","state":"AZ","email":"tbygravesap@jigsy.com"}, +{"id":387,"firstName":"Garfield","lastName":"Pressnell","street":"63077 Hudson Court","postalCode":"30061","city":"Marietta","state":"GA","email":"gpressnellaq@archive.org"}, +{"id":388,"firstName":"Romonda","lastName":"Stiggles","street":"17 Russell Parkway","postalCode":"32627","city":"Gainesville","state":"FL","phoneNumber":"352-600-9676"}, +{"id":389,"firstName":"Dedie","lastName":"Ralling","street":"8 Judy Plaza","postalCode":"94137","city":"San Francisco","state":"CA","email":"drallingas@wikia.com"}, +{"id":390,"firstName":"Maddi","lastName":"Cornau","street":"5 Oriole Way","postalCode":"92105","city":"San Diego","state":"CA","phoneNumber":"619-388-6359","email":"mcornauat@adobe.com"}, +{"id":391,"firstName":"Zeke","lastName":"Jennery","street":"65332 Sommers Avenue","postalCode":"48206","city":"Detroit","state":"MI","email":"zjenneryau@elegantthemes.com"}, +{"id":392,"firstName":"Danya","lastName":"Fairlaw","street":"343 Logan Alley","postalCode":"33111","city":"Miami","state":"FL","email":"dfairlawav@irs.gov"}, +{"id":393,"firstName":"Rabi","lastName":"Petheridge","street":"7 Monica Alley","postalCode":"64054","city":"Independence","state":"MO","phoneNumber":"816-501-9452"}, +{"id":394,"firstName":"Ebba","lastName":"Skellen","street":"2655 Iowa Terrace","postalCode":"63150","city":"Saint Louis","state":"MO","phoneNumber":"314-695-7831","email":"eskellenax@nbcnews.com"}, +{"id":395,"firstName":"Marie-ann","lastName":"Glaysher","street":"4 Lakewood Hill","postalCode":"12247","city":"Albany","state":"NY","phoneNumber":"518-634-2425"}, +{"id":396,"firstName":"Arne","lastName":"Quincey","street":"162 Redwing Way","postalCode":"83711","city":"Boise","state":"ID"}, +{"id":397,"firstName":"Clarita","lastName":"Okroy","street":"05 Delaware Way","postalCode":"45218","city":"Cincinnati","state":"OH","email":"cokroyb0@stumbleupon.com"}, +{"id":398,"firstName":"Renault","lastName":"Weighell","street":"498 Dovetail Place","postalCode":"79710","city":"Midland","state":"TX","phoneNumber":"432-955-1408"}, +{"id":399,"firstName":"Roderich","lastName":"Mankor","street":"07 Dayton Way","postalCode":"92160","city":"San Diego","state":"CA"}, +{"id":400,"firstName":"Arv","lastName":"Sunnex","street":"89 Ronald Regan Terrace","postalCode":"91109","city":"Pasadena","state":"CA","email":"asunnexb3@vkontakte.ru"}, +{"id":401,"firstName":"Sonia","lastName":"Cowperthwaite","street":"77 Dennis Point","postalCode":"16550","city":"Erie","state":"PA"}, +{"id":402,"firstName":"Buddie","lastName":"Goscomb","street":"85675 Eastlawn Pass","postalCode":"20535","city":"Washington","state":"DC"}, +{"id":403,"firstName":"Brandi","lastName":"Swaine","street":"39961 Del Mar Lane","postalCode":"39705","city":"Columbus","state":"MS","phoneNumber":"662-306-2164","email":"bswaineb6@miibeian.gov.cn"}, +{"id":404,"firstName":"Jenny","lastName":"Cabbell","street":"743 Fordem Center","postalCode":"78285","city":"San Antonio","state":"TX","phoneNumber":"210-491-9874","email":"jcabbellb7@techcrunch.com"}, +{"id":405,"firstName":"Vincent","lastName":"People","street":"83 Tennessee Way","postalCode":"77293","city":"Houston","state":"TX","phoneNumber":"281-261-1928","email":"vpeopleb8@github.io"}, +{"id":406,"firstName":"Reinald","lastName":"Roles","street":"2 Division Road","postalCode":"53785","city":"Madison","state":"WI","phoneNumber":"608-568-7958","email":"rrolesb9@google.fr"}, +{"id":407,"firstName":"Kale","lastName":"Wanek","street":"7 Crescent Oaks Terrace","postalCode":"46852","city":"Fort Wayne","state":"IN","phoneNumber":"260-844-9669","email":"kwanekba@scribd.com"}, +{"id":408,"firstName":"Charisse","lastName":"Perse","street":"94449 Gateway Street","postalCode":"91117","city":"Pasadena","state":"CA","email":"cpersebb@ycombinator.com"}, +{"id":409,"firstName":"Konstantin","lastName":"Aslum","street":"08 Kings Trail","postalCode":"80328","city":"Boulder","state":"CO","email":"kaslumbc@opera.com"}, +{"id":410,"firstName":"Tyson","lastName":"O'Hartigan","street":"75122 Crowley Place","postalCode":"95173","city":"San Jose","state":"CA","phoneNumber":"408-879-0901","email":"tohartiganbd@devhub.com"}, +{"id":411,"firstName":"Fallon","lastName":"Haysman","street":"477 High Crossing Place","postalCode":"23293","city":"Richmond","state":"VA"}, +{"id":412,"firstName":"Svend","lastName":"Scarlet","street":"2856 Merrick Circle","postalCode":"90087","city":"Los Angeles","state":"CA","email":"sscarletbf@clickbank.net"}, +{"id":413,"firstName":"Gabey","lastName":"Colter","street":"7 2nd Alley","postalCode":"90610","city":"Whittier","state":"CA"}, +{"id":414,"firstName":"Hart","lastName":"Densell","street":"2687 Elka Alley","postalCode":"99599","city":"Anchorage","state":"AK","phoneNumber":"907-286-6079"}, +{"id":415,"firstName":"Claresta","lastName":"Folger","street":"5 Amoth Alley","postalCode":"27116","city":"Winston Salem","state":"NC"}, +{"id":416,"firstName":"Rica","lastName":"Lightowlers","street":"54303 Mayer Drive","postalCode":"61825","city":"Champaign","state":"IL","email":"rlightowlersbj@so-net.ne.jp"}, +{"id":417,"firstName":"Paula","lastName":"Treadaway","street":"8 Anniversary Road","postalCode":"20456","city":"Washington","state":"DC"}, +{"id":418,"firstName":"Francoise","lastName":"Gooderick","street":"13 Knutson Lane","postalCode":"33325","city":"Fort Lauderdale","state":"FL","email":"fgooderickbl@dedecms.com"}, +{"id":419,"firstName":"Ferdy","lastName":"Nannizzi","street":"578 Esker Trail","postalCode":"25321","city":"Charleston","state":"WV","email":"fnannizzibm@rambler.ru"}, +{"id":420,"firstName":"Dody","lastName":"Gettone","street":"9 Veith Court","postalCode":"62711","city":"Springfield","state":"IL"}, +{"id":421,"firstName":"Ronna","lastName":"Godleman","street":"6 Jenna Trail","postalCode":"22301","city":"Alexandria","state":"VA","email":"rgodlemanbo@hexun.com"}, +{"id":422,"firstName":"Adey","lastName":"Waith","street":"2 Mayer Avenue","postalCode":"12325","city":"Schenectady","state":"NY"}, +{"id":423,"firstName":"Stanislaw","lastName":"Garahan","street":"660 Merry Avenue","postalCode":"62723","city":"Springfield","state":"IL","phoneNumber":"217-587-6734"}, +{"id":424,"firstName":"Westley","lastName":"Knowles","street":"67430 Lakeland Circle","postalCode":"53263","city":"Milwaukee","state":"WI","email":"wknowlesbr@msu.edu"}, +{"id":425,"firstName":"Dion","lastName":"Jamson","street":"696 Birchwood Circle","postalCode":"80015","city":"Aurora","state":"CO","phoneNumber":"720-486-4494"}, +{"id":426,"firstName":"Glynis","lastName":"Bourhill","street":"091 Harper Park","postalCode":"40250","city":"Louisville","state":"KY"}, +{"id":427,"firstName":"Massimo","lastName":"Briand","street":"37 Northview Junction","postalCode":"75507","city":"Texarkana","state":"TX","email":"mbriandbu@etsy.com"}, +{"id":428,"firstName":"Tremayne","lastName":"Cadore","street":"6721 Anthes Point","postalCode":"94605","city":"Oakland","state":"CA","email":"tcadorebv@mozilla.com"}, +{"id":429,"firstName":"Lea","lastName":"Wildman","street":"52 Dixon Point","postalCode":"50310","city":"Des Moines","state":"IA","phoneNumber":"515-536-2096"}, +{"id":430,"firstName":"Ambur","lastName":"Oxlade","street":"356 Porter Center","postalCode":"44485","city":"Warren","state":"OH"}, +{"id":431,"firstName":"Jyoti","lastName":"Gillet","street":"13 Del Mar Parkway","postalCode":"81505","city":"Grand Junction","state":"CO","phoneNumber":"970-598-0357"}, +{"id":432,"firstName":"Sascha","lastName":"Stanyan","street":"77289 Blue Bill Park Alley","postalCode":"06120","city":"Hartford","state":"CT","email":"sstanyanbz@geocities.jp"}, +{"id":433,"firstName":"Spenser","lastName":"Harry","street":"2021 Oak Place","postalCode":"32835","city":"Orlando","state":"FL","email":"sharryc0@privacy.gov.au"}, +{"id":434,"firstName":"Clim","lastName":"Penrose","street":"8 Warrior Road","postalCode":"15255","city":"Pittsburgh","state":"PA","email":"cpenrosec1@blogtalkradio.com"}, +{"id":435,"firstName":"Jewell","lastName":"McKinnon","street":"4 Delladonna Street","postalCode":"36114","city":"Montgomery","state":"AL","email":"jmckinnonc2@tinypic.com"}, +{"id":436,"firstName":"Estrellita","lastName":"Amburgy","street":"5538 Tennessee Plaza","postalCode":"17121","city":"Harrisburg","state":"PA","phoneNumber":"717-274-8930","email":"eamburgyc3@forbes.com"}, +{"id":437,"firstName":"Sarah","lastName":"Fears","street":"61 Springs Park","postalCode":"93034","city":"Oxnard","state":"CA","email":"sfearsc4@wisc.edu"}, +{"id":438,"firstName":"Nixie","lastName":"Peddie","street":"7 Armistice Way","postalCode":"10155","city":"New York City","state":"NY","email":"npeddiec5@free.fr"}, +{"id":439,"firstName":"Ardisj","lastName":"Rohmer","street":"726 Crowley Point","postalCode":"93399","city":"Bakersfield","state":"CA","email":"arohmerc6@google.nl"}, +{"id":440,"firstName":"Wallie","lastName":"Johanssen","street":"9555 Jana Park","postalCode":"28410","city":"Wilmington","state":"NC","phoneNumber":"910-160-4520","email":"wjohanssenc7@boston.com"}, +{"id":441,"firstName":"Allan","lastName":"Jodlkowski","street":"31585 Kedzie Park","postalCode":"89150","city":"Las Vegas","state":"NV","phoneNumber":"702-782-3289","email":"ajodlkowskic8@sogou.com"}, +{"id":442,"firstName":"Harris","lastName":"Cadden","street":"96829 Fieldstone Park","postalCode":"16565","city":"Erie","state":"PA","phoneNumber":"814-745-1099"}, +{"id":443,"firstName":"Nigel","lastName":"Girardengo","street":"24703 Red Cloud Road","postalCode":"90310","city":"Inglewood","state":"CA","email":"ngirardengoca@ow.ly"}, +{"id":444,"firstName":"Aila","lastName":"Tinniswood","street":"62812 Stephen Parkway","postalCode":"13205","city":"Syracuse","state":"NY","phoneNumber":"315-847-2259","email":"atinniswoodcb@google.com.br"}, +{"id":445,"firstName":"Genni","lastName":"Geockle","street":"81 Bobwhite Plaza","postalCode":"93721","city":"Fresno","state":"CA","email":"ggeocklecc@furl.net"}, +{"id":446,"firstName":"Madison","lastName":"Brikner","street":"166 Coolidge Trail","postalCode":"07208","city":"Elizabeth","state":"NJ","email":"mbriknercd@myspace.com"}, +{"id":447,"firstName":"Akim","lastName":"Gotthard.sf","street":"0017 Heffernan Parkway","postalCode":"71914","city":"Hot Springs National Park","state":"AR","email":"agotthardsfce@google.com.au"}, +{"id":448,"firstName":"Andria","lastName":"Cardello","street":"1089 Stang Road","postalCode":"96835","city":"Honolulu","state":"HI","phoneNumber":"808-372-6528"}, +{"id":449,"firstName":"Laureen","lastName":"Crawshaw","street":"13 Manitowish Avenue","postalCode":"23504","city":"Norfolk","state":"VA","phoneNumber":"757-220-4043"}, +{"id":450,"firstName":"Henderson","lastName":"Parmley","street":"3408 Superior Street","postalCode":"28410","city":"Wilmington","state":"NC","email":"hparmleych@diigo.com"}, +{"id":451,"firstName":"Henri","lastName":"Arnley","street":"54 Knutson Park","postalCode":"11470","city":"Jamaica","state":"NY","phoneNumber":"718-365-7389"}, +{"id":452,"firstName":"Phil","lastName":"Trunkfield","street":"07 Arizona Way","postalCode":"85030","city":"Phoenix","state":"AZ","email":"ptrunkfieldcj@cisco.com"}, +{"id":453,"firstName":"Chery","lastName":"Nangle","street":"03 Merrick Way","postalCode":"88569","city":"El Paso","state":"TX","phoneNumber":"915-959-5535","email":"cnangleck@tumblr.com"}, +{"id":454,"firstName":"Leora","lastName":"Fields","street":"0260 Eastlawn Lane","postalCode":"85311","city":"Glendale","state":"AZ","email":"lfieldscl@nyu.edu"}, +{"id":455,"firstName":"Ronnica","lastName":"Pocknoll","street":"786 Hovde Plaza","postalCode":"78410","city":"Corpus Christi","state":"TX","email":"rpocknollcm@unesco.org"}, +{"id":456,"firstName":"Valida","lastName":"Romayn","street":"1108 Hudson Drive","postalCode":"34615","city":"Clearwater","state":"FL","email":"vromayncn@usatoday.com"}, +{"id":457,"firstName":"Randee","lastName":"Strowther","street":"441 Cordelia Point","postalCode":"27710","city":"Durham","state":"NC","phoneNumber":"919-463-1516","email":"rstrowtherco@trellian.com"}, +{"id":458,"firstName":"Ansell","lastName":"Blacklock","street":"9393 Kedzie Point","postalCode":"75358","city":"Dallas","state":"TX","phoneNumber":"214-949-3912"}, +{"id":459,"firstName":"Bailie","lastName":"Wing","street":"79459 Buhler Way","postalCode":"15279","city":"Pittsburgh","state":"PA","phoneNumber":"412-431-5446"}, +{"id":460,"firstName":"Leesa","lastName":"Wellbeloved","street":"4553 Dakota Circle","postalCode":"40215","city":"Louisville","state":"KY","phoneNumber":"502-145-8496","email":"lwellbelovedcr@go.com"}, +{"id":461,"firstName":"Sarge","lastName":"Tocknell","street":"9884 North Alley","postalCode":"80249","city":"Denver","state":"CO","phoneNumber":"303-603-8315","email":"stocknellcs@artisteer.com"}, +{"id":462,"firstName":"Loralyn","lastName":"Grimolbie","street":"3620 Clyde Gallagher Junction","postalCode":"91103","city":"Pasadena","state":"CA","email":"lgrimolbiect@purevolume.com"}, +{"id":463,"firstName":"Ki","lastName":"Youdell","street":"3 Gina Center","postalCode":"81005","city":"Pueblo","state":"CO"}, +{"id":464,"firstName":"Katerine","lastName":"Herreros","street":"70 Westend Place","postalCode":"57105","city":"Sioux Falls","state":"SD"}, +{"id":465,"firstName":"Frasquito","lastName":"Nockolds","street":"21 Dwight Park","postalCode":"11236","city":"Brooklyn","state":"NY","phoneNumber":"917-761-0549"}, +{"id":466,"firstName":"Krystalle","lastName":"Brierly","street":"7797 Forest Dale Lane","postalCode":"90410","city":"Santa Monica","state":"CA","email":"kbrierlycx@simplemachines.org"}, +{"id":467,"firstName":"Tobin","lastName":"Guillford","street":"501 Messerschmidt Alley","postalCode":"98195","city":"Seattle","state":"WA","phoneNumber":"206-862-7413","email":"tguillfordcy@fastcompany.com"}, +{"id":468,"firstName":"Lorita","lastName":"Sikorski","street":"83 Corscot Junction","postalCode":"44905","city":"Mansfield","state":"OH","phoneNumber":"419-278-2324","email":"lsikorskicz@intel.com"}, +{"id":469,"firstName":"Hermon","lastName":"Chomley","street":"696 Talisman Lane","postalCode":"35290","city":"Birmingham","state":"AL"}, +{"id":470,"firstName":"Karolina","lastName":"Andrault","street":"49738 Maple Wood Place","postalCode":"99709","city":"Fairbanks","state":"AK","phoneNumber":"907-337-1698","email":"kandraultd1@bloglines.com"}, +{"id":471,"firstName":"Lev","lastName":"Pankhurst.","street":"442 Pennsylvania Crossing","postalCode":"23605","city":"Newport News","state":"VA","phoneNumber":"757-832-3631"}, +{"id":472,"firstName":"Bianca","lastName":"Garfath","street":"7 Forest Run Center","postalCode":"71914","city":"Hot Springs National Park","state":"AR","email":"bgarfathd3@youku.com"}, +{"id":473,"firstName":"Walden","lastName":"Van der Linde","street":"6 Namekagon Parkway","postalCode":"70187","city":"New Orleans","state":"LA","email":"wvanderlinded4@netscape.com"}, +{"id":474,"firstName":"Alexandra","lastName":"Vasyukhin","street":"471 School Alley","postalCode":"80910","city":"Colorado Springs","state":"CO","email":"avasyukhind5@samsung.com"}, +{"id":475,"firstName":"Perry","lastName":"Spere","street":"33 Autumn Leaf Street","postalCode":"79994","city":"El Paso","state":"TX","email":"pspered6@tamu.edu"}, +{"id":476,"firstName":"Cristobal","lastName":"Afonso","street":"5 Lake View Way","postalCode":"19136","city":"Philadelphia","state":"PA","email":"cafonsod7@themeforest.net"}, +{"id":477,"firstName":"Sebastien","lastName":"Annets","street":"4229 Bowman Trail","postalCode":"43699","city":"Toledo","state":"OH","phoneNumber":"419-981-8630","email":"sannetsd8@guardian.co.uk"}, +{"id":478,"firstName":"Prentice","lastName":"Desorts","street":"54 Mendota Drive","postalCode":"31196","city":"Atlanta","state":"GA","phoneNumber":"404-235-6736","email":"pdesortsd9@who.int"}, +{"id":479,"firstName":"Rubin","lastName":"Dunkerk","street":"035 Myrtle Park","postalCode":"94297","city":"Sacramento","state":"CA","phoneNumber":"916-658-2157","email":"rdunkerkda@columbia.edu"}, +{"id":480,"firstName":"Jesselyn","lastName":"Bidnall","street":"2353 Norway Maple Court","postalCode":"07522","city":"Paterson","state":"NJ","email":"jbidnalldb@4shared.com"}, +{"id":481,"firstName":"Arleta","lastName":"Massy","street":"2 Bluejay Lane","postalCode":"10310","city":"Staten Island","state":"NY"}, +{"id":482,"firstName":"Trescha","lastName":"Joncic","street":"052 Summit Way","postalCode":"13217","city":"Syracuse","state":"NY"}, +{"id":483,"firstName":"Joshuah","lastName":"Galbreth","street":"16 Elka Place","postalCode":"08922","city":"New Brunswick","state":"NJ","email":"jgalbrethde@rambler.ru"}, +{"id":484,"firstName":"Clywd","lastName":"Henlon","street":"26 Thackeray Pass","postalCode":"90040","city":"Los Angeles","state":"CA","email":"chenlondf@unesco.org"}, +{"id":485,"firstName":"Glenda","lastName":"Grayley","street":"6326 Ohio Plaza","postalCode":"91411","city":"Van Nuys","state":"CA"}, +{"id":486,"firstName":"Glynda","lastName":"Stokell","street":"6 Schmedeman Court","postalCode":"60641","city":"Chicago","state":"IL","email":"gstokelldh@ted.com"}, +{"id":487,"firstName":"Kath","lastName":"Harrap","street":"43769 Barby Plaza","postalCode":"32304","city":"Tallahassee","state":"FL","email":"kharrapdi@cargocollective.com"}, +{"id":488,"firstName":"Dickie","lastName":"Domotor","street":"2954 Toban Lane","postalCode":"98133","city":"Seattle","state":"WA","email":"ddomotordj@hhs.gov"}, +{"id":489,"firstName":"Ceciley","lastName":"Hitzke","street":"9102 Westport Pass","postalCode":"40618","city":"Frankfort","state":"KY","phoneNumber":"502-545-5506","email":"chitzkedk@newsvine.com"}, +{"id":490,"firstName":"Adler","lastName":"Webb-Bowen","street":"5 Hanover Street","postalCode":"32123","city":"Daytona Beach","state":"FL"}, +{"id":491,"firstName":"Fergus","lastName":"Domerq","street":"06 Hansons Road","postalCode":"58106","city":"Fargo","state":"ND","phoneNumber":"701-656-3778"}, +{"id":492,"firstName":"Kimbra","lastName":"Petherick","street":"867 Mayer Drive","postalCode":"39236","city":"Jackson","state":"MS"}, +{"id":493,"firstName":"Geneva","lastName":"Hobgen","street":"74 Vernon Parkway","postalCode":"53710","city":"Madison","state":"WI","email":"ghobgendo@google.de"}, +{"id":494,"firstName":"Jillane","lastName":"Skitral","street":"9747 Ruskin Point","postalCode":"22405","city":"Fredericksburg","state":"VA","email":"jskitraldp@mysql.com"}, +{"id":495,"firstName":"Carolin","lastName":"Pimblotte","street":"8 Union Way","postalCode":"75358","city":"Dallas","state":"TX","phoneNumber":"214-109-7114","email":"cpimblottedq@cargocollective.com"}, +{"id":496,"firstName":"Wandis","lastName":"Andreasson","street":"3 Nancy Parkway","postalCode":"70033","city":"Metairie","state":"LA","email":"wandreassondr@topsy.com"}, +{"id":497,"firstName":"Baily","lastName":"Dalliston","street":"602 Melrose Way","postalCode":"25331","city":"Charleston","state":"WV","email":"bdallistonds@storify.com"}, +{"id":498,"firstName":"Kissie","lastName":"Lammiman","street":"4 Memorial Terrace","postalCode":"06510","city":"New Haven","state":"CT","phoneNumber":"203-724-3731","email":"klammimandt@barnesandnoble.com"}, +{"id":499,"firstName":"Cloris","lastName":"Dorning","street":"4 Lien Road","postalCode":"37235","city":"Nashville","state":"TN","email":"cdorningdu@unesco.org"}, +{"id":500,"firstName":"Jemimah","lastName":"Juppe","street":"979 Tennessee Pass","postalCode":"85305","city":"Glendale","state":"AZ"}, +{"id":501,"firstName":"Fanchette","lastName":"Marlor","street":"90 Waywood Circle","postalCode":"44511","city":"Youngstown","state":"OH","email":"fmarlordw@is.gd"}, +{"id":502,"firstName":"Carmelle","lastName":"Stillmann","street":"9124 Sachtjen Way","postalCode":"74184","city":"Tulsa","state":"OK","email":"cstillmanndx@telegraph.co.uk"}, +{"id":503,"firstName":"Joelle","lastName":"Mumford","street":"5 Susan Point","postalCode":"28410","city":"Wilmington","state":"NC","email":"jmumforddy@yellowbook.com"}, +{"id":504,"firstName":"Vicky","lastName":"Danzelman","street":"472 Pond Junction","postalCode":"11220","city":"Brooklyn","state":"NY","email":"vdanzelmandz@stumbleupon.com"}, +{"id":505,"firstName":"Baudoin","lastName":"Grenshiels","street":"4703 Tony Circle","postalCode":"76198","city":"Fort Worth","state":"TX","email":"bgrenshielse0@devhub.com"}, +{"id":506,"firstName":"Rosetta","lastName":"Wennington","street":"3 Kensington Crossing","postalCode":"14619","city":"Rochester","state":"NY"}, +{"id":507,"firstName":"Eudora","lastName":"Murtell","street":"97 Mockingbird Circle","postalCode":"92867","city":"Orange","state":"CA","phoneNumber":"949-899-3967"}, +{"id":508,"firstName":"Sonnie","lastName":"Hawkin","street":"76669 Green Ridge Crossing","postalCode":"79491","city":"Lubbock","state":"TX","email":"shawkine3@wikia.com"}, +{"id":509,"firstName":"Ulysses","lastName":"Uman","street":"4 Fieldstone Circle","postalCode":"32128","city":"Daytona Beach","state":"FL","phoneNumber":"386-761-6071","email":"uumane4@multiply.com"}, +{"id":510,"firstName":"Alidia","lastName":"Kowalski","street":"3915 Harper Plaza","postalCode":"75221","city":"Dallas","state":"TX","email":"akowalskie5@simplemachines.org"}, +{"id":511,"firstName":"Willis","lastName":"Jeaneau","street":"8 Northport Center","postalCode":"37939","city":"Knoxville","state":"TN","phoneNumber":"865-336-2729","email":"wjeaneaue6@furl.net"}, +{"id":512,"firstName":"Clement","lastName":"Taudevin","street":"25062 Amoth Pass","postalCode":"31914","city":"Columbus","state":"GA","email":"ctaudevine7@mapquest.com"}, +{"id":513,"firstName":"Tally","lastName":"Arnatt","street":"5745 Nancy Terrace","postalCode":"95054","city":"Santa Clara","state":"CA","email":"tarnatte8@umich.edu"}, +{"id":514,"firstName":"Eldon","lastName":"Munnings","street":"17 Dayton Parkway","postalCode":"27690","city":"Raleigh","state":"NC","email":"emunningse9@gmpg.org"}, +{"id":515,"firstName":"Duffie","lastName":"Sibary","street":"840 Springview Avenue","postalCode":"48275","city":"Detroit","state":"MI","email":"dsibaryea@livejournal.com"}, +{"id":516,"firstName":"Winny","lastName":"Dobell","street":"0426 Lindbergh Street","postalCode":"81015","city":"Pueblo","state":"CO","phoneNumber":"719-882-3553","email":"wdobelleb@bizjournals.com"}, +{"id":517,"firstName":"Pancho","lastName":"Pointon","street":"79 Clyde Gallagher Park","postalCode":"97306","city":"Salem","state":"OR","phoneNumber":"503-151-2205"}, +{"id":518,"firstName":"Elston","lastName":"Warwicker","street":"96 Schmedeman Park","postalCode":"44705","city":"Canton","state":"OH","email":"ewarwickered@arstechnica.com"}, +{"id":519,"firstName":"Nicolle","lastName":"Shellcross","street":"23982 Cambridge Parkway","postalCode":"80940","city":"Colorado Springs","state":"CO","email":"nshellcrossee@hibu.com"}, +{"id":520,"firstName":"Bethanne","lastName":"Briggdale","street":"026 Portage Circle","postalCode":"43215","city":"Columbus","state":"OH","phoneNumber":"513-925-3139","email":"bbriggdaleef@flickr.com"}, +{"id":521,"firstName":"Elsey","lastName":"McCorry","street":"781 International Parkway","postalCode":"94286","city":"Sacramento","state":"CA","phoneNumber":"916-879-2104","email":"emccorryeg@sakura.ne.jp"}, +{"id":522,"firstName":"Abran","lastName":"Vasyuchov","street":"64 Grim Place","postalCode":"44177","city":"Cleveland","state":"OH"}, +{"id":523,"firstName":"Rhoda","lastName":"Grieveson","street":"50687 Towne Pass","postalCode":"11220","city":"Brooklyn","state":"NY","email":"rgrievesonei@mit.edu"}, +{"id":524,"firstName":"Florette","lastName":"Eke","street":"85057 Anzinger Lane","postalCode":"66225","city":"Shawnee Mission","state":"KS","phoneNumber":"913-299-0032","email":"fekeej@fema.gov"}, +{"id":525,"firstName":"Sheff","lastName":"Baigrie","street":"80366 Lawn Hill","postalCode":"02203","city":"Boston","state":"MA","phoneNumber":"617-556-4978","email":"sbaigrieek@aboutads.info"}, +{"id":526,"firstName":"Clarisse","lastName":"Hubbuck","street":"435 Truax Trail","postalCode":"02458","city":"Newton","state":"MA","phoneNumber":"781-641-2937"}, +{"id":527,"firstName":"Gilberte","lastName":"Yanele","street":"413 Glacier Hill Park","postalCode":"90610","city":"Whittier","state":"CA","phoneNumber":"562-451-1686","email":"gyaneleem@dot.gov"}, +{"id":528,"firstName":"Lefty","lastName":"Dufore","street":"957 Straubel Street","postalCode":"35220","city":"Birmingham","state":"AL","email":"lduforeen@slideshare.net"}, +{"id":529,"firstName":"Saul","lastName":"Shepperd","street":"44805 Sunnyside Place","postalCode":"32627","city":"Gainesville","state":"FL","phoneNumber":"352-904-7271"}, +{"id":530,"firstName":"Hadrian","lastName":"Cockhill","street":"479 Mayer Way","postalCode":"22119","city":"Merrifield","state":"VA","email":"hcockhillep@xrea.com"}, +{"id":531,"firstName":"Amalia","lastName":"Geare","street":"63075 Glendale Trail","postalCode":"90065","city":"Los Angeles","state":"CA","email":"ageareeq@vistaprint.com"}, +{"id":532,"firstName":"Adan","lastName":"Ibbeson","street":"5 Cambridge Lane","postalCode":"73142","city":"Oklahoma City","state":"OK"}, +{"id":533,"firstName":"Nicol","lastName":"Garbutt","street":"3 8th Street","postalCode":"50393","city":"Des Moines","state":"IA","phoneNumber":"515-946-8077"}, +{"id":534,"firstName":"Lilas","lastName":"Estcot","street":"1927 Mitchell Avenue","postalCode":"75185","city":"Mesquite","state":"TX","email":"lestcotet@ezinearticles.com"}, +{"id":535,"firstName":"Valina","lastName":"Dellenbrok","street":"1 Victoria Hill","postalCode":"45249","city":"Cincinnati","state":"OH","phoneNumber":"513-958-5055","email":"vdellenbrokeu@upenn.edu"}, +{"id":536,"firstName":"Gwen","lastName":"Harwell","street":"64275 Bartelt Terrace","postalCode":"93721","city":"Fresno","state":"CA"}, +{"id":537,"firstName":"Adriena","lastName":"Lochead","street":"0088 Hintze Point","postalCode":"43231","city":"Columbus","state":"OH","phoneNumber":"614-506-5616","email":"alocheadew@paypal.com"}, +{"id":538,"firstName":"Jacobo","lastName":"Jills","street":"809 Anderson Park","postalCode":"55557","city":"Young America","state":"MN","phoneNumber":"952-580-6574","email":"jjillsex@xing.com"}, +{"id":539,"firstName":"Saree","lastName":"Jeanequin","street":"0212 Clyde Gallagher Alley","postalCode":"32891","city":"Orlando","state":"FL","email":"sjeanequiney@who.int"}, +{"id":540,"firstName":"Kin","lastName":"Dewar","street":"3 Emmet Center","postalCode":"20244","city":"Washington","state":"DC","email":"kdewarez@discovery.com"}, +{"id":541,"firstName":"Kaleena","lastName":"Godfray","street":"4350 Eliot Parkway","postalCode":"76134","city":"Fort Worth","state":"TX","phoneNumber":"817-332-6412","email":"kgodfrayf0@webmd.com"}, +{"id":542,"firstName":"Wallace","lastName":"Poytres","street":"78157 Dovetail Crossing","postalCode":"14683","city":"Rochester","state":"NY","email":"wpoytresf1@springer.com"}, +{"id":543,"firstName":"Dur","lastName":"Burgise","street":"2 Weeping Birch Court","postalCode":"89130","city":"Las Vegas","state":"NV"}, +{"id":544,"firstName":"Sheridan","lastName":"Gardiner","street":"26 Gateway Crossing","postalCode":"64193","city":"Kansas City","state":"MO","phoneNumber":"816-647-4434","email":"sgardinerf3@jugem.jp"}, +{"id":545,"firstName":"Nickolaus","lastName":"Thomassen","street":"130 Anderson Drive","postalCode":"33330","city":"Fort Lauderdale","state":"FL","phoneNumber":"954-339-0290"}, +{"id":546,"firstName":"Boris","lastName":"Cortez","street":"55 Center Court","postalCode":"10184","city":"New York City","state":"NY","phoneNumber":"212-549-8414","email":"bcortezf5@mail.ru"}, +{"id":547,"firstName":"Candra","lastName":"Codner","street":"24078 Superior Point","postalCode":"93715","city":"Fresno","state":"CA","phoneNumber":"209-495-8135"}, +{"id":548,"firstName":"Ashton","lastName":"Hugin","street":"33 Fuller Place","postalCode":"63143","city":"Saint Louis","state":"MO"}, +{"id":549,"firstName":"Miguelita","lastName":"Lanceley","street":"34877 Arizona Street","postalCode":"80045","city":"Aurora","state":"CO","email":"mlanceleyf8@trellian.com"}, +{"id":550,"firstName":"Law","lastName":"Skim","street":"1795 Farmco Street","postalCode":"28230","city":"Charlotte","state":"NC","email":"lskimf9@bravesites.com"}, +{"id":551,"firstName":"Carlita","lastName":"Kindall","street":"7 Scofield Road","postalCode":"93709","city":"Fresno","state":"CA","email":"ckindallfa@zimbio.com"}, +{"id":552,"firstName":"Mehetabel","lastName":"Stawell","street":"648 Upham Plaza","postalCode":"75277","city":"Dallas","state":"TX","phoneNumber":"214-597-5958","email":"mstawellfb@ehow.com"}, +{"id":553,"firstName":"Charlena","lastName":"MacAlpyne","street":"2 Village Terrace","postalCode":"33758","city":"Clearwater","state":"FL","phoneNumber":"813-452-9764","email":"cmacalpynefc@xinhuanet.com"}, +{"id":554,"firstName":"Gayel","lastName":"Litel","street":"34782 Birchwood Road","postalCode":"46406","city":"Gary","state":"IN","phoneNumber":"219-156-8377","email":"glitelfd@alibaba.com"}, +{"id":555,"firstName":"Prisca","lastName":"Kanzler","street":"67 Miller Terrace","postalCode":"08619","city":"Trenton","state":"NJ","phoneNumber":"609-352-4487"}, +{"id":556,"firstName":"Marlowe","lastName":"Idenden","street":"396 Beilfuss Park","postalCode":"74103","city":"Tulsa","state":"OK","phoneNumber":"918-254-3102"}, +{"id":557,"firstName":"Ashley","lastName":"Skule","street":"2327 Valley Edge Terrace","postalCode":"93794","city":"Fresno","state":"CA","phoneNumber":"559-558-9123"}, +{"id":558,"firstName":"Trista","lastName":"Naptine","street":"646 Dahle Court","postalCode":"06538","city":"New Haven","state":"CT","phoneNumber":"203-257-3017","email":"tnaptinefh@hugedomains.com"}, +{"id":559,"firstName":"Hasheem","lastName":"Ottery","street":"004 Clemons Street","postalCode":"28815","city":"Asheville","state":"NC","phoneNumber":"828-768-3824","email":"hotteryfi@gmpg.org"}, +{"id":560,"firstName":"Alisa","lastName":"Bernhardt","street":"49 Cody Center","postalCode":"84120","city":"Salt Lake City","state":"UT","phoneNumber":"801-808-4005","email":"abernhardtfj@census.gov"}, +{"id":561,"firstName":"Isadora","lastName":"Hatchett","street":"78644 Hoepker Junction","postalCode":"77015","city":"Houston","state":"TX","email":"ihatchettfk@spiegel.de"}, +{"id":562,"firstName":"Valdemar","lastName":"Stithe","street":"75 East Street","postalCode":"48206","city":"Detroit","state":"MI","email":"vstithefl@marriott.com"}, +{"id":563,"firstName":"Elden","lastName":"Rebert","street":"2 Florence Place","postalCode":"65110","city":"Jefferson City","state":"MO","phoneNumber":"573-753-8030"}, +{"id":564,"firstName":"Stormie","lastName":"Trewartha","street":"59 Shoshone Lane","postalCode":"19136","city":"Philadelphia","state":"PA","phoneNumber":"215-466-6832"}, +{"id":565,"firstName":"Bernhard","lastName":"Boulsher","street":"50888 Dwight Drive","postalCode":"02114","city":"Boston","state":"MA","email":"bboulsherfo@zdnet.com"}, +{"id":566,"firstName":"Twyla","lastName":"Yerrill","street":"526 Clove Terrace","postalCode":"40745","city":"London","state":"KY","email":"tyerrillfp@smugmug.com"}, +{"id":567,"firstName":"Sullivan","lastName":"Dudeney","street":"953 Swallow Crossing","postalCode":"19160","city":"Philadelphia","state":"PA","email":"sdudeneyfq@kickstarter.com"}, +{"id":568,"firstName":"Estell","lastName":"Kiggel","street":"8170 Rusk Alley","postalCode":"20442","city":"Washington","state":"DC","phoneNumber":"202-645-5828","email":"ekiggelfr@imgur.com"}, +{"id":569,"firstName":"Jonis","lastName":"Pymer","street":"21296 International Pass","postalCode":"77844","city":"College Station","state":"TX","email":"jpymerfs@nymag.com"}, +{"id":570,"firstName":"Linea","lastName":"Cranmor","street":"2541 Thackeray Hill","postalCode":"31210","city":"Macon","state":"GA"}, +{"id":571,"firstName":"Starlin","lastName":"Reven","street":"7692 Mifflin Hill","postalCode":"66611","city":"Topeka","state":"KS","email":"srevenfu@nba.com"}, +{"id":572,"firstName":"Augusta","lastName":"Heustice","street":"947 Ramsey Lane","postalCode":"10292","city":"New York City","state":"NY","phoneNumber":"212-194-3346","email":"aheusticefv@cloudflare.com"}, +{"id":573,"firstName":"Glen","lastName":"O'Mailey","street":"90 6th Court","postalCode":"33982","city":"Punta Gorda","state":"FL","phoneNumber":"941-381-2231"}, +{"id":574,"firstName":"Astrix","lastName":"Bister","street":"505 Artisan Crossing","postalCode":"23324","city":"Chesapeake","state":"VA","phoneNumber":"757-469-4444","email":"abisterfx@uol.com.br"}, +{"id":575,"firstName":"Shaw","lastName":"Lidbetter","street":"70 New Castle Trail","postalCode":"10474","city":"Bronx","state":"NY","phoneNumber":"917-917-9173"}, +{"id":576,"firstName":"Yovonnda","lastName":"Wych","street":"97472 Derek Drive","postalCode":"90410","city":"Santa Monica","state":"CA","email":"ywychfz@symantec.com"}, +{"id":577,"firstName":"Harcourt","lastName":"Faier","street":"056 Northridge Street","postalCode":"16510","city":"Erie","state":"PA","email":"hfaierg0@cloudflare.com"}, +{"id":578,"firstName":"Archibold","lastName":"Kos","street":"6 Forster Park","postalCode":"63104","city":"Saint Louis","state":"MO","phoneNumber":"314-967-5566","email":"akosg1@soup.io"}, +{"id":579,"firstName":"Nataniel","lastName":"Beldom","street":"1 Sullivan Street","postalCode":"02453","city":"Waltham","state":"MA","email":"nbeldomg2@alibaba.com"}, +{"id":580,"firstName":"Felisha","lastName":"Bamfield","street":"970 Washington Avenue","postalCode":"12305","city":"Schenectady","state":"NY","email":"fbamfieldg3@jimdo.com"}, +{"id":581,"firstName":"Colly","lastName":"Rugge","street":"8 Golf Course Avenue","postalCode":"55172","city":"Saint Paul","state":"MN","phoneNumber":"651-450-9347","email":"cruggeg4@tmall.com"}, +{"id":582,"firstName":"Patti","lastName":"Maddrell","street":"0483 Coolidge Drive","postalCode":"74193","city":"Tulsa","state":"OK"}, +{"id":583,"firstName":"Antin","lastName":"Gabbetis","street":"93510 Clemons Drive","postalCode":"68583","city":"Lincoln","state":"NE","email":"agabbetisg6@java.com"}, +{"id":584,"firstName":"Bree","lastName":"Million","street":"3 Columbus Avenue","postalCode":"61614","city":"Peoria","state":"IL","phoneNumber":"309-360-1909","email":"bmilliong7@gnu.org"}, +{"id":585,"firstName":"Taber","lastName":"Lorait","street":"4 Melrose Way","postalCode":"62764","city":"Springfield","state":"IL","phoneNumber":"217-436-2021","email":"tloraitg8@cargocollective.com"}, +{"id":586,"firstName":"Roley","lastName":"Di Carlo","street":"981 Bowman Center","postalCode":"87505","city":"Santa Fe","state":"NM"}, +{"id":587,"firstName":"Seline","lastName":"Oxenham","street":"65051 Forest Run Center","postalCode":"94064","city":"Redwood City","state":"CA","email":"soxenhamga@fastcompany.com"}, +{"id":588,"firstName":"Costa","lastName":"Tomblin","street":"7 Arapahoe Alley","postalCode":"33315","city":"Fort Lauderdale","state":"FL","phoneNumber":"954-239-1335"}, +{"id":589,"firstName":"Opalina","lastName":"Cake","street":"88 Commercial Avenue","postalCode":"40215","city":"Louisville","state":"KY","email":"ocakegc@examiner.com"}, +{"id":590,"firstName":"Suzanne","lastName":"Giuroni","street":"73 Twin Pines Terrace","postalCode":"99260","city":"Spokane","state":"WA"}, +{"id":591,"firstName":"Faustine","lastName":"Croysdale","street":"01 Delladonna Point","postalCode":"48295","city":"Detroit","state":"MI"}, +{"id":592,"firstName":"Sheffie","lastName":"Aldine","street":"4 Hansons Junction","postalCode":"74108","city":"Tulsa","state":"OK"}, +{"id":593,"firstName":"Bret","lastName":"Birrane","street":"745 Mayer Junction","postalCode":"77030","city":"Houston","state":"TX","phoneNumber":"832-374-7571","email":"bbirranegg@opera.com"}, +{"id":594,"firstName":"Lennard","lastName":"Mowbury","street":"5 Dwight Road","postalCode":"94522","city":"Concord","state":"CA","email":"lmowburygh@1und1.de"}, +{"id":595,"firstName":"Albie","lastName":"Pert","street":"23705 Fieldstone Plaza","postalCode":"08922","city":"New Brunswick","state":"NJ","phoneNumber":"732-587-7312","email":"apertgi@netlog.com"}, +{"id":596,"firstName":"Stevie","lastName":"Pressnell","street":"0077 Ronald Regan Point","postalCode":"85020","city":"Phoenix","state":"AZ","phoneNumber":"623-991-0482","email":"spressnellgj@skype.com"}, +{"id":597,"firstName":"Eddy","lastName":"McIlreavy","street":"04 Luster Lane","postalCode":"94126","city":"San Francisco","state":"CA"}, +{"id":598,"firstName":"Webb","lastName":"Titterell","street":"94323 Kedzie Alley","postalCode":"91505","city":"Burbank","state":"CA","phoneNumber":"818-220-9105","email":"wtitterellgl@bandcamp.com"}, +{"id":599,"firstName":"Jeffrey","lastName":"Benito","street":"7487 Scott Lane","postalCode":"11470","city":"Jamaica","state":"NY","phoneNumber":"917-379-2592","email":"jbenitogm@deviantart.com"}, +{"id":600,"firstName":"Nollie","lastName":"Arsey","street":"7282 Summerview Plaza","postalCode":"55811","city":"Duluth","state":"MN","email":"narseygn@imageshack.us"}, +{"id":601,"firstName":"Petra","lastName":"Turpey","street":"43920 Evergreen Junction","postalCode":"77255","city":"Houston","state":"TX","phoneNumber":"713-446-0144"}, +{"id":602,"firstName":"Harwilll","lastName":"Lashbrook","street":"8063 Grasskamp Parkway","postalCode":"27621","city":"Raleigh","state":"NC","phoneNumber":"919-142-9887","email":"hlashbrookgp@seattletimes.com"}, +{"id":603,"firstName":"Tedman","lastName":"Steinor","street":"80230 Hanson Hill","postalCode":"47134","city":"Jeffersonville","state":"IN","email":"tsteinorgq@dmoz.org"}, +{"id":604,"firstName":"Georgette","lastName":"Tupper","street":"37 Lillian Avenue","postalCode":"33543","city":"Zephyrhills","state":"FL","phoneNumber":"813-743-2425","email":"gtuppergr@qq.com"}, +{"id":605,"firstName":"Torrance","lastName":"Welsh","street":"95802 Doe Crossing Crossing","postalCode":"13217","city":"Syracuse","state":"NY","phoneNumber":"315-145-4503","email":"twelshgs@imgur.com"}, +{"id":606,"firstName":"Silvie","lastName":"Souster","street":"52827 Fuller Place","postalCode":"99709","city":"Fairbanks","state":"AK"}, +{"id":607,"firstName":"Pauline","lastName":"Dulwitch","street":"8 Aberg Drive","postalCode":"17105","city":"Harrisburg","state":"PA","phoneNumber":"717-228-4960","email":"pdulwitchgu@aboutads.info"}, +{"id":608,"firstName":"Roberta","lastName":"Castanie","street":"182 Mosinee Avenue","postalCode":"75185","city":"Mesquite","state":"TX"}, +{"id":609,"firstName":"Percival","lastName":"Kristoffersen","street":"4 Del Mar Park","postalCode":"48335","city":"Farmington","state":"MI","phoneNumber":"248-438-1650","email":"pkristoffersengw@chron.com"}, +{"id":610,"firstName":"Caryl","lastName":"Boame","street":"094 Springview Avenue","postalCode":"78255","city":"San Antonio","state":"TX","email":"cboamegx@example.com"}, +{"id":611,"firstName":"Steve","lastName":"Simakov","street":"323 Brickson Park Trail","postalCode":"32244","city":"Jacksonville","state":"FL","phoneNumber":"904-468-9377","email":"ssimakovgy@angelfire.com"}, +{"id":612,"firstName":"Carl","lastName":"Tumayan","street":"93854 Clyde Gallagher Circle","postalCode":"98447","city":"Tacoma","state":"WA","email":"ctumayangz@1und1.de"}, +{"id":613,"firstName":"Gayle","lastName":"Blaker","street":"5930 Grasskamp Drive","postalCode":"12262","city":"Albany","state":"NY","email":"gblakerh0@spiegel.de"}, +{"id":614,"firstName":"Darrick","lastName":"Harefoot","street":"359 Waywood Trail","postalCode":"20189","city":"Dulles","state":"VA"}, +{"id":615,"firstName":"Sayer","lastName":"Eversfield","street":"86 Park Meadow Crossing","postalCode":"53263","city":"Milwaukee","state":"WI","email":"seversfieldh2@multiply.com"}, +{"id":616,"firstName":"Loralyn","lastName":"Poyner","street":"28530 Magdeline Crossing","postalCode":"84125","city":"Salt Lake City","state":"UT","phoneNumber":"801-363-2593"}, +{"id":617,"firstName":"Petrina","lastName":"Ridewood","street":"91782 Oriole Parkway","postalCode":"80235","city":"Denver","state":"CO","phoneNumber":"720-131-3660","email":"pridewoodh4@walmart.com"}, +{"id":618,"firstName":"Leroi","lastName":"Marde","street":"7992 Prairieview Junction","postalCode":"02142","city":"Cambridge","state":"MA","phoneNumber":"781-623-9420","email":"lmardeh5@oracle.com"}, +{"id":619,"firstName":"Brannon","lastName":"Janata","street":"79706 Wayridge Alley","postalCode":"24515","city":"Lynchburg","state":"VA","phoneNumber":"434-255-0721"}, +{"id":620,"firstName":"Berry","lastName":"Joska","street":"301 6th Alley","postalCode":"10150","city":"New York City","state":"NY","email":"bjoskah7@360.cn"}, +{"id":621,"firstName":"Blinnie","lastName":"Basten","street":"047 Canary Parkway","postalCode":"30343","city":"Atlanta","state":"GA","phoneNumber":"404-794-2760"}, +{"id":622,"firstName":"Inesita","lastName":"Abbitt","street":"8 Sachtjen Plaza","postalCode":"60681","city":"Chicago","state":"IL"}, +{"id":623,"firstName":"Nickie","lastName":"Ellicombe","street":"1067 Ridge Oak Terrace","postalCode":"38131","city":"Memphis","state":"TN","phoneNumber":"901-695-3826","email":"nellicombeha@imgur.com"}, +{"id":624,"firstName":"Barney","lastName":"Sheeres","street":"1 Rutledge Avenue","postalCode":"29208","city":"Columbia","state":"SC","phoneNumber":"803-166-1398"}, +{"id":625,"firstName":"Ogdan","lastName":"Lelievre","street":"27 Weeping Birch Plaza","postalCode":"27264","city":"High Point","state":"NC","phoneNumber":"336-416-3966","email":"olelievrehc@exblog.jp"}, +{"id":626,"firstName":"Zora","lastName":"Exter","street":"7 Ronald Regan Pass","postalCode":"33673","city":"Tampa","state":"FL"}, +{"id":627,"firstName":"Travus","lastName":"Jaulme","street":"3159 Montana Circle","postalCode":"79176","city":"Amarillo","state":"TX","phoneNumber":"806-894-9411"}, +{"id":628,"firstName":"Krishna","lastName":"Beckingham","street":"58 Fair Oaks Lane","postalCode":"30311","city":"Atlanta","state":"GA","email":"kbeckinghamhf@usnews.com"}, +{"id":629,"firstName":"Bartolomeo","lastName":"Bosanko","street":"753 Victoria Place","postalCode":"79699","city":"Abilene","state":"TX","phoneNumber":"325-223-9615","email":"bbosankohg@merriam-webster.com"}, +{"id":630,"firstName":"Umberto","lastName":"McGinly","street":"30 Upham Parkway","postalCode":"80945","city":"Colorado Springs","state":"CO","email":"umcginlyhh@cdc.gov"}, +{"id":631,"firstName":"Launce","lastName":"Fatkin","street":"03246 Esch Place","postalCode":"53779","city":"Madison","state":"WI","phoneNumber":"608-916-7032","email":"lfatkinhi@blogs.com"}, +{"id":632,"firstName":"Simone","lastName":"Soars","street":"9969 Forest Run Crossing","postalCode":"90101","city":"Los Angeles","state":"CA","phoneNumber":"213-282-8462"}, +{"id":633,"firstName":"Clerissa","lastName":"Leason","street":"59731 Mayfield Street","postalCode":"89510","city":"Reno","state":"NV"}, +{"id":634,"firstName":"Rutter","lastName":"Sultan","street":"697 Spenser Way","postalCode":"77245","city":"Houston","state":"TX"}, +{"id":635,"firstName":"Shannon","lastName":"De Carteret","street":"2 Grover Avenue","postalCode":"92717","city":"Irvine","state":"CA","phoneNumber":"714-410-2360","email":"sdecarterethm@simplemachines.org"}, +{"id":636,"firstName":"Sawyere","lastName":"Cardno","street":"428 Golf Course Drive","postalCode":"33111","city":"Miami","state":"FL"}, +{"id":637,"firstName":"Paulie","lastName":"Bucktharp","street":"5398 Sugar Park","postalCode":"10039","city":"New York City","state":"NY","phoneNumber":"646-197-4123","email":"pbucktharpho@businessweek.com"}, +{"id":638,"firstName":"Kippy","lastName":"Guisler","street":"2161 Claremont Trail","postalCode":"20546","city":"Washington","state":"DC","phoneNumber":"202-138-6171","email":"kguislerhp@ox.ac.uk"}, +{"id":639,"firstName":"Yoshiko","lastName":"Tolson","street":"2 Glendale Court","postalCode":"27415","city":"Greensboro","state":"NC","email":"ytolsonhq@example.com"}, +{"id":640,"firstName":"Page","lastName":"Chillingsworth","street":"8 Loomis Drive","postalCode":"55470","city":"Minneapolis","state":"MN","email":"pchillingsworthhr@wunderground.com"}, +{"id":641,"firstName":"Jillana","lastName":"O'Siaghail","street":"13517 Del Mar Road","postalCode":"29215","city":"Columbia","state":"SC","phoneNumber":"803-420-8597","email":"josiaghailhs@reuters.com"}, +{"id":642,"firstName":"Phedra","lastName":"Bagnold","street":"7059 Hallows Street","postalCode":"55470","city":"Minneapolis","state":"MN","email":"pbagnoldht@howstuffworks.com"}, +{"id":643,"firstName":"Bellina","lastName":"Gouldie","street":"7567 Bultman Way","postalCode":"88514","city":"El Paso","state":"TX","email":"bgouldiehu@salon.com"}, +{"id":644,"firstName":"Devi","lastName":"Bohden","street":"68833 Northview Hill","postalCode":"84115","city":"Salt Lake City","state":"UT"}, +{"id":645,"firstName":"Peggi","lastName":"Gobert","street":"667 Sauthoff Hill","postalCode":"44710","city":"Canton","state":"OH","email":"pgoberthw@mapy.cz"}, +{"id":646,"firstName":"Madelina","lastName":"Gurys","street":"70 Del Sol Trail","postalCode":"20420","city":"Washington","state":"DC","phoneNumber":"202-747-9276","email":"mguryshx@hibu.com"}, +{"id":647,"firstName":"Ikey","lastName":"Aubri","street":"76 Sutteridge Hill","postalCode":"36205","city":"Anniston","state":"AL","phoneNumber":"256-945-5095","email":"iaubrihy@mayoclinic.com"}, +{"id":648,"firstName":"Ginevra","lastName":"Duffitt","street":"25 Eagan Circle","postalCode":"31217","city":"Macon","state":"GA"}, +{"id":649,"firstName":"Cissiee","lastName":"Gozzard","street":"40240 Lillian Park","postalCode":"60609","city":"Chicago","state":"IL","email":"cgozzardi0@columbia.edu"}, +{"id":650,"firstName":"Sonny","lastName":"Jobern","street":"8 Green Trail","postalCode":"77065","city":"Houston","state":"TX","email":"sjoberni1@ucoz.com"}, +{"id":651,"firstName":"Mitch","lastName":"Guidera","street":"0 Dorton Junction","postalCode":"35210","city":"Birmingham","state":"AL","phoneNumber":"205-224-0177"}, +{"id":652,"firstName":"Dorey","lastName":"Marks","street":"81562 Maywood Crossing","postalCode":"71208","city":"Monroe","state":"LA","phoneNumber":"318-492-5487"}, +{"id":653,"firstName":"Pavla","lastName":"Conneely","street":"4007 Mifflin Lane","postalCode":"20456","city":"Washington","state":"DC"}, +{"id":654,"firstName":"Kym","lastName":"Gecks","street":"72638 Namekagon Plaza","postalCode":"61656","city":"Peoria","state":"IL","email":"kgecksi5@nature.com"}, +{"id":655,"firstName":"Prudence","lastName":"Peert","street":"91 Tomscot Parkway","postalCode":"32209","city":"Jacksonville","state":"FL","phoneNumber":"904-277-2945","email":"ppeerti6@usa.gov"}, +{"id":656,"firstName":"Elston","lastName":"Paolo","street":"4 Jenna Crossing","postalCode":"95155","city":"San Jose","state":"CA","email":"epaoloi7@umn.edu"}, +{"id":657,"firstName":"Indira","lastName":"Splaven","street":"8853 Vermont Drive","postalCode":"38188","city":"Memphis","state":"TN","phoneNumber":"901-706-3908","email":"isplaveni8@fda.gov"}, +{"id":658,"firstName":"Paul","lastName":"Mc Meekin","street":"56 Vidon Drive","postalCode":"08695","city":"Trenton","state":"NJ","phoneNumber":"609-361-1580"}, +{"id":659,"firstName":"Hadley","lastName":"Windmill","street":"31384 Evergreen Point","postalCode":"16550","city":"Erie","state":"PA","email":"hwindmillia@yale.edu"}, +{"id":660,"firstName":"Jay","lastName":"Yesichev","street":"675 Starling Pass","postalCode":"89150","city":"Las Vegas","state":"NV"}, +{"id":661,"firstName":"Ranna","lastName":"Dowtry","street":"303 Nevada Pass","postalCode":"48550","city":"Flint","state":"MI","phoneNumber":"810-164-4521","email":"rdowtryic@amazon.co.jp"}, +{"id":662,"firstName":"Annabel","lastName":"Pellamont","street":"277 Merrick Crossing","postalCode":"36605","city":"Mobile","state":"AL","phoneNumber":"251-595-3594","email":"apellamontid@reverbnation.com"}, +{"id":663,"firstName":"Kaitlynn","lastName":"Tracey","street":"612 Magdeline Road","postalCode":"97296","city":"Portland","state":"OR","email":"ktraceyie@ycombinator.com"}, +{"id":664,"firstName":"Matthiew","lastName":"Jills","street":"65 Walton Circle","postalCode":"93750","city":"Fresno","state":"CA","email":"mjillsif@addthis.com"}, +{"id":665,"firstName":"Bartlet","lastName":"Roe","street":"51573 Mandrake Park","postalCode":"02109","city":"Boston","state":"MA","phoneNumber":"617-460-5377","email":"broeig@nasa.gov"}, +{"id":666,"firstName":"Ban","lastName":"Knotton","street":"174 Westridge Parkway","postalCode":"32405","city":"Panama City","state":"FL","phoneNumber":"850-939-6502","email":"bknottonih@businesswire.com"}, +{"id":667,"firstName":"Cordelie","lastName":"O'Dee","street":"1733 Linden Avenue","postalCode":"80940","city":"Colorado Springs","state":"CO","phoneNumber":"719-966-3402","email":"codeeii@amazonaws.com"}, +{"id":668,"firstName":"Hardy","lastName":"Lob","street":"4 Bultman Road","postalCode":"75074","city":"Plano","state":"TX","email":"hlobij@dropbox.com"}, +{"id":669,"firstName":"Rosabelle","lastName":"Tonner","street":"1 Holy Cross Trail","postalCode":"36670","city":"Mobile","state":"AL","phoneNumber":"251-606-9437","email":"rtonnerik@google.ru"}, +{"id":670,"firstName":"Bernardina","lastName":"Mardy","street":"65 Myrtle Center","postalCode":"96845","city":"Honolulu","state":"HI","email":"bmardyil@wordpress.com"}, +{"id":671,"firstName":"Hynda","lastName":"Soldner","street":"88 Hazelcrest Drive","postalCode":"55470","city":"Minneapolis","state":"MN","email":"hsoldnerim@webeden.co.uk"}, +{"id":672,"firstName":"Quinn","lastName":"Templeton","street":"5 Village Way","postalCode":"19131","city":"Philadelphia","state":"PA","email":"qtempletonin@diigo.com"}, +{"id":673,"firstName":"Torrence","lastName":"Askwith","street":"1 Namekagon Point","postalCode":"31410","city":"Savannah","state":"GA","phoneNumber":"912-552-5239","email":"taskwithio@people.com.cn"}, +{"id":674,"firstName":"Bonnie","lastName":"Robilliard","street":"731 Johnson Lane","postalCode":"24515","city":"Lynchburg","state":"VA","phoneNumber":"434-382-5496"}, +{"id":675,"firstName":"Daphna","lastName":"D'Souza","street":"1549 Loftsgordon Center","postalCode":"91406","city":"Van Nuys","state":"CA","phoneNumber":"818-773-9088"}, +{"id":676,"firstName":"Palm","lastName":"Gandrich","street":"9 4th Pass","postalCode":"87121","city":"Albuquerque","state":"NM","phoneNumber":"505-815-5555"}, +{"id":677,"firstName":"Danie","lastName":"Gaydon","street":"382 Bayside Junction","postalCode":"55441","city":"Minneapolis","state":"MN","phoneNumber":"952-744-9400","email":"dgaydonis@seesaa.net"}, +{"id":678,"firstName":"Tabatha","lastName":"Caddock","street":"3858 Mccormick Road","postalCode":"53779","city":"Madison","state":"WI","phoneNumber":"608-996-7653","email":"tcaddockit@gizmodo.com"}, +{"id":679,"firstName":"Sergent","lastName":"Cade","street":"7 Riverside Crossing","postalCode":"13505","city":"Utica","state":"NY","email":"scadeiu@google.co.uk"}, +{"id":680,"firstName":"Shina","lastName":"Dumphry","street":"483 Del Mar Terrace","postalCode":"73109","city":"Oklahoma City","state":"OK","phoneNumber":"405-261-3364","email":"sdumphryiv@mediafire.com"}, +{"id":681,"firstName":"Aaron","lastName":"O'Neal","street":"669 Crowley Road","postalCode":"87140","city":"Albuquerque","state":"NM","phoneNumber":"505-451-6591","email":"aonealiw@npr.org"}, +{"id":682,"firstName":"Cynthea","lastName":"Wippermann","street":"109 Kinsman Parkway","postalCode":"06606","city":"Bridgeport","state":"CT","phoneNumber":"203-799-4552"}, +{"id":683,"firstName":"Stoddard","lastName":"Hullett","street":"06200 Mesta Park","postalCode":"78769","city":"Austin","state":"TX","phoneNumber":"512-190-7003"}, +{"id":684,"firstName":"Margit","lastName":"Comusso","street":"54 Springs Center","postalCode":"33737","city":"Saint Petersburg","state":"FL","phoneNumber":"727-144-3743","email":"mcomussoiz@drupal.org"}, +{"id":685,"firstName":"Dur","lastName":"Manns","street":"464 Park Meadow Road","postalCode":"90015","city":"Los Angeles","state":"CA","email":"dmannsj0@nymag.com"}, +{"id":686,"firstName":"Hollie","lastName":"Aldersey","street":"12195 Mallory Court","postalCode":"21405","city":"Annapolis","state":"MD","email":"halderseyj1@businessinsider.com"}, +{"id":687,"firstName":"Ralina","lastName":"Crepin","street":"13313 Clyde Gallagher Way","postalCode":"78285","city":"San Antonio","state":"TX"}, +{"id":688,"firstName":"Lyell","lastName":"Graveston","street":"20 Talisman Crossing","postalCode":"27157","city":"Winston Salem","state":"NC","phoneNumber":"336-638-3366","email":"lgravestonj3@webmd.com"}, +{"id":689,"firstName":"Anny","lastName":"Potell","street":"0 Ludington Circle","postalCode":"32803","city":"Orlando","state":"FL","email":"apotellj4@microsoft.com"}, +{"id":690,"firstName":"Harriot","lastName":"Klimpke","street":"8 Southridge Alley","postalCode":"22047","city":"Falls Church","state":"VA","phoneNumber":"571-470-2688","email":"hklimpkej5@slashdot.org"}, +{"id":691,"firstName":"Stacia","lastName":"Stainsby","street":"78 Mcbride Avenue","postalCode":"46862","city":"Fort Wayne","state":"IN"}, +{"id":692,"firstName":"Zacharia","lastName":"Willmont","street":"24 Everett Center","postalCode":"73135","city":"Oklahoma City","state":"OK","phoneNumber":"405-167-0584","email":"zwillmontj7@tuttocitta.it"}, +{"id":693,"firstName":"Dorelia","lastName":"Flexman","street":"0 Hauk Crossing","postalCode":"95298","city":"Stockton","state":"CA","phoneNumber":"209-759-3308"}, +{"id":694,"firstName":"Rubi","lastName":"Karran","street":"586 Eggendart Pass","postalCode":"64082","city":"Lees Summit","state":"MO","email":"rkarranj9@yahoo.com"}, +{"id":695,"firstName":"Edlin","lastName":"Davidsen","street":"5646 Arrowood Park","postalCode":"20591","city":"Washington","state":"DC","phoneNumber":"202-800-5817","email":"edavidsenja@purevolume.com"}, +{"id":696,"firstName":"Oralle","lastName":"Coneybeare","street":"0 Lakewood Parkway","postalCode":"08695","city":"Trenton","state":"NJ","email":"oconeybearejb@booking.com"}, +{"id":697,"firstName":"Scotti","lastName":"Cereceres","street":"2 Golf Hill","postalCode":"38119","city":"Memphis","state":"TN"}, +{"id":698,"firstName":"Hermione","lastName":"Mingotti","street":"14 Shoshone Alley","postalCode":"44511","city":"Youngstown","state":"OH","phoneNumber":"330-505-0585"}, +{"id":699,"firstName":"Janka","lastName":"Merredy","street":"877 Reinke Park","postalCode":"45233","city":"Cincinnati","state":"OH","email":"jmerredyje@furl.net"}, +{"id":700,"firstName":"Phillida","lastName":"Gannicleff","street":"48778 Sheridan Center","postalCode":"99210","city":"Spokane","state":"WA","email":"pgannicleffjf@github.io"}, +{"id":701,"firstName":"Bryn","lastName":"Shury","street":"82609 Surrey Road","postalCode":"78240","city":"San Antonio","state":"TX","phoneNumber":"210-361-9404","email":"bshuryjg@arstechnica.com"}, +{"id":702,"firstName":"Bobbe","lastName":"Yurocjhin","street":"54904 Southridge Parkway","postalCode":"33633","city":"Tampa","state":"FL","email":"byurocjhinjh@tumblr.com"}, +{"id":703,"firstName":"Noell","lastName":"Trewman","street":"63703 Fair Oaks Point","postalCode":"91520","city":"Burbank","state":"CA"}, +{"id":704,"firstName":"Adelind","lastName":"Marr","street":"68 Lotheville Park","postalCode":"02912","city":"Providence","state":"RI","email":"amarrjj@hexun.com"}, +{"id":705,"firstName":"Arabelle","lastName":"Oultram","street":"7927 Waxwing Place","postalCode":"77085","city":"Houston","state":"TX","email":"aoultramjk@diigo.com"}, +{"id":706,"firstName":"Derril","lastName":"Whylie","street":"1 Summerview Terrace","postalCode":"91606","city":"North Hollywood","state":"CA","phoneNumber":"323-244-3266","email":"dwhyliejl@auda.org.au"}, +{"id":707,"firstName":"Isadore","lastName":"Airth","street":"08897 Hauk Court","postalCode":"73104","city":"Oklahoma City","state":"OK","phoneNumber":"405-488-1807"}, +{"id":708,"firstName":"Barbara","lastName":"Feast","street":"420 Bayside Circle","postalCode":"63136","city":"Saint Louis","state":"MO","phoneNumber":"314-919-9094"}, +{"id":709,"firstName":"Engracia","lastName":"Laxtonne","street":"189 Oneill Center","postalCode":"22047","city":"Falls Church","state":"VA","email":"elaxtonnejo@addthis.com"}, +{"id":710,"firstName":"Dorice","lastName":"Dearle","street":"655 Union Way","postalCode":"47705","city":"Evansville","state":"IN","phoneNumber":"812-812-8795","email":"ddearlejp@mail.ru"}, +{"id":711,"firstName":"Crissie","lastName":"Leall","street":"1 1st Drive","postalCode":"36689","city":"Mobile","state":"AL","phoneNumber":"251-112-1542","email":"clealljq@nyu.edu"}, +{"id":712,"firstName":"Rica","lastName":"Wilshin","street":"0 Miller Way","postalCode":"79705","city":"Midland","state":"TX","phoneNumber":"432-935-1867"}, +{"id":713,"firstName":"Annie","lastName":"Thorns","street":"297 Thompson Park","postalCode":"32412","city":"Panama City","state":"FL","phoneNumber":"850-594-4049"}, +{"id":714,"firstName":"Lilah","lastName":"Beining","street":"1566 American Ash Avenue","postalCode":"25326","city":"Charleston","state":"WV","email":"lbeiningjt@mayoclinic.com"}, +{"id":715,"firstName":"Leeann","lastName":"Dorant","street":"5530 Mcguire Alley","postalCode":"93407","city":"San Luis Obispo","state":"CA","email":"ldorantju@homestead.com"}, +{"id":716,"firstName":"Elinor","lastName":"James","street":"2 Waxwing Terrace","postalCode":"88579","city":"El Paso","state":"TX","email":"ejamesjv@europa.eu"}, +{"id":717,"firstName":"Novelia","lastName":"Durman","street":"7 Hermina Junction","postalCode":"77050","city":"Houston","state":"TX","email":"ndurmanjw@fc2.com"}, +{"id":718,"firstName":"Sharai","lastName":"Pickervance","street":"739 Lien Junction","postalCode":"73167","city":"Oklahoma City","state":"OK","email":"spickervancejx@independent.co.uk"}, +{"id":719,"firstName":"Gilberte","lastName":"Stilling","street":"29950 Annamark Trail","postalCode":"89178","city":"Las Vegas","state":"NV","phoneNumber":"702-604-4240","email":"gstillingjy@feedburner.com"}, +{"id":720,"firstName":"Rosabelle","lastName":"Guinan","street":"13078 Sutherland Center","postalCode":"83757","city":"Boise","state":"ID","phoneNumber":"208-792-6705"}, +{"id":721,"firstName":"Karin","lastName":"Ackermann","street":"3 Susan Hill","postalCode":"48919","city":"Lansing","state":"MI","phoneNumber":"517-579-7811","email":"kackermannk0@csmonitor.com"}, +{"id":722,"firstName":"Reeta","lastName":"Attwell","street":"96 Alpine Junction","postalCode":"66622","city":"Topeka","state":"KS"}, +{"id":723,"firstName":"Dru","lastName":"Linck","street":"37 Wayridge Place","postalCode":"49505","city":"Grand Rapids","state":"MI","phoneNumber":"616-197-1837"}, +{"id":724,"firstName":"Frances","lastName":"Collingridge","street":"273 Ludington Crossing","postalCode":"77255","city":"Houston","state":"TX"}, +{"id":725,"firstName":"Wilmette","lastName":"Haimes","street":"8408 Shopko Circle","postalCode":"98907","city":"Yakima","state":"WA","phoneNumber":"509-821-5948"}, +{"id":726,"firstName":"Isahella","lastName":"Rubrow","street":"25 Melby Crossing","postalCode":"59105","city":"Billings","state":"MT","email":"irubrowk5@edublogs.org"}, +{"id":727,"firstName":"Walden","lastName":"Sappson","street":"1 3rd Hill","postalCode":"60435","city":"Joliet","state":"IL","email":"wsappsonk6@ameblo.jp"}, +{"id":728,"firstName":"Blondie","lastName":"Godehard.sf","street":"4606 Caliangt Circle","postalCode":"20709","city":"Laurel","state":"MD"}, +{"id":729,"firstName":"Dion","lastName":"Wingeatt","street":"098 Ridgeview Alley","postalCode":"78769","city":"Austin","state":"TX","phoneNumber":"512-948-4113","email":"dwingeattk8@clickbank.net"}, +{"id":730,"firstName":"Antoni","lastName":"Tibbles","street":"9 Muir Court","postalCode":"25313","city":"Charleston","state":"WV","phoneNumber":"304-298-6149","email":"atibblesk9@usa.gov"}, +{"id":731,"firstName":"Quinn","lastName":"McKevin","street":"063 Washington Parkway","postalCode":"55470","city":"Minneapolis","state":"MN","phoneNumber":"612-140-1997"}, +{"id":732,"firstName":"Rita","lastName":"Hallam","street":"4 Chive Court","postalCode":"85025","city":"Phoenix","state":"AZ","email":"rhallamkb@list-manage.com"}, +{"id":733,"firstName":"Cliff","lastName":"McCrum","street":"30841 Scoville Street","postalCode":"38150","city":"Memphis","state":"TN","phoneNumber":"901-983-7713","email":"cmccrumkc@yellowpages.com"}, +{"id":734,"firstName":"Allyson","lastName":"Petkov","street":"057 Grover Trail","postalCode":"55487","city":"Minneapolis","state":"MN","phoneNumber":"612-706-7185"}, +{"id":735,"firstName":"Tanney","lastName":"Cicccitti","street":"84959 Calypso Way","postalCode":"66629","city":"Topeka","state":"KS","phoneNumber":"785-516-0753","email":"tcicccittike@netscape.com"}, +{"id":736,"firstName":"Brendin","lastName":"Behnke","street":"3057 Browning Parkway","postalCode":"38181","city":"Memphis","state":"TN","email":"bbehnkekf@answers.com"}, +{"id":737,"firstName":"Sydelle","lastName":"Lestor","street":"6 Old Shore Way","postalCode":"73167","city":"Oklahoma City","state":"OK"}, +{"id":738,"firstName":"Nilson","lastName":"Nelthorp","street":"5 Gerald Trail","postalCode":"60567","city":"Naperville","state":"IL","phoneNumber":"630-718-5304","email":"nnelthorpkh@scribd.com"}, +{"id":739,"firstName":"Randy","lastName":"Boller","street":"64 Roth Junction","postalCode":"95354","city":"Modesto","state":"CA","phoneNumber":"209-795-8532","email":"rbollerki@nature.com"}, +{"id":740,"firstName":"Vicki","lastName":"De Vaan","street":"08 Mariners Cove Terrace","postalCode":"62776","city":"Springfield","state":"IL","email":"vdevaankj@disqus.com"}, +{"id":741,"firstName":"Romain","lastName":"Castri","street":"7 Atwood Road","postalCode":"02905","city":"Providence","state":"RI","phoneNumber":"401-865-9950","email":"rcastrikk@google.com.br"}, +{"id":742,"firstName":"Adlai","lastName":"Keppel","street":"6 Farragut Circle","postalCode":"76705","city":"Waco","state":"TX","phoneNumber":"254-852-6322"}, +{"id":743,"firstName":"Arlyne","lastName":"Whalley","street":"6 Esker Terrace","postalCode":"83727","city":"Boise","state":"ID","email":"awhalleykm@amazon.co.uk"}, +{"id":744,"firstName":"Alistair","lastName":"Jennins","street":"6 Loeprich Center","postalCode":"21684","city":"Ridgely","state":"MD","phoneNumber":"410-494-2201","email":"ajenninskn@sciencedaily.com"}, +{"id":745,"firstName":"Farr","lastName":"Steer","street":"8569 Eliot Lane","postalCode":"93381","city":"Bakersfield","state":"CA","phoneNumber":"661-416-1609","email":"fsteerko@usgs.gov"}, +{"id":746,"firstName":"Analise","lastName":"Balasini","street":"8901 Lyons Parkway","postalCode":"23242","city":"Richmond","state":"VA","email":"abalasinikp@imgur.com"}, +{"id":747,"firstName":"Gilbert","lastName":"Lockton","street":"3 Leroy Court","postalCode":"49018","city":"Battle Creek","state":"MI","email":"glocktonkq@google.nl"}, +{"id":748,"firstName":"Hamlen","lastName":"Massie","street":"469 Mallory Drive","postalCode":"77250","city":"Houston","state":"TX","email":"hmassiekr@admin.ch"}, +{"id":749,"firstName":"Ebony","lastName":"Loker","street":"21173 Raven Point","postalCode":"21265","city":"Baltimore","state":"MD"}, +{"id":750,"firstName":"Kristina","lastName":"Deeble","street":"479 Warner Park","postalCode":"92013","city":"Carlsbad","state":"CA","phoneNumber":"760-377-7198","email":"kdeeblekt@ezinearticles.com"}, +{"id":751,"firstName":"Jabez","lastName":"Mummery","street":"1 East Point","postalCode":"52809","city":"Davenport","state":"IA","email":"jmummeryku@sfgate.com"}, +{"id":752,"firstName":"Perrine","lastName":"Aldwinckle","street":"98 Montana Avenue","postalCode":"85030","city":"Phoenix","state":"AZ","phoneNumber":"602-224-2810","email":"paldwincklekv@eepurl.com"}, +{"id":753,"firstName":"Humfried","lastName":"Pendleton","street":"843 Swallow Park","postalCode":"89115","city":"Las Vegas","state":"NV","phoneNumber":"702-524-6047"}, +{"id":754,"firstName":"Dario","lastName":"Chesshire","street":"638 Westport Place","postalCode":"96845","city":"Honolulu","state":"HI","phoneNumber":"808-718-1386"}, +{"id":755,"firstName":"Cherianne","lastName":"Hearfield","street":"15 Quincy Street","postalCode":"14233","city":"Buffalo","state":"NY","email":"chearfieldky@technorati.com"}, +{"id":756,"firstName":"Jemima","lastName":"Oxnam","street":"22276 Maple Street","postalCode":"92165","city":"San Diego","state":"CA","email":"joxnamkz@addtoany.com"}, +{"id":757,"firstName":"Tedmund","lastName":"Chandler","street":"81 Katie Point","postalCode":"44310","city":"Akron","state":"OH","phoneNumber":"330-336-2279","email":"tchandlerl0@webeden.co.uk"}, +{"id":758,"firstName":"Tobie","lastName":"Risley","street":"82996 Reindahl Junction","postalCode":"17140","city":"Harrisburg","state":"PA","phoneNumber":"717-272-9110","email":"trisleyl1@youtu.be"}, +{"id":759,"firstName":"Tomi","lastName":"Crevagh","street":"91791 Buhler Park","postalCode":"33715","city":"Saint Petersburg","state":"FL"}, +{"id":760,"firstName":"Luce","lastName":"Gwatkin","street":"424 Lunder Crossing","postalCode":"31416","city":"Savannah","state":"GA"}, +{"id":761,"firstName":"Vinita","lastName":"Hannon","street":"90 Claremont Trail","postalCode":"39236","city":"Jackson","state":"MS"}, +{"id":762,"firstName":"Ruby","lastName":"O'Cosgra","street":"304 Dayton Avenue","postalCode":"07188","city":"Newark","state":"NJ"}, +{"id":763,"firstName":"Amandi","lastName":"Vasiltsov","street":"98188 Killdeer Alley","postalCode":"93399","city":"Bakersfield","state":"CA","email":"avasiltsovl6@smh.com.au"}, +{"id":764,"firstName":"Juliana","lastName":"Goldspink","street":"93 Maryland Terrace","postalCode":"06705","city":"Waterbury","state":"CT","email":"jgoldspinkl7@guardian.co.uk"}, +{"id":765,"firstName":"Giorgi","lastName":"Yakovl","street":"24240 Shasta Drive","postalCode":"46814","city":"Fort Wayne","state":"IN","phoneNumber":"260-754-5907"}, +{"id":766,"firstName":"Aleksandr","lastName":"Justun","street":"06 Fulton Terrace","postalCode":"85025","city":"Phoenix","state":"AZ"}, +{"id":767,"firstName":"Cornela","lastName":"Grindell","street":"1 Hazelcrest Lane","postalCode":"53285","city":"Milwaukee","state":"WI"}, +{"id":768,"firstName":"Liv","lastName":"Madrell","street":"623 Cordelia Terrace","postalCode":"17105","city":"Harrisburg","state":"PA","email":"lmadrelllb@1688.com"}, +{"id":769,"firstName":"Konstance","lastName":"Rosebotham","street":"8930 Utah Terrace","postalCode":"20029","city":"Washington","state":"DC","email":"krosebothamlc@studiopress.com"}, +{"id":770,"firstName":"Theo","lastName":"Scotland","street":"454 Hintze Park","postalCode":"45238","city":"Cincinnati","state":"OH"}, +{"id":771,"firstName":"Trefor","lastName":"Rein","street":"9 Redwing Plaza","postalCode":"22184","city":"Vienna","state":"VA","email":"treinle@barnesandnoble.com"}, +{"id":772,"firstName":"Angelina","lastName":"Bromehead","street":"62477 Walton Circle","postalCode":"14683","city":"Rochester","state":"NY","email":"abromeheadlf@php.net"}, +{"id":773,"firstName":"Thornie","lastName":"Ivanishin","street":"0 Sunbrook Court","postalCode":"34665","city":"Pinellas Park","state":"FL","email":"tivanishinlg@aol.com"}, +{"id":774,"firstName":"Dyana","lastName":"McNickle","street":"2696 Lakewood Gardens Pass","postalCode":"20456","city":"Washington","state":"DC","phoneNumber":"202-653-8740"}, +{"id":775,"firstName":"Humfried","lastName":"Suero","street":"643 Pearson Junction","postalCode":"28410","city":"Wilmington","state":"NC"}, +{"id":776,"firstName":"Jessamine","lastName":"Stockings","street":"739 Moose Street","postalCode":"94137","city":"San Francisco","state":"CA","phoneNumber":"415-641-0091","email":"jstockingslj@skype.com"}, +{"id":777,"firstName":"Laryssa","lastName":"Grahl","street":"0538 Bultman Point","postalCode":"81505","city":"Grand Junction","state":"CO"}, +{"id":778,"firstName":"Susan","lastName":"Stonnell","street":"7 Dennis Parkway","postalCode":"67215","city":"Wichita","state":"KS","phoneNumber":"316-966-3243","email":"sstonnellll@nps.gov"}, +{"id":779,"firstName":"Melinde","lastName":"Segoe","street":"9 Dottie Place","postalCode":"19125","city":"Philadelphia","state":"PA","phoneNumber":"215-119-3801"}, +{"id":780,"firstName":"Skip","lastName":"Sedgebeer","street":"1 Eliot Drive","postalCode":"20005","city":"Washington","state":"DC","email":"ssedgebeerln@blogtalkradio.com"}, +{"id":781,"firstName":"Annabel","lastName":"Schusterl","street":"6094 Talisman Lane","postalCode":"68510","city":"Lincoln","state":"NE","phoneNumber":"402-355-7934","email":"aschusterllo@cargocollective.com"}, +{"id":782,"firstName":"Emiline","lastName":"Whittlesey","street":"5 Claremont Lane","postalCode":"77040","city":"Houston","state":"TX","phoneNumber":"832-835-1321","email":"ewhittleseylp@geocities.com"}, +{"id":783,"firstName":"Frasquito","lastName":"Loukes","street":"47 Merchant Pass","postalCode":"27499","city":"Greensboro","state":"NC","phoneNumber":"336-265-5719","email":"floukeslq@google.it"}, +{"id":784,"firstName":"Jerald","lastName":"Fairholm","street":"5939 Mariners Cove Road","postalCode":"76598","city":"Gatesville","state":"TX","email":"jfairholmlr@smh.com.au"}, +{"id":785,"firstName":"Melisent","lastName":"Strange","street":"50 Glendale Trail","postalCode":"10606","city":"White Plains","state":"NY"}, +{"id":786,"firstName":"Aaron","lastName":"Mixter","street":"14347 Darwin Place","postalCode":"33124","city":"Miami","state":"FL","phoneNumber":"786-244-1856","email":"amixterlt@dmoz.org"}, +{"id":787,"firstName":"Margy","lastName":"Falla","street":"5 Caliangt Trail","postalCode":"40287","city":"Louisville","state":"KY","email":"mfallalu@booking.com"}, +{"id":788,"firstName":"Malinde","lastName":"Ashdown","street":"97234 Anniversary Hill","postalCode":"06152","city":"Hartford","state":"CT","phoneNumber":"860-140-7408","email":"mashdownlv@economist.com"}, +{"id":789,"firstName":"Carolynn","lastName":"Dulany","street":"33 Melby Road","postalCode":"74116","city":"Tulsa","state":"OK","phoneNumber":"918-140-7039","email":"cdulanylw@yelp.com"}, +{"id":790,"firstName":"Kissee","lastName":"Escale","street":"1470 Hanson Parkway","postalCode":"92812","city":"Anaheim","state":"CA","phoneNumber":"714-466-6376"}, +{"id":791,"firstName":"Rebeka","lastName":"Moralee","street":"898 Oak Street","postalCode":"34108","city":"Naples","state":"FL","email":"rmoraleely@shutterfly.com"}, +{"id":792,"firstName":"Cort","lastName":"Arter","street":"35039 Menomonie Way","postalCode":"50936","city":"Des Moines","state":"IA","email":"carterlz@surveymonkey.com"}, +{"id":793,"firstName":"Kirsteni","lastName":"Heady","street":"473 Lawn Street","postalCode":"32092","city":"Saint Augustine","state":"FL","phoneNumber":"904-424-3526","email":"kheadym0@usda.gov"}, +{"id":794,"firstName":"Ettie","lastName":"Overil","street":"1085 Waubesa Lane","postalCode":"18105","city":"Allentown","state":"PA"}, +{"id":795,"firstName":"Evey","lastName":"Tesimon","street":"9 Cordelia Place","postalCode":"55127","city":"Saint Paul","state":"MN"}, +{"id":796,"firstName":"Hersh","lastName":"Lebond","street":"5265 Bartelt Park","postalCode":"34282","city":"Bradenton","state":"FL","phoneNumber":"941-114-7090"}, +{"id":797,"firstName":"Hendrika","lastName":"Govan","street":"27747 La Follette Avenue","postalCode":"21229","city":"Baltimore","state":"MD","email":"hgovanm4@cam.ac.uk"}, +{"id":798,"firstName":"Renado","lastName":"Hambly","street":"5211 Schmedeman Drive","postalCode":"68105","city":"Omaha","state":"NE","phoneNumber":"402-183-0376","email":"rhamblym5@netlog.com"}, +{"id":799,"firstName":"Brewer","lastName":"Boyn","street":"3161 Novick Lane","postalCode":"77055","city":"Houston","state":"TX","email":"bboynm6@google.it"}, +{"id":800,"firstName":"Patrick","lastName":"Speck","street":"57052 Ronald Regan Way","postalCode":"30306","city":"Atlanta","state":"GA","phoneNumber":"770-764-6971","email":"pspeckm7@live.com"}, +{"id":801,"firstName":"Skipper","lastName":"Conybear","street":"75 Autumn Leaf Alley","postalCode":"79968","city":"El Paso","state":"TX","phoneNumber":"915-705-5594","email":"sconybearm8@jimdo.com"}, +{"id":802,"firstName":"Elmore","lastName":"Quilty","street":"027 Warbler Court","postalCode":"35210","city":"Birmingham","state":"AL","email":"equiltym9@ebay.co.uk"}, +{"id":803,"firstName":"Estella","lastName":"Jorck","street":"52695 Holy Cross Trail","postalCode":"47134","city":"Jeffersonville","state":"IN","email":"ejorckma@bluehost.com"}, +{"id":804,"firstName":"Scotti","lastName":"Goodale","street":"7551 Dottie Pass","postalCode":"77713","city":"Beaumont","state":"TX","email":"sgoodalemb@nba.com"}, +{"id":805,"firstName":"Catha","lastName":"Shekle","street":"38839 Derek Terrace","postalCode":"62718","city":"Springfield","state":"IL","email":"csheklemc@tmall.com"}, +{"id":806,"firstName":"Clemens","lastName":"Chuter","street":"015 Charing Cross Pass","postalCode":"30306","city":"Atlanta","state":"GA"}, +{"id":807,"firstName":"Kiley","lastName":"Vasiltsov","street":"8 Reindahl Hill","postalCode":"33432","city":"Boca Raton","state":"FL","email":"kvasiltsovme@google.nl"}, +{"id":808,"firstName":"Korrie","lastName":"McGauhy","street":"188 Golf Lane","postalCode":"89110","city":"Las Vegas","state":"NV","phoneNumber":"702-647-1620","email":"kmcgauhymf@goodreads.com"}, +{"id":809,"firstName":"Giustina","lastName":"Hentze","street":"62244 Roth Way","postalCode":"48604","city":"Saginaw","state":"MI","email":"ghentzemg@pcworld.com"}, +{"id":810,"firstName":"Emilia","lastName":"Virgoe","street":"13910 Alpine Lane","postalCode":"33994","city":"Fort Myers","state":"FL","phoneNumber":"239-993-2041","email":"evirgoemh@mediafire.com"}, +{"id":811,"firstName":"Gordan","lastName":"Trimming","street":"38168 Transport Avenue","postalCode":"38131","city":"Memphis","state":"TN","email":"gtrimmingmi@spiegel.de"}, +{"id":812,"firstName":"Tadeo","lastName":"Vannoort","street":"41476 Pond Alley","postalCode":"20851","city":"Rockville","state":"MD","phoneNumber":"240-432-6489","email":"tvannoortmj@privacy.gov.au"}, +{"id":813,"firstName":"Joseito","lastName":"Viant","street":"1390 Kropf Court","postalCode":"04109","city":"Portland","state":"ME"}, +{"id":814,"firstName":"Blake","lastName":"Tailby","street":"5 Bultman Terrace","postalCode":"31914","city":"Columbus","state":"GA"}, +{"id":815,"firstName":"Cynthie","lastName":"Victor","street":"64 Hoard Avenue","postalCode":"46221","city":"Indianapolis","state":"IN","phoneNumber":"317-836-2511","email":"cvictormm@bizjournals.com"}, +{"id":816,"firstName":"Kristoforo","lastName":"Luckman","street":"019 Ohio Avenue","postalCode":"58505","city":"Bismarck","state":"ND","phoneNumber":"701-921-3472"}, +{"id":817,"firstName":"Celinka","lastName":"Brakewell","street":"5702 Tennessee Pass","postalCode":"92612","city":"Irvine","state":"CA","phoneNumber":"714-584-5599","email":"cbrakewellmo@house.gov"}, +{"id":818,"firstName":"Analiese","lastName":"Debenham","street":"7 Straubel Pass","postalCode":"31704","city":"Albany","state":"GA","phoneNumber":"229-600-4384","email":"adebenhammp@dell.com"}, +{"id":819,"firstName":"Sebastiano","lastName":"Eskriett","street":"0 Northridge Pass","postalCode":"34114","city":"Naples","state":"FL","phoneNumber":"239-651-1326","email":"seskriettmq@berkeley.edu"}, +{"id":820,"firstName":"Jermaine","lastName":"Donisthorpe","street":"69319 Hollow Ridge Park","postalCode":"62794","city":"Springfield","state":"IL","phoneNumber":"217-510-3030","email":"jdonisthorpemr@istockphoto.com"}, +{"id":821,"firstName":"Tera","lastName":"Smalecombe","street":"646 Oakridge Avenue","postalCode":"43699","city":"Toledo","state":"OH","email":"tsmalecombems@tripod.com"}, +{"id":822,"firstName":"Issie","lastName":"Cohane","street":"79078 Fair Oaks Circle","postalCode":"40233","city":"Louisville","state":"KY","email":"icohanemt@wired.com"}, +{"id":823,"firstName":"Nanete","lastName":"Erb","street":"02 Truax Place","postalCode":"88563","city":"El Paso","state":"TX","phoneNumber":"915-234-2792"}, +{"id":824,"firstName":"Benetta","lastName":"Roger","street":"822 Fallview Alley","postalCode":"33625","city":"Tampa","state":"FL","phoneNumber":"813-715-8911","email":"brogermv@ca.gov"}, +{"id":825,"firstName":"Sascha","lastName":"Hillyatt","street":"06 Fisk Plaza","postalCode":"11407","city":"Jamaica","state":"NY"}, +{"id":826,"firstName":"Britt","lastName":"Gilderoy","street":"64312 Delaware Place","postalCode":"89135","city":"Las Vegas","state":"NV"}, +{"id":827,"firstName":"Sterne","lastName":"Frissell","street":"69121 Sycamore Way","postalCode":"06912","city":"Stamford","state":"CT"}, +{"id":828,"firstName":"Lonny","lastName":"Petersen","street":"6 Golf Course Crossing","postalCode":"32627","city":"Gainesville","state":"FL","phoneNumber":"352-245-3289","email":"lpetersenmz@msu.edu"}, +{"id":829,"firstName":"Maridel","lastName":"Clunie","street":"0312 Dryden Street","postalCode":"80328","city":"Boulder","state":"CO","phoneNumber":"303-848-1116","email":"mclunien0@china.com.cn"}, +{"id":830,"firstName":"Annabal","lastName":"Pruckner","street":"98481 Anhalt Pass","postalCode":"30340","city":"Atlanta","state":"GA","email":"aprucknern1@bandcamp.com"}, +{"id":831,"firstName":"Carin","lastName":"Ambrois","street":"7982 Vahlen Road","postalCode":"85010","city":"Phoenix","state":"AZ"}, +{"id":832,"firstName":"Consuela","lastName":"Grubey","street":"1 Lillian Circle","postalCode":"89714","city":"Carson City","state":"NV","email":"cgrubeyn3@google.pl"}, +{"id":833,"firstName":"Friedrick","lastName":"Ventom","street":"703 Almo Crossing","postalCode":"43215","city":"Columbus","state":"OH"}, +{"id":834,"firstName":"Shalom","lastName":"Rosten","street":"4460 Parkside Road","postalCode":"37215","city":"Nashville","state":"TN","email":"srostenn5@e-recht24.de"}, +{"id":835,"firstName":"Sofia","lastName":"Pottie","street":"89885 Golf Course Junction","postalCode":"27635","city":"Raleigh","state":"NC","email":"spottien6@weather.com"}, +{"id":836,"firstName":"Ed","lastName":"Cecely","street":"38576 Gina Trail","postalCode":"85305","city":"Glendale","state":"AZ","email":"ececelyn7@friendfeed.com"}, +{"id":837,"firstName":"Ruthann","lastName":"Bignold","street":"202 Monterey Alley","postalCode":"19104","city":"Philadelphia","state":"PA","phoneNumber":"610-892-3949"}, +{"id":838,"firstName":"Vonnie","lastName":"Leeming","street":"5 Farmco Center","postalCode":"18706","city":"Wilkes Barre","state":"PA"}, +{"id":839,"firstName":"Diandra","lastName":"Gredden","street":"68178 Parkside Hill","postalCode":"89120","city":"Las Vegas","state":"NV","phoneNumber":"702-952-4026"}, +{"id":840,"firstName":"Donny","lastName":"Bruckent","street":"6 Dapin Way","postalCode":"98127","city":"Seattle","state":"WA","email":"dbruckentnb@stumbleupon.com"}, +{"id":841,"firstName":"Mill","lastName":"Finlay","street":"9 Meadow Valley Terrace","postalCode":"94405","city":"San Mateo","state":"CA","email":"mfinlaync@hibu.com"}, +{"id":842,"firstName":"Garv","lastName":"Feldberger","street":"5916 Marquette Lane","postalCode":"98127","city":"Seattle","state":"WA"}, +{"id":843,"firstName":"Micheal","lastName":"Favela","street":"41587 Dunning Road","postalCode":"47712","city":"Evansville","state":"IN"}, +{"id":844,"firstName":"Shannon","lastName":"Alvaro","street":"86377 Becker Avenue","postalCode":"33315","city":"Fort Lauderdale","state":"FL","phoneNumber":"954-661-6648","email":"salvaronf@usa.gov"}, +{"id":845,"firstName":"Corenda","lastName":"Aldcorn","street":"19 Bowman Court","postalCode":"67220","city":"Wichita","state":"KS","phoneNumber":"316-835-1638","email":"caldcornng@ebay.com"}, +{"id":846,"firstName":"Alvy","lastName":"Mahood","street":"0814 Spohn Hill","postalCode":"50347","city":"Des Moines","state":"IA","phoneNumber":"515-865-3669","email":"amahoodnh@toplist.cz"}, +{"id":847,"firstName":"Alexandr","lastName":"Stut","street":"8672 Anderson Court","postalCode":"78410","city":"Corpus Christi","state":"TX"}, +{"id":848,"firstName":"Gale","lastName":"Chaperling","street":"78873 Bellgrove Alley","postalCode":"10009","city":"New York City","state":"NY","phoneNumber":"212-978-6798","email":"gchaperlingnj@livejournal.com"}, +{"id":849,"firstName":"Eunice","lastName":"Dadson","street":"340 Dwight Hill","postalCode":"52809","city":"Davenport","state":"IA","phoneNumber":"563-787-9869","email":"edadsonnk@businessinsider.com"}, +{"id":850,"firstName":"Florentia","lastName":"Camin","street":"68733 Orin Point","postalCode":"46867","city":"Fort Wayne","state":"IN","phoneNumber":"260-920-3928","email":"fcaminnl@technorati.com"}, +{"id":851,"firstName":"Norina","lastName":"Vannacci","street":"585 Karstens Circle","postalCode":"45233","city":"Cincinnati","state":"OH"}, +{"id":852,"firstName":"Syd","lastName":"Gianolo","street":"99755 Arrowood Hill","postalCode":"33673","city":"Tampa","state":"FL","phoneNumber":"813-878-8150","email":"sgianolonn@uol.com.br"}, +{"id":853,"firstName":"Timofei","lastName":"Serle","street":"1081 Cascade Park","postalCode":"94257","city":"Sacramento","state":"CA","email":"tserleno@behance.net"}, +{"id":854,"firstName":"Moina","lastName":"Ciobutaro","street":"502 Stone Corner Circle","postalCode":"33018","city":"Hialeah","state":"FL","email":"mciobutaronp@ycombinator.com"}, +{"id":855,"firstName":"Nikolaos","lastName":"Gavaghan","street":"47136 Golf Junction","postalCode":"97255","city":"Portland","state":"OR"}, +{"id":856,"firstName":"Gallard","lastName":"Jenks","street":"2 Carioca Terrace","postalCode":"35263","city":"Birmingham","state":"AL","email":"gjenksnr@blogtalkradio.com"}, +{"id":857,"firstName":"Dare","lastName":"Nielson","street":"3 Carberry Hill","postalCode":"48604","city":"Saginaw","state":"MI","phoneNumber":"989-211-0944"}, +{"id":858,"firstName":"Cecilius","lastName":"Fasse","street":"1 Novick Street","postalCode":"68583","city":"Lincoln","state":"NE","phoneNumber":"402-342-4624","email":"cfassent@zimbio.com"}, +{"id":859,"firstName":"Kevon","lastName":"Doxsey","street":"152 Warrior Pass","postalCode":"91616","city":"North Hollywood","state":"CA","phoneNumber":"213-339-9582"}, +{"id":860,"firstName":"Matti","lastName":"Gras","street":"4567 Bunting Way","postalCode":"94544","city":"Hayward","state":"CA"}, +{"id":861,"firstName":"Nathan","lastName":"Longfut","street":"3178 Mockingbird Alley","postalCode":"97255","city":"Portland","state":"OR","phoneNumber":"971-206-3004"}, +{"id":862,"firstName":"Willetta","lastName":"Fitzpayn","street":"87 Alpine Drive","postalCode":"48604","city":"Saginaw","state":"MI","phoneNumber":"989-698-7578","email":"wfitzpaynnx@geocities.jp"}, +{"id":863,"firstName":"Emanuel","lastName":"Jikylls","street":"42 Heffernan Court","postalCode":"33884","city":"Winter Haven","state":"FL","email":"ejikyllsny@biglobe.ne.jp"}, +{"id":864,"firstName":"Lenard","lastName":"Nore","street":"7 Nevada Avenue","postalCode":"77343","city":"Huntsville","state":"TX","phoneNumber":"936-267-6742","email":"lnorenz@netscape.com"}, +{"id":865,"firstName":"Jeanine","lastName":"MacTurlough","street":"26343 Gale Crossing","postalCode":"53779","city":"Madison","state":"WI","phoneNumber":"608-865-6630","email":"jmacturlougho0@scientificamerican.com"}, +{"id":866,"firstName":"Jaquenetta","lastName":"Dorn","street":"3963 Novick Way","postalCode":"19495","city":"Valley Forge","state":"PA","email":"jdorno1@about.com"}, +{"id":867,"firstName":"Amity","lastName":"Titterrell","street":"3216 Lindbergh Court","postalCode":"90071","city":"Los Angeles","state":"CA","phoneNumber":"626-416-1494","email":"atitterrello2@psu.edu"}, +{"id":868,"firstName":"Rafaelia","lastName":"Melly","street":"6 Westridge Center","postalCode":"61825","city":"Champaign","state":"IL","email":"rmellyo3@ovh.net"}, +{"id":869,"firstName":"Cordi","lastName":"Martinovsky","street":"38 Forest Dale Terrace","postalCode":"50362","city":"Des Moines","state":"IA","email":"cmartinovskyo4@tuttocitta.it"}, +{"id":870,"firstName":"Humfrid","lastName":"Varne","street":"858 Farwell Street","postalCode":"06127","city":"West Hartford","state":"CT","email":"hvarneo5@yolasite.com"}, +{"id":871,"firstName":"Ford","lastName":"Pinchback","street":"363 Lien Pass","postalCode":"20599","city":"Washington","state":"DC","email":"fpinchbacko6@nytimes.com"}, +{"id":872,"firstName":"Maible","lastName":"Haresign","street":"809 Monica Point","postalCode":"28230","city":"Charlotte","state":"NC"}, +{"id":873,"firstName":"Rozamond","lastName":"Challis","street":"312 Mcbride Plaza","postalCode":"77266","city":"Houston","state":"TX","email":"rchalliso8@google.ca"}, +{"id":874,"firstName":"Myrah","lastName":"Menendez","street":"21 Garrison Plaza","postalCode":"23208","city":"Richmond","state":"VA","email":"mmenendezo9@msn.com"}, +{"id":875,"firstName":"Roberto","lastName":"Lamb","street":"3339 Cottonwood Pass","postalCode":"43699","city":"Toledo","state":"OH","phoneNumber":"419-633-9671"}, +{"id":876,"firstName":"Foster","lastName":"Delyth","street":"91500 Carpenter Point","postalCode":"79928","city":"El Paso","state":"TX","phoneNumber":"915-782-9005"}, +{"id":877,"firstName":"Nicholle","lastName":"Pickring","street":"8083 Talmadge Lane","postalCode":"14624","city":"Rochester","state":"NY","email":"npickringoc@tuttocitta.it"}, +{"id":878,"firstName":"Theodosia","lastName":"Bayliss","street":"6 Marcy Parkway","postalCode":"33954","city":"Port Charlotte","state":"FL"}, +{"id":879,"firstName":"Araldo","lastName":"Dowzell","street":"8376 Carpenter Court","postalCode":"71151","city":"Shreveport","state":"LA","email":"adowzelloe@army.mil"}, +{"id":880,"firstName":"Hugues","lastName":"McColgan","street":"990 Southridge Point","postalCode":"93591","city":"Palmdale","state":"CA","phoneNumber":"661-978-2646","email":"hmccolganof@netvibes.com"}, +{"id":881,"firstName":"Annissa","lastName":"Mordue","street":"62114 Ludington Lane","postalCode":"30911","city":"Augusta","state":"GA","phoneNumber":"706-152-3967","email":"amordueog@tripod.com"}, +{"id":882,"firstName":"Tierney","lastName":"Claughton","street":"3 Twin Pines Trail","postalCode":"88563","city":"El Paso","state":"TX","phoneNumber":"915-784-7980"}, +{"id":883,"firstName":"Rey","lastName":"Fleckno","street":"49 Oakridge Point","postalCode":"27605","city":"Raleigh","state":"NC"}, +{"id":884,"firstName":"Stacee","lastName":"Rewcastle","street":"19 Glendale Point","postalCode":"78278","city":"San Antonio","state":"TX","phoneNumber":"210-454-3087","email":"srewcastleoj@ustream.tv"}, +{"id":885,"firstName":"Delano","lastName":"Bragger","street":"0 Hoffman Center","postalCode":"47725","city":"Evansville","state":"IN","email":"dbraggerok@ifeng.com"}, +{"id":886,"firstName":"Redford","lastName":"Bare","street":"801 Garrison Court","postalCode":"08638","city":"Trenton","state":"NJ"}, +{"id":887,"firstName":"Grantham","lastName":"Arlidge","street":"69 Shelley Parkway","postalCode":"34210","city":"Bradenton","state":"FL","email":"garlidgeom@google.nl"}, +{"id":888,"firstName":"Debbie","lastName":"Tommaseo","street":"295 Crowley Alley","postalCode":"98516","city":"Olympia","state":"WA","email":"dtommaseoon@xrea.com"}, +{"id":889,"firstName":"Ragnar","lastName":"O' Byrne","street":"88163 Manitowish Terrace","postalCode":"20260","city":"Washington","state":"DC","phoneNumber":"202-982-3050","email":"robyrneoo@ft.com"}, +{"id":890,"firstName":"Leopold","lastName":"Woodington","street":"44 Vera Pass","postalCode":"24009","city":"Roanoke","state":"VA","email":"lwoodingtonop@engadget.com"}, +{"id":891,"firstName":"Farrah","lastName":"Conniam","street":"2078 Bunting Parkway","postalCode":"68134","city":"Omaha","state":"NE","email":"fconniamoq@github.com"}, +{"id":892,"firstName":"Augustus","lastName":"Morrish","street":"430 Sauthoff Plaza","postalCode":"27710","city":"Durham","state":"NC","phoneNumber":"919-266-8155","email":"amorrishor@naver.com"}, +{"id":893,"firstName":"Cassaundra","lastName":"Deaves","street":"32 Clarendon Way","postalCode":"40266","city":"Louisville","state":"KY","phoneNumber":"502-138-7158"}, +{"id":894,"firstName":"Glynn","lastName":"Shewan","street":"989 Susan Avenue","postalCode":"95194","city":"San Jose","state":"CA","email":"gshewanot@reuters.com"}, +{"id":895,"firstName":"Neils","lastName":"Niesing","street":"488 Jana Road","postalCode":"48232","city":"Detroit","state":"MI","email":"nniesingou@cafepress.com"}, +{"id":896,"firstName":"Alix","lastName":"Cleeton","street":"8 Merrick Crossing","postalCode":"18018","city":"Bethlehem","state":"PA","email":"acleetonov@ask.com"}, +{"id":897,"firstName":"Kyrstin","lastName":"Alejandro","street":"45487 Carey Way","postalCode":"37919","city":"Knoxville","state":"TN","email":"kalejandroow@scribd.com"}, +{"id":898,"firstName":"Waylin","lastName":"De Caroli","street":"9237 Ludington Plaza","postalCode":"77554","city":"Galveston","state":"TX","email":"wdecaroliox@washingtonpost.com"}, +{"id":899,"firstName":"Lian","lastName":"Brade","street":"704 Lotheville Drive","postalCode":"24014","city":"Roanoke","state":"VA","phoneNumber":"540-712-7147"}, +{"id":900,"firstName":"Griz","lastName":"Elgie","street":"435 Northridge Point","postalCode":"93399","city":"Bakersfield","state":"CA","email":"gelgieoz@hao123.com"}, +{"id":901,"firstName":"Georgeanna","lastName":"Gilberthorpe","street":"6 Tomscot Park","postalCode":"37931","city":"Knoxville","state":"TN","phoneNumber":"865-664-6191","email":"ggilberthorpep0@typepad.com"}, +{"id":902,"firstName":"Korrie","lastName":"Goldstraw","street":"00 Lindbergh Plaza","postalCode":"14225","city":"Buffalo","state":"NY","email":"kgoldstrawp1@yellowbook.com"}, +{"id":903,"firstName":"Hervey","lastName":"Wyse","street":"27 Buell Road","postalCode":"75044","city":"Garland","state":"TX","phoneNumber":"972-243-9031","email":"hwysep2@deliciousdays.com"}, +{"id":904,"firstName":"Georgeta","lastName":"Buckam","street":"0 Continental Hill","postalCode":"65810","city":"Springfield","state":"MO","phoneNumber":"417-682-2553","email":"gbuckamp3@java.com"}, +{"id":905,"firstName":"Hussein","lastName":"Jacson","street":"478 Vermont Court","postalCode":"95354","city":"Modesto","state":"CA","phoneNumber":"209-714-7362","email":"hjacsonp4@squarespace.com"}, +{"id":906,"firstName":"Chrysler","lastName":"Heddy","street":"913 Steensland Parkway","postalCode":"20709","city":"Laurel","state":"MD","phoneNumber":"410-691-9748"}, +{"id":907,"firstName":"Jourdan","lastName":"Frise","street":"35 Erie Point","postalCode":"94245","city":"Sacramento","state":"CA","email":"jfrisep6@eepurl.com"}, +{"id":908,"firstName":"Roxie","lastName":"Gimber","street":"9237 Vermont Pass","postalCode":"88553","city":"El Paso","state":"TX","email":"rgimberp7@mayoclinic.com"}, +{"id":909,"firstName":"Jenilee","lastName":"MacNab","street":"23 Union Alley","postalCode":"29579","city":"Myrtle Beach","state":"SC","email":"jmacnabp8@mit.edu"}, +{"id":910,"firstName":"Lola","lastName":"Bier","street":"371 Bartillon Avenue","postalCode":"71105","city":"Shreveport","state":"LA","phoneNumber":"318-818-1659","email":"lbierp9@goo.gl"}, +{"id":911,"firstName":"Fayina","lastName":"Brosel","street":"3255 Macpherson Pass","postalCode":"55166","city":"Saint Paul","state":"MN","email":"fbroselpa@rakuten.co.jp"}, +{"id":912,"firstName":"Ellerey","lastName":"Darell","street":"735 Leroy Road","postalCode":"07544","city":"Paterson","state":"NJ"}, +{"id":913,"firstName":"Lorianne","lastName":"McLanachan","street":"22 Alpine Point","postalCode":"77293","city":"Houston","state":"TX","email":"lmclanachanpc@dmoz.org"}, +{"id":914,"firstName":"Merrill","lastName":"Searson","street":"8447 Namekagon Hill","postalCode":"55114","city":"Saint Paul","state":"MN","phoneNumber":"651-567-8380","email":"msearsonpd@census.gov"}, +{"id":915,"firstName":"Nisse","lastName":"Larive","street":"976 Forest Dale Way","postalCode":"10004","city":"New York City","state":"NY","phoneNumber":"347-192-6897","email":"nlarivepe@drupal.org"}, +{"id":916,"firstName":"Cazzie","lastName":"Brenard","street":"647 Gulseth Plaza","postalCode":"02283","city":"Boston","state":"MA","phoneNumber":"781-248-3572","email":"cbrenardpf@uiuc.edu"}, +{"id":917,"firstName":"Gael","lastName":"Ramirez","street":"161 Basil Terrace","postalCode":"93786","city":"Fresno","state":"CA","phoneNumber":"559-692-2653","email":"gramirezpg@ucoz.ru"}, +{"id":918,"firstName":"Culver","lastName":"Le Brun","street":"73906 Muir Terrace","postalCode":"95973","city":"Chico","state":"CA","email":"clebrunph@jigsy.com"}, +{"id":919,"firstName":"Bordie","lastName":"Muskett","street":"27 Nobel Trail","postalCode":"20599","city":"Washington","state":"DC","phoneNumber":"202-872-5253"}, +{"id":920,"firstName":"Riccardo","lastName":"Miskin","street":"778 Eagan Place","postalCode":"55407","city":"Minneapolis","state":"MN","email":"rmiskinpj@slideshare.net"}, +{"id":921,"firstName":"Cristabel","lastName":"Gowlett","street":"5 Quincy Lane","postalCode":"62525","city":"Decatur","state":"IL","email":"cgowlettpk@cafepress.com"}, +{"id":922,"firstName":"Crawford","lastName":"Huby","street":"6 Gina Lane","postalCode":"94913","city":"San Rafael","state":"CA","phoneNumber":"415-133-8552","email":"chubypl@jugem.jp"}, +{"id":923,"firstName":"Cherish","lastName":"Mutch","street":"8 Oak Valley Lane","postalCode":"20719","city":"Bowie","state":"MD","phoneNumber":"240-982-9087"}, +{"id":924,"firstName":"Jerrie","lastName":"Latek","street":"9462 Moulton Terrace","postalCode":"52809","city":"Davenport","state":"IA","phoneNumber":"563-687-6664","email":"jlatekpn@gov.uk"}, +{"id":925,"firstName":"Lacey","lastName":"Maris","street":"1 Carpenter Hill","postalCode":"61605","city":"Peoria","state":"IL","phoneNumber":"309-570-3216"}, +{"id":926,"firstName":"Daffy","lastName":"Binion","street":"8 Milwaukee Parkway","postalCode":"33129","city":"Miami","state":"FL","phoneNumber":"305-579-9009"}, +{"id":927,"firstName":"Melita","lastName":"Valde","street":"629 Packers Crossing","postalCode":"06140","city":"Hartford","state":"CT","phoneNumber":"860-747-5927","email":"mvaldepq@storify.com"}, +{"id":928,"firstName":"Cherlyn","lastName":"Rosenshine","street":"764 Pepper Wood Place","postalCode":"72204","city":"Little Rock","state":"AR","phoneNumber":"501-823-8134"}, +{"id":929,"firstName":"Morty","lastName":"Stanger","street":"3286 Charing Cross Court","postalCode":"08603","city":"Trenton","state":"NJ","email":"mstangerps@yellowpages.com"}, +{"id":930,"firstName":"Bernete","lastName":"Hirth","street":"83 Granby Center","postalCode":"95194","city":"San Jose","state":"CA","phoneNumber":"408-738-2333","email":"bhirthpt@people.com.cn"}, +{"id":931,"firstName":"Elena","lastName":"Wace","street":"98 Grover Trail","postalCode":"33742","city":"Saint Petersburg","state":"FL","phoneNumber":"727-883-2239","email":"ewacepu@merriam-webster.com"}, +{"id":932,"firstName":"Giselbert","lastName":"Sisland","street":"2214 Sheridan Pass","postalCode":"40225","city":"Louisville","state":"KY"}, +{"id":933,"firstName":"Herb","lastName":"Voyce","street":"628 Basil Pass","postalCode":"21265","city":"Baltimore","state":"MD"}, +{"id":934,"firstName":"Vina","lastName":"Antonetti","street":"6 Springview Terrace","postalCode":"20430","city":"Washington","state":"DC","phoneNumber":"202-955-4578"}, +{"id":935,"firstName":"Bard","lastName":"De Avenell","street":"2775 Clarendon Avenue","postalCode":"53215","city":"Milwaukee","state":"WI"}, +{"id":936,"firstName":"Briana","lastName":"Pinshon","street":"43 Del Sol Street","postalCode":"33615","city":"Tampa","state":"FL","email":"bpinshonpz@java.com"}, +{"id":937,"firstName":"Hilly","lastName":"Aysh","street":"37 Doe Crossing Terrace","postalCode":"23705","city":"Portsmouth","state":"VA","phoneNumber":"757-992-8124"}, +{"id":938,"firstName":"Marylin","lastName":"Ciotto","street":"3957 Browning Pass","postalCode":"94807","city":"Richmond","state":"CA"}, +{"id":939,"firstName":"Cam","lastName":"Kurth","street":"155 Walton Point","postalCode":"92867","city":"Orange","state":"CA","phoneNumber":"949-955-2248"}, +{"id":940,"firstName":"Rawley","lastName":"Bickle","street":"54 Macpherson Point","postalCode":"93762","city":"Fresno","state":"CA","phoneNumber":"559-331-2187","email":"rbickleq3@delicious.com"}, +{"id":941,"firstName":"Merlina","lastName":"Dunster","street":"70557 Toban Trail","postalCode":"20005","city":"Washington","state":"DC","phoneNumber":"202-999-8731"}, +{"id":942,"firstName":"Kennie","lastName":"MacCoughan","street":"04566 Browning Parkway","postalCode":"75507","city":"Texarkana","state":"TX","phoneNumber":"903-622-7509","email":"kmaccoughanq5@reuters.com"}, +{"id":943,"firstName":"Jase","lastName":"Cholomin","street":"21497 Blaine Road","postalCode":"33777","city":"Largo","state":"FL","email":"jcholominq6@cocolog-nifty.com"}, +{"id":944,"firstName":"Cirstoforo","lastName":"Billingsley","street":"1306 Summer Ridge Court","postalCode":"02124","city":"Boston","state":"MA","email":"cbillingsleyq7@google.es"}, +{"id":945,"firstName":"Berkly","lastName":"Lawles","street":"80400 Milwaukee Way","postalCode":"64082","city":"Lees Summit","state":"MO","email":"blawlesq8@jiathis.com"}, +{"id":946,"firstName":"Otha","lastName":"Key","street":"59639 Center Circle","postalCode":"35405","city":"Tuscaloosa","state":"AL","email":"okeyq9@deliciousdays.com"}, +{"id":947,"firstName":"Anselma","lastName":"Debow","street":"5 Spohn Parkway","postalCode":"80241","city":"Denver","state":"CO","email":"adebowqa@yelp.com"}, +{"id":948,"firstName":"Auria","lastName":"Beric","street":"5 Anderson Way","postalCode":"20022","city":"Washington","state":"DC","email":"abericqb@a8.net"}, +{"id":949,"firstName":"Eirena","lastName":"Caswall","street":"4648 Fulton Street","postalCode":"64054","city":"Independence","state":"MO","phoneNumber":"816-406-0779","email":"ecaswallqc@i2i.jp"}, +{"id":950,"firstName":"Tracy","lastName":"Sperwell","street":"4 Heath Drive","postalCode":"91499","city":"Van Nuys","state":"CA"}, +{"id":951,"firstName":"Cherilyn","lastName":"Faint","street":"814 Anniversary Lane","postalCode":"24503","city":"Lynchburg","state":"VA","phoneNumber":"434-722-2344","email":"cfaintqe@amazon.de"}, +{"id":952,"firstName":"Sela","lastName":"Darcey","street":"002 Walton Hill","postalCode":"78703","city":"Austin","state":"TX","email":"sdarceyqf@lycos.com"}, +{"id":953,"firstName":"Freddie","lastName":"Klagge","street":"842 Schlimgen Road","postalCode":"29905","city":"Beaufort","state":"SC","email":"fklaggeqg@1und1.de"}, +{"id":954,"firstName":"Eunice","lastName":"Walrond","street":"4 Mifflin Terrace","postalCode":"68117","city":"Omaha","state":"NE","email":"ewalrondqh@arstechnica.com"}, +{"id":955,"firstName":"Adelbert","lastName":"Meuse","street":"971 Doe Crossing Court","postalCode":"27157","city":"Winston Salem","state":"NC"}, +{"id":956,"firstName":"Caitlin","lastName":"Windham","street":"29 Cordelia Alley","postalCode":"76210","city":"Denton","state":"TX","phoneNumber":"214-498-2801","email":"cwindhamqj@trellian.com"}, +{"id":957,"firstName":"Jere","lastName":"Presho","street":"7 Monica Plaza","postalCode":"75710","city":"Tyler","state":"TX","email":"jpreshoqk@e-recht24.de"}, +{"id":958,"firstName":"Lonny","lastName":"Cotter","street":"5686 Rutledge Place","postalCode":"40596","city":"Lexington","state":"KY","email":"lcotterql@last.fm"}, +{"id":959,"firstName":"Sarah","lastName":"Earnshaw","street":"69 Prentice Point","postalCode":"60669","city":"Chicago","state":"IL","email":"searnshawqm@ycombinator.com"}, +{"id":960,"firstName":"Claire","lastName":"Minette","street":"3145 Butterfield Terrace","postalCode":"43204","city":"Columbus","state":"OH","phoneNumber":"614-157-5341","email":"cminetteqn@upenn.edu"}, +{"id":961,"firstName":"Traci","lastName":"Farnes","street":"2 Service Circle","postalCode":"06905","city":"Stamford","state":"CT","phoneNumber":"203-311-5859","email":"tfarnesqo@merriam-webster.com"}, +{"id":962,"firstName":"Storm","lastName":"de Werk","street":"9 Jenifer Alley","postalCode":"98121","city":"Seattle","state":"WA","phoneNumber":"425-172-3688"}, +{"id":963,"firstName":"Neile","lastName":"Mackrill","street":"5046 Schurz Point","postalCode":"28299","city":"Charlotte","state":"NC"}, +{"id":964,"firstName":"Temple","lastName":"Howlings","street":"8831 Randy Street","postalCode":"71161","city":"Shreveport","state":"LA","phoneNumber":"318-859-6319","email":"thowlingsqr@smugmug.com"}, +{"id":965,"firstName":"Roda","lastName":"Drissell","street":"16621 Mandrake Lane","postalCode":"78744","city":"Austin","state":"TX","email":"rdrissellqs@mayoclinic.com"}, +{"id":966,"firstName":"Francoise","lastName":"Lawman","street":"7 Calypso Point","postalCode":"14614","city":"Rochester","state":"NY","phoneNumber":"585-995-3882"}, +{"id":967,"firstName":"Helen","lastName":"Kigelman","street":"613 Manley Plaza","postalCode":"01905","city":"Lynn","state":"MA","email":"hkigelmanqu@shutterfly.com"}, +{"id":968,"firstName":"Dudley","lastName":"Cansdall","street":"153 Schmedeman Place","postalCode":"93715","city":"Fresno","state":"CA","email":"dcansdallqv@naver.com"}, +{"id":969,"firstName":"Shelby","lastName":"Fayers","street":"94681 Knutson Point","postalCode":"10039","city":"New York City","state":"NY"}, +{"id":970,"firstName":"Sileas","lastName":"Jalland","street":"2199 Buhler Circle","postalCode":"10029","city":"New York City","state":"NY","phoneNumber":"917-902-1667","email":"sjallandqx@rakuten.co.jp"}, +{"id":971,"firstName":"Zeke","lastName":"Duffett","street":"5 Coolidge Park","postalCode":"37995","city":"Knoxville","state":"TN","phoneNumber":"865-814-8540","email":"zduffettqy@wikispaces.com"}, +{"id":972,"firstName":"Tabby","lastName":"Mathieu","street":"78 Donald Circle","postalCode":"55114","city":"Saint Paul","state":"MN","email":"tmathieuqz@rediff.com"}, +{"id":973,"firstName":"Zsa zsa","lastName":"Knights","street":"208 Kingsford Park","postalCode":"15250","city":"Pittsburgh","state":"PA","phoneNumber":"412-652-8956","email":"zknightsr0@privacy.gov.au"}, +{"id":974,"firstName":"Tildi","lastName":"Knewstub","street":"8572 Gina Hill","postalCode":"32909","city":"Palm Bay","state":"FL","email":"tknewstubr1@archive.org"}, +{"id":975,"firstName":"Eric","lastName":"Wharrier","street":"9 Marcy Alley","postalCode":"38126","city":"Memphis","state":"TN","phoneNumber":"901-378-1545","email":"ewharrierr2@people.com.cn"}, +{"id":976,"firstName":"Jilleen","lastName":"Durgan","street":"7 Lien Plaza","postalCode":"75241","city":"Dallas","state":"TX","email":"jdurganr3@google.pl"}, +{"id":977,"firstName":"Ingeberg","lastName":"Whipp","street":"489 Bartillon Street","postalCode":"22205","city":"Arlington","state":"VA","phoneNumber":"703-356-7728","email":"iwhippr4@un.org"}, +{"id":978,"firstName":"Drake","lastName":"McCreagh","street":"735 Mcguire Lane","postalCode":"20530","city":"Washington","state":"DC","email":"dmccreaghr5@mediafire.com"}, +{"id":979,"firstName":"Byron","lastName":"Eades","street":"931 Hollow Ridge Avenue","postalCode":"23285","city":"Richmond","state":"VA","phoneNumber":"804-728-5669","email":"beadesr6@npr.org"}, +{"id":980,"firstName":"Free","lastName":"Tungate","street":"7037 Ramsey Crossing","postalCode":"64153","city":"Kansas City","state":"MO","email":"ftungater7@macromedia.com"}, +{"id":981,"firstName":"Augustus","lastName":"Benardet","street":"398 Bultman Circle","postalCode":"70165","city":"New Orleans","state":"LA"}, +{"id":982,"firstName":"Sanders","lastName":"Sullens","street":"75785 Westend Terrace","postalCode":"43656","city":"Toledo","state":"OH","phoneNumber":"419-314-1134"}, +{"id":983,"firstName":"Ynes","lastName":"Troup","street":"328 Schurz Trail","postalCode":"98907","city":"Yakima","state":"WA","phoneNumber":"509-696-5645"}, +{"id":984,"firstName":"Siana","lastName":"Bernath","street":"968 Sommers Lane","postalCode":"55487","city":"Minneapolis","state":"MN","phoneNumber":"612-351-3016"}, +{"id":985,"firstName":"Ellary","lastName":"Enders","street":"2 Charing Cross Court","postalCode":"06505","city":"New Haven","state":"CT","phoneNumber":"203-608-5058"}, +{"id":986,"firstName":"Mariann","lastName":"Damerell","street":"885 Pennsylvania Crossing","postalCode":"15220","city":"Pittsburgh","state":"PA","phoneNumber":"412-667-1349","email":"mdamerellrd@moonfruit.com"}, +{"id":987,"firstName":"Timotheus","lastName":"Muncer","street":"293 Hoepker Center","postalCode":"32405","city":"Panama City","state":"FL","phoneNumber":"850-740-2501","email":"tmuncerre@ifeng.com"}, +{"id":988,"firstName":"Hermina","lastName":"Tetsall","street":"9354 Nobel Road","postalCode":"55585","city":"Monticello","state":"MN","phoneNumber":"763-292-3970","email":"htetsallrf@wsj.com"}, +{"id":989,"firstName":"Dorelia","lastName":"Howship","street":"747 Namekagon Way","postalCode":"14269","city":"Buffalo","state":"NY","phoneNumber":"716-470-3584","email":"dhowshiprg@un.org"}, +{"id":990,"firstName":"Peggy","lastName":"Coutts","street":"34 Village Green Road","postalCode":"19131","city":"Philadelphia","state":"PA"}, +{"id":991,"firstName":"Dacey","lastName":"Inglefield","street":"05227 Buell Avenue","postalCode":"45414","city":"Dayton","state":"OH"}, +{"id":992,"firstName":"Hollyanne","lastName":"Hobbema","street":"684 La Follette Drive","postalCode":"45218","city":"Cincinnati","state":"OH","phoneNumber":"513-346-0258"}, +{"id":993,"firstName":"Freedman","lastName":"Whorlow","street":"291 Maywood Pass","postalCode":"48098","city":"Troy","state":"MI","phoneNumber":"248-890-5937"}, +{"id":994,"firstName":"Karine","lastName":"Gerring","street":"163 Graceland Street","postalCode":"95397","city":"Modesto","state":"CA"}, +{"id":995,"firstName":"Sonya","lastName":"Giercke","street":"1801 Rowland Junction","postalCode":"66215","city":"Shawnee Mission","state":"KS","email":"sgierckerm@mapquest.com"}, +{"id":996,"firstName":"Fabiano","lastName":"O'Hear","street":"87555 Sunnyside Plaza","postalCode":"33330","city":"Fort Lauderdale","state":"FL","email":"fohearrn@china.com.cn"}, +{"id":997,"firstName":"Lelia","lastName":"Gillman","street":"29838 Eagan Junction","postalCode":"78783","city":"Austin","state":"TX","phoneNumber":"512-515-1461","email":"lgillmanro@amazon.co.jp"}, +{"id":998,"firstName":"Ophelie","lastName":"Richardet","street":"9 Bay Point","postalCode":"94042","city":"Mountain View","state":"CA"}, +{"id":999,"firstName":"Batholomew","lastName":"Janzen","street":"9 Rigney Alley","postalCode":"95113","city":"San Jose","state":"CA"}, +{"id":1000,"firstName":"Kirstyn","lastName":"Bixley","street":"2 Cascade Trail","postalCode":"80015","city":"Aurora","state":"CO","phoneNumber":"303-339-2309","email":"kbixleyrr@i2i.jp"}] \ No newline at end of file From 90328358070ced845129d83ed7b125decb3dd861 Mon Sep 17 00:00:00 2001 From: Karsten Silz Date: Mon, 21 Sep 2020 20:40:16 +0100 Subject: [PATCH 195/263] Moved code to "json-2" module. --- .../baeldung/jsonoptimization/Customer.java | 123 -- .../CustomerDeserializer.java | 49 - .../jsonoptimization/CustomerSerializer.java | 34 - .../jsonoptimization/CustomerShortNames.java | 155 --- .../jsonoptimization/CustomerSlim.java | 73 -- .../CustomerSlimDeserializer.java | 37 - .../CustomerSlimSerializer.java | 28 - .../CustomerSlimShortNames.java | 81 -- .../JsonOptimizationUnitTest.java | 180 --- .../json_optimization_mock_data.json | 1000 ----------------- 10 files changed, 1760 deletions(-) delete mode 100644 json/src/main/java/com/baeldung/jsonoptimization/Customer.java delete mode 100644 json/src/main/java/com/baeldung/jsonoptimization/CustomerDeserializer.java delete mode 100644 json/src/main/java/com/baeldung/jsonoptimization/CustomerSerializer.java delete mode 100644 json/src/main/java/com/baeldung/jsonoptimization/CustomerShortNames.java delete mode 100644 json/src/main/java/com/baeldung/jsonoptimization/CustomerSlim.java delete mode 100644 json/src/main/java/com/baeldung/jsonoptimization/CustomerSlimDeserializer.java delete mode 100644 json/src/main/java/com/baeldung/jsonoptimization/CustomerSlimSerializer.java delete mode 100644 json/src/main/java/com/baeldung/jsonoptimization/CustomerSlimShortNames.java delete mode 100644 json/src/test/java/com/baeldung/jsonoptimization/JsonOptimizationUnitTest.java delete mode 100644 json/src/test/resources/json_optimization_mock_data.json diff --git a/json/src/main/java/com/baeldung/jsonoptimization/Customer.java b/json/src/main/java/com/baeldung/jsonoptimization/Customer.java deleted file mode 100644 index 85451731e9..0000000000 --- a/json/src/main/java/com/baeldung/jsonoptimization/Customer.java +++ /dev/null @@ -1,123 +0,0 @@ -package com.baeldung.jsonoptimization; - -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Objects; - -import com.fasterxml.jackson.databind.ObjectMapper; - -public class Customer { - - private long id; - private String firstName; - private String lastName; - private String street; - private String postalCode; - private String city; - private String state; - private String phoneNumber; - private String email; - - 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 String getStreet() { - return street; - } - - public void setStreet(String street) { - this.street = street; - } - - public String getPostalCode() { - return postalCode; - } - - public void setPostalCode(String postalCode) { - this.postalCode = postalCode; - } - - public String getCity() { - return city; - } - - public void setCity(String city) { - this.city = city; - } - - public String getState() { - return state; - } - - public void setState(String state) { - this.state = state; - } - - public String getPhoneNumber() { - return phoneNumber; - } - - public void setPhoneNumber(String phoneNumber) { - this.phoneNumber = phoneNumber; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - @Override - public int hashCode() { - return Objects.hash(city, email, firstName, id, lastName, phoneNumber, postalCode, state, street); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof Customer)) { - return false; - } - Customer other = (Customer) obj; - return Objects.equals(city, other.city) && Objects.equals(email, other.email) && Objects.equals(firstName, other.firstName) && id == other.id && Objects.equals(lastName, other.lastName) && Objects.equals(phoneNumber, other.phoneNumber) - && Objects.equals(postalCode, other.postalCode) && Objects.equals(state, other.state) && Objects.equals(street, other.street); - } - - @Override - public String toString() { - return "Customer [id=" + id + ", firstName=" + firstName + ", lastName=" + lastName + ", street=" + street + ", postalCode=" + postalCode + ", city=" + city + ", state=" + state + ", phoneNumber=" + phoneNumber + ", email=" + email + "]"; - } - - public static Customer[] fromMockFile() throws IOException { - ObjectMapper objectMapper = new ObjectMapper(); - InputStream jsonFile = new FileInputStream("src/test/resources/json_optimization_mock_data.json"); - Customer[] feedback = objectMapper.readValue(jsonFile, Customer[].class); - return feedback; - } -} diff --git a/json/src/main/java/com/baeldung/jsonoptimization/CustomerDeserializer.java b/json/src/main/java/com/baeldung/jsonoptimization/CustomerDeserializer.java deleted file mode 100644 index 16b66311ad..0000000000 --- a/json/src/main/java/com/baeldung/jsonoptimization/CustomerDeserializer.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.baeldung.jsonoptimization; - -import java.io.IOException; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.ObjectCodec; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; - -public class CustomerDeserializer extends StdDeserializer { - private static final long serialVersionUID = 1L; - - public CustomerDeserializer() { - this(null); - } - - public CustomerDeserializer(Class t) { - super(t); - } - - @Override - public Customer deserialize(JsonParser parser, DeserializationContext deserializer) throws IOException { - Customer feedback = new Customer(); - ObjectCodec codec = parser.getCodec(); - JsonNode node = codec.readTree(parser); - - feedback.setId(node.get(0) - .asLong()); - feedback.setFirstName(node.get(1) - .asText()); - feedback.setLastName(node.get(2) - .asText()); - feedback.setStreet(node.get(3) - .asText()); - feedback.setPostalCode(node.get(4) - .asText()); - feedback.setCity(node.get(5) - .asText()); - feedback.setState(node.get(6) - .asText()); - JsonNode phoneNumber = node.get(7); - feedback.setPhoneNumber(phoneNumber.isNull() ? null : phoneNumber.asText()); - JsonNode email = node.get(8); - feedback.setEmail(email.isNull() ? null : email.asText()); - - return feedback; - } -} diff --git a/json/src/main/java/com/baeldung/jsonoptimization/CustomerSerializer.java b/json/src/main/java/com/baeldung/jsonoptimization/CustomerSerializer.java deleted file mode 100644 index 0f631ee85b..0000000000 --- a/json/src/main/java/com/baeldung/jsonoptimization/CustomerSerializer.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.baeldung.jsonoptimization; - -import java.io.IOException; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.ser.std.StdSerializer; - -public class CustomerSerializer extends StdSerializer { - private static final long serialVersionUID = 1L; - - public CustomerSerializer() { - this(null); - } - - public CustomerSerializer(Class t) { - super(t); - } - - @Override - public void serialize(Customer customer, JsonGenerator jsonGenerator, SerializerProvider serializer) throws IOException { - jsonGenerator.writeStartArray(); - jsonGenerator.writeNumber(customer.getId()); - jsonGenerator.writeString(customer.getFirstName()); - jsonGenerator.writeString(customer.getLastName()); - jsonGenerator.writeString(customer.getStreet()); - jsonGenerator.writeString(customer.getPostalCode()); - jsonGenerator.writeString(customer.getCity()); - jsonGenerator.writeString(customer.getState()); - jsonGenerator.writeString(customer.getPhoneNumber()); - jsonGenerator.writeString(customer.getEmail()); - jsonGenerator.writeEndArray(); - } -} diff --git a/json/src/main/java/com/baeldung/jsonoptimization/CustomerShortNames.java b/json/src/main/java/com/baeldung/jsonoptimization/CustomerShortNames.java deleted file mode 100644 index b94fbb1033..0000000000 --- a/json/src/main/java/com/baeldung/jsonoptimization/CustomerShortNames.java +++ /dev/null @@ -1,155 +0,0 @@ -package com.baeldung.jsonoptimization; - -import java.util.Objects; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class CustomerShortNames { - - @JsonProperty("i") - private long id; - - @JsonProperty("f") - private String firstName; - - @JsonProperty("l") - private String lastName; - - @JsonProperty("s") - private String street; - - @JsonProperty("p") - private String postalCode; - - @JsonProperty("c") - private String city; - - @JsonProperty("a") - private String state; - - @JsonProperty("o") - private String phoneNumber; - - @JsonProperty("e") - private String email; - - 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 String getStreet() { - return street; - } - - public void setStreet(String street) { - this.street = street; - } - - public String getPostalCode() { - return postalCode; - } - - public void setPostalCode(String postalCode) { - this.postalCode = postalCode; - } - - public String getCity() { - return city; - } - - public void setCity(String city) { - this.city = city; - } - - public String getState() { - return state; - } - - public void setState(String state) { - this.state = state; - } - - public String getPhoneNumber() { - return phoneNumber; - } - - public void setPhoneNumber(String phoneNumber) { - this.phoneNumber = phoneNumber; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - @Override - public int hashCode() { - return Objects.hash(city, email, firstName, id, lastName, phoneNumber, postalCode, state, street); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof CustomerShortNames)) { - return false; - } - CustomerShortNames other = (CustomerShortNames) obj; - return Objects.equals(city, other.city) && Objects.equals(email, other.email) && Objects.equals(firstName, other.firstName) && id == other.id && Objects.equals(lastName, other.lastName) && Objects.equals(phoneNumber, other.phoneNumber) - && Objects.equals(postalCode, other.postalCode) && Objects.equals(state, other.state) && Objects.equals(street, other.street); - } - - @Override - public String toString() { - return "CustomerWithShorterAttributes [id=" + id + ", firstName=" + firstName + ", lastName=" + lastName + ", street=" + street + ", postalCode=" + postalCode + ", city=" + city + ", state=" + state + ", phoneNumber=" + phoneNumber + ", email=" + email - + "]"; - } - - public static CustomerShortNames[] fromCustomers(Customer[] customers) { - CustomerShortNames[] feedback = new CustomerShortNames[customers.length]; - - for (int i = 0; i < customers.length; i++) { - Customer aCustomer = customers[i]; - CustomerShortNames newOne = new CustomerShortNames(); - - newOne.setId(aCustomer.getId()); - newOne.setFirstName(aCustomer.getFirstName()); - newOne.setLastName(aCustomer.getLastName()); - newOne.setStreet(aCustomer.getStreet()); - newOne.setCity(aCustomer.getCity()); - newOne.setPostalCode(aCustomer.getPostalCode()); - newOne.setState(aCustomer.getState()); - newOne.setPhoneNumber(aCustomer.getPhoneNumber()); - newOne.setEmail(aCustomer.getEmail()); - - feedback[i] = newOne; - } - - return feedback; - } - -} diff --git a/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlim.java b/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlim.java deleted file mode 100644 index e2ef4664cf..0000000000 --- a/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlim.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.baeldung.jsonoptimization; - -import java.util.Objects; - -public class CustomerSlim { - private long id; - private String name; - private String address; - - 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 String getAddress() { - return address; - } - - public void setAddress(String address) { - this.address = address; - } - - @Override - public int hashCode() { - return Objects.hash(address, id, name); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof CustomerSlim)) { - return false; - } - CustomerSlim other = (CustomerSlim) obj; - return Objects.equals(address, other.address) && id == other.id && Objects.equals(name, other.name); - } - - @Override - public String toString() { - return "CustomerSlim [id=" + id + ", name=" + name + ", address=" + address + "]"; - } - - public static CustomerSlim[] fromCustomers(Customer[] customers) { - CustomerSlim[] feedback = new CustomerSlim[customers.length]; - - for (int i = 0; i < customers.length; i++) { - Customer aCustomer = customers[i]; - CustomerSlim newOne = new CustomerSlim(); - - newOne.setId(aCustomer.getId()); - newOne.setName(aCustomer.getFirstName() + " " + aCustomer.getLastName()); - newOne.setAddress(aCustomer.getStreet() + ", " + aCustomer.getCity() + " " + aCustomer.getState() + " " + aCustomer.getPostalCode()); - - feedback[i] = newOne; - } - - return feedback; - } - -} diff --git a/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlimDeserializer.java b/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlimDeserializer.java deleted file mode 100644 index 296ee6fdf6..0000000000 --- a/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlimDeserializer.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.baeldung.jsonoptimization; - -import java.io.IOException; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.ObjectCodec; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; - -public class CustomerSlimDeserializer extends StdDeserializer { - private static final long serialVersionUID = 1L; - - public CustomerSlimDeserializer() { - this(null); - } - - public CustomerSlimDeserializer(Class t) { - super(t); - } - - @Override - public CustomerSlim deserialize(JsonParser parser, DeserializationContext deserializer) throws IOException { - CustomerSlim feedback = new CustomerSlim(); - ObjectCodec codec = parser.getCodec(); - JsonNode node = codec.readTree(parser); - - feedback.setId(node.get(0) - .asLong()); - feedback.setName(node.get(1) - .asText()); - feedback.setAddress(node.get(2) - .asText()); - - return feedback; - } -} diff --git a/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlimSerializer.java b/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlimSerializer.java deleted file mode 100644 index 520c541da6..0000000000 --- a/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlimSerializer.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.baeldung.jsonoptimization; - -import java.io.IOException; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.ser.std.StdSerializer; - -public class CustomerSlimSerializer extends StdSerializer { - private static final long serialVersionUID = 1L; - - public CustomerSlimSerializer() { - this(null); - } - - public CustomerSlimSerializer(Class t) { - super(t); - } - - @Override - public void serialize(CustomerSlim customer, JsonGenerator jsonGenerator, SerializerProvider serializer) throws IOException { - jsonGenerator.writeStartArray(); - jsonGenerator.writeNumber(customer.getId()); - jsonGenerator.writeString(customer.getName()); - jsonGenerator.writeString(customer.getAddress()); - jsonGenerator.writeEndArray(); - } -} diff --git a/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlimShortNames.java b/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlimShortNames.java deleted file mode 100644 index bf00e847ac..0000000000 --- a/json/src/main/java/com/baeldung/jsonoptimization/CustomerSlimShortNames.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.baeldung.jsonoptimization; - -import java.util.Objects; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class CustomerSlimShortNames { - - @JsonProperty("i") - private long id; - - @JsonProperty("n") - private String name; - - @JsonProperty("a") - private String address; - - 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 String getAddress() { - return address; - } - - public void setAddress(String address) { - this.address = address; - } - - @Override - public int hashCode() { - return Objects.hash(address, id, name); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof CustomerSlimShortNames)) { - return false; - } - CustomerSlimShortNames other = (CustomerSlimShortNames) obj; - return Objects.equals(address, other.address) && id == other.id && Objects.equals(name, other.name); - } - - @Override - public String toString() { - return "CustomerSlim [id=" + id + ", name=" + name + ", address=" + address + "]"; - } - - public static CustomerSlimShortNames[] fromCustomers(Customer[] customers) { - CustomerSlimShortNames[] feedback = new CustomerSlimShortNames[customers.length]; - - for (int i = 0; i < customers.length; i++) { - Customer aCustomer = customers[i]; - CustomerSlimShortNames newOne = new CustomerSlimShortNames(); - - newOne.setId(aCustomer.getId()); - newOne.setName(aCustomer.getFirstName() + " " + aCustomer.getLastName()); - newOne.setAddress(aCustomer.getStreet() + ", " + aCustomer.getCity() + " " + aCustomer.getState() + " " + aCustomer.getPostalCode()); - - feedback[i] = newOne; - } - - return feedback; - } - -} diff --git a/json/src/test/java/com/baeldung/jsonoptimization/JsonOptimizationUnitTest.java b/json/src/test/java/com/baeldung/jsonoptimization/JsonOptimizationUnitTest.java deleted file mode 100644 index 7a56a68fe2..0000000000 --- a/json/src/test/java/com/baeldung/jsonoptimization/JsonOptimizationUnitTest.java +++ /dev/null @@ -1,180 +0,0 @@ -package com.baeldung.jsonoptimization; - -import static org.junit.Assert.assertArrayEquals; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.text.DecimalFormat; -import java.util.zip.GZIPOutputStream; - -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.core.Version; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.ObjectWriter; -import com.fasterxml.jackson.databind.module.SimpleModule; - -class JsonOptimizationUnitTest { - private static final String TEST_LABEL_JACKSON_DEFAULT_OPTIONS = "Default JSON"; - private static final String TEST_LABEL_DEFAULT_JSON_NO_NULL = "Default JSON without null"; - private static final String TEST_LABEL_SHORTER_FIELD_NAMES = "Shorter field names"; - private static final String TEST_LABEL_SHORTER_FIELD_NAMES_AND_NO_NULL = "Shorter field names without null"; - private static final String TEST_LABEL_SERIALIZING_TO_ARRAY = "Custom serializer"; - private static final String TEST_LABEL_SLIM_CUSTOM_SERIALIZER = "Slim custom serializer"; - private static final String TEST_LABEL_SLIM_CUSTOMER = "Slim customer"; - private static final String TEST_LABEL_SLIM_CUSTOMER_SHORT_NAMES = "Slim customer with shorter field names"; - private static DecimalFormat LENGTH_FORMATTER = new DecimalFormat("###,###.0"); - private static DecimalFormat PERCENT_FORMATTER = new DecimalFormat("###.0"); - private static Customer[] customers; - private ObjectMapper mapper; - private static int defaultJsonLength; - - @BeforeAll - static void setUpOnce() throws Exception { - customers = Customer.fromMockFile(); - ObjectMapper oneTimeMapper = new ObjectMapper(); - byte[] feedback = oneTimeMapper.writeValueAsBytes(customers); - defaultJsonLength = feedback.length; - System.out.println(); - System.out.println("Default JSON length: " + defaultJsonLength); - System.out.println(); - } - - @BeforeEach - void setUp() { - mapper = new ObjectMapper(); - } - - @Test - void whenSetUp_ThenOneThousandCustomers() { - assertEquals(1000, customers.length, "There should be a 1000 customers"); - } - - @Test - void whenJacksonDefaultOptions_thenValid() throws IOException { - printBanner(TEST_LABEL_JACKSON_DEFAULT_OPTIONS); - byte[] plainJson = createJsonAndVerify(TEST_LABEL_JACKSON_DEFAULT_OPTIONS, customers); - compressJson(TEST_LABEL_JACKSON_DEFAULT_OPTIONS, plainJson); - } - - @Test - void whenExcludingNull_thenValid() throws IOException { - printBanner(TEST_LABEL_DEFAULT_JSON_NO_NULL); - mapper.setSerializationInclusion(Include.NON_NULL); - byte[] plainJson = createJsonAndVerify(TEST_LABEL_DEFAULT_JSON_NO_NULL, customers); - compressJson(TEST_LABEL_DEFAULT_JSON_NO_NULL, plainJson); - } - - @Test - void whenShorterFieldNames_thenValid() throws IOException { - printBanner(TEST_LABEL_SHORTER_FIELD_NAMES); - CustomerShortNames[] shorterOnes = CustomerShortNames.fromCustomers(customers); - byte[] shorterJson = createJsonAndVerify(TEST_LABEL_SHORTER_FIELD_NAMES, shorterOnes); - compressJson(TEST_LABEL_SHORTER_FIELD_NAMES, shorterJson); - } - - @Test - void whenShorterFieldNamesAndExcludingNull_thenValid() throws IOException { - printBanner(TEST_LABEL_SHORTER_FIELD_NAMES_AND_NO_NULL); - CustomerShortNames[] shorterOnes = CustomerShortNames.fromCustomers(customers); - mapper.setSerializationInclusion(Include.NON_NULL); - byte[] shorterJson = createJsonAndVerify(TEST_LABEL_SHORTER_FIELD_NAMES_AND_NO_NULL, shorterOnes); - compressJson(TEST_LABEL_SHORTER_FIELD_NAMES_AND_NO_NULL, shorterJson); - } - - @Test - void whenSlimCustomer_thenValid() throws IOException { - printBanner(TEST_LABEL_SLIM_CUSTOMER); - CustomerSlim[] slimOnes = CustomerSlim.fromCustomers(customers); - byte[] slimJson = createJsonAndVerify(TEST_LABEL_SLIM_CUSTOMER, slimOnes); - compressJson(TEST_LABEL_SLIM_CUSTOMER, slimJson); - } - - @Test - void whenSlimCustomerAndShorterFieldNames_thenValid() throws IOException { - printBanner(TEST_LABEL_SLIM_CUSTOMER_SHORT_NAMES); - CustomerSlimShortNames[] slimOnes = CustomerSlimShortNames.fromCustomers(customers); - byte[] slimJson = createJsonAndVerify(TEST_LABEL_SLIM_CUSTOMER_SHORT_NAMES, slimOnes); - compressJson(TEST_LABEL_SLIM_CUSTOMER_SHORT_NAMES, slimJson); - } - - @Test - void whenSerializingToArray_thenValid() throws IOException { - printBanner(TEST_LABEL_SERIALIZING_TO_ARRAY); - SimpleModule serializer = new SimpleModule("CustomDeSerializer", new Version(1, 0, 0, null, null, null)); - serializer.addSerializer(Customer.class, new CustomerSerializer()); - serializer.addDeserializer(Customer.class, new CustomerDeserializer()); - mapper.registerModule(serializer); - - byte[] plainJson = createJsonAndVerify(TEST_LABEL_SERIALIZING_TO_ARRAY, customers); - compressJson(TEST_LABEL_SERIALIZING_TO_ARRAY, plainJson); - } - - @Test - void whenSerializingToArrayAndSlimCustomer_thenValid() throws IOException { - printBanner(TEST_LABEL_SLIM_CUSTOM_SERIALIZER); - SimpleModule serializer = new SimpleModule("SlimCustomDeSerializer", new Version(1, 0, 0, null, null, null)); - serializer.addSerializer(CustomerSlim.class, new CustomerSlimSerializer()); - serializer.addDeserializer(CustomerSlim.class, new CustomerSlimDeserializer()); - mapper.registerModule(serializer); - - CustomerSlim[] slimOnes = CustomerSlim.fromCustomers(customers); - byte[] plainJson = createJsonAndVerify(TEST_LABEL_SLIM_CUSTOM_SERIALIZER, slimOnes); - compressJson(TEST_LABEL_SLIM_CUSTOM_SERIALIZER, plainJson); - } - - private void printBanner(String name) { - System.out.println(); - System.out.println("************************************************"); - System.out.println("Testing " + name); - System.out.println(); - } - - void compressJson(String label, byte[] plainJson) throws IOException { - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - GZIPOutputStream gzipStream = new GZIPOutputStream(outputStream); - gzipStream.write(plainJson); - gzipStream.close(); - outputStream.close(); - byte[] gzippedJson = outputStream.toByteArray(); - double length = gzippedJson.length / 1024d; - double percent = gzippedJson.length * 100d / defaultJsonLength; - System.out.println(label + " GZIPped length: " + LENGTH_FORMATTER.format(length) - + "kB (" + PERCENT_FORMATTER.format(percent) + "%)"); - assertTrue(plainJson.length > gzippedJson.length, label + " should be longer than GZIPped data"); - } - - private byte[] createJsonAndVerify(String label, Object[] customers) throws IOException { - System.out.println(label + " sample: "); - ObjectWriter prettyWritter = mapper.writerWithDefaultPrettyPrinter(); - System.out.println(prettyWritter.writeValueAsString(customers[0])); - - byte[] feedback = mapper.writeValueAsBytes(customers); - double length = feedback.length / 1024d; - double percent = feedback.length * 100d / defaultJsonLength; - System.out.println(label + " length: " + LENGTH_FORMATTER.format(length) - + "kB (" + PERCENT_FORMATTER.format(percent) + "%)"); - assertTrue(feedback.length > 1, label + " should be there"); - - String prefix = label.replaceAll(" ", "-") - .toLowerCase(); - File tempFile = File.createTempFile("jon-optimization-" + prefix, ".json"); - FileOutputStream fos = new FileOutputStream(tempFile); - fos.write(feedback); - fos.close(); - System.out.println(label + " file: " + tempFile.toString()); - - Object[] restoredOnes = mapper.readValue(feedback, customers.getClass()); - assertArrayEquals(TEST_LABEL_JACKSON_DEFAULT_OPTIONS + ": restoring from JSON should work", customers, restoredOnes); - - return feedback; - } - -} diff --git a/json/src/test/resources/json_optimization_mock_data.json b/json/src/test/resources/json_optimization_mock_data.json deleted file mode 100644 index e09517cf61..0000000000 --- a/json/src/test/resources/json_optimization_mock_data.json +++ /dev/null @@ -1,1000 +0,0 @@ -[{"id":1,"firstName":"Horatius","lastName":"Strognell","street":"4848 New Castle Point","postalCode":"33432","city":"Boca Raton","state":"FL","phoneNumber":"561-824-9105","email":"hstrognell0@dailymail.co.uk"}, -{"id":2,"firstName":"Kerri","lastName":"Arend","street":"4 Welch Pass","postalCode":"60669","city":"Chicago","state":"IL","phoneNumber":"312-303-5993"}, -{"id":3,"firstName":"Silvano","lastName":"Bartholomaus","street":"2491 Arkansas Center","postalCode":"30195","city":"Duluth","state":"GA","email":"sbartholomaus2@prlog.org"}, -{"id":4,"firstName":"Venita","lastName":"Burgoine","street":"63894 Sage Park","postalCode":"67215","city":"Wichita","state":"KS","email":"vburgoine3@telegraph.co.uk"}, -{"id":5,"firstName":"Meghan","lastName":"Westover","street":"76 Pleasure Way","postalCode":"77388","city":"Spring","state":"TX","phoneNumber":"832-926-0689","email":"mwestover4@cnn.com"}, -{"id":6,"firstName":"Mia","lastName":"Baversor","street":"50 Sommers Road","postalCode":"43204","city":"Columbus","state":"OH","email":"mbaversor5@wsj.com"}, -{"id":7,"firstName":"Winna","lastName":"Buggy","street":"05 Jenna Street","postalCode":"68144","city":"Omaha","state":"NE","phoneNumber":"402-740-7818"}, -{"id":8,"firstName":"Antonin","lastName":"Autrie","street":"9 Fieldstone Terrace","postalCode":"85754","city":"Tucson","state":"AZ"}, -{"id":9,"firstName":"Maddi","lastName":"Ollerearnshaw","street":"061 Crowley Trail","postalCode":"48335","city":"Farmington","state":"MI","phoneNumber":"248-709-8128"}, -{"id":10,"firstName":"Fawnia","lastName":"Cristofaro","street":"92571 Kinsman Alley","postalCode":"77271","city":"Houston","state":"TX","email":"fcristofaro9@ox.ac.uk"}, -{"id":11,"firstName":"Zachariah","lastName":"Rouby","street":"2439 Hudson Circle","postalCode":"25313","city":"Charleston","state":"WV","phoneNumber":"304-587-5444"}, -{"id":12,"firstName":"Brier","lastName":"Benech","street":"3144 Sutteridge Place","postalCode":"20380","city":"Washington","state":"DC","phoneNumber":"202-740-8851","email":"bbenechb@zdnet.com"}, -{"id":13,"firstName":"Merry","lastName":"Leming","street":"419 Kropf Terrace","postalCode":"45440","city":"Dayton","state":"OH","email":"mlemingc@ow.ly"}, -{"id":14,"firstName":"Audrey","lastName":"Dilleston","street":"61 Melrose Trail","postalCode":"97306","city":"Salem","state":"OR","phoneNumber":"503-480-6254"}, -{"id":15,"firstName":"De witt","lastName":"Kedge","street":"819 Kingsford Point","postalCode":"84135","city":"Salt Lake City","state":"UT"}, -{"id":16,"firstName":"Charita","lastName":"de Clerc","street":"42 Loftsgordon Hill","postalCode":"28289","city":"Charlotte","state":"NC","phoneNumber":"704-532-8850","email":"cdeclercf@comsenz.com"}, -{"id":17,"firstName":"Edgard","lastName":"Bloore","street":"1659 Donald Trail","postalCode":"20051","city":"Washington","state":"DC"}, -{"id":18,"firstName":"Kristi","lastName":"Richichi","street":"11306 Longview Hill","postalCode":"75372","city":"Dallas","state":"TX","email":"krichichih@cloudflare.com"}, -{"id":19,"firstName":"Denna","lastName":"Cornford","street":"4 Gale Junction","postalCode":"10014","city":"New York City","state":"NY","phoneNumber":"646-273-3067","email":"dcornfordi@ebay.co.uk"}, -{"id":20,"firstName":"Randall","lastName":"McQuaid","street":"55712 Stone Corner Circle","postalCode":"10203","city":"New York City","state":"NY","email":"rmcquaidj@facebook.com"}, -{"id":21,"firstName":"Kirbie","lastName":"Walczak","street":"9 Coleman Road","postalCode":"99252","city":"Spokane","state":"WA","email":"kwalczakk@spotify.com"}, -{"id":22,"firstName":"Zedekiah","lastName":"Westby","street":"9 Victoria Road","postalCode":"22093","city":"Ashburn","state":"VA","phoneNumber":"571-642-0111","email":"zwestbyl@ox.ac.uk"}, -{"id":23,"firstName":"Corri","lastName":"Snar","street":"4 Service Terrace","postalCode":"68517","city":"Lincoln","state":"NE","email":"csnarm@tinyurl.com"}, -{"id":24,"firstName":"Manny","lastName":"Marchington","street":"942 Westend Center","postalCode":"22119","city":"Merrifield","state":"VA","email":"mmarchingtonn@opensource.org"}, -{"id":25,"firstName":"Ashla","lastName":"Grigoroni","street":"755 Lerdahl Parkway","postalCode":"55423","city":"Minneapolis","state":"MN","phoneNumber":"612-797-7928","email":"agrigoronio@cam.ac.uk"}, -{"id":26,"firstName":"Rita","lastName":"Sharratt","street":"710 Buena Vista Avenue","postalCode":"40576","city":"Lexington","state":"KY","phoneNumber":"859-727-0697"}, -{"id":27,"firstName":"Karrie","lastName":"Crathorne","street":"02 Loeprich Place","postalCode":"39505","city":"Gulfport","state":"MS"}, -{"id":28,"firstName":"Lothario","lastName":"Merck","street":"46 Golden Leaf Park","postalCode":"35205","city":"Birmingham","state":"AL"}, -{"id":29,"firstName":"Renault","lastName":"Banister","street":"7 Garrison Plaza","postalCode":"85072","city":"Phoenix","state":"AZ"}, -{"id":30,"firstName":"Wanda","lastName":"Burkart","street":"10 Mendota Place","postalCode":"48258","city":"Detroit","state":"MI","phoneNumber":"248-870-5185","email":"wburkartt@wikipedia.org"}, -{"id":31,"firstName":"Maggy","lastName":"Timby","street":"37 Crest Line Center","postalCode":"50305","city":"Des Moines","state":"IA","email":"mtimbyu@cnbc.com"}, -{"id":32,"firstName":"Chet","lastName":"Origan","street":"767 Bashford Lane","postalCode":"30919","city":"Augusta","state":"GA","email":"coriganv@behance.net"}, -{"id":33,"firstName":"Jammie","lastName":"Aslie","street":"7174 Hoffman Circle","postalCode":"23464","city":"Virginia Beach","state":"VA"}, -{"id":34,"firstName":"Dill","lastName":"Kingdon","street":"75 Corben Crossing","postalCode":"33013","city":"Hialeah","state":"FL","email":"dkingdonx@ibm.com"}, -{"id":35,"firstName":"Berenice","lastName":"Blodget","street":"8 Eliot Junction","postalCode":"93907","city":"Salinas","state":"CA","email":"bblodgety@blogs.com"}, -{"id":36,"firstName":"Kimberley","lastName":"Streatley","street":"56 Welch Center","postalCode":"77070","city":"Houston","state":"TX"}, -{"id":37,"firstName":"Warde","lastName":"Woodwind","street":"773 Gerald Park","postalCode":"35295","city":"Birmingham","state":"AL","email":"wwoodwind10@wsj.com"}, -{"id":38,"firstName":"Husain","lastName":"Christofe","street":"35118 Forest Dale Avenue","postalCode":"10175","city":"New York City","state":"NY","phoneNumber":"212-611-7995","email":"hchristofe11@seesaa.net"}, -{"id":39,"firstName":"Gertrud","lastName":"Defraine","street":"568 Walton Way","postalCode":"37405","city":"Chattanooga","state":"TN","phoneNumber":"423-125-5719","email":"gdefraine12@xrea.com"}, -{"id":40,"firstName":"Yulma","lastName":"Ramshay","street":"9976 Iowa Drive","postalCode":"87121","city":"Albuquerque","state":"NM","phoneNumber":"505-914-5281"}, -{"id":41,"firstName":"Bride","lastName":"Amsberger","street":"3 Service Lane","postalCode":"28272","city":"Charlotte","state":"NC","email":"bamsberger14@forbes.com"}, -{"id":42,"firstName":"Kaiser","lastName":"Froud","street":"7 Starling Lane","postalCode":"99507","city":"Anchorage","state":"AK","email":"kfroud15@cloudflare.com"}, -{"id":43,"firstName":"Leona","lastName":"Sciusscietto","street":"06392 East Lane","postalCode":"60193","city":"Schaumburg","state":"IL","phoneNumber":"630-981-3986","email":"lsciusscietto16@mit.edu"}, -{"id":44,"firstName":"Sibel","lastName":"Ripsher","street":"8672 Bayside Road","postalCode":"32511","city":"Pensacola","state":"FL","phoneNumber":"850-975-6365","email":"sripsher17@sitemeter.com"}, -{"id":45,"firstName":"Megen","lastName":"Dymond","street":"0547 Harper Place","postalCode":"28220","city":"Charlotte","state":"NC","phoneNumber":"704-632-5850"}, -{"id":46,"firstName":"Vitoria","lastName":"Niese","street":"365 Colorado Plaza","postalCode":"15279","city":"Pittsburgh","state":"PA","phoneNumber":"412-864-8563"}, -{"id":47,"firstName":"Cherianne","lastName":"Daveran","street":"5 Esch Parkway","postalCode":"36104","city":"Montgomery","state":"AL","email":"cdaveran1a@ft.com"}, -{"id":48,"firstName":"Harriott","lastName":"Mallam","street":"9 Monterey Place","postalCode":"20215","city":"Washington","state":"DC","phoneNumber":"202-727-0645"}, -{"id":49,"firstName":"Jozef","lastName":"Stranger","street":"07 Warner Drive","postalCode":"84199","city":"Salt Lake City","state":"UT","phoneNumber":"801-741-5946"}, -{"id":50,"firstName":"Teena","lastName":"Broggio","street":"287 Luster Park","postalCode":"78285","city":"San Antonio","state":"TX","phoneNumber":"210-482-0822","email":"tbroggio1d@craigslist.org"}, -{"id":51,"firstName":"Robin","lastName":"Membry","street":"0736 Forest Dale Crossing","postalCode":"45408","city":"Dayton","state":"OH","phoneNumber":"937-335-4964","email":"rmembry1e@toplist.cz"}, -{"id":52,"firstName":"Holly","lastName":"Lowcock","street":"819 Aberg Pass","postalCode":"28815","city":"Asheville","state":"NC","email":"hlowcock1f@bbc.co.uk"}, -{"id":53,"firstName":"Shandee","lastName":"Blowick","street":"81600 Moose Lane","postalCode":"46867","city":"Fort Wayne","state":"IN","phoneNumber":"260-904-5622"}, -{"id":54,"firstName":"Chaim","lastName":"Stilliard","street":"91 Spohn Court","postalCode":"28305","city":"Fayetteville","state":"NC","phoneNumber":"910-721-3938"}, -{"id":55,"firstName":"Maximilien","lastName":"Purkis","street":"66997 Algoma Park","postalCode":"10150","city":"New York City","state":"NY","phoneNumber":"212-824-3363","email":"mpurkis1i@unblog.fr"}, -{"id":56,"firstName":"Ferguson","lastName":"Whiles","street":"0550 Bowman Street","postalCode":"33142","city":"Miami","state":"FL","phoneNumber":"786-416-2947","email":"fwhiles1j@artisteer.com"}, -{"id":57,"firstName":"Elena","lastName":"Poyle","street":"54 Warner Court","postalCode":"28055","city":"Gastonia","state":"NC","email":"epoyle1k@tripod.com"}, -{"id":58,"firstName":"Carney","lastName":"Pengilly","street":"050 Welch Junction","postalCode":"76147","city":"Fort Worth","state":"TX","phoneNumber":"817-525-7801","email":"cpengilly1l@yellowpages.com"}, -{"id":59,"firstName":"Krispin","lastName":"Pouck","street":"03554 Twin Pines Point","postalCode":"55551","city":"Young America","state":"MN","email":"kpouck1m@nymag.com"}, -{"id":60,"firstName":"Kylie","lastName":"Osmar","street":"7 Milwaukee Plaza","postalCode":"45228","city":"Cincinnati","state":"OH","phoneNumber":"513-940-5020","email":"kosmar1n@storify.com"}, -{"id":61,"firstName":"Trudi","lastName":"Standrin","street":"526 Onsgard Park","postalCode":"12237","city":"Albany","state":"NY","email":"tstandrin1o@sfgate.com"}, -{"id":62,"firstName":"Frank","lastName":"Belt","street":"52 Stang Lane","postalCode":"27455","city":"Greensboro","state":"NC"}, -{"id":63,"firstName":"Nerita","lastName":"Daulton","street":"03 Sutherland Court","postalCode":"55417","city":"Minneapolis","state":"MN","phoneNumber":"651-796-2028"}, -{"id":64,"firstName":"Urbanus","lastName":"Camm","street":"6802 Weeping Birch Circle","postalCode":"92115","city":"San Diego","state":"CA","email":"ucamm1r@ucoz.com"}, -{"id":65,"firstName":"Perry","lastName":"Struther","street":"63916 Corry Alley","postalCode":"28805","city":"Asheville","state":"NC","phoneNumber":"828-821-0824","email":"pstruther1s@nih.gov"}, -{"id":66,"firstName":"Zorina","lastName":"Uc","street":"99 Merry Circle","postalCode":"37250","city":"Nashville","state":"TN","phoneNumber":"615-364-4726","email":"zuc1t@cbc.ca"}, -{"id":67,"firstName":"Ajay","lastName":"Rediers","street":"6872 Armistice Lane","postalCode":"92812","city":"Anaheim","state":"CA","phoneNumber":"714-845-0143"}, -{"id":68,"firstName":"Brendis","lastName":"Goor","street":"94 Mccormick Place","postalCode":"77346","city":"Humble","state":"TX","phoneNumber":"713-910-5956"}, -{"id":69,"firstName":"Barbey","lastName":"Konneke","street":"75613 Miller Trail","postalCode":"30328","city":"Atlanta","state":"GA","phoneNumber":"770-208-1453"}, -{"id":70,"firstName":"Adlai","lastName":"Colly","street":"4446 Loftsgordon Place","postalCode":"40576","city":"Lexington","state":"KY","email":"acolly1x@phpbb.com"}, -{"id":71,"firstName":"Libby","lastName":"Wherton","street":"9313 Buell Road","postalCode":"70116","city":"New Orleans","state":"LA","email":"lwherton1y@flickr.com"}, -{"id":72,"firstName":"Niko","lastName":"Stockell","street":"61 Havey Park","postalCode":"10034","city":"New York City","state":"NY","phoneNumber":"646-814-6395","email":"nstockell1z@xrea.com"}, -{"id":73,"firstName":"Phillip","lastName":"Dadley","street":"14534 Victoria Street","postalCode":"33906","city":"Fort Myers","state":"FL","email":"pdadley20@studiopress.com"}, -{"id":74,"firstName":"Leann","lastName":"Hebburn","street":"9 Center Place","postalCode":"84140","city":"Salt Lake City","state":"UT","email":"lhebburn21@1688.com"}, -{"id":75,"firstName":"Raynor","lastName":"Gernier","street":"5923 Gale Plaza","postalCode":"79118","city":"Amarillo","state":"TX"}, -{"id":76,"firstName":"Elmore","lastName":"Frankton","street":"770 Wayridge Crossing","postalCode":"14619","city":"Rochester","state":"NY"}, -{"id":77,"firstName":"Teresina","lastName":"Rives","street":"51261 Sycamore Terrace","postalCode":"63180","city":"Saint Louis","state":"MO","email":"trives24@cbsnews.com"}, -{"id":78,"firstName":"Pancho","lastName":"Thebeaud","street":"72 Pierstorff Way","postalCode":"33705","city":"Saint Petersburg","state":"FL","phoneNumber":"813-335-3556"}, -{"id":79,"firstName":"Deanne","lastName":"Crighton","street":"95 Duke Plaza","postalCode":"71151","city":"Shreveport","state":"LA","phoneNumber":"318-218-7196","email":"dcrighton26@sphinn.com"}, -{"id":80,"firstName":"Brucie","lastName":"Bury","street":"8948 Knutson Lane","postalCode":"93740","city":"Fresno","state":"CA","email":"bbury27@twitter.com"}, -{"id":81,"firstName":"Joleen","lastName":"Flack","street":"8007 Morningstar Street","postalCode":"33283","city":"Miami","state":"FL","phoneNumber":"305-459-0365"}, -{"id":82,"firstName":"Antonino","lastName":"Matelyunas","street":"2585 Gale Road","postalCode":"20591","city":"Washington","state":"DC","phoneNumber":"202-780-3589"}, -{"id":83,"firstName":"Vinnie","lastName":"Syne","street":"6 Fallview Pass","postalCode":"20231","city":"Washington","state":"DC","phoneNumber":"202-648-5977","email":"vsyne2a@etsy.com"}, -{"id":84,"firstName":"Sig","lastName":"Guillotin","street":"6 Buell Lane","postalCode":"46015","city":"Anderson","state":"IN","phoneNumber":"765-948-7663","email":"sguillotin2b@cisco.com"}, -{"id":85,"firstName":"Gabriel","lastName":"Vasyukhichev","street":"25801 Grasskamp Junction","postalCode":"45408","city":"Dayton","state":"OH","email":"gvasyukhichev2c@mac.com"}, -{"id":86,"firstName":"Casie","lastName":"Burgill","street":"0 Dapin Alley","postalCode":"37410","city":"Chattanooga","state":"TN"}, -{"id":87,"firstName":"Kristan","lastName":"Chalice","street":"5118 Calypso Junction","postalCode":"78721","city":"Austin","state":"TX","phoneNumber":"512-831-2347"}, -{"id":88,"firstName":"Brear","lastName":"Pruckner","street":"2 Corscot Street","postalCode":"53790","city":"Madison","state":"WI"}, -{"id":89,"firstName":"Estella","lastName":"Orpyne","street":"293 Hansons Plaza","postalCode":"55579","city":"Maple Plain","state":"MN","phoneNumber":"952-666-6951","email":"eorpyne2g@examiner.com"}, -{"id":90,"firstName":"Conroy","lastName":"de Banke","street":"40636 Farmco Park","postalCode":"30316","city":"Atlanta","state":"GA","phoneNumber":"404-199-0073","email":"cdebanke2h@prweb.com"}, -{"id":91,"firstName":"Elmira","lastName":"Bracken","street":"10 Macpherson Place","postalCode":"85099","city":"Phoenix","state":"AZ","phoneNumber":"602-991-7768","email":"ebracken2i@sourceforge.net"}, -{"id":92,"firstName":"Carlota","lastName":"Vasilechko","street":"33 American Ash Point","postalCode":"75507","city":"Texarkana","state":"TX","phoneNumber":"903-312-0610","email":"cvasilechko2j@nba.com"}, -{"id":93,"firstName":"Jamesy","lastName":"Valentelli","street":"59634 Charing Cross Trail","postalCode":"31416","city":"Savannah","state":"GA","phoneNumber":"912-657-6729","email":"jvalentelli2k@nifty.com"}, -{"id":94,"firstName":"Hildagarde","lastName":"Sandels","street":"1 Lotheville Lane","postalCode":"32277","city":"Jacksonville","state":"FL","phoneNumber":"904-981-2753","email":"hsandels2l@a8.net"}, -{"id":95,"firstName":"Kip","lastName":"Cranidge","street":"2 South Road","postalCode":"19160","city":"Philadelphia","state":"PA"}, -{"id":96,"firstName":"Tobit","lastName":"Jarrette","street":"777 Mallard Trail","postalCode":"49444","city":"Muskegon","state":"MI","phoneNumber":"231-706-1988"}, -{"id":97,"firstName":"Tibold","lastName":"Michie","street":"87796 Nevada Junction","postalCode":"22093","city":"Ashburn","state":"VA","phoneNumber":"571-188-4893","email":"tmichie2o@mapy.cz"}, -{"id":98,"firstName":"Maximo","lastName":"Ifill","street":"8307 Tony Point","postalCode":"22225","city":"Arlington","state":"VA","phoneNumber":"571-404-1412"}, -{"id":99,"firstName":"Patti","lastName":"Autry","street":"901 Iowa Crossing","postalCode":"55551","city":"Young America","state":"MN","phoneNumber":"952-772-9107","email":"pautry2q@scientificamerican.com"}, -{"id":100,"firstName":"Cathe","lastName":"Jost","street":"4400 Menomonie Road","postalCode":"21211","city":"Baltimore","state":"MD","phoneNumber":"410-800-4683","email":"cjost2r@tuttocitta.it"}, -{"id":101,"firstName":"Byron","lastName":"Maddams","street":"10729 Oak Trail","postalCode":"78255","city":"San Antonio","state":"TX","phoneNumber":"830-263-4129"}, -{"id":102,"firstName":"Sosanna","lastName":"Paley","street":"82207 Park Meadow Court","postalCode":"77010","city":"Houston","state":"TX","phoneNumber":"832-740-8766","email":"spaley2t@salon.com"}, -{"id":103,"firstName":"Elysia","lastName":"Skerratt","street":"88708 Cambridge Drive","postalCode":"31217","city":"Macon","state":"GA","phoneNumber":"478-265-6579","email":"eskerratt2u@japanpost.jp"}, -{"id":104,"firstName":"Nealson","lastName":"Sieur","street":"1286 Elmside Plaza","postalCode":"20904","city":"Silver Spring","state":"MD"}, -{"id":105,"firstName":"Yasmeen","lastName":"Bazire","street":"91904 Elmside Point","postalCode":"73167","city":"Oklahoma City","state":"OK"}, -{"id":106,"firstName":"Mandy","lastName":"Ewart","street":"91 Norway Maple Street","postalCode":"21239","city":"Baltimore","state":"MD","email":"mewart2x@weebly.com"}, -{"id":107,"firstName":"Chlo","lastName":"Keedy","street":"560 Oak Valley Avenue","postalCode":"20420","city":"Washington","state":"DC"}, -{"id":108,"firstName":"Benedicta","lastName":"Dinneen","street":"9 Cottonwood Circle","postalCode":"60686","city":"Chicago","state":"IL","email":"bdinneen2z@nydailynews.com"}, -{"id":109,"firstName":"Nanon","lastName":"Corsar","street":"40001 Barby Drive","postalCode":"95818","city":"Sacramento","state":"CA","email":"ncorsar30@house.gov"}, -{"id":110,"firstName":"Babette","lastName":"Scarsbrick","street":"96095 Loomis Terrace","postalCode":"94622","city":"Oakland","state":"CA","email":"bscarsbrick31@smugmug.com"}, -{"id":111,"firstName":"Cornall","lastName":"Christauffour","street":"9 Springview Alley","postalCode":"84170","city":"Salt Lake City","state":"UT","phoneNumber":"801-935-1246","email":"cchristauffour32@booking.com"}, -{"id":112,"firstName":"Micki","lastName":"Labell","street":"77729 Heath Place","postalCode":"25336","city":"Charleston","state":"WV"}, -{"id":113,"firstName":"Marissa","lastName":"Bricksey","street":"1 Jackson Pass","postalCode":"11470","city":"Jamaica","state":"NY","phoneNumber":"917-552-4280"}, -{"id":114,"firstName":"Alex","lastName":"Lyptrade","street":"74 Bunting Circle","postalCode":"40591","city":"Lexington","state":"KY","phoneNumber":"859-177-0753"}, -{"id":115,"firstName":"Tove","lastName":"Bielfeldt","street":"95 Mallard Hill","postalCode":"70894","city":"Baton Rouge","state":"LA","email":"tbielfeldt36@goo.gl"}, -{"id":116,"firstName":"Rodrigo","lastName":"Chestle","street":"53625 1st Junction","postalCode":"43635","city":"Toledo","state":"OH","phoneNumber":"419-928-0953","email":"rchestle37@princeton.edu"}, -{"id":117,"firstName":"Ulrike","lastName":"Kendle","street":"0 Cardinal Alley","postalCode":"80925","city":"Colorado Springs","state":"CO","phoneNumber":"719-796-1992","email":"ukendle38@naver.com"}, -{"id":118,"firstName":"Sandor","lastName":"Warwick","street":"8 Spaight Crossing","postalCode":"92030","city":"Escondido","state":"CA","email":"swarwick39@about.com"}, -{"id":119,"firstName":"Selina","lastName":"Slowcock","street":"7 7th Circle","postalCode":"50335","city":"Des Moines","state":"IA","phoneNumber":"515-865-9809"}, -{"id":120,"firstName":"Maxine","lastName":"Placstone","street":"42056 Sycamore Plaza","postalCode":"20244","city":"Washington","state":"DC"}, -{"id":121,"firstName":"Ardine","lastName":"Reven","street":"10634 Nancy Way","postalCode":"10175","city":"New York City","state":"NY","email":"areven3c@diigo.com"}, -{"id":122,"firstName":"Dilan","lastName":"Widdows","street":"37 Park Meadow Way","postalCode":"68144","city":"Omaha","state":"NE","phoneNumber":"402-383-9020"}, -{"id":123,"firstName":"Kevina","lastName":"Praten","street":"8531 Elmside Point","postalCode":"27610","city":"Raleigh","state":"NC","email":"kpraten3e@craigslist.org"}, -{"id":124,"firstName":"Sherman","lastName":"Jurczak","street":"8281 Acker Alley","postalCode":"07522","city":"Paterson","state":"NJ","email":"sjurczak3f@github.com"}, -{"id":125,"firstName":"Beckie","lastName":"Disney","street":"3 Butterfield Drive","postalCode":"49518","city":"Grand Rapids","state":"MI","phoneNumber":"616-493-1284","email":"bdisney3g@china.com.cn"}, -{"id":126,"firstName":"Blaine","lastName":"Leak","street":"369 Norway Maple Lane","postalCode":"03804","city":"Portsmouth","state":"NH","email":"bleak3h@lulu.com"}, -{"id":127,"firstName":"Dare","lastName":"Marney","street":"50 Lake View Alley","postalCode":"06505","city":"New Haven","state":"CT","phoneNumber":"203-876-6938","email":"dmarney3i@delicious.com"}, -{"id":128,"firstName":"Darby","lastName":"Sackler","street":"841 Ridgeview Trail","postalCode":"80279","city":"Denver","state":"CO"}, -{"id":129,"firstName":"Aurilia","lastName":"Seabrocke","street":"670 Schmedeman Road","postalCode":"11254","city":"Brooklyn","state":"NY","email":"aseabrocke3k@engadget.com"}, -{"id":130,"firstName":"Griz","lastName":"Riccioppo","street":"2204 Moland Circle","postalCode":"45218","city":"Cincinnati","state":"OH","email":"griccioppo3l@cisco.com"}, -{"id":131,"firstName":"Zahara","lastName":"Quinion","street":"4979 Mallory Circle","postalCode":"24515","city":"Lynchburg","state":"VA","email":"zquinion3m@sfgate.com"}, -{"id":132,"firstName":"Holly-anne","lastName":"Fontel","street":"60752 Hallows Circle","postalCode":"76705","city":"Waco","state":"TX","phoneNumber":"254-822-2565","email":"hfontel3n@exblog.jp"}, -{"id":133,"firstName":"Johannes","lastName":"Lemonby","street":"3 Grover Terrace","postalCode":"25709","city":"Huntington","state":"WV","phoneNumber":"304-342-4911","email":"jlemonby3o@woothemes.com"}, -{"id":134,"firstName":"Melvin","lastName":"Kain","street":"16 Pond Junction","postalCode":"85215","city":"Mesa","state":"AZ","phoneNumber":"602-146-3701"}, -{"id":135,"firstName":"Letta","lastName":"Smelley","street":"537 Helena Circle","postalCode":"22119","city":"Merrifield","state":"VA","phoneNumber":"571-472-5640"}, -{"id":136,"firstName":"Clerc","lastName":"Mc Ilwrick","street":"7050 Northfield Street","postalCode":"90050","city":"Los Angeles","state":"CA","email":"cmcilwrick3r@abc.net.au"}, -{"id":137,"firstName":"Abba","lastName":"Sutherns","street":"8087 Monterey Lane","postalCode":"83757","city":"Boise","state":"ID","phoneNumber":"208-110-3153","email":"asutherns3s@dropbox.com"}, -{"id":138,"firstName":"Karola","lastName":"Symper","street":"4596 Clyde Gallagher Road","postalCode":"28815","city":"Asheville","state":"NC","email":"ksymper3t@parallels.com"}, -{"id":139,"firstName":"Jessamyn","lastName":"Deacock","street":"19557 Bobwhite Way","postalCode":"19725","city":"Newark","state":"DE","phoneNumber":"302-174-2938"}, -{"id":140,"firstName":"Iggy","lastName":"Impey","street":"8 Brown Place","postalCode":"27499","city":"Greensboro","state":"NC"}, -{"id":141,"firstName":"Kary","lastName":"Mably","street":"75 Porter Avenue","postalCode":"70174","city":"New Orleans","state":"LA","email":"kmably3w@miibeian.gov.cn"}, -{"id":142,"firstName":"Ciel","lastName":"Tidbold","street":"54 Mitchell Lane","postalCode":"90055","city":"Los Angeles","state":"CA"}, -{"id":143,"firstName":"Dyana","lastName":"Orcott","street":"2 Kinsman Street","postalCode":"90005","city":"Los Angeles","state":"CA","phoneNumber":"310-366-6987"}, -{"id":144,"firstName":"Damien","lastName":"Haking","street":"2 Elmside Point","postalCode":"62705","city":"Springfield","state":"IL","email":"dhaking3z@drupal.org"}, -{"id":145,"firstName":"Ricardo","lastName":"Bille","street":"3 Mesta Hill","postalCode":"98411","city":"Tacoma","state":"WA","email":"rbille40@ebay.co.uk"}, -{"id":146,"firstName":"Carlene","lastName":"Roget","street":"8 Granby Avenue","postalCode":"35225","city":"Birmingham","state":"AL","phoneNumber":"205-762-4907","email":"croget41@statcounter.com"}, -{"id":147,"firstName":"Sharlene","lastName":"Antusch","street":"02445 Stang Parkway","postalCode":"55480","city":"Minneapolis","state":"MN","email":"santusch42@mtv.com"}, -{"id":148,"firstName":"Goober","lastName":"Danielczyk","street":"474 Union Court","postalCode":"70505","city":"Lafayette","state":"LA","phoneNumber":"337-779-0312","email":"gdanielczyk43@dion.ne.jp"}, -{"id":149,"firstName":"Janette","lastName":"Mauro","street":"1231 Commercial Crossing","postalCode":"97201","city":"Portland","state":"OR","phoneNumber":"971-423-7259"}, -{"id":150,"firstName":"Melinda","lastName":"Shitliffe","street":"244 Derek Drive","postalCode":"23208","city":"Richmond","state":"VA","phoneNumber":"804-864-5845"}, -{"id":151,"firstName":"Constance","lastName":"Fardon","street":"3 Lien Point","postalCode":"89105","city":"Las Vegas","state":"NV"}, -{"id":152,"firstName":"Tedd","lastName":"Storey","street":"2551 Luster Point","postalCode":"19151","city":"Philadelphia","state":"PA","phoneNumber":"215-622-9273","email":"tstorey47@google.com.au"}, -{"id":153,"firstName":"Brigitte","lastName":"Slograve","street":"8130 Waubesa Hill","postalCode":"11499","city":"Jamaica","state":"NY","email":"bslograve48@yandex.ru"}, -{"id":154,"firstName":"Ralph","lastName":"Comberbeach","street":"88140 Anderson Avenue","postalCode":"90076","city":"Los Angeles","state":"CA"}, -{"id":155,"firstName":"Deloria","lastName":"Thomazet","street":"666 Center Crossing","postalCode":"38119","city":"Memphis","state":"TN","phoneNumber":"615-840-7916"}, -{"id":156,"firstName":"Fidel","lastName":"MacClay","street":"01 Fairfield Point","postalCode":"24034","city":"Roanoke","state":"VA","email":"fmacclay4b@sitemeter.com"}, -{"id":157,"firstName":"Amalee","lastName":"Menzies","street":"6 Judy Drive","postalCode":"84605","city":"Provo","state":"UT"}, -{"id":158,"firstName":"Ansel","lastName":"Jory","street":"3 Nobel Park","postalCode":"32505","city":"Pensacola","state":"FL","phoneNumber":"850-394-8201"}, -{"id":159,"firstName":"Teodor","lastName":"Longhorn","street":"563 Sutherland Avenue","postalCode":"98008","city":"Bellevue","state":"WA"}, -{"id":160,"firstName":"Margarita","lastName":"Rewcassell","street":"64711 Beilfuss Point","postalCode":"79764","city":"Odessa","state":"TX","phoneNumber":"432-413-2196"}, -{"id":161,"firstName":"Tarra","lastName":"Albro","street":"2 Graceland Way","postalCode":"78405","city":"Corpus Christi","state":"TX"}, -{"id":162,"firstName":"Whitaker","lastName":"Brizell","street":"6 Luster Place","postalCode":"33694","city":"Tampa","state":"FL","email":"wbrizell4h@naver.com"}, -{"id":163,"firstName":"Gauthier","lastName":"Getsham","street":"0820 Duke Plaza","postalCode":"28263","city":"Charlotte","state":"NC","phoneNumber":"704-510-2908"}, -{"id":164,"firstName":"Thane","lastName":"Discombe","street":"56809 Aberg Street","postalCode":"63167","city":"Saint Louis","state":"MO"}, -{"id":165,"firstName":"Felicia","lastName":"Barthrup","street":"904 Stuart Junction","postalCode":"32220","city":"Jacksonville","state":"FL"}, -{"id":166,"firstName":"Emeline","lastName":"Jobes","street":"2670 Prairieview Plaza","postalCode":"10120","city":"New York City","state":"NY","email":"ejobes4l@newyorker.com"}, -{"id":167,"firstName":"Felicle","lastName":"Bowie","street":"9715 Lighthouse Bay Parkway","postalCode":"11210","city":"Brooklyn","state":"NY","email":"fbowie4m@auda.org.au"}, -{"id":168,"firstName":"Clare","lastName":"Miskelly","street":"8 Towne Trail","postalCode":"44555","city":"Youngstown","state":"OH"}, -{"id":169,"firstName":"Mort","lastName":"Danat","street":"6833 Shoshone Lane","postalCode":"12255","city":"Albany","state":"NY","phoneNumber":"518-967-9791","email":"mdanat4o@privacy.gov.au"}, -{"id":170,"firstName":"Ailey","lastName":"Scatchar","street":"3 Northfield Point","postalCode":"76505","city":"Temple","state":"TX"}, -{"id":171,"firstName":"Kevina","lastName":"Darwent","street":"8165 Reinke Alley","postalCode":"94132","city":"San Francisco","state":"CA","email":"kdarwent4q@artisteer.com"}, -{"id":172,"firstName":"My","lastName":"Buston","street":"715 Saint Paul Center","postalCode":"31416","city":"Savannah","state":"GA","phoneNumber":"912-281-8654"}, -{"id":173,"firstName":"Emera","lastName":"Lingner","street":"943 Eastlawn Hill","postalCode":"90605","city":"Whittier","state":"CA"}, -{"id":174,"firstName":"Drucie","lastName":"Byer","street":"988 4th Court","postalCode":"06816","city":"Danbury","state":"CT","email":"dbyer4t@xinhuanet.com"}, -{"id":175,"firstName":"Modestine","lastName":"Madeley","street":"1 Delaware Terrace","postalCode":"80126","city":"Littleton","state":"CO"}, -{"id":176,"firstName":"Selie","lastName":"O'Mohun","street":"42 Monument Trail","postalCode":"55590","city":"Monticello","state":"MN","phoneNumber":"763-384-5166"}, -{"id":177,"firstName":"Shayla","lastName":"Pesselt","street":"7 Pawling Center","postalCode":"20099","city":"Washington","state":"DC","phoneNumber":"202-816-7300","email":"spesselt4w@posterous.com"}, -{"id":178,"firstName":"Raeann","lastName":"Layland","street":"06548 Longview Alley","postalCode":"77005","city":"Houston","state":"TX","phoneNumber":"214-899-1257","email":"rlayland4x@pcworld.com"}, -{"id":179,"firstName":"Dael","lastName":"Christaeas","street":"375 Northfield Street","postalCode":"23509","city":"Norfolk","state":"VA","phoneNumber":"757-391-2798","email":"dchristaeas4y@sciencedaily.com"}, -{"id":180,"firstName":"Nicolas","lastName":"Baxill","street":"9 Autumn Leaf Terrace","postalCode":"77005","city":"Houston","state":"TX","email":"nbaxill4z@edublogs.org"}, -{"id":181,"firstName":"Onida","lastName":"Pengilly","street":"61 Commercial Junction","postalCode":"24029","city":"Roanoke","state":"VA","email":"opengilly50@slideshare.net"}, -{"id":182,"firstName":"Muffin","lastName":"Thrasher","street":"1 Morning Hill","postalCode":"64082","city":"Lees Summit","state":"MO"}, -{"id":183,"firstName":"Ignaz","lastName":"McLugish","street":"3936 Columbus Point","postalCode":"35263","city":"Birmingham","state":"AL"}, -{"id":184,"firstName":"Guillaume","lastName":"Gillings","street":"75541 Sheridan Center","postalCode":"68510","city":"Lincoln","state":"NE","email":"ggillings53@unblog.fr"}, -{"id":185,"firstName":"Kalli","lastName":"Branche","street":"33740 Manitowish Court","postalCode":"96805","city":"Honolulu","state":"HI"}, -{"id":186,"firstName":"Winthrop","lastName":"Barszczewski","street":"9 Luster Terrace","postalCode":"60158","city":"Carol Stream","state":"IL","phoneNumber":"309-633-3125","email":"wbarszczewski55@eventbrite.com"}, -{"id":187,"firstName":"Renaud","lastName":"Nitto","street":"1 Crownhardt Place","postalCode":"10310","city":"Staten Island","state":"NY","phoneNumber":"914-568-4524","email":"rnitto56@typepad.com"}, -{"id":188,"firstName":"Pollyanna","lastName":"Wherrett","street":"31380 Upham Street","postalCode":"76134","city":"Fort Worth","state":"TX","phoneNumber":"817-198-3301","email":"pwherrett57@bluehost.com"}, -{"id":189,"firstName":"Lilly","lastName":"Gatchell","street":"7 Elka Road","postalCode":"94064","city":"Redwood City","state":"CA","email":"lgatchell58@patch.com"}, -{"id":190,"firstName":"Leopold","lastName":"Leavey","street":"9 Darwin Crossing","postalCode":"20268","city":"Washington","state":"DC","phoneNumber":"202-964-5932","email":"lleavey59@aol.com"}, -{"id":191,"firstName":"Byram","lastName":"Stuckes","street":"782 Northport Alley","postalCode":"55436","city":"Minneapolis","state":"MN"}, -{"id":192,"firstName":"Cull","lastName":"Whiterod","street":"2586 Banding Terrace","postalCode":"80249","city":"Denver","state":"CO","email":"cwhiterod5b@skype.com"}, -{"id":193,"firstName":"Gretel","lastName":"Tacey","street":"6382 Fremont Avenue","postalCode":"25305","city":"Charleston","state":"WV"}, -{"id":194,"firstName":"Tudor","lastName":"Piff","street":"0 Monterey Circle","postalCode":"00214","city":"Portsmouth","state":"NH","email":"tpiff5d@eepurl.com"}, -{"id":195,"firstName":"Julienne","lastName":"Adshed","street":"91839 Lawn Avenue","postalCode":"92519","city":"Riverside","state":"CA"}, -{"id":196,"firstName":"Arnold","lastName":"Fearns","street":"7 West Trail","postalCode":"35242","city":"Birmingham","state":"AL","email":"afearns5f@bravesites.com"}, -{"id":197,"firstName":"Dunc","lastName":"Khoter","street":"048 Clove Lane","postalCode":"89505","city":"Reno","state":"NV","phoneNumber":"775-120-9532","email":"dkhoter5g@bbb.org"}, -{"id":198,"firstName":"Stevana","lastName":"Lush","street":"6 Dovetail Plaza","postalCode":"79945","city":"El Paso","state":"TX","email":"slush5h@economist.com"}, -{"id":199,"firstName":"Iggy","lastName":"Verryan","street":"5 Sommers Road","postalCode":"34114","city":"Naples","state":"FL","phoneNumber":"239-205-8767"}, -{"id":200,"firstName":"Breena","lastName":"Rubbert","street":"5 Kensington Crossing","postalCode":"90510","city":"Torrance","state":"CA","email":"brubbert5j@phpbb.com"}, -{"id":201,"firstName":"Jervis","lastName":"Doree","street":"2947 Center Plaza","postalCode":"70160","city":"New Orleans","state":"LA","phoneNumber":"504-278-7497","email":"jdoree5k@shutterfly.com"}, -{"id":202,"firstName":"Odelia","lastName":"Lidierth","street":"36699 Aberg Park","postalCode":"62764","city":"Springfield","state":"IL"}, -{"id":203,"firstName":"Ree","lastName":"Lammerding","street":"3542 Lerdahl Court","postalCode":"88558","city":"El Paso","state":"TX","phoneNumber":"915-384-9334","email":"rlammerding5m@msu.edu"}, -{"id":204,"firstName":"Davy","lastName":"Orniz","street":"49 Graedel Parkway","postalCode":"48295","city":"Detroit","state":"MI","email":"dorniz5n@examiner.com"}, -{"id":205,"firstName":"Syd","lastName":"Buckoke","street":"70 Pepper Wood Alley","postalCode":"74156","city":"Tulsa","state":"OK","phoneNumber":"918-604-5799"}, -{"id":206,"firstName":"Ginger","lastName":"Calkin","street":"7 Thompson Trail","postalCode":"71115","city":"Shreveport","state":"LA","phoneNumber":"318-650-6046"}, -{"id":207,"firstName":"Anissa","lastName":"Ivashinnikov","street":"61905 Chive Circle","postalCode":"40745","city":"London","state":"KY","email":"aivashinnikov5q@google.cn"}, -{"id":208,"firstName":"Vikky","lastName":"Kesley","street":"1 Grayhawk Street","postalCode":"06538","city":"New Haven","state":"CT","phoneNumber":"203-944-7163"}, -{"id":209,"firstName":"Alisha","lastName":"Lampke","street":"26940 Kensington Park","postalCode":"55446","city":"Minneapolis","state":"MN","phoneNumber":"612-814-9814","email":"alampke5s@apple.com"}, -{"id":210,"firstName":"Davidde","lastName":"Phlipon","street":"2044 Ruskin Road","postalCode":"07188","city":"Newark","state":"NJ","email":"dphlipon5t@shareasale.com"}, -{"id":211,"firstName":"Joly","lastName":"Crottagh","street":"532 Dawn Plaza","postalCode":"85083","city":"Phoenix","state":"AZ","phoneNumber":"602-533-4064"}, -{"id":212,"firstName":"Aggie","lastName":"Niesing","street":"3 Tony Drive","postalCode":"57110","city":"Sioux Falls","state":"SD","email":"aniesing5v@pbs.org"}, -{"id":213,"firstName":"Daron","lastName":"Baudassi","street":"2411 Melvin Court","postalCode":"40581","city":"Lexington","state":"KY","phoneNumber":"859-754-2542","email":"dbaudassi5w@joomla.org"}, -{"id":214,"firstName":"Thadeus","lastName":"Kleiser","street":"1394 Warner Street","postalCode":"87592","city":"Santa Fe","state":"NM","email":"tkleiser5x@bloomberg.com"}, -{"id":215,"firstName":"Terri","lastName":"Perrat","street":"0080 Upham Plaza","postalCode":"52245","city":"Iowa City","state":"IA"}, -{"id":216,"firstName":"Marlena","lastName":"Gatchell","street":"60888 Annamark Street","postalCode":"90060","city":"Los Angeles","state":"CA","phoneNumber":"323-121-6985","email":"mgatchell5z@ibm.com"}, -{"id":217,"firstName":"Locke","lastName":"Orcott","street":"459 Warner Lane","postalCode":"45020","city":"Hamilton","state":"OH","phoneNumber":"937-115-3187"}, -{"id":218,"firstName":"Wilmer","lastName":"Bewick","street":"0 Ohio Center","postalCode":"98166","city":"Seattle","state":"WA","phoneNumber":"253-805-8855","email":"wbewick61@seesaa.net"}, -{"id":219,"firstName":"Marena","lastName":"MacShirrie","street":"607 Badeau Circle","postalCode":"98008","city":"Bellevue","state":"WA","email":"mmacshirrie62@wikia.com"}, -{"id":220,"firstName":"Nathanial","lastName":"Sexty","street":"43 Basil Place","postalCode":"85020","city":"Phoenix","state":"AZ"}, -{"id":221,"firstName":"Wadsworth","lastName":"Iacovuzzi","street":"9610 Donald Crossing","postalCode":"88530","city":"El Paso","state":"TX","phoneNumber":"915-889-7936","email":"wiacovuzzi64@prnewswire.com"}, -{"id":222,"firstName":"Sutton","lastName":"Stych","street":"9 Brentwood Terrace","postalCode":"20546","city":"Washington","state":"DC","phoneNumber":"202-538-6355","email":"sstych65@wikimedia.org"}, -{"id":223,"firstName":"Gaspar","lastName":"Wabey","street":"3061 Bluejay Terrace","postalCode":"10110","city":"New York City","state":"NY","phoneNumber":"917-939-0802","email":"gwabey66@technorati.com"}, -{"id":224,"firstName":"Herminia","lastName":"Guyot","street":"91 Express Drive","postalCode":"85715","city":"Tucson","state":"AZ","phoneNumber":"520-777-1670","email":"hguyot67@admin.ch"}, -{"id":225,"firstName":"Udale","lastName":"Beurich","street":"675 Karstens Crossing","postalCode":"46852","city":"Fort Wayne","state":"IN","phoneNumber":"260-580-8627","email":"ubeurich68@bigcartel.com"}, -{"id":226,"firstName":"Kerrie","lastName":"Girauld","street":"56132 Charing Cross Court","postalCode":"71137","city":"Shreveport","state":"LA","email":"kgirauld69@nationalgeographic.com"}, -{"id":227,"firstName":"Irvin","lastName":"Nix","street":"0676 Aberg Terrace","postalCode":"97075","city":"Beaverton","state":"OR","email":"inix6a@xing.com"}, -{"id":228,"firstName":"Corene","lastName":"Spencock","street":"90 Meadow Ridge Drive","postalCode":"73173","city":"Oklahoma City","state":"OK","phoneNumber":"405-577-1312","email":"cspencock6b@shinystat.com"}, -{"id":229,"firstName":"Christos","lastName":"McIlreavy","street":"673 Jana Trail","postalCode":"23471","city":"Virginia Beach","state":"VA","email":"cmcilreavy6c@mayoclinic.com"}, -{"id":230,"firstName":"Bennett","lastName":"Melding","street":"4 Cardinal Lane","postalCode":"55448","city":"Minneapolis","state":"MN","email":"bmelding6d@t-online.de"}, -{"id":231,"firstName":"Winny","lastName":"de Leon","street":"941 Scoville Place","postalCode":"94611","city":"Oakland","state":"CA","phoneNumber":"510-230-4168","email":"wdeleon6e@dell.com"}, -{"id":232,"firstName":"Nike","lastName":"Iacobassi","street":"956 Service Junction","postalCode":"71914","city":"Hot Springs National Park","state":"AR","phoneNumber":"501-266-4142"}, -{"id":233,"firstName":"Gillan","lastName":"Baumann","street":"11 8th Alley","postalCode":"31190","city":"Atlanta","state":"GA","phoneNumber":"404-703-5154","email":"gbaumann6g@edublogs.org"}, -{"id":234,"firstName":"Brandtr","lastName":"Gadman","street":"5 Marquette Hill","postalCode":"32511","city":"Pensacola","state":"FL","phoneNumber":"850-834-0058","email":"bgadman6h@marriott.com"}, -{"id":235,"firstName":"Kenn","lastName":"Cage","street":"3759 Spohn Point","postalCode":"94126","city":"San Francisco","state":"CA","email":"kcage6i@earthlink.net"}, -{"id":236,"firstName":"Butch","lastName":"Causby","street":"02 Basil Crossing","postalCode":"10110","city":"New York City","state":"NY","phoneNumber":"212-190-1702","email":"bcausby6j@scribd.com"}, -{"id":237,"firstName":"Haleigh","lastName":"Parsonson","street":"8 Ruskin Trail","postalCode":"87201","city":"Albuquerque","state":"NM","phoneNumber":"505-987-1352"}, -{"id":238,"firstName":"Bartel","lastName":"Ruppeli","street":"7538 Red Cloud Center","postalCode":"37410","city":"Chattanooga","state":"TN","phoneNumber":"423-804-1016","email":"bruppeli6l@etsy.com"}, -{"id":239,"firstName":"Gretchen","lastName":"Le feaver","street":"7 Orin Way","postalCode":"98042","city":"Kent","state":"WA","phoneNumber":"253-205-3092","email":"glefeaver6m@mayoclinic.com"}, -{"id":240,"firstName":"Trumaine","lastName":"Dearden","street":"1 Vernon Trail","postalCode":"06127","city":"West Hartford","state":"CT","phoneNumber":"860-939-3865","email":"tdearden6n@goo.gl"}, -{"id":241,"firstName":"Aggie","lastName":"Dubs","street":"3601 Walton Trail","postalCode":"62764","city":"Springfield","state":"IL","phoneNumber":"217-834-6059","email":"adubs6o@cbsnews.com"}, -{"id":242,"firstName":"Shelly","lastName":"Skechley","street":"16 Morning Lane","postalCode":"60567","city":"Naperville","state":"IL","email":"sskechley6p@technorati.com"}, -{"id":243,"firstName":"Karin","lastName":"Fausch","street":"7532 Eggendart Way","postalCode":"19810","city":"Wilmington","state":"DE","phoneNumber":"302-548-2991"}, -{"id":244,"firstName":"Sal","lastName":"Harrow","street":"2632 Lien Way","postalCode":"33982","city":"Punta Gorda","state":"FL","phoneNumber":"941-904-5187","email":"sharrow6r@joomla.org"}, -{"id":245,"firstName":"Albie","lastName":"Strelitzki","street":"8436 Eggendart Terrace","postalCode":"49505","city":"Grand Rapids","state":"MI","email":"astrelitzki6s@google.com.br"}, -{"id":246,"firstName":"Augy","lastName":"Usherwood","street":"9078 Clemons Street","postalCode":"80915","city":"Colorado Springs","state":"CO","email":"ausherwood6t@wikimedia.org"}, -{"id":247,"firstName":"Solomon","lastName":"D'eathe","street":"778 Rockefeller Parkway","postalCode":"84199","city":"Salt Lake City","state":"UT"}, -{"id":248,"firstName":"Talya","lastName":"Joseff","street":"14 Graedel Court","postalCode":"99220","city":"Spokane","state":"WA","email":"tjoseff6v@amazon.de"}, -{"id":249,"firstName":"Anatol","lastName":"Self","street":"2 Stoughton Junction","postalCode":"85255","city":"Scottsdale","state":"AZ"}, -{"id":250,"firstName":"Elinore","lastName":"Bruhnke","street":"3 Bashford Alley","postalCode":"17105","city":"Harrisburg","state":"PA","email":"ebruhnke6x@usnews.com"}, -{"id":251,"firstName":"Stanfield","lastName":"Jagiello","street":"0804 Amoth Road","postalCode":"20067","city":"Washington","state":"DC"}, -{"id":252,"firstName":"Isak","lastName":"Venour","street":"04 Orin Court","postalCode":"78210","city":"San Antonio","state":"TX","email":"ivenour6z@springer.com"}, -{"id":253,"firstName":"Abigale","lastName":"Woolgar","street":"74 Porter Terrace","postalCode":"62705","city":"Springfield","state":"IL"}, -{"id":254,"firstName":"Phylys","lastName":"Casperri","street":"07 Delaware Street","postalCode":"33069","city":"Pompano Beach","state":"FL","phoneNumber":"954-224-4577"}, -{"id":255,"firstName":"Melania","lastName":"Fee","street":"194 Luster Point","postalCode":"70154","city":"New Orleans","state":"LA","phoneNumber":"504-168-6959","email":"mfee72@comsenz.com"}, -{"id":256,"firstName":"Joli","lastName":"Colquite","street":"9 Bayside Court","postalCode":"27425","city":"Greensboro","state":"NC","email":"jcolquite73@comcast.net"}, -{"id":257,"firstName":"Rahel","lastName":"Late","street":"2 Meadow Ridge Alley","postalCode":"32204","city":"Jacksonville","state":"FL"}, -{"id":258,"firstName":"Carny","lastName":"Fewell","street":"21826 Cardinal Pass","postalCode":"98140","city":"Seattle","state":"WA"}, -{"id":259,"firstName":"Lesly","lastName":"Vanyatin","street":"7730 South Court","postalCode":"25356","city":"Charleston","state":"WV","email":"lvanyatin76@histats.com"}, -{"id":260,"firstName":"Fianna","lastName":"Thomason","street":"2576 Holmberg Trail","postalCode":"27710","city":"Durham","state":"NC"}, -{"id":261,"firstName":"Bobinette","lastName":"Gowdridge","street":"6780 Superior Place","postalCode":"37605","city":"Johnson City","state":"TN","phoneNumber":"423-490-4990","email":"bgowdridge78@icio.us"}, -{"id":262,"firstName":"Karmen","lastName":"Megson","street":"34 Messerschmidt Point","postalCode":"97229","city":"Portland","state":"OR","email":"kmegson79@apache.org"}, -{"id":263,"firstName":"Thaddeus","lastName":"Padilla","street":"42 Corben Road","postalCode":"90010","city":"Los Angeles","state":"CA","phoneNumber":"213-659-3136","email":"tpadilla7a@hud.gov"}, -{"id":264,"firstName":"Hanna","lastName":"Baswall","street":"9 Old Shore Lane","postalCode":"53710","city":"Madison","state":"WI","email":"hbaswall7b@ezinearticles.com"}, -{"id":265,"firstName":"Tania","lastName":"McMorland","street":"4333 Commercial Point","postalCode":"45408","city":"Dayton","state":"OH"}, -{"id":266,"firstName":"Gifford","lastName":"Arne","street":"0 Drewry Point","postalCode":"24048","city":"Roanoke","state":"VA","email":"garne7d@samsung.com"}, -{"id":267,"firstName":"Tomasina","lastName":"Linch","street":"64992 Maple Wood Point","postalCode":"98447","city":"Tacoma","state":"WA","email":"tlinch7e@theglobeandmail.com"}, -{"id":268,"firstName":"Merrick","lastName":"Garvan","street":"7220 Melody Trail","postalCode":"90005","city":"Los Angeles","state":"CA","email":"mgarvan7f@mozilla.org"}, -{"id":269,"firstName":"Carmita","lastName":"Sailes","street":"3 Bay Lane","postalCode":"55428","city":"Minneapolis","state":"MN","email":"csailes7g@devhub.com"}, -{"id":270,"firstName":"Lesly","lastName":"Eslemont","street":"93302 Mcbride Terrace","postalCode":"19810","city":"Wilmington","state":"DE","email":"leslemont7h@wunderground.com"}, -{"id":271,"firstName":"Adelaida","lastName":"Keggins","street":"4 Birchwood Pass","postalCode":"97405","city":"Eugene","state":"OR","phoneNumber":"541-387-1319"}, -{"id":272,"firstName":"Peadar","lastName":"Forte","street":"1 Montana Center","postalCode":"32505","city":"Pensacola","state":"FL","email":"pforte7j@xing.com"}, -{"id":273,"firstName":"Godfrey","lastName":"Swatland","street":"477 Maple Wood Road","postalCode":"93034","city":"Oxnard","state":"CA","phoneNumber":"805-267-0614","email":"gswatland7k@photobucket.com"}, -{"id":274,"firstName":"Marten","lastName":"Jelleman","street":"57 Pennsylvania Plaza","postalCode":"20057","city":"Washington","state":"DC","email":"mjelleman7l@phoca.cz"}, -{"id":275,"firstName":"Sharity","lastName":"Keady","street":"753 Sauthoff Place","postalCode":"77505","city":"Pasadena","state":"TX"}, -{"id":276,"firstName":"Gabbie","lastName":"Pally","street":"45 Fallview Park","postalCode":"97255","city":"Portland","state":"OR","phoneNumber":"971-412-2293","email":"gpally7n@dyndns.org"}, -{"id":277,"firstName":"Betsy","lastName":"Rhelton","street":"9 Jackson Road","postalCode":"85040","city":"Phoenix","state":"AZ"}, -{"id":278,"firstName":"Patty","lastName":"Schooling","street":"4 Moulton Point","postalCode":"25705","city":"Huntington","state":"WV","phoneNumber":"304-908-8211","email":"pschooling7p@parallels.com"}, -{"id":279,"firstName":"Katlin","lastName":"O'Hallagan","street":"8418 Petterle Plaza","postalCode":"60636","city":"Chicago","state":"IL","email":"kohallagan7q@hao123.com"}, -{"id":280,"firstName":"Anne","lastName":"Wealleans","street":"3 Sachtjen Court","postalCode":"48609","city":"Saginaw","state":"MI"}, -{"id":281,"firstName":"Flory","lastName":"Pley","street":"6322 Golf View Court","postalCode":"19104","city":"Philadelphia","state":"PA"}, -{"id":282,"firstName":"Maryellen","lastName":"Baszkiewicz","street":"54165 Hanson Trail","postalCode":"93726","city":"Fresno","state":"CA","phoneNumber":"209-198-4916","email":"mbaszkiewicz7t@google.com.br"}, -{"id":283,"firstName":"Moyna","lastName":"Caddens","street":"17 Melrose Lane","postalCode":"11236","city":"Brooklyn","state":"NY","phoneNumber":"917-518-3987","email":"mcaddens7u@amazon.co.uk"}, -{"id":284,"firstName":"Lawton","lastName":"Ramiro","street":"2 Muir Park","postalCode":"48092","city":"Warren","state":"MI","phoneNumber":"810-472-5208","email":"lramiro7v@senate.gov"}, -{"id":285,"firstName":"Agnella","lastName":"Phelip","street":"24566 Colorado Pass","postalCode":"84145","city":"Salt Lake City","state":"UT","phoneNumber":"801-709-8696","email":"aphelip7w@woothemes.com"}, -{"id":286,"firstName":"Tracee","lastName":"Tighe","street":"41013 Cascade Lane","postalCode":"02142","city":"Cambridge","state":"MA"}, -{"id":287,"firstName":"Shelden","lastName":"Sowrey","street":"87 Glacier Hill Court","postalCode":"55557","city":"Young America","state":"MN","email":"ssowrey7y@sfgate.com"}, -{"id":288,"firstName":"Letizia","lastName":"Sallery","street":"65052 Shasta Court","postalCode":"44905","city":"Mansfield","state":"OH","phoneNumber":"419-752-9141"}, -{"id":289,"firstName":"Hilly","lastName":"Oyley","street":"7 Waywood Trail","postalCode":"30323","city":"Atlanta","state":"GA","email":"hoyley80@upenn.edu"}, -{"id":290,"firstName":"Sabra","lastName":"Grigoryev","street":"856 Michigan Trail","postalCode":"33705","city":"Saint Petersburg","state":"FL"}, -{"id":291,"firstName":"Nathanil","lastName":"Bodham","street":"536 Ridgeview Way","postalCode":"79984","city":"El Paso","state":"TX","email":"nbodham82@wikimedia.org"}, -{"id":292,"firstName":"Niven","lastName":"Hartzenberg","street":"5 Carpenter Hill","postalCode":"73167","city":"Oklahoma City","state":"OK","email":"nhartzenberg83@bandcamp.com"}, -{"id":293,"firstName":"Rachael","lastName":"Birdsall","street":"61484 Mendota Point","postalCode":"90410","city":"Santa Monica","state":"CA","email":"rbirdsall84@gmpg.org"}, -{"id":294,"firstName":"Gypsy","lastName":"Rallin","street":"4 Spohn Drive","postalCode":"77346","city":"Humble","state":"TX","phoneNumber":"713-508-2912","email":"grallin85@privacy.gov.au"}, -{"id":295,"firstName":"Skye","lastName":"Arsey","street":"49126 Maryland Lane","postalCode":"02119","city":"Boston","state":"MA"}, -{"id":296,"firstName":"Karalee","lastName":"Biddiss","street":"0327 Coleman Lane","postalCode":"10203","city":"New York City","state":"NY","email":"kbiddiss87@studiopress.com"}, -{"id":297,"firstName":"Russ","lastName":"O' Mahony","street":"7831 Caliangt Avenue","postalCode":"37665","city":"Kingsport","state":"TN","phoneNumber":"423-292-1177","email":"romahony88@umich.edu"}, -{"id":298,"firstName":"Gerianne","lastName":"Morfey","street":"1 Jay Hill","postalCode":"97229","city":"Portland","state":"OR","email":"gmorfey89@techcrunch.com"}, -{"id":299,"firstName":"Griz","lastName":"Vellacott","street":"44 Parkside Court","postalCode":"64149","city":"Kansas City","state":"MO","phoneNumber":"816-120-1692"}, -{"id":300,"firstName":"Parker","lastName":"Mantz","street":"3 Arkansas Lane","postalCode":"90005","city":"Los Angeles","state":"CA","email":"pmantz8b@va.gov"}, -{"id":301,"firstName":"Drugi","lastName":"Acaster","street":"426 Hagan Park","postalCode":"20599","city":"Washington","state":"DC","email":"dacaster8c@ihg.com"}, -{"id":302,"firstName":"Peder","lastName":"Monget","street":"9 Wayridge Parkway","postalCode":"92862","city":"Orange","state":"CA","phoneNumber":"714-532-0867","email":"pmonget8d@biblegateway.com"}, -{"id":303,"firstName":"Zilvia","lastName":"Grocutt","street":"1 Stuart Circle","postalCode":"34642","city":"Seminole","state":"FL"}, -{"id":304,"firstName":"Clyve","lastName":"Gunby","street":"75 Dunning Junction","postalCode":"79977","city":"El Paso","state":"TX","email":"cgunby8f@microsoft.com"}, -{"id":305,"firstName":"Zacharias","lastName":"Tomasini","street":"48488 Thackeray Way","postalCode":"40210","city":"Louisville","state":"KY","email":"ztomasini8g@harvard.edu"}, -{"id":306,"firstName":"Ferdinand","lastName":"McGuinley","street":"30366 Kipling Drive","postalCode":"23208","city":"Richmond","state":"VA","email":"fmcguinley8h@archive.org"}, -{"id":307,"firstName":"Ebonee","lastName":"Brumfitt","street":"18765 Division Terrace","postalCode":"30033","city":"Decatur","state":"GA","phoneNumber":"404-684-8364","email":"ebrumfitt8i@sourceforge.net"}, -{"id":308,"firstName":"Christy","lastName":"Cuniam","street":"6 Homewood Road","postalCode":"78744","city":"Austin","state":"TX","phoneNumber":"361-677-9833","email":"ccuniam8j@51.la"}, -{"id":309,"firstName":"Emelen","lastName":"Casin","street":"91 Thompson Plaza","postalCode":"33954","city":"Port Charlotte","state":"FL","email":"ecasin8k@webnode.com"}, -{"id":310,"firstName":"Babara","lastName":"Robberecht","street":"603 Oak Terrace","postalCode":"37450","city":"Chattanooga","state":"TN","email":"brobberecht8l@cargocollective.com"}, -{"id":311,"firstName":"Cesar","lastName":"Whitecross","street":"024 Oxford Junction","postalCode":"20226","city":"Washington","state":"DC","phoneNumber":"202-772-2936"}, -{"id":312,"firstName":"Frieda","lastName":"Sliman","street":"4 Beilfuss Hill","postalCode":"23324","city":"Chesapeake","state":"VA","email":"fsliman8n@bigcartel.com"}, -{"id":313,"firstName":"Dylan","lastName":"Paige","street":"26 Gina Parkway","postalCode":"55448","city":"Minneapolis","state":"MN","email":"dpaige8o@trellian.com"}, -{"id":314,"firstName":"Waring","lastName":"Labon","street":"2843 Spenser Center","postalCode":"49444","city":"Muskegon","state":"MI","phoneNumber":"231-274-0766","email":"wlabon8p@ucla.edu"}, -{"id":315,"firstName":"Conny","lastName":"Duinkerk","street":"65 Lunder Circle","postalCode":"45426","city":"Dayton","state":"OH","email":"cduinkerk8q@economist.com"}, -{"id":316,"firstName":"Nessie","lastName":"Stucksbury","street":"91449 Browning Drive","postalCode":"25705","city":"Huntington","state":"WV","phoneNumber":"304-182-0766"}, -{"id":317,"firstName":"Corrine","lastName":"Kohlert","street":"00706 Carioca Plaza","postalCode":"45223","city":"Cincinnati","state":"OH","email":"ckohlert8s@wunderground.com"}, -{"id":318,"firstName":"Horatio","lastName":"Greengrass","street":"0 Cascade Park","postalCode":"79905","city":"El Paso","state":"TX","email":"hgreengrass8t@ameblo.jp"}, -{"id":319,"firstName":"Jana","lastName":"McLae","street":"919 Esch Place","postalCode":"55428","city":"Minneapolis","state":"MN","email":"jmclae8u@nytimes.com"}, -{"id":320,"firstName":"Maressa","lastName":"Rehor","street":"55 Talisman Junction","postalCode":"90505","city":"Torrance","state":"CA","email":"mrehor8v@vinaora.com"}, -{"id":321,"firstName":"Filide","lastName":"Riehm","street":"0 Karstens Lane","postalCode":"95054","city":"Santa Clara","state":"CA"}, -{"id":322,"firstName":"Bunnie","lastName":"Mumbey","street":"9369 Bayside Circle","postalCode":"46216","city":"Indianapolis","state":"IN","email":"bmumbey8x@scribd.com"}, -{"id":323,"firstName":"Maxi","lastName":"Jentgens","street":"2970 Rowland Circle","postalCode":"84189","city":"Salt Lake City","state":"UT","phoneNumber":"801-423-8854","email":"mjentgens8y@ihg.com"}, -{"id":324,"firstName":"Florri","lastName":"Okenden","street":"2180 Cody Point","postalCode":"70187","city":"New Orleans","state":"LA","phoneNumber":"504-913-1989","email":"fokenden8z@networksolutions.com"}, -{"id":325,"firstName":"Imogen","lastName":"Grisard","street":"8 Westerfield Avenue","postalCode":"92668","city":"Orange","state":"CA","email":"igrisard90@tamu.edu"}, -{"id":326,"firstName":"Edwina","lastName":"Montes","street":"92 Carpenter Avenue","postalCode":"97216","city":"Portland","state":"OR","phoneNumber":"503-544-7296","email":"emontes91@reference.com"}, -{"id":327,"firstName":"Renelle","lastName":"MacCambridge","street":"77 Talmadge Circle","postalCode":"08638","city":"Trenton","state":"NJ","phoneNumber":"609-150-9438","email":"rmaccambridge92@springer.com"}, -{"id":328,"firstName":"Sterne","lastName":"Taberner","street":"642 6th Terrace","postalCode":"10120","city":"New York City","state":"NY","email":"staberner93@miibeian.gov.cn"}, -{"id":329,"firstName":"Garvy","lastName":"Pankethman","street":"8618 Kennedy Terrace","postalCode":"79405","city":"Lubbock","state":"TX","phoneNumber":"806-470-8784","email":"gpankethman94@free.fr"}, -{"id":330,"firstName":"Nathanil","lastName":"Holston","street":"27247 Eliot Avenue","postalCode":"31190","city":"Atlanta","state":"GA","email":"nholston95@drupal.org"}, -{"id":331,"firstName":"Caresse","lastName":"Kilty","street":"514 Manufacturers Pass","postalCode":"76205","city":"Denton","state":"TX","email":"ckilty96@umich.edu"}, -{"id":332,"firstName":"Arlinda","lastName":"Brenstuhl","street":"2 Sunnyside Avenue","postalCode":"55470","city":"Minneapolis","state":"MN","email":"abrenstuhl97@wisc.edu"}, -{"id":333,"firstName":"Darcy","lastName":"Dunne","street":"3 Badeau Park","postalCode":"91328","city":"Northridge","state":"CA"}, -{"id":334,"firstName":"Malva","lastName":"Grew","street":"2242 Huxley Hill","postalCode":"68510","city":"Lincoln","state":"NE","email":"mgrew99@com.com"}, -{"id":335,"firstName":"Sukey","lastName":"Winspur","street":"475 Melvin Way","postalCode":"68524","city":"Lincoln","state":"NE","phoneNumber":"402-816-9401"}, -{"id":336,"firstName":"Beth","lastName":"O'Dougherty","street":"450 Eastlawn Park","postalCode":"93591","city":"Palmdale","state":"CA","phoneNumber":"661-845-8781"}, -{"id":337,"firstName":"Cortney","lastName":"Meers","street":"9 Chive Drive","postalCode":"93762","city":"Fresno","state":"CA","email":"cmeers9c@diigo.com"}, -{"id":338,"firstName":"Geralda","lastName":"Brocket","street":"0686 La Follette Avenue","postalCode":"80126","city":"Littleton","state":"CO","phoneNumber":"720-641-1371","email":"gbrocket9d@youku.com"}, -{"id":339,"firstName":"Lishe","lastName":"Maliphant","street":"5 Erie Plaza","postalCode":"63169","city":"Saint Louis","state":"MO","email":"lmaliphant9e@sfgate.com"}, -{"id":340,"firstName":"Brod","lastName":"Dobrovsky","street":"9 Gateway Park","postalCode":"79405","city":"Lubbock","state":"TX"}, -{"id":341,"firstName":"Philippe","lastName":"Argile","street":"4 Red Cloud Plaza","postalCode":"49444","city":"Muskegon","state":"MI","phoneNumber":"231-633-5495"}, -{"id":342,"firstName":"Sadye","lastName":"Sally","street":"07 Mendota Terrace","postalCode":"75507","city":"Texarkana","state":"TX","email":"ssally9h@e-recht24.de"}, -{"id":343,"firstName":"Napoleon","lastName":"Piggott","street":"3968 Roxbury Point","postalCode":"35905","city":"Gadsden","state":"AL","email":"npiggott9i@cnbc.com"}, -{"id":344,"firstName":"Jere","lastName":"Larn","street":"5086 Dahle Crossing","postalCode":"39534","city":"Biloxi","state":"MS","email":"jlarn9j@twitter.com"}, -{"id":345,"firstName":"Bevon","lastName":"Stidson","street":"7 Armistice Court","postalCode":"23436","city":"Suffolk","state":"VA","email":"bstidson9k@alexa.com"}, -{"id":346,"firstName":"Drugi","lastName":"Ewbach","street":"6032 5th Avenue","postalCode":"02208","city":"Boston","state":"MA","email":"dewbach9l@techcrunch.com"}, -{"id":347,"firstName":"Milka","lastName":"Caizley","street":"7 Anderson Junction","postalCode":"37228","city":"Nashville","state":"TN","phoneNumber":"615-305-6985","email":"mcaizley9m@cyberchimps.com"}, -{"id":348,"firstName":"Wilton","lastName":"Biagi","street":"80833 6th Crossing","postalCode":"40215","city":"Louisville","state":"KY","email":"wbiagi9n@vinaora.com"}, -{"id":349,"firstName":"Dilly","lastName":"Spradbrow","street":"5 Harbort Street","postalCode":"45419","city":"Dayton","state":"OH","email":"dspradbrow9o@marketwatch.com"}, -{"id":350,"firstName":"Gan","lastName":"Gookey","street":"8387 Bultman Terrace","postalCode":"75241","city":"Dallas","state":"TX"}, -{"id":351,"firstName":"Nanon","lastName":"Mulrenan","street":"47257 Reindahl Drive","postalCode":"22119","city":"Merrifield","state":"VA","phoneNumber":"571-637-8154","email":"nmulrenan9q@godaddy.com"}, -{"id":352,"firstName":"Frederique","lastName":"Watkiss","street":"61 Heath Pass","postalCode":"70124","city":"New Orleans","state":"LA","phoneNumber":"504-891-7051"}, -{"id":353,"firstName":"Sinclare","lastName":"MacCurlye","street":"514 Meadow Ridge Place","postalCode":"97240","city":"Portland","state":"OR","phoneNumber":"971-190-5174","email":"smaccurlye9s@google.ru"}, -{"id":354,"firstName":"Jessie","lastName":"Newlands","street":"80509 Northland Pass","postalCode":"33111","city":"Miami","state":"FL","phoneNumber":"786-557-9193"}, -{"id":355,"firstName":"Jamaal","lastName":"Molder","street":"90 Mcbride Trail","postalCode":"78764","city":"Austin","state":"TX","phoneNumber":"512-320-8728"}, -{"id":356,"firstName":"Benni","lastName":"Sherel","street":"7 Springs Road","postalCode":"15235","city":"Pittsburgh","state":"PA","email":"bsherel9v@hostgator.com"}, -{"id":357,"firstName":"Dene","lastName":"Brigge","street":"8560 Sutteridge Parkway","postalCode":"32412","city":"Panama City","state":"FL"}, -{"id":358,"firstName":"Timoteo","lastName":"Iban","street":"52858 Oak Valley Hill","postalCode":"93750","city":"Fresno","state":"CA","email":"tiban9x@europa.eu"}, -{"id":359,"firstName":"Dar","lastName":"Quillinane","street":"2 Carberry Junction","postalCode":"66276","city":"Shawnee Mission","state":"KS","phoneNumber":"913-977-7562","email":"dquillinane9y@msn.com"}, -{"id":360,"firstName":"Claudian","lastName":"Tinson","street":"445 Novick Avenue","postalCode":"79968","city":"El Paso","state":"TX","email":"ctinson9z@google.cn"}, -{"id":361,"firstName":"Clarice","lastName":"Deneve","street":"94 Meadow Ridge Road","postalCode":"37131","city":"Murfreesboro","state":"TN","phoneNumber":"615-780-7667"}, -{"id":362,"firstName":"Hilary","lastName":"Bithell","street":"20 Russell Trail","postalCode":"81010","city":"Pueblo","state":"CO","email":"hbithella1@list-manage.com"}, -{"id":363,"firstName":"Mathew","lastName":"Scrivin","street":"4 Elgar Point","postalCode":"90081","city":"Los Angeles","state":"CA","phoneNumber":"213-898-6650","email":"mscrivina2@about.me"}, -{"id":364,"firstName":"Idell","lastName":"Rambadt","street":"6 Cherokee Hill","postalCode":"90840","city":"Long Beach","state":"CA","email":"irambadta3@ustream.tv"}, -{"id":365,"firstName":"Nealon","lastName":"Schoolfield","street":"1 Northland Point","postalCode":"74133","city":"Tulsa","state":"OK"}, -{"id":366,"firstName":"Gregorius","lastName":"Bartot","street":"24636 Eagle Crest Crossing","postalCode":"32215","city":"Jacksonville","state":"FL","email":"gbartota5@blogger.com"}, -{"id":367,"firstName":"Inessa","lastName":"Hullin","street":"559 Bartillon Trail","postalCode":"33142","city":"Miami","state":"FL","phoneNumber":"305-381-6621","email":"ihullina6@pcworld.com"}, -{"id":368,"firstName":"Andie","lastName":"Bampford","street":"5204 Meadow Valley Street","postalCode":"92825","city":"Anaheim","state":"CA","email":"abampforda7@sun.com"}, -{"id":369,"firstName":"Duane","lastName":"MacShirrie","street":"5077 Kings Parkway","postalCode":"92725","city":"Santa Ana","state":"CA","email":"dmacshirriea8@rambler.ru"}, -{"id":370,"firstName":"Sydel","lastName":"Deerr","street":"1 Commercial Road","postalCode":"30356","city":"Atlanta","state":"GA","phoneNumber":"404-209-0194","email":"sdeerra9@phpbb.com"}, -{"id":371,"firstName":"Mel","lastName":"Miles","street":"28164 Melody Plaza","postalCode":"90847","city":"Long Beach","state":"CA","phoneNumber":"562-932-1172"}, -{"id":372,"firstName":"Jone","lastName":"Drinkel","street":"946 Reindahl Point","postalCode":"48604","city":"Saginaw","state":"MI","phoneNumber":"989-547-0653"}, -{"id":373,"firstName":"Marcellus","lastName":"MacGilmartin","street":"10568 Westerfield Way","postalCode":"32868","city":"Orlando","state":"FL","phoneNumber":"407-874-6188","email":"mmacgilmartinac@fotki.com"}, -{"id":374,"firstName":"Bret","lastName":"Hardan","street":"9 Hayes Crossing","postalCode":"32309","city":"Tallahassee","state":"FL","email":"bhardanad@mit.edu"}, -{"id":375,"firstName":"Heddie","lastName":"Cesaric","street":"502 Cody Crossing","postalCode":"95397","city":"Modesto","state":"CA"}, -{"id":376,"firstName":"Tansy","lastName":"Maeer","street":"526 Messerschmidt Court","postalCode":"94089","city":"Sunnyvale","state":"CA","email":"tmaeeraf@arizona.edu"}, -{"id":377,"firstName":"Waverly","lastName":"West-Frimley","street":"02 Quincy Trail","postalCode":"20575","city":"Washington","state":"DC","phoneNumber":"202-493-3304","email":"wwestfrimleyag@ft.com"}, -{"id":378,"firstName":"Dido","lastName":"de Clercq","street":"7 Norway Maple Center","postalCode":"84125","city":"Salt Lake City","state":"UT","email":"ddeclercqah@trellian.com"}, -{"id":379,"firstName":"Vic","lastName":"Samuels","street":"2 Kipling Drive","postalCode":"31190","city":"Atlanta","state":"GA","email":"vsamuelsai@goo.gl"}, -{"id":380,"firstName":"Jeno","lastName":"Freiburger","street":"431 Golden Leaf Parkway","postalCode":"32610","city":"Gainesville","state":"FL","email":"jfreiburgeraj@theguardian.com"}, -{"id":381,"firstName":"Christine","lastName":"Basketter","street":"4 Lotheville Terrace","postalCode":"39305","city":"Meridian","state":"MS","phoneNumber":"601-702-1546"}, -{"id":382,"firstName":"Karry","lastName":"Corsan","street":"09189 Lakeland Point","postalCode":"27409","city":"Greensboro","state":"NC","phoneNumber":"336-445-0006","email":"kcorsanal@usgs.gov"}, -{"id":383,"firstName":"Barri","lastName":"Brinsden","street":"53 Shelley Drive","postalCode":"35225","city":"Birmingham","state":"AL","email":"bbrinsdenam@1und1.de"}, -{"id":384,"firstName":"Hyacintha","lastName":"Boddam","street":"45 Sugar Circle","postalCode":"10160","city":"New York City","state":"NY","phoneNumber":"212-794-6062"}, -{"id":385,"firstName":"Brande","lastName":"Remnant","street":"283 Stone Corner Road","postalCode":"31904","city":"Columbus","state":"GA","phoneNumber":"706-211-4851","email":"bremnantao@people.com.cn"}, -{"id":386,"firstName":"Tally","lastName":"Bygraves","street":"54833 Northport Pass","postalCode":"85072","city":"Phoenix","state":"AZ","email":"tbygravesap@jigsy.com"}, -{"id":387,"firstName":"Garfield","lastName":"Pressnell","street":"63077 Hudson Court","postalCode":"30061","city":"Marietta","state":"GA","email":"gpressnellaq@archive.org"}, -{"id":388,"firstName":"Romonda","lastName":"Stiggles","street":"17 Russell Parkway","postalCode":"32627","city":"Gainesville","state":"FL","phoneNumber":"352-600-9676"}, -{"id":389,"firstName":"Dedie","lastName":"Ralling","street":"8 Judy Plaza","postalCode":"94137","city":"San Francisco","state":"CA","email":"drallingas@wikia.com"}, -{"id":390,"firstName":"Maddi","lastName":"Cornau","street":"5 Oriole Way","postalCode":"92105","city":"San Diego","state":"CA","phoneNumber":"619-388-6359","email":"mcornauat@adobe.com"}, -{"id":391,"firstName":"Zeke","lastName":"Jennery","street":"65332 Sommers Avenue","postalCode":"48206","city":"Detroit","state":"MI","email":"zjenneryau@elegantthemes.com"}, -{"id":392,"firstName":"Danya","lastName":"Fairlaw","street":"343 Logan Alley","postalCode":"33111","city":"Miami","state":"FL","email":"dfairlawav@irs.gov"}, -{"id":393,"firstName":"Rabi","lastName":"Petheridge","street":"7 Monica Alley","postalCode":"64054","city":"Independence","state":"MO","phoneNumber":"816-501-9452"}, -{"id":394,"firstName":"Ebba","lastName":"Skellen","street":"2655 Iowa Terrace","postalCode":"63150","city":"Saint Louis","state":"MO","phoneNumber":"314-695-7831","email":"eskellenax@nbcnews.com"}, -{"id":395,"firstName":"Marie-ann","lastName":"Glaysher","street":"4 Lakewood Hill","postalCode":"12247","city":"Albany","state":"NY","phoneNumber":"518-634-2425"}, -{"id":396,"firstName":"Arne","lastName":"Quincey","street":"162 Redwing Way","postalCode":"83711","city":"Boise","state":"ID"}, -{"id":397,"firstName":"Clarita","lastName":"Okroy","street":"05 Delaware Way","postalCode":"45218","city":"Cincinnati","state":"OH","email":"cokroyb0@stumbleupon.com"}, -{"id":398,"firstName":"Renault","lastName":"Weighell","street":"498 Dovetail Place","postalCode":"79710","city":"Midland","state":"TX","phoneNumber":"432-955-1408"}, -{"id":399,"firstName":"Roderich","lastName":"Mankor","street":"07 Dayton Way","postalCode":"92160","city":"San Diego","state":"CA"}, -{"id":400,"firstName":"Arv","lastName":"Sunnex","street":"89 Ronald Regan Terrace","postalCode":"91109","city":"Pasadena","state":"CA","email":"asunnexb3@vkontakte.ru"}, -{"id":401,"firstName":"Sonia","lastName":"Cowperthwaite","street":"77 Dennis Point","postalCode":"16550","city":"Erie","state":"PA"}, -{"id":402,"firstName":"Buddie","lastName":"Goscomb","street":"85675 Eastlawn Pass","postalCode":"20535","city":"Washington","state":"DC"}, -{"id":403,"firstName":"Brandi","lastName":"Swaine","street":"39961 Del Mar Lane","postalCode":"39705","city":"Columbus","state":"MS","phoneNumber":"662-306-2164","email":"bswaineb6@miibeian.gov.cn"}, -{"id":404,"firstName":"Jenny","lastName":"Cabbell","street":"743 Fordem Center","postalCode":"78285","city":"San Antonio","state":"TX","phoneNumber":"210-491-9874","email":"jcabbellb7@techcrunch.com"}, -{"id":405,"firstName":"Vincent","lastName":"People","street":"83 Tennessee Way","postalCode":"77293","city":"Houston","state":"TX","phoneNumber":"281-261-1928","email":"vpeopleb8@github.io"}, -{"id":406,"firstName":"Reinald","lastName":"Roles","street":"2 Division Road","postalCode":"53785","city":"Madison","state":"WI","phoneNumber":"608-568-7958","email":"rrolesb9@google.fr"}, -{"id":407,"firstName":"Kale","lastName":"Wanek","street":"7 Crescent Oaks Terrace","postalCode":"46852","city":"Fort Wayne","state":"IN","phoneNumber":"260-844-9669","email":"kwanekba@scribd.com"}, -{"id":408,"firstName":"Charisse","lastName":"Perse","street":"94449 Gateway Street","postalCode":"91117","city":"Pasadena","state":"CA","email":"cpersebb@ycombinator.com"}, -{"id":409,"firstName":"Konstantin","lastName":"Aslum","street":"08 Kings Trail","postalCode":"80328","city":"Boulder","state":"CO","email":"kaslumbc@opera.com"}, -{"id":410,"firstName":"Tyson","lastName":"O'Hartigan","street":"75122 Crowley Place","postalCode":"95173","city":"San Jose","state":"CA","phoneNumber":"408-879-0901","email":"tohartiganbd@devhub.com"}, -{"id":411,"firstName":"Fallon","lastName":"Haysman","street":"477 High Crossing Place","postalCode":"23293","city":"Richmond","state":"VA"}, -{"id":412,"firstName":"Svend","lastName":"Scarlet","street":"2856 Merrick Circle","postalCode":"90087","city":"Los Angeles","state":"CA","email":"sscarletbf@clickbank.net"}, -{"id":413,"firstName":"Gabey","lastName":"Colter","street":"7 2nd Alley","postalCode":"90610","city":"Whittier","state":"CA"}, -{"id":414,"firstName":"Hart","lastName":"Densell","street":"2687 Elka Alley","postalCode":"99599","city":"Anchorage","state":"AK","phoneNumber":"907-286-6079"}, -{"id":415,"firstName":"Claresta","lastName":"Folger","street":"5 Amoth Alley","postalCode":"27116","city":"Winston Salem","state":"NC"}, -{"id":416,"firstName":"Rica","lastName":"Lightowlers","street":"54303 Mayer Drive","postalCode":"61825","city":"Champaign","state":"IL","email":"rlightowlersbj@so-net.ne.jp"}, -{"id":417,"firstName":"Paula","lastName":"Treadaway","street":"8 Anniversary Road","postalCode":"20456","city":"Washington","state":"DC"}, -{"id":418,"firstName":"Francoise","lastName":"Gooderick","street":"13 Knutson Lane","postalCode":"33325","city":"Fort Lauderdale","state":"FL","email":"fgooderickbl@dedecms.com"}, -{"id":419,"firstName":"Ferdy","lastName":"Nannizzi","street":"578 Esker Trail","postalCode":"25321","city":"Charleston","state":"WV","email":"fnannizzibm@rambler.ru"}, -{"id":420,"firstName":"Dody","lastName":"Gettone","street":"9 Veith Court","postalCode":"62711","city":"Springfield","state":"IL"}, -{"id":421,"firstName":"Ronna","lastName":"Godleman","street":"6 Jenna Trail","postalCode":"22301","city":"Alexandria","state":"VA","email":"rgodlemanbo@hexun.com"}, -{"id":422,"firstName":"Adey","lastName":"Waith","street":"2 Mayer Avenue","postalCode":"12325","city":"Schenectady","state":"NY"}, -{"id":423,"firstName":"Stanislaw","lastName":"Garahan","street":"660 Merry Avenue","postalCode":"62723","city":"Springfield","state":"IL","phoneNumber":"217-587-6734"}, -{"id":424,"firstName":"Westley","lastName":"Knowles","street":"67430 Lakeland Circle","postalCode":"53263","city":"Milwaukee","state":"WI","email":"wknowlesbr@msu.edu"}, -{"id":425,"firstName":"Dion","lastName":"Jamson","street":"696 Birchwood Circle","postalCode":"80015","city":"Aurora","state":"CO","phoneNumber":"720-486-4494"}, -{"id":426,"firstName":"Glynis","lastName":"Bourhill","street":"091 Harper Park","postalCode":"40250","city":"Louisville","state":"KY"}, -{"id":427,"firstName":"Massimo","lastName":"Briand","street":"37 Northview Junction","postalCode":"75507","city":"Texarkana","state":"TX","email":"mbriandbu@etsy.com"}, -{"id":428,"firstName":"Tremayne","lastName":"Cadore","street":"6721 Anthes Point","postalCode":"94605","city":"Oakland","state":"CA","email":"tcadorebv@mozilla.com"}, -{"id":429,"firstName":"Lea","lastName":"Wildman","street":"52 Dixon Point","postalCode":"50310","city":"Des Moines","state":"IA","phoneNumber":"515-536-2096"}, -{"id":430,"firstName":"Ambur","lastName":"Oxlade","street":"356 Porter Center","postalCode":"44485","city":"Warren","state":"OH"}, -{"id":431,"firstName":"Jyoti","lastName":"Gillet","street":"13 Del Mar Parkway","postalCode":"81505","city":"Grand Junction","state":"CO","phoneNumber":"970-598-0357"}, -{"id":432,"firstName":"Sascha","lastName":"Stanyan","street":"77289 Blue Bill Park Alley","postalCode":"06120","city":"Hartford","state":"CT","email":"sstanyanbz@geocities.jp"}, -{"id":433,"firstName":"Spenser","lastName":"Harry","street":"2021 Oak Place","postalCode":"32835","city":"Orlando","state":"FL","email":"sharryc0@privacy.gov.au"}, -{"id":434,"firstName":"Clim","lastName":"Penrose","street":"8 Warrior Road","postalCode":"15255","city":"Pittsburgh","state":"PA","email":"cpenrosec1@blogtalkradio.com"}, -{"id":435,"firstName":"Jewell","lastName":"McKinnon","street":"4 Delladonna Street","postalCode":"36114","city":"Montgomery","state":"AL","email":"jmckinnonc2@tinypic.com"}, -{"id":436,"firstName":"Estrellita","lastName":"Amburgy","street":"5538 Tennessee Plaza","postalCode":"17121","city":"Harrisburg","state":"PA","phoneNumber":"717-274-8930","email":"eamburgyc3@forbes.com"}, -{"id":437,"firstName":"Sarah","lastName":"Fears","street":"61 Springs Park","postalCode":"93034","city":"Oxnard","state":"CA","email":"sfearsc4@wisc.edu"}, -{"id":438,"firstName":"Nixie","lastName":"Peddie","street":"7 Armistice Way","postalCode":"10155","city":"New York City","state":"NY","email":"npeddiec5@free.fr"}, -{"id":439,"firstName":"Ardisj","lastName":"Rohmer","street":"726 Crowley Point","postalCode":"93399","city":"Bakersfield","state":"CA","email":"arohmerc6@google.nl"}, -{"id":440,"firstName":"Wallie","lastName":"Johanssen","street":"9555 Jana Park","postalCode":"28410","city":"Wilmington","state":"NC","phoneNumber":"910-160-4520","email":"wjohanssenc7@boston.com"}, -{"id":441,"firstName":"Allan","lastName":"Jodlkowski","street":"31585 Kedzie Park","postalCode":"89150","city":"Las Vegas","state":"NV","phoneNumber":"702-782-3289","email":"ajodlkowskic8@sogou.com"}, -{"id":442,"firstName":"Harris","lastName":"Cadden","street":"96829 Fieldstone Park","postalCode":"16565","city":"Erie","state":"PA","phoneNumber":"814-745-1099"}, -{"id":443,"firstName":"Nigel","lastName":"Girardengo","street":"24703 Red Cloud Road","postalCode":"90310","city":"Inglewood","state":"CA","email":"ngirardengoca@ow.ly"}, -{"id":444,"firstName":"Aila","lastName":"Tinniswood","street":"62812 Stephen Parkway","postalCode":"13205","city":"Syracuse","state":"NY","phoneNumber":"315-847-2259","email":"atinniswoodcb@google.com.br"}, -{"id":445,"firstName":"Genni","lastName":"Geockle","street":"81 Bobwhite Plaza","postalCode":"93721","city":"Fresno","state":"CA","email":"ggeocklecc@furl.net"}, -{"id":446,"firstName":"Madison","lastName":"Brikner","street":"166 Coolidge Trail","postalCode":"07208","city":"Elizabeth","state":"NJ","email":"mbriknercd@myspace.com"}, -{"id":447,"firstName":"Akim","lastName":"Gotthard.sf","street":"0017 Heffernan Parkway","postalCode":"71914","city":"Hot Springs National Park","state":"AR","email":"agotthardsfce@google.com.au"}, -{"id":448,"firstName":"Andria","lastName":"Cardello","street":"1089 Stang Road","postalCode":"96835","city":"Honolulu","state":"HI","phoneNumber":"808-372-6528"}, -{"id":449,"firstName":"Laureen","lastName":"Crawshaw","street":"13 Manitowish Avenue","postalCode":"23504","city":"Norfolk","state":"VA","phoneNumber":"757-220-4043"}, -{"id":450,"firstName":"Henderson","lastName":"Parmley","street":"3408 Superior Street","postalCode":"28410","city":"Wilmington","state":"NC","email":"hparmleych@diigo.com"}, -{"id":451,"firstName":"Henri","lastName":"Arnley","street":"54 Knutson Park","postalCode":"11470","city":"Jamaica","state":"NY","phoneNumber":"718-365-7389"}, -{"id":452,"firstName":"Phil","lastName":"Trunkfield","street":"07 Arizona Way","postalCode":"85030","city":"Phoenix","state":"AZ","email":"ptrunkfieldcj@cisco.com"}, -{"id":453,"firstName":"Chery","lastName":"Nangle","street":"03 Merrick Way","postalCode":"88569","city":"El Paso","state":"TX","phoneNumber":"915-959-5535","email":"cnangleck@tumblr.com"}, -{"id":454,"firstName":"Leora","lastName":"Fields","street":"0260 Eastlawn Lane","postalCode":"85311","city":"Glendale","state":"AZ","email":"lfieldscl@nyu.edu"}, -{"id":455,"firstName":"Ronnica","lastName":"Pocknoll","street":"786 Hovde Plaza","postalCode":"78410","city":"Corpus Christi","state":"TX","email":"rpocknollcm@unesco.org"}, -{"id":456,"firstName":"Valida","lastName":"Romayn","street":"1108 Hudson Drive","postalCode":"34615","city":"Clearwater","state":"FL","email":"vromayncn@usatoday.com"}, -{"id":457,"firstName":"Randee","lastName":"Strowther","street":"441 Cordelia Point","postalCode":"27710","city":"Durham","state":"NC","phoneNumber":"919-463-1516","email":"rstrowtherco@trellian.com"}, -{"id":458,"firstName":"Ansell","lastName":"Blacklock","street":"9393 Kedzie Point","postalCode":"75358","city":"Dallas","state":"TX","phoneNumber":"214-949-3912"}, -{"id":459,"firstName":"Bailie","lastName":"Wing","street":"79459 Buhler Way","postalCode":"15279","city":"Pittsburgh","state":"PA","phoneNumber":"412-431-5446"}, -{"id":460,"firstName":"Leesa","lastName":"Wellbeloved","street":"4553 Dakota Circle","postalCode":"40215","city":"Louisville","state":"KY","phoneNumber":"502-145-8496","email":"lwellbelovedcr@go.com"}, -{"id":461,"firstName":"Sarge","lastName":"Tocknell","street":"9884 North Alley","postalCode":"80249","city":"Denver","state":"CO","phoneNumber":"303-603-8315","email":"stocknellcs@artisteer.com"}, -{"id":462,"firstName":"Loralyn","lastName":"Grimolbie","street":"3620 Clyde Gallagher Junction","postalCode":"91103","city":"Pasadena","state":"CA","email":"lgrimolbiect@purevolume.com"}, -{"id":463,"firstName":"Ki","lastName":"Youdell","street":"3 Gina Center","postalCode":"81005","city":"Pueblo","state":"CO"}, -{"id":464,"firstName":"Katerine","lastName":"Herreros","street":"70 Westend Place","postalCode":"57105","city":"Sioux Falls","state":"SD"}, -{"id":465,"firstName":"Frasquito","lastName":"Nockolds","street":"21 Dwight Park","postalCode":"11236","city":"Brooklyn","state":"NY","phoneNumber":"917-761-0549"}, -{"id":466,"firstName":"Krystalle","lastName":"Brierly","street":"7797 Forest Dale Lane","postalCode":"90410","city":"Santa Monica","state":"CA","email":"kbrierlycx@simplemachines.org"}, -{"id":467,"firstName":"Tobin","lastName":"Guillford","street":"501 Messerschmidt Alley","postalCode":"98195","city":"Seattle","state":"WA","phoneNumber":"206-862-7413","email":"tguillfordcy@fastcompany.com"}, -{"id":468,"firstName":"Lorita","lastName":"Sikorski","street":"83 Corscot Junction","postalCode":"44905","city":"Mansfield","state":"OH","phoneNumber":"419-278-2324","email":"lsikorskicz@intel.com"}, -{"id":469,"firstName":"Hermon","lastName":"Chomley","street":"696 Talisman Lane","postalCode":"35290","city":"Birmingham","state":"AL"}, -{"id":470,"firstName":"Karolina","lastName":"Andrault","street":"49738 Maple Wood Place","postalCode":"99709","city":"Fairbanks","state":"AK","phoneNumber":"907-337-1698","email":"kandraultd1@bloglines.com"}, -{"id":471,"firstName":"Lev","lastName":"Pankhurst.","street":"442 Pennsylvania Crossing","postalCode":"23605","city":"Newport News","state":"VA","phoneNumber":"757-832-3631"}, -{"id":472,"firstName":"Bianca","lastName":"Garfath","street":"7 Forest Run Center","postalCode":"71914","city":"Hot Springs National Park","state":"AR","email":"bgarfathd3@youku.com"}, -{"id":473,"firstName":"Walden","lastName":"Van der Linde","street":"6 Namekagon Parkway","postalCode":"70187","city":"New Orleans","state":"LA","email":"wvanderlinded4@netscape.com"}, -{"id":474,"firstName":"Alexandra","lastName":"Vasyukhin","street":"471 School Alley","postalCode":"80910","city":"Colorado Springs","state":"CO","email":"avasyukhind5@samsung.com"}, -{"id":475,"firstName":"Perry","lastName":"Spere","street":"33 Autumn Leaf Street","postalCode":"79994","city":"El Paso","state":"TX","email":"pspered6@tamu.edu"}, -{"id":476,"firstName":"Cristobal","lastName":"Afonso","street":"5 Lake View Way","postalCode":"19136","city":"Philadelphia","state":"PA","email":"cafonsod7@themeforest.net"}, -{"id":477,"firstName":"Sebastien","lastName":"Annets","street":"4229 Bowman Trail","postalCode":"43699","city":"Toledo","state":"OH","phoneNumber":"419-981-8630","email":"sannetsd8@guardian.co.uk"}, -{"id":478,"firstName":"Prentice","lastName":"Desorts","street":"54 Mendota Drive","postalCode":"31196","city":"Atlanta","state":"GA","phoneNumber":"404-235-6736","email":"pdesortsd9@who.int"}, -{"id":479,"firstName":"Rubin","lastName":"Dunkerk","street":"035 Myrtle Park","postalCode":"94297","city":"Sacramento","state":"CA","phoneNumber":"916-658-2157","email":"rdunkerkda@columbia.edu"}, -{"id":480,"firstName":"Jesselyn","lastName":"Bidnall","street":"2353 Norway Maple Court","postalCode":"07522","city":"Paterson","state":"NJ","email":"jbidnalldb@4shared.com"}, -{"id":481,"firstName":"Arleta","lastName":"Massy","street":"2 Bluejay Lane","postalCode":"10310","city":"Staten Island","state":"NY"}, -{"id":482,"firstName":"Trescha","lastName":"Joncic","street":"052 Summit Way","postalCode":"13217","city":"Syracuse","state":"NY"}, -{"id":483,"firstName":"Joshuah","lastName":"Galbreth","street":"16 Elka Place","postalCode":"08922","city":"New Brunswick","state":"NJ","email":"jgalbrethde@rambler.ru"}, -{"id":484,"firstName":"Clywd","lastName":"Henlon","street":"26 Thackeray Pass","postalCode":"90040","city":"Los Angeles","state":"CA","email":"chenlondf@unesco.org"}, -{"id":485,"firstName":"Glenda","lastName":"Grayley","street":"6326 Ohio Plaza","postalCode":"91411","city":"Van Nuys","state":"CA"}, -{"id":486,"firstName":"Glynda","lastName":"Stokell","street":"6 Schmedeman Court","postalCode":"60641","city":"Chicago","state":"IL","email":"gstokelldh@ted.com"}, -{"id":487,"firstName":"Kath","lastName":"Harrap","street":"43769 Barby Plaza","postalCode":"32304","city":"Tallahassee","state":"FL","email":"kharrapdi@cargocollective.com"}, -{"id":488,"firstName":"Dickie","lastName":"Domotor","street":"2954 Toban Lane","postalCode":"98133","city":"Seattle","state":"WA","email":"ddomotordj@hhs.gov"}, -{"id":489,"firstName":"Ceciley","lastName":"Hitzke","street":"9102 Westport Pass","postalCode":"40618","city":"Frankfort","state":"KY","phoneNumber":"502-545-5506","email":"chitzkedk@newsvine.com"}, -{"id":490,"firstName":"Adler","lastName":"Webb-Bowen","street":"5 Hanover Street","postalCode":"32123","city":"Daytona Beach","state":"FL"}, -{"id":491,"firstName":"Fergus","lastName":"Domerq","street":"06 Hansons Road","postalCode":"58106","city":"Fargo","state":"ND","phoneNumber":"701-656-3778"}, -{"id":492,"firstName":"Kimbra","lastName":"Petherick","street":"867 Mayer Drive","postalCode":"39236","city":"Jackson","state":"MS"}, -{"id":493,"firstName":"Geneva","lastName":"Hobgen","street":"74 Vernon Parkway","postalCode":"53710","city":"Madison","state":"WI","email":"ghobgendo@google.de"}, -{"id":494,"firstName":"Jillane","lastName":"Skitral","street":"9747 Ruskin Point","postalCode":"22405","city":"Fredericksburg","state":"VA","email":"jskitraldp@mysql.com"}, -{"id":495,"firstName":"Carolin","lastName":"Pimblotte","street":"8 Union Way","postalCode":"75358","city":"Dallas","state":"TX","phoneNumber":"214-109-7114","email":"cpimblottedq@cargocollective.com"}, -{"id":496,"firstName":"Wandis","lastName":"Andreasson","street":"3 Nancy Parkway","postalCode":"70033","city":"Metairie","state":"LA","email":"wandreassondr@topsy.com"}, -{"id":497,"firstName":"Baily","lastName":"Dalliston","street":"602 Melrose Way","postalCode":"25331","city":"Charleston","state":"WV","email":"bdallistonds@storify.com"}, -{"id":498,"firstName":"Kissie","lastName":"Lammiman","street":"4 Memorial Terrace","postalCode":"06510","city":"New Haven","state":"CT","phoneNumber":"203-724-3731","email":"klammimandt@barnesandnoble.com"}, -{"id":499,"firstName":"Cloris","lastName":"Dorning","street":"4 Lien Road","postalCode":"37235","city":"Nashville","state":"TN","email":"cdorningdu@unesco.org"}, -{"id":500,"firstName":"Jemimah","lastName":"Juppe","street":"979 Tennessee Pass","postalCode":"85305","city":"Glendale","state":"AZ"}, -{"id":501,"firstName":"Fanchette","lastName":"Marlor","street":"90 Waywood Circle","postalCode":"44511","city":"Youngstown","state":"OH","email":"fmarlordw@is.gd"}, -{"id":502,"firstName":"Carmelle","lastName":"Stillmann","street":"9124 Sachtjen Way","postalCode":"74184","city":"Tulsa","state":"OK","email":"cstillmanndx@telegraph.co.uk"}, -{"id":503,"firstName":"Joelle","lastName":"Mumford","street":"5 Susan Point","postalCode":"28410","city":"Wilmington","state":"NC","email":"jmumforddy@yellowbook.com"}, -{"id":504,"firstName":"Vicky","lastName":"Danzelman","street":"472 Pond Junction","postalCode":"11220","city":"Brooklyn","state":"NY","email":"vdanzelmandz@stumbleupon.com"}, -{"id":505,"firstName":"Baudoin","lastName":"Grenshiels","street":"4703 Tony Circle","postalCode":"76198","city":"Fort Worth","state":"TX","email":"bgrenshielse0@devhub.com"}, -{"id":506,"firstName":"Rosetta","lastName":"Wennington","street":"3 Kensington Crossing","postalCode":"14619","city":"Rochester","state":"NY"}, -{"id":507,"firstName":"Eudora","lastName":"Murtell","street":"97 Mockingbird Circle","postalCode":"92867","city":"Orange","state":"CA","phoneNumber":"949-899-3967"}, -{"id":508,"firstName":"Sonnie","lastName":"Hawkin","street":"76669 Green Ridge Crossing","postalCode":"79491","city":"Lubbock","state":"TX","email":"shawkine3@wikia.com"}, -{"id":509,"firstName":"Ulysses","lastName":"Uman","street":"4 Fieldstone Circle","postalCode":"32128","city":"Daytona Beach","state":"FL","phoneNumber":"386-761-6071","email":"uumane4@multiply.com"}, -{"id":510,"firstName":"Alidia","lastName":"Kowalski","street":"3915 Harper Plaza","postalCode":"75221","city":"Dallas","state":"TX","email":"akowalskie5@simplemachines.org"}, -{"id":511,"firstName":"Willis","lastName":"Jeaneau","street":"8 Northport Center","postalCode":"37939","city":"Knoxville","state":"TN","phoneNumber":"865-336-2729","email":"wjeaneaue6@furl.net"}, -{"id":512,"firstName":"Clement","lastName":"Taudevin","street":"25062 Amoth Pass","postalCode":"31914","city":"Columbus","state":"GA","email":"ctaudevine7@mapquest.com"}, -{"id":513,"firstName":"Tally","lastName":"Arnatt","street":"5745 Nancy Terrace","postalCode":"95054","city":"Santa Clara","state":"CA","email":"tarnatte8@umich.edu"}, -{"id":514,"firstName":"Eldon","lastName":"Munnings","street":"17 Dayton Parkway","postalCode":"27690","city":"Raleigh","state":"NC","email":"emunningse9@gmpg.org"}, -{"id":515,"firstName":"Duffie","lastName":"Sibary","street":"840 Springview Avenue","postalCode":"48275","city":"Detroit","state":"MI","email":"dsibaryea@livejournal.com"}, -{"id":516,"firstName":"Winny","lastName":"Dobell","street":"0426 Lindbergh Street","postalCode":"81015","city":"Pueblo","state":"CO","phoneNumber":"719-882-3553","email":"wdobelleb@bizjournals.com"}, -{"id":517,"firstName":"Pancho","lastName":"Pointon","street":"79 Clyde Gallagher Park","postalCode":"97306","city":"Salem","state":"OR","phoneNumber":"503-151-2205"}, -{"id":518,"firstName":"Elston","lastName":"Warwicker","street":"96 Schmedeman Park","postalCode":"44705","city":"Canton","state":"OH","email":"ewarwickered@arstechnica.com"}, -{"id":519,"firstName":"Nicolle","lastName":"Shellcross","street":"23982 Cambridge Parkway","postalCode":"80940","city":"Colorado Springs","state":"CO","email":"nshellcrossee@hibu.com"}, -{"id":520,"firstName":"Bethanne","lastName":"Briggdale","street":"026 Portage Circle","postalCode":"43215","city":"Columbus","state":"OH","phoneNumber":"513-925-3139","email":"bbriggdaleef@flickr.com"}, -{"id":521,"firstName":"Elsey","lastName":"McCorry","street":"781 International Parkway","postalCode":"94286","city":"Sacramento","state":"CA","phoneNumber":"916-879-2104","email":"emccorryeg@sakura.ne.jp"}, -{"id":522,"firstName":"Abran","lastName":"Vasyuchov","street":"64 Grim Place","postalCode":"44177","city":"Cleveland","state":"OH"}, -{"id":523,"firstName":"Rhoda","lastName":"Grieveson","street":"50687 Towne Pass","postalCode":"11220","city":"Brooklyn","state":"NY","email":"rgrievesonei@mit.edu"}, -{"id":524,"firstName":"Florette","lastName":"Eke","street":"85057 Anzinger Lane","postalCode":"66225","city":"Shawnee Mission","state":"KS","phoneNumber":"913-299-0032","email":"fekeej@fema.gov"}, -{"id":525,"firstName":"Sheff","lastName":"Baigrie","street":"80366 Lawn Hill","postalCode":"02203","city":"Boston","state":"MA","phoneNumber":"617-556-4978","email":"sbaigrieek@aboutads.info"}, -{"id":526,"firstName":"Clarisse","lastName":"Hubbuck","street":"435 Truax Trail","postalCode":"02458","city":"Newton","state":"MA","phoneNumber":"781-641-2937"}, -{"id":527,"firstName":"Gilberte","lastName":"Yanele","street":"413 Glacier Hill Park","postalCode":"90610","city":"Whittier","state":"CA","phoneNumber":"562-451-1686","email":"gyaneleem@dot.gov"}, -{"id":528,"firstName":"Lefty","lastName":"Dufore","street":"957 Straubel Street","postalCode":"35220","city":"Birmingham","state":"AL","email":"lduforeen@slideshare.net"}, -{"id":529,"firstName":"Saul","lastName":"Shepperd","street":"44805 Sunnyside Place","postalCode":"32627","city":"Gainesville","state":"FL","phoneNumber":"352-904-7271"}, -{"id":530,"firstName":"Hadrian","lastName":"Cockhill","street":"479 Mayer Way","postalCode":"22119","city":"Merrifield","state":"VA","email":"hcockhillep@xrea.com"}, -{"id":531,"firstName":"Amalia","lastName":"Geare","street":"63075 Glendale Trail","postalCode":"90065","city":"Los Angeles","state":"CA","email":"ageareeq@vistaprint.com"}, -{"id":532,"firstName":"Adan","lastName":"Ibbeson","street":"5 Cambridge Lane","postalCode":"73142","city":"Oklahoma City","state":"OK"}, -{"id":533,"firstName":"Nicol","lastName":"Garbutt","street":"3 8th Street","postalCode":"50393","city":"Des Moines","state":"IA","phoneNumber":"515-946-8077"}, -{"id":534,"firstName":"Lilas","lastName":"Estcot","street":"1927 Mitchell Avenue","postalCode":"75185","city":"Mesquite","state":"TX","email":"lestcotet@ezinearticles.com"}, -{"id":535,"firstName":"Valina","lastName":"Dellenbrok","street":"1 Victoria Hill","postalCode":"45249","city":"Cincinnati","state":"OH","phoneNumber":"513-958-5055","email":"vdellenbrokeu@upenn.edu"}, -{"id":536,"firstName":"Gwen","lastName":"Harwell","street":"64275 Bartelt Terrace","postalCode":"93721","city":"Fresno","state":"CA"}, -{"id":537,"firstName":"Adriena","lastName":"Lochead","street":"0088 Hintze Point","postalCode":"43231","city":"Columbus","state":"OH","phoneNumber":"614-506-5616","email":"alocheadew@paypal.com"}, -{"id":538,"firstName":"Jacobo","lastName":"Jills","street":"809 Anderson Park","postalCode":"55557","city":"Young America","state":"MN","phoneNumber":"952-580-6574","email":"jjillsex@xing.com"}, -{"id":539,"firstName":"Saree","lastName":"Jeanequin","street":"0212 Clyde Gallagher Alley","postalCode":"32891","city":"Orlando","state":"FL","email":"sjeanequiney@who.int"}, -{"id":540,"firstName":"Kin","lastName":"Dewar","street":"3 Emmet Center","postalCode":"20244","city":"Washington","state":"DC","email":"kdewarez@discovery.com"}, -{"id":541,"firstName":"Kaleena","lastName":"Godfray","street":"4350 Eliot Parkway","postalCode":"76134","city":"Fort Worth","state":"TX","phoneNumber":"817-332-6412","email":"kgodfrayf0@webmd.com"}, -{"id":542,"firstName":"Wallace","lastName":"Poytres","street":"78157 Dovetail Crossing","postalCode":"14683","city":"Rochester","state":"NY","email":"wpoytresf1@springer.com"}, -{"id":543,"firstName":"Dur","lastName":"Burgise","street":"2 Weeping Birch Court","postalCode":"89130","city":"Las Vegas","state":"NV"}, -{"id":544,"firstName":"Sheridan","lastName":"Gardiner","street":"26 Gateway Crossing","postalCode":"64193","city":"Kansas City","state":"MO","phoneNumber":"816-647-4434","email":"sgardinerf3@jugem.jp"}, -{"id":545,"firstName":"Nickolaus","lastName":"Thomassen","street":"130 Anderson Drive","postalCode":"33330","city":"Fort Lauderdale","state":"FL","phoneNumber":"954-339-0290"}, -{"id":546,"firstName":"Boris","lastName":"Cortez","street":"55 Center Court","postalCode":"10184","city":"New York City","state":"NY","phoneNumber":"212-549-8414","email":"bcortezf5@mail.ru"}, -{"id":547,"firstName":"Candra","lastName":"Codner","street":"24078 Superior Point","postalCode":"93715","city":"Fresno","state":"CA","phoneNumber":"209-495-8135"}, -{"id":548,"firstName":"Ashton","lastName":"Hugin","street":"33 Fuller Place","postalCode":"63143","city":"Saint Louis","state":"MO"}, -{"id":549,"firstName":"Miguelita","lastName":"Lanceley","street":"34877 Arizona Street","postalCode":"80045","city":"Aurora","state":"CO","email":"mlanceleyf8@trellian.com"}, -{"id":550,"firstName":"Law","lastName":"Skim","street":"1795 Farmco Street","postalCode":"28230","city":"Charlotte","state":"NC","email":"lskimf9@bravesites.com"}, -{"id":551,"firstName":"Carlita","lastName":"Kindall","street":"7 Scofield Road","postalCode":"93709","city":"Fresno","state":"CA","email":"ckindallfa@zimbio.com"}, -{"id":552,"firstName":"Mehetabel","lastName":"Stawell","street":"648 Upham Plaza","postalCode":"75277","city":"Dallas","state":"TX","phoneNumber":"214-597-5958","email":"mstawellfb@ehow.com"}, -{"id":553,"firstName":"Charlena","lastName":"MacAlpyne","street":"2 Village Terrace","postalCode":"33758","city":"Clearwater","state":"FL","phoneNumber":"813-452-9764","email":"cmacalpynefc@xinhuanet.com"}, -{"id":554,"firstName":"Gayel","lastName":"Litel","street":"34782 Birchwood Road","postalCode":"46406","city":"Gary","state":"IN","phoneNumber":"219-156-8377","email":"glitelfd@alibaba.com"}, -{"id":555,"firstName":"Prisca","lastName":"Kanzler","street":"67 Miller Terrace","postalCode":"08619","city":"Trenton","state":"NJ","phoneNumber":"609-352-4487"}, -{"id":556,"firstName":"Marlowe","lastName":"Idenden","street":"396 Beilfuss Park","postalCode":"74103","city":"Tulsa","state":"OK","phoneNumber":"918-254-3102"}, -{"id":557,"firstName":"Ashley","lastName":"Skule","street":"2327 Valley Edge Terrace","postalCode":"93794","city":"Fresno","state":"CA","phoneNumber":"559-558-9123"}, -{"id":558,"firstName":"Trista","lastName":"Naptine","street":"646 Dahle Court","postalCode":"06538","city":"New Haven","state":"CT","phoneNumber":"203-257-3017","email":"tnaptinefh@hugedomains.com"}, -{"id":559,"firstName":"Hasheem","lastName":"Ottery","street":"004 Clemons Street","postalCode":"28815","city":"Asheville","state":"NC","phoneNumber":"828-768-3824","email":"hotteryfi@gmpg.org"}, -{"id":560,"firstName":"Alisa","lastName":"Bernhardt","street":"49 Cody Center","postalCode":"84120","city":"Salt Lake City","state":"UT","phoneNumber":"801-808-4005","email":"abernhardtfj@census.gov"}, -{"id":561,"firstName":"Isadora","lastName":"Hatchett","street":"78644 Hoepker Junction","postalCode":"77015","city":"Houston","state":"TX","email":"ihatchettfk@spiegel.de"}, -{"id":562,"firstName":"Valdemar","lastName":"Stithe","street":"75 East Street","postalCode":"48206","city":"Detroit","state":"MI","email":"vstithefl@marriott.com"}, -{"id":563,"firstName":"Elden","lastName":"Rebert","street":"2 Florence Place","postalCode":"65110","city":"Jefferson City","state":"MO","phoneNumber":"573-753-8030"}, -{"id":564,"firstName":"Stormie","lastName":"Trewartha","street":"59 Shoshone Lane","postalCode":"19136","city":"Philadelphia","state":"PA","phoneNumber":"215-466-6832"}, -{"id":565,"firstName":"Bernhard","lastName":"Boulsher","street":"50888 Dwight Drive","postalCode":"02114","city":"Boston","state":"MA","email":"bboulsherfo@zdnet.com"}, -{"id":566,"firstName":"Twyla","lastName":"Yerrill","street":"526 Clove Terrace","postalCode":"40745","city":"London","state":"KY","email":"tyerrillfp@smugmug.com"}, -{"id":567,"firstName":"Sullivan","lastName":"Dudeney","street":"953 Swallow Crossing","postalCode":"19160","city":"Philadelphia","state":"PA","email":"sdudeneyfq@kickstarter.com"}, -{"id":568,"firstName":"Estell","lastName":"Kiggel","street":"8170 Rusk Alley","postalCode":"20442","city":"Washington","state":"DC","phoneNumber":"202-645-5828","email":"ekiggelfr@imgur.com"}, -{"id":569,"firstName":"Jonis","lastName":"Pymer","street":"21296 International Pass","postalCode":"77844","city":"College Station","state":"TX","email":"jpymerfs@nymag.com"}, -{"id":570,"firstName":"Linea","lastName":"Cranmor","street":"2541 Thackeray Hill","postalCode":"31210","city":"Macon","state":"GA"}, -{"id":571,"firstName":"Starlin","lastName":"Reven","street":"7692 Mifflin Hill","postalCode":"66611","city":"Topeka","state":"KS","email":"srevenfu@nba.com"}, -{"id":572,"firstName":"Augusta","lastName":"Heustice","street":"947 Ramsey Lane","postalCode":"10292","city":"New York City","state":"NY","phoneNumber":"212-194-3346","email":"aheusticefv@cloudflare.com"}, -{"id":573,"firstName":"Glen","lastName":"O'Mailey","street":"90 6th Court","postalCode":"33982","city":"Punta Gorda","state":"FL","phoneNumber":"941-381-2231"}, -{"id":574,"firstName":"Astrix","lastName":"Bister","street":"505 Artisan Crossing","postalCode":"23324","city":"Chesapeake","state":"VA","phoneNumber":"757-469-4444","email":"abisterfx@uol.com.br"}, -{"id":575,"firstName":"Shaw","lastName":"Lidbetter","street":"70 New Castle Trail","postalCode":"10474","city":"Bronx","state":"NY","phoneNumber":"917-917-9173"}, -{"id":576,"firstName":"Yovonnda","lastName":"Wych","street":"97472 Derek Drive","postalCode":"90410","city":"Santa Monica","state":"CA","email":"ywychfz@symantec.com"}, -{"id":577,"firstName":"Harcourt","lastName":"Faier","street":"056 Northridge Street","postalCode":"16510","city":"Erie","state":"PA","email":"hfaierg0@cloudflare.com"}, -{"id":578,"firstName":"Archibold","lastName":"Kos","street":"6 Forster Park","postalCode":"63104","city":"Saint Louis","state":"MO","phoneNumber":"314-967-5566","email":"akosg1@soup.io"}, -{"id":579,"firstName":"Nataniel","lastName":"Beldom","street":"1 Sullivan Street","postalCode":"02453","city":"Waltham","state":"MA","email":"nbeldomg2@alibaba.com"}, -{"id":580,"firstName":"Felisha","lastName":"Bamfield","street":"970 Washington Avenue","postalCode":"12305","city":"Schenectady","state":"NY","email":"fbamfieldg3@jimdo.com"}, -{"id":581,"firstName":"Colly","lastName":"Rugge","street":"8 Golf Course Avenue","postalCode":"55172","city":"Saint Paul","state":"MN","phoneNumber":"651-450-9347","email":"cruggeg4@tmall.com"}, -{"id":582,"firstName":"Patti","lastName":"Maddrell","street":"0483 Coolidge Drive","postalCode":"74193","city":"Tulsa","state":"OK"}, -{"id":583,"firstName":"Antin","lastName":"Gabbetis","street":"93510 Clemons Drive","postalCode":"68583","city":"Lincoln","state":"NE","email":"agabbetisg6@java.com"}, -{"id":584,"firstName":"Bree","lastName":"Million","street":"3 Columbus Avenue","postalCode":"61614","city":"Peoria","state":"IL","phoneNumber":"309-360-1909","email":"bmilliong7@gnu.org"}, -{"id":585,"firstName":"Taber","lastName":"Lorait","street":"4 Melrose Way","postalCode":"62764","city":"Springfield","state":"IL","phoneNumber":"217-436-2021","email":"tloraitg8@cargocollective.com"}, -{"id":586,"firstName":"Roley","lastName":"Di Carlo","street":"981 Bowman Center","postalCode":"87505","city":"Santa Fe","state":"NM"}, -{"id":587,"firstName":"Seline","lastName":"Oxenham","street":"65051 Forest Run Center","postalCode":"94064","city":"Redwood City","state":"CA","email":"soxenhamga@fastcompany.com"}, -{"id":588,"firstName":"Costa","lastName":"Tomblin","street":"7 Arapahoe Alley","postalCode":"33315","city":"Fort Lauderdale","state":"FL","phoneNumber":"954-239-1335"}, -{"id":589,"firstName":"Opalina","lastName":"Cake","street":"88 Commercial Avenue","postalCode":"40215","city":"Louisville","state":"KY","email":"ocakegc@examiner.com"}, -{"id":590,"firstName":"Suzanne","lastName":"Giuroni","street":"73 Twin Pines Terrace","postalCode":"99260","city":"Spokane","state":"WA"}, -{"id":591,"firstName":"Faustine","lastName":"Croysdale","street":"01 Delladonna Point","postalCode":"48295","city":"Detroit","state":"MI"}, -{"id":592,"firstName":"Sheffie","lastName":"Aldine","street":"4 Hansons Junction","postalCode":"74108","city":"Tulsa","state":"OK"}, -{"id":593,"firstName":"Bret","lastName":"Birrane","street":"745 Mayer Junction","postalCode":"77030","city":"Houston","state":"TX","phoneNumber":"832-374-7571","email":"bbirranegg@opera.com"}, -{"id":594,"firstName":"Lennard","lastName":"Mowbury","street":"5 Dwight Road","postalCode":"94522","city":"Concord","state":"CA","email":"lmowburygh@1und1.de"}, -{"id":595,"firstName":"Albie","lastName":"Pert","street":"23705 Fieldstone Plaza","postalCode":"08922","city":"New Brunswick","state":"NJ","phoneNumber":"732-587-7312","email":"apertgi@netlog.com"}, -{"id":596,"firstName":"Stevie","lastName":"Pressnell","street":"0077 Ronald Regan Point","postalCode":"85020","city":"Phoenix","state":"AZ","phoneNumber":"623-991-0482","email":"spressnellgj@skype.com"}, -{"id":597,"firstName":"Eddy","lastName":"McIlreavy","street":"04 Luster Lane","postalCode":"94126","city":"San Francisco","state":"CA"}, -{"id":598,"firstName":"Webb","lastName":"Titterell","street":"94323 Kedzie Alley","postalCode":"91505","city":"Burbank","state":"CA","phoneNumber":"818-220-9105","email":"wtitterellgl@bandcamp.com"}, -{"id":599,"firstName":"Jeffrey","lastName":"Benito","street":"7487 Scott Lane","postalCode":"11470","city":"Jamaica","state":"NY","phoneNumber":"917-379-2592","email":"jbenitogm@deviantart.com"}, -{"id":600,"firstName":"Nollie","lastName":"Arsey","street":"7282 Summerview Plaza","postalCode":"55811","city":"Duluth","state":"MN","email":"narseygn@imageshack.us"}, -{"id":601,"firstName":"Petra","lastName":"Turpey","street":"43920 Evergreen Junction","postalCode":"77255","city":"Houston","state":"TX","phoneNumber":"713-446-0144"}, -{"id":602,"firstName":"Harwilll","lastName":"Lashbrook","street":"8063 Grasskamp Parkway","postalCode":"27621","city":"Raleigh","state":"NC","phoneNumber":"919-142-9887","email":"hlashbrookgp@seattletimes.com"}, -{"id":603,"firstName":"Tedman","lastName":"Steinor","street":"80230 Hanson Hill","postalCode":"47134","city":"Jeffersonville","state":"IN","email":"tsteinorgq@dmoz.org"}, -{"id":604,"firstName":"Georgette","lastName":"Tupper","street":"37 Lillian Avenue","postalCode":"33543","city":"Zephyrhills","state":"FL","phoneNumber":"813-743-2425","email":"gtuppergr@qq.com"}, -{"id":605,"firstName":"Torrance","lastName":"Welsh","street":"95802 Doe Crossing Crossing","postalCode":"13217","city":"Syracuse","state":"NY","phoneNumber":"315-145-4503","email":"twelshgs@imgur.com"}, -{"id":606,"firstName":"Silvie","lastName":"Souster","street":"52827 Fuller Place","postalCode":"99709","city":"Fairbanks","state":"AK"}, -{"id":607,"firstName":"Pauline","lastName":"Dulwitch","street":"8 Aberg Drive","postalCode":"17105","city":"Harrisburg","state":"PA","phoneNumber":"717-228-4960","email":"pdulwitchgu@aboutads.info"}, -{"id":608,"firstName":"Roberta","lastName":"Castanie","street":"182 Mosinee Avenue","postalCode":"75185","city":"Mesquite","state":"TX"}, -{"id":609,"firstName":"Percival","lastName":"Kristoffersen","street":"4 Del Mar Park","postalCode":"48335","city":"Farmington","state":"MI","phoneNumber":"248-438-1650","email":"pkristoffersengw@chron.com"}, -{"id":610,"firstName":"Caryl","lastName":"Boame","street":"094 Springview Avenue","postalCode":"78255","city":"San Antonio","state":"TX","email":"cboamegx@example.com"}, -{"id":611,"firstName":"Steve","lastName":"Simakov","street":"323 Brickson Park Trail","postalCode":"32244","city":"Jacksonville","state":"FL","phoneNumber":"904-468-9377","email":"ssimakovgy@angelfire.com"}, -{"id":612,"firstName":"Carl","lastName":"Tumayan","street":"93854 Clyde Gallagher Circle","postalCode":"98447","city":"Tacoma","state":"WA","email":"ctumayangz@1und1.de"}, -{"id":613,"firstName":"Gayle","lastName":"Blaker","street":"5930 Grasskamp Drive","postalCode":"12262","city":"Albany","state":"NY","email":"gblakerh0@spiegel.de"}, -{"id":614,"firstName":"Darrick","lastName":"Harefoot","street":"359 Waywood Trail","postalCode":"20189","city":"Dulles","state":"VA"}, -{"id":615,"firstName":"Sayer","lastName":"Eversfield","street":"86 Park Meadow Crossing","postalCode":"53263","city":"Milwaukee","state":"WI","email":"seversfieldh2@multiply.com"}, -{"id":616,"firstName":"Loralyn","lastName":"Poyner","street":"28530 Magdeline Crossing","postalCode":"84125","city":"Salt Lake City","state":"UT","phoneNumber":"801-363-2593"}, -{"id":617,"firstName":"Petrina","lastName":"Ridewood","street":"91782 Oriole Parkway","postalCode":"80235","city":"Denver","state":"CO","phoneNumber":"720-131-3660","email":"pridewoodh4@walmart.com"}, -{"id":618,"firstName":"Leroi","lastName":"Marde","street":"7992 Prairieview Junction","postalCode":"02142","city":"Cambridge","state":"MA","phoneNumber":"781-623-9420","email":"lmardeh5@oracle.com"}, -{"id":619,"firstName":"Brannon","lastName":"Janata","street":"79706 Wayridge Alley","postalCode":"24515","city":"Lynchburg","state":"VA","phoneNumber":"434-255-0721"}, -{"id":620,"firstName":"Berry","lastName":"Joska","street":"301 6th Alley","postalCode":"10150","city":"New York City","state":"NY","email":"bjoskah7@360.cn"}, -{"id":621,"firstName":"Blinnie","lastName":"Basten","street":"047 Canary Parkway","postalCode":"30343","city":"Atlanta","state":"GA","phoneNumber":"404-794-2760"}, -{"id":622,"firstName":"Inesita","lastName":"Abbitt","street":"8 Sachtjen Plaza","postalCode":"60681","city":"Chicago","state":"IL"}, -{"id":623,"firstName":"Nickie","lastName":"Ellicombe","street":"1067 Ridge Oak Terrace","postalCode":"38131","city":"Memphis","state":"TN","phoneNumber":"901-695-3826","email":"nellicombeha@imgur.com"}, -{"id":624,"firstName":"Barney","lastName":"Sheeres","street":"1 Rutledge Avenue","postalCode":"29208","city":"Columbia","state":"SC","phoneNumber":"803-166-1398"}, -{"id":625,"firstName":"Ogdan","lastName":"Lelievre","street":"27 Weeping Birch Plaza","postalCode":"27264","city":"High Point","state":"NC","phoneNumber":"336-416-3966","email":"olelievrehc@exblog.jp"}, -{"id":626,"firstName":"Zora","lastName":"Exter","street":"7 Ronald Regan Pass","postalCode":"33673","city":"Tampa","state":"FL"}, -{"id":627,"firstName":"Travus","lastName":"Jaulme","street":"3159 Montana Circle","postalCode":"79176","city":"Amarillo","state":"TX","phoneNumber":"806-894-9411"}, -{"id":628,"firstName":"Krishna","lastName":"Beckingham","street":"58 Fair Oaks Lane","postalCode":"30311","city":"Atlanta","state":"GA","email":"kbeckinghamhf@usnews.com"}, -{"id":629,"firstName":"Bartolomeo","lastName":"Bosanko","street":"753 Victoria Place","postalCode":"79699","city":"Abilene","state":"TX","phoneNumber":"325-223-9615","email":"bbosankohg@merriam-webster.com"}, -{"id":630,"firstName":"Umberto","lastName":"McGinly","street":"30 Upham Parkway","postalCode":"80945","city":"Colorado Springs","state":"CO","email":"umcginlyhh@cdc.gov"}, -{"id":631,"firstName":"Launce","lastName":"Fatkin","street":"03246 Esch Place","postalCode":"53779","city":"Madison","state":"WI","phoneNumber":"608-916-7032","email":"lfatkinhi@blogs.com"}, -{"id":632,"firstName":"Simone","lastName":"Soars","street":"9969 Forest Run Crossing","postalCode":"90101","city":"Los Angeles","state":"CA","phoneNumber":"213-282-8462"}, -{"id":633,"firstName":"Clerissa","lastName":"Leason","street":"59731 Mayfield Street","postalCode":"89510","city":"Reno","state":"NV"}, -{"id":634,"firstName":"Rutter","lastName":"Sultan","street":"697 Spenser Way","postalCode":"77245","city":"Houston","state":"TX"}, -{"id":635,"firstName":"Shannon","lastName":"De Carteret","street":"2 Grover Avenue","postalCode":"92717","city":"Irvine","state":"CA","phoneNumber":"714-410-2360","email":"sdecarterethm@simplemachines.org"}, -{"id":636,"firstName":"Sawyere","lastName":"Cardno","street":"428 Golf Course Drive","postalCode":"33111","city":"Miami","state":"FL"}, -{"id":637,"firstName":"Paulie","lastName":"Bucktharp","street":"5398 Sugar Park","postalCode":"10039","city":"New York City","state":"NY","phoneNumber":"646-197-4123","email":"pbucktharpho@businessweek.com"}, -{"id":638,"firstName":"Kippy","lastName":"Guisler","street":"2161 Claremont Trail","postalCode":"20546","city":"Washington","state":"DC","phoneNumber":"202-138-6171","email":"kguislerhp@ox.ac.uk"}, -{"id":639,"firstName":"Yoshiko","lastName":"Tolson","street":"2 Glendale Court","postalCode":"27415","city":"Greensboro","state":"NC","email":"ytolsonhq@example.com"}, -{"id":640,"firstName":"Page","lastName":"Chillingsworth","street":"8 Loomis Drive","postalCode":"55470","city":"Minneapolis","state":"MN","email":"pchillingsworthhr@wunderground.com"}, -{"id":641,"firstName":"Jillana","lastName":"O'Siaghail","street":"13517 Del Mar Road","postalCode":"29215","city":"Columbia","state":"SC","phoneNumber":"803-420-8597","email":"josiaghailhs@reuters.com"}, -{"id":642,"firstName":"Phedra","lastName":"Bagnold","street":"7059 Hallows Street","postalCode":"55470","city":"Minneapolis","state":"MN","email":"pbagnoldht@howstuffworks.com"}, -{"id":643,"firstName":"Bellina","lastName":"Gouldie","street":"7567 Bultman Way","postalCode":"88514","city":"El Paso","state":"TX","email":"bgouldiehu@salon.com"}, -{"id":644,"firstName":"Devi","lastName":"Bohden","street":"68833 Northview Hill","postalCode":"84115","city":"Salt Lake City","state":"UT"}, -{"id":645,"firstName":"Peggi","lastName":"Gobert","street":"667 Sauthoff Hill","postalCode":"44710","city":"Canton","state":"OH","email":"pgoberthw@mapy.cz"}, -{"id":646,"firstName":"Madelina","lastName":"Gurys","street":"70 Del Sol Trail","postalCode":"20420","city":"Washington","state":"DC","phoneNumber":"202-747-9276","email":"mguryshx@hibu.com"}, -{"id":647,"firstName":"Ikey","lastName":"Aubri","street":"76 Sutteridge Hill","postalCode":"36205","city":"Anniston","state":"AL","phoneNumber":"256-945-5095","email":"iaubrihy@mayoclinic.com"}, -{"id":648,"firstName":"Ginevra","lastName":"Duffitt","street":"25 Eagan Circle","postalCode":"31217","city":"Macon","state":"GA"}, -{"id":649,"firstName":"Cissiee","lastName":"Gozzard","street":"40240 Lillian Park","postalCode":"60609","city":"Chicago","state":"IL","email":"cgozzardi0@columbia.edu"}, -{"id":650,"firstName":"Sonny","lastName":"Jobern","street":"8 Green Trail","postalCode":"77065","city":"Houston","state":"TX","email":"sjoberni1@ucoz.com"}, -{"id":651,"firstName":"Mitch","lastName":"Guidera","street":"0 Dorton Junction","postalCode":"35210","city":"Birmingham","state":"AL","phoneNumber":"205-224-0177"}, -{"id":652,"firstName":"Dorey","lastName":"Marks","street":"81562 Maywood Crossing","postalCode":"71208","city":"Monroe","state":"LA","phoneNumber":"318-492-5487"}, -{"id":653,"firstName":"Pavla","lastName":"Conneely","street":"4007 Mifflin Lane","postalCode":"20456","city":"Washington","state":"DC"}, -{"id":654,"firstName":"Kym","lastName":"Gecks","street":"72638 Namekagon Plaza","postalCode":"61656","city":"Peoria","state":"IL","email":"kgecksi5@nature.com"}, -{"id":655,"firstName":"Prudence","lastName":"Peert","street":"91 Tomscot Parkway","postalCode":"32209","city":"Jacksonville","state":"FL","phoneNumber":"904-277-2945","email":"ppeerti6@usa.gov"}, -{"id":656,"firstName":"Elston","lastName":"Paolo","street":"4 Jenna Crossing","postalCode":"95155","city":"San Jose","state":"CA","email":"epaoloi7@umn.edu"}, -{"id":657,"firstName":"Indira","lastName":"Splaven","street":"8853 Vermont Drive","postalCode":"38188","city":"Memphis","state":"TN","phoneNumber":"901-706-3908","email":"isplaveni8@fda.gov"}, -{"id":658,"firstName":"Paul","lastName":"Mc Meekin","street":"56 Vidon Drive","postalCode":"08695","city":"Trenton","state":"NJ","phoneNumber":"609-361-1580"}, -{"id":659,"firstName":"Hadley","lastName":"Windmill","street":"31384 Evergreen Point","postalCode":"16550","city":"Erie","state":"PA","email":"hwindmillia@yale.edu"}, -{"id":660,"firstName":"Jay","lastName":"Yesichev","street":"675 Starling Pass","postalCode":"89150","city":"Las Vegas","state":"NV"}, -{"id":661,"firstName":"Ranna","lastName":"Dowtry","street":"303 Nevada Pass","postalCode":"48550","city":"Flint","state":"MI","phoneNumber":"810-164-4521","email":"rdowtryic@amazon.co.jp"}, -{"id":662,"firstName":"Annabel","lastName":"Pellamont","street":"277 Merrick Crossing","postalCode":"36605","city":"Mobile","state":"AL","phoneNumber":"251-595-3594","email":"apellamontid@reverbnation.com"}, -{"id":663,"firstName":"Kaitlynn","lastName":"Tracey","street":"612 Magdeline Road","postalCode":"97296","city":"Portland","state":"OR","email":"ktraceyie@ycombinator.com"}, -{"id":664,"firstName":"Matthiew","lastName":"Jills","street":"65 Walton Circle","postalCode":"93750","city":"Fresno","state":"CA","email":"mjillsif@addthis.com"}, -{"id":665,"firstName":"Bartlet","lastName":"Roe","street":"51573 Mandrake Park","postalCode":"02109","city":"Boston","state":"MA","phoneNumber":"617-460-5377","email":"broeig@nasa.gov"}, -{"id":666,"firstName":"Ban","lastName":"Knotton","street":"174 Westridge Parkway","postalCode":"32405","city":"Panama City","state":"FL","phoneNumber":"850-939-6502","email":"bknottonih@businesswire.com"}, -{"id":667,"firstName":"Cordelie","lastName":"O'Dee","street":"1733 Linden Avenue","postalCode":"80940","city":"Colorado Springs","state":"CO","phoneNumber":"719-966-3402","email":"codeeii@amazonaws.com"}, -{"id":668,"firstName":"Hardy","lastName":"Lob","street":"4 Bultman Road","postalCode":"75074","city":"Plano","state":"TX","email":"hlobij@dropbox.com"}, -{"id":669,"firstName":"Rosabelle","lastName":"Tonner","street":"1 Holy Cross Trail","postalCode":"36670","city":"Mobile","state":"AL","phoneNumber":"251-606-9437","email":"rtonnerik@google.ru"}, -{"id":670,"firstName":"Bernardina","lastName":"Mardy","street":"65 Myrtle Center","postalCode":"96845","city":"Honolulu","state":"HI","email":"bmardyil@wordpress.com"}, -{"id":671,"firstName":"Hynda","lastName":"Soldner","street":"88 Hazelcrest Drive","postalCode":"55470","city":"Minneapolis","state":"MN","email":"hsoldnerim@webeden.co.uk"}, -{"id":672,"firstName":"Quinn","lastName":"Templeton","street":"5 Village Way","postalCode":"19131","city":"Philadelphia","state":"PA","email":"qtempletonin@diigo.com"}, -{"id":673,"firstName":"Torrence","lastName":"Askwith","street":"1 Namekagon Point","postalCode":"31410","city":"Savannah","state":"GA","phoneNumber":"912-552-5239","email":"taskwithio@people.com.cn"}, -{"id":674,"firstName":"Bonnie","lastName":"Robilliard","street":"731 Johnson Lane","postalCode":"24515","city":"Lynchburg","state":"VA","phoneNumber":"434-382-5496"}, -{"id":675,"firstName":"Daphna","lastName":"D'Souza","street":"1549 Loftsgordon Center","postalCode":"91406","city":"Van Nuys","state":"CA","phoneNumber":"818-773-9088"}, -{"id":676,"firstName":"Palm","lastName":"Gandrich","street":"9 4th Pass","postalCode":"87121","city":"Albuquerque","state":"NM","phoneNumber":"505-815-5555"}, -{"id":677,"firstName":"Danie","lastName":"Gaydon","street":"382 Bayside Junction","postalCode":"55441","city":"Minneapolis","state":"MN","phoneNumber":"952-744-9400","email":"dgaydonis@seesaa.net"}, -{"id":678,"firstName":"Tabatha","lastName":"Caddock","street":"3858 Mccormick Road","postalCode":"53779","city":"Madison","state":"WI","phoneNumber":"608-996-7653","email":"tcaddockit@gizmodo.com"}, -{"id":679,"firstName":"Sergent","lastName":"Cade","street":"7 Riverside Crossing","postalCode":"13505","city":"Utica","state":"NY","email":"scadeiu@google.co.uk"}, -{"id":680,"firstName":"Shina","lastName":"Dumphry","street":"483 Del Mar Terrace","postalCode":"73109","city":"Oklahoma City","state":"OK","phoneNumber":"405-261-3364","email":"sdumphryiv@mediafire.com"}, -{"id":681,"firstName":"Aaron","lastName":"O'Neal","street":"669 Crowley Road","postalCode":"87140","city":"Albuquerque","state":"NM","phoneNumber":"505-451-6591","email":"aonealiw@npr.org"}, -{"id":682,"firstName":"Cynthea","lastName":"Wippermann","street":"109 Kinsman Parkway","postalCode":"06606","city":"Bridgeport","state":"CT","phoneNumber":"203-799-4552"}, -{"id":683,"firstName":"Stoddard","lastName":"Hullett","street":"06200 Mesta Park","postalCode":"78769","city":"Austin","state":"TX","phoneNumber":"512-190-7003"}, -{"id":684,"firstName":"Margit","lastName":"Comusso","street":"54 Springs Center","postalCode":"33737","city":"Saint Petersburg","state":"FL","phoneNumber":"727-144-3743","email":"mcomussoiz@drupal.org"}, -{"id":685,"firstName":"Dur","lastName":"Manns","street":"464 Park Meadow Road","postalCode":"90015","city":"Los Angeles","state":"CA","email":"dmannsj0@nymag.com"}, -{"id":686,"firstName":"Hollie","lastName":"Aldersey","street":"12195 Mallory Court","postalCode":"21405","city":"Annapolis","state":"MD","email":"halderseyj1@businessinsider.com"}, -{"id":687,"firstName":"Ralina","lastName":"Crepin","street":"13313 Clyde Gallagher Way","postalCode":"78285","city":"San Antonio","state":"TX"}, -{"id":688,"firstName":"Lyell","lastName":"Graveston","street":"20 Talisman Crossing","postalCode":"27157","city":"Winston Salem","state":"NC","phoneNumber":"336-638-3366","email":"lgravestonj3@webmd.com"}, -{"id":689,"firstName":"Anny","lastName":"Potell","street":"0 Ludington Circle","postalCode":"32803","city":"Orlando","state":"FL","email":"apotellj4@microsoft.com"}, -{"id":690,"firstName":"Harriot","lastName":"Klimpke","street":"8 Southridge Alley","postalCode":"22047","city":"Falls Church","state":"VA","phoneNumber":"571-470-2688","email":"hklimpkej5@slashdot.org"}, -{"id":691,"firstName":"Stacia","lastName":"Stainsby","street":"78 Mcbride Avenue","postalCode":"46862","city":"Fort Wayne","state":"IN"}, -{"id":692,"firstName":"Zacharia","lastName":"Willmont","street":"24 Everett Center","postalCode":"73135","city":"Oklahoma City","state":"OK","phoneNumber":"405-167-0584","email":"zwillmontj7@tuttocitta.it"}, -{"id":693,"firstName":"Dorelia","lastName":"Flexman","street":"0 Hauk Crossing","postalCode":"95298","city":"Stockton","state":"CA","phoneNumber":"209-759-3308"}, -{"id":694,"firstName":"Rubi","lastName":"Karran","street":"586 Eggendart Pass","postalCode":"64082","city":"Lees Summit","state":"MO","email":"rkarranj9@yahoo.com"}, -{"id":695,"firstName":"Edlin","lastName":"Davidsen","street":"5646 Arrowood Park","postalCode":"20591","city":"Washington","state":"DC","phoneNumber":"202-800-5817","email":"edavidsenja@purevolume.com"}, -{"id":696,"firstName":"Oralle","lastName":"Coneybeare","street":"0 Lakewood Parkway","postalCode":"08695","city":"Trenton","state":"NJ","email":"oconeybearejb@booking.com"}, -{"id":697,"firstName":"Scotti","lastName":"Cereceres","street":"2 Golf Hill","postalCode":"38119","city":"Memphis","state":"TN"}, -{"id":698,"firstName":"Hermione","lastName":"Mingotti","street":"14 Shoshone Alley","postalCode":"44511","city":"Youngstown","state":"OH","phoneNumber":"330-505-0585"}, -{"id":699,"firstName":"Janka","lastName":"Merredy","street":"877 Reinke Park","postalCode":"45233","city":"Cincinnati","state":"OH","email":"jmerredyje@furl.net"}, -{"id":700,"firstName":"Phillida","lastName":"Gannicleff","street":"48778 Sheridan Center","postalCode":"99210","city":"Spokane","state":"WA","email":"pgannicleffjf@github.io"}, -{"id":701,"firstName":"Bryn","lastName":"Shury","street":"82609 Surrey Road","postalCode":"78240","city":"San Antonio","state":"TX","phoneNumber":"210-361-9404","email":"bshuryjg@arstechnica.com"}, -{"id":702,"firstName":"Bobbe","lastName":"Yurocjhin","street":"54904 Southridge Parkway","postalCode":"33633","city":"Tampa","state":"FL","email":"byurocjhinjh@tumblr.com"}, -{"id":703,"firstName":"Noell","lastName":"Trewman","street":"63703 Fair Oaks Point","postalCode":"91520","city":"Burbank","state":"CA"}, -{"id":704,"firstName":"Adelind","lastName":"Marr","street":"68 Lotheville Park","postalCode":"02912","city":"Providence","state":"RI","email":"amarrjj@hexun.com"}, -{"id":705,"firstName":"Arabelle","lastName":"Oultram","street":"7927 Waxwing Place","postalCode":"77085","city":"Houston","state":"TX","email":"aoultramjk@diigo.com"}, -{"id":706,"firstName":"Derril","lastName":"Whylie","street":"1 Summerview Terrace","postalCode":"91606","city":"North Hollywood","state":"CA","phoneNumber":"323-244-3266","email":"dwhyliejl@auda.org.au"}, -{"id":707,"firstName":"Isadore","lastName":"Airth","street":"08897 Hauk Court","postalCode":"73104","city":"Oklahoma City","state":"OK","phoneNumber":"405-488-1807"}, -{"id":708,"firstName":"Barbara","lastName":"Feast","street":"420 Bayside Circle","postalCode":"63136","city":"Saint Louis","state":"MO","phoneNumber":"314-919-9094"}, -{"id":709,"firstName":"Engracia","lastName":"Laxtonne","street":"189 Oneill Center","postalCode":"22047","city":"Falls Church","state":"VA","email":"elaxtonnejo@addthis.com"}, -{"id":710,"firstName":"Dorice","lastName":"Dearle","street":"655 Union Way","postalCode":"47705","city":"Evansville","state":"IN","phoneNumber":"812-812-8795","email":"ddearlejp@mail.ru"}, -{"id":711,"firstName":"Crissie","lastName":"Leall","street":"1 1st Drive","postalCode":"36689","city":"Mobile","state":"AL","phoneNumber":"251-112-1542","email":"clealljq@nyu.edu"}, -{"id":712,"firstName":"Rica","lastName":"Wilshin","street":"0 Miller Way","postalCode":"79705","city":"Midland","state":"TX","phoneNumber":"432-935-1867"}, -{"id":713,"firstName":"Annie","lastName":"Thorns","street":"297 Thompson Park","postalCode":"32412","city":"Panama City","state":"FL","phoneNumber":"850-594-4049"}, -{"id":714,"firstName":"Lilah","lastName":"Beining","street":"1566 American Ash Avenue","postalCode":"25326","city":"Charleston","state":"WV","email":"lbeiningjt@mayoclinic.com"}, -{"id":715,"firstName":"Leeann","lastName":"Dorant","street":"5530 Mcguire Alley","postalCode":"93407","city":"San Luis Obispo","state":"CA","email":"ldorantju@homestead.com"}, -{"id":716,"firstName":"Elinor","lastName":"James","street":"2 Waxwing Terrace","postalCode":"88579","city":"El Paso","state":"TX","email":"ejamesjv@europa.eu"}, -{"id":717,"firstName":"Novelia","lastName":"Durman","street":"7 Hermina Junction","postalCode":"77050","city":"Houston","state":"TX","email":"ndurmanjw@fc2.com"}, -{"id":718,"firstName":"Sharai","lastName":"Pickervance","street":"739 Lien Junction","postalCode":"73167","city":"Oklahoma City","state":"OK","email":"spickervancejx@independent.co.uk"}, -{"id":719,"firstName":"Gilberte","lastName":"Stilling","street":"29950 Annamark Trail","postalCode":"89178","city":"Las Vegas","state":"NV","phoneNumber":"702-604-4240","email":"gstillingjy@feedburner.com"}, -{"id":720,"firstName":"Rosabelle","lastName":"Guinan","street":"13078 Sutherland Center","postalCode":"83757","city":"Boise","state":"ID","phoneNumber":"208-792-6705"}, -{"id":721,"firstName":"Karin","lastName":"Ackermann","street":"3 Susan Hill","postalCode":"48919","city":"Lansing","state":"MI","phoneNumber":"517-579-7811","email":"kackermannk0@csmonitor.com"}, -{"id":722,"firstName":"Reeta","lastName":"Attwell","street":"96 Alpine Junction","postalCode":"66622","city":"Topeka","state":"KS"}, -{"id":723,"firstName":"Dru","lastName":"Linck","street":"37 Wayridge Place","postalCode":"49505","city":"Grand Rapids","state":"MI","phoneNumber":"616-197-1837"}, -{"id":724,"firstName":"Frances","lastName":"Collingridge","street":"273 Ludington Crossing","postalCode":"77255","city":"Houston","state":"TX"}, -{"id":725,"firstName":"Wilmette","lastName":"Haimes","street":"8408 Shopko Circle","postalCode":"98907","city":"Yakima","state":"WA","phoneNumber":"509-821-5948"}, -{"id":726,"firstName":"Isahella","lastName":"Rubrow","street":"25 Melby Crossing","postalCode":"59105","city":"Billings","state":"MT","email":"irubrowk5@edublogs.org"}, -{"id":727,"firstName":"Walden","lastName":"Sappson","street":"1 3rd Hill","postalCode":"60435","city":"Joliet","state":"IL","email":"wsappsonk6@ameblo.jp"}, -{"id":728,"firstName":"Blondie","lastName":"Godehard.sf","street":"4606 Caliangt Circle","postalCode":"20709","city":"Laurel","state":"MD"}, -{"id":729,"firstName":"Dion","lastName":"Wingeatt","street":"098 Ridgeview Alley","postalCode":"78769","city":"Austin","state":"TX","phoneNumber":"512-948-4113","email":"dwingeattk8@clickbank.net"}, -{"id":730,"firstName":"Antoni","lastName":"Tibbles","street":"9 Muir Court","postalCode":"25313","city":"Charleston","state":"WV","phoneNumber":"304-298-6149","email":"atibblesk9@usa.gov"}, -{"id":731,"firstName":"Quinn","lastName":"McKevin","street":"063 Washington Parkway","postalCode":"55470","city":"Minneapolis","state":"MN","phoneNumber":"612-140-1997"}, -{"id":732,"firstName":"Rita","lastName":"Hallam","street":"4 Chive Court","postalCode":"85025","city":"Phoenix","state":"AZ","email":"rhallamkb@list-manage.com"}, -{"id":733,"firstName":"Cliff","lastName":"McCrum","street":"30841 Scoville Street","postalCode":"38150","city":"Memphis","state":"TN","phoneNumber":"901-983-7713","email":"cmccrumkc@yellowpages.com"}, -{"id":734,"firstName":"Allyson","lastName":"Petkov","street":"057 Grover Trail","postalCode":"55487","city":"Minneapolis","state":"MN","phoneNumber":"612-706-7185"}, -{"id":735,"firstName":"Tanney","lastName":"Cicccitti","street":"84959 Calypso Way","postalCode":"66629","city":"Topeka","state":"KS","phoneNumber":"785-516-0753","email":"tcicccittike@netscape.com"}, -{"id":736,"firstName":"Brendin","lastName":"Behnke","street":"3057 Browning Parkway","postalCode":"38181","city":"Memphis","state":"TN","email":"bbehnkekf@answers.com"}, -{"id":737,"firstName":"Sydelle","lastName":"Lestor","street":"6 Old Shore Way","postalCode":"73167","city":"Oklahoma City","state":"OK"}, -{"id":738,"firstName":"Nilson","lastName":"Nelthorp","street":"5 Gerald Trail","postalCode":"60567","city":"Naperville","state":"IL","phoneNumber":"630-718-5304","email":"nnelthorpkh@scribd.com"}, -{"id":739,"firstName":"Randy","lastName":"Boller","street":"64 Roth Junction","postalCode":"95354","city":"Modesto","state":"CA","phoneNumber":"209-795-8532","email":"rbollerki@nature.com"}, -{"id":740,"firstName":"Vicki","lastName":"De Vaan","street":"08 Mariners Cove Terrace","postalCode":"62776","city":"Springfield","state":"IL","email":"vdevaankj@disqus.com"}, -{"id":741,"firstName":"Romain","lastName":"Castri","street":"7 Atwood Road","postalCode":"02905","city":"Providence","state":"RI","phoneNumber":"401-865-9950","email":"rcastrikk@google.com.br"}, -{"id":742,"firstName":"Adlai","lastName":"Keppel","street":"6 Farragut Circle","postalCode":"76705","city":"Waco","state":"TX","phoneNumber":"254-852-6322"}, -{"id":743,"firstName":"Arlyne","lastName":"Whalley","street":"6 Esker Terrace","postalCode":"83727","city":"Boise","state":"ID","email":"awhalleykm@amazon.co.uk"}, -{"id":744,"firstName":"Alistair","lastName":"Jennins","street":"6 Loeprich Center","postalCode":"21684","city":"Ridgely","state":"MD","phoneNumber":"410-494-2201","email":"ajenninskn@sciencedaily.com"}, -{"id":745,"firstName":"Farr","lastName":"Steer","street":"8569 Eliot Lane","postalCode":"93381","city":"Bakersfield","state":"CA","phoneNumber":"661-416-1609","email":"fsteerko@usgs.gov"}, -{"id":746,"firstName":"Analise","lastName":"Balasini","street":"8901 Lyons Parkway","postalCode":"23242","city":"Richmond","state":"VA","email":"abalasinikp@imgur.com"}, -{"id":747,"firstName":"Gilbert","lastName":"Lockton","street":"3 Leroy Court","postalCode":"49018","city":"Battle Creek","state":"MI","email":"glocktonkq@google.nl"}, -{"id":748,"firstName":"Hamlen","lastName":"Massie","street":"469 Mallory Drive","postalCode":"77250","city":"Houston","state":"TX","email":"hmassiekr@admin.ch"}, -{"id":749,"firstName":"Ebony","lastName":"Loker","street":"21173 Raven Point","postalCode":"21265","city":"Baltimore","state":"MD"}, -{"id":750,"firstName":"Kristina","lastName":"Deeble","street":"479 Warner Park","postalCode":"92013","city":"Carlsbad","state":"CA","phoneNumber":"760-377-7198","email":"kdeeblekt@ezinearticles.com"}, -{"id":751,"firstName":"Jabez","lastName":"Mummery","street":"1 East Point","postalCode":"52809","city":"Davenport","state":"IA","email":"jmummeryku@sfgate.com"}, -{"id":752,"firstName":"Perrine","lastName":"Aldwinckle","street":"98 Montana Avenue","postalCode":"85030","city":"Phoenix","state":"AZ","phoneNumber":"602-224-2810","email":"paldwincklekv@eepurl.com"}, -{"id":753,"firstName":"Humfried","lastName":"Pendleton","street":"843 Swallow Park","postalCode":"89115","city":"Las Vegas","state":"NV","phoneNumber":"702-524-6047"}, -{"id":754,"firstName":"Dario","lastName":"Chesshire","street":"638 Westport Place","postalCode":"96845","city":"Honolulu","state":"HI","phoneNumber":"808-718-1386"}, -{"id":755,"firstName":"Cherianne","lastName":"Hearfield","street":"15 Quincy Street","postalCode":"14233","city":"Buffalo","state":"NY","email":"chearfieldky@technorati.com"}, -{"id":756,"firstName":"Jemima","lastName":"Oxnam","street":"22276 Maple Street","postalCode":"92165","city":"San Diego","state":"CA","email":"joxnamkz@addtoany.com"}, -{"id":757,"firstName":"Tedmund","lastName":"Chandler","street":"81 Katie Point","postalCode":"44310","city":"Akron","state":"OH","phoneNumber":"330-336-2279","email":"tchandlerl0@webeden.co.uk"}, -{"id":758,"firstName":"Tobie","lastName":"Risley","street":"82996 Reindahl Junction","postalCode":"17140","city":"Harrisburg","state":"PA","phoneNumber":"717-272-9110","email":"trisleyl1@youtu.be"}, -{"id":759,"firstName":"Tomi","lastName":"Crevagh","street":"91791 Buhler Park","postalCode":"33715","city":"Saint Petersburg","state":"FL"}, -{"id":760,"firstName":"Luce","lastName":"Gwatkin","street":"424 Lunder Crossing","postalCode":"31416","city":"Savannah","state":"GA"}, -{"id":761,"firstName":"Vinita","lastName":"Hannon","street":"90 Claremont Trail","postalCode":"39236","city":"Jackson","state":"MS"}, -{"id":762,"firstName":"Ruby","lastName":"O'Cosgra","street":"304 Dayton Avenue","postalCode":"07188","city":"Newark","state":"NJ"}, -{"id":763,"firstName":"Amandi","lastName":"Vasiltsov","street":"98188 Killdeer Alley","postalCode":"93399","city":"Bakersfield","state":"CA","email":"avasiltsovl6@smh.com.au"}, -{"id":764,"firstName":"Juliana","lastName":"Goldspink","street":"93 Maryland Terrace","postalCode":"06705","city":"Waterbury","state":"CT","email":"jgoldspinkl7@guardian.co.uk"}, -{"id":765,"firstName":"Giorgi","lastName":"Yakovl","street":"24240 Shasta Drive","postalCode":"46814","city":"Fort Wayne","state":"IN","phoneNumber":"260-754-5907"}, -{"id":766,"firstName":"Aleksandr","lastName":"Justun","street":"06 Fulton Terrace","postalCode":"85025","city":"Phoenix","state":"AZ"}, -{"id":767,"firstName":"Cornela","lastName":"Grindell","street":"1 Hazelcrest Lane","postalCode":"53285","city":"Milwaukee","state":"WI"}, -{"id":768,"firstName":"Liv","lastName":"Madrell","street":"623 Cordelia Terrace","postalCode":"17105","city":"Harrisburg","state":"PA","email":"lmadrelllb@1688.com"}, -{"id":769,"firstName":"Konstance","lastName":"Rosebotham","street":"8930 Utah Terrace","postalCode":"20029","city":"Washington","state":"DC","email":"krosebothamlc@studiopress.com"}, -{"id":770,"firstName":"Theo","lastName":"Scotland","street":"454 Hintze Park","postalCode":"45238","city":"Cincinnati","state":"OH"}, -{"id":771,"firstName":"Trefor","lastName":"Rein","street":"9 Redwing Plaza","postalCode":"22184","city":"Vienna","state":"VA","email":"treinle@barnesandnoble.com"}, -{"id":772,"firstName":"Angelina","lastName":"Bromehead","street":"62477 Walton Circle","postalCode":"14683","city":"Rochester","state":"NY","email":"abromeheadlf@php.net"}, -{"id":773,"firstName":"Thornie","lastName":"Ivanishin","street":"0 Sunbrook Court","postalCode":"34665","city":"Pinellas Park","state":"FL","email":"tivanishinlg@aol.com"}, -{"id":774,"firstName":"Dyana","lastName":"McNickle","street":"2696 Lakewood Gardens Pass","postalCode":"20456","city":"Washington","state":"DC","phoneNumber":"202-653-8740"}, -{"id":775,"firstName":"Humfried","lastName":"Suero","street":"643 Pearson Junction","postalCode":"28410","city":"Wilmington","state":"NC"}, -{"id":776,"firstName":"Jessamine","lastName":"Stockings","street":"739 Moose Street","postalCode":"94137","city":"San Francisco","state":"CA","phoneNumber":"415-641-0091","email":"jstockingslj@skype.com"}, -{"id":777,"firstName":"Laryssa","lastName":"Grahl","street":"0538 Bultman Point","postalCode":"81505","city":"Grand Junction","state":"CO"}, -{"id":778,"firstName":"Susan","lastName":"Stonnell","street":"7 Dennis Parkway","postalCode":"67215","city":"Wichita","state":"KS","phoneNumber":"316-966-3243","email":"sstonnellll@nps.gov"}, -{"id":779,"firstName":"Melinde","lastName":"Segoe","street":"9 Dottie Place","postalCode":"19125","city":"Philadelphia","state":"PA","phoneNumber":"215-119-3801"}, -{"id":780,"firstName":"Skip","lastName":"Sedgebeer","street":"1 Eliot Drive","postalCode":"20005","city":"Washington","state":"DC","email":"ssedgebeerln@blogtalkradio.com"}, -{"id":781,"firstName":"Annabel","lastName":"Schusterl","street":"6094 Talisman Lane","postalCode":"68510","city":"Lincoln","state":"NE","phoneNumber":"402-355-7934","email":"aschusterllo@cargocollective.com"}, -{"id":782,"firstName":"Emiline","lastName":"Whittlesey","street":"5 Claremont Lane","postalCode":"77040","city":"Houston","state":"TX","phoneNumber":"832-835-1321","email":"ewhittleseylp@geocities.com"}, -{"id":783,"firstName":"Frasquito","lastName":"Loukes","street":"47 Merchant Pass","postalCode":"27499","city":"Greensboro","state":"NC","phoneNumber":"336-265-5719","email":"floukeslq@google.it"}, -{"id":784,"firstName":"Jerald","lastName":"Fairholm","street":"5939 Mariners Cove Road","postalCode":"76598","city":"Gatesville","state":"TX","email":"jfairholmlr@smh.com.au"}, -{"id":785,"firstName":"Melisent","lastName":"Strange","street":"50 Glendale Trail","postalCode":"10606","city":"White Plains","state":"NY"}, -{"id":786,"firstName":"Aaron","lastName":"Mixter","street":"14347 Darwin Place","postalCode":"33124","city":"Miami","state":"FL","phoneNumber":"786-244-1856","email":"amixterlt@dmoz.org"}, -{"id":787,"firstName":"Margy","lastName":"Falla","street":"5 Caliangt Trail","postalCode":"40287","city":"Louisville","state":"KY","email":"mfallalu@booking.com"}, -{"id":788,"firstName":"Malinde","lastName":"Ashdown","street":"97234 Anniversary Hill","postalCode":"06152","city":"Hartford","state":"CT","phoneNumber":"860-140-7408","email":"mashdownlv@economist.com"}, -{"id":789,"firstName":"Carolynn","lastName":"Dulany","street":"33 Melby Road","postalCode":"74116","city":"Tulsa","state":"OK","phoneNumber":"918-140-7039","email":"cdulanylw@yelp.com"}, -{"id":790,"firstName":"Kissee","lastName":"Escale","street":"1470 Hanson Parkway","postalCode":"92812","city":"Anaheim","state":"CA","phoneNumber":"714-466-6376"}, -{"id":791,"firstName":"Rebeka","lastName":"Moralee","street":"898 Oak Street","postalCode":"34108","city":"Naples","state":"FL","email":"rmoraleely@shutterfly.com"}, -{"id":792,"firstName":"Cort","lastName":"Arter","street":"35039 Menomonie Way","postalCode":"50936","city":"Des Moines","state":"IA","email":"carterlz@surveymonkey.com"}, -{"id":793,"firstName":"Kirsteni","lastName":"Heady","street":"473 Lawn Street","postalCode":"32092","city":"Saint Augustine","state":"FL","phoneNumber":"904-424-3526","email":"kheadym0@usda.gov"}, -{"id":794,"firstName":"Ettie","lastName":"Overil","street":"1085 Waubesa Lane","postalCode":"18105","city":"Allentown","state":"PA"}, -{"id":795,"firstName":"Evey","lastName":"Tesimon","street":"9 Cordelia Place","postalCode":"55127","city":"Saint Paul","state":"MN"}, -{"id":796,"firstName":"Hersh","lastName":"Lebond","street":"5265 Bartelt Park","postalCode":"34282","city":"Bradenton","state":"FL","phoneNumber":"941-114-7090"}, -{"id":797,"firstName":"Hendrika","lastName":"Govan","street":"27747 La Follette Avenue","postalCode":"21229","city":"Baltimore","state":"MD","email":"hgovanm4@cam.ac.uk"}, -{"id":798,"firstName":"Renado","lastName":"Hambly","street":"5211 Schmedeman Drive","postalCode":"68105","city":"Omaha","state":"NE","phoneNumber":"402-183-0376","email":"rhamblym5@netlog.com"}, -{"id":799,"firstName":"Brewer","lastName":"Boyn","street":"3161 Novick Lane","postalCode":"77055","city":"Houston","state":"TX","email":"bboynm6@google.it"}, -{"id":800,"firstName":"Patrick","lastName":"Speck","street":"57052 Ronald Regan Way","postalCode":"30306","city":"Atlanta","state":"GA","phoneNumber":"770-764-6971","email":"pspeckm7@live.com"}, -{"id":801,"firstName":"Skipper","lastName":"Conybear","street":"75 Autumn Leaf Alley","postalCode":"79968","city":"El Paso","state":"TX","phoneNumber":"915-705-5594","email":"sconybearm8@jimdo.com"}, -{"id":802,"firstName":"Elmore","lastName":"Quilty","street":"027 Warbler Court","postalCode":"35210","city":"Birmingham","state":"AL","email":"equiltym9@ebay.co.uk"}, -{"id":803,"firstName":"Estella","lastName":"Jorck","street":"52695 Holy Cross Trail","postalCode":"47134","city":"Jeffersonville","state":"IN","email":"ejorckma@bluehost.com"}, -{"id":804,"firstName":"Scotti","lastName":"Goodale","street":"7551 Dottie Pass","postalCode":"77713","city":"Beaumont","state":"TX","email":"sgoodalemb@nba.com"}, -{"id":805,"firstName":"Catha","lastName":"Shekle","street":"38839 Derek Terrace","postalCode":"62718","city":"Springfield","state":"IL","email":"csheklemc@tmall.com"}, -{"id":806,"firstName":"Clemens","lastName":"Chuter","street":"015 Charing Cross Pass","postalCode":"30306","city":"Atlanta","state":"GA"}, -{"id":807,"firstName":"Kiley","lastName":"Vasiltsov","street":"8 Reindahl Hill","postalCode":"33432","city":"Boca Raton","state":"FL","email":"kvasiltsovme@google.nl"}, -{"id":808,"firstName":"Korrie","lastName":"McGauhy","street":"188 Golf Lane","postalCode":"89110","city":"Las Vegas","state":"NV","phoneNumber":"702-647-1620","email":"kmcgauhymf@goodreads.com"}, -{"id":809,"firstName":"Giustina","lastName":"Hentze","street":"62244 Roth Way","postalCode":"48604","city":"Saginaw","state":"MI","email":"ghentzemg@pcworld.com"}, -{"id":810,"firstName":"Emilia","lastName":"Virgoe","street":"13910 Alpine Lane","postalCode":"33994","city":"Fort Myers","state":"FL","phoneNumber":"239-993-2041","email":"evirgoemh@mediafire.com"}, -{"id":811,"firstName":"Gordan","lastName":"Trimming","street":"38168 Transport Avenue","postalCode":"38131","city":"Memphis","state":"TN","email":"gtrimmingmi@spiegel.de"}, -{"id":812,"firstName":"Tadeo","lastName":"Vannoort","street":"41476 Pond Alley","postalCode":"20851","city":"Rockville","state":"MD","phoneNumber":"240-432-6489","email":"tvannoortmj@privacy.gov.au"}, -{"id":813,"firstName":"Joseito","lastName":"Viant","street":"1390 Kropf Court","postalCode":"04109","city":"Portland","state":"ME"}, -{"id":814,"firstName":"Blake","lastName":"Tailby","street":"5 Bultman Terrace","postalCode":"31914","city":"Columbus","state":"GA"}, -{"id":815,"firstName":"Cynthie","lastName":"Victor","street":"64 Hoard Avenue","postalCode":"46221","city":"Indianapolis","state":"IN","phoneNumber":"317-836-2511","email":"cvictormm@bizjournals.com"}, -{"id":816,"firstName":"Kristoforo","lastName":"Luckman","street":"019 Ohio Avenue","postalCode":"58505","city":"Bismarck","state":"ND","phoneNumber":"701-921-3472"}, -{"id":817,"firstName":"Celinka","lastName":"Brakewell","street":"5702 Tennessee Pass","postalCode":"92612","city":"Irvine","state":"CA","phoneNumber":"714-584-5599","email":"cbrakewellmo@house.gov"}, -{"id":818,"firstName":"Analiese","lastName":"Debenham","street":"7 Straubel Pass","postalCode":"31704","city":"Albany","state":"GA","phoneNumber":"229-600-4384","email":"adebenhammp@dell.com"}, -{"id":819,"firstName":"Sebastiano","lastName":"Eskriett","street":"0 Northridge Pass","postalCode":"34114","city":"Naples","state":"FL","phoneNumber":"239-651-1326","email":"seskriettmq@berkeley.edu"}, -{"id":820,"firstName":"Jermaine","lastName":"Donisthorpe","street":"69319 Hollow Ridge Park","postalCode":"62794","city":"Springfield","state":"IL","phoneNumber":"217-510-3030","email":"jdonisthorpemr@istockphoto.com"}, -{"id":821,"firstName":"Tera","lastName":"Smalecombe","street":"646 Oakridge Avenue","postalCode":"43699","city":"Toledo","state":"OH","email":"tsmalecombems@tripod.com"}, -{"id":822,"firstName":"Issie","lastName":"Cohane","street":"79078 Fair Oaks Circle","postalCode":"40233","city":"Louisville","state":"KY","email":"icohanemt@wired.com"}, -{"id":823,"firstName":"Nanete","lastName":"Erb","street":"02 Truax Place","postalCode":"88563","city":"El Paso","state":"TX","phoneNumber":"915-234-2792"}, -{"id":824,"firstName":"Benetta","lastName":"Roger","street":"822 Fallview Alley","postalCode":"33625","city":"Tampa","state":"FL","phoneNumber":"813-715-8911","email":"brogermv@ca.gov"}, -{"id":825,"firstName":"Sascha","lastName":"Hillyatt","street":"06 Fisk Plaza","postalCode":"11407","city":"Jamaica","state":"NY"}, -{"id":826,"firstName":"Britt","lastName":"Gilderoy","street":"64312 Delaware Place","postalCode":"89135","city":"Las Vegas","state":"NV"}, -{"id":827,"firstName":"Sterne","lastName":"Frissell","street":"69121 Sycamore Way","postalCode":"06912","city":"Stamford","state":"CT"}, -{"id":828,"firstName":"Lonny","lastName":"Petersen","street":"6 Golf Course Crossing","postalCode":"32627","city":"Gainesville","state":"FL","phoneNumber":"352-245-3289","email":"lpetersenmz@msu.edu"}, -{"id":829,"firstName":"Maridel","lastName":"Clunie","street":"0312 Dryden Street","postalCode":"80328","city":"Boulder","state":"CO","phoneNumber":"303-848-1116","email":"mclunien0@china.com.cn"}, -{"id":830,"firstName":"Annabal","lastName":"Pruckner","street":"98481 Anhalt Pass","postalCode":"30340","city":"Atlanta","state":"GA","email":"aprucknern1@bandcamp.com"}, -{"id":831,"firstName":"Carin","lastName":"Ambrois","street":"7982 Vahlen Road","postalCode":"85010","city":"Phoenix","state":"AZ"}, -{"id":832,"firstName":"Consuela","lastName":"Grubey","street":"1 Lillian Circle","postalCode":"89714","city":"Carson City","state":"NV","email":"cgrubeyn3@google.pl"}, -{"id":833,"firstName":"Friedrick","lastName":"Ventom","street":"703 Almo Crossing","postalCode":"43215","city":"Columbus","state":"OH"}, -{"id":834,"firstName":"Shalom","lastName":"Rosten","street":"4460 Parkside Road","postalCode":"37215","city":"Nashville","state":"TN","email":"srostenn5@e-recht24.de"}, -{"id":835,"firstName":"Sofia","lastName":"Pottie","street":"89885 Golf Course Junction","postalCode":"27635","city":"Raleigh","state":"NC","email":"spottien6@weather.com"}, -{"id":836,"firstName":"Ed","lastName":"Cecely","street":"38576 Gina Trail","postalCode":"85305","city":"Glendale","state":"AZ","email":"ececelyn7@friendfeed.com"}, -{"id":837,"firstName":"Ruthann","lastName":"Bignold","street":"202 Monterey Alley","postalCode":"19104","city":"Philadelphia","state":"PA","phoneNumber":"610-892-3949"}, -{"id":838,"firstName":"Vonnie","lastName":"Leeming","street":"5 Farmco Center","postalCode":"18706","city":"Wilkes Barre","state":"PA"}, -{"id":839,"firstName":"Diandra","lastName":"Gredden","street":"68178 Parkside Hill","postalCode":"89120","city":"Las Vegas","state":"NV","phoneNumber":"702-952-4026"}, -{"id":840,"firstName":"Donny","lastName":"Bruckent","street":"6 Dapin Way","postalCode":"98127","city":"Seattle","state":"WA","email":"dbruckentnb@stumbleupon.com"}, -{"id":841,"firstName":"Mill","lastName":"Finlay","street":"9 Meadow Valley Terrace","postalCode":"94405","city":"San Mateo","state":"CA","email":"mfinlaync@hibu.com"}, -{"id":842,"firstName":"Garv","lastName":"Feldberger","street":"5916 Marquette Lane","postalCode":"98127","city":"Seattle","state":"WA"}, -{"id":843,"firstName":"Micheal","lastName":"Favela","street":"41587 Dunning Road","postalCode":"47712","city":"Evansville","state":"IN"}, -{"id":844,"firstName":"Shannon","lastName":"Alvaro","street":"86377 Becker Avenue","postalCode":"33315","city":"Fort Lauderdale","state":"FL","phoneNumber":"954-661-6648","email":"salvaronf@usa.gov"}, -{"id":845,"firstName":"Corenda","lastName":"Aldcorn","street":"19 Bowman Court","postalCode":"67220","city":"Wichita","state":"KS","phoneNumber":"316-835-1638","email":"caldcornng@ebay.com"}, -{"id":846,"firstName":"Alvy","lastName":"Mahood","street":"0814 Spohn Hill","postalCode":"50347","city":"Des Moines","state":"IA","phoneNumber":"515-865-3669","email":"amahoodnh@toplist.cz"}, -{"id":847,"firstName":"Alexandr","lastName":"Stut","street":"8672 Anderson Court","postalCode":"78410","city":"Corpus Christi","state":"TX"}, -{"id":848,"firstName":"Gale","lastName":"Chaperling","street":"78873 Bellgrove Alley","postalCode":"10009","city":"New York City","state":"NY","phoneNumber":"212-978-6798","email":"gchaperlingnj@livejournal.com"}, -{"id":849,"firstName":"Eunice","lastName":"Dadson","street":"340 Dwight Hill","postalCode":"52809","city":"Davenport","state":"IA","phoneNumber":"563-787-9869","email":"edadsonnk@businessinsider.com"}, -{"id":850,"firstName":"Florentia","lastName":"Camin","street":"68733 Orin Point","postalCode":"46867","city":"Fort Wayne","state":"IN","phoneNumber":"260-920-3928","email":"fcaminnl@technorati.com"}, -{"id":851,"firstName":"Norina","lastName":"Vannacci","street":"585 Karstens Circle","postalCode":"45233","city":"Cincinnati","state":"OH"}, -{"id":852,"firstName":"Syd","lastName":"Gianolo","street":"99755 Arrowood Hill","postalCode":"33673","city":"Tampa","state":"FL","phoneNumber":"813-878-8150","email":"sgianolonn@uol.com.br"}, -{"id":853,"firstName":"Timofei","lastName":"Serle","street":"1081 Cascade Park","postalCode":"94257","city":"Sacramento","state":"CA","email":"tserleno@behance.net"}, -{"id":854,"firstName":"Moina","lastName":"Ciobutaro","street":"502 Stone Corner Circle","postalCode":"33018","city":"Hialeah","state":"FL","email":"mciobutaronp@ycombinator.com"}, -{"id":855,"firstName":"Nikolaos","lastName":"Gavaghan","street":"47136 Golf Junction","postalCode":"97255","city":"Portland","state":"OR"}, -{"id":856,"firstName":"Gallard","lastName":"Jenks","street":"2 Carioca Terrace","postalCode":"35263","city":"Birmingham","state":"AL","email":"gjenksnr@blogtalkradio.com"}, -{"id":857,"firstName":"Dare","lastName":"Nielson","street":"3 Carberry Hill","postalCode":"48604","city":"Saginaw","state":"MI","phoneNumber":"989-211-0944"}, -{"id":858,"firstName":"Cecilius","lastName":"Fasse","street":"1 Novick Street","postalCode":"68583","city":"Lincoln","state":"NE","phoneNumber":"402-342-4624","email":"cfassent@zimbio.com"}, -{"id":859,"firstName":"Kevon","lastName":"Doxsey","street":"152 Warrior Pass","postalCode":"91616","city":"North Hollywood","state":"CA","phoneNumber":"213-339-9582"}, -{"id":860,"firstName":"Matti","lastName":"Gras","street":"4567 Bunting Way","postalCode":"94544","city":"Hayward","state":"CA"}, -{"id":861,"firstName":"Nathan","lastName":"Longfut","street":"3178 Mockingbird Alley","postalCode":"97255","city":"Portland","state":"OR","phoneNumber":"971-206-3004"}, -{"id":862,"firstName":"Willetta","lastName":"Fitzpayn","street":"87 Alpine Drive","postalCode":"48604","city":"Saginaw","state":"MI","phoneNumber":"989-698-7578","email":"wfitzpaynnx@geocities.jp"}, -{"id":863,"firstName":"Emanuel","lastName":"Jikylls","street":"42 Heffernan Court","postalCode":"33884","city":"Winter Haven","state":"FL","email":"ejikyllsny@biglobe.ne.jp"}, -{"id":864,"firstName":"Lenard","lastName":"Nore","street":"7 Nevada Avenue","postalCode":"77343","city":"Huntsville","state":"TX","phoneNumber":"936-267-6742","email":"lnorenz@netscape.com"}, -{"id":865,"firstName":"Jeanine","lastName":"MacTurlough","street":"26343 Gale Crossing","postalCode":"53779","city":"Madison","state":"WI","phoneNumber":"608-865-6630","email":"jmacturlougho0@scientificamerican.com"}, -{"id":866,"firstName":"Jaquenetta","lastName":"Dorn","street":"3963 Novick Way","postalCode":"19495","city":"Valley Forge","state":"PA","email":"jdorno1@about.com"}, -{"id":867,"firstName":"Amity","lastName":"Titterrell","street":"3216 Lindbergh Court","postalCode":"90071","city":"Los Angeles","state":"CA","phoneNumber":"626-416-1494","email":"atitterrello2@psu.edu"}, -{"id":868,"firstName":"Rafaelia","lastName":"Melly","street":"6 Westridge Center","postalCode":"61825","city":"Champaign","state":"IL","email":"rmellyo3@ovh.net"}, -{"id":869,"firstName":"Cordi","lastName":"Martinovsky","street":"38 Forest Dale Terrace","postalCode":"50362","city":"Des Moines","state":"IA","email":"cmartinovskyo4@tuttocitta.it"}, -{"id":870,"firstName":"Humfrid","lastName":"Varne","street":"858 Farwell Street","postalCode":"06127","city":"West Hartford","state":"CT","email":"hvarneo5@yolasite.com"}, -{"id":871,"firstName":"Ford","lastName":"Pinchback","street":"363 Lien Pass","postalCode":"20599","city":"Washington","state":"DC","email":"fpinchbacko6@nytimes.com"}, -{"id":872,"firstName":"Maible","lastName":"Haresign","street":"809 Monica Point","postalCode":"28230","city":"Charlotte","state":"NC"}, -{"id":873,"firstName":"Rozamond","lastName":"Challis","street":"312 Mcbride Plaza","postalCode":"77266","city":"Houston","state":"TX","email":"rchalliso8@google.ca"}, -{"id":874,"firstName":"Myrah","lastName":"Menendez","street":"21 Garrison Plaza","postalCode":"23208","city":"Richmond","state":"VA","email":"mmenendezo9@msn.com"}, -{"id":875,"firstName":"Roberto","lastName":"Lamb","street":"3339 Cottonwood Pass","postalCode":"43699","city":"Toledo","state":"OH","phoneNumber":"419-633-9671"}, -{"id":876,"firstName":"Foster","lastName":"Delyth","street":"91500 Carpenter Point","postalCode":"79928","city":"El Paso","state":"TX","phoneNumber":"915-782-9005"}, -{"id":877,"firstName":"Nicholle","lastName":"Pickring","street":"8083 Talmadge Lane","postalCode":"14624","city":"Rochester","state":"NY","email":"npickringoc@tuttocitta.it"}, -{"id":878,"firstName":"Theodosia","lastName":"Bayliss","street":"6 Marcy Parkway","postalCode":"33954","city":"Port Charlotte","state":"FL"}, -{"id":879,"firstName":"Araldo","lastName":"Dowzell","street":"8376 Carpenter Court","postalCode":"71151","city":"Shreveport","state":"LA","email":"adowzelloe@army.mil"}, -{"id":880,"firstName":"Hugues","lastName":"McColgan","street":"990 Southridge Point","postalCode":"93591","city":"Palmdale","state":"CA","phoneNumber":"661-978-2646","email":"hmccolganof@netvibes.com"}, -{"id":881,"firstName":"Annissa","lastName":"Mordue","street":"62114 Ludington Lane","postalCode":"30911","city":"Augusta","state":"GA","phoneNumber":"706-152-3967","email":"amordueog@tripod.com"}, -{"id":882,"firstName":"Tierney","lastName":"Claughton","street":"3 Twin Pines Trail","postalCode":"88563","city":"El Paso","state":"TX","phoneNumber":"915-784-7980"}, -{"id":883,"firstName":"Rey","lastName":"Fleckno","street":"49 Oakridge Point","postalCode":"27605","city":"Raleigh","state":"NC"}, -{"id":884,"firstName":"Stacee","lastName":"Rewcastle","street":"19 Glendale Point","postalCode":"78278","city":"San Antonio","state":"TX","phoneNumber":"210-454-3087","email":"srewcastleoj@ustream.tv"}, -{"id":885,"firstName":"Delano","lastName":"Bragger","street":"0 Hoffman Center","postalCode":"47725","city":"Evansville","state":"IN","email":"dbraggerok@ifeng.com"}, -{"id":886,"firstName":"Redford","lastName":"Bare","street":"801 Garrison Court","postalCode":"08638","city":"Trenton","state":"NJ"}, -{"id":887,"firstName":"Grantham","lastName":"Arlidge","street":"69 Shelley Parkway","postalCode":"34210","city":"Bradenton","state":"FL","email":"garlidgeom@google.nl"}, -{"id":888,"firstName":"Debbie","lastName":"Tommaseo","street":"295 Crowley Alley","postalCode":"98516","city":"Olympia","state":"WA","email":"dtommaseoon@xrea.com"}, -{"id":889,"firstName":"Ragnar","lastName":"O' Byrne","street":"88163 Manitowish Terrace","postalCode":"20260","city":"Washington","state":"DC","phoneNumber":"202-982-3050","email":"robyrneoo@ft.com"}, -{"id":890,"firstName":"Leopold","lastName":"Woodington","street":"44 Vera Pass","postalCode":"24009","city":"Roanoke","state":"VA","email":"lwoodingtonop@engadget.com"}, -{"id":891,"firstName":"Farrah","lastName":"Conniam","street":"2078 Bunting Parkway","postalCode":"68134","city":"Omaha","state":"NE","email":"fconniamoq@github.com"}, -{"id":892,"firstName":"Augustus","lastName":"Morrish","street":"430 Sauthoff Plaza","postalCode":"27710","city":"Durham","state":"NC","phoneNumber":"919-266-8155","email":"amorrishor@naver.com"}, -{"id":893,"firstName":"Cassaundra","lastName":"Deaves","street":"32 Clarendon Way","postalCode":"40266","city":"Louisville","state":"KY","phoneNumber":"502-138-7158"}, -{"id":894,"firstName":"Glynn","lastName":"Shewan","street":"989 Susan Avenue","postalCode":"95194","city":"San Jose","state":"CA","email":"gshewanot@reuters.com"}, -{"id":895,"firstName":"Neils","lastName":"Niesing","street":"488 Jana Road","postalCode":"48232","city":"Detroit","state":"MI","email":"nniesingou@cafepress.com"}, -{"id":896,"firstName":"Alix","lastName":"Cleeton","street":"8 Merrick Crossing","postalCode":"18018","city":"Bethlehem","state":"PA","email":"acleetonov@ask.com"}, -{"id":897,"firstName":"Kyrstin","lastName":"Alejandro","street":"45487 Carey Way","postalCode":"37919","city":"Knoxville","state":"TN","email":"kalejandroow@scribd.com"}, -{"id":898,"firstName":"Waylin","lastName":"De Caroli","street":"9237 Ludington Plaza","postalCode":"77554","city":"Galveston","state":"TX","email":"wdecaroliox@washingtonpost.com"}, -{"id":899,"firstName":"Lian","lastName":"Brade","street":"704 Lotheville Drive","postalCode":"24014","city":"Roanoke","state":"VA","phoneNumber":"540-712-7147"}, -{"id":900,"firstName":"Griz","lastName":"Elgie","street":"435 Northridge Point","postalCode":"93399","city":"Bakersfield","state":"CA","email":"gelgieoz@hao123.com"}, -{"id":901,"firstName":"Georgeanna","lastName":"Gilberthorpe","street":"6 Tomscot Park","postalCode":"37931","city":"Knoxville","state":"TN","phoneNumber":"865-664-6191","email":"ggilberthorpep0@typepad.com"}, -{"id":902,"firstName":"Korrie","lastName":"Goldstraw","street":"00 Lindbergh Plaza","postalCode":"14225","city":"Buffalo","state":"NY","email":"kgoldstrawp1@yellowbook.com"}, -{"id":903,"firstName":"Hervey","lastName":"Wyse","street":"27 Buell Road","postalCode":"75044","city":"Garland","state":"TX","phoneNumber":"972-243-9031","email":"hwysep2@deliciousdays.com"}, -{"id":904,"firstName":"Georgeta","lastName":"Buckam","street":"0 Continental Hill","postalCode":"65810","city":"Springfield","state":"MO","phoneNumber":"417-682-2553","email":"gbuckamp3@java.com"}, -{"id":905,"firstName":"Hussein","lastName":"Jacson","street":"478 Vermont Court","postalCode":"95354","city":"Modesto","state":"CA","phoneNumber":"209-714-7362","email":"hjacsonp4@squarespace.com"}, -{"id":906,"firstName":"Chrysler","lastName":"Heddy","street":"913 Steensland Parkway","postalCode":"20709","city":"Laurel","state":"MD","phoneNumber":"410-691-9748"}, -{"id":907,"firstName":"Jourdan","lastName":"Frise","street":"35 Erie Point","postalCode":"94245","city":"Sacramento","state":"CA","email":"jfrisep6@eepurl.com"}, -{"id":908,"firstName":"Roxie","lastName":"Gimber","street":"9237 Vermont Pass","postalCode":"88553","city":"El Paso","state":"TX","email":"rgimberp7@mayoclinic.com"}, -{"id":909,"firstName":"Jenilee","lastName":"MacNab","street":"23 Union Alley","postalCode":"29579","city":"Myrtle Beach","state":"SC","email":"jmacnabp8@mit.edu"}, -{"id":910,"firstName":"Lola","lastName":"Bier","street":"371 Bartillon Avenue","postalCode":"71105","city":"Shreveport","state":"LA","phoneNumber":"318-818-1659","email":"lbierp9@goo.gl"}, -{"id":911,"firstName":"Fayina","lastName":"Brosel","street":"3255 Macpherson Pass","postalCode":"55166","city":"Saint Paul","state":"MN","email":"fbroselpa@rakuten.co.jp"}, -{"id":912,"firstName":"Ellerey","lastName":"Darell","street":"735 Leroy Road","postalCode":"07544","city":"Paterson","state":"NJ"}, -{"id":913,"firstName":"Lorianne","lastName":"McLanachan","street":"22 Alpine Point","postalCode":"77293","city":"Houston","state":"TX","email":"lmclanachanpc@dmoz.org"}, -{"id":914,"firstName":"Merrill","lastName":"Searson","street":"8447 Namekagon Hill","postalCode":"55114","city":"Saint Paul","state":"MN","phoneNumber":"651-567-8380","email":"msearsonpd@census.gov"}, -{"id":915,"firstName":"Nisse","lastName":"Larive","street":"976 Forest Dale Way","postalCode":"10004","city":"New York City","state":"NY","phoneNumber":"347-192-6897","email":"nlarivepe@drupal.org"}, -{"id":916,"firstName":"Cazzie","lastName":"Brenard","street":"647 Gulseth Plaza","postalCode":"02283","city":"Boston","state":"MA","phoneNumber":"781-248-3572","email":"cbrenardpf@uiuc.edu"}, -{"id":917,"firstName":"Gael","lastName":"Ramirez","street":"161 Basil Terrace","postalCode":"93786","city":"Fresno","state":"CA","phoneNumber":"559-692-2653","email":"gramirezpg@ucoz.ru"}, -{"id":918,"firstName":"Culver","lastName":"Le Brun","street":"73906 Muir Terrace","postalCode":"95973","city":"Chico","state":"CA","email":"clebrunph@jigsy.com"}, -{"id":919,"firstName":"Bordie","lastName":"Muskett","street":"27 Nobel Trail","postalCode":"20599","city":"Washington","state":"DC","phoneNumber":"202-872-5253"}, -{"id":920,"firstName":"Riccardo","lastName":"Miskin","street":"778 Eagan Place","postalCode":"55407","city":"Minneapolis","state":"MN","email":"rmiskinpj@slideshare.net"}, -{"id":921,"firstName":"Cristabel","lastName":"Gowlett","street":"5 Quincy Lane","postalCode":"62525","city":"Decatur","state":"IL","email":"cgowlettpk@cafepress.com"}, -{"id":922,"firstName":"Crawford","lastName":"Huby","street":"6 Gina Lane","postalCode":"94913","city":"San Rafael","state":"CA","phoneNumber":"415-133-8552","email":"chubypl@jugem.jp"}, -{"id":923,"firstName":"Cherish","lastName":"Mutch","street":"8 Oak Valley Lane","postalCode":"20719","city":"Bowie","state":"MD","phoneNumber":"240-982-9087"}, -{"id":924,"firstName":"Jerrie","lastName":"Latek","street":"9462 Moulton Terrace","postalCode":"52809","city":"Davenport","state":"IA","phoneNumber":"563-687-6664","email":"jlatekpn@gov.uk"}, -{"id":925,"firstName":"Lacey","lastName":"Maris","street":"1 Carpenter Hill","postalCode":"61605","city":"Peoria","state":"IL","phoneNumber":"309-570-3216"}, -{"id":926,"firstName":"Daffy","lastName":"Binion","street":"8 Milwaukee Parkway","postalCode":"33129","city":"Miami","state":"FL","phoneNumber":"305-579-9009"}, -{"id":927,"firstName":"Melita","lastName":"Valde","street":"629 Packers Crossing","postalCode":"06140","city":"Hartford","state":"CT","phoneNumber":"860-747-5927","email":"mvaldepq@storify.com"}, -{"id":928,"firstName":"Cherlyn","lastName":"Rosenshine","street":"764 Pepper Wood Place","postalCode":"72204","city":"Little Rock","state":"AR","phoneNumber":"501-823-8134"}, -{"id":929,"firstName":"Morty","lastName":"Stanger","street":"3286 Charing Cross Court","postalCode":"08603","city":"Trenton","state":"NJ","email":"mstangerps@yellowpages.com"}, -{"id":930,"firstName":"Bernete","lastName":"Hirth","street":"83 Granby Center","postalCode":"95194","city":"San Jose","state":"CA","phoneNumber":"408-738-2333","email":"bhirthpt@people.com.cn"}, -{"id":931,"firstName":"Elena","lastName":"Wace","street":"98 Grover Trail","postalCode":"33742","city":"Saint Petersburg","state":"FL","phoneNumber":"727-883-2239","email":"ewacepu@merriam-webster.com"}, -{"id":932,"firstName":"Giselbert","lastName":"Sisland","street":"2214 Sheridan Pass","postalCode":"40225","city":"Louisville","state":"KY"}, -{"id":933,"firstName":"Herb","lastName":"Voyce","street":"628 Basil Pass","postalCode":"21265","city":"Baltimore","state":"MD"}, -{"id":934,"firstName":"Vina","lastName":"Antonetti","street":"6 Springview Terrace","postalCode":"20430","city":"Washington","state":"DC","phoneNumber":"202-955-4578"}, -{"id":935,"firstName":"Bard","lastName":"De Avenell","street":"2775 Clarendon Avenue","postalCode":"53215","city":"Milwaukee","state":"WI"}, -{"id":936,"firstName":"Briana","lastName":"Pinshon","street":"43 Del Sol Street","postalCode":"33615","city":"Tampa","state":"FL","email":"bpinshonpz@java.com"}, -{"id":937,"firstName":"Hilly","lastName":"Aysh","street":"37 Doe Crossing Terrace","postalCode":"23705","city":"Portsmouth","state":"VA","phoneNumber":"757-992-8124"}, -{"id":938,"firstName":"Marylin","lastName":"Ciotto","street":"3957 Browning Pass","postalCode":"94807","city":"Richmond","state":"CA"}, -{"id":939,"firstName":"Cam","lastName":"Kurth","street":"155 Walton Point","postalCode":"92867","city":"Orange","state":"CA","phoneNumber":"949-955-2248"}, -{"id":940,"firstName":"Rawley","lastName":"Bickle","street":"54 Macpherson Point","postalCode":"93762","city":"Fresno","state":"CA","phoneNumber":"559-331-2187","email":"rbickleq3@delicious.com"}, -{"id":941,"firstName":"Merlina","lastName":"Dunster","street":"70557 Toban Trail","postalCode":"20005","city":"Washington","state":"DC","phoneNumber":"202-999-8731"}, -{"id":942,"firstName":"Kennie","lastName":"MacCoughan","street":"04566 Browning Parkway","postalCode":"75507","city":"Texarkana","state":"TX","phoneNumber":"903-622-7509","email":"kmaccoughanq5@reuters.com"}, -{"id":943,"firstName":"Jase","lastName":"Cholomin","street":"21497 Blaine Road","postalCode":"33777","city":"Largo","state":"FL","email":"jcholominq6@cocolog-nifty.com"}, -{"id":944,"firstName":"Cirstoforo","lastName":"Billingsley","street":"1306 Summer Ridge Court","postalCode":"02124","city":"Boston","state":"MA","email":"cbillingsleyq7@google.es"}, -{"id":945,"firstName":"Berkly","lastName":"Lawles","street":"80400 Milwaukee Way","postalCode":"64082","city":"Lees Summit","state":"MO","email":"blawlesq8@jiathis.com"}, -{"id":946,"firstName":"Otha","lastName":"Key","street":"59639 Center Circle","postalCode":"35405","city":"Tuscaloosa","state":"AL","email":"okeyq9@deliciousdays.com"}, -{"id":947,"firstName":"Anselma","lastName":"Debow","street":"5 Spohn Parkway","postalCode":"80241","city":"Denver","state":"CO","email":"adebowqa@yelp.com"}, -{"id":948,"firstName":"Auria","lastName":"Beric","street":"5 Anderson Way","postalCode":"20022","city":"Washington","state":"DC","email":"abericqb@a8.net"}, -{"id":949,"firstName":"Eirena","lastName":"Caswall","street":"4648 Fulton Street","postalCode":"64054","city":"Independence","state":"MO","phoneNumber":"816-406-0779","email":"ecaswallqc@i2i.jp"}, -{"id":950,"firstName":"Tracy","lastName":"Sperwell","street":"4 Heath Drive","postalCode":"91499","city":"Van Nuys","state":"CA"}, -{"id":951,"firstName":"Cherilyn","lastName":"Faint","street":"814 Anniversary Lane","postalCode":"24503","city":"Lynchburg","state":"VA","phoneNumber":"434-722-2344","email":"cfaintqe@amazon.de"}, -{"id":952,"firstName":"Sela","lastName":"Darcey","street":"002 Walton Hill","postalCode":"78703","city":"Austin","state":"TX","email":"sdarceyqf@lycos.com"}, -{"id":953,"firstName":"Freddie","lastName":"Klagge","street":"842 Schlimgen Road","postalCode":"29905","city":"Beaufort","state":"SC","email":"fklaggeqg@1und1.de"}, -{"id":954,"firstName":"Eunice","lastName":"Walrond","street":"4 Mifflin Terrace","postalCode":"68117","city":"Omaha","state":"NE","email":"ewalrondqh@arstechnica.com"}, -{"id":955,"firstName":"Adelbert","lastName":"Meuse","street":"971 Doe Crossing Court","postalCode":"27157","city":"Winston Salem","state":"NC"}, -{"id":956,"firstName":"Caitlin","lastName":"Windham","street":"29 Cordelia Alley","postalCode":"76210","city":"Denton","state":"TX","phoneNumber":"214-498-2801","email":"cwindhamqj@trellian.com"}, -{"id":957,"firstName":"Jere","lastName":"Presho","street":"7 Monica Plaza","postalCode":"75710","city":"Tyler","state":"TX","email":"jpreshoqk@e-recht24.de"}, -{"id":958,"firstName":"Lonny","lastName":"Cotter","street":"5686 Rutledge Place","postalCode":"40596","city":"Lexington","state":"KY","email":"lcotterql@last.fm"}, -{"id":959,"firstName":"Sarah","lastName":"Earnshaw","street":"69 Prentice Point","postalCode":"60669","city":"Chicago","state":"IL","email":"searnshawqm@ycombinator.com"}, -{"id":960,"firstName":"Claire","lastName":"Minette","street":"3145 Butterfield Terrace","postalCode":"43204","city":"Columbus","state":"OH","phoneNumber":"614-157-5341","email":"cminetteqn@upenn.edu"}, -{"id":961,"firstName":"Traci","lastName":"Farnes","street":"2 Service Circle","postalCode":"06905","city":"Stamford","state":"CT","phoneNumber":"203-311-5859","email":"tfarnesqo@merriam-webster.com"}, -{"id":962,"firstName":"Storm","lastName":"de Werk","street":"9 Jenifer Alley","postalCode":"98121","city":"Seattle","state":"WA","phoneNumber":"425-172-3688"}, -{"id":963,"firstName":"Neile","lastName":"Mackrill","street":"5046 Schurz Point","postalCode":"28299","city":"Charlotte","state":"NC"}, -{"id":964,"firstName":"Temple","lastName":"Howlings","street":"8831 Randy Street","postalCode":"71161","city":"Shreveport","state":"LA","phoneNumber":"318-859-6319","email":"thowlingsqr@smugmug.com"}, -{"id":965,"firstName":"Roda","lastName":"Drissell","street":"16621 Mandrake Lane","postalCode":"78744","city":"Austin","state":"TX","email":"rdrissellqs@mayoclinic.com"}, -{"id":966,"firstName":"Francoise","lastName":"Lawman","street":"7 Calypso Point","postalCode":"14614","city":"Rochester","state":"NY","phoneNumber":"585-995-3882"}, -{"id":967,"firstName":"Helen","lastName":"Kigelman","street":"613 Manley Plaza","postalCode":"01905","city":"Lynn","state":"MA","email":"hkigelmanqu@shutterfly.com"}, -{"id":968,"firstName":"Dudley","lastName":"Cansdall","street":"153 Schmedeman Place","postalCode":"93715","city":"Fresno","state":"CA","email":"dcansdallqv@naver.com"}, -{"id":969,"firstName":"Shelby","lastName":"Fayers","street":"94681 Knutson Point","postalCode":"10039","city":"New York City","state":"NY"}, -{"id":970,"firstName":"Sileas","lastName":"Jalland","street":"2199 Buhler Circle","postalCode":"10029","city":"New York City","state":"NY","phoneNumber":"917-902-1667","email":"sjallandqx@rakuten.co.jp"}, -{"id":971,"firstName":"Zeke","lastName":"Duffett","street":"5 Coolidge Park","postalCode":"37995","city":"Knoxville","state":"TN","phoneNumber":"865-814-8540","email":"zduffettqy@wikispaces.com"}, -{"id":972,"firstName":"Tabby","lastName":"Mathieu","street":"78 Donald Circle","postalCode":"55114","city":"Saint Paul","state":"MN","email":"tmathieuqz@rediff.com"}, -{"id":973,"firstName":"Zsa zsa","lastName":"Knights","street":"208 Kingsford Park","postalCode":"15250","city":"Pittsburgh","state":"PA","phoneNumber":"412-652-8956","email":"zknightsr0@privacy.gov.au"}, -{"id":974,"firstName":"Tildi","lastName":"Knewstub","street":"8572 Gina Hill","postalCode":"32909","city":"Palm Bay","state":"FL","email":"tknewstubr1@archive.org"}, -{"id":975,"firstName":"Eric","lastName":"Wharrier","street":"9 Marcy Alley","postalCode":"38126","city":"Memphis","state":"TN","phoneNumber":"901-378-1545","email":"ewharrierr2@people.com.cn"}, -{"id":976,"firstName":"Jilleen","lastName":"Durgan","street":"7 Lien Plaza","postalCode":"75241","city":"Dallas","state":"TX","email":"jdurganr3@google.pl"}, -{"id":977,"firstName":"Ingeberg","lastName":"Whipp","street":"489 Bartillon Street","postalCode":"22205","city":"Arlington","state":"VA","phoneNumber":"703-356-7728","email":"iwhippr4@un.org"}, -{"id":978,"firstName":"Drake","lastName":"McCreagh","street":"735 Mcguire Lane","postalCode":"20530","city":"Washington","state":"DC","email":"dmccreaghr5@mediafire.com"}, -{"id":979,"firstName":"Byron","lastName":"Eades","street":"931 Hollow Ridge Avenue","postalCode":"23285","city":"Richmond","state":"VA","phoneNumber":"804-728-5669","email":"beadesr6@npr.org"}, -{"id":980,"firstName":"Free","lastName":"Tungate","street":"7037 Ramsey Crossing","postalCode":"64153","city":"Kansas City","state":"MO","email":"ftungater7@macromedia.com"}, -{"id":981,"firstName":"Augustus","lastName":"Benardet","street":"398 Bultman Circle","postalCode":"70165","city":"New Orleans","state":"LA"}, -{"id":982,"firstName":"Sanders","lastName":"Sullens","street":"75785 Westend Terrace","postalCode":"43656","city":"Toledo","state":"OH","phoneNumber":"419-314-1134"}, -{"id":983,"firstName":"Ynes","lastName":"Troup","street":"328 Schurz Trail","postalCode":"98907","city":"Yakima","state":"WA","phoneNumber":"509-696-5645"}, -{"id":984,"firstName":"Siana","lastName":"Bernath","street":"968 Sommers Lane","postalCode":"55487","city":"Minneapolis","state":"MN","phoneNumber":"612-351-3016"}, -{"id":985,"firstName":"Ellary","lastName":"Enders","street":"2 Charing Cross Court","postalCode":"06505","city":"New Haven","state":"CT","phoneNumber":"203-608-5058"}, -{"id":986,"firstName":"Mariann","lastName":"Damerell","street":"885 Pennsylvania Crossing","postalCode":"15220","city":"Pittsburgh","state":"PA","phoneNumber":"412-667-1349","email":"mdamerellrd@moonfruit.com"}, -{"id":987,"firstName":"Timotheus","lastName":"Muncer","street":"293 Hoepker Center","postalCode":"32405","city":"Panama City","state":"FL","phoneNumber":"850-740-2501","email":"tmuncerre@ifeng.com"}, -{"id":988,"firstName":"Hermina","lastName":"Tetsall","street":"9354 Nobel Road","postalCode":"55585","city":"Monticello","state":"MN","phoneNumber":"763-292-3970","email":"htetsallrf@wsj.com"}, -{"id":989,"firstName":"Dorelia","lastName":"Howship","street":"747 Namekagon Way","postalCode":"14269","city":"Buffalo","state":"NY","phoneNumber":"716-470-3584","email":"dhowshiprg@un.org"}, -{"id":990,"firstName":"Peggy","lastName":"Coutts","street":"34 Village Green Road","postalCode":"19131","city":"Philadelphia","state":"PA"}, -{"id":991,"firstName":"Dacey","lastName":"Inglefield","street":"05227 Buell Avenue","postalCode":"45414","city":"Dayton","state":"OH"}, -{"id":992,"firstName":"Hollyanne","lastName":"Hobbema","street":"684 La Follette Drive","postalCode":"45218","city":"Cincinnati","state":"OH","phoneNumber":"513-346-0258"}, -{"id":993,"firstName":"Freedman","lastName":"Whorlow","street":"291 Maywood Pass","postalCode":"48098","city":"Troy","state":"MI","phoneNumber":"248-890-5937"}, -{"id":994,"firstName":"Karine","lastName":"Gerring","street":"163 Graceland Street","postalCode":"95397","city":"Modesto","state":"CA"}, -{"id":995,"firstName":"Sonya","lastName":"Giercke","street":"1801 Rowland Junction","postalCode":"66215","city":"Shawnee Mission","state":"KS","email":"sgierckerm@mapquest.com"}, -{"id":996,"firstName":"Fabiano","lastName":"O'Hear","street":"87555 Sunnyside Plaza","postalCode":"33330","city":"Fort Lauderdale","state":"FL","email":"fohearrn@china.com.cn"}, -{"id":997,"firstName":"Lelia","lastName":"Gillman","street":"29838 Eagan Junction","postalCode":"78783","city":"Austin","state":"TX","phoneNumber":"512-515-1461","email":"lgillmanro@amazon.co.jp"}, -{"id":998,"firstName":"Ophelie","lastName":"Richardet","street":"9 Bay Point","postalCode":"94042","city":"Mountain View","state":"CA"}, -{"id":999,"firstName":"Batholomew","lastName":"Janzen","street":"9 Rigney Alley","postalCode":"95113","city":"San Jose","state":"CA"}, -{"id":1000,"firstName":"Kirstyn","lastName":"Bixley","street":"2 Cascade Trail","postalCode":"80015","city":"Aurora","state":"CO","phoneNumber":"303-339-2309","email":"kbixleyrr@i2i.jp"}] \ No newline at end of file From 6947342212b484dcf530ae39ce9a358d7adc8ed6 Mon Sep 17 00:00:00 2001 From: Karsten Silz Date: Mon, 21 Sep 2020 20:44:47 +0100 Subject: [PATCH 196/263] Undoing another change. --- json/pom.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/json/pom.xml b/json/pom.xml index 99fcfed362..bd901b526e 100644 --- a/json/pom.xml +++ b/json/pom.xml @@ -45,11 +45,6 @@ jackson-databind ${jackson.version} - - com.fasterxml.jackson.core - jackson-annotations - ${jackson.version} - javax.json.bind javax.json.bind-api From 9be17d36d21eb55f67e84521245f90a3896a1f16 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Tue, 22 Sep 2020 14:57:32 +0200 Subject: [PATCH 197/263] JAVA-2976: Get rid of the overriden spring-boot.version property --- .../spring-boot-property-exp/property-exp-custom-config/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/pom.xml b/spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/pom.xml index e38a2742d5..f0df50cf76 100644 --- a/spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/pom.xml +++ b/spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/pom.xml @@ -78,7 +78,6 @@ - 2.2.6.RELEASE Custom Property Value 2.7 1.6.0 From 5590f2389673c7be59ceaf197ce2bc2966483291 Mon Sep 17 00:00:00 2001 From: fdpro Date: Tue, 22 Sep 2020 21:49:49 +0200 Subject: [PATCH 198/263] [JAVA-2587] Added spring-boot dependency for freemarker --- spring-mvc-basics-2/pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spring-mvc-basics-2/pom.xml b/spring-mvc-basics-2/pom.xml index 6bcb1e90e5..c4688ffad6 100644 --- a/spring-mvc-basics-2/pom.xml +++ b/spring-mvc-basics-2/pom.xml @@ -84,6 +84,11 @@ spring-context-support ${spring.version} + + org.springframework.boot + spring-boot-starter-freemarker + ${spring-boot.version} + @@ -173,6 +178,7 @@ 5.1.0 20180130 1.6.1 + 2.3.4.RELEASE From 9f51e1c6e55bc55dbe69acf20179cc63fd7d0ddc Mon Sep 17 00:00:00 2001 From: Bruno Fontana Date: Tue, 22 Sep 2020 18:21:24 -0300 Subject: [PATCH 199/263] Assume Class examples redone. --- .../ConditionallyIgnoreTestsUnitTest.java | 64 ++++++++++++------- 1 file changed, 41 insertions(+), 23 deletions(-) diff --git a/testing-modules/junit-4/src/test/java/com/baeldung/assume/ConditionallyIgnoreTestsUnitTest.java b/testing-modules/junit-4/src/test/java/com/baeldung/assume/ConditionallyIgnoreTestsUnitTest.java index 0aa184f2e1..b3fd5e3b2c 100644 --- a/testing-modules/junit-4/src/test/java/com/baeldung/assume/ConditionallyIgnoreTestsUnitTest.java +++ b/testing-modules/junit-4/src/test/java/com/baeldung/assume/ConditionallyIgnoreTestsUnitTest.java @@ -5,37 +5,55 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assume.assumeFalse; import static org.junit.Assume.assumeThat; import static org.junit.Assume.assumeTrue; +import static org.junit.Assume.assumeNotNull; +import static org.junit.Assume.assumeNoException; + import org.junit.Test; public class ConditionallyIgnoreTestsUnitTest { + @Test public void whenAssumeThatAndOSIsLinux_thenRunTest() { + assumeThat(getOsName(), is("Linux")); + assertEquals("run", "RUN".toLowerCase()); + } - @Test - public void whenAssumeThatCodeVersionIsNot2_thenIgnore() { - final int codeVersion = 1; - assumeThat(codeVersion, is(2)); + @Test public void whenAssumeTrueAndOSIsLinux_thenRunTest() { + final int codeVersion = 1; + assumeTrue(isExpectedOS(getOsName())); + assertEquals("run", "RUN".toLowerCase()); + } - assertEquals("hello", "HELLO".toLowerCase()); + @Test public void whenAssumeFalseAndOSIsLinux_thenIgnore() { + assumeFalse(isExpectedOS(getOsName())); + assertEquals("run", "RUN".toLowerCase()); + } + + @Test public void whenAssumeNotNullAndNotNullOSVersion_thenIgnore() { + assumeNotNull(getOsName()); + assertEquals("run", "RUN".toLowerCase()); + } + + /** + * Let's use a different example here. + */ + @Test public void whenAssumeNoExceptionAndExceptionThrown_thenIgnore() { + assertEquals("everything ok", "EVERYTHING OK".toLowerCase()); + String t = null; + try { + t.charAt(0); + } catch (NullPointerException npe) { + assumeNoException(npe); } + assertEquals("run", "RUN".toLowerCase()); + } - @Test - public void whenAssumeTrueOnCondition_thenIgnore() { - final int codeVersion = 1; - assumeTrue(isCodeVersion2(codeVersion)); + private boolean isExpectedOS(final String osName) { + return "Linux".equals(osName); + } - assertEquals("hello", "HELLO".toLowerCase()); - } - - @Test - public void whenAssumeFalseOnCondition_thenIgnore() { - final int codeVersion = 2; - assumeFalse(isCodeVersion2(codeVersion)); - - assertEquals("hello", "HELLO".toLowerCase()); - } - - private boolean isCodeVersion2(final int codeVersion) { - return codeVersion == 2; - } + // This should use System.getProperty("os.name") in a real test. + private String getOsName() { + return "Linux"; + } } From 8b0b645e6fd48b5e6288f924625178ff0c9e5986 Mon Sep 17 00:00:00 2001 From: Kai Yuan Date: Tue, 22 Sep 2020 00:41:23 +0200 Subject: [PATCH 200/263] [BAEL-4612] get spring boot port at runtime --- .../serverport/GetServerPortApplication.java | 12 ++++ .../serverport/ServerPortService.java | 20 +++++++ .../GetServerFixedPortUnitTest.java | 37 +++++++++++++ .../GetServerRandomPortUnitTest.java | 55 +++++++++++++++++++ .../application-fixedport.properties | 1 + .../application-randomport.properties | 1 + 6 files changed, 126 insertions(+) create mode 100644 spring-boot-modules/spring-boot-environment/src/main/java/com/baeldung/serverport/GetServerPortApplication.java create mode 100644 spring-boot-modules/spring-boot-environment/src/main/java/com/baeldung/serverport/ServerPortService.java create mode 100644 spring-boot-modules/spring-boot-environment/src/test/java/com/baeldung/serverport/GetServerFixedPortUnitTest.java create mode 100644 spring-boot-modules/spring-boot-environment/src/test/java/com/baeldung/serverport/GetServerRandomPortUnitTest.java create mode 100644 spring-boot-modules/spring-boot-environment/src/test/resources/application-fixedport.properties create mode 100644 spring-boot-modules/spring-boot-environment/src/test/resources/application-randomport.properties diff --git a/spring-boot-modules/spring-boot-environment/src/main/java/com/baeldung/serverport/GetServerPortApplication.java b/spring-boot-modules/spring-boot-environment/src/main/java/com/baeldung/serverport/GetServerPortApplication.java new file mode 100644 index 0000000000..d7658ad8d5 --- /dev/null +++ b/spring-boot-modules/spring-boot-environment/src/main/java/com/baeldung/serverport/GetServerPortApplication.java @@ -0,0 +1,12 @@ +package com.baeldung.serverport; + + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class GetServerPortApplication { + public static void main(String[] args) { + SpringApplication.run(GetServerPortApplication.class, args); + } +} diff --git a/spring-boot-modules/spring-boot-environment/src/main/java/com/baeldung/serverport/ServerPortService.java b/spring-boot-modules/spring-boot-environment/src/main/java/com/baeldung/serverport/ServerPortService.java new file mode 100644 index 0000000000..59c0a0f333 --- /dev/null +++ b/spring-boot-modules/spring-boot-environment/src/main/java/com/baeldung/serverport/ServerPortService.java @@ -0,0 +1,20 @@ +package com.baeldung.serverport; + +import org.springframework.boot.web.servlet.context.ServletWebServerInitializedEvent; +import org.springframework.context.event.EventListener; +import org.springframework.stereotype.Service; + +@Service +public class ServerPortService { + private int port; + + public int getPort() { + return port; + } + + @EventListener + public void onApplicationEvent(final ServletWebServerInitializedEvent event) { + port = event.getWebServer().getPort(); + } + +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-environment/src/test/java/com/baeldung/serverport/GetServerFixedPortUnitTest.java b/spring-boot-modules/spring-boot-environment/src/test/java/com/baeldung/serverport/GetServerFixedPortUnitTest.java new file mode 100644 index 0000000000..81e663b7a1 --- /dev/null +++ b/spring-boot-modules/spring-boot-environment/src/test/java/com/baeldung/serverport/GetServerFixedPortUnitTest.java @@ -0,0 +1,37 @@ +package com.baeldung.serverport; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.web.ServerProperties; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + +import static org.junit.Assert.assertEquals; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = GetServerPortApplication.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) +@ActiveProfiles("fixedport") +public class GetServerFixedPortUnitTest { + private final static int EXPECTED_PORT = 7777; + + @Value("${server.port}") + private int serverPort; + + @Autowired + private ServerProperties serverProperties; + + @Test + public void givenFixedPortAsServerPort_whenReadServerPort_thenGetThePort() { + assertEquals("Reading fixed port by @Value(\"${server.port}\") will get the port.", EXPECTED_PORT, serverPort); + } + + @Test + public void givenFixedPortAsServerPort_whenReadServerProps_thenGetThePort() { + int port = serverProperties.getPort(); + assertEquals("Reading fixed port from serverProperties will get the port.", EXPECTED_PORT, port); + } + +} diff --git a/spring-boot-modules/spring-boot-environment/src/test/java/com/baeldung/serverport/GetServerRandomPortUnitTest.java b/spring-boot-modules/spring-boot-environment/src/test/java/com/baeldung/serverport/GetServerRandomPortUnitTest.java new file mode 100644 index 0000000000..3ad7e0fdf1 --- /dev/null +++ b/spring-boot-modules/spring-boot-environment/src/test/java/com/baeldung/serverport/GetServerRandomPortUnitTest.java @@ -0,0 +1,55 @@ +package com.baeldung.serverport; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.web.ServerProperties; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = GetServerPortApplication.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) +@ActiveProfiles("randomport") +public class GetServerRandomPortUnitTest { + + @Value("${server.port}") + private int randomServerPort; + + @Autowired + private ServerPortService serverPortService; + + @Autowired + private ServerProperties serverProperties; + + @Autowired + private ServletWebServerApplicationContext webServerAppCtxt; + + @Test + public void given0AsServerPort_whenReadServerPort_thenGet0() { + assertEquals("Reading random port by @Value(\"${server.port}\") will get 0.", 0, randomServerPort); + } + + @Test + public void given0AsServerPort_whenReadServerProps_thenGet0() { + int port = serverProperties.getPort(); + assertEquals("Reading random port by serverProperties will get 0.", 0, port); + } + + @Test + public void given0AsServerPort_whenReadWebAppCtxt_thenGetThePort() { + int port = webServerAppCtxt.getWebServer().getPort(); + assertTrue("The random port should be greater than 1023", port > 1023); + } + + @Test + public void given0AsServerPort_whenReadFromListener_thenGetThePort() { + int port = serverPortService.getPort(); + assertTrue("The random port should be greater than 1023", port > 1023); + } +} diff --git a/spring-boot-modules/spring-boot-environment/src/test/resources/application-fixedport.properties b/spring-boot-modules/spring-boot-environment/src/test/resources/application-fixedport.properties new file mode 100644 index 0000000000..0c5e84f3a2 --- /dev/null +++ b/spring-boot-modules/spring-boot-environment/src/test/resources/application-fixedport.properties @@ -0,0 +1 @@ +server.port=7777 diff --git a/spring-boot-modules/spring-boot-environment/src/test/resources/application-randomport.properties b/spring-boot-modules/spring-boot-environment/src/test/resources/application-randomport.properties new file mode 100644 index 0000000000..cbe617ef03 --- /dev/null +++ b/spring-boot-modules/spring-boot-environment/src/test/resources/application-randomport.properties @@ -0,0 +1 @@ +server.port=0 From 9a8f92de763b47f08928c69d11b7aab5e4e85b05 Mon Sep 17 00:00:00 2001 From: Bruno Fontana Date: Tue, 22 Sep 2020 20:54:25 -0300 Subject: [PATCH 201/263] Fixing formatting issues. --- .../ConditionallyIgnoreTestsUnitTest.java | 86 ++++++++++--------- 1 file changed, 45 insertions(+), 41 deletions(-) diff --git a/testing-modules/junit-4/src/test/java/com/baeldung/assume/ConditionallyIgnoreTestsUnitTest.java b/testing-modules/junit-4/src/test/java/com/baeldung/assume/ConditionallyIgnoreTestsUnitTest.java index b3fd5e3b2c..9f927310b3 100644 --- a/testing-modules/junit-4/src/test/java/com/baeldung/assume/ConditionallyIgnoreTestsUnitTest.java +++ b/testing-modules/junit-4/src/test/java/com/baeldung/assume/ConditionallyIgnoreTestsUnitTest.java @@ -13,47 +13,51 @@ import org.junit.Test; public class ConditionallyIgnoreTestsUnitTest { - @Test public void whenAssumeThatAndOSIsLinux_thenRunTest() { - assumeThat(getOsName(), is("Linux")); - assertEquals("run", "RUN".toLowerCase()); - } - - @Test public void whenAssumeTrueAndOSIsLinux_thenRunTest() { - final int codeVersion = 1; - assumeTrue(isExpectedOS(getOsName())); - assertEquals("run", "RUN".toLowerCase()); - } - - @Test public void whenAssumeFalseAndOSIsLinux_thenIgnore() { - assumeFalse(isExpectedOS(getOsName())); - assertEquals("run", "RUN".toLowerCase()); - } - - @Test public void whenAssumeNotNullAndNotNullOSVersion_thenIgnore() { - assumeNotNull(getOsName()); - assertEquals("run", "RUN".toLowerCase()); - } - - /** - * Let's use a different example here. - */ - @Test public void whenAssumeNoExceptionAndExceptionThrown_thenIgnore() { - assertEquals("everything ok", "EVERYTHING OK".toLowerCase()); - String t = null; - try { - t.charAt(0); - } catch (NullPointerException npe) { - assumeNoException(npe); + @Test + public void whenAssumeThatAndOSIsLinux_thenRunTest() { + assumeThat(getOsName(), is("Linux")); + assertEquals("run", "RUN".toLowerCase()); } - assertEquals("run", "RUN".toLowerCase()); - } - private boolean isExpectedOS(final String osName) { - return "Linux".equals(osName); - } + @Test + public void whenAssumeTrueAndOSIsLinux_thenRunTest() { + assumeTrue(isExpectedOS(getOsName())); + assertEquals("run", "RUN".toLowerCase()); + } - // This should use System.getProperty("os.name") in a real test. - private String getOsName() { - return "Linux"; - } -} + @Test + public void whenAssumeFalseAndOSIsLinux_thenIgnore() { + assumeFalse(isExpectedOS(getOsName())); + assertEquals("run", "RUN".toLowerCase()); + } + + @Test + public void whenAssumeNotNullAndNotNullOSVersion_thenRun() { + assumeNotNull(getOsName()); + assertEquals("run", "RUN".toLowerCase()); + } + + /** + * Let's use a different example here. + */ + @Test + public void whenAssumeNoExceptionAndExceptionThrown_thenIgnore() { + assertEquals("everything ok", "EVERYTHING OK".toLowerCase()); + String t = null; + try { + t.charAt(0); + } catch (NullPointerException npe) { + assumeNoException(npe); + } + assertEquals("run", "RUN".toLowerCase()); + } + + private boolean isExpectedOS(final String osName) { + return "Linux".equals(osName); + } + + // This should use System.getProperty("os.name") in a real test. + private String getOsName() { + return "Linux"; + } +} \ No newline at end of file From 465a878d02e5f2b4140ffd6bce02beb76aa01e73 Mon Sep 17 00:00:00 2001 From: Cristian Rosu Date: Wed, 23 Sep 2020 17:34:42 +0300 Subject: [PATCH 202/263] BAEL-4415 correct package name --- .../baeldung/trustedcert}/CertificatesUnitTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename core-java-modules/core-java-security-2/src/test/java/{certificates => com/baeldung/trustedcert}/CertificatesUnitTest.java (99%) diff --git a/core-java-modules/core-java-security-2/src/test/java/certificates/CertificatesUnitTest.java b/core-java-modules/core-java-security-2/src/test/java/com/baeldung/trustedcert/CertificatesUnitTest.java similarity index 99% rename from core-java-modules/core-java-security-2/src/test/java/certificates/CertificatesUnitTest.java rename to core-java-modules/core-java-security-2/src/test/java/com/baeldung/trustedcert/CertificatesUnitTest.java index a631df086b..d99589a2ec 100644 --- a/core-java-modules/core-java-security-2/src/test/java/certificates/CertificatesUnitTest.java +++ b/core-java-modules/core-java-security-2/src/test/java/com/baeldung/trustedcert/CertificatesUnitTest.java @@ -1,4 +1,4 @@ -package certificates; +package com.baeldung.trustedcert; import org.junit.jupiter.api.Test; From 478e6ccff6b60de96d4cabbaaa042d1ca45496ea Mon Sep 17 00:00:00 2001 From: Cristian Rosu Date: Wed, 23 Sep 2020 17:36:48 +0300 Subject: [PATCH 203/263] BAEL-4415 correct line continuations indent to 2 spaces --- .../baeldung/trustedcert/CertificatesUnitTest.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/core-java-modules/core-java-security-2/src/test/java/com/baeldung/trustedcert/CertificatesUnitTest.java b/core-java-modules/core-java-security-2/src/test/java/com/baeldung/trustedcert/CertificatesUnitTest.java index d99589a2ec..4f40c3c195 100644 --- a/core-java-modules/core-java-security-2/src/test/java/com/baeldung/trustedcert/CertificatesUnitTest.java +++ b/core-java-modules/core-java-security-2/src/test/java/com/baeldung/trustedcert/CertificatesUnitTest.java @@ -39,8 +39,8 @@ public class CertificatesUnitTest { Set trustAnchors = params.getTrustAnchors(); List certificates = trustAnchors.stream() - .map(TrustAnchor::getTrustedCert) - .collect(Collectors.toList()); + .map(TrustAnchor::getTrustedCert) + .collect(Collectors.toList()); assertFalse(certificates.isEmpty()); } @@ -52,11 +52,11 @@ public class CertificatesUnitTest { List trustManagers = Arrays.asList(trustManagerFactory.getTrustManagers()); List certificates = trustManagers.stream() - .filter(X509TrustManager.class::isInstance) - .map(X509TrustManager.class::cast) - .map(trustManager -> Arrays.asList(trustManager.getAcceptedIssuers())) - .flatMap(Collection::stream) - .collect(Collectors.toList()); + .filter(X509TrustManager.class::isInstance) + .map(X509TrustManager.class::cast) + .map(trustManager -> Arrays.asList(trustManager.getAcceptedIssuers())) + .flatMap(Collection::stream) + .collect(Collectors.toList()); assertFalse(certificates.isEmpty()); } From 20a3070093b70bdc6b80c6cf1a8716537b366df8 Mon Sep 17 00:00:00 2001 From: Cristian Stancalau Date: Wed, 23 Sep 2020 19:23:50 +0300 Subject: [PATCH 204/263] BAEL-4156 Does a method's signature in Java include its return type? (#10049) * BAEL-4156 Does a method's signature in Java include its return type? * BAEL-4156 Add varargs * Update OverloadingErrors.java Co-authored-by: Cristian Stancalau --- .../baeldung/signature/OverloadingErrors.java | 72 +++++++++++++++++++ .../com/baeldung/signature/StaticBinding.java | 46 ++++++++++++ 2 files changed, 118 insertions(+) create mode 100644 core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/signature/OverloadingErrors.java create mode 100644 core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/signature/StaticBinding.java diff --git a/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/signature/OverloadingErrors.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/signature/OverloadingErrors.java new file mode 100644 index 0000000000..4c9d11d925 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/signature/OverloadingErrors.java @@ -0,0 +1,72 @@ +package com.baeldung.signature; + +import java.io.Serializable; + +public class OverloadingErrors { + + public void print() { + System.out.println("Signature is: print()"); + } + + /* + // Uncommenting this method will lead to a compilation error: java: method print() is already defined in class + // The method signature is independent from return type + public int print() { + System.out.println("Signature is: print()"); + return 0; + } + */ + + /* + // Uncommenting this method will lead to a compilation error: java: method print() is already defined in class + // The method signature is independent from modifiers + private final void print() { + System.out.println("Signature is: print()"); + } + */ + + /* + // Uncommenting this method will lead to a compilation error: java: method print() is already defined in class + // The method signature is independent from thrown exception declaration + public void print() throws IllegalStateException { + System.out.println("Signature is: print()"); + throw new IllegalStateException(); + } + */ + + public void print(int parameter) { + System.out.println("Signature is: print(int)"); + } + + /* + // Uncommenting this method will lead to a compilation error: java: method print(int) is already defined in class + // The method signature is independent from parameter names + public void print(int anotherParameter) { + System.out.println("Signature is: print(int)"); + } + */ + + public void printElement(T t) { + System.out.println("Signature is: printElement(T)"); + } + + /* + // Uncommenting this method will lead to a compilation error: java: name clash: printElement(java.io.Serializable) and printElement(T) have the same erasure + // Even though the signatures appear different, the compiler cannot statically bind the correct method after type erasure + public void printElement(Serializable o) { + System.out.println("Signature is: printElement(Serializable)"); + } + */ + + public void print(Object... parameter) { + System.out.println("Signature is: print(Object...)"); + } + + /* + // Uncommenting this method will lead to a compilation error: java cannot declare both sum(Object...) and sum(Object[]) + // Even though the signatures appear different, after compilation they both resolve to sum(Object[]) + public void print(Object[] parameter) { + System.out.println("Signature is: print(Object[])"); + } + */ +} diff --git a/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/signature/StaticBinding.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/signature/StaticBinding.java new file mode 100644 index 0000000000..01016812f0 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/signature/StaticBinding.java @@ -0,0 +1,46 @@ +package com.baeldung.signature; + +public class StaticBinding { + + public Number sum(Integer term1, Integer term2) { + System.out.println("Adding integers"); + return term1 + term2; + } + + public Number sum(Number term1, Number term2) { + System.out.println("Adding numbers"); + return term1.doubleValue() + term2.doubleValue(); + } + + public Number sum(Object term1, Object term2) { + System.out.println("Adding objects"); + return term1.hashCode() + term2.hashCode(); + } + + public Number sum(Object term1, Object... term2) { + System.out.println("Adding variable arguments: " + term2.length); + int result = term1.hashCode(); + for (Object o : term2) { + result += o.hashCode(); + } + return result; + } + + public static void main(String[] args) { + StaticBinding obj = new StaticBinding(); + + obj.sum(2, 3); // "Adding integers" due to auto-boxing from int to Integer + obj.sum(Integer.valueOf(2), Integer.valueOf(3)); // "Adding integers" due to exact parameter types + obj.sum(2, 0x1); // "Adding integers" due to type promotion from byte to int + + obj.sum((Number) 2, (Number) 3); // "Adding numbers" due to explicit cast to Number + obj.sum(2.0d, 3.0d); // "Adding numbers" due to auto-boxing from double to Double + obj.sum(Float.valueOf(2), Float.valueOf(3)); // "Adding numbers" due to polimorphism + + obj.sum((Object) 2, (Object) 3); // "Adding objects" due to explicit cast to Object + obj.sum(2, "John"); // "Adding objects" due to polimorphism + + obj.sum(new Object(), new Object(), new Object()); // "Adding variable arguments 2" + obj.sum(new Object(), new Object[]{new Object()}); // "Adding variable arguments 1" + } +} From a2751ea0d5ab98c72f0df508286948b5f6253e9c Mon Sep 17 00:00:00 2001 From: fdpro Date: Wed, 23 Sep 2020 19:31:59 +0200 Subject: [PATCH 205/263] [JAVA-2590] Added example of @JdbcTest usage --- .../template/testing/EmployeeApplication.java | 7 ++++++ .../jdbc/template/testing/EmployeeDAO.java | 4 ++++ .../testing/EmployeeDAOIntegrationTest.java | 24 +++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/testing/EmployeeApplication.java create mode 100644 persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/template/testing/EmployeeDAOIntegrationTest.java diff --git a/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/testing/EmployeeApplication.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/testing/EmployeeApplication.java new file mode 100644 index 0000000000..a2917be105 --- /dev/null +++ b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/testing/EmployeeApplication.java @@ -0,0 +1,7 @@ +package com.baeldung.spring.jdbc.template.testing; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class EmployeeApplication { +} diff --git a/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/testing/EmployeeDAO.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/testing/EmployeeDAO.java index 64b146fd47..15da78ce35 100644 --- a/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/testing/EmployeeDAO.java +++ b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/template/testing/EmployeeDAO.java @@ -13,6 +13,10 @@ public class EmployeeDAO { jdbcTemplate = new JdbcTemplate(dataSource); } + public void setJdbcTemplate(JdbcTemplate jdbcTemplate) { + this.jdbcTemplate = jdbcTemplate; + } + public int getCountOfEmployees() { return jdbcTemplate.queryForObject("SELECT COUNT(*) FROM EMPLOYEE", Integer.class); } diff --git a/persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/template/testing/EmployeeDAOIntegrationTest.java b/persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/template/testing/EmployeeDAOIntegrationTest.java new file mode 100644 index 0000000000..9634c3e0d7 --- /dev/null +++ b/persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/template/testing/EmployeeDAOIntegrationTest.java @@ -0,0 +1,24 @@ +package com.baeldung.spring.jdbc.template.testing; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.JdbcTest; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.test.context.jdbc.Sql; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +@JdbcTest +@Sql({"schema.sql", "test-data.sql"}) +class EmployeeDAOIntegrationTest { + @Autowired + private JdbcTemplate jdbcTemplate; + + @Test + void whenInjectInMemoryDataSource_thenReturnCorrectEmployeeCount() { + EmployeeDAO employeeDAO = new EmployeeDAO(); + employeeDAO.setJdbcTemplate(jdbcTemplate); + + assertEquals(4, employeeDAO.getCountOfEmployees()); + } +} From 49590633a82ff00541438c0d86f633426973ebae Mon Sep 17 00:00:00 2001 From: Sampada <46674082+sampada07@users.noreply.github.com> Date: Wed, 23 Sep 2020 23:34:51 +0530 Subject: [PATCH 206/263] JAVA-2421: Merge spring-ehcache module into spring-caching module (#10072) * JAVA-2421: Moved 1 article from spring-ehcache to spring-caching * JAVA-2421: Removed module spring-ehcache * JAVA-2421: Removed module spring-ehcache from main pom --- pom.xml | 2 - spring-caching/README.md | 1 + spring-caching/pom.xml | 4 + .../com/baeldung/cachetest/Application.java | 0 .../cachetest/config/CacheConfig.java | 0 .../cachetest/config/CacheEventLogger.java | 0 .../cachetest/rest/NumberController.java | 0 .../cachetest/service/NumberService.java | 0 .../springdatacaching/model/Book.java | 4 +- .../src/main/resources/application.properties | 5 +- .../src/main/resources/ehcache.xml | 23 +++++ spring-ehcache/.gitignore | 13 --- spring-ehcache/README.md | 8 -- spring-ehcache/checkstyle.xml | 11 --- spring-ehcache/pom.xml | 87 ------------------- .../src/main/resources/application.properties | 1 - 16 files changed, 35 insertions(+), 124 deletions(-) rename {spring-ehcache => spring-caching}/src/main/java/com/baeldung/cachetest/Application.java (100%) rename {spring-ehcache => spring-caching}/src/main/java/com/baeldung/cachetest/config/CacheConfig.java (100%) rename {spring-ehcache => spring-caching}/src/main/java/com/baeldung/cachetest/config/CacheEventLogger.java (100%) rename {spring-ehcache => spring-caching}/src/main/java/com/baeldung/cachetest/rest/NumberController.java (100%) rename {spring-ehcache => spring-caching}/src/main/java/com/baeldung/cachetest/service/NumberService.java (100%) rename {spring-ehcache => spring-caching}/src/main/resources/ehcache.xml (58%) delete mode 100644 spring-ehcache/.gitignore delete mode 100644 spring-ehcache/README.md delete mode 100644 spring-ehcache/checkstyle.xml delete mode 100644 spring-ehcache/pom.xml delete mode 100644 spring-ehcache/src/main/resources/application.properties diff --git a/pom.xml b/pom.xml index 9fd8f65a61..6553716d63 100644 --- a/pom.xml +++ b/pom.xml @@ -651,7 +651,6 @@ spring-dispatcher-servlet spring-drools - spring-ehcache spring-ejb spring-exceptions @@ -1152,7 +1151,6 @@ spring-dispatcher-servlet spring-drools - spring-ehcache spring-ejb spring-exceptions diff --git a/spring-caching/README.md b/spring-caching/README.md index 705d998b1e..e10d6080e8 100644 --- a/spring-caching/README.md +++ b/spring-caching/README.md @@ -5,3 +5,4 @@ - [Cache Eviction in Spring Boot](https://www.baeldung.com/spring-boot-evict-cache) - [Using Multiple Cache Managers in Spring](https://www.baeldung.com/spring-multiple-cache-managers) - [Testing @Cacheable on Spring Data Repositories](https://www.baeldung.com/spring-data-testing-cacheable) +- [Spring Boot Ehcache Example](https://www.baeldung.com/spring-boot-ehcache) diff --git a/spring-caching/pom.xml b/spring-caching/pom.xml index b13755dafd..f58be35a76 100644 --- a/spring-caching/pom.xml +++ b/spring-caching/pom.xml @@ -36,6 +36,10 @@ org.springframework spring-webmvc + + javax.cache + cache-api + org.ehcache ehcache diff --git a/spring-ehcache/src/main/java/com/baeldung/cachetest/Application.java b/spring-caching/src/main/java/com/baeldung/cachetest/Application.java similarity index 100% rename from spring-ehcache/src/main/java/com/baeldung/cachetest/Application.java rename to spring-caching/src/main/java/com/baeldung/cachetest/Application.java diff --git a/spring-ehcache/src/main/java/com/baeldung/cachetest/config/CacheConfig.java b/spring-caching/src/main/java/com/baeldung/cachetest/config/CacheConfig.java similarity index 100% rename from spring-ehcache/src/main/java/com/baeldung/cachetest/config/CacheConfig.java rename to spring-caching/src/main/java/com/baeldung/cachetest/config/CacheConfig.java diff --git a/spring-ehcache/src/main/java/com/baeldung/cachetest/config/CacheEventLogger.java b/spring-caching/src/main/java/com/baeldung/cachetest/config/CacheEventLogger.java similarity index 100% rename from spring-ehcache/src/main/java/com/baeldung/cachetest/config/CacheEventLogger.java rename to spring-caching/src/main/java/com/baeldung/cachetest/config/CacheEventLogger.java diff --git a/spring-ehcache/src/main/java/com/baeldung/cachetest/rest/NumberController.java b/spring-caching/src/main/java/com/baeldung/cachetest/rest/NumberController.java similarity index 100% rename from spring-ehcache/src/main/java/com/baeldung/cachetest/rest/NumberController.java rename to spring-caching/src/main/java/com/baeldung/cachetest/rest/NumberController.java diff --git a/spring-ehcache/src/main/java/com/baeldung/cachetest/service/NumberService.java b/spring-caching/src/main/java/com/baeldung/cachetest/service/NumberService.java similarity index 100% rename from spring-ehcache/src/main/java/com/baeldung/cachetest/service/NumberService.java rename to spring-caching/src/main/java/com/baeldung/cachetest/service/NumberService.java diff --git a/spring-caching/src/main/java/com/baeldung/springdatacaching/model/Book.java b/spring-caching/src/main/java/com/baeldung/springdatacaching/model/Book.java index 7de567f0db..02285e3894 100644 --- a/spring-caching/src/main/java/com/baeldung/springdatacaching/model/Book.java +++ b/spring-caching/src/main/java/com/baeldung/springdatacaching/model/Book.java @@ -6,13 +6,15 @@ import lombok.NoArgsConstructor; import javax.persistence.Entity; import javax.persistence.Id; + +import java.io.Serializable; import java.util.UUID; @Data @Entity @NoArgsConstructor @AllArgsConstructor -public class Book { +public class Book implements Serializable { @Id private UUID id; diff --git a/spring-caching/src/main/resources/application.properties b/spring-caching/src/main/resources/application.properties index ee7b5e62c0..1039f85a42 100644 --- a/spring-caching/src/main/resources/application.properties +++ b/spring-caching/src/main/resources/application.properties @@ -1,4 +1,4 @@ -spring.datasource.url=jdbc:h2:mem:testdb +spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_ON_EXIT=FALSE spring.datasource.driverClassName=org.h2.Driver spring.datasource.username=sa spring.datasource.password= @@ -6,3 +6,6 @@ spring.datasource.password= # Enabling H2 Console spring.h2.console.enabled=true spring.h2.console.path=/h2 + +#ehcache +spring.cache.jcache.config=classpath:ehcache.xml diff --git a/spring-ehcache/src/main/resources/ehcache.xml b/spring-caching/src/main/resources/ehcache.xml similarity index 58% rename from spring-ehcache/src/main/resources/ehcache.xml rename to spring-caching/src/main/resources/ehcache.xml index caba0f2cc4..4b24394170 100644 --- a/spring-ehcache/src/main/resources/ehcache.xml +++ b/spring-caching/src/main/resources/ehcache.xml @@ -27,5 +27,28 @@ 10 + + + java.lang.String + com.baeldung.springdatacaching.model.Book + + 30 + + + + + com.baeldung.cachetest.config.CacheEventLogger + ASYNCHRONOUS + UNORDERED + CREATED + EXPIRED + + + + + 2 + 10 + + \ No newline at end of file diff --git a/spring-ehcache/.gitignore b/spring-ehcache/.gitignore deleted file mode 100644 index 83c05e60c8..0000000000 --- a/spring-ehcache/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -*.class - -#folders# -/target -/neoDb* -/data -/src/main/webapp/WEB-INF/classes -*/META-INF/* - -# Packaged files # -*.jar -*.war -*.ear \ No newline at end of file diff --git a/spring-ehcache/README.md b/spring-ehcache/README.md deleted file mode 100644 index da7376e476..0000000000 --- a/spring-ehcache/README.md +++ /dev/null @@ -1,8 +0,0 @@ -## Spring Ehcache - -This module contains articles about Spring with Ehcache - -### Relevant Articles: - -- [Spring Boot Ehcache Example](https://www.baeldung.com/spring-boot-ehcache) - diff --git a/spring-ehcache/checkstyle.xml b/spring-ehcache/checkstyle.xml deleted file mode 100644 index 85063a7570..0000000000 --- a/spring-ehcache/checkstyle.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/spring-ehcache/pom.xml b/spring-ehcache/pom.xml deleted file mode 100644 index bf78e1392c..0000000000 --- a/spring-ehcache/pom.xml +++ /dev/null @@ -1,87 +0,0 @@ - - - 4.0.0 - spring-ehcache - 0.1-SNAPSHOT - spring-ehcache - jar - - - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../parent-boot-2 - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-cache - - - javax.cache - cache-api - - - org.ehcache - ehcache - - - - - spring-ehcache - - - src/main/resources - true - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - org.apache.maven.plugins - maven-checkstyle-plugin - ${checkstyle-maven-plugin.version} - - checkstyle.xml - - - - - check - - - - - - - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - ${checkstyle-maven-plugin.version} - - checkstyle.xml - - - - - - - - 3.0.0 - false - - - diff --git a/spring-ehcache/src/main/resources/application.properties b/spring-ehcache/src/main/resources/application.properties deleted file mode 100644 index a5c2964d32..0000000000 --- a/spring-ehcache/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -spring.cache.jcache.config=classpath:ehcache.xml \ No newline at end of file From 68287516fef69d735e1204792a446c1227454aa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Dupire?= Date: Wed, 23 Sep 2020 20:10:21 +0200 Subject: [PATCH 207/263] [JAVA-1669] Upgrading JUnit and Maven Surefire Plugin versions (#10018) * [JAVA-1669] Upgrading JUnit and Maven Surefire Plugin versions * Upgraded JUnit version for persistence-module and the modules that directly depends on it * Upgraded Maven Surefire Plugin version for these as well * Either made modules inheriting from persistence-modules instead of parent-modules or added relative paths when already inheriting persistence-modules * Upgraded versions in other modules * [JAVA-1669] Removed explicit relativePath in pom.xml when default value used * [JAVA-1669] Minor fix --- persistence-modules/apache-bookkeeper/pom.xml | 3 +-- persistence-modules/deltaspike/pom.xml | 7 ------- persistence-modules/flyway-repair/pom.xml | 5 +++++ persistence-modules/flyway/pom.xml | 5 +++++ persistence-modules/jpa-hibernate-cascade-type/pom.xml | 1 + persistence-modules/pom.xml | 5 +++++ persistence-modules/r2dbc/pom.xml | 5 +++++ persistence-modules/redis/pom.xml | 5 +++++ persistence-modules/spring-boot-mysql/pom.xml | 5 +++++ persistence-modules/spring-boot-persistence-2/pom.xml | 8 +++++++- persistence-modules/spring-boot-persistence-h2/pom.xml | 5 +++++ .../spring-boot-persistence-mongodb/pom.xml | 6 ++++++ persistence-modules/spring-boot-persistence/pom.xml | 5 +++++ .../spring-data-cassandra-reactive/pom.xml | 5 +++++ persistence-modules/spring-data-cassandra/pom.xml | 5 +++++ persistence-modules/spring-data-cosmosdb/pom.xml | 5 +++++ persistence-modules/spring-data-dynamodb/pom.xml | 5 +++++ persistence-modules/spring-data-elasticsearch/pom.xml | 5 +++++ persistence-modules/spring-data-jdbc/pom.xml | 7 +++++++ persistence-modules/spring-data-jpa-annotations/pom.xml | 5 +++++ persistence-modules/spring-data-jpa-crud/pom.xml | 5 +++++ persistence-modules/spring-data-jpa-enterprise/pom.xml | 5 +++++ persistence-modules/spring-data-jpa-filtering/pom.xml | 5 +++++ persistence-modules/spring-data-jpa-query-2/pom.xml | 6 ++++++ persistence-modules/spring-data-jpa-query/pom.xml | 5 +++++ persistence-modules/spring-data-jpa-repo-2/pom.xml | 5 +++++ persistence-modules/spring-data-jpa-repo/pom.xml | 6 ++++++ persistence-modules/spring-data-keyvalue/pom.xml | 6 ++++++ persistence-modules/spring-data-mongodb/pom.xml | 5 +++++ persistence-modules/spring-data-redis/pom.xml | 5 +++++ persistence-modules/spring-data-solr/pom.xml | 5 +++++ persistence-modules/spring-hibernate4/pom.xml | 5 +++++ persistence-modules/spring-jdbc/pom.xml | 5 +++++ 33 files changed, 160 insertions(+), 10 deletions(-) diff --git a/persistence-modules/apache-bookkeeper/pom.xml b/persistence-modules/apache-bookkeeper/pom.xml index 0beea7f1fc..32467b9997 100644 --- a/persistence-modules/apache-bookkeeper/pom.xml +++ b/persistence-modules/apache-bookkeeper/pom.xml @@ -11,9 +11,8 @@ com.baeldung - parent-modules + persistence-modules 1.0.0-SNAPSHOT - ../../ diff --git a/persistence-modules/deltaspike/pom.xml b/persistence-modules/deltaspike/pom.xml index 871bacd18b..955ad4abe8 100644 --- a/persistence-modules/deltaspike/pom.xml +++ b/persistence-modules/deltaspike/pom.xml @@ -188,13 +188,6 @@ provided - - - junit - junit - test - - org.apache.commons diff --git a/persistence-modules/flyway-repair/pom.xml b/persistence-modules/flyway-repair/pom.xml index 5a5c4103f6..82e5d705f9 100644 --- a/persistence-modules/flyway-repair/pom.xml +++ b/persistence-modules/flyway-repair/pom.xml @@ -75,6 +75,11 @@ src/main/resources/application-${spring-boot.run.profiles}.properties + + + 2.22.2 + 5.6.2 + 4.13 diff --git a/persistence-modules/flyway/pom.xml b/persistence-modules/flyway/pom.xml index f2e393abbf..2379f996d7 100644 --- a/persistence-modules/flyway/pom.xml +++ b/persistence-modules/flyway/pom.xml @@ -65,6 +65,11 @@ 5.2.3 5.0.2 + + + 2.22.2 + 5.6.2 + 4.13 diff --git a/persistence-modules/jpa-hibernate-cascade-type/pom.xml b/persistence-modules/jpa-hibernate-cascade-type/pom.xml index 1fc119592c..e8117290b0 100644 --- a/persistence-modules/jpa-hibernate-cascade-type/pom.xml +++ b/persistence-modules/jpa-hibernate-cascade-type/pom.xml @@ -4,6 +4,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 jpa-hibernate-cascade-type + com.baeldung persistence-modules diff --git a/persistence-modules/pom.xml b/persistence-modules/pom.xml index 4e46c9204b..def2deb941 100644 --- a/persistence-modules/pom.xml +++ b/persistence-modules/pom.xml @@ -92,5 +92,10 @@ 5.2.17.Final + + + 2.22.2 + 5.6.2 + 4.13 diff --git a/persistence-modules/r2dbc/pom.xml b/persistence-modules/r2dbc/pom.xml index 119d0547e3..7083eea64d 100644 --- a/persistence-modules/r2dbc/pom.xml +++ b/persistence-modules/r2dbc/pom.xml @@ -68,6 +68,11 @@ 0.8.1.RELEASE 1.4.200 + + + 2.22.2 + 5.6.2 + 4.13 diff --git a/persistence-modules/redis/pom.xml b/persistence-modules/redis/pom.xml index e4c5eb4002..9e00566767 100644 --- a/persistence-modules/redis/pom.xml +++ b/persistence-modules/redis/pom.xml @@ -61,6 +61,11 @@ 3.13.1 3.3.0 4.1.50.Final + + + 2.22.2 + 5.6.2 + 4.13 diff --git a/persistence-modules/spring-boot-mysql/pom.xml b/persistence-modules/spring-boot-mysql/pom.xml index 9f6ec73522..9b8c6d0028 100644 --- a/persistence-modules/spring-boot-mysql/pom.xml +++ b/persistence-modules/spring-boot-mysql/pom.xml @@ -39,6 +39,11 @@ 8.0.12 + + + 2.22.2 + 5.6.2 + 4.13 diff --git a/persistence-modules/spring-boot-persistence-2/pom.xml b/persistence-modules/spring-boot-persistence-2/pom.xml index e90d61fda3..ca6ec93340 100644 --- a/persistence-modules/spring-boot-persistence-2/pom.xml +++ b/persistence-modules/spring-boot-persistence-2/pom.xml @@ -17,6 +17,13 @@ + + org.junit + junit-bom + ${junit-jupiter.version} + pom + import + org.springframework.boot spring-boot-dependencies @@ -36,7 +43,6 @@ jdbi3-sqlobject ${jdbi.version} - diff --git a/persistence-modules/spring-boot-persistence-h2/pom.xml b/persistence-modules/spring-boot-persistence-h2/pom.xml index 9e6c780931..23520a3fda 100644 --- a/persistence-modules/spring-boot-persistence-h2/pom.xml +++ b/persistence-modules/spring-boot-persistence-h2/pom.xml @@ -46,6 +46,11 @@ com.baeldung.h2db.demo.server.SpringBootApp 1.0.4 + + + 2.22.2 + 5.6.2 + 4.13 diff --git a/persistence-modules/spring-boot-persistence-mongodb/pom.xml b/persistence-modules/spring-boot-persistence-mongodb/pom.xml index de52a4b2d6..69ef09356d 100644 --- a/persistence-modules/spring-boot-persistence-mongodb/pom.xml +++ b/persistence-modules/spring-boot-persistence-mongodb/pom.xml @@ -36,4 +36,10 @@ + + + 2.22.2 + 5.6.2 + 4.13 + \ No newline at end of file diff --git a/persistence-modules/spring-boot-persistence/pom.xml b/persistence-modules/spring-boot-persistence/pom.xml index 9e44a7b9c1..b034f6dad9 100644 --- a/persistence-modules/spring-boot-persistence/pom.xml +++ b/persistence-modules/spring-boot-persistence/pom.xml @@ -76,6 +76,11 @@ 2.23.0 2.0.1.Final + + + 2.22.2 + 5.6.2 + 4.13 diff --git a/persistence-modules/spring-data-cassandra-reactive/pom.xml b/persistence-modules/spring-data-cassandra-reactive/pom.xml index 16486bf380..42329e03f0 100644 --- a/persistence-modules/spring-data-cassandra-reactive/pom.xml +++ b/persistence-modules/spring-data-cassandra-reactive/pom.xml @@ -53,6 +53,11 @@ 2.2.6.RELEASE 3.11.2.0 + + + 2.22.2 + 5.6.2 + 4.13 diff --git a/persistence-modules/spring-data-cassandra/pom.xml b/persistence-modules/spring-data-cassandra/pom.xml index b44324dc46..a56d067a05 100644 --- a/persistence-modules/spring-data-cassandra/pom.xml +++ b/persistence-modules/spring-data-cassandra/pom.xml @@ -104,6 +104,11 @@ 2.1.9.2 2.1.9.2 2.0-0 + + + 2.22.2 + 5.6.2 + 4.13 diff --git a/persistence-modules/spring-data-cosmosdb/pom.xml b/persistence-modules/spring-data-cosmosdb/pom.xml index 75cc830578..0f9e8ac72f 100644 --- a/persistence-modules/spring-data-cosmosdb/pom.xml +++ b/persistence-modules/spring-data-cosmosdb/pom.xml @@ -16,6 +16,11 @@ 1.8 2.3.0 + + + 2.22.2 + 5.6.2 + 4.13 diff --git a/persistence-modules/spring-data-dynamodb/pom.xml b/persistence-modules/spring-data-dynamodb/pom.xml index 377e35b635..0f4b578088 100644 --- a/persistence-modules/spring-data-dynamodb/pom.xml +++ b/persistence-modules/spring-data-dynamodb/pom.xml @@ -182,6 +182,11 @@ 1.11.86 https://s3-us-west-2.amazonaws.com/dynamodb-local/release 3.1.1 + + + 2.22.2 + 5.6.2 + 4.13 diff --git a/persistence-modules/spring-data-elasticsearch/pom.xml b/persistence-modules/spring-data-elasticsearch/pom.xml index 6a983145ee..c94962d39d 100644 --- a/persistence-modules/spring-data-elasticsearch/pom.xml +++ b/persistence-modules/spring-data-elasticsearch/pom.xml @@ -69,5 +69,10 @@ 1.2.47 0.7 1.15.0 + + + 2.22.2 + 5.6.2 + 4.13 \ No newline at end of file diff --git a/persistence-modules/spring-data-jdbc/pom.xml b/persistence-modules/spring-data-jdbc/pom.xml index ff034104d7..eca8037e20 100644 --- a/persistence-modules/spring-data-jdbc/pom.xml +++ b/persistence-modules/spring-data-jdbc/pom.xml @@ -26,4 +26,11 @@ runtime + + + + 2.22.2 + 5.6.2 + 4.13 + diff --git a/persistence-modules/spring-data-jpa-annotations/pom.xml b/persistence-modules/spring-data-jpa-annotations/pom.xml index 67b788c404..ea2fe34f3c 100644 --- a/persistence-modules/spring-data-jpa-annotations/pom.xml +++ b/persistence-modules/spring-data-jpa-annotations/pom.xml @@ -72,6 +72,11 @@ 1.10.6 42.2.5 21.0 + + + 2.22.2 + 5.6.2 + 4.13 \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-crud/pom.xml b/persistence-modules/spring-data-jpa-crud/pom.xml index 1708d14fc2..44944298e0 100644 --- a/persistence-modules/spring-data-jpa-crud/pom.xml +++ b/persistence-modules/spring-data-jpa-crud/pom.xml @@ -66,6 +66,11 @@ 1.4.1 21.0 1.12.2 + + + 2.22.2 + 5.6.2 + 4.13 diff --git a/persistence-modules/spring-data-jpa-enterprise/pom.xml b/persistence-modules/spring-data-jpa-enterprise/pom.xml index 093059ad78..6d9fc41df6 100644 --- a/persistence-modules/spring-data-jpa-enterprise/pom.xml +++ b/persistence-modules/spring-data-jpa-enterprise/pom.xml @@ -102,6 +102,11 @@ 1.3.1.Final 21.0 1.12.2 + + + 2.22.2 + 5.6.2 + 4.13 diff --git a/persistence-modules/spring-data-jpa-filtering/pom.xml b/persistence-modules/spring-data-jpa-filtering/pom.xml index 2039ef1a37..7448a5a818 100644 --- a/persistence-modules/spring-data-jpa-filtering/pom.xml +++ b/persistence-modules/spring-data-jpa-filtering/pom.xml @@ -72,6 +72,11 @@ 1.10.6 42.2.5 21.0 + + + 2.22.2 + 5.6.2 + 4.13 \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-query-2/pom.xml b/persistence-modules/spring-data-jpa-query-2/pom.xml index 22cd373c95..231640284e 100644 --- a/persistence-modules/spring-data-jpa-query-2/pom.xml +++ b/persistence-modules/spring-data-jpa-query-2/pom.xml @@ -30,4 +30,10 @@ + + + 2.22.2 + 5.6.2 + 4.13 + \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-query/pom.xml b/persistence-modules/spring-data-jpa-query/pom.xml index 71498143c3..fe42d4b595 100644 --- a/persistence-modules/spring-data-jpa-query/pom.xml +++ b/persistence-modules/spring-data-jpa-query/pom.xml @@ -43,6 +43,11 @@ 1.4.1 + + + 2.22.2 + 5.6.2 + 4.13 \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-repo-2/pom.xml b/persistence-modules/spring-data-jpa-repo-2/pom.xml index 855b441074..98ecdc6645 100644 --- a/persistence-modules/spring-data-jpa-repo-2/pom.xml +++ b/persistence-modules/spring-data-jpa-repo-2/pom.xml @@ -43,5 +43,10 @@ 29.0-jre + + + 2.22.2 + 5.6.2 + 4.13 \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-repo/pom.xml b/persistence-modules/spring-data-jpa-repo/pom.xml index 984bc1bdff..07514e9771 100644 --- a/persistence-modules/spring-data-jpa-repo/pom.xml +++ b/persistence-modules/spring-data-jpa-repo/pom.xml @@ -49,4 +49,10 @@ + + + 2.22.2 + 5.6.2 + 4.13 + \ No newline at end of file diff --git a/persistence-modules/spring-data-keyvalue/pom.xml b/persistence-modules/spring-data-keyvalue/pom.xml index b28773c414..190d6c7445 100644 --- a/persistence-modules/spring-data-keyvalue/pom.xml +++ b/persistence-modules/spring-data-keyvalue/pom.xml @@ -28,4 +28,10 @@ + + + 2.22.2 + 5.6.2 + 4.13 + \ No newline at end of file diff --git a/persistence-modules/spring-data-mongodb/pom.xml b/persistence-modules/spring-data-mongodb/pom.xml index 60e59f5186..a3a81fe450 100644 --- a/persistence-modules/spring-data-mongodb/pom.xml +++ b/persistence-modules/spring-data-mongodb/pom.xml @@ -107,6 +107,11 @@ 4.1.0 3.2.0.RELEASE 4.0.5 + + + 2.22.2 + 5.6.2 + 4.13 diff --git a/persistence-modules/spring-data-redis/pom.xml b/persistence-modules/spring-data-redis/pom.xml index d271df31c7..34674dc223 100644 --- a/persistence-modules/spring-data-redis/pom.xml +++ b/persistence-modules/spring-data-redis/pom.xml @@ -98,6 +98,11 @@ 3.2.4 0.10.0 0.6 + + + 2.22.2 + 5.6.2 + 4.13 diff --git a/persistence-modules/spring-data-solr/pom.xml b/persistence-modules/spring-data-solr/pom.xml index 5386c4f9e1..94a796c466 100644 --- a/persistence-modules/spring-data-solr/pom.xml +++ b/persistence-modules/spring-data-solr/pom.xml @@ -45,6 +45,11 @@ 2.0.5.RELEASE + + + 2.22.2 + 5.6.2 + 4.13 \ No newline at end of file diff --git a/persistence-modules/spring-hibernate4/pom.xml b/persistence-modules/spring-hibernate4/pom.xml index 5e931d5cff..3e5a6f913f 100644 --- a/persistence-modules/spring-hibernate4/pom.xml +++ b/persistence-modules/spring-hibernate4/pom.xml @@ -156,6 +156,11 @@ 19.0 + + + 2.22.2 + 5.6.2 + 4.13 diff --git a/persistence-modules/spring-jdbc/pom.xml b/persistence-modules/spring-jdbc/pom.xml index 4ac5239318..77200cd66e 100644 --- a/persistence-modules/spring-jdbc/pom.xml +++ b/persistence-modules/spring-jdbc/pom.xml @@ -37,5 +37,10 @@ 2.0.3.RELEASE + + + 2.22.2 + 5.6.2 + 4.13 \ No newline at end of file From b800a844fd4e7400ec69ea0be05aabec4456874d Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Wed, 23 Sep 2020 20:14:15 +0200 Subject: [PATCH 208/263] JAVA-2974: Clean up the pom.xml in spring-data-jpa-enterprise --- persistence-modules/spring-data-jpa-enterprise/pom.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/persistence-modules/spring-data-jpa-enterprise/pom.xml b/persistence-modules/spring-data-jpa-enterprise/pom.xml index 093059ad78..756ea59702 100644 --- a/persistence-modules/spring-data-jpa-enterprise/pom.xml +++ b/persistence-modules/spring-data-jpa-enterprise/pom.xml @@ -95,10 +95,6 @@ - 2.1.9.RELEASE - com.baeldung.springdatageode.app.ClientCacheApp - 1.1.1.RELEASE - 2.1.9.RELEASE 1.3.1.Final 21.0 1.12.2 From 027cba8b8bdf26b9cf21254d08eb7f6e80c84ab1 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 24 Sep 2020 02:39:41 +0800 Subject: [PATCH 209/263] Update README.md --- java-collections-conversions-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/java-collections-conversions-2/README.md b/java-collections-conversions-2/README.md index 9d0ba88cbf..628421b0e2 100644 --- a/java-collections-conversions-2/README.md +++ b/java-collections-conversions-2/README.md @@ -7,4 +7,5 @@ This module contains articles about conversions among Collection types and array - [Array to String Conversions](https://www.baeldung.com/java-array-to-string) - [Mapping Lists with ModelMapper](https://www.baeldung.com/java-modelmapper-lists) - [Converting List to Map With a Custom Supplier](https://www.baeldung.com/list-to-map-supplier) +- [Arrays.asList vs new ArrayList(Arrays.asList())](https://www.baeldung.com/java-arrays-aslist-vs-new-arraylist) - More articles: [[<-- prev]](../java-collections-conversions) From 14965826eb20c8b08a9054451297af45375e82a6 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 24 Sep 2020 02:49:18 +0800 Subject: [PATCH 210/263] Update README.md --- spring-boot-modules/spring-boot-mvc-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-boot-modules/spring-boot-mvc-3/README.md b/spring-boot-modules/spring-boot-mvc-3/README.md index 6627bd8eea..796ab72425 100644 --- a/spring-boot-modules/spring-boot-mvc-3/README.md +++ b/spring-boot-modules/spring-boot-mvc-3/README.md @@ -7,4 +7,5 @@ This module contains articles about Spring Web MVC in Spring Boot projects. - [Circular View Path Error](https://www.baeldung.com/spring-circular-view-path-error) - [Download an Image or a File with Spring MVC](https://www.baeldung.com/spring-controller-return-image-file) - [Spring MVC Async vs Spring WebFlux](https://www.baeldung.com/spring-mvc-async-vs-webflux) +- [Differences in @Valid and @Validated Annotations in Spring](https://www.baeldung.com/spring-valid-vs-validated) - More articles: [[prev -->]](/spring-boot-modules/spring-boot-mvc-2) From 7e0a8329a255376e859a2ca288d6ff2403192fbf Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 24 Sep 2020 02:53:02 +0800 Subject: [PATCH 211/263] Create README.md --- core-groovy-strings/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 core-groovy-strings/README.md diff --git a/core-groovy-strings/README.md b/core-groovy-strings/README.md new file mode 100644 index 0000000000..2f49f47cf9 --- /dev/null +++ b/core-groovy-strings/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [How to Remove a Prefix From Strings in Groovy](https://www.baeldung.com/groovy-remove-string-prefix) From 46c071b40bf68f394855dd4486e325a7cf0e15e3 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 24 Sep 2020 02:55:21 +0800 Subject: [PATCH 212/263] Update README.md --- core-java-modules/core-java-networking-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-networking-2/README.md b/core-java-modules/core-java-networking-2/README.md index dbda8bdc7c..fa49c35bf8 100644 --- a/core-java-modules/core-java-networking-2/README.md +++ b/core-java-modules/core-java-networking-2/README.md @@ -13,4 +13,5 @@ This module contains articles about networking in Java - [Download a File from an URL in Java](https://www.baeldung.com/java-download-file) - [Handling java.net.ConnectException](https://www.baeldung.com/java-net-connectexception) - [Getting MAC addresses in Java](https://www.baeldung.com/java-mac-address) +- [Sending Emails with Attachments in Java](https://www.baeldung.com/java-send-emails-attachments) - [[<-- Prev]](/core-java-modules/core-java-networking) From 95549836ec4476b1aaa837fbb33cf9b913e4f373 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 24 Sep 2020 03:32:03 +0800 Subject: [PATCH 213/263] Update README.md --- spring-mvc-basics-4/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-mvc-basics-4/README.md b/spring-mvc-basics-4/README.md index 19cb9059ed..0da83540ad 100644 --- a/spring-mvc-basics-4/README.md +++ b/spring-mvc-basics-4/README.md @@ -8,4 +8,5 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Model, ModelMap, and ModelView in Spring MVC](https://www.baeldung.com/spring-mvc-model-model-map-model-view) - [Spring Web Contexts](https://www.baeldung.com/spring-web-contexts) - [Spring Optional Path variables](https://www.baeldung.com/spring-optional-path-variables) -- More articles: [[<-- prev]](/spring-mvc-basics-3) \ No newline at end of file +- [JSON Parameters with Spring MVC](https://www.baeldung.com/spring-mvc-send-json-parameters) +- More articles: [[<-- prev]](/spring-mvc-basics-3) From 2ba94bd15408e394ffeefc2d97315734f164d2a0 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 24 Sep 2020 03:34:17 +0800 Subject: [PATCH 214/263] Create README.md --- testing-modules/testing-libraries-2/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 testing-modules/testing-libraries-2/README.md diff --git a/testing-modules/testing-libraries-2/README.md b/testing-modules/testing-libraries-2/README.md new file mode 100644 index 0000000000..3325600b5e --- /dev/null +++ b/testing-modules/testing-libraries-2/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Guide to the System Rules Library](https://www.baeldung.com/java-system-rules-junit) From 4575ad984632801664636dacf90e9b71308c62df Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 24 Sep 2020 03:36:26 +0800 Subject: [PATCH 215/263] Update README.md --- json/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/json/README.md b/json/README.md index 0e50dcfddb..6ad4c8a29d 100644 --- a/json/README.md +++ b/json/README.md @@ -13,3 +13,4 @@ This module contains articles about JSON. - [Get a Value by Key in a JSONArray](https://www.baeldung.com/java-jsonarray-get-value-by-key) - [Iterating Over an Instance of org.json.JSONObject](https://www.baeldung.com/jsonobject-iteration) - [Escape JSON String in Java](https://www.baeldung.com/java-json-escaping) +- [Reducing JSON Data Size](https://www.baeldung.com/json-reduce-data-size) From bea5c242afe1405842ca5d391c8b8b5a0b773086 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 24 Sep 2020 03:39:09 +0800 Subject: [PATCH 216/263] Update README.md --- core-java-modules/core-java-reflection-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-reflection-2/README.md b/core-java-modules/core-java-reflection-2/README.md index e5ddb7a8b8..1668eeade3 100644 --- a/core-java-modules/core-java-reflection-2/README.md +++ b/core-java-modules/core-java-reflection-2/README.md @@ -2,3 +2,4 @@ - [Reading the Value of ‘private’ Fields from a Different Class in Java](https://www.baeldung.com/java-reflection-read-private-field-value) - [Set Field Value With Reflection](https://www.baeldung.com/java-set-private-field-value) +- [Checking If a Method is Static Using Reflection in Java](https://www.baeldung.com/java-check-method-is-static) From 86876c57d1a94788991e19951fd77c056e21ceae Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 24 Sep 2020 03:40:31 +0800 Subject: [PATCH 217/263] Update README.md --- core-java-modules/core-java-lang-oop-methods/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-lang-oop-methods/README.md b/core-java-modules/core-java-lang-oop-methods/README.md index afceaded9a..43eab24003 100644 --- a/core-java-modules/core-java-lang-oop-methods/README.md +++ b/core-java-modules/core-java-lang-oop-methods/README.md @@ -9,3 +9,4 @@ This module contains articles about methods in Java - [Java equals() and hashCode() Contracts](https://www.baeldung.com/java-equals-hashcode-contracts) - [Guide to hashCode() in Java](https://www.baeldung.com/java-hashcode) - [The Covariant Return Type in Java](https://www.baeldung.com/java-covariant-return-type) +- [Does a Method’s Signature Include the Return Type in Java?](https://www.baeldung.com/java-method-signature-return-type) From 17369c4b7733cfb09fd5be036faae1d350fddf07 Mon Sep 17 00:00:00 2001 From: Tarun Jain Date: Thu, 24 Sep 2020 03:02:04 +0530 Subject: [PATCH 218/263] BAEL-4404|Updated test class name --- ...rollerTest.java => CharEncodingCheckControllerUnitTest.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename spring-boot-modules/spring-boot-mvc-3/src/test/java/com/baeldung/charencoding/controller/{CharEncodingCheckControllerTest.java => CharEncodingCheckControllerUnitTest.java} (96%) diff --git a/spring-boot-modules/spring-boot-mvc-3/src/test/java/com/baeldung/charencoding/controller/CharEncodingCheckControllerTest.java b/spring-boot-modules/spring-boot-mvc-3/src/test/java/com/baeldung/charencoding/controller/CharEncodingCheckControllerUnitTest.java similarity index 96% rename from spring-boot-modules/spring-boot-mvc-3/src/test/java/com/baeldung/charencoding/controller/CharEncodingCheckControllerTest.java rename to spring-boot-modules/spring-boot-mvc-3/src/test/java/com/baeldung/charencoding/controller/CharEncodingCheckControllerUnitTest.java index 25f257eced..6dcbfe390f 100644 --- a/spring-boot-modules/spring-boot-mvc-3/src/test/java/com/baeldung/charencoding/controller/CharEncodingCheckControllerTest.java +++ b/spring-boot-modules/spring-boot-mvc-3/src/test/java/com/baeldung/charencoding/controller/CharEncodingCheckControllerUnitTest.java @@ -13,7 +13,7 @@ import javax.servlet.http.HttpServletResponse; import org.junit.jupiter.api.Test; import org.springframework.web.filter.CharacterEncodingFilter; -class CharEncodingCheckControllerTest { +class CharEncodingCheckControllerUnitTest { @Test void whenCharEncodingFilter_thenVerifyEncoding() throws ServletException, IOException { From bea3fccca7a72a9e1857aae9a4dbcdc25b6de3b0 Mon Sep 17 00:00:00 2001 From: KevinGilmore Date: Wed, 23 Sep 2020 21:50:39 -0500 Subject: [PATCH 219/263] BAEL-4327 update README (#10084) * BAEL-3336 BAEL-3058 add links * BAEL-3319: add link * BAEL-3284: add link * BAEL-3198: add link to article * BAEL-3479: add link to article * BAEL-3485: add article link * SCALA-38: move to new package and add link back to article * SCALA-38: add imports back into unit test * BAEL-3908: add link back to article * BAEL-2893 BAEL-3927 add link back to article * BAEL-3569: update README * BAEL-4327: update README --- spring-mvc-basics-4/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-mvc-basics-4/README.md b/spring-mvc-basics-4/README.md index 19cb9059ed..0da83540ad 100644 --- a/spring-mvc-basics-4/README.md +++ b/spring-mvc-basics-4/README.md @@ -8,4 +8,5 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Model, ModelMap, and ModelView in Spring MVC](https://www.baeldung.com/spring-mvc-model-model-map-model-view) - [Spring Web Contexts](https://www.baeldung.com/spring-web-contexts) - [Spring Optional Path variables](https://www.baeldung.com/spring-optional-path-variables) -- More articles: [[<-- prev]](/spring-mvc-basics-3) \ No newline at end of file +- [JSON Parameters with Spring MVC](https://www.baeldung.com/spring-mvc-send-json-parameters) +- More articles: [[<-- prev]](/spring-mvc-basics-3) From d100adc9c59ef660da247d4786ccfd45197ea09b Mon Sep 17 00:00:00 2001 From: Joe Boudreau Date: Thu, 24 Sep 2020 12:28:05 -0400 Subject: [PATCH 220/263] BAEL-4448: Added examples for setting TLS version in HttpClient (#9936) * [BAEL-4448] Added examples for setting TLS version in HttpClient (cherry picked from commit f4d40fc3f3140fd046ed957030e9a54582bd4a67) * [BAEL-4448] Simplified the code for one example * [BAEL-4448] Formatting fixes and moved to new package * [BAEL-4448] Forgot an import and fixed class name typo * [BAEL-4448] Created second module for httpclient and moved article code Co-authored-by: joe --- httpclient-2/.gitignore | 13 ++++ httpclient-2/README.md | 12 ++++ httpclient-2/pom.xml | 43 +++++++++++++ .../tlsversion/ClientTlsVersionExamples.java | 64 +++++++++++++++++++ httpclient/README.md | 1 + pom.xml | 2 + 6 files changed, 135 insertions(+) create mode 100644 httpclient-2/.gitignore create mode 100644 httpclient-2/README.md create mode 100644 httpclient-2/pom.xml create mode 100644 httpclient-2/src/main/java/com/baeldung/tlsversion/ClientTlsVersionExamples.java diff --git a/httpclient-2/.gitignore b/httpclient-2/.gitignore new file mode 100644 index 0000000000..83c05e60c8 --- /dev/null +++ b/httpclient-2/.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/httpclient-2/README.md b/httpclient-2/README.md new file mode 100644 index 0000000000..52d8b8fcff --- /dev/null +++ b/httpclient-2/README.md @@ -0,0 +1,12 @@ +## HttpClient 4.x + +This module contains articles about HttpClient 4.x + +### The Course + +The "REST With Spring" Classes: http://bit.ly/restwithspring + +### Relevant Articles: + +- [How to Set TLS Version in Apache HttpClient](https://www.baeldung.com/TODO) +- More articles: [[<-- prev]](../httpclient) diff --git a/httpclient-2/pom.xml b/httpclient-2/pom.xml new file mode 100644 index 0000000000..1a27d9b5fe --- /dev/null +++ b/httpclient-2/pom.xml @@ -0,0 +1,43 @@ + + + 4.0.0 + httpclient-2 + 0.1-SNAPSHOT + + + com.baeldung + parent-java + 0.0.1-SNAPSHOT + ../parent-java + + + + + org.apache.httpcomponents + httpclient + ${httpclient.version} + + + commons-logging + commons-logging + + + + + + + httpclient-2 + + + src/main/resources + true + + + + + + 4.5.8 + + + \ No newline at end of file diff --git a/httpclient-2/src/main/java/com/baeldung/tlsversion/ClientTlsVersionExamples.java b/httpclient-2/src/main/java/com/baeldung/tlsversion/ClientTlsVersionExamples.java new file mode 100644 index 0000000000..c58763b1c0 --- /dev/null +++ b/httpclient-2/src/main/java/com/baeldung/tlsversion/ClientTlsVersionExamples.java @@ -0,0 +1,64 @@ +package com.baeldung.tlsversion; + +import javax.net.ssl.SSLSocket; + +import org.apache.http.HttpEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.ssl.SSLContexts; +import org.apache.http.util.EntityUtils; + +import java.io.IOException; + +public class ClientTlsVersionExamples { + + public static CloseableHttpClient setViaSocketFactory() { + SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory( + SSLContexts.createDefault(), + new String[] { "TLSv1.2", "TLSv1.3" }, + null, + SSLConnectionSocketFactory.getDefaultHostnameVerifier()); + + return HttpClients.custom().setSSLSocketFactory(sslsf).build(); + } + + public static CloseableHttpClient setTlsVersionPerConnection() { + SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(SSLContexts.createDefault()) { + + @Override + protected void prepareSocket(SSLSocket socket) { + String hostname = socket.getInetAddress().getHostName(); + if (hostname.endsWith("internal.system.com")) { + socket.setEnabledProtocols(new String[] { "TLSv1", "TLSv1.1", "TLSv1.2", "TLSv1.3" }); + } else { + socket.setEnabledProtocols(new String[] { "TLSv1.3" }); + } + } + }; + + return HttpClients.custom().setSSLSocketFactory(sslsf).build(); + } + + // To configure the TLS versions for the client, set the https.protocols system property during runtime. + // For example: java -Dhttps.protocols=TLSv1.1,TLSv1.2,TLSv1.3 -jar webClient.jar + public static CloseableHttpClient setViaSystemProperties() { + return HttpClients.createSystem(); + // Alternatively: + // return HttpClients.custom().useSystemProperties().build(); + } + + public static void main(String[] args) throws IOException { + // Alternatively: + // CloseableHttpClient httpClient = setTlsVersionPerConnection(); + // CloseableHttpClient httpClient = setViaSystemProperties(); + try (CloseableHttpClient httpClient = setViaSocketFactory(); + CloseableHttpResponse response = httpClient.execute(new HttpGet("https://httpbin.org/"))) { + + HttpEntity entity = response.getEntity(); + EntityUtils.consume(entity); + } + } +} \ No newline at end of file diff --git a/httpclient/README.md b/httpclient/README.md index d88739e901..23fe7c7271 100644 --- a/httpclient/README.md +++ b/httpclient/README.md @@ -18,3 +18,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Advanced HttpClient Configuration](https://www.baeldung.com/httpclient-advanced-config) - [HttpClient 4 – Do Not Follow Redirects](https://www.baeldung.com/httpclient-stop-follow-redirect) - [Custom User-Agent in HttpClient 4](https://www.baeldung.com/httpclient-user-agent-header) +- More articles: [[next -->]](../httpclient-2) diff --git a/pom.xml b/pom.xml index 6553716d63..065d6abbdd 100644 --- a/pom.xml +++ b/pom.xml @@ -424,6 +424,7 @@ hazelcast helidon httpclient + httpclient-2 httpclient-simple hystrix @@ -935,6 +936,7 @@ hazelcast helidon httpclient + httpclient-2 httpclient-simple hystrix From 0fd213eb5d5874ccf1c93d38911e9e9c2ceab154 Mon Sep 17 00:00:00 2001 From: mikr Date: Thu, 24 Sep 2020 19:13:13 +0200 Subject: [PATCH 221/263] Java-82 Fix test (change port) --- .../baeldung/reactive/security/SpringSecurity5Application.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-5-reactive-security/src/main/java/com/baeldung/reactive/security/SpringSecurity5Application.java b/spring-5-reactive-security/src/main/java/com/baeldung/reactive/security/SpringSecurity5Application.java index d315bf8238..bb0f007ada 100644 --- a/spring-5-reactive-security/src/main/java/com/baeldung/reactive/security/SpringSecurity5Application.java +++ b/spring-5-reactive-security/src/main/java/com/baeldung/reactive/security/SpringSecurity5Application.java @@ -28,7 +28,7 @@ public class SpringSecurity5Application { HttpHandler handler = WebHttpHandlerBuilder.applicationContext(context) .build(); ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler); - HttpServer httpServer = HttpServer.create().host("localhost").port(8080); + HttpServer httpServer = HttpServer.create().host("localhost").port(8083); return httpServer.handle(adapter).bindNow(); } From 68272ef58fde5cedff32e2d9f1dc8e27aacf1864 Mon Sep 17 00:00:00 2001 From: kwoyke Date: Fri, 25 Sep 2020 13:17:43 +0200 Subject: [PATCH 222/263] BAEL-4641: Use MapStruct 1.3.1.Final (#10088) --- mapstruct/pom.xml | 2 +- .../mappingCollections/mapper/CompanyMapperAdderPreferred.java | 3 ++- .../mapstruct/mappingCollections/mapper/EmployeeMapper.java | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mapstruct/pom.xml b/mapstruct/pom.xml index 9fe6ab6485..9b416177e7 100644 --- a/mapstruct/pom.xml +++ b/mapstruct/pom.xml @@ -71,7 +71,7 @@ - 1.4.0.Beta1 + 1.3.1.Final 4.3.4.RELEASE 1.8 1.8 diff --git a/mapstruct/src/main/java/com/baeldung/mapstruct/mappingCollections/mapper/CompanyMapperAdderPreferred.java b/mapstruct/src/main/java/com/baeldung/mapstruct/mappingCollections/mapper/CompanyMapperAdderPreferred.java index e5cc43074e..094d87351a 100644 --- a/mapstruct/src/main/java/com/baeldung/mapstruct/mappingCollections/mapper/CompanyMapperAdderPreferred.java +++ b/mapstruct/src/main/java/com/baeldung/mapstruct/mappingCollections/mapper/CompanyMapperAdderPreferred.java @@ -5,7 +5,8 @@ import com.baeldung.mapstruct.mappingCollections.model.Company; import org.mapstruct.CollectionMappingStrategy; import org.mapstruct.Mapper; -@Mapper(collectionMappingStrategy = CollectionMappingStrategy.ADDER_PREFERRED) +@Mapper(collectionMappingStrategy = CollectionMappingStrategy.ADDER_PREFERRED, + uses = EmployeeMapper.class) public interface CompanyMapperAdderPreferred { CompanyDTO map(Company company); diff --git a/mapstruct/src/main/java/com/baeldung/mapstruct/mappingCollections/mapper/EmployeeMapper.java b/mapstruct/src/main/java/com/baeldung/mapstruct/mappingCollections/mapper/EmployeeMapper.java index 45bf76c5a4..4a723f049a 100644 --- a/mapstruct/src/main/java/com/baeldung/mapstruct/mappingCollections/mapper/EmployeeMapper.java +++ b/mapstruct/src/main/java/com/baeldung/mapstruct/mappingCollections/mapper/EmployeeMapper.java @@ -11,6 +11,8 @@ import java.util.Set; @Mapper public interface EmployeeMapper { + EmployeeDTO map(Employee employee); + List map(List employees); Set map(Set employees); From 725a7b2a7aba4ed53b614d4c306aabb3c5063a22 Mon Sep 17 00:00:00 2001 From: azhwani <> Date: Fri, 25 Sep 2020 18:40:26 +0100 Subject: [PATCH 223/263] Add cleanUp --- .../lastmodifiedfile/LastModifiedFileAppUnitTest.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core-java-modules/core-java-io-3/src/test/java/com/baeldung/lastmodifiedfile/LastModifiedFileAppUnitTest.java b/core-java-modules/core-java-io-3/src/test/java/com/baeldung/lastmodifiedfile/LastModifiedFileAppUnitTest.java index 4e1f7719a9..fe704c3c40 100644 --- a/core-java-modules/core-java-io-3/src/test/java/com/baeldung/lastmodifiedfile/LastModifiedFileAppUnitTest.java +++ b/core-java-modules/core-java-io-3/src/test/java/com/baeldung/lastmodifiedfile/LastModifiedFileAppUnitTest.java @@ -9,6 +9,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import org.apache.commons.io.FileUtils; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -57,8 +58,7 @@ public class LastModifiedFileAppUnitTest { Path lastModPath = LastModifiedFileApp.findUsingNIOApi(SOURCEDIRECTORY); assertThat(lastModPath).isNotNull(); - assertThat(lastModPath.toFile() - .getName()).isEqualTo("file02.txt"); + assertThat(lastModPath.toFile().getName()).isEqualTo("file02.txt"); } @Test @@ -69,4 +69,10 @@ public class LastModifiedFileAppUnitTest { assertThat(lastModFile.getName()).isEqualTo("file02.txt"); } + @AfterAll + public static void cleanUp() throws IOException { + File srcDir = new File(SOURCEDIRECTORY); + FileUtils.deleteDirectory(srcDir); + } + } \ No newline at end of file From 32f4eeef0207f19f217c6c92b78e906fb6b65ed6 Mon Sep 17 00:00:00 2001 From: Krzysztof Majewski Date: Fri, 25 Sep 2020 23:39:32 +0200 Subject: [PATCH 224/263] BAEL-4520 Getting Started with jOOQ (#10086) * BAEL-4520 Getting Started with jOOQ * add generated sources * remove maven files * create tests Co-authored-by: Krzysztof Majewski --- persistence-modules/jooq/pom.xml | 46 ++++ .../src/main/java/com/baeldung/jooq/Crud.java | 57 ++++ .../java/com/baeldung/jooq/CrudExamples.java | 117 ++++++++ .../baeldung/jooq/model/DefaultCatalog.java | 44 +++ .../java/com/baeldung/jooq/model/Keys.java | 48 ++++ .../java/com/baeldung/jooq/model/Public.java | 59 ++++ .../java/com/baeldung/jooq/model/Tables.java | 25 ++ .../baeldung/jooq/model/tables/Article.java | 159 +++++++++++ .../baeldung/jooq/model/tables/Author.java | 149 ++++++++++ .../model/tables/records/ArticleRecord.java | 218 +++++++++++++++ .../model/tables/records/AuthorRecord.java | 217 +++++++++++++++ .../java/com/baeldung/jooq/CrudLiveTest.java | 257 ++++++++++++++++++ persistence-modules/pom.xml | 1 + 13 files changed, 1397 insertions(+) create mode 100644 persistence-modules/jooq/pom.xml create mode 100644 persistence-modules/jooq/src/main/java/com/baeldung/jooq/Crud.java create mode 100644 persistence-modules/jooq/src/main/java/com/baeldung/jooq/CrudExamples.java create mode 100644 persistence-modules/jooq/src/main/java/com/baeldung/jooq/model/DefaultCatalog.java create mode 100644 persistence-modules/jooq/src/main/java/com/baeldung/jooq/model/Keys.java create mode 100644 persistence-modules/jooq/src/main/java/com/baeldung/jooq/model/Public.java create mode 100644 persistence-modules/jooq/src/main/java/com/baeldung/jooq/model/Tables.java create mode 100644 persistence-modules/jooq/src/main/java/com/baeldung/jooq/model/tables/Article.java create mode 100644 persistence-modules/jooq/src/main/java/com/baeldung/jooq/model/tables/Author.java create mode 100644 persistence-modules/jooq/src/main/java/com/baeldung/jooq/model/tables/records/ArticleRecord.java create mode 100644 persistence-modules/jooq/src/main/java/com/baeldung/jooq/model/tables/records/AuthorRecord.java create mode 100644 persistence-modules/jooq/src/test/java/com/baeldung/jooq/CrudLiveTest.java diff --git a/persistence-modules/jooq/pom.xml b/persistence-modules/jooq/pom.xml new file mode 100644 index 0000000000..f0c5a27a96 --- /dev/null +++ b/persistence-modules/jooq/pom.xml @@ -0,0 +1,46 @@ + + + 4.0.0 + jooq + 0.0.1-SNAPSHOT + jooq-examples + jar + jOOQ Examples + + + com.baeldung + persistence-modules + 1.0.0-SNAPSHOT + + + + + org.jooq + jooq + 3.13.4 + + + org.jooq + jooq-meta + 3.13.4 + + + org.jooq + jooq-codegen + 3.13.4 + + + org.postgresql + postgresql + 42.2.16 + + + com.h2database + h2 + 1.4.200 + + + + diff --git a/persistence-modules/jooq/src/main/java/com/baeldung/jooq/Crud.java b/persistence-modules/jooq/src/main/java/com/baeldung/jooq/Crud.java new file mode 100644 index 0000000000..0427b71c25 --- /dev/null +++ b/persistence-modules/jooq/src/main/java/com/baeldung/jooq/Crud.java @@ -0,0 +1,57 @@ +package com.baeldung.jooq; + +import org.jooq.Condition; +import org.jooq.DSLContext; +import org.jooq.Field; +import org.jooq.Record; +import org.jooq.Result; +import org.jooq.SelectFieldOrAsterisk; +import org.jooq.Table; +import org.jooq.UpdatableRecord; + +import java.util.Map; + +public class Crud { + + public static > void save(UpdatableRecord record) { + record.store(); + } + + public static Result getAll(DSLContext context, Table table) { + return context.select() + .from(table) + .fetch(); + } + + public static Result getFields(DSLContext context, Table table, SelectFieldOrAsterisk... fields) { + return context.select(fields) + .from(table) + .fetch(); + } + + public static R getOne(DSLContext context, Table table, Condition condition) { + return context.fetchOne(table, condition); + } + + public static void update(DSLContext context, Table table, Map, T> values, Condition condition) { + context.update(table) + .set(values) + .where(condition) + .execute(); + } + + public static > void update(UpdatableRecord record) { + record.update(); + } + + public static void delete(DSLContext context, Table table, Condition condition) { + context.delete(table) + .where(condition) + .execute(); + } + + public static > void delete(UpdatableRecord record) { + record.delete(); + } + +} diff --git a/persistence-modules/jooq/src/main/java/com/baeldung/jooq/CrudExamples.java b/persistence-modules/jooq/src/main/java/com/baeldung/jooq/CrudExamples.java new file mode 100644 index 0000000000..87a7b6439e --- /dev/null +++ b/persistence-modules/jooq/src/main/java/com/baeldung/jooq/CrudExamples.java @@ -0,0 +1,117 @@ +package com.baeldung.jooq; + +import com.baeldung.jooq.model.tables.Article; +import com.baeldung.jooq.model.tables.Author; +import com.baeldung.jooq.model.tables.records.ArticleRecord; +import com.baeldung.jooq.model.tables.records.AuthorRecord; +import org.jooq.DSLContext; +import org.jooq.Field; +import org.jooq.Record; +import org.jooq.Result; +import org.jooq.SQLDialect; +import org.jooq.impl.DSL; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.util.HashMap; + +import static com.baeldung.jooq.Crud.delete; +import static com.baeldung.jooq.Crud.getAll; +import static com.baeldung.jooq.Crud.getFields; +import static com.baeldung.jooq.Crud.getOne; +import static com.baeldung.jooq.Crud.save; +import static com.baeldung.jooq.Crud.update; + +public class CrudExamples { + + public void crudExamples() throws SQLException { + String userName = "username"; + String password = "password"; + String url = "jdbc:postgresql://db_url:5432/baeldung_database"; + + Connection conn = DriverManager.getConnection(url, userName, password); + DSLContext context = DSL.using(conn, SQLDialect.POSTGRES); + + createValues(context); + readValues(context); + updateValues(context); + deleteValues(context); + } + + private void createValues(DSLContext context) { + ArticleRecord article = context.newRecord(Article.ARTICLE); + + article.setId(2); + article.setTitle("jOOQ examples"); + article.setDescription("A few examples of jOOQ CRUD operations"); + article.setAuthorId(1); + + save(article); + + AuthorRecord author = context.newRecord(Author.AUTHOR); + author.setId(1); + author.setFirstName("John"); + author.setLastName("Smith"); + author.setAge(40); + + save(author); + } + + private void readValues(DSLContext context) { + Result authors = getAll( + context, + Author.AUTHOR + ); + + authors.forEach(author -> { + Integer id = author.getValue(Author.AUTHOR.ID); + String firstName = author.getValue(Author.AUTHOR.FIRST_NAME); + String lastName = author.getValue(Author.AUTHOR.LAST_NAME); + Integer age = author.getValue(Author.AUTHOR.AGE); + System.out.printf("Author %s %s has id: %d and age: %d%n", firstName, lastName, id, age); + }); + + Result articles = getFields( + context, + Author.AUTHOR, + Article.ARTICLE.ID, Article.ARTICLE.TITLE + ); + + AuthorRecord author = getOne( + context, + Author.AUTHOR, + Author.AUTHOR.ID.eq(1) + ); + } + + private void updateValues(DSLContext context) { + HashMap, String> fieldsToUpdate = new HashMap<>(); + fieldsToUpdate.put(Author.AUTHOR.FIRST_NAME, "David"); + fieldsToUpdate.put(Author.AUTHOR.LAST_NAME, "Brown"); + update( + context, + Author.AUTHOR, + fieldsToUpdate, + Author.AUTHOR.ID.eq(1) + ); + + ArticleRecord article = context.fetchOne(Article.ARTICLE, Article.ARTICLE.ID.eq(1)); + article.setTitle("A New Article Title"); + update( + article + ); + } + + private void deleteValues(DSLContext context) { + delete( + context, + Article.ARTICLE, + Article.ARTICLE.ID.eq(1) + ); + + AuthorRecord author = context.fetchOne(Author.AUTHOR, Author.AUTHOR.ID.eq(1)); + delete(author); + } + +} diff --git a/persistence-modules/jooq/src/main/java/com/baeldung/jooq/model/DefaultCatalog.java b/persistence-modules/jooq/src/main/java/com/baeldung/jooq/model/DefaultCatalog.java new file mode 100644 index 0000000000..b18484877a --- /dev/null +++ b/persistence-modules/jooq/src/main/java/com/baeldung/jooq/model/DefaultCatalog.java @@ -0,0 +1,44 @@ +/* + * This file is generated by jOOQ. + */ +package com.baeldung.jooq.model; + + +import org.jooq.Schema; +import org.jooq.impl.CatalogImpl; + +import java.util.Arrays; +import java.util.List; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class DefaultCatalog extends CatalogImpl { + + private static final long serialVersionUID = 1035293962; + + /** + * The reference instance of DEFAULT_CATALOG + */ + public static final DefaultCatalog DEFAULT_CATALOG = new DefaultCatalog(); + + /** + * The schema public. + */ + public final Public PUBLIC = Public.PUBLIC; + + /** + * No further instances allowed + */ + private DefaultCatalog() { + super(""); + } + + @Override + public final List getSchemas() { + return Arrays.asList( + Public.PUBLIC); + } +} diff --git a/persistence-modules/jooq/src/main/java/com/baeldung/jooq/model/Keys.java b/persistence-modules/jooq/src/main/java/com/baeldung/jooq/model/Keys.java new file mode 100644 index 0000000000..461ffb58c7 --- /dev/null +++ b/persistence-modules/jooq/src/main/java/com/baeldung/jooq/model/Keys.java @@ -0,0 +1,48 @@ +/* + * This file is generated by jOOQ. + */ +package com.baeldung.jooq.model; + + +import com.baeldung.jooq.model.tables.Article; +import com.baeldung.jooq.model.tables.Author; +import com.baeldung.jooq.model.tables.records.ArticleRecord; +import com.baeldung.jooq.model.tables.records.AuthorRecord; +import org.jooq.ForeignKey; +import org.jooq.TableField; +import org.jooq.UniqueKey; +import org.jooq.impl.Internal; + + +/** + * A class modelling foreign key relationships and constraints of tables of + * the public schema. + */ +@SuppressWarnings({"all", "unchecked", "rawtypes"}) +public class Keys { + + // ------------------------------------------------------------------------- + // UNIQUE and PRIMARY KEY definitions + // ------------------------------------------------------------------------- + + public static final UniqueKey ARTICLE_PKEY = UniqueKeys0.ARTICLE_PKEY; + public static final UniqueKey AUTHOR_PKEY = UniqueKeys0.AUTHOR_PKEY; + + // ------------------------------------------------------------------------- + // FOREIGN KEY definitions + // ------------------------------------------------------------------------- + public static final ForeignKey ARTICLE__XXX = ForeignKeys0.ARTICLE__XXX; + + // ------------------------------------------------------------------------- + // [#1459] distribute members to avoid static initialisers > 64kb + // ------------------------------------------------------------------------- + + private static class UniqueKeys0 { + public static final UniqueKey ARTICLE_PKEY = Internal.createUniqueKey(Article.ARTICLE, "article_pkey", new TableField[]{Article.ARTICLE.ID}, true); + public static final UniqueKey AUTHOR_PKEY = Internal.createUniqueKey(Author.AUTHOR, "author_pkey", new TableField[]{Author.AUTHOR.ID}, true); + } + + private static class ForeignKeys0 { + public static final ForeignKey ARTICLE__XXX = Internal.createForeignKey(Keys.AUTHOR_PKEY, Article.ARTICLE, "xxx", new TableField[]{Article.ARTICLE.AUTHOR_ID}, true); + } +} diff --git a/persistence-modules/jooq/src/main/java/com/baeldung/jooq/model/Public.java b/persistence-modules/jooq/src/main/java/com/baeldung/jooq/model/Public.java new file mode 100644 index 0000000000..02c664522b --- /dev/null +++ b/persistence-modules/jooq/src/main/java/com/baeldung/jooq/model/Public.java @@ -0,0 +1,59 @@ +/* + * This file is generated by jOOQ. + */ +package com.baeldung.jooq.model; + +import com.baeldung.jooq.model.tables.Article; +import com.baeldung.jooq.model.tables.Author; +import org.jooq.Catalog; +import org.jooq.Table; +import org.jooq.impl.SchemaImpl; + +import java.util.Arrays; +import java.util.List; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({"all", "unchecked", "rawtypes"}) +public class Public extends SchemaImpl { + + private static final long serialVersionUID = -2049410122; + + /** + * The reference instance of public + */ + public static final Public PUBLIC = new Public(); + + /** + * The table public.article. + */ + public final Article ARTICLE = Article.ARTICLE; + + /** + * The table public.author. + */ + public final Author AUTHOR = Author.AUTHOR; + + /** + * No further instances allowed + */ + private Public() { + super("public", null); + } + + + @Override + public Catalog getCatalog() { + return DefaultCatalog.DEFAULT_CATALOG; + } + + @Override + public final List> getTables() { + return Arrays.>asList( + Article.ARTICLE, + Author.AUTHOR + ); + } +} diff --git a/persistence-modules/jooq/src/main/java/com/baeldung/jooq/model/Tables.java b/persistence-modules/jooq/src/main/java/com/baeldung/jooq/model/Tables.java new file mode 100644 index 0000000000..eb1f14e05a --- /dev/null +++ b/persistence-modules/jooq/src/main/java/com/baeldung/jooq/model/Tables.java @@ -0,0 +1,25 @@ +/* + * This file is generated by jOOQ. + */ +package com.baeldung.jooq.model; + +import com.baeldung.jooq.model.tables.Article; +import com.baeldung.jooq.model.tables.Author; + +/** + * Convenience access to all tables in public + */ +@SuppressWarnings({"all", "unchecked", "rawtypes"}) +public class Tables { + + /** + * The table public.article. + */ + public static final Article ARTICLE = Article.ARTICLE; + + /** + * The table public.author. + */ + public static final Author AUTHOR = Author.AUTHOR; + +} diff --git a/persistence-modules/jooq/src/main/java/com/baeldung/jooq/model/tables/Article.java b/persistence-modules/jooq/src/main/java/com/baeldung/jooq/model/tables/Article.java new file mode 100644 index 0000000000..3159c91aa8 --- /dev/null +++ b/persistence-modules/jooq/src/main/java/com/baeldung/jooq/model/tables/Article.java @@ -0,0 +1,159 @@ +/* + * This file is generated by jOOQ. + */ +package com.baeldung.jooq.model.tables; + + +import com.baeldung.jooq.model.Keys; +import com.baeldung.jooq.model.Public; +import com.baeldung.jooq.model.tables.records.ArticleRecord; +import org.jooq.Field; +import org.jooq.ForeignKey; +import org.jooq.Name; +import org.jooq.Record; +import org.jooq.Row4; +import org.jooq.Schema; +import org.jooq.Table; +import org.jooq.TableField; +import org.jooq.TableOptions; +import org.jooq.UniqueKey; +import org.jooq.impl.DSL; +import org.jooq.impl.TableImpl; + +import java.util.Arrays; +import java.util.List; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class Article extends TableImpl { + + private static final long serialVersionUID = -1401275800; + + /** + * The reference instance of public.article + */ + public static final Article ARTICLE = new Article(); + + /** + * The class holding records for this type + */ + @Override + public Class getRecordType() { + return ArticleRecord.class; + } + + /** + * The column public.article.id. + */ + public final TableField ID = createField(DSL.name("id"), org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column public.article.title. + */ + public final TableField TITLE = createField(DSL.name("title"), org.jooq.impl.SQLDataType.VARCHAR(255).nullable(false), this, ""); + + /** + * The column public.article.description. + */ + public final TableField DESCRIPTION = createField(DSL.name("description"), org.jooq.impl.SQLDataType.VARCHAR(255), this, ""); + + /** + * The column public.article.author_id. + */ + public final TableField AUTHOR_ID = createField(DSL.name("author_id"), org.jooq.impl.SQLDataType.INTEGER, this, ""); + + /** + * Create a public.article table reference + */ + public Article() { + this(DSL.name("article"), null); + } + + /** + * Create an aliased public.article table reference + */ + public Article(String alias) { + this(DSL.name(alias), ARTICLE); + } + + /** + * Create an aliased public.article table reference + */ + public Article(Name alias) { + this(alias, ARTICLE); + } + + private Article(Name alias, Table aliased) { + this(alias, aliased, null); + } + + private Article(Name alias, Table aliased, Field[] parameters) { + super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table()); + } + + public Article(Table child, ForeignKey key) { + super(child, key, ARTICLE); + } + + @Override + public Schema getSchema() { + return Public.PUBLIC; + } + + @Override + public UniqueKey getPrimaryKey() { + return Keys.ARTICLE_PKEY; + } + + @Override + public List> getKeys() { + return Arrays.>asList(Keys.ARTICLE_PKEY); + } + + @Override + public List> getReferences() { + return Arrays.>asList(Keys.ARTICLE__XXX); + } + + public Author author() { + return new Author(this, Keys.ARTICLE__XXX); + } + + @Override + public Article as(String alias) { + return new Article(DSL.name(alias), this); + } + + @Override + public Article as(Name alias) { + return new Article(alias, this); + } + + /** + * Rename this table + */ + @Override + public Article rename(String name) { + return new Article(DSL.name(name), null); + } + + /** + * Rename this table + */ + @Override + public Article rename(Name name) { + return new Article(name, null); + } + + // ------------------------------------------------------------------------- + // Row4 type methods + // ------------------------------------------------------------------------- + + @Override + public Row4 fieldsRow() { + return (Row4) super.fieldsRow(); + } +} diff --git a/persistence-modules/jooq/src/main/java/com/baeldung/jooq/model/tables/Author.java b/persistence-modules/jooq/src/main/java/com/baeldung/jooq/model/tables/Author.java new file mode 100644 index 0000000000..9da9415109 --- /dev/null +++ b/persistence-modules/jooq/src/main/java/com/baeldung/jooq/model/tables/Author.java @@ -0,0 +1,149 @@ +/* + * This file is generated by jOOQ. + */ +package com.baeldung.jooq.model.tables; + +import com.baeldung.jooq.model.Keys; +import com.baeldung.jooq.model.Public; +import com.baeldung.jooq.model.tables.records.AuthorRecord; +import org.jooq.Field; +import org.jooq.ForeignKey; +import org.jooq.Name; +import org.jooq.Record; +import org.jooq.Row4; +import org.jooq.Schema; +import org.jooq.Table; +import org.jooq.TableField; +import org.jooq.TableOptions; +import org.jooq.UniqueKey; +import org.jooq.impl.DSL; +import org.jooq.impl.TableImpl; + +import java.util.Arrays; +import java.util.List; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class Author extends TableImpl { + + private static final long serialVersionUID = -798376522; + + /** + * The reference instance of public.author + */ + public static final Author AUTHOR = new Author(); + + /** + * The class holding records for this type + */ + @Override + public Class getRecordType() { + return AuthorRecord.class; + } + + /** + * The column public.author.id. + */ + public final TableField ID = createField(DSL.name("id"), org.jooq.impl.SQLDataType.INTEGER.nullable(false), AUTHOR, ""); + + /** + * The column public.author.first_name. + */ + public final TableField FIRST_NAME = createField(DSL.name("first_name"), org.jooq.impl.SQLDataType.VARCHAR(255), this, ""); + + /** + * The column public.author.last_name. + */ + public final TableField LAST_NAME = createField(DSL.name("last_name"), org.jooq.impl.SQLDataType.VARCHAR(255), this, ""); + + /** + * The column public.author.age. + */ + public final TableField AGE = createField(DSL.name("age"), org.jooq.impl.SQLDataType.INTEGER, this, ""); + + /** + * Create a public.author table reference + */ + public Author() { + this(DSL.name("author"), null); + } + + /** + * Create an aliased public.author table reference + */ + public Author(String alias) { + this(DSL.name(alias), AUTHOR); + } + + /** + * Create an aliased public.author table reference + */ + public Author(Name alias) { + this(alias, AUTHOR); + } + + private Author(Name alias, Table aliased) { + this(alias, aliased, null); + } + + private Author(Name alias, Table aliased, Field[] parameters) { + super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table()); + } + + public Author(Table child, ForeignKey key) { + super(child, key, AUTHOR); + } + + @Override + public Schema getSchema() { + return Public.PUBLIC; + } + + @Override + public UniqueKey getPrimaryKey() { + return Keys.AUTHOR_PKEY; + } + + @Override + public List> getKeys() { + return Arrays.>asList(Keys.AUTHOR_PKEY); + } + + @Override + public Author as(String alias) { + return new Author(DSL.name(alias), this); + } + + @Override + public Author as(Name alias) { + return new Author(alias, this); + } + + /** + * Rename this table + */ + @Override + public Author rename(String name) { + return new Author(DSL.name(name), null); + } + + /** + * Rename this table + */ + @Override + public Author rename(Name name) { + return new Author(name, null); + } + + // ------------------------------------------------------------------------- + // Row4 type methods + // ------------------------------------------------------------------------- + + @Override + public Row4 fieldsRow() { + return (Row4) super.fieldsRow(); + } +} diff --git a/persistence-modules/jooq/src/main/java/com/baeldung/jooq/model/tables/records/ArticleRecord.java b/persistence-modules/jooq/src/main/java/com/baeldung/jooq/model/tables/records/ArticleRecord.java new file mode 100644 index 0000000000..cee17fe716 --- /dev/null +++ b/persistence-modules/jooq/src/main/java/com/baeldung/jooq/model/tables/records/ArticleRecord.java @@ -0,0 +1,218 @@ +/* + * This file is generated by jOOQ. + */ +package com.baeldung.jooq.model.tables.records; + + +import com.baeldung.jooq.model.tables.Article; + +import org.jooq.Field; +import org.jooq.Record1; +import org.jooq.Record4; +import org.jooq.Row4; +import org.jooq.impl.UpdatableRecordImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class ArticleRecord extends UpdatableRecordImpl implements Record4 { + + private static final long serialVersionUID = 1297442421; + + /** + * Setter for public.article.id. + */ + public void setId(Integer value) { + set(0, value); + } + + /** + * Getter for public.article.id. + */ + public Integer getId() { + return (Integer) get(0); + } + + /** + * Setter for public.article.title. + */ + public void setTitle(String value) { + set(1, value); + } + + /** + * Getter for public.article.title. + */ + public String getTitle() { + return (String) get(1); + } + + /** + * Setter for public.article.description. + */ + public void setDescription(String value) { + set(2, value); + } + + /** + * Getter for public.article.description. + */ + public String getDescription() { + return (String) get(2); + } + + /** + * Setter for public.article.author_id. + */ + public void setAuthorId(Integer value) { + set(3, value); + } + + /** + * Getter for public.article.author_id. + */ + public Integer getAuthorId() { + return (Integer) get(3); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + @Override + public Record1 key() { + return (Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record4 type implementation + // ------------------------------------------------------------------------- + + @Override + public Row4 fieldsRow() { + return (Row4) super.fieldsRow(); + } + + @Override + public Row4 valuesRow() { + return (Row4) super.valuesRow(); + } + + @Override + public Field field1() { + return Article.ARTICLE.ID; + } + + @Override + public Field field2() { + return Article.ARTICLE.TITLE; + } + + @Override + public Field field3() { + return Article.ARTICLE.DESCRIPTION; + } + + @Override + public Field field4() { + return Article.ARTICLE.AUTHOR_ID; + } + + @Override + public Integer component1() { + return getId(); + } + + @Override + public String component2() { + return getTitle(); + } + + @Override + public String component3() { + return getDescription(); + } + + @Override + public Integer component4() { + return getAuthorId(); + } + + @Override + public Integer value1() { + return getId(); + } + + @Override + public String value2() { + return getTitle(); + } + + @Override + public String value3() { + return getDescription(); + } + + @Override + public Integer value4() { + return getAuthorId(); + } + + @Override + public ArticleRecord value1(Integer value) { + setId(value); + return this; + } + + @Override + public ArticleRecord value2(String value) { + setTitle(value); + return this; + } + + @Override + public ArticleRecord value3(String value) { + setDescription(value); + return this; + } + + @Override + public ArticleRecord value4(Integer value) { + setAuthorId(value); + return this; + } + + @Override + public ArticleRecord values(Integer value1, String value2, String value3, Integer value4) { + value1(value1); + value2(value2); + value3(value3); + value4(value4); + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached ArticleRecord + */ + public ArticleRecord() { + super(Article.ARTICLE); + } + + /** + * Create a detached, initialised ArticleRecord + */ + public ArticleRecord(Integer id, String title, String description, Integer authorId) { + super(Article.ARTICLE); + + set(0, id); + set(1, title); + set(2, description); + set(3, authorId); + } +} diff --git a/persistence-modules/jooq/src/main/java/com/baeldung/jooq/model/tables/records/AuthorRecord.java b/persistence-modules/jooq/src/main/java/com/baeldung/jooq/model/tables/records/AuthorRecord.java new file mode 100644 index 0000000000..365de20747 --- /dev/null +++ b/persistence-modules/jooq/src/main/java/com/baeldung/jooq/model/tables/records/AuthorRecord.java @@ -0,0 +1,217 @@ +/* + * This file is generated by jOOQ. + */ +package com.baeldung.jooq.model.tables.records; + + +import com.baeldung.jooq.model.tables.Author; +import org.jooq.Field; +import org.jooq.Record1; +import org.jooq.Record4; +import org.jooq.Row4; +import org.jooq.impl.UpdatableRecordImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class AuthorRecord extends UpdatableRecordImpl implements Record4 { + + private static final long serialVersionUID = -2120822720; + + /** + * Setter for public.author.id. + */ + public void setId(Integer value) { + set(0, value); + } + + /** + * Getter for public.author.id. + */ + public Integer getId() { + return (Integer) get(0); + } + + /** + * Setter for public.author.first_name. + */ + public void setFirstName(String value) { + set(1, value); + } + + /** + * Getter for public.author.first_name. + */ + public String getFirstName() { + return (String) get(1); + } + + /** + * Setter for public.author.last_name. + */ + public void setLastName(String value) { + set(2, value); + } + + /** + * Getter for public.author.last_name. + */ + public String getLastName() { + return (String) get(2); + } + + /** + * Setter for public.author.age. + */ + public void setAge(Integer value) { + set(3, value); + } + + /** + * Getter for public.author.age. + */ + public Integer getAge() { + return (Integer) get(3); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + @Override + public Record1 key() { + return (Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record4 type implementation + // ------------------------------------------------------------------------- + + @Override + public Row4 fieldsRow() { + return (Row4) super.fieldsRow(); + } + + @Override + public Row4 valuesRow() { + return (Row4) super.valuesRow(); + } + + @Override + public Field field1() { + return Author.AUTHOR.ID; + } + + @Override + public Field field2() { + return Author.AUTHOR.FIRST_NAME; + } + + @Override + public Field field3() { + return Author.AUTHOR.LAST_NAME; + } + + @Override + public Field field4() { + return Author.AUTHOR.AGE; + } + + @Override + public Integer component1() { + return getId(); + } + + @Override + public String component2() { + return getFirstName(); + } + + @Override + public String component3() { + return getLastName(); + } + + @Override + public Integer component4() { + return getAge(); + } + + @Override + public Integer value1() { + return getId(); + } + + @Override + public String value2() { + return getFirstName(); + } + + @Override + public String value3() { + return getLastName(); + } + + @Override + public Integer value4() { + return getAge(); + } + + @Override + public AuthorRecord value1(Integer value) { + setId(value); + return this; + } + + @Override + public AuthorRecord value2(String value) { + setFirstName(value); + return this; + } + + @Override + public AuthorRecord value3(String value) { + setLastName(value); + return this; + } + + @Override + public AuthorRecord value4(Integer value) { + setAge(value); + return this; + } + + @Override + public AuthorRecord values(Integer value1, String value2, String value3, Integer value4) { + value1(value1); + value2(value2); + value3(value3); + value4(value4); + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached AuthorRecord + */ + public AuthorRecord() { + super(Author.AUTHOR); + } + + /** + * Create a detached, initialised AuthorRecord + */ + public AuthorRecord(Integer id, String firstName, String lastName, Integer age) { + super(Author.AUTHOR); + + set(0, id); + set(1, firstName); + set(2, lastName); + set(3, age); + } +} diff --git a/persistence-modules/jooq/src/test/java/com/baeldung/jooq/CrudLiveTest.java b/persistence-modules/jooq/src/test/java/com/baeldung/jooq/CrudLiveTest.java new file mode 100644 index 0000000000..d41344c08e --- /dev/null +++ b/persistence-modules/jooq/src/test/java/com/baeldung/jooq/CrudLiveTest.java @@ -0,0 +1,257 @@ +package com.baeldung.jooq; + +import com.baeldung.jooq.model.tables.Article; +import com.baeldung.jooq.model.tables.Author; +import com.baeldung.jooq.model.tables.records.ArticleRecord; +import org.jooq.DSLContext; +import org.jooq.Field; +import org.jooq.Record; +import org.jooq.Result; +import org.jooq.SQLDialect; +import org.jooq.impl.DSL; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.util.HashMap; + +import static com.baeldung.jooq.Crud.delete; +import static com.baeldung.jooq.Crud.getAll; +import static com.baeldung.jooq.Crud.getFields; +import static com.baeldung.jooq.Crud.getOne; +import static com.baeldung.jooq.Crud.save; +import static com.baeldung.jooq.Crud.update; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +public class CrudLiveTest { + + static DSLContext context; + + @BeforeClass + public static void setup() throws SQLException { + Connection conn = DriverManager.getConnection("jdbc:h2:mem:tes;INIT=CREATE SCHEMA IF NOT EXISTS \"public\""); + context = DSL.using(conn, SQLDialect.H2); + + context.createTable(Author.AUTHOR) + .columns( + Author.AUTHOR.ID, + Author.AUTHOR.FIRST_NAME, + Author.AUTHOR.LAST_NAME, + Author.AUTHOR.AGE + ) + .execute(); + context.createTable(Article.ARTICLE) + .columns( + Article.ARTICLE.ID, + Article.ARTICLE.TITLE, + Article.ARTICLE.DESCRIPTION, + Article.ARTICLE.AUTHOR_ID + ) + .execute(); + } + + @Before + public void cleanup() { + context.truncateTable(Article.ARTICLE) + .execute(); + context.truncateTable(Author.AUTHOR) + .execute(); + } + + @Test + public void givenArticleRecord_whenSave_thenNewRecordInDb() { + // given + ArticleRecord article = article(); + + // when + save(article); + + // then + ArticleRecord savedArticle = getOne( + context, + Article.ARTICLE, + Article.ARTICLE.ID.eq(1) + ); + assertEquals(savedArticle.getId().intValue(), 1); + assertEquals(savedArticle.getTitle(), "jOOQ examples"); + assertEquals(savedArticle.getDescription(), "A few examples of jOOQ CRUD operations"); + assertEquals(savedArticle.getAuthorId().intValue(), 1); + } + + @Test + public void givenArticleRecord_whenGetAll_thenValidOneRecord() { + // given + ArticleRecord article = article(); + save(article); + + // when + Result articles = getAll( + context, + Article.ARTICLE + ); + + // then + assertEquals(articles.size(), 1); + + Record record = articles.get(0); + ArticleRecord savedArticle = record.into(Article.ARTICLE); + + assertEquals(savedArticle.getId().intValue(), 1); + assertEquals(savedArticle.getTitle(), "jOOQ examples"); + assertEquals(savedArticle.getDescription(), "A few examples of jOOQ CRUD operations"); + assertEquals(savedArticle.getAuthorId().intValue(), 1); + } + + @Test + public void givenArticleRecord_whenGetOnlyTitles_thenValidOneValue() { + // given + ArticleRecord article = article(); + save(article); + + // when + Result articles = getFields( + context, + Article.ARTICLE, + Article.ARTICLE.TITLE + ); + + // then + assertEquals(articles.size(), 1); + + Record record = articles.get(0); + ArticleRecord savedArticle = record.into(Article.ARTICLE); + + assertNull(savedArticle.getId()); + assertEquals(savedArticle.getTitle(), "jOOQ examples"); + assertNull(savedArticle.getDescription()); + assertNull(savedArticle.getAuthorId()); + } + + @Test + public void givenArticleRecord_whenGetOne_thenValidRecord() { + // given + ArticleRecord article = article(); + save(article); + + // when + ArticleRecord savedArticle = getOne( + context, + Article.ARTICLE, + Article.ARTICLE.ID.eq(1) + ); + + // then + assertEquals(savedArticle.getId().intValue(), 1); + assertEquals(savedArticle.getTitle(), "jOOQ examples"); + assertEquals(savedArticle.getDescription(), "A few examples of jOOQ CRUD operations"); + assertEquals(savedArticle.getAuthorId().intValue(), 1); + } + + @Test + public void givenArticleRecord_whenUpdateById_thenChangedValuesDbTable() { + // given + ArticleRecord article = article(); + save(article); + + HashMap, String> updateFields = new HashMap<>(); + updateFields.put(Article.ARTICLE.TITLE, "new title"); + updateFields.put(Article.ARTICLE.DESCRIPTION, "new description"); + + // when + update( + context, + Article.ARTICLE, + updateFields, + Article.ARTICLE.ID.eq(1) + ); + + // then + ArticleRecord updatedArticle = getOne( + context, + Article.ARTICLE, + Article.ARTICLE.ID.eq(1) + ); + assertEquals(updatedArticle.getId().intValue(), 1); + assertEquals(updatedArticle.getTitle(), "new title"); + assertEquals(updatedArticle.getDescription(), "new description"); + assertEquals(updatedArticle.getAuthorId().intValue(), 1); + } + + @Test + public void givenArticleRecord_whenUpdate_thenChangedValuesDbTable() { + // given + ArticleRecord article = article(); + save(article); + + article.setTitle("new title"); + article.setDescription("new description"); + + // when + update(article); + + // then + ArticleRecord updatedArticle = getOne( + context, + Article.ARTICLE, + Article.ARTICLE.ID.eq(1) + ); + assertEquals(updatedArticle.getId().intValue(), 1); + assertEquals(updatedArticle.getTitle(), "new title"); + assertEquals(updatedArticle.getDescription(), "new description"); + assertEquals(updatedArticle.getAuthorId().intValue(), 1); + } + + @Test + public void givenArticleRecord_whenDelete_thenEmptyDbTable() { + // given + ArticleRecord article = article(); + save(article); + + // when + delete(article); + + // then + Result articles = getAll( + context, + Article.ARTICLE + ); + assertTrue(articles.isEmpty()); + } + + @Test + public void givenArticleRecord_whenDeleteById_thenEmptyDbTable() { + // given + ArticleRecord article = article(); + save(article); + + // when + delete( + context, + Article.ARTICLE, + Article.ARTICLE.ID.eq(1) + ); + + // then + Result articles = getAll( + context, + Article.ARTICLE + ); + assertTrue(articles.isEmpty()); + } + + private ArticleRecord article() { + ArticleRecord article = context.newRecord(Article.ARTICLE); + article.setId(1); + article.setTitle("jOOQ examples"); + article.setDescription("A few examples of jOOQ CRUD operations"); + article.setAuthorId(1); + + return article; + } + +} diff --git a/persistence-modules/pom.xml b/persistence-modules/pom.xml index def2deb941..590e5da76e 100644 --- a/persistence-modules/pom.xml +++ b/persistence-modules/pom.xml @@ -39,6 +39,7 @@ java-jpa-2 java-mongodb jnosql + jooq jpa-hibernate-cascade-type liquibase orientdb From c6b1da41802030e665206c9c8bc3f22eabf1cc22 Mon Sep 17 00:00:00 2001 From: fdpro Date: Sat, 26 Sep 2020 08:23:21 +0200 Subject: [PATCH 225/263] [JAVA-1669] Added missing byte-buddy dependency --- persistence-modules/spring-jpa-2/pom.xml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/persistence-modules/spring-jpa-2/pom.xml b/persistence-modules/spring-jpa-2/pom.xml index 1c21f6b98d..8d8dfe3a7b 100644 --- a/persistence-modules/spring-jpa-2/pom.xml +++ b/persistence-modules/spring-jpa-2/pom.xml @@ -66,6 +66,11 @@ guava ${guava.version} + + net.bytebuddy + byte-buddy + ${byte-buddy.version} + @@ -85,13 +90,14 @@ 5.1.5.RELEASE + 2.2.6.RELEASE 9.0.0.M26 21.0 - 2.2.6.RELEASE + 1.10.16 \ No newline at end of file From 428e8dac62b901208872dde784e7eb9379cb369d Mon Sep 17 00:00:00 2001 From: Kai Yuan Date: Thu, 17 Sep 2020 00:20:42 +0200 Subject: [PATCH 226/263] [BAEL-4532]a.getClass() vs A.class --- .../com/baeldung/getclassobject/Animal.java | 5 ++ .../com/baeldung/getclassobject/Monkey.java | 4 ++ .../getclassobject/SomeAbstractClass.java | 4 ++ .../getclassobject/SomeInterface.java | 4 ++ .../baeldung/getclassobject/SomeUtils.java | 9 +++ .../GetClassObjectUnitTest.java | 55 +++++++++++++++++++ 6 files changed, 81 insertions(+) create mode 100644 core-java-modules/core-java-lang-3/src/main/java/com/baeldung/getclassobject/Animal.java create mode 100644 core-java-modules/core-java-lang-3/src/main/java/com/baeldung/getclassobject/Monkey.java create mode 100644 core-java-modules/core-java-lang-3/src/main/java/com/baeldung/getclassobject/SomeAbstractClass.java create mode 100644 core-java-modules/core-java-lang-3/src/main/java/com/baeldung/getclassobject/SomeInterface.java create mode 100644 core-java-modules/core-java-lang-3/src/main/java/com/baeldung/getclassobject/SomeUtils.java create mode 100644 core-java-modules/core-java-lang-3/src/test/java/com/baeldung/getclassobject/GetClassObjectUnitTest.java diff --git a/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/getclassobject/Animal.java b/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/getclassobject/Animal.java new file mode 100644 index 0000000000..426f1403af --- /dev/null +++ b/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/getclassobject/Animal.java @@ -0,0 +1,5 @@ +package com.baeldung.getclassobject; + +public class Animal { + protected int numberOfEyes; +} diff --git a/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/getclassobject/Monkey.java b/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/getclassobject/Monkey.java new file mode 100644 index 0000000000..76ad8a96e3 --- /dev/null +++ b/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/getclassobject/Monkey.java @@ -0,0 +1,4 @@ +package com.baeldung.getclassobject; + +public class Monkey extends Animal { +} diff --git a/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/getclassobject/SomeAbstractClass.java b/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/getclassobject/SomeAbstractClass.java new file mode 100644 index 0000000000..7ee34cf62a --- /dev/null +++ b/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/getclassobject/SomeAbstractClass.java @@ -0,0 +1,4 @@ +package com.baeldung.getclassobject; + +public abstract class SomeAbstractClass { +} diff --git a/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/getclassobject/SomeInterface.java b/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/getclassobject/SomeInterface.java new file mode 100644 index 0000000000..eec8048481 --- /dev/null +++ b/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/getclassobject/SomeInterface.java @@ -0,0 +1,4 @@ +package com.baeldung.getclassobject; + +interface SomeInterface { +} diff --git a/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/getclassobject/SomeUtils.java b/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/getclassobject/SomeUtils.java new file mode 100644 index 0000000000..294ef5bc9e --- /dev/null +++ b/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/getclassobject/SomeUtils.java @@ -0,0 +1,9 @@ +package com.baeldung.getclassobject; + +public class SomeUtils { + private SomeUtils() { + throw new RuntimeException("This Util class is not allowed to be instantiated!"); + } + // public static utilMethods + // ... +} diff --git a/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/getclassobject/GetClassObjectUnitTest.java b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/getclassobject/GetClassObjectUnitTest.java new file mode 100644 index 0000000000..20b5b8e0c8 --- /dev/null +++ b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/getclassobject/GetClassObjectUnitTest.java @@ -0,0 +1,55 @@ +package com.baeldung.getclassobject; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class GetClassObjectUnitTest { + @Test + public void givenObjectAndType_whenGettingClassObject_thenTwoMethodsHaveTheSameResult() { + String str = "I am an object of the String class"; + Class fromStrObject = str.getClass(); + Class clazz = String.class; + assertSame(fromStrObject, clazz); + } + + @Test + public void givenClassInheritance_whenGettingRuntimeTypeAndStaticType_thenGetDifferentResult() { + Animal animal = new Monkey(); + Class runtimeType = animal.getClass(); + Class staticType = Animal.class; + //Not equals + assertNotEquals(staticType, runtimeType); + + Class monkeyClass = Monkey.class; + assertSame(runtimeType, monkeyClass); + } + + @Test + public void givenPrimitiveType_whenGettingClassObject_thenOnlyStaticTypeWorks() { + int number = 7; + // Class numberClass = number.getClass(); <-- compilation error + Class intType = int.class; + + assertNotNull(intType); + assertEquals("int", intType.getName()); + assertTrue(intType.isPrimitive()); + } + + @Test + public void givenTypeCannotInstantiate_whenGetTypeStatically_thenGetTypesSuccefully() { + Class interfaceType = SomeInterface.class; + Class abstractClassType = SomeAbstractClass.class; + Class utilClassType = SomeUtils.class; + + assertNotNull(interfaceType); + assertTrue(interfaceType.isInterface()); + assertEquals("SomeInterface", interfaceType.getSimpleName()); + + assertNotNull(abstractClassType); + assertEquals("SomeAbstractClass", abstractClassType.getSimpleName()); + + assertNotNull(utilClassType); + assertEquals("SomeUtils", utilClassType.getSimpleName()); + } +} From 70203a988b81a564cf281ed1b94efd6b0b6e9809 Mon Sep 17 00:00:00 2001 From: Ronald Dehuysser Date: Sat, 26 Sep 2020 23:14:11 +0200 Subject: [PATCH 227/263] [BAEL-4639] Running background jobs in Spring with JobRunr (#10089) * [BAEL-4639] Running background jobs in Spring with JobRunr * [BAEL-4639] Background jobs in Spring with JobRunr - update dependencies and readme * [BAEL-4639] Background jobs in Spring with JobRunr - add required newline to application.properties * [BAEL-4639] Background jobs in Spring with JobRunr - Make sure link is correct * [BAEL-4639] Background jobs in Spring with JobRunr - Cleanup and LiveTest added * [BAEL-4639] - Feedback * [BAEL-4639] Update test with feedback --- spring-boot-modules/pom.xml | 1 + .../spring-boot-libraries-2/README.md | 7 +++ .../spring-boot-libraries-2/pom.xml | 46 +++++++++++++++++++ .../jobrunr/JobRunrSpringBootApp.java | 37 +++++++++++++++ .../jobrunr/controller/JobRunrController.java | 43 +++++++++++++++++ .../jobrunr/service/SampleJobService.java | 36 +++++++++++++++ .../src/main/resources/application.properties | 2 + .../com/baeldung/jobrunr/JobRunrLiveTest.java | 46 +++++++++++++++++++ 8 files changed, 218 insertions(+) create mode 100644 spring-boot-modules/spring-boot-libraries-2/README.md create mode 100644 spring-boot-modules/spring-boot-libraries-2/pom.xml create mode 100644 spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/jobrunr/JobRunrSpringBootApp.java create mode 100644 spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/jobrunr/controller/JobRunrController.java create mode 100644 spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/jobrunr/service/SampleJobService.java create mode 100644 spring-boot-modules/spring-boot-libraries-2/src/main/resources/application.properties create mode 100644 spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/jobrunr/JobRunrLiveTest.java diff --git a/spring-boot-modules/pom.xml b/spring-boot-modules/pom.xml index 527f7dcad8..fa70a9f058 100644 --- a/spring-boot-modules/pom.xml +++ b/spring-boot-modules/pom.xml @@ -46,6 +46,7 @@ spring-boot-jasypt spring-boot-keycloak spring-boot-libraries + spring-boot-libraries-2 spring-boot-logging-log4j2 spring-boot-kotlin spring-boot-mvc diff --git a/spring-boot-modules/spring-boot-libraries-2/README.md b/spring-boot-modules/spring-boot-libraries-2/README.md new file mode 100644 index 0000000000..b0840798e3 --- /dev/null +++ b/spring-boot-modules/spring-boot-libraries-2/README.md @@ -0,0 +1,7 @@ +## Spring Boot Libraries + +This module contains articles about various Spring Boot libraries + +### Relevant Articles: + +- Running background jobs in Spring with JobRunr diff --git a/spring-boot-modules/spring-boot-libraries-2/pom.xml b/spring-boot-modules/spring-boot-libraries-2/pom.xml new file mode 100644 index 0000000000..2633c8fad3 --- /dev/null +++ b/spring-boot-modules/spring-boot-libraries-2/pom.xml @@ -0,0 +1,46 @@ + + + + spring-boot-modules + com.baeldung.spring-boot-modules + 1.0.0-SNAPSHOT + + 4.0.0 + + spring-boot-libraries-2 + + + + org.springframework.boot + spring-boot-starter-web + + + + + org.jobrunr + jobrunr-spring-boot-starter + ${jobrunr.version} + + + + org.springframework.boot + spring-boot-starter-test + test + + + + org.awaitility + awaitility + ${awaitility.version} + test + + + + + 1.0.0 + 4.0.3 + + + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/jobrunr/JobRunrSpringBootApp.java b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/jobrunr/JobRunrSpringBootApp.java new file mode 100644 index 0000000000..d72e9464d9 --- /dev/null +++ b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/jobrunr/JobRunrSpringBootApp.java @@ -0,0 +1,37 @@ +package com.baeldung.jobrunr; + +import com.baeldung.jobrunr.service.SampleJobService; +import org.jobrunr.jobs.mappers.JobMapper; +import org.jobrunr.scheduling.JobScheduler; +import org.jobrunr.scheduling.cron.Cron; +import org.jobrunr.storage.InMemoryStorageProvider; +import org.jobrunr.storage.StorageProvider; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +import javax.annotation.PostConstruct; + +@SpringBootApplication +public class JobRunrSpringBootApp { + + @Autowired + private JobScheduler jobScheduler; + + public static void main(String[] args) { + SpringApplication.run(JobRunrSpringBootApp.class, args); + } + + @Bean + public StorageProvider storageProvider(JobMapper jobMapper) { + InMemoryStorageProvider storageProvider = new InMemoryStorageProvider(); + storageProvider.setJobMapper(jobMapper); + return storageProvider; + } + + @PostConstruct + public void scheduleRecurrently() { + jobScheduler.scheduleRecurrently(x -> x.executeSampleJob("a recurring job"), Cron.every5minutes()); + } +} diff --git a/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/jobrunr/controller/JobRunrController.java b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/jobrunr/controller/JobRunrController.java new file mode 100644 index 0000000000..af5f0b1196 --- /dev/null +++ b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/jobrunr/controller/JobRunrController.java @@ -0,0 +1,43 @@ +package com.baeldung.jobrunr.controller; + +import com.baeldung.jobrunr.service.SampleJobService; +import org.jobrunr.scheduling.JobScheduler; +import org.springframework.boot.context.properties.bind.DefaultValue; +import org.springframework.format.annotation.DateTimeFormat; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.time.LocalDateTime; + +@RestController +@RequestMapping("/jobrunr") +public class JobRunrController { + + private JobScheduler jobScheduler; + private SampleJobService sampleJobService; + + private JobRunrController(JobScheduler jobScheduler, SampleJobService sampleJobService) { + this.jobScheduler = jobScheduler; + this.sampleJobService = sampleJobService; + } + + @GetMapping(value = "/enqueue/{input}", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity enqueue(@PathVariable("input") @DefaultValue("default-input") String input) { + jobScheduler.enqueue(() -> sampleJobService.executeSampleJob(input)); + return okResponse("job enqueued successfully"); + } + + @GetMapping(value = "/schedule/{input}", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity schedule( + @PathVariable("input") @DefaultValue("default-input") String input, + @RequestParam("scheduleAt") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime scheduleAt) { + jobScheduler.schedule(() -> sampleJobService.executeSampleJob(input), scheduleAt); + return okResponse("job scheduled successfully"); + } + + private ResponseEntity okResponse(String feedback) { + return new ResponseEntity<>(feedback, HttpStatus.OK); + } +} diff --git a/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/jobrunr/service/SampleJobService.java b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/jobrunr/service/SampleJobService.java new file mode 100644 index 0000000000..dff4309374 --- /dev/null +++ b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/jobrunr/service/SampleJobService.java @@ -0,0 +1,36 @@ +package com.baeldung.jobrunr.service; + +import org.jobrunr.jobs.annotations.Job; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +import java.util.concurrent.atomic.AtomicInteger; + +@Service +public class SampleJobService { + + public static final long EXECUTION_TIME = 5000L; + + private Logger logger = LoggerFactory.getLogger(getClass()); + + private AtomicInteger count = new AtomicInteger(); + + @Job(name = "The sample job with variable %0", retries = 2) + public void executeSampleJob(String variable) { + + logger.info("The sample job has begun. The variable you passed is {}", variable); + try { + Thread.sleep(EXECUTION_TIME); + } catch (InterruptedException e) { + logger.error("Error while executing sample job", e); + } finally { + count.incrementAndGet(); + logger.info("Sample job has finished..."); + } + } + + public int getNumberOfInvocations() { + return count.get(); + } +} diff --git a/spring-boot-modules/spring-boot-libraries-2/src/main/resources/application.properties b/spring-boot-modules/spring-boot-libraries-2/src/main/resources/application.properties new file mode 100644 index 0000000000..69f5a7356e --- /dev/null +++ b/spring-boot-modules/spring-boot-libraries-2/src/main/resources/application.properties @@ -0,0 +1,2 @@ +org.jobrunr.background_job_server=true +org.jobrunr.dashboard=true diff --git a/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/jobrunr/JobRunrLiveTest.java b/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/jobrunr/JobRunrLiveTest.java new file mode 100644 index 0000000000..83222e7726 --- /dev/null +++ b/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/jobrunr/JobRunrLiveTest.java @@ -0,0 +1,46 @@ +package com.baeldung.jobrunr; + +import org.awaitility.Awaitility; +import org.jobrunr.jobs.states.StateName; +import org.jobrunr.storage.StorageProvider; +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.boot.test.web.client.TestRestTemplate; +import org.springframework.test.context.junit4.SpringRunner; + +import java.net.URI; +import java.util.concurrent.TimeUnit; + +import static org.awaitility.Awaitility.await; +import static org.junit.Assert.assertEquals; +import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.DEFINED_PORT; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = DEFINED_PORT, classes = JobRunrSpringBootApp.class) +public class JobRunrLiveTest { + + @Autowired + TestRestTemplate restTemplate; + + @Autowired + StorageProvider storageProvider; + + @Test + public void givenEndpoint_whenJobEnqueued_thenJobIsProcessedWithin30Seconds() { + String response = enqueueJobViaRest("some-input"); + assertEquals("job enqueued successfully", response); + + await().atMost(30, TimeUnit.SECONDS).until(() -> storageProvider.countJobs(StateName.SUCCEEDED) == 1); + } + + private String enqueueJobViaRest(String input) { + try { + return restTemplate.getForObject(new URI("http://localhost:8080/jobrunr/enqueue/" + input), String.class); + } catch (Exception ignored) { + ignored.printStackTrace(); + } + return null; + } +} From e134c020ceb050ecacfb23509f1a8418fe481e41 Mon Sep 17 00:00:00 2001 From: Oussama BEN MAHMOUD Date: Mon, 28 Sep 2020 10:43:07 +0200 Subject: [PATCH 228/263] BAEL-4443 Reading HTTP ResponseBody as a String --- httpclient-2/pom.xml | 29 ++++++++++++++++ .../ApacheHttpClientUnitTest.java | 26 ++++++++++++++ .../HttpClientUnitTest.java | 29 ++++++++++++++++ .../HttpUrlConnectionUnitTest.java | 34 +++++++++++++++++++ .../SpringRestTemplateUnitTest.java | 17 ++++++++++ pom.xml | 4 +-- 6 files changed, 137 insertions(+), 2 deletions(-) create mode 100644 httpclient-2/src/test/java/com/baeldung/httpclient/readresponsebodystring/ApacheHttpClientUnitTest.java create mode 100644 httpclient-2/src/test/java/com/baeldung/httpclient/readresponsebodystring/HttpClientUnitTest.java create mode 100644 httpclient-2/src/test/java/com/baeldung/httpclient/readresponsebodystring/HttpUrlConnectionUnitTest.java create mode 100644 httpclient-2/src/test/java/com/baeldung/httpclient/readresponsebodystring/SpringRestTemplateUnitTest.java diff --git a/httpclient-2/pom.xml b/httpclient-2/pom.xml index 1a27d9b5fe..7638c692dc 100644 --- a/httpclient-2/pom.xml +++ b/httpclient-2/pom.xml @@ -4,6 +4,7 @@ 4.0.0 httpclient-2 0.1-SNAPSHOT + httpclient-2 com.baeldung @@ -13,6 +14,7 @@ + org.apache.httpcomponents httpclient @@ -24,6 +26,19 @@ + + + + org.springframework.boot + spring-boot-starter-web + ${spring-boot.version} + + + org.springframework.boot + spring-boot-starter-test + ${spring-boot.version} + test + @@ -34,10 +49,24 @@ true + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${maven.compiler.source.version} + ${maven.compiler.target.version} + + + 4.5.8 + 11 + 11 + 2.1.7.RELEASE \ No newline at end of file diff --git a/httpclient-2/src/test/java/com/baeldung/httpclient/readresponsebodystring/ApacheHttpClientUnitTest.java b/httpclient-2/src/test/java/com/baeldung/httpclient/readresponsebodystring/ApacheHttpClientUnitTest.java new file mode 100644 index 0000000000..5a638b2bd5 --- /dev/null +++ b/httpclient-2/src/test/java/com/baeldung/httpclient/readresponsebodystring/ApacheHttpClientUnitTest.java @@ -0,0 +1,26 @@ +package com.baeldung.httpclient.readresponsebodystring; + +import org.apache.http.HttpEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; +import org.junit.Test; + +import java.io.IOException; + +public class ApacheHttpClientUnitTest { + public static final String DUMMY_URL = "https://postman-echo.com/get"; + + @Test + public void whenUseApacheHttpClient_thenCorrect() throws IOException { + HttpGet request = new HttpGet(DUMMY_URL); + + try (CloseableHttpClient client = HttpClients.createDefault(); CloseableHttpResponse response = client.execute(request)) { + HttpEntity entity = response.getEntity(); + String result = EntityUtils.toString(entity); + System.out.println("Response -> " + result); + } + } +} diff --git a/httpclient-2/src/test/java/com/baeldung/httpclient/readresponsebodystring/HttpClientUnitTest.java b/httpclient-2/src/test/java/com/baeldung/httpclient/readresponsebodystring/HttpClientUnitTest.java new file mode 100644 index 0000000000..1dca1bf7c6 --- /dev/null +++ b/httpclient-2/src/test/java/com/baeldung/httpclient/readresponsebodystring/HttpClientUnitTest.java @@ -0,0 +1,29 @@ +package com.baeldung.httpclient.readresponsebodystring; + +import org.junit.Test; + +import java.io.IOException; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; + +public class HttpClientUnitTest { + public static final String DUMMY_URL = "https://postman-echo.com/get"; + + @Test + public void whenUseHttpClient_thenCorrect() throws IOException, InterruptedException { + HttpClient client = HttpClient.newHttpClient(); + HttpRequest request = HttpRequest.newBuilder().uri(URI.create(DUMMY_URL)).build(); + + // synchronous response + HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); + System.out.println(response.body()); + + // asynchronous response + client.sendAsync(request, HttpResponse.BodyHandlers.ofString()) + .thenApply(HttpResponse::body) + .thenAccept(System.out::println) + .join(); + } +} diff --git a/httpclient-2/src/test/java/com/baeldung/httpclient/readresponsebodystring/HttpUrlConnectionUnitTest.java b/httpclient-2/src/test/java/com/baeldung/httpclient/readresponsebodystring/HttpUrlConnectionUnitTest.java new file mode 100644 index 0000000000..54ae887eb4 --- /dev/null +++ b/httpclient-2/src/test/java/com/baeldung/httpclient/readresponsebodystring/HttpUrlConnectionUnitTest.java @@ -0,0 +1,34 @@ +package com.baeldung.httpclient.readresponsebodystring; + +import org.junit.Assert; +import org.junit.Test; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; + +public class HttpUrlConnectionUnitTest { + + public static final String DUMMY_URL = "https://postman-echo.com/get"; + + @Test + public void whenUseHttpUrlConnection_thenCorrect() throws IOException { + HttpURLConnection connection = (HttpURLConnection) new URL(DUMMY_URL).openConnection(); + + InputStream inputStream = connection.getInputStream(); + + BufferedReader in = new BufferedReader(new InputStreamReader(inputStream)); + StringBuilder response = new StringBuilder(); + String currentLine; + + while ((currentLine = in.readLine()) != null) + response.append(currentLine); + + in.close(); + Assert.assertNotNull(response.toString()); + System.out.println("Response -> " + response.toString()); + } +} diff --git a/httpclient-2/src/test/java/com/baeldung/httpclient/readresponsebodystring/SpringRestTemplateUnitTest.java b/httpclient-2/src/test/java/com/baeldung/httpclient/readresponsebodystring/SpringRestTemplateUnitTest.java new file mode 100644 index 0000000000..c59d7662f1 --- /dev/null +++ b/httpclient-2/src/test/java/com/baeldung/httpclient/readresponsebodystring/SpringRestTemplateUnitTest.java @@ -0,0 +1,17 @@ +package com.baeldung.httpclient.readresponsebodystring; + +import org.junit.Test; +import org.springframework.web.client.RestTemplate; + +public class SpringRestTemplateUnitTest { + + public static final String DUMMY_URL = "https://postman-echo.com/get"; + + @Test + public void whenUseRestTemplate_thenCorrect() { + RestTemplate restTemplate = new RestTemplate(); + String response = restTemplate.getForObject(DUMMY_URL, String.class); + System.out.println(response); + } + +} diff --git a/pom.xml b/pom.xml index 065d6abbdd..c93aeffcbd 100644 --- a/pom.xml +++ b/pom.xml @@ -424,7 +424,7 @@ hazelcast helidon httpclient - httpclient-2 + httpclient-simple hystrix @@ -936,7 +936,7 @@ hazelcast helidon httpclient - httpclient-2 + httpclient-simple hystrix From 664d170cf45b392c23652aa443a945ba0beae5d0 Mon Sep 17 00:00:00 2001 From: kwoyke Date: Mon, 28 Sep 2020 16:29:44 +0200 Subject: [PATCH 229/263] BAEL-4656: Get available port number for the test (#10096) --- .../PactConsumerDrivenContractUnitTest.java | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/libraries-5/src/test/java/com/baeldung/pact/PactConsumerDrivenContractUnitTest.java b/libraries-5/src/test/java/com/baeldung/pact/PactConsumerDrivenContractUnitTest.java index e4ac8a3a95..8d4918a3e7 100644 --- a/libraries-5/src/test/java/com/baeldung/pact/PactConsumerDrivenContractUnitTest.java +++ b/libraries-5/src/test/java/com/baeldung/pact/PactConsumerDrivenContractUnitTest.java @@ -7,22 +7,38 @@ import au.com.dius.pact.consumer.dsl.PactDslWithProvider; import au.com.dius.pact.model.RequestResponsePact; import org.junit.Rule; import org.junit.Test; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; +import org.springframework.http.*; import org.springframework.web.client.RestTemplate; +import java.io.IOException; +import java.net.ServerSocket; import java.util.HashMap; import java.util.Map; +import java.util.Random; import static org.assertj.core.api.Assertions.assertThat; public class PactConsumerDrivenContractUnitTest { + private static int getAvailablePort() { + return new Random() + .ints(6000, 9000) + .filter(PactConsumerDrivenContractUnitTest::isFree) + .findFirst() + .orElse(8080); + } + + private static boolean isFree(int port) { + try { + new ServerSocket(port).close(); + return true; + } catch (IOException e) { + return false; + } + } + @Rule - public PactProviderRuleMk2 mockProvider = new PactProviderRuleMk2("test_provider", "localhost", 8080, this); + public PactProviderRuleMk2 mockProvider = new PactProviderRuleMk2("test_provider", "localhost", getAvailablePort(), this); @Pact(consumer = "test_consumer") public RequestResponsePact createPact(PactDslWithProvider builder) { From 7ee94d7455955233b462267d99366e0992e6306a Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Mon, 28 Sep 2020 23:10:40 +0530 Subject: [PATCH 230/263] JAVA-2432: Moved articles from here to other modules --- .../spring-hibernate4/.gitignore | 15 - .../spring-hibernate4/README.md | 24 -- persistence-modules/spring-hibernate4/pom.xml | 166 ----------- .../hibernate/audit/AuditorAwareImpl.java | 19 -- .../hibernate/criteria/model/Item.java | 81 ------ .../hibernate/fetching/model/OrderDetail.java | 58 ---- .../hibernate/fetching/model/UserEager.java | 71 ----- .../hibernate/fetching/model/UserLazy.java | 71 ----- .../fetching/util/HibernateUtil.java | 29 -- .../fetching/view/FetchingAppView.java | 68 ----- .../persistence/dao/IBarAuditableDao.java | 8 - .../persistence/dao/IBarCrudRepository.java | 10 - .../com/baeldung/persistence/dao/IBarDao.java | 8 - .../baeldung/persistence/dao/IChildDao.java | 8 - .../persistence/dao/IFooAuditableDao.java | 8 - .../com/baeldung/persistence/dao/IFooDao.java | 8 - .../baeldung/persistence/dao/IParentDao.java | 8 - .../persistence/dao/common/AbstractDao.java | 14 - .../common/AbstractHibernateAuditableDao.java | 37 --- .../dao/common/AbstractHibernateDao.java | 59 ---- .../dao/common/AbstractJpaDao.java | 56 ---- .../dao/common/GenericHibernateDao.java | 13 - .../dao/common/IAuditOperations.java | 14 - .../persistence/dao/common/IGenericDao.java | 7 - .../persistence/dao/common/IOperations.java | 20 -- .../persistence/dao/impl/BarAuditableDao.java | 28 -- .../baeldung/persistence/dao/impl/BarDao.java | 19 -- .../persistence/dao/impl/BarJpaDao.java | 19 -- .../persistence/dao/impl/ChildDao.java | 19 -- .../persistence/dao/impl/FooAuditableDao.java | 17 -- .../baeldung/persistence/dao/impl/FooDao.java | 19 -- .../persistence/dao/impl/ParentDao.java | 19 -- .../com/baeldung/persistence/model/Bar.java | 242 ---------------- .../com/baeldung/persistence/model/Child.java | 51 ---- .../com/baeldung/persistence/model/Foo.java | 105 ------- .../baeldung/persistence/model/Parent.java | 60 ---- .../baeldung/persistence/model/Person.java | 31 --- .../service/IBarAuditableService.java | 8 - .../persistence/service/IBarService.java | 8 - .../persistence/service/IChildService.java | 8 - .../service/IFooAuditableService.java | 8 - .../persistence/service/IFooService.java | 8 - .../persistence/service/IParentService.java | 8 - .../AbstractHibernateAuditableService.java | 30 -- .../common/AbstractHibernateService.java | 42 --- .../service/common/AbstractJpaService.java | 42 --- .../service/common/AbstractService.java | 42 --- .../common/AbstractSpringDataJpaService.java | 46 --- .../service/impl/BarAuditableService.java | 41 --- .../service/impl/BarJpaService.java | 30 -- .../persistence/service/impl/BarService.java | 30 -- .../service/impl/BarSpringDataJpaService.java | 26 -- .../service/impl/ChildService.java | 28 -- .../service/impl/FooAuditableService.java | 41 --- .../persistence/service/impl/FooService.java | 30 -- .../service/impl/ParentService.java | 28 -- .../baeldung/spring/PersistenceConfig.java | 186 ------------- .../baeldung/spring/PersistenceXmlConfig.java | 18 -- .../src/main/resources/fetching.cfg.xml | 20 -- .../src/main/resources/fetchingLazy.cfg.xml | 17 -- .../resources/fetching_create_queries.sql | 14 - .../src/main/resources/hibernate4Config.xml | 34 --- .../src/main/resources/immutable.cfg.xml | 38 --- .../src/main/resources/insert_statements.sql | 31 --- .../src/main/resources/logback.xml | 19 -- .../resources/persistence-mysql.properties | 13 - .../src/main/resources/stored_procedure.sql | 20 -- .../src/main/resources/webSecurityConfig.xml | 37 --- .../java/com/baeldung/SpringContextTest.java | 18 -- .../HibernateFetchingIntegrationTest.java | 42 --- .../persistence/IntegrationTestSuite.java | 25 -- .../persistence/audit/AuditTestSuite.java | 14 - .../EnversFooBarAuditIntegrationTest.java | 146 ---------- .../audit/JPABarAuditIntegrationTest.java | 103 ------- .../SpringDataJPABarAuditIntegrationTest.java | 77 ----- .../persistence/hibernate/FooFixtures.java | 101 ------- ...oPaginationPersistenceIntegrationTest.java | 185 ------------- .../FooSortingPersistenceIntegrationTest.java | 174 ------------ .../save/SaveMethodsIntegrationTest.java | 262 ------------------ ...erviceBasicPersistenceIntegrationTest.java | 55 ---- .../FooServicePersistenceIntegrationTest.java | 64 ----- .../service/FooStoredProceduresLiveTest.java | 121 -------- ...rentServicePersistenceIntegrationTest.java | 70 ----- .../spring/config/PersistenceTestConfig.java | 179 ------------ .../src/test/resources/.gitignore | 13 - .../src/test/resources/fetching.cfg.xml | 19 -- .../src/test/resources/fetchingLazy.cfg.xml | 19 -- .../test/resources/persistence-h2.properties | 13 - 88 files changed, 4160 deletions(-) delete mode 100644 persistence-modules/spring-hibernate4/.gitignore delete mode 100644 persistence-modules/spring-hibernate4/README.md delete mode 100644 persistence-modules/spring-hibernate4/pom.xml delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/audit/AuditorAwareImpl.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/criteria/model/Item.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/fetching/model/OrderDetail.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/fetching/model/UserEager.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/fetching/model/UserLazy.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/fetching/util/HibernateUtil.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/fetching/view/FetchingAppView.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IBarAuditableDao.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IBarCrudRepository.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IBarDao.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IChildDao.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IFooAuditableDao.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IFooDao.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IParentDao.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/AbstractDao.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/AbstractHibernateAuditableDao.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/AbstractHibernateDao.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/AbstractJpaDao.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/GenericHibernateDao.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/IAuditOperations.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/IGenericDao.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/IOperations.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/BarAuditableDao.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/BarDao.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/BarJpaDao.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/ChildDao.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/FooAuditableDao.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/FooDao.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/ParentDao.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/model/Bar.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/model/Child.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/model/Foo.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/model/Parent.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/model/Person.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/IBarAuditableService.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/IBarService.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/IChildService.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/IFooAuditableService.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/IFooService.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/IParentService.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/common/AbstractHibernateAuditableService.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/common/AbstractHibernateService.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/common/AbstractJpaService.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/common/AbstractService.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/common/AbstractSpringDataJpaService.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/BarAuditableService.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/BarJpaService.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/BarService.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/BarSpringDataJpaService.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/ChildService.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/FooAuditableService.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/FooService.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/ParentService.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/spring/PersistenceConfig.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/spring/PersistenceXmlConfig.java delete mode 100644 persistence-modules/spring-hibernate4/src/main/resources/fetching.cfg.xml delete mode 100644 persistence-modules/spring-hibernate4/src/main/resources/fetchingLazy.cfg.xml delete mode 100644 persistence-modules/spring-hibernate4/src/main/resources/fetching_create_queries.sql delete mode 100644 persistence-modules/spring-hibernate4/src/main/resources/hibernate4Config.xml delete mode 100644 persistence-modules/spring-hibernate4/src/main/resources/immutable.cfg.xml delete mode 100644 persistence-modules/spring-hibernate4/src/main/resources/insert_statements.sql delete mode 100644 persistence-modules/spring-hibernate4/src/main/resources/logback.xml delete mode 100644 persistence-modules/spring-hibernate4/src/main/resources/persistence-mysql.properties delete mode 100644 persistence-modules/spring-hibernate4/src/main/resources/stored_procedure.sql delete mode 100644 persistence-modules/spring-hibernate4/src/main/resources/webSecurityConfig.xml delete mode 100644 persistence-modules/spring-hibernate4/src/test/java/com/baeldung/SpringContextTest.java delete mode 100644 persistence-modules/spring-hibernate4/src/test/java/com/baeldung/hibernate/fetching/HibernateFetchingIntegrationTest.java delete mode 100644 persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/IntegrationTestSuite.java delete mode 100644 persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/audit/AuditTestSuite.java delete mode 100644 persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/audit/EnversFooBarAuditIntegrationTest.java delete mode 100644 persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/audit/JPABarAuditIntegrationTest.java delete mode 100644 persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/audit/SpringDataJPABarAuditIntegrationTest.java delete mode 100644 persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/hibernate/FooFixtures.java delete mode 100644 persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/hibernate/FooPaginationPersistenceIntegrationTest.java delete mode 100644 persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/hibernate/FooSortingPersistenceIntegrationTest.java delete mode 100644 persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/save/SaveMethodsIntegrationTest.java delete mode 100644 persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/service/FooServiceBasicPersistenceIntegrationTest.java delete mode 100644 persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java delete mode 100644 persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/service/FooStoredProceduresLiveTest.java delete mode 100644 persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/service/ParentServicePersistenceIntegrationTest.java delete mode 100644 persistence-modules/spring-hibernate4/src/test/java/com/baeldung/spring/config/PersistenceTestConfig.java delete mode 100644 persistence-modules/spring-hibernate4/src/test/resources/.gitignore delete mode 100644 persistence-modules/spring-hibernate4/src/test/resources/fetching.cfg.xml delete mode 100644 persistence-modules/spring-hibernate4/src/test/resources/fetchingLazy.cfg.xml delete mode 100644 persistence-modules/spring-hibernate4/src/test/resources/persistence-h2.properties diff --git a/persistence-modules/spring-hibernate4/.gitignore b/persistence-modules/spring-hibernate4/.gitignore deleted file mode 100644 index d31cc4c619..0000000000 --- a/persistence-modules/spring-hibernate4/.gitignore +++ /dev/null @@ -1,15 +0,0 @@ -*.class - -#folders# -/target -/neoDb* -/data -/src/main/webapp/WEB-INF/classes -*/META-INF/* - -# Packaged files # -*.jar -*.war -*.ear -/target/ -/target/ diff --git a/persistence-modules/spring-hibernate4/README.md b/persistence-modules/spring-hibernate4/README.md deleted file mode 100644 index a5a72a9b7e..0000000000 --- a/persistence-modules/spring-hibernate4/README.md +++ /dev/null @@ -1,24 +0,0 @@ -## Spring with Hibernate 4 - -This module contains articles about Spring with Hibernate 4 - -### Relevant Articles: -- [Guide to Hibernate 4 with Spring](https://www.baeldung.com/hibernate-4-spring) -- [Hibernate Pagination](https://www.baeldung.com/hibernate-pagination) -- [Sorting with Hibernate](https://www.baeldung.com/hibernate-sort) -- [Stored Procedures with Hibernate](https://www.baeldung.com/stored-procedures-with-hibernate-tutorial) -- [Hibernate: save, persist, update, merge, saveOrUpdate](https://www.baeldung.com/hibernate-save-persist-update-merge-saveorupdate) -- [Eager/Lazy Loading In Hibernate](https://www.baeldung.com/hibernate-lazy-eager-loading) -- [Auditing with JPA, Hibernate, and Spring Data JPA](https://www.baeldung.com/database-auditing-jpa) - -### Quick Start - -``` -git clone git://github.com/eugenp/REST.git -cd REST -mvn install -mvn cargo:run -``` - -- **note**: starts on port `8082` - diff --git a/persistence-modules/spring-hibernate4/pom.xml b/persistence-modules/spring-hibernate4/pom.xml deleted file mode 100644 index 3e5a6f913f..0000000000 --- a/persistence-modules/spring-hibernate4/pom.xml +++ /dev/null @@ -1,166 +0,0 @@ - - - 4.0.0 - spring-hibernate4 - 0.1-SNAPSHOT - spring-hibernate4 - - - com.baeldung - parent-spring-4 - 0.0.1-SNAPSHOT - ../../parent-spring-4 - - - - - - - org.springframework - spring-context - ${org.springframework.version} - - - commons-logging - commons-logging - - - - - org.springframework - spring-aspects - ${org.springframework.version} - - - org.springframework.security - spring-security-core - ${org.springframework.security.version} - - - - - - org.springframework - spring-orm - ${org.springframework.version} - - - org.springframework.data - spring-data-jpa - ${org.springframework.data.version} - - - org.hibernate - hibernate-core - ${hibernate.version} - - - org.hibernate - hibernate-envers - ${hibernate-envers.version} - - - javax.transaction - jta - ${jta.version} - - - mysql - mysql-connector-java - ${mysql-connector-java.version} - - - - org.apache.tomcat - tomcat-dbcp - ${tomcat-dbcp.version} - - - - - - org.hibernate - hibernate-validator - ${hibernate-validator.version} - - - javax.el - javax.el-api - ${javax.el-api.version} - - - - - - com.google.guava - guava - ${guava.version} - - - - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - test - - - - org.springframework - spring-test - ${org.springframework.version} - test - - - - org.springframework.security - spring-security-test - ${org.springframework.security.version} - test - - - - org.hsqldb - hsqldb - ${hsqldb.version} - test - - - com.h2database - h2 - ${h2.version} - test - - - - - - - 4.3.4.RELEASE - 4.2.0.RELEASE - 1.10.5.RELEASE - - - 4.3.11.Final - ${hibernate.version} - 5.1.40 - 8.5.8 - 1.1 - 2.3.4 - - - 5.3.3.Final - 2.2.5 - - - 19.0 - - - 2.22.2 - 5.6.2 - 4.13 - - - diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/audit/AuditorAwareImpl.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/audit/AuditorAwareImpl.java deleted file mode 100644 index 7aef08b2ce..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/audit/AuditorAwareImpl.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.baeldung.hibernate.audit; - -import java.util.Optional; - -import org.springframework.data.domain.AuditorAware; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContextHolder; - -public class AuditorAwareImpl implements AuditorAware { - - @Override - public String getCurrentAuditor() { - return Optional.ofNullable(SecurityContextHolder.getContext()) - .map(e -> e.getAuthentication()) - .map(Authentication::getName) - .orElse(null); - } - -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/criteria/model/Item.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/criteria/model/Item.java deleted file mode 100644 index 957207b7e6..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/criteria/model/Item.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.baeldung.hibernate.criteria.model; - -import java.io.Serializable; - -public class Item implements Serializable { - - private static final long serialVersionUID = 1L; - private Integer itemId; - private String itemName; - private String itemDescription; - private Integer itemPrice; - - // constructors - public Item() { - - } - - public Item(final Integer itemId, final String itemName, final String itemDescription) { - super(); - this.itemId = itemId; - this.itemName = itemName; - this.itemDescription = itemDescription; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((itemId == null) ? 0 : itemId.hashCode()); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - final Item other = (Item) obj; - if (itemId == null) { - if (other.itemId != null) - return false; - } else if (!itemId.equals(other.itemId)) - return false; - return true; - } - - public Integer getItemId() { - return itemId; - } - - public void setItemId(final Integer itemId) { - this.itemId = itemId; - } - - public String getItemName() { - return itemName; - } - - public void setItemName(final String itemName) { - this.itemName = itemName; - } - - public String getItemDescription() { - return itemDescription; - } - - public Integer getItemPrice() { - return itemPrice; - } - - public void setItemPrice(final Integer itemPrice) { - this.itemPrice = itemPrice; - } - - public void setItemDescription(final String itemDescription) { - this.itemDescription = itemDescription; - } -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/fetching/model/OrderDetail.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/fetching/model/OrderDetail.java deleted file mode 100644 index f4a9b8a678..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/fetching/model/OrderDetail.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.baeldung.hibernate.fetching.model; - -import javax.persistence.*; -import java.io.Serializable; -import java.sql.Date; - -@Entity -@Table(name = "USER_ORDER") -public class OrderDetail implements Serializable { - - private static final long serialVersionUID = 1L; - - @Id - @GeneratedValue - @Column(name = "ORDER_ID") - private Long orderId; - - public OrderDetail() { - } - - public OrderDetail(Date orderDate, String orderDesc) { - super(); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((orderId == null) ? 0 : orderId.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; - OrderDetail other = (OrderDetail) obj; - if (orderId == null) { - if (other.orderId != null) - return false; - } else if (!orderId.equals(other.orderId)) - return false; - - return true; - } - - public Long getOrderId() { - return orderId; - } - - public void setOrderId(Long orderId) { - this.orderId = orderId; - } -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/fetching/model/UserEager.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/fetching/model/UserEager.java deleted file mode 100644 index 9fda4c43bb..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/fetching/model/UserEager.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.baeldung.hibernate.fetching.model; - -import javax.persistence.*; -import java.io.Serializable; -import java.util.HashSet; -import java.util.Set; - -@Entity -@Table(name = "USER") -public class UserEager implements Serializable { - - private static final long serialVersionUID = 1L; - - @Id - @GeneratedValue - @Column(name = "USER_ID") - private Long userId; - - @OneToMany(fetch = FetchType.EAGER) - private Set orderDetail = new HashSet(); - - public UserEager() { - } - - public UserEager(final Long userId) { - super(); - this.userId = userId; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((userId == null) ? 0 : userId.hashCode()); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - final UserEager other = (UserEager) obj; - if (userId == null) { - if (other.userId != null) - return false; - } else if (!userId.equals(other.userId)) - return false; - return true; - } - - public Long getUserId() { - return userId; - } - - public void setUserId(final Long userId) { - this.userId = userId; - } - - public Set getOrderDetail() { - return orderDetail; - } - - public void setOrderDetail(Set orderDetail) { - this.orderDetail = orderDetail; - } - -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/fetching/model/UserLazy.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/fetching/model/UserLazy.java deleted file mode 100644 index a78eaa4ac0..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/fetching/model/UserLazy.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.baeldung.hibernate.fetching.model; - -import javax.persistence.*; -import java.io.Serializable; -import java.util.HashSet; -import java.util.Set; - -@Entity -@Table(name = "USER") -public class UserLazy implements Serializable { - - private static final long serialVersionUID = 1L; - - @Id - @GeneratedValue - @Column(name = "USER_ID") - private Long userId; - - @OneToMany(fetch = FetchType.LAZY) - private Set orderDetail = new HashSet(); - - public UserLazy() { - } - - public UserLazy(final Long userId) { - super(); - this.userId = userId; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((userId == null) ? 0 : userId.hashCode()); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - final UserLazy other = (UserLazy) obj; - if (userId == null) { - if (other.userId != null) - return false; - } else if (!userId.equals(other.userId)) - return false; - return true; - } - - public Long getUserId() { - return userId; - } - - public void setUserId(final Long userId) { - this.userId = userId; - } - - public Set getOrderDetail() { - return orderDetail; - } - - public void setOrderDetail(Set orderDetail) { - this.orderDetail = orderDetail; - } - -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/fetching/util/HibernateUtil.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/fetching/util/HibernateUtil.java deleted file mode 100644 index c7be96abb7..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/fetching/util/HibernateUtil.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.baeldung.hibernate.fetching.util; - -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.cfg.Configuration; - -public class HibernateUtil { - - @SuppressWarnings("deprecation") - public static Session getHibernateSession(String fetchMethod) { - // two config files are there - // one with lazy loading enabled - // another lazy = false - SessionFactory sf; - if ("lazy".equals(fetchMethod)) { - sf = new Configuration().configure("fetchingLazy.cfg.xml").buildSessionFactory(); - } else { - sf = new Configuration().configure("fetching.cfg.xml").buildSessionFactory(); - } - - // fetching.cfg.xml is used for this example - return sf.openSession(); - } - - public static Session getHibernateSession() { - return new Configuration().configure("fetching.cfg.xml").buildSessionFactory().openSession(); - } - -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/fetching/view/FetchingAppView.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/fetching/view/FetchingAppView.java deleted file mode 100644 index 35cdd254e3..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/fetching/view/FetchingAppView.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.baeldung.hibernate.fetching.view; - -import com.baeldung.hibernate.fetching.model.OrderDetail; -import com.baeldung.hibernate.fetching.model.UserEager; -import com.baeldung.hibernate.fetching.model.UserLazy; -import com.baeldung.hibernate.fetching.util.HibernateUtil; -import org.hibernate.Session; -import org.hibernate.Transaction; - -import java.util.List; -import java.util.Set; - -public class FetchingAppView { - - public FetchingAppView() { - - } - - // lazily loaded - public Set lazyLoaded() { - final Session sessionLazy = HibernateUtil.getHibernateSession("lazy"); - List users = sessionLazy.createQuery("From UserLazy").list(); - UserLazy userLazyLoaded = users.get(0); - // since data is lazyloaded so data won't be initialized - return (userLazyLoaded.getOrderDetail()); - } - - // eagerly loaded - public Set eagerLoaded() { - final Session sessionEager = HibernateUtil.getHibernateSession(); - // data should be loaded in the following line - // also note the queries generated - List user = sessionEager.createQuery("From UserEager").list(); - UserEager userEagerLoaded = user.get(0); - return userEagerLoaded.getOrderDetail(); - } - - // creates test data - // call this method to create the data in the database - public void createTestData() { - - final Session session = HibernateUtil.getHibernateSession("lazy"); - Transaction tx = session.beginTransaction(); - final UserLazy user1 = new UserLazy(); - final UserLazy user2 = new UserLazy(); - final UserLazy user3 = new UserLazy(); - - session.save(user1); - session.save(user2); - session.save(user3); - - final OrderDetail order1 = new OrderDetail(); - final OrderDetail order2 = new OrderDetail(); - final OrderDetail order3 = new OrderDetail(); - final OrderDetail order4 = new OrderDetail(); - final OrderDetail order5 = new OrderDetail(); - - session.saveOrUpdate(order1); - session.saveOrUpdate(order2); - session.saveOrUpdate(order3); - session.saveOrUpdate(order4); - session.saveOrUpdate(order5); - - tx.commit(); - session.close(); - - } -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IBarAuditableDao.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IBarAuditableDao.java deleted file mode 100644 index 182b493592..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IBarAuditableDao.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.baeldung.persistence.dao; - -import com.baeldung.persistence.dao.common.IAuditOperations; -import com.baeldung.persistence.model.Bar; - -public interface IBarAuditableDao extends IBarDao, IAuditOperations { - // -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IBarCrudRepository.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IBarCrudRepository.java deleted file mode 100644 index 4d7db64240..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IBarCrudRepository.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.baeldung.persistence.dao; - -import java.io.Serializable; - -import com.baeldung.persistence.model.Bar; -import org.springframework.data.repository.CrudRepository; - -public interface IBarCrudRepository extends CrudRepository { - // -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IBarDao.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IBarDao.java deleted file mode 100644 index 7896a2a84a..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IBarDao.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.baeldung.persistence.dao; - -import com.baeldung.persistence.dao.common.IOperations; -import com.baeldung.persistence.model.Bar; - -public interface IBarDao extends IOperations { - // -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IChildDao.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IChildDao.java deleted file mode 100644 index a55a0b0598..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IChildDao.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.baeldung.persistence.dao; - -import com.baeldung.persistence.model.Child; -import com.baeldung.persistence.dao.common.IOperations; - -public interface IChildDao extends IOperations { - // -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IFooAuditableDao.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IFooAuditableDao.java deleted file mode 100644 index ddbb685988..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IFooAuditableDao.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.baeldung.persistence.dao; - -import com.baeldung.persistence.dao.common.IAuditOperations; -import com.baeldung.persistence.model.Foo; - -public interface IFooAuditableDao extends IFooDao, IAuditOperations { - // -} \ No newline at end of file diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IFooDao.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IFooDao.java deleted file mode 100644 index 0935772dbd..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IFooDao.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.baeldung.persistence.dao; - -import com.baeldung.persistence.model.Foo; -import com.baeldung.persistence.dao.common.IOperations; - -public interface IFooDao extends IOperations { - // -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IParentDao.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IParentDao.java deleted file mode 100644 index 03680158bb..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/IParentDao.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.baeldung.persistence.dao; - -import com.baeldung.persistence.model.Parent; -import com.baeldung.persistence.dao.common.IOperations; - -public interface IParentDao extends IOperations { - // -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/AbstractDao.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/AbstractDao.java deleted file mode 100644 index 5a6c76a93a..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/AbstractDao.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.baeldung.persistence.dao.common; - -import java.io.Serializable; - -import com.google.common.base.Preconditions; - -public abstract class AbstractDao implements IOperations { - - protected Class clazz; - - protected final void setClazz(final Class clazzToSet) { - clazz = Preconditions.checkNotNull(clazzToSet); - } -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/AbstractHibernateAuditableDao.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/AbstractHibernateAuditableDao.java deleted file mode 100644 index 41184669ad..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/AbstractHibernateAuditableDao.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.baeldung.persistence.dao.common; - -import java.io.Serializable; -import java.util.List; - -import org.hibernate.envers.AuditReader; -import org.hibernate.envers.AuditReaderFactory; -import org.hibernate.envers.query.AuditQuery; - -@SuppressWarnings("unchecked") -public class AbstractHibernateAuditableDao extends AbstractHibernateDao implements IAuditOperations { - - @Override - public List getEntitiesAtRevision(final Number revision) { - final AuditReader auditReader = AuditReaderFactory.get(getCurrentSession()); - final AuditQuery query = auditReader.createQuery().forEntitiesAtRevision(clazz, revision); - final List resultList = query.getResultList(); - return resultList; - } - - @Override - public List getEntitiesModifiedAtRevision(final Number revision) { - final AuditReader auditReader = AuditReaderFactory.get(getCurrentSession()); - final AuditQuery query = auditReader.createQuery().forEntitiesModifiedAtRevision(clazz, revision); - final List resultList = query.getResultList(); - return resultList; - } - - @Override - public List getRevisions() { - final AuditReader auditReader = AuditReaderFactory.get(getCurrentSession()); - final AuditQuery query = auditReader.createQuery().forRevisionsOfEntity(clazz, true, true); - final List resultList = query.getResultList(); - return resultList; - } - -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/AbstractHibernateDao.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/AbstractHibernateDao.java deleted file mode 100644 index f3ade67f80..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/AbstractHibernateDao.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.baeldung.persistence.dao.common; - -import java.io.Serializable; -import java.util.List; - -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.springframework.beans.factory.annotation.Autowired; - -import com.google.common.base.Preconditions; - -@SuppressWarnings("unchecked") -public abstract class AbstractHibernateDao extends AbstractDao implements IOperations { - - @Autowired - protected SessionFactory sessionFactory; - - // API - - @Override - public T findOne(final long id) { - return (T) getCurrentSession().get(clazz, id); - } - - @Override - public List findAll() { - return getCurrentSession().createQuery("from " + clazz.getName()).list(); - } - - @Override - public void create(final T entity) { - Preconditions.checkNotNull(entity); - getCurrentSession().saveOrUpdate(entity); - } - - @Override - public T update(final T entity) { - Preconditions.checkNotNull(entity); - return (T) getCurrentSession().merge(entity); - } - - @Override - public void delete(final T entity) { - Preconditions.checkNotNull(entity); - getCurrentSession().delete(entity); - } - - @Override - public void deleteById(final long entityId) { - final T entity = findOne(entityId); - Preconditions.checkState(entity != null); - delete(entity); - } - - protected Session getCurrentSession() { - return sessionFactory.getCurrentSession(); - } - -} \ No newline at end of file diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/AbstractJpaDao.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/AbstractJpaDao.java deleted file mode 100644 index 69f8e58c25..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/AbstractJpaDao.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.baeldung.persistence.dao.common; - -import java.io.Serializable; -import java.util.List; - -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; -import javax.persistence.TypedQuery; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; - -public class AbstractJpaDao extends AbstractDao implements IOperations { - - @PersistenceContext - private EntityManager em; - - // API - - @Override - public T findOne(final long id) { - return em.find(clazz, Long.valueOf(id).intValue()); - } - - @Override - public List findAll() { - final CriteriaBuilder cb = em.getCriteriaBuilder(); - final CriteriaQuery cq = cb.createQuery(clazz); - final Root rootEntry = cq.from(clazz); - final CriteriaQuery all = cq.select(rootEntry); - final TypedQuery allQuery = em.createQuery(all); - return allQuery.getResultList(); - } - - @Override - public void create(final T entity) { - em.persist(entity); - } - - @Override - public T update(final T entity) { - em.merge(entity); - return entity; - } - - @Override - public void delete(final T entity) { - em.remove(entity); - } - - @Override - public void deleteById(final long entityId) { - delete(findOne(entityId)); - } - -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/GenericHibernateDao.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/GenericHibernateDao.java deleted file mode 100644 index 18b16fa033..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/GenericHibernateDao.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.baeldung.persistence.dao.common; - -import java.io.Serializable; - -import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Repository; - -@Repository -@Scope(BeanDefinition.SCOPE_PROTOTYPE) -public class GenericHibernateDao extends AbstractHibernateDao implements IGenericDao { - // -} \ No newline at end of file diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/IAuditOperations.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/IAuditOperations.java deleted file mode 100644 index 169d3fed72..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/IAuditOperations.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.baeldung.persistence.dao.common; - -import java.io.Serializable; -import java.util.List; - -public interface IAuditOperations { - - List getEntitiesAtRevision(Number revision); - - List getEntitiesModifiedAtRevision(Number revision); - - List getRevisions(); - -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/IGenericDao.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/IGenericDao.java deleted file mode 100644 index 8d8af18394..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/IGenericDao.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.baeldung.persistence.dao.common; - -import java.io.Serializable; - -public interface IGenericDao extends IOperations { - // -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/IOperations.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/IOperations.java deleted file mode 100644 index 4ef99221ab..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/common/IOperations.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.baeldung.persistence.dao.common; - -import java.io.Serializable; -import java.util.List; - -public interface IOperations { - - T findOne(final long id); - - List findAll(); - - void create(final T entity); - - T update(final T entity); - - void delete(final T entity); - - void deleteById(final long entityId); - -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/BarAuditableDao.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/BarAuditableDao.java deleted file mode 100644 index e12b6ae2da..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/BarAuditableDao.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.baeldung.persistence.dao.impl; - -import java.util.List; - -import com.baeldung.persistence.dao.IBarAuditableDao; -import com.baeldung.persistence.dao.common.AbstractHibernateAuditableDao; -import com.baeldung.persistence.model.Bar; - -public class BarAuditableDao extends AbstractHibernateAuditableDao implements IBarAuditableDao { - - public BarAuditableDao() { - super(); - - setClazz(Bar.class); - } - - // API - - @Override - public List getRevisions() { - final List resultList = super.getRevisions(); - for (final Bar bar : resultList) { - bar.getFooSet().size(); // force FooSet initialization - } - return resultList; - } - -} \ No newline at end of file diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/BarDao.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/BarDao.java deleted file mode 100644 index 0ead802dc5..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/BarDao.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.baeldung.persistence.dao.impl; - -import com.baeldung.persistence.dao.common.AbstractHibernateDao; -import com.baeldung.persistence.dao.IBarDao; -import com.baeldung.persistence.model.Bar; -import org.springframework.stereotype.Repository; - -@Repository -public class BarDao extends AbstractHibernateDao implements IBarDao { - - public BarDao() { - super(); - - setClazz(Bar.class); - } - - // API - -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/BarJpaDao.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/BarJpaDao.java deleted file mode 100644 index e0fa382d41..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/BarJpaDao.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.baeldung.persistence.dao.impl; - -import com.baeldung.persistence.dao.IBarDao; -import com.baeldung.persistence.dao.common.AbstractJpaDao; -import com.baeldung.persistence.model.Bar; -import org.springframework.stereotype.Repository; - -@Repository -public class BarJpaDao extends AbstractJpaDao implements IBarDao { - - public BarJpaDao() { - super(); - - setClazz(Bar.class); - } - - // API - -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/ChildDao.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/ChildDao.java deleted file mode 100644 index b55da6e43a..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/ChildDao.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.baeldung.persistence.dao.impl; - -import com.baeldung.persistence.dao.common.AbstractHibernateDao; -import com.baeldung.persistence.model.Child; -import com.baeldung.persistence.dao.IChildDao; -import org.springframework.stereotype.Repository; - -@Repository -public class ChildDao extends AbstractHibernateDao implements IChildDao { - - public ChildDao() { - super(); - - setClazz(Child.class); - } - - // API - -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/FooAuditableDao.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/FooAuditableDao.java deleted file mode 100644 index 05064c1478..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/FooAuditableDao.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.baeldung.persistence.dao.impl; - -import com.baeldung.persistence.dao.common.AbstractHibernateAuditableDao; -import com.baeldung.persistence.model.Foo; -import com.baeldung.persistence.dao.IFooAuditableDao; - -public class FooAuditableDao extends AbstractHibernateAuditableDao implements IFooAuditableDao { - - public FooAuditableDao() { - super(); - - setClazz(Foo.class); - } - - // API - -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/FooDao.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/FooDao.java deleted file mode 100644 index 787c449b1d..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/FooDao.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.baeldung.persistence.dao.impl; - -import com.baeldung.persistence.dao.common.AbstractHibernateDao; -import com.baeldung.persistence.dao.IFooDao; -import com.baeldung.persistence.model.Foo; -import org.springframework.stereotype.Repository; - -@Repository -public class FooDao extends AbstractHibernateDao implements IFooDao { - - public FooDao() { - super(); - - setClazz(Foo.class); - } - - // API - -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/ParentDao.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/ParentDao.java deleted file mode 100644 index 4602b5f30e..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/dao/impl/ParentDao.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.baeldung.persistence.dao.impl; - -import com.baeldung.persistence.dao.IParentDao; -import com.baeldung.persistence.dao.common.AbstractHibernateDao; -import com.baeldung.persistence.model.Parent; -import org.springframework.stereotype.Repository; - -@Repository -public class ParentDao extends AbstractHibernateDao implements IParentDao { - - public ParentDao() { - super(); - - setClazz(Parent.class); - } - - // API - -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/model/Bar.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/model/Bar.java deleted file mode 100644 index c7f05254cc..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/model/Bar.java +++ /dev/null @@ -1,242 +0,0 @@ -package com.baeldung.persistence.model; - -import java.io.Serializable; -import java.util.Date; -import java.util.Set; - -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EntityListeners; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.NamedQuery; -import javax.persistence.OneToMany; -import javax.persistence.PrePersist; -import javax.persistence.PreRemove; -import javax.persistence.PreUpdate; - -import org.hibernate.annotations.OrderBy; -import org.hibernate.envers.Audited; -import org.jboss.logging.Logger; -import org.springframework.data.annotation.CreatedBy; -import org.springframework.data.annotation.CreatedDate; -import org.springframework.data.annotation.LastModifiedBy; -import org.springframework.data.annotation.LastModifiedDate; -import org.springframework.data.jpa.domain.support.AuditingEntityListener; - -import com.google.common.collect.Sets; - -@Entity -@NamedQuery(name = "Bar.findAll", query = "SELECT b FROM Bar b") -@Audited -@EntityListeners(AuditingEntityListener.class) -public class Bar implements Serializable { - - private static Logger logger = Logger.getLogger(Bar.class); - - public enum OPERATION { - INSERT, UPDATE, DELETE; - private String value; - - OPERATION() { - value = toString(); - } - - public String getValue() { - return value; - } - - public static OPERATION parse(final String value) { - OPERATION operation = null; - for (final OPERATION op : OPERATION.values()) { - if (op.getValue().equals(value)) { - operation = op; - break; - } - } - return operation; - } - }; - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name = "id") - private int id; - - @Column(name = "name") - private String name; - - @OneToMany(mappedBy = "bar", cascade = CascadeType.ALL, fetch = FetchType.LAZY) - @OrderBy(clause = "NAME DESC") - // @NotAudited - private Set fooSet = Sets.newHashSet(); - - @Column(name = "operation") - private String operation; - - @Column(name = "timestamp") - private long timestamp; - - @Column(name = "created_date", updatable = false, nullable = false) - @CreatedDate - private long createdDate; - - @Column(name = "modified_date") - @LastModifiedDate - private long modifiedDate; - - @Column(name = "created_by") - @CreatedBy - private String createdBy; - - @Column(name = "modified_by") - @LastModifiedBy - private String modifiedBy; - - public Bar() { - super(); - } - - public Bar(final String name) { - super(); - - this.name = name; - } - - // API - - public Set getFooSet() { - return fooSet; - } - - public void setFooSet(final Set fooSet) { - this.fooSet = fooSet; - } - - 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 OPERATION getOperation() { - return OPERATION.parse(operation); - } - - public void setOperation(final OPERATION operation) { - this.operation = operation.getValue(); - } - - public long getTimestamp() { - return timestamp; - } - - public void setTimestamp(final long timestamp) { - this.timestamp = timestamp; - } - - public long getCreatedDate() { - return createdDate; - } - - public void setCreatedDate(final long createdDate) { - this.createdDate = createdDate; - } - - public long getModifiedDate() { - return modifiedDate; - } - - public void setModifiedDate(final long modifiedDate) { - this.modifiedDate = modifiedDate; - } - - public String getCreatedBy() { - return createdBy; - } - - public void setCreatedBy(final String createdBy) { - this.createdBy = createdBy; - } - - public String getModifiedBy() { - return modifiedBy; - } - - public void setModifiedBy(final String modifiedBy) { - this.modifiedBy = modifiedBy; - } - - public void setOperation(final String operation) { - this.operation = operation; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - final Bar other = (Bar) obj; - 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("Bar [name=").append(name).append("]"); - return builder.toString(); - } - - @PrePersist - public void onPrePersist() { - logger.info("@PrePersist"); - audit(OPERATION.INSERT); - } - - @PreUpdate - public void onPreUpdate() { - logger.info("@PreUpdate"); - audit(OPERATION.UPDATE); - } - - @PreRemove - public void onPreRemove() { - logger.info("@PreRemove"); - audit(OPERATION.DELETE); - } - - private void audit(final OPERATION operation) { - setOperation(operation); - setTimestamp((new Date()).getTime()); - } - -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/model/Child.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/model/Child.java deleted file mode 100644 index 19cfb2e237..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/model/Child.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.baeldung.persistence.model; - -import java.io.Serializable; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.OneToOne; - -@Entity -public class Child implements Serializable { - - @Id - @GeneratedValue - private long id; - - @OneToOne(mappedBy = "child") - private Parent parent; - - public Child() { - super(); - } - - // API - - public long getId() { - return id; - } - - public void setId(final long id) { - this.id = id; - } - - public Parent getParent() { - return parent; - } - - public void setParent(final Parent parent) { - this.parent = parent; - } - - // - - @Override - public String toString() { - final StringBuilder builder = new StringBuilder(); - builder.append("Child [id=").append(id).append("]"); - return builder.toString(); - } - -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/model/Foo.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/model/Foo.java deleted file mode 100644 index d36a1e58cf..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/model/Foo.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.baeldung.persistence.model; - -import java.io.Serializable; - -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.NamedNativeQueries; -import javax.persistence.NamedNativeQuery; - -import org.hibernate.envers.Audited; - -@NamedNativeQueries({ @NamedNativeQuery(name = "callGetAllFoos", query = "CALL GetAllFoos()", resultClass = Foo.class), @NamedNativeQuery(name = "callGetFoosByName", query = "CALL GetFoosByName(:fooName)", resultClass = Foo.class) }) -@Entity -@Audited -// @Proxy(lazy = false) -public class Foo implements Serializable { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name = "id") - private long id; - - @Column(name = "name") - private String name; - - @ManyToOne(targetEntity = Bar.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER) - @JoinColumn(name = "BAR_ID") - private Bar bar = new Bar(); - - public Foo() { - super(); - } - - public Foo(final String name) { - super(); - this.name = name; - } - - // - - public Bar getBar() { - return bar; - } - - public void setBar(final Bar bar) { - this.bar = bar; - } - - public long getId() { - return id; - } - - public void setId(final long 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 + ((name == null) ? 0 : name.hashCode()); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - final Foo other = (Foo) obj; - 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("Foo [name=").append(name).append("]"); - return builder.toString(); - } -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/model/Parent.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/model/Parent.java deleted file mode 100644 index fa6948990b..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/model/Parent.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.baeldung.persistence.model; - -import java.io.Serializable; - -import javax.persistence.CascadeType; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.OneToOne; - -@Entity -public class Parent implements Serializable { - - @Id - @GeneratedValue - private long id; - - @OneToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH, CascadeType.DETACH }) - @JoinColumn(name = "child_fk") - private Child child; - - public Parent() { - super(); - } - - public Parent(final Child child) { - super(); - - this.child = child; - } - - // API - - public long getId() { - return id; - } - - public void setId(final long id) { - this.id = id; - } - - public Child getChild() { - return child; - } - - public void setChild(final Child child) { - this.child = child; - } - - // - - @Override - public String toString() { - final StringBuilder builder = new StringBuilder(); - builder.append("Parent [id=").append(id).append("]"); - return builder.toString(); - } - -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/model/Person.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/model/Person.java deleted file mode 100644 index 6a95a7acf5..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/model/Person.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.baeldung.persistence.model; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; - -@Entity -public class Person { - - @Id - @GeneratedValue - private Long id; - - private String name; - - 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; - } -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/IBarAuditableService.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/IBarAuditableService.java deleted file mode 100644 index 33e5634d12..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/IBarAuditableService.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.baeldung.persistence.service; - -import com.baeldung.persistence.dao.common.IAuditOperations; -import com.baeldung.persistence.model.Bar; - -public interface IBarAuditableService extends IBarService, IAuditOperations { - -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/IBarService.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/IBarService.java deleted file mode 100644 index 21185b5990..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/IBarService.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.baeldung.persistence.service; - -import com.baeldung.persistence.dao.common.IOperations; -import com.baeldung.persistence.model.Bar; - -public interface IBarService extends IOperations { - // -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/IChildService.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/IChildService.java deleted file mode 100644 index afe67a70c2..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/IChildService.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.baeldung.persistence.service; - -import com.baeldung.persistence.model.Child; -import com.baeldung.persistence.dao.common.IOperations; - -public interface IChildService extends IOperations { - // -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/IFooAuditableService.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/IFooAuditableService.java deleted file mode 100644 index b787e7fe91..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/IFooAuditableService.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.baeldung.persistence.service; - -import com.baeldung.persistence.dao.common.IAuditOperations; -import com.baeldung.persistence.model.Foo; - -public interface IFooAuditableService extends IFooService, IAuditOperations { - // -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/IFooService.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/IFooService.java deleted file mode 100644 index ffdb53964a..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/IFooService.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.baeldung.persistence.service; - -import com.baeldung.persistence.model.Foo; -import com.baeldung.persistence.dao.common.IOperations; - -public interface IFooService extends IOperations { - // -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/IParentService.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/IParentService.java deleted file mode 100644 index f941416aac..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/IParentService.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.baeldung.persistence.service; - -import com.baeldung.persistence.model.Parent; -import com.baeldung.persistence.dao.common.IOperations; - -public interface IParentService extends IOperations { - // -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/common/AbstractHibernateAuditableService.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/common/AbstractHibernateAuditableService.java deleted file mode 100644 index 2695d7760a..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/common/AbstractHibernateAuditableService.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.baeldung.persistence.service.common; - -import java.io.Serializable; -import java.util.List; - -import com.baeldung.persistence.dao.common.IAuditOperations; -import com.baeldung.persistence.dao.common.IOperations; -import org.springframework.transaction.annotation.Transactional; - -@Transactional(value = "hibernateTransactionManager") -public abstract class AbstractHibernateAuditableService extends AbstractHibernateService implements IOperations, IAuditOperations { - - @Override - public List getEntitiesAtRevision(final Number revision) { - return getAuditableDao().getEntitiesAtRevision(revision); - } - - @Override - public List getEntitiesModifiedAtRevision(final Number revision) { - return getAuditableDao().getEntitiesModifiedAtRevision(revision); - } - - @Override - public List getRevisions() { - return getAuditableDao().getRevisions(); - } - - abstract protected IAuditOperations getAuditableDao(); - -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/common/AbstractHibernateService.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/common/AbstractHibernateService.java deleted file mode 100644 index 02b8ccf48b..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/common/AbstractHibernateService.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.baeldung.persistence.service.common; - -import java.io.Serializable; -import java.util.List; - -import com.baeldung.persistence.dao.common.IOperations; -import org.springframework.transaction.annotation.Transactional; - -@Transactional(value = "hibernateTransactionManager") -public abstract class AbstractHibernateService extends AbstractService implements IOperations { - - @Override - public T findOne(final long id) { - return super.findOne(id); - } - - @Override - public List findAll() { - return super.findAll(); - } - - @Override - public void create(final T entity) { - super.create(entity); - } - - @Override - public T update(final T entity) { - return super.update(entity); - } - - @Override - public void delete(final T entity) { - super.delete(entity); - } - - @Override - public void deleteById(final long entityId) { - super.deleteById(entityId); - } - -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/common/AbstractJpaService.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/common/AbstractJpaService.java deleted file mode 100644 index a1c6fe9edf..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/common/AbstractJpaService.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.baeldung.persistence.service.common; - -import java.io.Serializable; -import java.util.List; - -import com.baeldung.persistence.dao.common.IOperations; -import org.springframework.transaction.annotation.Transactional; - -@Transactional(value = "jpaTransactionManager") -public abstract class AbstractJpaService extends AbstractService implements IOperations { - - @Override - public T findOne(final long id) { - return super.findOne(id); - } - - @Override - public List findAll() { - return super.findAll(); - } - - @Override - public void create(final T entity) { - super.create(entity); - } - - @Override - public T update(final T entity) { - return super.update(entity); - } - - @Override - public void delete(final T entity) { - super.delete(entity); - } - - @Override - public void deleteById(final long entityId) { - super.deleteById(entityId); - } - -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/common/AbstractService.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/common/AbstractService.java deleted file mode 100644 index 9b001b1fac..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/common/AbstractService.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.baeldung.persistence.service.common; - -import java.io.Serializable; -import java.util.List; - -import com.baeldung.persistence.dao.common.IOperations; - -public abstract class AbstractService implements IOperations { - - @Override - public T findOne(final long id) { - return getDao().findOne(id); - } - - @Override - public List findAll() { - return getDao().findAll(); - } - - @Override - public void create(final T entity) { - getDao().create(entity); - } - - @Override - public T update(final T entity) { - return getDao().update(entity); - } - - @Override - public void delete(final T entity) { - getDao().delete(entity); - } - - @Override - public void deleteById(final long entityId) { - getDao().deleteById(entityId); - } - - protected abstract IOperations getDao(); - -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/common/AbstractSpringDataJpaService.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/common/AbstractSpringDataJpaService.java deleted file mode 100644 index cef483e6bf..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/common/AbstractSpringDataJpaService.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.baeldung.persistence.service.common; - -import java.io.Serializable; -import java.util.List; - -import com.baeldung.persistence.dao.common.IOperations; -import org.springframework.data.repository.CrudRepository; -import org.springframework.transaction.annotation.Transactional; - -import com.google.common.collect.Lists; - -@Transactional(value = "jpaTransactionManager") -public abstract class AbstractSpringDataJpaService implements IOperations { - - @Override - public T findOne(final long id) { - return getDao().findOne(Long.valueOf(id)); - } - - @Override - public List findAll() { - return Lists.newArrayList(getDao().findAll()); - } - - @Override - public void create(final T entity) { - getDao().save(entity); - } - - @Override - public T update(final T entity) { - return getDao().save(entity); - } - - @Override - public void delete(final T entity) { - getDao().delete(entity); - } - - @Override - public void deleteById(final long entityId) { - getDao().delete(Long.valueOf(entityId)); - } - - protected abstract CrudRepository getDao(); -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/BarAuditableService.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/BarAuditableService.java deleted file mode 100644 index d84c28caa5..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/BarAuditableService.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.baeldung.persistence.service.impl; - -import com.baeldung.persistence.dao.common.IAuditOperations; -import com.baeldung.persistence.service.common.AbstractHibernateAuditableService; -import com.baeldung.persistence.dao.IBarAuditableDao; -import com.baeldung.persistence.dao.IBarDao; -import com.baeldung.persistence.dao.common.IOperations; -import com.baeldung.persistence.model.Bar; -import com.baeldung.persistence.service.IBarAuditableService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Service; - -@Service -public class BarAuditableService extends AbstractHibernateAuditableService implements IBarAuditableService { - - @Autowired - @Qualifier("barHibernateDao") - private IBarDao dao; - - @Autowired - @Qualifier("barHibernateAuditableDao") - private IBarAuditableDao auditDao; - - public BarAuditableService() { - super(); - } - - // API - - @Override - protected IOperations getDao() { - return dao; - } - - @Override - protected IAuditOperations getAuditableDao() { - return auditDao; - } - -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/BarJpaService.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/BarJpaService.java deleted file mode 100644 index 1c1b7a2274..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/BarJpaService.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.baeldung.persistence.service.impl; - -import com.baeldung.persistence.dao.IBarDao; -import com.baeldung.persistence.dao.common.IOperations; -import com.baeldung.persistence.model.Bar; -import com.baeldung.persistence.service.IBarService; -import com.baeldung.persistence.service.common.AbstractJpaService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Service; - -@Service -public class BarJpaService extends AbstractJpaService implements IBarService { - - @Autowired - @Qualifier("barJpaDao") - private IBarDao dao; - - public BarJpaService() { - super(); - } - - // API - - @Override - protected IOperations getDao() { - return dao; - } - -} \ No newline at end of file diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/BarService.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/BarService.java deleted file mode 100644 index 32d1f919c5..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/BarService.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.baeldung.persistence.service.impl; - -import com.baeldung.persistence.dao.IBarDao; -import com.baeldung.persistence.dao.common.IOperations; -import com.baeldung.persistence.model.Bar; -import com.baeldung.persistence.service.IBarService; -import com.baeldung.persistence.service.common.AbstractHibernateService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Service; - -@Service -public class BarService extends AbstractHibernateService implements IBarService { - - @Autowired - @Qualifier("barHibernateDao") - private IBarDao dao; - - public BarService() { - super(); - } - - // API - - @Override - protected IOperations getDao() { - return dao; - } - -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/BarSpringDataJpaService.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/BarSpringDataJpaService.java deleted file mode 100644 index 4a55d08a35..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/BarSpringDataJpaService.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.baeldung.persistence.service.impl; - -import java.io.Serializable; - -import com.baeldung.persistence.service.common.AbstractSpringDataJpaService; -import com.baeldung.persistence.dao.IBarCrudRepository; -import com.baeldung.persistence.model.Bar; -import com.baeldung.persistence.service.IBarService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.repository.CrudRepository; - -public class BarSpringDataJpaService extends AbstractSpringDataJpaService implements IBarService { - - @Autowired - private IBarCrudRepository dao; - - public BarSpringDataJpaService() { - super(); - } - - @Override - protected CrudRepository getDao() { - return dao; - } - -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/ChildService.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/ChildService.java deleted file mode 100644 index 417fe2c49a..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/ChildService.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.baeldung.persistence.service.impl; - -import com.baeldung.persistence.model.Child; -import com.baeldung.persistence.service.IChildService; -import com.baeldung.persistence.dao.IChildDao; -import com.baeldung.persistence.dao.common.IOperations; -import com.baeldung.persistence.service.common.AbstractHibernateService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class ChildService extends AbstractHibernateService implements IChildService { - - @Autowired - private IChildDao dao; - - public ChildService() { - super(); - } - - // API - - @Override - protected IOperations getDao() { - return dao; - } - -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/FooAuditableService.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/FooAuditableService.java deleted file mode 100644 index 45ad315c42..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/FooAuditableService.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.baeldung.persistence.service.impl; - -import com.baeldung.persistence.dao.common.IAuditOperations; -import com.baeldung.persistence.service.IFooAuditableService; -import com.baeldung.persistence.service.common.AbstractHibernateAuditableService; -import com.baeldung.persistence.dao.IFooAuditableDao; -import com.baeldung.persistence.dao.IFooDao; -import com.baeldung.persistence.dao.common.IOperations; -import com.baeldung.persistence.model.Foo; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Service; - -@Service -public class FooAuditableService extends AbstractHibernateAuditableService implements IFooAuditableService { - - @Autowired - @Qualifier("fooHibernateDao") - private IFooDao dao; - - @Autowired - @Qualifier("fooHibernateAuditableDao") - private IFooAuditableDao auditDao; - - public FooAuditableService() { - super(); - } - - // API - - @Override - protected IOperations getDao() { - return dao; - } - - @Override - protected IAuditOperations getAuditableDao() { - return auditDao; - } - -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/FooService.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/FooService.java deleted file mode 100644 index 84cf018fee..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/FooService.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.baeldung.persistence.service.impl; - -import com.baeldung.persistence.dao.IFooDao; -import com.baeldung.persistence.dao.common.IOperations; -import com.baeldung.persistence.model.Foo; -import com.baeldung.persistence.service.IFooService; -import com.baeldung.persistence.service.common.AbstractHibernateService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Service; - -@Service -public class FooService extends AbstractHibernateService implements IFooService { - - @Autowired - @Qualifier("fooHibernateDao") - private IFooDao dao; - - public FooService() { - super(); - } - - // API - - @Override - protected IOperations getDao() { - return dao; - } - -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/ParentService.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/ParentService.java deleted file mode 100644 index 078acfc369..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/persistence/service/impl/ParentService.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.baeldung.persistence.service.impl; - -import com.baeldung.persistence.model.Parent; -import com.baeldung.persistence.service.IParentService; -import com.baeldung.persistence.dao.IParentDao; -import com.baeldung.persistence.dao.common.IOperations; -import com.baeldung.persistence.service.common.AbstractHibernateService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class ParentService extends AbstractHibernateService implements IParentService { - - @Autowired - private IParentDao dao; - - public ParentService() { - super(); - } - - // API - - @Override - protected IOperations getDao() { - return dao; - } - -} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/spring/PersistenceConfig.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/spring/PersistenceConfig.java deleted file mode 100644 index 4927c9957c..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/spring/PersistenceConfig.java +++ /dev/null @@ -1,186 +0,0 @@ -package com.baeldung.spring; - -import java.util.Properties; - -import javax.sql.DataSource; - -import org.apache.tomcat.dbcp.dbcp2.BasicDataSource; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; -import org.springframework.core.env.Environment; -import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; -import org.springframework.data.domain.AuditorAware; -import org.springframework.data.jpa.repository.config.EnableJpaAuditing; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import org.springframework.orm.hibernate4.HibernateTransactionManager; -import org.springframework.orm.hibernate4.LocalSessionFactoryBean; -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 com.baeldung.hibernate.audit.AuditorAwareImpl; -import com.baeldung.persistence.dao.IBarAuditableDao; -import com.baeldung.persistence.dao.IBarDao; -import com.baeldung.persistence.dao.IFooAuditableDao; -import com.baeldung.persistence.dao.IFooDao; -import com.baeldung.persistence.dao.impl.BarAuditableDao; -import com.baeldung.persistence.dao.impl.BarDao; -import com.baeldung.persistence.dao.impl.BarJpaDao; -import com.baeldung.persistence.dao.impl.FooAuditableDao; -import com.baeldung.persistence.dao.impl.FooDao; -import com.baeldung.persistence.service.IBarAuditableService; -import com.baeldung.persistence.service.IBarService; -import com.baeldung.persistence.service.IFooAuditableService; -import com.baeldung.persistence.service.IFooService; -import com.baeldung.persistence.service.impl.BarAuditableService; -import com.baeldung.persistence.service.impl.BarJpaService; -import com.baeldung.persistence.service.impl.BarSpringDataJpaService; -import com.baeldung.persistence.service.impl.FooAuditableService; -import com.baeldung.persistence.service.impl.FooService; -import com.google.common.base.Preconditions; - -@Configuration -@EnableTransactionManagement -@EnableJpaRepositories(basePackages = { "com.baeldung.persistence" }, transactionManagerRef = "jpaTransactionManager") -@EnableJpaAuditing(auditorAwareRef = "auditorProvider") -@PropertySource({ "classpath:persistence-h2.properties" }) -@ComponentScan({ "com.baeldung.persistence" }) -public class PersistenceConfig { - - @Autowired - private Environment env; - - public PersistenceConfig() { - super(); - } - - @Bean("auditorProvider") - public AuditorAware auditorProvider() { - return new AuditorAwareImpl(); - } - - @Bean - public LocalSessionFactoryBean sessionFactory() { - final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); - sessionFactory.setDataSource(restDataSource()); - sessionFactory.setPackagesToScan(new String[] { "com.baeldung.persistence.model" }); - sessionFactory.setHibernateProperties(hibernateProperties()); - - return sessionFactory; - } - - @Bean - public LocalContainerEntityManagerFactoryBean entityManagerFactory() { - final LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean(); - emf.setDataSource(restDataSource()); - emf.setPackagesToScan(new String[] { "com.baeldung.persistence.model" }); - - final JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); - emf.setJpaVendorAdapter(vendorAdapter); - emf.setJpaProperties(hibernateProperties()); - - return emf; - } - - @Bean - public DataSource restDataSource() { - final BasicDataSource dataSource = new BasicDataSource(); - 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 hibernateTransactionManager() { - final HibernateTransactionManager transactionManager = new HibernateTransactionManager(); - transactionManager.setSessionFactory(sessionFactory().getObject()); - return transactionManager; - } - - @Bean - public PlatformTransactionManager jpaTransactionManager() { - final JpaTransactionManager transactionManager = new JpaTransactionManager(); - transactionManager.setEntityManagerFactory(entityManagerFactory().getObject()); - return transactionManager; - } - - @Bean - public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { - return new PersistenceExceptionTranslationPostProcessor(); - } - - @Bean - public IBarService barJpaService() { - return new BarJpaService(); - } - - @Bean - public IBarService barSpringDataJpaService() { - return new BarSpringDataJpaService(); - } - - @Bean - public IFooService fooHibernateService() { - return new FooService(); - } - - @Bean - public IBarAuditableService barHibernateAuditableService() { - return new BarAuditableService(); - } - - @Bean - public IFooAuditableService fooHibernateAuditableService() { - return new FooAuditableService(); - } - - @Bean - public IBarDao barJpaDao() { - return new BarJpaDao(); - } - - @Bean - public IBarDao barHibernateDao() { - return new BarDao(); - } - - @Bean - public IBarAuditableDao barHibernateAuditableDao() { - return new BarAuditableDao(); - } - - @Bean - public IFooDao fooHibernateDao() { - return new FooDao(); - } - - @Bean - public IFooAuditableDao fooHibernateAuditableDao() { - return new FooAuditableDao(); - } - - 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-hibernate4/src/main/java/com/baeldung/spring/PersistenceXmlConfig.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/spring/PersistenceXmlConfig.java deleted file mode 100644 index 9cbeb8e1f8..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/spring/PersistenceXmlConfig.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.baeldung.spring; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.ImportResource; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -@Configuration -@EnableTransactionManagement -@ComponentScan({ "com.baeldung.persistence.dao", "com.baeldung.persistence.service" }) -@ImportResource({ "classpath:hibernate4Config.xml" }) -public class PersistenceXmlConfig { - - public PersistenceXmlConfig() { - super(); - } - -} \ No newline at end of file diff --git a/persistence-modules/spring-hibernate4/src/main/resources/fetching.cfg.xml b/persistence-modules/spring-hibernate4/src/main/resources/fetching.cfg.xml deleted file mode 100644 index 1b9a4a191c..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/resources/fetching.cfg.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - com.mysql.jdbc.Driver - jdbc:mysql://localhost:3306/test - root - iamtheking - org.hibernate.dialect.MySQLDialect - true - validate - - - - - - \ No newline at end of file diff --git a/persistence-modules/spring-hibernate4/src/main/resources/fetchingLazy.cfg.xml b/persistence-modules/spring-hibernate4/src/main/resources/fetchingLazy.cfg.xml deleted file mode 100644 index c5f608e1a7..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/resources/fetchingLazy.cfg.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - com.mysql.jdbc.Driver - jdbc:mysql://localhost:3306/test - root - iamtheking - org.hibernate.dialect.MySQLDialect - true - - - - \ No newline at end of file diff --git a/persistence-modules/spring-hibernate4/src/main/resources/fetching_create_queries.sql b/persistence-modules/spring-hibernate4/src/main/resources/fetching_create_queries.sql deleted file mode 100644 index b36d9828f1..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/resources/fetching_create_queries.sql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE TABLE `user` ( - `user_id` int(10) NOT NULL AUTO_INCREMENT, - PRIMARY KEY (`user_id`) -) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=latin1 ; - - -CREATE TABLE `user_order` ( - `ORDER_ID` int(10) NOT NULL AUTO_INCREMENT, - `USER_ID` int(10) NOT NULL DEFAULT '0', - PRIMARY KEY (`ORDER_ID`,`USER_ID`), - KEY `USER_ID` (`USER_ID`), - CONSTRAINT `user_order_ibfk_1` FOREIGN KEY (`USER_ID`) REFERENCES `USER` (`user_id`) -) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1; - diff --git a/persistence-modules/spring-hibernate4/src/main/resources/hibernate4Config.xml b/persistence-modules/spring-hibernate4/src/main/resources/hibernate4Config.xml deleted file mode 100644 index ca507802cd..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/resources/hibernate4Config.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - ${hibernate.hbm2ddl.auto} - ${hibernate.dialect} - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/persistence-modules/spring-hibernate4/src/main/resources/immutable.cfg.xml b/persistence-modules/spring-hibernate4/src/main/resources/immutable.cfg.xml deleted file mode 100644 index fe1e3cb723..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/resources/immutable.cfg.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - org.hsqldb.jdbcDriver - jdbc:hsqldb:hsql:mem://localhost/xdb - sa - - - - 1 - - - org.hibernate.dialect.HSQLDialect - - - thread - - - org.hibernate.cache.NoCacheProvider - - - true - - - update - - - - - - \ No newline at end of file diff --git a/persistence-modules/spring-hibernate4/src/main/resources/insert_statements.sql b/persistence-modules/spring-hibernate4/src/main/resources/insert_statements.sql deleted file mode 100644 index ae008f29bc..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/resources/insert_statements.sql +++ /dev/null @@ -1,31 +0,0 @@ -insert into item (item_id, item_name, item_desc, item_price) -values(1,'item One', 'test 1', 35.12); - -insert into item (item_id, item_name, item_desc, item_price) -values(2,'Pogo stick', 'Pogo stick', 466.12); -insert into item (item_id, item_name, item_desc, item_price) -values(3,'Raft', 'Raft', 345.12); - -insert into item (item_id, item_name, item_desc, item_price) -values(4,'Skate Board', 'Skating', 135.71); - -insert into item (item_id, item_name, item_desc, item_price) -values(5,'Umbrella', 'Umbrella for Rain', 619.25); - -insert into item (item_id, item_name, item_desc, item_price) -values(6,'Glue', 'Glue for home', 432.73); - -insert into item (item_id, item_name, item_desc, item_price) -values(7,'Paint', 'Paint for Room', 1311.40); - -insert into item (item_id, item_name, item_desc, item_price) -values(8,'Red paint', 'Red paint for room', 1135.71); - -insert into item (item_id, item_name, item_desc, item_price) -values(9,'Household Chairs', 'Chairs for house', 25.71); - -insert into item (item_id, item_name, item_desc, item_price) -values(10,'Office Chairs', 'Chairs for office', 395.98); - -insert into item (item_id, item_name, item_desc, item_price) -values(11,'Outdoor Chairs', 'Chairs for outdoor activities', 1234.36); diff --git a/persistence-modules/spring-hibernate4/src/main/resources/logback.xml b/persistence-modules/spring-hibernate4/src/main/resources/logback.xml deleted file mode 100644 index 56af2d397e..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/resources/logback.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - - - - - - - \ No newline at end of file diff --git a/persistence-modules/spring-hibernate4/src/main/resources/persistence-mysql.properties b/persistence-modules/spring-hibernate4/src/main/resources/persistence-mysql.properties deleted file mode 100644 index f6b6ab6fca..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/resources/persistence-mysql.properties +++ /dev/null @@ -1,13 +0,0 @@ -# jdbc.X -jdbc.driverClassName=com.mysql.jdbc.Driver -jdbc.url=jdbc:mysql://localhost:3306/spring_hibernate4_01?createDatabaseIfNotExist=true -jdbc.user=tutorialuser -jdbc.pass=tutorialmy5ql - -# hibernate.X -hibernate.dialect=org.hibernate.dialect.MySQL5Dialect -hibernate.show_sql=false -hibernate.hbm2ddl.auto=create-drop - -# envers.X -envers.audit_table_suffix=_audit_log diff --git a/persistence-modules/spring-hibernate4/src/main/resources/stored_procedure.sql b/persistence-modules/spring-hibernate4/src/main/resources/stored_procedure.sql deleted file mode 100644 index 9cedb75c37..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/resources/stored_procedure.sql +++ /dev/null @@ -1,20 +0,0 @@ -DELIMITER // - CREATE PROCEDURE GetFoosByName(IN fooName VARCHAR(255)) - LANGUAGE SQL - DETERMINISTIC - SQL SECURITY DEFINER - BEGIN - SELECT * FROM foo WHERE name = fooName; - END // -DELIMITER ; - - -DELIMITER // - CREATE PROCEDURE GetAllFoos() - LANGUAGE SQL - DETERMINISTIC - SQL SECURITY DEFINER - BEGIN - SELECT * FROM foo; - END // -DELIMITER ; \ No newline at end of file diff --git a/persistence-modules/spring-hibernate4/src/main/resources/webSecurityConfig.xml b/persistence-modules/spring-hibernate4/src/main/resources/webSecurityConfig.xml deleted file mode 100644 index e5c19a4ad7..0000000000 --- a/persistence-modules/spring-hibernate4/src/main/resources/webSecurityConfig.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/SpringContextTest.java b/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/SpringContextTest.java deleted file mode 100644 index e19965773e..0000000000 --- a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/SpringContextTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.baeldung; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; - -import com.baeldung.spring.PersistenceConfig; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) -public class SpringContextTest { - - @Test - public void whenSpringContextIsBootstrapped_thenNoExceptions() { - } -} diff --git a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/hibernate/fetching/HibernateFetchingIntegrationTest.java b/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/hibernate/fetching/HibernateFetchingIntegrationTest.java deleted file mode 100644 index 65bf36f8bf..0000000000 --- a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/hibernate/fetching/HibernateFetchingIntegrationTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.baeldung.hibernate.fetching; - -import com.baeldung.hibernate.fetching.model.OrderDetail; -import com.baeldung.hibernate.fetching.view.FetchingAppView; -import org.hibernate.Hibernate; -import org.junit.Before; -import org.junit.Test; - -import java.util.Set; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -public class HibernateFetchingIntegrationTest { - - // this loads sample data in the database - @Before - public void addFecthingTestData() { - FetchingAppView fav = new FetchingAppView(); - fav.createTestData(); - } - - // testLazyFetching() tests the lazy loading - // Since it lazily loaded so orderDetalSetLazy won't - // be initialized - @Test - public void testLazyFetching() { - FetchingAppView fav = new FetchingAppView(); - Set orderDetalSetLazy = fav.lazyLoaded(); - assertFalse(Hibernate.isInitialized(orderDetalSetLazy)); - } - - // testEagerFetching() tests the eager loading - // Since it eagerly loaded so orderDetalSetLazy would - // be initialized - @Test - public void testEagerFetching() { - FetchingAppView fav = new FetchingAppView(); - Set orderDetalSetEager = fav.eagerLoaded(); - assertTrue(Hibernate.isInitialized(orderDetalSetEager)); - } -} diff --git a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/IntegrationTestSuite.java b/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/IntegrationTestSuite.java deleted file mode 100644 index f5c45a5d6f..0000000000 --- a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/IntegrationTestSuite.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.baeldung.persistence; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -import com.baeldung.persistence.audit.AuditTestSuite; -import com.baeldung.persistence.hibernate.FooPaginationPersistenceIntegrationTest; -import com.baeldung.persistence.hibernate.FooSortingPersistenceIntegrationTest; -import com.baeldung.persistence.service.FooServiceBasicPersistenceIntegrationTest; -import com.baeldung.persistence.service.FooServicePersistenceIntegrationTest; -import com.baeldung.persistence.service.ParentServicePersistenceIntegrationTest; - -@RunWith(Suite.class) -@Suite.SuiteClasses({ // @formatter:off - AuditTestSuite.class - ,FooServiceBasicPersistenceIntegrationTest.class - ,FooPaginationPersistenceIntegrationTest.class - ,FooServicePersistenceIntegrationTest.class - ,ParentServicePersistenceIntegrationTest.class - ,FooSortingPersistenceIntegrationTest.class - -}) // @formatter:on -public class IntegrationTestSuite { - // -} diff --git a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/audit/AuditTestSuite.java b/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/audit/AuditTestSuite.java deleted file mode 100644 index 34c725d62b..0000000000 --- a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/audit/AuditTestSuite.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.baeldung.persistence.audit; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -@RunWith(Suite.class) -@Suite.SuiteClasses({ // @formatter:off - EnversFooBarAuditIntegrationTest.class, - JPABarAuditIntegrationTest.class, - SpringDataJPABarAuditIntegrationTest.class -}) // @formatter:on -public class AuditTestSuite { - // -} \ No newline at end of file diff --git a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/audit/EnversFooBarAuditIntegrationTest.java b/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/audit/EnversFooBarAuditIntegrationTest.java deleted file mode 100644 index 444324dafc..0000000000 --- a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/audit/EnversFooBarAuditIntegrationTest.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.baeldung.persistence.audit; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.List; - -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -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.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; - -import com.baeldung.persistence.model.Bar; -import com.baeldung.persistence.model.Foo; -import com.baeldung.persistence.service.IBarAuditableService; -import com.baeldung.persistence.service.IFooAuditableService; -import com.baeldung.spring.config.PersistenceTestConfig; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { PersistenceTestConfig.class }, loader = AnnotationConfigContextLoader.class) -@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS) -public class EnversFooBarAuditIntegrationTest { - - private static Logger logger = LoggerFactory.getLogger(EnversFooBarAuditIntegrationTest.class); - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - logger.info("setUpBeforeClass()"); - } - - @AfterClass - public static void tearDownAfterClass() throws Exception { - logger.info("tearDownAfterClass()"); - } - - @Autowired - @Qualifier("fooHibernateAuditableService") - private IFooAuditableService fooService; - - @Autowired - @Qualifier("barHibernateAuditableService") - private IBarAuditableService barService; - - @Autowired - private SessionFactory sessionFactory; - - private Session session; - - @Before - public void setUp() throws Exception { - logger.info("setUp()"); - makeRevisions(); - session = sessionFactory.openSession(); - } - - @After - public void tearDown() throws Exception { - logger.info("tearDown()"); - session.close(); - } - - private void makeRevisions() { - final Bar bar = rev1(); - rev2(bar); - rev3(bar); - rev4(bar); - } - - // REV #1: insert BAR & FOO1 - private Bar rev1() { - final Bar bar = new Bar("BAR"); - final Foo foo1 = new Foo("FOO1"); - foo1.setBar(bar); - fooService.create(foo1); - return bar; - } - - // REV #2: insert FOO2 & update BAR - private void rev2(final Bar bar) { - final Foo foo2 = new Foo("FOO2"); - foo2.setBar(bar); - fooService.create(foo2); - } - - // REV #3: update BAR - private void rev3(final Bar bar) { - - bar.setName("BAR1"); - barService.update(bar); - } - - // REV #4: insert FOO3 & update BAR - private void rev4(final Bar bar) { - - final Foo foo3 = new Foo("FOO3"); - foo3.setBar(bar); - fooService.create(foo3); - } - - @Test - public final void whenFooBarsModified_thenFooBarsAudited() { - - List barRevisionList; - List fooRevisionList; - - // test Bar revisions - - barRevisionList = barService.getRevisions(); - - assertNotNull(barRevisionList); - assertEquals(4, barRevisionList.size()); - - assertEquals("BAR", barRevisionList.get(0).getName()); - assertEquals("BAR", barRevisionList.get(1).getName()); - assertEquals("BAR1", barRevisionList.get(2).getName()); - assertEquals("BAR1", barRevisionList.get(3).getName()); - - assertEquals(1, barRevisionList.get(0).getFooSet().size()); - assertEquals(2, barRevisionList.get(1).getFooSet().size()); - assertEquals(2, barRevisionList.get(2).getFooSet().size()); - assertEquals(3, barRevisionList.get(3).getFooSet().size()); - - // test Foo revisions - - fooRevisionList = fooService.getRevisions(); - assertNotNull(fooRevisionList); - assertEquals(3, fooRevisionList.size()); - assertEquals("FOO1", fooRevisionList.get(0).getName()); - assertEquals("FOO2", fooRevisionList.get(1).getName()); - assertEquals("FOO3", fooRevisionList.get(2).getName()); - } - -} diff --git a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/audit/JPABarAuditIntegrationTest.java b/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/audit/JPABarAuditIntegrationTest.java deleted file mode 100644 index 733074a6a3..0000000000 --- a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/audit/JPABarAuditIntegrationTest.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.baeldung.persistence.audit; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -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.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; - -import com.baeldung.persistence.model.Bar; -import com.baeldung.persistence.model.Bar.OPERATION; -import com.baeldung.persistence.service.IBarService; -import com.baeldung.spring.config.PersistenceTestConfig; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { PersistenceTestConfig.class }, loader = AnnotationConfigContextLoader.class) -public class JPABarAuditIntegrationTest { - - private static Logger logger = LoggerFactory.getLogger(JPABarAuditIntegrationTest.class); - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - logger.info("setUpBeforeClass()"); - } - - @AfterClass - public static void tearDownAfterClass() throws Exception { - logger.info("tearDownAfterClass()"); - } - - @Autowired - @Qualifier("barJpaService") - private IBarService barService; - - @Autowired - private EntityManagerFactory entityManagerFactory; - - private EntityManager em; - - @Before - public void setUp() throws Exception { - logger.info("setUp()"); - em = entityManagerFactory.createEntityManager(); - } - - @After - public void tearDown() throws Exception { - logger.info("tearDown()"); - em.close(); - } - - @Test - public final void whenBarsModified_thenBarsAudited() { - - // insert BAR1 - Bar bar1 = new Bar("BAR1"); - barService.create(bar1); - - // update BAR1 - bar1.setName("BAR1a"); - barService.update(bar1); - - // insert BAR2 - Bar bar2 = new Bar("BAR2"); - barService.create(bar2); - - // update BAR1 - bar1.setName("BAR1b"); - barService.update(bar1); - - // get BAR1 and BAR2 from the DB and check the audit values - // detach instances from persistence context to make sure we fire db - em.detach(bar1); - em.detach(bar2); - bar1 = barService.findOne(bar1.getId()); - bar2 = barService.findOne(bar2.getId()); - - assertNotNull(bar1); - assertNotNull(bar2); - assertEquals(OPERATION.UPDATE, bar1.getOperation()); - assertEquals(OPERATION.INSERT, bar2.getOperation()); - assertTrue(bar1.getTimestamp() > bar2.getTimestamp()); - - barService.deleteById(bar1.getId()); - barService.deleteById(bar2.getId()); - - } - -} \ No newline at end of file diff --git a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/audit/SpringDataJPABarAuditIntegrationTest.java b/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/audit/SpringDataJPABarAuditIntegrationTest.java deleted file mode 100644 index 18227abd28..0000000000 --- a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/audit/SpringDataJPABarAuditIntegrationTest.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.baeldung.persistence.audit; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -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.security.test.context.support.WithMockUser; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; - -import com.baeldung.persistence.model.Bar; -import com.baeldung.persistence.service.IBarService; -import com.baeldung.spring.config.PersistenceTestConfig; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { PersistenceTestConfig.class }, loader = AnnotationConfigContextLoader.class) -public class SpringDataJPABarAuditIntegrationTest { - - private static Logger logger = LoggerFactory.getLogger(SpringDataJPABarAuditIntegrationTest.class); - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - logger.info("setUpBeforeClass()"); - } - - @AfterClass - public static void tearDownAfterClass() throws Exception { - logger.info("tearDownAfterClass()"); - } - - @Autowired - @Qualifier("barSpringDataJpaService") - private IBarService barService; - - @Autowired - private EntityManagerFactory entityManagerFactory; - - private EntityManager em; - - @Before - public void setUp() throws Exception { - logger.info("setUp()"); - em = entityManagerFactory.createEntityManager(); - } - - @After - public void tearDown() throws Exception { - logger.info("tearDown()"); - em.close(); - } - - @Test - @WithMockUser(username = "tutorialuser") - public final void whenBarsModified_thenBarsAudited() { - Bar bar = new Bar("BAR1"); - barService.create(bar); - assertEquals(bar.getCreatedDate(), bar.getModifiedDate()); - assertEquals("tutorialuser", bar.getCreatedBy(), bar.getModifiedBy()); - bar.setName("BAR2"); - bar = barService.update(bar); - assertTrue(bar.getCreatedDate() < bar.getModifiedDate()); - assertEquals("tutorialuser", bar.getCreatedBy(), bar.getModifiedBy()); - } -} diff --git a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/hibernate/FooFixtures.java b/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/hibernate/FooFixtures.java deleted file mode 100644 index da840dc027..0000000000 --- a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/hibernate/FooFixtures.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.baeldung.persistence.hibernate; - -import java.util.List; - -import com.baeldung.persistence.model.Foo; -import com.baeldung.persistence.model.Bar; -import org.hibernate.HibernateException; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; - -import com.google.common.collect.Lists; - -public class FooFixtures { - private SessionFactory sessionFactory; - - public FooFixtures(final SessionFactory sessionFactory) { - super(); - - this.sessionFactory = sessionFactory; - } - - // API - - public void createBars() { - Session session = null; - Transaction tx = null; - session = sessionFactory.openSession(); - tx = session.getTransaction(); - try { - tx.begin(); - for (int i = 156; i < 160; i++) { - final Bar bar = new Bar(); - bar.setName("Bar_" + i); - final Foo foo = new Foo("Foo_" + (i + 120)); - foo.setBar(bar); - session.save(foo); - final Foo foo2 = new Foo(null); - if (i % 2 == 0) - foo2.setName("LuckyFoo" + (i + 120)); - foo2.setBar(bar); - session.save(foo2); - bar.getFooSet().add(foo); - bar.getFooSet().add(foo2); - session.merge(bar); - } - tx.commit(); - session.flush(); - } catch (final HibernateException he) { - if (tx != null) - tx.rollback(); - System.out.println("Not able to open session"); - he.printStackTrace(); - } catch (final Exception e) { - e.printStackTrace(); - } finally { - if (session != null) - session.close(); - } - - } - - public void createFoos() { - Session session = null; - Transaction tx = null; - session = sessionFactory.openSession(); - tx = session.getTransaction(); - final List fooList = Lists.newArrayList(); - for (int i = 35; i < 46; i++) { - - final Foo foo = new Foo(); - foo.setName("Foo_" + (i + 120)); - final Bar bar = new Bar("bar_" + i); - bar.getFooSet().add(foo); - foo.setBar(bar); - fooList.add(foo); - - } - try { - tx.begin(); - for (final Foo foo : fooList) { - - session.save(foo.getBar()); - session.save(foo); - } - tx.commit(); - session.flush(); - } catch (final HibernateException he) { - if (tx != null) - tx.rollback(); - System.out.println("Not able to open session"); - he.printStackTrace(); - } catch (final Exception e) { - e.printStackTrace(); - } finally { - if (session != null) - session.close(); - } - } - -} diff --git a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/hibernate/FooPaginationPersistenceIntegrationTest.java b/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/hibernate/FooPaginationPersistenceIntegrationTest.java deleted file mode 100644 index fd7bc4aabf..0000000000 --- a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/hibernate/FooPaginationPersistenceIntegrationTest.java +++ /dev/null @@ -1,185 +0,0 @@ -package com.baeldung.persistence.hibernate; - -import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.Matchers.lessThan; -import static org.junit.Assert.assertThat; - -import java.util.List; - -import org.hibernate.Criteria; -import org.hibernate.Query; -import org.hibernate.ScrollMode; -import org.hibernate.ScrollableResults; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.criterion.Projections; -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.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; - -import com.baeldung.persistence.model.Foo; -import com.baeldung.persistence.service.IFooService; -import com.baeldung.spring.config.PersistenceTestConfig; -import com.google.common.collect.Lists; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { PersistenceTestConfig.class }, loader = AnnotationConfigContextLoader.class) -public class FooPaginationPersistenceIntegrationTest { - - @Autowired - private IFooService fooService; - - @Autowired - private SessionFactory sessionFactory; - - private Session session; - - // tests - - @Before - public final void before() { - final int minimalNumberOfEntities = 25; - if (fooService.findAll().size() <= minimalNumberOfEntities) { - for (int i = 0; i < minimalNumberOfEntities; i++) { - fooService.create(new Foo(randomAlphabetic(6))); - } - } - - session = sessionFactory.openSession(); - } - - @After - public final void after() { - session.close(); - } - - // tests - - @Test - public final void whenContextIsBootstrapped_thenNoExceptions() { - // - } - - @SuppressWarnings("unchecked") - @Test - public final void whenRetrievingPaginatedEntities_thenCorrectSize() { - final int pageNumber = 1; - final int pageSize = 10; - - final Query query = session.createQuery("From Foo"); - query.setFirstResult((pageNumber - 1) * pageSize); - query.setMaxResults(pageSize); - final List fooList = query.list(); - - assertThat(fooList, hasSize(pageSize)); - } - - @SuppressWarnings("unchecked") - @Test - public final void whenRetrievingAllPages_thenCorrect() { - int pageNumber = 1; - final int pageSize = 10; - - final String countQ = "Select count (f.id) from Foo f"; - final Query countQuery = session.createQuery(countQ); - final Long countResult = (Long) countQuery.uniqueResult(); - - final List fooList = Lists.newArrayList(); - int totalEntities = 0; - final Query query = session.createQuery("From Foo"); - while (totalEntities < countResult) { - query.setFirstResult((pageNumber - 1) * pageSize); - query.setMaxResults(pageSize); - fooList.addAll(query.list()); - totalEntities = fooList.size(); - pageNumber++; - } - } - - @SuppressWarnings("unchecked") - @Test - public final void whenRetrievingLastPage_thenCorrectSize() { - final int pageSize = 10; - - final String countQ = "Select count (f.id) from Foo f"; - final Query countQuery = session.createQuery(countQ); - final Long countResults = (Long) countQuery.uniqueResult(); - final int lastPageNumber = (int) (Math.ceil(countResults / pageSize)); - - final Query selectQuery = session.createQuery("From Foo"); - selectQuery.setFirstResult((lastPageNumber - 1) * pageSize); - selectQuery.setMaxResults(pageSize); - final List lastPage = selectQuery.list(); - - assertThat(lastPage, hasSize(lessThan(pageSize + 1))); - } - - // testing - scrollable - - @Test - public final void givenUsingTheScrollableApi_whenRetrievingPaginatedData_thenCorrect() { - final int pageSize = 10; - final String hql = "FROM Foo f order by f.name"; - final Query query = session.createQuery(hql); - - final ScrollableResults resultScroll = query.scroll(ScrollMode.FORWARD_ONLY); - - // resultScroll.last(); - // final int totalResults = resultScroll.getRowNumber() + 1; - - resultScroll.first(); - resultScroll.scroll(0); - final List fooPage = Lists.newArrayList(); - int i = 0; - while (pageSize > i++) { - fooPage.add((Foo) resultScroll.get(0)); - if (!resultScroll.next()) { - break; - } - } - - assertThat(fooPage, hasSize(lessThan(10 + 1))); - } - - @SuppressWarnings("unchecked") - @Test - public final void givenUsingTheCriteriaApi_whenRetrievingFirstPage_thenCorrect() { - final int pageSize = 10; - - final Criteria criteria = session.createCriteria(Foo.class); - criteria.setFirstResult(0); - criteria.setMaxResults(pageSize); - final List firstPage = criteria.list(); - - assertThat(firstPage, hasSize(pageSize)); - } - - @SuppressWarnings("unchecked") - @Test - public final void givenUsingTheCriteriaApi_whenRetrievingPaginatedData_thenCorrect() { - final Criteria criteriaCount = session.createCriteria(Foo.class); - criteriaCount.setProjection(Projections.rowCount()); - final Long count = (Long) criteriaCount.uniqueResult(); - - int pageNumber = 1; - final int pageSize = 10; - final List fooList = Lists.newArrayList(); - - final Criteria criteria = session.createCriteria(Foo.class); - int totalEntities = 0; - while (totalEntities < count.intValue()) { - criteria.setFirstResult((pageNumber - 1) * pageSize); - criteria.setMaxResults(pageSize); - fooList.addAll(criteria.list()); - totalEntities = fooList.size(); - pageNumber++; - } - } - -} diff --git a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/hibernate/FooSortingPersistenceIntegrationTest.java b/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/hibernate/FooSortingPersistenceIntegrationTest.java deleted file mode 100644 index 8173088af0..0000000000 --- a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/hibernate/FooSortingPersistenceIntegrationTest.java +++ /dev/null @@ -1,174 +0,0 @@ -package com.baeldung.persistence.hibernate; - -import static org.junit.Assert.assertNull; - -import java.util.List; -import java.util.Set; - -import org.hibernate.Criteria; -import org.hibernate.NullPrecedence; -import org.hibernate.Query; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.criterion.Order; -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.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; - -import com.baeldung.persistence.model.Bar; -import com.baeldung.persistence.model.Foo; -import com.baeldung.spring.config.PersistenceTestConfig; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { PersistenceTestConfig.class }, loader = AnnotationConfigContextLoader.class) -@SuppressWarnings("unchecked") -public class FooSortingPersistenceIntegrationTest { - - @Autowired - private SessionFactory sessionFactory; - - private Session session; - - @Before - public void before() { - session = sessionFactory.openSession(); - - session.beginTransaction(); - - final FooFixtures fooData = new FooFixtures(sessionFactory); - fooData.createBars(); - } - - @After - public void after() { - session.getTransaction().commit(); - session.close(); - } - - @Test - public final void whenHQlSortingByOneAttribute_thenPrintSortedResults() { - final String hql = "FROM Foo f ORDER BY f.name"; - final Query query = session.createQuery(hql); - final List fooList = query.list(); - for (final Foo foo : fooList) { - System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); - } - } - - @Test - public final void whenHQlSortingByStringNullLast_thenLastNull() { - final String hql = "FROM Foo f ORDER BY f.name NULLS LAST"; - final Query query = session.createQuery(hql); - final List fooList = query.list(); - - assertNull(fooList.get(fooList.toArray().length - 1).getName()); - for (final Foo foo : fooList) { - System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); - } - } - - @Test - public final void whenSortingByStringNullsFirst_thenReturnNullsFirst() { - final String hql = "FROM Foo f ORDER BY f.name NULLS FIRST"; - final Query query = session.createQuery(hql); - final List fooList = query.list(); - assertNull(fooList.get(0).getName()); - for (final Foo foo : fooList) { - System.out.println("Name:" + foo.getName()); - - } - } - - @Test - public final void whenHQlSortingByOneAttribute_andOrderDirection_thenPrintSortedResults() { - final String hql = "FROM Foo f ORDER BY f.name ASC"; - final Query query = session.createQuery(hql); - final List fooList = query.list(); - for (final Foo foo : fooList) { - System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); - } - } - - @Test - public final void whenHQlSortingByMultipleAttributes_thenSortedResults() { - final String hql = "FROM Foo f ORDER BY f.name, f.id"; - final Query query = session.createQuery(hql); - final List fooList = query.list(); - for (final Foo foo : fooList) { - System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); - } - } - - @Test - public final void whenHQlSortingByMultipleAttributes_andOrderDirection_thenPrintSortedResults() { - final String hql = "FROM Foo f ORDER BY f.name DESC, f.id ASC"; - final Query query = session.createQuery(hql); - final List fooList = query.list(); - for (final Foo foo : fooList) { - System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); - } - } - - @Test - public final void whenHQLCriteriaSortingByOneAttr_thenPrintSortedResults() { - final Criteria criteria = session.createCriteria(Foo.class, "FOO"); - criteria.addOrder(Order.asc("id")); - final List fooList = criteria.list(); - for (final Foo foo : fooList) { - System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); - } - } - - @Test - public final void whenHQLCriteriaSortingByMultipAttr_thenSortedResults() { - final Criteria criteria = session.createCriteria(Foo.class, "FOO"); - criteria.addOrder(Order.asc("name")); - criteria.addOrder(Order.asc("id")); - final List fooList = criteria.list(); - for (final Foo foo : fooList) { - System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); - } - } - - @Test - public final void whenCriteriaSortingStringNullsLastAsc_thenNullsLast() { - final Criteria criteria = session.createCriteria(Foo.class, "FOO"); - criteria.addOrder(Order.asc("name").nulls(NullPrecedence.LAST)); - final List fooList = criteria.list(); - assertNull(fooList.get(fooList.toArray().length - 1).getName()); - for (final Foo foo : fooList) { - System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); - } - } - - @Test - public final void whenCriteriaSortingStringNullsFirstDesc_thenNullsFirst() { - final Criteria criteria = session.createCriteria(Foo.class, "FOO"); - criteria.addOrder(Order.desc("name").nulls(NullPrecedence.FIRST)); - final List fooList = criteria.list(); - assertNull(fooList.get(0).getName()); - for (final Foo foo : fooList) { - System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); - } - } - - @Test - public final void whenSortingBars_thenBarsWithSortedFoos() { - final String hql = "FROM Bar b ORDER BY b.id"; - final Query query = session.createQuery(hql); - final List barList = query.list(); - for (final Bar bar : barList) { - final Set fooSet = bar.getFooSet(); - System.out.println("Bar Id:" + bar.getId()); - for (final Foo foo : fooSet) { - System.out.println("FooName:" + foo.getName()); - } - } - } - -} diff --git a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/save/SaveMethodsIntegrationTest.java b/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/save/SaveMethodsIntegrationTest.java deleted file mode 100644 index ef83af3a0d..0000000000 --- a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/save/SaveMethodsIntegrationTest.java +++ /dev/null @@ -1,262 +0,0 @@ -package com.baeldung.persistence.save; - -import com.baeldung.persistence.model.Person; -import org.hibernate.HibernateException; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.boot.registry.StandardServiceRegistryBuilder; -import org.hibernate.cfg.Configuration; -import org.hibernate.dialect.HSQLDialect; -import org.hibernate.service.ServiceRegistry; -import org.junit.*; - -import static org.junit.Assert.*; - -/** - * Testing specific implementation details for different methods: - * persist, save, merge, update, saveOrUpdate. - */ -public class SaveMethodsIntegrationTest { - - private static SessionFactory sessionFactory; - - private Session session; - - @BeforeClass - public static void beforeTests() { - Configuration configuration = new Configuration().addAnnotatedClass(Person.class).setProperty("hibernate.dialect", HSQLDialect.class.getName()).setProperty("hibernate.connection.driver_class", org.hsqldb.jdbcDriver.class.getName()) - .setProperty("hibernate.connection.url", "jdbc:hsqldb:mem:test").setProperty("hibernate.connection.username", "sa").setProperty("hibernate.connection.password", "").setProperty("hibernate.hbm2ddl.auto", "update"); - ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).build(); - sessionFactory = configuration.buildSessionFactory(serviceRegistry); - } - - @Before - public void setUp() { - session = sessionFactory.openSession(); - session.beginTransaction(); - } - - @Test - public void whenPersistTransient_thenSavedToDatabaseOnCommit() { - - Person person = new Person(); - person.setName("John"); - session.persist(person); - - session.getTransaction().commit(); - session.close(); - - session = sessionFactory.openSession(); - session.beginTransaction(); - - assertNotNull(session.get(Person.class, person.getId())); - - } - - @Test - public void whenPersistPersistent_thenNothingHappens() { - - Person person = new Person(); - person.setName("John"); - - session.persist(person); - Long id1 = person.getId(); - - session.persist(person); - Long id2 = person.getId(); - - assertEquals(id1, id2); - } - - @Test(expected = HibernateException.class) - public void whenPersistDetached_thenThrowsException() { - - Person person = new Person(); - person.setName("John"); - session.persist(person); - session.evict(person); - - session.persist(person); - - } - - @Test - public void whenSaveTransient_thenIdGeneratedImmediately() { - - Person person = new Person(); - person.setName("John"); - - assertNull(person.getId()); - - Long id = (Long) session.save(person); - - assertNotNull(id); - - session.getTransaction().commit(); - session.close(); - - assertEquals(id, person.getId()); - - session = sessionFactory.openSession(); - session.beginTransaction(); - - assertNotNull(session.get(Person.class, person.getId())); - - } - - @Test - public void whenSavePersistent_thenNothingHappens() { - - Person person = new Person(); - person.setName("John"); - Long id1 = (Long) session.save(person); - Long id2 = (Long) session.save(person); - assertEquals(id1, id2); - - } - - @Test - public void whenSaveDetached_thenNewInstancePersisted() { - - Person person = new Person(); - person.setName("John"); - Long id1 = (Long) session.save(person); - session.evict(person); - - Long id2 = (Long) session.save(person); - assertNotEquals(id1, id2); - - } - - @Test - public void whenMergeDetached_thenEntityUpdatedFromDatabase() { - - Person person = new Person(); - person.setName("John"); - session.save(person); - session.evict(person); - - person.setName("Mary"); - Person mergedPerson = (Person) session.merge(person); - - assertNotSame(person, mergedPerson); - assertEquals("Mary", mergedPerson.getName()); - - } - - @Test - public void whenMergeTransient_thenNewEntitySavedToDatabase() { - - Person person = new Person(); - person.setName("John"); - Person mergedPerson = (Person) session.merge(person); - - session.getTransaction().commit(); - session.beginTransaction(); - - assertNull(person.getId()); - assertNotNull(mergedPerson.getId()); - - } - - @Test - public void whenMergePersistent_thenReturnsSameObject() { - - Person person = new Person(); - person.setName("John"); - session.save(person); - - Person mergedPerson = (Person) session.merge(person); - - assertSame(person, mergedPerson); - - } - - @Test - public void whenUpdateDetached_thenEntityUpdatedFromDatabase() { - - Person person = new Person(); - person.setName("John"); - session.save(person); - session.evict(person); - - person.setName("Mary"); - session.update(person); - assertEquals("Mary", person.getName()); - - } - - @Test(expected = HibernateException.class) - public void whenUpdateTransient_thenThrowsException() { - - Person person = new Person(); - person.setName("John"); - session.update(person); - - } - - @Test - public void whenUpdatePersistent_thenNothingHappens() { - - Person person = new Person(); - person.setName("John"); - session.save(person); - - session.update(person); - - } - - @Test - public void whenSaveOrUpdateDetached_thenEntityUpdatedFromDatabase() { - - Person person = new Person(); - person.setName("John"); - session.save(person); - session.evict(person); - - person.setName("Mary"); - session.saveOrUpdate(person); - assertEquals("Mary", person.getName()); - - } - - @Test - public void whenSaveOrUpdateTransient_thenSavedToDatabaseOnCommit() { - - Person person = new Person(); - person.setName("John"); - session.saveOrUpdate(person); - - session.getTransaction().commit(); - session.close(); - - session = sessionFactory.openSession(); - session.beginTransaction(); - - assertNotNull(session.get(Person.class, person.getId())); - - } - - @Test - public void whenSaveOrUpdatePersistent_thenNothingHappens() { - - Person person = new Person(); - person.setName("John"); - session.save(person); - - session.saveOrUpdate(person); - - } - - @After - public void tearDown() { - session.getTransaction().commit(); - session.close(); - } - - @AfterClass - public static void afterTests() { - sessionFactory.close(); - } - -} diff --git a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/service/FooServiceBasicPersistenceIntegrationTest.java b/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/service/FooServiceBasicPersistenceIntegrationTest.java deleted file mode 100644 index 146f8e9622..0000000000 --- a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/service/FooServiceBasicPersistenceIntegrationTest.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.baeldung.persistence.service; - -import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; - -import org.hibernate.Session; -import org.hibernate.SessionFactory; -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.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; - -import com.baeldung.persistence.model.Foo; -import com.baeldung.spring.config.PersistenceTestConfig; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { PersistenceTestConfig.class }, loader = AnnotationConfigContextLoader.class) -public class FooServiceBasicPersistenceIntegrationTest { - - @Autowired - private SessionFactory sessionFactory; - - @Autowired - private IFooService fooService; - - private Session session; - - // tests - - @Before - public final void before() { - session = sessionFactory.openSession(); - } - - @After - public final void after() { - session.close(); - } - - // tests - - @Test - public final void whenContextIsBootstrapped_thenNoExceptions() { - // - } - - @Test - public final void whenEntityIsCreated_thenNoExceptions() { - fooService.create(new Foo(randomAlphabetic(6))); - } - -} diff --git a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java b/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java deleted file mode 100644 index 6d426849a6..0000000000 --- a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.baeldung.persistence.service; - -import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; - -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.dao.DataAccessException; -import org.springframework.dao.DataIntegrityViolationException; -import org.springframework.dao.InvalidDataAccessApiUsageException; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; - -import com.baeldung.persistence.model.Foo; -import com.baeldung.spring.config.PersistenceTestConfig; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { PersistenceTestConfig.class }, loader = AnnotationConfigContextLoader.class) -public class FooServicePersistenceIntegrationTest { - - @Autowired - @Qualifier("fooHibernateService") - private IFooService service; - - // tests - - @Test - public final void whenContextIsBootstrapped_thenNoExceptions() { - // - } - - @Test - public final void whenEntityIsCreated_thenNoExceptions() { - service.create(new Foo(randomAlphabetic(6))); - } - - @Test(expected = DataIntegrityViolationException.class) - @Ignore("work in progress") - public final void whenInvalidEntityIsCreated_thenDataException() { - service.create(new Foo()); - } - - @Test(expected = DataIntegrityViolationException.class) - public final void whenEntityWithLongNameIsCreated_thenDataException() { - service.create(new Foo(randomAlphabetic(2048))); - } - - @Test(expected = InvalidDataAccessApiUsageException.class) - @Ignore("Right now, persist has saveOrUpdate semantics, so this will no longer fail") - public final void whenSameEntityIsCreatedTwice_thenDataException() { - final Foo entity = new Foo(randomAlphabetic(8)); - service.create(entity); - service.create(entity); - } - - @Test(expected = DataAccessException.class) - public final void temp_whenInvalidEntityIsCreated_thenDataException() { - service.create(new Foo(randomAlphabetic(2048))); - } - -} diff --git a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/service/FooStoredProceduresLiveTest.java b/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/service/FooStoredProceduresLiveTest.java deleted file mode 100644 index d9353f1ad1..0000000000 --- a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/service/FooStoredProceduresLiveTest.java +++ /dev/null @@ -1,121 +0,0 @@ -package com.baeldung.persistence.service; - -import java.util.List; - -import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; -import static org.junit.Assert.assertEquals; - -import org.hibernate.Query; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.exception.SQLGrammarException; -import org.junit.After; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; - -import com.baeldung.persistence.model.Foo; -import com.baeldung.spring.PersistenceConfig; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) -public class FooStoredProceduresLiveTest { - - private static final Logger LOGGER = LoggerFactory.getLogger(FooStoredProceduresLiveTest.class); - - @Autowired - private SessionFactory sessionFactory; - - @Autowired - private IFooService fooService; - - private Session session; - - @Before - public final void before() { - session = sessionFactory.openSession(); - Assume.assumeTrue(getAllFoosExists()); - Assume.assumeTrue(getFoosByNameExists()); - } - - private boolean getFoosByNameExists() { - try { - Query sqlQuery = session.createSQLQuery("CALL GetAllFoos()").addEntity(Foo.class); - sqlQuery.list(); - return true; - } catch (SQLGrammarException e) { - LOGGER.error("WARNING : GetFoosByName() Procedure is may be missing ", e); - return false; - } - } - - private boolean getAllFoosExists() { - try { - Query sqlQuery = session.createSQLQuery("CALL GetAllFoos()").addEntity(Foo.class); - sqlQuery.list(); - return true; - } catch (SQLGrammarException e) { - LOGGER.error("WARNING : GetAllFoos() Procedure is may be missing ", e); - return false; - } - } - - @After - public final void after() { - session.close(); - } - - @Test - public final void getAllFoosUsingStoredProcedures() { - - fooService.create(new Foo(randomAlphabetic(6))); - - // Stored procedure getAllFoos using createSQLQuery - Query sqlQuery = session.createSQLQuery("CALL GetAllFoos()").addEntity(Foo.class); - @SuppressWarnings("unchecked") - List allFoos = sqlQuery.list(); - for (Foo foo : allFoos) { - LOGGER.info("getAllFoos() SQL Query result : {}", foo.getName()); - } - assertEquals(allFoos.size(), fooService.findAll().size()); - - // Stored procedure getAllFoos using a Named Query - Query namedQuery = session.getNamedQuery("callGetAllFoos"); - @SuppressWarnings("unchecked") - List allFoos2 = namedQuery.list(); - for (Foo foo : allFoos2) { - LOGGER.info("getAllFoos() NamedQuery result : {}", foo.getName()); - } - assertEquals(allFoos2.size(), fooService.findAll().size()); - } - - @Test - public final void getFoosByNameUsingStoredProcedures() { - - fooService.create(new Foo("NewFooName")); - - // Stored procedure getFoosByName using createSQLQuery() - Query sqlQuery = session.createSQLQuery("CALL GetFoosByName(:fooName)").addEntity(Foo.class).setParameter("fooName", "NewFooName"); - @SuppressWarnings("unchecked") - List allFoosByName = sqlQuery.list(); - for (Foo foo : allFoosByName) { - LOGGER.info("getFoosByName() using SQL Query : found => {}", foo.toString()); - } - - // Stored procedure getFoosByName using getNamedQuery() - Query namedQuery = session.getNamedQuery("callGetFoosByName").setParameter("fooName", "NewFooName"); - @SuppressWarnings("unchecked") - List allFoosByName2 = namedQuery.list(); - for (Foo foo : allFoosByName2) { - LOGGER.info("getFoosByName() using Native Query : found => {}", foo.toString()); - } - - } -} diff --git a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/service/ParentServicePersistenceIntegrationTest.java b/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/service/ParentServicePersistenceIntegrationTest.java deleted file mode 100644 index 5a73e39ca2..0000000000 --- a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/persistence/service/ParentServicePersistenceIntegrationTest.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.baeldung.persistence.service; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.dao.DataIntegrityViolationException; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; - -import com.baeldung.persistence.model.Child; -import com.baeldung.persistence.model.Parent; -import com.baeldung.spring.config.PersistenceTestConfig; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { PersistenceTestConfig.class }, loader = AnnotationConfigContextLoader.class) -public class ParentServicePersistenceIntegrationTest { - - @Autowired - private IParentService service; - - @Autowired - private IChildService childService; - - // tests - - @Test - public final void whenContextIsBootstrapped_thenNoExceptions() { - // - } - - @Test - public final void whenOneToOneEntitiesAreCreated_thenNoExceptions() { - final Child childEntity = new Child(); - childService.create(childEntity); - - final Parent parentEntity = new Parent(childEntity); - service.create(parentEntity); - - System.out.println("Child = " + childService.findOne(childEntity.getId())); - System.out.println("Child - parent = " + childService.findOne(childEntity.getId()).getParent()); - - System.out.println("Parent = " + service.findOne(parentEntity.getId())); - System.out.println("Parent - child = " + service.findOne(parentEntity.getId()).getChild()); - } - - @Test(expected = DataIntegrityViolationException.class) - public final void whenChildIsDeletedWhileParentStillHasForeignKeyToIt_thenDataException() { - final Child childEntity = new Child(); - childService.create(childEntity); - - final Parent parentEntity = new Parent(childEntity); - service.create(parentEntity); - - childService.delete(childEntity); - } - - @Test - public final void whenChildIsDeletedAfterTheParent_thenNoExceptions() { - final Child childEntity = new Child(); - childService.create(childEntity); - - final Parent parentEntity = new Parent(childEntity); - service.create(parentEntity); - - service.delete(parentEntity); - childService.delete(childEntity); - } - -} diff --git a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/spring/config/PersistenceTestConfig.java b/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/spring/config/PersistenceTestConfig.java deleted file mode 100644 index 9bf55c902a..0000000000 --- a/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/spring/config/PersistenceTestConfig.java +++ /dev/null @@ -1,179 +0,0 @@ -package com.baeldung.spring.config; - -import java.util.Properties; - -import javax.sql.DataSource; - -import org.apache.tomcat.dbcp.dbcp2.BasicDataSource; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; -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.orm.hibernate4.HibernateTransactionManager; -import org.springframework.orm.hibernate4.LocalSessionFactoryBean; -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 com.baeldung.persistence.dao.IBarAuditableDao; -import com.baeldung.persistence.dao.IBarDao; -import com.baeldung.persistence.dao.IFooAuditableDao; -import com.baeldung.persistence.dao.IFooDao; -import com.baeldung.persistence.dao.impl.BarAuditableDao; -import com.baeldung.persistence.dao.impl.BarDao; -import com.baeldung.persistence.dao.impl.BarJpaDao; -import com.baeldung.persistence.dao.impl.FooAuditableDao; -import com.baeldung.persistence.dao.impl.FooDao; -import com.baeldung.persistence.service.IBarAuditableService; -import com.baeldung.persistence.service.IBarService; -import com.baeldung.persistence.service.IFooAuditableService; -import com.baeldung.persistence.service.IFooService; -import com.baeldung.persistence.service.impl.BarAuditableService; -import com.baeldung.persistence.service.impl.BarJpaService; -import com.baeldung.persistence.service.impl.BarSpringDataJpaService; -import com.baeldung.persistence.service.impl.FooAuditableService; -import com.baeldung.persistence.service.impl.FooService; -import com.google.common.base.Preconditions; - -@Configuration -@EnableTransactionManagement -@EnableJpaRepositories(basePackages = { "com.baeldung.persistence" }, transactionManagerRef = "jpaTransactionManager") -@EnableJpaAuditing -@PropertySource({ "classpath:persistence-h2.properties" }) -@ComponentScan({ "com.baeldung.persistence" }) -public class PersistenceTestConfig { - - @Autowired - private Environment env; - - public PersistenceTestConfig() { - super(); - } - - @Bean - public LocalSessionFactoryBean sessionFactory() { - final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); - sessionFactory.setDataSource(restDataSource()); - sessionFactory.setPackagesToScan(new String[] { "com.baeldung.persistence.model" }); - sessionFactory.setHibernateProperties(hibernateProperties()); - - return sessionFactory; - } - - @Bean - public LocalContainerEntityManagerFactoryBean entityManagerFactory() { - final LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean(); - emf.setDataSource(restDataSource()); - emf.setPackagesToScan(new String[] { "com.baeldung.persistence.model" }); - - final JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); - emf.setJpaVendorAdapter(vendorAdapter); - emf.setJpaProperties(hibernateProperties()); - - return emf; - } - - @Bean - public DataSource restDataSource() { - final BasicDataSource dataSource = new BasicDataSource(); - 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 hibernateTransactionManager() { - final HibernateTransactionManager transactionManager = new HibernateTransactionManager(); - transactionManager.setSessionFactory(sessionFactory().getObject()); - return transactionManager; - } - - @Bean - public PlatformTransactionManager jpaTransactionManager() { - final JpaTransactionManager transactionManager = new JpaTransactionManager(); - transactionManager.setEntityManagerFactory(entityManagerFactory().getObject()); - return transactionManager; - } - - @Bean - public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { - return new PersistenceExceptionTranslationPostProcessor(); - } - - @Bean - public IBarService barJpaService() { - return new BarJpaService(); - } - - @Bean - public IBarService barSpringDataJpaService() { - return new BarSpringDataJpaService(); - } - - @Bean - public IFooService fooHibernateService() { - return new FooService(); - } - - @Bean - public IBarAuditableService barHibernateAuditableService() { - return new BarAuditableService(); - } - - @Bean - public IFooAuditableService fooHibernateAuditableService() { - return new FooAuditableService(); - } - - @Bean - public IBarDao barJpaDao() { - return new BarJpaDao(); - } - - @Bean - public IBarDao barHibernateDao() { - return new BarDao(); - } - - @Bean - public IBarAuditableDao barHibernateAuditableDao() { - return new BarAuditableDao(); - } - - @Bean - public IFooDao fooHibernateDao() { - return new FooDao(); - } - - @Bean - public IFooAuditableDao fooHibernateAuditableDao() { - return new FooAuditableDao(); - } - - 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-hibernate4/src/test/resources/.gitignore b/persistence-modules/spring-hibernate4/src/test/resources/.gitignore deleted file mode 100644 index 83c05e60c8..0000000000 --- a/persistence-modules/spring-hibernate4/src/test/resources/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -*.class - -#folders# -/target -/neoDb* -/data -/src/main/webapp/WEB-INF/classes -*/META-INF/* - -# Packaged files # -*.jar -*.war -*.ear \ No newline at end of file diff --git a/persistence-modules/spring-hibernate4/src/test/resources/fetching.cfg.xml b/persistence-modules/spring-hibernate4/src/test/resources/fetching.cfg.xml deleted file mode 100644 index 55a3aeb51c..0000000000 --- a/persistence-modules/spring-hibernate4/src/test/resources/fetching.cfg.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - org.h2.Driver - jdbc:h2:mem:testdb - sa - - org.hibernate.dialect.H2Dialect - update - true - - - - - \ No newline at end of file diff --git a/persistence-modules/spring-hibernate4/src/test/resources/fetchingLazy.cfg.xml b/persistence-modules/spring-hibernate4/src/test/resources/fetchingLazy.cfg.xml deleted file mode 100644 index 8fcf578660..0000000000 --- a/persistence-modules/spring-hibernate4/src/test/resources/fetchingLazy.cfg.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - org.h2.Driver - jdbc:h2:mem:testdb - sa - - org.hibernate.dialect.H2Dialect - update - true - - - - - \ No newline at end of file diff --git a/persistence-modules/spring-hibernate4/src/test/resources/persistence-h2.properties b/persistence-modules/spring-hibernate4/src/test/resources/persistence-h2.properties deleted file mode 100644 index 911619193b..0000000000 --- a/persistence-modules/spring-hibernate4/src/test/resources/persistence-h2.properties +++ /dev/null @@ -1,13 +0,0 @@ -# jdbc.X -jdbc.driverClassName=org.h2.Driver -jdbc.url=jdbc:h2:mem:test -jdbc.user=sa -jdbc.pass= - -# hibernate.X -hibernate.dialect=org.hibernate.dialect.H2Dialect -hibernate.show_sql=false -hibernate.hbm2ddl.auto=create-drop - -# envers.X -envers.audit_table_suffix=_audit_log From 0ba96c9c43465a133934b244313e7e36433233d9 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Mon, 28 Sep 2020 23:12:26 +0530 Subject: [PATCH 231/263] JAVA-2432: Moved 1 article to hibernate-enterprise --- .../hibernate-enterprise/README.md | 3 ++- .../hibernate-enterprise/pom.xml | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/persistence-modules/hibernate-enterprise/README.md b/persistence-modules/hibernate-enterprise/README.md index c5606d0970..1a86c32afa 100644 --- a/persistence-modules/hibernate-enterprise/README.md +++ b/persistence-modules/hibernate-enterprise/README.md @@ -9,4 +9,5 @@ This module contains articles about enterprise concerns such as Multitenancy, Er - [Hibernate Aggregate Functions](https://www.baeldung.com/hibernate-aggregate-functions) - [Common Hibernate Exceptions](https://www.baeldung.com/hibernate-exceptions) - [Hibernate Error “Not all named parameters have been set”](https://www.baeldung.com/hibernate-error-named-parameters-not-set) -- [Various Logging Levels in Hibernate](https://www.baeldung.com/hibernate-logging-levels) \ No newline at end of file +- [Various Logging Levels in Hibernate](https://www.baeldung.com/hibernate-logging-levels) +- [Hibernate: save, persist, update, merge, saveOrUpdate](https://www.baeldung.com/hibernate-save-persist-update-merge-saveorupdate) \ No newline at end of file diff --git a/persistence-modules/hibernate-enterprise/pom.xml b/persistence-modules/hibernate-enterprise/pom.xml index ae58e409c4..c088cc1eca 100644 --- a/persistence-modules/hibernate-enterprise/pom.xml +++ b/persistence-modules/hibernate-enterprise/pom.xml @@ -61,13 +61,25 @@ ${byte-buddy.version} test + + org.hsqldb + hsqldb + ${hsqldb.version} + test + - geodb-repo - GeoDB repository - http://repo.boundlessgeo.com/main/ + osgeo + OSGeo Release Repository + https://repo.osgeo.org/repository/release/ + + false + + + true + @@ -77,6 +89,7 @@ 2.2.3 3.8.0 0.9 + 2.3.4 From d77c22b05f944119f7bde91af4b35deb9081f979 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Mon, 28 Sep 2020 23:13:14 +0530 Subject: [PATCH 232/263] JAVA-2432: Moved 1 article to hibernate-enterprise --- .../baeldung/persistence/model/Person.java | 31 ++ .../save/SaveMethodsIntegrationTest.java | 291 ++++++++++++++++++ 2 files changed, 322 insertions(+) create mode 100644 persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/persistence/model/Person.java create mode 100644 persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/persistence/save/SaveMethodsIntegrationTest.java diff --git a/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/persistence/model/Person.java b/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/persistence/model/Person.java new file mode 100644 index 0000000000..6a95a7acf5 --- /dev/null +++ b/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/persistence/model/Person.java @@ -0,0 +1,31 @@ +package com.baeldung.persistence.model; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +@Entity +public class Person { + + @Id + @GeneratedValue + private Long id; + + private String name; + + 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; + } +} diff --git a/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/persistence/save/SaveMethodsIntegrationTest.java b/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/persistence/save/SaveMethodsIntegrationTest.java new file mode 100644 index 0000000000..8c571428b4 --- /dev/null +++ b/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/persistence/save/SaveMethodsIntegrationTest.java @@ -0,0 +1,291 @@ +package com.baeldung.persistence.save; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; + +import javax.persistence.PersistenceException; + +import org.hibernate.HibernateException; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; +import org.hibernate.cfg.Configuration; +import org.hibernate.dialect.HSQLDialect; +import org.hibernate.service.ServiceRegistry; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.baeldung.persistence.model.Person; + +/** + * Testing specific implementation details for different methods: + * persist, save, merge, update, saveOrUpdate. + */ +public class SaveMethodsIntegrationTest { + + private static SessionFactory sessionFactory; + + private Session session; + private boolean doNotCommit = false; + + @BeforeClass + public static void beforeTests() { + Configuration configuration = new Configuration().addAnnotatedClass(Person.class) + .setProperty("hibernate.dialect", HSQLDialect.class.getName()) + .setProperty("hibernate.connection.driver_class", org.hsqldb.jdbcDriver.class.getName()) + .setProperty("hibernate.connection.url", "jdbc:hsqldb:mem:test") + .setProperty("hibernate.connection.username", "sa") + .setProperty("hibernate.connection.password", "") + .setProperty("hibernate.hbm2ddl.auto", "update"); + ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()) + .build(); + sessionFactory = configuration.buildSessionFactory(serviceRegistry); + } + + @Before + public void setUp() { + session = sessionFactory.openSession(); + session.beginTransaction(); + doNotCommit = false; + } + + @Test + public void whenPersistTransient_thenSavedToDatabaseOnCommit() { + + Person person = new Person(); + person.setName("John"); + session.persist(person); + + session.getTransaction() + .commit(); + session.close(); + + session = sessionFactory.openSession(); + session.beginTransaction(); + + assertNotNull(session.get(Person.class, person.getId())); + + } + + @Test + public void whenPersistPersistent_thenNothingHappens() { + + Person person = new Person(); + person.setName("John"); + + session.persist(person); + Long id1 = person.getId(); + + session.persist(person); + Long id2 = person.getId(); + + assertEquals(id1, id2); + } + + @Test(expected = PersistenceException.class) + public void whenPersistDetached_thenThrowsException() { + + doNotCommit = true; + + Person person = new Person(); + person.setName("John"); + session.persist(person); + session.evict(person); + + session.persist(person); + } + + @Test + public void whenMergeDetached_thenEntityUpdatedFromDatabase() { + + Person person = new Person(); + person.setName("John"); + session.save(person); + session.flush(); + session.evict(person); + + person.setName("Mary"); + Person mergedPerson = (Person) session.merge(person); + + assertNotSame(person, mergedPerson); + assertEquals("Mary", mergedPerson.getName()); + + } + + @Test + public void whenSaveTransient_thenIdGeneratedImmediately() { + + Person person = new Person(); + person.setName("John"); + + assertNull(person.getId()); + + Long id = (Long) session.save(person); + + assertNotNull(id); + + session.getTransaction() + .commit(); + session.close(); + + assertEquals(id, person.getId()); + + session = sessionFactory.openSession(); + session.beginTransaction(); + + assertNotNull(session.get(Person.class, person.getId())); + + } + + @Test + public void whenSavePersistent_thenNothingHappens() { + + Person person = new Person(); + person.setName("John"); + Long id1 = (Long) session.save(person); + Long id2 = (Long) session.save(person); + assertEquals(id1, id2); + + } + + @Test + public void whenSaveDetached_thenNewInstancePersisted() { + + Person person = new Person(); + person.setName("John"); + Long id1 = (Long) session.save(person); + session.evict(person); + + Long id2 = (Long) session.save(person); + assertNotEquals(id1, id2); + + } + + @Test + public void whenMergeTransient_thenNewEntitySavedToDatabase() { + + Person person = new Person(); + person.setName("John"); + Person mergedPerson = (Person) session.merge(person); + + session.getTransaction() + .commit(); + session.beginTransaction(); + + assertNull(person.getId()); + assertNotNull(mergedPerson.getId()); + + } + + @Test + public void whenMergePersistent_thenReturnsSameObject() { + + Person person = new Person(); + person.setName("John"); + session.save(person); + + Person mergedPerson = (Person) session.merge(person); + + assertSame(person, mergedPerson); + + } + + @Test + public void whenUpdateDetached_thenEntityUpdatedFromDatabase() { + + Person person = new Person(); + person.setName("John"); + session.save(person); + session.evict(person); + + person.setName("Mary"); + session.update(person); + assertEquals("Mary", person.getName()); + + } + + @Test(expected = HibernateException.class) + public void whenUpdateTransient_thenThrowsException() { + + Person person = new Person(); + person.setName("John"); + session.update(person); + + } + + @Test + public void whenUpdatePersistent_thenNothingHappens() { + + Person person = new Person(); + person.setName("John"); + session.save(person); + + session.update(person); + + } + + @Test + public void whenSaveOrUpdateDetached_thenEntityUpdatedFromDatabase() { + + Person person = new Person(); + person.setName("John"); + session.save(person); + session.evict(person); + + person.setName("Mary"); + session.saveOrUpdate(person); + assertEquals("Mary", person.getName()); + + } + + @Test + public void whenSaveOrUpdateTransient_thenSavedToDatabaseOnCommit() { + + Person person = new Person(); + person.setName("John"); + session.saveOrUpdate(person); + + session.getTransaction() + .commit(); + session.close(); + + session = sessionFactory.openSession(); + session.beginTransaction(); + + assertNotNull(session.get(Person.class, person.getId())); + + } + + @Test + public void whenSaveOrUpdatePersistent_thenNothingHappens() { + + Person person = new Person(); + person.setName("John"); + session.save(person); + + session.saveOrUpdate(person); + + } + + @After + public void tearDown() { + if (!doNotCommit) { + session.getTransaction() + .commit(); + } + session.close(); + } + + @AfterClass + public static void afterTests() { + sessionFactory.close(); + } + +} From 7de65d1211d54e5b15fdd6ee4c432e04b1c74e2a Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Mon, 28 Sep 2020 23:13:49 +0530 Subject: [PATCH 233/263] JAVA-2432: removed unused module from parent pom --- persistence-modules/pom.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/persistence-modules/pom.xml b/persistence-modules/pom.xml index def2deb941..0e9c04f55d 100644 --- a/persistence-modules/pom.xml +++ b/persistence-modules/pom.xml @@ -80,8 +80,7 @@ spring-data-redis spring-data-solr spring-hibernate-3 - spring-hibernate-5 - spring-hibernate4 + spring-hibernate-5 spring-jpa spring-jpa-2 spring-jdbc From 2dd77a259db8eaa15f1a61b2752fee17d85611d4 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Mon, 28 Sep 2020 23:17:31 +0530 Subject: [PATCH 234/263] JAVA-2432: Moved 5 articles to spring-data-jpa-query-2 --- .../spring-data-jpa-query-2/README.md | 6 + .../spring-data-jpa-query-2/pom.xml | 58 +++++ .../baeldung/config/PersistenceConfig.java | 186 ++++++++++++++ .../baeldung/config/PersistenceXmlConfig.java | 18 ++ .../hibernate/audit/AuditorAwareImpl.java | 18 ++ .../hibernate/fetching/model/OrderDetail.java | 58 +++++ .../hibernate/fetching/model/UserEager.java | 71 +++++ .../hibernate/fetching/model/UserLazy.java | 71 +++++ .../fetching/util/HibernateUtil.java | 29 +++ .../fetching/view/FetchingAppView.java | 68 +++++ .../persistence/dao/BookRepository.java | 9 - .../persistence/dao/BookRepositoryCustom.java | 11 - .../persistence/dao/BookRepositoryImpl.java | 44 ---- .../baeldung/persistence/dao/BookService.java | 25 -- .../persistence/dao/BookSpecifications.java | 16 -- .../persistence/dao/IBarAuditableDao.java | 8 + .../persistence/dao/IBarCrudRepository.java | 10 + .../com/baeldung/persistence/dao/IBarDao.java | 8 + .../baeldung/persistence/dao/IChildDao.java | 8 + .../persistence/dao/IFooAuditableDao.java | 8 + .../com/baeldung/persistence/dao/IFooDao.java | 8 + .../baeldung/persistence/dao/IParentDao.java | 8 + .../persistence/dao/common/AbstractDao.java | 14 + .../common/AbstractHibernateAuditableDao.java | 37 +++ .../dao/common/AbstractHibernateDao.java | 59 +++++ .../dao/common/AbstractJpaDao.java | 56 ++++ .../dao/common/GenericHibernateDao.java | 13 + .../dao/common/IAuditOperations.java | 14 + .../persistence/dao/common/IGenericDao.java | 7 + .../persistence/dao/common/IOperations.java | 20 ++ .../persistence/dao/impl/BarAuditableDao.java | 28 ++ .../baeldung/persistence/dao/impl/BarDao.java | 19 ++ .../persistence/dao/impl/BarJpaDao.java | 19 ++ .../persistence/dao/impl/ChildDao.java | 19 ++ .../persistence/dao/impl/FooAuditableDao.java | 17 ++ .../baeldung/persistence/dao/impl/FooDao.java | 19 ++ .../persistence/dao/impl/ParentDao.java | 19 ++ .../com/baeldung/persistence/model/Bar.java | 242 ++++++++++++++++++ .../com/baeldung/persistence/model/Book.java | 36 --- .../com/baeldung/persistence/model/Child.java | 51 ++++ .../com/baeldung/persistence/model/Foo.java | 105 ++++++++ .../baeldung/persistence/model/Parent.java | 60 +++++ .../baeldung/persistence/model/Person.java | 31 +++ .../service/IBarAuditableService.java | 8 + .../persistence/service/IBarService.java | 8 + .../persistence/service/IChildService.java | 8 + .../service/IFooAuditableService.java | 8 + .../persistence/service/IFooService.java | 8 + .../persistence/service/IParentService.java | 8 + .../AbstractHibernateAuditableService.java | 30 +++ .../common/AbstractHibernateService.java | 42 +++ .../service/common/AbstractJpaService.java | 42 +++ .../service/common/AbstractService.java | 42 +++ .../common/AbstractSpringDataJpaService.java | 48 ++++ .../service/impl/BarAuditableService.java | 41 +++ .../service/impl/BarJpaService.java | 30 +++ .../persistence/service/impl/BarService.java | 30 +++ .../service/impl/BarSpringDataJpaService.java | 26 ++ .../service/impl/ChildService.java | 28 ++ .../service/impl/FooAuditableService.java | 41 +++ .../persistence/service/impl/FooService.java | 30 +++ .../service/impl/ParentService.java | 28 ++ .../src/main/resources/fetching.cfg.xml | 20 ++ .../src/main/resources/fetchingLazy.cfg.xml | 17 ++ .../resources/fetching_create_queries.sql | 14 + .../src/main/resources/hibernate5Config.xml | 34 +++ .../resources/hibernate5Configuration.xml | 30 +++ .../src/main/resources/immutable.cfg.xml | 38 +++ .../src/main/resources/insert_statements.sql | 31 +++ .../src/main/resources/logback.xml | 19 ++ .../resources/persistence-mysql.properties | 13 + .../src/main/resources/stored_procedure.sql | 20 ++ .../src/main/resources/webSecurityConfig.xml | 37 +++ .../HibernateFetchingIntegrationTest.java | 42 +++ .../persistence/IntegrationTestSuite.java | 25 ++ .../persistence/audit/AuditTestSuite.java | 14 + .../EnversFooBarAuditIntegrationTest.java | 146 +++++++++++ .../audit/JPABarAuditIntegrationTest.java | 104 ++++++++ .../SpringDataJPABarAuditIntegrationTest.java | 78 ++++++ .../persistence/hibernate/FooFixtures.java | 101 ++++++++ ...oPaginationPersistenceIntegrationTest.java | 185 +++++++++++++ .../FooSortingPersistenceIntegrationTest.java | 174 +++++++++++++ ...erviceBasicPersistenceIntegrationTest.java | 55 ++++ .../FooServicePersistenceIntegrationTest.java | 64 +++++ .../service/FooStoredProceduresLiveTest.java | 121 +++++++++ ...rentServicePersistenceIntegrationTest.java | 70 +++++ .../spring/config/PersistenceTestConfig.java | 179 +++++++++++++ .../ArticleRepositoryIntegrationTest.java | 3 + .../src/test/resources/fetching.cfg.xml | 19 ++ .../src/test/resources/fetchingLazy.cfg.xml | 19 ++ .../test/resources/persistence-h2.properties | 13 + 91 files changed, 3681 insertions(+), 141 deletions(-) create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/config/PersistenceConfig.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/config/PersistenceXmlConfig.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/audit/AuditorAwareImpl.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/fetching/model/OrderDetail.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/fetching/model/UserEager.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/fetching/model/UserLazy.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/fetching/util/HibernateUtil.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/fetching/view/FetchingAppView.java delete mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookRepository.java delete mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookRepositoryCustom.java delete mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookRepositoryImpl.java delete mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookService.java delete mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookSpecifications.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IBarAuditableDao.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IBarCrudRepository.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IBarDao.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IChildDao.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IFooAuditableDao.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IFooDao.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IParentDao.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/AbstractDao.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/AbstractHibernateAuditableDao.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/AbstractHibernateDao.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/AbstractJpaDao.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/GenericHibernateDao.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/IAuditOperations.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/IGenericDao.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/IOperations.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/BarAuditableDao.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/BarDao.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/BarJpaDao.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/ChildDao.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/FooAuditableDao.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/FooDao.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/ParentDao.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Bar.java delete mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Book.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Child.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Foo.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Parent.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Person.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/IBarAuditableService.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/IBarService.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/IChildService.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/IFooAuditableService.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/IFooService.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/IParentService.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/common/AbstractHibernateAuditableService.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/common/AbstractHibernateService.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/common/AbstractJpaService.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/common/AbstractService.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/common/AbstractSpringDataJpaService.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/BarAuditableService.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/BarJpaService.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/BarService.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/BarSpringDataJpaService.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/ChildService.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/FooAuditableService.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/FooService.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/ParentService.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/resources/fetching.cfg.xml create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/resources/fetchingLazy.cfg.xml create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/resources/fetching_create_queries.sql create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/resources/hibernate5Config.xml create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/resources/hibernate5Configuration.xml create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/resources/immutable.cfg.xml create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/resources/insert_statements.sql create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/resources/logback.xml create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/resources/persistence-mysql.properties create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/resources/stored_procedure.sql create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/resources/webSecurityConfig.xml create mode 100644 persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/hibernate/fetching/HibernateFetchingIntegrationTest.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/IntegrationTestSuite.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/audit/AuditTestSuite.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/audit/EnversFooBarAuditIntegrationTest.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/audit/JPABarAuditIntegrationTest.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/audit/SpringDataJPABarAuditIntegrationTest.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/hibernate/FooFixtures.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/hibernate/FooPaginationPersistenceIntegrationTest.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/hibernate/FooSortingPersistenceIntegrationTest.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/service/FooServiceBasicPersistenceIntegrationTest.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/service/FooStoredProceduresLiveTest.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/service/ParentServicePersistenceIntegrationTest.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/config/PersistenceTestConfig.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/test/resources/fetching.cfg.xml create mode 100644 persistence-modules/spring-data-jpa-query-2/src/test/resources/fetchingLazy.cfg.xml create mode 100644 persistence-modules/spring-data-jpa-query-2/src/test/resources/persistence-h2.properties diff --git a/persistence-modules/spring-data-jpa-query-2/README.md b/persistence-modules/spring-data-jpa-query-2/README.md index fdb4ce3db7..bdc8d7cb32 100644 --- a/persistence-modules/spring-data-jpa-query-2/README.md +++ b/persistence-modules/spring-data-jpa-query-2/README.md @@ -6,6 +6,12 @@ This module contains articles about querying data using Spring Data JPA - [Spring Data JPA @Query Annotation](https://www.baeldung.com/spring-data-jpa-query) - [Use Criteria Queries in a Spring Data Application](https://www.baeldung.com/spring-data-criteria-queries) - [Query Entities by Dates and Times with Spring Data JPA](https://www.baeldung.com/spring-data-jpa-query-by-date) +- [Hibernate Pagination](https://www.baeldung.com/hibernate-pagination) +- [Sorting with Hibernate](https://www.baeldung.com/hibernate-sort) +- [Stored Procedures with Hibernate](https://www.baeldung.com/stored-procedures-with-hibernate-tutorial) +- [Eager/Lazy Loading In Hibernate](https://www.baeldung.com/hibernate-lazy-eager-loading) +- [Auditing with JPA, Hibernate, and Spring Data JPA](https://www.baeldung.com/database-auditing-jpa) + - More articles: [[<-- prev]](../spring-data-jpa-query) ### Eclipse Config diff --git a/persistence-modules/spring-data-jpa-query-2/pom.xml b/persistence-modules/spring-data-jpa-query-2/pom.xml index 231640284e..abac7b28da 100644 --- a/persistence-modules/spring-data-jpa-query-2/pom.xml +++ b/persistence-modules/spring-data-jpa-query-2/pom.xml @@ -18,6 +18,10 @@ org.springframework.boot spring-boot-starter-data-jpa + + org.springframework.security + spring-security-core + com.h2database @@ -28,6 +32,55 @@ com.fasterxml.jackson.core jackson-databind + + + org.hibernate + hibernate-envers + + + javax.transaction + jta + ${jta.version} + + + mysql + mysql-connector-java + + + com.google.guava + guava + ${guava.version} + + + org.apache.tomcat + tomcat-dbcp + ${tomcat-dbcp.version} + + + org.hibernate + hibernate-core + ${hibernate.version} + + + org.hibernate + hibernate-envers + ${hibernate.version} + + + org.springframework + spring-test + test + + + org.springframework.security + spring-security-test + test + + + org.hsqldb + hsqldb + test + @@ -35,5 +88,10 @@ 2.22.2 5.6.2 4.13 + 9.0.0.M26 + 1.1 + 21.0 + + 5.2.10.Final \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/config/PersistenceConfig.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/config/PersistenceConfig.java new file mode 100644 index 0000000000..a0d70ed006 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/config/PersistenceConfig.java @@ -0,0 +1,186 @@ +package com.baeldung.config; + +import java.util.Properties; + +import javax.sql.DataSource; + +import org.apache.tomcat.dbcp.dbcp2.BasicDataSource; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.core.env.Environment; +import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; +import org.springframework.data.domain.AuditorAware; +import org.springframework.data.jpa.repository.config.EnableJpaAuditing; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.orm.hibernate5.HibernateTransactionManager; +import org.springframework.orm.hibernate5.LocalSessionFactoryBean; +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 com.baeldung.hibernate.audit.AuditorAwareImpl; +import com.baeldung.persistence.dao.IBarAuditableDao; +import com.baeldung.persistence.dao.IBarDao; +import com.baeldung.persistence.dao.IFooAuditableDao; +import com.baeldung.persistence.dao.IFooDao; +import com.baeldung.persistence.dao.impl.BarAuditableDao; +import com.baeldung.persistence.dao.impl.BarDao; +import com.baeldung.persistence.dao.impl.BarJpaDao; +import com.baeldung.persistence.dao.impl.FooAuditableDao; +import com.baeldung.persistence.dao.impl.FooDao; +import com.baeldung.persistence.service.IBarAuditableService; +import com.baeldung.persistence.service.IBarService; +import com.baeldung.persistence.service.IFooAuditableService; +import com.baeldung.persistence.service.IFooService; +import com.baeldung.persistence.service.impl.BarAuditableService; +import com.baeldung.persistence.service.impl.BarJpaService; +import com.baeldung.persistence.service.impl.BarSpringDataJpaService; +import com.baeldung.persistence.service.impl.FooAuditableService; +import com.baeldung.persistence.service.impl.FooService; +import com.google.common.base.Preconditions; + +@Configuration +@EnableTransactionManagement +@EnableJpaRepositories(basePackages = { "com.baeldung.persistence" }, transactionManagerRef = "jpaTransactionManager", entityManagerFactoryRef = "jpaEntityManager") +@EnableJpaAuditing(auditorAwareRef = "auditorProvider") +@PropertySource({ "classpath:persistence-h2.properties" }) +@ComponentScan({ "com.baeldung.persistence" }) +public class PersistenceConfig { + + @Autowired + private Environment env; + + public PersistenceConfig() { + super(); + } + + @Bean("auditorProvider") + public AuditorAware auditorProvider() { + return new AuditorAwareImpl(); + } + + @Bean + public LocalSessionFactoryBean sessionFactory() { + final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); + sessionFactory.setDataSource(restDataSource()); + sessionFactory.setPackagesToScan(new String[] { "com.baeldung.persistence.model" }); + sessionFactory.setHibernateProperties(hibernateProperties()); + + return sessionFactory; + } + + @Bean("jpaEntityManager") + public LocalContainerEntityManagerFactoryBean entityManagerFactory() { + final LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean(); + emf.setDataSource(restDataSource()); + emf.setPackagesToScan(new String[] { "com.baeldung.persistence.model" }); + + final JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); + emf.setJpaVendorAdapter(vendorAdapter); + emf.setJpaProperties(hibernateProperties()); + + return emf; + } + + @Bean + public DataSource restDataSource() { + final BasicDataSource dataSource = new BasicDataSource(); + 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 hibernateTransactionManager() { + final HibernateTransactionManager transactionManager = new HibernateTransactionManager(); + transactionManager.setSessionFactory(sessionFactory().getObject()); + return transactionManager; + } + + @Bean + public PlatformTransactionManager jpaTransactionManager() { + final JpaTransactionManager transactionManager = new JpaTransactionManager(); + transactionManager.setEntityManagerFactory(entityManagerFactory().getObject()); + return transactionManager; + } + + @Bean + public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { + return new PersistenceExceptionTranslationPostProcessor(); + } + + @Bean + public IBarService barJpaService() { + return new BarJpaService(); + } + + @Bean + public IBarService barSpringDataJpaService() { + return new BarSpringDataJpaService(); + } + + @Bean + public IFooService fooHibernateService() { + return new FooService(); + } + + @Bean + public IBarAuditableService barHibernateAuditableService() { + return new BarAuditableService(); + } + + @Bean + public IFooAuditableService fooHibernateAuditableService() { + return new FooAuditableService(); + } + + @Bean + public IBarDao barJpaDao() { + return new BarJpaDao(); + } + + @Bean + public IBarDao barHibernateDao() { + return new BarDao(); + } + + @Bean + public IBarAuditableDao barHibernateAuditableDao() { + return new BarAuditableDao(); + } + + @Bean + public IFooDao fooHibernateDao() { + return new FooDao(); + } + + @Bean + public IFooAuditableDao fooHibernateAuditableDao() { + return new FooAuditableDao(); + } + + 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-query-2/src/main/java/com/baeldung/config/PersistenceXmlConfig.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/config/PersistenceXmlConfig.java new file mode 100644 index 0000000000..388494b21a --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/config/PersistenceXmlConfig.java @@ -0,0 +1,18 @@ +package com.baeldung.config; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +@Configuration +@EnableTransactionManagement +@ComponentScan({ "com.baeldung.persistence.dao", "com.baeldung.persistence.service" }) +@ImportResource({ "classpath:hibernate4Config.xml" }) +public class PersistenceXmlConfig { + + public PersistenceXmlConfig() { + super(); + } + +} \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/audit/AuditorAwareImpl.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/audit/AuditorAwareImpl.java new file mode 100644 index 0000000000..5dd12e6841 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/audit/AuditorAwareImpl.java @@ -0,0 +1,18 @@ +package com.baeldung.hibernate.audit; + +import java.util.Optional; + +import org.springframework.data.domain.AuditorAware; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; + +public class AuditorAwareImpl implements AuditorAware { + + @Override + public Optional getCurrentAuditor() { + return Optional.ofNullable(SecurityContextHolder.getContext()) + .map(e -> e.getAuthentication()) + .map(Authentication::getName); + } + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/fetching/model/OrderDetail.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/fetching/model/OrderDetail.java new file mode 100644 index 0000000000..f4a9b8a678 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/fetching/model/OrderDetail.java @@ -0,0 +1,58 @@ +package com.baeldung.hibernate.fetching.model; + +import javax.persistence.*; +import java.io.Serializable; +import java.sql.Date; + +@Entity +@Table(name = "USER_ORDER") +public class OrderDetail implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue + @Column(name = "ORDER_ID") + private Long orderId; + + public OrderDetail() { + } + + public OrderDetail(Date orderDate, String orderDesc) { + super(); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((orderId == null) ? 0 : orderId.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; + OrderDetail other = (OrderDetail) obj; + if (orderId == null) { + if (other.orderId != null) + return false; + } else if (!orderId.equals(other.orderId)) + return false; + + return true; + } + + public Long getOrderId() { + return orderId; + } + + public void setOrderId(Long orderId) { + this.orderId = orderId; + } +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/fetching/model/UserEager.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/fetching/model/UserEager.java new file mode 100644 index 0000000000..9fda4c43bb --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/fetching/model/UserEager.java @@ -0,0 +1,71 @@ +package com.baeldung.hibernate.fetching.model; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.HashSet; +import java.util.Set; + +@Entity +@Table(name = "USER") +public class UserEager implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue + @Column(name = "USER_ID") + private Long userId; + + @OneToMany(fetch = FetchType.EAGER) + private Set orderDetail = new HashSet(); + + public UserEager() { + } + + public UserEager(final Long userId) { + super(); + this.userId = userId; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((userId == null) ? 0 : userId.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final UserEager other = (UserEager) obj; + if (userId == null) { + if (other.userId != null) + return false; + } else if (!userId.equals(other.userId)) + return false; + return true; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(final Long userId) { + this.userId = userId; + } + + public Set getOrderDetail() { + return orderDetail; + } + + public void setOrderDetail(Set orderDetail) { + this.orderDetail = orderDetail; + } + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/fetching/model/UserLazy.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/fetching/model/UserLazy.java new file mode 100644 index 0000000000..a78eaa4ac0 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/fetching/model/UserLazy.java @@ -0,0 +1,71 @@ +package com.baeldung.hibernate.fetching.model; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.HashSet; +import java.util.Set; + +@Entity +@Table(name = "USER") +public class UserLazy implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue + @Column(name = "USER_ID") + private Long userId; + + @OneToMany(fetch = FetchType.LAZY) + private Set orderDetail = new HashSet(); + + public UserLazy() { + } + + public UserLazy(final Long userId) { + super(); + this.userId = userId; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((userId == null) ? 0 : userId.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final UserLazy other = (UserLazy) obj; + if (userId == null) { + if (other.userId != null) + return false; + } else if (!userId.equals(other.userId)) + return false; + return true; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(final Long userId) { + this.userId = userId; + } + + public Set getOrderDetail() { + return orderDetail; + } + + public void setOrderDetail(Set orderDetail) { + this.orderDetail = orderDetail; + } + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/fetching/util/HibernateUtil.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/fetching/util/HibernateUtil.java new file mode 100644 index 0000000000..c7be96abb7 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/fetching/util/HibernateUtil.java @@ -0,0 +1,29 @@ +package com.baeldung.hibernate.fetching.util; + +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.cfg.Configuration; + +public class HibernateUtil { + + @SuppressWarnings("deprecation") + public static Session getHibernateSession(String fetchMethod) { + // two config files are there + // one with lazy loading enabled + // another lazy = false + SessionFactory sf; + if ("lazy".equals(fetchMethod)) { + sf = new Configuration().configure("fetchingLazy.cfg.xml").buildSessionFactory(); + } else { + sf = new Configuration().configure("fetching.cfg.xml").buildSessionFactory(); + } + + // fetching.cfg.xml is used for this example + return sf.openSession(); + } + + public static Session getHibernateSession() { + return new Configuration().configure("fetching.cfg.xml").buildSessionFactory().openSession(); + } + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/fetching/view/FetchingAppView.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/fetching/view/FetchingAppView.java new file mode 100644 index 0000000000..35cdd254e3 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/hibernate/fetching/view/FetchingAppView.java @@ -0,0 +1,68 @@ +package com.baeldung.hibernate.fetching.view; + +import com.baeldung.hibernate.fetching.model.OrderDetail; +import com.baeldung.hibernate.fetching.model.UserEager; +import com.baeldung.hibernate.fetching.model.UserLazy; +import com.baeldung.hibernate.fetching.util.HibernateUtil; +import org.hibernate.Session; +import org.hibernate.Transaction; + +import java.util.List; +import java.util.Set; + +public class FetchingAppView { + + public FetchingAppView() { + + } + + // lazily loaded + public Set lazyLoaded() { + final Session sessionLazy = HibernateUtil.getHibernateSession("lazy"); + List users = sessionLazy.createQuery("From UserLazy").list(); + UserLazy userLazyLoaded = users.get(0); + // since data is lazyloaded so data won't be initialized + return (userLazyLoaded.getOrderDetail()); + } + + // eagerly loaded + public Set eagerLoaded() { + final Session sessionEager = HibernateUtil.getHibernateSession(); + // data should be loaded in the following line + // also note the queries generated + List user = sessionEager.createQuery("From UserEager").list(); + UserEager userEagerLoaded = user.get(0); + return userEagerLoaded.getOrderDetail(); + } + + // creates test data + // call this method to create the data in the database + public void createTestData() { + + final Session session = HibernateUtil.getHibernateSession("lazy"); + Transaction tx = session.beginTransaction(); + final UserLazy user1 = new UserLazy(); + final UserLazy user2 = new UserLazy(); + final UserLazy user3 = new UserLazy(); + + session.save(user1); + session.save(user2); + session.save(user3); + + final OrderDetail order1 = new OrderDetail(); + final OrderDetail order2 = new OrderDetail(); + final OrderDetail order3 = new OrderDetail(); + final OrderDetail order4 = new OrderDetail(); + final OrderDetail order5 = new OrderDetail(); + + session.saveOrUpdate(order1); + session.saveOrUpdate(order2); + session.saveOrUpdate(order3); + session.saveOrUpdate(order4); + session.saveOrUpdate(order5); + + tx.commit(); + session.close(); + + } +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookRepository.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookRepository.java deleted file mode 100644 index 48620f4ff1..0000000000 --- a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookRepository.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.baeldung.persistence.dao; - -import com.baeldung.persistence.model.Book; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.JpaSpecificationExecutor; - -public interface BookRepository extends JpaRepository, BookRepositoryCustom, JpaSpecificationExecutor { - -} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookRepositoryCustom.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookRepositoryCustom.java deleted file mode 100644 index eda34542df..0000000000 --- a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookRepositoryCustom.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.baeldung.persistence.dao; - -import com.baeldung.persistence.model.Book; - -import java.util.List; - -public interface BookRepositoryCustom { - - List findBooksByAuthorNameAndTitle(String authorName, String title); - -} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookRepositoryImpl.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookRepositoryImpl.java deleted file mode 100644 index 7f5bedd018..0000000000 --- a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookRepositoryImpl.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.baeldung.persistence.dao; - -import com.baeldung.persistence.model.Book; -import org.springframework.stereotype.Repository; - -import javax.persistence.EntityManager; -import javax.persistence.TypedQuery; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Predicate; -import javax.persistence.criteria.Root; -import java.util.ArrayList; -import java.util.List; - -@Repository -public class BookRepositoryImpl implements BookRepositoryCustom { - - private EntityManager em; - - public BookRepositoryImpl(EntityManager em) { - this.em = em; - } - - @Override - public List findBooksByAuthorNameAndTitle(String authorName, String title) { - CriteriaBuilder cb = em.getCriteriaBuilder(); - CriteriaQuery cq = cb.createQuery(Book.class); - - Root book = cq.from(Book.class); - List predicates = new ArrayList<>(); - - if (authorName != null) { - predicates.add(cb.equal(book.get("author"), authorName)); - } - if (title != null) { - predicates.add(cb.like(book.get("title"), "%" + title + "%")); - } - cq.where(predicates.toArray(new Predicate[0])); - - TypedQuery query = em.createQuery(cq); - return query.getResultList(); - } - -} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookService.java deleted file mode 100644 index 4165cd8eb9..0000000000 --- a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookService.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.baeldung.persistence.dao; - -import com.baeldung.persistence.model.Book; -import org.springframework.stereotype.Service; - -import java.util.List; - -import static com.baeldung.persistence.dao.BookSpecifications.hasAuthor; -import static com.baeldung.persistence.dao.BookSpecifications.titleContains; -import static org.springframework.data.jpa.domain.Specification.where; - -@Service -public class BookService { - - private BookRepository bookRepository; - - public BookService(BookRepository bookRepository) { - this.bookRepository = bookRepository; - } - - public List query(String author, String title) { - return bookRepository.findAll(where(hasAuthor(author)).and(titleContains(title))); - } - -} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookSpecifications.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookSpecifications.java deleted file mode 100644 index 16646a5b4b..0000000000 --- a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookSpecifications.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.baeldung.persistence.dao; - -import com.baeldung.persistence.model.Book; -import org.springframework.data.jpa.domain.Specification; - -public class BookSpecifications { - - public static Specification hasAuthor(String author) { - return (book, cq, cb) -> cb.equal(book.get("author"), author); - } - - public static Specification titleContains(String title) { - return (book, cq, cb) -> cb.like(book.get("title"), "%" + title + "%"); - } - -} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IBarAuditableDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IBarAuditableDao.java new file mode 100644 index 0000000000..182b493592 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IBarAuditableDao.java @@ -0,0 +1,8 @@ +package com.baeldung.persistence.dao; + +import com.baeldung.persistence.dao.common.IAuditOperations; +import com.baeldung.persistence.model.Bar; + +public interface IBarAuditableDao extends IBarDao, IAuditOperations { + // +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IBarCrudRepository.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IBarCrudRepository.java new file mode 100644 index 0000000000..4d7db64240 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IBarCrudRepository.java @@ -0,0 +1,10 @@ +package com.baeldung.persistence.dao; + +import java.io.Serializable; + +import com.baeldung.persistence.model.Bar; +import org.springframework.data.repository.CrudRepository; + +public interface IBarCrudRepository extends CrudRepository { + // +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IBarDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IBarDao.java new file mode 100644 index 0000000000..7896a2a84a --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IBarDao.java @@ -0,0 +1,8 @@ +package com.baeldung.persistence.dao; + +import com.baeldung.persistence.dao.common.IOperations; +import com.baeldung.persistence.model.Bar; + +public interface IBarDao extends IOperations { + // +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IChildDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IChildDao.java new file mode 100644 index 0000000000..a55a0b0598 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IChildDao.java @@ -0,0 +1,8 @@ +package com.baeldung.persistence.dao; + +import com.baeldung.persistence.model.Child; +import com.baeldung.persistence.dao.common.IOperations; + +public interface IChildDao extends IOperations { + // +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IFooAuditableDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IFooAuditableDao.java new file mode 100644 index 0000000000..ddbb685988 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IFooAuditableDao.java @@ -0,0 +1,8 @@ +package com.baeldung.persistence.dao; + +import com.baeldung.persistence.dao.common.IAuditOperations; +import com.baeldung.persistence.model.Foo; + +public interface IFooAuditableDao extends IFooDao, IAuditOperations { + // +} \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IFooDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IFooDao.java new file mode 100644 index 0000000000..0935772dbd --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IFooDao.java @@ -0,0 +1,8 @@ +package com.baeldung.persistence.dao; + +import com.baeldung.persistence.model.Foo; +import com.baeldung.persistence.dao.common.IOperations; + +public interface IFooDao extends IOperations { + // +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IParentDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IParentDao.java new file mode 100644 index 0000000000..03680158bb --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/IParentDao.java @@ -0,0 +1,8 @@ +package com.baeldung.persistence.dao; + +import com.baeldung.persistence.model.Parent; +import com.baeldung.persistence.dao.common.IOperations; + +public interface IParentDao extends IOperations { + // +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/AbstractDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/AbstractDao.java new file mode 100644 index 0000000000..5a6c76a93a --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/AbstractDao.java @@ -0,0 +1,14 @@ +package com.baeldung.persistence.dao.common; + +import java.io.Serializable; + +import com.google.common.base.Preconditions; + +public abstract class AbstractDao implements IOperations { + + protected Class clazz; + + protected final void setClazz(final Class clazzToSet) { + clazz = Preconditions.checkNotNull(clazzToSet); + } +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/AbstractHibernateAuditableDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/AbstractHibernateAuditableDao.java new file mode 100644 index 0000000000..41184669ad --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/AbstractHibernateAuditableDao.java @@ -0,0 +1,37 @@ +package com.baeldung.persistence.dao.common; + +import java.io.Serializable; +import java.util.List; + +import org.hibernate.envers.AuditReader; +import org.hibernate.envers.AuditReaderFactory; +import org.hibernate.envers.query.AuditQuery; + +@SuppressWarnings("unchecked") +public class AbstractHibernateAuditableDao extends AbstractHibernateDao implements IAuditOperations { + + @Override + public List getEntitiesAtRevision(final Number revision) { + final AuditReader auditReader = AuditReaderFactory.get(getCurrentSession()); + final AuditQuery query = auditReader.createQuery().forEntitiesAtRevision(clazz, revision); + final List resultList = query.getResultList(); + return resultList; + } + + @Override + public List getEntitiesModifiedAtRevision(final Number revision) { + final AuditReader auditReader = AuditReaderFactory.get(getCurrentSession()); + final AuditQuery query = auditReader.createQuery().forEntitiesModifiedAtRevision(clazz, revision); + final List resultList = query.getResultList(); + return resultList; + } + + @Override + public List getRevisions() { + final AuditReader auditReader = AuditReaderFactory.get(getCurrentSession()); + final AuditQuery query = auditReader.createQuery().forRevisionsOfEntity(clazz, true, true); + final List resultList = query.getResultList(); + return resultList; + } + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/AbstractHibernateDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/AbstractHibernateDao.java new file mode 100644 index 0000000000..f3ade67f80 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/AbstractHibernateDao.java @@ -0,0 +1,59 @@ +package com.baeldung.persistence.dao.common; + +import java.io.Serializable; +import java.util.List; + +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.springframework.beans.factory.annotation.Autowired; + +import com.google.common.base.Preconditions; + +@SuppressWarnings("unchecked") +public abstract class AbstractHibernateDao extends AbstractDao implements IOperations { + + @Autowired + protected SessionFactory sessionFactory; + + // API + + @Override + public T findOne(final long id) { + return (T) getCurrentSession().get(clazz, id); + } + + @Override + public List findAll() { + return getCurrentSession().createQuery("from " + clazz.getName()).list(); + } + + @Override + public void create(final T entity) { + Preconditions.checkNotNull(entity); + getCurrentSession().saveOrUpdate(entity); + } + + @Override + public T update(final T entity) { + Preconditions.checkNotNull(entity); + return (T) getCurrentSession().merge(entity); + } + + @Override + public void delete(final T entity) { + Preconditions.checkNotNull(entity); + getCurrentSession().delete(entity); + } + + @Override + public void deleteById(final long entityId) { + final T entity = findOne(entityId); + Preconditions.checkState(entity != null); + delete(entity); + } + + protected Session getCurrentSession() { + return sessionFactory.getCurrentSession(); + } + +} \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/AbstractJpaDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/AbstractJpaDao.java new file mode 100644 index 0000000000..79bdd86658 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/AbstractJpaDao.java @@ -0,0 +1,56 @@ +package com.baeldung.persistence.dao.common; + +import java.io.Serializable; +import java.util.List; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.persistence.TypedQuery; +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Root; + +public class AbstractJpaDao extends AbstractDao implements IOperations { + + @PersistenceContext(unitName = "jpaEntityManager") + private EntityManager em; + + // API + + @Override + public T findOne(final long id) { + return em.find(clazz, Long.valueOf(id).intValue()); + } + + @Override + public List findAll() { + final CriteriaBuilder cb = em.getCriteriaBuilder(); + final CriteriaQuery cq = cb.createQuery(clazz); + final Root rootEntry = cq.from(clazz); + final CriteriaQuery all = cq.select(rootEntry); + final TypedQuery allQuery = em.createQuery(all); + return allQuery.getResultList(); + } + + @Override + public void create(final T entity) { + em.persist(entity); + } + + @Override + public T update(final T entity) { + em.merge(entity); + return entity; + } + + @Override + public void delete(final T entity) { + em.remove(entity); + } + + @Override + public void deleteById(final long entityId) { + delete(findOne(entityId)); + } + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/GenericHibernateDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/GenericHibernateDao.java new file mode 100644 index 0000000000..18b16fa033 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/GenericHibernateDao.java @@ -0,0 +1,13 @@ +package com.baeldung.persistence.dao.common; + +import java.io.Serializable; + +import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Repository; + +@Repository +@Scope(BeanDefinition.SCOPE_PROTOTYPE) +public class GenericHibernateDao extends AbstractHibernateDao implements IGenericDao { + // +} \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/IAuditOperations.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/IAuditOperations.java new file mode 100644 index 0000000000..169d3fed72 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/IAuditOperations.java @@ -0,0 +1,14 @@ +package com.baeldung.persistence.dao.common; + +import java.io.Serializable; +import java.util.List; + +public interface IAuditOperations { + + List getEntitiesAtRevision(Number revision); + + List getEntitiesModifiedAtRevision(Number revision); + + List getRevisions(); + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/IGenericDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/IGenericDao.java new file mode 100644 index 0000000000..8d8af18394 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/IGenericDao.java @@ -0,0 +1,7 @@ +package com.baeldung.persistence.dao.common; + +import java.io.Serializable; + +public interface IGenericDao extends IOperations { + // +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/IOperations.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/IOperations.java new file mode 100644 index 0000000000..4ef99221ab --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/common/IOperations.java @@ -0,0 +1,20 @@ +package com.baeldung.persistence.dao.common; + +import java.io.Serializable; +import java.util.List; + +public interface IOperations { + + T findOne(final long id); + + List findAll(); + + void create(final T entity); + + T update(final T entity); + + void delete(final T entity); + + void deleteById(final long entityId); + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/BarAuditableDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/BarAuditableDao.java new file mode 100644 index 0000000000..e12b6ae2da --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/BarAuditableDao.java @@ -0,0 +1,28 @@ +package com.baeldung.persistence.dao.impl; + +import java.util.List; + +import com.baeldung.persistence.dao.IBarAuditableDao; +import com.baeldung.persistence.dao.common.AbstractHibernateAuditableDao; +import com.baeldung.persistence.model.Bar; + +public class BarAuditableDao extends AbstractHibernateAuditableDao implements IBarAuditableDao { + + public BarAuditableDao() { + super(); + + setClazz(Bar.class); + } + + // API + + @Override + public List getRevisions() { + final List resultList = super.getRevisions(); + for (final Bar bar : resultList) { + bar.getFooSet().size(); // force FooSet initialization + } + return resultList; + } + +} \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/BarDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/BarDao.java new file mode 100644 index 0000000000..0ead802dc5 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/BarDao.java @@ -0,0 +1,19 @@ +package com.baeldung.persistence.dao.impl; + +import com.baeldung.persistence.dao.common.AbstractHibernateDao; +import com.baeldung.persistence.dao.IBarDao; +import com.baeldung.persistence.model.Bar; +import org.springframework.stereotype.Repository; + +@Repository +public class BarDao extends AbstractHibernateDao implements IBarDao { + + public BarDao() { + super(); + + setClazz(Bar.class); + } + + // API + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/BarJpaDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/BarJpaDao.java new file mode 100644 index 0000000000..e0fa382d41 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/BarJpaDao.java @@ -0,0 +1,19 @@ +package com.baeldung.persistence.dao.impl; + +import com.baeldung.persistence.dao.IBarDao; +import com.baeldung.persistence.dao.common.AbstractJpaDao; +import com.baeldung.persistence.model.Bar; +import org.springframework.stereotype.Repository; + +@Repository +public class BarJpaDao extends AbstractJpaDao implements IBarDao { + + public BarJpaDao() { + super(); + + setClazz(Bar.class); + } + + // API + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/ChildDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/ChildDao.java new file mode 100644 index 0000000000..b55da6e43a --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/ChildDao.java @@ -0,0 +1,19 @@ +package com.baeldung.persistence.dao.impl; + +import com.baeldung.persistence.dao.common.AbstractHibernateDao; +import com.baeldung.persistence.model.Child; +import com.baeldung.persistence.dao.IChildDao; +import org.springframework.stereotype.Repository; + +@Repository +public class ChildDao extends AbstractHibernateDao implements IChildDao { + + public ChildDao() { + super(); + + setClazz(Child.class); + } + + // API + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/FooAuditableDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/FooAuditableDao.java new file mode 100644 index 0000000000..05064c1478 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/FooAuditableDao.java @@ -0,0 +1,17 @@ +package com.baeldung.persistence.dao.impl; + +import com.baeldung.persistence.dao.common.AbstractHibernateAuditableDao; +import com.baeldung.persistence.model.Foo; +import com.baeldung.persistence.dao.IFooAuditableDao; + +public class FooAuditableDao extends AbstractHibernateAuditableDao implements IFooAuditableDao { + + public FooAuditableDao() { + super(); + + setClazz(Foo.class); + } + + // API + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/FooDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/FooDao.java new file mode 100644 index 0000000000..787c449b1d --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/FooDao.java @@ -0,0 +1,19 @@ +package com.baeldung.persistence.dao.impl; + +import com.baeldung.persistence.dao.common.AbstractHibernateDao; +import com.baeldung.persistence.dao.IFooDao; +import com.baeldung.persistence.model.Foo; +import org.springframework.stereotype.Repository; + +@Repository +public class FooDao extends AbstractHibernateDao implements IFooDao { + + public FooDao() { + super(); + + setClazz(Foo.class); + } + + // API + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/ParentDao.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/ParentDao.java new file mode 100644 index 0000000000..4602b5f30e --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/impl/ParentDao.java @@ -0,0 +1,19 @@ +package com.baeldung.persistence.dao.impl; + +import com.baeldung.persistence.dao.IParentDao; +import com.baeldung.persistence.dao.common.AbstractHibernateDao; +import com.baeldung.persistence.model.Parent; +import org.springframework.stereotype.Repository; + +@Repository +public class ParentDao extends AbstractHibernateDao implements IParentDao { + + public ParentDao() { + super(); + + setClazz(Parent.class); + } + + // API + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Bar.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Bar.java new file mode 100644 index 0000000000..c7f05254cc --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Bar.java @@ -0,0 +1,242 @@ +package com.baeldung.persistence.model; + +import java.io.Serializable; +import java.util.Date; +import java.util.Set; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EntityListeners; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.PrePersist; +import javax.persistence.PreRemove; +import javax.persistence.PreUpdate; + +import org.hibernate.annotations.OrderBy; +import org.hibernate.envers.Audited; +import org.jboss.logging.Logger; +import org.springframework.data.annotation.CreatedBy; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.LastModifiedBy; +import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +import com.google.common.collect.Sets; + +@Entity +@NamedQuery(name = "Bar.findAll", query = "SELECT b FROM Bar b") +@Audited +@EntityListeners(AuditingEntityListener.class) +public class Bar implements Serializable { + + private static Logger logger = Logger.getLogger(Bar.class); + + public enum OPERATION { + INSERT, UPDATE, DELETE; + private String value; + + OPERATION() { + value = toString(); + } + + public String getValue() { + return value; + } + + public static OPERATION parse(final String value) { + OPERATION operation = null; + for (final OPERATION op : OPERATION.values()) { + if (op.getValue().equals(value)) { + operation = op; + break; + } + } + return operation; + } + }; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "id") + private int id; + + @Column(name = "name") + private String name; + + @OneToMany(mappedBy = "bar", cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @OrderBy(clause = "NAME DESC") + // @NotAudited + private Set fooSet = Sets.newHashSet(); + + @Column(name = "operation") + private String operation; + + @Column(name = "timestamp") + private long timestamp; + + @Column(name = "created_date", updatable = false, nullable = false) + @CreatedDate + private long createdDate; + + @Column(name = "modified_date") + @LastModifiedDate + private long modifiedDate; + + @Column(name = "created_by") + @CreatedBy + private String createdBy; + + @Column(name = "modified_by") + @LastModifiedBy + private String modifiedBy; + + public Bar() { + super(); + } + + public Bar(final String name) { + super(); + + this.name = name; + } + + // API + + public Set getFooSet() { + return fooSet; + } + + public void setFooSet(final Set fooSet) { + this.fooSet = fooSet; + } + + 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 OPERATION getOperation() { + return OPERATION.parse(operation); + } + + public void setOperation(final OPERATION operation) { + this.operation = operation.getValue(); + } + + public long getTimestamp() { + return timestamp; + } + + public void setTimestamp(final long timestamp) { + this.timestamp = timestamp; + } + + public long getCreatedDate() { + return createdDate; + } + + public void setCreatedDate(final long createdDate) { + this.createdDate = createdDate; + } + + public long getModifiedDate() { + return modifiedDate; + } + + public void setModifiedDate(final long modifiedDate) { + this.modifiedDate = modifiedDate; + } + + public String getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(final String createdBy) { + this.createdBy = createdBy; + } + + public String getModifiedBy() { + return modifiedBy; + } + + public void setModifiedBy(final String modifiedBy) { + this.modifiedBy = modifiedBy; + } + + public void setOperation(final String operation) { + this.operation = operation; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final Bar other = (Bar) obj; + 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("Bar [name=").append(name).append("]"); + return builder.toString(); + } + + @PrePersist + public void onPrePersist() { + logger.info("@PrePersist"); + audit(OPERATION.INSERT); + } + + @PreUpdate + public void onPreUpdate() { + logger.info("@PreUpdate"); + audit(OPERATION.UPDATE); + } + + @PreRemove + public void onPreRemove() { + logger.info("@PreRemove"); + audit(OPERATION.DELETE); + } + + private void audit(final OPERATION operation) { + setOperation(operation); + setTimestamp((new Date()).getTime()); + } + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Book.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Book.java deleted file mode 100644 index 507043dd56..0000000000 --- a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Book.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.baeldung.persistence.model; - -import javax.persistence.Entity; -import javax.persistence.Id; - -@Entity -public class Book { - - @Id - private Long id; - - private String title; - - private String author; - - public Long getId() { - return id; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getAuthor() { - return author; - } - - public void setAuthor(String author) { - this.author = author; - } - -} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Child.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Child.java new file mode 100644 index 0000000000..19cfb2e237 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Child.java @@ -0,0 +1,51 @@ +package com.baeldung.persistence.model; + +import java.io.Serializable; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.OneToOne; + +@Entity +public class Child implements Serializable { + + @Id + @GeneratedValue + private long id; + + @OneToOne(mappedBy = "child") + private Parent parent; + + public Child() { + super(); + } + + // API + + public long getId() { + return id; + } + + public void setId(final long id) { + this.id = id; + } + + public Parent getParent() { + return parent; + } + + public void setParent(final Parent parent) { + this.parent = parent; + } + + // + + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(); + builder.append("Child [id=").append(id).append("]"); + return builder.toString(); + } + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Foo.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Foo.java new file mode 100644 index 0000000000..d36a1e58cf --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Foo.java @@ -0,0 +1,105 @@ +package com.baeldung.persistence.model; + +import java.io.Serializable; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedNativeQueries; +import javax.persistence.NamedNativeQuery; + +import org.hibernate.envers.Audited; + +@NamedNativeQueries({ @NamedNativeQuery(name = "callGetAllFoos", query = "CALL GetAllFoos()", resultClass = Foo.class), @NamedNativeQuery(name = "callGetFoosByName", query = "CALL GetFoosByName(:fooName)", resultClass = Foo.class) }) +@Entity +@Audited +// @Proxy(lazy = false) +public class Foo implements Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "id") + private long id; + + @Column(name = "name") + private String name; + + @ManyToOne(targetEntity = Bar.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER) + @JoinColumn(name = "BAR_ID") + private Bar bar = new Bar(); + + public Foo() { + super(); + } + + public Foo(final String name) { + super(); + this.name = name; + } + + // + + public Bar getBar() { + return bar; + } + + public void setBar(final Bar bar) { + this.bar = bar; + } + + public long getId() { + return id; + } + + public void setId(final long 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 + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final Foo other = (Foo) obj; + 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("Foo [name=").append(name).append("]"); + return builder.toString(); + } +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Parent.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Parent.java new file mode 100644 index 0000000000..fa6948990b --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Parent.java @@ -0,0 +1,60 @@ +package com.baeldung.persistence.model; + +import java.io.Serializable; + +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.OneToOne; + +@Entity +public class Parent implements Serializable { + + @Id + @GeneratedValue + private long id; + + @OneToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH, CascadeType.DETACH }) + @JoinColumn(name = "child_fk") + private Child child; + + public Parent() { + super(); + } + + public Parent(final Child child) { + super(); + + this.child = child; + } + + // API + + public long getId() { + return id; + } + + public void setId(final long id) { + this.id = id; + } + + public Child getChild() { + return child; + } + + public void setChild(final Child child) { + this.child = child; + } + + // + + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(); + builder.append("Parent [id=").append(id).append("]"); + return builder.toString(); + } + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Person.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Person.java new file mode 100644 index 0000000000..6a95a7acf5 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Person.java @@ -0,0 +1,31 @@ +package com.baeldung.persistence.model; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +@Entity +public class Person { + + @Id + @GeneratedValue + private Long id; + + private String name; + + 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; + } +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/IBarAuditableService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/IBarAuditableService.java new file mode 100644 index 0000000000..33e5634d12 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/IBarAuditableService.java @@ -0,0 +1,8 @@ +package com.baeldung.persistence.service; + +import com.baeldung.persistence.dao.common.IAuditOperations; +import com.baeldung.persistence.model.Bar; + +public interface IBarAuditableService extends IBarService, IAuditOperations { + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/IBarService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/IBarService.java new file mode 100644 index 0000000000..21185b5990 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/IBarService.java @@ -0,0 +1,8 @@ +package com.baeldung.persistence.service; + +import com.baeldung.persistence.dao.common.IOperations; +import com.baeldung.persistence.model.Bar; + +public interface IBarService extends IOperations { + // +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/IChildService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/IChildService.java new file mode 100644 index 0000000000..afe67a70c2 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/IChildService.java @@ -0,0 +1,8 @@ +package com.baeldung.persistence.service; + +import com.baeldung.persistence.model.Child; +import com.baeldung.persistence.dao.common.IOperations; + +public interface IChildService extends IOperations { + // +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/IFooAuditableService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/IFooAuditableService.java new file mode 100644 index 0000000000..b787e7fe91 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/IFooAuditableService.java @@ -0,0 +1,8 @@ +package com.baeldung.persistence.service; + +import com.baeldung.persistence.dao.common.IAuditOperations; +import com.baeldung.persistence.model.Foo; + +public interface IFooAuditableService extends IFooService, IAuditOperations { + // +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/IFooService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/IFooService.java new file mode 100644 index 0000000000..ffdb53964a --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/IFooService.java @@ -0,0 +1,8 @@ +package com.baeldung.persistence.service; + +import com.baeldung.persistence.model.Foo; +import com.baeldung.persistence.dao.common.IOperations; + +public interface IFooService extends IOperations { + // +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/IParentService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/IParentService.java new file mode 100644 index 0000000000..f941416aac --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/IParentService.java @@ -0,0 +1,8 @@ +package com.baeldung.persistence.service; + +import com.baeldung.persistence.model.Parent; +import com.baeldung.persistence.dao.common.IOperations; + +public interface IParentService extends IOperations { + // +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/common/AbstractHibernateAuditableService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/common/AbstractHibernateAuditableService.java new file mode 100644 index 0000000000..2695d7760a --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/common/AbstractHibernateAuditableService.java @@ -0,0 +1,30 @@ +package com.baeldung.persistence.service.common; + +import java.io.Serializable; +import java.util.List; + +import com.baeldung.persistence.dao.common.IAuditOperations; +import com.baeldung.persistence.dao.common.IOperations; +import org.springframework.transaction.annotation.Transactional; + +@Transactional(value = "hibernateTransactionManager") +public abstract class AbstractHibernateAuditableService extends AbstractHibernateService implements IOperations, IAuditOperations { + + @Override + public List getEntitiesAtRevision(final Number revision) { + return getAuditableDao().getEntitiesAtRevision(revision); + } + + @Override + public List getEntitiesModifiedAtRevision(final Number revision) { + return getAuditableDao().getEntitiesModifiedAtRevision(revision); + } + + @Override + public List getRevisions() { + return getAuditableDao().getRevisions(); + } + + abstract protected IAuditOperations getAuditableDao(); + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/common/AbstractHibernateService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/common/AbstractHibernateService.java new file mode 100644 index 0000000000..02b8ccf48b --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/common/AbstractHibernateService.java @@ -0,0 +1,42 @@ +package com.baeldung.persistence.service.common; + +import java.io.Serializable; +import java.util.List; + +import com.baeldung.persistence.dao.common.IOperations; +import org.springframework.transaction.annotation.Transactional; + +@Transactional(value = "hibernateTransactionManager") +public abstract class AbstractHibernateService extends AbstractService implements IOperations { + + @Override + public T findOne(final long id) { + return super.findOne(id); + } + + @Override + public List findAll() { + return super.findAll(); + } + + @Override + public void create(final T entity) { + super.create(entity); + } + + @Override + public T update(final T entity) { + return super.update(entity); + } + + @Override + public void delete(final T entity) { + super.delete(entity); + } + + @Override + public void deleteById(final long entityId) { + super.deleteById(entityId); + } + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/common/AbstractJpaService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/common/AbstractJpaService.java new file mode 100644 index 0000000000..a1c6fe9edf --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/common/AbstractJpaService.java @@ -0,0 +1,42 @@ +package com.baeldung.persistence.service.common; + +import java.io.Serializable; +import java.util.List; + +import com.baeldung.persistence.dao.common.IOperations; +import org.springframework.transaction.annotation.Transactional; + +@Transactional(value = "jpaTransactionManager") +public abstract class AbstractJpaService extends AbstractService implements IOperations { + + @Override + public T findOne(final long id) { + return super.findOne(id); + } + + @Override + public List findAll() { + return super.findAll(); + } + + @Override + public void create(final T entity) { + super.create(entity); + } + + @Override + public T update(final T entity) { + return super.update(entity); + } + + @Override + public void delete(final T entity) { + super.delete(entity); + } + + @Override + public void deleteById(final long entityId) { + super.deleteById(entityId); + } + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/common/AbstractService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/common/AbstractService.java new file mode 100644 index 0000000000..9b001b1fac --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/common/AbstractService.java @@ -0,0 +1,42 @@ +package com.baeldung.persistence.service.common; + +import java.io.Serializable; +import java.util.List; + +import com.baeldung.persistence.dao.common.IOperations; + +public abstract class AbstractService implements IOperations { + + @Override + public T findOne(final long id) { + return getDao().findOne(id); + } + + @Override + public List findAll() { + return getDao().findAll(); + } + + @Override + public void create(final T entity) { + getDao().create(entity); + } + + @Override + public T update(final T entity) { + return getDao().update(entity); + } + + @Override + public void delete(final T entity) { + getDao().delete(entity); + } + + @Override + public void deleteById(final long entityId) { + getDao().deleteById(entityId); + } + + protected abstract IOperations getDao(); + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/common/AbstractSpringDataJpaService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/common/AbstractSpringDataJpaService.java new file mode 100644 index 0000000000..73fe27e9ec --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/common/AbstractSpringDataJpaService.java @@ -0,0 +1,48 @@ +package com.baeldung.persistence.service.common; + +import java.io.Serializable; +import java.util.List; +import java.util.Optional; + +import com.baeldung.persistence.dao.common.IOperations; +import org.springframework.data.repository.CrudRepository; +import org.springframework.transaction.annotation.Transactional; + +import com.google.common.collect.Lists; + +@Transactional(value = "jpaTransactionManager") +public abstract class AbstractSpringDataJpaService implements IOperations { + + @Override + public T findOne(final long id) { + Optional opt = getDao().findById(Long.valueOf(id)); + return opt.get(); + } + + @Override + public List findAll() { + return Lists.newArrayList(getDao().findAll()); + } + + @Override + public void create(final T entity) { + getDao().save(entity); + } + + @Override + public T update(final T entity) { + return getDao().save(entity); + } + + @Override + public void delete(final T entity) { + getDao().delete(entity); + } + + @Override + public void deleteById(final long entityId) { + getDao().deleteById(Long.valueOf(entityId)); + } + + protected abstract CrudRepository getDao(); +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/BarAuditableService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/BarAuditableService.java new file mode 100644 index 0000000000..d84c28caa5 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/BarAuditableService.java @@ -0,0 +1,41 @@ +package com.baeldung.persistence.service.impl; + +import com.baeldung.persistence.dao.common.IAuditOperations; +import com.baeldung.persistence.service.common.AbstractHibernateAuditableService; +import com.baeldung.persistence.dao.IBarAuditableDao; +import com.baeldung.persistence.dao.IBarDao; +import com.baeldung.persistence.dao.common.IOperations; +import com.baeldung.persistence.model.Bar; +import com.baeldung.persistence.service.IBarAuditableService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +@Service +public class BarAuditableService extends AbstractHibernateAuditableService implements IBarAuditableService { + + @Autowired + @Qualifier("barHibernateDao") + private IBarDao dao; + + @Autowired + @Qualifier("barHibernateAuditableDao") + private IBarAuditableDao auditDao; + + public BarAuditableService() { + super(); + } + + // API + + @Override + protected IOperations getDao() { + return dao; + } + + @Override + protected IAuditOperations getAuditableDao() { + return auditDao; + } + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/BarJpaService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/BarJpaService.java new file mode 100644 index 0000000000..1c1b7a2274 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/BarJpaService.java @@ -0,0 +1,30 @@ +package com.baeldung.persistence.service.impl; + +import com.baeldung.persistence.dao.IBarDao; +import com.baeldung.persistence.dao.common.IOperations; +import com.baeldung.persistence.model.Bar; +import com.baeldung.persistence.service.IBarService; +import com.baeldung.persistence.service.common.AbstractJpaService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +@Service +public class BarJpaService extends AbstractJpaService implements IBarService { + + @Autowired + @Qualifier("barJpaDao") + private IBarDao dao; + + public BarJpaService() { + super(); + } + + // API + + @Override + protected IOperations getDao() { + return dao; + } + +} \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/BarService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/BarService.java new file mode 100644 index 0000000000..32d1f919c5 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/BarService.java @@ -0,0 +1,30 @@ +package com.baeldung.persistence.service.impl; + +import com.baeldung.persistence.dao.IBarDao; +import com.baeldung.persistence.dao.common.IOperations; +import com.baeldung.persistence.model.Bar; +import com.baeldung.persistence.service.IBarService; +import com.baeldung.persistence.service.common.AbstractHibernateService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +@Service +public class BarService extends AbstractHibernateService implements IBarService { + + @Autowired + @Qualifier("barHibernateDao") + private IBarDao dao; + + public BarService() { + super(); + } + + // API + + @Override + protected IOperations getDao() { + return dao; + } + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/BarSpringDataJpaService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/BarSpringDataJpaService.java new file mode 100644 index 0000000000..4a55d08a35 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/BarSpringDataJpaService.java @@ -0,0 +1,26 @@ +package com.baeldung.persistence.service.impl; + +import java.io.Serializable; + +import com.baeldung.persistence.service.common.AbstractSpringDataJpaService; +import com.baeldung.persistence.dao.IBarCrudRepository; +import com.baeldung.persistence.model.Bar; +import com.baeldung.persistence.service.IBarService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.repository.CrudRepository; + +public class BarSpringDataJpaService extends AbstractSpringDataJpaService implements IBarService { + + @Autowired + private IBarCrudRepository dao; + + public BarSpringDataJpaService() { + super(); + } + + @Override + protected CrudRepository getDao() { + return dao; + } + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/ChildService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/ChildService.java new file mode 100644 index 0000000000..417fe2c49a --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/ChildService.java @@ -0,0 +1,28 @@ +package com.baeldung.persistence.service.impl; + +import com.baeldung.persistence.model.Child; +import com.baeldung.persistence.service.IChildService; +import com.baeldung.persistence.dao.IChildDao; +import com.baeldung.persistence.dao.common.IOperations; +import com.baeldung.persistence.service.common.AbstractHibernateService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class ChildService extends AbstractHibernateService implements IChildService { + + @Autowired + private IChildDao dao; + + public ChildService() { + super(); + } + + // API + + @Override + protected IOperations getDao() { + return dao; + } + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/FooAuditableService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/FooAuditableService.java new file mode 100644 index 0000000000..45ad315c42 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/FooAuditableService.java @@ -0,0 +1,41 @@ +package com.baeldung.persistence.service.impl; + +import com.baeldung.persistence.dao.common.IAuditOperations; +import com.baeldung.persistence.service.IFooAuditableService; +import com.baeldung.persistence.service.common.AbstractHibernateAuditableService; +import com.baeldung.persistence.dao.IFooAuditableDao; +import com.baeldung.persistence.dao.IFooDao; +import com.baeldung.persistence.dao.common.IOperations; +import com.baeldung.persistence.model.Foo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +@Service +public class FooAuditableService extends AbstractHibernateAuditableService implements IFooAuditableService { + + @Autowired + @Qualifier("fooHibernateDao") + private IFooDao dao; + + @Autowired + @Qualifier("fooHibernateAuditableDao") + private IFooAuditableDao auditDao; + + public FooAuditableService() { + super(); + } + + // API + + @Override + protected IOperations getDao() { + return dao; + } + + @Override + protected IAuditOperations getAuditableDao() { + return auditDao; + } + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/FooService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/FooService.java new file mode 100644 index 0000000000..84cf018fee --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/FooService.java @@ -0,0 +1,30 @@ +package com.baeldung.persistence.service.impl; + +import com.baeldung.persistence.dao.IFooDao; +import com.baeldung.persistence.dao.common.IOperations; +import com.baeldung.persistence.model.Foo; +import com.baeldung.persistence.service.IFooService; +import com.baeldung.persistence.service.common.AbstractHibernateService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +@Service +public class FooService extends AbstractHibernateService implements IFooService { + + @Autowired + @Qualifier("fooHibernateDao") + private IFooDao dao; + + public FooService() { + super(); + } + + // API + + @Override + protected IOperations getDao() { + return dao; + } + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/ParentService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/ParentService.java new file mode 100644 index 0000000000..078acfc369 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/service/impl/ParentService.java @@ -0,0 +1,28 @@ +package com.baeldung.persistence.service.impl; + +import com.baeldung.persistence.model.Parent; +import com.baeldung.persistence.service.IParentService; +import com.baeldung.persistence.dao.IParentDao; +import com.baeldung.persistence.dao.common.IOperations; +import com.baeldung.persistence.service.common.AbstractHibernateService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class ParentService extends AbstractHibernateService implements IParentService { + + @Autowired + private IParentDao dao; + + public ParentService() { + super(); + } + + // API + + @Override + protected IOperations getDao() { + return dao; + } + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/resources/fetching.cfg.xml b/persistence-modules/spring-data-jpa-query-2/src/main/resources/fetching.cfg.xml new file mode 100644 index 0000000000..1b9a4a191c --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/resources/fetching.cfg.xml @@ -0,0 +1,20 @@ + + + + + + com.mysql.jdbc.Driver + jdbc:mysql://localhost:3306/test + root + iamtheking + org.hibernate.dialect.MySQLDialect + true + validate + + + + + + \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/resources/fetchingLazy.cfg.xml b/persistence-modules/spring-data-jpa-query-2/src/main/resources/fetchingLazy.cfg.xml new file mode 100644 index 0000000000..c5f608e1a7 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/resources/fetchingLazy.cfg.xml @@ -0,0 +1,17 @@ + + + + + + com.mysql.jdbc.Driver + jdbc:mysql://localhost:3306/test + root + iamtheking + org.hibernate.dialect.MySQLDialect + true + + + + \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/resources/fetching_create_queries.sql b/persistence-modules/spring-data-jpa-query-2/src/main/resources/fetching_create_queries.sql new file mode 100644 index 0000000000..b36d9828f1 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/resources/fetching_create_queries.sql @@ -0,0 +1,14 @@ +CREATE TABLE `user` ( + `user_id` int(10) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`user_id`) +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=latin1 ; + + +CREATE TABLE `user_order` ( + `ORDER_ID` int(10) NOT NULL AUTO_INCREMENT, + `USER_ID` int(10) NOT NULL DEFAULT '0', + PRIMARY KEY (`ORDER_ID`,`USER_ID`), + KEY `USER_ID` (`USER_ID`), + CONSTRAINT `user_order_ibfk_1` FOREIGN KEY (`USER_ID`) REFERENCES `USER` (`user_id`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1; + diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/resources/hibernate5Config.xml b/persistence-modules/spring-data-jpa-query-2/src/main/resources/hibernate5Config.xml new file mode 100644 index 0000000000..bbb61cb3e0 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/resources/hibernate5Config.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + ${hibernate.hbm2ddl.auto} + ${hibernate.dialect} + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/resources/hibernate5Configuration.xml b/persistence-modules/spring-data-jpa-query-2/src/main/resources/hibernate5Configuration.xml new file mode 100644 index 0000000000..1870cfb917 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/resources/hibernate5Configuration.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + ${hibernate.hbm2ddl.auto} + ${hibernate.dialect} + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/resources/immutable.cfg.xml b/persistence-modules/spring-data-jpa-query-2/src/main/resources/immutable.cfg.xml new file mode 100644 index 0000000000..fe1e3cb723 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/resources/immutable.cfg.xml @@ -0,0 +1,38 @@ + + + + + + + + + org.hsqldb.jdbcDriver + jdbc:hsqldb:hsql:mem://localhost/xdb + sa + + + + 1 + + + org.hibernate.dialect.HSQLDialect + + + thread + + + org.hibernate.cache.NoCacheProvider + + + true + + + update + + + + + + \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/resources/insert_statements.sql b/persistence-modules/spring-data-jpa-query-2/src/main/resources/insert_statements.sql new file mode 100644 index 0000000000..ae008f29bc --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/resources/insert_statements.sql @@ -0,0 +1,31 @@ +insert into item (item_id, item_name, item_desc, item_price) +values(1,'item One', 'test 1', 35.12); + +insert into item (item_id, item_name, item_desc, item_price) +values(2,'Pogo stick', 'Pogo stick', 466.12); +insert into item (item_id, item_name, item_desc, item_price) +values(3,'Raft', 'Raft', 345.12); + +insert into item (item_id, item_name, item_desc, item_price) +values(4,'Skate Board', 'Skating', 135.71); + +insert into item (item_id, item_name, item_desc, item_price) +values(5,'Umbrella', 'Umbrella for Rain', 619.25); + +insert into item (item_id, item_name, item_desc, item_price) +values(6,'Glue', 'Glue for home', 432.73); + +insert into item (item_id, item_name, item_desc, item_price) +values(7,'Paint', 'Paint for Room', 1311.40); + +insert into item (item_id, item_name, item_desc, item_price) +values(8,'Red paint', 'Red paint for room', 1135.71); + +insert into item (item_id, item_name, item_desc, item_price) +values(9,'Household Chairs', 'Chairs for house', 25.71); + +insert into item (item_id, item_name, item_desc, item_price) +values(10,'Office Chairs', 'Chairs for office', 395.98); + +insert into item (item_id, item_name, item_desc, item_price) +values(11,'Outdoor Chairs', 'Chairs for outdoor activities', 1234.36); diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/resources/logback.xml b/persistence-modules/spring-data-jpa-query-2/src/main/resources/logback.xml new file mode 100644 index 0000000000..56af2d397e --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/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/persistence-modules/spring-data-jpa-query-2/src/main/resources/persistence-mysql.properties b/persistence-modules/spring-data-jpa-query-2/src/main/resources/persistence-mysql.properties new file mode 100644 index 0000000000..f6b6ab6fca --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/resources/persistence-mysql.properties @@ -0,0 +1,13 @@ +# jdbc.X +jdbc.driverClassName=com.mysql.jdbc.Driver +jdbc.url=jdbc:mysql://localhost:3306/spring_hibernate4_01?createDatabaseIfNotExist=true +jdbc.user=tutorialuser +jdbc.pass=tutorialmy5ql + +# hibernate.X +hibernate.dialect=org.hibernate.dialect.MySQL5Dialect +hibernate.show_sql=false +hibernate.hbm2ddl.auto=create-drop + +# envers.X +envers.audit_table_suffix=_audit_log diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/resources/stored_procedure.sql b/persistence-modules/spring-data-jpa-query-2/src/main/resources/stored_procedure.sql new file mode 100644 index 0000000000..9cedb75c37 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/resources/stored_procedure.sql @@ -0,0 +1,20 @@ +DELIMITER // + CREATE PROCEDURE GetFoosByName(IN fooName VARCHAR(255)) + LANGUAGE SQL + DETERMINISTIC + SQL SECURITY DEFINER + BEGIN + SELECT * FROM foo WHERE name = fooName; + END // +DELIMITER ; + + +DELIMITER // + CREATE PROCEDURE GetAllFoos() + LANGUAGE SQL + DETERMINISTIC + SQL SECURITY DEFINER + BEGIN + SELECT * FROM foo; + END // +DELIMITER ; \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/resources/webSecurityConfig.xml b/persistence-modules/spring-data-jpa-query-2/src/main/resources/webSecurityConfig.xml new file mode 100644 index 0000000000..e5c19a4ad7 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/resources/webSecurityConfig.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/hibernate/fetching/HibernateFetchingIntegrationTest.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/hibernate/fetching/HibernateFetchingIntegrationTest.java new file mode 100644 index 0000000000..65bf36f8bf --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/hibernate/fetching/HibernateFetchingIntegrationTest.java @@ -0,0 +1,42 @@ +package com.baeldung.hibernate.fetching; + +import com.baeldung.hibernate.fetching.model.OrderDetail; +import com.baeldung.hibernate.fetching.view.FetchingAppView; +import org.hibernate.Hibernate; +import org.junit.Before; +import org.junit.Test; + +import java.util.Set; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +public class HibernateFetchingIntegrationTest { + + // this loads sample data in the database + @Before + public void addFecthingTestData() { + FetchingAppView fav = new FetchingAppView(); + fav.createTestData(); + } + + // testLazyFetching() tests the lazy loading + // Since it lazily loaded so orderDetalSetLazy won't + // be initialized + @Test + public void testLazyFetching() { + FetchingAppView fav = new FetchingAppView(); + Set orderDetalSetLazy = fav.lazyLoaded(); + assertFalse(Hibernate.isInitialized(orderDetalSetLazy)); + } + + // testEagerFetching() tests the eager loading + // Since it eagerly loaded so orderDetalSetLazy would + // be initialized + @Test + public void testEagerFetching() { + FetchingAppView fav = new FetchingAppView(); + Set orderDetalSetEager = fav.eagerLoaded(); + assertTrue(Hibernate.isInitialized(orderDetalSetEager)); + } +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/IntegrationTestSuite.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/IntegrationTestSuite.java new file mode 100644 index 0000000000..f5c45a5d6f --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/IntegrationTestSuite.java @@ -0,0 +1,25 @@ +package com.baeldung.persistence; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +import com.baeldung.persistence.audit.AuditTestSuite; +import com.baeldung.persistence.hibernate.FooPaginationPersistenceIntegrationTest; +import com.baeldung.persistence.hibernate.FooSortingPersistenceIntegrationTest; +import com.baeldung.persistence.service.FooServiceBasicPersistenceIntegrationTest; +import com.baeldung.persistence.service.FooServicePersistenceIntegrationTest; +import com.baeldung.persistence.service.ParentServicePersistenceIntegrationTest; + +@RunWith(Suite.class) +@Suite.SuiteClasses({ // @formatter:off + AuditTestSuite.class + ,FooServiceBasicPersistenceIntegrationTest.class + ,FooPaginationPersistenceIntegrationTest.class + ,FooServicePersistenceIntegrationTest.class + ,ParentServicePersistenceIntegrationTest.class + ,FooSortingPersistenceIntegrationTest.class + +}) // @formatter:on +public class IntegrationTestSuite { + // +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/audit/AuditTestSuite.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/audit/AuditTestSuite.java new file mode 100644 index 0000000000..34c725d62b --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/audit/AuditTestSuite.java @@ -0,0 +1,14 @@ +package com.baeldung.persistence.audit; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses({ // @formatter:off + EnversFooBarAuditIntegrationTest.class, + JPABarAuditIntegrationTest.class, + SpringDataJPABarAuditIntegrationTest.class +}) // @formatter:on +public class AuditTestSuite { + // +} \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/audit/EnversFooBarAuditIntegrationTest.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/audit/EnversFooBarAuditIntegrationTest.java new file mode 100644 index 0000000000..444324dafc --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/audit/EnversFooBarAuditIntegrationTest.java @@ -0,0 +1,146 @@ +package com.baeldung.persistence.audit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.util.List; + +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +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.test.annotation.DirtiesContext; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +import com.baeldung.persistence.model.Bar; +import com.baeldung.persistence.model.Foo; +import com.baeldung.persistence.service.IBarAuditableService; +import com.baeldung.persistence.service.IFooAuditableService; +import com.baeldung.spring.config.PersistenceTestConfig; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PersistenceTestConfig.class }, loader = AnnotationConfigContextLoader.class) +@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS) +public class EnversFooBarAuditIntegrationTest { + + private static Logger logger = LoggerFactory.getLogger(EnversFooBarAuditIntegrationTest.class); + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + logger.info("setUpBeforeClass()"); + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + logger.info("tearDownAfterClass()"); + } + + @Autowired + @Qualifier("fooHibernateAuditableService") + private IFooAuditableService fooService; + + @Autowired + @Qualifier("barHibernateAuditableService") + private IBarAuditableService barService; + + @Autowired + private SessionFactory sessionFactory; + + private Session session; + + @Before + public void setUp() throws Exception { + logger.info("setUp()"); + makeRevisions(); + session = sessionFactory.openSession(); + } + + @After + public void tearDown() throws Exception { + logger.info("tearDown()"); + session.close(); + } + + private void makeRevisions() { + final Bar bar = rev1(); + rev2(bar); + rev3(bar); + rev4(bar); + } + + // REV #1: insert BAR & FOO1 + private Bar rev1() { + final Bar bar = new Bar("BAR"); + final Foo foo1 = new Foo("FOO1"); + foo1.setBar(bar); + fooService.create(foo1); + return bar; + } + + // REV #2: insert FOO2 & update BAR + private void rev2(final Bar bar) { + final Foo foo2 = new Foo("FOO2"); + foo2.setBar(bar); + fooService.create(foo2); + } + + // REV #3: update BAR + private void rev3(final Bar bar) { + + bar.setName("BAR1"); + barService.update(bar); + } + + // REV #4: insert FOO3 & update BAR + private void rev4(final Bar bar) { + + final Foo foo3 = new Foo("FOO3"); + foo3.setBar(bar); + fooService.create(foo3); + } + + @Test + public final void whenFooBarsModified_thenFooBarsAudited() { + + List barRevisionList; + List fooRevisionList; + + // test Bar revisions + + barRevisionList = barService.getRevisions(); + + assertNotNull(barRevisionList); + assertEquals(4, barRevisionList.size()); + + assertEquals("BAR", barRevisionList.get(0).getName()); + assertEquals("BAR", barRevisionList.get(1).getName()); + assertEquals("BAR1", barRevisionList.get(2).getName()); + assertEquals("BAR1", barRevisionList.get(3).getName()); + + assertEquals(1, barRevisionList.get(0).getFooSet().size()); + assertEquals(2, barRevisionList.get(1).getFooSet().size()); + assertEquals(2, barRevisionList.get(2).getFooSet().size()); + assertEquals(3, barRevisionList.get(3).getFooSet().size()); + + // test Foo revisions + + fooRevisionList = fooService.getRevisions(); + assertNotNull(fooRevisionList); + assertEquals(3, fooRevisionList.size()); + assertEquals("FOO1", fooRevisionList.get(0).getName()); + assertEquals("FOO2", fooRevisionList.get(1).getName()); + assertEquals("FOO3", fooRevisionList.get(2).getName()); + } + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/audit/JPABarAuditIntegrationTest.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/audit/JPABarAuditIntegrationTest.java new file mode 100644 index 0000000000..f591773cde --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/audit/JPABarAuditIntegrationTest.java @@ -0,0 +1,104 @@ +package com.baeldung.persistence.audit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +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.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +import com.baeldung.persistence.model.Bar; +import com.baeldung.persistence.model.Bar.OPERATION; +import com.baeldung.persistence.service.IBarService; +import com.baeldung.spring.config.PersistenceTestConfig; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PersistenceTestConfig.class }, loader = AnnotationConfigContextLoader.class) +public class JPABarAuditIntegrationTest { + + private static Logger logger = LoggerFactory.getLogger(JPABarAuditIntegrationTest.class); + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + logger.info("setUpBeforeClass()"); + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + logger.info("tearDownAfterClass()"); + } + + @Autowired + @Qualifier("barJpaService") + private IBarService barService; + + @Autowired + @Qualifier("jpaEntityManager") + private EntityManagerFactory entityManagerFactory; + + private EntityManager em; + + @Before + public void setUp() throws Exception { + logger.info("setUp()"); + em = entityManagerFactory.createEntityManager(); + } + + @After + public void tearDown() throws Exception { + logger.info("tearDown()"); + em.close(); + } + + @Test + public final void whenBarsModified_thenBarsAudited() { + + // insert BAR1 + Bar bar1 = new Bar("BAR1"); + barService.create(bar1); + + // update BAR1 + bar1.setName("BAR1a"); + barService.update(bar1); + + // insert BAR2 + Bar bar2 = new Bar("BAR2"); + barService.create(bar2); + + // update BAR1 + bar1.setName("BAR1b"); + barService.update(bar1); + + // get BAR1 and BAR2 from the DB and check the audit values + // detach instances from persistence context to make sure we fire db + em.detach(bar1); + em.detach(bar2); + bar1 = barService.findOne(bar1.getId()); + bar2 = barService.findOne(bar2.getId()); + + assertNotNull(bar1); + assertNotNull(bar2); + assertEquals(OPERATION.UPDATE, bar1.getOperation()); + assertEquals(OPERATION.INSERT, bar2.getOperation()); + assertTrue(bar1.getTimestamp() > bar2.getTimestamp()); + + barService.deleteById(bar1.getId()); + barService.deleteById(bar2.getId()); + + } + +} \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/audit/SpringDataJPABarAuditIntegrationTest.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/audit/SpringDataJPABarAuditIntegrationTest.java new file mode 100644 index 0000000000..0603067810 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/audit/SpringDataJPABarAuditIntegrationTest.java @@ -0,0 +1,78 @@ +package com.baeldung.persistence.audit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +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.security.test.context.support.WithMockUser; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +import com.baeldung.persistence.model.Bar; +import com.baeldung.persistence.service.IBarService; +import com.baeldung.spring.config.PersistenceTestConfig; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PersistenceTestConfig.class }, loader = AnnotationConfigContextLoader.class) +public class SpringDataJPABarAuditIntegrationTest { + + private static Logger logger = LoggerFactory.getLogger(SpringDataJPABarAuditIntegrationTest.class); + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + logger.info("setUpBeforeClass()"); + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + logger.info("tearDownAfterClass()"); + } + + @Autowired + @Qualifier("barSpringDataJpaService") + private IBarService barService; + + @Autowired + @Qualifier("jpaEntityManager") + private EntityManagerFactory entityManagerFactory; + + private EntityManager em; + + @Before + public void setUp() throws Exception { + logger.info("setUp()"); + em = entityManagerFactory.createEntityManager(); + } + + @After + public void tearDown() throws Exception { + logger.info("tearDown()"); + em.close(); + } + + @Test + @WithMockUser(username = "tutorialuser") + public final void whenBarsModified_thenBarsAudited() { + Bar bar = new Bar("BAR1"); + barService.create(bar); + assertEquals(bar.getCreatedDate(), bar.getModifiedDate()); + assertEquals("tutorialuser", bar.getCreatedBy(), bar.getModifiedBy()); + bar.setName("BAR2"); + bar = barService.update(bar); + assertTrue(bar.getCreatedDate() < bar.getModifiedDate()); + assertEquals("tutorialuser", bar.getCreatedBy(), bar.getModifiedBy()); + } +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/hibernate/FooFixtures.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/hibernate/FooFixtures.java new file mode 100644 index 0000000000..da840dc027 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/hibernate/FooFixtures.java @@ -0,0 +1,101 @@ +package com.baeldung.persistence.hibernate; + +import java.util.List; + +import com.baeldung.persistence.model.Foo; +import com.baeldung.persistence.model.Bar; +import org.hibernate.HibernateException; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.Transaction; + +import com.google.common.collect.Lists; + +public class FooFixtures { + private SessionFactory sessionFactory; + + public FooFixtures(final SessionFactory sessionFactory) { + super(); + + this.sessionFactory = sessionFactory; + } + + // API + + public void createBars() { + Session session = null; + Transaction tx = null; + session = sessionFactory.openSession(); + tx = session.getTransaction(); + try { + tx.begin(); + for (int i = 156; i < 160; i++) { + final Bar bar = new Bar(); + bar.setName("Bar_" + i); + final Foo foo = new Foo("Foo_" + (i + 120)); + foo.setBar(bar); + session.save(foo); + final Foo foo2 = new Foo(null); + if (i % 2 == 0) + foo2.setName("LuckyFoo" + (i + 120)); + foo2.setBar(bar); + session.save(foo2); + bar.getFooSet().add(foo); + bar.getFooSet().add(foo2); + session.merge(bar); + } + tx.commit(); + session.flush(); + } catch (final HibernateException he) { + if (tx != null) + tx.rollback(); + System.out.println("Not able to open session"); + he.printStackTrace(); + } catch (final Exception e) { + e.printStackTrace(); + } finally { + if (session != null) + session.close(); + } + + } + + public void createFoos() { + Session session = null; + Transaction tx = null; + session = sessionFactory.openSession(); + tx = session.getTransaction(); + final List fooList = Lists.newArrayList(); + for (int i = 35; i < 46; i++) { + + final Foo foo = new Foo(); + foo.setName("Foo_" + (i + 120)); + final Bar bar = new Bar("bar_" + i); + bar.getFooSet().add(foo); + foo.setBar(bar); + fooList.add(foo); + + } + try { + tx.begin(); + for (final Foo foo : fooList) { + + session.save(foo.getBar()); + session.save(foo); + } + tx.commit(); + session.flush(); + } catch (final HibernateException he) { + if (tx != null) + tx.rollback(); + System.out.println("Not able to open session"); + he.printStackTrace(); + } catch (final Exception e) { + e.printStackTrace(); + } finally { + if (session != null) + session.close(); + } + } + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/hibernate/FooPaginationPersistenceIntegrationTest.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/hibernate/FooPaginationPersistenceIntegrationTest.java new file mode 100644 index 0000000000..fd7bc4aabf --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/hibernate/FooPaginationPersistenceIntegrationTest.java @@ -0,0 +1,185 @@ +package com.baeldung.persistence.hibernate; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.lessThan; +import static org.junit.Assert.assertThat; + +import java.util.List; + +import org.hibernate.Criteria; +import org.hibernate.Query; +import org.hibernate.ScrollMode; +import org.hibernate.ScrollableResults; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.criterion.Projections; +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.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +import com.baeldung.persistence.model.Foo; +import com.baeldung.persistence.service.IFooService; +import com.baeldung.spring.config.PersistenceTestConfig; +import com.google.common.collect.Lists; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PersistenceTestConfig.class }, loader = AnnotationConfigContextLoader.class) +public class FooPaginationPersistenceIntegrationTest { + + @Autowired + private IFooService fooService; + + @Autowired + private SessionFactory sessionFactory; + + private Session session; + + // tests + + @Before + public final void before() { + final int minimalNumberOfEntities = 25; + if (fooService.findAll().size() <= minimalNumberOfEntities) { + for (int i = 0; i < minimalNumberOfEntities; i++) { + fooService.create(new Foo(randomAlphabetic(6))); + } + } + + session = sessionFactory.openSession(); + } + + @After + public final void after() { + session.close(); + } + + // tests + + @Test + public final void whenContextIsBootstrapped_thenNoExceptions() { + // + } + + @SuppressWarnings("unchecked") + @Test + public final void whenRetrievingPaginatedEntities_thenCorrectSize() { + final int pageNumber = 1; + final int pageSize = 10; + + final Query query = session.createQuery("From Foo"); + query.setFirstResult((pageNumber - 1) * pageSize); + query.setMaxResults(pageSize); + final List fooList = query.list(); + + assertThat(fooList, hasSize(pageSize)); + } + + @SuppressWarnings("unchecked") + @Test + public final void whenRetrievingAllPages_thenCorrect() { + int pageNumber = 1; + final int pageSize = 10; + + final String countQ = "Select count (f.id) from Foo f"; + final Query countQuery = session.createQuery(countQ); + final Long countResult = (Long) countQuery.uniqueResult(); + + final List fooList = Lists.newArrayList(); + int totalEntities = 0; + final Query query = session.createQuery("From Foo"); + while (totalEntities < countResult) { + query.setFirstResult((pageNumber - 1) * pageSize); + query.setMaxResults(pageSize); + fooList.addAll(query.list()); + totalEntities = fooList.size(); + pageNumber++; + } + } + + @SuppressWarnings("unchecked") + @Test + public final void whenRetrievingLastPage_thenCorrectSize() { + final int pageSize = 10; + + final String countQ = "Select count (f.id) from Foo f"; + final Query countQuery = session.createQuery(countQ); + final Long countResults = (Long) countQuery.uniqueResult(); + final int lastPageNumber = (int) (Math.ceil(countResults / pageSize)); + + final Query selectQuery = session.createQuery("From Foo"); + selectQuery.setFirstResult((lastPageNumber - 1) * pageSize); + selectQuery.setMaxResults(pageSize); + final List lastPage = selectQuery.list(); + + assertThat(lastPage, hasSize(lessThan(pageSize + 1))); + } + + // testing - scrollable + + @Test + public final void givenUsingTheScrollableApi_whenRetrievingPaginatedData_thenCorrect() { + final int pageSize = 10; + final String hql = "FROM Foo f order by f.name"; + final Query query = session.createQuery(hql); + + final ScrollableResults resultScroll = query.scroll(ScrollMode.FORWARD_ONLY); + + // resultScroll.last(); + // final int totalResults = resultScroll.getRowNumber() + 1; + + resultScroll.first(); + resultScroll.scroll(0); + final List fooPage = Lists.newArrayList(); + int i = 0; + while (pageSize > i++) { + fooPage.add((Foo) resultScroll.get(0)); + if (!resultScroll.next()) { + break; + } + } + + assertThat(fooPage, hasSize(lessThan(10 + 1))); + } + + @SuppressWarnings("unchecked") + @Test + public final void givenUsingTheCriteriaApi_whenRetrievingFirstPage_thenCorrect() { + final int pageSize = 10; + + final Criteria criteria = session.createCriteria(Foo.class); + criteria.setFirstResult(0); + criteria.setMaxResults(pageSize); + final List firstPage = criteria.list(); + + assertThat(firstPage, hasSize(pageSize)); + } + + @SuppressWarnings("unchecked") + @Test + public final void givenUsingTheCriteriaApi_whenRetrievingPaginatedData_thenCorrect() { + final Criteria criteriaCount = session.createCriteria(Foo.class); + criteriaCount.setProjection(Projections.rowCount()); + final Long count = (Long) criteriaCount.uniqueResult(); + + int pageNumber = 1; + final int pageSize = 10; + final List fooList = Lists.newArrayList(); + + final Criteria criteria = session.createCriteria(Foo.class); + int totalEntities = 0; + while (totalEntities < count.intValue()) { + criteria.setFirstResult((pageNumber - 1) * pageSize); + criteria.setMaxResults(pageSize); + fooList.addAll(criteria.list()); + totalEntities = fooList.size(); + pageNumber++; + } + } + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/hibernate/FooSortingPersistenceIntegrationTest.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/hibernate/FooSortingPersistenceIntegrationTest.java new file mode 100644 index 0000000000..8173088af0 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/hibernate/FooSortingPersistenceIntegrationTest.java @@ -0,0 +1,174 @@ +package com.baeldung.persistence.hibernate; + +import static org.junit.Assert.assertNull; + +import java.util.List; +import java.util.Set; + +import org.hibernate.Criteria; +import org.hibernate.NullPrecedence; +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.criterion.Order; +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.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +import com.baeldung.persistence.model.Bar; +import com.baeldung.persistence.model.Foo; +import com.baeldung.spring.config.PersistenceTestConfig; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PersistenceTestConfig.class }, loader = AnnotationConfigContextLoader.class) +@SuppressWarnings("unchecked") +public class FooSortingPersistenceIntegrationTest { + + @Autowired + private SessionFactory sessionFactory; + + private Session session; + + @Before + public void before() { + session = sessionFactory.openSession(); + + session.beginTransaction(); + + final FooFixtures fooData = new FooFixtures(sessionFactory); + fooData.createBars(); + } + + @After + public void after() { + session.getTransaction().commit(); + session.close(); + } + + @Test + public final void whenHQlSortingByOneAttribute_thenPrintSortedResults() { + final String hql = "FROM Foo f ORDER BY f.name"; + final Query query = session.createQuery(hql); + final List fooList = query.list(); + for (final Foo foo : fooList) { + System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); + } + } + + @Test + public final void whenHQlSortingByStringNullLast_thenLastNull() { + final String hql = "FROM Foo f ORDER BY f.name NULLS LAST"; + final Query query = session.createQuery(hql); + final List fooList = query.list(); + + assertNull(fooList.get(fooList.toArray().length - 1).getName()); + for (final Foo foo : fooList) { + System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); + } + } + + @Test + public final void whenSortingByStringNullsFirst_thenReturnNullsFirst() { + final String hql = "FROM Foo f ORDER BY f.name NULLS FIRST"; + final Query query = session.createQuery(hql); + final List fooList = query.list(); + assertNull(fooList.get(0).getName()); + for (final Foo foo : fooList) { + System.out.println("Name:" + foo.getName()); + + } + } + + @Test + public final void whenHQlSortingByOneAttribute_andOrderDirection_thenPrintSortedResults() { + final String hql = "FROM Foo f ORDER BY f.name ASC"; + final Query query = session.createQuery(hql); + final List fooList = query.list(); + for (final Foo foo : fooList) { + System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); + } + } + + @Test + public final void whenHQlSortingByMultipleAttributes_thenSortedResults() { + final String hql = "FROM Foo f ORDER BY f.name, f.id"; + final Query query = session.createQuery(hql); + final List fooList = query.list(); + for (final Foo foo : fooList) { + System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); + } + } + + @Test + public final void whenHQlSortingByMultipleAttributes_andOrderDirection_thenPrintSortedResults() { + final String hql = "FROM Foo f ORDER BY f.name DESC, f.id ASC"; + final Query query = session.createQuery(hql); + final List fooList = query.list(); + for (final Foo foo : fooList) { + System.out.println("Name: " + foo.getName() + ", Id: " + foo.getId()); + } + } + + @Test + public final void whenHQLCriteriaSortingByOneAttr_thenPrintSortedResults() { + final Criteria criteria = session.createCriteria(Foo.class, "FOO"); + criteria.addOrder(Order.asc("id")); + final List fooList = criteria.list(); + for (final Foo foo : fooList) { + System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); + } + } + + @Test + public final void whenHQLCriteriaSortingByMultipAttr_thenSortedResults() { + final Criteria criteria = session.createCriteria(Foo.class, "FOO"); + criteria.addOrder(Order.asc("name")); + criteria.addOrder(Order.asc("id")); + final List fooList = criteria.list(); + for (final Foo foo : fooList) { + System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); + } + } + + @Test + public final void whenCriteriaSortingStringNullsLastAsc_thenNullsLast() { + final Criteria criteria = session.createCriteria(Foo.class, "FOO"); + criteria.addOrder(Order.asc("name").nulls(NullPrecedence.LAST)); + final List fooList = criteria.list(); + assertNull(fooList.get(fooList.toArray().length - 1).getName()); + for (final Foo foo : fooList) { + System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); + } + } + + @Test + public final void whenCriteriaSortingStringNullsFirstDesc_thenNullsFirst() { + final Criteria criteria = session.createCriteria(Foo.class, "FOO"); + criteria.addOrder(Order.desc("name").nulls(NullPrecedence.FIRST)); + final List fooList = criteria.list(); + assertNull(fooList.get(0).getName()); + for (final Foo foo : fooList) { + System.out.println("Id: " + foo.getId() + ", FirstName: " + foo.getName()); + } + } + + @Test + public final void whenSortingBars_thenBarsWithSortedFoos() { + final String hql = "FROM Bar b ORDER BY b.id"; + final Query query = session.createQuery(hql); + final List barList = query.list(); + for (final Bar bar : barList) { + final Set fooSet = bar.getFooSet(); + System.out.println("Bar Id:" + bar.getId()); + for (final Foo foo : fooSet) { + System.out.println("FooName:" + foo.getName()); + } + } + } + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/service/FooServiceBasicPersistenceIntegrationTest.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/service/FooServiceBasicPersistenceIntegrationTest.java new file mode 100644 index 0000000000..146f8e9622 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/service/FooServiceBasicPersistenceIntegrationTest.java @@ -0,0 +1,55 @@ +package com.baeldung.persistence.service; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; + +import org.hibernate.Session; +import org.hibernate.SessionFactory; +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.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +import com.baeldung.persistence.model.Foo; +import com.baeldung.spring.config.PersistenceTestConfig; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PersistenceTestConfig.class }, loader = AnnotationConfigContextLoader.class) +public class FooServiceBasicPersistenceIntegrationTest { + + @Autowired + private SessionFactory sessionFactory; + + @Autowired + private IFooService fooService; + + private Session session; + + // tests + + @Before + public final void before() { + session = sessionFactory.openSession(); + } + + @After + public final void after() { + session.close(); + } + + // tests + + @Test + public final void whenContextIsBootstrapped_thenNoExceptions() { + // + } + + @Test + public final void whenEntityIsCreated_thenNoExceptions() { + fooService.create(new Foo(randomAlphabetic(6))); + } + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java new file mode 100644 index 0000000000..6d426849a6 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java @@ -0,0 +1,64 @@ +package com.baeldung.persistence.service; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.dao.DataAccessException; +import org.springframework.dao.DataIntegrityViolationException; +import org.springframework.dao.InvalidDataAccessApiUsageException; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +import com.baeldung.persistence.model.Foo; +import com.baeldung.spring.config.PersistenceTestConfig; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PersistenceTestConfig.class }, loader = AnnotationConfigContextLoader.class) +public class FooServicePersistenceIntegrationTest { + + @Autowired + @Qualifier("fooHibernateService") + private IFooService service; + + // tests + + @Test + public final void whenContextIsBootstrapped_thenNoExceptions() { + // + } + + @Test + public final void whenEntityIsCreated_thenNoExceptions() { + service.create(new Foo(randomAlphabetic(6))); + } + + @Test(expected = DataIntegrityViolationException.class) + @Ignore("work in progress") + public final void whenInvalidEntityIsCreated_thenDataException() { + service.create(new Foo()); + } + + @Test(expected = DataIntegrityViolationException.class) + public final void whenEntityWithLongNameIsCreated_thenDataException() { + service.create(new Foo(randomAlphabetic(2048))); + } + + @Test(expected = InvalidDataAccessApiUsageException.class) + @Ignore("Right now, persist has saveOrUpdate semantics, so this will no longer fail") + public final void whenSameEntityIsCreatedTwice_thenDataException() { + final Foo entity = new Foo(randomAlphabetic(8)); + service.create(entity); + service.create(entity); + } + + @Test(expected = DataAccessException.class) + public final void temp_whenInvalidEntityIsCreated_thenDataException() { + service.create(new Foo(randomAlphabetic(2048))); + } + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/service/FooStoredProceduresLiveTest.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/service/FooStoredProceduresLiveTest.java new file mode 100644 index 0000000000..8bf33c4110 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/service/FooStoredProceduresLiveTest.java @@ -0,0 +1,121 @@ +package com.baeldung.persistence.service; + +import java.util.List; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import static org.junit.Assert.assertEquals; + +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.exception.SQLGrammarException; +import org.junit.After; +import org.junit.Assume; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +import com.baeldung.config.PersistenceConfig; +import com.baeldung.persistence.model.Foo; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) +public class FooStoredProceduresLiveTest { + + private static final Logger LOGGER = LoggerFactory.getLogger(FooStoredProceduresLiveTest.class); + + @Autowired + private SessionFactory sessionFactory; + + @Autowired + private IFooService fooService; + + private Session session; + + @Before + public final void before() { + session = sessionFactory.openSession(); + Assume.assumeTrue(getAllFoosExists()); + Assume.assumeTrue(getFoosByNameExists()); + } + + private boolean getFoosByNameExists() { + try { + Query sqlQuery = session.createSQLQuery("CALL GetAllFoos()").addEntity(Foo.class); + sqlQuery.list(); + return true; + } catch (SQLGrammarException e) { + LOGGER.error("WARNING : GetFoosByName() Procedure is may be missing ", e); + return false; + } + } + + private boolean getAllFoosExists() { + try { + Query sqlQuery = session.createSQLQuery("CALL GetAllFoos()").addEntity(Foo.class); + sqlQuery.list(); + return true; + } catch (SQLGrammarException e) { + LOGGER.error("WARNING : GetAllFoos() Procedure is may be missing ", e); + return false; + } + } + + @After + public final void after() { + session.close(); + } + + @Test + public final void getAllFoosUsingStoredProcedures() { + + fooService.create(new Foo(randomAlphabetic(6))); + + // Stored procedure getAllFoos using createSQLQuery + Query sqlQuery = session.createSQLQuery("CALL GetAllFoos()").addEntity(Foo.class); + @SuppressWarnings("unchecked") + List allFoos = sqlQuery.list(); + for (Foo foo : allFoos) { + LOGGER.info("getAllFoos() SQL Query result : {}", foo.getName()); + } + assertEquals(allFoos.size(), fooService.findAll().size()); + + // Stored procedure getAllFoos using a Named Query + Query namedQuery = session.getNamedQuery("callGetAllFoos"); + @SuppressWarnings("unchecked") + List allFoos2 = namedQuery.list(); + for (Foo foo : allFoos2) { + LOGGER.info("getAllFoos() NamedQuery result : {}", foo.getName()); + } + assertEquals(allFoos2.size(), fooService.findAll().size()); + } + + @Test + public final void getFoosByNameUsingStoredProcedures() { + + fooService.create(new Foo("NewFooName")); + + // Stored procedure getFoosByName using createSQLQuery() + Query sqlQuery = session.createSQLQuery("CALL GetFoosByName(:fooName)").addEntity(Foo.class).setParameter("fooName", "NewFooName"); + @SuppressWarnings("unchecked") + List allFoosByName = sqlQuery.list(); + for (Foo foo : allFoosByName) { + LOGGER.info("getFoosByName() using SQL Query : found => {}", foo.toString()); + } + + // Stored procedure getFoosByName using getNamedQuery() + Query namedQuery = session.getNamedQuery("callGetFoosByName").setParameter("fooName", "NewFooName"); + @SuppressWarnings("unchecked") + List allFoosByName2 = namedQuery.list(); + for (Foo foo : allFoosByName2) { + LOGGER.info("getFoosByName() using Native Query : found => {}", foo.toString()); + } + + } +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/service/ParentServicePersistenceIntegrationTest.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/service/ParentServicePersistenceIntegrationTest.java new file mode 100644 index 0000000000..5a73e39ca2 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/persistence/service/ParentServicePersistenceIntegrationTest.java @@ -0,0 +1,70 @@ +package com.baeldung.persistence.service; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.dao.DataIntegrityViolationException; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +import com.baeldung.persistence.model.Child; +import com.baeldung.persistence.model.Parent; +import com.baeldung.spring.config.PersistenceTestConfig; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PersistenceTestConfig.class }, loader = AnnotationConfigContextLoader.class) +public class ParentServicePersistenceIntegrationTest { + + @Autowired + private IParentService service; + + @Autowired + private IChildService childService; + + // tests + + @Test + public final void whenContextIsBootstrapped_thenNoExceptions() { + // + } + + @Test + public final void whenOneToOneEntitiesAreCreated_thenNoExceptions() { + final Child childEntity = new Child(); + childService.create(childEntity); + + final Parent parentEntity = new Parent(childEntity); + service.create(parentEntity); + + System.out.println("Child = " + childService.findOne(childEntity.getId())); + System.out.println("Child - parent = " + childService.findOne(childEntity.getId()).getParent()); + + System.out.println("Parent = " + service.findOne(parentEntity.getId())); + System.out.println("Parent - child = " + service.findOne(parentEntity.getId()).getChild()); + } + + @Test(expected = DataIntegrityViolationException.class) + public final void whenChildIsDeletedWhileParentStillHasForeignKeyToIt_thenDataException() { + final Child childEntity = new Child(); + childService.create(childEntity); + + final Parent parentEntity = new Parent(childEntity); + service.create(parentEntity); + + childService.delete(childEntity); + } + + @Test + public final void whenChildIsDeletedAfterTheParent_thenNoExceptions() { + final Child childEntity = new Child(); + childService.create(childEntity); + + final Parent parentEntity = new Parent(childEntity); + service.create(parentEntity); + + service.delete(parentEntity); + childService.delete(childEntity); + } + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/config/PersistenceTestConfig.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/config/PersistenceTestConfig.java new file mode 100644 index 0000000000..34301741fe --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/config/PersistenceTestConfig.java @@ -0,0 +1,179 @@ +package com.baeldung.spring.config; + +import java.util.Properties; + +import javax.sql.DataSource; + +import org.apache.tomcat.dbcp.dbcp2.BasicDataSource; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +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.orm.hibernate5.HibernateTransactionManager; +import org.springframework.orm.hibernate5.LocalSessionFactoryBean; +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 com.baeldung.persistence.dao.IBarAuditableDao; +import com.baeldung.persistence.dao.IBarDao; +import com.baeldung.persistence.dao.IFooAuditableDao; +import com.baeldung.persistence.dao.IFooDao; +import com.baeldung.persistence.dao.impl.BarAuditableDao; +import com.baeldung.persistence.dao.impl.BarDao; +import com.baeldung.persistence.dao.impl.BarJpaDao; +import com.baeldung.persistence.dao.impl.FooAuditableDao; +import com.baeldung.persistence.dao.impl.FooDao; +import com.baeldung.persistence.service.IBarAuditableService; +import com.baeldung.persistence.service.IBarService; +import com.baeldung.persistence.service.IFooAuditableService; +import com.baeldung.persistence.service.IFooService; +import com.baeldung.persistence.service.impl.BarAuditableService; +import com.baeldung.persistence.service.impl.BarJpaService; +import com.baeldung.persistence.service.impl.BarSpringDataJpaService; +import com.baeldung.persistence.service.impl.FooAuditableService; +import com.baeldung.persistence.service.impl.FooService; +import com.google.common.base.Preconditions; + +@Configuration +@EnableTransactionManagement +@EnableJpaRepositories(basePackages = { "com.baeldung.persistence" }, transactionManagerRef = "jpaTransactionManager", entityManagerFactoryRef = "jpaEntityManager") +@EnableJpaAuditing +@PropertySource({ "classpath:persistence-h2.properties" }) +@ComponentScan({ "com.baeldung.persistence" }) +public class PersistenceTestConfig { + + @Autowired + private Environment env; + + public PersistenceTestConfig() { + super(); + } + + @Bean + public LocalSessionFactoryBean sessionFactory() { + final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); + sessionFactory.setDataSource(restDataSource()); + sessionFactory.setPackagesToScan(new String[] { "com.baeldung.persistence.model" }); + sessionFactory.setHibernateProperties(hibernateProperties()); + + return sessionFactory; + } + + @Bean("jpaEntityManager") + public LocalContainerEntityManagerFactoryBean entityManagerFactory() { + final LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean(); + emf.setDataSource(restDataSource()); + emf.setPackagesToScan(new String[] { "com.baeldung.persistence.model" }); + + final JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); + emf.setJpaVendorAdapter(vendorAdapter); + emf.setJpaProperties(hibernateProperties()); + + return emf; + } + + @Bean + public DataSource restDataSource() { + final BasicDataSource dataSource = new BasicDataSource(); + 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 hibernateTransactionManager() { + final HibernateTransactionManager transactionManager = new HibernateTransactionManager(); + transactionManager.setSessionFactory(sessionFactory().getObject()); + return transactionManager; + } + + @Bean + public PlatformTransactionManager jpaTransactionManager() { + final JpaTransactionManager transactionManager = new JpaTransactionManager(); + transactionManager.setEntityManagerFactory(entityManagerFactory().getObject()); + return transactionManager; + } + + @Bean + public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { + return new PersistenceExceptionTranslationPostProcessor(); + } + + @Bean + public IBarService barJpaService() { + return new BarJpaService(); + } + + @Bean + public IBarService barSpringDataJpaService() { + return new BarSpringDataJpaService(); + } + + @Bean + public IFooService fooHibernateService() { + return new FooService(); + } + + @Bean + public IBarAuditableService barHibernateAuditableService() { + return new BarAuditableService(); + } + + @Bean + public IFooAuditableService fooHibernateAuditableService() { + return new FooAuditableService(); + } + + @Bean + public IBarDao barJpaDao() { + return new BarJpaDao(); + } + + @Bean + public IBarDao barHibernateDao() { + return new BarDao(); + } + + @Bean + public IBarAuditableDao barHibernateAuditableDao() { + return new BarAuditableDao(); + } + + @Bean + public IFooDao fooHibernateDao() { + return new FooDao(); + } + + @Bean + public IFooAuditableDao fooHibernateAuditableDao() { + return new FooAuditableDao(); + } + + 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-query-2/src/test/java/com/baeldung/spring/data/jpa/query/datetime/ArticleRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/datetime/ArticleRepositoryIntegrationTest.java index 38fd804195..b1158b3dae 100644 --- a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/datetime/ArticleRepositoryIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/datetime/ArticleRepositoryIntegrationTest.java @@ -6,6 +6,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.test.context.junit4.SpringRunner; +import com.baeldung.spring.data.jpa.query.datetime.Article; +import com.baeldung.spring.data.jpa.query.datetime.ArticleRepository; + import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.List; diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/resources/fetching.cfg.xml b/persistence-modules/spring-data-jpa-query-2/src/test/resources/fetching.cfg.xml new file mode 100644 index 0000000000..55a3aeb51c --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/test/resources/fetching.cfg.xml @@ -0,0 +1,19 @@ + + + + + + org.h2.Driver + jdbc:h2:mem:testdb + sa + + org.hibernate.dialect.H2Dialect + update + true + + + + + \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/resources/fetchingLazy.cfg.xml b/persistence-modules/spring-data-jpa-query-2/src/test/resources/fetchingLazy.cfg.xml new file mode 100644 index 0000000000..8fcf578660 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/test/resources/fetchingLazy.cfg.xml @@ -0,0 +1,19 @@ + + + + + + org.h2.Driver + jdbc:h2:mem:testdb + sa + + org.hibernate.dialect.H2Dialect + update + true + + + + + \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/resources/persistence-h2.properties b/persistence-modules/spring-data-jpa-query-2/src/test/resources/persistence-h2.properties new file mode 100644 index 0000000000..911619193b --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/test/resources/persistence-h2.properties @@ -0,0 +1,13 @@ +# jdbc.X +jdbc.driverClassName=org.h2.Driver +jdbc.url=jdbc:h2:mem:test +jdbc.user=sa +jdbc.pass= + +# hibernate.X +hibernate.dialect=org.hibernate.dialect.H2Dialect +hibernate.show_sql=false +hibernate.hbm2ddl.auto=create-drop + +# envers.X +envers.audit_table_suffix=_audit_log From 6d9024049e1cdc01f22c77f3d9160cf3d8e0d410 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Mon, 28 Sep 2020 23:18:18 +0530 Subject: [PATCH 235/263] JAVA-2432: Added link to existing article --- persistence-modules/spring-hibernate-5/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/persistence-modules/spring-hibernate-5/README.md b/persistence-modules/spring-hibernate-5/README.md index 6d7526a13b..c7506026dd 100644 --- a/persistence-modules/spring-hibernate-5/README.md +++ b/persistence-modules/spring-hibernate-5/README.md @@ -12,4 +12,5 @@ This module contains articles about Hibernate 5 with Spring. - [Hibernate Second-Level Cache](http://www.baeldung.com/hibernate-second-level-cache) - [Deleting Objects with Hibernate](http://www.baeldung.com/delete-with-hibernate) - [Spring, Hibernate and a JNDI Datasource](http://www.baeldung.com/spring-persistence-jpa-jndi-datasource) -- [@Immutable in Hibernate](http://www.baeldung.com/hibernate-immutable) \ No newline at end of file +- [@Immutable in Hibernate](http://www.baeldung.com/hibernate-immutable) +- [Guide to Hibernate 5 with Spring](https://www.baeldung.com/hibernate-4-spring) \ No newline at end of file From 42141b88891f3b331435a90957e59892ef49861b Mon Sep 17 00:00:00 2001 From: Krzysztof Majewski Date: Tue, 29 Sep 2020 05:30:32 +0200 Subject: [PATCH 236/263] BAEL-4520 Getting Started with jOOQ (#10101) Co-authored-by: Krzysztof Majewski --- .../src/main/java/com/baeldung/jooq/Crud.java | 18 +++++----- .../java/com/baeldung/jooq/CrudExamples.java | 34 +++++++++---------- 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/persistence-modules/jooq/src/main/java/com/baeldung/jooq/Crud.java b/persistence-modules/jooq/src/main/java/com/baeldung/jooq/Crud.java index 0427b71c25..fb3d21c467 100644 --- a/persistence-modules/jooq/src/main/java/com/baeldung/jooq/Crud.java +++ b/persistence-modules/jooq/src/main/java/com/baeldung/jooq/Crud.java @@ -19,14 +19,14 @@ public class Crud { public static Result getAll(DSLContext context, Table table) { return context.select() - .from(table) - .fetch(); + .from(table) + .fetch(); } public static Result getFields(DSLContext context, Table table, SelectFieldOrAsterisk... fields) { return context.select(fields) - .from(table) - .fetch(); + .from(table) + .fetch(); } public static R getOne(DSLContext context, Table table, Condition condition) { @@ -35,9 +35,9 @@ public class Crud { public static void update(DSLContext context, Table table, Map, T> values, Condition condition) { context.update(table) - .set(values) - .where(condition) - .execute(); + .set(values) + .where(condition) + .execute(); } public static > void update(UpdatableRecord record) { @@ -46,8 +46,8 @@ public class Crud { public static void delete(DSLContext context, Table table, Condition condition) { context.delete(table) - .where(condition) - .execute(); + .where(condition) + .execute(); } public static > void delete(UpdatableRecord record) { diff --git a/persistence-modules/jooq/src/main/java/com/baeldung/jooq/CrudExamples.java b/persistence-modules/jooq/src/main/java/com/baeldung/jooq/CrudExamples.java index 87a7b6439e..57f6df4915 100644 --- a/persistence-modules/jooq/src/main/java/com/baeldung/jooq/CrudExamples.java +++ b/persistence-modules/jooq/src/main/java/com/baeldung/jooq/CrudExamples.java @@ -60,8 +60,8 @@ public class CrudExamples { private void readValues(DSLContext context) { Result authors = getAll( - context, - Author.AUTHOR + context, + Author.AUTHOR ); authors.forEach(author -> { @@ -73,15 +73,15 @@ public class CrudExamples { }); Result articles = getFields( - context, - Author.AUTHOR, - Article.ARTICLE.ID, Article.ARTICLE.TITLE + context, + Author.AUTHOR, + Article.ARTICLE.ID, Article.ARTICLE.TITLE ); AuthorRecord author = getOne( - context, - Author.AUTHOR, - Author.AUTHOR.ID.eq(1) + context, + Author.AUTHOR, + Author.AUTHOR.ID.eq(1) ); } @@ -90,24 +90,22 @@ public class CrudExamples { fieldsToUpdate.put(Author.AUTHOR.FIRST_NAME, "David"); fieldsToUpdate.put(Author.AUTHOR.LAST_NAME, "Brown"); update( - context, - Author.AUTHOR, - fieldsToUpdate, - Author.AUTHOR.ID.eq(1) + context, + Author.AUTHOR, + fieldsToUpdate, + Author.AUTHOR.ID.eq(1) ); ArticleRecord article = context.fetchOne(Article.ARTICLE, Article.ARTICLE.ID.eq(1)); article.setTitle("A New Article Title"); - update( - article - ); + update(article); } private void deleteValues(DSLContext context) { delete( - context, - Article.ARTICLE, - Article.ARTICLE.ID.eq(1) + context, + Article.ARTICLE, + Article.ARTICLE.ID.eq(1) ); AuthorRecord author = context.fetchOne(Author.AUTHOR, Author.AUTHOR.ID.eq(1)); From 154a23d9d968933ba697525457f9ffb3ffbfbec8 Mon Sep 17 00:00:00 2001 From: Krzysztof Majewski Date: Tue, 29 Sep 2020 05:32:37 +0200 Subject: [PATCH 237/263] BAEL-3997 (#10102) * BAEL-3997 Verify Working with Date Parameters in Spring app level config * rename properties Co-authored-by: Krzysztof Majewski --- .../com/baeldung/datetime/DateTimeConfig.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/spring-mvc-java-2/src/main/java/com/baeldung/datetime/DateTimeConfig.java b/spring-mvc-java-2/src/main/java/com/baeldung/datetime/DateTimeConfig.java index 8a5d1c71af..c89b043486 100644 --- a/spring-mvc-java-2/src/main/java/com/baeldung/datetime/DateTimeConfig.java +++ b/spring-mvc-java-2/src/main/java/com/baeldung/datetime/DateTimeConfig.java @@ -2,28 +2,35 @@ package com.baeldung.datetime; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.format.datetime.DateFormatter; +import org.springframework.format.datetime.DateFormatterRegistrar; import org.springframework.format.datetime.standard.DateTimeFormatterRegistrar; import org.springframework.format.number.NumberFormatAnnotationFormatterFactory; import org.springframework.format.support.DefaultFormattingConversionService; import org.springframework.format.support.FormattingConversionService; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; import java.time.format.DateTimeFormatter; @Configuration -class DateTimeConfig { +public class DateTimeConfig extends WebMvcConfigurationSupport { @Bean - public FormattingConversionService conversionService() { + @Override + public FormattingConversionService mvcConversionService() { DefaultFormattingConversionService conversionService = new DefaultFormattingConversionService(false); conversionService.addFormatterForFieldAnnotation(new NumberFormatAnnotationFormatterFactory()); - DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); - registrar.setDateFormatter(DateTimeFormatter.ofPattern("dd.MM.yyyy")); - registrar.setDateTimeFormatter(DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm:ss")); - registrar.registerFormatters(conversionService); + DateTimeFormatterRegistrar dateTimeRegistrar = new DateTimeFormatterRegistrar(); + dateTimeRegistrar.setDateFormatter(DateTimeFormatter.ofPattern("dd.MM.yyyy")); + dateTimeRegistrar.setDateTimeFormatter(DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm:ss")); + dateTimeRegistrar.registerFormatters(conversionService); + + DateFormatterRegistrar dateRegistrar = new DateFormatterRegistrar(); + dateRegistrar.setFormatter(new DateFormatter("dd.MM.yyyy")); + dateRegistrar.registerFormatters(conversionService); return conversionService; } - } \ No newline at end of file From 92bd1bbae6c75938ff8286671b6195a274ccd24a Mon Sep 17 00:00:00 2001 From: kwoyke Date: Tue, 29 Sep 2020 14:54:05 +0200 Subject: [PATCH 238/263] BAEL-2626: Update Feign to 10.11 (#10105) --- feign/pom.xml | 20 +------------------ .../feign/clients/BookClientLiveTest.java | 3 --- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/feign/pom.xml b/feign/pom.xml index 4b994be1f2..da3cbcb0fd 100644 --- a/feign/pom.xml +++ b/feign/pom.xml @@ -16,11 +16,6 @@ - - io.github.openfeign - feign-core - ${feign.version} - io.github.openfeign feign-okhttp @@ -44,21 +39,8 @@ - - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring-boot-maven-plugin.version} - - - - - - 9.4.0 - 1.4.2.RELEASE + 10.11 diff --git a/feign/src/test/java/com/baeldung/feign/clients/BookClientLiveTest.java b/feign/src/test/java/com/baeldung/feign/clients/BookClientLiveTest.java index bee440bd9e..6f6666de32 100644 --- a/feign/src/test/java/com/baeldung/feign/clients/BookClientLiveTest.java +++ b/feign/src/test/java/com/baeldung/feign/clients/BookClientLiveTest.java @@ -6,8 +6,6 @@ import com.baeldung.feign.models.BookResource; import lombok.extern.slf4j.Slf4j; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; import java.util.List; import java.util.UUID; @@ -22,7 +20,6 @@ import static org.junit.Assert.assertTrue; * Consumes https://github.com/Baeldung/spring-hypermedia-api */ @Slf4j -@RunWith(JUnit4.class) public class BookClientLiveTest { private BookClient bookClient; From 2f8478db349260fc51b143972b72367af579a3c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20G=C5=82=C3=B3wka?= Date: Tue, 29 Sep 2020 19:12:16 +0200 Subject: [PATCH 239/263] BAEL-4446: Getting cookies from httpclient response example (#10104) --- .../HttpClientGettingCookieValueUnitTest.java | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 httpclient-2/src/test/java/com/baeldung/httpclient/cookies/HttpClientGettingCookieValueUnitTest.java diff --git a/httpclient-2/src/test/java/com/baeldung/httpclient/cookies/HttpClientGettingCookieValueUnitTest.java b/httpclient-2/src/test/java/com/baeldung/httpclient/cookies/HttpClientGettingCookieValueUnitTest.java new file mode 100644 index 0000000000..c3b0ef3c25 --- /dev/null +++ b/httpclient-2/src/test/java/com/baeldung/httpclient/cookies/HttpClientGettingCookieValueUnitTest.java @@ -0,0 +1,54 @@ +package com.baeldung.httpclient.cookies; + +import org.apache.http.client.CookieStore; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.protocol.HttpClientContext; +import org.apache.http.cookie.Cookie; +import org.apache.http.impl.client.BasicCookieStore; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.impl.cookie.BasicClientCookie; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; + +import static org.junit.Assert.assertEquals; + + +public class HttpClientGettingCookieValueUnitTest { + private static Logger log = LoggerFactory.getLogger(HttpClientGettingCookieValueUnitTest.class); + + private static final String SAMPLE_URL = "http://www.baeldung.com/"; + + @Test + public final void whenSettingCustomCookieOnTheRequest_thenGettingTheSameCookieFromTheResponse() throws IOException { + HttpClientContext context = HttpClientContext.create(); + context.setAttribute(HttpClientContext.COOKIE_STORE, createCustomCookieStore()); + + try (CloseableHttpClient httpClient = HttpClients.createDefault()) { + try (CloseableHttpResponse response = httpClient.execute(new HttpGet(SAMPLE_URL), context)) { + CookieStore cookieStore = context.getCookieStore(); + Cookie customCookie = cookieStore.getCookies() + .stream() + .peek(cookie -> log.info("cookie name:{}", cookie.getName())) + .filter(cookie -> "custom_cookie".equals(cookie.getName())) + .findFirst() + .orElseThrow(IllegalStateException::new); + + assertEquals("test_value", customCookie.getValue()); + } + } + } + + private BasicCookieStore createCustomCookieStore() { + BasicCookieStore cookieStore = new BasicCookieStore(); + BasicClientCookie cookie = new BasicClientCookie("custom_cookie", "test_value"); + cookie.setDomain("baeldung.com"); + cookie.setPath("/"); + cookieStore.addCookie(cookie); + return cookieStore; + } +} From fc1964251c6115574ed0f45bf3deb79687b3632c Mon Sep 17 00:00:00 2001 From: Dhawal Kapil Date: Wed, 30 Sep 2020 19:19:44 +0530 Subject: [PATCH 240/263] JAVA-2432 Move articles out of spring-hibernate4 Removed legacy hibernate-4-spring article --- persistence-modules/spring-hibernate-5/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/persistence-modules/spring-hibernate-5/README.md b/persistence-modules/spring-hibernate-5/README.md index c7506026dd..cb227592f6 100644 --- a/persistence-modules/spring-hibernate-5/README.md +++ b/persistence-modules/spring-hibernate-5/README.md @@ -13,4 +13,3 @@ This module contains articles about Hibernate 5 with Spring. - [Deleting Objects with Hibernate](http://www.baeldung.com/delete-with-hibernate) - [Spring, Hibernate and a JNDI Datasource](http://www.baeldung.com/spring-persistence-jpa-jndi-datasource) - [@Immutable in Hibernate](http://www.baeldung.com/hibernate-immutable) -- [Guide to Hibernate 5 with Spring](https://www.baeldung.com/hibernate-4-spring) \ No newline at end of file From 5a8f42080742d63dac7d74dae390be440cc89585 Mon Sep 17 00:00:00 2001 From: Sampada <46674082+sampada07@users.noreply.github.com> Date: Wed, 30 Sep 2020 21:08:21 +0530 Subject: [PATCH 241/263] BAEL-4075: Validating phone number with libphonenumber (#10111) * BAEL-4075: Validating phone number with libphonenumber * BAEL-4075: Validating phone number with libphonenumber --- libraries-6/pom.xml | 7 ++ .../LibPhoneNumberUnitTest.java | 79 +++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 libraries-6/src/test/java/com/baeldung/libphonenumber/LibPhoneNumberUnitTest.java diff --git a/libraries-6/pom.xml b/libraries-6/pom.xml index 2f8cc385cb..7bb6028f17 100644 --- a/libraries-6/pom.xml +++ b/libraries-6/pom.xml @@ -107,6 +107,12 @@ renjin-script-engine ${renjin.version} + + + com.googlecode.libphonenumber + libphonenumber + ${libphonenumber.version} + @@ -150,6 +156,7 @@ RELEASE 3.0 1.8.1 + 8.12.9 diff --git a/libraries-6/src/test/java/com/baeldung/libphonenumber/LibPhoneNumberUnitTest.java b/libraries-6/src/test/java/com/baeldung/libphonenumber/LibPhoneNumberUnitTest.java new file mode 100644 index 0000000000..39b96b3e38 --- /dev/null +++ b/libraries-6/src/test/java/com/baeldung/libphonenumber/LibPhoneNumberUnitTest.java @@ -0,0 +1,79 @@ +package com.baeldung.libphonenumber; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +import com.google.i18n.phonenumbers.NumberParseException; +import com.google.i18n.phonenumbers.PhoneNumberUtil; +import com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberType; +import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber; +import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber.CountryCodeSource; + +public class LibPhoneNumberUnitTest { + + private static final PhoneNumberUtil phoneNumberUtil = PhoneNumberUtil.getInstance(); + + @Test + public void givenPhoneNumber_whenValid_thenOK() throws Exception { + + PhoneNumber phone = phoneNumberUtil.parse("+911234567890", CountryCodeSource.UNSPECIFIED.name()); + + assertTrue(phoneNumberUtil.isValidNumber(phone)); + assertTrue(phoneNumberUtil.isValidNumberForRegion(phone, "IN")); + assertFalse(phoneNumberUtil.isValidNumberForRegion(phone, "US")); + assertTrue(phoneNumberUtil.isValidNumber(phoneNumberUtil.getExampleNumber("IN"))); + } + + @Test + public void givenPhoneNumber_whenAlphaNumber_thenValid() { + assertTrue(phoneNumberUtil.isAlphaNumber("325-CARS")); + assertTrue(phoneNumberUtil.isAlphaNumber("0800 REPAIR")); + assertTrue(phoneNumberUtil.isAlphaNumber("1-800-MY-APPLE")); + assertTrue(phoneNumberUtil.isAlphaNumber("1-800-MY-APPLE..")); + assertFalse(phoneNumberUtil.isAlphaNumber("+876 1234-1234")); + } + + @Test + public void givenPhoneNumber_whenPossibleForType_thenValid() { + PhoneNumber number = new PhoneNumber(); + number.setCountryCode(54); + + number.setNationalNumber(123456); + assertTrue(phoneNumberUtil.isPossibleNumberForType(number, PhoneNumberType.FIXED_LINE)); + assertFalse(phoneNumberUtil.isPossibleNumberForType(number, PhoneNumberType.TOLL_FREE)); + + number.setNationalNumber(12345678901L); + assertFalse(phoneNumberUtil.isPossibleNumberForType(number, PhoneNumberType.FIXED_LINE)); + assertTrue(phoneNumberUtil.isPossibleNumberForType(number, PhoneNumberType.MOBILE)); + assertFalse(phoneNumberUtil.isPossibleNumberForType(number, PhoneNumberType.TOLL_FREE)); + } + + @Test + public void givenPhoneNumber_whenPossible_thenValid() { + PhoneNumber number = new PhoneNumber(); + number.setCountryCode(1) + .setNationalNumber(123000L); + assertFalse(phoneNumberUtil.isPossibleNumber(number)); + assertFalse(phoneNumberUtil.isPossibleNumber("+1 343 253 00000", "US")); + assertFalse(phoneNumberUtil.isPossibleNumber("(343) 253-00000", "US")); + assertFalse(phoneNumberUtil.isPossibleNumber("dial p for pizza", "US")); + assertFalse(phoneNumberUtil.isPossibleNumber("123-000", "US")); + } + + @Test + public void givenPhoneNumber_whenNumberGeographical_thenValid() throws NumberParseException { + + PhoneNumber phone = phoneNumberUtil.parse("+911234567890", "IN"); + assertTrue(phoneNumberUtil.isNumberGeographical(phone)); + + phone = new PhoneNumber().setCountryCode(1) + .setNationalNumber(2530000L); + assertFalse(phoneNumberUtil.isNumberGeographical(phone)); + + phone = new PhoneNumber().setCountryCode(800) + .setNationalNumber(12345678L); + assertFalse(phoneNumberUtil.isNumberGeographical(phone)); + } +} From 3dddb550b63ab5725ad0ac0d588dd7f55bb87772 Mon Sep 17 00:00:00 2001 From: psevestre Date: Thu, 1 Oct 2020 17:13:15 -0300 Subject: [PATCH 242/263] [BAEL-4204] JNA (#10113) * [BAEL-4203] JNA * [BAEL-4203] JNA --- {jni => java-native}/README.md | 0 java-native/pom.xml | 39 +++++++++++++++ .../com_baeldung_jni_ExampleObjectsJNI.cpp | 0 .../cpp/com_baeldung_jni_ExampleObjectsJNI.h | 0 .../com_baeldung_jni_ExampleParametersJNI.cpp | 0 .../com_baeldung_jni_ExampleParametersJNI.h | 0 .../cpp/com_baeldung_jni_HelloWorldJNI.cpp | 0 .../main/cpp/com_baeldung_jni_HelloWorldJNI.h | 0 .../src/main/cpp/generateNativeLib.bat | 0 .../src/main/cpp/generateNativeLib.sh | 0 .../src/main/cpp/generateNativeLibMac.sh | 0 .../src/main/java/com/baeldung/jna/CMath.java | 10 ++++ .../src/main/java/com/baeldung/jna/Main.java | 8 +++ .../main/java/com/baeldung/jna/NativeFS.java | 46 +++++++++++++++++ .../src/main/java/com/baeldung/jna/StdC.java | 17 +++++++ .../com/baeldung/jni/ExampleObjectsJNI.java | 0 .../baeldung/jni/ExampleParametersJNI.java | 0 .../java/com/baeldung/jni/HelloWorldJNI.java | 0 .../main/java/com/baeldung/jni/UserData.java | 0 .../src/main/resources/logback.xml | 0 .../java/com/baeldung/jna/CMathUnitTest.java | 18 +++++++ .../com/baeldung/jna/NativeFSUnitTest.java | 38 ++++++++++++++ .../java/com/baeldung/jna/StdCUnitTest.java | 47 ++++++++++++++++++ .../com/baeldung/jni/JNINativeManualTest.java | 0 jni/native/linux_x86_64/libnative.so | Bin 19856 -> 0 bytes jni/native/macos/libnative.dylib | Bin 23056 -> 0 bytes jni/pom.xml | 14 ------ pom.xml | 4 +- 28 files changed, 225 insertions(+), 16 deletions(-) rename {jni => java-native}/README.md (100%) create mode 100644 java-native/pom.xml rename {jni => java-native}/src/main/cpp/com_baeldung_jni_ExampleObjectsJNI.cpp (100%) rename {jni => java-native}/src/main/cpp/com_baeldung_jni_ExampleObjectsJNI.h (100%) rename {jni => java-native}/src/main/cpp/com_baeldung_jni_ExampleParametersJNI.cpp (100%) rename {jni => java-native}/src/main/cpp/com_baeldung_jni_ExampleParametersJNI.h (100%) rename {jni => java-native}/src/main/cpp/com_baeldung_jni_HelloWorldJNI.cpp (100%) rename {jni => java-native}/src/main/cpp/com_baeldung_jni_HelloWorldJNI.h (100%) rename {jni => java-native}/src/main/cpp/generateNativeLib.bat (100%) rename {jni => java-native}/src/main/cpp/generateNativeLib.sh (100%) mode change 100755 => 100644 rename {jni => java-native}/src/main/cpp/generateNativeLibMac.sh (100%) mode change 100755 => 100644 create mode 100644 java-native/src/main/java/com/baeldung/jna/CMath.java create mode 100644 java-native/src/main/java/com/baeldung/jna/Main.java create mode 100644 java-native/src/main/java/com/baeldung/jna/NativeFS.java create mode 100644 java-native/src/main/java/com/baeldung/jna/StdC.java rename {jni => java-native}/src/main/java/com/baeldung/jni/ExampleObjectsJNI.java (100%) rename {jni => java-native}/src/main/java/com/baeldung/jni/ExampleParametersJNI.java (100%) rename {jni => java-native}/src/main/java/com/baeldung/jni/HelloWorldJNI.java (100%) rename {jni => java-native}/src/main/java/com/baeldung/jni/UserData.java (100%) rename {jni => java-native}/src/main/resources/logback.xml (100%) create mode 100644 java-native/src/test/java/com/baeldung/jna/CMathUnitTest.java create mode 100644 java-native/src/test/java/com/baeldung/jna/NativeFSUnitTest.java create mode 100644 java-native/src/test/java/com/baeldung/jna/StdCUnitTest.java rename {jni => java-native}/src/test/java/com/baeldung/jni/JNINativeManualTest.java (100%) delete mode 100755 jni/native/linux_x86_64/libnative.so delete mode 100755 jni/native/macos/libnative.dylib delete mode 100644 jni/pom.xml diff --git a/jni/README.md b/java-native/README.md similarity index 100% rename from jni/README.md rename to java-native/README.md diff --git a/java-native/pom.xml b/java-native/pom.xml new file mode 100644 index 0000000000..29fc13b8d8 --- /dev/null +++ b/java-native/pom.xml @@ -0,0 +1,39 @@ + + + 4.0.0 + java-native + java-native + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + 5.6.0 + + + + + net.java.dev.jna + jna-platform + ${jna.version} + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + false + + + + + \ No newline at end of file diff --git a/jni/src/main/cpp/com_baeldung_jni_ExampleObjectsJNI.cpp b/java-native/src/main/cpp/com_baeldung_jni_ExampleObjectsJNI.cpp similarity index 100% rename from jni/src/main/cpp/com_baeldung_jni_ExampleObjectsJNI.cpp rename to java-native/src/main/cpp/com_baeldung_jni_ExampleObjectsJNI.cpp diff --git a/jni/src/main/cpp/com_baeldung_jni_ExampleObjectsJNI.h b/java-native/src/main/cpp/com_baeldung_jni_ExampleObjectsJNI.h similarity index 100% rename from jni/src/main/cpp/com_baeldung_jni_ExampleObjectsJNI.h rename to java-native/src/main/cpp/com_baeldung_jni_ExampleObjectsJNI.h diff --git a/jni/src/main/cpp/com_baeldung_jni_ExampleParametersJNI.cpp b/java-native/src/main/cpp/com_baeldung_jni_ExampleParametersJNI.cpp similarity index 100% rename from jni/src/main/cpp/com_baeldung_jni_ExampleParametersJNI.cpp rename to java-native/src/main/cpp/com_baeldung_jni_ExampleParametersJNI.cpp diff --git a/jni/src/main/cpp/com_baeldung_jni_ExampleParametersJNI.h b/java-native/src/main/cpp/com_baeldung_jni_ExampleParametersJNI.h similarity index 100% rename from jni/src/main/cpp/com_baeldung_jni_ExampleParametersJNI.h rename to java-native/src/main/cpp/com_baeldung_jni_ExampleParametersJNI.h diff --git a/jni/src/main/cpp/com_baeldung_jni_HelloWorldJNI.cpp b/java-native/src/main/cpp/com_baeldung_jni_HelloWorldJNI.cpp similarity index 100% rename from jni/src/main/cpp/com_baeldung_jni_HelloWorldJNI.cpp rename to java-native/src/main/cpp/com_baeldung_jni_HelloWorldJNI.cpp diff --git a/jni/src/main/cpp/com_baeldung_jni_HelloWorldJNI.h b/java-native/src/main/cpp/com_baeldung_jni_HelloWorldJNI.h similarity index 100% rename from jni/src/main/cpp/com_baeldung_jni_HelloWorldJNI.h rename to java-native/src/main/cpp/com_baeldung_jni_HelloWorldJNI.h diff --git a/jni/src/main/cpp/generateNativeLib.bat b/java-native/src/main/cpp/generateNativeLib.bat similarity index 100% rename from jni/src/main/cpp/generateNativeLib.bat rename to java-native/src/main/cpp/generateNativeLib.bat diff --git a/jni/src/main/cpp/generateNativeLib.sh b/java-native/src/main/cpp/generateNativeLib.sh old mode 100755 new mode 100644 similarity index 100% rename from jni/src/main/cpp/generateNativeLib.sh rename to java-native/src/main/cpp/generateNativeLib.sh diff --git a/jni/src/main/cpp/generateNativeLibMac.sh b/java-native/src/main/cpp/generateNativeLibMac.sh old mode 100755 new mode 100644 similarity index 100% rename from jni/src/main/cpp/generateNativeLibMac.sh rename to java-native/src/main/cpp/generateNativeLibMac.sh diff --git a/java-native/src/main/java/com/baeldung/jna/CMath.java b/java-native/src/main/java/com/baeldung/jna/CMath.java new file mode 100644 index 0000000000..3ab5bdf48b --- /dev/null +++ b/java-native/src/main/java/com/baeldung/jna/CMath.java @@ -0,0 +1,10 @@ +package com.baeldung.jna; + +import com.sun.jna.Library; +import com.sun.jna.Native; +import com.sun.jna.Platform; + +public interface CMath extends Library { + CMath INSTANCE = Native.load(Platform.isWindows() ? "msvcrt" : "c", CMath.class); + double cosh(double value); +} diff --git a/java-native/src/main/java/com/baeldung/jna/Main.java b/java-native/src/main/java/com/baeldung/jna/Main.java new file mode 100644 index 0000000000..a81c878cde --- /dev/null +++ b/java-native/src/main/java/com/baeldung/jna/Main.java @@ -0,0 +1,8 @@ +package com.baeldung.jna; + +public class Main { + + public static void main(String[] args) { + + } +} \ No newline at end of file diff --git a/java-native/src/main/java/com/baeldung/jna/NativeFS.java b/java-native/src/main/java/com/baeldung/jna/NativeFS.java new file mode 100644 index 0000000000..58f2bda035 --- /dev/null +++ b/java-native/src/main/java/com/baeldung/jna/NativeFS.java @@ -0,0 +1,46 @@ +package com.baeldung.jna; + +import java.util.Collections; +import java.util.Map; + +import com.sun.jna.FunctionMapper; +import com.sun.jna.LastErrorException; +import com.sun.jna.Library; +import com.sun.jna.Native; +import com.sun.jna.NativeLong; +import com.sun.jna.Platform; +import com.sun.jna.Structure; +import com.sun.jna.Structure.FieldOrder; + +public interface NativeFS extends Library { + + FunctionMapper mapper = (library,method) -> { + if (Platform.isWindows()) { + return "_" + method.getName(); + } + else { + return "__x" + method.getName(); // On Linux, stat is actually _xstat + } + }; + + public NativeFS INSTANCE = Native.load(Platform.isWindows() ? "msvcrt" : "c", + NativeFS.class, + Collections.singletonMap(Library.OPTION_FUNCTION_MAPPER, mapper)); + + int stat(String path, Stat stat) throws LastErrorException; + + @FieldOrder({"st_dev","st_ino","st_mode","st_nlink","st_uid","st_gid","st_rdev","st_size","st_atime","st_mtime","st_ctime"}) + public class Stat extends Structure { + public int st_dev; + public int st_ino; + public short st_mode; + public short st_nlink; + public short st_uid; + public short st_gid; + public int st_rdev; + public NativeLong st_size; + public NativeLong st_atime; + public NativeLong st_mtime; + public NativeLong st_ctime; + } +} diff --git a/java-native/src/main/java/com/baeldung/jna/StdC.java b/java-native/src/main/java/com/baeldung/jna/StdC.java new file mode 100644 index 0000000000..1adbe684c4 --- /dev/null +++ b/java-native/src/main/java/com/baeldung/jna/StdC.java @@ -0,0 +1,17 @@ +package com.baeldung.jna; + +import com.sun.jna.LastErrorException; +import com.sun.jna.Library; +import com.sun.jna.Native; +import com.sun.jna.Platform; +import com.sun.jna.Pointer; + +public interface StdC extends Library { + StdC INSTANCE = Native.load(Platform.isWindows() ? "msvcrt" : "c", StdC.class ); + Pointer malloc(long n); + void free(Pointer p); + Pointer memset(Pointer p, int c, long n); + int open(String path, int flags) throws LastErrorException; + int close(int fd) throws LastErrorException; +} + diff --git a/jni/src/main/java/com/baeldung/jni/ExampleObjectsJNI.java b/java-native/src/main/java/com/baeldung/jni/ExampleObjectsJNI.java similarity index 100% rename from jni/src/main/java/com/baeldung/jni/ExampleObjectsJNI.java rename to java-native/src/main/java/com/baeldung/jni/ExampleObjectsJNI.java diff --git a/jni/src/main/java/com/baeldung/jni/ExampleParametersJNI.java b/java-native/src/main/java/com/baeldung/jni/ExampleParametersJNI.java similarity index 100% rename from jni/src/main/java/com/baeldung/jni/ExampleParametersJNI.java rename to java-native/src/main/java/com/baeldung/jni/ExampleParametersJNI.java diff --git a/jni/src/main/java/com/baeldung/jni/HelloWorldJNI.java b/java-native/src/main/java/com/baeldung/jni/HelloWorldJNI.java similarity index 100% rename from jni/src/main/java/com/baeldung/jni/HelloWorldJNI.java rename to java-native/src/main/java/com/baeldung/jni/HelloWorldJNI.java diff --git a/jni/src/main/java/com/baeldung/jni/UserData.java b/java-native/src/main/java/com/baeldung/jni/UserData.java similarity index 100% rename from jni/src/main/java/com/baeldung/jni/UserData.java rename to java-native/src/main/java/com/baeldung/jni/UserData.java diff --git a/jni/src/main/resources/logback.xml b/java-native/src/main/resources/logback.xml similarity index 100% rename from jni/src/main/resources/logback.xml rename to java-native/src/main/resources/logback.xml diff --git a/java-native/src/test/java/com/baeldung/jna/CMathUnitTest.java b/java-native/src/test/java/com/baeldung/jna/CMathUnitTest.java new file mode 100644 index 0000000000..a9cc6ed1c4 --- /dev/null +++ b/java-native/src/test/java/com/baeldung/jna/CMathUnitTest.java @@ -0,0 +1,18 @@ +package com.baeldung.jna; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.Test; + +import com.sun.jna.Native; +import com.sun.jna.Platform; + +class CMathUnitTest { + @Test + void whenCallNative_thenSuccess() { + CMath lib = Native.load(Platform.isWindows() ? "msvcrt" : "c", CMath.class); + double result = lib.cosh(0); + assertEquals(1.0,result); + } + +} diff --git a/java-native/src/test/java/com/baeldung/jna/NativeFSUnitTest.java b/java-native/src/test/java/com/baeldung/jna/NativeFSUnitTest.java new file mode 100644 index 0000000000..d296f9e2ca --- /dev/null +++ b/java-native/src/test/java/com/baeldung/jna/NativeFSUnitTest.java @@ -0,0 +1,38 @@ +package com.baeldung.jna; + +import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; + +import org.junit.jupiter.api.Test; + +import com.baeldung.jna.NativeFS.Stat; +import com.sun.jna.LastErrorException; +import com.sun.jna.Platform; + +public class NativeFSUnitTest { + + + @Test + public void whenCallNative_thenSuccess() throws IOException { + NativeFS lib = NativeFS.INSTANCE; + + File f = Files.createTempFile("junit", ".bin").toFile(); + f.deleteOnExit(); + Stat stat = new Stat(); + try { + if (Platform.isWindows()) { + int rc = lib.stat(f.getAbsolutePath(), stat); + assertEquals(0, rc); + assertEquals(0,stat.st_size.longValue()); + } + } + catch(LastErrorException error) { + fail("stat failed: error code=" + error.getErrorCode()); + } + + } +} diff --git a/java-native/src/test/java/com/baeldung/jna/StdCUnitTest.java b/java-native/src/test/java/com/baeldung/jna/StdCUnitTest.java new file mode 100644 index 0000000000..c536fd63d5 --- /dev/null +++ b/java-native/src/test/java/com/baeldung/jna/StdCUnitTest.java @@ -0,0 +1,47 @@ +package com.baeldung.jna; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.BeforeClass; +import org.junit.jupiter.api.Test; + +import com.sun.jna.Native; +import com.sun.jna.Platform; +import com.sun.jna.Pointer; + +class StdCUnitTest { + + @BeforeClass + public static void setupProtectedMode() { + Native.setProtected(true); + } + + @Test + public void whenMalloc_thenSuccess() { + StdC lib = StdC.INSTANCE; + Pointer p = lib.malloc(1024); + p.setMemory(0l, 1024l, (byte) 0); + lib.free(p); + } + + @Test + public void whenAccessViolation_thenShouldThrowError() { + // Running this test on Linux requires additional setup using libjsig.so + // Details here: http://java-native-access.github.io/jna/5.6.0/javadoc/overview-summary.html#crash-protection + // IMPORTANT NOTICE: Code for illustration purposes only. DON'T DO THIS IN YOUR OWN CODE + if ( Platform.isWindows()) { + Error e = null; + Pointer p = new Pointer(0l); + + try { + p.setMemory(0, 100*1024, (byte) 0); + } + catch(Error err) { + e = err; + } + + assertNotNull(e, "Should throw Error"); + } + } + +} diff --git a/jni/src/test/java/com/baeldung/jni/JNINativeManualTest.java b/java-native/src/test/java/com/baeldung/jni/JNINativeManualTest.java similarity index 100% rename from jni/src/test/java/com/baeldung/jni/JNINativeManualTest.java rename to java-native/src/test/java/com/baeldung/jni/JNINativeManualTest.java diff --git a/jni/native/linux_x86_64/libnative.so b/jni/native/linux_x86_64/libnative.so deleted file mode 100755 index 213491e2688a87bdecd1fea411e578149f8e3f32..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 19856 zcmeHPe|%h3mA{iTZD>Oipe?0E7_fzg$~4m^ZD_ZWHkt5Jk`nSmBT!!_Gm~UOG81Rs zl(bq6hOmTe+Afvf)8NW(q2~8zDz_o@y$Qj7_pU zr*>(i20&6!R)^PZ5$M!h*KKcQ8(x|}G=0_6PrkY3&-1!mOJ90ppX*AJI}g{zxJb=B zTzAZ=>Yh`0|2gx|ec*=^x3~%^?|rx~!R5wvIj$ABD6ParN=gYqS}g$orS9$(D>@aJbRnUt`L zSfSS~IR!Y*?JQzPFBJHI%$<__B{u#Lx4(#WFBObo)SuEN(w-`54~=6=&r169G$9~u z5`aC;^)Jn`=N;J&B{n_xK<<3hcPBLn(mMjMJm{fzSSZ^^lk_goiT^vx1>r}M9+CDu zBK7}H(#O#bq-U*c{|ZU3ka~_wI{6KyUr0M&p#g{_A1CZVseiw$uj-cscu4;fvYl1? zFkSELjYjmi;g1=*&h&63Y%sk8fa!HD4SFyX3w4I$MkvVnC%gxY+ji+qQbTo*KOPUonSRsu4coTY`69b?@7nF5+nSA7IMUhLQtNBHKESs5 zclq@|v{!HUhkAmENT=Q%3F}&@rziU1Xsjm)Nj>i0%?YHc*s{OKkB0-O87Z#|G#g%TpvxcAjhH`d#3924NfM+N_hV?bkaN>R5{k-d1PYjH1a}Be#VkL3DUL(Tlz(w+h^<2fA+6 zJN)4ua<=|{y)P7tN69^m-TJOF-snbUI2uQX$3x|HaKKD&TIr$??qGf+)K8vja-|K| zg^aW-RimrXB$ax%aDc`x2gmaD`+NI(LXG~Izc&Ook8}S@^wvd;P$y8{GwA*7&d=2= zffn?7g-(7<&P3f3KCObKW4A;b(0k+!Etp*bH?(($0*0?~gWesW zsfuh*PgLdbF2NvGz_p@Wz{2JQTSLg`iU#XyGMeBIa(+qcTVL((=@AMAKX+E4vC&(m zcf%XGmOU2zWzb(6#>99M_2tdVT+VG)evRJUAv835c?+j)BB7dS0u%f!Lc!VnSyYLS zq5!5sBh(rX#ZFnI50kY)5;cCq&w9e`aU&R5z1kCxde##fNZ)k^FkcboWqK$`+`8T# zkBcW6NRc4BuDV)Z=P6^?)z@vU*4KK<(|2n<6|B0gZOhg=-RoH=$Zc(4F88eUno<66 zAG&XJGz6g;T;9lfg%R)C9g=%U}b_??H#b;^HK262CzuSpnl18=-y_X2vu`8jBm zT+sY=nNQE|Md9$d3}ydH(h|$U=g=GCYia&`_9dA|@-KYjR;&!>vUeoyW7A(iMe^BP zyhN2C-zfboUN!UBVtT1UQtz?q{j*H2dk)C=RYm`@Tu+SK=oicN%7l&nj9jlw+UO_b z`}%a5o0qTjD|~#7pi}j*1Wcz16CF#Ubec5Ll`hJhGSSgs>2$b9)J6(g zFLpC+Xxu1Bz6=l61`ifKC6vxod>UCZEAPN>@ugL`BfN_;Q%7cyR_-C3+&(qQ@fhLc zqN#C?cN0!SI`t^W+X<(koEqc!O@x!{ruK2XiEwhw)Bwk~5l$|d>f`uU!fD8-c5-|p z;WX4!jT~P~IJs)7isM%iPA-}%<;S<{TlhoQT}eI zqspX6<;>&`?jLmDj6u+*4exze8%~S`wUIe1S5eJ|eM#@QHtKs)8$O)818t{`wmu0Q zw2EipfJENG$%5q!>tv+)Nz9KLDkaQx0jvFC`D9Sq~?V(mgTwQ2tLz zWdFNFc}nOyoUG#vQ`$&FGN`R9;>H=9j+F}*Ze53Df$%&0HZ5F~$szlaA0T}2VB5_* zo}#Lw<|V^>-yKd&5AJ=}l~{ZG-szbcG=C}j^={aktS4JW7x$9wqZPLi7%AAWRMbsJ z=Dr_tMgK}-Ptr7y{4#aVQ~Q*9G%S27aRL>b)Iow+JMrEoafLWGm}CK%yBFJ z;nw5B4M`Nb8-pK(zCzuK3cmdgZ?6&GakMkq@^1+rtuTlS*)OZ?q{#lbz@gwPTmhG< zh2c=31tv#)No~L8lI1sRw;#WY_x;|xVDo@B{JDPAW_aSRAp_9v8zZBXi;CU#1cXpL z>T)<)%Dd0EA4bvY4JBVGO}|#zf=prE)rwNEAY%>vk+O?%Kkz*&oEeKbakPTg ziInF?LB}qT#QP+10hLZ(IMNCW8lZ$5_3GP_47q+)s1KFo9(M)hW<2gC!ORW#H=bql zzO~0zo7f))%P|aiayl;a1u28FdQevK+l1eKkXrT>{O$s@MDizpB6}DAVTqgkj#1-` z6g;^Y07`#@%#-<@TltYT+?vezp2mHTDCCh1@V|do&PUTgC8Va%^OKO8$m;IaNhm@# zZ?h(<)JW@uiF7UOI<|}&g0me?euio>42i?Z0B47^Wf&JE?2#c-w;)li!WwCFfm z^Z-P0`GE5#{4Zhg6iUGb^60r23VT*cdv*v8S=9z9OdfrJMqF}~%HwtB_Dq<^;r(0| zPFe9wEI;5rV;2bbIlzVflj`(!eoM3S2+!oR!zvP_iDB@dmgyG9c`~>N{h zxU^wkacS#Vap{gni%Ub}#ihNI#ifZO#ie^sn1w-gmPJXDT5da=UX zgC-oR1geb=H4+#eq7|SvGQ^GHkDjGu-RLNZYa_y}5n<#AH+cpFe`uAE65w-GB%ZsA z#B;YGdGrr6GucloKFe6z=>*omj_qW6&Sgthad)-1FdRtrep%XAFt^bRVd|a%F1**& zJv7PfouW~SVT{=hieMS7`!maY#&_G@9kFPyyL$C%_hpx%Nhtx@=x*r>xg&|*cI=kA zW1&DOyekxR`(q*ZMmKZ&BSCkDO>D+yxWaMpG{imliQxy^{%h2>{~B!juSstO)pz4q zU`>xd(z!T}ktTvqxbB#*M-e&VM*=6rQ3=Z+*UZiu3fh2 zs&y+aCwbzj!PSkr^L>ad3rp_It3G$`txzQM0hnt~V?8fn-n~P`ZnoT94wW_e=FH4H zfOF^|S?TZ%=I8xBqvvbL|9gy*I>0nfUJYj;JD#Bn`SjA0&Tq`f9|w6O+P=b^-@8g_-Y$W|_QBOKMob!H@o!Vf2{w=OF-<#l@hjNAh=Ui&yqxuMSyxl$l zJ=eo0oa*yM zWc2?9^4pRBJ9B7l`J2r0yE6K}i2M%ZYv%mC>a_mvBA=d* z&sy>)cs}*l&yfFPli!g!g>&Nx7NhiH(g!~%arTFZ{)GN^9peP`8;I5NI&2yS_|kasAqn_ zv*~OLoNa-#EpWC4&bGkW7C74iXIntDfI3H3=f>)sSe*;2b70k8SlaSLXW5h#PJ5hY zoX*ZE6$z03o>rY1w#o1F)LEE1-(D{H-4ZU7P@PZHx{?yT15x_Jdoxjj^xj8FE%mD8 zp{O*2J&ZLgC3Plxnao#bp|m+cNxr^ef$iqF6k}uZM!nZbasHl4jN^2|grw+g#R6A$ z@)I|Z=-`WzDi5!W-2MqV!9v331;>>gCnVl3^YJRn^Hsfs)c>Df_1(PPqR-32)`ukg zmV}2S{HcV$mhdeJ=gJ0OBHl3w@09TK5eK^@a6op-&^T(m>M5edI3{@W~I+%%0I32 zc})4am0p-04_12iclDH?k5M@w``gODfHlhYwbJq3Z%%slchN%sLe?ec8>^n;bR342 zUcw45GgHKUKE7nHrx##b%Ey<*YW^~3<+BTznzyX--nH$cx-uLn8*MeH1}8+V!K z+T*w<`){TVNhH3P0r)B|qO0eosvdp+Kb!vf4*Fk^4??AX3G|SD^*mPkKY9}V3mo(h z$_J;?e}mMop7TmS$T{sFLWT=prfD|+zlYPa{Q+un>iIj)kEfrsQ#~KC%Y&3X9-rg< z*?#`2)MJldpn1@h!~g%x>Dl9JE}rX`qn+*F;jfT%dmO=sCH;~2k-d!ZJvzY8fPOxw zSbrV_-EAdt>~RPB1lN;2k3Hw0{|(T|etUex5-cEc+0*GjzukfU5a_w=|A7Plyg9kc zy%BV>(;m+)0 zG|lxFF?-y{`BbgBdwj|xpi}$U<4~TLbbFl6 zpB(gSSm5Tee;=o3#|<3@oyxVx(Y)cHXA35TT>9y2*bx}K^^z8M_mmK(6AZEmkL`R1Qfe8Ax>L$IuuDJyPKACtP-RRW=6w!n4 z-1T5o@9c@gc9&FAo_p5Vk{H57=#Tx{A* z!5Yr-9H$>pV~QrR6iAT*6l>~1N>X`}onLU=r66a{`{L>0y%*`yP zqRfnoI5T>RA#k~h^ZmJHU}G8i$B%6m?DGB zQ_3j^H_aN0^*@MxwA4nq{h5VjT2##*|1?|dVa6Lz7T(BboYRf@!!*hR?JU;Had7%m zCA6tn+H8d~NDKa>0(LDt^fbr{4y~#(MQQyXgyC8&qGp)Yp>6$U3Ei|r!a}VKMU(N> zXEI%h@XRa=nJ2!x*YLLk8ZiO8)LkTMggl**gr_|b?g?HU4l<5)`Qu&86Wkqvq<}_D zd5FL53P>-Jkb^SwK@{xo4F@0>HK;&PDBjP5a6jh3Dzz6Y&+H}h z8Bu8e2(Jp*3lT}}e=4{_(iOn#p(W8i6Fx19DtWa}s^9_1jn`S8@OofLmB8qXK*_6f z1O@3sTuKCpN6D-G{VLE%w~|-;t_rGi2(a*kZ3;`$fYF(Nl2`k)X(+js{fbY)R^-ze zgTmE5u7dldJlRh=l>L&-g1Aw2BbwUpRZyL4sPdJ(s((bvZzW+Qbxxw-m^6&!X^YJ+ z-wztK30_BeQva7lLHo`n*=kO4AZB^B&#d62t-(vAu!5ho$*cWn1r?tvQ`xWZzqHA# z{ZR$q!uz5*+4YUuG zosRO9yxPy7Ghx$qK7>SLG`|`n0Wl zb&fE;1{p|I{5SKXEXLTS;S1PGjnp5-t!M8G|kPU*tHUGS%~xnXh{Lt+pV7!QF#OrxN7dg&!rE#WeWLZ?AP0}&A5)6`5w7-A*R zsK57izxyZIv5lFwGy2BgzJ0rI-@bkO_U(RePk!OeU%jY<)ss4J>R1I@+q4SY~GeN_oXcmcm0XU^$*FcR%<>o}mwi}@W}D=WUQ z>K$C6b9n1|tmBhy9W8oW$No+b74zG(PPROy7!ZCj`N&RcFcw{}+qQd~YDB=Xj|x>* zgp-|+?a@n*t{>>kGm{JQ^Ds3M@N?Qy5zXf+%BV-zJHmS8NPBZ;OIK%Ir{f@{{StyYc5)~MfM=%EsD zwZcg+3(tZE7BsM+fdvgLXkbAD3mRC^!2drDG-<}qwf=KenpyUu2S;FQ>8|$x7`?V; z#3nUkR5PBpxBey9bYXa!;hoWphH1_0otbT#20Eejk5uhF?S4-mjb8EdfCK1aOsAOy zy&xv8;24{({rC8)0%OXX-=>)}M(xj`EUVe`QXC?{*vN1_(r{ru z2SKQ&ip)4`vLC^xrM-hV8}UIj%vr5P=miWn{SB^z?Z#zpXaEIl!70kYh~r-boT?=; z3+#AnRuI!WX2Q6QcoLL`^$^jogyl)Qwi3YYC-D``roG5%cAOczpBdB46phq4&a2mq zvtAN}B+e#MpFx#orpd~V#|f$9COpk($yzp9%RVzsTDGOp$9s@>Y>BYErnv zsYa!&cmz&sDI0#~xtUQ)m4n6|@7?W&QOyViI+UF`t#1`0v?SpLKEtD96s4pE6_q-q!pRT01%CNRq3 z5MZ)PDS(lxrMmt%U=x1|wZaQXQQ{RSpZZ7G0*Xiw^v%+(hWCk&a{)^R>=gH+KulLHEIlNgpojjM3Q_wXJb#>^^os@wMW^)S1P$2~HkjILaG^ z)V3^vDrHaXF%7lPNdGws>!NWuESMpk5k^_Tva&$eyAY?6M%SNaJ-8n}k14BueHacz z7|%hR0g}q(+PdS?B8&#O-rm8wg!fz6IOrTOSa%$Gqk*>kF_e#@9QlR`)J>pl5^xgG z2DIyqH+*zzF|01|wjYKK!12OEr3rUG(==+AQ<>BEkhBiD`I%}Dv}#EWrUZuC3ey_v zChg}s35@g}i4kx=y`+EA)jtFOJ=97AGpv2o=P`;v!vF|@|4Bgn1jJ7QCIL?X;;pX$ z{T`4^QS>lN9^c0uSPTrc*GhmP$~p%9&$_^%N0u;fwqD5=9Em$QK=OVV9b2rKlA@-j z$*Qn68Ca9j#<(zRV_avZxQ=bii2F%kntSD4xB#|Cyxqr!Xe6*b$$E^yD0_HF3H`>o z#I!Q9eu9BDPC)J5qr{q&p;%}%0xO;%fI|rZ!(vQsnHMz1(fBbClL=2zfR&x(36vPt zqr}8YlO@^$S4C61P%p`mf%vlO=N07WiAg+T#Onav$8f}y<2JdV-*(~9#WjuSY3hDT z_?)#HISgVNbr5@o0DGMb<+2{&ht!>NSBfg@0S2UQPB2I%rHZ&PJ3Cxw%DMs%(96S! z_fTh+)hapl5E$hRMNWp?TFq3KtWPjV^${@n0H9?(fWv|q8u5LSQ#k-S%8me=5K5-% zQRLW$EgS5S4g9$VTw-c)w3bGdrbU&Sfsz9E4UCxLv`pL1-qTpsG>P^&PJe1QyNz&? z!*BPwA&s%ORE@(~VWZy&f`E4lVCyWT#`5oPTr$+D-A zB?%6N@GM&C6R6azA(|Px9rSVqT5&E{w!u3Qb|b@!od~bt#V&-GHwgYtK82m>6m}>a zvl|B8PcQ5LsjL4@3@6=1>@i+|?CwSg+D?LY5^b;<u?O4@}Ptr z{xGVgwqdoT3foQfhLvq$qG*M^b2auA%sKOqiG*b+WR6=45 z47J;+jU{!0>WuU$1}6t3C1WOkdE%^2iozL)Gy|RzON}u$#K0Julo$aV{-+5uhGt|T z0iTg7C%ZS&Ra|%8cpi)^x#lcp+Jl_^?Q3|lsFaF$oun8zM^|}*HBwcwj)B34+|l?A zC?i|xPg5@E5>@~+Eh@`*352stpbWbNn2A)L3|+vOd7Z$B3yeB%-NaWw((HmEzk|}k1ROE7j&|x@laiEW9-*jm~XolNBG-?W^_z9TlRseeueZU)Wjf<4*^4rmr zpde&Klo%=+GcYc8?sfP7#Dy;|G${x3><9_L2on%B0ktFn;bsaByaFW7fmf1Wl>;xa zg%TLBKZ^|jmCBGu46G>ESq!d=VvtPmIuw3@$P%HCFX$+X&{vN6^SUS%! zm0V7)*LhVTxK<6b%DJ6dv^1>S^4gyu_VV*lGW-lN#QsP$M@MK$f6VbaW}4dDzk-8M z9_Ab!ao&AidYHm^VgET#*1xcOL{#gaYuL9qQQ7kv1vkAmI};Cm%;&{l`_I*CR@q~; zuJYW}Ywl&_*D20>#vUMU6bvRDXB%6m0&DrFsFAhw2)D&4#;LwlR!3!ZOjg5+RqJ<2 zb{SQGc1@@xC-|)WKB|+1RGxXwUE!UymvAY1=pU)&!&`y;bI1Qc75GhKJm6V8_~Q8U zy!xA<{o#Tviu70L-x0Hh(L+y&j(&EUJT*ti=~ERNHR$v81rPu#}yz_+e^r=S(|Q`tuppu6nm>Pb+lWx(WE#=V-ut?t$QY2aS{%}MwW_v){XGdP)HkQ!uQ4KPqA>vRGb z4&i+aI0TDLr3)DLUv`DY&^~H#tOdh%S8_A=YQAM~S1MkXA3KM;Qgy&5ad)Na^&}mS z-IYp|P@lU}3D=%OL1i2Dmv--5h z5g*Luo_utKCU5U)``=KQoLzYzTF$QgYfeAT={`=IIc?!|Kc}sn9^^F4X$PlWoOW{> z<@7M8J)GXpDakjx@^3lqE}6p zg3~W>N_)rb$}e;J6{J4v-R+Bn*w#3^axY-A6$2Mjzra+sRsf%RnR2Ts_kGIMP;QKJ z2t|vjXDC-kxu+=CM!Bz3?itDrP_6!93G z%C%6A!pl?lQSMrJizzbc);lP72jzm4yNz;xN4fQsJ3~1##MU2E?ncVZP>#-wvycCi zDBTFjgpU$>C{vI3Bq3kJi_KA_@w&c+j_Ctj*w_gDHAZqxz9@RufN*6aG zSuM+j*g*|}FasZuRZa~g?{(oNJU8CAz?L7%P{TB_{2mhGpTyC}H34Kyj+1_)NYCu! z)1s6OV#ukWOafKoRIpr0{$b)y`v)=Ong)e@3D9*flB|3WRvA^fCfXNP8unRX&N!+PV zg6TNmvakxlxPb<`?2K!c-ar3CvFUP}uP&!l5bYCQ~ixHxNN=M>-974(qu@YE{k zhs^vy7xY}K;0+4is9>dn>lM6B!8;W6D|nxRq+fbk6yBj=kAhv82YN`~^gO7_A5!o! z1)o=PPbm0P1!b#+bU_0P8d%W4f(8~eu%Lkj4J>G2K?4gKSkSC}zbc3!} zZwz+EqF&KAL9se|T*%9J3^n<~0AQJKK3^s1iAykd*B1>Jp4e_JkUCjqW z!Dx=0ySr~!jtV>*LebXF`Ir`QT)!*yNf`=i+I@!?9Tzj(2xhXw?IfDlU!x!FWC7+- zHin{gow4R{hzFEM>EEIs+%E^&GG8mn|01m#tM%e`o3{tTVcAfQHNU^=D*a%)(!l-2 zEpNeyvP0h98t9gTl94rkYZ3XDJ75cH=vnPZi>R&+qO~6F4zxuhnELAK&>{RU1NdJM zU<%&0Hqlp+Zz9Fy8$zA?y@yqI^K;xB4s{%ew&u-?q+7pH*Slg-7;vCF5R8Vp^+@PY zEQB~-eQ;N!Ufh${>%E7HH#7$#Z9%;gLk$Jm>v!wBt8}lo@fO{`vvH%|F8ciW@`fYz zm(DA=n>cL-r=aM=TFR}PuJHUaf%g_nVP`N9?d*p3@KAT_rHpbmq=>t#!TX+_jax|0 z&9DS^B!{YKB{#|c+u@#2B!>8AQXERS#F6+A4Wn^tdy4Kwy2I93O(4_5oyDosdvNec6WYKYUsrL?KcI(p+L9yAoV{eNgAVD z;Kth9@Sk;rc+m}WxgP8Z=*^)6Z5=xNL=esycAl$&spiVZN{Y7j{eiYHH5jLg_E0-S zCUk;O_!szAptvB=MVTnM6E`CmMLPy1uTOMbpXlOd?Ej)cl<>{XM?1U2E!esBNZ<$; z2+i9QXzvP##8*m7#lVfY1(8ldG&{So_*JP`bj7apm6AV_tADkmc#{xQC0E~7KU!A0 zX!=G`x@i0++~DMIXQ|RT+vVp=)t30hQZ)DgS`E}7$<#oter$Bu(Q%w&{fjfDa_?tU z;P$vA)?VKc4IKc5_*to%pWU4eAz@=`#=%HTZULieacoi1p8i~!Sp0T}f=9~co|HaU zRxL)$E_Q-Dws@m37GK6u<iRZX#XQh5s0dZ|V3>FTSKy zWbPzF9|-3^8_t$p>@@fY`pfu;LjySA04Kh=_`(Oi<4Z)zC7soNxA+ncf_>iPtn~{ zj%#RFAKxcZQLn=3K9QbZE4)J8vt5JR?|0x@neHCxd6&ZJ4w9Y^DV**i>G>;#)14$e zcPpIkCh4L3PdBc4Yt_BrW`z%^d%<>v)4e7=U&BlEeudNhJK=OsO3!u3yD=W;{&ADS zoqNc874Fq^Q)Sq*YA6EE)holkWb56aw-+W5p z&i&;p3U}@?F{jMWxzAjsaOWQKGYWU^9nUJ;wu>M*NX7( z6yax!@c$^ne=YH>eoL`F^7Z}BBK*c8d{q%nKUZCf7k?fi$b{*-8Q1Uve^4Uu_c7uI zytEYQr#aXt1^sap{-&1y|0(*v!8~|x!uwvl@56gD-j#S);e9{eO1!J_(w}(K5~XEG zOOO6+mX^>uyj6Is@ovDo2`{Zd`l$h3QLo2KKd-q3FP_@}tMYn;KL1%n9X0ayy}YgA zlG_ySAQx{|wCUz=s+ZL;Z)?6ly9*qz=qu7WNL@5kQb2ftC`lpB#dgI4%DMY~LG?xA zBZYLA79E+>=92c?f>xJt+$d=Gc1NIm;-V82RjIGzw~L8fm{cA9E=-Vre9Te(kq*eY z4zBp{o?~(K57xzz59;d@LLPZ!*{``=tRp9IQ5a_4FX^`na$GHLh;IDBtn$Mee>k&T zJmU}L#UI*vOfDyaakQI#e - - 4.0.0 - jni - jni - - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - - - \ No newline at end of file diff --git a/pom.xml b/pom.xml index ab1c47361c..ac1a16a728 100644 --- a/pom.xml +++ b/pom.xml @@ -465,7 +465,7 @@ jjwt jmeter jmh - jni + java-native jooby jsf json @@ -1501,4 +1501,4 @@ 1.4.197 - \ No newline at end of file + From 76676ebfd86baa9960c2bb08d8547936de6fe8bc Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 2 Oct 2020 13:05:41 +0800 Subject: [PATCH 243/263] Update README.md --- core-java-modules/core-java-collections-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-collections-3/README.md b/core-java-modules/core-java-collections-3/README.md index c80e493767..e21e3642f9 100644 --- a/core-java-modules/core-java-collections-3/README.md +++ b/core-java-modules/core-java-collections-3/README.md @@ -13,3 +13,4 @@ - [Quick Guide to the Java Stack](https://www.baeldung.com/java-stack) - [Convert an Array of Primitives to a List](https://www.baeldung.com/java-primitive-array-to-list) - [A Guide to BitSet in Java](https://www.baeldung.com/java-bitset) +- [Get the First Key and Value From a HashMap](https://www.baeldung.com/java-hashmap-get-first-entry) From ffe826a6b6123c16b0a7c2ce08a95e77c4d116f2 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 2 Oct 2020 13:07:19 +0800 Subject: [PATCH 244/263] Update README.md --- spring-boot-modules/spring-boot-mvc-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-boot-modules/spring-boot-mvc-3/README.md b/spring-boot-modules/spring-boot-mvc-3/README.md index 796ab72425..bc3eb9e496 100644 --- a/spring-boot-modules/spring-boot-mvc-3/README.md +++ b/spring-boot-modules/spring-boot-mvc-3/README.md @@ -8,4 +8,5 @@ This module contains articles about Spring Web MVC in Spring Boot projects. - [Download an Image or a File with Spring MVC](https://www.baeldung.com/spring-controller-return-image-file) - [Spring MVC Async vs Spring WebFlux](https://www.baeldung.com/spring-mvc-async-vs-webflux) - [Differences in @Valid and @Validated Annotations in Spring](https://www.baeldung.com/spring-valid-vs-validated) +- [CharacterEncodingFilter In SpringBoot](https://www.baeldung.com/spring-boot-characterencodingfilter) - More articles: [[prev -->]](/spring-boot-modules/spring-boot-mvc-2) From cfdbef76ba47f959a9848abfd03636664d5a3484 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 2 Oct 2020 13:09:22 +0800 Subject: [PATCH 245/263] Update README.md --- core-java-modules/core-java-security-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-security-2/README.md b/core-java-modules/core-java-security-2/README.md index ba8cce46a0..11f0a34fa9 100644 --- a/core-java-modules/core-java-security-2/README.md +++ b/core-java-modules/core-java-security-2/README.md @@ -10,4 +10,5 @@ This module contains articles about core Java Security - [SHA-256 and SHA3-256 Hashing in Java](https://www.baeldung.com/sha-256-hashing-java) - [Checksums in Java](https://www.baeldung.com/java-checksums) - [How to Read PEM File to Get Public and Private Keys](https://www.baeldung.com/java-read-pem-file-keys) +- [Listing the Available Cipher Algorithms](https://www.baeldung.com/java-list-cipher-algorithms) - More articles: [[<-- prev]](/core-java-modules/core-java-security) From 92b4aba6b4c407f8843082d2b6fa56e8ca5dea54 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 2 Oct 2020 13:13:08 +0800 Subject: [PATCH 246/263] Create README.md --- gradle/gradle-wrapper/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 gradle/gradle-wrapper/README.md diff --git a/gradle/gradle-wrapper/README.md b/gradle/gradle-wrapper/README.md new file mode 100644 index 0000000000..972ced46c8 --- /dev/null +++ b/gradle/gradle-wrapper/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Guide to the Gradle Wrapper](https://www.baeldung.com/gradle-wrapper) From 5bae06c7ff4319dcfd3e53d46e85e497a810ead5 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 2 Oct 2020 13:15:04 +0800 Subject: [PATCH 247/263] Update README.md --- httpclient-2/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpclient-2/README.md b/httpclient-2/README.md index 52d8b8fcff..dc0fb553b6 100644 --- a/httpclient-2/README.md +++ b/httpclient-2/README.md @@ -8,5 +8,5 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles: -- [How to Set TLS Version in Apache HttpClient](https://www.baeldung.com/TODO) +- [How to Set TLS Version in Apache HttpClient](https://www.baeldung.com/apache-httpclient-tls) - More articles: [[<-- prev]](../httpclient) From 39c0a4fa84e2a16da1e3580fa98a3c3a7ce599f1 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 2 Oct 2020 13:16:46 +0800 Subject: [PATCH 248/263] Update README.md --- core-java-modules/core-java-io-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-io-3/README.md b/core-java-modules/core-java-io-3/README.md index 4b1a14ab3e..18caabc784 100644 --- a/core-java-modules/core-java-io-3/README.md +++ b/core-java-modules/core-java-io-3/README.md @@ -11,4 +11,5 @@ This module contains articles about core Java input and output (IO) - [Java Files Open Options](https://www.baeldung.com/java-file-options) - [Creating Temporary Directories in Java](https://www.baeldung.com/java-temp-directories) - [Reading a Line at a Given Line Number From a File in Java](https://www.baeldung.com/java-read-line-at-number) +- [Find the Last Modified File in a Directory with Java](https://www.baeldung.com/java-last-modified-file) - [[<-- Prev]](/core-java-modules/core-java-io-2) From f77d8a6b4e0315171c6ad89828a5f7d6e8ed2534 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 2 Oct 2020 13:19:45 +0800 Subject: [PATCH 249/263] Update README.md --- core-java-modules/core-java-lang-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-lang-3/README.md b/core-java-modules/core-java-lang-3/README.md index 121d30f20f..598014bb92 100644 --- a/core-java-modules/core-java-lang-3/README.md +++ b/core-java-modules/core-java-lang-3/README.md @@ -6,4 +6,5 @@ This module contains articles about core features in the Java language - [Converting a Java String Into a Boolean](https://www.baeldung.com/java-string-to-boolean) - [When are Static Variables Initialized in Java?](https://www.baeldung.com/java-static-variables-initialization) - [Checking if a Class Exists in Java](https://www.baeldung.com/java-check-class-exists) +- [The Difference Between a.getClass() and A.class in Java](https://www.baeldung.com/java-getclass-vs-class) - [[<-- Prev]](/core-java-modules/core-java-lang-2) From d0f0e197e401325b595a6d3dc3c06cd9b29ee2e9 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 2 Oct 2020 13:22:31 +0800 Subject: [PATCH 250/263] Update README.md --- algorithms-miscellaneous-6/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/algorithms-miscellaneous-6/README.md b/algorithms-miscellaneous-6/README.md index 6ddae75f43..e1841fced7 100644 --- a/algorithms-miscellaneous-6/README.md +++ b/algorithms-miscellaneous-6/README.md @@ -9,4 +9,5 @@ - [The Caesar Cipher in Java](https://www.baeldung.com/java-caesar-cipher) - [Implementing a 2048 Solver in Java](https://www.baeldung.com/2048-java-solver) - [Finding Top K Elements in an Array](https://www.baeldung.com/java-array-top-elements) +- [Reversing a Linked List in Java](https://www.baeldung.com/java-reverse-linked-list) - More articles: [[<-- prev]](/../algorithms-miscellaneous-5) From 511c0183cf0ba6e1226f1ad35dd24d691453f175 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 2 Oct 2020 13:24:04 +0800 Subject: [PATCH 251/263] Update README.md --- spring-boot-modules/spring-boot-environment/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-environment/README.md b/spring-boot-modules/spring-boot-environment/README.md index e916c503bc..e7b0ace7a4 100644 --- a/spring-boot-modules/spring-boot-environment/README.md +++ b/spring-boot-modules/spring-boot-environment/README.md @@ -4,4 +4,5 @@ This module contains articles about configuring the Spring Boot `Environment` ### Relevant Articles: - [EnvironmentPostProcessor in Spring Boot](https://www.baeldung.com/spring-boot-environmentpostprocessor) - - [Spring Properties File Outside jar](https://www.baeldung.com/spring-properties-file-outside-jar) \ No newline at end of file + - [Spring Properties File Outside jar](https://www.baeldung.com/spring-properties-file-outside-jar) + - [Get the Running Port in Spring Boot](https://www.baeldung.com/spring-boot-running-port) From c1c380094cca00b54d019e6cdaeb77bd98189828 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 2 Oct 2020 13:26:20 +0800 Subject: [PATCH 252/263] Update README.md --- testing-modules/junit-4/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/testing-modules/junit-4/README.md b/testing-modules/junit-4/README.md index 6cc3981ed4..cf20c8da91 100644 --- a/testing-modules/junit-4/README.md +++ b/testing-modules/junit-4/README.md @@ -5,3 +5,4 @@ - [Introduction to JUnitParams](http://www.baeldung.com/junit-params) - [Running JUnit Tests Programmatically, from a Java Application](https://www.baeldung.com/junit-tests-run-programmatically-from-java) - [Introduction to Lambda Behave](https://www.baeldung.com/lambda-behave) +- [Conditionally Run or Ignore Tests in JUnit 4](https://www.baeldung.com/junit-conditional-assume) From e9059bbb72c77664a14dbb7c42bc7b6608448ab9 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 2 Oct 2020 13:29:42 +0800 Subject: [PATCH 253/263] Update README.md --- testing-modules/junit-5/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/testing-modules/junit-5/README.md b/testing-modules/junit-5/README.md index e62f2dd345..984b79c29d 100644 --- a/testing-modules/junit-5/README.md +++ b/testing-modules/junit-5/README.md @@ -7,3 +7,4 @@ - [Testing an Abstract Class With JUnit](https://www.baeldung.com/junit-test-abstract-class) - [Guide to Dynamic Tests in JUnit 5](https://www.baeldung.com/junit5-dynamic-tests) - [Determine the Execution Time of JUnit Tests](https://www.baeldung.com/junit-test-execution-time) +- [@BeforeAll and @AfterAll in Non-Static Methods](https://www.baeldung.com/java-beforeall-afterall-non-static) From c68b6f68b56e5fadb245054dd0726a372727f0a1 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 2 Oct 2020 13:31:26 +0800 Subject: [PATCH 254/263] Update README.md --- core-java-modules/core-java-security-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-security-2/README.md b/core-java-modules/core-java-security-2/README.md index 11f0a34fa9..03a5a94acc 100644 --- a/core-java-modules/core-java-security-2/README.md +++ b/core-java-modules/core-java-security-2/README.md @@ -11,4 +11,5 @@ This module contains articles about core Java Security - [Checksums in Java](https://www.baeldung.com/java-checksums) - [How to Read PEM File to Get Public and Private Keys](https://www.baeldung.com/java-read-pem-file-keys) - [Listing the Available Cipher Algorithms](https://www.baeldung.com/java-list-cipher-algorithms) +- [Get a List of Trusted Certificates in Java](https://www.baeldung.com/java-list-trusted-certificates) - More articles: [[<-- prev]](/core-java-modules/core-java-security) From ea64a31131147d288046123a897e18cf71b407df Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 2 Oct 2020 13:33:56 +0800 Subject: [PATCH 255/263] Update README.md --- httpclient-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/httpclient-2/README.md b/httpclient-2/README.md index dc0fb553b6..6fdd743fcc 100644 --- a/httpclient-2/README.md +++ b/httpclient-2/README.md @@ -9,4 +9,5 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles: - [How to Set TLS Version in Apache HttpClient](https://www.baeldung.com/apache-httpclient-tls) +- [Reading an HTTP Response Body as a String in Java](https://www.baeldung.com/java-http-response-body-as-string) - More articles: [[<-- prev]](../httpclient) From 9ee2aee60f9f79584cb61301d9f8eab3ebe9de56 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 2 Oct 2020 13:35:14 +0800 Subject: [PATCH 256/263] Update README.md --- httpclient-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/httpclient-2/README.md b/httpclient-2/README.md index 6fdd743fcc..9d7a9683cd 100644 --- a/httpclient-2/README.md +++ b/httpclient-2/README.md @@ -10,4 +10,5 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [How to Set TLS Version in Apache HttpClient](https://www.baeldung.com/apache-httpclient-tls) - [Reading an HTTP Response Body as a String in Java](https://www.baeldung.com/java-http-response-body-as-string) +- [How To Get Cookies From the Apache HttpClient Response](https://www.baeldung.com/java-apache-httpclient-cookies) - More articles: [[<-- prev]](../httpclient) From 99d35b68e37bf6adc1edf1bcc69df59011413193 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 2 Oct 2020 13:36:59 +0800 Subject: [PATCH 257/263] Create README.md --- persistence-modules/jooq/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 persistence-modules/jooq/README.md diff --git a/persistence-modules/jooq/README.md b/persistence-modules/jooq/README.md new file mode 100644 index 0000000000..348baab50c --- /dev/null +++ b/persistence-modules/jooq/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Getting Started with jOOQ](https://www.baeldung.com/jooq-intro) From 67981e7cba0f746046088f3fd8e816fd1a131d7f Mon Sep 17 00:00:00 2001 From: Aaron Juarez Date: Fri, 2 Oct 2020 12:46:48 -0400 Subject: [PATCH 258/263] BAEL-3862: Spark differences DS, DF, RDD (#9976) --- apache-spark/data/Tourist.csv | 2247 +++++++++++++++++ .../dataframe/dataset/rdd/TouristData.java | 75 + .../differences/rdd/ActionsUnitTest.java | 67 + .../differences/rdd/DataFrameUnitTest.java | 74 + .../differences/rdd/DatasetUnitTest.java | 83 + .../rdd/TransformationsUnitTest.java | 63 + 6 files changed, 2609 insertions(+) create mode 100644 apache-spark/data/Tourist.csv create mode 100644 apache-spark/src/main/java/com/baeldung/differences/dataframe/dataset/rdd/TouristData.java create mode 100644 apache-spark/src/test/java/com/baeldung/differences/rdd/ActionsUnitTest.java create mode 100644 apache-spark/src/test/java/com/baeldung/differences/rdd/DataFrameUnitTest.java create mode 100644 apache-spark/src/test/java/com/baeldung/differences/rdd/DatasetUnitTest.java create mode 100644 apache-spark/src/test/java/com/baeldung/differences/rdd/TransformationsUnitTest.java diff --git a/apache-spark/data/Tourist.csv b/apache-spark/data/Tourist.csv new file mode 100644 index 0000000000..4970e8c2f0 --- /dev/null +++ b/apache-spark/data/Tourist.csv @@ -0,0 +1,2247 @@ +Region,Country,Year,Series,Series_Type,Series_Type_Footnote,Value,Footnotes,Source +4,Afghanistan,2010,Tourism expenditure (millions of US dollars),,,147.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +4,Afghanistan,2016,Tourism expenditure (millions of US dollars),,,62.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +4,Afghanistan,2017,Tourism expenditure (millions of US dollars),,,16.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +4,Afghanistan,2018,Tourism expenditure (millions of US dollars),,,50.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +8,Albania,2010,Tourist/visitor arrivals (thousands),TF,,2191.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +8,Albania,2016,Tourist/visitor arrivals (thousands),TF,,4070.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +8,Albania,2017,Tourist/visitor arrivals (thousands),TF,,4643.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +8,Albania,2018,Tourist/visitor arrivals (thousands),TF,,5340.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +8,Albania,1995,Tourism expenditure (millions of US dollars),,,70.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +8,Albania,2005,Tourism expenditure (millions of US dollars),,,880.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +8,Albania,2010,Tourism expenditure (millions of US dollars),,,1778.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +8,Albania,2016,Tourism expenditure (millions of US dollars),,,1821.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +8,Albania,2017,Tourism expenditure (millions of US dollars),,,2050.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +8,Albania,2018,Tourism expenditure (millions of US dollars),,,2306.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +12,Algeria,1995,Tourist/visitor arrivals (thousands),VF,,520.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +12,Algeria,2005,Tourist/visitor arrivals (thousands),VF,,1443.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +12,Algeria,2010,Tourist/visitor arrivals (thousands),VF,,2070.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +12,Algeria,2016,Tourist/visitor arrivals (thousands),VF,,2039.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +12,Algeria,2017,Tourist/visitor arrivals (thousands),VF,,2451.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +12,Algeria,2018,Tourist/visitor arrivals (thousands),VF,,2657.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +12,Algeria,2005,Tourism expenditure (millions of US dollars),,,477.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +12,Algeria,2010,Tourism expenditure (millions of US dollars),,,324.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +12,Algeria,2016,Tourism expenditure (millions of US dollars),,,246.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +12,Algeria,2017,Tourism expenditure (millions of US dollars),,,172.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +16,American Samoa,1995,Tourist/visitor arrivals (thousands),TF,,34.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +16,American Samoa,2005,Tourist/visitor arrivals (thousands),TF,,24.5000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +16,American Samoa,2010,Tourist/visitor arrivals (thousands),TF,,23.1000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +16,American Samoa,2016,Tourist/visitor arrivals (thousands),TF,,20.1000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +16,American Samoa,2017,Tourist/visitor arrivals (thousands),TF,,20.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +16,American Samoa,2018,Tourist/visitor arrivals (thousands),TF,,20.2000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +16,American Samoa,2016,Tourism expenditure (millions of US dollars),,,22.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +16,American Samoa,2017,Tourism expenditure (millions of US dollars),,,22.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +20,Andorra,2005,Tourist/visitor arrivals (thousands),TF,,2418.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +20,Andorra,2010,Tourist/visitor arrivals (thousands),TF,,1808.0000,Break in the time series.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +20,Andorra,2016,Tourist/visitor arrivals (thousands),TF,,2819.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +20,Andorra,2017,Tourist/visitor arrivals (thousands),TF,,3003.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +20,Andorra,2018,Tourist/visitor arrivals (thousands),TF,,3042.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +24,Angola,1995,Tourist/visitor arrivals (thousands),TF,,9.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +24,Angola,2005,Tourist/visitor arrivals (thousands),TF,,210.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +24,Angola,2010,Tourist/visitor arrivals (thousands),TF,,425.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +24,Angola,2016,Tourist/visitor arrivals (thousands),TF,,397.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +24,Angola,2017,Tourist/visitor arrivals (thousands),TF,,261.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +24,Angola,2018,Tourist/visitor arrivals (thousands),TF,,218.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +24,Angola,1995,Tourism expenditure (millions of US dollars),,,27.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +24,Angola,2005,Tourism expenditure (millions of US dollars),,,103.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +24,Angola,2010,Tourism expenditure (millions of US dollars),,,726.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +24,Angola,2016,Tourism expenditure (millions of US dollars),,,628.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +24,Angola,2017,Tourism expenditure (millions of US dollars),,,884.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +24,Angola,2018,Tourism expenditure (millions of US dollars),,,557.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +660,Anguilla,1995,Tourist/visitor arrivals (thousands),TF,,39.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +660,Anguilla,2005,Tourist/visitor arrivals (thousands),TF,,62.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +660,Anguilla,2010,Tourist/visitor arrivals (thousands),TF,,62.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +660,Anguilla,2016,Tourist/visitor arrivals (thousands),TF,,79.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +660,Anguilla,2017,Tourist/visitor arrivals (thousands),TF,,68.3000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +660,Anguilla,2018,Tourist/visitor arrivals (thousands),TF,,55.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +660,Anguilla,1995,Tourism expenditure (millions of US dollars),,,50.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +660,Anguilla,2005,Tourism expenditure (millions of US dollars),,,86.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +660,Anguilla,2010,Tourism expenditure (millions of US dollars),,,99.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +660,Anguilla,2016,Tourism expenditure (millions of US dollars),,,136.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +660,Anguilla,2017,Tourism expenditure (millions of US dollars),,,141.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +660,Anguilla,2018,Tourism expenditure (millions of US dollars),,,102.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +28,Antigua and Barbuda,1995,Tourist/visitor arrivals (thousands),TF,,220.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +28,Antigua and Barbuda,2005,Tourist/visitor arrivals (thousands),TF,,245.0000,Excluding nationals residing abroad.;Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +28,Antigua and Barbuda,2010,Tourist/visitor arrivals (thousands),TF,,230.0000,Excluding nationals residing abroad.;Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +28,Antigua and Barbuda,2016,Tourist/visitor arrivals (thousands),TF,,265.0000,Excluding nationals residing abroad.;Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +28,Antigua and Barbuda,2017,Tourist/visitor arrivals (thousands),TF,,247.0000,Excluding nationals residing abroad.;Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +28,Antigua and Barbuda,2018,Tourist/visitor arrivals (thousands),TF,,269.0000,Excluding nationals residing abroad.;Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +28,Antigua and Barbuda,1995,Tourism expenditure (millions of US dollars),,,247.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +28,Antigua and Barbuda,2005,Tourism expenditure (millions of US dollars),,,309.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +28,Antigua and Barbuda,2010,Tourism expenditure (millions of US dollars),,,298.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +28,Antigua and Barbuda,2016,Tourism expenditure (millions of US dollars),,,753.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +28,Antigua and Barbuda,2017,Tourism expenditure (millions of US dollars),,,737.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +28,Antigua and Barbuda,2018,Tourism expenditure (millions of US dollars),,,881.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +32,Argentina,1995,Tourist/visitor arrivals (thousands),TF,,2289.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +32,Argentina,2005,Tourist/visitor arrivals (thousands),TF,,3823.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +32,Argentina,2010,Tourist/visitor arrivals (thousands),TF,,6800.0000,Break in the time series.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +32,Argentina,2016,Tourist/visitor arrivals (thousands),TF,,6668.0000,Break in the time series.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +32,Argentina,2017,Tourist/visitor arrivals (thousands),TF,,6711.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +32,Argentina,2018,Tourist/visitor arrivals (thousands),TF,,6942.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +32,Argentina,1995,Tourism expenditure (millions of US dollars),,,2550.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +32,Argentina,2005,Tourism expenditure (millions of US dollars),,,3209.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +32,Argentina,2010,Tourism expenditure (millions of US dollars),,,5605.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +32,Argentina,2016,Tourism expenditure (millions of US dollars),,,5466.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +32,Argentina,2017,Tourism expenditure (millions of US dollars),,,5835.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +32,Argentina,2018,Tourism expenditure (millions of US dollars),,,5999.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +51,Armenia,1995,Tourist/visitor arrivals (thousands),TF,,12.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +51,Armenia,2005,Tourist/visitor arrivals (thousands),TF,,319.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +51,Armenia,2010,Tourist/visitor arrivals (thousands),TF,,684.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +51,Armenia,2016,Tourist/visitor arrivals (thousands),TF,,1260.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +51,Armenia,2017,Tourist/visitor arrivals (thousands),TF,,1495.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +51,Armenia,2018,Tourist/visitor arrivals (thousands),TF,,1652.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +51,Armenia,1995,Tourism expenditure (millions of US dollars),,,14.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +51,Armenia,2005,Tourism expenditure (millions of US dollars),,,243.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +51,Armenia,2010,Tourism expenditure (millions of US dollars),,,694.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +51,Armenia,2016,Tourism expenditure (millions of US dollars),,,988.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +51,Armenia,2017,Tourism expenditure (millions of US dollars),,,1140.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +51,Armenia,2018,Tourism expenditure (millions of US dollars),,,1237.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +533,Aruba,1995,Tourist/visitor arrivals (thousands),TF,,619.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +533,Aruba,2005,Tourist/visitor arrivals (thousands),TF,,733.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +533,Aruba,2010,Tourist/visitor arrivals (thousands),TF,,824.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +533,Aruba,2016,Tourist/visitor arrivals (thousands),TF,,1102.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +533,Aruba,2017,Tourist/visitor arrivals (thousands),TF,,1070.5000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +533,Aruba,2018,Tourist/visitor arrivals (thousands),TF,,1082.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +533,Aruba,1995,Tourism expenditure (millions of US dollars),,,554.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +533,Aruba,2005,Tourism expenditure (millions of US dollars),,,1097.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +533,Aruba,2010,Tourism expenditure (millions of US dollars),,,1254.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +533,Aruba,2016,Tourism expenditure (millions of US dollars),,,1764.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +533,Aruba,2017,Tourism expenditure (millions of US dollars),,,1857.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +533,Aruba,2018,Tourism expenditure (millions of US dollars),,,2024.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +36,Australia,1995,Tourist/visitor arrivals (thousands),VF,,3726.0000,Excluding nationals residing abroad and crew members.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +36,Australia,2005,Tourist/visitor arrivals (thousands),VF,,5499.0000,Excluding nationals residing abroad and crew members.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +36,Australia,2010,Tourist/visitor arrivals (thousands),VF,,5790.0000,Excluding nationals residing abroad and crew members.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +36,Australia,2016,Tourist/visitor arrivals (thousands),VF,,8269.0000,Excluding nationals residing abroad and crew members.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +36,Australia,2017,Tourist/visitor arrivals (thousands),VF,,8815.0000,Excluding nationals residing abroad and crew members.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +36,Australia,2018,Tourist/visitor arrivals (thousands),VF,,9246.0000,Excluding nationals residing abroad and crew members.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +36,Australia,1995,Tourism expenditure (millions of US dollars),,,10370.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +36,Australia,2005,Tourism expenditure (millions of US dollars),,,19719.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +36,Australia,2010,Tourism expenditure (millions of US dollars),,,31064.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +36,Australia,2016,Tourism expenditure (millions of US dollars),,,39059.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +36,Australia,2017,Tourism expenditure (millions of US dollars),,,43975.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +36,Australia,2018,Tourism expenditure (millions of US dollars),,,47327.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +40,Austria,1995,Tourist/visitor arrivals (thousands),TCE,,17173.0000,Only paid accommodation; excluding stays at friends and relatives and second homes.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +40,Austria,2005,Tourist/visitor arrivals (thousands),TCE,,19952.0000,Only paid accommodation; excluding stays at friends and relatives and second homes.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +40,Austria,2010,Tourist/visitor arrivals (thousands),TCE,,22004.0000,Only paid accommodation; excluding stays at friends and relatives and second homes.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +40,Austria,2016,Tourist/visitor arrivals (thousands),TCE,,28121.0000,Only paid accommodation; excluding stays at friends and relatives and second homes.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +40,Austria,2017,Tourist/visitor arrivals (thousands),TCE,,29460.0000,Only paid accommodation; excluding stays at friends and relatives and second homes.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +40,Austria,2018,Tourist/visitor arrivals (thousands),TCE,,30816.0000,Only paid accommodation; excluding stays at friends and relatives and second homes.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +40,Austria,1995,Tourism expenditure (millions of US dollars),,,13435.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +40,Austria,2005,Tourism expenditure (millions of US dollars),,,16243.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +40,Austria,2010,Tourism expenditure (millions of US dollars),,,18751.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +40,Austria,2016,Tourism expenditure (millions of US dollars),,,19244.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +40,Austria,2017,Tourism expenditure (millions of US dollars),,,20333.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +40,Austria,2018,Tourism expenditure (millions of US dollars),,,23233.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +31,Azerbaijan,2005,Tourist/visitor arrivals (thousands),TF,,693.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +31,Azerbaijan,2010,Tourist/visitor arrivals (thousands),TF,,1280.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +31,Azerbaijan,2016,Tourist/visitor arrivals (thousands),TF,,2044.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +31,Azerbaijan,2017,Tourist/visitor arrivals (thousands),TF,,2454.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +31,Azerbaijan,2018,Tourist/visitor arrivals (thousands),TF,,2633.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +31,Azerbaijan,1995,Tourism expenditure (millions of US dollars),,,87.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +31,Azerbaijan,2005,Tourism expenditure (millions of US dollars),,,100.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +31,Azerbaijan,2010,Tourism expenditure (millions of US dollars),,,792.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +31,Azerbaijan,2016,Tourism expenditure (millions of US dollars),,,2855.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +31,Azerbaijan,2017,Tourism expenditure (millions of US dollars),,,3214.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +31,Azerbaijan,2018,Tourism expenditure (millions of US dollars),,,2830.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +44,Bahamas,1995,Tourist/visitor arrivals (thousands),TF,,1598.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +44,Bahamas,2005,Tourist/visitor arrivals (thousands),TF,,1608.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +44,Bahamas,2010,Tourist/visitor arrivals (thousands),TF,,1370.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +44,Bahamas,2016,Tourist/visitor arrivals (thousands),TF,,1500.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +44,Bahamas,2017,Tourist/visitor arrivals (thousands),TF,,1442.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +44,Bahamas,2018,Tourist/visitor arrivals (thousands),TF,,1633.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +44,Bahamas,1995,Tourism expenditure (millions of US dollars),,,1356.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +44,Bahamas,2005,Tourism expenditure (millions of US dollars),,,2081.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +44,Bahamas,2010,Tourism expenditure (millions of US dollars),,,2159.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +44,Bahamas,2016,Tourism expenditure (millions of US dollars),,,3091.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +44,Bahamas,2017,Tourism expenditure (millions of US dollars),,,3017.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +44,Bahamas,2018,Tourism expenditure (millions of US dollars),,,3383.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +48,Bahrain,1995,Tourist/visitor arrivals (thousands),VF,,2311.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +48,Bahrain,2005,Tourist/visitor arrivals (thousands),VF,,6313.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +48,Bahrain,2010,Tourist/visitor arrivals (thousands),VF,,11952.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +48,Bahrain,2016,Tourist/visitor arrivals (thousands),VF,,10158.0000,Break in the time series.;Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +48,Bahrain,2017,Tourist/visitor arrivals (thousands),VF,,11374.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +48,Bahrain,2018,Tourist/visitor arrivals (thousands),VF,,12045.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +48,Bahrain,1995,Tourism expenditure (millions of US dollars),,,593.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +48,Bahrain,2005,Tourism expenditure (millions of US dollars),,,1603.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +48,Bahrain,2010,Tourism expenditure (millions of US dollars),,,2163.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +48,Bahrain,2016,Tourism expenditure (millions of US dollars),,,4021.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +48,Bahrain,2017,Tourism expenditure (millions of US dollars),,,4380.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +48,Bahrain,2018,Tourism expenditure (millions of US dollars),,,3834.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +50,Bangladesh,1995,Tourist/visitor arrivals (thousands),TF,,156.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +50,Bangladesh,2005,Tourist/visitor arrivals (thousands),TF,,208.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +50,Bangladesh,2010,Tourist/visitor arrivals (thousands),TF,,303.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +50,Bangladesh,2016,Tourist/visitor arrivals (thousands),TF,,830.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +50,Bangladesh,2017,Tourist/visitor arrivals (thousands),TF,,1026.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +50,Bangladesh,2005,Tourism expenditure (millions of US dollars),,,82.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +50,Bangladesh,2010,Tourism expenditure (millions of US dollars),,,103.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +50,Bangladesh,2016,Tourism expenditure (millions of US dollars),,,214.3000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +50,Bangladesh,2017,Tourism expenditure (millions of US dollars),,,348.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +50,Bangladesh,2018,Tourism expenditure (millions of US dollars),,,357.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +52,Barbados,1995,Tourist/visitor arrivals (thousands),TF,,442.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +52,Barbados,2005,Tourist/visitor arrivals (thousands),TF,,548.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +52,Barbados,2010,Tourist/visitor arrivals (thousands),TF,,532.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +52,Barbados,2016,Tourist/visitor arrivals (thousands),TF,,632.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +52,Barbados,2017,Tourist/visitor arrivals (thousands),TF,,664.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +52,Barbados,2018,Tourist/visitor arrivals (thousands),TF,,680.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +52,Barbados,1995,Tourism expenditure (millions of US dollars),,,630.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +52,Barbados,2005,Tourism expenditure (millions of US dollars),,,1081.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +52,Barbados,2010,Tourism expenditure (millions of US dollars),,,1074.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +112,Belarus,1995,Tourist/visitor arrivals (thousands),TF,,160.6000,Excludes the Belarusian-Russian border segment.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +112,Belarus,2005,Tourist/visitor arrivals (thousands),TF,,91.0000,Excludes the Belarusian-Russian border segment.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +112,Belarus,2010,Tourist/visitor arrivals (thousands),TF,,119.3000,Excludes the Belarusian-Russian border segment.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +112,Belarus,2016,Tourist/visitor arrivals (thousands),TF,,10935.4000,Includes estimation of the Belarusian-Russian border segment.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +112,Belarus,2017,Tourist/visitor arrivals (thousands),TF,,11060.2000,Includes estimation of the Belarusian-Russian border segment.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +112,Belarus,2018,Tourist/visitor arrivals (thousands),TF,,11501.6000,Includes estimation of the Belarusian-Russian border segment.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +112,Belarus,1995,Tourism expenditure (millions of US dollars),,,28.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +112,Belarus,2005,Tourism expenditure (millions of US dollars),,,346.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +112,Belarus,2010,Tourism expenditure (millions of US dollars),,,665.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +112,Belarus,2016,Tourism expenditure (millions of US dollars),,,1019.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +112,Belarus,2017,Tourism expenditure (millions of US dollars),,,1124.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +112,Belarus,2018,Tourism expenditure (millions of US dollars),,,1221.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +56,Belgium,1995,Tourist/visitor arrivals (thousands),TCE,,5560.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +56,Belgium,2005,Tourist/visitor arrivals (thousands),TCE,,6747.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +56,Belgium,2010,Tourist/visitor arrivals (thousands),TCE,,7186.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +56,Belgium,2016,Tourist/visitor arrivals (thousands),TCE,,7481.0000,Break in the time series.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +56,Belgium,2017,Tourist/visitor arrivals (thousands),TCE,,8385.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +56,Belgium,2018,Tourist/visitor arrivals (thousands),TCE,,9119.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +56,Belgium,2005,Tourism expenditure (millions of US dollars),,,10881.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +56,Belgium,2010,Tourism expenditure (millions of US dollars),,,12680.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +56,Belgium,2016,Tourism expenditure (millions of US dollars),,,8784.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +56,Belgium,2017,Tourism expenditure (millions of US dollars),,,9636.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +56,Belgium,2018,Tourism expenditure (millions of US dollars),,,10381.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +84,Belize,1995,Tourist/visitor arrivals (thousands),TF,,131.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +84,Belize,2005,Tourist/visitor arrivals (thousands),TF,,237.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +84,Belize,2010,Tourist/visitor arrivals (thousands),TF,,242.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +84,Belize,2016,Tourist/visitor arrivals (thousands),TF,,386.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +84,Belize,2017,Tourist/visitor arrivals (thousands),TF,,427.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +84,Belize,2018,Tourist/visitor arrivals (thousands),TF,,489.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +84,Belize,1995,Tourism expenditure (millions of US dollars),,,78.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +84,Belize,2005,Tourism expenditure (millions of US dollars),,,214.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +84,Belize,2010,Tourism expenditure (millions of US dollars),,,264.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +84,Belize,2016,Tourism expenditure (millions of US dollars),,,391.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +84,Belize,2017,Tourism expenditure (millions of US dollars),,,427.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +84,Belize,2018,Tourism expenditure (millions of US dollars),,,487.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +204,Benin,1995,Tourist/visitor arrivals (thousands),TF,,138.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +204,Benin,2005,Tourist/visitor arrivals (thousands),TF,,176.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +204,Benin,2010,Tourist/visitor arrivals (thousands),TF,,199.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +204,Benin,2016,Tourist/visitor arrivals (thousands),TF,,267.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +204,Benin,2017,Tourist/visitor arrivals (thousands),TF,,281.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +204,Benin,2018,Tourist/visitor arrivals (thousands),TF,,295.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +204,Benin,2005,Tourism expenditure (millions of US dollars),,,107.7000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +204,Benin,2010,Tourism expenditure (millions of US dollars),,,149.4000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +204,Benin,2016,Tourism expenditure (millions of US dollars),,,129.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +204,Benin,2017,Tourism expenditure (millions of US dollars),,,160.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +60,Bermuda,1995,Tourist/visitor arrivals (thousands),TF,,387.0000,Excluding nationals residing abroad.;Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +60,Bermuda,2005,Tourist/visitor arrivals (thousands),TF,,270.0000,Excluding nationals residing abroad.;Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +60,Bermuda,2010,Tourist/visitor arrivals (thousands),TF,,232.0000,Excluding nationals residing abroad.;Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +60,Bermuda,2016,Tourist/visitor arrivals (thousands),TF,,244.0000,Excluding nationals residing abroad.;Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +60,Bermuda,2017,Tourist/visitor arrivals (thousands),TF,,270.0000,Excluding nationals residing abroad.;Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +60,Bermuda,2018,Tourist/visitor arrivals (thousands),TF,,282.0000,Excluding nationals residing abroad.;Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +60,Bermuda,1995,Tourism expenditure (millions of US dollars),,,488.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +60,Bermuda,2005,Tourism expenditure (millions of US dollars),,,429.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +60,Bermuda,2010,Tourism expenditure (millions of US dollars),,,442.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +60,Bermuda,2016,Tourism expenditure (millions of US dollars),,,441.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +60,Bermuda,2017,Tourism expenditure (millions of US dollars),,,513.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +60,Bermuda,2018,Tourism expenditure (millions of US dollars),,,583.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +64,Bhutan,1995,Tourist/visitor arrivals (thousands),TF,,4.8000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +64,Bhutan,2005,Tourist/visitor arrivals (thousands),TF,,13.6000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +64,Bhutan,2010,Tourist/visitor arrivals (thousands),TF,,41.0000,Break in the time series.;Including regional high end tourists.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +64,Bhutan,2016,Tourist/visitor arrivals (thousands),TF,,210.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +64,Bhutan,2017,Tourist/visitor arrivals (thousands),TF,,255.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +64,Bhutan,2018,Tourist/visitor arrivals (thousands),TF,,274.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +64,Bhutan,1995,Tourism expenditure (millions of US dollars),,,5.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +64,Bhutan,2005,Tourism expenditure (millions of US dollars),,,19.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +64,Bhutan,2010,Tourism expenditure (millions of US dollars),,,64.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +64,Bhutan,2016,Tourism expenditure (millions of US dollars),,,139.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +64,Bhutan,2017,Tourism expenditure (millions of US dollars),,,153.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +64,Bhutan,2018,Tourism expenditure (millions of US dollars),,,121.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +68,Bolivia (Plurin. State of),1995,Tourist/visitor arrivals (thousands),TF,,284.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +68,Bolivia (Plurin. State of),2005,Tourist/visitor arrivals (thousands),TF,,524.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +68,Bolivia (Plurin. State of),2010,Tourist/visitor arrivals (thousands),TF,,679.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +68,Bolivia (Plurin. State of),2016,Tourist/visitor arrivals (thousands),TF,,961.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +68,Bolivia (Plurin. State of),2017,Tourist/visitor arrivals (thousands),TF,,1109.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +68,Bolivia (Plurin. State of),2018,Tourist/visitor arrivals (thousands),TF,,1142.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +68,Bolivia (Plurin. State of),1995,Tourism expenditure (millions of US dollars),,,92.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +68,Bolivia (Plurin. State of),2005,Tourism expenditure (millions of US dollars),,,345.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +68,Bolivia (Plurin. State of),2010,Tourism expenditure (millions of US dollars),,,339.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +68,Bolivia (Plurin. State of),2016,Tourism expenditure (millions of US dollars),,,827.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +68,Bolivia (Plurin. State of),2017,Tourism expenditure (millions of US dollars),,,912.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +68,Bolivia (Plurin. State of),2018,Tourism expenditure (millions of US dollars),,,970.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +669,Bonaire,1995,Tourist/visitor arrivals (thousands),TF,,59.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +669,Bonaire,2005,Tourist/visitor arrivals (thousands),TF,,63.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +669,Bonaire,2010,Tourist/visitor arrivals (thousands),TF,,71.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +669,Bonaire,1995,Tourism expenditure (millions of US dollars),,,37.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +669,Bonaire,2005,Tourism expenditure (millions of US dollars),,,87.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +70,Bosnia and Herzegovina,2005,Tourist/visitor arrivals (thousands),TCE,,217.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +70,Bosnia and Herzegovina,2010,Tourist/visitor arrivals (thousands),TCE,,365.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +70,Bosnia and Herzegovina,2016,Tourist/visitor arrivals (thousands),TCE,,778.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +70,Bosnia and Herzegovina,2017,Tourist/visitor arrivals (thousands),TCE,,923.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +70,Bosnia and Herzegovina,2018,Tourist/visitor arrivals (thousands),TCE,,1053.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +70,Bosnia and Herzegovina,2005,Tourism expenditure (millions of US dollars),,,557.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +70,Bosnia and Herzegovina,2010,Tourism expenditure (millions of US dollars),,,662.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +70,Bosnia and Herzegovina,2016,Tourism expenditure (millions of US dollars),,,876.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +70,Bosnia and Herzegovina,2017,Tourism expenditure (millions of US dollars),,,985.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +70,Bosnia and Herzegovina,2018,Tourism expenditure (millions of US dollars),,,1081.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +72,Botswana,1995,Tourist/visitor arrivals (thousands),TF,,521.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +72,Botswana,2005,Tourist/visitor arrivals (thousands),TF,,1474.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +72,Botswana,2010,Tourist/visitor arrivals (thousands),TF,,1973.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +72,Botswana,2016,Tourist/visitor arrivals (thousands),TF,,1574.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +72,Botswana,2017,Tourist/visitor arrivals (thousands),TF,,1623.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +72,Botswana,1995,Tourism expenditure (millions of US dollars),,,176.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +72,Botswana,2005,Tourism expenditure (millions of US dollars),,,563.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +72,Botswana,2010,Tourism expenditure (millions of US dollars),,,440.1000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +72,Botswana,2016,Tourism expenditure (millions of US dollars),,,505.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +72,Botswana,2017,Tourism expenditure (millions of US dollars),,,541.6000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +72,Botswana,2018,Tourism expenditure (millions of US dollars),,,575.3000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +76,Brazil,1995,Tourist/visitor arrivals (thousands),TF,,1991.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +76,Brazil,2005,Tourist/visitor arrivals (thousands),TF,,5358.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +76,Brazil,2010,Tourist/visitor arrivals (thousands),TF,,5161.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +76,Brazil,2016,Tourist/visitor arrivals (thousands),TF,,6547.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +76,Brazil,2017,Tourist/visitor arrivals (thousands),TF,,6589.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +76,Brazil,2018,Tourist/visitor arrivals (thousands),TF,,6621.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +76,Brazil,1995,Tourism expenditure (millions of US dollars),,,1085.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +76,Brazil,2005,Tourism expenditure (millions of US dollars),,,4168.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +76,Brazil,2010,Tourism expenditure (millions of US dollars),,,5522.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +76,Brazil,2016,Tourism expenditure (millions of US dollars),,,6613.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +76,Brazil,2017,Tourism expenditure (millions of US dollars),,,6175.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +76,Brazil,2018,Tourism expenditure (millions of US dollars),,,6324.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +92,British Virgin Islands,1995,Tourist/visitor arrivals (thousands),TF,,219.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +92,British Virgin Islands,2005,Tourist/visitor arrivals (thousands),TF,,337.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +92,British Virgin Islands,2010,Tourist/visitor arrivals (thousands),TF,,330.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +92,British Virgin Islands,2016,Tourist/visitor arrivals (thousands),TF,,408.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +92,British Virgin Islands,2017,Tourist/visitor arrivals (thousands),TF,,335.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +92,British Virgin Islands,2018,Tourist/visitor arrivals (thousands),TF,,192.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +92,British Virgin Islands,1995,Tourism expenditure (millions of US dollars),,,211.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +92,British Virgin Islands,2005,Tourism expenditure (millions of US dollars),,,412.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +92,British Virgin Islands,2010,Tourism expenditure (millions of US dollars),,,389.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +96,Brunei Darussalam,2005,Tourist/visitor arrivals (thousands),TF,,126.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +96,Brunei Darussalam,2010,Tourist/visitor arrivals (thousands),TF,,214.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +96,Brunei Darussalam,2016,Tourist/visitor arrivals (thousands),TF,,219.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +96,Brunei Darussalam,2017,Tourist/visitor arrivals (thousands),TF,,259.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +96,Brunei Darussalam,2018,Tourist/visitor arrivals (thousands),TF,,278.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +96,Brunei Darussalam,2005,Tourism expenditure (millions of US dollars),,,191.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +96,Brunei Darussalam,2016,Tourism expenditure (millions of US dollars),,,144.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +96,Brunei Darussalam,2017,Tourism expenditure (millions of US dollars),,,177.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +96,Brunei Darussalam,2018,Tourism expenditure (millions of US dollars),,,190.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +100,Bulgaria,1995,Tourist/visitor arrivals (thousands),TF,,3466.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +100,Bulgaria,2005,Tourist/visitor arrivals (thousands),TF,,4837.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +100,Bulgaria,2010,Tourist/visitor arrivals (thousands),TF,,6047.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +100,Bulgaria,2016,Tourist/visitor arrivals (thousands),TF,,8252.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +100,Bulgaria,2017,Tourist/visitor arrivals (thousands),TF,,8883.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +100,Bulgaria,2018,Tourist/visitor arrivals (thousands),TF,,9273.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +100,Bulgaria,1995,Tourism expenditure (millions of US dollars),,,662.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +100,Bulgaria,2005,Tourism expenditure (millions of US dollars),,,3063.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +100,Bulgaria,2010,Tourism expenditure (millions of US dollars),,,3807.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +100,Bulgaria,2016,Tourism expenditure (millions of US dollars),,,4164.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +100,Bulgaria,2017,Tourism expenditure (millions of US dollars),,,4678.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +100,Bulgaria,2018,Tourism expenditure (millions of US dollars),,,5072.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +854,Burkina Faso,1995,Tourist/visitor arrivals (thousands),THS,,124.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +854,Burkina Faso,2005,Tourist/visitor arrivals (thousands),THS,,245.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +854,Burkina Faso,2010,Tourist/visitor arrivals (thousands),THS,,274.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +854,Burkina Faso,2016,Tourist/visitor arrivals (thousands),THS,,152.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +854,Burkina Faso,2017,Tourist/visitor arrivals (thousands),THS,,143.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +854,Burkina Faso,2018,Tourist/visitor arrivals (thousands),THS,,144.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +854,Burkina Faso,2005,Tourism expenditure (millions of US dollars),,,46.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +854,Burkina Faso,2010,Tourism expenditure (millions of US dollars),,,105.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +854,Burkina Faso,2016,Tourism expenditure (millions of US dollars),,,172.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +854,Burkina Faso,2017,Tourism expenditure (millions of US dollars),,,172.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +108,Burundi,1995,Tourist/visitor arrivals (thousands),TF,,34.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +108,Burundi,2005,Tourist/visitor arrivals (thousands),TF,,148.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +108,Burundi,2010,Tourist/visitor arrivals (thousands),TF,,142.0000,Break in the time series.;Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +108,Burundi,2016,Tourist/visitor arrivals (thousands),TF,,187.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +108,Burundi,2017,Tourist/visitor arrivals (thousands),TF,,299.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +108,Burundi,1995,Tourism expenditure (millions of US dollars),,,2.4250,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +108,Burundi,2005,Tourism expenditure (millions of US dollars),,,1.9000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +108,Burundi,2010,Tourism expenditure (millions of US dollars),,,2.1000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +132,Cabo Verde,1995,Tourist/visitor arrivals (thousands),TF,,28.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +132,Cabo Verde,2005,Tourist/visitor arrivals (thousands),TF,,198.0000,Non-resident tourists staying in hotels and similar establishments.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +132,Cabo Verde,2010,Tourist/visitor arrivals (thousands),TF,,336.0000,Non-resident tourists staying in hotels and similar establishments.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +132,Cabo Verde,2016,Tourist/visitor arrivals (thousands),TF,,598.0000,Non-resident tourists staying in hotels and similar establishments.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +132,Cabo Verde,2017,Tourist/visitor arrivals (thousands),TF,,668.0000,Non-resident tourists staying in hotels and similar establishments.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +132,Cabo Verde,2018,Tourist/visitor arrivals (thousands),TF,,710.0000,Non-resident tourists staying in hotels and similar establishments.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +132,Cabo Verde,1995,Tourism expenditure (millions of US dollars),,,29.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +132,Cabo Verde,2005,Tourism expenditure (millions of US dollars),,,177.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +132,Cabo Verde,2010,Tourism expenditure (millions of US dollars),,,387.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +132,Cabo Verde,2016,Tourism expenditure (millions of US dollars),,,397.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +132,Cabo Verde,2017,Tourism expenditure (millions of US dollars),,,450.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +132,Cabo Verde,2018,Tourism expenditure (millions of US dollars),,,524.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +116,Cambodia,1995,Tourist/visitor arrivals (thousands),TF,,220.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +116,Cambodia,2005,Tourist/visitor arrivals (thousands),TF,,1422.0000,Arrivals by all means of transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +116,Cambodia,2010,Tourist/visitor arrivals (thousands),TF,,2508.0000,Arrivals by all means of transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +116,Cambodia,2016,Tourist/visitor arrivals (thousands),TF,,5012.0000,Arrivals by all means of transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +116,Cambodia,2017,Tourist/visitor arrivals (thousands),TF,,5602.0000,Arrivals by all means of transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +116,Cambodia,2018,Tourist/visitor arrivals (thousands),TF,,6201.0000,Arrivals by all means of transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +116,Cambodia,1995,Tourism expenditure (millions of US dollars),,,71.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +116,Cambodia,2005,Tourism expenditure (millions of US dollars),,,929.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +116,Cambodia,2010,Tourism expenditure (millions of US dollars),,,1671.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +116,Cambodia,2016,Tourism expenditure (millions of US dollars),,,3523.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +116,Cambodia,2017,Tourism expenditure (millions of US dollars),,,4024.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +116,Cambodia,2018,Tourism expenditure (millions of US dollars),,,4832.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +120,Cameroon,2010,Tourist/visitor arrivals (thousands),VF,,573.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +120,Cameroon,2016,Tourist/visitor arrivals (thousands),VF,,994.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +120,Cameroon,2017,Tourist/visitor arrivals (thousands),VF,,1081.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +120,Cameroon,1995,Tourism expenditure (millions of US dollars),,,75.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +120,Cameroon,2005,Tourism expenditure (millions of US dollars),,,229.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +120,Cameroon,2010,Tourism expenditure (millions of US dollars),,,171.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +120,Cameroon,2016,Tourism expenditure (millions of US dollars),,,508.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +120,Cameroon,2017,Tourism expenditure (millions of US dollars),,,543.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +120,Cameroon,2018,Tourism expenditure (millions of US dollars),,,633.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +124,Canada,1995,Tourist/visitor arrivals (thousands),TF,,16932.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +124,Canada,2005,Tourist/visitor arrivals (thousands),TF,,18771.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +124,Canada,2010,Tourist/visitor arrivals (thousands),TF,,16219.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +124,Canada,2016,Tourist/visitor arrivals (thousands),TF,,19971.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +124,Canada,2017,Tourist/visitor arrivals (thousands),TF,,20883.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +124,Canada,2018,Tourist/visitor arrivals (thousands),TF,,21134.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +124,Canada,1995,Tourism expenditure (millions of US dollars),,,9176.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +124,Canada,2005,Tourism expenditure (millions of US dollars),,,15887.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +124,Canada,2010,Tourism expenditure (millions of US dollars),,,18439.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +136,Cayman Islands,1995,Tourist/visitor arrivals (thousands),TF,,361.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +136,Cayman Islands,2005,Tourist/visitor arrivals (thousands),TF,,168.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +136,Cayman Islands,2010,Tourist/visitor arrivals (thousands),TF,,288.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +136,Cayman Islands,2016,Tourist/visitor arrivals (thousands),TF,,385.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +136,Cayman Islands,2017,Tourist/visitor arrivals (thousands),TF,,418.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +136,Cayman Islands,2018,Tourist/visitor arrivals (thousands),TF,,463.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +136,Cayman Islands,1995,Tourism expenditure (millions of US dollars),,,394.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +136,Cayman Islands,2005,Tourism expenditure (millions of US dollars),,,356.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +136,Cayman Islands,2010,Tourism expenditure (millions of US dollars),,,465.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +136,Cayman Islands,2016,Tourism expenditure (millions of US dollars),,,696.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +136,Cayman Islands,2017,Tourism expenditure (millions of US dollars),,,782.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +136,Cayman Islands,2018,Tourism expenditure (millions of US dollars),,,880.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +140,Central African Republic,1995,Tourist/visitor arrivals (thousands),TF,,26.0000,Arrivals by air at Bangui only.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +140,Central African Republic,2005,Tourist/visitor arrivals (thousands),TF,,12.0000,Arrivals by air at Bangui only.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +140,Central African Republic,2010,Tourist/visitor arrivals (thousands),TF,,53.8000,Arrivals by air at Bangui only.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +140,Central African Republic,2016,Tourist/visitor arrivals (thousands),TF,,82.0000,Arrivals by air at Bangui only.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +140,Central African Republic,2017,Tourist/visitor arrivals (thousands),TF,,107.0000,Arrivals by air at Bangui only.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +140,Central African Republic,1995,Tourism expenditure (millions of US dollars),,,4.0000,Arrivals by air at Bangui only.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +140,Central African Republic,2005,Tourism expenditure (millions of US dollars),,,7.2000,Arrivals by air at Bangui only.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +140,Central African Republic,2010,Tourism expenditure (millions of US dollars),,,14.4000,Arrivals by air at Bangui only.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +148,Chad,2010,Tourist/visitor arrivals (thousands),TF,,71.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +148,Chad,2016,Tourist/visitor arrivals (thousands),TF,,98.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +148,Chad,2017,Tourist/visitor arrivals (thousands),TF,,87.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +148,Chad,1995,Tourism expenditure (millions of US dollars),,,43.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +152,Chile,1995,Tourist/visitor arrivals (thousands),TF,,1540.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +152,Chile,2005,Tourist/visitor arrivals (thousands),TF,,2027.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +152,Chile,2010,Tourist/visitor arrivals (thousands),TF,,2801.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +152,Chile,2016,Tourist/visitor arrivals (thousands),TF,,5641.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +152,Chile,2017,Tourist/visitor arrivals (thousands),TF,,6450.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +152,Chile,2018,Tourist/visitor arrivals (thousands),TF,,5723.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +152,Chile,1995,Tourism expenditure (millions of US dollars),,,1186.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +152,Chile,2005,Tourism expenditure (millions of US dollars),,,1608.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +152,Chile,2010,Tourism expenditure (millions of US dollars),,,2362.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +152,Chile,2016,Tourism expenditure (millions of US dollars),,,3744.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +152,Chile,2017,Tourism expenditure (millions of US dollars),,,4372.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +152,Chile,2018,Tourism expenditure (millions of US dollars),,,3972.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +156,China,1995,Tourist/visitor arrivals (thousands),TF,,20034.0000,"For statistical purposes, the data for China do not include those for the Hong Kong Special Administrative Region (Hong Kong SAR), Macao Special Administrative Region (Macao SAR) and Taiwan Province of China.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +156,China,2005,Tourist/visitor arrivals (thousands),TF,,46809.0000,"For statistical purposes, the data for China do not include those for the Hong Kong Special Administrative Region (Hong Kong SAR), Macao Special Administrative Region (Macao SAR) and Taiwan Province of China.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +156,China,2010,Tourist/visitor arrivals (thousands),TF,,55664.0000,"For statistical purposes, the data for China do not include those for the Hong Kong Special Administrative Region (Hong Kong SAR), Macao Special Administrative Region (Macao SAR) and Taiwan Province of China.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +156,China,2016,Tourist/visitor arrivals (thousands),TF,,59270.0000,"For statistical purposes, the data for China do not include those for the Hong Kong Special Administrative Region (Hong Kong SAR), Macao Special Administrative Region (Macao SAR) and Taiwan Province of China.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +156,China,2017,Tourist/visitor arrivals (thousands),TF,,60740.0000,"For statistical purposes, the data for China do not include those for the Hong Kong Special Administrative Region (Hong Kong SAR), Macao Special Administrative Region (Macao SAR) and Taiwan Province of China.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +156,China,2018,Tourist/visitor arrivals (thousands),TF,,62900.0000,"For statistical purposes, the data for China do not include those for the Hong Kong Special Administrative Region (Hong Kong SAR), Macao Special Administrative Region (Macao SAR) and Taiwan Province of China.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +156,China,1995,Tourism expenditure (millions of US dollars),,,8730.0000,"For statistical purposes, the data for China do not include those for the Hong Kong Special Administrative Region (Hong Kong SAR), Macao Special Administrative Region (Macao SAR) and Taiwan Province of China.;Excluding passenger transport.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +156,China,2005,Tourism expenditure (millions of US dollars),,,29296.0000,"For statistical purposes, the data for China do not include those for the Hong Kong Special Administrative Region (Hong Kong SAR), Macao Special Administrative Region (Macao SAR) and Taiwan Province of China.;Excluding passenger transport.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +156,China,2010,Tourism expenditure (millions of US dollars),,,45814.0000,"For statistical purposes, the data for China do not include those for the Hong Kong Special Administrative Region (Hong Kong SAR), Macao Special Administrative Region (Macao SAR) and Taiwan Province of China.;Excluding passenger transport.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +156,China,2016,Tourism expenditure (millions of US dollars),,,44432.0000,"For statistical purposes, the data for China do not include those for the Hong Kong Special Administrative Region (Hong Kong SAR), Macao Special Administrative Region (Macao SAR) and Taiwan Province of China.;Excluding passenger transport.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +156,China,2017,Tourism expenditure (millions of US dollars),,,38559.0000,"For statistical purposes, the data for China do not include those for the Hong Kong Special Administrative Region (Hong Kong SAR), Macao Special Administrative Region (Macao SAR) and Taiwan Province of China.;Excluding passenger transport.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +156,China,2018,Tourism expenditure (millions of US dollars),,,40386.0000,"For statistical purposes, the data for China do not include those for the Hong Kong Special Administrative Region (Hong Kong SAR), Macao Special Administrative Region (Macao SAR) and Taiwan Province of China.;Excluding passenger transport.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +344,"China, Hong Kong SAR",2005,Tourist/visitor arrivals (thousands),TF,,14773.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +344,"China, Hong Kong SAR",2010,Tourist/visitor arrivals (thousands),TF,,20085.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +344,"China, Hong Kong SAR",2016,Tourist/visitor arrivals (thousands),TF,,26553.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +344,"China, Hong Kong SAR",2017,Tourist/visitor arrivals (thousands),TF,,27884.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +344,"China, Hong Kong SAR",2018,Tourist/visitor arrivals (thousands),TF,,29263.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +344,"China, Hong Kong SAR",2005,Tourism expenditure (millions of US dollars),,,13588.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +344,"China, Hong Kong SAR",2010,Tourism expenditure (millions of US dollars),,,27208.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +344,"China, Hong Kong SAR",2016,Tourism expenditure (millions of US dollars),,,37838.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +344,"China, Hong Kong SAR",2017,Tourism expenditure (millions of US dollars),,,38170.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +344,"China, Hong Kong SAR",2018,Tourism expenditure (millions of US dollars),,,41870.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +446,"China, Macao SAR",1995,Tourist/visitor arrivals (thousands),TF,,4202.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +446,"China, Macao SAR",2005,Tourist/visitor arrivals (thousands),TF,,9014.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +446,"China, Macao SAR",2010,Tourist/visitor arrivals (thousands),TF,,11926.0000,"Does not include other non-residents namely workers, students, etc.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +446,"China, Macao SAR",2016,Tourist/visitor arrivals (thousands),TF,,15703.6000,"Does not include other non-residents namely workers, students, etc.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +446,"China, Macao SAR",2017,Tourist/visitor arrivals (thousands),TF,,17255.0000,"Does not include other non-residents namely workers, students, etc.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +446,"China, Macao SAR",2018,Tourist/visitor arrivals (thousands),TF,,18493.0000,"Does not include other non-residents namely workers, students, etc.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +446,"China, Macao SAR",1995,Tourism expenditure (millions of US dollars),,,3233.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +446,"China, Macao SAR",2005,Tourism expenditure (millions of US dollars),,,7181.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +446,"China, Macao SAR",2010,Tourism expenditure (millions of US dollars),,,22688.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +446,"China, Macao SAR",2016,Tourism expenditure (millions of US dollars),,,31015.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +446,"China, Macao SAR",2017,Tourism expenditure (millions of US dollars),,,36465.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +446,"China, Macao SAR",2018,Tourism expenditure (millions of US dollars),,,40358.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +170,Colombia,1995,Tourist/visitor arrivals (thousands),TF,,1399.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +170,Colombia,2005,Tourist/visitor arrivals (thousands),TF,,933.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +170,Colombia,2010,Tourist/visitor arrivals (thousands),TF,,1405.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +170,Colombia,2016,Tourist/visitor arrivals (thousands),TF,,3254.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +170,Colombia,2017,Tourist/visitor arrivals (thousands),TF,,3631.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +170,Colombia,2018,Tourist/visitor arrivals (thousands),TF,,3904.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +170,Colombia,1995,Tourism expenditure (millions of US dollars),,,887.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +170,Colombia,2005,Tourism expenditure (millions of US dollars),,,1891.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +170,Colombia,2010,Tourism expenditure (millions of US dollars),,,3441.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +170,Colombia,2016,Tourism expenditure (millions of US dollars),,,5584.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +170,Colombia,2017,Tourism expenditure (millions of US dollars),,,5882.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +170,Colombia,2018,Tourism expenditure (millions of US dollars),,,6617.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +174,Comoros,1995,Tourist/visitor arrivals (thousands),TF,,23.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +174,Comoros,2005,Tourist/visitor arrivals (thousands),TF,,25.9000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +174,Comoros,2010,Tourist/visitor arrivals (thousands),TF,,15.3000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +174,Comoros,2016,Tourist/visitor arrivals (thousands),TF,,26.8000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +174,Comoros,2017,Tourist/visitor arrivals (thousands),TF,,28.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +174,Comoros,2018,Tourist/visitor arrivals (thousands),TF,,35.9000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +174,Comoros,1995,Tourism expenditure (millions of US dollars),,,22.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +174,Comoros,2005,Tourism expenditure (millions of US dollars),,,24.4000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +174,Comoros,2010,Tourism expenditure (millions of US dollars),,,35.2000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +174,Comoros,2016,Tourism expenditure (millions of US dollars),,,50.5000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +174,Comoros,2017,Tourism expenditure (millions of US dollars),,,60.6000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +174,Comoros,2018,Tourism expenditure (millions of US dollars),,,76.7000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +178,Congo,2005,Tourist/visitor arrivals (thousands),TF,,35.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +178,Congo,2010,Tourist/visitor arrivals (thousands),TF,,194.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +178,Congo,2016,Tourist/visitor arrivals (thousands),TF,,211.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +178,Congo,2017,Tourist/visitor arrivals (thousands),TF,,149.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +178,Congo,2018,Tourist/visitor arrivals (thousands),TF,,156.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +178,Congo,1995,Tourism expenditure (millions of US dollars),,,14.6691,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +178,Congo,2010,Tourism expenditure (millions of US dollars),,,39.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +178,Congo,2016,Tourism expenditure (millions of US dollars),,,42.9000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +184,Cook Islands,1995,Tourist/visitor arrivals (thousands),TF,,48.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +184,Cook Islands,2005,Tourist/visitor arrivals (thousands),TF,,88.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +184,Cook Islands,2010,Tourist/visitor arrivals (thousands),TF,,104.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +184,Cook Islands,2016,Tourist/visitor arrivals (thousands),TF,,146.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +184,Cook Islands,2017,Tourist/visitor arrivals (thousands),TF,,161.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +184,Cook Islands,2018,Tourist/visitor arrivals (thousands),TF,,169.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +184,Cook Islands,1995,Tourism expenditure (millions of US dollars),,,28.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +184,Cook Islands,2005,Tourism expenditure (millions of US dollars),,,91.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +184,Cook Islands,2010,Tourism expenditure (millions of US dollars),,,111.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +184,Cook Islands,2016,Tourism expenditure (millions of US dollars),,,137.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +184,Cook Islands,2017,Tourism expenditure (millions of US dollars),,,153.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +188,Costa Rica,1995,Tourist/visitor arrivals (thousands),TF,,785.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +188,Costa Rica,2005,Tourist/visitor arrivals (thousands),TF,,1679.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +188,Costa Rica,2010,Tourist/visitor arrivals (thousands),TF,,2100.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +188,Costa Rica,2016,Tourist/visitor arrivals (thousands),TF,,2925.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +188,Costa Rica,2017,Tourist/visitor arrivals (thousands),TF,,2960.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +188,Costa Rica,2018,Tourist/visitor arrivals (thousands),TF,,3017.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +188,Costa Rica,1995,Tourism expenditure (millions of US dollars),,,763.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +188,Costa Rica,2005,Tourism expenditure (millions of US dollars),,,2008.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +188,Costa Rica,2010,Tourism expenditure (millions of US dollars),,,2426.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +188,Costa Rica,2016,Tourism expenditure (millions of US dollars),,,3776.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +188,Costa Rica,2017,Tourism expenditure (millions of US dollars),,,3826.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +188,Costa Rica,2018,Tourism expenditure (millions of US dollars),,,3995.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +384,Côte d’Ivoire,2010,Tourist/visitor arrivals (thousands),VF,,252.0000,Arrivals to Félix Houphouët Boigny Airport only.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +384,Côte d’Ivoire,2016,Tourist/visitor arrivals (thousands),VF,,1583.0000,Arrivals to Félix Houphouët Boigny Airport only.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +384,Côte d’Ivoire,2017,Tourist/visitor arrivals (thousands),VF,,1800.0000,Arrivals to Félix Houphouët Boigny Airport only.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +384,Côte d’Ivoire,2018,Tourist/visitor arrivals (thousands),VF,,1965.0000,Arrivals to Félix Houphouët Boigny Airport only.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +384,Côte d’Ivoire,1995,Tourism expenditure (millions of US dollars),,,103.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +384,Côte d’Ivoire,2005,Tourism expenditure (millions of US dollars),,,93.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +384,Côte d’Ivoire,2010,Tourism expenditure (millions of US dollars),,,213.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +384,Côte d’Ivoire,2016,Tourism expenditure (millions of US dollars),,,477.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +384,Côte d’Ivoire,2017,Tourism expenditure (millions of US dollars),,,508.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +191,Croatia,1995,Tourist/visitor arrivals (thousands),TCE,,1485.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +191,Croatia,2005,Tourist/visitor arrivals (thousands),TCE,,7743.0000,Break in the time series.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +191,Croatia,2010,Tourist/visitor arrivals (thousands),TCE,,9111.0000,Excluding arrivals in ports of nautical tourism.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +191,Croatia,2016,Tourist/visitor arrivals (thousands),TCE,,13809.0000,Excluding arrivals in ports of nautical tourism.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +191,Croatia,2017,Tourist/visitor arrivals (thousands),TCE,,15593.0000,Excluding arrivals in ports of nautical tourism.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +191,Croatia,2018,Tourist/visitor arrivals (thousands),TCE,,16645.0000,Excluding arrivals in ports of nautical tourism.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +191,Croatia,2005,Tourism expenditure (millions of US dollars),,,7625.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +191,Croatia,2010,Tourism expenditure (millions of US dollars),,,8299.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +191,Croatia,2016,Tourism expenditure (millions of US dollars),,,9820.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +191,Croatia,2017,Tourism expenditure (millions of US dollars),,,11128.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +191,Croatia,2018,Tourism expenditure (millions of US dollars),,,12075.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +192,Cuba,1995,Tourist/visitor arrivals (thousands),TF,,742.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +192,Cuba,2005,Tourist/visitor arrivals (thousands),TF,,2261.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +192,Cuba,2010,Tourist/visitor arrivals (thousands),TF,,2507.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +192,Cuba,2016,Tourist/visitor arrivals (thousands),TF,,3975.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +192,Cuba,2017,Tourist/visitor arrivals (thousands),TF,,4594.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +192,Cuba,2018,Tourist/visitor arrivals (thousands),TF,,4684.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +192,Cuba,1995,Tourism expenditure (millions of US dollars),,,1100.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +192,Cuba,2005,Tourism expenditure (millions of US dollars),,,2591.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +192,Cuba,2010,Tourism expenditure (millions of US dollars),,,2396.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +192,Cuba,2016,Tourism expenditure (millions of US dollars),,,3069.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +192,Cuba,2017,Tourism expenditure (millions of US dollars),,,3302.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +192,Cuba,2018,Tourism expenditure (millions of US dollars),,,2969.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +531,Curaçao,1995,Tourist/visitor arrivals (thousands),TF,,224.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +531,Curaçao,2005,Tourist/visitor arrivals (thousands),TF,,222.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +531,Curaçao,2010,Tourist/visitor arrivals (thousands),TF,,342.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +531,Curaçao,2016,Tourist/visitor arrivals (thousands),TF,,441.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +531,Curaçao,2017,Tourist/visitor arrivals (thousands),TF,,399.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +531,Curaçao,2018,Tourist/visitor arrivals (thousands),TF,,432.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +531,Curaçao,1995,Tourism expenditure (millions of US dollars),,,175.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +531,Curaçao,2005,Tourism expenditure (millions of US dollars),,,244.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +531,Curaçao,2010,Tourism expenditure (millions of US dollars),,,438.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +531,Curaçao,2016,Tourism expenditure (millions of US dollars),,,644.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +531,Curaçao,2017,Tourism expenditure (millions of US dollars),,,572.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +531,Curaçao,2018,Tourism expenditure (millions of US dollars),,,605.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +196,Cyprus,1995,Tourist/visitor arrivals (thousands),TF,,2100.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +196,Cyprus,2005,Tourist/visitor arrivals (thousands),TF,,2470.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +196,Cyprus,2010,Tourist/visitor arrivals (thousands),TF,,2173.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +196,Cyprus,2016,Tourist/visitor arrivals (thousands),TF,,3187.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +196,Cyprus,2017,Tourist/visitor arrivals (thousands),TF,,3652.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +196,Cyprus,2018,Tourist/visitor arrivals (thousands),TF,,3939.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +196,Cyprus,1995,Tourism expenditure (millions of US dollars),,,2018.0443,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +196,Cyprus,2005,Tourism expenditure (millions of US dollars),,,2644.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +196,Cyprus,2010,Tourism expenditure (millions of US dollars),,,2137.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +196,Cyprus,2016,Tourism expenditure (millions of US dollars),,,2870.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +196,Cyprus,2017,Tourism expenditure (millions of US dollars),,,3274.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +196,Cyprus,2018,Tourism expenditure (millions of US dollars),,,3449.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +203,Czechia,2005,Tourist/visitor arrivals (thousands),TF,,9404.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +203,Czechia,2010,Tourist/visitor arrivals (thousands),TF,,8629.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +203,Czechia,2016,Tourist/visitor arrivals (thousands),TF,,12808.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +203,Czechia,2017,Tourist/visitor arrivals (thousands),TF,,13665.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +203,Czechia,2005,Tourism expenditure (millions of US dollars),,,5772.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +203,Czechia,2010,Tourism expenditure (millions of US dollars),,,8068.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +203,Czechia,2016,Tourism expenditure (millions of US dollars),,,7041.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +203,Czechia,2017,Tourism expenditure (millions of US dollars),,,7695.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +203,Czechia,2018,Tourism expenditure (millions of US dollars),,,8291.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +180,Dem. Rep. of the Congo,1995,Tourist/visitor arrivals (thousands),TF,,35.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +180,Dem. Rep. of the Congo,2005,Tourist/visitor arrivals (thousands),TF,,61.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +180,Dem. Rep. of the Congo,2010,Tourist/visitor arrivals (thousands),TF,,81.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +180,Dem. Rep. of the Congo,2016,Tourist/visitor arrivals (thousands),TF,,351.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +180,Dem. Rep. of the Congo,2005,Tourism expenditure (millions of US dollars),,,3.2000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +180,Dem. Rep. of the Congo,2010,Tourism expenditure (millions of US dollars),,,10.7000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +180,Dem. Rep. of the Congo,2016,Tourism expenditure (millions of US dollars),,,4.3000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +180,Dem. Rep. of the Congo,2017,Tourism expenditure (millions of US dollars),,,6.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +180,Dem. Rep. of the Congo,2018,Tourism expenditure (millions of US dollars),,,60.5000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +208,Denmark,2005,Tourist/visitor arrivals (thousands),TCE,,9587.0000,Break in the time series.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +208,Denmark,2010,Tourist/visitor arrivals (thousands),TCE,,9425.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +208,Denmark,2016,Tourist/visitor arrivals (thousands),TCE,,10781.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +208,Denmark,2017,Tourist/visitor arrivals (thousands),TCE,,12426.0000,Break in the time series.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +208,Denmark,2018,Tourist/visitor arrivals (thousands),TCE,,12749.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +208,Denmark,1995,Tourism expenditure (millions of US dollars),,,3691.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +208,Denmark,2005,Tourism expenditure (millions of US dollars),,,5293.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +208,Denmark,2010,Tourism expenditure (millions of US dollars),,,5704.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +208,Denmark,2016,Tourism expenditure (millions of US dollars),,,7494.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +208,Denmark,2017,Tourism expenditure (millions of US dollars),,,8508.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +208,Denmark,2018,Tourism expenditure (millions of US dollars),,,9097.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +262,Djibouti,1995,Tourist/visitor arrivals (thousands),THS,,21.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +262,Djibouti,2005,Tourist/visitor arrivals (thousands),THS,,30.2000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +262,Djibouti,2010,Tourist/visitor arrivals (thousands),THS,,51.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +262,Djibouti,1995,Tourism expenditure (millions of US dollars),,,5.4000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +262,Djibouti,2005,Tourism expenditure (millions of US dollars),,,7.1000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +262,Djibouti,2010,Tourism expenditure (millions of US dollars),,,18.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +262,Djibouti,2016,Tourism expenditure (millions of US dollars),,,33.5000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +262,Djibouti,2017,Tourism expenditure (millions of US dollars),,,36.2000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +262,Djibouti,2018,Tourism expenditure (millions of US dollars),,,57.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +212,Dominica,1995,Tourist/visitor arrivals (thousands),TF,,60.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +212,Dominica,2005,Tourist/visitor arrivals (thousands),TF,,79.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +212,Dominica,2010,Tourist/visitor arrivals (thousands),TF,,77.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +212,Dominica,2016,Tourist/visitor arrivals (thousands),TF,,78.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +212,Dominica,2017,Tourist/visitor arrivals (thousands),TF,,72.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +212,Dominica,2018,Tourist/visitor arrivals (thousands),TF,,63.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +212,Dominica,1995,Tourism expenditure (millions of US dollars),,,42.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +212,Dominica,2005,Tourism expenditure (millions of US dollars),,,57.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +212,Dominica,2010,Tourism expenditure (millions of US dollars),,,94.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +212,Dominica,2016,Tourism expenditure (millions of US dollars),,,198.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +212,Dominica,2017,Tourism expenditure (millions of US dollars),,,161.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +212,Dominica,2018,Tourism expenditure (millions of US dollars),,,111.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +214,Dominican Republic,1995,Tourist/visitor arrivals (thousands),TF,,1776.0000,Including nationals residing abroad.;Arrivals by air.;Excluding the passengers at Herrera airport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +214,Dominican Republic,2005,Tourist/visitor arrivals (thousands),TF,,3691.0000,Including nationals residing abroad.;Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +214,Dominican Republic,2010,Tourist/visitor arrivals (thousands),TF,,4125.0000,Including nationals residing abroad.;Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +214,Dominican Republic,2016,Tourist/visitor arrivals (thousands),TF,,5959.3000,Including nationals residing abroad.;Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +214,Dominican Republic,2017,Tourist/visitor arrivals (thousands),TF,,6188.0000,Including nationals residing abroad.;Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +214,Dominican Republic,2018,Tourist/visitor arrivals (thousands),TF,,6569.0000,Including nationals residing abroad.;Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +214,Dominican Republic,1995,Tourism expenditure (millions of US dollars),,,1571.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +214,Dominican Republic,2005,Tourism expenditure (millions of US dollars),,,3518.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +214,Dominican Republic,2010,Tourism expenditure (millions of US dollars),,,4162.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +214,Dominican Republic,2016,Tourism expenditure (millions of US dollars),,,6720.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +214,Dominican Republic,2017,Tourism expenditure (millions of US dollars),,,7184.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +214,Dominican Republic,2018,Tourism expenditure (millions of US dollars),,,7561.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +218,Ecuador,1995,Tourist/visitor arrivals (thousands),VF,,440.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +218,Ecuador,2005,Tourist/visitor arrivals (thousands),VF,,860.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +218,Ecuador,2010,Tourist/visitor arrivals (thousands),VF,,1047.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +218,Ecuador,2016,Tourist/visitor arrivals (thousands),VF,,1569.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +218,Ecuador,2017,Tourist/visitor arrivals (thousands),VF,,1806.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +218,Ecuador,2018,Tourist/visitor arrivals (thousands),VF,,2535.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +218,Ecuador,1995,Tourism expenditure (millions of US dollars),,,315.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +218,Ecuador,2005,Tourism expenditure (millions of US dollars),,,488.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +218,Ecuador,2010,Tourism expenditure (millions of US dollars),,,786.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +218,Ecuador,2016,Tourism expenditure (millions of US dollars),,,1450.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +218,Ecuador,2017,Tourism expenditure (millions of US dollars),,,1554.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +218,Ecuador,2018,Tourism expenditure (millions of US dollars),,,1878.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +818,Egypt,1995,Tourist/visitor arrivals (thousands),TF,,2871.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +818,Egypt,2005,Tourist/visitor arrivals (thousands),TF,,8244.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +818,Egypt,2010,Tourist/visitor arrivals (thousands),TF,,14051.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +818,Egypt,2016,Tourist/visitor arrivals (thousands),TF,,5258.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +818,Egypt,2017,Tourist/visitor arrivals (thousands),TF,,8157.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +818,Egypt,2018,Tourist/visitor arrivals (thousands),TF,,11196.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +818,Egypt,1995,Tourism expenditure (millions of US dollars),,,2954.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +818,Egypt,2005,Tourism expenditure (millions of US dollars),,,7206.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +818,Egypt,2010,Tourism expenditure (millions of US dollars),,,13633.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +818,Egypt,2016,Tourism expenditure (millions of US dollars),,,3306.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +818,Egypt,2017,Tourism expenditure (millions of US dollars),,,8636.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +818,Egypt,2018,Tourism expenditure (millions of US dollars),,,12704.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +222,El Salvador,1995,Tourist/visitor arrivals (thousands),TF,,235.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +222,El Salvador,2005,Tourist/visitor arrivals (thousands),TF,,1127.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +222,El Salvador,2010,Tourist/visitor arrivals (thousands),TF,,1150.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +222,El Salvador,2016,Tourist/visitor arrivals (thousands),TF,,1434.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +222,El Salvador,2017,Tourist/visitor arrivals (thousands),TF,,1556.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +222,El Salvador,2018,Tourist/visitor arrivals (thousands),TF,,1677.3000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +222,El Salvador,1995,Tourism expenditure (millions of US dollars),,,152.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +222,El Salvador,2005,Tourism expenditure (millions of US dollars),,,656.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +222,El Salvador,2010,Tourism expenditure (millions of US dollars),,,646.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +222,El Salvador,2016,Tourism expenditure (millions of US dollars),,,1161.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +222,El Salvador,2017,Tourism expenditure (millions of US dollars),,,1227.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +222,El Salvador,2018,Tourism expenditure (millions of US dollars),,,1370.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +226,Equatorial Guinea,1995,Tourism expenditure (millions of US dollars),,,1.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +232,Eritrea,1995,Tourist/visitor arrivals (thousands),VF,,315.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +232,Eritrea,2005,Tourist/visitor arrivals (thousands),VF,,83.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +232,Eritrea,2010,Tourist/visitor arrivals (thousands),VF,,84.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +232,Eritrea,2016,Tourist/visitor arrivals (thousands),VF,,142.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +232,Eritrea,1995,Tourism expenditure (millions of US dollars),,,58.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +232,Eritrea,2005,Tourism expenditure (millions of US dollars),,,66.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +232,Eritrea,2016,Tourism expenditure (millions of US dollars),,,48.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +233,Estonia,1995,Tourist/visitor arrivals (thousands),TF,,530.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +233,Estonia,2005,Tourist/visitor arrivals (thousands),TF,,1917.0000,"Border statistics are not collected any more, surveys used instead.;Calculated on the basis of accommodation statistics and “Foreign Visitor Survey” carried out by the Statistical Office of Estonia.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +233,Estonia,2010,Tourist/visitor arrivals (thousands),TF,,2511.0000,"Border statistics are not collected any more, surveys used instead.;Based on mobile positioning data.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +233,Estonia,2016,Tourist/visitor arrivals (thousands),TF,,3131.0000,"Border statistics are not collected any more, surveys used instead.;Based on mobile positioning data.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +233,Estonia,2017,Tourist/visitor arrivals (thousands),TF,,3244.0000,"Border statistics are not collected any more, surveys used instead.;Based on mobile positioning data.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +233,Estonia,2018,Tourist/visitor arrivals (thousands),TF,,3234.0000,"Border statistics are not collected any more, surveys used instead.;Based on mobile positioning data.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +233,Estonia,1995,Tourism expenditure (millions of US dollars),,,452.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +233,Estonia,2005,Tourism expenditure (millions of US dollars),,,1229.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +233,Estonia,2016,Tourism expenditure (millions of US dollars),,,1916.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +233,Estonia,2017,Tourism expenditure (millions of US dollars),,,2126.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +233,Estonia,2018,Tourism expenditure (millions of US dollars),,,2332.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +748,Eswatini,1995,Tourist/visitor arrivals (thousands),TF,,300.0000,Arrivals in hotels only.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +748,Eswatini,2005,Tourist/visitor arrivals (thousands),TF,,837.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +748,Eswatini,2010,Tourist/visitor arrivals (thousands),TF,,868.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +748,Eswatini,2016,Tourist/visitor arrivals (thousands),TF,,947.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +748,Eswatini,2017,Tourist/visitor arrivals (thousands),TF,,921.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +748,Eswatini,2018,Tourist/visitor arrivals (thousands),TF,,782.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +748,Eswatini,1995,Tourism expenditure (millions of US dollars),,,54.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +748,Eswatini,2005,Tourism expenditure (millions of US dollars),,,77.3000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +748,Eswatini,2010,Tourism expenditure (millions of US dollars),,,51.4000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +748,Eswatini,2016,Tourism expenditure (millions of US dollars),,,13.2000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +748,Eswatini,2017,Tourism expenditure (millions of US dollars),,,13.2000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +748,Eswatini,2018,Tourism expenditure (millions of US dollars),,,16.4000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +231,Ethiopia,1995,Tourist/visitor arrivals (thousands),TF,,103.0000,Arrivals to Bole airport only.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +231,Ethiopia,2005,Tourist/visitor arrivals (thousands),TF,,227.0000,Including nationals residing abroad.;Arrivals through all ports of entry.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +231,Ethiopia,2010,Tourist/visitor arrivals (thousands),TF,,468.0000,Including nationals residing abroad.;Arrivals through all ports of entry.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +231,Ethiopia,2016,Tourist/visitor arrivals (thousands),TF,,871.0000,Including nationals residing abroad.;Arrivals through all ports of entry.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +231,Ethiopia,2017,Tourist/visitor arrivals (thousands),TF,,933.0000,Including nationals residing abroad.;Arrivals through all ports of entry.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +231,Ethiopia,2018,Tourist/visitor arrivals (thousands),TF,,849.0000,Including nationals residing abroad.;Arrivals through all ports of entry.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +231,Ethiopia,1995,Tourism expenditure (millions of US dollars),,,177.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +231,Ethiopia,2005,Tourism expenditure (millions of US dollars),,,533.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +231,Ethiopia,2010,Tourism expenditure (millions of US dollars),,,1434.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +231,Ethiopia,2016,Tourism expenditure (millions of US dollars),,,2138.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +231,Ethiopia,2017,Tourism expenditure (millions of US dollars),,,2505.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +231,Ethiopia,2018,Tourism expenditure (millions of US dollars),,,3548.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +242,Fiji,1995,Tourist/visitor arrivals (thousands),TF,,318.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +242,Fiji,2005,Tourist/visitor arrivals (thousands),TF,,545.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +242,Fiji,2010,Tourist/visitor arrivals (thousands),TF,,632.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +242,Fiji,2016,Tourist/visitor arrivals (thousands),TF,,792.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +242,Fiji,2017,Tourist/visitor arrivals (thousands),TF,,843.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +242,Fiji,2018,Tourist/visitor arrivals (thousands),TF,,870.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +242,Fiji,1995,Tourism expenditure (millions of US dollars),,,369.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +242,Fiji,2005,Tourism expenditure (millions of US dollars),,,722.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +242,Fiji,2010,Tourism expenditure (millions of US dollars),,,825.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +242,Fiji,2016,Tourism expenditure (millions of US dollars),,,1149.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +242,Fiji,2017,Tourism expenditure (millions of US dollars),,,1243.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +242,Fiji,2018,Tourism expenditure (millions of US dollars),,,1370.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +246,Finland,1995,Tourist/visitor arrivals (thousands),TCE,,1779.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +246,Finland,2005,Tourist/visitor arrivals (thousands),TCE,,2080.0000,Break in the time series.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +246,Finland,2010,Tourist/visitor arrivals (thousands),TCE,,2319.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +246,Finland,2016,Tourist/visitor arrivals (thousands),TCE,,2789.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +246,Finland,2017,Tourist/visitor arrivals (thousands),TCE,,3180.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +246,Finland,2018,Tourist/visitor arrivals (thousands),TCE,,3224.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +246,Finland,1995,Tourism expenditure (millions of US dollars),,,2383.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +246,Finland,2005,Tourism expenditure (millions of US dollars),,,3069.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +246,Finland,2010,Tourism expenditure (millions of US dollars),,,4497.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +246,Finland,2016,Tourism expenditure (millions of US dollars),,,4016.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +246,Finland,2017,Tourism expenditure (millions of US dollars),,,5207.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +246,Finland,2018,Tourism expenditure (millions of US dollars),,,5663.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +250,France,1995,Tourist/visitor arrivals (thousands),TF,,60033.0000,Estimated based on surveys at national borders.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +250,France,2005,Tourist/visitor arrivals (thousands),TF,,74988.0000,Arrivals of non-resident visitors.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +250,France,2010,Tourist/visitor arrivals (thousands),TF,,76647.0000,Arrivals of non-resident visitors.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +250,France,2016,Tourist/visitor arrivals (thousands),TF,,82682.0000,Arrivals of non-resident visitors.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +250,France,2017,Tourist/visitor arrivals (thousands),TF,,86758.0000,Arrivals of non-resident visitors.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +250,France,2018,Tourist/visitor arrivals (thousands),TF,,89322.0000,Estimate.;Arrivals of non-resident visitors.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +250,France,1995,Tourism expenditure (millions of US dollars),,,31295.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +250,France,2005,Tourism expenditure (millions of US dollars),,,52126.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +250,France,2010,Tourism expenditure (millions of US dollars),,,56178.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +250,France,2016,Tourism expenditure (millions of US dollars),,,63557.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +250,France,2017,Tourism expenditure (millions of US dollars),,,67936.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +250,France,2018,Tourism expenditure (millions of US dollars),,,73125.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +254,French Guiana,2005,Tourist/visitor arrivals (thousands),TF,,95.0000,Survey at Cayenne-Rochambeau airport on departure.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +254,French Guiana,2016,Tourist/visitor arrivals (thousands),TF,,96.0000,Survey at Cayenne-Rochambeau airport on departure.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +254,French Guiana,2017,Tourist/visitor arrivals (thousands),TF,,111.0000,Survey at Cayenne-Rochambeau airport on departure.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +254,French Guiana,2005,Tourism expenditure (millions of US dollars),,,44.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +258,French Polynesia,1995,Tourist/visitor arrivals (thousands),TF,,172.0000,Excluding nationals residing abroad.;Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +258,French Polynesia,2005,Tourist/visitor arrivals (thousands),TF,,208.0000,Excluding nationals residing abroad.;Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +258,French Polynesia,2010,Tourist/visitor arrivals (thousands),TF,,154.0000,Excluding nationals residing abroad.;Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +258,French Polynesia,2016,Tourist/visitor arrivals (thousands),TF,,192.0000,Excluding nationals residing abroad.;Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +258,French Polynesia,2017,Tourist/visitor arrivals (thousands),TF,,199.0000,Excluding nationals residing abroad.;Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +258,French Polynesia,2018,Tourist/visitor arrivals (thousands),TF,,216.3000,Excluding nationals residing abroad.;Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +258,French Polynesia,1995,Tourism expenditure (millions of US dollars),,,326.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +258,French Polynesia,2005,Tourism expenditure (millions of US dollars),,,759.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +258,French Polynesia,2010,Tourism expenditure (millions of US dollars),,,630.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +258,French Polynesia,2016,Tourism expenditure (millions of US dollars),,,782.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +266,Gabon,1995,Tourist/visitor arrivals (thousands),TF,,125.0000,Arrivals of non-resident tourists at Libreville airport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +266,Gabon,2005,Tourist/visitor arrivals (thousands),TF,,269.0000,Arrivals of non-resident tourists at Libreville airport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +266,Gabon,1995,Tourism expenditure (millions of US dollars),,,94.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +266,Gabon,2005,Tourism expenditure (millions of US dollars),,,13.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +266,Gabon,2010,Tourism expenditure (millions of US dollars),,,89.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +266,Gabon,2016,Tourism expenditure (millions of US dollars),,,28.7000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +270,Gambia,1995,Tourist/visitor arrivals (thousands),TF,,45.0000,Including nationals residing abroad.;Arrivals by air only.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +270,Gambia,2005,Tourist/visitor arrivals (thousands),TF,,108.0000,Including nationals residing abroad.;Arrivals by air only.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +270,Gambia,2010,Tourist/visitor arrivals (thousands),TF,,91.0000,Including nationals residing abroad.;Arrivals by air only.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +270,Gambia,2016,Tourist/visitor arrivals (thousands),TF,,450.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +270,Gambia,2017,Tourist/visitor arrivals (thousands),TF,,522.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +270,Gambia,2018,Tourist/visitor arrivals (thousands),TF,,552.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +270,Gambia,2005,Tourism expenditure (millions of US dollars),,,59.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +270,Gambia,2010,Tourism expenditure (millions of US dollars),,,80.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +270,Gambia,2016,Tourism expenditure (millions of US dollars),,,120.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +270,Gambia,2017,Tourism expenditure (millions of US dollars),,,116.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +270,Gambia,2018,Tourism expenditure (millions of US dollars),,,168.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +268,Georgia,2010,Tourist/visitor arrivals (thousands),TF,,1067.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +268,Georgia,2016,Tourist/visitor arrivals (thousands),TF,,3297.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +268,Georgia,2017,Tourist/visitor arrivals (thousands),TF,,4069.4000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +268,Georgia,2018,Tourist/visitor arrivals (thousands),TF,,4757.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +268,Georgia,2005,Tourism expenditure (millions of US dollars),,,287.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +268,Georgia,2010,Tourism expenditure (millions of US dollars),,,737.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +268,Georgia,2016,Tourism expenditure (millions of US dollars),,,2315.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +268,Georgia,2017,Tourism expenditure (millions of US dollars),,,2971.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +268,Georgia,2018,Tourism expenditure (millions of US dollars),,,3518.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +276,Germany,1995,Tourist/visitor arrivals (thousands),TCE,,14847.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +276,Germany,2005,Tourist/visitor arrivals (thousands),TCE,,21500.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +276,Germany,2010,Tourist/visitor arrivals (thousands),TCE,,26875.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +276,Germany,2016,Tourist/visitor arrivals (thousands),TCE,,35555.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +276,Germany,2017,Tourist/visitor arrivals (thousands),TCE,,37452.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +276,Germany,2018,Tourist/visitor arrivals (thousands),TCE,,38881.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +276,Germany,1995,Tourism expenditure (millions of US dollars),,,24053.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +276,Germany,2005,Tourism expenditure (millions of US dollars),,,40518.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +276,Germany,2010,Tourism expenditure (millions of US dollars),,,49116.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +276,Germany,2016,Tourism expenditure (millions of US dollars),,,52229.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +276,Germany,2017,Tourism expenditure (millions of US dollars),,,56330.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +276,Germany,2018,Tourism expenditure (millions of US dollars),,,60260.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +288,Ghana,1995,Tourist/visitor arrivals (thousands),TF,,286.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +288,Ghana,2005,Tourist/visitor arrivals (thousands),TF,,429.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +288,Ghana,2010,Tourist/visitor arrivals (thousands),TF,,931.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +288,Ghana,1995,Tourism expenditure (millions of US dollars),,,30.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +288,Ghana,2005,Tourism expenditure (millions of US dollars),,,867.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +288,Ghana,2010,Tourism expenditure (millions of US dollars),,,706.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +288,Ghana,2016,Tourism expenditure (millions of US dollars),,,952.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +288,Ghana,2017,Tourism expenditure (millions of US dollars),,,919.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +288,Ghana,2018,Tourism expenditure (millions of US dollars),,,996.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +300,Greece,1995,Tourist/visitor arrivals (thousands),TF,,10130.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +300,Greece,2005,Tourist/visitor arrivals (thousands),TF,,14765.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +300,Greece,2010,Tourist/visitor arrivals (thousands),TF,,15007.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +300,Greece,2016,Tourist/visitor arrivals (thousands),TF,,24799.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +300,Greece,2017,Tourist/visitor arrivals (thousands),TF,,27194.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +300,Greece,2018,Tourist/visitor arrivals (thousands),TF,,30123.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +300,Greece,1995,Tourism expenditure (millions of US dollars),,,4182.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +300,Greece,2005,Tourism expenditure (millions of US dollars),,,13455.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +300,Greece,2010,Tourism expenditure (millions of US dollars),,,13857.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +300,Greece,2016,Tourism expenditure (millions of US dollars),,,16811.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +300,Greece,2017,Tourism expenditure (millions of US dollars),,,19139.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +300,Greece,2018,Tourism expenditure (millions of US dollars),,,21594.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +308,Grenada,1995,Tourist/visitor arrivals (thousands),TF,,108.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +308,Grenada,2005,Tourist/visitor arrivals (thousands),TF,,99.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +308,Grenada,2010,Tourist/visitor arrivals (thousands),TF,,110.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +308,Grenada,2016,Tourist/visitor arrivals (thousands),TF,,156.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +308,Grenada,2017,Tourist/visitor arrivals (thousands),TF,,168.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +308,Grenada,2018,Tourist/visitor arrivals (thousands),TF,,185.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +308,Grenada,1995,Tourism expenditure (millions of US dollars),,,76.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +308,Grenada,2005,Tourism expenditure (millions of US dollars),,,71.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +308,Grenada,2010,Tourism expenditure (millions of US dollars),,,112.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +308,Grenada,2016,Tourism expenditure (millions of US dollars),,,437.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +308,Grenada,2017,Tourism expenditure (millions of US dollars),,,482.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +308,Grenada,2018,Tourism expenditure (millions of US dollars),,,548.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +312,Guadeloupe,1995,Tourist/visitor arrivals (thousands),TF,,640.0000,"Arrivals by air.;Excluding the north islands, Saint Barthélemy and Saint Martin (French part).;Non-resident tourists staying in all types of accommodation establishments.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +312,Guadeloupe,2005,Tourist/visitor arrivals (thousands),TF,,372.0000,"Arrivals by air.;Excluding the north islands, Saint Barthélemy and Saint Martin (French part).","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +312,Guadeloupe,2010,Tourist/visitor arrivals (thousands),TF,,392.0000,"Arrivals by air.;Excluding the north islands, Saint Barthélemy and Saint Martin (French part).","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +312,Guadeloupe,2016,Tourist/visitor arrivals (thousands),TF,,581.0000,"Arrivals by air.;Excluding the north islands, Saint Barthélemy and Saint Martin (French part).","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +312,Guadeloupe,2017,Tourist/visitor arrivals (thousands),TF,,650.0000,"Arrivals by air.;Excluding the north islands, Saint Barthélemy and Saint Martin (French part).","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +312,Guadeloupe,2018,Tourist/visitor arrivals (thousands),TF,,735.0000,"Arrivals by air.;Excluding the north islands, Saint Barthélemy and Saint Martin (French part).","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +312,Guadeloupe,1995,Tourism expenditure (millions of US dollars),,,458.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +312,Guadeloupe,2005,Tourism expenditure (millions of US dollars),,,306.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +312,Guadeloupe,2010,Tourism expenditure (millions of US dollars),,,510.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +312,Guadeloupe,2018,Tourism expenditure (millions of US dollars),,,860.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +316,Guam,1995,Tourist/visitor arrivals (thousands),TF,,1362.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +316,Guam,2005,Tourist/visitor arrivals (thousands),TF,,1228.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +316,Guam,2010,Tourist/visitor arrivals (thousands),TF,,1197.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +316,Guam,2016,Tourist/visitor arrivals (thousands),TF,,1536.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +316,Guam,2017,Tourist/visitor arrivals (thousands),TF,,1545.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +316,Guam,2018,Tourist/visitor arrivals (thousands),TF,,1549.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +320,Guatemala,2010,Tourist/visitor arrivals (thousands),TF,,1119.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +320,Guatemala,2016,Tourist/visitor arrivals (thousands),TF,,1585.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +320,Guatemala,2017,Tourist/visitor arrivals (thousands),TF,,1660.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +320,Guatemala,2018,Tourist/visitor arrivals (thousands),TF,,1781.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +320,Guatemala,1995,Tourism expenditure (millions of US dollars),,,213.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +320,Guatemala,2005,Tourism expenditure (millions of US dollars),,,791.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +320,Guatemala,2010,Tourism expenditure (millions of US dollars),,,1378.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +320,Guatemala,2016,Tourism expenditure (millions of US dollars),,,1550.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +320,Guatemala,2017,Tourism expenditure (millions of US dollars),,,1566.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +320,Guatemala,2018,Tourism expenditure (millions of US dollars),,,1549.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +324,Guinea,2005,Tourist/visitor arrivals (thousands),TF,,45.0000,Arrivals by air at Conakry airport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +324,Guinea,2010,Tourist/visitor arrivals (thousands),TF,,12.4000,Arrivals by air at Conakry airport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +324,Guinea,2016,Tourist/visitor arrivals (thousands),TF,,63.0000,Arrivals by air at Conakry airport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +324,Guinea,2017,Tourist/visitor arrivals (thousands),TF,,99.0000,Arrivals by air at Conakry airport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +324,Guinea,1995,Tourism expenditure (millions of US dollars),,,0.9110,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +324,Guinea,2010,Tourism expenditure (millions of US dollars),,,2.0400,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +324,Guinea,2016,Tourism expenditure (millions of US dollars),,,16.6000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +324,Guinea,2017,Tourism expenditure (millions of US dollars),,,16.6000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +324,Guinea,2018,Tourism expenditure (millions of US dollars),,,7.7000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +624,Guinea-Bissau,2005,Tourist/visitor arrivals (thousands),TF,,5.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +624,Guinea-Bissau,2010,Tourist/visitor arrivals (thousands),TF,,22.3000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +624,Guinea-Bissau,2016,Tourist/visitor arrivals (thousands),TF,,45.2000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +624,Guinea-Bissau,2005,Tourism expenditure (millions of US dollars),,,1.6000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +624,Guinea-Bissau,2010,Tourism expenditure (millions of US dollars),,,13.3000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +624,Guinea-Bissau,2016,Tourism expenditure (millions of US dollars),,,11.5000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +624,Guinea-Bissau,2017,Tourism expenditure (millions of US dollars),,,16.3000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +624,Guinea-Bissau,2018,Tourism expenditure (millions of US dollars),,,19.8000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +328,Guyana,1995,Tourist/visitor arrivals (thousands),TF,,106.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +328,Guyana,2005,Tourist/visitor arrivals (thousands),TF,,117.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +328,Guyana,2010,Tourist/visitor arrivals (thousands),TF,,152.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +328,Guyana,2016,Tourist/visitor arrivals (thousands),TF,,235.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +328,Guyana,2017,Tourist/visitor arrivals (thousands),TF,,247.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +328,Guyana,2018,Tourist/visitor arrivals (thousands),TF,,287.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +328,Guyana,1995,Tourism expenditure (millions of US dollars),,,33.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +328,Guyana,2005,Tourism expenditure (millions of US dollars),,,35.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +328,Guyana,2010,Tourism expenditure (millions of US dollars),,,80.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +328,Guyana,2016,Tourism expenditure (millions of US dollars),,,104.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +328,Guyana,2017,Tourism expenditure (millions of US dollars),,,95.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +328,Guyana,2018,Tourism expenditure (millions of US dollars),,,28.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +332,Haiti,1995,Tourist/visitor arrivals (thousands),TF,,145.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +332,Haiti,2005,Tourist/visitor arrivals (thousands),TF,,112.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +332,Haiti,2010,Tourist/visitor arrivals (thousands),TF,,255.0000,Arrivals by air.;Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +332,Haiti,2016,Tourist/visitor arrivals (thousands),TF,,445.0000,Arrivals by air.;Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +332,Haiti,2017,Tourist/visitor arrivals (thousands),TF,,467.0000,Arrivals by air.;Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +332,Haiti,2018,Tourist/visitor arrivals (thousands),TF,,447.0000,Arrivals by air.;Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +332,Haiti,1995,Tourism expenditure (millions of US dollars),,,90.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +332,Haiti,2005,Tourism expenditure (millions of US dollars),,,80.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +332,Haiti,2010,Tourism expenditure (millions of US dollars),,,383.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +332,Haiti,2016,Tourism expenditure (millions of US dollars),,,511.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +332,Haiti,2017,Tourism expenditure (millions of US dollars),,,460.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +332,Haiti,2018,Tourism expenditure (millions of US dollars),,,620.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +340,Honduras,1995,Tourist/visitor arrivals (thousands),TF,,271.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +340,Honduras,2005,Tourist/visitor arrivals (thousands),TF,,673.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +340,Honduras,2010,Tourist/visitor arrivals (thousands),TF,,863.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +340,Honduras,2016,Tourist/visitor arrivals (thousands),TF,,838.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +340,Honduras,2017,Tourist/visitor arrivals (thousands),TF,,851.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +340,Honduras,1995,Tourism expenditure (millions of US dollars),,,85.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +340,Honduras,2005,Tourism expenditure (millions of US dollars),,,465.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +340,Honduras,2010,Tourism expenditure (millions of US dollars),,,626.7000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +340,Honduras,2016,Tourism expenditure (millions of US dollars),,,700.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +340,Honduras,2017,Tourism expenditure (millions of US dollars),,,722.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +340,Honduras,2018,Tourism expenditure (millions of US dollars),,,745.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +348,Hungary,2005,Tourist/visitor arrivals (thousands),TF,,9979.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +348,Hungary,2010,Tourist/visitor arrivals (thousands),TF,,9510.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +348,Hungary,2016,Tourist/visitor arrivals (thousands),TF,,15255.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +348,Hungary,2017,Tourist/visitor arrivals (thousands),TF,,15785.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +348,Hungary,2018,Tourist/visitor arrivals (thousands),TF,,17552.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +348,Hungary,1995,Tourism expenditure (millions of US dollars),,,2938.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +348,Hungary,2005,Tourism expenditure (millions of US dollars),,,4761.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +348,Hungary,2010,Tourism expenditure (millions of US dollars),,,6595.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +348,Hungary,2016,Tourism expenditure (millions of US dollars),,,7481.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +348,Hungary,2017,Tourism expenditure (millions of US dollars),,,8448.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +348,Hungary,2018,Tourism expenditure (millions of US dollars),,,9595.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +352,Iceland,1995,Tourist/visitor arrivals (thousands),TF,,190.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +352,Iceland,2005,Tourist/visitor arrivals (thousands),TF,,374.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +352,Iceland,2010,Tourist/visitor arrivals (thousands),TF,,489.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +352,Iceland,2016,Tourist/visitor arrivals (thousands),TF,,1792.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +352,Iceland,2017,Tourist/visitor arrivals (thousands),TF,,2225.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +352,Iceland,2018,Tourist/visitor arrivals (thousands),TF,,2343.8000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +352,Iceland,1995,Tourism expenditure (millions of US dollars),,,186.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +352,Iceland,2005,Tourism expenditure (millions of US dollars),,,413.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +352,Iceland,2010,Tourism expenditure (millions of US dollars),,,562.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +352,Iceland,2016,Tourism expenditure (millions of US dollars),,,2411.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +352,Iceland,2017,Tourism expenditure (millions of US dollars),,,3024.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +352,Iceland,2018,Tourism expenditure (millions of US dollars),,,3128.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +356,India,1995,Tourist/visitor arrivals (thousands),TF,,2124.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +356,India,2005,Tourist/visitor arrivals (thousands),TF,,3919.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +356,India,2010,Tourist/visitor arrivals (thousands),TF,,5776.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +356,India,2016,Tourist/visitor arrivals (thousands),TF,,14570.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +356,India,2017,Tourist/visitor arrivals (thousands),TF,,15543.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +356,India,2018,Tourist/visitor arrivals (thousands),TF,,17423.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +356,India,2005,Tourism expenditure (millions of US dollars),,,7659.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +356,India,2016,Tourism expenditure (millions of US dollars),,,23111.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +356,India,2017,Tourism expenditure (millions of US dollars),,,27878.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +356,India,2018,Tourism expenditure (millions of US dollars),,,29143.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +360,Indonesia,1995,Tourist/visitor arrivals (thousands),VF,,4324.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +360,Indonesia,2005,Tourist/visitor arrivals (thousands),VF,,5002.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +360,Indonesia,2010,Tourist/visitor arrivals (thousands),VF,,7003.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +360,Indonesia,2016,Tourist/visitor arrivals (thousands),VF,,11519.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +360,Indonesia,2017,Tourist/visitor arrivals (thousands),VF,,14040.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +360,Indonesia,2018,Tourist/visitor arrivals (thousands),VF,,15810.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +360,Indonesia,2005,Tourism expenditure (millions of US dollars),,,5094.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +360,Indonesia,2010,Tourism expenditure (millions of US dollars),,,7618.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +360,Indonesia,2016,Tourism expenditure (millions of US dollars),,,12566.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +360,Indonesia,2017,Tourism expenditure (millions of US dollars),,,14691.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +360,Indonesia,2018,Tourism expenditure (millions of US dollars),,,15600.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +364,Iran (Islamic Republic of),1995,Tourist/visitor arrivals (thousands),VF,,568.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +364,Iran (Islamic Republic of),2010,Tourist/visitor arrivals (thousands),VF,,2938.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +364,Iran (Islamic Republic of),2016,Tourist/visitor arrivals (thousands),VF,,4942.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +364,Iran (Islamic Republic of),2017,Tourist/visitor arrivals (thousands),VF,,4867.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +364,Iran (Islamic Republic of),2018,Tourist/visitor arrivals (thousands),VF,,7295.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +364,Iran (Islamic Republic of),1995,Tourism expenditure (millions of US dollars),,,205.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +364,Iran (Islamic Republic of),2005,Tourism expenditure (millions of US dollars),,,1025.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +364,Iran (Islamic Republic of),2010,Tourism expenditure (millions of US dollars),,,2631.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +364,Iran (Islamic Republic of),2016,Tourism expenditure (millions of US dollars),,,3914.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +364,Iran (Islamic Republic of),2017,Tourism expenditure (millions of US dollars),,,4632.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +368,Iraq,1995,Tourist/visitor arrivals (thousands),VF,,61.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +368,Iraq,2010,Tourist/visitor arrivals (thousands),VF,,1518.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +368,Iraq,2005,Tourism expenditure (millions of US dollars),,,186.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +368,Iraq,2010,Tourism expenditure (millions of US dollars),,,1736.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +368,Iraq,2016,Tourism expenditure (millions of US dollars),,,3120.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +368,Iraq,2017,Tourism expenditure (millions of US dollars),,,2959.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +368,Iraq,2018,Tourism expenditure (millions of US dollars),,,1986.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +372,Ireland,1995,Tourist/visitor arrivals (thousands),TF,,4818.0000,Including tourists from Northern Ireland.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +372,Ireland,2005,Tourist/visitor arrivals (thousands),TF,,7333.0000,Including tourists from Northern Ireland.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +372,Ireland,2010,Tourist/visitor arrivals (thousands),TF,,7134.0000,Break in the time series.;Including tourists from Northern Ireland.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +372,Ireland,2016,Tourist/visitor arrivals (thousands),TF,,10100.0000,Including tourists from Northern Ireland.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +372,Ireland,2017,Tourist/visitor arrivals (thousands),TF,,10338.0000,Including tourists from Northern Ireland.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +372,Ireland,2018,Tourist/visitor arrivals (thousands),TF,,10926.0000,Including tourists from Northern Ireland.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +372,Ireland,1995,Tourism expenditure (millions of US dollars),,,2697.7927,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +372,Ireland,2005,Tourism expenditure (millions of US dollars),,,6779.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +372,Ireland,2010,Tourism expenditure (millions of US dollars),,,8185.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +372,Ireland,2016,Tourism expenditure (millions of US dollars),,,11429.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +372,Ireland,2017,Tourism expenditure (millions of US dollars),,,14294.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +372,Ireland,2018,Tourism expenditure (millions of US dollars),,,14658.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +376,Israel,1995,Tourist/visitor arrivals (thousands),TF,,2215.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +376,Israel,2005,Tourist/visitor arrivals (thousands),TF,,1903.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +376,Israel,2010,Tourist/visitor arrivals (thousands),TF,,2803.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +376,Israel,2016,Tourist/visitor arrivals (thousands),TF,,2900.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +376,Israel,2017,Tourist/visitor arrivals (thousands),TF,,3613.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +376,Israel,2018,Tourist/visitor arrivals (thousands),TF,,4121.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +376,Israel,1995,Tourism expenditure (millions of US dollars),,,3491.0000,Including the expenditures of foreign workers in Israel.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +376,Israel,2005,Tourism expenditure (millions of US dollars),,,2750.0000,Including the expenditures of foreign workers in Israel.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +376,Israel,2010,Tourism expenditure (millions of US dollars),,,5621.0000,Including the expenditures of foreign workers in Israel.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +376,Israel,2016,Tourism expenditure (millions of US dollars),,,6587.0000,Including the expenditures of foreign workers in Israel.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +376,Israel,2017,Tourism expenditure (millions of US dollars),,,7578.0000,Including the expenditures of foreign workers in Israel.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +376,Israel,2018,Tourism expenditure (millions of US dollars),,,8073.0000,Including the expenditures of foreign workers in Israel.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +380,Italy,1995,Tourist/visitor arrivals (thousands),TF,,31052.0000,Excluding seasonal and border workers.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +380,Italy,2005,Tourist/visitor arrivals (thousands),TF,,36513.0000,Excluding seasonal and border workers.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +380,Italy,2010,Tourist/visitor arrivals (thousands),TF,,43626.0000,Excluding seasonal and border workers.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +380,Italy,2016,Tourist/visitor arrivals (thousands),TF,,52372.0000,Excluding seasonal and border workers.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +380,Italy,2017,Tourist/visitor arrivals (thousands),TF,,58253.0000,Excluding seasonal and border workers.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +380,Italy,2018,Tourist/visitor arrivals (thousands),TF,,61567.2000,Excluding seasonal and border workers.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +380,Italy,1995,Tourism expenditure (millions of US dollars),,,30411.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +380,Italy,2005,Tourism expenditure (millions of US dollars),,,38364.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +380,Italy,2016,Tourism expenditure (millions of US dollars),,,42423.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +380,Italy,2017,Tourism expenditure (millions of US dollars),,,46719.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +380,Italy,2018,Tourism expenditure (millions of US dollars),,,51602.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +388,Jamaica,1995,Tourist/visitor arrivals (thousands),TF,,1147.0000,Including nationals residing abroad; E/D cards.;Arrivals of non-resident tourists by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +388,Jamaica,2005,Tourist/visitor arrivals (thousands),TF,,1479.0000,Including nationals residing abroad; E/D cards.;Arrivals of non-resident tourists by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +388,Jamaica,2010,Tourist/visitor arrivals (thousands),TF,,1922.0000,Including nationals residing abroad; E/D cards.;Arrivals of non-resident tourists by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +388,Jamaica,2016,Tourist/visitor arrivals (thousands),TF,,2182.0000,Including nationals residing abroad; E/D cards.;Arrivals of non-resident tourists by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +388,Jamaica,2017,Tourist/visitor arrivals (thousands),TF,,2353.0000,Including nationals residing abroad; E/D cards.;Arrivals of non-resident tourists by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +388,Jamaica,2018,Tourist/visitor arrivals (thousands),TF,,2473.0000,Including nationals residing abroad; E/D cards.;Arrivals of non-resident tourists by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +388,Jamaica,1995,Tourism expenditure (millions of US dollars),,,1069.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +388,Jamaica,2005,Tourism expenditure (millions of US dollars),,,1545.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +388,Jamaica,2010,Tourism expenditure (millions of US dollars),,,2001.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +388,Jamaica,2016,Tourism expenditure (millions of US dollars),,,2539.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +388,Jamaica,2017,Tourism expenditure (millions of US dollars),,,2809.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +388,Jamaica,2018,Tourism expenditure (millions of US dollars),,,3099.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +392,Japan,1995,Tourist/visitor arrivals (thousands),VF,,3345.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +392,Japan,2005,Tourist/visitor arrivals (thousands),VF,,6728.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +392,Japan,2010,Tourist/visitor arrivals (thousands),VF,,8611.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +392,Japan,2016,Tourist/visitor arrivals (thousands),VF,,24040.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +392,Japan,2017,Tourist/visitor arrivals (thousands),VF,,28691.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +392,Japan,2018,Tourist/visitor arrivals (thousands),VF,,31192.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +392,Japan,1995,Tourism expenditure (millions of US dollars),,,4894.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +392,Japan,2005,Tourism expenditure (millions of US dollars),,,15554.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +392,Japan,2010,Tourism expenditure (millions of US dollars),,,15356.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +392,Japan,2016,Tourism expenditure (millions of US dollars),,,33456.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +392,Japan,2017,Tourism expenditure (millions of US dollars),,,36978.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +392,Japan,2018,Tourism expenditure (millions of US dollars),,,45276.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +400,Jordan,1995,Tourist/visitor arrivals (thousands),TF,,1075.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +400,Jordan,2005,Tourist/visitor arrivals (thousands),TF,,2987.0000,Break in the time series.;Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +400,Jordan,2010,Tourist/visitor arrivals (thousands),TF,,4207.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +400,Jordan,2016,Tourist/visitor arrivals (thousands),TF,,3567.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +400,Jordan,2017,Tourist/visitor arrivals (thousands),TF,,3843.5000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +400,Jordan,2018,Tourist/visitor arrivals (thousands),TF,,4150.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +400,Jordan,1995,Tourism expenditure (millions of US dollars),,,973.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +400,Jordan,2005,Tourism expenditure (millions of US dollars),,,1759.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +400,Jordan,2010,Tourism expenditure (millions of US dollars),,,4390.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +400,Jordan,2016,Tourism expenditure (millions of US dollars),,,4943.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +400,Jordan,2017,Tourism expenditure (millions of US dollars),,,5549.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +400,Jordan,2018,Tourism expenditure (millions of US dollars),,,6221.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +398,Kazakhstan,2005,Tourist/visitor arrivals (thousands),TF,,3143.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +398,Kazakhstan,2010,Tourist/visitor arrivals (thousands),TF,,2991.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +398,Kazakhstan,1995,Tourism expenditure (millions of US dollars),,,155.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +398,Kazakhstan,2005,Tourism expenditure (millions of US dollars),,,801.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +398,Kazakhstan,2010,Tourism expenditure (millions of US dollars),,,1236.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +398,Kazakhstan,2016,Tourism expenditure (millions of US dollars),,,2038.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +398,Kazakhstan,2017,Tourism expenditure (millions of US dollars),,,2356.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +398,Kazakhstan,2018,Tourism expenditure (millions of US dollars),,,2651.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +404,Kenya,1995,Tourist/visitor arrivals (thousands),TF,,918.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +404,Kenya,2005,Tourist/visitor arrivals (thousands),TF,,1399.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +404,Kenya,2010,Tourist/visitor arrivals (thousands),TF,,1470.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +404,Kenya,2016,Tourist/visitor arrivals (thousands),TF,,1268.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +404,Kenya,2017,Tourist/visitor arrivals (thousands),TF,,1364.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +404,Kenya,1995,Tourism expenditure (millions of US dollars),,,785.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +404,Kenya,2005,Tourism expenditure (millions of US dollars),,,969.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +404,Kenya,2010,Tourism expenditure (millions of US dollars),,,1620.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +404,Kenya,2016,Tourism expenditure (millions of US dollars),,,1471.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +404,Kenya,2017,Tourism expenditure (millions of US dollars),,,1564.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +296,Kiribati,1995,Tourist/visitor arrivals (thousands),TF,,3.9000,Air arrivals. Tarawa and Christmas Island.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +296,Kiribati,2005,Tourist/visitor arrivals (thousands),TF,,4.1000,Air arrivals. Tarawa and Christmas Island.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +296,Kiribati,2010,Tourist/visitor arrivals (thousands),TF,,4.7000,Air arrivals. Tarawa and Christmas Island.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +296,Kiribati,2016,Tourist/visitor arrivals (thousands),TF,,5.7000,Air arrivals. Tarawa and Christmas Island.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +296,Kiribati,2017,Tourist/visitor arrivals (thousands),TF,,5.8000,Air arrivals. Tarawa and Christmas Island.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +296,Kiribati,2018,Tourist/visitor arrivals (thousands),TF,,7.1000,Air arrivals. Tarawa and Christmas Island.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +296,Kiribati,2010,Tourism expenditure (millions of US dollars),,,4.3000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +296,Kiribati,2016,Tourism expenditure (millions of US dollars),,,2.8000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +296,Kiribati,2017,Tourism expenditure (millions of US dollars),,,4.1000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +414,Kuwait,1995,Tourist/visitor arrivals (thousands),VF,,1443.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +414,Kuwait,2005,Tourist/visitor arrivals (thousands),VF,,3474.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +414,Kuwait,2010,Tourist/visitor arrivals (thousands),VF,,5208.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +414,Kuwait,2016,Tourist/visitor arrivals (thousands),VF,,7055.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +414,Kuwait,2017,Tourist/visitor arrivals (thousands),VF,,7407.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +414,Kuwait,2018,Tourist/visitor arrivals (thousands),VF,,8508.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +414,Kuwait,1995,Tourism expenditure (millions of US dollars),,,307.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +414,Kuwait,2005,Tourism expenditure (millions of US dollars),,,413.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +414,Kuwait,2010,Tourism expenditure (millions of US dollars),,,574.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +414,Kuwait,2016,Tourism expenditure (millions of US dollars),,,831.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +414,Kuwait,2017,Tourism expenditure (millions of US dollars),,,643.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +414,Kuwait,2018,Tourism expenditure (millions of US dollars),,,919.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +417,Kyrgyzstan,2005,Tourist/visitor arrivals (thousands),VF,,319.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +417,Kyrgyzstan,2010,Tourist/visitor arrivals (thousands),VF,,1224.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +417,Kyrgyzstan,2016,Tourist/visitor arrivals (thousands),VF,,3853.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +417,Kyrgyzstan,2017,Tourist/visitor arrivals (thousands),VF,,4568.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +417,Kyrgyzstan,2018,Tourist/visitor arrivals (thousands),VF,,6947.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +417,Kyrgyzstan,2005,Tourism expenditure (millions of US dollars),,,94.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +417,Kyrgyzstan,2010,Tourism expenditure (millions of US dollars),,,212.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +417,Kyrgyzstan,2016,Tourism expenditure (millions of US dollars),,,477.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +417,Kyrgyzstan,2017,Tourism expenditure (millions of US dollars),,,480.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +417,Kyrgyzstan,2018,Tourism expenditure (millions of US dollars),,,487.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +418,Lao People's Dem. Rep.,1995,Tourist/visitor arrivals (thousands),TF,,60.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +418,Lao People's Dem. Rep.,2005,Tourist/visitor arrivals (thousands),TF,,672.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +418,Lao People's Dem. Rep.,2010,Tourist/visitor arrivals (thousands),TF,,1670.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +418,Lao People's Dem. Rep.,2016,Tourist/visitor arrivals (thousands),TF,,3315.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +418,Lao People's Dem. Rep.,2017,Tourist/visitor arrivals (thousands),TF,,3257.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +418,Lao People's Dem. Rep.,2018,Tourist/visitor arrivals (thousands),TF,,3770.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +418,Lao People's Dem. Rep.,1995,Tourism expenditure (millions of US dollars),,,52.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +418,Lao People's Dem. Rep.,2005,Tourism expenditure (millions of US dollars),,,143.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +418,Lao People's Dem. Rep.,2010,Tourism expenditure (millions of US dollars),,,385.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +418,Lao People's Dem. Rep.,2016,Tourism expenditure (millions of US dollars),,,717.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +418,Lao People's Dem. Rep.,2017,Tourism expenditure (millions of US dollars),,,655.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +418,Lao People's Dem. Rep.,2018,Tourism expenditure (millions of US dollars),,,757.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +428,Latvia,1995,Tourist/visitor arrivals (thousands),TF,,539.0000,Non-resident departures. Survey of persons crossing the state border.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +428,Latvia,2005,Tourist/visitor arrivals (thousands),TF,,1116.0000,Non-resident departures. Survey of persons crossing the state border.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +428,Latvia,2010,Tourist/visitor arrivals (thousands),TF,,1373.0000,Non-resident departures. Survey of persons crossing the state border.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +428,Latvia,2016,Tourist/visitor arrivals (thousands),TF,,1793.0000,Non-resident departures. Survey of persons crossing the state border.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +428,Latvia,2017,Tourist/visitor arrivals (thousands),TF,,1949.0000,Non-resident departures. Survey of persons crossing the state border.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +428,Latvia,2018,Tourist/visitor arrivals (thousands),TF,,1946.0000,Non-resident departures. Survey of persons crossing the state border.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +428,Latvia,1995,Tourism expenditure (millions of US dollars),,,37.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +428,Latvia,2005,Tourism expenditure (millions of US dollars),,,446.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +422,Lebanon,1995,Tourist/visitor arrivals (thousands),TF,,450.0000,"Excluding the Lebanon, Syria and Palestine nationalities.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +422,Lebanon,2005,Tourist/visitor arrivals (thousands),TF,,1140.0000,"Excluding the Lebanon, Syria and Palestine nationalities.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +422,Lebanon,2010,Tourist/visitor arrivals (thousands),TF,,2168.0000,"Excluding the Lebanon, Syria and Palestine nationalities.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +422,Lebanon,2016,Tourist/visitor arrivals (thousands),TF,,1688.0000,"Excluding the Lebanon, Syria and Palestine nationalities.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +422,Lebanon,2017,Tourist/visitor arrivals (thousands),TF,,1857.0000,"Excluding the Lebanon, Syria and Palestine nationalities.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +422,Lebanon,2018,Tourist/visitor arrivals (thousands),TF,,1964.0000,"Excluding the Lebanon, Syria and Palestine nationalities.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +422,Lebanon,1995,Tourism expenditure (millions of US dollars),,,710.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +422,Lebanon,2005,Tourism expenditure (millions of US dollars),,,5969.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +422,Lebanon,2010,Tourism expenditure (millions of US dollars),,,8026.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +422,Lebanon,2016,Tourism expenditure (millions of US dollars),,,7373.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +422,Lebanon,2017,Tourism expenditure (millions of US dollars),,,8086.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +422,Lebanon,2018,Tourism expenditure (millions of US dollars),,,8694.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +426,Lesotho,1995,Tourist/visitor arrivals (thousands),VF,,209.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +426,Lesotho,2005,Tourist/visitor arrivals (thousands),VF,,304.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +426,Lesotho,2010,Tourist/visitor arrivals (thousands),VF,,426.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +426,Lesotho,2016,Tourist/visitor arrivals (thousands),VF,,1196.0000,Break in the time series.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +426,Lesotho,2017,Tourist/visitor arrivals (thousands),VF,,1137.0000,Break in the time series.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +426,Lesotho,2018,Tourist/visitor arrivals (thousands),VF,,1173.0000,Break in the time series.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +426,Lesotho,1995,Tourism expenditure (millions of US dollars),,,27.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +426,Lesotho,2005,Tourism expenditure (millions of US dollars),,,27.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +426,Lesotho,2010,Tourism expenditure (millions of US dollars),,,23.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +426,Lesotho,2016,Tourism expenditure (millions of US dollars),,,48.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +426,Lesotho,2017,Tourism expenditure (millions of US dollars),,,23.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +426,Lesotho,2018,Tourism expenditure (millions of US dollars),,,24.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +430,Liberia,2005,Tourism expenditure (millions of US dollars),,,67.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +434,Libya,2005,Tourist/visitor arrivals (thousands),THS,,81.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +434,Libya,1995,Tourism expenditure (millions of US dollars),,,4.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +434,Libya,2005,Tourism expenditure (millions of US dollars),,,301.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +434,Libya,2010,Tourism expenditure (millions of US dollars),,,170.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +438,Liechtenstein,2010,Tourist/visitor arrivals (thousands),TCE,,64.3000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +438,Liechtenstein,2016,Tourist/visitor arrivals (thousands),TCE,,69.1000,Excluding long term tourists on campgrounds and in holiday flats.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +438,Liechtenstein,2017,Tourist/visitor arrivals (thousands),TCE,,79.3000,Excluding long term tourists on campgrounds and in holiday flats.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +438,Liechtenstein,2018,Tourist/visitor arrivals (thousands),TCE,,85.3000,Excluding long term tourists on campgrounds and in holiday flats.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +440,Lithuania,1995,Tourist/visitor arrivals (thousands),TF,,650.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +440,Lithuania,2005,Tourist/visitor arrivals (thousands),TF,,2000.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +440,Lithuania,2010,Tourist/visitor arrivals (thousands),TF,,1507.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +440,Lithuania,2016,Tourist/visitor arrivals (thousands),TF,,2296.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +440,Lithuania,2017,Tourist/visitor arrivals (thousands),TF,,2523.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +440,Lithuania,2018,Tourist/visitor arrivals (thousands),TF,,2825.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +440,Lithuania,1995,Tourism expenditure (millions of US dollars),,,77.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +440,Lithuania,2005,Tourism expenditure (millions of US dollars),,,920.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +440,Lithuania,2010,Tourism expenditure (millions of US dollars),,,958.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +440,Lithuania,2016,Tourism expenditure (millions of US dollars),,,1210.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +440,Lithuania,2017,Tourism expenditure (millions of US dollars),,,1325.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +440,Lithuania,2018,Tourism expenditure (millions of US dollars),,,1419.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +442,Luxembourg,1995,Tourist/visitor arrivals (thousands),TCE,,768.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +442,Luxembourg,2005,Tourist/visitor arrivals (thousands),TCE,,913.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +442,Luxembourg,2010,Tourist/visitor arrivals (thousands),TCE,,805.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +442,Luxembourg,2016,Tourist/visitor arrivals (thousands),TCE,,1054.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +442,Luxembourg,2017,Tourist/visitor arrivals (thousands),TCE,,1046.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +442,Luxembourg,2018,Tourist/visitor arrivals (thousands),TCE,,1018.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +442,Luxembourg,2005,Tourism expenditure (millions of US dollars),,,3770.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +442,Luxembourg,2010,Tourism expenditure (millions of US dollars),,,4519.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +442,Luxembourg,2016,Tourism expenditure (millions of US dollars),,,4766.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +442,Luxembourg,2017,Tourism expenditure (millions of US dollars),,,4993.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +442,Luxembourg,2018,Tourism expenditure (millions of US dollars),,,5537.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +450,Madagascar,1995,Tourist/visitor arrivals (thousands),TF,,75.0000,Arrivals of non-resident tourists by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +450,Madagascar,2005,Tourist/visitor arrivals (thousands),TF,,277.0000,Arrivals of non-resident tourists by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +450,Madagascar,2010,Tourist/visitor arrivals (thousands),TF,,196.0000,Arrivals of non-resident tourists by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +450,Madagascar,2016,Tourist/visitor arrivals (thousands),TF,,293.0000,Arrivals of non-resident tourists by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +450,Madagascar,2017,Tourist/visitor arrivals (thousands),TF,,255.0000,Arrivals of non-resident tourists by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +450,Madagascar,2018,Tourist/visitor arrivals (thousands),TF,,291.0000,Arrivals of non-resident tourists by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +450,Madagascar,1995,Tourism expenditure (millions of US dollars),,,106.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +450,Madagascar,2005,Tourism expenditure (millions of US dollars),,,275.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +450,Madagascar,2010,Tourism expenditure (millions of US dollars),,,425.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +450,Madagascar,2016,Tourism expenditure (millions of US dollars),,,913.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +450,Madagascar,2017,Tourism expenditure (millions of US dollars),,,849.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +450,Madagascar,2018,Tourism expenditure (millions of US dollars),,,879.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +454,Malawi,1995,Tourist/visitor arrivals (thousands),TF,,192.0000,Departures.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +454,Malawi,2005,Tourist/visitor arrivals (thousands),TF,,438.0000,Departures.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +454,Malawi,2010,Tourist/visitor arrivals (thousands),TF,,746.0000,Departures.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +454,Malawi,2016,Tourist/visitor arrivals (thousands),TF,,849.0000,Departures.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +454,Malawi,2017,Tourist/visitor arrivals (thousands),TF,,837.0000,Departures.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +454,Malawi,2018,Tourist/visitor arrivals (thousands),TF,,871.0000,Departures.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +454,Malawi,1995,Tourism expenditure (millions of US dollars),,,22.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +454,Malawi,2005,Tourism expenditure (millions of US dollars),,,48.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +454,Malawi,2010,Tourism expenditure (millions of US dollars),,,45.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +454,Malawi,2016,Tourism expenditure (millions of US dollars),,,30.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +454,Malawi,2017,Tourism expenditure (millions of US dollars),,,35.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +454,Malawi,2018,Tourism expenditure (millions of US dollars),,,43.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +458,Malaysia,1995,Tourist/visitor arrivals (thousands),TF,,7469.0000,Including Singapore residents crossing the frontier by road through Johore Causeway.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +458,Malaysia,2005,Tourist/visitor arrivals (thousands),TF,,16431.0000,Including Singapore residents crossing the frontier by road through Johore Causeway.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +458,Malaysia,2010,Tourist/visitor arrivals (thousands),TF,,24577.0000,Including Singapore residents crossing the frontier by road through Johore Causeway.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +458,Malaysia,2016,Tourist/visitor arrivals (thousands),TF,,26757.0000,Including Singapore residents crossing the frontier by road through Johore Causeway.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +458,Malaysia,2017,Tourist/visitor arrivals (thousands),TF,,25948.0000,Including Singapore residents crossing the frontier by road through Johore Causeway.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +458,Malaysia,2018,Tourist/visitor arrivals (thousands),TF,,25832.0000,Including Singapore residents crossing the frontier by road through Johore Causeway.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +458,Malaysia,1995,Tourism expenditure (millions of US dollars),,,5044.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +458,Malaysia,2005,Tourism expenditure (millions of US dollars),,,10389.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +458,Malaysia,2010,Tourism expenditure (millions of US dollars),,,19619.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +458,Malaysia,2016,Tourism expenditure (millions of US dollars),,,19682.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +458,Malaysia,2017,Tourism expenditure (millions of US dollars),,,20311.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +458,Malaysia,2018,Tourism expenditure (millions of US dollars),,,21774.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +462,Maldives,1995,Tourist/visitor arrivals (thousands),TF,,315.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +462,Maldives,2005,Tourist/visitor arrivals (thousands),TF,,395.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +462,Maldives,2010,Tourist/visitor arrivals (thousands),TF,,792.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +462,Maldives,2016,Tourist/visitor arrivals (thousands),TF,,1286.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +462,Maldives,2017,Tourist/visitor arrivals (thousands),TF,,1390.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +462,Maldives,2018,Tourist/visitor arrivals (thousands),TF,,1484.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +462,Maldives,2016,Tourism expenditure (millions of US dollars),,,2640.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +462,Maldives,2017,Tourism expenditure (millions of US dollars),,,2771.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +462,Maldives,2018,Tourism expenditure (millions of US dollars),,,3054.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +466,Mali,2010,Tourist/visitor arrivals (thousands),TF,,169.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +466,Mali,2016,Tourist/visitor arrivals (thousands),TF,,173.2000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +466,Mali,2017,Tourist/visitor arrivals (thousands),TF,,193.3000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +466,Mali,1995,Tourism expenditure (millions of US dollars),,,26.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +466,Mali,2005,Tourism expenditure (millions of US dollars),,,149.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +466,Mali,2010,Tourism expenditure (millions of US dollars),,,208.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +466,Mali,2016,Tourism expenditure (millions of US dollars),,,201.6000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +466,Mali,2017,Tourism expenditure (millions of US dollars),,,206.4000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +470,Malta,1995,Tourist/visitor arrivals (thousands),TF,,1116.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +470,Malta,2005,Tourist/visitor arrivals (thousands),TF,,1171.0000,Departures by air and by sea.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +470,Malta,2010,Tourist/visitor arrivals (thousands),TF,,1339.0000,Departures by air and by sea.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +470,Malta,2016,Tourist/visitor arrivals (thousands),TF,,1966.0000,Departures by air and by sea.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +470,Malta,2017,Tourist/visitor arrivals (thousands),TF,,2274.0000,Departures by air and by sea.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +470,Malta,2018,Tourist/visitor arrivals (thousands),TF,,2599.0000,Departures by air and by sea.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +470,Malta,1995,Tourism expenditure (millions of US dollars),,,656.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +470,Malta,2005,Tourism expenditure (millions of US dollars),,,755.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +470,Malta,2010,Tourism expenditure (millions of US dollars),,,1066.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +470,Malta,2016,Tourism expenditure (millions of US dollars),,,1451.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +470,Malta,2017,Tourism expenditure (millions of US dollars),,,1746.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +470,Malta,2018,Tourism expenditure (millions of US dollars),,,1845.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +584,Marshall Islands,1995,Tourist/visitor arrivals (thousands),TF,,5.5000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +584,Marshall Islands,2005,Tourist/visitor arrivals (thousands),TF,,9.2000,Air and sea arrivals.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +584,Marshall Islands,2010,Tourist/visitor arrivals (thousands),TF,,4.6000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +584,Marshall Islands,2016,Tourist/visitor arrivals (thousands),TF,,5.4000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +584,Marshall Islands,2017,Tourist/visitor arrivals (thousands),TF,,6.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +584,Marshall Islands,2018,Tourist/visitor arrivals (thousands),TF,,6.8000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +584,Marshall Islands,1995,Tourism expenditure (millions of US dollars),,,2.5000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +584,Marshall Islands,2005,Tourism expenditure (millions of US dollars),,,3.6900,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +584,Marshall Islands,2010,Tourism expenditure (millions of US dollars),,,3.7000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +584,Marshall Islands,2016,Tourism expenditure (millions of US dollars),,,30.4000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +584,Marshall Islands,2017,Tourism expenditure (millions of US dollars),,,18.1000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +584,Marshall Islands,2018,Tourism expenditure (millions of US dollars),,,20.1000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +474,Martinique,1995,Tourist/visitor arrivals (thousands),TF,,457.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +474,Martinique,2005,Tourist/visitor arrivals (thousands),TF,,484.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +474,Martinique,2010,Tourist/visitor arrivals (thousands),TF,,478.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +474,Martinique,2016,Tourist/visitor arrivals (thousands),TF,,519.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +474,Martinique,2017,Tourist/visitor arrivals (thousands),TF,,536.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +474,Martinique,2018,Tourist/visitor arrivals (thousands),TF,,537.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +474,Martinique,1995,Tourism expenditure (millions of US dollars),,,384.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +474,Martinique,2005,Tourism expenditure (millions of US dollars),,,280.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +474,Martinique,2010,Tourism expenditure (millions of US dollars),,,472.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +474,Martinique,2016,Tourism expenditure (millions of US dollars),,,348.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +474,Martinique,2017,Tourism expenditure (millions of US dollars),,,510.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +474,Martinique,2018,Tourism expenditure (millions of US dollars),,,530.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +478,Mauritania,2016,Tourism expenditure (millions of US dollars),,,33.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +478,Mauritania,2017,Tourism expenditure (millions of US dollars),,,24.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +478,Mauritania,2018,Tourism expenditure (millions of US dollars),,,6.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +480,Mauritius,1995,Tourist/visitor arrivals (thousands),TF,,422.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +480,Mauritius,2005,Tourist/visitor arrivals (thousands),TF,,761.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +480,Mauritius,2010,Tourist/visitor arrivals (thousands),TF,,935.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +480,Mauritius,2016,Tourist/visitor arrivals (thousands),TF,,1275.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +480,Mauritius,2017,Tourist/visitor arrivals (thousands),TF,,1342.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +480,Mauritius,2018,Tourist/visitor arrivals (thousands),TF,,1399.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +480,Mauritius,1995,Tourism expenditure (millions of US dollars),,,616.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +480,Mauritius,2005,Tourism expenditure (millions of US dollars),,,1189.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +480,Mauritius,2010,Tourism expenditure (millions of US dollars),,,1585.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +480,Mauritius,2016,Tourism expenditure (millions of US dollars),,,1824.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +480,Mauritius,2017,Tourism expenditure (millions of US dollars),,,2005.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +480,Mauritius,2018,Tourism expenditure (millions of US dollars),,,2161.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +484,Mexico,1995,Tourist/visitor arrivals (thousands),TF,,20241.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +484,Mexico,2005,Tourist/visitor arrivals (thousands),TF,,21915.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +484,Mexico,2010,Tourist/visitor arrivals (thousands),TF,,23290.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +484,Mexico,2016,Tourist/visitor arrivals (thousands),TF,,35079.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +484,Mexico,2017,Tourist/visitor arrivals (thousands),TF,,39291.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +484,Mexico,2018,Tourist/visitor arrivals (thousands),TF,,41313.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +484,Mexico,1995,Tourism expenditure (millions of US dollars),,,6847.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +484,Mexico,2005,Tourism expenditure (millions of US dollars),,,12801.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +484,Mexico,2010,Tourism expenditure (millions of US dollars),,,12628.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +484,Mexico,2016,Tourism expenditure (millions of US dollars),,,20619.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +484,Mexico,2017,Tourism expenditure (millions of US dollars),,,22467.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +484,Mexico,2018,Tourism expenditure (millions of US dollars),,,23802.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +583,Micronesia (Fed. States of),2005,Tourist/visitor arrivals (thousands),TF,,19.0000,"Arrivals in the States of Kosrae, Chuuk, Pohnpei and Yap; excluding FSM citizens.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +583,Micronesia (Fed. States of),2010,Tourist/visitor arrivals (thousands),TF,,44.7000,"Arrivals in the States of Kosrae, Chuuk, Pohnpei and Yap; excluding FSM citizens.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +583,Micronesia (Fed. States of),2016,Tourist/visitor arrivals (thousands),TF,,29.6000,"Arrivals in the States of Kosrae, Chuuk, Pohnpei and Yap; excluding FSM citizens.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +583,Micronesia (Fed. States of),2018,Tourist/visitor arrivals (thousands),TF,,19.2000,"Arrivals in the States of Kosrae, Chuuk, Pohnpei and Yap; excluding FSM citizens.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +583,Micronesia (Fed. States of),2010,Tourism expenditure (millions of US dollars),,,24.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +492,Monaco,1995,Tourist/visitor arrivals (thousands),THS,,233.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +492,Monaco,2005,Tourist/visitor arrivals (thousands),THS,,286.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +492,Monaco,2010,Tourist/visitor arrivals (thousands),THS,,279.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +492,Monaco,2016,Tourist/visitor arrivals (thousands),THS,,336.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +492,Monaco,2017,Tourist/visitor arrivals (thousands),THS,,355.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +492,Monaco,2018,Tourist/visitor arrivals (thousands),THS,,347.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +496,Mongolia,2005,Tourist/visitor arrivals (thousands),TF,,339.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +496,Mongolia,2010,Tourist/visitor arrivals (thousands),TF,,456.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +496,Mongolia,2016,Tourist/visitor arrivals (thousands),TF,,404.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +496,Mongolia,2017,Tourist/visitor arrivals (thousands),TF,,469.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +496,Mongolia,2018,Tourist/visitor arrivals (thousands),TF,,529.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +496,Mongolia,1995,Tourism expenditure (millions of US dollars),,,33.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +496,Mongolia,2005,Tourism expenditure (millions of US dollars),,,203.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +496,Mongolia,2010,Tourism expenditure (millions of US dollars),,,288.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +496,Mongolia,2016,Tourism expenditure (millions of US dollars),,,379.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +496,Mongolia,2017,Tourism expenditure (millions of US dollars),,,462.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +496,Mongolia,2018,Tourism expenditure (millions of US dollars),,,526.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +499,Montenegro,2005,Tourist/visitor arrivals (thousands),TCE,,272.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +499,Montenegro,2010,Tourist/visitor arrivals (thousands),TCE,,1088.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +499,Montenegro,2016,Tourist/visitor arrivals (thousands),TCE,,1662.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +499,Montenegro,2017,Tourist/visitor arrivals (thousands),TCE,,1877.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +499,Montenegro,2018,Tourist/visitor arrivals (thousands),TCE,,2077.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +499,Montenegro,2010,Tourism expenditure (millions of US dollars),,,765.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +499,Montenegro,2016,Tourism expenditure (millions of US dollars),,,978.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +499,Montenegro,2017,Tourism expenditure (millions of US dollars),,,1110.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +499,Montenegro,2018,Tourism expenditure (millions of US dollars),,,1224.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +500,Montserrat,1995,Tourist/visitor arrivals (thousands),TF,,17.7000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +500,Montserrat,2005,Tourist/visitor arrivals (thousands),TF,,9.7000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +500,Montserrat,2010,Tourist/visitor arrivals (thousands),TF,,6.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +500,Montserrat,2016,Tourist/visitor arrivals (thousands),TF,,8.8000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +500,Montserrat,2017,Tourist/visitor arrivals (thousands),TF,,8.8000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +500,Montserrat,2018,Tourist/visitor arrivals (thousands),TF,,8.8000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +500,Montserrat,1995,Tourism expenditure (millions of US dollars),,,17.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +500,Montserrat,2005,Tourism expenditure (millions of US dollars),,,9.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +500,Montserrat,2010,Tourism expenditure (millions of US dollars),,,5.9000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +500,Montserrat,2016,Tourism expenditure (millions of US dollars),,,8.6000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +500,Montserrat,2017,Tourism expenditure (millions of US dollars),,,8.4000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +500,Montserrat,2018,Tourism expenditure (millions of US dollars),,,11.1000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +504,Morocco,1995,Tourist/visitor arrivals (thousands),TF,,2602.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +504,Morocco,2005,Tourist/visitor arrivals (thousands),TF,,5843.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +504,Morocco,2010,Tourist/visitor arrivals (thousands),TF,,9288.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +504,Morocco,2016,Tourist/visitor arrivals (thousands),TF,,10332.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +504,Morocco,2017,Tourist/visitor arrivals (thousands),TF,,11349.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +504,Morocco,2018,Tourist/visitor arrivals (thousands),TF,,12289.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +504,Morocco,1995,Tourism expenditure (millions of US dollars),,,1469.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +504,Morocco,2005,Tourism expenditure (millions of US dollars),,,5426.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +504,Morocco,2010,Tourism expenditure (millions of US dollars),,,8176.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +504,Morocco,2016,Tourism expenditure (millions of US dollars),,,7922.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +504,Morocco,2017,Tourism expenditure (millions of US dollars),,,9086.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +504,Morocco,2018,Tourism expenditure (millions of US dollars),,,9523.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +508,Mozambique,2005,Tourist/visitor arrivals (thousands),TF,,578.0000,The data correspond only to 12 border posts.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +508,Mozambique,2010,Tourist/visitor arrivals (thousands),TF,,1718.0000,Break in the time series.;The data of all the border posts of the country are used.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +508,Mozambique,2016,Tourist/visitor arrivals (thousands),TF,,1639.0000,The data of all the border posts of the country are used.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +508,Mozambique,2017,Tourist/visitor arrivals (thousands),TF,,1447.0000,The data of all the border posts of the country are used.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +508,Mozambique,2018,Tourist/visitor arrivals (thousands),TF,,2743.0000,The data of all the border posts of the country are used.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +508,Mozambique,2005,Tourism expenditure (millions of US dollars),,,138.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +508,Mozambique,2010,Tourism expenditure (millions of US dollars),,,135.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +508,Mozambique,2016,Tourism expenditure (millions of US dollars),,,114.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +508,Mozambique,2017,Tourism expenditure (millions of US dollars),,,164.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +508,Mozambique,2018,Tourism expenditure (millions of US dollars),,,331.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +104,Myanmar,1995,Tourist/visitor arrivals (thousands),TF,,194.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +104,Myanmar,2005,Tourist/visitor arrivals (thousands),TF,,660.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +104,Myanmar,2010,Tourist/visitor arrivals (thousands),TF,,792.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +104,Myanmar,2016,Tourist/visitor arrivals (thousands),TF,,2907.0000,Break in the time series.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +104,Myanmar,2017,Tourist/visitor arrivals (thousands),TF,,3443.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +104,Myanmar,2018,Tourist/visitor arrivals (thousands),TF,,3551.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +104,Myanmar,1995,Tourism expenditure (millions of US dollars),,,169.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +104,Myanmar,2005,Tourism expenditure (millions of US dollars),,,83.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +104,Myanmar,2010,Tourism expenditure (millions of US dollars),,,91.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +104,Myanmar,2016,Tourism expenditure (millions of US dollars),,,2289.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +104,Myanmar,2017,Tourism expenditure (millions of US dollars),,,1988.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +104,Myanmar,2018,Tourism expenditure (millions of US dollars),,,1670.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +516,Namibia,1995,Tourist/visitor arrivals (thousands),TF,,272.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +516,Namibia,2005,Tourist/visitor arrivals (thousands),TF,,778.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +516,Namibia,2010,Tourist/visitor arrivals (thousands),TF,,984.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +516,Namibia,2016,Tourist/visitor arrivals (thousands),TF,,1469.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +516,Namibia,2017,Tourist/visitor arrivals (thousands),TF,,1499.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +516,Namibia,2005,Tourism expenditure (millions of US dollars),,,363.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +516,Namibia,2010,Tourism expenditure (millions of US dollars),,,473.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +516,Namibia,2016,Tourism expenditure (millions of US dollars),,,349.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +516,Namibia,2017,Tourism expenditure (millions of US dollars),,,449.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +516,Namibia,2018,Tourism expenditure (millions of US dollars),,,488.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +520,Nauru,2010,Tourism expenditure (millions of US dollars),,,0.6000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +520,Nauru,2016,Tourism expenditure (millions of US dollars),,,3.4000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +520,Nauru,2017,Tourism expenditure (millions of US dollars),,,3.9000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +520,Nauru,2018,Tourism expenditure (millions of US dollars),,,1.6000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +524,Nepal,1995,Tourist/visitor arrivals (thousands),TF,,363.0000,Including arrivals from India.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +524,Nepal,2005,Tourist/visitor arrivals (thousands),TF,,375.0000,Including arrivals from India.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +524,Nepal,2010,Tourist/visitor arrivals (thousands),TF,,603.0000,Including arrivals from India.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +524,Nepal,2016,Tourist/visitor arrivals (thousands),TF,,753.0000,Including arrivals from India.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +524,Nepal,2017,Tourist/visitor arrivals (thousands),TF,,940.0000,Including arrivals from India.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +524,Nepal,2018,Tourist/visitor arrivals (thousands),TF,,1173.0000,Including arrivals from India.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +524,Nepal,1995,Tourism expenditure (millions of US dollars),,,232.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +524,Nepal,2005,Tourism expenditure (millions of US dollars),,,160.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +524,Nepal,2010,Tourism expenditure (millions of US dollars),,,378.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +524,Nepal,2016,Tourism expenditure (millions of US dollars),,,498.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +524,Nepal,2017,Tourism expenditure (millions of US dollars),,,712.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +524,Nepal,2018,Tourism expenditure (millions of US dollars),,,744.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +528,Netherlands,1995,Tourist/visitor arrivals (thousands),TCE,,6574.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +528,Netherlands,2005,Tourist/visitor arrivals (thousands),TCE,,10012.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +528,Netherlands,2010,Tourist/visitor arrivals (thousands),TCE,,10883.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +528,Netherlands,2016,Tourist/visitor arrivals (thousands),TCE,,15828.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +528,Netherlands,2017,Tourist/visitor arrivals (thousands),TCE,,17924.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +528,Netherlands,2018,Tourist/visitor arrivals (thousands),TCE,,18780.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +528,Netherlands,1995,Tourism expenditure (millions of US dollars),,,10611.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +528,Netherlands,2016,Tourism expenditure (millions of US dollars),,,21151.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +528,Netherlands,2017,Tourism expenditure (millions of US dollars),,,23414.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +528,Netherlands,2018,Tourism expenditure (millions of US dollars),,,25850.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +540,New Caledonia,1995,Tourist/visitor arrivals (thousands),TF,,86.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +540,New Caledonia,2005,Tourist/visitor arrivals (thousands),TF,,101.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +540,New Caledonia,2010,Tourist/visitor arrivals (thousands),TF,,99.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +540,New Caledonia,2016,Tourist/visitor arrivals (thousands),TF,,116.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +540,New Caledonia,2017,Tourist/visitor arrivals (thousands),TF,,121.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +540,New Caledonia,2018,Tourist/visitor arrivals (thousands),TF,,120.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +540,New Caledonia,1995,Tourism expenditure (millions of US dollars),,,108.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +540,New Caledonia,2005,Tourism expenditure (millions of US dollars),,,149.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +540,New Caledonia,2010,Tourism expenditure (millions of US dollars),,,129.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +540,New Caledonia,2016,Tourism expenditure (millions of US dollars),,,159.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +554,New Zealand,2005,Tourist/visitor arrivals (thousands),TF,,2353.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +554,New Zealand,2010,Tourist/visitor arrivals (thousands),TF,,2435.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +554,New Zealand,2016,Tourist/visitor arrivals (thousands),TF,,3370.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +554,New Zealand,2017,Tourist/visitor arrivals (thousands),TF,,3555.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +554,New Zealand,2018,Tourist/visitor arrivals (thousands),TF,,3686.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +554,New Zealand,1995,Tourism expenditure (millions of US dollars),,,2318.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +554,New Zealand,2005,Tourism expenditure (millions of US dollars),,,6486.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +554,New Zealand,2010,Tourism expenditure (millions of US dollars),,,6523.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +554,New Zealand,2016,Tourism expenditure (millions of US dollars),,,9773.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +554,New Zealand,2017,Tourism expenditure (millions of US dollars),,,10594.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +554,New Zealand,2018,Tourism expenditure (millions of US dollars),,,10961.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +558,Nicaragua,1995,Tourist/visitor arrivals (thousands),TF,,281.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +558,Nicaragua,2005,Tourist/visitor arrivals (thousands),TF,,712.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +558,Nicaragua,2010,Tourist/visitor arrivals (thousands),TF,,1011.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +558,Nicaragua,2016,Tourist/visitor arrivals (thousands),TF,,1504.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +558,Nicaragua,2017,Tourist/visitor arrivals (thousands),TF,,1787.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +558,Nicaragua,2018,Tourist/visitor arrivals (thousands),TF,,1256.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +558,Nicaragua,1995,Tourism expenditure (millions of US dollars),,,50.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +558,Nicaragua,2005,Tourism expenditure (millions of US dollars),,,206.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +558,Nicaragua,2010,Tourism expenditure (millions of US dollars),,,314.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +558,Nicaragua,2016,Tourism expenditure (millions of US dollars),,,642.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +558,Nicaragua,2017,Tourism expenditure (millions of US dollars),,,841.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +558,Nicaragua,2018,Tourism expenditure (millions of US dollars),,,544.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +562,Niger,1995,Tourist/visitor arrivals (thousands),TF,,35.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +562,Niger,2005,Tourist/visitor arrivals (thousands),TF,,58.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +562,Niger,2010,Tourist/visitor arrivals (thousands),TF,,74.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +562,Niger,2016,Tourist/visitor arrivals (thousands),TF,,152.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +562,Niger,2017,Tourist/visitor arrivals (thousands),TF,,164.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +562,Niger,2018,Tourist/visitor arrivals (thousands),TF,,157.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +562,Niger,2005,Tourism expenditure (millions of US dollars),,,43.9000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +562,Niger,2010,Tourism expenditure (millions of US dollars),,,105.5000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +562,Niger,2016,Tourism expenditure (millions of US dollars),,,84.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +562,Niger,2017,Tourism expenditure (millions of US dollars),,,91.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +566,Nigeria,1995,Tourist/visitor arrivals (thousands),TF,,656.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +566,Nigeria,2005,Tourist/visitor arrivals (thousands),TF,,1010.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +566,Nigeria,2010,Tourist/visitor arrivals (thousands),TF,,1555.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +566,Nigeria,2016,Tourist/visitor arrivals (thousands),TF,,1889.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +566,Nigeria,1995,Tourism expenditure (millions of US dollars),,,47.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +566,Nigeria,2005,Tourism expenditure (millions of US dollars),,,139.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +566,Nigeria,2010,Tourism expenditure (millions of US dollars),,,736.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +566,Nigeria,2016,Tourism expenditure (millions of US dollars),,,1088.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +566,Nigeria,2017,Tourism expenditure (millions of US dollars),,,2615.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +566,Nigeria,2018,Tourism expenditure (millions of US dollars),,,1977.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +570,Niue,1995,Tourist/visitor arrivals (thousands),TF,,2.2000,Including Niueans residing usually in New Zealand.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +570,Niue,2005,Tourist/visitor arrivals (thousands),TF,,2.8000,Including Niueans residing usually in New Zealand.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +570,Niue,2010,Tourist/visitor arrivals (thousands),TF,,6.2000,Including Niueans residing usually in New Zealand.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +570,Niue,2016,Tourist/visitor arrivals (thousands),TF,,8.9000,Including Niueans residing usually in New Zealand.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +570,Niue,2017,Tourist/visitor arrivals (thousands),TF,,9.8000,Including Niueans residing usually in New Zealand.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +570,Niue,1995,Tourism expenditure (millions of US dollars),,,2.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +570,Niue,2005,Tourism expenditure (millions of US dollars),,,1.2000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +570,Niue,2010,Tourism expenditure (millions of US dollars),,,2.2000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +807,North Macedonia,1995,Tourist/visitor arrivals (thousands),TCE,,147.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +807,North Macedonia,2005,Tourist/visitor arrivals (thousands),TCE,,197.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +807,North Macedonia,2010,Tourist/visitor arrivals (thousands),TCE,,262.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +807,North Macedonia,2016,Tourist/visitor arrivals (thousands),TCE,,510.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +807,North Macedonia,2017,Tourist/visitor arrivals (thousands),TCE,,631.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +807,North Macedonia,2018,Tourist/visitor arrivals (thousands),TCE,,707.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +807,North Macedonia,2005,Tourism expenditure (millions of US dollars),,,116.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +807,North Macedonia,2010,Tourism expenditure (millions of US dollars),,,199.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +807,North Macedonia,2016,Tourism expenditure (millions of US dollars),,,283.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +807,North Macedonia,2017,Tourism expenditure (millions of US dollars),,,331.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +807,North Macedonia,2018,Tourism expenditure (millions of US dollars),,,387.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +580,Northern Mariana Islands,1995,Tourist/visitor arrivals (thousands),TF,,669.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +580,Northern Mariana Islands,2005,Tourist/visitor arrivals (thousands),TF,,498.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +580,Northern Mariana Islands,2010,Tourist/visitor arrivals (thousands),TF,,375.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +580,Northern Mariana Islands,2016,Tourist/visitor arrivals (thousands),TF,,526.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +580,Northern Mariana Islands,2017,Tourist/visitor arrivals (thousands),TF,,656.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +580,Northern Mariana Islands,2018,Tourist/visitor arrivals (thousands),TF,,517.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +580,Northern Mariana Islands,1995,Tourism expenditure (millions of US dollars),,,655.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +578,Norway,1995,Tourist/visitor arrivals (thousands),TF,,2880.0000,Non-resident tourists staying in registered hotels.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +578,Norway,2005,Tourist/visitor arrivals (thousands),TF,,3824.0000,Arrivals of non-resident tourists at national borders.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +578,Norway,2010,Tourist/visitor arrivals (thousands),TF,,4767.0000,Arrivals of non-resident tourists at national borders.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +578,Norway,2016,Tourist/visitor arrivals (thousands),TF,,5960.0000,Non-resident tourists staying in all types of accommodation establishments.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +578,Norway,2017,Tourist/visitor arrivals (thousands),TF,,6252.0000,Non-resident tourists staying in all types of accommodation establishments.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +578,Norway,2018,Tourist/visitor arrivals (thousands),TF,,5688.0000,Non-resident tourists staying in all types of accommodation establishments.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +578,Norway,1995,Tourism expenditure (millions of US dollars),,,2730.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +578,Norway,2005,Tourism expenditure (millions of US dollars),,,4243.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +578,Norway,2010,Tourism expenditure (millions of US dollars),,,5299.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +578,Norway,2016,Tourism expenditure (millions of US dollars),,,6285.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +578,Norway,2017,Tourism expenditure (millions of US dollars),,,6840.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +578,Norway,2018,Tourism expenditure (millions of US dollars),,,7096.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +512,Oman,2005,Tourist/visitor arrivals (thousands),TF,,891.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +512,Oman,2010,Tourist/visitor arrivals (thousands),TF,,1441.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +512,Oman,2016,Tourist/visitor arrivals (thousands),TF,,2335.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +512,Oman,2017,Tourist/visitor arrivals (thousands),TF,,2316.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +512,Oman,2018,Tourist/visitor arrivals (thousands),TF,,2301.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +512,Oman,2005,Tourism expenditure (millions of US dollars),,,627.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +512,Oman,2010,Tourism expenditure (millions of US dollars),,,1072.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +512,Oman,2016,Tourism expenditure (millions of US dollars),,,2390.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +512,Oman,2017,Tourism expenditure (millions of US dollars),,,2717.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +512,Oman,2018,Tourism expenditure (millions of US dollars),,,2975.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +158,Other non-specified areas,1995,Tourist/visitor arrivals (thousands),VF,,2332.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +158,Other non-specified areas,2005,Tourist/visitor arrivals (thousands),VF,,3378.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +158,Other non-specified areas,2010,Tourist/visitor arrivals (thousands),VF,,5567.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +158,Other non-specified areas,2016,Tourist/visitor arrivals (thousands),VF,,10690.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +158,Other non-specified areas,2017,Tourist/visitor arrivals (thousands),VF,,10740.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +158,Other non-specified areas,2018,Tourist/visitor arrivals (thousands),VF,,11067.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +158,Other non-specified areas,1995,Tourism expenditure (millions of US dollars),,,3985.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +158,Other non-specified areas,2005,Tourism expenditure (millions of US dollars),,,5740.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +158,Other non-specified areas,2010,Tourism expenditure (millions of US dollars),,,10387.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +158,Other non-specified areas,2016,Tourism expenditure (millions of US dollars),,,15825.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +158,Other non-specified areas,2017,Tourism expenditure (millions of US dollars),,,14847.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +158,Other non-specified areas,2018,Tourism expenditure (millions of US dollars),,,16366.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +586,Pakistan,1995,Tourist/visitor arrivals (thousands),TF,,378.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +586,Pakistan,2005,Tourist/visitor arrivals (thousands),TF,,798.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +586,Pakistan,2010,Tourist/visitor arrivals (thousands),TF,,907.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +586,Pakistan,1995,Tourism expenditure (millions of US dollars),,,582.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +586,Pakistan,2005,Tourism expenditure (millions of US dollars),,,828.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +586,Pakistan,2010,Tourism expenditure (millions of US dollars),,,998.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +586,Pakistan,2016,Tourism expenditure (millions of US dollars),,,791.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +586,Pakistan,2017,Tourism expenditure (millions of US dollars),,,866.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +586,Pakistan,2018,Tourism expenditure (millions of US dollars),,,818.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +585,Palau,1995,Tourist/visitor arrivals (thousands),TF,,53.0000,Air arrivals (Palau International Airport).,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +585,Palau,2005,Tourist/visitor arrivals (thousands),TF,,81.0000,Air arrivals (Palau International Airport).,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +585,Palau,2010,Tourist/visitor arrivals (thousands),TF,,85.0000,Air arrivals (Palau International Airport).,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +585,Palau,2016,Tourist/visitor arrivals (thousands),TF,,138.0000,Air arrivals (Palau International Airport).,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +585,Palau,2017,Tourist/visitor arrivals (thousands),TF,,123.0000,Air arrivals (Palau International Airport).,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +585,Palau,2018,Tourist/visitor arrivals (thousands),TF,,106.0000,Air arrivals (Palau International Airport).,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +585,Palau,2005,Tourism expenditure (millions of US dollars),,,63.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +585,Palau,2010,Tourism expenditure (millions of US dollars),,,76.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +585,Palau,2016,Tourism expenditure (millions of US dollars),,,148.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +585,Palau,2017,Tourism expenditure (millions of US dollars),,,123.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +591,Panama,1995,Tourist/visitor arrivals (thousands),TF,,345.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +591,Panama,2005,Tourist/visitor arrivals (thousands),TF,,702.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +591,Panama,2010,Tourist/visitor arrivals (thousands),TF,,1324.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +591,Panama,2016,Tourist/visitor arrivals (thousands),TF,,1921.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +591,Panama,2017,Tourist/visitor arrivals (thousands),TF,,1843.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +591,Panama,2018,Tourist/visitor arrivals (thousands),TF,,1785.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +591,Panama,1995,Tourism expenditure (millions of US dollars),,,372.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +591,Panama,2005,Tourism expenditure (millions of US dollars),,,1108.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +591,Panama,2010,Tourism expenditure (millions of US dollars),,,2621.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +591,Panama,2016,Tourism expenditure (millions of US dollars),,,6280.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +591,Panama,2017,Tourism expenditure (millions of US dollars),,,6824.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +591,Panama,2018,Tourism expenditure (millions of US dollars),,,5615.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +598,Papua New Guinea,1995,Tourist/visitor arrivals (thousands),TF,,42.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +598,Papua New Guinea,2005,Tourist/visitor arrivals (thousands),TF,,69.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +598,Papua New Guinea,2010,Tourist/visitor arrivals (thousands),TF,,140.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +598,Papua New Guinea,2016,Tourist/visitor arrivals (thousands),TF,,179.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +598,Papua New Guinea,2017,Tourist/visitor arrivals (thousands),TF,,139.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +598,Papua New Guinea,2018,Tourist/visitor arrivals (thousands),TF,,140.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +598,Papua New Guinea,2005,Tourism expenditure (millions of US dollars),,,9.4000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +598,Papua New Guinea,2010,Tourism expenditure (millions of US dollars),,,2.4000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +598,Papua New Guinea,2016,Tourism expenditure (millions of US dollars),,,1.6000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +598,Papua New Guinea,2017,Tourism expenditure (millions of US dollars),,,15.3000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +600,Paraguay,1995,Tourist/visitor arrivals (thousands),TF,,438.0000,Excluding nationals residing abroad and crew members.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +600,Paraguay,2005,Tourist/visitor arrivals (thousands),TF,,341.0000,Excluding nationals residing abroad and crew members.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +600,Paraguay,2010,Tourist/visitor arrivals (thousands),TF,,465.0000,Excluding nationals residing abroad and crew members.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +600,Paraguay,2016,Tourist/visitor arrivals (thousands),TF,,1308.0000,Excluding nationals residing abroad and crew members.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +600,Paraguay,2017,Tourist/visitor arrivals (thousands),TF,,1584.0000,Excluding nationals residing abroad and crew members.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +600,Paraguay,2018,Tourist/visitor arrivals (thousands),TF,,1181.0000,Excluding nationals residing abroad and crew members.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +600,Paraguay,1995,Tourism expenditure (millions of US dollars),,,162.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +600,Paraguay,2005,Tourism expenditure (millions of US dollars),,,96.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +600,Paraguay,2010,Tourism expenditure (millions of US dollars),,,243.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +600,Paraguay,2016,Tourism expenditure (millions of US dollars),,,356.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +600,Paraguay,2017,Tourism expenditure (millions of US dollars),,,399.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +600,Paraguay,2018,Tourism expenditure (millions of US dollars),,,393.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +604,Peru,1995,Tourist/visitor arrivals (thousands),TF,,479.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +604,Peru,2005,Tourist/visitor arrivals (thousands),TF,,1571.0000,Including nationals residing abroad.;Including tourists with identity document other than a passport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +604,Peru,2010,Tourist/visitor arrivals (thousands),TF,,2299.0000,Including nationals residing abroad.;Including tourists with identity document other than a passport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +604,Peru,2016,Tourist/visitor arrivals (thousands),TF,,3744.0000,Including nationals residing abroad.;Including tourists with identity document other than a passport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +604,Peru,2017,Tourist/visitor arrivals (thousands),TF,,4032.0000,Including nationals residing abroad.;Including tourists with identity document other than a passport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +604,Peru,2018,Tourist/visitor arrivals (thousands),TF,,4419.0000,Including nationals residing abroad.;Including tourists with identity document other than a passport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +604,Peru,1995,Tourism expenditure (millions of US dollars),,,521.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +604,Peru,2005,Tourism expenditure (millions of US dollars),,,1438.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +604,Peru,2010,Tourism expenditure (millions of US dollars),,,2475.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +604,Peru,2016,Tourism expenditure (millions of US dollars),,,4288.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +604,Peru,2017,Tourism expenditure (millions of US dollars),,,4573.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +604,Peru,2018,Tourism expenditure (millions of US dollars),,,4894.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +608,Philippines,1995,Tourist/visitor arrivals (thousands),TF,,1760.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +608,Philippines,2005,Tourist/visitor arrivals (thousands),TF,,2623.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +608,Philippines,2010,Tourist/visitor arrivals (thousands),TF,,3520.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +608,Philippines,2016,Tourist/visitor arrivals (thousands),TF,,5967.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +608,Philippines,2017,Tourist/visitor arrivals (thousands),TF,,6621.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +608,Philippines,2018,Tourist/visitor arrivals (thousands),TF,,7168.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +608,Philippines,1995,Tourism expenditure (millions of US dollars),,,1141.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +608,Philippines,2005,Tourism expenditure (millions of US dollars),,,2863.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +608,Philippines,2010,Tourism expenditure (millions of US dollars),,,3441.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +608,Philippines,2016,Tourism expenditure (millions of US dollars),,,6289.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +608,Philippines,2017,Tourism expenditure (millions of US dollars),,,8349.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +608,Philippines,2018,Tourism expenditure (millions of US dollars),,,9730.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +616,Poland,1995,Tourist/visitor arrivals (thousands),TF,,19215.0000,"Border statistics are not collected any more, surveys used instead.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +616,Poland,2005,Tourist/visitor arrivals (thousands),TF,,15200.0000,"Border statistics are not collected any more, surveys used instead.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +616,Poland,2010,Tourist/visitor arrivals (thousands),TF,,12470.0000,"Border statistics are not collected any more, surveys used instead.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +616,Poland,2016,Tourist/visitor arrivals (thousands),TF,,17471.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +616,Poland,2017,Tourist/visitor arrivals (thousands),TF,,18258.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +616,Poland,2018,Tourist/visitor arrivals (thousands),TF,,19622.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +616,Poland,1995,Tourism expenditure (millions of US dollars),,,6927.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +616,Poland,2005,Tourism expenditure (millions of US dollars),,,7161.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +616,Poland,2010,Tourism expenditure (millions of US dollars),,,10036.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +616,Poland,2016,Tourism expenditure (millions of US dollars),,,12052.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +616,Poland,2017,Tourism expenditure (millions of US dollars),,,14083.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +616,Poland,2018,Tourism expenditure (millions of US dollars),,,15748.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +620,Portugal,1995,Tourist/visitor arrivals (thousands),TCE,,4572.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +620,Portugal,2005,Tourist/visitor arrivals (thousands),TCE,,5769.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +620,Portugal,2010,Tourist/visitor arrivals (thousands),TCE,,6756.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +620,Portugal,2016,Tourist/visitor arrivals (thousands),TCE,,13359.0000,"Include hotels, apartment hotels, “pousadas”, tourist apartments, tourist villages, camping sites, recreation centres, tourism in rural areas and local accommodation.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +620,Portugal,2017,Tourist/visitor arrivals (thousands),TCE,,15432.0000,"Include hotels, apartment hotels, “pousadas”, tourist apartments, tourist villages, camping sites, recreation centres, tourism in rural areas and local accommodation.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +620,Portugal,2018,Tourist/visitor arrivals (thousands),TCE,,16186.0000,"Include hotels, apartment hotels, “pousadas”, tourist apartments, tourist villages, camping sites, recreation centres, tourism in rural areas and local accommodation.","World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +620,Portugal,1995,Tourism expenditure (millions of US dollars),,,5646.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +620,Portugal,2005,Tourism expenditure (millions of US dollars),,,9038.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +620,Portugal,2010,Tourism expenditure (millions of US dollars),,,12984.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +620,Portugal,2016,Tourism expenditure (millions of US dollars),,,17347.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +620,Portugal,2017,Tourism expenditure (millions of US dollars),,,21586.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +620,Portugal,2018,Tourism expenditure (millions of US dollars),,,24105.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +630,Puerto Rico,1995,Tourist/visitor arrivals (thousands),TF,,3131.0000,Arrivals of non-resident tourists by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +630,Puerto Rico,2005,Tourist/visitor arrivals (thousands),TF,,3686.0000,Arrivals of non-resident tourists by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +630,Puerto Rico,2010,Tourist/visitor arrivals (thousands),TF,,3186.0000,Arrivals of non-resident tourists by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +630,Puerto Rico,2016,Tourist/visitor arrivals (thousands),TF,,3736.0000,Arrivals of non-resident tourists by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +630,Puerto Rico,2017,Tourist/visitor arrivals (thousands),TF,,3513.0000,Arrivals of non-resident tourists by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +630,Puerto Rico,2018,Tourist/visitor arrivals (thousands),TF,,3068.0000,Arrivals of non-resident tourists by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +630,Puerto Rico,1995,Tourism expenditure (millions of US dollars),,,1828.0000,Data refer to fiscal years beginning 1 July.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +630,Puerto Rico,2005,Tourism expenditure (millions of US dollars),,,3239.0000,Data refer to fiscal years beginning 1 July.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +630,Puerto Rico,2010,Tourism expenditure (millions of US dollars),,,3211.0000,Data refer to fiscal years beginning 1 July.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +630,Puerto Rico,2016,Tourism expenditure (millions of US dollars),,,3974.0000,Data refer to fiscal years beginning 1 July.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +630,Puerto Rico,2017,Tourism expenditure (millions of US dollars),,,3848.0000,Data refer to fiscal years beginning 1 July.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +630,Puerto Rico,2018,Tourism expenditure (millions of US dollars),,,3282.0000,Data refer to fiscal years beginning 1 July.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +634,Qatar,2010,Tourist/visitor arrivals (thousands),TF,,1699.5000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +634,Qatar,2016,Tourist/visitor arrivals (thousands),TF,,2938.2000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +634,Qatar,2017,Tourist/visitor arrivals (thousands),TF,,2256.5000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +634,Qatar,2018,Tourist/visitor arrivals (thousands),TF,,1819.3000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +634,Qatar,2016,Tourism expenditure (millions of US dollars),,,12593.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +634,Qatar,2017,Tourism expenditure (millions of US dollars),,,15757.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +634,Qatar,2018,Tourism expenditure (millions of US dollars),,,15239.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +410,Republic of Korea,1995,Tourist/visitor arrivals (thousands),VF,,3753.0000,Including nationals residing abroad and crew members.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +410,Republic of Korea,2005,Tourist/visitor arrivals (thousands),VF,,6023.0000,Including nationals residing abroad and crew members.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +410,Republic of Korea,2010,Tourist/visitor arrivals (thousands),VF,,8798.0000,Including nationals residing abroad and crew members.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +410,Republic of Korea,2016,Tourist/visitor arrivals (thousands),VF,,17242.0000,Including nationals residing abroad and crew members.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +410,Republic of Korea,2017,Tourist/visitor arrivals (thousands),VF,,13336.0000,Including nationals residing abroad and crew members.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +410,Republic of Korea,2018,Tourist/visitor arrivals (thousands),VF,,15347.0000,Including nationals residing abroad and crew members.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +410,Republic of Korea,1995,Tourism expenditure (millions of US dollars),,,6670.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +410,Republic of Korea,2005,Tourism expenditure (millions of US dollars),,,8282.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +410,Republic of Korea,2010,Tourism expenditure (millions of US dollars),,,14315.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +410,Republic of Korea,2016,Tourism expenditure (millions of US dollars),,,20924.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +410,Republic of Korea,2017,Tourism expenditure (millions of US dollars),,,17173.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +410,Republic of Korea,2018,Tourism expenditure (millions of US dollars),,,19856.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +498,Republic of Moldova,2005,Tourist/visitor arrivals (thousands),TCE,,67.0000,Excluding the left side of the river Nistru and the municipality of Bender.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +498,Republic of Moldova,2010,Tourist/visitor arrivals (thousands),TCE,,64.0000,Excluding the left side of the river Nistru and the municipality of Bender.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +498,Republic of Moldova,2016,Tourist/visitor arrivals (thousands),TCE,,121.0000,Excluding the left side of the river Nistru and the municipality of Bender.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +498,Republic of Moldova,2017,Tourist/visitor arrivals (thousands),TCE,,145.0000,Excluding the left side of the river Nistru and the municipality of Bender.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +498,Republic of Moldova,2018,Tourist/visitor arrivals (thousands),TCE,,160.0000,Excluding the left side of the river Nistru and the municipality of Bender.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +498,Republic of Moldova,1995,Tourism expenditure (millions of US dollars),,,71.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +498,Republic of Moldova,2005,Tourism expenditure (millions of US dollars),,,138.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +498,Republic of Moldova,2010,Tourism expenditure (millions of US dollars),,,222.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +498,Republic of Moldova,2016,Tourism expenditure (millions of US dollars),,,344.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +498,Republic of Moldova,2017,Tourism expenditure (millions of US dollars),,,443.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +498,Republic of Moldova,2018,Tourism expenditure (millions of US dollars),,,500.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +638,Réunion,1995,Tourist/visitor arrivals (thousands),TF,,304.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +638,Réunion,2005,Tourist/visitor arrivals (thousands),TF,,409.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +638,Réunion,2010,Tourist/visitor arrivals (thousands),TF,,420.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +638,Réunion,2016,Tourist/visitor arrivals (thousands),TF,,458.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +638,Réunion,2017,Tourist/visitor arrivals (thousands),TF,,508.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +638,Réunion,2018,Tourist/visitor arrivals (thousands),TF,,535.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +638,Réunion,1995,Tourism expenditure (millions of US dollars),,,216.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +638,Réunion,2005,Tourism expenditure (millions of US dollars),,,364.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +638,Réunion,2010,Tourism expenditure (millions of US dollars),,,392.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +638,Réunion,2016,Tourism expenditure (millions of US dollars),,,343.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +638,Réunion,2017,Tourism expenditure (millions of US dollars),,,427.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +638,Réunion,2018,Tourism expenditure (millions of US dollars),,,495.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +642,Romania,1995,Tourist/visitor arrivals (thousands),VF,,5445.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +642,Romania,2005,Tourist/visitor arrivals (thousands),VF,,5839.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +642,Romania,2010,Tourist/visitor arrivals (thousands),VF,,7498.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +642,Romania,2016,Tourist/visitor arrivals (thousands),VF,,10223.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +642,Romania,2017,Tourist/visitor arrivals (thousands),VF,,10926.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +642,Romania,2018,Tourist/visitor arrivals (thousands),VF,,11720.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +642,Romania,1995,Tourism expenditure (millions of US dollars),,,689.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +642,Romania,2005,Tourism expenditure (millions of US dollars),,,1324.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +642,Romania,2010,Tourism expenditure (millions of US dollars),,,1631.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +642,Romania,2016,Tourism expenditure (millions of US dollars),,,2172.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +642,Romania,2017,Tourism expenditure (millions of US dollars),,,3008.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +642,Romania,2018,Tourism expenditure (millions of US dollars),,,3261.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +643,Russian Federation,1995,Tourist/visitor arrivals (thousands),VF,,10290.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +643,Russian Federation,2005,Tourist/visitor arrivals (thousands),VF,,22201.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +643,Russian Federation,2010,Tourist/visitor arrivals (thousands),VF,,22281.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +643,Russian Federation,2016,Tourist/visitor arrivals (thousands),VF,,24571.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +643,Russian Federation,2017,Tourist/visitor arrivals (thousands),VF,,24390.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +643,Russian Federation,2018,Tourist/visitor arrivals (thousands),VF,,24551.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +643,Russian Federation,2005,Tourism expenditure (millions of US dollars),,,7805.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +643,Russian Federation,2010,Tourism expenditure (millions of US dollars),,,13239.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +643,Russian Federation,2016,Tourism expenditure (millions of US dollars),,,12822.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +643,Russian Federation,2017,Tourism expenditure (millions of US dollars),,,14983.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +643,Russian Federation,2018,Tourism expenditure (millions of US dollars),,,18670.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +646,Rwanda,2010,Tourist/visitor arrivals (thousands),TF,,504.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +646,Rwanda,2016,Tourist/visitor arrivals (thousands),TF,,932.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +646,Rwanda,1995,Tourism expenditure (millions of US dollars),,,4.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +646,Rwanda,2005,Tourism expenditure (millions of US dollars),,,67.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +646,Rwanda,2010,Tourism expenditure (millions of US dollars),,,224.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +646,Rwanda,2016,Tourism expenditure (millions of US dollars),,,443.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +646,Rwanda,2017,Tourism expenditure (millions of US dollars),,,548.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +646,Rwanda,2018,Tourism expenditure (millions of US dollars),,,528.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +667,Saba,1995,Tourist/visitor arrivals (thousands),TF,,10.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +667,Saba,2005,Tourist/visitor arrivals (thousands),TF,,11.5000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +667,Saba,2010,Tourist/visitor arrivals (thousands),TF,,12.3000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +659,Saint Kitts and Nevis,1995,Tourist/visitor arrivals (thousands),TF,,79.0000,Arrivals of non-resident tourists by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +659,Saint Kitts and Nevis,2005,Tourist/visitor arrivals (thousands),TF,,141.0000,Arrivals of non-resident tourists by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +659,Saint Kitts and Nevis,2010,Tourist/visitor arrivals (thousands),TF,,98.0000,Arrivals of non-resident tourists by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +659,Saint Kitts and Nevis,2016,Tourist/visitor arrivals (thousands),TF,,116.0000,Arrivals of non-resident tourists by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +659,Saint Kitts and Nevis,2017,Tourist/visitor arrivals (thousands),TF,,115.0000,Arrivals of non-resident tourists by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +659,Saint Kitts and Nevis,2018,Tourist/visitor arrivals (thousands),TF,,125.0000,Arrivals of non-resident tourists by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +659,Saint Kitts and Nevis,1995,Tourism expenditure (millions of US dollars),,,63.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +659,Saint Kitts and Nevis,2005,Tourism expenditure (millions of US dollars),,,121.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +659,Saint Kitts and Nevis,2010,Tourism expenditure (millions of US dollars),,,90.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +659,Saint Kitts and Nevis,2016,Tourism expenditure (millions of US dollars),,,332.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +659,Saint Kitts and Nevis,2017,Tourism expenditure (millions of US dollars),,,355.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +659,Saint Kitts and Nevis,2018,Tourism expenditure (millions of US dollars),,,367.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +662,Saint Lucia,1995,Tourist/visitor arrivals (thousands),TF,,231.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +662,Saint Lucia,2005,Tourist/visitor arrivals (thousands),TF,,318.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +662,Saint Lucia,2010,Tourist/visitor arrivals (thousands),TF,,306.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +662,Saint Lucia,2016,Tourist/visitor arrivals (thousands),TF,,348.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +662,Saint Lucia,2017,Tourist/visitor arrivals (thousands),TF,,386.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +662,Saint Lucia,2018,Tourist/visitor arrivals (thousands),TF,,395.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +662,Saint Lucia,1995,Tourism expenditure (millions of US dollars),,,230.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +662,Saint Lucia,2005,Tourism expenditure (millions of US dollars),,,382.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +662,Saint Lucia,2010,Tourism expenditure (millions of US dollars),,,309.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +662,Saint Lucia,2016,Tourism expenditure (millions of US dollars),,,776.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +662,Saint Lucia,2017,Tourism expenditure (millions of US dollars),,,875.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +662,Saint Lucia,2018,Tourism expenditure (millions of US dollars),,,989.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +670,Saint Vincent & Grenadines,1995,Tourist/visitor arrivals (thousands),TF,,60.0000,Arrivals of non-resident tourists by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +670,Saint Vincent & Grenadines,2005,Tourist/visitor arrivals (thousands),TF,,96.0000,Arrivals of non-resident tourists by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +670,Saint Vincent & Grenadines,2010,Tourist/visitor arrivals (thousands),TF,,72.0000,Arrivals of non-resident tourists by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +670,Saint Vincent & Grenadines,2016,Tourist/visitor arrivals (thousands),TF,,79.0000,Arrivals of non-resident tourists by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +670,Saint Vincent & Grenadines,2017,Tourist/visitor arrivals (thousands),TF,,76.0000,Arrivals of non-resident tourists by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +670,Saint Vincent & Grenadines,2018,Tourist/visitor arrivals (thousands),TF,,80.0000,Arrivals of non-resident tourists by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +670,Saint Vincent & Grenadines,1995,Tourism expenditure (millions of US dollars),,,53.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +670,Saint Vincent & Grenadines,2005,Tourism expenditure (millions of US dollars),,,104.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +670,Saint Vincent & Grenadines,2010,Tourism expenditure (millions of US dollars),,,86.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +670,Saint Vincent & Grenadines,2016,Tourism expenditure (millions of US dollars),,,216.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +670,Saint Vincent & Grenadines,2017,Tourism expenditure (millions of US dollars),,,211.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +670,Saint Vincent & Grenadines,2018,Tourism expenditure (millions of US dollars),,,235.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +882,Samoa,1995,Tourist/visitor arrivals (thousands),TF,,68.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +882,Samoa,2005,Tourist/visitor arrivals (thousands),TF,,102.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +882,Samoa,2010,Tourist/visitor arrivals (thousands),TF,,122.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +882,Samoa,2016,Tourist/visitor arrivals (thousands),TF,,134.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +882,Samoa,2017,Tourist/visitor arrivals (thousands),TF,,146.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +882,Samoa,2018,Tourist/visitor arrivals (thousands),TF,,164.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +882,Samoa,1995,Tourism expenditure (millions of US dollars),,,35.6994,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +882,Samoa,2005,Tourism expenditure (millions of US dollars),,,73.8000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +882,Samoa,2010,Tourism expenditure (millions of US dollars),,,123.7000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +882,Samoa,2016,Tourism expenditure (millions of US dollars),,,148.7000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +882,Samoa,2017,Tourism expenditure (millions of US dollars),,,167.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +882,Samoa,2018,Tourism expenditure (millions of US dollars),,,191.3000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +674,San Marino,1995,Tourist/visitor arrivals (thousands),THS,,28.0000,Including Italian tourists.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +674,San Marino,2005,Tourist/visitor arrivals (thousands),THS,,50.0000,Including Italian tourists.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +674,San Marino,2010,Tourist/visitor arrivals (thousands),THS,,120.0000,Including Italian tourists.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +674,San Marino,2016,Tourist/visitor arrivals (thousands),THS,,60.0000,Including Italian tourists.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +674,San Marino,2017,Tourist/visitor arrivals (thousands),THS,,78.0000,Including Italian tourists.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +674,San Marino,2018,Tourist/visitor arrivals (thousands),THS,,84.0000,Including Italian tourists.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +678,Sao Tome and Principe,1995,Tourist/visitor arrivals (thousands),TF,,6.2000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +678,Sao Tome and Principe,2005,Tourist/visitor arrivals (thousands),TF,,15.8000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +678,Sao Tome and Principe,2010,Tourist/visitor arrivals (thousands),TF,,8.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +678,Sao Tome and Principe,2016,Tourist/visitor arrivals (thousands),TF,,28.9000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +678,Sao Tome and Principe,2017,Tourist/visitor arrivals (thousands),TF,,28.9000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +678,Sao Tome and Principe,2018,Tourist/visitor arrivals (thousands),TF,,33.4000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +678,Sao Tome and Principe,2016,Tourism expenditure (millions of US dollars),,,69.1000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +678,Sao Tome and Principe,2017,Tourism expenditure (millions of US dollars),,,65.9000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +678,Sao Tome and Principe,2018,Tourism expenditure (millions of US dollars),,,71.9000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +682,Saudi Arabia,1995,Tourist/visitor arrivals (thousands),TF,,3325.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +682,Saudi Arabia,2005,Tourist/visitor arrivals (thousands),TF,,8037.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +682,Saudi Arabia,2010,Tourist/visitor arrivals (thousands),TF,,10850.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +682,Saudi Arabia,2016,Tourist/visitor arrivals (thousands),TF,,18044.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +682,Saudi Arabia,2017,Tourist/visitor arrivals (thousands),TF,,16109.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +682,Saudi Arabia,2018,Tourist/visitor arrivals (thousands),TF,,15334.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +682,Saudi Arabia,2010,Tourism expenditure (millions of US dollars),,,7536.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +682,Saudi Arabia,2016,Tourism expenditure (millions of US dollars),,,13438.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +682,Saudi Arabia,2017,Tourism expenditure (millions of US dollars),,,15020.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +682,Saudi Arabia,2018,Tourism expenditure (millions of US dollars),,,16975.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +686,Senegal,2005,Tourist/visitor arrivals (thousands),TF,,769.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +686,Senegal,2010,Tourist/visitor arrivals (thousands),TF,,900.0000,Estimate.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +686,Senegal,2016,Tourist/visitor arrivals (thousands),TF,,1210.0000,Estimate.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +686,Senegal,2017,Tourist/visitor arrivals (thousands),TF,,1365.0000,Estimate.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +686,Senegal,1995,Tourism expenditure (millions of US dollars),,,168.1803,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +686,Senegal,2005,Tourism expenditure (millions of US dollars),,,334.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +686,Senegal,2010,Tourism expenditure (millions of US dollars),,,464.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +686,Senegal,2016,Tourism expenditure (millions of US dollars),,,438.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +686,Senegal,2017,Tourism expenditure (millions of US dollars),,,468.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +688,Serbia,2005,Tourist/visitor arrivals (thousands),TCE,,453.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +688,Serbia,2010,Tourist/visitor arrivals (thousands),TCE,,683.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +688,Serbia,2016,Tourist/visitor arrivals (thousands),TCE,,1281.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +688,Serbia,2017,Tourist/visitor arrivals (thousands),TCE,,1497.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +688,Serbia,2018,Tourist/visitor arrivals (thousands),TCE,,1711.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +688,Serbia,2005,Tourism expenditure (millions of US dollars),,,308.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +688,Serbia,2010,Tourism expenditure (millions of US dollars),,,950.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +688,Serbia,2016,Tourism expenditure (millions of US dollars),,,1461.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +688,Serbia,2017,Tourism expenditure (millions of US dollars),,,1706.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +688,Serbia,2018,Tourism expenditure (millions of US dollars),,,1921.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +690,Seychelles,1995,Tourist/visitor arrivals (thousands),TF,,121.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +690,Seychelles,2005,Tourist/visitor arrivals (thousands),TF,,129.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +690,Seychelles,2010,Tourist/visitor arrivals (thousands),TF,,175.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +690,Seychelles,2016,Tourist/visitor arrivals (thousands),TF,,303.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +690,Seychelles,2017,Tourist/visitor arrivals (thousands),TF,,350.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +690,Seychelles,2018,Tourist/visitor arrivals (thousands),TF,,362.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +690,Seychelles,1995,Tourism expenditure (millions of US dollars),,,224.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +690,Seychelles,2005,Tourism expenditure (millions of US dollars),,,269.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +690,Seychelles,2010,Tourism expenditure (millions of US dollars),,,352.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +690,Seychelles,2016,Tourism expenditure (millions of US dollars),,,505.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +690,Seychelles,2017,Tourism expenditure (millions of US dollars),,,585.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +690,Seychelles,2018,Tourism expenditure (millions of US dollars),,,611.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +694,Sierra Leone,1995,Tourist/visitor arrivals (thousands),TF,,13.8000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +694,Sierra Leone,2005,Tourist/visitor arrivals (thousands),TF,,40.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +694,Sierra Leone,2010,Tourist/visitor arrivals (thousands),TF,,39.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +694,Sierra Leone,2016,Tourist/visitor arrivals (thousands),TF,,55.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +694,Sierra Leone,2017,Tourist/visitor arrivals (thousands),TF,,51.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +694,Sierra Leone,2018,Tourist/visitor arrivals (thousands),TF,,57.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +694,Sierra Leone,1995,Tourism expenditure (millions of US dollars),,,57.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +694,Sierra Leone,2005,Tourism expenditure (millions of US dollars),,,64.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +694,Sierra Leone,2010,Tourism expenditure (millions of US dollars),,,26.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +694,Sierra Leone,2016,Tourism expenditure (millions of US dollars),,,41.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +694,Sierra Leone,2017,Tourism expenditure (millions of US dollars),,,39.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +694,Sierra Leone,2018,Tourism expenditure (millions of US dollars),,,39.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +702,Singapore,1995,Tourist/visitor arrivals (thousands),TF,,6070.0000,Excluding Malaysian citizens arriving by land.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +702,Singapore,2005,Tourist/visitor arrivals (thousands),TF,,7079.0000,Excluding Malaysian citizens arriving by land.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +702,Singapore,2010,Tourist/visitor arrivals (thousands),TF,,9161.0000,Excluding Malaysian citizens arriving by land.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +702,Singapore,2016,Tourist/visitor arrivals (thousands),TF,,12913.0000,Excluding Malaysian citizens arriving by land.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +702,Singapore,2017,Tourist/visitor arrivals (thousands),TF,,13903.0000,Excluding Malaysian citizens arriving by land.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +702,Singapore,2018,Tourist/visitor arrivals (thousands),TF,,14673.0000,Excluding Malaysian citizens arriving by land.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +702,Singapore,1995,Tourism expenditure (millions of US dollars),,,7611.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +702,Singapore,2005,Tourism expenditure (millions of US dollars),,,6209.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +702,Singapore,2010,Tourism expenditure (millions of US dollars),,,14178.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +702,Singapore,2016,Tourism expenditure (millions of US dollars),,,18944.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +702,Singapore,2017,Tourism expenditure (millions of US dollars),,,19891.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +702,Singapore,2018,Tourism expenditure (millions of US dollars),,,20416.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +668,Sint Eustatius,1995,Tourist/visitor arrivals (thousands),TF,,8.8000,Excluding Netherlands Antillean residents.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +668,Sint Eustatius,2005,Tourist/visitor arrivals (thousands),TF,,10.4000,Excluding Netherlands Antillean residents.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +668,Sint Eustatius,2010,Tourist/visitor arrivals (thousands),TF,,11.4000,Excluding Netherlands Antillean residents.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +534,Sint Maarten (Dutch part),1995,Tourist/visitor arrivals (thousands),TF,,460.0000,Arrivals by air. Including arrivals to Saint Martin (French part).,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +534,Sint Maarten (Dutch part),2005,Tourist/visitor arrivals (thousands),TF,,468.0000,Arrivals by air. Including arrivals to Saint Martin (French part).,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +534,Sint Maarten (Dutch part),2010,Tourist/visitor arrivals (thousands),TF,,443.0000,Arrivals by air. Including arrivals to Saint Martin (French part).,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +534,Sint Maarten (Dutch part),2016,Tourist/visitor arrivals (thousands),TF,,528.0000,Arrivals by air. Including arrivals to Saint Martin (French part).,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +534,Sint Maarten (Dutch part),2017,Tourist/visitor arrivals (thousands),TF,,402.0000,Arrivals by air. Including arrivals to Saint Martin (French part).,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +534,Sint Maarten (Dutch part),2018,Tourist/visitor arrivals (thousands),TF,,178.0000,Arrivals by air. Including arrivals to Saint Martin (French part).,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +534,Sint Maarten (Dutch part),2010,Tourism expenditure (millions of US dollars),,,681.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +534,Sint Maarten (Dutch part),2016,Tourism expenditure (millions of US dollars),,,871.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +534,Sint Maarten (Dutch part),2017,Tourism expenditure (millions of US dollars),,,646.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +534,Sint Maarten (Dutch part),2018,Tourism expenditure (millions of US dollars),,,468.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +703,Slovakia,1995,Tourist/visitor arrivals (thousands),TCE,,903.0000,Non-resident tourists staying in commercial accommodation only (representing approximately 25% of all tourists).,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +703,Slovakia,2005,Tourist/visitor arrivals (thousands),TCE,,1515.0000,Non-resident tourists staying in commercial accommodation only (representing approximately 25% of all tourists).,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +703,Slovakia,2010,Tourist/visitor arrivals (thousands),TCE,,1327.0000,Non-resident tourists staying in commercial accommodation only (representing approximately 25% of all tourists).,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +703,Slovakia,2016,Tourist/visitor arrivals (thousands),TCE,,2027.0000,Non-resident tourists staying in commercial accommodation only (representing approximately 25% of all tourists).,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +703,Slovakia,2017,Tourist/visitor arrivals (thousands),TCE,,2162.0000,Non-resident tourists staying in commercial accommodation only (representing approximately 25% of all tourists).,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +703,Slovakia,2018,Tourist/visitor arrivals (thousands),TCE,,2256.0000,Non-resident tourists staying in commercial accommodation only (representing approximately 25% of all tourists).,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +703,Slovakia,1995,Tourism expenditure (millions of US dollars),,,630.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +703,Slovakia,2005,Tourism expenditure (millions of US dollars),,,1282.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +703,Slovakia,2010,Tourism expenditure (millions of US dollars),,,2334.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +703,Slovakia,2016,Tourism expenditure (millions of US dollars),,,2812.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +703,Slovakia,2017,Tourism expenditure (millions of US dollars),,,3024.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +703,Slovakia,2018,Tourism expenditure (millions of US dollars),,,3318.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +705,Slovenia,1995,Tourist/visitor arrivals (thousands),TCE,,732.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +705,Slovenia,2005,Tourist/visitor arrivals (thousands),TCE,,1555.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +705,Slovenia,2010,Tourist/visitor arrivals (thousands),TCE,,2049.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +705,Slovenia,2016,Tourist/visitor arrivals (thousands),TCE,,3397.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +705,Slovenia,2017,Tourist/visitor arrivals (thousands),TCE,,3991.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +705,Slovenia,2018,Tourist/visitor arrivals (thousands),TCE,,4425.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +705,Slovenia,1995,Tourism expenditure (millions of US dollars),,,1128.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +705,Slovenia,2005,Tourism expenditure (millions of US dollars),,,1894.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +705,Slovenia,2010,Tourism expenditure (millions of US dollars),,,2808.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +705,Slovenia,2016,Tourism expenditure (millions of US dollars),,,2717.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +705,Slovenia,2017,Tourism expenditure (millions of US dollars),,,3057.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +705,Slovenia,2018,Tourism expenditure (millions of US dollars),,,3378.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +90,Solomon Islands,1995,Tourist/visitor arrivals (thousands),TF,,11.8000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +90,Solomon Islands,2005,Tourist/visitor arrivals (thousands),TF,,9.4000,Without first quarter.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +90,Solomon Islands,2010,Tourist/visitor arrivals (thousands),TF,,20.5000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +90,Solomon Islands,2016,Tourist/visitor arrivals (thousands),TF,,23.2000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +90,Solomon Islands,2017,Tourist/visitor arrivals (thousands),TF,,25.7000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +90,Solomon Islands,2018,Tourist/visitor arrivals (thousands),TF,,27.9000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +90,Solomon Islands,1995,Tourism expenditure (millions of US dollars),,,17.1000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +90,Solomon Islands,2005,Tourism expenditure (millions of US dollars),,,6.4000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +90,Solomon Islands,2010,Tourism expenditure (millions of US dollars),,,50.8000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +90,Solomon Islands,2016,Tourism expenditure (millions of US dollars),,,71.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +90,Solomon Islands,2017,Tourism expenditure (millions of US dollars),,,79.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +90,Solomon Islands,2018,Tourism expenditure (millions of US dollars),,,92.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +710,South Africa,1995,Tourist/visitor arrivals (thousands),TF,,4488.0000,Excluding arrivals for work and contract workers.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +710,South Africa,2005,Tourist/visitor arrivals (thousands),TF,,7369.0000,Excluding arrivals for work and contract workers.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +710,South Africa,2010,Tourist/visitor arrivals (thousands),TF,,8074.0000,Break in the time series.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +710,South Africa,2016,Tourist/visitor arrivals (thousands),TF,,10044.0000,Break in the time series.;Excluding transit.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +710,South Africa,2017,Tourist/visitor arrivals (thousands),TF,,10285.0000,Excluding transit.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +710,South Africa,2018,Tourist/visitor arrivals (thousands),TF,,10472.0000,Excluding transit.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +710,South Africa,1995,Tourism expenditure (millions of US dollars),,,2654.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +710,South Africa,2005,Tourism expenditure (millions of US dollars),,,8629.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +710,South Africa,2010,Tourism expenditure (millions of US dollars),,,10309.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +710,South Africa,2016,Tourism expenditure (millions of US dollars),,,8807.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +710,South Africa,2017,Tourism expenditure (millions of US dollars),,,9706.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +710,South Africa,2018,Tourism expenditure (millions of US dollars),,,9789.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +728,South Sudan,2016,Tourism expenditure (millions of US dollars),,,23.5000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +728,South Sudan,2017,Tourism expenditure (millions of US dollars),,,26.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +728,South Sudan,2018,Tourism expenditure (millions of US dollars),,,12.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +724,Spain,1995,Tourist/visitor arrivals (thousands),TF,,32971.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +724,Spain,2005,Tourist/visitor arrivals (thousands),TF,,55914.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +724,Spain,2010,Tourist/visitor arrivals (thousands),TF,,52677.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +724,Spain,2016,Tourist/visitor arrivals (thousands),TF,,75315.0000,Break in the time series.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +724,Spain,2017,Tourist/visitor arrivals (thousands),TF,,81869.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +724,Spain,2018,Tourist/visitor arrivals (thousands),TF,,82773.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +724,Spain,1995,Tourism expenditure (millions of US dollars),,,25368.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +724,Spain,2005,Tourism expenditure (millions of US dollars),,,51959.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +724,Spain,2010,Tourism expenditure (millions of US dollars),,,58348.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +724,Spain,2016,Tourism expenditure (millions of US dollars),,,66982.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +724,Spain,2017,Tourism expenditure (millions of US dollars),,,75906.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +724,Spain,2018,Tourism expenditure (millions of US dollars),,,81250.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +144,Sri Lanka,1995,Tourist/visitor arrivals (thousands),TF,,403.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +144,Sri Lanka,2005,Tourist/visitor arrivals (thousands),TF,,549.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +144,Sri Lanka,2010,Tourist/visitor arrivals (thousands),TF,,654.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +144,Sri Lanka,2016,Tourist/visitor arrivals (thousands),TF,,2051.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +144,Sri Lanka,2017,Tourist/visitor arrivals (thousands),TF,,2116.4000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +144,Sri Lanka,2018,Tourist/visitor arrivals (thousands),TF,,2334.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +144,Sri Lanka,1995,Tourism expenditure (millions of US dollars),,,367.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +144,Sri Lanka,2005,Tourism expenditure (millions of US dollars),,,729.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +144,Sri Lanka,2010,Tourism expenditure (millions of US dollars),,,1044.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +144,Sri Lanka,2016,Tourism expenditure (millions of US dollars),,,4591.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +144,Sri Lanka,2017,Tourism expenditure (millions of US dollars),,,5083.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +144,Sri Lanka,2018,Tourism expenditure (millions of US dollars),,,5608.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +275,State of Palestine,2005,Tourist/visitor arrivals (thousands),THS,,88.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +275,State of Palestine,2010,Tourist/visitor arrivals (thousands),THS,,522.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +275,State of Palestine,2016,Tourist/visitor arrivals (thousands),THS,,400.0000,West Bank only.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +275,State of Palestine,2017,Tourist/visitor arrivals (thousands),THS,,503.0000,West Bank only.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +275,State of Palestine,2018,Tourist/visitor arrivals (thousands),THS,,606.0000,West Bank only.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +275,State of Palestine,1995,Tourism expenditure (millions of US dollars),,,255.0000,Excluding passenger transport.;West Bank and Gaza.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +275,State of Palestine,2005,Tourism expenditure (millions of US dollars),,,52.0000,Excluding passenger transport.;West Bank and Gaza.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +275,State of Palestine,2010,Tourism expenditure (millions of US dollars),,,409.0000,Excluding passenger transport.;West Bank and Gaza.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +275,State of Palestine,2016,Tourism expenditure (millions of US dollars),,,235.0000,Excluding passenger transport.;West Bank and Gaza.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +275,State of Palestine,2017,Tourism expenditure (millions of US dollars),,,225.0000,Excluding passenger transport.;West Bank and Gaza.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +275,State of Palestine,2018,Tourism expenditure (millions of US dollars),,,245.0000,Excluding passenger transport.;West Bank and Gaza.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +729,Sudan,1995,Tourist/visitor arrivals (thousands),TF,,29.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +729,Sudan,2005,Tourist/visitor arrivals (thousands),TF,,246.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +729,Sudan,2010,Tourist/visitor arrivals (thousands),TF,,495.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +729,Sudan,2016,Tourist/visitor arrivals (thousands),TF,,800.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +729,Sudan,2017,Tourist/visitor arrivals (thousands),TF,,813.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +729,Sudan,2018,Tourist/visitor arrivals (thousands),TF,,836.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +729,Sudan,1995,Tourism expenditure (millions of US dollars),,,8.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +729,Sudan,2005,Tourism expenditure (millions of US dollars),,,114.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +729,Sudan,2010,Tourism expenditure (millions of US dollars),,,82.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +729,Sudan,2016,Tourism expenditure (millions of US dollars),,,1009.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +729,Sudan,2017,Tourism expenditure (millions of US dollars),,,1029.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +729,Sudan,2018,Tourism expenditure (millions of US dollars),,,1043.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +740,Suriname,1995,Tourist/visitor arrivals (thousands),TF,,43.0000,Arrivals at Zanderij Airport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +740,Suriname,2005,Tourist/visitor arrivals (thousands),TF,,161.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +740,Suriname,2010,Tourist/visitor arrivals (thousands),TF,,205.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +740,Suriname,2016,Tourist/visitor arrivals (thousands),TF,,256.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +740,Suriname,2017,Tourist/visitor arrivals (thousands),TF,,278.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +740,Suriname,1995,Tourism expenditure (millions of US dollars),,,52.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +740,Suriname,2005,Tourism expenditure (millions of US dollars),,,96.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +740,Suriname,2010,Tourism expenditure (millions of US dollars),,,69.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +740,Suriname,2016,Tourism expenditure (millions of US dollars),,,74.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +740,Suriname,2017,Tourism expenditure (millions of US dollars),,,61.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +740,Suriname,2018,Tourism expenditure (millions of US dollars),,,73.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +752,Sweden,1995,Tourist/visitor arrivals (thousands),TCE,,2310.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +752,Sweden,2005,Tourist/visitor arrivals (thousands),TCE,,4883.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +752,Sweden,2010,Tourist/visitor arrivals (thousands),TCE,,5183.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +752,Sweden,2016,Tourist/visitor arrivals (thousands),TCE,,6782.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +752,Sweden,2017,Tourist/visitor arrivals (thousands),TCE,,7054.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +752,Sweden,2018,Tourist/visitor arrivals (thousands),TCE,,7440.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +752,Sweden,1995,Tourism expenditure (millions of US dollars),,,3471.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +752,Sweden,2005,Tourism expenditure (millions of US dollars),,,6554.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +752,Sweden,2010,Tourism expenditure (millions of US dollars),,,8336.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +752,Sweden,2016,Tourism expenditure (millions of US dollars),,,12764.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +752,Sweden,2017,Tourism expenditure (millions of US dollars),,,14168.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +752,Sweden,2018,Tourism expenditure (millions of US dollars),,,14926.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +756,Switzerland,1995,Tourist/visitor arrivals (thousands),THS,,6946.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +756,Switzerland,2005,Tourist/visitor arrivals (thousands),THS,,7229.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +756,Switzerland,2010,Tourist/visitor arrivals (thousands),THS,,8628.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +756,Switzerland,2016,Tourist/visitor arrivals (thousands),THS,,9205.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +756,Switzerland,2017,Tourist/visitor arrivals (thousands),THS,,9889.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +756,Switzerland,2018,Tourist/visitor arrivals (thousands),THS,,10362.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +756,Switzerland,1995,Tourism expenditure (millions of US dollars),,,11354.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +756,Switzerland,2005,Tourism expenditure (millions of US dollars),,,11952.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +756,Switzerland,2010,Tourism expenditure (millions of US dollars),,,17614.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +756,Switzerland,2016,Tourism expenditure (millions of US dollars),,,19042.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +756,Switzerland,2017,Tourism expenditure (millions of US dollars),,,19654.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +756,Switzerland,2018,Tourism expenditure (millions of US dollars),,,20276.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +760,Syrian Arab Republic,1995,Tourist/visitor arrivals (thousands),TCE,,815.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +760,Syrian Arab Republic,2005,Tourist/visitor arrivals (thousands),TCE,,3571.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +760,Syrian Arab Republic,2010,Tourist/visitor arrivals (thousands),TCE,,8546.0000,Including nationals residing abroad.;Including Iraqi nationals.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +760,Syrian Arab Republic,2005,Tourism expenditure (millions of US dollars),,,2035.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +760,Syrian Arab Republic,2010,Tourism expenditure (millions of US dollars),,,6308.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +762,Tajikistan,2010,Tourist/visitor arrivals (thousands),VF,,160.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +762,Tajikistan,2016,Tourist/visitor arrivals (thousands),VF,,344.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +762,Tajikistan,2017,Tourist/visitor arrivals (thousands),VF,,431.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +762,Tajikistan,2018,Tourist/visitor arrivals (thousands),VF,,1035.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +762,Tajikistan,2005,Tourism expenditure (millions of US dollars),,,9.1000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +762,Tajikistan,2010,Tourism expenditure (millions of US dollars),,,141.5000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +762,Tajikistan,2016,Tourism expenditure (millions of US dollars),,,149.6000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +762,Tajikistan,2017,Tourism expenditure (millions of US dollars),,,171.6000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +762,Tajikistan,2018,Tourism expenditure (millions of US dollars),,,170.9000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +764,Thailand,1995,Tourist/visitor arrivals (thousands),TF,,6952.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +764,Thailand,2005,Tourist/visitor arrivals (thousands),TF,,11567.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +764,Thailand,2010,Tourist/visitor arrivals (thousands),TF,,15936.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +764,Thailand,2016,Tourist/visitor arrivals (thousands),TF,,32530.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +764,Thailand,2017,Tourist/visitor arrivals (thousands),TF,,35592.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +764,Thailand,2018,Tourist/visitor arrivals (thousands),TF,,38178.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +764,Thailand,1995,Tourism expenditure (millions of US dollars),,,9257.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +764,Thailand,2005,Tourism expenditure (millions of US dollars),,,12103.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +764,Thailand,2010,Tourism expenditure (millions of US dollars),,,23796.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +764,Thailand,2016,Tourism expenditure (millions of US dollars),,,48459.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +764,Thailand,2017,Tourism expenditure (millions of US dollars),,,57057.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +764,Thailand,2018,Tourism expenditure (millions of US dollars),,,65242.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +626,Timor-Leste,2010,Tourist/visitor arrivals (thousands),TF,,40.0000,Arrivals by air at Dili Airport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +626,Timor-Leste,2016,Tourist/visitor arrivals (thousands),TF,,66.0000,Arrivals by air at Dili Airport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +626,Timor-Leste,2017,Tourist/visitor arrivals (thousands),TF,,74.0000,Arrivals by air at Dili Airport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +626,Timor-Leste,2018,Tourist/visitor arrivals (thousands),TF,,75.0000,Arrivals by air at Dili Airport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +626,Timor-Leste,2010,Tourism expenditure (millions of US dollars),,,24.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +626,Timor-Leste,2016,Tourism expenditure (millions of US dollars),,,58.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +626,Timor-Leste,2017,Tourism expenditure (millions of US dollars),,,73.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +626,Timor-Leste,2018,Tourism expenditure (millions of US dollars),,,78.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +768,Togo,1995,Tourist/visitor arrivals (thousands),THS,,53.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +768,Togo,2005,Tourist/visitor arrivals (thousands),THS,,81.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +768,Togo,2010,Tourist/visitor arrivals (thousands),THS,,202.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +768,Togo,2016,Tourist/visitor arrivals (thousands),THS,,338.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +768,Togo,2017,Tourist/visitor arrivals (thousands),THS,,514.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +768,Togo,2018,Tourist/visitor arrivals (thousands),THS,,573.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +768,Togo,2005,Tourism expenditure (millions of US dollars),,,27.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +768,Togo,2010,Tourism expenditure (millions of US dollars),,,105.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +768,Togo,2016,Tourism expenditure (millions of US dollars),,,223.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +768,Togo,2017,Tourism expenditure (millions of US dollars),,,245.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +776,Tonga,1995,Tourist/visitor arrivals (thousands),TF,,29.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +776,Tonga,2005,Tourist/visitor arrivals (thousands),TF,,42.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +776,Tonga,2010,Tourist/visitor arrivals (thousands),TF,,47.1000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +776,Tonga,2016,Tourist/visitor arrivals (thousands),TF,,59.1000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +776,Tonga,2017,Tourist/visitor arrivals (thousands),TF,,62.5000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +776,Tonga,2018,Tourist/visitor arrivals (thousands),TF,,54.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +776,Tonga,2005,Tourism expenditure (millions of US dollars),,,15.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +776,Tonga,2010,Tourism expenditure (millions of US dollars),,,17.3000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +776,Tonga,2016,Tourism expenditure (millions of US dollars),,,52.7000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +776,Tonga,2017,Tourism expenditure (millions of US dollars),,,48.5000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +776,Tonga,2018,Tourism expenditure (millions of US dollars),,,48.1000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +780,Trinidad and Tobago,1995,Tourist/visitor arrivals (thousands),TF,,260.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +780,Trinidad and Tobago,2005,Tourist/visitor arrivals (thousands),TF,,463.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +780,Trinidad and Tobago,2010,Tourist/visitor arrivals (thousands),TF,,388.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +780,Trinidad and Tobago,2016,Tourist/visitor arrivals (thousands),TF,,409.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +780,Trinidad and Tobago,2017,Tourist/visitor arrivals (thousands),TF,,395.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +780,Trinidad and Tobago,2018,Tourist/visitor arrivals (thousands),TF,,375.0000,Arrivals by air.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +780,Trinidad and Tobago,1995,Tourism expenditure (millions of US dollars),,,232.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +780,Trinidad and Tobago,2005,Tourism expenditure (millions of US dollars),,,593.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +780,Trinidad and Tobago,2010,Tourism expenditure (millions of US dollars),,,630.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +780,Trinidad and Tobago,2016,Tourism expenditure (millions of US dollars),,,708.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +780,Trinidad and Tobago,2017,Tourism expenditure (millions of US dollars),,,717.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +780,Trinidad and Tobago,2018,Tourism expenditure (millions of US dollars),,,541.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +788,Tunisia,1995,Tourist/visitor arrivals (thousands),TF,,4120.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +788,Tunisia,2005,Tourist/visitor arrivals (thousands),TF,,6378.0000,Excluding nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +788,Tunisia,2010,Tourist/visitor arrivals (thousands),TF,,7828.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +788,Tunisia,2016,Tourist/visitor arrivals (thousands),TF,,5724.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +788,Tunisia,2017,Tourist/visitor arrivals (thousands),TF,,7052.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +788,Tunisia,2018,Tourist/visitor arrivals (thousands),TF,,8299.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +788,Tunisia,1995,Tourism expenditure (millions of US dollars),,,1838.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +788,Tunisia,2005,Tourism expenditure (millions of US dollars),,,2800.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +788,Tunisia,2010,Tourism expenditure (millions of US dollars),,,3477.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +788,Tunisia,2016,Tourism expenditure (millions of US dollars),,,1706.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +788,Tunisia,2017,Tourism expenditure (millions of US dollars),,,1782.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +788,Tunisia,2018,Tourism expenditure (millions of US dollars),,,2320.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +792,Turkey,1995,Tourist/visitor arrivals (thousands),TF,,7083.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +792,Turkey,2005,Tourist/visitor arrivals (thousands),TF,,20273.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +792,Turkey,2010,Tourist/visitor arrivals (thousands),TF,,31364.0000,Turkish citizens resident abroad are included.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +792,Turkey,2016,Tourist/visitor arrivals (thousands),TF,,30289.0000,Turkish citizens resident abroad are included.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +792,Turkey,2017,Tourist/visitor arrivals (thousands),TF,,37601.0000,Turkish citizens resident abroad are included.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +792,Turkey,2018,Tourist/visitor arrivals (thousands),TF,,45768.0000,Turkish citizens resident abroad are included.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +792,Turkey,2005,Tourism expenditure (millions of US dollars),,,20760.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +792,Turkey,2010,Tourism expenditure (millions of US dollars),,,26318.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +792,Turkey,2016,Tourism expenditure (millions of US dollars),,,26788.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +792,Turkey,2017,Tourism expenditure (millions of US dollars),,,31870.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +792,Turkey,2018,Tourism expenditure (millions of US dollars),,,37140.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +795,Turkmenistan,1995,Tourist/visitor arrivals (thousands),TF,,218.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +795,Turkmenistan,2005,Tourist/visitor arrivals (thousands),TF,,11.6000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +796,Turks and Caicos Islands,1995,Tourist/visitor arrivals (thousands),TF,,79.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +796,Turks and Caicos Islands,2005,Tourist/visitor arrivals (thousands),TF,,176.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +796,Turks and Caicos Islands,2010,Tourist/visitor arrivals (thousands),TF,,281.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +796,Turks and Caicos Islands,2016,Tourist/visitor arrivals (thousands),TF,,449.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +796,Turks and Caicos Islands,2017,Tourist/visitor arrivals (thousands),TF,,416.4000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +796,Turks and Caicos Islands,2018,Tourist/visitor arrivals (thousands),TF,,441.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +796,Turks and Caicos Islands,1995,Tourism expenditure (millions of US dollars),,,53.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +798,Tuvalu,1995,Tourist/visitor arrivals (thousands),TF,,0.9000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +798,Tuvalu,2005,Tourist/visitor arrivals (thousands),TF,,1.1000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +798,Tuvalu,2010,Tourist/visitor arrivals (thousands),TF,,1.7000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +798,Tuvalu,2016,Tourist/visitor arrivals (thousands),TF,,2.5000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +798,Tuvalu,2017,Tourist/visitor arrivals (thousands),TF,,2.5000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +798,Tuvalu,2018,Tourist/visitor arrivals (thousands),TF,,2.7000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +798,Tuvalu,2005,Tourism expenditure (millions of US dollars),,,1.2000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +798,Tuvalu,2010,Tourism expenditure (millions of US dollars),,,2.4000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +800,Uganda,1995,Tourist/visitor arrivals (thousands),TF,,160.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +800,Uganda,2005,Tourist/visitor arrivals (thousands),TF,,468.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +800,Uganda,2010,Tourist/visitor arrivals (thousands),TF,,946.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +800,Uganda,2016,Tourist/visitor arrivals (thousands),TF,,1323.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +800,Uganda,2017,Tourist/visitor arrivals (thousands),TF,,1402.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +800,Uganda,2005,Tourism expenditure (millions of US dollars),,,382.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +800,Uganda,2010,Tourism expenditure (millions of US dollars),,,802.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +800,Uganda,2016,Tourism expenditure (millions of US dollars),,,1118.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +800,Uganda,2017,Tourism expenditure (millions of US dollars),,,957.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +800,Uganda,2018,Tourism expenditure (millions of US dollars),,,1044.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +804,Ukraine,1995,Tourist/visitor arrivals (thousands),TF,,3716.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +804,Ukraine,2005,Tourist/visitor arrivals (thousands),TF,,17631.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +804,Ukraine,2010,Tourist/visitor arrivals (thousands),TF,,21203.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +804,Ukraine,2016,Tourist/visitor arrivals (thousands),TF,,13333.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +804,Ukraine,2017,Tourist/visitor arrivals (thousands),TF,,14230.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +804,Ukraine,2018,Tourist/visitor arrivals (thousands),TF,,14104.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +804,Ukraine,2005,Tourism expenditure (millions of US dollars),,,3542.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +804,Ukraine,2010,Tourism expenditure (millions of US dollars),,,4696.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +804,Ukraine,2016,Tourism expenditure (millions of US dollars),,,1723.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +804,Ukraine,2017,Tourism expenditure (millions of US dollars),,,2019.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +804,Ukraine,2018,Tourism expenditure (millions of US dollars),,,2269.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +784,United Arab Emirates,1995,Tourist/visitor arrivals (thousands),THS,,2315.0000,Arrivals in hotels only. Including domestic tourism and nationals of the country residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +784,United Arab Emirates,2005,Tourist/visitor arrivals (thousands),THS,,7126.0000,Arrivals in hotels only. Including domestic tourism and nationals of the country residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +784,United Arab Emirates,2016,Tourist/visitor arrivals (thousands),THS,,18967.0000,Arrivals in hotels only. Including domestic tourism and nationals of the country residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +784,United Arab Emirates,2017,Tourist/visitor arrivals (thousands),THS,,20394.0000,Arrivals in hotels only. Including domestic tourism and nationals of the country residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +784,United Arab Emirates,2018,Tourist/visitor arrivals (thousands),THS,,21286.0000,Arrivals in hotels only. Including domestic tourism and nationals of the country residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +784,United Arab Emirates,1995,Tourism expenditure (millions of US dollars),,,632.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +784,United Arab Emirates,2005,Tourism expenditure (millions of US dollars),,,3218.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +784,United Arab Emirates,2010,Tourism expenditure (millions of US dollars),,,8577.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +784,United Arab Emirates,2016,Tourism expenditure (millions of US dollars),,,19496.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +784,United Arab Emirates,2017,Tourism expenditure (millions of US dollars),,,21048.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +784,United Arab Emirates,2018,Tourism expenditure (millions of US dollars),,,21390.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +826,United Kingdom,1995,Tourist/visitor arrivals (thousands),TF,,21719.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +826,United Kingdom,2005,Tourist/visitor arrivals (thousands),TF,,28039.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +826,United Kingdom,2010,Tourist/visitor arrivals (thousands),TF,,28295.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +826,United Kingdom,2016,Tourist/visitor arrivals (thousands),TF,,35814.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +826,United Kingdom,2017,Tourist/visitor arrivals (thousands),TF,,37651.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +826,United Kingdom,2018,Tourist/visitor arrivals (thousands),TF,,36316.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +826,United Kingdom,1995,Tourism expenditure (millions of US dollars),,,27577.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +826,United Kingdom,2005,Tourism expenditure (millions of US dollars),,,32948.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +826,United Kingdom,2010,Tourism expenditure (millions of US dollars),,,34715.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +826,United Kingdom,2016,Tourism expenditure (millions of US dollars),,,47777.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +826,United Kingdom,2017,Tourism expenditure (millions of US dollars),,,47719.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +826,United Kingdom,2018,Tourism expenditure (millions of US dollars),,,48515.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +834,United Rep. of Tanzania,1995,Tourist/visitor arrivals (thousands),TF,,285.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +834,United Rep. of Tanzania,2005,Tourist/visitor arrivals (thousands),TF,,590.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +834,United Rep. of Tanzania,2010,Tourist/visitor arrivals (thousands),TF,,754.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +834,United Rep. of Tanzania,2016,Tourist/visitor arrivals (thousands),TF,,1233.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +834,United Rep. of Tanzania,2017,Tourist/visitor arrivals (thousands),TF,,1275.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +834,United Rep. of Tanzania,2018,Tourist/visitor arrivals (thousands),TF,,1378.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +834,United Rep. of Tanzania,2005,Tourism expenditure (millions of US dollars),,,835.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +834,United Rep. of Tanzania,2010,Tourism expenditure (millions of US dollars),,,1279.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +834,United Rep. of Tanzania,2016,Tourism expenditure (millions of US dollars),,,2149.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +834,United Rep. of Tanzania,2017,Tourism expenditure (millions of US dollars),,,2265.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +834,United Rep. of Tanzania,2018,Tourism expenditure (millions of US dollars),,,2465.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +840,United States of America,1995,Tourist/visitor arrivals (thousands),TF,,43318.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +840,United States of America,2005,Tourist/visitor arrivals (thousands),TF,,49206.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +840,United States of America,2010,Tourist/visitor arrivals (thousands),TF,,60010.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +840,United States of America,2016,Tourist/visitor arrivals (thousands),TF,,76407.4880,Break in the time series.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +840,United States of America,2017,Tourist/visitor arrivals (thousands),TF,,77186.7460,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +840,United States of America,2018,Tourist/visitor arrivals (thousands),TF,,79745.9180,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +840,United States of America,1995,Tourism expenditure (millions of US dollars),,,93743.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +840,United States of America,2005,Tourism expenditure (millions of US dollars),,,122077.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +840,United States of America,2010,Tourism expenditure (millions of US dollars),,,167996.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +840,United States of America,2016,Tourism expenditure (millions of US dollars),,,245991.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +840,United States of America,2017,Tourism expenditure (millions of US dollars),,,251544.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +840,United States of America,2018,Tourism expenditure (millions of US dollars),,,256145.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +850,United States Virgin Islands,1995,Tourist/visitor arrivals (thousands),TF,,454.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +850,United States Virgin Islands,2005,Tourist/visitor arrivals (thousands),TF,,594.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +850,United States Virgin Islands,2010,Tourist/visitor arrivals (thousands),TF,,572.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +850,United States Virgin Islands,2016,Tourist/visitor arrivals (thousands),TF,,667.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +850,United States Virgin Islands,2017,Tourist/visitor arrivals (thousands),TF,,535.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +850,United States Virgin Islands,2018,Tourist/visitor arrivals (thousands),TF,,381.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +850,United States Virgin Islands,1995,Tourism expenditure (millions of US dollars),,,822.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +850,United States Virgin Islands,2005,Tourism expenditure (millions of US dollars),,,1432.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +850,United States Virgin Islands,2010,Tourism expenditure (millions of US dollars),,,1223.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +850,United States Virgin Islands,2016,Tourism expenditure (millions of US dollars),,,1343.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +850,United States Virgin Islands,2017,Tourism expenditure (millions of US dollars),,,1202.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +850,United States Virgin Islands,2018,Tourism expenditure (millions of US dollars),,,1046.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +858,Uruguay,1995,Tourist/visitor arrivals (thousands),TF,,2022.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +858,Uruguay,2005,Tourist/visitor arrivals (thousands),TF,,1808.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +858,Uruguay,2010,Tourist/visitor arrivals (thousands),TF,,2353.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +858,Uruguay,2016,Tourist/visitor arrivals (thousands),TF,,3037.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +858,Uruguay,2017,Tourist/visitor arrivals (thousands),TF,,3674.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +858,Uruguay,2018,Tourist/visitor arrivals (thousands),TF,,3469.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +858,Uruguay,1995,Tourism expenditure (millions of US dollars),,,725.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +858,Uruguay,2005,Tourism expenditure (millions of US dollars),,,699.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +858,Uruguay,2010,Tourism expenditure (millions of US dollars),,,1669.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +858,Uruguay,2016,Tourism expenditure (millions of US dollars),,,2182.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +858,Uruguay,2017,Tourism expenditure (millions of US dollars),,,2660.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +858,Uruguay,2018,Tourism expenditure (millions of US dollars),,,2439.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +860,Uzbekistan,1995,Tourist/visitor arrivals (thousands),TF,,92.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +860,Uzbekistan,2005,Tourist/visitor arrivals (thousands),TF,,242.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +860,Uzbekistan,2010,Tourist/visitor arrivals (thousands),TF,,975.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +860,Uzbekistan,2016,Tourist/visitor arrivals (thousands),TF,,2027.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +860,Uzbekistan,2017,Tourist/visitor arrivals (thousands),TF,,2690.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +860,Uzbekistan,2018,Tourist/visitor arrivals (thousands),TF,,5346.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +860,Uzbekistan,2005,Tourism expenditure (millions of US dollars),,,28.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +860,Uzbekistan,2010,Tourism expenditure (millions of US dollars),,,121.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +860,Uzbekistan,2016,Tourism expenditure (millions of US dollars),,,458.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +860,Uzbekistan,2017,Tourism expenditure (millions of US dollars),,,689.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +860,Uzbekistan,2018,Tourism expenditure (millions of US dollars),,,1144.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +548,Vanuatu,1995,Tourist/visitor arrivals (thousands),TF,,44.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +548,Vanuatu,2005,Tourist/visitor arrivals (thousands),TF,,62.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +548,Vanuatu,2010,Tourist/visitor arrivals (thousands),TF,,97.2000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +548,Vanuatu,2016,Tourist/visitor arrivals (thousands),TF,,95.1000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +548,Vanuatu,2017,Tourist/visitor arrivals (thousands),TF,,109.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +548,Vanuatu,2018,Tourist/visitor arrivals (thousands),TF,,116.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +548,Vanuatu,2005,Tourism expenditure (millions of US dollars),,,104.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +548,Vanuatu,2010,Tourism expenditure (millions of US dollars),,,242.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +548,Vanuatu,2016,Tourism expenditure (millions of US dollars),,,275.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +548,Vanuatu,2017,Tourism expenditure (millions of US dollars),,,289.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +548,Vanuatu,2018,Tourism expenditure (millions of US dollars),,,325.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +862,Venezuela (Boliv. Rep. of),1995,Tourist/visitor arrivals (thousands),TF,,700.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +862,Venezuela (Boliv. Rep. of),2005,Tourist/visitor arrivals (thousands),TF,,706.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +862,Venezuela (Boliv. Rep. of),2010,Tourist/visitor arrivals (thousands),TF,,526.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +862,Venezuela (Boliv. Rep. of),2016,Tourist/visitor arrivals (thousands),TF,,601.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +862,Venezuela (Boliv. Rep. of),2017,Tourist/visitor arrivals (thousands),TF,,427.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +862,Venezuela (Boliv. Rep. of),1995,Tourism expenditure (millions of US dollars),,,995.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +862,Venezuela (Boliv. Rep. of),2005,Tourism expenditure (millions of US dollars),,,722.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +862,Venezuela (Boliv. Rep. of),2010,Tourism expenditure (millions of US dollars),,,885.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +862,Venezuela (Boliv. Rep. of),2016,Tourism expenditure (millions of US dollars),,,546.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +704,Viet Nam,1995,Tourist/visitor arrivals (thousands),VF,,1351.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +704,Viet Nam,2005,Tourist/visitor arrivals (thousands),VF,,3477.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +704,Viet Nam,2010,Tourist/visitor arrivals (thousands),VF,,5050.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +704,Viet Nam,2016,Tourist/visitor arrivals (thousands),VF,,10013.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +704,Viet Nam,2017,Tourist/visitor arrivals (thousands),VF,,12922.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +704,Viet Nam,2018,Tourist/visitor arrivals (thousands),VF,,15498.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +704,Viet Nam,2005,Tourism expenditure (millions of US dollars),,,2300.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +704,Viet Nam,2010,Tourism expenditure (millions of US dollars),,,4450.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +704,Viet Nam,2016,Tourism expenditure (millions of US dollars),,,8500.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +704,Viet Nam,2017,Tourism expenditure (millions of US dollars),,,8890.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +704,Viet Nam,2018,Tourism expenditure (millions of US dollars),,,10080.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +887,Yemen,1995,Tourist/visitor arrivals (thousands),TF,,61.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +887,Yemen,2005,Tourist/visitor arrivals (thousands),TF,,336.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +887,Yemen,2010,Tourist/visitor arrivals (thousands),TF,,1025.0000,Including nationals residing abroad.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +887,Yemen,2010,Tourism expenditure (millions of US dollars),,,1291.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +887,Yemen,2016,Tourism expenditure (millions of US dollars),,,116.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +894,Zambia,1995,Tourist/visitor arrivals (thousands),TF,,163.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +894,Zambia,2005,Tourist/visitor arrivals (thousands),TF,,669.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +894,Zambia,2010,Tourist/visitor arrivals (thousands),TF,,815.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +894,Zambia,2016,Tourist/visitor arrivals (thousands),TF,,956.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +894,Zambia,2017,Tourist/visitor arrivals (thousands),TF,,1083.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +894,Zambia,2018,Tourist/visitor arrivals (thousands),TF,,1072.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +894,Zambia,2005,Tourism expenditure (millions of US dollars),,,447.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +894,Zambia,2010,Tourism expenditure (millions of US dollars),,,492.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +894,Zambia,2016,Tourism expenditure (millions of US dollars),,,683.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +894,Zambia,2017,Tourism expenditure (millions of US dollars),,,653.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +894,Zambia,2018,Tourism expenditure (millions of US dollars),,,742.0000,Excluding passenger transport.,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +716,Zimbabwe,1995,Tourist/visitor arrivals (thousands),VF,,1416.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +716,Zimbabwe,2005,Tourist/visitor arrivals (thousands),VF,,1559.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +716,Zimbabwe,2010,Tourist/visitor arrivals (thousands),VF,,2239.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +716,Zimbabwe,2016,Tourist/visitor arrivals (thousands),VF,,2168.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +716,Zimbabwe,2017,Tourist/visitor arrivals (thousands),VF,,2423.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +716,Zimbabwe,2018,Tourist/visitor arrivals (thousands),VF,,2580.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +716,Zimbabwe,1995,Tourism expenditure (millions of US dollars),,,145.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +716,Zimbabwe,2005,Tourism expenditure (millions of US dollars),,,99.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +716,Zimbabwe,2010,Tourism expenditure (millions of US dollars),,,135.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +716,Zimbabwe,2016,Tourism expenditure (millions of US dollars),,,194.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." +716,Zimbabwe,2017,Tourism expenditure (millions of US dollars),,,158.0000,,"World Tourism Organization (UNWTO), Madrid, the UNWTO Statistics Database, last accessed January 2020." diff --git a/apache-spark/src/main/java/com/baeldung/differences/dataframe/dataset/rdd/TouristData.java b/apache-spark/src/main/java/com/baeldung/differences/dataframe/dataset/rdd/TouristData.java new file mode 100644 index 0000000000..fbeef4283a --- /dev/null +++ b/apache-spark/src/main/java/com/baeldung/differences/dataframe/dataset/rdd/TouristData.java @@ -0,0 +1,75 @@ +package com.baeldung.differences.dataframe.dataset.rdd; + + +public class TouristData { + + private String region; + private String country; + private String year; + private String series; + private Double value; + private String footnotes; + private String source; + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country = country; + } + + public String getYear() { + return year; + } + + public void setYear(String year) { + this.year = year; + } + + public String getSeries() { + return series; + } + + public void setSeries(String series) { + this.series = series; + } + + public Double getValue() { + return value; + } + + public void setValue(Double value) { + this.value = value; + } + + public String getFootnotes() { + return footnotes; + } + + public void setFootnotes(String footnotes) { + this.footnotes = footnotes; + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + @Override + public String toString() { + return "TouristData [region=" + region + ", country=" + country + ", year=" + year + ", series=" + series + ", value=" + value + ", footnotes=" + footnotes + ", source=" + source + "]"; + } + +} diff --git a/apache-spark/src/test/java/com/baeldung/differences/rdd/ActionsUnitTest.java b/apache-spark/src/test/java/com/baeldung/differences/rdd/ActionsUnitTest.java new file mode 100644 index 0000000000..a3e1811e6f --- /dev/null +++ b/apache-spark/src/test/java/com/baeldung/differences/rdd/ActionsUnitTest.java @@ -0,0 +1,67 @@ +package com.baeldung.differences.rdd; + +import static org.junit.Assert.assertEquals; + +import java.util.List; + +import org.apache.spark.SparkConf; +import org.apache.spark.api.java.JavaPairRDD; +import org.apache.spark.api.java.JavaRDD; +import org.apache.spark.api.java.JavaSparkContext; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import scala.Tuple2; + +public class ActionsUnitTest { + private static JavaRDD tourists; + private static JavaSparkContext sc; + public static final String COMMA_DELIMITER = ",(?=([^\"]*\"[^\"]*\")*[^\"]*$)"; + + @BeforeClass + public static void init() { + SparkConf conf = new SparkConf().setAppName("reduce") + .setMaster("local[*]"); + sc = new JavaSparkContext(conf); + tourists = sc.textFile("data/Tourist.csv").filter(line -> !line.startsWith("Region")); + } + + @AfterClass + public static void cleanup() { + sc.close(); + } + + @Test + public void whenDistinctCount_thenReturnDistinctNumRecords() { + JavaRDD countries = tourists.map(line -> { + String[] columns = line.split(COMMA_DELIMITER); + return columns[1]; + }) + .distinct(); + Long numberOfCountries = countries.count(); + System.out.println("Count: " + numberOfCountries); + + assertEquals(Long.valueOf(220), numberOfCountries); + } + + @Test + public void whenReduceByKeySum_thenTotalValuePerKey() { + JavaRDD touristsExpenditure = tourists.filter(line -> line.split(COMMA_DELIMITER)[3].contains("expenditure")); + + JavaPairRDD expenditurePairRdd = touristsExpenditure.mapToPair(line -> { + String[] columns = line.split(COMMA_DELIMITER); + return new Tuple2<>(columns[1], Double.valueOf(columns[6])); + }); + List> totalByCountry = expenditurePairRdd.reduceByKey((x, y) -> x + y) + .collect(); + System.out.println("Total per Country: " + totalByCountry); + + for(Tuple2 tuple : totalByCountry) { + if (tuple._1.equals("Mexico")) { + assertEquals(Double.valueOf(99164), tuple._2); + } + } + } + +} diff --git a/apache-spark/src/test/java/com/baeldung/differences/rdd/DataFrameUnitTest.java b/apache-spark/src/test/java/com/baeldung/differences/rdd/DataFrameUnitTest.java new file mode 100644 index 0000000000..f294e5bc66 --- /dev/null +++ b/apache-spark/src/test/java/com/baeldung/differences/rdd/DataFrameUnitTest.java @@ -0,0 +1,74 @@ +package com.baeldung.differences.rdd; + +import static org.apache.spark.sql.functions.col; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.Arrays; +import java.util.List; + +import org.apache.spark.sql.DataFrameReader; +import org.apache.spark.sql.Dataset; +import org.apache.spark.sql.Row; +import org.apache.spark.sql.SparkSession; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +public class DataFrameUnitTest { + private static SparkSession session; + private static Dataset data; + + @BeforeClass + public static void init() { + session = SparkSession.builder() + .appName("TouristDataFrameExample") + .master("local[*]") + .getOrCreate(); + DataFrameReader dataFrameReader = session.read(); + data = dataFrameReader.option("header", "true") + .csv("data/Tourist.csv"); + } + + @AfterClass + public static void cleanup() { + session.stop(); + } + + @Test + public void whenSelectSpecificColumns_thenColumnsFiltered() { + Dataset selectedData = data.select(col("country"), col("year"), col("value")); + selectedData.show(); + + List resultList = Arrays.asList(selectedData.columns()); + assertTrue(resultList.contains("country")); + assertTrue(resultList.contains("year")); + assertTrue(resultList.contains("value")); + assertFalse(resultList.contains("Series")); + + } + + @Test + public void whenFilteringByCountry_thenCountryRecordsSelected() { + Dataset filteredData = data.filter(col("country").equalTo("Mexico")); + filteredData.show(); + + filteredData.foreach(record -> { + assertEquals("Mexico", record.get(1)); + }); + + } + + @Test + public void whenGroupCountByCountry_thenContryTotalRecords() { + Dataset recordsPerCountry = data.groupBy(col("country")) + .count(); + recordsPerCountry.show(); + + Dataset filteredData = recordsPerCountry.filter(col("country").equalTo("Sweden")); + assertEquals(new Long(12), filteredData.first() + .get(1)); + } + +} diff --git a/apache-spark/src/test/java/com/baeldung/differences/rdd/DatasetUnitTest.java b/apache-spark/src/test/java/com/baeldung/differences/rdd/DatasetUnitTest.java new file mode 100644 index 0000000000..1d83505812 --- /dev/null +++ b/apache-spark/src/test/java/com/baeldung/differences/rdd/DatasetUnitTest.java @@ -0,0 +1,83 @@ +package com.baeldung.differences.rdd; + +import static org.apache.spark.sql.functions.col; +import static org.apache.spark.sql.functions.sum; +import static org.junit.Assert.assertEquals; + +import org.apache.spark.api.java.function.FilterFunction; +import org.apache.spark.sql.DataFrameReader; +import org.apache.spark.sql.Dataset; +import org.apache.spark.sql.Encoders; +import org.apache.spark.sql.Row; +import org.apache.spark.sql.SparkSession; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.baeldung.differences.dataframe.dataset.rdd.TouristData; + +public class DatasetUnitTest { + private static SparkSession session; + private static Dataset typedDataset; + + @BeforeClass + public static void init() { + session = SparkSession.builder() + .appName("TouristDatasetExample") + .master("local[*]") + .getOrCreate(); + DataFrameReader dataFrameReader = session.read(); + Dataset data = dataFrameReader.option("header", "true") + .csv("data/Tourist.csv"); + Dataset responseWithSelectedColumns = data.select(col("region"), + col("country"), col("year"), col("series"), col("value").cast("double"), + col("footnotes"), col("source")); + typedDataset = responseWithSelectedColumns.as(Encoders.bean(TouristData.class)); + } + + @AfterClass + public static void cleanup() { + session.stop(); + } + + @Test + public void whenFilteringByCountry_thenCountryRecordsSelected() { + Dataset selectedData = typedDataset + .filter((FilterFunction) record -> record.getCountry() + .equals("Norway")); + selectedData.show(); + + selectedData.foreach(record -> { + assertEquals("Norway", record.getCountry()); + }); + } + + @Test + public void whenGroupCountByCountry_thenContryTotalRecords() { + Dataset countriesCount = typedDataset.groupBy(typedDataset.col("country")) + .count(); + countriesCount.show(); + + assertEquals(Long.valueOf(220), Long.valueOf(countriesCount.count())); + } + + @Test + public void whenFilteredByPropertyRange_thenRetreiveValidRecords() { + // Filter records with existing data for years between 2010 and 2017 + typedDataset.filter((FilterFunction) record -> record.getYear() != null + && (Long.valueOf(record.getYear()) > 2010 && Long.valueOf(record.getYear()) < 2017)) + .show(); + } + + @Test + public void whenSumValue_thenRetreiveTotalValue() { + // Total tourist expenditure by country + typedDataset.filter((FilterFunction) record -> record.getValue() != null + && record.getSeries() + .contains("expenditure")) + .groupBy("country") + .agg(sum("value")) + .show(); + } + +} diff --git a/apache-spark/src/test/java/com/baeldung/differences/rdd/TransformationsUnitTest.java b/apache-spark/src/test/java/com/baeldung/differences/rdd/TransformationsUnitTest.java new file mode 100644 index 0000000000..4b2d9e1127 --- /dev/null +++ b/apache-spark/src/test/java/com/baeldung/differences/rdd/TransformationsUnitTest.java @@ -0,0 +1,63 @@ +package com.baeldung.differences.rdd; + + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.apache.commons.lang3.StringUtils; +import org.apache.spark.SparkConf; +import org.apache.spark.api.java.JavaRDD; +import org.apache.spark.api.java.JavaSparkContext; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +public class TransformationsUnitTest { + + public static final String COMMA_DELIMITER = ",(?=([^\"]*\"[^\"]*\")*[^\"]*$)"; + private static JavaSparkContext sc; + private static JavaRDD tourists; + + @BeforeClass + public static void init() { + SparkConf conf = new SparkConf().setAppName("uppercaseCountries") + .setMaster("local[*]"); + sc = new JavaSparkContext(conf); + tourists = sc.textFile("data/Tourist.csv") + .filter(line -> !line.startsWith("Region")); //filter header row + } + + @AfterClass + public static void cleanup() { + sc.close(); + } + + @Test + public void whenMapUpperCase_thenCountryNameUppercased() { + JavaRDD upperCaseCountries = tourists.map(line -> { + String[] columns = line.split(COMMA_DELIMITER); + return columns[1].toUpperCase(); + }) + .distinct(); + + upperCaseCountries.saveAsTextFile("data/output/uppercase.txt"); + + upperCaseCountries.foreach(country -> { + //replace non alphanumerical characters + country = country.replaceAll("[^a-zA-Z]", ""); + assertTrue(StringUtils.isAllUpperCase(country)); + }); + } + + @Test + public void whenFilterByCountry_thenShowRequestedCountryRecords() { + JavaRDD touristsInMexico = tourists.filter(line -> line.split(COMMA_DELIMITER)[1].equals("Mexico")); + + touristsInMexico.saveAsTextFile("data/output/touristInMexico.txt"); + + touristsInMexico.foreach(record -> { + assertEquals("Mexico", record.split(COMMA_DELIMITER)[1]); + }); + } + +} From b9dbeb6c58d19e7ca88e56086136678cc2883a66 Mon Sep 17 00:00:00 2001 From: andrebrowne <42154231+andrebrowne@users.noreply.github.com> Date: Fri, 2 Oct 2020 13:21:18 -0400 Subject: [PATCH 259/263] BAEL-4012 Add Netflix Feign (#10110) * BAEL-4012 Add Netflix Feign * BAEL-4012 Cleanup pom --- .../spring-cloud-netflix-feign/pom.xml | 71 +++++++++++++++++++ .../netflix/feign/ExampleApplication.java | 16 +++++ .../feign/client/JSONPlaceHolderClient.java | 25 +++++++ .../feign/config/ClientConfiguration.java | 38 ++++++++++ .../feign/config/CustomErrorDecoder.java | 21 ++++++ .../feign/exception/BadRequestException.java | 21 ++++++ .../feign/exception/NotFoundException.java | 21 ++++++ .../hystrix/JSONPlaceHolderFallback.java | 22 ++++++ .../cloud/netflix/feign/model/Post.java | 41 +++++++++++ .../feign/service/JSONPlaceHolderService.java | 12 ++++ .../impl/JSONPlaceHolderServiceImpl.java | 26 +++++++ .../src/main/resources/application.properties | 3 + .../netflix/feign/ExampleTestApplication.java | 21 ++++++ .../netflix/feign/NetflixFeignUnitTest.java | 43 +++++++++++ 14 files changed, 381 insertions(+) create mode 100644 spring-cloud/spring-cloud-netflix-feign/pom.xml create mode 100644 spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/ExampleApplication.java create mode 100644 spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/client/JSONPlaceHolderClient.java create mode 100644 spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/config/ClientConfiguration.java create mode 100644 spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/config/CustomErrorDecoder.java create mode 100644 spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/exception/BadRequestException.java create mode 100644 spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/exception/NotFoundException.java create mode 100644 spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/hystrix/JSONPlaceHolderFallback.java create mode 100644 spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/model/Post.java create mode 100644 spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/service/JSONPlaceHolderService.java create mode 100644 spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/service/impl/JSONPlaceHolderServiceImpl.java create mode 100644 spring-cloud/spring-cloud-netflix-feign/src/main/resources/application.properties create mode 100644 spring-cloud/spring-cloud-netflix-feign/src/test/java/com/baeldung/cloud/netflix/feign/ExampleTestApplication.java create mode 100644 spring-cloud/spring-cloud-netflix-feign/src/test/java/com/baeldung/cloud/netflix/feign/NetflixFeignUnitTest.java diff --git a/spring-cloud/spring-cloud-netflix-feign/pom.xml b/spring-cloud/spring-cloud-netflix-feign/pom.xml new file mode 100644 index 0000000000..aa5ba5dbdb --- /dev/null +++ b/spring-cloud/spring-cloud-netflix-feign/pom.xml @@ -0,0 +1,71 @@ + + + 4.0.0 + com.baeldung.cloud + spring-cloud-netlix-feign + 0.0.1-SNAPSHOT + spring-cloud-netflix-feign + Netflix Feign project for Spring Boot + + + com.baeldung + parent-boot-1 + 0.0.1-SNAPSHOT + ../../parent-boot-1 + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + + + + + org.springframework.cloud + spring-cloud-starter-feign + + + + com.netflix.feign + feign-okhttp + ${feign-ok.version} + + + + org.springframework.boot + spring-boot-starter-web + + + + org.apache.httpcomponents + httpcore + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + Camden.SR7 + 8.18.0 + + + + + diff --git a/spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/ExampleApplication.java b/spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/ExampleApplication.java new file mode 100644 index 0000000000..e5ed9cbecf --- /dev/null +++ b/spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/ExampleApplication.java @@ -0,0 +1,16 @@ +package com.baeldung.cloud.netflix.feign; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.netflix.feign.EnableFeignClients; + +@SpringBootApplication +@EnableFeignClients +public class ExampleApplication { + + public static void main(String[] args) { + SpringApplication.run(ExampleApplication.class, args); + } + +} + diff --git a/spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/client/JSONPlaceHolderClient.java b/spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/client/JSONPlaceHolderClient.java new file mode 100644 index 0000000000..80a455a4c4 --- /dev/null +++ b/spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/client/JSONPlaceHolderClient.java @@ -0,0 +1,25 @@ +package com.baeldung.cloud.netflix.feign.client; + +import com.baeldung.cloud.netflix.feign.config.ClientConfiguration; +import com.baeldung.cloud.netflix.feign.hystrix.JSONPlaceHolderFallback; +import com.baeldung.cloud.netflix.feign.model.Post; +import org.springframework.cloud.netflix.feign.FeignClient; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +import java.util.List; + +@FeignClient(value = "jplaceholder", + url = "https://jsonplaceholder.typicode.com/", + configuration = ClientConfiguration.class, + fallback = JSONPlaceHolderFallback.class) +public interface JSONPlaceHolderClient { + + @RequestMapping(method = RequestMethod.GET, value = "/posts") + List getPosts(); + + + @RequestMapping(method = RequestMethod.GET, value = "/posts/{postId}", produces = "application/json") + Post getPostById(@PathVariable("postId") Long postId); +} diff --git a/spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/config/ClientConfiguration.java b/spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/config/ClientConfiguration.java new file mode 100644 index 0000000000..bc211b181e --- /dev/null +++ b/spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/config/ClientConfiguration.java @@ -0,0 +1,38 @@ +package com.baeldung.cloud.netflix.feign.config; + +import feign.Logger; +import feign.RequestInterceptor; +import feign.codec.ErrorDecoder; +import feign.okhttp.OkHttpClient; + +import org.apache.http.entity.ContentType; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class ClientConfiguration { + + @Bean + public Logger.Level feignLoggerLevel() { + return Logger.Level.FULL; + } + + @Bean + public ErrorDecoder errorDecoder() { + return new ErrorDecoder.Default(); + } + + @Bean + public OkHttpClient client() { + return new OkHttpClient(); + } + + @Bean + public RequestInterceptor requestInterceptor() { + return requestTemplate -> { + requestTemplate.header("user", "ajeje"); + requestTemplate.header("password", "brazof"); + requestTemplate.header("Accept", ContentType.APPLICATION_JSON.getMimeType()); + }; + } +} diff --git a/spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/config/CustomErrorDecoder.java b/spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/config/CustomErrorDecoder.java new file mode 100644 index 0000000000..3e0e80f6d5 --- /dev/null +++ b/spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/config/CustomErrorDecoder.java @@ -0,0 +1,21 @@ +package com.baeldung.cloud.netflix.feign.config; + +import com.baeldung.cloud.netflix.feign.exception.BadRequestException; +import com.baeldung.cloud.netflix.feign.exception.NotFoundException; +import feign.Response; +import feign.codec.ErrorDecoder; + +public class CustomErrorDecoder implements ErrorDecoder { + @Override + public Exception decode(String methodKey, Response response) { + + switch (response.status()){ + case 400: + return new BadRequestException(); + case 404: + return new NotFoundException(); + default: + return new Exception("Generic error"); + } + } +} diff --git a/spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/exception/BadRequestException.java b/spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/exception/BadRequestException.java new file mode 100644 index 0000000000..6a5f60f7c0 --- /dev/null +++ b/spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/exception/BadRequestException.java @@ -0,0 +1,21 @@ +package com.baeldung.cloud.netflix.feign.exception; + +public class BadRequestException extends Exception { + + public BadRequestException() { + } + + public BadRequestException(String message) { + super(message); + } + + public BadRequestException(Throwable cause) { + super(cause); + } + + @Override + public String toString() { + return "BadRequestException: "+getMessage(); + } + +} diff --git a/spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/exception/NotFoundException.java b/spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/exception/NotFoundException.java new file mode 100644 index 0000000000..a8d89049fd --- /dev/null +++ b/spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/exception/NotFoundException.java @@ -0,0 +1,21 @@ +package com.baeldung.cloud.netflix.feign.exception; + +public class NotFoundException extends Exception { + + public NotFoundException() { + } + + public NotFoundException(String message) { + super(message); + } + + public NotFoundException(Throwable cause) { + super(cause); + } + + @Override + public String toString() { + return "NotFoundException: "+getMessage(); + } + +} diff --git a/spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/hystrix/JSONPlaceHolderFallback.java b/spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/hystrix/JSONPlaceHolderFallback.java new file mode 100644 index 0000000000..ab1aa6bf50 --- /dev/null +++ b/spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/hystrix/JSONPlaceHolderFallback.java @@ -0,0 +1,22 @@ +package com.baeldung.cloud.netflix.feign.hystrix; + +import com.baeldung.cloud.netflix.feign.client.JSONPlaceHolderClient; +import com.baeldung.cloud.netflix.feign.model.Post; +import org.springframework.stereotype.Component; + +import java.util.Collections; +import java.util.List; + +@Component +public class JSONPlaceHolderFallback implements JSONPlaceHolderClient { + + @Override + public List getPosts() { + return Collections.emptyList(); + } + + @Override + public Post getPostById(Long postId) { + return null; + } +} diff --git a/spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/model/Post.java b/spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/model/Post.java new file mode 100644 index 0000000000..73dd2bc198 --- /dev/null +++ b/spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/model/Post.java @@ -0,0 +1,41 @@ +package com.baeldung.cloud.netflix.feign.model; + +public class Post { + + private String userId; + private Long id; + private String title; + private String body; + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + 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 String getBody() { + return body; + } + + public void setBody(String body) { + this.body = body; + } +} diff --git a/spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/service/JSONPlaceHolderService.java b/spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/service/JSONPlaceHolderService.java new file mode 100644 index 0000000000..d2e174a1f0 --- /dev/null +++ b/spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/service/JSONPlaceHolderService.java @@ -0,0 +1,12 @@ +package com.baeldung.cloud.netflix.feign.service; + +import com.baeldung.cloud.netflix.feign.model.Post; + +import java.util.List; + +public interface JSONPlaceHolderService { + + List getPosts(); + + Post getPostById(Long id); +} diff --git a/spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/service/impl/JSONPlaceHolderServiceImpl.java b/spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/service/impl/JSONPlaceHolderServiceImpl.java new file mode 100644 index 0000000000..0cc8d296f0 --- /dev/null +++ b/spring-cloud/spring-cloud-netflix-feign/src/main/java/com/baeldung/cloud/netflix/feign/service/impl/JSONPlaceHolderServiceImpl.java @@ -0,0 +1,26 @@ +package com.baeldung.cloud.netflix.feign.service.impl; + +import com.baeldung.cloud.netflix.feign.client.JSONPlaceHolderClient; +import com.baeldung.cloud.netflix.feign.model.Post; +import com.baeldung.cloud.netflix.feign.service.JSONPlaceHolderService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class JSONPlaceHolderServiceImpl implements JSONPlaceHolderService { + + @Autowired + private JSONPlaceHolderClient jsonPlaceHolderClient; + + @Override + public List getPosts() { + return jsonPlaceHolderClient.getPosts(); + } + + @Override + public Post getPostById(Long id) { + return jsonPlaceHolderClient.getPostById(id); + } +} diff --git a/spring-cloud/spring-cloud-netflix-feign/src/main/resources/application.properties b/spring-cloud/spring-cloud-netflix-feign/src/main/resources/application.properties new file mode 100644 index 0000000000..5927ccb9c1 --- /dev/null +++ b/spring-cloud/spring-cloud-netflix-feign/src/main/resources/application.properties @@ -0,0 +1,3 @@ +spring.application.name=netflix-feign +logging.level.com.baeldung.cloud.netflix.feign.client=DEBUG +feign.hystrix.enabled=true diff --git a/spring-cloud/spring-cloud-netflix-feign/src/test/java/com/baeldung/cloud/netflix/feign/ExampleTestApplication.java b/spring-cloud/spring-cloud-netflix-feign/src/test/java/com/baeldung/cloud/netflix/feign/ExampleTestApplication.java new file mode 100644 index 0000000000..f3c8459f87 --- /dev/null +++ b/spring-cloud/spring-cloud-netflix-feign/src/test/java/com/baeldung/cloud/netflix/feign/ExampleTestApplication.java @@ -0,0 +1,21 @@ +package com.baeldung.cloud.netflix.feign; + +import com.baeldung.cloud.netflix.feign.config.ClientConfiguration; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +@EnableAutoConfiguration +@ContextConfiguration(classes = { ClientConfiguration.class }) +public class ExampleTestApplication { + + @Test + public void whenSpringContextIsBootstrapped_thenNoExceptions() { + } +} diff --git a/spring-cloud/spring-cloud-netflix-feign/src/test/java/com/baeldung/cloud/netflix/feign/NetflixFeignUnitTest.java b/spring-cloud/spring-cloud-netflix-feign/src/test/java/com/baeldung/cloud/netflix/feign/NetflixFeignUnitTest.java new file mode 100644 index 0000000000..880948d6d1 --- /dev/null +++ b/spring-cloud/spring-cloud-netflix-feign/src/test/java/com/baeldung/cloud/netflix/feign/NetflixFeignUnitTest.java @@ -0,0 +1,43 @@ +package com.baeldung.cloud.netflix.feign; + +import com.baeldung.cloud.netflix.feign.model.Post; +import com.baeldung.cloud.netflix.feign.service.JSONPlaceHolderService; +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.assertFalse; +import static org.junit.Assert.assertNotNull; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class NetflixFeignUnitTest { + + @Autowired + private JSONPlaceHolderService jsonPlaceHolderService; + + @Test + public void whenSpringContextIsBootstrapped_thenNoExceptions() { + } + + @Test + public void whenGetPosts_thenListPostSizeGreaterThanZero() { + + List posts = jsonPlaceHolderService.getPosts(); + + assertFalse(posts.isEmpty()); + } + + @Test + public void whenGetPostWithId_thenPostExist() { + + Post post = jsonPlaceHolderService.getPostById(1L); + + assertNotNull(post); + } + +} From d3744f76947a78fb5ed6595b0a6530c37bab85e0 Mon Sep 17 00:00:00 2001 From: majajoksovic Date: Fri, 2 Oct 2020 19:23:50 +0200 Subject: [PATCH 260/263] BAEL-4505 (#10119) * initial commit * fixed formatting * formatting changes * test fix --- .../application-persistent-on.properties | 10 ++++ .../persistent/FilesLocationUnitTest.java | 52 +++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 persistence-modules/spring-boot-persistence-h2/src/main/resources/application-persistent-on.properties create mode 100644 persistence-modules/spring-boot-persistence-h2/src/test/java/com/baeldung/persistent/FilesLocationUnitTest.java diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-persistent-on.properties b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-persistent-on.properties new file mode 100644 index 0000000000..be939ffa69 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-persistent-on.properties @@ -0,0 +1,10 @@ +#spring.datasource.url=jdbc:h2:file:C:/data/demodb +#spring.datasource.url=jdbc:h2:file:~/demodb +spring.datasource.url=jdbc:h2:file:./src/main/resources/db/demodb +spring.datasource.driverClassName=org.h2.Driver +spring.datasource.username=sa +spring.datasource.password= +spring.h2.console.enabled=true +spring.jpa.hibernate.ddl-auto=create-drop +spring.jpa.database-platform=org.hibernate.dialect.H2Dialect +spring.h2.console.path=/h2-console diff --git a/persistence-modules/spring-boot-persistence-h2/src/test/java/com/baeldung/persistent/FilesLocationUnitTest.java b/persistence-modules/spring-boot-persistence-h2/src/test/java/com/baeldung/persistent/FilesLocationUnitTest.java new file mode 100644 index 0000000000..63f195e88d --- /dev/null +++ b/persistence-modules/spring-boot-persistence-h2/src/test/java/com/baeldung/persistent/FilesLocationUnitTest.java @@ -0,0 +1,52 @@ +package com.baeldung.persistent; + +import static org.junit.Assert.assertTrue; + +import java.io.File; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +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.annotation.DirtiesContext.ClassMode; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + +import com.baeldung.h2db.auto.configuration.AutoConfigurationDemo; + +@ActiveProfiles("persistent-on") +@RunWith(SpringRunner.class) +@DirtiesContext(classMode = ClassMode.BEFORE_EACH_TEST_METHOD) +@SpringBootTest(classes = AutoConfigurationDemo.class) +public class FilesLocationUnitTest { + + @BeforeClass + public static void beforeClass() { + + } + + @Test(expected = Test.None.class) + public void whenApplicationStarted_thenEmbeddedDbSubfolderCreated() { + File subdirectory = new File("src/main/resources/db"); + System.out.println(subdirectory.getAbsolutePath()); + assertTrue(subdirectory.exists()); + assertTrue(subdirectory.isDirectory()); + } + + @Test(expected = Test.None.class) + public void whenApplicationStarted_thenEmbeddedDbFilesCreated() { + File dbFile = new File("src/main/resources/db/demodb.mv.db"); + System.out.println(dbFile.getAbsolutePath()); + + assertTrue(dbFile.exists()); + assertTrue(dbFile.isFile()); + } + + @AfterClass + public static void cleanUp() { + File dbFile = new File("src/main/resources/db/demodb.mv.db"); + dbFile.deleteOnExit(); + } +} From 67e2165bb6d35707a05dc18f477f342a732afec3 Mon Sep 17 00:00:00 2001 From: kwoyke Date: Fri, 2 Oct 2020 19:26:00 +0200 Subject: [PATCH 261/263] BAEL-4658: Upgrade to Cucumber 6.8.0 (#10121) --- spring-cucumber/pom.xml | 18 +++++++++--------- .../java/com/baeldung/BaeldungController.java | 6 ++---- .../java/com/baeldung/VersionController.java | 5 ++--- .../com/baeldung/CucumberIntegrationTest.java | 6 +++--- .../com/baeldung/SpringIntegrationTest.java | 4 ++-- .../com/baeldung/StepDefsIntegrationTest.java | 12 ++++++------ 6 files changed, 24 insertions(+), 27 deletions(-) diff --git a/spring-cucumber/pom.xml b/spring-cucumber/pom.xml index 245d10e77b..a945797ee1 100644 --- a/spring-cucumber/pom.xml +++ b/spring-cucumber/pom.xml @@ -21,27 +21,27 @@ spring-boot-starter-web - info.cukes + io.cucumber cucumber-core - ${cucumber.java.version} + ${cucumber.version} test - info.cukes + io.cucumber cucumber-java - ${cucumber.java.version} + ${cucumber.version} test - info.cukes + io.cucumber cucumber-junit - ${cucumber.java.version} + ${cucumber.version} test - info.cukes + io.cucumber cucumber-spring - ${cucumber.java.version} + ${cucumber.version} test @@ -53,7 +53,7 @@ - 1.2.5 + 6.8.0 1.3.2 diff --git a/spring-cucumber/src/main/java/com/baeldung/BaeldungController.java b/spring-cucumber/src/main/java/com/baeldung/BaeldungController.java index e74e773106..713c1022c5 100644 --- a/spring-cucumber/src/main/java/com/baeldung/BaeldungController.java +++ b/spring-cucumber/src/main/java/com/baeldung/BaeldungController.java @@ -4,18 +4,16 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RestController; -import javax.servlet.http.HttpServletResponse; - @RestController public class BaeldungController { @GetMapping("/hello") - public String sayHello(HttpServletResponse response) { + public String sayHello() { return "hello"; } @PostMapping("/baeldung") - public String sayHelloPost(HttpServletResponse response) { + public String sayHelloPost() { return "hello"; } } diff --git a/spring-cucumber/src/main/java/com/baeldung/VersionController.java b/spring-cucumber/src/main/java/com/baeldung/VersionController.java index f673f0e31f..e46ca64a01 100644 --- a/spring-cucumber/src/main/java/com/baeldung/VersionController.java +++ b/spring-cucumber/src/main/java/com/baeldung/VersionController.java @@ -1,13 +1,12 @@ package com.baeldung; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class VersionController { - @RequestMapping(method = { RequestMethod.GET }, value = { "/version" }) + @GetMapping("/version") public String getVersion() { return "1.0"; } diff --git a/spring-cucumber/src/test/java/com/baeldung/CucumberIntegrationTest.java b/spring-cucumber/src/test/java/com/baeldung/CucumberIntegrationTest.java index f48ab410ca..2077a28146 100644 --- a/spring-cucumber/src/test/java/com/baeldung/CucumberIntegrationTest.java +++ b/spring-cucumber/src/test/java/com/baeldung/CucumberIntegrationTest.java @@ -1,11 +1,11 @@ package com.baeldung; +import io.cucumber.junit.Cucumber; +import io.cucumber.junit.CucumberOptions; import org.junit.runner.RunWith; -import cucumber.api.CucumberOptions; -import cucumber.api.junit.Cucumber; @RunWith(Cucumber.class) @CucumberOptions(features = "src/test/resources") -public class CucumberIntegrationTest extends SpringIntegrationTest{ +public class CucumberIntegrationTest extends SpringIntegrationTest { } \ No newline at end of file diff --git a/spring-cucumber/src/test/java/com/baeldung/SpringIntegrationTest.java b/spring-cucumber/src/test/java/com/baeldung/SpringIntegrationTest.java index 8655a02469..7b5c4e21ff 100644 --- a/spring-cucumber/src/test/java/com/baeldung/SpringIntegrationTest.java +++ b/spring-cucumber/src/test/java/com/baeldung/SpringIntegrationTest.java @@ -4,6 +4,7 @@ import java.io.IOException; import java.util.HashMap; import java.util.Map; +import io.cucumber.spring.CucumberContextConfiguration; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; @@ -13,9 +14,8 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.web.client.ResponseErrorHandler; import org.springframework.web.client.RestTemplate; -//@RunWith(SpringJUnit4ClassRunner.class) +@CucumberContextConfiguration @SpringBootTest(classes = SpringDemoApplication.class, webEnvironment = WebEnvironment.DEFINED_PORT) -@ContextConfiguration public class SpringIntegrationTest { static ResponseResults latestResponse = null; diff --git a/spring-cucumber/src/test/java/com/baeldung/StepDefsIntegrationTest.java b/spring-cucumber/src/test/java/com/baeldung/StepDefsIntegrationTest.java index e1b6e370c7..9611e95dcf 100644 --- a/spring-cucumber/src/test/java/com/baeldung/StepDefsIntegrationTest.java +++ b/spring-cucumber/src/test/java/com/baeldung/StepDefsIntegrationTest.java @@ -1,14 +1,14 @@ package com.baeldung; +import io.cucumber.java.en.And; +import io.cucumber.java.en.Given; +import io.cucumber.java.en.Then; +import io.cucumber.java.en.When; +import org.springframework.http.HttpStatus; + import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; -import cucumber.api.java.en.Given; -import org.springframework.http.HttpStatus; - -import cucumber.api.java.en.And; -import cucumber.api.java.en.Then; -import cucumber.api.java.en.When; public class StepDefsIntegrationTest extends SpringIntegrationTest { From be481348409fb7b5b24f36417ffb9d3818f9c6f8 Mon Sep 17 00:00:00 2001 From: kwoyke Date: Fri, 2 Oct 2020 19:28:05 +0200 Subject: [PATCH 262/263] BAEL-4659: Upgrade Cucumber to 6.8.0 (#10115) --- testing-modules/rest-testing/pom.xml | 76 ++++++++----------- .../main/resources/karate/cucumber.feature | 10 --- .../cucumber/CucumberIntegrationTest.java | 4 +- .../rest/cucumber/StepDefinition.java | 11 +-- .../test/resources/Feature/cucumber.feature | 2 +- 5 files changed, 41 insertions(+), 62 deletions(-) delete mode 100644 testing-modules/rest-testing/src/main/resources/karate/cucumber.feature diff --git a/testing-modules/rest-testing/pom.xml b/testing-modules/rest-testing/pom.xml index 1e8a27afa5..b3966c1b6a 100644 --- a/testing-modules/rest-testing/pom.xml +++ b/testing-modules/rest-testing/pom.xml @@ -65,13 +65,13 @@ - info.cukes + io.cucumber cucumber-java ${cucumber.version} test - info.cukes + io.cucumber cucumber-junit ${cucumber.version} @@ -105,56 +105,44 @@ true - - - - maven-failsafe-plugin - ${maven-failsafe-plugin.version} - - classes - 4 - - - - - integration-test - verify - - - - - - com.github.temyers - cucumber-jvm-parallel-plugin - 5.0.0 - - - generateRunners - generate-test-sources - - generateRunners - - - - com.baeldung.rest.cucumber - - src/test/resources/Feature/ - SCENARIO - - - - - - + + + parallel + + + + maven-failsafe-plugin + ${maven-failsafe-plugin.version} + + + CucumberIntegrationTest.java + + methods + 2 + + + + + integration-test + verify + + + + + + + + + 19.0 2.9.0 - 1.2.5 + 6.8.0 2.21.0 0.6.1 diff --git a/testing-modules/rest-testing/src/main/resources/karate/cucumber.feature b/testing-modules/rest-testing/src/main/resources/karate/cucumber.feature deleted file mode 100644 index 99dd8249fe..0000000000 --- a/testing-modules/rest-testing/src/main/resources/karate/cucumber.feature +++ /dev/null @@ -1,10 +0,0 @@ -Feature: Testing a REST API - Users should be able to submit GET and POST requests to a web service, represented by WireMock - - Scenario: Data Upload to a web service - When users upload data on a project - Then the server should handle it and return a success status - - Scenario: Data retrieval from a web service - When users want to get information on the Cucumber project - Then the requested data is returned \ No newline at end of file diff --git a/testing-modules/rest-testing/src/test/java/com/baeldung/rest/cucumber/CucumberIntegrationTest.java b/testing-modules/rest-testing/src/test/java/com/baeldung/rest/cucumber/CucumberIntegrationTest.java index f80178a43d..33e2c62301 100644 --- a/testing-modules/rest-testing/src/test/java/com/baeldung/rest/cucumber/CucumberIntegrationTest.java +++ b/testing-modules/rest-testing/src/test/java/com/baeldung/rest/cucumber/CucumberIntegrationTest.java @@ -1,8 +1,8 @@ package com.baeldung.rest.cucumber; +import io.cucumber.junit.Cucumber; +import io.cucumber.junit.CucumberOptions; import org.junit.runner.RunWith; -import cucumber.api.CucumberOptions; -import cucumber.api.junit.Cucumber; @RunWith(Cucumber.class) @CucumberOptions(features = "classpath:Feature") diff --git a/testing-modules/rest-testing/src/test/java/com/baeldung/rest/cucumber/StepDefinition.java b/testing-modules/rest-testing/src/test/java/com/baeldung/rest/cucumber/StepDefinition.java index 35a913ae25..f1fcb48f01 100644 --- a/testing-modules/rest-testing/src/test/java/com/baeldung/rest/cucumber/StepDefinition.java +++ b/testing-modules/rest-testing/src/test/java/com/baeldung/rest/cucumber/StepDefinition.java @@ -20,6 +20,8 @@ import java.io.IOException; import java.io.InputStream; import java.util.Scanner; +import io.cucumber.java.en.Then; +import io.cucumber.java.en.When; import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; @@ -29,8 +31,6 @@ import org.apache.http.impl.client.HttpClients; import com.github.tomakehurst.wiremock.WireMockServer; -import cucumber.api.java.en.Then; -import cucumber.api.java.en.When; public class StepDefinition { @@ -66,7 +66,8 @@ public class StepDefinition { wireMockServer.stop(); } - @When("^users want to get information on the (.+) project$") +// @When("^users want to get information on the '(.+)' project$") + @When("users want to get information on the {string} project") public void usersGetInformationOnAProject(String projectName) throws IOException { wireMockServer.start(); @@ -86,11 +87,11 @@ public class StepDefinition { wireMockServer.stop(); } - @Then("^the server should handle it and return a success status$") + @Then("the server should handle it and return a success status") public void theServerShouldReturnASuccessStatus() { } - @Then("^the requested data is returned$") + @Then("the requested data is returned") public void theRequestedDataIsReturned() { } diff --git a/testing-modules/rest-testing/src/test/resources/Feature/cucumber.feature b/testing-modules/rest-testing/src/test/resources/Feature/cucumber.feature index 99dd8249fe..f8bbd809de 100644 --- a/testing-modules/rest-testing/src/test/resources/Feature/cucumber.feature +++ b/testing-modules/rest-testing/src/test/resources/Feature/cucumber.feature @@ -6,5 +6,5 @@ Feature: Testing a REST API Then the server should handle it and return a success status Scenario: Data retrieval from a web service - When users want to get information on the Cucumber project + When users want to get information on the 'Cucumber' project Then the requested data is returned \ No newline at end of file From d48defc3e223c176e41e6f8b7b161ac313b9db8d Mon Sep 17 00:00:00 2001 From: Umang Budhwar Date: Sat, 3 Oct 2020 08:28:12 +0530 Subject: [PATCH 263/263] BAEL-4531 (#10093) * Added code for checking if a class is abstract or not. * Renamed test name as per review comments. --- .../check/abstractclass/AbstractExample.java | 15 +++++++++++++++ .../abstractclass/AbstractExampleUnitTest.java | 16 ++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 core-java-modules/core-java-reflection-2/src/main/java/com/baeldung/reflection/check/abstractclass/AbstractExample.java create mode 100644 core-java-modules/core-java-reflection-2/src/test/java/com/baeldung/reflection/check/abstractclass/AbstractExampleUnitTest.java diff --git a/core-java-modules/core-java-reflection-2/src/main/java/com/baeldung/reflection/check/abstractclass/AbstractExample.java b/core-java-modules/core-java-reflection-2/src/main/java/com/baeldung/reflection/check/abstractclass/AbstractExample.java new file mode 100644 index 0000000000..e8ad3bc3bd --- /dev/null +++ b/core-java-modules/core-java-reflection-2/src/main/java/com/baeldung/reflection/check/abstractclass/AbstractExample.java @@ -0,0 +1,15 @@ +package com.baeldung.reflection.check.abstractclass; + +import java.time.LocalDate; +import java.time.LocalTime; + +public abstract class AbstractExample { + + public static String getAuthorName() { + return "Umang Budhwar"; + } + + public abstract LocalDate getLocalDate(); + + public abstract LocalTime getLocalTime(); +} diff --git a/core-java-modules/core-java-reflection-2/src/test/java/com/baeldung/reflection/check/abstractclass/AbstractExampleUnitTest.java b/core-java-modules/core-java-reflection-2/src/test/java/com/baeldung/reflection/check/abstractclass/AbstractExampleUnitTest.java new file mode 100644 index 0000000000..cb5d927c23 --- /dev/null +++ b/core-java-modules/core-java-reflection-2/src/test/java/com/baeldung/reflection/check/abstractclass/AbstractExampleUnitTest.java @@ -0,0 +1,16 @@ +package com.baeldung.reflection.check.abstractclass; + +import java.lang.reflect.Modifier; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class AbstractExampleUnitTest { + + @Test + void givenAbstractClass_whenCheckModifierIsAbstract_thenTrue() throws Exception { + Class clazz = AbstractExample.class; + Assertions.assertTrue(Modifier.isAbstract(clazz.getModifiers())); + } + +}