WIP
authorKai Moritz <kai@juplo.de>
Sat, 13 Mar 2021 15:13:41 +0000 (16:13 +0100)
committerKai Moritz <kai@juplo.de>
Sat, 13 Mar 2021 15:13:41 +0000 (16:13 +0100)
consumer/src/main/java/de/juplo/demos/consumer/adapter/RemoteUserServiceConsumer.java [deleted file]
consumer/src/main/java/de/juplo/demos/consumer/adapter/RemoteUserServiceConsumerIT.java [deleted file]
consumer/src/main/java/de/juplo/demos/consumer/adapter/RemoteUsersServiceConsumer.java [new file with mode: 0644]
consumer/src/main/java/de/juplo/demos/consumer/domain/UserService.java [deleted file]
consumer/src/main/java/de/juplo/demos/consumer/domain/UsersService.java [new file with mode: 0644]
consumer/src/test/java/de/juplo/demos/consumer/adapter/RemoteUsersServiceConsumerIT.java [new file with mode: 0644]

diff --git a/consumer/src/main/java/de/juplo/demos/consumer/adapter/RemoteUserServiceConsumer.java b/consumer/src/main/java/de/juplo/demos/consumer/adapter/RemoteUserServiceConsumer.java
deleted file mode 100644 (file)
index 104339c..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-package de.juplo.demos.consumer.adapter;
-
-import de.juplo.demos.consumer.domain.User;
-import de.juplo.demos.consumer.domain.UserService;
-import lombok.RequiredArgsConstructor;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.client.RestTemplate;
-
-import java.util.Optional;
-import java.util.UUID;
-
-
-@RequiredArgsConstructor
-public class RemoteUserServiceConsumer implements UserService
-{
-  private String uriTemplate;
-  private RestTemplate restTemplate;
-
-
-  @Override
-  public Optional<User> getUser(UUID id) {
-    ResponseEntity<UserDTO> response =
-        restTemplate.getForEntity(uriTemplate, UserDTO.class, id);
-    HttpStatus status = response.getStatusCode();
-    UserDTO dto = response.getBody();
-    switch (response.getStatusCode()) {
-      case OK:
-        return
-            Optional.of(
-                User.builder()
-                    .id(dto.id)
-                    .email(dto.email)
-                    .build());
-      case NOT_FOUND:
-        return Optional.empty();
-      default:
-        throw new RuntimeException(status.toString());
-    }
-  }
-}
diff --git a/consumer/src/main/java/de/juplo/demos/consumer/adapter/RemoteUserServiceConsumerIT.java b/consumer/src/main/java/de/juplo/demos/consumer/adapter/RemoteUserServiceConsumerIT.java
deleted file mode 100644 (file)
index 2a33f89..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-package de.juplo.demos.consumer.adapter;
-
-import org.junit.jupiter.api.extension.ExtendWith;
-
-
-@ExtendWith(PactConsumerTestExt.class)
-@PactTestFor(providerName = "UsersProvider")
-public class RemoteUserServiceConsumerIT
-{
-
-}
diff --git a/consumer/src/main/java/de/juplo/demos/consumer/adapter/RemoteUsersServiceConsumer.java b/consumer/src/main/java/de/juplo/demos/consumer/adapter/RemoteUsersServiceConsumer.java
new file mode 100644 (file)
index 0000000..fd09ddc
--- /dev/null
@@ -0,0 +1,41 @@
+package de.juplo.demos.consumer.adapter;
+
+import de.juplo.demos.consumer.domain.User;
+import de.juplo.demos.consumer.domain.UserService;
+import lombok.RequiredArgsConstructor;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.Optional;
+import java.util.UUID;
+
+
+@RequiredArgsConstructor
+public class RemoteUsersServiceConsumer implements UserService
+{
+  private String uriTemplate;
+  private RestTemplate restTemplate;
+
+
+  @Override
+  public Optional<User> getUser(UUID id) {
+    ResponseEntity<UserDTO> response =
+        restTemplate.getForEntity(uriTemplate, UserDTO.class, id);
+    HttpStatus status = response.getStatusCode();
+    UserDTO dto = response.getBody();
+    switch (response.getStatusCode()) {
+      case OK:
+        return
+            Optional.of(
+                User.builder()
+                    .id(dto.id)
+                    .email(dto.email)
+                    .build());
+      case NOT_FOUND:
+        return Optional.empty();
+      default:
+        throw new RuntimeException(status.toString());
+    }
+  }
+}
diff --git a/consumer/src/main/java/de/juplo/demos/consumer/domain/UserService.java b/consumer/src/main/java/de/juplo/demos/consumer/domain/UserService.java
deleted file mode 100644 (file)
index b65f4eb..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-package de.juplo.demos.consumer.domain;
-
-import java.util.Optional;
-import java.util.UUID;
-
-
-public interface UserService
-{
-  Optional<User> getUser(UUID id);
-}
diff --git a/consumer/src/main/java/de/juplo/demos/consumer/domain/UsersService.java b/consumer/src/main/java/de/juplo/demos/consumer/domain/UsersService.java
new file mode 100644 (file)
index 0000000..b65f4eb
--- /dev/null
@@ -0,0 +1,10 @@
+package de.juplo.demos.consumer.domain;
+
+import java.util.Optional;
+import java.util.UUID;
+
+
+public interface UserService
+{
+  Optional<User> getUser(UUID id);
+}
diff --git a/consumer/src/test/java/de/juplo/demos/consumer/adapter/RemoteUsersServiceConsumerIT.java b/consumer/src/test/java/de/juplo/demos/consumer/adapter/RemoteUsersServiceConsumerIT.java
new file mode 100644 (file)
index 0000000..12ce6c9
--- /dev/null
@@ -0,0 +1,13 @@
+package de.juplo.demos.consumer.adapter;
+
+import au.com.dius.pact.consumer.junit5.PactConsumerTestExt;
+import au.com.dius.pact.consumer.junit5.PactTestFor;
+import org.junit.jupiter.api.extension.ExtendWith;
+
+
+@ExtendWith(PactConsumerTestExt.class)
+@PactTestFor(providerName = "UsersProvider")
+public class RemoteUsersServiceConsumerIT
+{
+
+}