Moved all classes to io.pactfolw.example.sirenconsumer
authorKai Moritz <kai@juplo.de>
Fri, 3 Jun 2022 09:53:51 +0000 (11:53 +0200)
committerKai Moritz <kai@juplo.de>
Fri, 3 Jun 2022 11:50:31 +0000 (13:50 +0200)
spring-consumer/pom.xml
spring-consumer/src/main/java/de/juplo/demos/pact/Application.java [deleted file]
spring-consumer/src/main/java/io/pactflow/example/sirenconsumer/Application.java [new file with mode: 0644]
spring-consumer/src/test/java/de/juplo/demos/pact/ApplicationTests.java [deleted file]
spring-consumer/src/test/java/de/juplo/demos/pact/ContractTest.java [deleted file]
spring-consumer/src/test/java/io/pactflow/example/sirenconsumer/ApplicationTests.java [new file with mode: 0644]
spring-consumer/src/test/java/io/pactflow/example/sirenconsumer/ContractTest.java [new file with mode: 0644]

index 23844a2..2927e83 100644 (file)
@@ -10,7 +10,7 @@
        </parent>
 
        <modelVersion>4.0.0</modelVersion>
-       <groupId>de.juplo.demos.pact</groupId>
+       <groupId>io.pactflow.example.sirenconsumer.pact</groupId>
        <artifactId>siren-consumer</artifactId>
        <version>1.0.0-SNAPSHOT</version>
 
