diff --git a/README.md b/README.md
index 9213d6c..ecd8898 100644
--- a/README.md
+++ b/README.md
@@ -14,6 +14,7 @@ Sandbox to play with spring cloud features
|----------------------|-----------------------------|--------------|--------------------------------------------------|
| Rating service | Rating Calculation Service | 8081 | |
| Hackster service| Hackster Detection Service | 8082| |
+| Client service| Client Service | 8083| |
| Realtor service| Realtor Api Service | 8080| To call other services used Feign, RestTemplate |
| Storage service| Storage of Apartment Records Service | 8091| H2 based service for ApartmentRecord data storage. |
| API gateway service| Zull API Gateway Service | 8090| |
diff --git a/api-gateway-service/src/main/resources/application.yml b/api-gateway-service/src/main/resources/application.yml
index c19606d..9c380ca 100644
--- a/api-gateway-service/src/main/resources/application.yml
+++ b/api-gateway-service/src/main/resources/application.yml
@@ -5,5 +5,7 @@ zuul:
realtor:
path: /realtor-service/**
serviceId: realtor-service
-
+ client:
+ path: /client-service/**
+ serviceId: client-service
ignored-services: '*'
\ No newline at end of file
diff --git a/client-service/pom.xml b/client-service/pom.xml
new file mode 100644
index 0000000..3864989
--- /dev/null
+++ b/client-service/pom.xml
@@ -0,0 +1,111 @@
+
+
+ 4.0.0
+
+ com.lohika.jclub.client
+ client-service
+ 0.0.1-SNAPSHOT
+ jar
+
+ Client service
+ Client service for Spring Boot
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 1.5.3.RELEASE
+
+
+
+
+ UTF-8
+ UTF-8
+ 1.8
+ Dalston.RELEASE
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-eureka
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.projectlombok
+ lombok
+ 1.16.12
+
+
+ org.springframework.cloud
+ spring-cloud-starter-feign
+
+
+ com.lohika.jclub.storage.client
+ storage-service-client
+ 0.0.1-SNAPSHOT
+
+
+ org.testcontainers
+ testcontainers
+ 1.3.0
+ test
+
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ ${spring-cloud.version}
+ pom
+ import
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+ com.spotify
+ docker-maven-plugin
+ 1.0.0
+
+
+ build-image
+ install
+
+ build
+
+
+
+
+ client-service
+ java
+ ["java", "-jar", "/${project.build.finalName}.jar"]
+
+
+ /
+ ${project.build.directory}
+ ${project.build.finalName}.jar
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/client-service/src/main/java/com/lohika/jclub/client/ClientController.java b/client-service/src/main/java/com/lohika/jclub/client/ClientController.java
new file mode 100644
index 0000000..f52eeed
--- /dev/null
+++ b/client-service/src/main/java/com/lohika/jclub/client/ClientController.java
@@ -0,0 +1,26 @@
+package com.lohika.jclub.client;
+
+import com.lohika.jclub.storage.client.Apartment;
+import com.lohika.jclub.storage.client.StorageServiceClient;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.hateoas.PagedResources;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+@RestController
+public class ClientController {
+
+ @Autowired
+ private StorageServiceClient storageServiceClient;
+
+ @GetMapping("/apartments")
+ public PagedResources getApartments() {
+ PagedResources list = storageServiceClient.list();
+ return new PagedResources<>(list.getContent(), list.getMetadata());
+ }
+
+}
\ No newline at end of file
diff --git a/client-service/src/main/java/com/lohika/jclub/client/ClientServiceApplication.java b/client-service/src/main/java/com/lohika/jclub/client/ClientServiceApplication.java
new file mode 100644
index 0000000..55a2b86
--- /dev/null
+++ b/client-service/src/main/java/com/lohika/jclub/client/ClientServiceApplication.java
@@ -0,0 +1,19 @@
+package com.lohika.jclub.client;
+
+import com.lohika.jclub.storage.client.EnableStorageServiceClient;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.loadbalancer.LoadBalanced;
+import org.springframework.context.annotation.Bean;
+import org.springframework.web.client.RestTemplate;
+
+@SpringBootApplication
+@EnableStorageServiceClient
+public class ClientServiceApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(ClientServiceApplication.class, args);
+ }
+
+}
diff --git a/client-service/src/main/resources/application.properties b/client-service/src/main/resources/application.properties
new file mode 100644
index 0000000..60ea3d6
--- /dev/null
+++ b/client-service/src/main/resources/application.properties
@@ -0,0 +1,3 @@
+spring.application.name=client-service
+server.port=8083
+eureka.instance.prefer-ip-address=true
\ No newline at end of file
diff --git a/client-service/src/main/resources/banner.txt b/client-service/src/main/resources/banner.txt
new file mode 100644
index 0000000..87dbc92
--- /dev/null
+++ b/client-service/src/main/resources/banner.txt
@@ -0,0 +1,7 @@
+ _________ __ _
+ / ____/ (_)__ ____ / /_ ________ ______ __(_)_______
+ / / / / / _ \/ __ \/ __/ / ___/ _ \/ ___/ | / / / ___/ _ \
+/ /___/ / / __/ / / / /_ (__ ) __/ / | |/ / / /__/ __/
+\____/_/_/\___/_/ /_/\__/ /____/\___/_/ |___/_/\___/\___/
+
+v.${application.version}
\ No newline at end of file
diff --git a/client-service/src/test/java/com/lohika/jclub/client/ClientServiceApplicationTests.java b/client-service/src/test/java/com/lohika/jclub/client/ClientServiceApplicationTests.java
new file mode 100644
index 0000000..5050dbf
--- /dev/null
+++ b/client-service/src/test/java/com/lohika/jclub/client/ClientServiceApplicationTests.java
@@ -0,0 +1,16 @@
+package com.lohika.jclub.client;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class ClientServiceApplicationTests {
+
+ @Test
+ public void contextLoads() {
+ }
+
+}
diff --git a/client-service/src/test/java/com/lohika/jclub/client/ClientServiceTest.java b/client-service/src/test/java/com/lohika/jclub/client/ClientServiceTest.java
new file mode 100644
index 0000000..d256aec
--- /dev/null
+++ b/client-service/src/test/java/com/lohika/jclub/client/ClientServiceTest.java
@@ -0,0 +1,82 @@
+package com.lohika.jclub.client;
+
+import com.lohika.jclub.storage.client.Apartment;
+import com.lohika.jclub.storage.client.StorageServiceClient;
+
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.util.EnvironmentTestUtils;
+import org.springframework.context.ApplicationContextInitializer;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.wait.LogMessageWaitStrategy;
+
+import java.time.Duration;
+
+import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = ClientServiceApplication.class)
+@ContextConfiguration(initializers = ClientServiceTest.Initializer.class)
+@AutoConfigureMockMvc
+public class ClientServiceTest {
+
+ @ClassRule
+ public static GenericContainer discoveryService = new GenericContainer("discovery-service:latest")
+ .waitingFor(new LogMessageWaitStrategy().withRegEx(".*Started EurekaServerApplication in.*\\s"))
+ .withExposedPorts(8761);
+
+ @Rule
+ public GenericContainer storageService = new GenericContainer("storage-service:latest")
+ .withExposedPorts(8091)
+ .withEnv("eureka.client.serviceUrl.defaultZone", "http://" + discoveryService.getContainerIpAddress() + ":" + discoveryService.getMappedPort(8761) + "/eureka")
+ .withEnv("eureka.instance.preferIpAddress", "true")
+ .waitingFor(new LogMessageWaitStrategy().withRegEx(".*DiscoveryClient_STORAGE-SERVICE.*registration status: 204.*\\s"));
+
+ @Autowired
+ private StorageServiceClient storageServiceClient;
+
+ @Autowired
+ private MockMvc mockMvc;
+
+ public static class Initializer implements ApplicationContextInitializer {
+ @Override
+ public void initialize(ConfigurableApplicationContext configurableApplicationContext) {
+ EnvironmentTestUtils.addEnvironment("testcontainers", configurableApplicationContext.getEnvironment(),
+ "eureka.client.serviceUrl.defaultZone=http://" + discoveryService.getContainerIpAddress() +
+ ":" + discoveryService.getMappedPort(8761) + "/eureka",
+ "storage-service.ribbon.servers=http://");
+ }
+ }
+
+ @Test
+ public void testGetApartments() throws Exception {
+ // Given
+ Apartment lviv = storageServiceClient.create(
+ Apartment.builder()
+ .location("LVIV")
+ .mail("asfafs@asf.com")
+ .phone("02510505001")
+ .price(5225)
+ .realtorName("Bariga")
+ .sqft(55)
+ .build());
+
+ // When
+ mockMvc.perform(MockMvcRequestBuilders.get("/apartments"))
+ .andDo(print());
+
+ // Then
+ //TODO storageServiceClient does not creating the records.
+ // fallback is working with 0 paging
+ }
+}
diff --git a/client-service/src/test/resources/application.properties b/client-service/src/test/resources/application.properties
new file mode 100644
index 0000000..ffb7b0f
--- /dev/null
+++ b/client-service/src/test/resources/application.properties
@@ -0,0 +1 @@
+feign.hystrix.enabled=true
\ No newline at end of file
diff --git a/discovery-server/pom.xml b/discovery-server/pom.xml
index b54d099..1107e2c 100644
--- a/discovery-server/pom.xml
+++ b/discovery-server/pom.xml
@@ -56,6 +56,32 @@
org.springframework.boot
spring-boot-maven-plugin
+
+ com.spotify
+ docker-maven-plugin
+ 1.0.0
+
+
+ build-image
+ install
+
+ build
+
+
+
+
+ discovery-service
+ java
+ ["java", "-jar", "/${project.build.finalName}.jar"]
+
+
+ /
+ ${project.build.directory}
+ ${project.build.finalName}.jar
+
+
+
+
diff --git a/pom.xml b/pom.xml
index 8a25d39..07fad45 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,5 +22,6 @@
storage-service
storage-service-client
api-gateway-service
+ client-service
-
+
\ No newline at end of file
diff --git a/rating-service/pom.xml b/rating-service/pom.xml
index afdbb2b..25862a6 100644
--- a/rating-service/pom.xml
+++ b/rating-service/pom.xml
@@ -42,14 +42,11 @@
org.springframework.cloud
spring-cloud-starter-eureka
-
org.projectlombok
lombok
1.16.16
-
-
org.springframework.boot
spring-boot-starter-test
diff --git a/realtor-service/pom.xml b/realtor-service/pom.xml
index 1a2677c..4673e03 100644
--- a/realtor-service/pom.xml
+++ b/realtor-service/pom.xml
@@ -9,7 +9,7 @@
jar
Realtor service
- Demo project for Spring Boot
+ Realtor for Spring Boot
org.springframework.boot
diff --git a/realtor-service/src/main/java/com/lohika/jclub/realtor/RealtorController.java b/realtor-service/src/main/java/com/lohika/jclub/realtor/RealtorController.java
index 9e43a1c..055072a 100644
--- a/realtor-service/src/main/java/com/lohika/jclub/realtor/RealtorController.java
+++ b/realtor-service/src/main/java/com/lohika/jclub/realtor/RealtorController.java
@@ -16,7 +16,7 @@
import java.util.List;
@Slf4j
-@RestController()
+@RestController
public class RealtorController {
@Autowired
diff --git a/realtor-service/src/main/resources/application.properties b/realtor-service/src/main/resources/application.properties
index eedde86..a58c307 100644
--- a/realtor-service/src/main/resources/application.properties
+++ b/realtor-service/src/main/resources/application.properties
@@ -1,2 +1,2 @@
spring.application.name=realtor-service
-feign.hystrix.enabled=true
+feign.hystrix.enabled=true
\ No newline at end of file