From 60acc2fd1dd106df1608455c73b6288b8b97291d Mon Sep 17 00:00:00 2001 From: lor6 Date: Wed, 20 Sep 2017 09:46:21 +0300 Subject: [PATCH 01/10] linkrest ex (#2647) --- linkrest/WebContent/META-INF/MANIFEST.MF | 3 + linkrest/WebContent/WEB-INF/web.xml | 20 +++++ linkrest/pom.xml | 81 +++++++++++++++++++ .../com/baeldung/LinkRestApplication.java | 24 ++++++ .../java/com/baeldung/cayenne/Department.java | 9 +++ .../java/com/baeldung/cayenne/Employee.java | 9 +++ .../baeldung/cayenne/auto/_Department.java | 44 ++++++++++ .../com/baeldung/cayenne/auto/_Employee.java | 39 +++++++++ .../linkrest/apis/DepartmentResource.java | 58 +++++++++++++ .../linkrest/apis/EmployeeSubResource.java | 65 +++++++++++++++ .../resources/cayenne-linkrest-project.xml | 17 ++++ linkrest/src/main/resources/linkrest.map.xml | 29 +++++++ pom.xml | 3 +- 13 files changed, 400 insertions(+), 1 deletion(-) create mode 100644 linkrest/WebContent/META-INF/MANIFEST.MF create mode 100644 linkrest/WebContent/WEB-INF/web.xml create mode 100644 linkrest/pom.xml create mode 100644 linkrest/src/main/java/com/baeldung/LinkRestApplication.java create mode 100644 linkrest/src/main/java/com/baeldung/cayenne/Department.java create mode 100644 linkrest/src/main/java/com/baeldung/cayenne/Employee.java create mode 100644 linkrest/src/main/java/com/baeldung/cayenne/auto/_Department.java create mode 100644 linkrest/src/main/java/com/baeldung/cayenne/auto/_Employee.java create mode 100644 linkrest/src/main/java/com/baeldung/linkrest/apis/DepartmentResource.java create mode 100644 linkrest/src/main/java/com/baeldung/linkrest/apis/EmployeeSubResource.java create mode 100644 linkrest/src/main/resources/cayenne-linkrest-project.xml create mode 100644 linkrest/src/main/resources/linkrest.map.xml diff --git a/linkrest/WebContent/META-INF/MANIFEST.MF b/linkrest/WebContent/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..254272e1c0 --- /dev/null +++ b/linkrest/WebContent/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/linkrest/WebContent/WEB-INF/web.xml b/linkrest/WebContent/WEB-INF/web.xml new file mode 100644 index 0000000000..046c82b08a --- /dev/null +++ b/linkrest/WebContent/WEB-INF/web.xml @@ -0,0 +1,20 @@ + + + linkrest + + linkrest + org.glassfish.jersey.servlet.ServletContainer + + javax.ws.rs.Application + com.baeldung.LinkRestApplication + + 1 + + + linkrest + /* + + \ No newline at end of file diff --git a/linkrest/pom.xml b/linkrest/pom.xml new file mode 100644 index 0000000000..aa2f0f8bda --- /dev/null +++ b/linkrest/pom.xml @@ -0,0 +1,81 @@ + + 4.0.0 + com.baeldung + linkrest + 0.0.1-SNAPSHOT + war + + + + com.nhl.link.rest + link-rest + ${linkrest.version} + + + org.glassfish.jersey.containers + jersey-container-servlet + ${jersey.version} + + + org.glassfish.jersey.media + jersey-media-moxy + ${jersey.version} + + + com.h2database + h2 + ${h2.version} + + + + + + + maven-compiler-plugin + 3.5 + + 1.8 + 1.8 + + + + maven-war-plugin + 2.6 + + WebContent + false + + + + org.apache.cayenne.plugins + cayenne-maven-plugin + ${cayenne.version} + + + ${project.basedir}/src/main/resources/linkrest.map.xml + + + + + + cgen + + + + + + org.apache.cayenne.plugins + cayenne-modeler-maven-plugin + ${cayenne.version} + + + + + + 2.9 + 4.0.B1 + 1.4.196 + 2.25.1 + + \ No newline at end of file diff --git a/linkrest/src/main/java/com/baeldung/LinkRestApplication.java b/linkrest/src/main/java/com/baeldung/LinkRestApplication.java new file mode 100644 index 0000000000..7a2f7c8903 --- /dev/null +++ b/linkrest/src/main/java/com/baeldung/LinkRestApplication.java @@ -0,0 +1,24 @@ +package com.baeldung; + + +import javax.ws.rs.ApplicationPath; + +import org.apache.cayenne.configuration.server.ServerRuntime; +import org.glassfish.jersey.server.ResourceConfig; + +import com.nhl.link.rest.runtime.LinkRestBuilder; +import com.nhl.link.rest.runtime.LinkRestRuntime; + +@ApplicationPath("/linkrest") +public class LinkRestApplication extends ResourceConfig { + + public LinkRestApplication() { + ServerRuntime cayenneRuntime = ServerRuntime.builder() + .addConfig("cayenne-linkrest-project.xml") + .build(); + LinkRestRuntime lrRuntime = LinkRestBuilder.build(cayenneRuntime); + super.register(lrRuntime); + packages("com.baeldung.linkrest.apis"); + } + +} diff --git a/linkrest/src/main/java/com/baeldung/cayenne/Department.java b/linkrest/src/main/java/com/baeldung/cayenne/Department.java new file mode 100644 index 0000000000..ed7a2bd795 --- /dev/null +++ b/linkrest/src/main/java/com/baeldung/cayenne/Department.java @@ -0,0 +1,9 @@ +package com.baeldung.cayenne; + +import com.baeldung.cayenne.auto._Department; + +public class Department extends _Department { + + private static final long serialVersionUID = 1L; + +} diff --git a/linkrest/src/main/java/com/baeldung/cayenne/Employee.java b/linkrest/src/main/java/com/baeldung/cayenne/Employee.java new file mode 100644 index 0000000000..632ea4fbf9 --- /dev/null +++ b/linkrest/src/main/java/com/baeldung/cayenne/Employee.java @@ -0,0 +1,9 @@ +package com.baeldung.cayenne; + +import com.baeldung.cayenne.auto._Employee; + +public class Employee extends _Employee { + + private static final long serialVersionUID = 1L; + +} diff --git a/linkrest/src/main/java/com/baeldung/cayenne/auto/_Department.java b/linkrest/src/main/java/com/baeldung/cayenne/auto/_Department.java new file mode 100644 index 0000000000..4111a8c8b2 --- /dev/null +++ b/linkrest/src/main/java/com/baeldung/cayenne/auto/_Department.java @@ -0,0 +1,44 @@ +package com.baeldung.cayenne.auto; + +import java.util.List; + +import org.apache.cayenne.CayenneDataObject; +import org.apache.cayenne.exp.Property; + +import com.baeldung.cayenne.Employee; + +/** + * Class _Department was generated by Cayenne. + * It is probably a good idea to avoid changing this class manually, + * since it may be overwritten next time code is regenerated. + * If you need to make any customizations, please use subclass. + */ +public abstract class _Department extends CayenneDataObject { + + private static final long serialVersionUID = 1L; + + public static final String DEP_ID_PK_COLUMN = "dep_id"; + + public static final Property NAME = Property.create("name", String.class); + public static final Property> EMPLOYEES = Property.create("employees", List.class); + + public void setName(String name) { + writeProperty("name", name); + } + public String getName() { + return (String)readProperty("name"); + } + + public void addToEmployees(Employee obj) { + addToManyTarget("employees", obj, true); + } + public void removeFromEmployees(Employee obj) { + removeToManyTarget("employees", obj, true); + } + @SuppressWarnings("unchecked") + public List getEmployees() { + return (List)readProperty("employees"); + } + + +} diff --git a/linkrest/src/main/java/com/baeldung/cayenne/auto/_Employee.java b/linkrest/src/main/java/com/baeldung/cayenne/auto/_Employee.java new file mode 100644 index 0000000000..50e1880a56 --- /dev/null +++ b/linkrest/src/main/java/com/baeldung/cayenne/auto/_Employee.java @@ -0,0 +1,39 @@ +package com.baeldung.cayenne.auto; + +import org.apache.cayenne.CayenneDataObject; +import org.apache.cayenne.exp.Property; + +import com.baeldung.cayenne.Department; + +/** + * Class _Employee was generated by Cayenne. + * It is probably a good idea to avoid changing this class manually, + * since it may be overwritten next time code is regenerated. + * If you need to make any customizations, please use subclass. + */ +public abstract class _Employee extends CayenneDataObject { + + private static final long serialVersionUID = 1L; + + public static final String EMP_ID_PK_COLUMN = "emp_id"; + + public static final Property NAME = Property.create("name", String.class); + public static final Property DEPARTMENT = Property.create("department", Department.class); + + public void setName(String name) { + writeProperty("name", name); + } + public String getName() { + return (String)readProperty("name"); + } + + public void setDepartment(Department department) { + setToOneTarget("department", department, true); + } + + public Department getDepartment() { + return (Department)readProperty("department"); + } + + +} diff --git a/linkrest/src/main/java/com/baeldung/linkrest/apis/DepartmentResource.java b/linkrest/src/main/java/com/baeldung/linkrest/apis/DepartmentResource.java new file mode 100644 index 0000000000..f4090b580e --- /dev/null +++ b/linkrest/src/main/java/com/baeldung/linkrest/apis/DepartmentResource.java @@ -0,0 +1,58 @@ +package com.baeldung.linkrest.apis; + +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Configuration; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; + +import com.baeldung.cayenne.Department; +import com.nhl.link.rest.DataResponse; +import com.nhl.link.rest.LinkRest; +import com.nhl.link.rest.SimpleResponse; + +@Path("department") +@Produces(MediaType.APPLICATION_JSON) +public class DepartmentResource { + + @Context + private Configuration config; + + @GET + public DataResponse getAll(@Context UriInfo uriInfo) { + return LinkRest.select(Department.class, config).uri(uriInfo).get(); + } + + @GET + @Path("{id}") + public DataResponse getOne(@PathParam("id") int id, @Context UriInfo uriInfo) { + return LinkRest.select(Department.class, config).byId(id).uri(uriInfo).getOne(); + } + + @POST + public SimpleResponse create(String data) { + return LinkRest.create(Department.class, config).sync(data); + } + + @PUT + public SimpleResponse createOrUpdate(String data) { + return LinkRest.createOrUpdate(Department.class, config).sync(data); + } + + @Path("{id}/employees") + public EmployeeSubResource getEmployees(@PathParam("id") int id, @Context UriInfo uriInfo) { + return new EmployeeSubResource(id, config); + } + + @DELETE + @Path("{id}") + public SimpleResponse delete(@PathParam("id") int id) { + return LinkRest.delete(Department.class, config).id(id).delete(); + } +} diff --git a/linkrest/src/main/java/com/baeldung/linkrest/apis/EmployeeSubResource.java b/linkrest/src/main/java/com/baeldung/linkrest/apis/EmployeeSubResource.java new file mode 100644 index 0000000000..ba9c3759bb --- /dev/null +++ b/linkrest/src/main/java/com/baeldung/linkrest/apis/EmployeeSubResource.java @@ -0,0 +1,65 @@ +package com.baeldung.linkrest.apis; + +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Configuration; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; + +import com.baeldung.cayenne.Department; +import com.baeldung.cayenne.Employee; +import com.nhl.link.rest.DataResponse; +import com.nhl.link.rest.LinkRest; +import com.nhl.link.rest.SimpleResponse; + +@Produces(MediaType.APPLICATION_JSON) +public class EmployeeSubResource { + + private Configuration config; + + private int departmentId; + + public EmployeeSubResource(int departmentId, Configuration config) { + this.departmentId = departmentId; + this.config = config; + } + + public EmployeeSubResource() { + } + + @GET + public DataResponse getAll(@Context UriInfo uriInfo) { + return LinkRest.select(Employee.class, config).toManyParent(Department.class, departmentId, Department.EMPLOYEES).uri(uriInfo).get(); + } + + @GET + @Path("{id}") + public DataResponse getOne(@PathParam("id") int id, @Context UriInfo uriInfo) { + return LinkRest.select(Employee.class, config).toManyParent(Department.class, departmentId, Department.EMPLOYEES).byId(id).uri(uriInfo).getOne(); + } + + @POST + public SimpleResponse create(String data) { + + return LinkRest.create(Employee.class, config).toManyParent(Department.class, departmentId, Department.EMPLOYEES).sync(data); + } + + @PUT + public SimpleResponse createOrUpdate(String data) { + return LinkRest.create(Employee.class, config).toManyParent(Department.class, departmentId, Department.EMPLOYEES).sync(data); + } + + @DELETE + @Path("{id}") + public SimpleResponse delete(@PathParam("id") int id) { + return LinkRest.delete(Employee.class, config).toManyParent(Department.class, departmentId, Department.EMPLOYEES).id(id).delete(); + + } + +} diff --git a/linkrest/src/main/resources/cayenne-linkrest-project.xml b/linkrest/src/main/resources/cayenne-linkrest-project.xml new file mode 100644 index 0000000000..8a4ba39c4d --- /dev/null +++ b/linkrest/src/main/resources/cayenne-linkrest-project.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + diff --git a/linkrest/src/main/resources/linkrest.map.xml b/linkrest/src/main/resources/linkrest.map.xml new file mode 100644 index 0000000000..105d7d9d14 --- /dev/null +++ b/linkrest/src/main/resources/linkrest.map.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pom.xml b/pom.xml index fac746f7df..015efbab05 100644 --- a/pom.xml +++ b/pom.xml @@ -97,7 +97,8 @@ jws libraries - libraries-data + libraries-data + linkrest log-mdc log4j log4j2 From 771ded6b03bb86690b18a578b1d8856847bcab7f Mon Sep 17 00:00:00 2001 From: KevinGilmore Date: Wed, 20 Sep 2017 07:03:20 -0500 Subject: [PATCH 02/10] BAEL-1069 update README (#2648) * BAEL-973: updated README * BAEL-1069: Updated README --- core-java/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java/README.md b/core-java/README.md index 0f0e4cc858..a251de1daa 100644 --- a/core-java/README.md +++ b/core-java/README.md @@ -106,3 +106,4 @@ - [Converting a List to String in Java](http://www.baeldung.com/java-list-to-string) - [CharSequence vs. String in Java](http://www.baeldung.com/java-char-sequence-string) - [Period and Duration in Java](http://www.baeldung.com/java-period-duration) +- [Guide to the Diamond Operator in Java](http://www.baeldung.com/java-diamond-operator) \ No newline at end of file From 01dddf49c0a2545f4477d8d220add3c5849e2fb0 Mon Sep 17 00:00:00 2001 From: ahmetcetin39 <30636222+ahmetcetin39@users.noreply.github.com> Date: Wed, 20 Sep 2017 16:54:10 +0300 Subject: [PATCH 03/10] BAEL-1088 / fix / RequestMapping is replaced with GetMapping (#2640) * RequestMapping is replaced with GetMapping * Update PassParametersController.java --- .../controller/PassParametersController.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/spring-all/src/main/java/org/baeldung/controller/controller/PassParametersController.java b/spring-all/src/main/java/org/baeldung/controller/controller/PassParametersController.java index 54047cedf3..c282ae6a62 100644 --- a/spring-all/src/main/java/org/baeldung/controller/controller/PassParametersController.java +++ b/spring-all/src/main/java/org/baeldung/controller/controller/PassParametersController.java @@ -3,8 +3,7 @@ package org.baeldung.controller.controller; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.ui.ModelMap; -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.servlet.ModelAndView; /** @@ -16,23 +15,23 @@ import org.springframework.web.servlet.ModelAndView; */ @Controller public class PassParametersController { - @RequestMapping(value = "/showViewPage", method = RequestMethod.GET) + @GetMapping("/showViewPage") public String passParametersWithModel(Model model) { model.addAttribute("message", "Baeldung"); return "viewPage"; } - @RequestMapping(value = "/printViewPage", method = RequestMethod.GET) + @GetMapping("/printViewPage") public String passParametersWithModelMap(ModelMap map) { map.addAttribute("welcomeMessage", "welcome"); map.addAttribute("message", "Baeldung"); return "viewPage"; } - @RequestMapping(value = "/goToViewPage", method = RequestMethod.GET) + @GetMapping("/goToViewPage") public ModelAndView passParametersWithModelAndView() { ModelAndView modelAndView = new ModelAndView("viewPage"); modelAndView.addObject("message", "Baeldung"); return modelAndView; } -} \ No newline at end of file +} From 1852438f6afd4ac5b89b589e3e7eb2a7f2a0a9b6 Mon Sep 17 00:00:00 2001 From: Doha2012 Date: Wed, 20 Sep 2017 16:15:22 +0200 Subject: [PATCH 04/10] rename kotlin to core-kotlin (#2651) * fix spring config * fix spring config * fix spring config * minor fix * fix spring-boot module * fix pom * upgrade jackson * minor fix * java concurrency * cleanup * fix conflict * java 8 * clean up * add core-java-8 to main pom * rename kotlin to core-kotlin --- {kotlin => core-kotlin}/README.md | 0 {kotlin => core-kotlin}/pom.xml | 2 +- .../src/main/java/com/baeldung/dataclass/Movie.java | 0 .../src/main/java/com/baeldung/java/ArrayExample.java | 0 .../src/main/java/com/baeldung/java/Customer.java | 0 .../src/main/java/com/baeldung/java/StringUtils.java | 0 .../java/com/baeldung/lazy/ClassWithHeavyInitialization.java | 0 .../src/main/kotlin/com/baeldung/dataclass/Movie.kt | 0 .../src/main/kotlin/com/baeldung/dataclass/Sandbox.kt | 0 .../kotlin/com/baeldung/destructuringdeclarations/Person.kt | 0 .../kotlin/com/baeldung/destructuringdeclarations/Result.kt | 0 .../kotlin/com/baeldung/destructuringdeclarations/Sandbox.kt | 0 .../src/main/kotlin/com/baeldung/kotlin/Example1.kt | 0 .../src/main/kotlin/com/baeldung/kotlin/Item.kt | 0 .../src/main/kotlin/com/baeldung/kotlin/ItemService.kt | 0 .../src/main/kotlin/com/baeldung/kotlin/JvmSample.kt | 0 .../src/main/kotlin/com/baeldung/kotlin/ListExtension.kt | 0 .../main/kotlin/com/baeldung/kotlin/MathematicsOperations.kt | 0 .../src/main/kotlin/com/baeldung/kotlin/Sealed.kt | 0 .../src/main/kotlin/com/baeldung/kotlin/User.kt | 0 .../src/main/kotlin/com/baeldung/kotlin/WhenBlockTypes.kt | 0 .../src/main/kotlin/com/baeldung/kotlin/delegates/Database.kt | 0 .../kotlin/com/baeldung/kotlin/delegates/DatabaseDelegate.kt | 0 .../src/main/kotlin/com/baeldung/kotlin/delegates/User.kt | 0 .../src/main/kotlin/com/baeldung/kotlin/mockito/BookService.kt | 0 .../main/kotlin/com/baeldung/kotlin/mockito/LendBookManager.kt | 0 .../test/java/com/baeldung/kotlin/JavaCallToKotlinUnitTest.java | 0 .../src/test/java/com/baeldung/kotlin/LazyJavaUnitTest.java | 0 .../src/test/kotlin/com/baeldung/kotlin/ArrayTest.kt | 0 .../src/test/kotlin/com/baeldung/kotlin/CollectionsTest.kt | 0 .../src/test/kotlin/com/baeldung/kotlin/CoroutinesTest.kt | 0 .../src/test/kotlin/com/baeldung/kotlin/CustomerTest.kt | 0 .../src/test/kotlin/com/baeldung/kotlin/EqualityTest.kt | 0 .../src/test/kotlin/com/baeldung/kotlin/GenericsTest.kt | 0 .../src/test/kotlin/com/baeldung/kotlin/ItemServiceTest.kt | 0 .../src/test/kotlin/com/baeldung/kotlin/JvmSampleTest.kt | 0 .../com/baeldung/kotlin/KotlinJavaInteroperabilityTest.kt | 0 .../src/test/kotlin/com/baeldung/kotlin/LambdaTest.kt | 0 .../src/test/kotlin/com/baeldung/kotlin/LazyUnitTest.kt | 0 .../src/test/kotlin/com/baeldung/kotlin/ListExtensionTest.kt | 0 .../src/test/kotlin/com/baeldung/kotlin/ListToMapTest.kt | 0 .../src/test/kotlin/com/baeldung/kotlin/NullSafetyTest.kt | 0 .../src/test/kotlin/com/baeldung/kotlin/SealedTest.kt | 0 .../src/test/kotlin/com/baeldung/kotlin/WhenBlockUnitTest.kt | 0 .../com/baeldung/kotlin/delegates/DatabaseDelegatesTest.kt | 0 .../kotlin/com/baeldung/kotlin/mockito/LendBookManagerTest.kt | 0 .../baeldung/kotlin/mockito/LendBookManagerTestMockitoKotlin.kt | 0 47 files changed, 1 insertion(+), 1 deletion(-) rename {kotlin => core-kotlin}/README.md (100%) rename {kotlin => core-kotlin}/pom.xml (99%) rename {kotlin => core-kotlin}/src/main/java/com/baeldung/dataclass/Movie.java (100%) rename {kotlin => core-kotlin}/src/main/java/com/baeldung/java/ArrayExample.java (100%) rename {kotlin => core-kotlin}/src/main/java/com/baeldung/java/Customer.java (100%) rename {kotlin => core-kotlin}/src/main/java/com/baeldung/java/StringUtils.java (100%) rename {kotlin => core-kotlin}/src/main/java/com/baeldung/lazy/ClassWithHeavyInitialization.java (100%) rename {kotlin => core-kotlin}/src/main/kotlin/com/baeldung/dataclass/Movie.kt (100%) rename {kotlin => core-kotlin}/src/main/kotlin/com/baeldung/dataclass/Sandbox.kt (100%) rename {kotlin => core-kotlin}/src/main/kotlin/com/baeldung/destructuringdeclarations/Person.kt (100%) rename {kotlin => core-kotlin}/src/main/kotlin/com/baeldung/destructuringdeclarations/Result.kt (100%) rename {kotlin => core-kotlin}/src/main/kotlin/com/baeldung/destructuringdeclarations/Sandbox.kt (100%) rename {kotlin => core-kotlin}/src/main/kotlin/com/baeldung/kotlin/Example1.kt (100%) rename {kotlin => core-kotlin}/src/main/kotlin/com/baeldung/kotlin/Item.kt (100%) rename {kotlin => core-kotlin}/src/main/kotlin/com/baeldung/kotlin/ItemService.kt (100%) rename {kotlin => core-kotlin}/src/main/kotlin/com/baeldung/kotlin/JvmSample.kt (100%) rename {kotlin => core-kotlin}/src/main/kotlin/com/baeldung/kotlin/ListExtension.kt (100%) rename {kotlin => core-kotlin}/src/main/kotlin/com/baeldung/kotlin/MathematicsOperations.kt (100%) rename {kotlin => core-kotlin}/src/main/kotlin/com/baeldung/kotlin/Sealed.kt (100%) rename {kotlin => core-kotlin}/src/main/kotlin/com/baeldung/kotlin/User.kt (100%) rename {kotlin => core-kotlin}/src/main/kotlin/com/baeldung/kotlin/WhenBlockTypes.kt (100%) rename {kotlin => core-kotlin}/src/main/kotlin/com/baeldung/kotlin/delegates/Database.kt (100%) rename {kotlin => core-kotlin}/src/main/kotlin/com/baeldung/kotlin/delegates/DatabaseDelegate.kt (100%) rename {kotlin => core-kotlin}/src/main/kotlin/com/baeldung/kotlin/delegates/User.kt (100%) rename {kotlin => core-kotlin}/src/main/kotlin/com/baeldung/kotlin/mockito/BookService.kt (100%) rename {kotlin => core-kotlin}/src/main/kotlin/com/baeldung/kotlin/mockito/LendBookManager.kt (100%) rename {kotlin => core-kotlin}/src/test/java/com/baeldung/kotlin/JavaCallToKotlinUnitTest.java (100%) rename {kotlin => core-kotlin}/src/test/java/com/baeldung/kotlin/LazyJavaUnitTest.java (100%) rename {kotlin => core-kotlin}/src/test/kotlin/com/baeldung/kotlin/ArrayTest.kt (100%) rename {kotlin => core-kotlin}/src/test/kotlin/com/baeldung/kotlin/CollectionsTest.kt (100%) rename {kotlin => core-kotlin}/src/test/kotlin/com/baeldung/kotlin/CoroutinesTest.kt (100%) rename {kotlin => core-kotlin}/src/test/kotlin/com/baeldung/kotlin/CustomerTest.kt (100%) rename {kotlin => core-kotlin}/src/test/kotlin/com/baeldung/kotlin/EqualityTest.kt (100%) rename {kotlin => core-kotlin}/src/test/kotlin/com/baeldung/kotlin/GenericsTest.kt (100%) rename {kotlin => core-kotlin}/src/test/kotlin/com/baeldung/kotlin/ItemServiceTest.kt (100%) rename {kotlin => core-kotlin}/src/test/kotlin/com/baeldung/kotlin/JvmSampleTest.kt (100%) rename {kotlin => core-kotlin}/src/test/kotlin/com/baeldung/kotlin/KotlinJavaInteroperabilityTest.kt (100%) rename {kotlin => core-kotlin}/src/test/kotlin/com/baeldung/kotlin/LambdaTest.kt (100%) rename {kotlin => core-kotlin}/src/test/kotlin/com/baeldung/kotlin/LazyUnitTest.kt (100%) rename {kotlin => core-kotlin}/src/test/kotlin/com/baeldung/kotlin/ListExtensionTest.kt (100%) rename {kotlin => core-kotlin}/src/test/kotlin/com/baeldung/kotlin/ListToMapTest.kt (100%) rename {kotlin => core-kotlin}/src/test/kotlin/com/baeldung/kotlin/NullSafetyTest.kt (100%) rename {kotlin => core-kotlin}/src/test/kotlin/com/baeldung/kotlin/SealedTest.kt (100%) rename {kotlin => core-kotlin}/src/test/kotlin/com/baeldung/kotlin/WhenBlockUnitTest.kt (100%) rename {kotlin => core-kotlin}/src/test/kotlin/com/baeldung/kotlin/delegates/DatabaseDelegatesTest.kt (100%) rename {kotlin => core-kotlin}/src/test/kotlin/com/baeldung/kotlin/mockito/LendBookManagerTest.kt (100%) rename {kotlin => core-kotlin}/src/test/kotlin/com/baeldung/kotlin/mockito/LendBookManagerTestMockitoKotlin.kt (100%) diff --git a/kotlin/README.md b/core-kotlin/README.md similarity index 100% rename from kotlin/README.md rename to core-kotlin/README.md diff --git a/kotlin/pom.xml b/core-kotlin/pom.xml similarity index 99% rename from kotlin/pom.xml rename to core-kotlin/pom.xml index e88013ab69..856a37ded0 100644 --- a/kotlin/pom.xml +++ b/core-kotlin/pom.xml @@ -3,7 +3,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - kotlin + core-kotlin 1.0-SNAPSHOT diff --git a/kotlin/src/main/java/com/baeldung/dataclass/Movie.java b/core-kotlin/src/main/java/com/baeldung/dataclass/Movie.java similarity index 100% rename from kotlin/src/main/java/com/baeldung/dataclass/Movie.java rename to core-kotlin/src/main/java/com/baeldung/dataclass/Movie.java diff --git a/kotlin/src/main/java/com/baeldung/java/ArrayExample.java b/core-kotlin/src/main/java/com/baeldung/java/ArrayExample.java similarity index 100% rename from kotlin/src/main/java/com/baeldung/java/ArrayExample.java rename to core-kotlin/src/main/java/com/baeldung/java/ArrayExample.java diff --git a/kotlin/src/main/java/com/baeldung/java/Customer.java b/core-kotlin/src/main/java/com/baeldung/java/Customer.java similarity index 100% rename from kotlin/src/main/java/com/baeldung/java/Customer.java rename to core-kotlin/src/main/java/com/baeldung/java/Customer.java diff --git a/kotlin/src/main/java/com/baeldung/java/StringUtils.java b/core-kotlin/src/main/java/com/baeldung/java/StringUtils.java similarity index 100% rename from kotlin/src/main/java/com/baeldung/java/StringUtils.java rename to core-kotlin/src/main/java/com/baeldung/java/StringUtils.java diff --git a/kotlin/src/main/java/com/baeldung/lazy/ClassWithHeavyInitialization.java b/core-kotlin/src/main/java/com/baeldung/lazy/ClassWithHeavyInitialization.java similarity index 100% rename from kotlin/src/main/java/com/baeldung/lazy/ClassWithHeavyInitialization.java rename to core-kotlin/src/main/java/com/baeldung/lazy/ClassWithHeavyInitialization.java diff --git a/kotlin/src/main/kotlin/com/baeldung/dataclass/Movie.kt b/core-kotlin/src/main/kotlin/com/baeldung/dataclass/Movie.kt similarity index 100% rename from kotlin/src/main/kotlin/com/baeldung/dataclass/Movie.kt rename to core-kotlin/src/main/kotlin/com/baeldung/dataclass/Movie.kt diff --git a/kotlin/src/main/kotlin/com/baeldung/dataclass/Sandbox.kt b/core-kotlin/src/main/kotlin/com/baeldung/dataclass/Sandbox.kt similarity index 100% rename from kotlin/src/main/kotlin/com/baeldung/dataclass/Sandbox.kt rename to core-kotlin/src/main/kotlin/com/baeldung/dataclass/Sandbox.kt diff --git a/kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Person.kt b/core-kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Person.kt similarity index 100% rename from kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Person.kt rename to core-kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Person.kt diff --git a/kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Result.kt b/core-kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Result.kt similarity index 100% rename from kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Result.kt rename to core-kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Result.kt diff --git a/kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Sandbox.kt b/core-kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Sandbox.kt similarity index 100% rename from kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Sandbox.kt rename to core-kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Sandbox.kt diff --git a/kotlin/src/main/kotlin/com/baeldung/kotlin/Example1.kt b/core-kotlin/src/main/kotlin/com/baeldung/kotlin/Example1.kt similarity index 100% rename from kotlin/src/main/kotlin/com/baeldung/kotlin/Example1.kt rename to core-kotlin/src/main/kotlin/com/baeldung/kotlin/Example1.kt diff --git a/kotlin/src/main/kotlin/com/baeldung/kotlin/Item.kt b/core-kotlin/src/main/kotlin/com/baeldung/kotlin/Item.kt similarity index 100% rename from kotlin/src/main/kotlin/com/baeldung/kotlin/Item.kt rename to core-kotlin/src/main/kotlin/com/baeldung/kotlin/Item.kt diff --git a/kotlin/src/main/kotlin/com/baeldung/kotlin/ItemService.kt b/core-kotlin/src/main/kotlin/com/baeldung/kotlin/ItemService.kt similarity index 100% rename from kotlin/src/main/kotlin/com/baeldung/kotlin/ItemService.kt rename to core-kotlin/src/main/kotlin/com/baeldung/kotlin/ItemService.kt diff --git a/kotlin/src/main/kotlin/com/baeldung/kotlin/JvmSample.kt b/core-kotlin/src/main/kotlin/com/baeldung/kotlin/JvmSample.kt similarity index 100% rename from kotlin/src/main/kotlin/com/baeldung/kotlin/JvmSample.kt rename to core-kotlin/src/main/kotlin/com/baeldung/kotlin/JvmSample.kt diff --git a/kotlin/src/main/kotlin/com/baeldung/kotlin/ListExtension.kt b/core-kotlin/src/main/kotlin/com/baeldung/kotlin/ListExtension.kt similarity index 100% rename from kotlin/src/main/kotlin/com/baeldung/kotlin/ListExtension.kt rename to core-kotlin/src/main/kotlin/com/baeldung/kotlin/ListExtension.kt diff --git a/kotlin/src/main/kotlin/com/baeldung/kotlin/MathematicsOperations.kt b/core-kotlin/src/main/kotlin/com/baeldung/kotlin/MathematicsOperations.kt similarity index 100% rename from kotlin/src/main/kotlin/com/baeldung/kotlin/MathematicsOperations.kt rename to core-kotlin/src/main/kotlin/com/baeldung/kotlin/MathematicsOperations.kt diff --git a/kotlin/src/main/kotlin/com/baeldung/kotlin/Sealed.kt b/core-kotlin/src/main/kotlin/com/baeldung/kotlin/Sealed.kt similarity index 100% rename from kotlin/src/main/kotlin/com/baeldung/kotlin/Sealed.kt rename to core-kotlin/src/main/kotlin/com/baeldung/kotlin/Sealed.kt diff --git a/kotlin/src/main/kotlin/com/baeldung/kotlin/User.kt b/core-kotlin/src/main/kotlin/com/baeldung/kotlin/User.kt similarity index 100% rename from kotlin/src/main/kotlin/com/baeldung/kotlin/User.kt rename to core-kotlin/src/main/kotlin/com/baeldung/kotlin/User.kt diff --git a/kotlin/src/main/kotlin/com/baeldung/kotlin/WhenBlockTypes.kt b/core-kotlin/src/main/kotlin/com/baeldung/kotlin/WhenBlockTypes.kt similarity index 100% rename from kotlin/src/main/kotlin/com/baeldung/kotlin/WhenBlockTypes.kt rename to core-kotlin/src/main/kotlin/com/baeldung/kotlin/WhenBlockTypes.kt diff --git a/kotlin/src/main/kotlin/com/baeldung/kotlin/delegates/Database.kt b/core-kotlin/src/main/kotlin/com/baeldung/kotlin/delegates/Database.kt similarity index 100% rename from kotlin/src/main/kotlin/com/baeldung/kotlin/delegates/Database.kt rename to core-kotlin/src/main/kotlin/com/baeldung/kotlin/delegates/Database.kt diff --git a/kotlin/src/main/kotlin/com/baeldung/kotlin/delegates/DatabaseDelegate.kt b/core-kotlin/src/main/kotlin/com/baeldung/kotlin/delegates/DatabaseDelegate.kt similarity index 100% rename from kotlin/src/main/kotlin/com/baeldung/kotlin/delegates/DatabaseDelegate.kt rename to core-kotlin/src/main/kotlin/com/baeldung/kotlin/delegates/DatabaseDelegate.kt diff --git a/kotlin/src/main/kotlin/com/baeldung/kotlin/delegates/User.kt b/core-kotlin/src/main/kotlin/com/baeldung/kotlin/delegates/User.kt similarity index 100% rename from kotlin/src/main/kotlin/com/baeldung/kotlin/delegates/User.kt rename to core-kotlin/src/main/kotlin/com/baeldung/kotlin/delegates/User.kt diff --git a/kotlin/src/main/kotlin/com/baeldung/kotlin/mockito/BookService.kt b/core-kotlin/src/main/kotlin/com/baeldung/kotlin/mockito/BookService.kt similarity index 100% rename from kotlin/src/main/kotlin/com/baeldung/kotlin/mockito/BookService.kt rename to core-kotlin/src/main/kotlin/com/baeldung/kotlin/mockito/BookService.kt diff --git a/kotlin/src/main/kotlin/com/baeldung/kotlin/mockito/LendBookManager.kt b/core-kotlin/src/main/kotlin/com/baeldung/kotlin/mockito/LendBookManager.kt similarity index 100% rename from kotlin/src/main/kotlin/com/baeldung/kotlin/mockito/LendBookManager.kt rename to core-kotlin/src/main/kotlin/com/baeldung/kotlin/mockito/LendBookManager.kt diff --git a/kotlin/src/test/java/com/baeldung/kotlin/JavaCallToKotlinUnitTest.java b/core-kotlin/src/test/java/com/baeldung/kotlin/JavaCallToKotlinUnitTest.java similarity index 100% rename from kotlin/src/test/java/com/baeldung/kotlin/JavaCallToKotlinUnitTest.java rename to core-kotlin/src/test/java/com/baeldung/kotlin/JavaCallToKotlinUnitTest.java diff --git a/kotlin/src/test/java/com/baeldung/kotlin/LazyJavaUnitTest.java b/core-kotlin/src/test/java/com/baeldung/kotlin/LazyJavaUnitTest.java similarity index 100% rename from kotlin/src/test/java/com/baeldung/kotlin/LazyJavaUnitTest.java rename to core-kotlin/src/test/java/com/baeldung/kotlin/LazyJavaUnitTest.java diff --git a/kotlin/src/test/kotlin/com/baeldung/kotlin/ArrayTest.kt b/core-kotlin/src/test/kotlin/com/baeldung/kotlin/ArrayTest.kt similarity index 100% rename from kotlin/src/test/kotlin/com/baeldung/kotlin/ArrayTest.kt rename to core-kotlin/src/test/kotlin/com/baeldung/kotlin/ArrayTest.kt diff --git a/kotlin/src/test/kotlin/com/baeldung/kotlin/CollectionsTest.kt b/core-kotlin/src/test/kotlin/com/baeldung/kotlin/CollectionsTest.kt similarity index 100% rename from kotlin/src/test/kotlin/com/baeldung/kotlin/CollectionsTest.kt rename to core-kotlin/src/test/kotlin/com/baeldung/kotlin/CollectionsTest.kt diff --git a/kotlin/src/test/kotlin/com/baeldung/kotlin/CoroutinesTest.kt b/core-kotlin/src/test/kotlin/com/baeldung/kotlin/CoroutinesTest.kt similarity index 100% rename from kotlin/src/test/kotlin/com/baeldung/kotlin/CoroutinesTest.kt rename to core-kotlin/src/test/kotlin/com/baeldung/kotlin/CoroutinesTest.kt diff --git a/kotlin/src/test/kotlin/com/baeldung/kotlin/CustomerTest.kt b/core-kotlin/src/test/kotlin/com/baeldung/kotlin/CustomerTest.kt similarity index 100% rename from kotlin/src/test/kotlin/com/baeldung/kotlin/CustomerTest.kt rename to core-kotlin/src/test/kotlin/com/baeldung/kotlin/CustomerTest.kt diff --git a/kotlin/src/test/kotlin/com/baeldung/kotlin/EqualityTest.kt b/core-kotlin/src/test/kotlin/com/baeldung/kotlin/EqualityTest.kt similarity index 100% rename from kotlin/src/test/kotlin/com/baeldung/kotlin/EqualityTest.kt rename to core-kotlin/src/test/kotlin/com/baeldung/kotlin/EqualityTest.kt diff --git a/kotlin/src/test/kotlin/com/baeldung/kotlin/GenericsTest.kt b/core-kotlin/src/test/kotlin/com/baeldung/kotlin/GenericsTest.kt similarity index 100% rename from kotlin/src/test/kotlin/com/baeldung/kotlin/GenericsTest.kt rename to core-kotlin/src/test/kotlin/com/baeldung/kotlin/GenericsTest.kt diff --git a/kotlin/src/test/kotlin/com/baeldung/kotlin/ItemServiceTest.kt b/core-kotlin/src/test/kotlin/com/baeldung/kotlin/ItemServiceTest.kt similarity index 100% rename from kotlin/src/test/kotlin/com/baeldung/kotlin/ItemServiceTest.kt rename to core-kotlin/src/test/kotlin/com/baeldung/kotlin/ItemServiceTest.kt diff --git a/kotlin/src/test/kotlin/com/baeldung/kotlin/JvmSampleTest.kt b/core-kotlin/src/test/kotlin/com/baeldung/kotlin/JvmSampleTest.kt similarity index 100% rename from kotlin/src/test/kotlin/com/baeldung/kotlin/JvmSampleTest.kt rename to core-kotlin/src/test/kotlin/com/baeldung/kotlin/JvmSampleTest.kt diff --git a/kotlin/src/test/kotlin/com/baeldung/kotlin/KotlinJavaInteroperabilityTest.kt b/core-kotlin/src/test/kotlin/com/baeldung/kotlin/KotlinJavaInteroperabilityTest.kt similarity index 100% rename from kotlin/src/test/kotlin/com/baeldung/kotlin/KotlinJavaInteroperabilityTest.kt rename to core-kotlin/src/test/kotlin/com/baeldung/kotlin/KotlinJavaInteroperabilityTest.kt diff --git a/kotlin/src/test/kotlin/com/baeldung/kotlin/LambdaTest.kt b/core-kotlin/src/test/kotlin/com/baeldung/kotlin/LambdaTest.kt similarity index 100% rename from kotlin/src/test/kotlin/com/baeldung/kotlin/LambdaTest.kt rename to core-kotlin/src/test/kotlin/com/baeldung/kotlin/LambdaTest.kt diff --git a/kotlin/src/test/kotlin/com/baeldung/kotlin/LazyUnitTest.kt b/core-kotlin/src/test/kotlin/com/baeldung/kotlin/LazyUnitTest.kt similarity index 100% rename from kotlin/src/test/kotlin/com/baeldung/kotlin/LazyUnitTest.kt rename to core-kotlin/src/test/kotlin/com/baeldung/kotlin/LazyUnitTest.kt diff --git a/kotlin/src/test/kotlin/com/baeldung/kotlin/ListExtensionTest.kt b/core-kotlin/src/test/kotlin/com/baeldung/kotlin/ListExtensionTest.kt similarity index 100% rename from kotlin/src/test/kotlin/com/baeldung/kotlin/ListExtensionTest.kt rename to core-kotlin/src/test/kotlin/com/baeldung/kotlin/ListExtensionTest.kt diff --git a/kotlin/src/test/kotlin/com/baeldung/kotlin/ListToMapTest.kt b/core-kotlin/src/test/kotlin/com/baeldung/kotlin/ListToMapTest.kt similarity index 100% rename from kotlin/src/test/kotlin/com/baeldung/kotlin/ListToMapTest.kt rename to core-kotlin/src/test/kotlin/com/baeldung/kotlin/ListToMapTest.kt diff --git a/kotlin/src/test/kotlin/com/baeldung/kotlin/NullSafetyTest.kt b/core-kotlin/src/test/kotlin/com/baeldung/kotlin/NullSafetyTest.kt similarity index 100% rename from kotlin/src/test/kotlin/com/baeldung/kotlin/NullSafetyTest.kt rename to core-kotlin/src/test/kotlin/com/baeldung/kotlin/NullSafetyTest.kt diff --git a/kotlin/src/test/kotlin/com/baeldung/kotlin/SealedTest.kt b/core-kotlin/src/test/kotlin/com/baeldung/kotlin/SealedTest.kt similarity index 100% rename from kotlin/src/test/kotlin/com/baeldung/kotlin/SealedTest.kt rename to core-kotlin/src/test/kotlin/com/baeldung/kotlin/SealedTest.kt diff --git a/kotlin/src/test/kotlin/com/baeldung/kotlin/WhenBlockUnitTest.kt b/core-kotlin/src/test/kotlin/com/baeldung/kotlin/WhenBlockUnitTest.kt similarity index 100% rename from kotlin/src/test/kotlin/com/baeldung/kotlin/WhenBlockUnitTest.kt rename to core-kotlin/src/test/kotlin/com/baeldung/kotlin/WhenBlockUnitTest.kt diff --git a/kotlin/src/test/kotlin/com/baeldung/kotlin/delegates/DatabaseDelegatesTest.kt b/core-kotlin/src/test/kotlin/com/baeldung/kotlin/delegates/DatabaseDelegatesTest.kt similarity index 100% rename from kotlin/src/test/kotlin/com/baeldung/kotlin/delegates/DatabaseDelegatesTest.kt rename to core-kotlin/src/test/kotlin/com/baeldung/kotlin/delegates/DatabaseDelegatesTest.kt diff --git a/kotlin/src/test/kotlin/com/baeldung/kotlin/mockito/LendBookManagerTest.kt b/core-kotlin/src/test/kotlin/com/baeldung/kotlin/mockito/LendBookManagerTest.kt similarity index 100% rename from kotlin/src/test/kotlin/com/baeldung/kotlin/mockito/LendBookManagerTest.kt rename to core-kotlin/src/test/kotlin/com/baeldung/kotlin/mockito/LendBookManagerTest.kt diff --git a/kotlin/src/test/kotlin/com/baeldung/kotlin/mockito/LendBookManagerTestMockitoKotlin.kt b/core-kotlin/src/test/kotlin/com/baeldung/kotlin/mockito/LendBookManagerTestMockitoKotlin.kt similarity index 100% rename from kotlin/src/test/kotlin/com/baeldung/kotlin/mockito/LendBookManagerTestMockitoKotlin.kt rename to core-kotlin/src/test/kotlin/com/baeldung/kotlin/mockito/LendBookManagerTestMockitoKotlin.kt From 16b6e089c6e873834e34e88147eabb352c4cdcf3 Mon Sep 17 00:00:00 2001 From: Dassi orleando Date: Thu, 21 Sep 2017 02:01:43 +0100 Subject: [PATCH 05/10] BAEL-1107 : Introduction to Apache Cayenne Orm (#2650) * Different types of bean injection in Spring * Difference between two dates in java * Update README.md * Simple clean of difference between dates * Clean my test article * Improve dates diff: for dates and datetimes * Move difference between dates from core-java to libraries * BAEL-890 - Kotlin-Allopen with Spring example * BAEL-1107 - Introduction to Apache Cayenne Orm --- apache-cayenne/pom.xml | 59 ++++++++ .../apachecayenne/persistent/Article.java | 9 ++ .../apachecayenne/persistent/Author.java | 9 ++ .../persistent/auto/_Article.java | 47 ++++++ .../persistent/auto/_Author.java | 52 +++++++ .../src/main/resources/cayenne-project.xml | 17 +++ .../src/main/resources/datamap.map.xml | 34 +++++ .../apachecayenne/CayenneOperationTests.java | 140 ++++++++++++++++++ libraries/pom.xml | 1 + pom.xml | 1 + 10 files changed, 369 insertions(+) create mode 100644 apache-cayenne/pom.xml create mode 100644 apache-cayenne/src/main/java/com/baeldung/apachecayenne/persistent/Article.java create mode 100644 apache-cayenne/src/main/java/com/baeldung/apachecayenne/persistent/Author.java create mode 100644 apache-cayenne/src/main/java/com/baeldung/apachecayenne/persistent/auto/_Article.java create mode 100644 apache-cayenne/src/main/java/com/baeldung/apachecayenne/persistent/auto/_Author.java create mode 100644 apache-cayenne/src/main/resources/cayenne-project.xml create mode 100644 apache-cayenne/src/main/resources/datamap.map.xml create mode 100644 apache-cayenne/src/test/java/com/baeldung/apachecayenne/CayenneOperationTests.java diff --git a/apache-cayenne/pom.xml b/apache-cayenne/pom.xml new file mode 100644 index 0000000000..23837d7019 --- /dev/null +++ b/apache-cayenne/pom.xml @@ -0,0 +1,59 @@ + + + 4.0.0 + + apache-cayenne + 0.0.1-SNAPSHOT + jar + + apache-cayenne + Introduction to Apache Cayenne + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + UTF-8 + UTF-8 + 1.8 + 5.1.31 + 4.0.M5 + 4.12 + + + + + org.apache.cayenne + cayenne-server + ${cayenne.version} + + + mysql + mysql-connector-java + ${mysql.connector.version} + runtime + + + + junit + junit + ${junit.version} + test + + + + + + + org.apache.cayenne.plugins + cayenne-modeler-maven-plugin + ${cayenne.version} + + + + + diff --git a/apache-cayenne/src/main/java/com/baeldung/apachecayenne/persistent/Article.java b/apache-cayenne/src/main/java/com/baeldung/apachecayenne/persistent/Article.java new file mode 100644 index 0000000000..303c180887 --- /dev/null +++ b/apache-cayenne/src/main/java/com/baeldung/apachecayenne/persistent/Article.java @@ -0,0 +1,9 @@ +package com.baeldung.apachecayenne.persistent; + +import com.baeldung.apachecayenne.persistent.auto._Article; + +public class Article extends _Article { + + private static final long serialVersionUID = 1L; + +} diff --git a/apache-cayenne/src/main/java/com/baeldung/apachecayenne/persistent/Author.java b/apache-cayenne/src/main/java/com/baeldung/apachecayenne/persistent/Author.java new file mode 100644 index 0000000000..5a8df57c6e --- /dev/null +++ b/apache-cayenne/src/main/java/com/baeldung/apachecayenne/persistent/Author.java @@ -0,0 +1,9 @@ +package com.baeldung.apachecayenne.persistent; + +import com.baeldung.apachecayenne.persistent.auto._Author; + +public class Author extends _Author { + + private static final long serialVersionUID = 1L; + +} diff --git a/apache-cayenne/src/main/java/com/baeldung/apachecayenne/persistent/auto/_Article.java b/apache-cayenne/src/main/java/com/baeldung/apachecayenne/persistent/auto/_Article.java new file mode 100644 index 0000000000..f6c179fcfd --- /dev/null +++ b/apache-cayenne/src/main/java/com/baeldung/apachecayenne/persistent/auto/_Article.java @@ -0,0 +1,47 @@ +package com.baeldung.apachecayenne.persistent.auto; + +import org.apache.cayenne.CayenneDataObject; +import org.apache.cayenne.exp.Property; + +import com.baeldung.apachecayenne.persistent.Author; + +/** + * Class _Article was generated by Cayenne. + * It is probably a good idea to avoid changing this class manually, + * since it may be overwritten next time code is regenerated. + * If you need to make any customizations, please use subclass. + */ +public abstract class _Article extends CayenneDataObject { + + private static final long serialVersionUID = 1L; + + public static final String ID_PK_COLUMN = "id"; + + public static final Property CONTENT = Property.create("content", String.class); + public static final Property TITLE = Property.create("title", String.class); + public static final Property AUTHOR = Property.create("author", Author.class); + + public void setContent(String content) { + writeProperty("content", content); + } + public String getContent() { + return (String)readProperty("content"); + } + + public void setTitle(String title) { + writeProperty("title", title); + } + public String getTitle() { + return (String)readProperty("title"); + } + + public void setAuthor(Author author) { + setToOneTarget("author", author, true); + } + + public Author getAuthor() { + return (Author)readProperty("author"); + } + + +} diff --git a/apache-cayenne/src/main/java/com/baeldung/apachecayenne/persistent/auto/_Author.java b/apache-cayenne/src/main/java/com/baeldung/apachecayenne/persistent/auto/_Author.java new file mode 100644 index 0000000000..3d068423c8 --- /dev/null +++ b/apache-cayenne/src/main/java/com/baeldung/apachecayenne/persistent/auto/_Author.java @@ -0,0 +1,52 @@ +package com.baeldung.apachecayenne.persistent.auto; + +import java.util.List; + +import org.apache.cayenne.CayenneDataObject; +import org.apache.cayenne.exp.Property; + +import com.baeldung.apachecayenne.persistent.Article; + +/** + * Class _Author was generated by Cayenne. + * It is probably a good idea to avoid changing this class manually, + * since it may be overwritten next time code is regenerated. + * If you need to make any customizations, please use subclass. + */ +public abstract class _Author extends CayenneDataObject { + + private static final long serialVersionUID = 1L; + + public static final String ID_PK_COLUMN = "id"; + + public static final Property FIRSTNAME = Property.create("firstname", String.class); + public static final Property LASTNAME = Property.create("lastname", String.class); + public static final Property> ARTICLES = Property.create("articles", List.class); + + public void setFirstname(String firstname) { + writeProperty("firstname", firstname); + } + public String getFirstname() { + return (String)readProperty("firstname"); + } + + public void setLastname(String lastname) { + writeProperty("lastname", lastname); + } + public String getLastname() { + return (String)readProperty("lastname"); + } + + public void addToArticles(Article obj) { + addToManyTarget("articles", obj, true); + } + public void removeFromArticles(Article obj) { + removeToManyTarget("articles", obj, true); + } + @SuppressWarnings("unchecked") + public List
getArticles() { + return (List
)readProperty("articles"); + } + + +} diff --git a/apache-cayenne/src/main/resources/cayenne-project.xml b/apache-cayenne/src/main/resources/cayenne-project.xml new file mode 100644 index 0000000000..3f3c59e0e9 --- /dev/null +++ b/apache-cayenne/src/main/resources/cayenne-project.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + diff --git a/apache-cayenne/src/main/resources/datamap.map.xml b/apache-cayenne/src/main/resources/datamap.map.xml new file mode 100644 index 0000000000..dc78ad4348 --- /dev/null +++ b/apache-cayenne/src/main/resources/datamap.map.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apache-cayenne/src/test/java/com/baeldung/apachecayenne/CayenneOperationTests.java b/apache-cayenne/src/test/java/com/baeldung/apachecayenne/CayenneOperationTests.java new file mode 100644 index 0000000000..da9667b029 --- /dev/null +++ b/apache-cayenne/src/test/java/com/baeldung/apachecayenne/CayenneOperationTests.java @@ -0,0 +1,140 @@ +package com.baeldung.apachecayenne; + +import com.baeldung.apachecayenne.persistent.Article; +import com.baeldung.apachecayenne.persistent.Author; +import org.apache.cayenne.ObjectContext; +import org.apache.cayenne.configuration.server.ServerRuntime; +import org.apache.cayenne.query.ObjectSelect; +import org.apache.cayenne.query.SQLTemplate; +import org.junit.After; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.util.List; + +import static junit.framework.Assert.assertEquals; +import static org.junit.Assert.assertNull; + + +public class CayenneOperationTests { + private static ObjectContext context = null; + + @BeforeClass + public static void setupTheCayenneContext(){ + ServerRuntime cayenneRuntime = ServerRuntime.builder() + .addConfig("cayenne-project.xml") + .build(); + context = cayenneRuntime.newContext(); + } + + @After + public void deleteAllRecords(){ + SQLTemplate deleteArticles = new SQLTemplate(Article.class, "delete from article"); + SQLTemplate deleteAuthors = new SQLTemplate(Author.class, "delete from author"); + + context.performGenericQuery(deleteArticles); + context.performGenericQuery(deleteAuthors); + } + + @Test + public void givenAuthor_whenInsert_thenWeGetOneRecordInTheDatabase(){ + Author author = context.newObject(Author.class); + author.setFirstname("Paul"); + author.setLastname("Smith"); + + context.commitChanges(); + + long records = ObjectSelect.dataRowQuery(Author.class).selectCount(context); + assertEquals(1, records); + } + + @Test + public void givenAuthor_whenInsert_andQueryByFirstName_thenWeGetTheAuthor(){ + Author author = context.newObject(Author.class); + author.setFirstname("Paul"); + author.setLastname("Smith"); + + context.commitChanges(); + + Author expectedAuthor = ObjectSelect.query(Author.class) + .where(Author.FIRSTNAME.eq("Paul")) + .selectOne(context); + + assertEquals("Paul", expectedAuthor.getFirstname()); + assertEquals("Smith", expectedAuthor.getLastname()); + } + + @Test + public void givenTwoAuthor_whenInsert_andQueryAll_thenWeGetTwoAuthors(){ + Author firstAuthor = context.newObject(Author.class); + firstAuthor.setFirstname("Paul"); + firstAuthor.setLastname("Smith"); + + Author secondAuthor = context.newObject(Author.class); + secondAuthor.setFirstname("Ludovic"); + secondAuthor.setLastname("Garcia"); + + context.commitChanges(); + + List authors = ObjectSelect.query(Author.class).select(context); + assertEquals(2, authors.size()); + } + + @Test + public void givenAuthor_whenUpdating_thenWeGetAnUpatedeAuthor(){ + Author author = context.newObject(Author.class); + author.setFirstname("Paul"); + author.setLastname("Smith"); + context.commitChanges(); + + Author expectedAuthor = ObjectSelect.query(Author.class) + .where(Author.FIRSTNAME.eq("Paul")) + .selectOne(context); + expectedAuthor.setLastname("Smith 2"); + context.commitChanges(); + + assertEquals(author.getFirstname(), expectedAuthor.getFirstname()); + assertEquals(author.getLastname(), expectedAuthor.getLastname()); + } + + @Test + public void givenAuthor_whenDeleting_thenWeLostHisDetails(){ + Author author = context.newObject(Author.class); + author.setFirstname("Paul"); + author.setLastname("Smith"); + context.commitChanges(); + + Author savedAuthor = ObjectSelect.query(Author.class) + .where(Author.FIRSTNAME.eq("Paul")).selectOne(context); + if(savedAuthor != null) { + context.deleteObjects(author); + context.commitChanges(); + } + + Author expectedAuthor = ObjectSelect.query(Author.class) + .where(Author.FIRSTNAME.eq("Paul")).selectOne(context); + assertNull(expectedAuthor); + } + + @Test + public void givenAuthor_whenAttachingToArticle_thenTheRelationIsMade(){ + Author author = context.newObject(Author.class); + author.setFirstname("Paul"); + author.setLastname("Smith"); + + Article article = context.newObject(Article.class); + article.setTitle("My post title"); + article.setContent("The content"); + article.setAuthor(author); + + context.commitChanges(); + + Author expectedAuthor = ObjectSelect.query(Author.class) + .where(Author.LASTNAME.eq("Smith")) + .selectOne(context); + + Article expectedArticle = (expectedAuthor.getArticles()).get(0); + assertEquals(article.getTitle(), expectedArticle.getTitle()); + } + +} diff --git a/libraries/pom.xml b/libraries/pom.xml index 77e7c2634a..da89318e50 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -620,6 +620,7 @@ 8.2.0 0.6.5 0.9.0 + 15.2 2.9.9 1.5.1 2.3.0 diff --git a/pom.xml b/pom.xml index 015efbab05..dd0871ae79 100644 --- a/pom.xml +++ b/pom.xml @@ -28,6 +28,7 @@ + apache-cayenne aws akka-streams algorithms From 5fe5887be7ef034cd10a4b4e7b4e6c7738c36dce Mon Sep 17 00:00:00 2001 From: lor6 Date: Thu, 21 Sep 2017 11:22:04 +0300 Subject: [PATCH 06/10] add simpleentry test (#2654) --- .../pairs/CoreJavaSimpleEntryUnitTest.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 libraries/src/test/java/com/baeldung/pairs/CoreJavaSimpleEntryUnitTest.java diff --git a/libraries/src/test/java/com/baeldung/pairs/CoreJavaSimpleEntryUnitTest.java b/libraries/src/test/java/com/baeldung/pairs/CoreJavaSimpleEntryUnitTest.java new file mode 100644 index 0000000000..ca425339fa --- /dev/null +++ b/libraries/src/test/java/com/baeldung/pairs/CoreJavaSimpleEntryUnitTest.java @@ -0,0 +1,39 @@ +package com.baeldung.pairs; + +import static org.junit.Assert.*; + +import java.util.AbstractMap; + +import org.junit.Test; + +public class CoreJavaSimpleEntryUnitTest { + + @Test + public void givenSimpleEntry_whenGetValue_thenOk() { + AbstractMap.SimpleEntry entry = new AbstractMap.SimpleEntry(1, "one"); + Integer key = entry.getKey(); + String value = entry.getValue(); + + assertEquals(key.intValue(), 1); + assertEquals(value, "one"); + } + + @Test(expected = UnsupportedOperationException.class) + public void givenSimpleImmutableEntry_whenSetValue_thenException() { + AbstractMap.SimpleImmutableEntry entry = new AbstractMap.SimpleImmutableEntry(1, "one"); + + entry.setValue("two"); + + } + + @Test + public void givenSimpleImmutableEntry_whenGetValue_thenOk() { + AbstractMap.SimpleImmutableEntry entry = new AbstractMap.SimpleImmutableEntry(1, "one"); + Integer key = entry.getKey(); + String value = entry.getValue(); + + assertEquals(key.intValue(), 1); + assertEquals(value, "one"); + } + +} From 476f0df4a2e65efa067b6dbad614e1ef9f0eeb09 Mon Sep 17 00:00:00 2001 From: Blue Montag Software Date: Thu, 21 Sep 2017 08:43:08 -0300 Subject: [PATCH 07/10] author: ignaciogallego@gmail.com article:Collection Factory Methods for Vavr (#2652) * New test class for the collections factory methods in vavr * rename unit test for collection factory methods * the vavr version changed to 0.9.1 --- vavr/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vavr/pom.xml b/vavr/pom.xml index 53cd07ddf7..2efaf7fd8c 100644 --- a/vavr/pom.xml +++ b/vavr/pom.xml @@ -74,7 +74,7 @@ 1.8 - 0.9.0 + 0.9.1 4.12 3.0.0 From c7f180f3a147e1d4a29873c5ce643e8c21c314cb Mon Sep 17 00:00:00 2001 From: KevinGilmore Date: Thu, 21 Sep 2017 06:47:53 -0500 Subject: [PATCH 08/10] BAEL-817 README (#2655) * BAEL-973: updated README * BAEL-1069: Updated README * BAEL-817: add README file --- geotools/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 geotools/README.md diff --git a/geotools/README.md b/geotools/README.md new file mode 100644 index 0000000000..188ff0fddb --- /dev/null +++ b/geotools/README.md @@ -0,0 +1,3 @@ +### Relevant Articles + +[Introduction to GeoTools](http://www.baeldung.com/geo-tools) From 1ddd46f1afdcaf6364e3b1b5cf67cefd91747f4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ho=C3=A0ng=20H=C6=B0ng?= Date: Thu, 21 Sep 2017 21:04:55 +0700 Subject: [PATCH 09/10] BAEL-1080 Introduction to Future in Vavr (#2627) * Add example of different types of bean injection * BAEL-1080 Introduction to Future and Pattern Matching in Vavr * Update future with Pattern Matching * remove unused files * Update future unit test of cancelled Future * remove unused import * delete unused files * using await() on future to wait until future completed instead of using while(true) * Add Awaitability to FutureTest, avoid using while loop * format code * add some static void method that print the result to console --- .../baeldung/vavr/future/FutureUnitTest.java | 144 ++++++++++++++---- 1 file changed, 115 insertions(+), 29 deletions(-) diff --git a/vavr/src/test/java/com/baeldung/vavr/future/FutureUnitTest.java b/vavr/src/test/java/com/baeldung/vavr/future/FutureUnitTest.java index 84621e3a68..437742c964 100644 --- a/vavr/src/test/java/com/baeldung/vavr/future/FutureUnitTest.java +++ b/vavr/src/test/java/com/baeldung/vavr/future/FutureUnitTest.java @@ -5,17 +5,23 @@ import static io.vavr.API.Case; import static io.vavr.API.Match; import static io.vavr.Predicates.exists; import static io.vavr.Predicates.forAll; -import static org.awaitility.Awaitility.await; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.util.concurrent.CancellationException; +import java.util.function.Consumer; import java.util.function.Predicate; import org.junit.Test; +import org.mockito.Mockito; +import org.mockito.internal.verification.VerificationModeFactory; +import org.mockito.verification.Timeout; +import io.vavr.Tuple; +import io.vavr.Tuple2; import io.vavr.collection.List; import io.vavr.concurrent.Future; +import io.vavr.control.Try; public class FutureUnitTest { @@ -26,8 +32,7 @@ public class FutureUnitTest { public void givenFunctionReturnInteger_WhenCallWithFuture_ShouldReturnFunctionValue() { Future future = Future.of(() -> 1); - assertEquals(1, future.get() - .intValue()); + assertEquals(1, future.get().intValue()); } @Test @@ -57,33 +62,29 @@ public class FutureUnitTest { @Test public void givenFunction_WhenCallWithFutureAndRegisterConsumerForSuccess_ShouldCallConsumerToStoreValue() { - final int[] store = new int[] { 0 }; Future future = Future.of(() -> 1); - future.onSuccess(i -> { - store[0] = i; - }); - await().until(() -> store[0] == 1); + MockConsumer consumer = Mockito.mock(MockConsumer.class); + future.onSuccess(consumer); + Mockito.verify(consumer, new Timeout(1000, VerificationModeFactory.times(1))).accept(1); } @Test public void givenFunctionThrowException_WhenCallWithFutureAndRegisterConsumerForFailer_ShouldCallConsumerToStoreException() { - final Throwable[] store = new Throwable[] { null }; Future future = Future.of(() -> getResourceThrowException("")); - future.onFailure(err -> store[0] = err); - await().until(() -> RuntimeException.class.isInstance(store[0])); + MockThrowableConsumer consumer = Mockito.mock(MockThrowableConsumer.class); + future.onFailure(consumer); + Mockito.verify(consumer, new Timeout(1000, VerificationModeFactory.times(1))).accept(Mockito.any()); } @Test public void givenAFuture_WhenAddAndThenConsumer_ShouldCallConsumerWithResultOfFutureAction() { - int[] store1 = new int[1]; - int[] store2 = new int[1]; + MockTryConsumer consumer1 = Mockito.mock(MockTryConsumer.class); + MockTryConsumer consumer2 = Mockito.mock(MockTryConsumer.class); Future future = Future.of(() -> 1); - Future andThenFuture = future.andThen(i -> store1[0] = i.get() + 1) - .andThen(i -> store2[0] = store1[0] + 1); + Future andThenFuture = future.andThen(consumer1).andThen(consumer2); andThenFuture.await(); - - assertEquals(2, store1[0]); - assertEquals(3, store2[0]); + Mockito.verify(consumer1, VerificationModeFactory.times(1)).accept(Try.success(1)); + Mockito.verify(consumer2, VerificationModeFactory.times(1)).accept(Try.success(1)); } @Test @@ -91,8 +92,7 @@ public class FutureUnitTest { Future future = Future.failed(new RuntimeException()); Future future2 = future.orElse(Future.of(() -> 2)); - assertEquals(2, future2.get() - .intValue()); + assertEquals(2, future2.get().intValue()); } @Test(expected = CancellationException.class) @@ -124,17 +124,46 @@ public class FutureUnitTest { Future future = Future.failed(new RuntimeException()); Future fallbackFuture = Future.of(() -> expectedResult); Future futureResult = future.fallbackTo(fallbackFuture); - futureResult.await(); assertEquals(expectedResult, futureResult.get()); } + + @Test + public void givenAFuture_WhenTransformByAddingOne_ShouldReturn() { + Future future = Future.of(() -> 1).transformValue(f -> Try.of(() -> "Hello: " + f.get())); + + assertEquals("Hello: 1", future.get()); + } + + @Test + public void givenAFutureOfInt_WhenMapToString_ShouldCombineAndReturn() { + Future future = Future.of(()->1).map(i -> "Hello: " + i); + + assertEquals("Hello: 1", future.get()); + } + + @Test + public void givenAFutureOfInt_WhenFlatMapToString_ShouldCombineAndReturn() { + Future futureMap = Future.of(() -> 1).flatMap((i) -> Future.of(() -> "Hello: " + i)); + + assertEquals("Hello: 1", futureMap.get()); + } + + @Test + public void givenAFutureOf2String_WhenZip_ShouldReturnTupleOf2String() { + Future> future = Future.of(() -> "hello").zip(Future.of(() -> "world")); + + assertEquals(Tuple.of("hello", "world"), future.get()); + } @Test public void givenGetResourceWithFuture_WhenWaitAndMatchWithPredicate_ShouldReturnSuccess() { String url = "http://resource"; Future future = Future.of(() -> getResource(url)); future.await(); - String s = Match(future).of(Case($(future0 -> future0.isSuccess()), SUCCESS), Case($(), FAILURE)); + String s = Match(future).of( + Case($(future0 -> future0.isSuccess()), SUCCESS), + Case($(), FAILURE)); assertEquals(SUCCESS, s); } @@ -143,7 +172,9 @@ public class FutureUnitTest { public void givenAFailedFuture_WhenWaitAndMatchWithPredicateCheckSuccess_ShouldReturnFailed() { Future future = Future.failed(new RuntimeException()); future.await(); - String s = Match(future).of(Case($(future0 -> future0.isSuccess()), SUCCESS), Case($(), FAILURE)); + String s = Match(future).of( + Case($(future0 -> future0.isSuccess()), SUCCESS), + Case($(), FAILURE)); assertEquals(FAILURE, s); } @@ -155,7 +186,10 @@ public class FutureUnitTest { return 1; }); Predicate> predicate = f -> f.exists(i -> i % 2 == 1); - String s = Match(future).of(Case($(predicate), "Even"), Case($(), "Odd")); + + String s = Match(future).of( + Case($(predicate), "Even"), + Case($(), "Odd")); assertEquals("Even", s); } @@ -164,7 +198,9 @@ public class FutureUnitTest { public void givenAListOfFutureReturnFist3Integers_WhenMatchWithExistEvenNumberPredicate_ShouldReturnSuccess() { List> futures = getFutureOfFirst3Number(); Predicate> predicate0 = future -> future.exists(i -> i % 2 == 0); - String s = Match(futures).of(Case($(exists(predicate0)), "Even"), Case($(), "Odd")); + String s = Match(futures).of( + Case($(exists(predicate0)), "Even"), + Case($(), "Odd")); assertEquals("Even", s); } @@ -173,7 +209,9 @@ public class FutureUnitTest { public void givenAListOfFutureReturnFist3Integers_WhenMatchWithForAllNumberBiggerThanZeroPredicate_ShouldReturnSuccess() { List> futures = getFutureOfFirst3Number(); Predicate> predicate0 = future -> future.exists(i -> i > 0); - String s = Match(futures).of(Case($(forAll(predicate0)), "Positive numbers"), Case($(), "None")); + String s = Match(futures).of( + Case($(forAll(predicate0)), "Positive numbers"), + Case($(), "None")); assertEquals("Positive numbers", s); } @@ -182,13 +220,19 @@ public class FutureUnitTest { public void givenAListOfFutureReturnFist3Integers_WhenMatchWithForAllNumberSmallerThanZeroPredicate_ShouldReturnFailed() { List> futures = getFutureOfFirst3Number(); Predicate> predicate0 = future -> future.exists(i -> i < 0); - String s = Match(futures).of(Case($(forAll(predicate0)), "Negative numbers"), Case($(), "None")); + String s = Match(futures).of( + Case($(forAll(predicate0)), "Negative numbers"), + Case($(), "None")); assertEquals("None", s); } - private String getResource(String url) throws InterruptedException { - Thread.sleep(10); + private String getResource(String url) { + try { + Thread.sleep(10); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } return "Content from " + url; } @@ -200,4 +244,46 @@ public class FutureUnitTest { List> futures = List.of(Future.of(() -> 1), Future.of(() -> 2), Future.of(() -> 3)); return futures; } + + private static void checkOnSuccessFunction() { + Future future = Future.of(() -> 1); + future.onSuccess(i -> System.out.println("Future finish with result: " + i)); + } + + private static void checkOnFailureFunction() { + Future future = Future.of(() -> {throw new RuntimeException("Failed");}); + future.onFailure(t -> System.out.println("Future failures with exception: " + t)); + } + + private static void runAndThenConsumer() { + Future future = Future.of(() -> 1); + future.andThen(i -> System.out.println("Do side-effect action 1 with input: " + i.get())). + andThen((i) -> System.out.println("Do side-effect action 2 with input: " + i.get())); + } + + public static void main(String[] args) throws InterruptedException { + checkOnSuccessFunction(); + checkOnFailureFunction(); + runAndThenConsumer(); + Thread.sleep(1000); + } +} + + +class MockConsumer implements Consumer { + @Override + public void accept(Integer t) { + } +} + +class MockTryConsumer implements Consumer> { + @Override + public void accept(Try t) { + } +} + +class MockThrowableConsumer implements Consumer { + @Override + public void accept(Throwable t) { + } } From ec6aca9c51f5a3b54bcc591dfff9c350cd12845c Mon Sep 17 00:00:00 2001 From: felipeazv Date: Thu, 21 Sep 2017 18:38:56 +0200 Subject: [PATCH 10/10] BAEL-781: Explore the new Spring Cloud Gateway (#2613) * spring beans DI examples * fix-1: shortening examples * List of Rules Engines in Java * BAEL-812: Openl-Tablets example added * BAEL-812: artifacts names changed * BAEL-812: moving rule-engines examples to rule-engines folder * BAEL-812: removing evaluation article files * BAEL-812: folder renamed * BAEL-812: folder renamed * BAEL-812: pom.xml - parent added * BAEL-1027: Introduction to GraphQL - initial commit * BAEL-781: Explore the new Spring Cloud Gateway * BAEL-781: Fix UserService.java * BAEL-781: Fix user-service pom.xml * BAEL-781: remove eureka-server from the example * BAEL-781: modifying example --- spring-cloud/pom.xml | 1 + spring-cloud/spring-cloud-gateway/README.MD | 2 + .../gateway-service/pom.xml | 79 +++++++++++++++++++ .../spring/cloud/GatewayApplication.java | 12 +++ .../src/main/resources/application.yml | 13 +++ spring-cloud/spring-cloud-gateway/pom.xml | 50 ++++++++++++ 6 files changed, 157 insertions(+) create mode 100644 spring-cloud/spring-cloud-gateway/README.MD create mode 100644 spring-cloud/spring-cloud-gateway/gateway-service/pom.xml create mode 100644 spring-cloud/spring-cloud-gateway/gateway-service/src/main/java/com/baeldung/spring/cloud/GatewayApplication.java create mode 100644 spring-cloud/spring-cloud-gateway/gateway-service/src/main/resources/application.yml create mode 100644 spring-cloud/spring-cloud-gateway/pom.xml diff --git a/spring-cloud/pom.xml b/spring-cloud/pom.xml index e36f5265b2..44e72535f8 100644 --- a/spring-cloud/pom.xml +++ b/spring-cloud/pom.xml @@ -15,6 +15,7 @@ spring-cloud-ribbon-client spring-cloud-rest spring-cloud-zookeeper + spring-cloud-gateway pom diff --git a/spring-cloud/spring-cloud-gateway/README.MD b/spring-cloud/spring-cloud-gateway/README.MD new file mode 100644 index 0000000000..48fbf41b8e --- /dev/null +++ b/spring-cloud/spring-cloud-gateway/README.MD @@ -0,0 +1,2 @@ +### Relevant Articles: +- [Explore the new Spring Cloud Gateway](http://www.baeldung.com/spring-cloud-gateway) diff --git a/spring-cloud/spring-cloud-gateway/gateway-service/pom.xml b/spring-cloud/spring-cloud-gateway/gateway-service/pom.xml new file mode 100644 index 0000000000..14cde4901a --- /dev/null +++ b/spring-cloud/spring-cloud-gateway/gateway-service/pom.xml @@ -0,0 +1,79 @@ + + 4.0.0 + + gateway-service + 1.0.0-SNAPSHOT + jar + + Spring Cloud Gateway Service + + + com.baeldung.spring.cloud + spring-cloud-gateway + 1.0.0-SNAPSHOT + .. + + + + 2.0.0.M2 + + + + + org.springframework.boot + spring-boot-actuator + ${version} + + + org.springframework.boot + spring-boot-starter-webflux + ${version} + + + org.springframework.cloud + spring-cloud-gateway-core + ${version} + + + org.springframework.cloud + spring-cloud-starter-eureka + ${version} + + + org.hibernate + hibernate-validator-cdi + 6.0.2.Final + + + javax.validation + validation-api + 2.0.0.Final + + + io.projectreactor.ipc + reactor-netty + 0.7.0.M1 + + + + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + false + + + + + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-gateway/gateway-service/src/main/java/com/baeldung/spring/cloud/GatewayApplication.java b/spring-cloud/spring-cloud-gateway/gateway-service/src/main/java/com/baeldung/spring/cloud/GatewayApplication.java new file mode 100644 index 0000000000..4d5f61315f --- /dev/null +++ b/spring-cloud/spring-cloud-gateway/gateway-service/src/main/java/com/baeldung/spring/cloud/GatewayApplication.java @@ -0,0 +1,12 @@ +package com.baeldung.spring.cloud; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class GatewayApplication { + + public static void main(String[] args) { + SpringApplication.run(GatewayApplication.class, args); + } +} \ No newline at end of file diff --git a/spring-cloud/spring-cloud-gateway/gateway-service/src/main/resources/application.yml b/spring-cloud/spring-cloud-gateway/gateway-service/src/main/resources/application.yml new file mode 100644 index 0000000000..8b981f8071 --- /dev/null +++ b/spring-cloud/spring-cloud-gateway/gateway-service/src/main/resources/application.yml @@ -0,0 +1,13 @@ +server: + port: 80 +spring: + cloud: + gateway: + routes: + - id: baeldung_route + uri: http://www.baeldung.com + predicates: + - Path=/baeldung +management: + security: + enabled: false \ No newline at end of file diff --git a/spring-cloud/spring-cloud-gateway/pom.xml b/spring-cloud/spring-cloud-gateway/pom.xml new file mode 100644 index 0000000000..095ca4ea31 --- /dev/null +++ b/spring-cloud/spring-cloud-gateway/pom.xml @@ -0,0 +1,50 @@ + + + 4.0.0 + + com.baeldung.spring.cloud + spring-cloud-gateway + 1.0.0-SNAPSHOT + + gateway-service + + pom + + Spring Cloud Gateway + + + com.baeldung.spring.cloud + spring-cloud + 1.0.0-SNAPSHOT + .. + + + + UTF-8 + 3.6.0 + 1.4.2.RELEASE + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.8 + 1.8 + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot-maven-plugin.version} + + + + +