├── .travis.yml ├── steeltoe-petclinic-customers-service ├── readme.md ├── Customers.Api │ ├── appsettings.json │ ├── Properties │ │ └── launchSettings.json │ ├── appsettings.Development.json │ ├── DTOs │ │ ├── PetType.cs │ │ ├── PetRequest.cs │ │ ├── PetDetails.cs │ │ ├── OwnerRequest.cs │ │ └── OwnerDetails.cs │ ├── ResourceNotFoundException.cs │ ├── appsettings.docker.json │ ├── DateTimeConverter.cs │ ├── Dockerfile │ ├── Domain │ │ ├── PetType.cs │ │ ├── Pet.cs │ │ └── Owner.cs │ ├── Repository │ │ ├── IOwners.cs │ │ ├── IPets.cs │ │ ├── Owners.cs │ │ └── Pets.cs │ ├── Infrastructure │ │ └── SeedData.cs │ ├── Steeltoe.Petclinic.Customers.Api.csproj │ ├── Program.cs │ └── Controllers │ │ └── OwnersController.cs ├── Customers.ITest │ ├── Steeltoe.Petclinic.Customers.ITest.csproj │ └── CustomersAppFactory.cs └── Customers.Test │ ├── Steeltoe.Petclinic.Customers.Test.csproj │ └── OwnerTest.cs ├── spring-petclinic-api-gateway ├── .gitignore └── src │ ├── test │ ├── resources │ │ └── bootstrap-test.yml │ └── java │ │ └── org │ │ └── springframework │ │ └── samples │ │ └── petclinic │ │ └── api │ │ ├── ApiGatewayApplicationTests.java │ │ └── application │ │ └── VisitsServiceClientIntegrationTest.java │ └── main │ ├── wro │ ├── wro.properties │ └── wro.xml │ ├── resources │ ├── messages │ │ ├── messages_en.properties │ │ ├── messages.properties │ │ └── messages_de.properties │ ├── static │ │ ├── images │ │ │ ├── pets.png │ │ │ ├── favicon.png │ │ │ ├── platform-bg.png │ │ │ ├── spring-pivotal-logo.png │ │ │ ├── spring-logo-dataflow.png │ │ │ └── spring-logo-dataflow-mobile.png │ │ ├── fonts │ │ │ ├── montserrat-webfont.eot │ │ │ ├── montserrat-webfont.ttf │ │ │ ├── montserrat-webfont.woff │ │ │ ├── varela_round-webfont.eot │ │ │ ├── varela_round-webfont.ttf │ │ │ └── varela_round-webfont.woff │ │ ├── scripts │ │ │ ├── fragments │ │ │ │ ├── welcome.html │ │ │ │ ├── footer.html │ │ │ │ └── nav.html │ │ │ ├── visits │ │ │ │ ├── visits.component.js │ │ │ │ ├── visits.js │ │ │ │ ├── visits.template.html │ │ │ │ └── visits.controller.js │ │ │ ├── pet-form │ │ │ │ ├── pet-form.component.js │ │ │ │ ├── pet-form.js │ │ │ │ ├── pet-form.template.html │ │ │ │ └── pet-form.controller.js │ │ │ ├── vet-list │ │ │ │ ├── vet-list.component.js │ │ │ │ ├── vet-list.controller.js │ │ │ │ ├── vet-list.js │ │ │ │ └── vet-list.template.html │ │ │ ├── owner-form │ │ │ │ ├── owner-form.component.js │ │ │ │ ├── owner-form.js │ │ │ │ ├── owner-form.controller.js │ │ │ │ └── owner-form.template.html │ │ │ ├── owner-list │ │ │ │ ├── owner-list.component.js │ │ │ │ ├── owner-list.controller.js │ │ │ │ ├── owner-list.js │ │ │ │ └── owner-list.template.html │ │ │ ├── owner-details │ │ │ │ ├── owner-details.component.js │ │ │ │ ├── owner-details.controller.js │ │ │ │ ├── owner-details.js │ │ │ │ └── owner-details.template.html │ │ │ └── app.js │ │ └── index.html │ ├── bootstrap.yml │ ├── logback-spring.xml │ └── application.yml │ ├── less │ ├── responsive.less │ ├── header.less │ └── typography.less │ └── java │ └── org │ └── springframework │ └── samples │ └── petclinic │ └── api │ ├── dto │ ├── PetType.java │ ├── Visits.java │ ├── VisitDetails.java │ ├── PetDetails.java │ └── OwnerDetails.java │ └── application │ ├── CustomersServiceClient.java │ └── VisitsServiceClient.java ├── spring-petclinic-vets-service ├── .gitignore └── src │ ├── main │ ├── resources │ │ ├── application.properties │ │ ├── bootstrap.yml │ │ ├── logback-spring.xml │ │ └── db │ │ │ ├── hsqldb │ │ │ ├── data.sql │ │ │ └── schema.sql │ │ │ └── mysql │ │ │ ├── data.sql │ │ │ └── schema.sql │ └── java │ │ └── org │ │ └── springframework │ │ └── samples │ │ └── petclinic │ │ └── vets │ │ ├── system │ │ ├── CacheConfig.java │ │ └── VetsProperties.java │ │ ├── model │ │ ├── VetRepository.java │ │ └── Specialty.java │ │ ├── VetsServiceApplication.java │ │ └── web │ │ └── VetResource.java │ └── test │ ├── resources │ ├── bootstrap-test.yml │ └── application-test.yml │ └── java │ └── org │ └── springframework │ └── samples │ └── petclinic │ └── vets │ └── web │ └── VetResourceTest.java ├── spring-petclinic-visits-service └── src │ ├── main │ ├── resources │ │ ├── application.properties │ │ ├── db │ │ │ ├── hsqldb │ │ │ │ ├── data.sql │ │ │ │ └── schema.sql │ │ │ └── mysql │ │ │ │ ├── data.sql │ │ │ │ └── schema.sql │ │ ├── bootstrap.yml │ │ └── logback-spring.xml │ └── java │ │ └── org │ │ └── springframework │ │ └── samples │ │ └── petclinic │ │ └── visits │ │ ├── VisitsServiceApplication.java │ │ ├── model │ │ ├── VisitRepository.java │ │ └── Visit.java │ │ └── web │ │ └── VisitResource.java │ └── test │ ├── resources │ ├── bootstrap-test.yml │ └── application-test.yml │ └── java │ └── org │ └── springframework │ └── samples │ └── petclinic │ └── visits │ └── web │ └── VisitResourceTest.java ├── spring-petclinic-customers-service └── src │ ├── main │ ├── resources │ │ ├── application.properties │ │ ├── bootstrap.yml │ │ ├── logback-spring.xml │ │ └── db │ │ │ ├── hsqldb │ │ │ ├── schema.sql │ │ │ └── data.sql │ │ │ └── mysql │ │ │ ├── schema.sql │ │ │ └── data.sql │ └── java │ │ └── org │ │ └── springframework │ │ └── samples │ │ └── petclinic │ │ └── customers │ │ ├── web │ │ ├── ResourceNotFoundException.java │ │ ├── PetRequest.java │ │ └── PetDetails.java │ │ ├── CustomersServiceApplication.java │ │ └── model │ │ ├── OwnerRepository.java │ │ ├── PetType.java │ │ └── PetRepository.java │ └── test │ ├── resources │ ├── bootstrap-test.yml │ └── application-test.yml │ └── java │ └── org │ └── springframework │ └── samples │ └── petclinic │ └── customers │ └── web │ └── PetResourceTest.java ├── .vscode └── settings.json ├── docker ├── prometheus │ ├── Dockerfile │ └── prometheus.yml ├── grafana │ ├── Dockerfile │ ├── provisioning │ │ ├── dashboards │ │ │ └── all.yml │ │ └── datasources │ │ │ └── all.yml │ └── grafana.ini └── Dockerfile ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── docs ├── application-screenshot.png ├── revised-architecture-diagram.png ├── grafana-custom-metrics-dashboard.png └── microservices-architecture-diagram.jpg ├── .editorconfig ├── steeltoe-petclinic-vets-service ├── Vets.Api │ ├── Infrastructure │ │ ├── Repository │ │ │ ├── IVets.cs │ │ │ ├── IVetSpecialties.cs │ │ │ ├── Vets.cs │ │ │ └── VetSpecialties.cs │ │ ├── Fill.cs │ │ └── SeedData.cs │ ├── appsettings.json │ ├── Properties │ │ └── launchSettings.json │ ├── DTOs │ │ ├── SpecialtyDetails.cs │ │ └── VetDetails.cs │ ├── appsettings.Development.json │ ├── appsettings.docker.json │ ├── Dockerfile │ ├── Domain │ │ ├── Vet.cs │ │ ├── VetSpecialty.cs │ │ └── Specialty.cs │ ├── Steeltoe.Petclinic.Vets.Api.csproj │ ├── Controllers │ │ └── VetsController.cs │ └── Program.cs ├── Vets.Test │ ├── VetTests.cs │ └── Steeltoe.Petclinic.Vets.Test.csproj └── Vets.ITest │ ├── Steeltoe.Petclinic.Vets.ITest.csproj │ ├── VetsAppFactory.cs │ └── Controllers │ └── Vets.cs ├── spring-petclinic-admin-server ├── src │ └── main │ │ ├── resources │ │ ├── bootstrap.yml │ │ └── logback-spring.xml │ │ └── java │ │ └── org │ │ └── springframework │ │ └── samples │ │ └── petclinic │ │ └── admin │ │ └── SpringBootAdminApplication.java └── pom.xml ├── spring-petclinic-discovery-server ├── src │ ├── main │ │ ├── resources │ │ │ └── bootstrap.yml │ │ └── java │ │ │ └── org │ │ │ └── springframework │ │ │ └── samples │ │ │ └── petclinic │ │ │ └── discovery │ │ │ └── DiscoveryServerApplication.java │ └── test │ │ └── java │ │ └── org │ │ └── springframework │ │ └── samples │ │ └── petclinic │ │ └── discovery │ │ └── DiscoveryServerApplicationTests.java └── pom.xml ├── steeltoe-petclinic-visits-service ├── Visits.Api │ ├── appsettings.json │ ├── Properties │ │ └── launchSettings.json │ ├── appsettings.Development.json │ ├── appsettings.docker.json │ ├── DTOs │ │ ├── VisitRequest.cs │ │ └── VisitDetails.cs │ ├── DateTimeConverter.cs │ ├── Dockerfile │ ├── Infrastructure │ │ ├── Repository │ │ │ ├── IVisits.cs │ │ │ └── Visits.cs │ │ ├── Fill.cs │ │ ├── SeedData.cs │ │ └── VisitsContext.cs │ ├── Domain │ │ └── Visit.cs │ ├── Steeltoe.Petclinic.Visits.Api.csproj │ └── Program.cs ├── Visits.Test │ ├── VisitsTest.cs │ └── Steeltoe.Petclinic.Visits.Test.csproj └── Visits.ITest │ ├── Steeltoe.Petclinic.Visits.ITest.csproj │ ├── VisitsAppFactory.cs │ └── Controllers │ └── Visits.cs ├── spring-petclinic-config-server ├── src │ ├── main │ │ ├── resources │ │ │ ├── bootstrap.yml │ │ │ └── static │ │ │ │ └── index.html │ │ └── java │ │ │ └── org │ │ │ └── springframework │ │ │ └── samples │ │ │ └── petclinic │ │ │ └── config │ │ │ └── ConfigServerApplication.java │ └── test │ │ └── java │ │ └── org │ │ └── springframework │ │ └── samples │ │ └── petclinic │ │ └── config │ │ └── PetclinicConfigServerApplicationTests.java └── pom.xml └── LICENSE /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | jdk: openjdk8 3 | -------------------------------------------------------------------------------- /steeltoe-petclinic-customers-service/readme.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/.gitignore: -------------------------------------------------------------------------------- 1 | /.apt_generated/ 2 | -------------------------------------------------------------------------------- /spring-petclinic-vets-service/.gitignore: -------------------------------------------------------------------------------- 1 | /.apt_generated/ 2 | -------------------------------------------------------------------------------- /spring-petclinic-visits-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spring-petclinic-customers-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "java.configuration.updateBuildConfiguration": "automatic" 3 | } -------------------------------------------------------------------------------- /docker/prometheus/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM prom/prometheus:v2.4.2 2 | ADD prometheus.yml /etc/prometheus/ 3 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SteeltoeOSS/spring-petclinic-microservices/HEAD/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/test/resources/bootstrap-test.yml: -------------------------------------------------------------------------------- 1 | spring.cloud.config.enabled: false 2 | eureka.client.enabled: false 3 | -------------------------------------------------------------------------------- /docs/application-screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SteeltoeOSS/spring-petclinic-microservices/HEAD/docs/application-screenshot.png -------------------------------------------------------------------------------- /spring-petclinic-vets-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.profiles.active=production 2 | spring.cache.cache-names=vets 3 | -------------------------------------------------------------------------------- /spring-petclinic-vets-service/src/test/resources/bootstrap-test.yml: -------------------------------------------------------------------------------- 1 | spring.cloud.config.enabled: false 2 | eureka.client.enabled: false 3 | -------------------------------------------------------------------------------- /spring-petclinic-visits-service/src/test/resources/bootstrap-test.yml: -------------------------------------------------------------------------------- 1 | spring.cloud.config.enabled: false 2 | eureka.client.enabled: false 3 | -------------------------------------------------------------------------------- /spring-petclinic-customers-service/src/test/resources/bootstrap-test.yml: -------------------------------------------------------------------------------- 1 | spring.cloud.config.enabled: false 2 | eureka.client.enabled: false 3 | -------------------------------------------------------------------------------- /docs/revised-architecture-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SteeltoeOSS/spring-petclinic-microservices/HEAD/docs/revised-architecture-diagram.png -------------------------------------------------------------------------------- /docs/grafana-custom-metrics-dashboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SteeltoeOSS/spring-petclinic-microservices/HEAD/docs/grafana-custom-metrics-dashboard.png -------------------------------------------------------------------------------- /docs/microservices-architecture-diagram.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SteeltoeOSS/spring-petclinic-microservices/HEAD/docs/microservices-architecture-diagram.jpg -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/wro/wro.properties: -------------------------------------------------------------------------------- 1 | #List of preProcessors 2 | preProcessors=lessCssImport 3 | #List of postProcessors 4 | postProcessors=less4j -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/messages/messages_en.properties: -------------------------------------------------------------------------------- 1 | # This file is intentionally empty. Message look-ups will fall back to the default "messages.properties" file. -------------------------------------------------------------------------------- /docker/grafana/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM grafana/grafana:5.2.4 2 | ADD ./provisioning /etc/grafana/provisioning 3 | ADD ./grafana.ini /etc/grafana/grafana.ini 4 | ADD ./dashboards /var/lib/grafana/dashboards 5 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/images/pets.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SteeltoeOSS/spring-petclinic-microservices/HEAD/spring-petclinic-api-gateway/src/main/resources/static/images/pets.png -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/images/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SteeltoeOSS/spring-petclinic-microservices/HEAD/spring-petclinic-api-gateway/src/main/resources/static/images/favicon.png -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/images/platform-bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SteeltoeOSS/spring-petclinic-microservices/HEAD/spring-petclinic-api-gateway/src/main/resources/static/images/platform-bg.png -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/fonts/montserrat-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SteeltoeOSS/spring-petclinic-microservices/HEAD/spring-petclinic-api-gateway/src/main/resources/static/fonts/montserrat-webfont.eot -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/fonts/montserrat-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SteeltoeOSS/spring-petclinic-microservices/HEAD/spring-petclinic-api-gateway/src/main/resources/static/fonts/montserrat-webfont.ttf -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/fonts/montserrat-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SteeltoeOSS/spring-petclinic-microservices/HEAD/spring-petclinic-api-gateway/src/main/resources/static/fonts/montserrat-webfont.woff -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/fonts/varela_round-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SteeltoeOSS/spring-petclinic-microservices/HEAD/spring-petclinic-api-gateway/src/main/resources/static/fonts/varela_round-webfont.eot -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/fonts/varela_round-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SteeltoeOSS/spring-petclinic-microservices/HEAD/spring-petclinic-api-gateway/src/main/resources/static/fonts/varela_round-webfont.ttf -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/images/spring-pivotal-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SteeltoeOSS/spring-petclinic-microservices/HEAD/spring-petclinic-api-gateway/src/main/resources/static/images/spring-pivotal-logo.png -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/fonts/varela_round-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SteeltoeOSS/spring-petclinic-microservices/HEAD/spring-petclinic-api-gateway/src/main/resources/static/fonts/varela_round-webfont.woff -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/images/spring-logo-dataflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SteeltoeOSS/spring-petclinic-microservices/HEAD/spring-petclinic-api-gateway/src/main/resources/static/images/spring-logo-dataflow.png -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.4/maven-wrapper-0.5.4.jar 3 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # top-most EditorConfig file 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | insert_final_newline = true 8 | indent_style = space 9 | 10 | [*.{java,xml}] 11 | indent_size = 4 12 | trim_trailing_whitespace = true 13 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/images/spring-logo-dataflow-mobile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SteeltoeOSS/spring-petclinic-microservices/HEAD/spring-petclinic-api-gateway/src/main/resources/static/images/spring-logo-dataflow-mobile.png -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/scripts/fragments/welcome.html: -------------------------------------------------------------------------------- 1 |

Welcome to Petclinic

