package com.example.client;

import static org.junit.Assert.assertEquals;

import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.web.client.HttpClientErrorException;

import com.epages.wiremock.starter.WireMockTest;

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = { ClientApplication.class })
@ActiveProfiles("test")
@WireMockTest(stubPath = "wiremock/restdocs-server")
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class NoteServiceTest {

	@Autowired
	private NoteService noteService;

	@Test
	@WireMockTest(stubPath = "wiremock/restdocs-server/mappings/note-get-example")
	public void should_1_use_dedicated_wiremock_stub() {
		assertEquals("REST maturity model", noteService.getNote("1").getTitle());
	}

	@Test(expected = HttpClientErrorException.class)
	@WireMockTest(stubPath = "wiremock/restdocs-server/mappings/note-badrequest-example")
	public void should_2_use_different_wiremock_stub() {
		noteService.getNote("xy");
	}

	@Test
	public void should_3_use_default_wiremock_stubs() {
		assertEquals("REST maturity model", noteService.getNote("1").getTitle());
	}

}

@@ -1470,10 +1470,285 @@
 ));%0A%09%7D%0A%0A
+%09@Test(expected = HttpClientErrorException.class)%0A%09@WireMockTest(stubPath = %22wiremock/restdocs-server/mappings/note-badrequest-example%22)%0A%09public void should_4_not_find_excluded_wiremock_stub() %7B%0A%09%09assertEquals(%22REST maturity model%22, noteService.getNote(%221%22).getTitle());%0A%09%7D%0A%0A
 %7D%0A

Add test for a negative-match in wiremock-client test.