// Path: spanners-mvc/src/main/java/org/dontpanic/spanners/springmvc/domain/Spanner.java
// public class Spanner {
// 
//     private Long id;
//     private String name;
//     private int size;
//     private String owner;
// 
//     public Long getId() {
//         return id;
//     }
// 
//     public void setId(Long id) {
//         this.id = id;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public void setName(String name) {
//         this.name = name;
//     }
// 
//     public int getSize() {
//         return size;
//     }
// 
//     public void setSize(int size) {
//         this.size = size;
//     }
// 
//     public String getOwner() {
//         return owner;
//     }
// 
//     public void setOwner(String owner) {
//         this.owner = owner;
//     }
// }
// 
// Path: spanners-mvc/src/test/java/org/dontpanic/spanners/springmvc/stubs/SpannerAssert.java
// public static void assertSpanner(String expectedName, int expectedSize, String expectedOwner, Spanner actual) {
//     assertNotNull("Spanner is null", actual);
//     assertEquals("spanner name", expectedName, actual.getName());
//     assertEquals("spanner size", expectedSize, actual.getSize());
//     assertEquals("spanner owner", expectedOwner, actual.getOwner());
// }
// 
// Path: spanners-mvc/src/test/java/org/dontpanic/spanners/springmvc/stubs/SpannerBuilder.java
// public static SpannerBuilder aSpanner() {
// 	return new SpannerBuilder();
// }


import org.dontpanic.spanners.springmvc.domain.Spanner;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.client.RestClientTest;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.client.MockRestServiceServer;
import org.springframework.test.web.client.ResponseCreator;
import java.util.Collection;
import static org.dontpanic.spanners.springmvc.stubs.SpannerAssert.assertSpanner;
import static org.dontpanic.spanners.springmvc.stubs.SpannerBuilder.aSpanner;
import static org.hamcrest.Matchers.hasSize;
import static org.junit.Assert.assertThat;
import static org.springframework.http.HttpMethod.*;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
package org.dontpanic.spanners.springmvc.services;




/**
 * Test for Spanners REST service client
 * Created by stevie on 09/06/16.
 */
@RunWith(SpringRunner.class)
@RestClientTest(SpannersService.class)
public class SpannersServiceTest {

    private static final MediaType APPLICATION_HAL_JSON = MediaType.valueOf("application/hal+json;charset=UTF-8");

    @Autowired
    private MockRestServiceServer server;
    @Autowired
    private SpannersService service;

    @Test
    public void testFindAll() throws Exception {

        server.expect(requestTo("/")).andExpect(method(GET))
                .andRespond(withHalJsonResponse("/spannersGET.txt"));

        Collection<Spanner> spanners = service.findAll();
        assertThat(spanners, hasSize(2));
    }


    @Test
    public void testFindOne() throws Exception {

        server.expect(requestTo("/1")).andExpect(method(GET))
                .andRespond(withHalJsonResponse("/spanner1GET.txt"));

        Spanner spanner = service.findOne(1L);
// Path: spanners-mvc/src/main/java/org/dontpanic/spanners/springmvc/domain/Spanner.java
// public class Spanner {
// 
//     private Long id;
//     private String name;
//     private int size;
//     private String owner;
// 
//     public Long getId() {
//         return id;
//     }
// 
//     public void setId(Long id) {
//         this.id = id;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public void setName(String name) {
//         this.name = name;
//     }
// 
//     public int getSize() {
//         return size;
//     }
// 
//     public void setSize(int size) {
//         this.size = size;
//     }
// 
//     public String getOwner() {
//         return owner;
//     }
// 
//     public void setOwner(String owner) {
//         this.owner = owner;
//     }
// }
// 
// Path: spanners-mvc/src/test/java/org/dontpanic/spanners/springmvc/stubs/SpannerAssert.java
// public static void assertSpanner(String expectedName, int expectedSize, String expectedOwner, Spanner actual) {
//     assertNotNull("Spanner is null", actual);
//     assertEquals("spanner name", expectedName, actual.getName());
//     assertEquals("spanner size", expectedSize, actual.getSize());
//     assertEquals("spanner owner", expectedOwner, actual.getOwner());
// }
// 
// Path: spanners-mvc/src/test/java/org/dontpanic/spanners/springmvc/stubs/SpannerBuilder.java
// public static SpannerBuilder aSpanner() {
// 	return new SpannerBuilder();
// }


// Path: spanners-mvc/src/test/java/org/dontpanic/spanners/springmvc/services/SpannersServiceTest.java
import org.dontpanic.spanners.springmvc.domain.Spanner;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.client.RestClientTest;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.client.MockRestServiceServer;
import org.springframework.test.web.client.ResponseCreator;
import java.util.Collection;
import static org.dontpanic.spanners.springmvc.stubs.SpannerAssert.assertSpanner;
import static org.dontpanic.spanners.springmvc.stubs.SpannerBuilder.aSpanner;
import static org.hamcrest.Matchers.hasSize;
import static org.junit.Assert.assertThat;
import static org.springframework.http.HttpMethod.*;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;

package org.dontpanic.spanners.springmvc.services;




/**
 * Test for Spanners REST service client
 * Created by stevie on 09/06/16.
 */
@RunWith(SpringRunner.class)
@RestClientTest(SpannersService.class)
public class SpannersServiceTest {

    private static final MediaType APPLICATION_HAL_JSON = MediaType.valueOf("application/hal+json;charset=UTF-8");

    @Autowired
    private MockRestServiceServer server;
    @Autowired
    private SpannersService service;

    @Test
    public void testFindAll() throws Exception {

        server.expect(requestTo("/")).andExpect(method(GET))
                .andRespond(withHalJsonResponse("/spannersGET.txt"));

        Collection<Spanner> spanners = service.findAll();
        assertThat(spanners, hasSize(2));
    }


    @Test
    public void testFindOne() throws Exception {

        server.expect(requestTo("/1")).andExpect(method(GET))
                .andRespond(withHalJsonResponse("/spanner1GET.txt"));

        Spanner spanner = service.findOne(1L);
        assertSpanner("Belinda", 10, "jones", spanner);