2 | 3 |
4 |
5 | pets logo 6 |
7 |
-------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/wro/wro.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | classpath:META-INF/resources/webjars/bootstrap/3.3.7-1/less/bootstrap.less 4 | /petclinic.less 5 | 6 | 7 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/scripts/visits/visits.component.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('visits') 4 | .component('visits', { 5 | templateUrl: 'scripts/visits/visits.template.html', 6 | controller: 'VisitsController' 7 | }); 8 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/scripts/pet-form/pet-form.component.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('petForm') 4 | .component('petForm', { 5 | templateUrl: 'scripts/pet-form/pet-form.template.html', 6 | controller: 'PetFormController' 7 | }); 8 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/scripts/vet-list/vet-list.component.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('vetList') 4 | .component('vetList', { 5 | templateUrl: 'scripts/vet-list/vet-list.template.html', 6 | controller: 'VetListController' 7 | }); 8 | -------------------------------------------------------------------------------- /spring-petclinic-visits-service/src/test/resources/application-test.yml: -------------------------------------------------------------------------------- 1 | spring.jpa.hibernate.ddl-auto: none 2 | 3 | spring: 4 | datasource: 5 | schema: classpath*:db/hsqldb/schema.sql 6 | data: classpath*:db/hsqldb/data.sql 7 | 8 | logging.level.org.springframework: INFO 9 | 10 | -------------------------------------------------------------------------------- /spring-petclinic-customers-service/src/test/resources/application-test.yml: -------------------------------------------------------------------------------- 1 | spring.jpa.hibernate.ddl-auto: none 2 | 3 | spring: 4 | datasource: 5 | schema: classpath*:db/hsqldb/schema.sql 6 | data: classpath*:db/hsqldb/data.sql 7 | 8 | logging.level.org.springframework: INFO 9 | 10 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/scripts/owner-form/owner-form.component.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('ownerForm') 4 | .component('ownerForm', { 5 | templateUrl: 'scripts/owner-form/owner-form.template.html', 6 | controller: 'OwnerFormController' 7 | }); 8 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/scripts/owner-list/owner-list.component.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('ownerList') 4 | .component('ownerList', { 5 | templateUrl: 'scripts/owner-list/owner-list.template.html', 6 | controller: 'OwnerListController' 7 | }); 8 | -------------------------------------------------------------------------------- /spring-petclinic-vets-service/src/test/resources/application-test.yml: -------------------------------------------------------------------------------- 1 | spring.jpa.hibernate.ddl-auto: none 2 | 3 | spring: 4 | datasource: 5 | schema: classpath*:db/hsqldb/schema.sql 6 | data: classpath*:db/hsqldb/data.sql 7 | 8 | vets: 9 | cache: 10 | ttl: 10 11 | heap-size: 10 12 | -------------------------------------------------------------------------------- /steeltoe-petclinic-vets-service/Vets.Api/Infrastructure/Repository/IVets.cs: -------------------------------------------------------------------------------- 1 | using Petclinic.Vets.Domain; 2 | using System.Collections.Generic; 3 | 4 | namespace Petclinic.Vets.Infrastructure.Repository 5 | { 6 | public interface IVets 7 | { 8 | IEnumerable FindAll(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/scripts/fragments/footer.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
Sponsored by Pivotal
5 |
6 |
-------------------------------------------------------------------------------- /spring-petclinic-visits-service/src/main/resources/db/hsqldb/data.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO visits VALUES (1, 7, '2013-01-01', 'rabies shot'); 2 | INSERT INTO visits VALUES (2, 8, '2013-01-02', 'rabies shot'); 3 | INSERT INTO visits VALUES (3, 8, '2013-01-03', 'neutered'); 4 | INSERT INTO visits VALUES (4, 7, '2013-01-04', 'spayed'); 5 | -------------------------------------------------------------------------------- /docker/grafana/provisioning/dashboards/all.yml: -------------------------------------------------------------------------------- 1 | apiVersion: 1 2 | 3 | providers: 4 | - name: 'default' 5 | orgId: 1 6 | folder: '' 7 | type: file 8 | disableDeletion: false 9 | updateIntervalSeconds: 10 #how often Grafana will scan for changed dashboards 10 | options: 11 | path: /var/lib/grafana/dashboards 12 | -------------------------------------------------------------------------------- /spring-petclinic-admin-server/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | cloud: 3 | config: 4 | uri: http://localhost:8888 5 | application: 6 | name: admin-server 7 | --- 8 | spring: 9 | profiles: docker 10 | cloud: 11 | config: 12 | failFast: true 13 | uri: http://config-server:8888 14 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | cloud: 3 | config: 4 | uri: http://localhost:8888 5 | application: 6 | name: api-gateway 7 | --- 8 | spring: 9 | profiles: docker 10 | cloud: 11 | config: 12 | failFast: true 13 | uri: http://config-server:8888 14 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/scripts/owner-details/owner-details.component.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('ownerDetails') 4 | .component('ownerDetails', { 5 | templateUrl: 'scripts/owner-details/owner-details.template.html', 6 | controller: 'OwnerDetailsController' 7 | }); 8 | -------------------------------------------------------------------------------- /spring-petclinic-vets-service/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | cloud: 3 | config: 4 | uri: http://localhost:8888 5 | application: 6 | name: vets-service 7 | --- 8 | spring: 9 | profiles: docker 10 | cloud: 11 | config: 12 | failFast: true 13 | uri: http://config-server:8888 14 | -------------------------------------------------------------------------------- /spring-petclinic-visits-service/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | cloud: 3 | config: 4 | uri: http://localhost:8888 5 | application: 6 | name: visits-service 7 | --- 8 | spring: 9 | profiles: docker 10 | cloud: 11 | config: 12 | failFast: true 13 | uri: http://config-server:8888 14 | -------------------------------------------------------------------------------- /spring-petclinic-admin-server/src/main/resources/logback-spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/logback-spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/messages/messages.properties: -------------------------------------------------------------------------------- 1 | required=is required 2 | notFound=has not been found 3 | duplicate=is already in use 4 | nonNumeric=must be all numeric 5 | duplicateFormSubmission=Duplicate form submission is not allowed 6 | typeMismatch.date=invalid date 7 | typeMismatch.birthDate=invalid date 8 | -------------------------------------------------------------------------------- /spring-petclinic-customers-service/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | cloud: 3 | config: 4 | uri: http://localhost:8888 5 | application: 6 | name: customers-service 7 | --- 8 | spring: 9 | profiles: docker 10 | cloud: 11 | config: 12 | failFast: true 13 | uri: http://config-server:8888 14 | -------------------------------------------------------------------------------- /spring-petclinic-discovery-server/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | cloud: 3 | config: 4 | uri: http://localhost:8888 5 | application: 6 | name: discovery-server 7 | --- 8 | spring: 9 | profiles: docker 10 | cloud: 11 | config: 12 | failFast: true 13 | uri: http://config-server:8888 14 | -------------------------------------------------------------------------------- /spring-petclinic-vets-service/src/main/resources/logback-spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /spring-petclinic-visits-service/src/main/resources/logback-spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /spring-petclinic-customers-service/src/main/resources/logback-spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /spring-petclinic-visits-service/src/main/resources/db/hsqldb/schema.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE visits IF EXISTS; 2 | 3 | CREATE TABLE visits ( 4 | id INTEGER IDENTITY PRIMARY KEY, 5 | pet_id INTEGER NOT NULL, 6 | visit_date DATE, 7 | description VARCHAR(8192) 8 | ); 9 | 10 | CREATE INDEX visits_pet_id ON visits (pet_id); 11 | -------------------------------------------------------------------------------- /spring-petclinic-visits-service/src/main/resources/db/mysql/data.sql: -------------------------------------------------------------------------------- 1 | INSERT IGNORE INTO visits VALUES (1, 7, '2010-03-04', 'rabies shot'); 2 | INSERT IGNORE INTO visits VALUES (2, 8, '2011-03-04', 'rabies shot'); 3 | INSERT IGNORE INTO visits VALUES (3, 8, '2009-06-04', 'neutered'); 4 | INSERT IGNORE INTO visits VALUES (4, 7, '2008-09-04', 'spayed'); 5 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/messages/messages_de.properties: -------------------------------------------------------------------------------- 1 | required=muss angegeben werden 2 | notFound=wurde nicht gefunden 3 | duplicate=ist bereits vergeben 4 | nonNumeric=darf nur numerisch sein 5 | duplicateFormSubmission=Wiederholtes Absenden des Formulars ist nicht erlaubt 6 | typeMismatch.date=ung�ltiges Datum 7 | typeMismatch.birthDate=ung�ltiges Datum 8 | -------------------------------------------------------------------------------- /steeltoe-petclinic-customers-service/Customers.Api/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://steeltoe.io/schema/latest/schema.json", 3 | "Logging": { 4 | "LogLevel": { 5 | "Default": "Error", 6 | "System": "Error", 7 | "Microsoft": "Error", 8 | "Steeltoe": "Error" 9 | } 10 | }, 11 | "AllowedHosts": "*", 12 | "UseMySql": false 13 | } 14 | -------------------------------------------------------------------------------- /docker/grafana/provisioning/datasources/all.yml: -------------------------------------------------------------------------------- 1 | # config file version 2 | apiVersion: 1 3 | 4 | # list of datasources to insert/update depending what's available in the database 5 | datasources: 6 | - name: Prometheus 7 | type: prometheus 8 | access: proxy 9 | org_id: 1 10 | url: http://prometheus-server:9090 11 | is_default: true 12 | version: 1 13 | editable: true 14 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/scripts/vet-list/vet-list.controller.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('vetList') 4 | .controller('VetListController', ['$http', function ($http) { 5 | var self = this; 6 | 7 | $http.get('api/vet/vets').then(function (resp) { 8 | self.vetList = resp.data; 9 | }); 10 | }]); 11 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/scripts/owner-list/owner-list.controller.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('ownerList') 4 | .controller('OwnerListController', ['$http', function ($http) { 5 | var self = this; 6 | 7 | $http.get('api/customer/owners').then(function (resp) { 8 | self.owners = resp.data; 9 | }); 10 | }]); 11 | -------------------------------------------------------------------------------- /steeltoe-petclinic-vets-service/Vets.Api/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://steeltoe.io/schema/latest/schema.json", 3 | "AllowedHosts": "*", 4 | "Logging": { 5 | "LogLevel": { 6 | "Default": "Information", 7 | "System": "Information", 8 | "Microsoft": "Information", 9 | "Steeltoe": "Information" 10 | } 11 | }, 12 | "UseMySql": false 13 | } 14 | -------------------------------------------------------------------------------- /steeltoe-petclinic-visits-service/Visits.Api/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://steeltoe.io/schema/latest/schema.json", 3 | "AllowedHosts": "*", 4 | "Logging": { 5 | "LogLevel": { 6 | "Default": "Information", 7 | "System": "Information", 8 | "Microsoft": "Information", 9 | "Steeltoe": "Information" 10 | } 11 | }, 12 | "UseMySql": false 13 | } 14 | -------------------------------------------------------------------------------- /steeltoe-petclinic-vets-service/Vets.Api/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "Petclinic.Vets.Api": { 4 | "commandName": "Project", 5 | "launchBrowser": true, 6 | "launchUrl": "swagger", 7 | "applicationUrl": "http://localhost:5001", 8 | "environmentVariables": { 9 | "ASPNETCORE_ENVIRONMENT": "Development" 10 | } 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /steeltoe-petclinic-visits-service/Visits.Api/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "Petclinic.Visits.Api": { 4 | "commandName": "Project", 5 | "launchBrowser": true, 6 | "launchUrl": "swagger", 7 | "applicationUrl": "http://localhost:5002", 8 | "environmentVariables": { 9 | "ASPNETCORE_ENVIRONMENT": "Development" 10 | } 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/scripts/vet-list/vet-list.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('vetList', ['ui.router']) 4 | .config(['$stateProvider', function ($stateProvider) { 5 | $stateProvider 6 | .state('vets', { 7 | parent: 'app', 8 | url: '/vets', 9 | template: '' 10 | }) 11 | }]); -------------------------------------------------------------------------------- /steeltoe-petclinic-customers-service/Customers.Api/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "spring_petclinic_customers_api": { 4 | "commandName": "Project", 5 | "launchBrowser": true, 6 | "launchUrl": "swagger", 7 | "applicationUrl": "http://localhost:5000", 8 | "environmentVariables": { 9 | "ASPNETCORE_ENVIRONMENT": "Development" 10 | } 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/scripts/owner-list/owner-list.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('ownerList', ['ui.router']) 4 | .config(['$stateProvider', function ($stateProvider) { 5 | $stateProvider 6 | .state('owners', { 7 | parent: 'app', 8 | url: '/owners', 9 | template: '' 10 | }) 11 | }]); -------------------------------------------------------------------------------- /steeltoe-petclinic-vets-service/Vets.Api/Infrastructure/Repository/IVetSpecialties.cs: -------------------------------------------------------------------------------- 1 | using Petclinic.Vets.Domain; 2 | using System.Collections.Generic; 3 | 4 | namespace Petclinic.Vets.Infrastructure.Repository 5 | { 6 | public interface IVetSpecialties 7 | { 8 | IEnumerable FindAllBySpecialtyId(int specialtyId); 9 | 10 | IEnumerable FindAllByVetId(int vetId); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-petclinic-config-server/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | server.port: 8888 2 | spring: 3 | cloud: 4 | config: 5 | server: 6 | git: 7 | uri: https://github.com/steeltoeoss-incubator/spring-petclinic-microservices-config 8 | # Use the File System Backend to avoid git pulling. Enable "native" profile in the Config Server. 9 | native: 10 | searchLocations: file:///${GIT_REPO} 11 | 12 | -------------------------------------------------------------------------------- /steeltoe-petclinic-vets-service/Vets.Api/DTOs/SpecialtyDetails.cs: -------------------------------------------------------------------------------- 1 | namespace Petclinic.Vets.DTOs 2 | { 3 | public class SpecialtyDetails 4 | { 5 | public int Id { get; set; } 6 | public string Name { get; set; } 7 | 8 | public SpecialtyDetails() { } 9 | 10 | public SpecialtyDetails(int id, string name) 11 | { 12 | Id = id; 13 | Name = name; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/scripts/visits/visits.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('visits', ['ui.router']) 4 | .config(['$stateProvider', function ($stateProvider) { 5 | $stateProvider 6 | .state('visits', { 7 | parent: 'app', 8 | url: '/owners/:ownerId/pets/:petId/visits', 9 | template: '' 10 | }) 11 | }]); 12 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/scripts/owner-details/owner-details.controller.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('ownerDetails') 4 | .controller('OwnerDetailsController', ['$http', '$stateParams', function ($http, $stateParams) { 5 | var self = this; 6 | 7 | $http.get('api/gateway/owners/' + $stateParams.ownerId).then(function (resp) { 8 | self.owner = resp.data; 9 | }); 10 | }]); 11 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/scripts/owner-details/owner-details.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('ownerDetails', ['ui.router']) 4 | .config(['$stateProvider', function ($stateProvider) { 5 | $stateProvider 6 | .state('ownerDetails', { 7 | parent: 'app', 8 | url: '/owners/details/:ownerId', 9 | template: '' 10 | }) 11 | }]); -------------------------------------------------------------------------------- /spring-petclinic-visits-service/src/main/resources/db/mysql/schema.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS petclinic; 2 | GRANT ALL PRIVILEGES ON petclinic.* TO pc@localhost IDENTIFIED BY 'pc'; 3 | 4 | USE petclinic; 5 | 6 | CREATE TABLE IF NOT EXISTS visits ( 7 | id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 8 | pet_id INT(4) UNSIGNED NOT NULL, 9 | visit_date DATE, 10 | description VARCHAR(8192), 11 | FOREIGN KEY (pet_id) REFERENCES pets(id) 12 | ) engine=InnoDB; 13 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/test/java/org/springframework/samples/petclinic/api/ApiGatewayApplicationTests.java: -------------------------------------------------------------------------------- 1 | package org.springframework.samples.petclinic.api; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | import org.springframework.test.context.ActiveProfiles; 6 | 7 | @ActiveProfiles("test") 8 | @SpringBootTest 9 | class ApiGatewayApplicationTests { 10 | 11 | @Test 12 | void contextLoads() { 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /steeltoe-petclinic-vets-service/Vets.Test/VetTests.cs: -------------------------------------------------------------------------------- 1 | using Petclinic.Vets.Domain; 2 | using Xunit; 3 | 4 | namespace Petclinic.Vets.unit_test 5 | { 6 | [Collection("Vets Test Collection")] 7 | public class VetTests 8 | { 9 | public VetTests() { } 10 | 11 | [Fact(DisplayName = "Create vet")] 12 | public void NewOwner() 13 | { 14 | var vet = new Vet("AFirst", "ALast"); 15 | Assert.NotNull(vet); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/scripts/vet-list/vet-list.template.html: -------------------------------------------------------------------------------- 1 |

Veterinarians

2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
NameSpecialties
{{vet.firstName}} {{vet.lastName}}{{specialty.name + ' '}}
16 | -------------------------------------------------------------------------------- /steeltoe-petclinic-vets-service/Vets.Api/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://steeltoe.io/schema/latest/schema.json", 3 | "Logging": { 4 | "LogLevel": { 5 | "Default": "Error", 6 | "System": "Error", 7 | "Microsoft": "Error", 8 | "Steeltoe": "Trace" 9 | } 10 | }, 11 | 12 | "Spring": { 13 | "Cloud": { 14 | "Config": { 15 | "Uri": "http://${SERVICE:CONFIG-SERVER:HOST?localhost}:8888", 16 | "FailFast": true 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /steeltoe-petclinic-customers-service/Customers.Api/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://steeltoe.io/schema/latest/schema.json", 3 | "Logging": { 4 | "LogLevel": { 5 | "Default": "Error", 6 | "System": "Error", 7 | "Microsoft": "Error", 8 | "Steeltoe": "Trace" 9 | } 10 | }, 11 | "Spring": { 12 | "Cloud": { 13 | "Config": { 14 | "Uri": "http://${SERVICE:CONFIG-SERVER:HOST?localhost}:8888", 15 | "FailFast": true 16 | } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /steeltoe-petclinic-visits-service/Visits.Api/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://steeltoe.io/schema/latest/schema.json", 3 | "Logging": { 4 | "LogLevel": { 5 | "Default": "Error", 6 | "System": "Error", 7 | "Microsoft": "Error", 8 | "Steeltoe": "Trace" 9 | } 10 | }, 11 | 12 | "Spring": { 13 | "Cloud": { 14 | "Config": { 15 | "Uri": "http://${SERVICE:CONFIG-SERVER:HOST?localhost}:8888", 16 | "FailFast": true 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /steeltoe-petclinic-vets-service/Vets.Api/appsettings.docker.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://steeltoe.io/schema/latest/schema.json", 3 | "Logging": { 4 | "LogLevel": { 5 | "Default": "Error", 6 | "System": "Error", 7 | "Microsoft": "Error", 8 | "Steeltoe": "Warning", 9 | "Petclinic.Vets": "Trace" 10 | } 11 | }, 12 | 13 | "Spring": { 14 | "Cloud": { 15 | "Config": { 16 | "Uri": "http://config-server:8888", 17 | "FailFast": true 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /steeltoe-petclinic-visits-service/Visits.Api/appsettings.docker.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://steeltoe.io/schema/latest/schema.json", 3 | "Logging": { 4 | "LogLevel": { 5 | "Default": "Error", 6 | "System": "Error", 7 | //"Microsoft": "Error", 8 | "Steeltoe": "Warning", 9 | "Petclinic.Visits": "Trace" 10 | } 11 | }, 12 | 13 | "Spring": { 14 | "Cloud": { 15 | "Config": { 16 | "Uri": "http://config-server:8888", 17 | "FailFast": true 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /steeltoe-petclinic-customers-service/Customers.Api/DTOs/PetType.cs: -------------------------------------------------------------------------------- 1 | namespace Petclinic.Customers.DTOs 2 | { 3 | public class PetType 4 | { 5 | 6 | public PetType() { } 7 | 8 | public int Id { get; set; } 9 | 10 | public string Name { get; set; } 11 | 12 | public static PetType ToDTO(Domain.PetType petType) 13 | { 14 | return new PetType() 15 | { 16 | Id = petType.Id, 17 | Name = petType.Name 18 | }; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /steeltoe-petclinic-customers-service/Customers.Api/ResourceNotFoundException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Petclinic.Customers 4 | { 5 | public class ResourceNotFoundException : Exception 6 | { 7 | public ResourceNotFoundException() 8 | { 9 | } 10 | 11 | public ResourceNotFoundException(string message) : base(message) 12 | { 13 | } 14 | 15 | public ResourceNotFoundException(string message, Exception inner) 16 | : base(message, inner) 17 | { 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /steeltoe-petclinic-customers-service/Customers.Api/appsettings.docker.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://steeltoe.io/schema/latest/schema.json", 3 | "Logging": { 4 | "LogLevel": { 5 | "Default": "Warning", 6 | "System": "Warning", 7 | "Microsoft": "Warning", 8 | "Steeltoe": "Warning", 9 | "Petclinic.Customers": "Information" 10 | } 11 | }, 12 | 13 | "Spring": { 14 | "Cloud": { 15 | "Config": { 16 | "Uri": "http://config-server:8888", 17 | "FailFast": true 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /steeltoe-petclinic-vets-service/Vets.Api/Infrastructure/Repository/Vets.cs: -------------------------------------------------------------------------------- 1 | using Petclinic.Vets.Domain; 2 | using System.Collections.Generic; 3 | 4 | namespace Petclinic.Vets.Infrastructure.Repository 5 | { 6 | public class Vets : IVets 7 | { 8 | private readonly VetsContext _dbContext; 9 | 10 | public Vets(VetsContext dbContext) 11 | { 12 | _dbContext = dbContext; 13 | } 14 | 15 | public IEnumerable FindAll() 16 | { 17 | return _dbContext.Vets; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /steeltoe-petclinic-vets-service/Vets.Api/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster as builder 2 | WORKDIR /application 3 | COPY ["Steeltoe.Petclinic.Vets.Api.csproj", ""] 4 | RUN dotnet restore 5 | COPY . . 6 | RUN dotnet publish -c Release -o publish 7 | 8 | FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 9 | WORKDIR /application 10 | 11 | ARG EXPOSED_PORT=5000 12 | ENV PORT ${EXPOSED_PORT} 13 | EXPOSE ${EXPOSED_PORT} 14 | 15 | ENV ASPNETCORE_ENVIRONMENT docker 16 | ENV ENVIRONMENT docker 17 | 18 | COPY --from=builder application/publish . 19 | ENTRYPOINT ["dotnet", "vets-service.dll"] 20 | -------------------------------------------------------------------------------- /steeltoe-petclinic-visits-service/Visits.Api/DTOs/VisitRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace Petclinic.Visits.DTOs 5 | { 6 | public class VisitRequest 7 | { 8 | public VisitRequest() { } 9 | 10 | [JsonConverter(typeof(DateTimeConverter))] 11 | public DateTime? VisitDate { get; set; } 12 | 13 | public string Description { get; set; } 14 | 15 | public override string ToString() 16 | { 17 | return $"visit request on {VisitDate} with description {Description}"; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /steeltoe-petclinic-visits-service/Visits.Api/DateTimeConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text.Json; 3 | using System.Text.Json.Serialization; 4 | 5 | namespace Petclinic.Visits 6 | { 7 | public class DateTimeConverter : JsonConverter 8 | { 9 | public override DateTime? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => DateTime.Parse(reader.GetString()); 10 | 11 | public override void Write(Utf8JsonWriter writer, DateTime? value, JsonSerializerOptions options) => writer.WriteStringValue(value?.ToString("yyyy-MM-dd")); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /steeltoe-petclinic-visits-service/Visits.Api/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster as builder 2 | WORKDIR /application 3 | COPY ["Steeltoe.Petclinic.Visits.Api.csproj", ""] 4 | RUN dotnet restore 5 | COPY . . 6 | RUN dotnet publish -c Release -o publish 7 | 8 | FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 9 | WORKDIR /application 10 | 11 | ARG EXPOSED_PORT=5000 12 | ENV PORT ${EXPOSED_PORT} 13 | EXPOSE ${EXPOSED_PORT} 14 | 15 | ENV ASPNETCORE_ENVIRONMENT docker 16 | ENV ENVIRONMENT docker 17 | 18 | COPY --from=builder application/publish . 19 | ENTRYPOINT ["dotnet", "visits-service.dll"] 20 | -------------------------------------------------------------------------------- /steeltoe-petclinic-customers-service/Customers.Api/DateTimeConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text.Json; 3 | using System.Text.Json.Serialization; 4 | 5 | namespace Petclinic.Customers 6 | { 7 | public class DateTimeConverter : JsonConverter 8 | { 9 | public override DateTime? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => DateTime.Parse(reader.GetString()); 10 | 11 | public override void Write(Utf8JsonWriter writer, DateTime? value, JsonSerializerOptions options) => writer.WriteStringValue(value?.ToString("yyyy-MM-dd")); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /steeltoe-petclinic-customers-service/Customers.Api/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster as builder 2 | WORKDIR /application 3 | COPY ["Steeltoe.Petclinic.Customers.Api.csproj", ""] 4 | RUN dotnet restore 5 | COPY . . 6 | RUN dotnet publish -c Release -o publish 7 | 8 | FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 9 | WORKDIR /application 10 | 11 | ARG EXPOSED_PORT=5000 12 | ENV PORT ${EXPOSED_PORT} 13 | EXPOSE ${EXPOSED_PORT} 14 | 15 | ENV ASPNETCORE_ENVIRONMENT docker 16 | ENV ENVIRONMENT docker 17 | 18 | COPY --from=builder application/publish . 19 | ENTRYPOINT ["dotnet", "customers-service.dll"] 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2002-2020 the original author or authors. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /steeltoe-petclinic-visits-service/Visits.Api/Infrastructure/Repository/IVisits.cs: -------------------------------------------------------------------------------- 1 | using Petclinic.Visits.Domain; 2 | using System.Collections.Generic; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | 6 | namespace Petclinic.Visits.Infrastructure.Repository 7 | { 8 | public interface IVisits 9 | { 10 | Task> FindByPetIdAsync(int petId, CancellationToken cancellationToken = default); 11 | 12 | Task> FindByPetIdIn(IEnumerable petIds); 13 | 14 | Task SaveAsync(int petId, Visit visit, CancellationToken cancellationToken = default); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/ResourceNotFoundException.java: -------------------------------------------------------------------------------- 1 | package org.springframework.samples.petclinic.customers.web; 2 | 3 | import org.springframework.http.HttpStatus; 4 | import org.springframework.web.bind.annotation.ResponseStatus; 5 | 6 | @ResponseStatus(value = HttpStatus.NOT_FOUND) 7 | public class ResourceNotFoundException extends RuntimeException { 8 | 9 | /** 10 | * 11 | */ 12 | private static final long serialVersionUID = 1L; 13 | 14 | public ResourceNotFoundException(String message) { 15 | super(message); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/scripts/owner-form/owner-form.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('ownerForm', ['ui.router']) 4 | .config(['$stateProvider', function ($stateProvider) { 5 | $stateProvider 6 | .state('ownerNew', { 7 | parent: 'app', 8 | url: '/owners/new', 9 | template: '' 10 | }) 11 | .state('ownerEdit', { 12 | parent: 'app', 13 | url: '/owners/:ownerId/edit', 14 | template: '' 15 | }) 16 | }]); 17 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/scripts/pet-form/pet-form.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('petForm', ['ui.router']) 4 | .config(['$stateProvider', function ($stateProvider) { 5 | $stateProvider 6 | .state('petNew', { 7 | parent: 'app', 8 | url: '/owners/:ownerId/new-pet', 9 | template: '' 10 | }) 11 | .state('petEdit', { 12 | parent: 'app', 13 | url: '/owners/:ownerId/pets/:petId', 14 | template: '' 15 | }) 16 | }]); 17 | -------------------------------------------------------------------------------- /steeltoe-petclinic-customers-service/Customers.Api/Domain/PetType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Petclinic.Customers.Domain 5 | { 6 | public partial class PetType 7 | { 8 | public PetType(string name, int id = default) 9 | { 10 | Id = id; 11 | Name = name ?? throw new ArgumentNullException(nameof(name)); 12 | } 13 | 14 | protected PetType() 15 | { 16 | } 17 | 18 | public int Id { get; set; } 19 | 20 | public string Name { get; set; } 21 | 22 | public virtual ICollection Pets { get; set; } = new HashSet(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:11-jre as builder 2 | WORKDIR /application 3 | ARG ARTIFACT_NAME 4 | COPY ${ARTIFACT_NAME}.jar application.jar 5 | RUN java -Djarmode=layertools -jar application.jar extract 6 | 7 | # wget is not installed on adoptopenjdk:11-jre-hotspot 8 | FROM adoptopenjdk:11-jre-hotspot 9 | 10 | WORKDIR /application 11 | 12 | ARG EXPOSED_PORT 13 | EXPOSE ${EXPOSED_PORT} 14 | 15 | ENV SPRING_PROFILES_ACTIVE docker,mysql 16 | 17 | COPY --from=builder application/dependencies/ ./ 18 | COPY --from=builder application/spring-boot-loader/ ./ 19 | COPY --from=builder application/snapshot-dependencies/ ./ 20 | COPY --from=builder application/application/ ./ 21 | ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"] 22 | -------------------------------------------------------------------------------- /spring-petclinic-config-server/src/main/resources/static/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

Spring Cloud Config Server

5 |

The Spring Cloud Config Server provides an HTTP resource-based API for external yaml configuration for all the Spring Petclinic microservices

6 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | cloud: 3 | loadbalancer: 4 | ribbon: 5 | enabled: false 6 | gateway: 7 | routes: 8 | - id: vets-service 9 | uri: lb://vets-service 10 | predicates: 11 | - Path=/api/vet/** 12 | filters: 13 | - StripPrefix=2 14 | - id: visits-service 15 | uri: lb://visits-service 16 | predicates: 17 | - Path=/api/visit/** 18 | filters: 19 | - StripPrefix=2 20 | - id: customers-service 21 | uri: lb://customers-service 22 | predicates: 23 | - Path=/api/customer/** 24 | filters: 25 | - StripPrefix=2 26 | -------------------------------------------------------------------------------- /spring-petclinic-vets-service/src/main/resources/db/hsqldb/data.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO vets VALUES (1, 'James', 'Carter'); 2 | INSERT INTO vets VALUES (2, 'Helen', 'Leary'); 3 | INSERT INTO vets VALUES (3, 'Linda', 'Douglas'); 4 | INSERT INTO vets VALUES (4, 'Rafael', 'Ortega'); 5 | INSERT INTO vets VALUES (5, 'Henry', 'Stevens'); 6 | INSERT INTO vets VALUES (6, 'Sharon', 'Jenkins'); 7 | 8 | INSERT INTO specialties VALUES (1, 'radiology'); 9 | INSERT INTO specialties VALUES (2, 'surgery'); 10 | INSERT INTO specialties VALUES (3, 'dentistry'); 11 | 12 | INSERT INTO vet_specialties VALUES (2, 1); 13 | INSERT INTO vet_specialties VALUES (3, 2); 14 | INSERT INTO vet_specialties VALUES (3, 3); 15 | INSERT INTO vet_specialties VALUES (4, 2); 16 | INSERT INTO vet_specialties VALUES (5, 1); 17 | -------------------------------------------------------------------------------- /steeltoe-petclinic-vets-service/Vets.Api/Domain/Vet.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Petclinic.Vets.Domain 5 | { 6 | public class Vet 7 | { 8 | public Vet(string firstName, string lastName, int id = default) 9 | { 10 | Id = id; 11 | FirstName = firstName ?? throw new ArgumentNullException(nameof(firstName)); 12 | LastName = lastName ?? throw new ArgumentNullException(nameof(lastName)); 13 | } 14 | 15 | public int Id { get; private set; } 16 | 17 | public string FirstName { get; private set; } 18 | 19 | public string LastName { get; private set; } 20 | 21 | public ICollection VetSpecialties{ get; set; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /steeltoe-petclinic-vets-service/Vets.Api/Domain/VetSpecialty.cs: -------------------------------------------------------------------------------- 1 | using Petclinic.Vets.Infrastructure; 2 | using System.Linq; 3 | 4 | namespace Petclinic.Vets.Domain 5 | { 6 | public class VetSpecialty 7 | { 8 | public VetSpecialty(int vetId, int specialtyId) 9 | { 10 | VetId = vetId; 11 | SpecialtyId = specialtyId; 12 | //Specialty = Fill.Specialties.FirstOrDefault(i => i.Id == specialtyId); 13 | //Vet = Fill.Vets.FirstOrDefault(i => i.Id == vetId); 14 | } 15 | 16 | public int VetId { get; private set; } 17 | 18 | public Vet Vet { get; set; } 19 | 20 | public int SpecialtyId { get; private set; } 21 | 22 | public Specialty Specialty { get; set; } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /steeltoe-petclinic-customers-service/Customers.Api/DTOs/PetRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace Petclinic.Customers.DTOs 5 | { 6 | public class PetRequest 7 | { 8 | public PetRequest() { } 9 | 10 | public PetRequest(int id, DateTime? birthDate, string name, string petTypeId) 11 | { 12 | Id = id; 13 | BirthDate = birthDate; 14 | Name = name; 15 | TypeId = petTypeId; 16 | } 17 | public int Id { get; set; } 18 | 19 | [JsonConverter(typeof(DateTimeConverter))] 20 | public DateTime? BirthDate { get; set; } 21 | 22 | public string Name { get; set; } 23 | 24 | public string TypeId { get; set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /steeltoe-petclinic-visits-service/Visits.Api/Domain/Visit.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Petclinic.Visits.Domain 4 | { 5 | public partial class Visit 6 | { 7 | public Visit(int petId, DateTime? date, string description, int id = default) 8 | { 9 | Id = id; 10 | PetId = petId; 11 | Date = date; 12 | Description = description; 13 | } 14 | 15 | public int Id { get; private set; } 16 | 17 | public int PetId { get; private set; } 18 | 19 | public DateTime? Date { get; private set; } 20 | 21 | public string Description { get; private set; } 22 | 23 | public void SetPetId(int petId) 24 | { 25 | PetId = petId; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /steeltoe-petclinic-vets-service/Vets.Api/DTOs/VetDetails.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | 4 | namespace Petclinic.Vets.DTOs 5 | { 6 | public class VetDetails 7 | { 8 | public VetDetails() { } 9 | 10 | public VetDetails(int id, string firstName, string lastName, List specialties) 11 | { 12 | Id = id; 13 | FirstName = firstName; 14 | LastName = lastName; 15 | Specialties = specialties; 16 | } 17 | 18 | public int Id { get; set; } 19 | 20 | public string FirstName { get; set; } 21 | 22 | public string LastName { get; set; } 23 | 24 | public List Specialties { get; set; } 25 | 26 | public int NrOfSpecialties => Specialties?.Count() ?? 0; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /steeltoe-petclinic-visits-service/Visits.Api/Infrastructure/Fill.cs: -------------------------------------------------------------------------------- 1 | using Petclinic.Visits.Domain; 2 | using System; 3 | using System.Globalization; 4 | 5 | namespace Petclinic.Visits.Infrastructure 6 | { 7 | public static class Fill 8 | { 9 | public static Visit[] Visits => new[] 10 | { 11 | new Visit(7, DateTime.ParseExact("2013-01-01", "yyyy-MM-dd", CultureInfo.InvariantCulture), "rabies shot", id: 1), 12 | new Visit(8, DateTime.ParseExact("2013-01-02", "yyyy-MM-dd", CultureInfo.InvariantCulture), "rabies shot", id: 2), 13 | new Visit(8, DateTime.ParseExact("2013-01-03", "yyyy-MM-dd", CultureInfo.InvariantCulture), "neutered", id: 3), 14 | new Visit(7, DateTime.ParseExact("2013-01-04", "yyyy-MM-dd", CultureInfo.InvariantCulture), "spayed", id: 4) 15 | }; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /steeltoe-petclinic-visits-service/Visits.Test/VisitsTest.cs: -------------------------------------------------------------------------------- 1 | using Petclinic.Visits.Domain; 2 | using Petclinic.Visits.Infrastructure; 3 | using System; 4 | using System.Linq; 5 | using Xunit; 6 | 7 | namespace Petclinic.Visits.Test 8 | { 9 | [Collection("Visits Test Collection")] 10 | public class VisitsTest 11 | { 12 | public VisitsTest() { } 13 | 14 | [Fact(DisplayName = "Create visit")] 15 | public void NewOwner() 16 | { 17 | var visit = new Visit(1, DateTime.Now, "a description"); 18 | Assert.NotNull(visit); 19 | } 20 | 21 | [Fact(DisplayName = "Set petId")] 22 | public void SetPetIdsTest() 23 | { 24 | var visit = Fill.Visits.First(); 25 | visit.SetPetId(2); 26 | Assert.Equal(2, visit.PetId); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /spring-petclinic-vets-service/src/main/resources/db/mysql/data.sql: -------------------------------------------------------------------------------- 1 | INSERT IGNORE INTO vets VALUES (1, 'James', 'Carter'); 2 | INSERT IGNORE INTO vets VALUES (2, 'Helen', 'Leary'); 3 | INSERT IGNORE INTO vets VALUES (3, 'Linda', 'Douglas'); 4 | INSERT IGNORE INTO vets VALUES (4, 'Rafael', 'Ortega'); 5 | INSERT IGNORE INTO vets VALUES (5, 'Henry', 'Stevens'); 6 | INSERT IGNORE INTO vets VALUES (6, 'Sharon', 'Jenkins'); 7 | 8 | INSERT IGNORE INTO specialties VALUES (1, 'radiology'); 9 | INSERT IGNORE INTO specialties VALUES (2, 'surgery'); 10 | INSERT IGNORE INTO specialties VALUES (3, 'dentistry'); 11 | 12 | INSERT IGNORE INTO vet_specialties VALUES (2, 1); 13 | INSERT IGNORE INTO vet_specialties VALUES (3, 2); 14 | INSERT IGNORE INTO vet_specialties VALUES (3, 3); 15 | INSERT IGNORE INTO vet_specialties VALUES (4, 2); 16 | INSERT IGNORE INTO vet_specialties VALUES (5, 1); 17 | -------------------------------------------------------------------------------- /steeltoe-petclinic-customers-service/Customers.Api/DTOs/PetDetails.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace Petclinic.Customers.DTOs 5 | { 6 | public class PetDetails 7 | { 8 | public int Id { get; set; } 9 | 10 | public string Name { get; set; } 11 | 12 | public string Owner { get; set; } 13 | 14 | [JsonConverter(typeof(DateTimeConverter))] 15 | public DateTime? BirthDate { get; set; } 16 | 17 | public PetType Type { get; set; } 18 | 19 | public PetDetails() { } 20 | 21 | public PetDetails(int id, string name, string owner, DateTime? birthDate, PetType petType) 22 | { 23 | Id = id; 24 | Name = name; 25 | Owner = owner; 26 | BirthDate = birthDate; 27 | Type = petType; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /spring-petclinic-vets-service/src/main/resources/db/mysql/schema.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS petclinic; 2 | GRANT ALL PRIVILEGES ON petclinic.* TO pc@localhost IDENTIFIED BY 'pc'; 3 | 4 | USE petclinic; 5 | 6 | CREATE TABLE IF NOT EXISTS vets ( 7 | id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 8 | first_name VARCHAR(30), 9 | last_name VARCHAR(30), 10 | INDEX(last_name) 11 | ) engine=InnoDB; 12 | 13 | CREATE TABLE IF NOT EXISTS specialties ( 14 | id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 15 | name VARCHAR(80), 16 | INDEX(name) 17 | ) engine=InnoDB; 18 | 19 | CREATE TABLE IF NOT EXISTS vet_specialties ( 20 | vet_id INT(4) UNSIGNED NOT NULL, 21 | specialty_id INT(4) UNSIGNED NOT NULL, 22 | FOREIGN KEY (vet_id) REFERENCES vets(id), 23 | FOREIGN KEY (specialty_id) REFERENCES specialties(id), 24 | UNIQUE (vet_id,specialty_id) 25 | ) engine=InnoDB; 26 | -------------------------------------------------------------------------------- /spring-petclinic-vets-service/src/main/resources/db/hsqldb/schema.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE vet_specialties IF EXISTS; 2 | DROP TABLE vets IF EXISTS; 3 | DROP TABLE specialties IF EXISTS; 4 | 5 | CREATE TABLE vets ( 6 | id INTEGER IDENTITY PRIMARY KEY, 7 | first_name VARCHAR(30), 8 | last_name VARCHAR(30) 9 | ); 10 | CREATE INDEX vets_last_name ON vets (last_name); 11 | 12 | CREATE TABLE specialties ( 13 | id INTEGER IDENTITY PRIMARY KEY, 14 | name VARCHAR(80) 15 | ); 16 | CREATE INDEX specialties_name ON specialties (name); 17 | 18 | CREATE TABLE vet_specialties ( 19 | vet_id INTEGER NOT NULL, 20 | specialty_id INTEGER NOT NULL 21 | ); 22 | ALTER TABLE vet_specialties ADD CONSTRAINT fk_vet_specialties_vets FOREIGN KEY (vet_id) REFERENCES vets (id); 23 | ALTER TABLE vet_specialties ADD CONSTRAINT fk_vet_specialties_specialties FOREIGN KEY (specialty_id) REFERENCES specialties (id); 24 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/scripts/visits/visits.template.html: -------------------------------------------------------------------------------- 1 |

Visits

2 | 3 |
4 | 5 |
6 | 7 | 8 |
9 | 10 |
11 | 12 | 13 |
14 | 15 |
16 | 17 |
18 | 19 |
20 | 21 |

Previous Visits

22 | 23 | 24 | 25 | 26 | 27 |
{{v.date}}{{v.description}}
-------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/less/responsive.less: -------------------------------------------------------------------------------- 1 | @media (max-width: 768px) { 2 | .navbar-toggle { 3 | position:absolute; 4 | z-index: 9999; 5 | left:0px; 6 | top:0px; 7 | } 8 | 9 | .navbar a.navbar-brand { 10 | display: block; 11 | margin: 0 auto 0 auto; 12 | width: 148px; 13 | height: 50px; 14 | float: none; 15 | background: url("../images/spring-logo-dataflow-mobile.png") 0 center no-repeat; 16 | } 17 | 18 | .homepage-billboard .homepage-subtitle { 19 | font-size: 21px; 20 | line-height: 21px; 21 | } 22 | 23 | .navbar a.navbar-brand span { 24 | display: none; 25 | } 26 | 27 | .navbar { 28 | border-top-width: 0; 29 | } 30 | 31 | .xd-container { 32 | margin-top: 20px; 33 | margin-bottom: 30px; 34 | } 35 | 36 | .index-page--subtitle { 37 | margin-top: 10px; 38 | margin-bottom: 30px; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /steeltoe-petclinic-customers-service/Customers.Api/Repository/IOwners.cs: -------------------------------------------------------------------------------- 1 | using Petclinic.Customers.Domain; 2 | using System.Collections.Generic; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | 6 | namespace Petclinic.Customers.Repository 7 | { 8 | public interface IOwners 9 | { 10 | Task Delete(Owner Owner, CancellationToken cancellationToken = default); 11 | 12 | Task> FindAll(CancellationToken cancellationToken = default); 13 | 14 | Task> FindAll(int page, int pageSize, CancellationToken cancellationToken = default); 15 | 16 | Task FindById(int id, CancellationToken cancellationToken = default); 17 | 18 | Task Save(Owner owner, CancellationToken cancellationToken = default); 19 | 20 | Task Update(Owner owner, Owner newOwnerVals, CancellationToken cancellationToken = default); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /steeltoe-petclinic-customers-service/Customers.Api/Repository/IPets.cs: -------------------------------------------------------------------------------- 1 | using Petclinic.Customers.Domain; 2 | using System.Collections.Generic; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | 6 | namespace Petclinic.Customers.Repository 7 | { 8 | public interface IPets 9 | { 10 | Task> FindAll(CancellationToken cancellationToken = default); 11 | 12 | Task> FindAll(int page, int pageSize, CancellationToken cancellationToken = default); 13 | 14 | Task FindById(int id, CancellationToken cancellationToken = default); 15 | 16 | Task FindPetTypeById(int id, CancellationToken cancellationToken = default); 17 | 18 | Task> FindPetTypes(CancellationToken cancellationToken = default); 19 | 20 | Task Save(Pet pet, CancellationToken cancellationToken = default); 21 | 22 | Task Update(Pet pet, CancellationToken cancellationToken = default); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/dto/PetType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.api.dto; 17 | 18 | import lombok.Data; 19 | 20 | /** 21 | * @author Maciej Szarlinski 22 | */ 23 | @Data 24 | public class PetType { 25 | 26 | private String name; 27 | } 28 | -------------------------------------------------------------------------------- /steeltoe-petclinic-visits-service/Visits.Api/Infrastructure/SeedData.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Threading; 3 | 4 | namespace Petclinic.Visits.Infrastructure 5 | { 6 | public static class SeedData 7 | { 8 | public static async void SeedAll(this VisitsContext dbContext, bool ensureDelete = false, bool ensureCreated = false, CancellationToken cancellationToken = default) 9 | { 10 | if (ensureDelete) 11 | { 12 | dbContext.Database.EnsureDeleted(); 13 | } 14 | 15 | if (ensureCreated) 16 | { 17 | dbContext.Database.EnsureCreated(); 18 | } 19 | 20 | if (!dbContext.Visits.Any()) 21 | { 22 | foreach (var visit in Fill.Visits) 23 | { 24 | await dbContext.AddAsync(visit, cancellationToken); 25 | } 26 | } 27 | 28 | await dbContext.SaveChangesAsync(cancellationToken); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spring-petclinic-customers-service/src/main/resources/db/hsqldb/schema.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE pets IF EXISTS; 2 | DROP TABLE types IF EXISTS; 3 | DROP TABLE owners IF EXISTS; 4 | 5 | CREATE TABLE types ( 6 | id INTEGER IDENTITY PRIMARY KEY, 7 | name VARCHAR(80) 8 | ); 9 | CREATE INDEX types_name ON types (name); 10 | 11 | CREATE TABLE owners ( 12 | id INTEGER IDENTITY PRIMARY KEY, 13 | first_name VARCHAR(30), 14 | last_name VARCHAR(30), 15 | address VARCHAR(255), 16 | city VARCHAR(80), 17 | telephone VARCHAR(20) 18 | ); 19 | CREATE INDEX owners_last_name ON owners (last_name); 20 | 21 | CREATE TABLE pets ( 22 | id INTEGER IDENTITY PRIMARY KEY, 23 | name VARCHAR(30), 24 | birth_date DATE, 25 | type_id INTEGER NOT NULL, 26 | owner_id INTEGER NOT NULL 27 | ); 28 | ALTER TABLE pets ADD CONSTRAINT fk_pets_owners FOREIGN KEY (owner_id) REFERENCES owners (id); 29 | ALTER TABLE pets ADD CONSTRAINT fk_pets_types FOREIGN KEY (type_id) REFERENCES types (id); 30 | CREATE INDEX pets_name ON pets (name); 31 | -------------------------------------------------------------------------------- /spring-petclinic-customers-service/src/main/resources/db/mysql/schema.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS petclinic; 2 | GRANT ALL PRIVILEGES ON petclinic.* TO pc@localhost IDENTIFIED BY 'pc'; 3 | 4 | USE petclinic; 5 | 6 | CREATE TABLE IF NOT EXISTS types ( 7 | id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 8 | name VARCHAR(80), 9 | INDEX(name) 10 | ) engine=InnoDB; 11 | 12 | CREATE TABLE IF NOT EXISTS owners ( 13 | id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 14 | first_name VARCHAR(30), 15 | last_name VARCHAR(30), 16 | address VARCHAR(255), 17 | city VARCHAR(80), 18 | telephone VARCHAR(20), 19 | INDEX(last_name) 20 | ) engine=InnoDB; 21 | 22 | CREATE TABLE IF NOT EXISTS pets ( 23 | id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 24 | name VARCHAR(30), 25 | birth_date DATE, 26 | type_id INT(4) UNSIGNED NOT NULL, 27 | owner_id INT(4) UNSIGNED NOT NULL, 28 | INDEX(name), 29 | FOREIGN KEY (owner_id) REFERENCES owners(id), 30 | FOREIGN KEY (type_id) REFERENCES types(id) 31 | ) engine=InnoDB; 32 | -------------------------------------------------------------------------------- /steeltoe-petclinic-vets-service/Vets.Api/Domain/Specialty.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Petclinic.Vets.Domain 5 | { 6 | public class Specialty : IComparable 7 | { 8 | public Specialty(string name, int id = default) 9 | { 10 | Id = id; 11 | Name = name ?? throw new ArgumentNullException(nameof(name)); 12 | } 13 | 14 | public int Id { get; private set; } 15 | 16 | public string Name { get; private set; } 17 | 18 | public ICollection VetSpecialties { get; set; } 19 | 20 | public int CompareTo(object obj) 21 | { 22 | if (obj == null) 23 | { 24 | return 1; 25 | } 26 | 27 | if (obj is Specialty other) 28 | { 29 | return Id.CompareTo(other.Id); 30 | } 31 | else 32 | { 33 | throw new ArgumentException("Object is not a specialty"); 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /docker/grafana/grafana.ini: -------------------------------------------------------------------------------- 1 | ##################### Spring Petclinic Microservices Grafana Configuration ##################### 2 | 3 | # possible values : production, development 4 | app_mode = development 5 | 6 | #################################### Paths #################################### 7 | [paths] 8 | # folder that contains provisioning config files that grafana will apply on startup and while running. 9 | provisioning = /etc/grafana/provisioning 10 | 11 | #################################### Server #################################### 12 | [server] 13 | # enable gzip 14 | enable_gzip = true 15 | 16 | #################################### Anonymous Auth ########################## 17 | # Anonymous authentication has been enabled in the Petclinic sample with Admin role 18 | # Do not do that in Production environment 19 | [auth.anonymous] 20 | # enable anonymous access 21 | enabled = true 22 | 23 | # specify organization name that should be used for unauthenticated users 24 | org_name = Main Org. 25 | 26 | # specify role for unauthenticated users 27 | org_role = Admin 28 | -------------------------------------------------------------------------------- /steeltoe-petclinic-vets-service/Vets.Api/Infrastructure/Repository/VetSpecialties.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Petclinic.Vets.Domain; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | 6 | namespace Petclinic.Vets.Infrastructure.Repository 7 | { 8 | public class VetSpecialties : IVetSpecialties 9 | { 10 | private readonly VetsContext _dbContext; 11 | 12 | public VetSpecialties(VetsContext dbContext) 13 | { 14 | _dbContext = dbContext; 15 | } 16 | 17 | public IEnumerable FindAllByVetId(int vetId) 18 | { 19 | return _dbContext.VetSpecialties 20 | .Include(vs => vs.Specialty) 21 | .Include(vs => vs.Vet) 22 | .Where(q => q.VetId == vetId); 23 | } 24 | 25 | public IEnumerable FindAllBySpecialtyId(int specialtyId) 26 | { 27 | return _dbContext.VetSpecialties.Where(q => q.SpecialtyId == specialtyId); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /steeltoe-petclinic-customers-service/Customers.ITest/Steeltoe.Petclinic.Customers.ITest.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | Petclinic.Customers.ITest 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /steeltoe-petclinic-customers-service/Customers.Api/DTOs/OwnerRequest.cs: -------------------------------------------------------------------------------- 1 | using Petclinic.Customers.Domain; 2 | 3 | namespace Petclinic.Customers.DTOs 4 | { 5 | public class OwnerRequest 6 | { 7 | public OwnerRequest() { } 8 | 9 | public OwnerRequest(string firstName, string lastName, string address, string city, string telephone, int id = default) 10 | { 11 | Id = id; 12 | FirstName = firstName; 13 | LastName = lastName; 14 | Address = address; 15 | City = city; 16 | Telephone = telephone; 17 | } 18 | 19 | public int Id { get; set; } 20 | 21 | public string FirstName { get; set; } 22 | 23 | public string LastName { get; set; } 24 | 25 | public string Address { get; set; } 26 | 27 | public string City { get; set; } 28 | 29 | public string Telephone { get; set; } 30 | 31 | public Owner ToOwner() 32 | { 33 | return new Owner(FirstName, LastName, Address, City, Telephone, Id); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /docker/prometheus/prometheus.yml: -------------------------------------------------------------------------------- 1 | # my global config 2 | global: 3 | scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. 4 | evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. 5 | # scrape_timeout is set to the global default (10s). 6 | 7 | # A scrape configuration containing exactly one endpoint to scrape: 8 | # Here it's Prometheus itself. 9 | scrape_configs: 10 | - job_name: prometheus 11 | static_configs: 12 | - targets: ['localhost:9090'] 13 | 14 | - job_name: api-gateway 15 | metrics_path: /actuator/prometheus 16 | static_configs: 17 | - targets: ['api-gateway:8080'] 18 | 19 | - job_name: customers-service 20 | metrics_path: /actuator/prometheus 21 | static_configs: 22 | - targets: ['customers-service:8081'] 23 | 24 | - job_name: visits-service 25 | metrics_path: /actuator/prometheus 26 | static_configs: 27 | - targets: ['visits-service:8082'] 28 | 29 | - job_name: vets-service 30 | metrics_path: /actuator/prometheus 31 | static_configs: 32 | - targets: ['vets-service:8083'] 33 | -------------------------------------------------------------------------------- /spring-petclinic-discovery-server/src/test/java/org/springframework/samples/petclinic/discovery/DiscoveryServerApplicationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.discovery; 17 | 18 | import org.junit.jupiter.api.Test; 19 | import org.springframework.boot.test.context.SpringBootTest; 20 | 21 | @SpringBootTest 22 | class DiscoveryServerApplicationTests { 23 | 24 | @Test 25 | void contextLoads() { 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /spring-petclinic-config-server/src/test/java/org/springframework/samples/petclinic/config/PetclinicConfigServerApplicationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.config; 17 | 18 | import org.junit.jupiter.api.Test; 19 | import org.springframework.boot.test.context.SpringBootTest; 20 | 21 | @SpringBootTest 22 | class PetclinicConfigServerApplicationTests { 23 | 24 | @Test 25 | void contextLoads() { 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /steeltoe-petclinic-vets-service/Vets.Api/Infrastructure/Fill.cs: -------------------------------------------------------------------------------- 1 | using Petclinic.Vets.Domain; 2 | using System.Linq; 3 | 4 | namespace Petclinic.Vets.Infrastructure 5 | { 6 | public static class Fill 7 | { 8 | public static Vet[] Vets => new[] 9 | { 10 | new Vet("James", "Carter", 1), 11 | new Vet("Helen", "Leary", 2), 12 | new Vet("Linda", "Douglas", 3), 13 | new Vet("Rafael", "Ortega", 4), 14 | new Vet("Henry", "Stevens", 5), 15 | new Vet("Sharon", "Jenkins", 6) 16 | }; 17 | 18 | public static VetSpecialty[] VetSpecialties => new[] 19 | { 20 | new VetSpecialty(2, 1), 21 | new VetSpecialty(3, 2), 22 | new VetSpecialty(3, 3), 23 | new VetSpecialty(4, 2), 24 | new VetSpecialty(5, 1) 25 | }; 26 | 27 | public static Specialty[] Specialties => new[] 28 | { 29 | new Specialty("radiology", 1), 30 | new Specialty("surgery", 2), 31 | new Specialty("dentistry", 3) 32 | }; 33 | 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/dto/Visits.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.api.dto; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | import lombok.NoArgsConstructor; 22 | import lombok.Value; 23 | 24 | /** 25 | * @author Maciej Szarlinski 26 | */ 27 | @Value 28 | public class Visits { 29 | 30 | private List items = new ArrayList<>(); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /steeltoe-petclinic-visits-service/Visits.ITest/Steeltoe.Petclinic.Visits.ITest.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | Petclinic.Visits.ITest 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /steeltoe-petclinic-visits-service/Visits.Api/DTOs/VisitDetails.cs: -------------------------------------------------------------------------------- 1 | using Petclinic.Visits.Domain; 2 | using System; 3 | using System.Text.Json.Serialization; 4 | 5 | namespace Petclinic.Visits.DTOs 6 | { 7 | public class VisitDetails 8 | { 9 | public VisitDetails() { } 10 | 11 | public VisitDetails(int id, int petId, DateTime? date, string description) 12 | { 13 | Id = id; 14 | this.petId = petId; 15 | Date = date; 16 | this.description = description; 17 | } 18 | 19 | public int Id { get; set; } 20 | 21 | public int petId { get; set; } 22 | 23 | [JsonConverter(typeof(DateTimeConverter))] 24 | public DateTime? Date { get; set; } 25 | 26 | public string description { get; set; } 27 | 28 | public static VisitDetails FromVisit(Visit visit) 29 | { 30 | return new VisitDetails() 31 | { 32 | Id = visit.Id, 33 | petId = visit.PetId, 34 | Date = visit.Date, 35 | description = visit.Description 36 | }; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/dto/VisitDetails.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.api.dto; 17 | 18 | import lombok.Data; 19 | import lombok.NoArgsConstructor; 20 | 21 | /** 22 | * @author Maciej Szarlinski 23 | */ 24 | @Data 25 | @NoArgsConstructor 26 | public class VisitDetails { 27 | 28 | private Integer id = null; 29 | 30 | private Integer petId = null; 31 | 32 | private String date = null; 33 | 34 | private String description = null; 35 | } 36 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/scripts/owner-list/owner-list.template.html: -------------------------------------------------------------------------------- 1 |

Owners

2 | 3 |
4 |
5 | 6 |
7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 26 | 27 | 28 | 29 | 30 | 31 |
NameCityTelephone
22 | 23 | {{owner.firstName}} {{owner.lastName}} 24 | 25 | {{owner.city}}{{owner.telephone}}
32 | -------------------------------------------------------------------------------- /steeltoe-petclinic-visits-service/Visits.Test/Steeltoe.Petclinic.Visits.Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | Petclinic.Visits.Test 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | all 15 | runtime; build; native; contentfiles; analyzers; buildtransitive 16 | 17 | 18 | all 19 | runtime; build; native; contentfiles; analyzers; buildtransitive 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/system/CacheConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.vets.system; 17 | 18 | import org.springframework.cache.annotation.EnableCaching; 19 | import org.springframework.context.annotation.Configuration; 20 | import org.springframework.context.annotation.Profile; 21 | 22 | /** 23 | * Cache could be disable in unit test. 24 | * @author Maciej Szarlinski 25 | */ 26 | @Configuration 27 | @EnableCaching 28 | @Profile("production") 29 | class CacheConfig { 30 | } 31 | -------------------------------------------------------------------------------- /steeltoe-petclinic-vets-service/Vets.ITest/Steeltoe.Petclinic.Vets.ITest.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | Petclinic.Vets.ITest 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/dto/PetDetails.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.api.dto; 17 | 18 | import lombok.Data; 19 | 20 | import java.util.ArrayList; 21 | import java.util.List; 22 | 23 | /** 24 | * @author Maciej Szarlinski 25 | */ 26 | @Data 27 | public class PetDetails { 28 | 29 | private int id; 30 | 31 | private String name; 32 | 33 | private String birthDate; 34 | 35 | private PetType type; 36 | 37 | private final List visits = new ArrayList<>(); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/scripts/visits/visits.controller.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('visits') 4 | .controller('VisitsController', ['$http', '$state', '$stateParams', '$filter', function ($http, $state, $stateParams, $filter) { 5 | var self = this; 6 | var petId = $stateParams.petId || 0; 7 | var url = "api/visit/owners/" + ($stateParams.ownerId || 0) + "/pets/" + petId + "/visits"; 8 | self.date = new Date(); 9 | self.desc = ""; 10 | 11 | $http.get(url).then(function (resp) { 12 | self.visits = resp.data; 13 | }); 14 | 15 | self.submit = function () { 16 | var data = { 17 | date: $filter('date')(self.date, "yyyy-MM-dd"), 18 | description: self.desc 19 | }; 20 | 21 | $http.post(url, data).then(function () { 22 | $state.go("owners", { ownerId: $stateParams.ownerId }); 23 | }, function (response) { 24 | var error = response.data; 25 | alert(error.error + "\r\n" + error.errors.map(function (e) { 26 | return e.field + ": " + e.defaultMessage; 27 | }).join("\r\n")); 28 | }); 29 | }; 30 | }]); 31 | -------------------------------------------------------------------------------- /spring-petclinic-config-server/src/main/java/org/springframework/samples/petclinic/config/ConfigServerApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.config; 17 | 18 | import org.springframework.boot.SpringApplication; 19 | import org.springframework.boot.autoconfigure.SpringBootApplication; 20 | import org.springframework.cloud.config.server.EnableConfigServer; 21 | 22 | /** 23 | * @author Maciej Szarlinski 24 | */ 25 | @EnableConfigServer 26 | @SpringBootApplication 27 | public class ConfigServerApplication { 28 | 29 | public static void main(String[] args) { 30 | SpringApplication.run(ConfigServerApplication.class, args); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/system/VetsProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.vets.system; 17 | 18 | import lombok.Data; 19 | 20 | import org.springframework.boot.context.properties.ConfigurationProperties; 21 | 22 | /** 23 | * Typesafe custom configuration. 24 | * 25 | * @author Maciej Szarlinski 26 | */ 27 | @Data 28 | @ConfigurationProperties(prefix = "vets") 29 | public class VetsProperties { 30 | 31 | private Cache cache; 32 | 33 | @Data 34 | public static class Cache { 35 | 36 | private int ttl; 37 | 38 | private int heapSize; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /steeltoe-petclinic-visits-service/Visits.ITest/VisitsAppFactory.cs: -------------------------------------------------------------------------------- 1 | using MartinCostello.Logging.XUnit; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.AspNetCore.Mvc.Testing; 4 | using Microsoft.Extensions.Hosting; 5 | using Microsoft.Extensions.Logging; 6 | using Xunit.Abstractions; 7 | 8 | namespace Petclinic.Visits.ITest 9 | { 10 | public class CustomersAppFactory : WebApplicationFactory, ITestOutputHelperAccessor where TStartup : class 11 | { 12 | public ITestOutputHelper OutputHelper { get; set; } 13 | 14 | public CustomersAppFactory() : base() { } 15 | 16 | protected override IHostBuilder CreateHostBuilder() 17 | { 18 | var builder = Program.CreateHostBuilder(new string[] { }); 19 | 20 | builder.ConfigureLogging(logging => 21 | { 22 | logging.ClearProviders(); // Remove other loggers 23 | logging.AddXUnit(OutputHelper); // Use the ITestOutputHelper instance 24 | }); 25 | 26 | builder.UseEnvironment("Development"); 27 | 28 | return builder; 29 | } 30 | protected override void ConfigureWebHost(IWebHostBuilder builder) 31 | { 32 | builder.ConfigureServices(services => 33 | { 34 | }); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/scripts/owner-form/owner-form.controller.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('ownerForm') 4 | .controller('OwnerFormController', ["$http", '$state', '$stateParams', function ($http, $state, $stateParams) { 5 | var self = this; 6 | 7 | var ownerId = $stateParams.ownerId || 0; 8 | 9 | if (!ownerId) { 10 | self.owner = {}; 11 | } else { 12 | $http.get("api/customer/owners/" + ownerId).then(function (resp) { 13 | self.owner = resp.data; 14 | }); 15 | } 16 | 17 | self.submitOwnerForm = function () { 18 | var id = self.owner.id; 19 | var req; 20 | if (id) { 21 | req = $http.put("api/customer/owners/" + id, self.owner); 22 | } else { 23 | req = $http.post("api/customer/owners", self.owner); 24 | } 25 | 26 | req.then(function () { 27 | $state.go('owners'); 28 | }, function (response) { 29 | var error = response.data; 30 | alert(error.error + "\r\n" + error.errors.map(function (e) { 31 | return e.field + ": " + e.defaultMessage; 32 | }).join("\r\n")); 33 | }); 34 | }; 35 | }]); 36 | -------------------------------------------------------------------------------- /spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/PetRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.customers.web; 17 | 18 | import lombok.Data; 19 | 20 | import java.util.Date; 21 | 22 | import javax.validation.constraints.Size; 23 | 24 | import com.fasterxml.jackson.annotation.JsonFormat; 25 | 26 | /** 27 | * @author mszarlinski@bravurasolutions.com on 2016-12-05. 28 | */ 29 | @Data 30 | class PetRequest { 31 | private int id; 32 | 33 | @JsonFormat(pattern = "yyyy-MM-dd") 34 | private Date birthDate; 35 | 36 | @Size(min = 1) 37 | private String name; 38 | 39 | private int typeId; 40 | } 41 | -------------------------------------------------------------------------------- /spring-petclinic-discovery-server/src/main/java/org/springframework/samples/petclinic/discovery/DiscoveryServerApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.discovery; 17 | 18 | import org.springframework.boot.SpringApplication; 19 | import org.springframework.boot.autoconfigure.SpringBootApplication; 20 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 21 | 22 | /** 23 | * @author Maciej Szarlinski 24 | */ 25 | @EnableEurekaServer 26 | @SpringBootApplication 27 | public class DiscoveryServerApplication { 28 | 29 | public static void main(String[] args) { 30 | SpringApplication.run(DiscoveryServerApplication.class, args); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/VisitsServiceApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.visits; 17 | 18 | import org.springframework.boot.SpringApplication; 19 | import org.springframework.boot.autoconfigure.SpringBootApplication; 20 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 21 | 22 | /** 23 | * @author Maciej Szarlinski 24 | */ 25 | @EnableDiscoveryClient 26 | @SpringBootApplication 27 | public class VisitsServiceApplication { 28 | 29 | public static void main(String[] args) { 30 | SpringApplication.run(VisitsServiceApplication.class, args); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /steeltoe-petclinic-vets-service/Vets.ITest/VetsAppFactory.cs: -------------------------------------------------------------------------------- 1 | using MartinCostello.Logging.XUnit; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.AspNetCore.Mvc.Testing; 4 | using Microsoft.Extensions.Hosting; 5 | using Microsoft.Extensions.Logging; 6 | using Xunit.Abstractions; 7 | 8 | namespace Petclinic.Vets.ITest 9 | { 10 | public class CustomersAppFactory : WebApplicationFactory, ITestOutputHelperAccessor where TStartup : class 11 | { 12 | public ITestOutputHelper OutputHelper { get; set; } 13 | 14 | public CustomersAppFactory() : base() { } 15 | 16 | protected override IHostBuilder CreateHostBuilder() 17 | { 18 | var builder = Program.CreateHostBuilder(new string[] { }); 19 | 20 | builder.ConfigureLogging(logging => 21 | { 22 | logging.ClearProviders(); // Remove other loggers 23 | logging.AddXUnit(OutputHelper); // Use the ITestOutputHelper instance 24 | }); 25 | 26 | builder.UseEnvironment("Development"); 27 | 28 | return builder; 29 | } 30 | 31 | protected override void ConfigureWebHost(IWebHostBuilder builder) 32 | { 33 | builder.ConfigureServices(services => 34 | { 35 | 36 | }); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/CustomersServiceApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.customers; 17 | 18 | import org.springframework.boot.SpringApplication; 19 | import org.springframework.boot.autoconfigure.SpringBootApplication; 20 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 21 | 22 | /** 23 | * @author Maciej Szarlinski 24 | */ 25 | @EnableDiscoveryClient 26 | @SpringBootApplication 27 | public class CustomersServiceApplication { 28 | 29 | public static void main(String[] args) { 30 | SpringApplication.run(CustomersServiceApplication.class, args); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /steeltoe-petclinic-customers-service/Customers.ITest/CustomersAppFactory.cs: -------------------------------------------------------------------------------- 1 | using MartinCostello.Logging.XUnit; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.AspNetCore.Mvc.Testing; 4 | using Microsoft.Extensions.Hosting; 5 | using Microsoft.Extensions.Logging; 6 | using Xunit.Abstractions; 7 | 8 | namespace Petclinic.Customers.ITest 9 | { 10 | public class CustomersAppFactory : WebApplicationFactory, ITestOutputHelperAccessor where TStartup : class 11 | { 12 | public ITestOutputHelper OutputHelper { get; set; } 13 | 14 | public CustomersAppFactory() : base() { } 15 | 16 | protected override IHostBuilder CreateHostBuilder() 17 | { 18 | var builder = Program.CreateHostBuilder(new string[] { }); 19 | 20 | builder.ConfigureLogging(logging => 21 | { 22 | logging.ClearProviders(); // Remove other loggers 23 | logging.AddXUnit(OutputHelper); // Use the ITestOutputHelper instance 24 | }); 25 | 26 | builder.UseEnvironment("Development"); 27 | 28 | return builder; 29 | } 30 | protected override void ConfigureWebHost(IWebHostBuilder builder) 31 | { 32 | builder.ConfigureServices(services => 33 | { 34 | 35 | }); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /spring-petclinic-admin-server/src/main/java/org/springframework/samples/petclinic/admin/SpringBootAdminApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.admin; 17 | 18 | import de.codecentric.boot.admin.server.config.EnableAdminServer; 19 | import org.springframework.boot.SpringApplication; 20 | import org.springframework.boot.autoconfigure.SpringBootApplication; 21 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 22 | 23 | @SpringBootApplication 24 | @EnableAdminServer 25 | @EnableDiscoveryClient 26 | public class SpringBootAdminApplication { 27 | public static void main(String[] args) { 28 | SpringApplication.run(SpringBootAdminApplication.class, args); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/scripts/app.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | /* App Module */ 3 | var petClinicApp = angular.module('petClinicApp', [ 4 | 'ui.router', 'layoutNav', 'layoutFooter', 'layoutWelcome', 5 | 'ownerList', 'ownerDetails', 'ownerForm', 'petForm', 'visits', 'vetList']); 6 | 7 | petClinicApp.config(['$stateProvider', '$urlRouterProvider', '$locationProvider', '$httpProvider', function( 8 | $stateProvider, $urlRouterProvider, $locationProvider, $httpProvider) { 9 | 10 | // safari turns to be lazy sending the Cache-Control header 11 | $httpProvider.defaults.headers.common["Cache-Control"] = 'no-cache'; 12 | 13 | $locationProvider.hashPrefix('!'); 14 | 15 | $urlRouterProvider.otherwise('/welcome'); 16 | $stateProvider 17 | .state('app', { 18 | abstract: true, 19 | url: '', 20 | template: '' 21 | }) 22 | .state('welcome', { 23 | parent: 'app', 24 | url: '/welcome', 25 | template: '' 26 | }); 27 | }]); 28 | 29 | ['welcome', 'nav', 'footer'].forEach(function(c) { 30 | var mod = 'layout' + c.toUpperCase().substring(0, 1) + c.substring(1); 31 | angular.module(mod, []); 32 | angular.module(mod).component(mod, { 33 | templateUrl: "scripts/fragments/" + c + ".html" 34 | }); 35 | }); -------------------------------------------------------------------------------- /steeltoe-petclinic-vets-service/Vets.Test/Steeltoe.Petclinic.Vets.Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | Petclinic.Vets.Test 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | all 15 | runtime; build; native; contentfiles; analyzers; buildtransitive 16 | 17 | 18 | all 19 | runtime; build; native; contentfiles; analyzers; buildtransitive 20 | 21 | 22 | 23 | runtime; build; native; contentfiles; analyzers; buildtransitive 24 | all 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/model/VetRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.vets.model; 17 | 18 | import org.springframework.data.jpa.repository.JpaRepository; 19 | 20 | /** 21 | * Repository class for Vet domain objects All method names are compliant with Spring Data naming 22 | * conventions so this interface can easily be extended for Spring Data See here: http://static.springsource.org/spring-data/jpa/docs/current/reference/html/jpa.repositories.html#jpa.query-methods.query-creation 23 | * 24 | * @author Ken Krebs 25 | * @author Juergen Hoeller 26 | * @author Sam Brannen 27 | * @author Michael Isvy 28 | * @author Maciej Szarlinski 29 | */ 30 | public interface VetRepository extends JpaRepository { 31 | } 32 | -------------------------------------------------------------------------------- /spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/OwnerRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.customers.model; 17 | 18 | import org.springframework.data.jpa.repository.JpaRepository; 19 | 20 | /** 21 | * Repository class for Owner domain objects All method names are compliant with Spring Data naming 22 | * conventions so this interface can easily be extended for Spring Data See here: http://static.springsource.org/spring-data/jpa/docs/current/reference/html/jpa.repositories.html#jpa.query-methods.query-creation 23 | * 24 | * @author Ken Krebs 25 | * @author Juergen Hoeller 26 | * @author Sam Brannen 27 | * @author Michael Isvy 28 | * @author Maciej Szarlinski 29 | */ 30 | public interface OwnerRepository extends JpaRepository { } 31 | -------------------------------------------------------------------------------- /steeltoe-petclinic-visits-service/Visits.Api/Infrastructure/Repository/Visits.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Microsoft.Extensions.Logging; 3 | using Petclinic.Visits.Domain; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | 9 | namespace Petclinic.Visits.Infrastructure.Repository 10 | { 11 | internal class Visits : IVisits 12 | { 13 | private readonly ILogger _logger; 14 | private readonly VisitsContext _dbContext; 15 | 16 | public Visits(ILogger logger, VisitsContext dbContext) 17 | { 18 | _logger = logger; 19 | _dbContext = dbContext; 20 | } 21 | 22 | public Task> FindByPetIdAsync(int petId, CancellationToken cancellationToken = default) 23 | { 24 | return _dbContext.Visits.Where(q => q.PetId == petId).ToListAsync(cancellationToken); 25 | } 26 | 27 | public Task> FindByPetIdIn(IEnumerable petIds) 28 | { 29 | return _dbContext.Visits.Where(q => petIds.Any(a => a == q.PetId)).ToListAsync(); 30 | } 31 | 32 | public async Task SaveAsync(int petId, Visit visit, CancellationToken cancellationToken = default) 33 | { 34 | visit.SetPetId(petId); 35 | 36 | _dbContext.Visits.Add(visit); 37 | await _dbContext.SaveChangesAsync(cancellationToken); 38 | return visit; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/VetsServiceApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.vets; 17 | 18 | import org.springframework.boot.SpringApplication; 19 | import org.springframework.boot.autoconfigure.SpringBootApplication; 20 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 21 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 22 | import org.springframework.samples.petclinic.vets.system.VetsProperties; 23 | 24 | /** 25 | * @author Maciej Szarlinski 26 | */ 27 | @EnableDiscoveryClient 28 | @SpringBootApplication 29 | @EnableConfigurationProperties(VetsProperties.class) 30 | public class VetsServiceApplication { 31 | 32 | public static void main(String[] args) { 33 | SpringApplication.run(VetsServiceApplication.class, args); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /steeltoe-petclinic-customers-service/Customers.Api/Domain/Pet.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace Petclinic.Customers.Domain 5 | { 6 | public partial class Pet 7 | { 8 | internal Pet() 9 | { 10 | } 11 | 12 | public Pet(string name, DateTime? birthDate, int petTypeId, int ownerId, int id = default) 13 | { 14 | Id = id; 15 | Name = name ?? throw new ArgumentNullException(nameof(name)); 16 | BirthDate = birthDate; 17 | TypeId = petTypeId; 18 | OwnerId = ownerId; 19 | } 20 | 21 | public int Id { get; private set; } 22 | 23 | public string Name { get; private set; } 24 | 25 | public DateTime? BirthDate { get; private set; } 26 | 27 | public int TypeId { get; private set; } 28 | 29 | public int OwnerId { get; private set; } 30 | 31 | [JsonIgnore] 32 | public virtual Owner Owner { get; set; } 33 | 34 | [JsonIgnore] 35 | public virtual PetType PetType { get; set; } 36 | 37 | public override string ToString() 38 | { 39 | return $@"id:{Id}, name: {Name}, birthDate: {BirthDate}, type: {PetType}, owner: {Owner}"; 40 | } 41 | 42 | public void SetBirthDate(DateTime? birthDate) 43 | { 44 | BirthDate = birthDate; 45 | } 46 | 47 | public void SetName(string name) 48 | { 49 | Name = name ?? throw new ArgumentNullException(nameof(name)); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /steeltoe-petclinic-customers-service/Customers.Api/Infrastructure/SeedData.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Threading; 3 | 4 | namespace Petclinic.Customers.Infrastructure 5 | { 6 | internal static class SeedData 7 | { 8 | public static async void SeedAll(this CustomersContext dbContext, bool ensureDelete = false, bool ensureCreated = false, CancellationToken cancellationToken = default) 9 | { 10 | if (ensureDelete) 11 | { 12 | dbContext.Database.EnsureDeleted(); 13 | } 14 | 15 | if (ensureCreated) 16 | { 17 | dbContext.Database.EnsureCreated(); 18 | } 19 | 20 | if (!dbContext.PetTypes.Any()) 21 | { 22 | foreach (var petType in Fill.PetTypes) 23 | { 24 | await dbContext.AddAsync(petType, cancellationToken); 25 | } 26 | } 27 | 28 | if (!dbContext.Owners.Any()) 29 | { 30 | foreach (var owner in Fill.Owners) 31 | { 32 | await dbContext.AddAsync(owner, cancellationToken); 33 | } 34 | } 35 | 36 | if (!dbContext.Pets.Any()) 37 | { 38 | foreach (var pet in Fill.Pets) 39 | { 40 | await dbContext.AddAsync(pet, cancellationToken); 41 | } 42 | } 43 | 44 | await dbContext.SaveChangesAsync(cancellationToken); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /steeltoe-petclinic-vets-service/Vets.Api/Infrastructure/SeedData.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Threading; 3 | 4 | namespace Petclinic.Vets.Infrastructure 5 | { 6 | internal static class SeedData 7 | { 8 | public static async void SeedAll(this VetsContext dbContext, bool ensureDelete = false, bool ensureCreated = false, CancellationToken cancellationToken = default) 9 | { 10 | if (ensureDelete) 11 | { 12 | dbContext.Database.EnsureDeleted(); 13 | } 14 | 15 | if (ensureCreated) 16 | { 17 | dbContext.Database.EnsureCreated(); 18 | } 19 | 20 | if (!dbContext.Vets.Any()) 21 | { 22 | foreach (var vet in Fill.Vets) 23 | { 24 | await dbContext.AddAsync(vet, cancellationToken); 25 | } 26 | } 27 | 28 | if (!dbContext.Specialties.Any()) 29 | { 30 | foreach (var specialty in Fill.Specialties) 31 | { 32 | await dbContext.AddAsync(specialty, cancellationToken); 33 | } 34 | } 35 | 36 | if (!dbContext.VetSpecialties.Any()) 37 | { 38 | foreach (var vetSpecialty in Fill.VetSpecialties) 39 | { 40 | await dbContext.AddAsync(vetSpecialty, cancellationToken); 41 | } 42 | } 43 | 44 | await dbContext.SaveChangesAsync(cancellationToken); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/dto/OwnerDetails.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.api.dto; 17 | 18 | import com.fasterxml.jackson.annotation.JsonIgnore; 19 | import lombok.Data; 20 | 21 | import java.util.ArrayList; 22 | import java.util.List; 23 | 24 | import static java.util.stream.Collectors.toList; 25 | 26 | /** 27 | * @author Maciej Szarlinski 28 | */ 29 | @Data 30 | public class OwnerDetails { 31 | 32 | private int id; 33 | 34 | private String firstName; 35 | 36 | private String lastName; 37 | 38 | private String address; 39 | 40 | private String city; 41 | 42 | private String telephone; 43 | 44 | private final List pets = new ArrayList<>(); 45 | 46 | @JsonIgnore 47 | public List getPetIds() { 48 | return pets.stream() 49 | .map(PetDetails::getId) 50 | .collect(toList()); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/PetType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.customers.model; 17 | 18 | import javax.persistence.Column; 19 | import javax.persistence.Entity; 20 | import javax.persistence.GeneratedValue; 21 | import javax.persistence.GenerationType; 22 | import javax.persistence.Id; 23 | import javax.persistence.Table; 24 | 25 | /** 26 | * @author Juergen Hoeller 27 | * Can be Cat, Dog, Hamster... 28 | */ 29 | @Entity 30 | @Table(name = "types") 31 | public class PetType { 32 | @Id 33 | @GeneratedValue(strategy = GenerationType.IDENTITY) 34 | private Integer id; 35 | 36 | @Column(name = "name") 37 | private String name; 38 | 39 | public Integer getId() { 40 | return id; 41 | } 42 | 43 | public void setId(final Integer id) { 44 | this.id = id; 45 | } 46 | 47 | public String getName() { 48 | return this.name; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/application/CustomersServiceClient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.api.application; 17 | 18 | import lombok.RequiredArgsConstructor; 19 | import org.springframework.samples.petclinic.api.dto.OwnerDetails; 20 | import org.springframework.stereotype.Component; 21 | import org.springframework.web.client.RestTemplate; 22 | import org.springframework.web.reactive.function.client.WebClient; 23 | import reactor.core.publisher.Mono; 24 | 25 | /** 26 | * @author Maciej Szarlinski 27 | */ 28 | @Component 29 | @RequiredArgsConstructor 30 | public class CustomersServiceClient { 31 | 32 | private final WebClient.Builder webClientBuilder; 33 | 34 | public Mono getOwner(final int ownerId) { 35 | return webClientBuilder.build().get() 36 | .uri("http://customers-service/owners/{ownerId}", ownerId) 37 | .retrieve() 38 | .bodyToMono(OwnerDetails.class); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/model/VisitRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.visits.model; 17 | 18 | import java.util.Collection; 19 | import java.util.List; 20 | 21 | import org.springframework.data.jpa.repository.JpaRepository; 22 | 23 | /** 24 | * Repository class for Visit domain objects All method names are compliant with Spring Data naming conventions so this interface can easily be extended for Spring 25 | * Data See here: http://static.springsource.org/spring-data/jpa/docs/current/reference/html/jpa.repositories.html#jpa.query-methods.query-creation 26 | * 27 | * @author Ken Krebs 28 | * @author Juergen Hoeller 29 | * @author Sam Brannen 30 | * @author Michael Isvy 31 | * @author Maciej Szarlinski 32 | */ 33 | public interface VisitRepository extends JpaRepository { 34 | 35 | List findByPetId(int petId); 36 | 37 | List findByPetIdIn(Collection petIds); 38 | } 39 | -------------------------------------------------------------------------------- /steeltoe-petclinic-customers-service/Customers.Api/DTOs/OwnerDetails.cs: -------------------------------------------------------------------------------- 1 | using Petclinic.Customers.Domain; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace Petclinic.Customers.DTOs 6 | { 7 | public class OwnerDetails 8 | { 9 | public OwnerDetails() { } 10 | 11 | public OwnerDetails(int id, string firstName, string lastName, string address, string city, string telephone, List pets) 12 | { 13 | Id = id; 14 | FirstName = firstName; 15 | LastName = lastName; 16 | Address = address; 17 | City = city; 18 | Telephone = telephone; 19 | Pets = pets; 20 | } 21 | 22 | public int Id { get; set; } 23 | 24 | public string FirstName { get; set; } 25 | 26 | public string LastName { get; set; } 27 | 28 | public string Address { get; set; } 29 | 30 | public string City { get; set; } 31 | 32 | public string Telephone { get; set; } 33 | 34 | public List Pets { get; set; } 35 | 36 | public static OwnerDetails FromOwner(Owner owner) 37 | { 38 | return new OwnerDetails() 39 | { 40 | Id = owner.Id, 41 | FirstName = owner.FirstName, 42 | LastName = owner.LastName, 43 | Address = owner.Address, 44 | City = owner.City, 45 | Telephone = owner.Telephone, 46 | Pets = owner.Pets.Select(q => new PetDetails(q.Id, q.Name, owner.FirstName + " " + owner.LastName, q.BirthDate, PetType.ToDTO(q.PetType))).ToList() 47 | }; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /steeltoe-petclinic-customers-service/Customers.Test/Steeltoe.Petclinic.Customers.Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | Petclinic.Customers.Test 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | all 18 | runtime; build; native; contentfiles; analyzers; buildtransitive 19 | 20 | 21 | all 22 | runtime; build; native; contentfiles; analyzers; buildtransitive 23 | 24 | 25 | 26 | runtime; build; native; contentfiles; analyzers; buildtransitive 27 | all 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/web/VetResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.vets.web; 17 | 18 | import lombok.RequiredArgsConstructor; 19 | 20 | import java.util.List; 21 | 22 | import org.springframework.samples.petclinic.vets.model.Vet; 23 | import org.springframework.samples.petclinic.vets.model.VetRepository; 24 | import org.springframework.web.bind.annotation.GetMapping; 25 | import org.springframework.web.bind.annotation.RequestMapping; 26 | import org.springframework.web.bind.annotation.RestController; 27 | 28 | /** 29 | * @author Juergen Hoeller 30 | * @author Mark Fisher 31 | * @author Ken Krebs 32 | * @author Arjen Poutsma 33 | * @author Maciej Szarlinski 34 | */ 35 | @RequestMapping("/vets") 36 | @RestController 37 | @RequiredArgsConstructor 38 | class VetResource { 39 | 40 | private final VetRepository vetRepository; 41 | 42 | @GetMapping 43 | public List showResourcesVetList() { 44 | return vetRepository.findAll(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/less/header.less: -------------------------------------------------------------------------------- 1 | .navbar { 2 | border-top: 4px solid #6db33f; 3 | background-color: #34302d; 4 | margin-bottom: 0px; 5 | border-bottom: 0; 6 | border-left: 0; 7 | border-right: 0; 8 | } 9 | 10 | .navbar a.navbar-brand { 11 | background: url("../images/spring-logo-dataflow.png") -1px -1px no-repeat; 12 | margin: 12px 0 6px; 13 | width: 229px; 14 | height: 46px; 15 | display: inline-block; 16 | text-decoration: none; 17 | padding: 0; 18 | } 19 | 20 | .navbar a.navbar-brand span { 21 | display: block; 22 | width: 229px; 23 | height: 46px; 24 | background: url("../images/spring-logo-dataflow.png") -1px -48px no-repeat; 25 | opacity: 0; 26 | -moz-transition: opacity 0.12s ease-in-out; 27 | -webkit-transition: opacity 0.12s ease-in-out; 28 | -o-transition: opacity 0.12s ease-in-out; 29 | } 30 | 31 | .navbar a:hover.navbar-brand span { 32 | opacity: 1; 33 | } 34 | 35 | .navbar li > a, .navbar-text { 36 | font-family: "montserratregular", sans-serif; 37 | text-shadow: none; 38 | font-size: 14px; 39 | 40 | /* line-height: 14px; */ 41 | padding: 28px 20px; 42 | transition: all 0.15s; 43 | -webkit-transition: all 0.15s; 44 | -moz-transition: all 0.15s; 45 | -o-transition: all 0.15s; 46 | -ms-transition: all 0.15s; 47 | } 48 | 49 | .navbar li > a { 50 | text-transform: uppercase; 51 | } 52 | 53 | .navbar .navbar-text { 54 | margin-top: 0; 55 | margin-bottom: 0; 56 | } 57 | .navbar li:hover > a { 58 | color: #eeeeee; 59 | background-color: #6db33f; 60 | } 61 | 62 | .navbar-toggle { 63 | border-width: 0; 64 | 65 | .icon-bar + .icon-bar { 66 | margin-top: 3px; 67 | } 68 | .icon-bar { 69 | width: 19px; 70 | height: 3px; 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/less/typography.less: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'varela_roundregular'; 3 | 4 | src: url('../fonts/varela_round-webfont.eot'); 5 | src: url('../fonts/varela_round-webfont.eot?#iefix') format('embedded-opentype'), 6 | url('../fonts/varela_round-webfont.woff') format('woff'), 7 | url('../fonts/varela_round-webfont.ttf') format('truetype'), 8 | url('../fonts/varela_round-webfont.svg#varela_roundregular') format('svg'); 9 | font-weight: normal; 10 | font-style: normal; 11 | } 12 | 13 | @font-face { 14 | font-family: 'montserratregular'; 15 | src: url('../fonts/montserrat-webfont.eot'); 16 | src: url('../fonts/montserrat-webfont.eot?#iefix') format('embedded-opentype'), 17 | url('../fonts/montserrat-webfont.woff') format('woff'), 18 | url('../fonts/montserrat-webfont.ttf') format('truetype'), 19 | url('../fonts/montserrat-webfont.svg#montserratregular') format('svg'); 20 | font-weight: normal; 21 | font-style: normal; 22 | } 23 | 24 | body, h1, h2, h3, p, input { 25 | margin: 0; 26 | font-weight: 400; 27 | font-family: "varela_roundregular", sans-serif; 28 | color: #34302d; 29 | } 30 | 31 | h1 { 32 | font-size: 24px; 33 | line-height: 30px; 34 | font-family: "montserratregular", sans-serif; 35 | } 36 | 37 | h2 { 38 | font-size: 18px; 39 | font-weight: 700; 40 | line-height: 24px; 41 | margin-bottom: 10px; 42 | font-family: "montserratregular", sans-serif; 43 | } 44 | 45 | h3 { 46 | font-size: 16px; 47 | line-height: 24px; 48 | margin-bottom: 10px; 49 | font-weight: 700; 50 | } 51 | 52 | p { 53 | //font-size: 15px; 54 | //line-height: 24px; 55 | } 56 | 57 | strong { 58 | font-weight: 700; 59 | font-family: "montserratregular", sans-serif; 60 | } 61 | -------------------------------------------------------------------------------- /spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/PetDetails.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.customers.web; 17 | 18 | import lombok.Data; 19 | 20 | import java.util.Date; 21 | 22 | import org.springframework.format.annotation.DateTimeFormat; 23 | import org.springframework.samples.petclinic.customers.model.Pet; 24 | import org.springframework.samples.petclinic.customers.model.PetType; 25 | 26 | /** 27 | * @author mszarlinski@bravurasolutions.com on 2016-12-05. 28 | */ 29 | @Data 30 | class PetDetails { 31 | 32 | private long id; 33 | 34 | private String name; 35 | 36 | private String owner; 37 | 38 | @DateTimeFormat(pattern = "yyyy-MM-dd") 39 | private Date birthDate; 40 | 41 | private PetType type; 42 | 43 | PetDetails(Pet pet) { 44 | this.id = pet.getId(); 45 | this.name = pet.getName(); 46 | this.owner = pet.getOwner().getFirstName() + " " + pet.getOwner().getLastName(); 47 | this.birthDate = pet.getBirthDate(); 48 | this.type = pet.getType(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /steeltoe-petclinic-visits-service/Visits.Api/Infrastructure/VisitsContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Petclinic.Visits.Domain; 3 | 4 | namespace Petclinic.Visits.Infrastructure 5 | { 6 | public partial class VisitsContext : DbContext 7 | { 8 | public VisitsContext() 9 | { 10 | } 11 | 12 | public VisitsContext(DbContextOptions options) 13 | : base(options) 14 | { 15 | } 16 | 17 | public virtual DbSet Visits { get; set; } 18 | 19 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) 20 | { 21 | optionsBuilder.EnableSensitiveDataLogging(true); 22 | } 23 | 24 | protected override void OnModelCreating(ModelBuilder modelBuilder) 25 | { 26 | modelBuilder.Entity(entity => 27 | { 28 | entity.ToTable("visits"); 29 | 30 | entity.HasIndex(e => e.PetId) 31 | .HasName("visits_pet_id"); 32 | 33 | entity.Property(e => e.Id) 34 | .HasColumnName("id"); 35 | 36 | entity.Property(e => e.Description) 37 | .HasColumnName("description") 38 | .HasMaxLength(8000) 39 | .IsUnicode(false); 40 | 41 | entity.Property(e => e.PetId).HasColumnName("pet_id"); 42 | 43 | entity.Property(e => e.Date) 44 | .HasColumnName("visit_date") 45 | .HasColumnType("date"); 46 | }); 47 | 48 | OnModelCreatingPartial(modelBuilder); 49 | } 50 | 51 | partial void OnModelCreatingPartial(ModelBuilder modelBuilder); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/model/Specialty.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.vets.model; 17 | 18 | import javax.persistence.Column; 19 | import javax.persistence.Entity; 20 | import javax.persistence.GeneratedValue; 21 | import javax.persistence.GenerationType; 22 | import javax.persistence.Id; 23 | import javax.persistence.Table; 24 | 25 | /** 26 | * Models a {@link Vet Vet's} specialty (for example, dentistry). 27 | * 28 | * @author Juergen Hoeller 29 | */ 30 | @Entity 31 | @Table(name = "specialties") 32 | public class Specialty { 33 | @Id 34 | @GeneratedValue(strategy = GenerationType.IDENTITY) 35 | private Integer id; 36 | 37 | @Column(name = "name") 38 | private String name; 39 | 40 | public Integer getId() { 41 | return id; 42 | } 43 | 44 | public void setId(final Integer id) { 45 | this.id = id; 46 | } 47 | 48 | public String getName() { 49 | return name; 50 | } 51 | 52 | public void setName(final String name) { 53 | this.name = name; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/scripts/owner-form/owner-form.template.html: -------------------------------------------------------------------------------- 1 |

Owner

2 |
3 |
4 | 5 | 6 | First name is required. 7 |
8 | 9 |
10 | 11 | 12 | Last name is required. 13 |
14 | 15 | 16 |
17 | 18 | 19 | Address is required. 20 |
21 | 22 |
23 | 24 | 25 | City is required. 26 |
27 | 28 |
29 | 30 | 31 | Telephone is required. 32 |
33 | 34 |
35 | 36 |
37 |
38 | 39 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/scripts/pet-form/pet-form.template.html: -------------------------------------------------------------------------------- 1 |

Pet

2 | 3 |
4 |
5 | 6 |
7 |

{{$ctrl.pet.owner}}

8 |
9 |
10 | 11 |
12 | 13 |
14 | 15 | Name is required. 16 |
17 |
18 | 19 |
20 | 21 |
22 | 23 | birth date is required. 24 |
25 |
26 | 27 |
28 | 29 |
30 | 33 |
34 |
35 | 36 |
37 |
38 | 41 |
42 |
43 |
44 | -------------------------------------------------------------------------------- /steeltoe-petclinic-vets-service/Vets.ITest/Controllers/Vets.cs: -------------------------------------------------------------------------------- 1 | using Petclinic.Vets.DTOs; 2 | using Petclinic.Vets.Infrastructure; 3 | using System; 4 | using System.Linq; 5 | using System.Net.Http; 6 | using System.Net.Http.Json; 7 | using System.Threading.Tasks; 8 | using Xunit; 9 | using Xunit.Abstractions; 10 | 11 | namespace Petclinic.Vets.ITest.Controllers 12 | { 13 | [Collection("Vets API Test Collection")] 14 | public class Vets : IClassFixture>, IDisposable 15 | { 16 | private readonly HttpClient _client; 17 | private readonly CustomersAppFactory _factory; 18 | 19 | public Vets(CustomersAppFactory factory, ITestOutputHelper outputHelper) 20 | { 21 | factory.OutputHelper = outputHelper; 22 | _factory = factory; 23 | _client = _factory.CreateClient(); 24 | } 25 | public void Dispose() 26 | { 27 | //_client.Dispose(); 28 | //_factory.OutputHelper = null; 29 | //_factory.Dispose(); 30 | } 31 | 32 | [Fact(DisplayName = "GET Health")] 33 | public async Task Health() 34 | { 35 | var respObj = await _client.GetFromJsonAsync("actuator/health"); 36 | Assert.NotNull(respObj); 37 | } 38 | 39 | [Fact(DisplayName = "GET vets")] 40 | public async Task FindPet() 41 | { 42 | var vets = await _client.GetFromJsonAsync($"vets"); 43 | 44 | Assert.NotNull(vets); 45 | Assert.Equal(Fill.Vets.Count(), vets.Count()); 46 | foreach (var vet in vets) 47 | Assert.Equal(Fill.VetSpecialties.Where(q => q.VetId == vet.Id).Count(), vet.Specialties.Count()); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /steeltoe-petclinic-vets-service/Vets.Api/Steeltoe.Petclinic.Vets.Api.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | Petclinic.Vets.Api 6 | 1.0.0 7 | vets-service 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | runtime; build; native; contentfiles; analyzers; buildtransitive 29 | all 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /steeltoe-petclinic-visits-service/Visits.Api/Steeltoe.Petclinic.Visits.Api.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | Petclinic.Visits 6 | 1.0.0 7 | visits-service 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | runtime; build; native; contentfiles; analyzers; buildtransitive 29 | all 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /steeltoe-petclinic-customers-service/Customers.Api/Steeltoe.Petclinic.Customers.Api.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | Petclinic.Customers 6 | 1.0.0 7 | customers-service 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | runtime; build; native; contentfiles; analyzers; buildtransitive 29 | all 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /steeltoe-petclinic-vets-service/Vets.Api/Controllers/VetsController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Petclinic.Vets.DTOs; 3 | using Petclinic.Vets.Infrastructure.Repository; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Net; 7 | using System.Threading; 8 | 9 | namespace Petclinic.Vets.Controllers 10 | { 11 | [Route("[controller]")] 12 | [ApiController] 13 | [Produces("application/json")] 14 | public class VetsController : ControllerBase 15 | { 16 | private readonly IVets _vetsRepo; 17 | private readonly IVetSpecialties _vetSpecialtiesRepo; 18 | 19 | public VetsController(IVets vetsRepo, IVetSpecialties vetSpecialtiesRepo) 20 | { 21 | _vetsRepo = vetsRepo; 22 | _vetSpecialtiesRepo = vetSpecialtiesRepo; 23 | } 24 | 25 | [HttpGet] 26 | [ProducesResponseType(typeof(List), (int)HttpStatusCode.OK)] 27 | public ActionResult> ShowResourcesVetList(CancellationToken cancellationToken) 28 | { 29 | var ret = new List(); 30 | 31 | _vetsRepo.FindAll().ToList().ForEach((vet) => 32 | { 33 | cancellationToken.ThrowIfCancellationRequested(); 34 | 35 | var vetSpecialties = _vetSpecialtiesRepo.FindAllByVetId(vet.Id); 36 | 37 | var specialtyDetails = new List(); 38 | vetSpecialties.ToList().ForEach((vetSpecialty) => 39 | { 40 | cancellationToken.ThrowIfCancellationRequested(); 41 | 42 | specialtyDetails.Add(new SpecialtyDetails(vetSpecialty.Specialty.Id, vetSpecialty.Specialty.Name)); 43 | }); 44 | 45 | ret.Add(new VetDetails(vet.Id, vet.FirstName, vet.LastName, specialtyDetails)); 46 | }); 47 | 48 | return Ok(ret); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /steeltoe-petclinic-vets-service/Vets.Api/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Hosting; 2 | using Microsoft.Extensions.DependencyInjection; 3 | using Microsoft.Extensions.Hosting; 4 | using Microsoft.Extensions.Logging; 5 | using Steeltoe.Common.Hosting; 6 | using Steeltoe.Discovery.Client; 7 | using Steeltoe.Extensions.Configuration.ConfigServer; 8 | using Steeltoe.Extensions.Configuration.Placeholder; 9 | using Steeltoe.Management.Endpoint; 10 | using System; 11 | 12 | namespace Petclinic.Vets 13 | { 14 | public class Program 15 | { 16 | public static void Main(string[] args) 17 | { 18 | CreateHostBuilder(args).Build().Run(); 19 | } 20 | 21 | public static IHostBuilder CreateHostBuilder(string[] args) => 22 | Host.CreateDefaultBuilder(args) 23 | .ConfigureWebHostDefaults(webBuilder => 24 | { 25 | webBuilder.UseStartup(); 26 | }) 27 | .ConfigureAppConfiguration(builder => 28 | { 29 | builder.AddPlaceholderResolver(); 30 | builder.AddConfigServer(Environment.GetEnvironmentVariable("ENVIRONMENT"), GetLoggerFactory()); 31 | }) 32 | .UseCloudHosting(8083) 33 | .AddDiscoveryClient() 34 | .AddAllActuators(); 35 | 36 | public static ILoggerFactory GetLoggerFactory() 37 | { 38 | IServiceCollection serviceCollection = new ServiceCollection(); 39 | serviceCollection.AddLogging(builder => builder.SetMinimumLevel(LogLevel.Trace)); 40 | serviceCollection.AddLogging(builder => builder.AddConsole((opts) => 41 | { 42 | opts.DisableColors = true; 43 | })); 44 | serviceCollection.AddLogging(builder => builder.AddDebug()); 45 | return serviceCollection.BuildServiceProvider().GetService(); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /steeltoe-petclinic-visits-service/Visits.Api/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Hosting; 2 | using Microsoft.Extensions.DependencyInjection; 3 | using Microsoft.Extensions.Hosting; 4 | using Microsoft.Extensions.Logging; 5 | using Steeltoe.Common.Hosting; 6 | using Steeltoe.Discovery.Client; 7 | using Steeltoe.Extensions.Configuration.ConfigServer; 8 | using Steeltoe.Extensions.Configuration.Placeholder; 9 | using Steeltoe.Management.Endpoint; 10 | using System; 11 | 12 | namespace Petclinic.Visits 13 | { 14 | public class Program 15 | { 16 | public static void Main(string[] args) 17 | { 18 | CreateHostBuilder(args).Build().Run(); 19 | } 20 | 21 | public static IHostBuilder CreateHostBuilder(string[] args) => 22 | Host.CreateDefaultBuilder(args) 23 | .ConfigureWebHostDefaults(webBuilder => 24 | { 25 | webBuilder.UseStartup(); 26 | }) 27 | .ConfigureAppConfiguration(builder => 28 | { 29 | builder.AddPlaceholderResolver(); 30 | builder.AddConfigServer(Environment.GetEnvironmentVariable("ENVIRONMENT"), GetLoggerFactory()); 31 | }) 32 | .UseCloudHosting(8082) 33 | .AddDiscoveryClient() 34 | .AddAllActuators(); 35 | 36 | public static ILoggerFactory GetLoggerFactory() 37 | { 38 | IServiceCollection serviceCollection = new ServiceCollection(); 39 | serviceCollection.AddLogging(builder => builder.SetMinimumLevel(LogLevel.Trace)); 40 | serviceCollection.AddLogging(builder => builder.AddConsole((opts) => 41 | { 42 | opts.DisableColors = true; 43 | })); 44 | serviceCollection.AddLogging(builder => builder.AddDebug()); 45 | return serviceCollection.BuildServiceProvider().GetService(); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /steeltoe-petclinic-customers-service/Customers.Api/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Hosting; 2 | using Microsoft.Extensions.DependencyInjection; 3 | using Microsoft.Extensions.Hosting; 4 | using Microsoft.Extensions.Logging; 5 | using Steeltoe.Common.Hosting; 6 | using Steeltoe.Discovery.Client; 7 | using Steeltoe.Extensions.Configuration.ConfigServer; 8 | using Steeltoe.Extensions.Configuration.Placeholder; 9 | using Steeltoe.Management.Endpoint; 10 | using System; 11 | 12 | namespace Petclinic.Customers 13 | { 14 | public class Program 15 | { 16 | public static void Main(string[] args) 17 | { 18 | CreateHostBuilder(args).Build().Run(); 19 | } 20 | 21 | public static IHostBuilder CreateHostBuilder(string[] args) => 22 | Host.CreateDefaultBuilder(args) 23 | .ConfigureWebHostDefaults(webBuilder => 24 | { 25 | webBuilder.UseStartup(); 26 | }) 27 | .ConfigureAppConfiguration(builder => 28 | { 29 | builder.AddPlaceholderResolver(); 30 | builder.AddConfigServer(Environment.GetEnvironmentVariable("ENVIRONMENT"), GetLoggerFactory()); 31 | }) 32 | .UseCloudHosting(8081) 33 | .AddDiscoveryClient() 34 | .AddAllActuators(); 35 | 36 | public static ILoggerFactory GetLoggerFactory() 37 | { 38 | IServiceCollection serviceCollection = new ServiceCollection(); 39 | serviceCollection.AddLogging(builder => builder.SetMinimumLevel(LogLevel.Trace)); 40 | serviceCollection.AddLogging(builder => builder.AddConsole((opts) => 41 | { 42 | opts.DisableColors = true; 43 | })); 44 | serviceCollection.AddLogging(builder => builder.AddDebug()); 45 | return serviceCollection.BuildServiceProvider().GetService(); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/PetRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.customers.model; 17 | 18 | import java.util.List; 19 | import java.util.Optional; 20 | 21 | import org.springframework.data.jpa.repository.JpaRepository; 22 | import org.springframework.data.jpa.repository.Query; 23 | import org.springframework.data.repository.query.Param; 24 | 25 | /** 26 | * Repository class for Pet domain objects All method names are compliant with Spring Data naming 27 | * conventions so this interface can easily be extended for Spring Data See here: http://static.springsource.org/spring-data/jpa/docs/current/reference/html/jpa.repositories.html#jpa.query-methods.query-creation 28 | * 29 | * @author Ken Krebs 30 | * @author Juergen Hoeller 31 | * @author Sam Brannen 32 | * @author Michael Isvy 33 | * @author Maciej Szarlinski 34 | */ 35 | public interface PetRepository extends JpaRepository { 36 | 37 | /** 38 | * Retrieve all {@link PetType}s from the data store. 39 | * @return a Collection of {@link PetType}s. 40 | */ 41 | @Query("SELECT ptype FROM PetType ptype ORDER BY ptype.name") 42 | List findPetTypes(); 43 | 44 | @Query("FROM PetType ptype WHERE ptype.id = :typeId") 45 | Optional findPetTypeById(@Param("typeId") int typeId); 46 | 47 | 48 | } 49 | 50 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/application/VisitsServiceClient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.api.application; 17 | 18 | import lombok.RequiredArgsConstructor; 19 | import org.springframework.samples.petclinic.api.dto.Visits; 20 | import org.springframework.stereotype.Component; 21 | import org.springframework.web.reactive.function.client.WebClient; 22 | import reactor.core.publisher.Mono; 23 | 24 | import java.util.List; 25 | 26 | import static java.util.stream.Collectors.joining; 27 | 28 | /** 29 | * @author Maciej Szarlinski 30 | */ 31 | @Component 32 | @RequiredArgsConstructor 33 | public class VisitsServiceClient { 34 | 35 | // Could be changed for testing purpose 36 | private String hostname = "http://visits-service/"; 37 | 38 | private final WebClient.Builder webClientBuilder; 39 | 40 | public Mono getVisitsForPets(final List petIds) { 41 | return webClientBuilder.build() 42 | .get() 43 | .uri(hostname + "pets/visits?petId={petId}", joinIds(petIds)) 44 | .retrieve() 45 | .bodyToMono(Visits.class); 46 | } 47 | 48 | private String joinIds(List petIds) { 49 | return petIds.stream().map(Object::toString).collect(joining(",")); 50 | } 51 | 52 | void setHostname(String hostname) { 53 | this.hostname = hostname; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /spring-petclinic-config-server/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.samples.petclinic.config 7 | spring-petclinic-config-server 8 | jar 9 | Spring PetClinic Config Server 10 | 11 | 12 | org.springframework.samples 13 | spring-petclinic-microservices 14 | 2.3.6 15 | 16 | 17 | 18 | 8888 19 | ${basedir}/../docker 20 | 21 | 22 | 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-test 27 | test 28 | 29 | 30 | 31 | 32 | org.springframework.cloud 33 | spring-cloud-config-server 34 | 35 | 36 | 37 | 38 | org.jolokia 39 | jolokia-core 40 | 41 | 42 | 43 | 44 | org.junit.jupiter 45 | junit-jupiter-api 46 | test 47 | 48 | 49 | org.junit.jupiter 50 | junit-jupiter-engine 51 | test 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /spring-petclinic-customers-service/src/main/resources/db/hsqldb/data.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO types VALUES (1, 'cat'); 2 | INSERT INTO types VALUES (2, 'dog'); 3 | INSERT INTO types VALUES (3, 'lizard'); 4 | INSERT INTO types VALUES (4, 'snake'); 5 | INSERT INTO types VALUES (5, 'bird'); 6 | INSERT INTO types VALUES (6, 'hamster'); 7 | 8 | INSERT INTO owners VALUES (1, 'George', 'Franklin', '110 W. Liberty St.', 'Madison', '6085551023'); 9 | INSERT INTO owners VALUES (2, 'Betty', 'Davis', '638 Cardinal Ave.', 'Sun Prairie', '6085551749'); 10 | INSERT INTO owners VALUES (3, 'Eduardo', 'Rodriquez', '2693 Commerce St.', 'McFarland', '6085558763'); 11 | INSERT INTO owners VALUES (4, 'Harold', 'Davis', '563 Friendly St.', 'Windsor', '6085553198'); 12 | INSERT INTO owners VALUES (5, 'Peter', 'McTavish', '2387 S. Fair Way', 'Madison', '6085552765'); 13 | INSERT INTO owners VALUES (6, 'Jean', 'Coleman', '105 N. Lake St.', 'Monona', '6085552654'); 14 | INSERT INTO owners VALUES (7, 'Jeff', 'Black', '1450 Oak Blvd.', 'Monona', '6085555387'); 15 | INSERT INTO owners VALUES (8, 'Maria', 'Escobito', '345 Maple St.', 'Madison', '6085557683'); 16 | INSERT INTO owners VALUES (9, 'David', 'Schroeder', '2749 Blackhawk Trail', 'Madison', '6085559435'); 17 | INSERT INTO owners VALUES (10, 'Carlos', 'Estaban', '2335 Independence La.', 'Waunakee', '6085555487'); 18 | 19 | INSERT INTO pets VALUES (1, 'Leo', '2010-09-07', 1, 1); 20 | INSERT INTO pets VALUES (2, 'Basil', '2012-08-06', 6, 2); 21 | INSERT INTO pets VALUES (3, 'Rosy', '2011-04-17', 2, 3); 22 | INSERT INTO pets VALUES (4, 'Jewel', '2010-03-07', 2, 3); 23 | INSERT INTO pets VALUES (5, 'Iggy', '2010-11-30', 3, 4); 24 | INSERT INTO pets VALUES (6, 'George', '2010-01-20', 4, 5); 25 | INSERT INTO pets VALUES (7, 'Samantha', '2012-09-04', 1, 6); 26 | INSERT INTO pets VALUES (8, 'Max', '2012-09-04', 1, 6); 27 | INSERT INTO pets VALUES (9, 'Lucky', '2011-08-06', 5, 7); 28 | INSERT INTO pets VALUES (10, 'Mulligan', '2007-02-24', 2, 8); 29 | INSERT INTO pets VALUES (11, 'Freddy', '2010-03-09', 5, 9); 30 | INSERT INTO pets VALUES (12, 'Lucky', '2010-06-24', 2, 10); 31 | INSERT INTO pets VALUES (13, 'Sly', '2012-06-08', 1, 10); 32 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/scripts/fragments/nav.html: -------------------------------------------------------------------------------- 1 | 39 | -------------------------------------------------------------------------------- /spring-petclinic-customers-service/src/main/resources/db/mysql/data.sql: -------------------------------------------------------------------------------- 1 | INSERT IGNORE INTO types VALUES (1, 'cat'); 2 | INSERT IGNORE INTO types VALUES (2, 'dog'); 3 | INSERT IGNORE INTO types VALUES (3, 'lizard'); 4 | INSERT IGNORE INTO types VALUES (4, 'snake'); 5 | INSERT IGNORE INTO types VALUES (5, 'bird'); 6 | INSERT IGNORE INTO types VALUES (6, 'hamster'); 7 | 8 | INSERT IGNORE INTO owners VALUES (1, 'George', 'Franklin', '110 W. Liberty St.', 'Madison', '6085551023'); 9 | INSERT IGNORE INTO owners VALUES (2, 'Betty', 'Davis', '638 Cardinal Ave.', 'Sun Prairie', '6085551749'); 10 | INSERT IGNORE INTO owners VALUES (3, 'Eduardo', 'Rodriquez', '2693 Commerce St.', 'McFarland', '6085558763'); 11 | INSERT IGNORE INTO owners VALUES (4, 'Harold', 'Davis', '563 Friendly St.', 'Windsor', '6085553198'); 12 | INSERT IGNORE INTO owners VALUES (5, 'Peter', 'McTavish', '2387 S. Fair Way', 'Madison', '6085552765'); 13 | INSERT IGNORE INTO owners VALUES (6, 'Jean', 'Coleman', '105 N. Lake St.', 'Monona', '6085552654'); 14 | INSERT IGNORE INTO owners VALUES (7, 'Jeff', 'Black', '1450 Oak Blvd.', 'Monona', '6085555387'); 15 | INSERT IGNORE INTO owners VALUES (8, 'Maria', 'Escobito', '345 Maple St.', 'Madison', '6085557683'); 16 | INSERT IGNORE INTO owners VALUES (9, 'David', 'Schroeder', '2749 Blackhawk Trail', 'Madison', '6085559435'); 17 | INSERT IGNORE INTO owners VALUES (10, 'Carlos', 'Estaban', '2335 Independence La.', 'Waunakee', '6085555487'); 18 | 19 | INSERT IGNORE INTO pets VALUES (1, 'Leo', '2000-09-07', 1, 1); 20 | INSERT IGNORE INTO pets VALUES (2, 'Basil', '2002-08-06', 6, 2); 21 | INSERT IGNORE INTO pets VALUES (3, 'Rosy', '2001-04-17', 2, 3); 22 | INSERT IGNORE INTO pets VALUES (4, 'Jewel', '2000-03-07', 2, 3); 23 | INSERT IGNORE INTO pets VALUES (5, 'Iggy', '2000-11-30', 3, 4); 24 | INSERT IGNORE INTO pets VALUES (6, 'George', '2000-01-20', 4, 5); 25 | INSERT IGNORE INTO pets VALUES (7, 'Samantha', '1995-09-04', 1, 6); 26 | INSERT IGNORE INTO pets VALUES (8, 'Max', '1995-09-04', 1, 6); 27 | INSERT IGNORE INTO pets VALUES (9, 'Lucky', '1999-08-06', 5, 7); 28 | INSERT IGNORE INTO pets VALUES (10, 'Mulligan', '1997-02-24', 2, 8); 29 | INSERT IGNORE INTO pets VALUES (11, 'Freddy', '2000-03-09', 5, 9); 30 | INSERT IGNORE INTO pets VALUES (12, 'Lucky', '2000-06-24', 2, 10); 31 | INSERT IGNORE INTO pets VALUES (13, 'Sly', '2002-06-08', 1, 10); 32 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/scripts/pet-form/pet-form.controller.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('petForm') 4 | .controller('PetFormController', ['$http', '$state', '$stateParams', function ($http, $state, $stateParams) { 5 | var self = this; 6 | var ownerId = $stateParams.ownerId || 0; 7 | 8 | $http.get('api/customer/petTypes').then(function (resp) { 9 | self.types = resp.data; 10 | }).then(function () { 11 | 12 | var petId = $stateParams.petId || 0; 13 | 14 | if (petId) { // edit 15 | $http.get("api/customer/owners/" + ownerId + "/pets/" + petId).then(function (resp) { 16 | self.pet = resp.data; 17 | self.pet.birthDate = new Date(self.pet.birthDate); 18 | self.petTypeId = "" + self.pet.type.id; 19 | }); 20 | } else { 21 | $http.get('api/customer/owners/' + ownerId).then(function (resp) { 22 | self.pet = { 23 | owner: resp.data.firstName + " " + resp.data.lastName 24 | }; 25 | self.petTypeId = "1"; 26 | }) 27 | 28 | } 29 | }); 30 | 31 | self.submit = function () { 32 | var id = self.pet.id || 0; 33 | 34 | var data = { 35 | id: id, 36 | name: self.pet.name, 37 | birthDate: self.pet.birthDate, 38 | typeId: self.petTypeId 39 | }; 40 | 41 | var req; 42 | if (id) { 43 | req = $http.put("api/customer/owners/" + ownerId + "/pets/" + id, data); 44 | } else { 45 | req = $http.post("api/customer/owners/" + ownerId + "/pets", data); 46 | } 47 | 48 | req.then(function () { 49 | $state.go("owners", {ownerId: ownerId}); 50 | }, function (response) { 51 | var error = response.data; 52 | error.errors = error.errors || []; 53 | alert(error.error + "\r\n" + error.errors.map(function (e) { 54 | return e.field + ": " + e.defaultMessage; 55 | }).join("\r\n")); 56 | }); 57 | }; 58 | }]); 59 | -------------------------------------------------------------------------------- /spring-petclinic-discovery-server/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.samples.petclinic.discovery 7 | spring-petclinic-discovery-server 8 | jar 9 | Spring PetClinic Discovery Server 10 | 11 | 12 | org.springframework.samples 13 | spring-petclinic-microservices 14 | 2.3.6 15 | 16 | 17 | 18 | 8761 19 | ${basedir}/../docker 20 | 21 | 22 | 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-test 27 | test 28 | 29 | 30 | 31 | 32 | org.springframework.cloud 33 | spring-cloud-starter-config 34 | 35 | 36 | org.springframework.cloud 37 | spring-cloud-starter-netflix-eureka-server 38 | 39 | 40 | 41 | 42 | org.junit.jupiter 43 | junit-jupiter-api 44 | test 45 | 46 | 47 | org.junit.jupiter 48 | junit-jupiter-engine 49 | test 50 | 51 | 52 | 53 | 54 | org.glassfish.jaxb 55 | jaxb-runtime 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /spring-petclinic-admin-server/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.springframework.samples.petclinic.admin 8 | spring-petclinic-admin-server 9 | jar 10 | Spring Boot Admin server 11 | 12 | 13 | org.springframework.samples 14 | spring-petclinic-microservices 15 | 2.3.6 16 | 17 | 18 | 19 | 2.2.2 20 | 9090 21 | ${basedir}/../docker 22 | 23 | 24 | 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter 29 | 30 | 31 | org.springframework.cloud 32 | spring-cloud-starter-config 33 | 34 | 35 | org.springframework.cloud 36 | spring-cloud-starter-netflix-eureka-client 37 | 38 | 39 | 40 | 41 | de.codecentric 42 | spring-boot-admin-starter-server 43 | ${spring-boot-admin.version} 44 | 45 | 46 | de.codecentric 47 | spring-boot-admin-server-ui 48 | ${spring-boot-admin.version} 49 | 50 | 51 | 52 | 53 | org.jolokia 54 | jolokia-core 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/scripts/owner-details/owner-details.template.html: -------------------------------------------------------------------------------- 1 |

Owner Information

2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 24 | 27 | 28 |
Name{{$ctrl.owner.firstName}} {{$ctrl.owner.lastName}}
Address{{$ctrl.owner.address}}
City{{$ctrl.owner.city}}
Telephone{{$ctrl.owner.telephone}}
22 | Edit Owner 23 | 25 | Add New Pet 26 |
29 | 30 |

Pets and Visits

31 | 32 | 33 | 34 | 44 | 66 | 67 |
35 |
36 |
Name
37 |
{{pet.name}}
38 |
Birth Date
39 |
{{pet.birthDate | date:'yyyy MMM dd'}}
40 |
Type
41 |
{{pet.type.name}}
42 |
43 |
45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 60 | 63 | 64 |
Visit DateDescription
{{visit.date | date:'yyyy MMM dd'}}{{visit.description}}
58 | Edit Pet 59 | 61 | Add Visit 62 |
65 |
68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /steeltoe-petclinic-customers-service/Customers.Api/Domain/Owner.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Petclinic.Customers.Domain 5 | { 6 | public class Owner 7 | { 8 | public Owner(string firstName, string lastName, string address, string city, string telephone, int id = default) 9 | { 10 | FirstName = firstName ?? throw new ArgumentNullException(nameof(firstName)); 11 | LastName = lastName ?? throw new ArgumentNullException(nameof(lastName)); 12 | Address = address ?? throw new ArgumentNullException(nameof(address)); 13 | City = city ?? throw new ArgumentNullException(nameof(city)); 14 | Telephone = telephone ?? throw new ArgumentNullException(nameof(telephone)); 15 | 16 | Id = id; 17 | Pets = new HashSet(); 18 | } 19 | 20 | public int Id { get; private set; } 21 | 22 | public string FirstName { get; private set; } 23 | 24 | public string LastName { get; private set; } 25 | 26 | public string Address { get; private set; } 27 | 28 | public string City { get; private set; } 29 | 30 | public string Telephone { get; private set; } 31 | 32 | public virtual ICollection Pets { get; set; } 33 | 34 | public void AddPet(Pet pet) 35 | { 36 | pet.Owner = this; 37 | Pets.Add(pet); 38 | } 39 | 40 | public override string ToString() 41 | { 42 | return $@"id:{Id}, lastName:{LastName}, firstName:{FirstName}, address:{Address}, city:{City}, telephone:{Telephone}"; 43 | } 44 | 45 | public void SetFirstName(string firstName) 46 | { 47 | FirstName = firstName ?? throw new ArgumentNullException(nameof(firstName)); 48 | } 49 | 50 | public void SetCity(string city) 51 | { 52 | City = city ?? throw new ArgumentNullException(nameof(city)); 53 | } 54 | 55 | public void SetLastName(string lastName) 56 | { 57 | LastName = lastName ?? throw new ArgumentNullException(nameof(lastName)); 58 | } 59 | 60 | public void SetTelephone(string telephone) 61 | { 62 | Telephone = telephone ?? throw new ArgumentNullException(nameof(telephone)); 63 | } 64 | 65 | public void SetAddress(string address) 66 | { 67 | Address = address ?? throw new ArgumentNullException(nameof(address)); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/test/java/org/springframework/samples/petclinic/api/application/VisitsServiceClientIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package org.springframework.samples.petclinic.api.application; 2 | 3 | import okhttp3.mockwebserver.MockResponse; 4 | import okhttp3.mockwebserver.MockWebServer; 5 | import org.junit.jupiter.api.AfterEach; 6 | import org.junit.jupiter.api.BeforeEach; 7 | import org.junit.jupiter.api.Test; 8 | import org.springframework.samples.petclinic.api.dto.Visits; 9 | import org.springframework.web.reactive.function.client.WebClient; 10 | import reactor.core.publisher.Mono; 11 | 12 | import java.io.IOException; 13 | import java.util.Collections; 14 | import java.util.function.Consumer; 15 | 16 | import static org.junit.jupiter.api.Assertions.assertEquals; 17 | import static org.junit.jupiter.api.Assertions.assertNotNull; 18 | 19 | class VisitsServiceClientIntegrationTest { 20 | 21 | private static final Integer PET_ID = 1; 22 | 23 | private VisitsServiceClient visitsServiceClient; 24 | 25 | private MockWebServer server; 26 | 27 | @BeforeEach 28 | void setUp() { 29 | server = new MockWebServer(); 30 | visitsServiceClient = new VisitsServiceClient(WebClient.builder()); 31 | visitsServiceClient.setHostname(server.url("/").toString()); 32 | } 33 | 34 | @AfterEach 35 | void shutdown() throws IOException { 36 | this.server.shutdown(); 37 | } 38 | 39 | @Test 40 | void getVisitsForPets_withAvailableVisitsService() { 41 | prepareResponse(response -> response 42 | .setHeader("Content-Type", "application/json") 43 | .setBody("{\"items\":[{\"id\":5,\"date\":\"2018-11-15\",\"description\":\"test visit\",\"petId\":1}]}")); 44 | 45 | Mono visits = visitsServiceClient.getVisitsForPets(Collections.singletonList(1)); 46 | 47 | assertVisitDescriptionEquals(visits.block(), PET_ID,"test visit"); 48 | } 49 | 50 | 51 | private void assertVisitDescriptionEquals(Visits visits, int petId, String description) { 52 | assertEquals(1, visits.getItems().size()); 53 | assertNotNull(visits.getItems().get(0)); 54 | assertEquals(petId, visits.getItems().get(0).getPetId()); 55 | assertEquals(description, visits.getItems().get(0).getDescription()); 56 | } 57 | 58 | private void prepareResponse(Consumer consumer) { 59 | MockResponse response = new MockResponse(); 60 | consumer.accept(response); 61 | this.server.enqueue(response); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/model/Visit.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.visits.model; 17 | 18 | import com.fasterxml.jackson.annotation.JsonFormat; 19 | import java.util.Date; 20 | import javax.persistence.Column; 21 | import javax.persistence.Entity; 22 | import javax.persistence.GeneratedValue; 23 | import javax.persistence.GenerationType; 24 | import javax.persistence.Id; 25 | import javax.persistence.Table; 26 | import javax.persistence.Temporal; 27 | import javax.persistence.TemporalType; 28 | import javax.validation.constraints.Size; 29 | import lombok.AllArgsConstructor; 30 | import lombok.Builder; 31 | import lombok.NoArgsConstructor; 32 | 33 | /** 34 | * Simple JavaBean domain object representing a visit. 35 | * 36 | * @author Ken Krebs 37 | * @author Maciej Szarlinski 38 | */ 39 | @Entity 40 | @Table(name = "visits") 41 | @Builder(builderMethodName = "visit") 42 | @NoArgsConstructor 43 | @AllArgsConstructor 44 | public class Visit { 45 | 46 | @Id 47 | @GeneratedValue(strategy = GenerationType.IDENTITY) 48 | private Integer id; 49 | 50 | @Builder.Default 51 | @Column(name = "visit_date") 52 | @Temporal(TemporalType.TIMESTAMP) 53 | @JsonFormat(pattern = "yyyy-MM-dd") 54 | private Date date = new Date(); 55 | 56 | @Size(max = 8192) 57 | @Column(name = "description") 58 | private String description; 59 | 60 | @Column(name = "pet_id") 61 | private int petId; 62 | 63 | public Integer getId() { 64 | return id; 65 | } 66 | 67 | public Date getDate() { 68 | return date; 69 | } 70 | 71 | public String getDescription() { 72 | return description; 73 | } 74 | 75 | public int getPetId() { 76 | return petId; 77 | } 78 | 79 | public void setPetId(final int petId) { 80 | this.petId = petId; 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /spring-petclinic-vets-service/src/test/java/org/springframework/samples/petclinic/vets/web/VetResourceTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.vets.web; 17 | 18 | import org.junit.jupiter.api.Test; 19 | import org.junit.jupiter.api.extension.ExtendWith; 20 | import org.springframework.beans.factory.annotation.Autowired; 21 | import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; 22 | import org.springframework.boot.test.mock.mockito.MockBean; 23 | import org.springframework.http.MediaType; 24 | import org.springframework.samples.petclinic.vets.model.Vet; 25 | import org.springframework.samples.petclinic.vets.model.VetRepository; 26 | import org.springframework.test.context.ActiveProfiles; 27 | import org.springframework.test.context.junit.jupiter.SpringExtension; 28 | import org.springframework.test.web.servlet.MockMvc; 29 | 30 | import static java.util.Arrays.asList; 31 | import static org.mockito.BDDMockito.given; 32 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; 33 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; 34 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; 35 | 36 | /** 37 | * @author Maciej Szarlinski 38 | */ 39 | @ExtendWith(SpringExtension.class) 40 | @WebMvcTest(VetResource.class) 41 | @ActiveProfiles("test") 42 | class VetResourceTest { 43 | 44 | @Autowired 45 | MockMvc mvc; 46 | 47 | @MockBean 48 | VetRepository vetRepository; 49 | 50 | @Test 51 | void shouldGetAListOfVets() throws Exception { 52 | 53 | Vet vet = new Vet(); 54 | vet.setId(1); 55 | 56 | given(vetRepository.findAll()).willReturn(asList(vet)); 57 | 58 | mvc.perform(get("/vets").accept(MediaType.APPLICATION_JSON)) 59 | .andExpect(status().isOk()) 60 | .andExpect(jsonPath("$[0].id").value(1)); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /spring-petclinic-visits-service/src/test/java/org/springframework/samples/petclinic/visits/web/VisitResourceTest.java: -------------------------------------------------------------------------------- 1 | package org.springframework.samples.petclinic.visits.web; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.junit.jupiter.api.extension.ExtendWith; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; 7 | import org.springframework.boot.test.mock.mockito.MockBean; 8 | import org.springframework.samples.petclinic.visits.model.VisitRepository; 9 | import org.springframework.test.context.ActiveProfiles; 10 | import org.springframework.test.context.junit.jupiter.SpringExtension; 11 | import org.springframework.test.web.servlet.MockMvc; 12 | 13 | 14 | import static java.util.Arrays.asList; 15 | import static org.mockito.BDDMockito.given; 16 | import static org.springframework.samples.petclinic.visits.model.Visit.visit; 17 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; 18 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; 19 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; 20 | 21 | @ExtendWith(SpringExtension.class) 22 | @WebMvcTest(VisitResource.class) 23 | @ActiveProfiles("test") 24 | class VisitResourceTest { 25 | 26 | @Autowired 27 | MockMvc mvc; 28 | 29 | @MockBean 30 | VisitRepository visitRepository; 31 | 32 | @Test 33 | void shouldFetchVisits() throws Exception { 34 | given(visitRepository.findByPetIdIn(asList(111, 222))) 35 | .willReturn( 36 | asList( 37 | visit() 38 | .id(1) 39 | .petId(111) 40 | .build(), 41 | visit() 42 | .id(2) 43 | .petId(222) 44 | .build(), 45 | visit() 46 | .id(3) 47 | .petId(222) 48 | .build() 49 | ) 50 | ); 51 | 52 | mvc.perform(get("/pets/visits?petId=111,222")) 53 | .andExpect(status().isOk()) 54 | .andExpect(jsonPath("$.items[0].id").value(1)) 55 | .andExpect(jsonPath("$.items[1].id").value(2)) 56 | .andExpect(jsonPath("$.items[2].id").value(3)) 57 | .andExpect(jsonPath("$.items[0].petId").value(111)) 58 | .andExpect(jsonPath("$.items[1].petId").value(222)) 59 | .andExpect(jsonPath("$.items[2].petId").value(222)); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /steeltoe-petclinic-customers-service/Customers.Api/Repository/Owners.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Microsoft.Extensions.Logging; 3 | using Petclinic.Customers.Domain; 4 | using Petclinic.Customers.Infrastructure; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Threading; 8 | using System.Threading.Tasks; 9 | 10 | namespace Petclinic.Customers.Repository 11 | { 12 | internal class Owners : IOwners 13 | { 14 | private readonly ILogger _logger; 15 | private readonly CustomersContext _dbContext; 16 | 17 | public Owners(ILogger logger, CustomersContext dbContext) 18 | { 19 | _logger = logger; 20 | _dbContext = dbContext; 21 | } 22 | 23 | public Task FindById(int id, CancellationToken cancellationToken = default) 24 | { 25 | return _dbContext.Owners.Include(b => b.Pets).ThenInclude(p => p.PetType).FirstAsync(q => q.Id == id, cancellationToken); 26 | } 27 | 28 | public Task> FindAll(CancellationToken cancellationToken = default) 29 | { 30 | return _dbContext.Owners.Include(b => b.Pets).ThenInclude(p => p.PetType).ToListAsync(cancellationToken); 31 | } 32 | 33 | public Task> FindAll(int page, int pageSize, CancellationToken cancellationToken = default) 34 | { 35 | return _dbContext.Owners.Include(b => b.Pets).ThenInclude(p => p.PetType).Skip(page * pageSize).Take(pageSize).ToListAsync(cancellationToken); 36 | } 37 | 38 | public async Task Save(Owner owner, CancellationToken cancellationToken = default) 39 | { 40 | _dbContext.Owners.Add(owner); 41 | await _dbContext.SaveChangesAsync(cancellationToken); 42 | return owner; 43 | } 44 | 45 | public async Task Update(Owner owner, Owner newOwnerVals, CancellationToken cancellationToken = default) 46 | { 47 | owner.SetFirstName(newOwnerVals.FirstName); 48 | owner.SetLastName(newOwnerVals.LastName); 49 | owner.SetCity(newOwnerVals.City); 50 | owner.SetAddress(newOwnerVals.Address); 51 | owner.SetTelephone(newOwnerVals.Telephone); 52 | 53 | _dbContext.Owners.Update(owner); 54 | await _dbContext.SaveChangesAsync(cancellationToken); 55 | return owner; 56 | } 57 | 58 | public Task Delete(Owner Owner, CancellationToken cancellationToken = default) 59 | { 60 | _dbContext.Owners.Remove(Owner); 61 | return _dbContext.SaveChangesAsync(cancellationToken); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /steeltoe-petclinic-customers-service/Customers.Api/Repository/Pets.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Microsoft.Extensions.Logging; 3 | using Petclinic.Customers.Domain; 4 | using Petclinic.Customers.Infrastructure; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Threading; 8 | using System.Threading.Tasks; 9 | 10 | namespace Petclinic.Customers.Repository 11 | { 12 | internal class Pets : IPets 13 | { 14 | private readonly ILogger _logger; 15 | private readonly CustomersContext _dbContext; 16 | 17 | public Pets(ILogger logger, CustomersContext dbContext) 18 | { 19 | _logger = logger; 20 | _dbContext = dbContext; 21 | } 22 | 23 | public Task> FindPetTypes(CancellationToken cancellationToken = default) 24 | { 25 | return _dbContext.PetTypes.OrderByDescending(q => q.Name).ToListAsync(cancellationToken); 26 | } 27 | 28 | public Task FindPetTypeById(int id, CancellationToken cancellationToken = default) 29 | { 30 | return _dbContext.PetTypes.FirstOrDefaultAsync(q => q.Id == id, cancellationToken); 31 | } 32 | 33 | public Task FindById(int id, CancellationToken cancellationToken = default) 34 | { 35 | return _dbContext.Pets.Include(b => b.Owner).Include(b => b.PetType).FirstOrDefaultAsync(q => q.Id == id, cancellationToken); 36 | } 37 | 38 | public Task> FindAll(CancellationToken cancellationToken = default) 39 | { 40 | return _dbContext.Pets.Include(b => b.Owner).Include(b => b.PetType).ToListAsync(cancellationToken); 41 | } 42 | 43 | public Task> FindAll(int page, int pageSize, CancellationToken cancellationToken = default) 44 | { 45 | return _dbContext.Pets.Include(b => b.Owner).Include(b => b.PetType).Skip(page * pageSize).Take(pageSize).ToListAsync(cancellationToken); 46 | } 47 | 48 | public async Task Save(Pet pet, CancellationToken cancellationToken = default) 49 | { 50 | _dbContext.Pets.Add(pet); 51 | await _dbContext.SaveChangesAsync(cancellationToken); 52 | } 53 | 54 | public async Task Update(Pet pet, CancellationToken cancellationToken = default) 55 | { 56 | _dbContext.Pets.Update(pet); 57 | await _dbContext.SaveChangesAsync(cancellationToken); 58 | } 59 | //public Task Delete(Pet pet, CancellationToken cancellationToken = default) 60 | //{ 61 | // _dbContext.Pets.Remove(pet); 62 | // return _dbContext.SaveChangesAsync(cancellationToken); 63 | //} 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /steeltoe-petclinic-customers-service/Customers.Test/OwnerTest.cs: -------------------------------------------------------------------------------- 1 | using Petclinic.Customers.Domain; 2 | using Petclinic.Customers.Infrastructure; 3 | using System; 4 | using System.Linq; 5 | using Xunit; 6 | 7 | namespace Petclinic.Customers.Test 8 | { 9 | [Collection("Pets Test Collection")] 10 | public class OwnerTest 11 | { 12 | public OwnerTest() 13 | { 14 | } 15 | 16 | [Fact(DisplayName = "Create owner")] 17 | public void NewOwner() 18 | { 19 | var owner = new Owner("first", "last", "123 street rd", "Some City", "123-123-1234"); 20 | Assert.NotNull(owner); 21 | } 22 | 23 | [Fact(DisplayName = "Add Pet")] 24 | public void AddPetTest() 25 | { 26 | var owner = Fill.Owners.First(); 27 | var petTypeId = Fill.PetTypes.First().Id; 28 | var pet = new Pet("Herbert", DateTime.Now, petTypeId, owner.Id); 29 | var expectedResult = owner.Pets.Count() + 1; 30 | 31 | owner.AddPet(pet); 32 | 33 | Assert.Equal(expectedResult, owner.Pets.Count()); 34 | } 35 | 36 | [Fact(DisplayName = "To string")] 37 | public void ToStringTest() 38 | { 39 | var owner = Fill.Owners.First(); 40 | 41 | var str = owner.ToString(); 42 | 43 | Assert.NotNull(str); 44 | } 45 | 46 | [Fact(DisplayName = "Set first name")] 47 | public void SetFirstNameTest() 48 | { 49 | var owner = Fill.Owners.First(); 50 | owner.SetFirstName("asdf"); 51 | Assert.Equal("asdf", owner.FirstName); 52 | } 53 | 54 | [Fact(DisplayName = "Set city")] 55 | public void SetCityTest() 56 | { 57 | var owner = Fill.Owners.First(); 58 | owner.SetCity("asdf"); 59 | Assert.Equal("asdf", owner.City); 60 | } 61 | 62 | [Fact(DisplayName = "Set last name")] 63 | public void SetLastNameTest() 64 | { 65 | var owner = Fill.Owners.First(); 66 | owner.SetLastName("asdf"); 67 | Assert.Equal("asdf", owner.LastName); 68 | } 69 | 70 | [Fact(DisplayName = "Set telephone")] 71 | public void SetTelephoneTest() 72 | { 73 | var owner = Fill.Owners.First(); 74 | owner.SetTelephone("asdf"); 75 | Assert.Equal("asdf", owner.Telephone); 76 | } 77 | 78 | [Fact(DisplayName = "Set address")] 79 | public void SetAddressTest() 80 | { 81 | var owner = Fill.Owners.First(); 82 | owner.SetAddress("asdf"); 83 | Assert.Equal("asdf", owner.Address); 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /spring-petclinic-api-gateway/src/main/resources/static/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | PetClinic :: a Spring Framework demonstration 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 |
54 |
55 |
56 |
57 |
58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /spring-petclinic-customers-service/src/test/java/org/springframework/samples/petclinic/customers/web/PetResourceTest.java: -------------------------------------------------------------------------------- 1 | package org.springframework.samples.petclinic.customers.web; 2 | 3 | import java.util.Optional; 4 | 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.extension.ExtendWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; 9 | import org.springframework.boot.test.mock.mockito.MockBean; 10 | import org.springframework.http.MediaType; 11 | import org.springframework.samples.petclinic.customers.model.Owner; 12 | import org.springframework.samples.petclinic.customers.model.OwnerRepository; 13 | import org.springframework.samples.petclinic.customers.model.Pet; 14 | import org.springframework.samples.petclinic.customers.model.PetRepository; 15 | import org.springframework.samples.petclinic.customers.model.PetType; 16 | import org.springframework.test.context.ActiveProfiles; 17 | import org.springframework.test.context.junit.jupiter.SpringExtension; 18 | import org.springframework.test.web.servlet.MockMvc; 19 | 20 | 21 | import static org.mockito.BDDMockito.given; 22 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; 23 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; 24 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; 25 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; 26 | 27 | /** 28 | * @author Maciej Szarlinski 29 | */ 30 | @ExtendWith(SpringExtension.class) 31 | @WebMvcTest(PetResource.class) 32 | @ActiveProfiles("test") 33 | class PetResourceTest { 34 | 35 | @Autowired 36 | MockMvc mvc; 37 | 38 | @MockBean 39 | PetRepository petRepository; 40 | 41 | @MockBean 42 | OwnerRepository ownerRepository; 43 | 44 | @Test 45 | void shouldGetAPetInJSonFormat() throws Exception { 46 | 47 | Pet pet = setupPet(); 48 | 49 | given(petRepository.findById(2)).willReturn(Optional.of(pet)); 50 | 51 | 52 | mvc.perform(get("/owners/2/pets/2").accept(MediaType.APPLICATION_JSON)) 53 | .andExpect(status().isOk()) 54 | .andExpect(content().contentType("application/json")) 55 | .andExpect(jsonPath("$.id").value(2)) 56 | .andExpect(jsonPath("$.name").value("Basil")) 57 | .andExpect(jsonPath("$.type.id").value(6)); 58 | } 59 | 60 | private Pet setupPet() { 61 | Owner owner = new Owner(); 62 | owner.setFirstName("George"); 63 | owner.setLastName("Bush"); 64 | 65 | Pet pet = new Pet(); 66 | 67 | pet.setName("Basil"); 68 | pet.setId(2); 69 | 70 | PetType petType = new PetType(); 71 | petType.setId(6); 72 | pet.setType(petType); 73 | 74 | owner.addPet(pet); 75 | return pet; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/web/VisitResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.visits.web; 17 | 18 | import java.util.List; 19 | import javax.validation.Valid; 20 | 21 | import io.micrometer.core.annotation.Timed; 22 | import lombok.RequiredArgsConstructor; 23 | import lombok.Value; 24 | import lombok.extern.slf4j.Slf4j; 25 | import org.springframework.http.HttpStatus; 26 | import org.springframework.samples.petclinic.visits.model.Visit; 27 | import org.springframework.samples.petclinic.visits.model.VisitRepository; 28 | import org.springframework.web.bind.annotation.GetMapping; 29 | import org.springframework.web.bind.annotation.PathVariable; 30 | import org.springframework.web.bind.annotation.PostMapping; 31 | import org.springframework.web.bind.annotation.RequestBody; 32 | import org.springframework.web.bind.annotation.RequestParam; 33 | import org.springframework.web.bind.annotation.ResponseStatus; 34 | import org.springframework.web.bind.annotation.RestController; 35 | 36 | /** 37 | * @author Juergen Hoeller 38 | * @author Ken Krebs 39 | * @author Arjen Poutsma 40 | * @author Michael Isvy 41 | * @author Maciej Szarlinski 42 | */ 43 | @RestController 44 | @RequiredArgsConstructor 45 | @Slf4j 46 | @Timed("petclinic.visit") 47 | class VisitResource { 48 | 49 | private final VisitRepository visitRepository; 50 | 51 | @PostMapping("owners/*/pets/{petId}/visits") 52 | @ResponseStatus(HttpStatus.CREATED) 53 | public Visit create( 54 | @Valid @RequestBody Visit visit, 55 | @PathVariable("petId") int petId) { 56 | 57 | visit.setPetId(petId); 58 | log.info("Saving visit {}", visit); 59 | return visitRepository.save(visit); 60 | } 61 | 62 | @GetMapping("owners/*/pets/{petId}/visits") 63 | public List visits(@PathVariable("petId") int petId) { 64 | return visitRepository.findByPetId(petId); 65 | } 66 | 67 | @GetMapping("pets/visits") 68 | public Visits visitsMultiGet(@RequestParam("petId") List petIds) { 69 | final List byPetIdIn = visitRepository.findByPetIdIn(petIds); 70 | return new Visits(byPetIdIn); 71 | } 72 | 73 | @Value 74 | static class Visits { 75 | List items; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /steeltoe-petclinic-visits-service/Visits.ITest/Controllers/Visits.cs: -------------------------------------------------------------------------------- 1 | using Petclinic.Visits.DTOs; 2 | using Petclinic.Visits.Infrastructure; 3 | using System; 4 | using System.Linq; 5 | using System.Net.Http; 6 | using System.Net.Http.Json; 7 | using System.Threading.Tasks; 8 | using Xunit; 9 | using Xunit.Abstractions; 10 | 11 | namespace Petclinic.Visits.ITest.Controllers 12 | { 13 | [Collection("Vets API Test Collection")] 14 | public class Visits : IClassFixture>, IDisposable 15 | { 16 | private readonly HttpClient _client; 17 | private readonly CustomersAppFactory _factory; 18 | 19 | public Visits(CustomersAppFactory factory, ITestOutputHelper outputHelper) 20 | { 21 | factory.OutputHelper = outputHelper; 22 | _factory = factory; 23 | _client = _factory.CreateClient(); 24 | } 25 | public void Dispose() 26 | { 27 | //_client.Dispose(); 28 | //_factory.OutputHelper = null; 29 | //_factory.Dispose(); 30 | } 31 | 32 | [Fact(DisplayName = "GET Health")] 33 | public async Task Health() 34 | { 35 | var respObj = await _client.GetFromJsonAsync("actuator/health"); 36 | Assert.NotNull(respObj); 37 | } 38 | 39 | [Fact(DisplayName = "GET visit by petId")] 40 | public async Task GetVisits() 41 | { 42 | var petId = Fill.Visits.First().PetId; 43 | 44 | var visits = await _client.GetFromJsonAsync($"owners/pets/{petId}/visits"); 45 | 46 | Assert.NotNull(visits); 47 | Assert.Equal(Fill.Visits.Where(q => q.PetId == petId).Count(), visits.Count()); 48 | } 49 | 50 | [Fact(DisplayName = "GET visit by petIds")] 51 | public async Task GetVisitsMultipleIds() 52 | { 53 | var petId1 = Fill.Visits.First().PetId; 54 | var petId2 = Fill.Visits.First(q => q.PetId != petId1).PetId; 55 | 56 | var visits = await _client.GetFromJsonAsync($"pets/visits?petId={petId1}%2C{petId2}"); 57 | 58 | Assert.NotNull(visits); 59 | Assert.NotEmpty(visits); 60 | } 61 | 62 | [Fact(DisplayName = "POST new visit")] 63 | public async Task Save() 64 | { 65 | var petId = Fill.Visits.First().PetId; 66 | 67 | var visitRequest = new VisitRequest() 68 | { 69 | Description = "Another one", 70 | VisitDate = DateTime.Now 71 | }; 72 | 73 | var resp = await _client.PostAsJsonAsync($"owners/pets/{petId}/visits", visitRequest); 74 | 75 | Assert.True(resp.IsSuccessStatusCode); 76 | 77 | var vist = await resp.Content.ReadFromJsonAsync(); 78 | 79 | Assert.NotNull(vist); 80 | Assert.Equal(visitRequest.Description, vist.description); 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /steeltoe-petclinic-customers-service/Customers.Api/Controllers/OwnersController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.Extensions.Logging; 3 | using Petclinic.Customers.DTOs; 4 | using Petclinic.Customers.Repository; 5 | using System.Collections.Generic; 6 | using System.Net; 7 | using System.Threading; 8 | using System.Threading.Tasks; 9 | 10 | namespace Petclinic.Customers.Controllers 11 | { 12 | [Route("[controller]")] 13 | [ApiController] 14 | [Produces("application/json")] 15 | public class OwnersController : ControllerBase 16 | { 17 | private readonly ILogger _logger; 18 | private readonly IOwners _ownersRepo; 19 | 20 | public OwnersController(ILogger logger, IOwners ownersRepo) 21 | { 22 | _logger = logger; 23 | _ownersRepo = ownersRepo; 24 | } 25 | 26 | [HttpPost] 27 | [ProducesResponseType((int)HttpStatusCode.Created)] 28 | public async Task CreateOwner([FromBody] OwnerRequest ownerRequest, CancellationToken cancellationToken) 29 | { 30 | _logger.LogInformation($"Saving owner {ownerRequest}"); 31 | var owner = await _ownersRepo.Save(ownerRequest.ToOwner(), cancellationToken); 32 | return Created($"owners/{owner.Id}", OwnerDetails.FromOwner(owner)); 33 | } 34 | 35 | [HttpGet("{ownerId}")] 36 | [ProducesResponseType(typeof(OwnerDetails), (int)HttpStatusCode.OK)] 37 | public async Task> FindOwner(int ownerId, CancellationToken cancellationToken) 38 | { 39 | var owner = await _ownersRepo.FindById(ownerId, cancellationToken); 40 | return Ok(OwnerDetails.FromOwner(owner)); 41 | } 42 | 43 | [HttpGet] 44 | [ProducesResponseType(typeof(List), (int)HttpStatusCode.OK)] 45 | public async Task>> FindAll(CancellationToken cancellationToken) 46 | { 47 | var owners = await _ownersRepo.FindAll(cancellationToken); 48 | 49 | var ret = new List(); 50 | foreach (var owner in owners) 51 | { 52 | ret.Add(OwnerDetails.FromOwner(owner)); 53 | } 54 | 55 | return Ok(ret); 56 | } 57 | 58 | [HttpPut("{ownerId}")] 59 | [ProducesResponseType((int)HttpStatusCode.NoContent)] 60 | public async Task ProcessUpdateForm(int ownerId, [FromBody] OwnerRequest ownerRequest, CancellationToken cancellationToken) 61 | { 62 | var owner = await _ownersRepo.FindById(ownerId, cancellationToken); 63 | 64 | if (owner == null) 65 | { 66 | throw new ResourceNotFoundException("Owner " + ownerId + " not found"); 67 | } 68 | 69 | _logger.LogInformation($"Updating owner {ownerRequest}"); 70 | await _ownersRepo.Update(owner, ownerRequest.ToOwner(), cancellationToken); 71 | 72 | return NoContent(); 73 | } 74 | } 75 | } 76 | --------------------------------------------------------------------------------