Skip to content

Commit

Permalink
Merge branch 'release/2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
mohamed-taman committed Apr 9, 2020
2 parents a1fec30 + 5e50ae6 commit ddead98
Show file tree
Hide file tree
Showing 22 changed files with 490 additions and 290 deletions.
65 changes: 37 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,57 +92,66 @@ mohamed.taman@DTLNV8 ~/springy-store-microservices
λ ./setup.sh
```

And you should expect output like this:
Now you should expect output like this:

```bash
Installing all Springy store core shared modules
................................................

1- Installing shared [Utilities] module...
1- Installing [build parent] module...
Done successfully.

2- Installing shared [APIs] module...
2- Installing shared [Utilities] module...
Done successfully.

3- Installing [parent project] module...
3- Installing shared [APIs] module...
Done successfully.

Wooohooo, building & installing all project modules are finished successfully.
and the project is ready for the next step. :)
4- Installing [service parent] module...
Done successfully.

Woohoo, building & installing all project modules are finished successfully.
The project is ready for the next step. :)
```

#### Second: Build & Test Microservices

Now it is time to build our **4 microservices** and run each service integration test in isolation by running the following commands:
Now it is time to build our **4 microservices** and run each service integration test in
isolation by running the following commands:

```bash
mohamed.taman@DTLNV8 ~/springy-store-microservices
λ ./mvnw clean verify -f store-chassis/
λ ./mvnw clean verify
```

All build commands and test suite for each microservice should run successfully, and the final output should be like this:

```bash
[INFO] ---------------< com.siriusxi.ms.store:store-aggregator >---------------
[INFO] Building Springy Store Aggregator 1.0-SNAPSHOT [9/9]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ store-aggregator ---
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] Reactor Summary for Springy Store Aggregator 1.0-SNAPSHOT:
[INFO]
[INFO] Springy Store APIs 1.0-SNAPSHOT .................... SUCCESS [ 3.048 s]
[INFO] Springy Store Utils 1.0-SNAPSHOT ................... SUCCESS [ 2.107 s]
[INFO] Springy Store Chassis 0.0.1-SNAPSHOT ............... SUCCESS [ 0.865 s]
[INFO] Product Composite Service 0.0.1-SNAPSHOT ........... SUCCESS [ 11.086 s]
[INFO] Product Service 0.0.1-SNAPSHOT ..................... SUCCESS [ 9.795 s]
[INFO] Review Service 0.0.1-SNAPSHOT ...................... SUCCESS [ 9.214 s]
[INFO] Recommendation Service 0.0.1-SNAPSHOT .............. SUCCESS [ 9.288 s]
[INFO] Springy Store Build Chassis ........................ SUCCESS [ 0.276 s]
[INFO] Springy Store APIs ................................. SUCCESS [ 3.920 s]
[INFO] Springy Store Utils ................................ SUCCESS [ 1.508 s]
[INFO] Springy Store Chassis .............................. SUCCESS [ 0.608 s]
[INFO] Product Composite Service .......................... SUCCESS [ 4.073 s]
[INFO] Product Service .................................... SUCCESS [ 2.710 s]
[INFO] Review Service ..................................... SUCCESS [ 2.633 s]
[INFO] Recommendation Service ............................. SUCCESS [ 2.615 s]
[INFO] Springy Store Aggregator ........................... SUCCESS [ 0.071 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 46.006 s
[INFO] Finished at: 2020-04-01T17:07:52+02:00
[INFO] Total time: 18.900 s
[INFO] Finished at: 2020-04-09T01:33:14+02:00
[INFO] ------------------------------------------------------------------------
```

### Running Them All

Now it's the time to run all of them, and it's very simple just run the following two commands:

```bash
Expand All @@ -153,13 +162,12 @@ mohamed.taman@DTLNV8 ~/springy-store-microservices
All the services will run in parallel, and their output will be printed to the console.

### Testing Them All

Now it's time to test all functionality of the application as one part. And to do so just run
Now it's time to test all functionality of the application as one part. To do so just run
the following automation test script:

```bash
mohamed.taman@DTLNV8 ~/springy-store-microservices
λ ./test-em-all.sh
λ PORT=9080 ./test-em-all.sh
```

The result should be something like this:
Expand All @@ -173,7 +181,8 @@ Test OK (HTTP Code: 200)
Test OK (actual value: 1)
Test OK (actual value: 3)
Test OK (actual value: 3)
Test OK (HTTP Code: 404, {"httpStatus":"NOT_FOUND","message":"No product found for productId: 13","path":"/product-composite/13","time":"2020-04-01@14:51:48.812+0200"})
Test OK (HTTP Code: 404, {"httpStatus":"NOT_FOUND","message":"No product found for productId: 13
","path":"/v1/product-composite/13","time":"2020-04-01@14:51:48.812+0200"})
Test OK (HTTP Code: 200)
Test OK (actual value: 113)
Test OK (actual value: 0)
Expand All @@ -182,9 +191,11 @@ Test OK (HTTP Code: 200)
Test OK (actual value: 213)
Test OK (actual value: 3)
Test OK (actual value: 0)
Test OK (HTTP Code: 422, {"httpStatus":"UNPROCESSABLE_ENTITY","message":"Invalid productId: -1","path":"/product-composite/-1","time":"2020-04-01@14:51:49.763+0200"})
Test OK (HTTP Code: 422, {"httpStatus":"UNPROCESSABLE_ENTITY","message":"Invalid productId: -1
","path":"/v1/product-composite/-1","time":"2020-04-01@14:51:49.763+0200"})
Test OK (actual value: "Invalid productId: -1")
Test OK (HTTP Code: 400, {"timestamp":"2020-04-01T12:51:49.965+0000","path":"/product-composite/invalidProductId","status":400,"error":"Bad Request","message":"Type mismatch."})
Test OK (HTTP Code: 400, {"timestamp":"2020-04-01T12:51:49.965+0000","path":"/v1/product-composite
/invalidProductId","status":400,"error":"Bad Request","message":"Type mismatch."})
Test OK (actual value: "Type mismatch.")
```

Expand Down Expand Up @@ -222,11 +233,9 @@ Microservice at port 9083 stopped successfully ....
```

### The End

Happy coding :)

# License

Copyright (C) 2017-2020 Mohamed Taman

Licensed under the MIT License.
30 changes: 30 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.siriusxi.ms.store</groupId>
<artifactId>store-aggregator</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Springy Store Aggregator</name>
<description>Aggregator pom project for Springy μServices</description>
<packaging>pom</packaging>

<properties>
<maven.install.skip>true</maven.install.skip>
<maven.deploy.skip>true</maven.deploy.skip>
</properties>


<modules>
<module>product-composite-service</module>
<module>product-service</module>
<module>review-service</module>
<module>recommendation-service</module>
<module>store-api</module>
<module>store-utils</module>
<module>store-build-chassis</module>
<module>store-service-chassis</module>
</modules>
</project>
28 changes: 24 additions & 4 deletions product-composite-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,35 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<parent>
<groupId>com.siriusxi.ms.store</groupId>
<artifactId>store-chassis</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../store-chassis</relativePath>
<artifactId>store-service-chassis</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../store-service-chassis</relativePath>
</parent>

<artifactId>product-composite-service</artifactId>
<name>Product Composite Service</name>
<version>1.0-SNAPSHOT</version>
<description>Product Composite Service Spring Boot based project</description>
<packaging>jar</packaging>

<dependencies>
<!-- Start - API documentation dependencies -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-spring-webflux</artifactId>
<version>${springfox.swagger.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${springfox.swagger.version}</version>
</dependency>
<!-- End - API documentation dependencies -->
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,15 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.client.RestTemplate;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebFlux;

@SpringBootApplication
@EnableSwagger2WebFlux // Starting point for initiating SpringFox
@ComponentScan("com.siriusxi.ms.store")
public class ProductCompositeServiceApplication {

public static void main(String[] args) {
SpringApplication.run(ProductCompositeServiceApplication.class, args);
}

@Bean
RestTemplate newRestClient() {
return new RestTemplate();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package com.siriusxi.ms.store.pcs.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spring.web.plugins.Docket;

import static java.util.Collections.emptyList;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static springfox.documentation.builders.RequestHandlerSelectors.basePackage;
import static springfox.documentation.spi.DocumentationType.SWAGGER_2;

@Configuration
public class ProductCompositeConfiguration {
@Value("${api.common.version}")
String apiVersion;
@Value("${api.common.title}")
String apiTitle;
@Value("${api.common.description}")
String apiDescription;
@Value("${api.common.termsOfServiceUrl}")
String apiTermsOfServiceUrl;
@Value("${api.common.license}")
String apiLicense;
@Value("${api.common.licenseUrl}")
String apiLicenseUrl;
@Value("${api.common.contact.name}")
String apiContactName;
@Value("${api.common.contact.url}")
String apiContactUrl;
@Value("${api.common.contact.email}")
String apiContactEmail;

@Bean
RestTemplate newRestClient() {
return new RestTemplate();
}

/**
* Will exposed on $HOST:$PORT/swagger-ui.html
*
* @return Docket swagger configuration
*/
@Bean
public Docket apiDocumentation() {

return new Docket(SWAGGER_2)
.select()
/*
Using the apis() and paths() methods,
we can specify where SpringFox shall look for API documentation.
*/
.apis(basePackage("com.siriusxi.ms.store.pcs"))
.paths(PathSelectors.any())
.build()
/*
Using the globalResponseMessage() method, we ask SpringFox not to add any default HTTP response codes to the API documentation, such as 401 and 403, which we don't currently use.
*/
.globalResponseMessage(GET, emptyList())
/*
The api* variables that are used to configure the Docket bean with general information about the API are initialized from the property file using Spring @Value annotations.
*/
.apiInfo(new ApiInfo(
apiTitle,
apiDescription,
apiVersion,
apiTermsOfServiceUrl,
new Contact(apiContactName, apiContactUrl, apiContactEmail),
apiLicense,
apiLicenseUrl,
emptyList()
));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,61 @@
"name": "app.review-service.port",
"type": "java.lang.Integer",
"description": "Description for app.review-service.port."
},
{
"name": "api.common.version",
"type": "java.lang.String",
"description": "Description for api.common.version."
},
{
"name": "api.common.title",
"type": "java.lang.String",
"description": "Description for api.common.title."
},
{
"name": "api.common.description",
"type": "java.lang.String",
"description": "Description for api.common.description."
},
{
"name": "api.common.termsOfServiceUrl",
"type": "java.lang.String",
"description": "Description for api.common.termsOfServiceUrl."
},
{
"name": "api.common.license",
"type": "java.lang.String",
"description": "Description for api.common.license."
},
{
"name": "api.common.licenseUrl",
"type": "java.lang.String",
"description": "Description for api.common.licenseUrl."
},
{
"name": "api.common.contact.name",
"type": "java.lang.String",
"description": "Description for api.common.contact.name."
},
{
"name": "api.common.contact.url",
"type": "java.lang.String",
"description": "Description for api.common.contact.url."
},
{
"name": "api.common.contact.email",
"type": "java.lang.String",
"description": "Description for api.common.contact.email."
},
{
"name": "api.product-composite.get-composite-product.description",
"type": "java.lang.String",
"description": "Description for api.product-composite.get-composite-product.description."
},
{
"name": "api.product-composite.get-composite-product.notes",
"type": "java.lang.String",
"description": "Description for api.product-composite.get-composite-product.notes."
}
]
}
Loading

0 comments on commit ddead98

Please sign in to comment.