package com.mollie.api;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

public class ApiTest {
	private static String API_KEY = "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM";

	protected MollieClient api;

	@Rule
	public ExpectedException thrown = ExpectedException.none();

	@Before
	public void setUp() throws Exception {
		api = new MollieClient();
		api.setApiKey(API_KEY);
	}

	@Test
	public void testInvalidApiKeyFails() throws MollieException
	{
		thrown.expect(MollieException.class);
		thrown.expectMessage("Invalid api key: \"invalid\". An API key must start with \"test_\" or \"live_\".");
		api.setApiKey("invalid");
	}
}
@@ -18,16 +18,84 @@
 e.api;%0A%0A
+import static org.mockito.Mockito.*;%0A%0Aimport java.math.BigDecimal;%0A%0A
 import o
@@ -111,16 +111,16 @@
 Before;%0A
-
 import o
@@ -452,16 +452,20 @@
 %09%09api = 
+spy(
 new Moll
@@ -474,18 +474,96 @@
 Client()
+)
 ;%0A
+%09%09api.initResources(api); // make sure the resources also get the spied api%0A%0A
 %09%09api.se
@@ -655,16 +655,44 @@
 tion%0A%09%7B%0A
+%09%09api = new MollieClient();%0A
 %09%09thrown
@@ -831,16 +831,16 @@
 _%5C%22.%22);%0A
-
 %09%09api.se
@@ -861,10 +861,540 @@
 id%22);%0A%09%7D
+%0A%0A%09@Test%0A%09public void testCreatePaymentFailsEmptyHttpBody() throws MollieException%0A%09%7B%0A%09%09thrown.expect(MollieException.class);%0A%09%09thrown.expectMessage(%22Unable to decode Mollie response: %5C%22%5C%22%22);%0A%0A%09%09doReturn(%22%22).when(api).performHttpCall(MollieClient.HTTP_POST, %22payments%22, %22%7B%5C%22amount%5C%22:100,%5C%22redirectUrl%5C%22:%5C%22http://www.chucknorris.rhk/return.php%5C%22,%5C%22description%5C%22:%5C%22Order #1337 24 Roundhousekicks%5C%22%7D%22);%0A%0A%09%09api.payments().create(new BigDecimal(100), %22Order #1337 24 Roundhousekicks%22, %22http://www.chucknorris.rhk/return.php%22, null);%0A%09%7D
 %0A%7D

Add empty body payment test result