diff --git a/spring-consumer/src/main/java/de/juplo/demos/pact/Application.java b/spring-consumer/src/main/java/de/juplo/demos/pact/Application.java
deleted file mode 100644 (file)
index 5dccaa0..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-package de.juplo.demos.pact;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-
-@SpringBootApplication
-public class Application
-{
-
-       public static void main(String[] args) {
-               SpringApplication.run(Application.class, args);
-       }
-
-}
diff --git a/spring-consumer/src/main/java/io/pactflow/example/sirenconsumer/Application.java b/spring-consumer/src/main/java/io/pactflow/example/sirenconsumer/Application.java
new file mode 100644 (file)
index 0000000..fee9494
--- /dev/null
@@ -0,0 +1,14 @@
+package io.pactflow.example.sirenconsumer;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class Application
+{
+
+       public static void main(String[] args) {
+               SpringApplication.run(Application.class, args);
+       }
+
+}
diff --git a/spring-consumer/src/test/java/de/juplo/demos/pact/ApplicationTests.java b/spring-consumer/src/test/java/de/juplo/demos/pact/ApplicationTests.java
deleted file mode 100644 (file)
index 7c96248..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-package de.juplo.demos.pact;
-
-import org.junit.jupiter.api.Test;
-import org.springframework.boot.test.context.SpringBootTest;
-
-@SpringBootTest
-class ApplicationTests
-{
-
-       @Test
-       void contextLoads() {
-       }
-
-}
diff --git a/spring-consumer/src/test/java/de/juplo/demos/pact/ContractTest.java b/spring-consumer/src/test/java/de/juplo/demos/pact/ContractTest.java
deleted file mode 100644 (file)
index b5c41a3..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-package de.juplo.demos.pact;
-
-import au.com.dius.pact.consumer.MockServer;
-import au.com.dius.pact.consumer.dsl.*;
-import au.com.dius.pact.consumer.junit5.PactConsumerTestExt;
-import au.com.dius.pact.consumer.junit5.PactTestFor;
-import au.com.dius.pact.core.model.RequestResponsePact;
-import au.com.dius.pact.core.model.annotations.Pact;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.springframework.boot.web.client.RestTemplateBuilder;
-import org.springframework.web.client.RestTemplate;
-
-import java.util.Map;
-
-import static org.assertj.core.api.Assertions.fail;
-
-
-@ExtendWith(PactConsumerTestExt.class)
-@PactTestFor(providerName = "SirenOrderProvider")
-public class ContractTest
-{
-  @Pact(consumer="SpringConsumer")
-  public RequestResponsePact deletesTheFirstOrderUsingtheDeleteAction(PactDslWithProvider builder)
-  {
-    return builder
-        .uponReceiving("get root")
-        .path("/")
-        .method("GET")
-        .willRespondWith()
-        .status(200)
-        .headers(Map.of("Content-Type", "application/vnd.siren+json"))
-        .body(LambdaDsl.newJsonBody(body ->
-        {
-          body.array("class", classArray ->
-          {
-            classArray.stringValue("representation");
-          });
-          body.array("links", linksArray ->
-          {
-            linksArray.object(object->
-            {
-              object.matchUrl2("href", "orders");
-              object.array("rel", relArray ->
-              {
-                relArray.stringValue("orders");
-              });
-            });
-          });
-        }).build())
-        .uponReceiving("get all orders")
-        .path("/orders")
-        .method("GET")
-        .willRespondWith()
-        .status(200)
-        .headers(Map.of("Content-Type", "application/vnd.siren+json"))
-        .body(LambdaDsl.newJsonBody(body ->
-        {
-          body.array("class", classArray ->
-          {
-            classArray.stringValue("entity");
-          });
-          body.eachLike("entities", entities ->
-          {
-            entities.arrayContaining("actions", actionsArray->
-            {
-              actionsArray.object(object ->
-              {
-                object.stringValue("name","update");
-                object.stringValue("method", "PUT");
-                object.matchUrl2("href", "orders", Matchers.regexp("\\d+", "1234").getMatcher());
-              });
-              actionsArray.object(object ->
-              {
-                object.stringValue("name","delete");
-                object.stringValue("method", "DELETE");
-                object.matchUrl2("href", "orders", Matchers.regexp("\\d+", "1234").getMatcher());
-              });
-            });
-            entities.array("class", classArray ->
-            {
-              classArray.stringValue("entity");
-            });
-            entities.array("links", linksArray ->
-            {
-              linksArray.object(object->
-              {
-                object.matchUrl2("href", "orders", Matchers.regexp("\\d+", "1234").getMatcher());
-                object.array("rel", relArray ->
-                {
-                  relArray.stringValue("self");
-                });
-              });
-            });
-            entities.object("properties", object->
-            {
-              object.integerType("id", 1234);
-            });
-            entities.array("rel", relArray ->
-            {
-              relArray.stringValue("item");
-            });
-          });
-          body.array("links", linksArray ->
-          {
-            linksArray.object(object->
-            {
-              object.matchUrl2("href", "orders");
-              object.array("rel", relArray ->
-              {
-                relArray.stringValue("self");
-              });
-            });
-          });
-        }).build())
-        .uponReceiving("delete order")
-        .matchPath("/orders/\\d+", "/orders/1234")
-        .method("DELETE")
-        .willRespondWith()
-        .status(200)
-        .toPact();
-  }
-
-  @Test
-  @PactTestFor(pactMethod = "deletesTheFirstOrderUsingtheDeleteAction")
-  public void testDeletesTheFirstOrderUsingtheDeleteAction(MockServer mockServer)
-  {
-    RestTemplate restTemplate =
-        new RestTemplateBuilder()
-            .rootUri(mockServer.getUrl())
-            .build();
-    try
-    {
-      restTemplate.getForEntity("/", String.class);
-      restTemplate.getForEntity("/orders", String.class);
-      restTemplate.delete("/orders/1234");
-    }
-    catch (Exception e)
-    {
-      fail("Unexpected exception", e);
-    }
-  }
-}
diff --git a/spring-consumer/src/test/java/io/pactflow/example/sirenconsumer/ApplicationTests.java b/spring-consumer/src/test/java/io/pactflow/example/sirenconsumer/ApplicationTests.java
new file mode 100644 (file)
index 0000000..d1ca158
--- /dev/null
@@ -0,0 +1,14 @@
+package io.pactflow.example.sirenconsumer;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class ApplicationTests
+{
+
+       @Test
+       void contextLoads() {
+       }
+
+}
diff --git a/spring-consumer/src/test/java/io/pactflow/example/sirenconsumer/ContractTest.java b/spring-consumer/src/test/java/io/pactflow/example/sirenconsumer/ContractTest.java
new file mode 100644 (file)
index 0000000..16235cc
--- /dev/null
@@ -0,0 +1,143 @@
+package io.pactflow.example.sirenconsumer;
+
+import au.com.dius.pact.consumer.MockServer;
+import au.com.dius.pact.consumer.dsl.*;
+import au.com.dius.pact.consumer.junit5.PactConsumerTestExt;
+import au.com.dius.pact.consumer.junit5.PactTestFor;
+import au.com.dius.pact.core.model.RequestResponsePact;
+import au.com.dius.pact.core.model.annotations.Pact;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.springframework.boot.web.client.RestTemplateBuilder;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.Map;
+
+import static org.assertj.core.api.Assertions.fail;
+
+
+@ExtendWith(PactConsumerTestExt.class)
+@PactTestFor(providerName = "SirenOrderProvider")
+public class ContractTest
+{
+  @Pact(consumer="SpringConsumer")
+  public RequestResponsePact deletesTheFirstOrderUsingtheDeleteAction(PactDslWithProvider builder)
+  {
+    return builder
+        .uponReceiving("get root")
+        .path("/")
+        .method("GET")
+        .willRespondWith()
+        .status(200)
+        .headers(Map.of("Content-Type", "application/vnd.siren+json"))
+        .body(LambdaDsl.newJsonBody(body ->
+        {
+          body.array("class", classArray ->
+          {
+            classArray.stringValue("representation");
+          });
+          body.array("links", linksArray ->
+          {
+            linksArray.object(object->
+            {
+              object.matchUrl2("href", "orders");
+              object.array("rel", relArray ->
+              {
+                relArray.stringValue("orders");
+              });
+            });
+          });
+        }).build())
+        .uponReceiving("get all orders")
+        .path("/orders")
+        .method("GET")
+        .willRespondWith()
+        .status(200)
+        .headers(Map.of("Content-Type", "application/vnd.siren+json"))
+        .body(LambdaDsl.newJsonBody(body ->
+        {
+          body.array("class", classArray ->
+          {
+            classArray.stringValue("entity");
+          });
+          body.eachLike("entities", entities ->
+          {
+            entities.arrayContaining("actions", actionsArray->
+            {
+              actionsArray.object(object ->
+              {
+                object.stringValue("name","update");
+                object.stringValue("method", "PUT");
+                object.matchUrl2("href", "orders", Matchers.regexp("\\d+", "1234").getMatcher());
+              });
+              actionsArray.object(object ->
+              {
+                object.stringValue("name","delete");
+                object.stringValue("method", "DELETE");
+                object.matchUrl2("href", "orders", Matchers.regexp("\\d+", "1234").getMatcher());
+              });
+            });
+            entities.array("class", classArray ->
+            {
+              classArray.stringValue("entity");
+            });
+            entities.array("links", linksArray ->
+            {
+              linksArray.object(object->
+              {
+                object.matchUrl2("href", "orders", Matchers.regexp("\\d+", "1234").getMatcher());
+                object.array("rel", relArray ->
+                {
+                  relArray.stringValue("self");
+                });
+              });
+            });
+            entities.object("properties", object->
+            {
+              object.integerType("id", 1234);
+            });
+            entities.array("rel", relArray ->
+            {
+              relArray.stringValue("item");
+            });
+          });
+          body.array("links", linksArray ->
+          {
+            linksArray.object(object->
+            {
+              object.matchUrl2("href", "orders");
+              object.array("rel", relArray ->
+              {
+                relArray.stringValue("self");
+              });
+            });
+          });
+        }).build())
+        .uponReceiving("delete order")
+        .matchPath("/orders/\\d+", "/orders/1234")
+        .method("DELETE")
+        .willRespondWith()
+        .status(200)
+        .toPact();
+  }
+
+  @Test
+  @PactTestFor(pactMethod = "deletesTheFirstOrderUsingtheDeleteAction")
+  public void testDeletesTheFirstOrderUsingtheDeleteAction(MockServer mockServer)
+  {
+    RestTemplate restTemplate =
+        new RestTemplateBuilder()
+            .rootUri(mockServer.getUrl())
+            .build();
+    try
+    {
+      restTemplate.getForEntity("/", String.class);
+      restTemplate.getForEntity("/orders", String.class);
+      restTemplate.delete("/orders/1234");
+    }
+    catch (Exception e)
+    {
+      fail("Unexpected exception", e);
+    }
+  }
+}