Delete old project files in spring-boot-modules
This commit is contained in:
parent
c63c9b889e
commit
28af7f1e3d
@ -1,11 +0,0 @@
|
|||||||
--------------------------------- CustomerOrderApp installation steps----------------------------------
|
|
||||||
|
|
||||||
1. Clone or download sample project from GitHub repo: https://github.com/eugenp/tutorials/tree/master/spring-boot-modules/spring-boot-microservices
|
|
||||||
2. Unzip project folder to local disk for example to: C:/baeldung-tutorials/spring-boot-microservices/customer-order-app
|
|
||||||
3. Run `mvn clean install -DskipTests=true`
|
|
||||||
4. Navigate to order-service/order-server module folder and type `mvn spring-boot:run`
|
|
||||||
5. Open another CMD PROMPT window.
|
|
||||||
Navigate to customer-service module folder and type `mvn spring-boot:run`
|
|
||||||
|
|
||||||
6. Launch the Postman application from your machine and import the collection located in the _postman_ folder in project root
|
|
||||||
7. Verify successful request from the POSTMAN to http://localhost:8001/customer-service/order
|
|
@ -1,41 +0,0 @@
|
|||||||
#https://github.com/spring-projects/spring-boot/blob/master/.gitignore
|
|
||||||
|
|
||||||
*#
|
|
||||||
*.iml
|
|
||||||
*.ipr
|
|
||||||
*.iws
|
|
||||||
*.jar
|
|
||||||
*.sw?
|
|
||||||
*~
|
|
||||||
.#*
|
|
||||||
.*.md.html
|
|
||||||
.DS_Store
|
|
||||||
.classpath
|
|
||||||
.factorypath
|
|
||||||
.gradle
|
|
||||||
.idea
|
|
||||||
.metadata
|
|
||||||
.project
|
|
||||||
.recommenders
|
|
||||||
.settings
|
|
||||||
.springBeans
|
|
||||||
/build
|
|
||||||
/code
|
|
||||||
MANIFEST.MF
|
|
||||||
_site/
|
|
||||||
activemq-data
|
|
||||||
bin
|
|
||||||
build
|
|
||||||
build.log
|
|
||||||
dependency-reduced-pom.xml
|
|
||||||
dump.rdb
|
|
||||||
interpolated*.xml
|
|
||||||
lib/
|
|
||||||
manifest.yml
|
|
||||||
overridedb.*
|
|
||||||
target
|
|
||||||
transaction-logs
|
|
||||||
.flattened-pom.xml
|
|
||||||
secrets.yml
|
|
||||||
.gradletasknamecache
|
|
||||||
.sts4-cache
|
|
@ -1,85 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>CustomerOrderApp</artifactId>
|
|
||||||
<groupId>com.baeldung</groupId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<groupId>com.baeldung.customerservice</groupId>
|
|
||||||
<artifactId>customer-service</artifactId>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<java.version>1.8</java.version>
|
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencyManagement>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-dependencies</artifactId>
|
|
||||||
<version>2.3.0.RELEASE</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</dependencyManagement>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-json</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>junit</groupId>
|
|
||||||
<artifactId>junit</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.baeldung.orderservice</groupId>
|
|
||||||
<artifactId>order-client</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<pluginManagement>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<goals>
|
|
||||||
<goal>repackage</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<classifier>exec</classifier>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</pluginManagement>
|
|
||||||
</build>
|
|
||||||
</project>
|
|
@ -1,14 +0,0 @@
|
|||||||
package com.baeldung.customerservice;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class Customer {
|
|
||||||
|
|
||||||
private int id;
|
|
||||||
private String firstName;
|
|
||||||
private String lastName;
|
|
||||||
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
package com.baeldung.customerservice;
|
|
||||||
|
|
||||||
import com.baeldung.orderservice.client.OrderClient;
|
|
||||||
import com.baeldung.orderservice.client.OrderClientImpl;
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Spring Boot application starter class
|
|
||||||
*/
|
|
||||||
@SpringBootApplication
|
|
||||||
public class CustomerApplication {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
SpringApplication.run(CustomerApplication.class, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public OrderClient getOrderClient() {
|
|
||||||
|
|
||||||
return new OrderClientImpl(new RestTemplateBuilder());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
package com.baeldung.customerservice;
|
|
||||||
|
|
||||||
import com.baeldung.orderservice.client.OrderClient;
|
|
||||||
import com.baeldung.orderservice.client.OrderDTO;
|
|
||||||
import com.baeldung.orderservice.client.OrderResponse;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
public class CustomerService {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private OrderClient orderClient;
|
|
||||||
|
|
||||||
private List<Customer> customers = Arrays.asList(
|
|
||||||
|
|
||||||
new Customer(1, "John", "Smith"),
|
|
||||||
new Customer(2, "Deny", "Dominic"));
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping
|
|
||||||
public List<Customer> getAllCustomers() {
|
|
||||||
return customers;
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/{id}")
|
|
||||||
public Customer getCustomerById(@PathVariable int id) {
|
|
||||||
return customers.stream()
|
|
||||||
.filter(customer -> customer.getId() == id)
|
|
||||||
.findFirst()
|
|
||||||
.orElseThrow(IllegalArgumentException::new);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping(value = "/order")
|
|
||||||
public String sendOrder(@RequestBody Map<String, Object> body) {
|
|
||||||
|
|
||||||
OrderDTO dto = new OrderDTO();
|
|
||||||
dto.setCustomerId((Integer) body.get("customerId"));
|
|
||||||
dto.setItemId((String) body.get("itemId"));
|
|
||||||
|
|
||||||
OrderResponse response = orderClient.order(dto);
|
|
||||||
|
|
||||||
return response.getStatus();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,4 +0,0 @@
|
|||||||
#Spring Boot server configuration
|
|
||||||
server.servlet.context-path=/customer-service
|
|
||||||
server.port=8001
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
|||||||
package com.baeldung.customerservice;
|
|
||||||
|
|
||||||
import com.baeldung.orderservice.client.OrderClient;
|
|
||||||
import com.baeldung.orderservice.client.OrderDTO;
|
|
||||||
import com.baeldung.orderservice.client.OrderResponse;
|
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|
||||||
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
|
||||||
@SpringBootTest(classes = CustomerApplication.class)
|
|
||||||
public class CustomerServiceTest {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private OrderClient orderClient;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testAddOrderSuccess(){
|
|
||||||
|
|
||||||
|
|
||||||
OrderDTO dto = new OrderDTO(2,"A152");
|
|
||||||
|
|
||||||
OrderResponse response = orderClient.order(dto);
|
|
||||||
|
|
||||||
Assert.assertNotNull("Order Id not generated", response.getOrderId());
|
|
||||||
Assert.assertEquals("A152", response.getProductId());
|
|
||||||
Assert.assertEquals("CREATED", response.getStatus());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,2 +0,0 @@
|
|||||||
local.server.port=8001
|
|
||||||
server.servlet.context-path=/customer-service
|
|
@ -1,41 +0,0 @@
|
|||||||
#https://github.com/spring-projects/spring-boot/blob/master/.gitignore
|
|
||||||
|
|
||||||
*#
|
|
||||||
*.iml
|
|
||||||
*.ipr
|
|
||||||
*.iws
|
|
||||||
*.jar
|
|
||||||
*.sw?
|
|
||||||
*~
|
|
||||||
.#*
|
|
||||||
.*.md.html
|
|
||||||
.DS_Store
|
|
||||||
.classpath
|
|
||||||
.factorypath
|
|
||||||
.gradle
|
|
||||||
.idea
|
|
||||||
.metadata
|
|
||||||
.project
|
|
||||||
.recommenders
|
|
||||||
.settings
|
|
||||||
.springBeans
|
|
||||||
/build
|
|
||||||
/code
|
|
||||||
MANIFEST.MF
|
|
||||||
_site/
|
|
||||||
activemq-data
|
|
||||||
bin
|
|
||||||
build
|
|
||||||
build.log
|
|
||||||
dependency-reduced-pom.xml
|
|
||||||
dump.rdb
|
|
||||||
interpolated*.xml
|
|
||||||
lib/
|
|
||||||
manifest.yml
|
|
||||||
overridedb.*
|
|
||||||
target
|
|
||||||
transaction-logs
|
|
||||||
.flattened-pom.xml
|
|
||||||
secrets.yml
|
|
||||||
.gradletasknamecache
|
|
||||||
.sts4-cache
|
|
@ -1,17 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<parent>
|
|
||||||
<!-- Your own application should inherit from spring-boot-starter-parent -->
|
|
||||||
<groupId>com.baeldung.orderservice</groupId>
|
|
||||||
<artifactId>order-service</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
<artifactId>order-client</artifactId>
|
|
||||||
<groupId>com.baeldung.orderservice</groupId>
|
|
||||||
<name>order-client</name>
|
|
||||||
<description>Order service client module</description>
|
|
||||||
<url>http://projects.spring.io/spring-boot/</url>
|
|
||||||
|
|
||||||
</project>
|
|
@ -1,6 +0,0 @@
|
|||||||
package com.baeldung.orderservice.client;
|
|
||||||
|
|
||||||
public interface OrderClient {
|
|
||||||
|
|
||||||
OrderResponse order(OrderDTO orderDTO);
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
package com.baeldung.orderservice.client;
|
|
||||||
|
|
||||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
|
||||||
import org.springframework.http.HttpEntity;
|
|
||||||
import org.springframework.http.HttpHeaders;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
|
||||||
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class OrderClientImpl implements OrderClient {
|
|
||||||
|
|
||||||
private RestTemplate restTemplate;
|
|
||||||
|
|
||||||
public OrderClientImpl(RestTemplateBuilder builder) {
|
|
||||||
|
|
||||||
this.restTemplate = builder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public OrderResponse order(OrderDTO orderDTO) {
|
|
||||||
|
|
||||||
String serviceUrl = "http://localhost:8002/order-service";
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
|
||||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
||||||
|
|
||||||
HttpEntity<OrderDTO> request = new HttpEntity<>(orderDTO, headers);
|
|
||||||
|
|
||||||
OrderResponse orderResponse = restTemplate.postForObject(serviceUrl + "/create", request, OrderResponse.class);
|
|
||||||
|
|
||||||
return orderResponse;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
package com.baeldung.orderservice.client;
|
|
||||||
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class OrderDTO {
|
|
||||||
|
|
||||||
private int customerId;
|
|
||||||
private String itemId;
|
|
||||||
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
package com.baeldung.orderservice.client;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class OrderResponse {
|
|
||||||
|
|
||||||
private int orderId;
|
|
||||||
private String productId;
|
|
||||||
private String status;
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
server.port=8002
|
|
@ -1,29 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>order-service</artifactId>
|
|
||||||
<groupId>com.baeldung.orderservice</groupId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<groupId>com.baeldung.orderservice</groupId>
|
|
||||||
<artifactId>order-server</artifactId>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.baeldung.orderservice</groupId>
|
|
||||||
<artifactId>order-client</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.baeldung.paymentservice</groupId>
|
|
||||||
<artifactId>payment-client</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
</project>
|
|
@ -1,18 +0,0 @@
|
|||||||
package com.baeldung.orderservice;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class Order {
|
|
||||||
|
|
||||||
private Integer id;
|
|
||||||
private Integer customerId;
|
|
||||||
private String itemId;
|
|
||||||
private String date;
|
|
||||||
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
package com.baeldung.orderservice;
|
|
||||||
|
|
||||||
import com.baeldung.paymentservice.PaymentClient;
|
|
||||||
import com.baeldung.paymentservice.PaymentClientImpl;
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Spring Boot application starter class
|
|
||||||
*/
|
|
||||||
@SpringBootApplication
|
|
||||||
public class OrderApplication {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
SpringApplication.run(OrderApplication.class, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public PaymentClient getPaymentClient() {
|
|
||||||
|
|
||||||
return new PaymentClientImpl(new RestTemplateBuilder());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
package com.baeldung.orderservice;
|
|
||||||
|
|
||||||
import com.baeldung.orderservice.client.OrderDTO;
|
|
||||||
import com.baeldung.orderservice.client.OrderResponse;
|
|
||||||
import com.baeldung.paymentservice.PaymentClient;
|
|
||||||
import com.baeldung.paymentservice.PaymentDTO;
|
|
||||||
import com.baeldung.paymentservice.PaymentResponse;
|
|
||||||
import org.apache.commons.lang.time.DateFormatUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
public class OrderService {
|
|
||||||
|
|
||||||
|
|
||||||
private List<Order> orders = Arrays.asList(
|
|
||||||
|
|
||||||
new Order(1, 1, "A101", "2020/02/14"),
|
|
||||||
new Order(2, 1, "A101", "2020/02/14"),
|
|
||||||
new Order(3, 2, "A150", "2020/02/17"));
|
|
||||||
|
|
||||||
@GetMapping
|
|
||||||
public List<Order> getAllOrders() {
|
|
||||||
return orders;
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/{id}")
|
|
||||||
public List<Order> getOrdersByCustomer(@PathVariable int id) {
|
|
||||||
return orders.stream()
|
|
||||||
.filter(order -> order.getCustomerId() == id).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/create")
|
|
||||||
public OrderResponse createOrder(@RequestBody OrderDTO request) {
|
|
||||||
|
|
||||||
int lastIndex = orders.size();
|
|
||||||
Order order = new Order();
|
|
||||||
order.setId(lastIndex + 1);
|
|
||||||
order.setCustomerId(request.getCustomerId());
|
|
||||||
order.setItemId(request.getItemId());
|
|
||||||
String date = DateFormatUtils.format(new Date(), "yyyy/MM/dd");
|
|
||||||
order.setDate(date);
|
|
||||||
|
|
||||||
return new OrderResponse(order.getId(), order.getItemId(), "CREATED");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,4 +0,0 @@
|
|||||||
#Spring Boot server configuration
|
|
||||||
server.servlet.context-path=/order-service
|
|
||||||
server.port=8002
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
|||||||
package com.baeldung.orderservice;
|
|
||||||
|
|
||||||
import com.baeldung.paymentservice.PaymentClient;
|
|
||||||
import com.baeldung.paymentservice.PaymentDTO;
|
|
||||||
import com.baeldung.paymentservice.PaymentResponse;
|
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|
||||||
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
|
||||||
@SpringBootTest(classes = OrderApplication.class)
|
|
||||||
public class OrderServiceTest {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private PaymentClient paymentClient;
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSendPaySuccess(){
|
|
||||||
|
|
||||||
|
|
||||||
PaymentDTO dto = new PaymentDTO("Sasa","Milenkovic","4260-6720-3283-7081",150.0,"USD");
|
|
||||||
|
|
||||||
PaymentResponse response = paymentClient.pay("A152", dto);
|
|
||||||
|
|
||||||
Assert.assertNotNull("Payment Id not generated", response.getPaymentId());
|
|
||||||
Assert.assertEquals("CREDITCARD", response.getPaymentMethod());
|
|
||||||
Assert.assertEquals("Sasa Milenkovic", response.getCustomerFullName());
|
|
||||||
Assert.assertEquals(new Double(150.0), response.getAmount());
|
|
||||||
Assert.assertEquals("USD", response.getCurrency());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,128 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>CustomerOrderApp</artifactId>
|
|
||||||
<groupId>com.baeldung</groupId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<groupId>com.baeldung.orderservice</groupId>
|
|
||||||
<artifactId>order-service</artifactId>
|
|
||||||
<packaging>pom</packaging>
|
|
||||||
<modules>
|
|
||||||
<module>order-client</module>
|
|
||||||
<module>order-server</module>
|
|
||||||
</modules>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<java.version>1.8</java.version>
|
|
||||||
<commons-lang.version>2.6</commons-lang.version>
|
|
||||||
<structure-maven.version>0.0.2</structure-maven.version>
|
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
<orderservice.mainclass>com.baeldung.orderservice.OrderApplication</orderservice.mainclass>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencyManagement>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-dependencies</artifactId>
|
|
||||||
<version>2.3.0.RELEASE</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</dependencyManagement>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>commons-lang</groupId>
|
|
||||||
<artifactId>commons-lang</artifactId>
|
|
||||||
<version>${commons-lang.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.qunix</groupId>
|
|
||||||
<artifactId>structure-maven-plugin</artifactId>
|
|
||||||
<version>${structure-maven.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-json</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-test-autoconfigure</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>junit</groupId>
|
|
||||||
<artifactId>junit</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<pluginManagement>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<mainClass>${orderservice.mainclass}</mainClass>
|
|
||||||
</configuration>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<goals>
|
|
||||||
<goal>repackage</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<classifier>exe</classifier>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
<execution>
|
|
||||||
<id>start-application</id>
|
|
||||||
<configuration>
|
|
||||||
<mainClass>com.baeldung.orderservice.OrderApplication</mainClass>
|
|
||||||
<classesDirectory>../order-server/target/classes</classesDirectory>
|
|
||||||
</configuration>
|
|
||||||
<goals>
|
|
||||||
<goal>start</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.qunix</groupId>
|
|
||||||
<artifactId>structure-maven-plugin</artifactId>
|
|
||||||
<version>${structure-maven.version}</version>
|
|
||||||
<inherited>false</inherited>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>compile</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>modules</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</pluginManagement>
|
|
||||||
</build>
|
|
||||||
</project>
|
|
@ -1,46 +0,0 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<groupId>com.baeldung</groupId>
|
|
||||||
<artifactId>CustomerOrderApp</artifactId>
|
|
||||||
<packaging>pom</packaging>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
<name>CustomerOrderApp</name>
|
|
||||||
<url>http://maven.apache.org</url>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
|
||||||
<version>2.3.0.RELEASE</version>
|
|
||||||
<relativePath/> <!-- lookup parent from repository -->
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<modules>
|
|
||||||
<module>customer-service</module>
|
|
||||||
<module>order-service</module>
|
|
||||||
<module>shared-dto</module>
|
|
||||||
</modules>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
@ -1,59 +0,0 @@
|
|||||||
{
|
|
||||||
"info": {
|
|
||||||
"_postman_id": "92594398-49cc-4a7c-b44f-1037307afbd3",
|
|
||||||
"name": "postman-requests",
|
|
||||||
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
|
|
||||||
},
|
|
||||||
"item": [
|
|
||||||
{
|
|
||||||
"name": "Crete new Customer order",
|
|
||||||
"request": {
|
|
||||||
"method": "POST",
|
|
||||||
"header": [
|
|
||||||
{
|
|
||||||
"key": "Content-Type",
|
|
||||||
"value": "multipart/form-data",
|
|
||||||
"type": "text",
|
|
||||||
"disabled": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"key": "Accept-Charset",
|
|
||||||
"value": "utf-8",
|
|
||||||
"type": "text",
|
|
||||||
"disabled": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"key": "boundary",
|
|
||||||
"value": "nAp4nMEt-BuGuuLlq-6fnASQErGjSamaG",
|
|
||||||
"type": "text",
|
|
||||||
"disabled": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"body": {
|
|
||||||
"mode": "raw",
|
|
||||||
"raw": "{\n \"customerId\":2,\n \"itemId\":\"A152\"\n}",
|
|
||||||
"options": {
|
|
||||||
"raw": {
|
|
||||||
"language": "json"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"url": {
|
|
||||||
"raw": "http://localhost:8001/customer-service/order",
|
|
||||||
"protocol": "http",
|
|
||||||
"host": [
|
|
||||||
"localhost"
|
|
||||||
],
|
|
||||||
"port": "8001",
|
|
||||||
"path": [
|
|
||||||
"customer-service",
|
|
||||||
"order"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"response": []
|
|
||||||
}
|
|
||||||
|
|
||||||
],
|
|
||||||
"protocolProfileBehavior": {}
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>CustomerOrderApp</artifactId>
|
|
||||||
<groupId>com.baeldung</groupId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<groupId>com.baeldung</groupId>
|
|
||||||
<artifactId>shared-dto</artifactId>
|
|
||||||
|
|
||||||
<name>shared-dto</name>
|
|
||||||
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
|
||||||
<structure-maven.version>0.0.2</structure-maven.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.qunix</groupId>
|
|
||||||
<artifactId>structure-maven-plugin</artifactId>
|
|
||||||
<version>${structure-maven.version}</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<pluginManagement>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.qunix</groupId>
|
|
||||||
<artifactId>structure-maven-plugin</artifactId>
|
|
||||||
<version>${structure-maven.version}</version>
|
|
||||||
<inherited>false</inherited>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>compile</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>files</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</pluginManagement>
|
|
||||||
</build>
|
|
||||||
</project>
|
|
@ -1,17 +0,0 @@
|
|||||||
package com.baeldung.paymentservice;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class CustomerDTO {
|
|
||||||
|
|
||||||
private String firstName;
|
|
||||||
private String lastName;
|
|
||||||
private String homeAddress;
|
|
||||||
private String cardNumber;
|
|
||||||
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
package com.baeldung.orderservice.client;
|
|
||||||
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class OrderDTO {
|
|
||||||
|
|
||||||
private int customerId;
|
|
||||||
private String itemId;
|
|
||||||
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
package com.baeldung;
|
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Customer Order Spring Boot Main Application
|
|
||||||
*
|
|
||||||
* */
|
|
||||||
|
|
||||||
@SpringBootApplication
|
|
||||||
@ComponentScan(basePackages = "com.baeldung.*")
|
|
||||||
public class CustomerOrderApp
|
|
||||||
{
|
|
||||||
|
|
||||||
public static void main( String[] args )
|
|
||||||
{
|
|
||||||
|
|
||||||
SpringApplication.run(CustomerOrderApp.class,args);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user