From cf7947ea84c2786dbf48f7002193f166b70f8595 Mon Sep 17 00:00:00 2001 From: Mats Stijlaart Date: Wed, 26 Oct 2016 11:26:24 +0200 Subject: [PATCH] #19: Move tests to concepts package and change PUT to POST --- .../nl/stil4m/mollie/concepts/Customers.java | 7 +++---- .../CustomerPaymentsIntegrationTest.java | 10 ++++++---- .../CustomersIntegrationTest.java} | 18 +++++++++++------- 3 files changed, 20 insertions(+), 15 deletions(-) rename src/test/java/nl/stil4m/mollie/{ => concepts}/CustomerPaymentsIntegrationTest.java (87%) rename src/test/java/nl/stil4m/mollie/{CustomersIntegerationTest.java => concepts/CustomersIntegrationTest.java} (86%) diff --git a/src/main/java/nl/stil4m/mollie/concepts/Customers.java b/src/main/java/nl/stil4m/mollie/concepts/Customers.java index a3436ca..5c9183b 100644 --- a/src/main/java/nl/stil4m/mollie/concepts/Customers.java +++ b/src/main/java/nl/stil4m/mollie/concepts/Customers.java @@ -46,10 +46,9 @@ public ResponseOrError create(CreateCustomer createCustomer) throws IO } public ResponseOrError update(String customerId, UpdateCustomer updateCustomer) throws IOException { - HttpPut httpPut = new HttpPut(endpoint + "/customers/" + customerId); - System.out.println(requestExecutor.serialize(updateCustomer)); - httpPut.setEntity(new StringEntity(requestExecutor.serialize(updateCustomer), ContentType.APPLICATION_JSON)); - return requestExecutor.execute(apiKey, httpPut, new TypeReference() { + HttpPost httpPost = new HttpPost(endpoint + "/customers/" + customerId); + httpPost.setEntity(new StringEntity(requestExecutor.serialize(updateCustomer), ContentType.APPLICATION_JSON)); + return requestExecutor.execute(apiKey, httpPost, new TypeReference() { }); } diff --git a/src/test/java/nl/stil4m/mollie/CustomerPaymentsIntegrationTest.java b/src/test/java/nl/stil4m/mollie/concepts/CustomerPaymentsIntegrationTest.java similarity index 87% rename from src/test/java/nl/stil4m/mollie/CustomerPaymentsIntegrationTest.java rename to src/test/java/nl/stil4m/mollie/concepts/CustomerPaymentsIntegrationTest.java index b912a22..a9c3d47 100644 --- a/src/test/java/nl/stil4m/mollie/CustomerPaymentsIntegrationTest.java +++ b/src/test/java/nl/stil4m/mollie/concepts/CustomerPaymentsIntegrationTest.java @@ -1,5 +1,8 @@ -package nl.stil4m.mollie; +package nl.stil4m.mollie.concepts; +import nl.stil4m.mollie.Client; +import nl.stil4m.mollie.ClientBuilder; +import nl.stil4m.mollie.ResponseOrError; import nl.stil4m.mollie.domain.CreateCustomer; import nl.stil4m.mollie.domain.CreatePayment; import nl.stil4m.mollie.domain.Customer; @@ -25,7 +28,6 @@ public class CustomerPaymentsIntegrationTest { private Client client; - private Map defaultMetadata; private Customer customer; @Before @@ -33,12 +35,12 @@ public void before() throws InterruptedException, IOException { Thread.sleep(TEST_TIMEOUT); client = new ClientBuilder().withApiKey(VALID_API_KEY).build(); - defaultMetadata = new HashMap<>(); + Map defaultMetadata = new HashMap<>(); defaultMetadata.put("foo", "bar"); String uuid = UUID.randomUUID().toString(); String name = "Test Customer " + uuid; - customer = client.customers().create(new CreateCustomer(name, "test@foobar.com", Optional.empty(), null)).getData(); + customer = client.customers().create(new CreateCustomer(name, "test@foobar.com", Optional.empty(), defaultMetadata)).getData(); } @Test diff --git a/src/test/java/nl/stil4m/mollie/CustomersIntegerationTest.java b/src/test/java/nl/stil4m/mollie/concepts/CustomersIntegrationTest.java similarity index 86% rename from src/test/java/nl/stil4m/mollie/CustomersIntegerationTest.java rename to src/test/java/nl/stil4m/mollie/concepts/CustomersIntegrationTest.java index 2d3f050..8a0a970 100644 --- a/src/test/java/nl/stil4m/mollie/CustomersIntegerationTest.java +++ b/src/test/java/nl/stil4m/mollie/concepts/CustomersIntegrationTest.java @@ -1,5 +1,8 @@ -package nl.stil4m.mollie; +package nl.stil4m.mollie.concepts; +import nl.stil4m.mollie.Client; +import nl.stil4m.mollie.ClientBuilder; +import nl.stil4m.mollie.ResponseOrError; import nl.stil4m.mollie.domain.CreateCustomer; import nl.stil4m.mollie.domain.Customer; import nl.stil4m.mollie.domain.Page; @@ -19,10 +22,10 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; -public class CustomersIntegerationTest { +public class CustomersIntegrationTest { private Client client; - private Map defaultMetadata; + private Map defaultMetadata; @Before public void before() throws InterruptedException { @@ -57,22 +60,23 @@ public void testCreateCustomer() throws IOException, URISyntaxException { } @Test - public void testGetCustomer() throws IOException, URISyntaxException { + public void testGetCustomer() throws IOException, URISyntaxException { String uuid = UUID.randomUUID().toString(); - String originalName= "Test Customer " + uuid; + String originalName = "Test Customer " + uuid; ResponseOrError createdCustomer = client.customers().create(new CreateCustomer(originalName, "test@foobar.nl", Optional.empty(), defaultMetadata)); ResponseOrError fetchedCustomer = client.customers().get(createdCustomer.getData().getId()); - assertThat(fetchedCustomer.getData().getName(),is(originalName)); + assertThat(fetchedCustomer.getData().getName(), is(originalName)); //TODO Expand } + @Test public void testUpdateCustomer() throws IOException, URISyntaxException { String uuid = UUID.randomUUID().toString(); String uuid2 = UUID.randomUUID().toString(); String originalName = "Test Customer " + uuid; String newName = "Test Customer " + uuid2; - ResponseOrError createdCustomer = client.customers().create(new CreateCustomer(originalName, "test@foobar.nl", Optional.empty(), null)); + ResponseOrError createdCustomer = client.customers().create(new CreateCustomer(originalName, "test@foobar.nl", Optional.empty(), null)); ResponseOrError update = client.customers().update(createdCustomer.getData().getId(), new UpdateCustomer( Optional.of(newName),