From 644cae69a77ee335a161ea19f5efcfbc167d0930 Mon Sep 17 00:00:00 2001 From: chriscj08 <38863697+chriscj08@users.noreply.github.com> Date: Tue, 23 Jun 2020 17:18:06 -0500 Subject: [PATCH 1/6] Add .circleci/config.yml --- .circleci/config.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..01c267cc --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,13 @@ +# Use the latest 2.1 version of CircleCI pipeline process engine. See: https://circleci.com/docs/2.0/configuration-reference +version: 2.1 +# Use a package of configuration called an orb. +orbs: + # Declare a dependency on the welcome-orb + welcome: circleci/welcome-orb@0.4.1 +# Orchestrate or schedule a set of jobs +workflows: + # Name the workflow "welcome" + welcome: + # Run the welcome/run job in its own container + jobs: + - welcome/run \ No newline at end of file From befba8ccff156fb8eba9838766e772fbc3e22914 Mon Sep 17 00:00:00 2001 From: chriscj08 <38863697+chriscj08@users.noreply.github.com> Date: Tue, 23 Jun 2020 17:25:30 -0500 Subject: [PATCH 2/6] Add .circleci/config.yml --- .circleci/config.yml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 01c267cc..a5e876ca 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,13 +1,9 @@ -# Use the latest 2.1 version of CircleCI pipeline process engine. See: https://circleci.com/docs/2.0/configuration-reference version: 2.1 -# Use a package of configuration called an orb. + orbs: - # Declare a dependency on the welcome-orb - welcome: circleci/welcome-orb@0.4.1 -# Orchestrate or schedule a set of jobs + maven: circleci/maven@0.0.12 + workflows: - # Name the workflow "welcome" - welcome: - # Run the welcome/run job in its own container + maven_test: jobs: - - welcome/run \ No newline at end of file + - maven/test # checkout, build, test, and upload test results From b440f00489c3edf21021f3a0a31c1dfb89231178 Mon Sep 17 00:00:00 2001 From: chriscj08 <38863697+chriscj08@users.noreply.github.com> Date: Wed, 24 Jun 2020 20:12:40 -0500 Subject: [PATCH 3/6] Add .circleci/config.yml From 7ed87e0da14e4e6ccb57041b017ac262de56fbda Mon Sep 17 00:00:00 2001 From: Chris Jurrens Date: Wed, 24 Jun 2020 20:26:53 -0500 Subject: [PATCH 4/6] source and target now 11 for maven-compiler-plugin --- .circleci/config.yml | 18 +- .gitignore | 282 +++++------ .mvn/wrapper/maven-wrapper.properties | 2 +- LICENSE | 404 ++++++++-------- README.md | 34 +- mvnw | 450 +++++++++--------- mvnw.cmd | 286 +++++------ pom.xml | 202 ++++---- .../controllers/IndexController.java | 26 +- .../controllers/OwnerController.java | 182 +++---- .../controllers/PetController.java | 166 +++---- .../controllers/VetController.java | 40 +- .../controllers/VisitController.java | 100 ++-- .../fauxspring/BindingResult.java | 16 +- .../sfgpetclinic/fauxspring/Formatter.java | 28 +- .../sfgpetclinic/fauxspring/Model.java | 16 +- .../sfgpetclinic/fauxspring/ModelAndView.java | 28 +- .../sfgpetclinic/fauxspring/ModelMap.java | 14 +- .../fauxspring/WebDataBinder.java | 10 +- .../formatters/PetTypeFormatter.java | 74 +-- .../sfgpetclinic/model/BaseEntity.java | 56 +-- .../sfgpetclinic/model/Owner.java | 146 +++--- .../sfgpetclinic/model/Person.java | 58 +-- .../sfgpetclinic/model/Pet.java | 124 ++--- .../sfgpetclinic/model/PetType.java | 64 +-- .../sfgpetclinic/model/Speciality.java | 50 +- .../sfgpetclinic/model/Vet.java | 46 +- .../sfgpetclinic/model/Visit.java | 94 ++-- .../repositories/CrudRepository.java | 184 +++---- .../repositories/OwnerRepository.java | 26 +- .../repositories/PetRepository.java | 12 +- .../repositories/PetTypeRepository.java | 12 +- .../sfgpetclinic/repositories/Repository.java | 10 +- .../repositories/SpecialtyRepository.java | 12 +- .../repositories/VetRepository.java | 12 +- .../repositories/VisitRepository.java | 12 +- .../sfgpetclinic/services/CrudService.java | 32 +- .../sfgpetclinic/services/OwnerService.java | 24 +- .../sfgpetclinic/services/PetService.java | 20 +- .../sfgpetclinic/services/PetTypeService.java | 12 +- .../services/SpecialtyService.java | 12 +- .../sfgpetclinic/services/VetService.java | 14 +- .../sfgpetclinic/services/VisitService.java | 12 +- .../services/map/AbstractMapService.java | 110 ++--- .../services/map/OwnerMapService.java | 170 +++---- .../services/map/PetMapService.java | 68 +-- .../services/map/PetTypeMapService.java | 68 +-- .../services/map/SpecialityMapService.java | 68 +-- .../services/map/VetMapService.java | 104 ++-- .../services/map/VisitMapService.java | 80 ++-- .../springdatajpa/OwnerSDJpaService.java | 124 ++--- .../springdatajpa/PetSDJpaService.java | 90 ++-- .../springdatajpa/PetTypeSDJpaService.java | 90 ++-- .../springdatajpa/SpecialitySDJpaService.java | 90 ++-- .../springdatajpa/VetSDJpaService.java | 88 ++-- .../springdatajpa/VisitSDJpaService.java | 88 ++-- 56 files changed, 2332 insertions(+), 2328 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a5e876ca..ed1de9e8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,9 +1,9 @@ -version: 2.1 - -orbs: - maven: circleci/maven@0.0.12 - -workflows: - maven_test: - jobs: - - maven/test # checkout, build, test, and upload test results +version: 2.1 + +orbs: + maven: circleci/maven@0.0.12 + +workflows: + maven_test: + jobs: + - maven/test # checkout, build, test, and upload test results diff --git a/.gitignore b/.gitignore index 86367d07..938495b4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,141 +1,141 @@ -###################### -# Project Specific -###################### -/build/www/** -/src/test/javascript/coverage/ -/src/test/javascript/PhantomJS*/ - -###################### -# Node -###################### -/node/ -node_tmp/ -node_modules/ -npm-debug.log.* - -###################### -# SASS -###################### -.sass-cache/ - -###################### -# Eclipse -###################### -*.pydevproject -.project -.metadata -tmp/ -tmp/**/* -*.tmp -*.bak -*.swp -*~.nib -local.properties -.classpath -.settings/ -.loadpath -.factorypath -/src/main/resources/rebel.xml - -# External tool builders -.externalToolBuilders/** - -# Locally stored "Eclipse launch configurations" -*.launch - -# CDT-specific -.cproject - -# PDT-specific -.buildpath - -###################### -# Intellij -###################### -.idea/ -*.iml -*.iws -*.ipr -*.ids -*.orig - -###################### -# Visual Studio Code -###################### -.vscode/ - -###################### -# Maven -###################### -/log/ -/target/ - -###################### -# Gradle -###################### -.gradle/ -/build/ - -###################### -# Package Files -###################### -*.jar -*.war -*.ear -*.db - -###################### -# Windows -###################### -# Windows image file caches -Thumbs.db - -# Folder config file -Desktop.ini - -###################### -# Mac OSX -###################### -.DS_Store -.svn - -# Thumbnails -._* - -# Files that might appear on external disk -.Spotlight-V100 -.Trashes - -###################### -# Directories -###################### -/bin/ -/deploy/ - -###################### -# Logs -###################### -*.log - -###################### -# Others -###################### -*.class -*.*~ -*~ -.merge_file* - -###################### -# Gradle Wrapper -###################### -!gradle/wrapper/gradle-wrapper.jar - -###################### -# Maven Wrapper -###################### -!.mvn/wrapper/maven-wrapper.jar - -###################### -# ESLint -###################### -.eslintcache +###################### +# Project Specific +###################### +/build/www/** +/src/test/javascript/coverage/ +/src/test/javascript/PhantomJS*/ + +###################### +# Node +###################### +/node/ +node_tmp/ +node_modules/ +npm-debug.log.* + +###################### +# SASS +###################### +.sass-cache/ + +###################### +# Eclipse +###################### +*.pydevproject +.project +.metadata +tmp/ +tmp/**/* +*.tmp +*.bak +*.swp +*~.nib +local.properties +.classpath +.settings/ +.loadpath +.factorypath +/src/main/resources/rebel.xml + +# External tool builders +.externalToolBuilders/** + +# Locally stored "Eclipse launch configurations" +*.launch + +# CDT-specific +.cproject + +# PDT-specific +.buildpath + +###################### +# Intellij +###################### +.idea/ +*.iml +*.iws +*.ipr +*.ids +*.orig + +###################### +# Visual Studio Code +###################### +.vscode/ + +###################### +# Maven +###################### +/log/ +/target/ + +###################### +# Gradle +###################### +.gradle/ +/build/ + +###################### +# Package Files +###################### +*.jar +*.war +*.ear +*.db + +###################### +# Windows +###################### +# Windows image file caches +Thumbs.db + +# Folder config file +Desktop.ini + +###################### +# Mac OSX +###################### +.DS_Store +.svn + +# Thumbnails +._* + +# Files that might appear on external disk +.Spotlight-V100 +.Trashes + +###################### +# Directories +###################### +/bin/ +/deploy/ + +###################### +# Logs +###################### +*.log + +###################### +# Others +###################### +*.class +*.*~ +*~ +.merge_file* + +###################### +# Gradle Wrapper +###################### +!gradle/wrapper/gradle-wrapper.jar + +###################### +# Maven Wrapper +###################### +!.mvn/wrapper/maven-wrapper.jar + +###################### +# ESLint +###################### +.eslintcache diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 6c8c0e08..488eeee1 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -1 +1 @@ -distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip +distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip diff --git a/LICENSE b/LICENSE index e06d2081..7b216eb0 100644 --- a/LICENSE +++ b/LICENSE @@ -1,202 +1,202 @@ -Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - 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 - - http://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. - +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + 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 + + http://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. + diff --git a/README.md b/README.md index f3e94a56..65de048f 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,17 @@ -# Introduction to JUnit 5 with Maven - -All source code examples in the repository are for my [Online Course - Testing Spring Beginner to Guru](https://www.udemy.com/testing-spring-boot-beginner-to-guru/?couponCode=GITHUB_REPO) - -This source code repository contains JUnit 5 test examples with Maven. - -## Setup -### Requirements -* Should use Java 11 or higher. Previous versions of Java are un-tested. -* Use Maven 3.5.2 or higher - -## Support -For questions and help: -* Please post in course -* Or post in the Slack Community exclusive to the course. - -GitHub Issues will not be addressed. +# Introduction to JUnit 5 with Maven + +All source code examples in the repository are for my [Online Course - Testing Spring Beginner to Guru](https://www.udemy.com/testing-spring-boot-beginner-to-guru/?couponCode=GITHUB_REPO) + +This source code repository contains JUnit 5 test examples with Maven. + +## Setup +### Requirements +* Should use Java 11 or higher. Previous versions of Java are un-tested. +* Use Maven 3.5.2 or higher + +## Support +For questions and help: +* Please post in course +* Or post in the Slack Community exclusive to the course. + +GitHub Issues will not be addressed. diff --git a/mvnw b/mvnw index 5bf251c0..7778d42f 100755 --- a/mvnw +++ b/mvnw @@ -1,225 +1,225 @@ -#!/bin/sh -# ---------------------------------------------------------------------------- -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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 -# -# http://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. -# ---------------------------------------------------------------------------- - -# ---------------------------------------------------------------------------- -# Maven2 Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir -# -# Optional ENV vars -# ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files -# ---------------------------------------------------------------------------- - -if [ -z "$MAVEN_SKIP_RC" ] ; then - - if [ -f /etc/mavenrc ] ; then - . /etc/mavenrc - fi - - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" - fi - -fi - -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home - # See https://developer.apple.com/library/mac/qa/qa1170/_index.html - if [ -z "$JAVA_HOME" ]; then - if [ -x "/usr/libexec/java_home" ]; then - export JAVA_HOME="`/usr/libexec/java_home`" - else - export JAVA_HOME="/Library/Java/Home" - fi - fi - ;; -esac - -if [ -z "$JAVA_HOME" ] ; then - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` - fi -fi - -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - 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 - - saveddir=`pwd` - - M2_HOME=`dirname "$PRG"`/.. - - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` - - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi - -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi - -# For Migwn, ensure paths are in UNIX format before anything is touched -if $mingw ; then - [ -n "$M2_HOME" ] && - M2_HOME="`(cd "$M2_HOME"; pwd)`" - [ -n "$JAVA_HOME" ] && - JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" - # TODO classpath? -fi - -if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" - else - javaExecutable="`readlink -f \"$javaExecutable\"`" - fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi - -if [ -z "$JAVACMD" ] ; then - 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 - else - JAVACMD="`which java`" - fi -fi - -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi - -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." -fi - -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher - -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { - - if [ -z "$1" ] - then - echo "Path not specified to find_maven_basedir" - return 1 - fi - - basedir="$1" - wdir="$1" - while [ "$wdir" != '/' ] ; do - if [ -d "$wdir"/.mvn ] ; then - basedir=$wdir - break - fi - # workaround for JBEAP-8937 (on Solaris 10/Sparc) - if [ -d "${wdir}" ]; then - wdir=`cd "$wdir/.."; pwd` - fi - # end of workaround - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" - fi -} - -BASE_DIR=`find_maven_basedir "$(pwd)"` -if [ -z "$BASE_DIR" ]; then - exit 1; -fi - -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} -echo $MAVEN_PROJECTBASEDIR -MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" - -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` - [ -n "$MAVEN_PROJECTBASEDIR" ] && - MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` -fi - -WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -exec "$JAVACMD" \ - $MAVEN_OPTS \ - -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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 +# +# http://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. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven2 Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + 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 + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Migwn, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" + # TODO classpath? +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + 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 + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +echo $MAVEN_PROJECTBASEDIR +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/mvnw.cmd b/mvnw.cmd index 019bd74d..48c810ef 100644 --- a/mvnw.cmd +++ b/mvnw.cmd @@ -1,143 +1,143 @@ -@REM ---------------------------------------------------------------------------- -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@REM "License"); you may not use this file except in compliance -@REM with the License. You may obtain a copy of the License at -@REM -@REM http://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, -@REM software distributed under the License is distributed on an -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. -@REM ---------------------------------------------------------------------------- - -@REM ---------------------------------------------------------------------------- -@REM Maven2 Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir -@REM -@REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files -@REM ---------------------------------------------------------------------------- - -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" - -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" + +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/pom.xml b/pom.xml index 9bd5d015..fdaab5e4 100644 --- a/pom.xml +++ b/pom.xml @@ -1,100 +1,104 @@ - - - 4.0.0 - - guru.springframework - testing-java-junit5 - 1.0-SNAPSHOT - - testing-java-junit5 - Testing Java with JUnit 5 - - - Spring Framework Guru - https://springframework.guru/ - - - - - jt - John Thompson - john@springframework.guru - - - - 2018 - - - - The Apache License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - - - - - UTF-8 - UTF-8 - 11 - ${java.version} - ${java.version} - 5.3.1 - - - - - javax.validation - validation-api - 2.0.1.Final - - - org.apache.commons - commons-lang3 - 3.8.1 - - - org.junit.jupiter - junit-jupiter-api - ${junit-platform.version} - test - - - org.junit.jupiter - junit-jupiter-engine - ${junit-platform.version} - test - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.0 - - - org.apache.maven.plugins - maven-surefire-plugin - 2.22.0 - - - --illegal-access=permit - - - - - org.apache.maven.plugins - maven-failsafe-plugin - 2.22.0 - - - --illegal-access=permit - - - - - - + + + 4.0.0 + + guru.springframework + testing-java-junit5 + 1.0-SNAPSHOT + + testing-java-junit5 + Testing Java with JUnit 5 + + + Spring Framework Guru + https://springframework.guru/ + + + + + jt + John Thompson + john@springframework.guru + + + + 2018 + + + + The Apache License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + + + + + UTF-8 + UTF-8 + 11 + ${java.version} + ${java.version} + 5.3.1 + + + + + javax.validation + validation-api + 2.0.1.Final + + + org.apache.commons + commons-lang3 + 3.8.1 + + + org.junit.jupiter + junit-jupiter-api + ${junit-platform.version} + test + + + org.junit.jupiter + junit-jupiter-engine + ${junit-platform.version} + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.0 + + 11 + 11 + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.0 + + + --illegal-access=permit + + + + + org.apache.maven.plugins + maven-failsafe-plugin + 2.22.0 + + + --illegal-access=permit + + + + + + \ No newline at end of file diff --git a/src/main/java/guru/springframework/sfgpetclinic/controllers/IndexController.java b/src/main/java/guru/springframework/sfgpetclinic/controllers/IndexController.java index 731a2119..767b7f77 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/controllers/IndexController.java +++ b/src/main/java/guru/springframework/sfgpetclinic/controllers/IndexController.java @@ -1,13 +1,13 @@ -package guru.springframework.sfgpetclinic.controllers; - -public class IndexController { - - public String index(){ - - return "index"; - } - - public String oupsHandler(){ - return "notimplemented"; - } -} +package guru.springframework.sfgpetclinic.controllers; + +public class IndexController { + + public String index(){ + + return "index"; + } + + public String oupsHandler(){ + return "notimplemented"; + } +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/controllers/OwnerController.java b/src/main/java/guru/springframework/sfgpetclinic/controllers/OwnerController.java index 76ceabdb..0da3763d 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/controllers/OwnerController.java +++ b/src/main/java/guru/springframework/sfgpetclinic/controllers/OwnerController.java @@ -1,91 +1,91 @@ -package guru.springframework.sfgpetclinic.controllers; - -import guru.springframework.sfgpetclinic.fauxspring.BindingResult; -import guru.springframework.sfgpetclinic.fauxspring.Model; -import guru.springframework.sfgpetclinic.fauxspring.ModelAndView; -import guru.springframework.sfgpetclinic.fauxspring.WebDataBinder; -import guru.springframework.sfgpetclinic.model.Owner; -import guru.springframework.sfgpetclinic.services.OwnerService; - -import javax.validation.Valid; -import java.util.List; - - -public class OwnerController { - private static final String VIEWS_OWNER_CREATE_OR_UPDATE_FORM = "owners/createOrUpdateOwnerForm"; - - private final OwnerService ownerService; - - public OwnerController(OwnerService ownerService) { - this.ownerService = ownerService; - } - - public void setAllowedFields(WebDataBinder dataBinder) { - dataBinder.setDisallowedFields("id"); - } - - public String findOwners(Model model){ - model.addAttribute("owner", new Owner(null, null, null)); - return "owners/findOwners"; - } - - public String processFindForm(Owner owner, BindingResult result, Model model){ - // allow parameterless GET request for /owners to return all records - if (owner.getLastName() == null) { - owner.setLastName(""); // empty string signifies broadest possible search - } - - // find owners by last name - List results = ownerService.findAllByLastNameLike("%"+ owner.getLastName() + "%"); - - if (results.isEmpty()) { - // no owners found - result.rejectValue("lastName", "notFound", "not found"); - return "owners/findOwners"; - } else if (results.size() == 1) { - // 1 owner found - owner = results.get(0); - return "redirect:/owners/" + owner.getId(); - } else { - // multiple owners found - model.addAttribute("selections", results); - return "owners/ownersList"; - } - } - - public ModelAndView showOwner(Long ownerId) { - ModelAndView mav = new ModelAndView("owners/ownerDetails"); - mav.addObject(ownerService.findById(ownerId)); - return mav; - } - - public String initCreationForm(Model model) { - model.addAttribute("owner", new Owner(null, null, null)); - return VIEWS_OWNER_CREATE_OR_UPDATE_FORM; - } - - public String processCreationForm(@Valid Owner owner, BindingResult result) { - if (result.hasErrors()) { - return VIEWS_OWNER_CREATE_OR_UPDATE_FORM; - } else { - Owner savedOwner = ownerService.save(owner); - return "redirect:/owners/" + savedOwner.getId(); - } - } - - public String initUpdateOwnerForm(Long ownerId, Model model) { - model.addAttribute(ownerService.findById(ownerId)); - return VIEWS_OWNER_CREATE_OR_UPDATE_FORM; - } - - public String processUpdateOwnerForm(@Valid Owner owner, BindingResult result, Long ownerId) { - if (result.hasErrors()) { - return VIEWS_OWNER_CREATE_OR_UPDATE_FORM; - } else { - owner.setId(ownerId); - Owner savedOwner = ownerService.save(owner); - return "redirect:/owners/" + savedOwner.getId(); - } - } - -} +package guru.springframework.sfgpetclinic.controllers; + +import guru.springframework.sfgpetclinic.fauxspring.BindingResult; +import guru.springframework.sfgpetclinic.fauxspring.Model; +import guru.springframework.sfgpetclinic.fauxspring.ModelAndView; +import guru.springframework.sfgpetclinic.fauxspring.WebDataBinder; +import guru.springframework.sfgpetclinic.model.Owner; +import guru.springframework.sfgpetclinic.services.OwnerService; + +import javax.validation.Valid; +import java.util.List; + + +public class OwnerController { + private static final String VIEWS_OWNER_CREATE_OR_UPDATE_FORM = "owners/createOrUpdateOwnerForm"; + + private final OwnerService ownerService; + + public OwnerController(OwnerService ownerService) { + this.ownerService = ownerService; + } + + public void setAllowedFields(WebDataBinder dataBinder) { + dataBinder.setDisallowedFields("id"); + } + + public String findOwners(Model model){ + model.addAttribute("owner", new Owner(null, null, null)); + return "owners/findOwners"; + } + + public String processFindForm(Owner owner, BindingResult result, Model model){ + // allow parameterless GET request for /owners to return all records + if (owner.getLastName() == null) { + owner.setLastName(""); // empty string signifies broadest possible search + } + + // find owners by last name + List results = ownerService.findAllByLastNameLike("%"+ owner.getLastName() + "%"); + + if (results.isEmpty()) { + // no owners found + result.rejectValue("lastName", "notFound", "not found"); + return "owners/findOwners"; + } else if (results.size() == 1) { + // 1 owner found + owner = results.get(0); + return "redirect:/owners/" + owner.getId(); + } else { + // multiple owners found + model.addAttribute("selections", results); + return "owners/ownersList"; + } + } + + public ModelAndView showOwner(Long ownerId) { + ModelAndView mav = new ModelAndView("owners/ownerDetails"); + mav.addObject(ownerService.findById(ownerId)); + return mav; + } + + public String initCreationForm(Model model) { + model.addAttribute("owner", new Owner(null, null, null)); + return VIEWS_OWNER_CREATE_OR_UPDATE_FORM; + } + + public String processCreationForm(@Valid Owner owner, BindingResult result) { + if (result.hasErrors()) { + return VIEWS_OWNER_CREATE_OR_UPDATE_FORM; + } else { + Owner savedOwner = ownerService.save(owner); + return "redirect:/owners/" + savedOwner.getId(); + } + } + + public String initUpdateOwnerForm(Long ownerId, Model model) { + model.addAttribute(ownerService.findById(ownerId)); + return VIEWS_OWNER_CREATE_OR_UPDATE_FORM; + } + + public String processUpdateOwnerForm(@Valid Owner owner, BindingResult result, Long ownerId) { + if (result.hasErrors()) { + return VIEWS_OWNER_CREATE_OR_UPDATE_FORM; + } else { + owner.setId(ownerId); + Owner savedOwner = ownerService.save(owner); + return "redirect:/owners/" + savedOwner.getId(); + } + } + +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/controllers/PetController.java b/src/main/java/guru/springframework/sfgpetclinic/controllers/PetController.java index 3c0a2395..73294bcc 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/controllers/PetController.java +++ b/src/main/java/guru/springframework/sfgpetclinic/controllers/PetController.java @@ -1,83 +1,83 @@ -package guru.springframework.sfgpetclinic.controllers; - -import guru.springframework.sfgpetclinic.fauxspring.BindingResult; -import guru.springframework.sfgpetclinic.fauxspring.Model; -import guru.springframework.sfgpetclinic.fauxspring.ModelMap; -import guru.springframework.sfgpetclinic.fauxspring.WebDataBinder; -import guru.springframework.sfgpetclinic.model.Owner; -import guru.springframework.sfgpetclinic.model.Pet; -import guru.springframework.sfgpetclinic.model.PetType; -import guru.springframework.sfgpetclinic.services.OwnerService; -import guru.springframework.sfgpetclinic.services.PetService; -import guru.springframework.sfgpetclinic.services.PetTypeService; -import org.apache.commons.lang3.StringUtils; - -import javax.validation.Valid; -import java.util.Collection; - -public class PetController { - - private static final String VIEWS_PETS_CREATE_OR_UPDATE_FORM = "pets/createOrUpdatePetForm"; - - private final PetService petService; - private final OwnerService ownerService; - private final PetTypeService petTypeService; - - public PetController(PetService petService, OwnerService ownerService, PetTypeService petTypeService) { - this.petService = petService; - this.ownerService = ownerService; - this.petTypeService = petTypeService; - } - - public Collection populatePetTypes() { - return petTypeService.findAll(); - } - - public Owner findOwner(Long ownerId) { - return ownerService.findById(ownerId); - } - - public void initOwnerBinder(WebDataBinder dataBinder) { - dataBinder.setDisallowedFields("id"); - } - - public String initCreationForm(Owner owner, Model model) { - Pet pet = new Pet(); - owner.getPets().add(pet); - pet.setOwner(owner); - model.addAttribute("pet", pet); - return VIEWS_PETS_CREATE_OR_UPDATE_FORM; - } - - public String processCreationForm(Owner owner, @Valid Pet pet, BindingResult result, ModelMap model) { - if (StringUtils.length(pet.getName()) > 0 && pet.isNew() && owner.getPet(pet.getName(), true) != null){ - result.rejectValue("name", "duplicate", "already exists"); - } - owner.getPets().add(pet); - if (result.hasErrors()) { - model.put("pet", pet); - return VIEWS_PETS_CREATE_OR_UPDATE_FORM; - } else { - petService.save(pet); - - return "redirect:/owners/" + owner.getId(); - } - } - - public String initUpdateForm(Long petId, Model model) { - model.addAttribute("pet", petService.findById(petId)); - return VIEWS_PETS_CREATE_OR_UPDATE_FORM; - } - - public String processUpdateForm(@Valid Pet pet, BindingResult result, Owner owner, Model model) { - if (result.hasErrors()) { - pet.setOwner(owner); - model.addAttribute("pet", pet); - return VIEWS_PETS_CREATE_OR_UPDATE_FORM; - } else { - owner.getPets().add(pet); - petService.save(pet); - return "redirect:/owners/" + owner.getId(); - } - } -} +package guru.springframework.sfgpetclinic.controllers; + +import guru.springframework.sfgpetclinic.fauxspring.BindingResult; +import guru.springframework.sfgpetclinic.fauxspring.Model; +import guru.springframework.sfgpetclinic.fauxspring.ModelMap; +import guru.springframework.sfgpetclinic.fauxspring.WebDataBinder; +import guru.springframework.sfgpetclinic.model.Owner; +import guru.springframework.sfgpetclinic.model.Pet; +import guru.springframework.sfgpetclinic.model.PetType; +import guru.springframework.sfgpetclinic.services.OwnerService; +import guru.springframework.sfgpetclinic.services.PetService; +import guru.springframework.sfgpetclinic.services.PetTypeService; +import org.apache.commons.lang3.StringUtils; + +import javax.validation.Valid; +import java.util.Collection; + +public class PetController { + + private static final String VIEWS_PETS_CREATE_OR_UPDATE_FORM = "pets/createOrUpdatePetForm"; + + private final PetService petService; + private final OwnerService ownerService; + private final PetTypeService petTypeService; + + public PetController(PetService petService, OwnerService ownerService, PetTypeService petTypeService) { + this.petService = petService; + this.ownerService = ownerService; + this.petTypeService = petTypeService; + } + + public Collection populatePetTypes() { + return petTypeService.findAll(); + } + + public Owner findOwner(Long ownerId) { + return ownerService.findById(ownerId); + } + + public void initOwnerBinder(WebDataBinder dataBinder) { + dataBinder.setDisallowedFields("id"); + } + + public String initCreationForm(Owner owner, Model model) { + Pet pet = new Pet(); + owner.getPets().add(pet); + pet.setOwner(owner); + model.addAttribute("pet", pet); + return VIEWS_PETS_CREATE_OR_UPDATE_FORM; + } + + public String processCreationForm(Owner owner, @Valid Pet pet, BindingResult result, ModelMap model) { + if (StringUtils.length(pet.getName()) > 0 && pet.isNew() && owner.getPet(pet.getName(), true) != null){ + result.rejectValue("name", "duplicate", "already exists"); + } + owner.getPets().add(pet); + if (result.hasErrors()) { + model.put("pet", pet); + return VIEWS_PETS_CREATE_OR_UPDATE_FORM; + } else { + petService.save(pet); + + return "redirect:/owners/" + owner.getId(); + } + } + + public String initUpdateForm(Long petId, Model model) { + model.addAttribute("pet", petService.findById(petId)); + return VIEWS_PETS_CREATE_OR_UPDATE_FORM; + } + + public String processUpdateForm(@Valid Pet pet, BindingResult result, Owner owner, Model model) { + if (result.hasErrors()) { + pet.setOwner(owner); + model.addAttribute("pet", pet); + return VIEWS_PETS_CREATE_OR_UPDATE_FORM; + } else { + owner.getPets().add(pet); + petService.save(pet); + return "redirect:/owners/" + owner.getId(); + } + } +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/controllers/VetController.java b/src/main/java/guru/springframework/sfgpetclinic/controllers/VetController.java index 6d6f8c20..a6b48767 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/controllers/VetController.java +++ b/src/main/java/guru/springframework/sfgpetclinic/controllers/VetController.java @@ -1,20 +1,20 @@ -package guru.springframework.sfgpetclinic.controllers; - -import guru.springframework.sfgpetclinic.fauxspring.Model; -import guru.springframework.sfgpetclinic.services.VetService; - -public class VetController { - - private final VetService vetService; - - public VetController(VetService vetService) { - this.vetService = vetService; - } - - public String listVets(Model model){ - - model.addAttribute("vets", vetService.findAll()); - - return "vets/index"; - } -} +package guru.springframework.sfgpetclinic.controllers; + +import guru.springframework.sfgpetclinic.fauxspring.Model; +import guru.springframework.sfgpetclinic.services.VetService; + +public class VetController { + + private final VetService vetService; + + public VetController(VetService vetService) { + this.vetService = vetService; + } + + public String listVets(Model model){ + + model.addAttribute("vets", vetService.findAll()); + + return "vets/index"; + } +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/controllers/VisitController.java b/src/main/java/guru/springframework/sfgpetclinic/controllers/VisitController.java index ec1c8a97..10149f9f 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/controllers/VisitController.java +++ b/src/main/java/guru/springframework/sfgpetclinic/controllers/VisitController.java @@ -1,50 +1,50 @@ -package guru.springframework.sfgpetclinic.controllers; - -import guru.springframework.sfgpetclinic.fauxspring.BindingResult; -import guru.springframework.sfgpetclinic.fauxspring.WebDataBinder; -import guru.springframework.sfgpetclinic.model.Pet; -import guru.springframework.sfgpetclinic.model.Visit; -import guru.springframework.sfgpetclinic.services.PetService; -import guru.springframework.sfgpetclinic.services.VisitService; - -import javax.validation.Valid; -import java.util.Map; - - -public class VisitController { - - private final VisitService visitService; - private final PetService petService; - - public VisitController(VisitService visitService, PetService petService) { - this.visitService = visitService; - this.petService = petService; - } - - public void setAllowedFields(WebDataBinder dataBinder) { - dataBinder.setDisallowedFields("id"); - } - - public Visit loadPetWithVisit(Long petId, Map model) { - Pet pet = petService.findById(petId); - model.put("pet", pet); - Visit visit = new Visit(); - pet.getVisits().add(visit); - visit.setPet(pet); - return visit; - } - - public String initNewVisitForm(Long petId, Map model) { - return "pets/createOrUpdateVisitForm"; - } - - public String processNewVisitForm(@Valid Visit visit, BindingResult result) { - if (result.hasErrors()) { - return "pets/createOrUpdateVisitForm"; - } else { - visitService.save(visit); - - return "redirect:/owners/{ownerId}"; - } - } -} +package guru.springframework.sfgpetclinic.controllers; + +import guru.springframework.sfgpetclinic.fauxspring.BindingResult; +import guru.springframework.sfgpetclinic.fauxspring.WebDataBinder; +import guru.springframework.sfgpetclinic.model.Pet; +import guru.springframework.sfgpetclinic.model.Visit; +import guru.springframework.sfgpetclinic.services.PetService; +import guru.springframework.sfgpetclinic.services.VisitService; + +import javax.validation.Valid; +import java.util.Map; + + +public class VisitController { + + private final VisitService visitService; + private final PetService petService; + + public VisitController(VisitService visitService, PetService petService) { + this.visitService = visitService; + this.petService = petService; + } + + public void setAllowedFields(WebDataBinder dataBinder) { + dataBinder.setDisallowedFields("id"); + } + + public Visit loadPetWithVisit(Long petId, Map model) { + Pet pet = petService.findById(petId); + model.put("pet", pet); + Visit visit = new Visit(); + pet.getVisits().add(visit); + visit.setPet(pet); + return visit; + } + + public String initNewVisitForm(Long petId, Map model) { + return "pets/createOrUpdateVisitForm"; + } + + public String processNewVisitForm(@Valid Visit visit, BindingResult result) { + if (result.hasErrors()) { + return "pets/createOrUpdateVisitForm"; + } else { + visitService.save(visit); + + return "redirect:/owners/{ownerId}"; + } + } +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/fauxspring/BindingResult.java b/src/main/java/guru/springframework/sfgpetclinic/fauxspring/BindingResult.java index 3df3bdd8..4bd7f19e 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/fauxspring/BindingResult.java +++ b/src/main/java/guru/springframework/sfgpetclinic/fauxspring/BindingResult.java @@ -1,8 +1,8 @@ -package guru.springframework.sfgpetclinic.fauxspring; - - -public interface BindingResult { - void rejectValue(String lastName, String notFound, String not_found); - - boolean hasErrors(); -} +package guru.springframework.sfgpetclinic.fauxspring; + + +public interface BindingResult { + void rejectValue(String lastName, String notFound, String not_found); + + boolean hasErrors(); +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/fauxspring/Formatter.java b/src/main/java/guru/springframework/sfgpetclinic/fauxspring/Formatter.java index 0ba8eb7d..18a28cd4 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/fauxspring/Formatter.java +++ b/src/main/java/guru/springframework/sfgpetclinic/fauxspring/Formatter.java @@ -1,14 +1,14 @@ -package guru.springframework.sfgpetclinic.fauxspring; - -import guru.springframework.sfgpetclinic.model.PetType; - -import java.text.ParseException; -import java.util.Locale; - - -public interface Formatter { - - String print(PetType petType, Locale locale); - - PetType parse(String text, Locale locale) throws ParseException; -} +package guru.springframework.sfgpetclinic.fauxspring; + +import guru.springframework.sfgpetclinic.model.PetType; + +import java.text.ParseException; +import java.util.Locale; + + +public interface Formatter { + + String print(PetType petType, Locale locale); + + PetType parse(String text, Locale locale) throws ParseException; +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/fauxspring/Model.java b/src/main/java/guru/springframework/sfgpetclinic/fauxspring/Model.java index 4a50a26b..71e318bd 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/fauxspring/Model.java +++ b/src/main/java/guru/springframework/sfgpetclinic/fauxspring/Model.java @@ -1,8 +1,8 @@ -package guru.springframework.sfgpetclinic.fauxspring; - -public interface Model { - - void addAttribute(String key, Object o); - - void addAttribute(Object o); -} +package guru.springframework.sfgpetclinic.fauxspring; + +public interface Model { + + void addAttribute(String key, Object o); + + void addAttribute(Object o); +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/fauxspring/ModelAndView.java b/src/main/java/guru/springframework/sfgpetclinic/fauxspring/ModelAndView.java index 6baa165f..f38a2539 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/fauxspring/ModelAndView.java +++ b/src/main/java/guru/springframework/sfgpetclinic/fauxspring/ModelAndView.java @@ -1,14 +1,14 @@ -package guru.springframework.sfgpetclinic.fauxspring; - - -public class ModelAndView { - - public ModelAndView() { - } - - public ModelAndView(String view) { - } - - public void addObject(Object o){} - -} +package guru.springframework.sfgpetclinic.fauxspring; + + +public class ModelAndView { + + public ModelAndView() { + } + + public ModelAndView(String view) { + } + + public void addObject(Object o){} + +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/fauxspring/ModelMap.java b/src/main/java/guru/springframework/sfgpetclinic/fauxspring/ModelMap.java index 5295200d..183984e9 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/fauxspring/ModelMap.java +++ b/src/main/java/guru/springframework/sfgpetclinic/fauxspring/ModelMap.java @@ -1,7 +1,7 @@ -package guru.springframework.sfgpetclinic.fauxspring; - -import guru.springframework.sfgpetclinic.model.Pet; - -public interface ModelMap { - void put(String pet, Pet pet1); -} +package guru.springframework.sfgpetclinic.fauxspring; + +import guru.springframework.sfgpetclinic.model.Pet; + +public interface ModelMap { + void put(String pet, Pet pet1); +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/fauxspring/WebDataBinder.java b/src/main/java/guru/springframework/sfgpetclinic/fauxspring/WebDataBinder.java index 9d117d20..47aeb88b 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/fauxspring/WebDataBinder.java +++ b/src/main/java/guru/springframework/sfgpetclinic/fauxspring/WebDataBinder.java @@ -1,5 +1,5 @@ -package guru.springframework.sfgpetclinic.fauxspring; - -public interface WebDataBinder { - void setDisallowedFields(String id); -} +package guru.springframework.sfgpetclinic.fauxspring; + +public interface WebDataBinder { + void setDisallowedFields(String id); +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/formatters/PetTypeFormatter.java b/src/main/java/guru/springframework/sfgpetclinic/formatters/PetTypeFormatter.java index bfcc4e05..da7dbca0 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/formatters/PetTypeFormatter.java +++ b/src/main/java/guru/springframework/sfgpetclinic/formatters/PetTypeFormatter.java @@ -1,37 +1,37 @@ -package guru.springframework.sfgpetclinic.formatters; - -import guru.springframework.sfgpetclinic.fauxspring.Formatter; -import guru.springframework.sfgpetclinic.model.PetType; -import guru.springframework.sfgpetclinic.services.PetTypeService; - -import java.text.ParseException; -import java.util.Collection; -import java.util.Locale; - - -public class PetTypeFormatter implements Formatter { - - private final PetTypeService petTypeService; - - public PetTypeFormatter(PetTypeService petTypeService) { - this.petTypeService = petTypeService; - } - - @Override - public String print(PetType petType, Locale locale) { - return petType.getName(); - } - - @Override - public PetType parse(String text, Locale locale) throws ParseException { - Collection findPetTypes = petTypeService.findAll(); - - for (PetType type : findPetTypes) { - if (type.getName().equals(text)) { - return type; - } - } - - throw new ParseException("type not found: " + text, 0); - } -} +package guru.springframework.sfgpetclinic.formatters; + +import guru.springframework.sfgpetclinic.fauxspring.Formatter; +import guru.springframework.sfgpetclinic.model.PetType; +import guru.springframework.sfgpetclinic.services.PetTypeService; + +import java.text.ParseException; +import java.util.Collection; +import java.util.Locale; + + +public class PetTypeFormatter implements Formatter { + + private final PetTypeService petTypeService; + + public PetTypeFormatter(PetTypeService petTypeService) { + this.petTypeService = petTypeService; + } + + @Override + public String print(PetType petType, Locale locale) { + return petType.getName(); + } + + @Override + public PetType parse(String text, Locale locale) throws ParseException { + Collection findPetTypes = petTypeService.findAll(); + + for (PetType type : findPetTypes) { + if (type.getName().equals(text)) { + return type; + } + } + + throw new ParseException("type not found: " + text, 0); + } +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/model/BaseEntity.java b/src/main/java/guru/springframework/sfgpetclinic/model/BaseEntity.java index 6e55bfa7..dcf327c6 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/model/BaseEntity.java +++ b/src/main/java/guru/springframework/sfgpetclinic/model/BaseEntity.java @@ -1,28 +1,28 @@ -package guru.springframework.sfgpetclinic.model; - -import java.io.Serializable; - - -public class BaseEntity implements Serializable { - - private Long id; - - public boolean isNew() { - return this.id == null; - } - - public BaseEntity() { - } - - public BaseEntity(Long id) { - this.id = id; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } -} +package guru.springframework.sfgpetclinic.model; + +import java.io.Serializable; + + +public class BaseEntity implements Serializable { + + private Long id; + + public boolean isNew() { + return this.id == null; + } + + public BaseEntity() { + } + + public BaseEntity(Long id) { + this.id = id; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/model/Owner.java b/src/main/java/guru/springframework/sfgpetclinic/model/Owner.java index cff63506..8350382c 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/model/Owner.java +++ b/src/main/java/guru/springframework/sfgpetclinic/model/Owner.java @@ -1,73 +1,73 @@ -package guru.springframework.sfgpetclinic.model; - - -import java.util.HashSet; -import java.util.Set; - -public class Owner extends Person { - - private String address; - private String city; - private String telephone; - private Set pets = new HashSet<>(); - - public Owner(Long id, String firstName, String lastName) { - super(id, firstName, lastName); - } - - public Pet getPet(String name) { - return getPet(name, false); - } - - /** - * Return the Pet with the given name, or null if none found for this Owner. - * - * @param name to test - * @return true if pet name is already in use - */ - public Pet getPet(String name, boolean ignoreNew) { - name = name.toLowerCase(); - for (Pet pet : pets) { - if (!ignoreNew || !pet.isNew()) { - String compName = pet.getName(); - compName = compName.toLowerCase(); - if (compName.equals(name)) { - return pet; - } - } - } - return null; - } - - public String getAddress() { - return address; - } - - public void setAddress(String address) { - this.address = address; - } - - public String getCity() { - return city; - } - - public void setCity(String city) { - this.city = city; - } - - public String getTelephone() { - return telephone; - } - - public void setTelephone(String telephone) { - this.telephone = telephone; - } - - public Set getPets() { - return pets; - } - - public void setPets(Set pets) { - this.pets = pets; - } -} +package guru.springframework.sfgpetclinic.model; + + +import java.util.HashSet; +import java.util.Set; + +public class Owner extends Person { + + private String address; + private String city; + private String telephone; + private Set pets = new HashSet<>(); + + public Owner(Long id, String firstName, String lastName) { + super(id, firstName, lastName); + } + + public Pet getPet(String name) { + return getPet(name, false); + } + + /** + * Return the Pet with the given name, or null if none found for this Owner. + * + * @param name to test + * @return true if pet name is already in use + */ + public Pet getPet(String name, boolean ignoreNew) { + name = name.toLowerCase(); + for (Pet pet : pets) { + if (!ignoreNew || !pet.isNew()) { + String compName = pet.getName(); + compName = compName.toLowerCase(); + if (compName.equals(name)) { + return pet; + } + } + } + return null; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getTelephone() { + return telephone; + } + + public void setTelephone(String telephone) { + this.telephone = telephone; + } + + public Set getPets() { + return pets; + } + + public void setPets(Set pets) { + this.pets = pets; + } +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/model/Person.java b/src/main/java/guru/springframework/sfgpetclinic/model/Person.java index 644850b8..a591e24c 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/model/Person.java +++ b/src/main/java/guru/springframework/sfgpetclinic/model/Person.java @@ -1,29 +1,29 @@ -package guru.springframework.sfgpetclinic.model; - -public class Person extends BaseEntity { - - public Person(Long id, String firstName, String lastName) { - super(id); - this.firstName = firstName; - this.lastName = lastName; - } - - private String firstName; - private String lastName; - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } -} +package guru.springframework.sfgpetclinic.model; + +public class Person extends BaseEntity { + + public Person(Long id, String firstName, String lastName) { + super(id); + this.firstName = firstName; + this.lastName = lastName; + } + + private String firstName; + private String lastName; + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/model/Pet.java b/src/main/java/guru/springframework/sfgpetclinic/model/Pet.java index 809014ff..45f27dc7 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/model/Pet.java +++ b/src/main/java/guru/springframework/sfgpetclinic/model/Pet.java @@ -1,62 +1,62 @@ -package guru.springframework.sfgpetclinic.model; - -import java.time.LocalDate; -import java.util.HashSet; -import java.util.Set; - - -public class Pet extends BaseEntity{ - - private String name; - private PetType petType; - private Owner owner; - private LocalDate birthDate; - private Set visits = new HashSet<>(); - - public Pet() { - } - - public Pet(Long id) { - super(id); - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public PetType getPetType() { - return petType; - } - - public void setPetType(PetType petType) { - this.petType = petType; - } - - public Owner getOwner() { - return owner; - } - - public void setOwner(Owner owner) { - this.owner = owner; - } - - public LocalDate getBirthDate() { - return birthDate; - } - - public void setBirthDate(LocalDate birthDate) { - this.birthDate = birthDate; - } - - public Set getVisits() { - return visits; - } - - public void setVisits(Set visits) { - this.visits = visits; - } -} +package guru.springframework.sfgpetclinic.model; + +import java.time.LocalDate; +import java.util.HashSet; +import java.util.Set; + + +public class Pet extends BaseEntity{ + + private String name; + private PetType petType; + private Owner owner; + private LocalDate birthDate; + private Set visits = new HashSet<>(); + + public Pet() { + } + + public Pet(Long id) { + super(id); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public PetType getPetType() { + return petType; + } + + public void setPetType(PetType petType) { + this.petType = petType; + } + + public Owner getOwner() { + return owner; + } + + public void setOwner(Owner owner) { + this.owner = owner; + } + + public LocalDate getBirthDate() { + return birthDate; + } + + public void setBirthDate(LocalDate birthDate) { + this.birthDate = birthDate; + } + + public Set getVisits() { + return visits; + } + + public void setVisits(Set visits) { + this.visits = visits; + } +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/model/PetType.java b/src/main/java/guru/springframework/sfgpetclinic/model/PetType.java index 5f6b339c..cd728c2e 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/model/PetType.java +++ b/src/main/java/guru/springframework/sfgpetclinic/model/PetType.java @@ -1,32 +1,32 @@ -package guru.springframework.sfgpetclinic.model; - - -public class PetType extends BaseEntity { - - private String name; - - @Override - public String toString() { - return name; - } - - public PetType() { - } - - public PetType(String name) { - this.name = name; - } - - public PetType(Long id, String name) { - super(id); - this.name = name; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} +package guru.springframework.sfgpetclinic.model; + + +public class PetType extends BaseEntity { + + private String name; + + @Override + public String toString() { + return name; + } + + public PetType() { + } + + public PetType(String name) { + this.name = name; + } + + public PetType(Long id, String name) { + super(id); + this.name = name; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/model/Speciality.java b/src/main/java/guru/springframework/sfgpetclinic/model/Speciality.java index e788c460..21c3322a 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/model/Speciality.java +++ b/src/main/java/guru/springframework/sfgpetclinic/model/Speciality.java @@ -1,25 +1,25 @@ -package guru.springframework.sfgpetclinic.model; - -public class Speciality extends BaseEntity { - private String description; - - public Speciality() { - } - - public Speciality(String description) { - this.description = description; - } - - public Speciality(Long id, String description) { - super(id); - this.description = description; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } -} +package guru.springframework.sfgpetclinic.model; + +public class Speciality extends BaseEntity { + private String description; + + public Speciality() { + } + + public Speciality(String description) { + this.description = description; + } + + public Speciality(Long id, String description) { + super(id); + this.description = description; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/model/Vet.java b/src/main/java/guru/springframework/sfgpetclinic/model/Vet.java index e2dca998..666e40ea 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/model/Vet.java +++ b/src/main/java/guru/springframework/sfgpetclinic/model/Vet.java @@ -1,23 +1,23 @@ -package guru.springframework.sfgpetclinic.model; - -import java.util.HashSet; -import java.util.Set; - - -public class Vet extends Person { - - private Set specialities = new HashSet<>(); - - public Vet(Long id, String firstName, String lastName, Set specialities) { - super(id, firstName, lastName); - this.specialities = specialities; - } - - public Set getSpecialities() { - return specialities; - } - - public void setSpecialities(Set specialities) { - this.specialities = specialities; - } -} +package guru.springframework.sfgpetclinic.model; + +import java.util.HashSet; +import java.util.Set; + + +public class Vet extends Person { + + private Set specialities = new HashSet<>(); + + public Vet(Long id, String firstName, String lastName, Set specialities) { + super(id, firstName, lastName); + this.specialities = specialities; + } + + public Set getSpecialities() { + return specialities; + } + + public void setSpecialities(Set specialities) { + this.specialities = specialities; + } +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/model/Visit.java b/src/main/java/guru/springframework/sfgpetclinic/model/Visit.java index 6e43cb4f..e716246f 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/model/Visit.java +++ b/src/main/java/guru/springframework/sfgpetclinic/model/Visit.java @@ -1,47 +1,47 @@ -package guru.springframework.sfgpetclinic.model; - -import java.time.LocalDate; - -public class Visit extends BaseEntity { - - private LocalDate date; - private String description; - private Pet pet; - - public Visit() { - super(null); - } - - public Visit(Long id) { - super(id); - } - - public Visit(Long id, LocalDate date) { - super(id); - this.date = date; - } - - public LocalDate getDate() { - return date; - } - - public void setDate(LocalDate date) { - this.date = date; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Pet getPet() { - return pet; - } - - public void setPet(Pet pet) { - this.pet = pet; - } -} +package guru.springframework.sfgpetclinic.model; + +import java.time.LocalDate; + +public class Visit extends BaseEntity { + + private LocalDate date; + private String description; + private Pet pet; + + public Visit() { + super(null); + } + + public Visit(Long id) { + super(id); + } + + public Visit(Long id, LocalDate date) { + super(id); + this.date = date; + } + + public LocalDate getDate() { + return date; + } + + public void setDate(LocalDate date) { + this.date = date; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Pet getPet() { + return pet; + } + + public void setPet(Pet pet) { + this.pet = pet; + } +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/repositories/CrudRepository.java b/src/main/java/guru/springframework/sfgpetclinic/repositories/CrudRepository.java index 96c781b2..ed8dfbb5 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/repositories/CrudRepository.java +++ b/src/main/java/guru/springframework/sfgpetclinic/repositories/CrudRepository.java @@ -1,93 +1,93 @@ -package guru.springframework.sfgpetclinic.repositories; - -import java.util.Optional; - -public interface CrudRepository extends Repository { - - /** - * Saves a given entity. Use the returned instance for further operations as the save operation might have changed the - * entity instance completely. - * - * @param entity must not be {@literal null}. - * @return the saved entity will never be {@literal null}. - */ - S save(S entity); - - /** - * Saves all given entities. - * - * @param entities must not be {@literal null}. - * @return the saved entities will never be {@literal null}. - * @throws IllegalArgumentException in case the given entity is {@literal null}. - */ - Iterable saveAll(Iterable entities); - - /** - * Retrieves an entity by its id. - * - * @param id must not be {@literal null}. - * @return the entity with the given id or {@literal Optional#empty()} if none found - * @throws IllegalArgumentException if {@code id} is {@literal null}. - */ - Optional findById(ID id); - - /** - * Returns whether an entity with the given id exists. - * - * @param id must not be {@literal null}. - * @return {@literal true} if an entity with the given id exists, {@literal false} otherwise. - * @throws IllegalArgumentException if {@code id} is {@literal null}. - */ - boolean existsById(ID id); - - /** - * Returns all instances of the type. - * - * @return all entities - */ - Iterable findAll(); - - /** - * Returns all instances of the type with the given IDs. - * - * @param ids - * @return - */ - Iterable findAllById(Iterable ids); - - /** - * Returns the number of entities available. - * - * @return the number of entities - */ - long count(); - - /** - * Deletes the entity with the given id. - * - * @param id must not be {@literal null}. - * @throws IllegalArgumentException in case the given {@code id} is {@literal null} - */ - void deleteById(ID id); - - /** - * Deletes a given entity. - * - * @param entity - * @throws IllegalArgumentException in case the given entity is {@literal null}. - */ - void delete(T entity); - - /** - * Deletes the given entities. - * - * @param entities - * @throws IllegalArgumentException in case the given {@link Iterable} is {@literal null}. - */ - void deleteAll(Iterable entities); - - /** - * Deletes all entities managed by the repository. - */ - void deleteAll(); +package guru.springframework.sfgpetclinic.repositories; + +import java.util.Optional; + +public interface CrudRepository extends Repository { + + /** + * Saves a given entity. Use the returned instance for further operations as the save operation might have changed the + * entity instance completely. + * + * @param entity must not be {@literal null}. + * @return the saved entity will never be {@literal null}. + */ + S save(S entity); + + /** + * Saves all given entities. + * + * @param entities must not be {@literal null}. + * @return the saved entities will never be {@literal null}. + * @throws IllegalArgumentException in case the given entity is {@literal null}. + */ + Iterable saveAll(Iterable entities); + + /** + * Retrieves an entity by its id. + * + * @param id must not be {@literal null}. + * @return the entity with the given id or {@literal Optional#empty()} if none found + * @throws IllegalArgumentException if {@code id} is {@literal null}. + */ + Optional findById(ID id); + + /** + * Returns whether an entity with the given id exists. + * + * @param id must not be {@literal null}. + * @return {@literal true} if an entity with the given id exists, {@literal false} otherwise. + * @throws IllegalArgumentException if {@code id} is {@literal null}. + */ + boolean existsById(ID id); + + /** + * Returns all instances of the type. + * + * @return all entities + */ + Iterable findAll(); + + /** + * Returns all instances of the type with the given IDs. + * + * @param ids + * @return + */ + Iterable findAllById(Iterable ids); + + /** + * Returns the number of entities available. + * + * @return the number of entities + */ + long count(); + + /** + * Deletes the entity with the given id. + * + * @param id must not be {@literal null}. + * @throws IllegalArgumentException in case the given {@code id} is {@literal null} + */ + void deleteById(ID id); + + /** + * Deletes a given entity. + * + * @param entity + * @throws IllegalArgumentException in case the given entity is {@literal null}. + */ + void delete(T entity); + + /** + * Deletes the given entities. + * + * @param entities + * @throws IllegalArgumentException in case the given {@link Iterable} is {@literal null}. + */ + void deleteAll(Iterable entities); + + /** + * Deletes all entities managed by the repository. + */ + void deleteAll(); } \ No newline at end of file diff --git a/src/main/java/guru/springframework/sfgpetclinic/repositories/OwnerRepository.java b/src/main/java/guru/springframework/sfgpetclinic/repositories/OwnerRepository.java index fa684140..03882864 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/repositories/OwnerRepository.java +++ b/src/main/java/guru/springframework/sfgpetclinic/repositories/OwnerRepository.java @@ -1,13 +1,13 @@ -package guru.springframework.sfgpetclinic.repositories; - - -import guru.springframework.sfgpetclinic.model.Owner; - -import java.util.List; - -public interface OwnerRepository extends CrudRepository { - - Owner findByLastName(String lastName); - - List findAllByLastNameLike(String lastName); -} +package guru.springframework.sfgpetclinic.repositories; + + +import guru.springframework.sfgpetclinic.model.Owner; + +import java.util.List; + +public interface OwnerRepository extends CrudRepository { + + Owner findByLastName(String lastName); + + List findAllByLastNameLike(String lastName); +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/repositories/PetRepository.java b/src/main/java/guru/springframework/sfgpetclinic/repositories/PetRepository.java index 0f32da8d..bcfd6112 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/repositories/PetRepository.java +++ b/src/main/java/guru/springframework/sfgpetclinic/repositories/PetRepository.java @@ -1,6 +1,6 @@ -package guru.springframework.sfgpetclinic.repositories; - -import guru.springframework.sfgpetclinic.model.Pet; - -public interface PetRepository extends CrudRepository { -} +package guru.springframework.sfgpetclinic.repositories; + +import guru.springframework.sfgpetclinic.model.Pet; + +public interface PetRepository extends CrudRepository { +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/repositories/PetTypeRepository.java b/src/main/java/guru/springframework/sfgpetclinic/repositories/PetTypeRepository.java index 39263411..e4d72e39 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/repositories/PetTypeRepository.java +++ b/src/main/java/guru/springframework/sfgpetclinic/repositories/PetTypeRepository.java @@ -1,6 +1,6 @@ -package guru.springframework.sfgpetclinic.repositories; - -import guru.springframework.sfgpetclinic.model.PetType; - -public interface PetTypeRepository extends CrudRepository { -} +package guru.springframework.sfgpetclinic.repositories; + +import guru.springframework.sfgpetclinic.model.PetType; + +public interface PetTypeRepository extends CrudRepository { +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/repositories/Repository.java b/src/main/java/guru/springframework/sfgpetclinic/repositories/Repository.java index 7a14fb9a..8141e269 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/repositories/Repository.java +++ b/src/main/java/guru/springframework/sfgpetclinic/repositories/Repository.java @@ -1,6 +1,6 @@ -package guru.springframework.sfgpetclinic.repositories; - - -public interface Repository { - +package guru.springframework.sfgpetclinic.repositories; + + +public interface Repository { + } \ No newline at end of file diff --git a/src/main/java/guru/springframework/sfgpetclinic/repositories/SpecialtyRepository.java b/src/main/java/guru/springframework/sfgpetclinic/repositories/SpecialtyRepository.java index 241ed070..fde1688c 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/repositories/SpecialtyRepository.java +++ b/src/main/java/guru/springframework/sfgpetclinic/repositories/SpecialtyRepository.java @@ -1,6 +1,6 @@ -package guru.springframework.sfgpetclinic.repositories; - -import guru.springframework.sfgpetclinic.model.Speciality; - -public interface SpecialtyRepository extends CrudRepository { -} +package guru.springframework.sfgpetclinic.repositories; + +import guru.springframework.sfgpetclinic.model.Speciality; + +public interface SpecialtyRepository extends CrudRepository { +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/repositories/VetRepository.java b/src/main/java/guru/springframework/sfgpetclinic/repositories/VetRepository.java index c19e85f6..dc6befbe 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/repositories/VetRepository.java +++ b/src/main/java/guru/springframework/sfgpetclinic/repositories/VetRepository.java @@ -1,6 +1,6 @@ -package guru.springframework.sfgpetclinic.repositories; - -import guru.springframework.sfgpetclinic.model.Vet; - -public interface VetRepository extends CrudRepository { -} +package guru.springframework.sfgpetclinic.repositories; + +import guru.springframework.sfgpetclinic.model.Vet; + +public interface VetRepository extends CrudRepository { +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/repositories/VisitRepository.java b/src/main/java/guru/springframework/sfgpetclinic/repositories/VisitRepository.java index 13bc7d39..4c5c8445 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/repositories/VisitRepository.java +++ b/src/main/java/guru/springframework/sfgpetclinic/repositories/VisitRepository.java @@ -1,6 +1,6 @@ -package guru.springframework.sfgpetclinic.repositories; - -import guru.springframework.sfgpetclinic.model.Visit; - -public interface VisitRepository extends CrudRepository { -} +package guru.springframework.sfgpetclinic.repositories; + +import guru.springframework.sfgpetclinic.model.Visit; + +public interface VisitRepository extends CrudRepository { +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/services/CrudService.java b/src/main/java/guru/springframework/sfgpetclinic/services/CrudService.java index 2d6fc3d7..004c0106 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/services/CrudService.java +++ b/src/main/java/guru/springframework/sfgpetclinic/services/CrudService.java @@ -1,16 +1,16 @@ -package guru.springframework.sfgpetclinic.services; - -import java.util.Set; - -public interface CrudService { - - Set findAll(); - - T findById(ID id); - - T save(T object); - - void delete(T object); - - void deleteById(ID id); -} +package guru.springframework.sfgpetclinic.services; + +import java.util.Set; + +public interface CrudService { + + Set findAll(); + + T findById(ID id); + + T save(T object); + + void delete(T object); + + void deleteById(ID id); +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/services/OwnerService.java b/src/main/java/guru/springframework/sfgpetclinic/services/OwnerService.java index 1af84af4..f652c7ce 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/services/OwnerService.java +++ b/src/main/java/guru/springframework/sfgpetclinic/services/OwnerService.java @@ -1,12 +1,12 @@ -package guru.springframework.sfgpetclinic.services; - -import guru.springframework.sfgpetclinic.model.Owner; - -import java.util.List; - -public interface OwnerService extends CrudService { - - Owner findByLastName(String lastName); - - List findAllByLastNameLike(String lastName); - } +package guru.springframework.sfgpetclinic.services; + +import guru.springframework.sfgpetclinic.model.Owner; + +import java.util.List; + +public interface OwnerService extends CrudService { + + Owner findByLastName(String lastName); + + List findAllByLastNameLike(String lastName); + } diff --git a/src/main/java/guru/springframework/sfgpetclinic/services/PetService.java b/src/main/java/guru/springframework/sfgpetclinic/services/PetService.java index e2655f30..cbcf0235 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/services/PetService.java +++ b/src/main/java/guru/springframework/sfgpetclinic/services/PetService.java @@ -1,10 +1,10 @@ -package guru.springframework.sfgpetclinic.services; - -import guru.springframework.sfgpetclinic.model.Pet; - -/** - * Created by jt on 7/18/18. - */ -public interface PetService extends CrudService { - -} +package guru.springframework.sfgpetclinic.services; + +import guru.springframework.sfgpetclinic.model.Pet; + +/** + * Created by jt on 7/18/18. + */ +public interface PetService extends CrudService { + +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/services/PetTypeService.java b/src/main/java/guru/springframework/sfgpetclinic/services/PetTypeService.java index 045b322c..07727137 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/services/PetTypeService.java +++ b/src/main/java/guru/springframework/sfgpetclinic/services/PetTypeService.java @@ -1,6 +1,6 @@ -package guru.springframework.sfgpetclinic.services; - -import guru.springframework.sfgpetclinic.model.PetType; - -public interface PetTypeService extends CrudService { -} +package guru.springframework.sfgpetclinic.services; + +import guru.springframework.sfgpetclinic.model.PetType; + +public interface PetTypeService extends CrudService { +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/services/SpecialtyService.java b/src/main/java/guru/springframework/sfgpetclinic/services/SpecialtyService.java index 5102d0b3..886b3c7d 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/services/SpecialtyService.java +++ b/src/main/java/guru/springframework/sfgpetclinic/services/SpecialtyService.java @@ -1,6 +1,6 @@ -package guru.springframework.sfgpetclinic.services; - -import guru.springframework.sfgpetclinic.model.Speciality; - -public interface SpecialtyService extends CrudService { -} +package guru.springframework.sfgpetclinic.services; + +import guru.springframework.sfgpetclinic.model.Speciality; + +public interface SpecialtyService extends CrudService { +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/services/VetService.java b/src/main/java/guru/springframework/sfgpetclinic/services/VetService.java index 4358d661..a908e99c 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/services/VetService.java +++ b/src/main/java/guru/springframework/sfgpetclinic/services/VetService.java @@ -1,7 +1,7 @@ -package guru.springframework.sfgpetclinic.services; - -import guru.springframework.sfgpetclinic.model.Vet; - -public interface VetService extends CrudService{ - -} +package guru.springframework.sfgpetclinic.services; + +import guru.springframework.sfgpetclinic.model.Vet; + +public interface VetService extends CrudService{ + +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/services/VisitService.java b/src/main/java/guru/springframework/sfgpetclinic/services/VisitService.java index 3b82a247..b606a121 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/services/VisitService.java +++ b/src/main/java/guru/springframework/sfgpetclinic/services/VisitService.java @@ -1,6 +1,6 @@ -package guru.springframework.sfgpetclinic.services; - -import guru.springframework.sfgpetclinic.model.Visit; - -public interface VisitService extends CrudService { -} +package guru.springframework.sfgpetclinic.services; + +import guru.springframework.sfgpetclinic.model.Visit; + +public interface VisitService extends CrudService { +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/services/map/AbstractMapService.java b/src/main/java/guru/springframework/sfgpetclinic/services/map/AbstractMapService.java index c12fee19..79b2ebb7 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/services/map/AbstractMapService.java +++ b/src/main/java/guru/springframework/sfgpetclinic/services/map/AbstractMapService.java @@ -1,55 +1,55 @@ -package guru.springframework.sfgpetclinic.services.map; - -import guru.springframework.sfgpetclinic.model.BaseEntity; - -import java.util.*; - - -public abstract class AbstractMapService { - - protected Map map = new HashMap<>(); - - Set findAll(){ - return new HashSet<>(map.values()); - } - - T findById(ID id) { - return map.get(id); - } - - T save(T object){ - - if(object != null) { - if(object.getId() == null){ - object.setId(getNextId()); - } - - map.put(object.getId(), object); - } else { - throw new RuntimeException("Object cannot be null"); - } - - return object; - } - - void deleteById(ID id){ - map.remove(id); - } - - void delete(T object){ - map.entrySet().removeIf(entry -> entry.getValue().equals(object)); - } - - private Long getNextId(){ - - Long nextId = null; - - try { - nextId = Collections.max(map.keySet()) + 1; - } catch (NoSuchElementException e) { - nextId = 1L; - } - - return nextId; - } -} +package guru.springframework.sfgpetclinic.services.map; + +import guru.springframework.sfgpetclinic.model.BaseEntity; + +import java.util.*; + + +public abstract class AbstractMapService { + + protected Map map = new HashMap<>(); + + Set findAll(){ + return new HashSet<>(map.values()); + } + + T findById(ID id) { + return map.get(id); + } + + T save(T object){ + + if(object != null) { + if(object.getId() == null){ + object.setId(getNextId()); + } + + map.put(object.getId(), object); + } else { + throw new RuntimeException("Object cannot be null"); + } + + return object; + } + + void deleteById(ID id){ + map.remove(id); + } + + void delete(T object){ + map.entrySet().removeIf(entry -> entry.getValue().equals(object)); + } + + private Long getNextId(){ + + Long nextId = null; + + try { + nextId = Collections.max(map.keySet()) + 1; + } catch (NoSuchElementException e) { + nextId = 1L; + } + + return nextId; + } +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/services/map/OwnerMapService.java b/src/main/java/guru/springframework/sfgpetclinic/services/map/OwnerMapService.java index 828abfad..6e1a7953 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/services/map/OwnerMapService.java +++ b/src/main/java/guru/springframework/sfgpetclinic/services/map/OwnerMapService.java @@ -1,85 +1,85 @@ -package guru.springframework.sfgpetclinic.services.map; - -import guru.springframework.sfgpetclinic.model.Owner; -import guru.springframework.sfgpetclinic.model.Pet; -import guru.springframework.sfgpetclinic.services.OwnerService; -import guru.springframework.sfgpetclinic.services.PetService; -import guru.springframework.sfgpetclinic.services.PetTypeService; - -import java.util.List; -import java.util.Set; - -public class OwnerMapService extends AbstractMapService implements OwnerService { - - private final PetTypeService petTypeService; - private final PetService petService; - - public OwnerMapService(PetTypeService petTypeService, PetService petService) { - this.petTypeService = petTypeService; - this.petService = petService; - } - - @Override - public Set findAll() { - return super.findAll(); - } - - @Override - public Owner findById(Long id) { - return super.findById(id); - } - - @Override - public Owner save(Owner object) { - - if(object != null){ - if (object.getPets() != null) { - object.getPets().forEach(pet -> { - if (pet.getPetType() != null){ - if(pet.getPetType().getId() == null){ - pet.setPetType(petTypeService.save(pet.getPetType())); - } - } else { - throw new RuntimeException("Pet Type is required"); - } - - if(pet.getId() == null){ - Pet savedPet = petService.save(pet); - pet.setId(savedPet.getId()); - } - }); - } - - return super.save(object); - - } else { - return null; - } - } - - @Override - public void delete(Owner object) { - super.delete(object); - } - - @Override - public void deleteById(Long id) { - super.deleteById(id); - } - - @Override - public Owner findByLastName(String lastName) { - return this.findAll() - .stream() - .filter(owner -> owner.getLastName().equalsIgnoreCase(lastName)) - .findFirst() - .orElse(null); - } - - @Override - public List findAllByLastNameLike(String lastName) { - - //todo - impl - return null; - } -} +package guru.springframework.sfgpetclinic.services.map; + +import guru.springframework.sfgpetclinic.model.Owner; +import guru.springframework.sfgpetclinic.model.Pet; +import guru.springframework.sfgpetclinic.services.OwnerService; +import guru.springframework.sfgpetclinic.services.PetService; +import guru.springframework.sfgpetclinic.services.PetTypeService; + +import java.util.List; +import java.util.Set; + +public class OwnerMapService extends AbstractMapService implements OwnerService { + + private final PetTypeService petTypeService; + private final PetService petService; + + public OwnerMapService(PetTypeService petTypeService, PetService petService) { + this.petTypeService = petTypeService; + this.petService = petService; + } + + @Override + public Set findAll() { + return super.findAll(); + } + + @Override + public Owner findById(Long id) { + return super.findById(id); + } + + @Override + public Owner save(Owner object) { + + if(object != null){ + if (object.getPets() != null) { + object.getPets().forEach(pet -> { + if (pet.getPetType() != null){ + if(pet.getPetType().getId() == null){ + pet.setPetType(petTypeService.save(pet.getPetType())); + } + } else { + throw new RuntimeException("Pet Type is required"); + } + + if(pet.getId() == null){ + Pet savedPet = petService.save(pet); + pet.setId(savedPet.getId()); + } + }); + } + + return super.save(object); + + } else { + return null; + } + } + + @Override + public void delete(Owner object) { + super.delete(object); + } + + @Override + public void deleteById(Long id) { + super.deleteById(id); + } + + @Override + public Owner findByLastName(String lastName) { + return this.findAll() + .stream() + .filter(owner -> owner.getLastName().equalsIgnoreCase(lastName)) + .findFirst() + .orElse(null); + } + + @Override + public List findAllByLastNameLike(String lastName) { + + //todo - impl + return null; + } +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/services/map/PetMapService.java b/src/main/java/guru/springframework/sfgpetclinic/services/map/PetMapService.java index 4454f252..17d54540 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/services/map/PetMapService.java +++ b/src/main/java/guru/springframework/sfgpetclinic/services/map/PetMapService.java @@ -1,34 +1,34 @@ -package guru.springframework.sfgpetclinic.services.map; - -import guru.springframework.sfgpetclinic.model.Pet; -import guru.springframework.sfgpetclinic.services.PetService; - -import java.util.Set; - - -public class PetMapService extends AbstractMapService implements PetService { - @Override - public Set findAll() { - return super.findAll(); - } - - @Override - public Pet findById(Long id) { - return super.findById(id); - } - - @Override - public Pet save(Pet object) { - return super.save(object); - } - - @Override - public void delete(Pet object) { - super.delete(object); - } - - @Override - public void deleteById(Long id) { - super.deleteById(id); - } -} +package guru.springframework.sfgpetclinic.services.map; + +import guru.springframework.sfgpetclinic.model.Pet; +import guru.springframework.sfgpetclinic.services.PetService; + +import java.util.Set; + + +public class PetMapService extends AbstractMapService implements PetService { + @Override + public Set findAll() { + return super.findAll(); + } + + @Override + public Pet findById(Long id) { + return super.findById(id); + } + + @Override + public Pet save(Pet object) { + return super.save(object); + } + + @Override + public void delete(Pet object) { + super.delete(object); + } + + @Override + public void deleteById(Long id) { + super.deleteById(id); + } +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/services/map/PetTypeMapService.java b/src/main/java/guru/springframework/sfgpetclinic/services/map/PetTypeMapService.java index f884dc42..c7454fbb 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/services/map/PetTypeMapService.java +++ b/src/main/java/guru/springframework/sfgpetclinic/services/map/PetTypeMapService.java @@ -1,34 +1,34 @@ -package guru.springframework.sfgpetclinic.services.map; - -import guru.springframework.sfgpetclinic.model.PetType; -import guru.springframework.sfgpetclinic.services.PetTypeService; - -import java.util.Set; - -public class PetTypeMapService extends AbstractMapService implements PetTypeService { - - @Override - public Set findAll() { - return super.findAll(); - } - - @Override - public PetType findById(Long id) { - return super.findById(id); - } - - @Override - public PetType save(PetType object) { - return super.save(object); - } - - @Override - public void delete(PetType object) { - super.delete(object); - } - - @Override - public void deleteById(Long id) { - super.deleteById(id); - } -} +package guru.springframework.sfgpetclinic.services.map; + +import guru.springframework.sfgpetclinic.model.PetType; +import guru.springframework.sfgpetclinic.services.PetTypeService; + +import java.util.Set; + +public class PetTypeMapService extends AbstractMapService implements PetTypeService { + + @Override + public Set findAll() { + return super.findAll(); + } + + @Override + public PetType findById(Long id) { + return super.findById(id); + } + + @Override + public PetType save(PetType object) { + return super.save(object); + } + + @Override + public void delete(PetType object) { + super.delete(object); + } + + @Override + public void deleteById(Long id) { + super.deleteById(id); + } +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/services/map/SpecialityMapService.java b/src/main/java/guru/springframework/sfgpetclinic/services/map/SpecialityMapService.java index b781ac1c..42d7ebbe 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/services/map/SpecialityMapService.java +++ b/src/main/java/guru/springframework/sfgpetclinic/services/map/SpecialityMapService.java @@ -1,34 +1,34 @@ -package guru.springframework.sfgpetclinic.services.map; - -import guru.springframework.sfgpetclinic.model.Speciality; -import guru.springframework.sfgpetclinic.services.SpecialtyService; - -import java.util.Set; - -public class SpecialityMapService extends AbstractMapService implements SpecialtyService { - - @Override - public Set findAll() { - return super.findAll(); - } - - @Override - public Speciality findById(Long id) { - return super.findById(id); - } - - @Override - public Speciality save(Speciality object) { - return super.save(object); - } - - @Override - public void delete(Speciality object) { - super.delete(object); - } - - @Override - public void deleteById(Long id) { - super.deleteById(id); - } -} +package guru.springframework.sfgpetclinic.services.map; + +import guru.springframework.sfgpetclinic.model.Speciality; +import guru.springframework.sfgpetclinic.services.SpecialtyService; + +import java.util.Set; + +public class SpecialityMapService extends AbstractMapService implements SpecialtyService { + + @Override + public Set findAll() { + return super.findAll(); + } + + @Override + public Speciality findById(Long id) { + return super.findById(id); + } + + @Override + public Speciality save(Speciality object) { + return super.save(object); + } + + @Override + public void delete(Speciality object) { + super.delete(object); + } + + @Override + public void deleteById(Long id) { + super.deleteById(id); + } +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/services/map/VetMapService.java b/src/main/java/guru/springframework/sfgpetclinic/services/map/VetMapService.java index c94fe453..1b2a8422 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/services/map/VetMapService.java +++ b/src/main/java/guru/springframework/sfgpetclinic/services/map/VetMapService.java @@ -1,52 +1,52 @@ -package guru.springframework.sfgpetclinic.services.map; - -import guru.springframework.sfgpetclinic.model.Speciality; -import guru.springframework.sfgpetclinic.model.Vet; -import guru.springframework.sfgpetclinic.services.SpecialtyService; -import guru.springframework.sfgpetclinic.services.VetService; - -import java.util.Set; - -public class VetMapService extends AbstractMapService implements VetService { - - private final SpecialtyService specialtyService; - - public VetMapService(SpecialtyService specialtyService) { - this.specialtyService = specialtyService; - } - - @Override - public Set findAll() { - return super.findAll(); - } - - @Override - public Vet findById(Long id) { - return super.findById(id); - } - - @Override - public Vet save(Vet object) { - - if (object.getSpecialities().size() > 0){ - object.getSpecialities().forEach(speciality -> { - if(speciality.getId() == null){ - Speciality savedSpecialty = specialtyService.save(speciality); - speciality.setId(savedSpecialty.getId()); - } - }); - } - - return super.save(object); - } - - @Override - public void delete(Vet object) { - super.delete(object); - } - - @Override - public void deleteById(Long id) { - super.deleteById(id); - } -} +package guru.springframework.sfgpetclinic.services.map; + +import guru.springframework.sfgpetclinic.model.Speciality; +import guru.springframework.sfgpetclinic.model.Vet; +import guru.springframework.sfgpetclinic.services.SpecialtyService; +import guru.springframework.sfgpetclinic.services.VetService; + +import java.util.Set; + +public class VetMapService extends AbstractMapService implements VetService { + + private final SpecialtyService specialtyService; + + public VetMapService(SpecialtyService specialtyService) { + this.specialtyService = specialtyService; + } + + @Override + public Set findAll() { + return super.findAll(); + } + + @Override + public Vet findById(Long id) { + return super.findById(id); + } + + @Override + public Vet save(Vet object) { + + if (object.getSpecialities().size() > 0){ + object.getSpecialities().forEach(speciality -> { + if(speciality.getId() == null){ + Speciality savedSpecialty = specialtyService.save(speciality); + speciality.setId(savedSpecialty.getId()); + } + }); + } + + return super.save(object); + } + + @Override + public void delete(Vet object) { + super.delete(object); + } + + @Override + public void deleteById(Long id) { + super.deleteById(id); + } +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/services/map/VisitMapService.java b/src/main/java/guru/springframework/sfgpetclinic/services/map/VisitMapService.java index b9afc94c..88cf3ce4 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/services/map/VisitMapService.java +++ b/src/main/java/guru/springframework/sfgpetclinic/services/map/VisitMapService.java @@ -1,40 +1,40 @@ -package guru.springframework.sfgpetclinic.services.map; - -import guru.springframework.sfgpetclinic.model.Visit; -import guru.springframework.sfgpetclinic.services.VisitService; - -import java.util.Set; - -public class VisitMapService extends AbstractMapService implements VisitService { - - @Override - public Set findAll() { - return super.findAll(); - } - - @Override - public Visit findById(Long id) { - return super.findById(id); - } - - @Override - public Visit save(Visit visit) { - - if(visit.getPet() == null || visit.getPet().getOwner() == null || visit.getPet().getId() == null - || visit.getPet().getOwner().getId() == null){ - throw new RuntimeException("Invalid Visit"); - } - - return super.save(visit); - } - - @Override - public void delete(Visit object) { - super.delete(object); - } - - @Override - public void deleteById(Long id) { - super.deleteById(id); - } -} +package guru.springframework.sfgpetclinic.services.map; + +import guru.springframework.sfgpetclinic.model.Visit; +import guru.springframework.sfgpetclinic.services.VisitService; + +import java.util.Set; + +public class VisitMapService extends AbstractMapService implements VisitService { + + @Override + public Set findAll() { + return super.findAll(); + } + + @Override + public Visit findById(Long id) { + return super.findById(id); + } + + @Override + public Visit save(Visit visit) { + + if(visit.getPet() == null || visit.getPet().getOwner() == null || visit.getPet().getId() == null + || visit.getPet().getOwner().getId() == null){ + throw new RuntimeException("Invalid Visit"); + } + + return super.save(visit); + } + + @Override + public void delete(Visit object) { + super.delete(object); + } + + @Override + public void deleteById(Long id) { + super.deleteById(id); + } +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/services/springdatajpa/OwnerSDJpaService.java b/src/main/java/guru/springframework/sfgpetclinic/services/springdatajpa/OwnerSDJpaService.java index 4eaaf8b2..aba3803f 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/services/springdatajpa/OwnerSDJpaService.java +++ b/src/main/java/guru/springframework/sfgpetclinic/services/springdatajpa/OwnerSDJpaService.java @@ -1,62 +1,62 @@ -package guru.springframework.sfgpetclinic.services.springdatajpa; - -import guru.springframework.sfgpetclinic.model.Owner; -import guru.springframework.sfgpetclinic.repositories.OwnerRepository; -import guru.springframework.sfgpetclinic.repositories.PetRepository; -import guru.springframework.sfgpetclinic.repositories.PetTypeRepository; -import guru.springframework.sfgpetclinic.services.OwnerService; - -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -public class OwnerSDJpaService implements OwnerService { - - private final OwnerRepository ownerRepository; - private final PetRepository petRepository; - private final PetTypeRepository petTypeRepository; - - public OwnerSDJpaService(OwnerRepository ownerRepository, PetRepository petRepository, - PetTypeRepository petTypeRepository) { - this.ownerRepository = ownerRepository; - this.petRepository = petRepository; - this.petTypeRepository = petTypeRepository; - } - - @Override - public Owner findByLastName(String lastName) { - return ownerRepository.findByLastName(lastName); - } - - @Override - public List findAllByLastNameLike(String lastName) { - return ownerRepository.findAllByLastNameLike(lastName); - } - - @Override - public Set findAll() { - Set owners = new HashSet<>(); - ownerRepository.findAll().forEach(owners::add); - return owners; - } - - @Override - public Owner findById(Long aLong) { - return ownerRepository.findById(aLong).orElse(null); - } - - @Override - public Owner save(Owner object) { - return ownerRepository.save(object); - } - - @Override - public void delete(Owner object) { - ownerRepository.delete(object); - } - - @Override - public void deleteById(Long aLong) { - ownerRepository.deleteById(aLong); - } -} +package guru.springframework.sfgpetclinic.services.springdatajpa; + +import guru.springframework.sfgpetclinic.model.Owner; +import guru.springframework.sfgpetclinic.repositories.OwnerRepository; +import guru.springframework.sfgpetclinic.repositories.PetRepository; +import guru.springframework.sfgpetclinic.repositories.PetTypeRepository; +import guru.springframework.sfgpetclinic.services.OwnerService; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class OwnerSDJpaService implements OwnerService { + + private final OwnerRepository ownerRepository; + private final PetRepository petRepository; + private final PetTypeRepository petTypeRepository; + + public OwnerSDJpaService(OwnerRepository ownerRepository, PetRepository petRepository, + PetTypeRepository petTypeRepository) { + this.ownerRepository = ownerRepository; + this.petRepository = petRepository; + this.petTypeRepository = petTypeRepository; + } + + @Override + public Owner findByLastName(String lastName) { + return ownerRepository.findByLastName(lastName); + } + + @Override + public List findAllByLastNameLike(String lastName) { + return ownerRepository.findAllByLastNameLike(lastName); + } + + @Override + public Set findAll() { + Set owners = new HashSet<>(); + ownerRepository.findAll().forEach(owners::add); + return owners; + } + + @Override + public Owner findById(Long aLong) { + return ownerRepository.findById(aLong).orElse(null); + } + + @Override + public Owner save(Owner object) { + return ownerRepository.save(object); + } + + @Override + public void delete(Owner object) { + ownerRepository.delete(object); + } + + @Override + public void deleteById(Long aLong) { + ownerRepository.deleteById(aLong); + } +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/services/springdatajpa/PetSDJpaService.java b/src/main/java/guru/springframework/sfgpetclinic/services/springdatajpa/PetSDJpaService.java index 687ce72e..487e4539 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/services/springdatajpa/PetSDJpaService.java +++ b/src/main/java/guru/springframework/sfgpetclinic/services/springdatajpa/PetSDJpaService.java @@ -1,45 +1,45 @@ -package guru.springframework.sfgpetclinic.services.springdatajpa; - -import guru.springframework.sfgpetclinic.model.Pet; -import guru.springframework.sfgpetclinic.repositories.PetRepository; -import guru.springframework.sfgpetclinic.services.PetService; - -import java.util.HashSet; -import java.util.Set; - - -public class PetSDJpaService implements PetService { - - private final PetRepository petRepository; - - public PetSDJpaService(PetRepository petRepository) { - this.petRepository = petRepository; - } - - @Override - public Set findAll() { - Set pets = new HashSet<>(); - petRepository.findAll().forEach(pets::add); - return pets; - } - - @Override - public Pet findById(Long aLong) { - return petRepository.findById(aLong).orElse(null); - } - - @Override - public Pet save(Pet object) { - return petRepository.save(object); - } - - @Override - public void delete(Pet object) { - petRepository.delete(object); - } - - @Override - public void deleteById(Long aLong) { - petRepository.deleteById(aLong); - } -} +package guru.springframework.sfgpetclinic.services.springdatajpa; + +import guru.springframework.sfgpetclinic.model.Pet; +import guru.springframework.sfgpetclinic.repositories.PetRepository; +import guru.springframework.sfgpetclinic.services.PetService; + +import java.util.HashSet; +import java.util.Set; + + +public class PetSDJpaService implements PetService { + + private final PetRepository petRepository; + + public PetSDJpaService(PetRepository petRepository) { + this.petRepository = petRepository; + } + + @Override + public Set findAll() { + Set pets = new HashSet<>(); + petRepository.findAll().forEach(pets::add); + return pets; + } + + @Override + public Pet findById(Long aLong) { + return petRepository.findById(aLong).orElse(null); + } + + @Override + public Pet save(Pet object) { + return petRepository.save(object); + } + + @Override + public void delete(Pet object) { + petRepository.delete(object); + } + + @Override + public void deleteById(Long aLong) { + petRepository.deleteById(aLong); + } +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/services/springdatajpa/PetTypeSDJpaService.java b/src/main/java/guru/springframework/sfgpetclinic/services/springdatajpa/PetTypeSDJpaService.java index d152fcc3..a30f1833 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/services/springdatajpa/PetTypeSDJpaService.java +++ b/src/main/java/guru/springframework/sfgpetclinic/services/springdatajpa/PetTypeSDJpaService.java @@ -1,45 +1,45 @@ -package guru.springframework.sfgpetclinic.services.springdatajpa; - -import guru.springframework.sfgpetclinic.model.PetType; -import guru.springframework.sfgpetclinic.repositories.PetTypeRepository; -import guru.springframework.sfgpetclinic.services.PetTypeService; - -import java.util.HashSet; -import java.util.Set; - - -public class PetTypeSDJpaService implements PetTypeService { - - private final PetTypeRepository petTypeRepository; - - public PetTypeSDJpaService(PetTypeRepository petTypeRepository) { - this.petTypeRepository = petTypeRepository; - } - - @Override - public Set findAll() { - Set petTypes = new HashSet<>(); - petTypeRepository.findAll().forEach(petTypes::add); - return petTypes; - } - - @Override - public PetType findById(Long aLong) { - return petTypeRepository.findById(aLong).orElse(null); - } - - @Override - public PetType save(PetType object) { - return petTypeRepository.save(object); - } - - @Override - public void delete(PetType object) { - petTypeRepository.delete(object); - } - - @Override - public void deleteById(Long aLong) { - petTypeRepository.deleteById(aLong); - } -} +package guru.springframework.sfgpetclinic.services.springdatajpa; + +import guru.springframework.sfgpetclinic.model.PetType; +import guru.springframework.sfgpetclinic.repositories.PetTypeRepository; +import guru.springframework.sfgpetclinic.services.PetTypeService; + +import java.util.HashSet; +import java.util.Set; + + +public class PetTypeSDJpaService implements PetTypeService { + + private final PetTypeRepository petTypeRepository; + + public PetTypeSDJpaService(PetTypeRepository petTypeRepository) { + this.petTypeRepository = petTypeRepository; + } + + @Override + public Set findAll() { + Set petTypes = new HashSet<>(); + petTypeRepository.findAll().forEach(petTypes::add); + return petTypes; + } + + @Override + public PetType findById(Long aLong) { + return petTypeRepository.findById(aLong).orElse(null); + } + + @Override + public PetType save(PetType object) { + return petTypeRepository.save(object); + } + + @Override + public void delete(PetType object) { + petTypeRepository.delete(object); + } + + @Override + public void deleteById(Long aLong) { + petTypeRepository.deleteById(aLong); + } +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/services/springdatajpa/SpecialitySDJpaService.java b/src/main/java/guru/springframework/sfgpetclinic/services/springdatajpa/SpecialitySDJpaService.java index 6cadbb67..c0955db4 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/services/springdatajpa/SpecialitySDJpaService.java +++ b/src/main/java/guru/springframework/sfgpetclinic/services/springdatajpa/SpecialitySDJpaService.java @@ -1,45 +1,45 @@ -package guru.springframework.sfgpetclinic.services.springdatajpa; - -import guru.springframework.sfgpetclinic.model.Speciality; -import guru.springframework.sfgpetclinic.repositories.SpecialtyRepository; -import guru.springframework.sfgpetclinic.services.SpecialtyService; - -import java.util.HashSet; -import java.util.Set; - - -public class SpecialitySDJpaService implements SpecialtyService { - - private final SpecialtyRepository specialtyRepository; - - public SpecialitySDJpaService(SpecialtyRepository specialtyRepository) { - this.specialtyRepository = specialtyRepository; - } - - @Override - public Set findAll() { - Set specialities = new HashSet<>(); - specialtyRepository.findAll().forEach(specialities::add); - return specialities; - } - - @Override - public Speciality findById(Long aLong) { - return specialtyRepository.findById(aLong).orElse(null); - } - - @Override - public Speciality save(Speciality object) { - return specialtyRepository.save(object); - } - - @Override - public void delete(Speciality object) { - specialtyRepository.delete(object); - } - - @Override - public void deleteById(Long aLong) { - specialtyRepository.deleteById(aLong); - } -} +package guru.springframework.sfgpetclinic.services.springdatajpa; + +import guru.springframework.sfgpetclinic.model.Speciality; +import guru.springframework.sfgpetclinic.repositories.SpecialtyRepository; +import guru.springframework.sfgpetclinic.services.SpecialtyService; + +import java.util.HashSet; +import java.util.Set; + + +public class SpecialitySDJpaService implements SpecialtyService { + + private final SpecialtyRepository specialtyRepository; + + public SpecialitySDJpaService(SpecialtyRepository specialtyRepository) { + this.specialtyRepository = specialtyRepository; + } + + @Override + public Set findAll() { + Set specialities = new HashSet<>(); + specialtyRepository.findAll().forEach(specialities::add); + return specialities; + } + + @Override + public Speciality findById(Long aLong) { + return specialtyRepository.findById(aLong).orElse(null); + } + + @Override + public Speciality save(Speciality object) { + return specialtyRepository.save(object); + } + + @Override + public void delete(Speciality object) { + specialtyRepository.delete(object); + } + + @Override + public void deleteById(Long aLong) { + specialtyRepository.deleteById(aLong); + } +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/services/springdatajpa/VetSDJpaService.java b/src/main/java/guru/springframework/sfgpetclinic/services/springdatajpa/VetSDJpaService.java index 9028b6b3..893a7077 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/services/springdatajpa/VetSDJpaService.java +++ b/src/main/java/guru/springframework/sfgpetclinic/services/springdatajpa/VetSDJpaService.java @@ -1,44 +1,44 @@ -package guru.springframework.sfgpetclinic.services.springdatajpa; - -import guru.springframework.sfgpetclinic.model.Vet; -import guru.springframework.sfgpetclinic.repositories.VetRepository; -import guru.springframework.sfgpetclinic.services.VetService; - -import java.util.HashSet; -import java.util.Set; - -public class VetSDJpaService implements VetService { - - private final VetRepository vetRepository; - - public VetSDJpaService(VetRepository vetRepository) { - this.vetRepository = vetRepository; - } - - @Override - public Set findAll() { - Set vets = new HashSet<>(); - vetRepository.findAll().forEach(vets::add); - return vets; - } - - @Override - public Vet findById(Long aLong) { - return vetRepository.findById(aLong).orElse(null); - } - - @Override - public Vet save(Vet object) { - return vetRepository.save(object); - } - - @Override - public void delete(Vet object) { - vetRepository.delete(object); - } - - @Override - public void deleteById(Long aLong) { - vetRepository.deleteById(aLong); - } -} +package guru.springframework.sfgpetclinic.services.springdatajpa; + +import guru.springframework.sfgpetclinic.model.Vet; +import guru.springframework.sfgpetclinic.repositories.VetRepository; +import guru.springframework.sfgpetclinic.services.VetService; + +import java.util.HashSet; +import java.util.Set; + +public class VetSDJpaService implements VetService { + + private final VetRepository vetRepository; + + public VetSDJpaService(VetRepository vetRepository) { + this.vetRepository = vetRepository; + } + + @Override + public Set findAll() { + Set vets = new HashSet<>(); + vetRepository.findAll().forEach(vets::add); + return vets; + } + + @Override + public Vet findById(Long aLong) { + return vetRepository.findById(aLong).orElse(null); + } + + @Override + public Vet save(Vet object) { + return vetRepository.save(object); + } + + @Override + public void delete(Vet object) { + vetRepository.delete(object); + } + + @Override + public void deleteById(Long aLong) { + vetRepository.deleteById(aLong); + } +} diff --git a/src/main/java/guru/springframework/sfgpetclinic/services/springdatajpa/VisitSDJpaService.java b/src/main/java/guru/springframework/sfgpetclinic/services/springdatajpa/VisitSDJpaService.java index b914429d..6dadf589 100644 --- a/src/main/java/guru/springframework/sfgpetclinic/services/springdatajpa/VisitSDJpaService.java +++ b/src/main/java/guru/springframework/sfgpetclinic/services/springdatajpa/VisitSDJpaService.java @@ -1,44 +1,44 @@ -package guru.springframework.sfgpetclinic.services.springdatajpa; - -import guru.springframework.sfgpetclinic.model.Visit; -import guru.springframework.sfgpetclinic.repositories.VisitRepository; -import guru.springframework.sfgpetclinic.services.VisitService; - -import java.util.HashSet; -import java.util.Set; - -public class VisitSDJpaService implements VisitService { - - private final VisitRepository visitRepository; - - public VisitSDJpaService(VisitRepository visitRepository) { - this.visitRepository = visitRepository; - } - - @Override - public Set findAll() { - Set visits = new HashSet<>(); - visitRepository.findAll().forEach(visits::add); - return visits; - } - - @Override - public Visit findById(Long aLong) { - return visitRepository.findById(aLong).orElse(null); - } - - @Override - public Visit save(Visit object) { - return visitRepository.save(object); - } - - @Override - public void delete(Visit object) { - visitRepository.delete(object); - } - - @Override - public void deleteById(Long aLong) { - visitRepository.deleteById(aLong); - } -} +package guru.springframework.sfgpetclinic.services.springdatajpa; + +import guru.springframework.sfgpetclinic.model.Visit; +import guru.springframework.sfgpetclinic.repositories.VisitRepository; +import guru.springframework.sfgpetclinic.services.VisitService; + +import java.util.HashSet; +import java.util.Set; + +public class VisitSDJpaService implements VisitService { + + private final VisitRepository visitRepository; + + public VisitSDJpaService(VisitRepository visitRepository) { + this.visitRepository = visitRepository; + } + + @Override + public Set findAll() { + Set visits = new HashSet<>(); + visitRepository.findAll().forEach(visits::add); + return visits; + } + + @Override + public Visit findById(Long aLong) { + return visitRepository.findById(aLong).orElse(null); + } + + @Override + public Visit save(Visit object) { + return visitRepository.save(object); + } + + @Override + public void delete(Visit object) { + visitRepository.delete(object); + } + + @Override + public void deleteById(Long aLong) { + visitRepository.deleteById(aLong); + } +} From ced29f732c6de259c74c1f06cb972ee780e25f18 Mon Sep 17 00:00:00 2001 From: Chris Jurrens Date: Wed, 24 Jun 2020 20:52:52 -0500 Subject: [PATCH 5/6] creating new config.yml for circleci --- .circleci/config.yml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ed1de9e8..e937f4f4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,4 +6,23 @@ orbs: workflows: maven_test: jobs: - - maven/test # checkout, build, test, and upload test results + build: + docker: + - image: circleci/openjdk:11-browser-legacy + working_directory: ~/repo + + environment: + MAVEN_OPTS: -Xmx3200m + + steps: + - checkout + - restore cache: + keys: + - v1-dependencies={{ checksum "pom.xml" }} + - v1-dependencies- + - run: mvn dependency:go-offline + - save_cache: + paths: + - ~/.m2 + key: v1-dependencies-{{ checksum "pom.xml" }} + - run: mvn integration-test \ No newline at end of file From 6e2cddad3d55ef370e13a8e9efbd7dcd8dc52091 Mon Sep 17 00:00:00 2001 From: Chris Jurrens Date: Wed, 24 Jun 2020 20:54:45 -0500 Subject: [PATCH 6/6] just copying the config.yml --- .circleci/config.yml | 69 ++++++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 28 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e937f4f4..c60b4ff8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,28 +1,41 @@ -version: 2.1 - -orbs: - maven: circleci/maven@0.0.12 - -workflows: - maven_test: - jobs: - build: - docker: - - image: circleci/openjdk:11-browser-legacy - working_directory: ~/repo - - environment: - MAVEN_OPTS: -Xmx3200m - - steps: - - checkout - - restore cache: - keys: - - v1-dependencies={{ checksum "pom.xml" }} - - v1-dependencies- - - run: mvn dependency:go-offline - - save_cache: - paths: - - ~/.m2 - key: v1-dependencies-{{ checksum "pom.xml" }} - - run: mvn integration-test \ No newline at end of file +# Java Maven CircleCI 2.0 configuration file +# +# Check https://circleci.com/docs/2.0/language-java/ for more details +# +version: 2 +jobs: + build: + docker: + # specify the version you desire here + - image: circleci/openjdk:11-browsers-legacy + + # Specify service dependencies here if necessary + # CircleCI maintains a library of pre-built images + # documented at https://circleci.com/docs/2.0/circleci-images/ + # - image: circleci/postgres:9.4 + + working_directory: ~/repo + + environment: + # Customize the JVM maximum heap limit + MAVEN_OPTS: -Xmx3200m + + steps: + - checkout + + # Download and cache dependencies + - restore_cache: + keys: + - v1-dependencies-{{ checksum "pom.xml" }} + # fallback to using the latest cache if no exact match is found + - v1-dependencies- + + - run: mvn dependency:go-offline + + - save_cache: + paths: + - ~/.m2 + key: v1-dependencies-{{ checksum "pom.xml" }} + + # run tests! + - run: mvn integration-test \ No newline at end of file