diff --git a/feign-client/src/main/java/com/baeldung/feign/Controller.java b/feign-client/src/main/java/com/baeldung/feign/BookControllerFeignClientBuilder.java similarity index 93% rename from feign-client/src/main/java/com/baeldung/feign/Controller.java rename to feign-client/src/main/java/com/baeldung/feign/BookControllerFeignClientBuilder.java index f5405be87a..9c0c359d88 100644 --- a/feign-client/src/main/java/com/baeldung/feign/Controller.java +++ b/feign-client/src/main/java/com/baeldung/feign/BookControllerFeignClientBuilder.java @@ -10,7 +10,7 @@ import feign.slf4j.Slf4jLogger; import lombok.Getter; @Getter -public class Controller { +public class BookControllerFeignClientBuilder { private BookClient bookClient = createClient(BookClient.class, "http://localhost:8081/api/books"); diff --git a/feign-client/src/test/java/com/baeldung/feign/clients/BookClientTest.java b/feign-client/src/test/java/com/baeldung/feign/clients/BookClientTest.java index 37f91c5b51..fa470cd0a0 100644 --- a/feign-client/src/test/java/com/baeldung/feign/clients/BookClientTest.java +++ b/feign-client/src/test/java/com/baeldung/feign/clients/BookClientTest.java @@ -1,9 +1,10 @@ package com.baeldung.feign.clients; -import com.baeldung.feign.Controller; +import com.baeldung.feign.BookControllerFeignClientBuilder; import com.baeldung.feign.models.Book; import com.baeldung.feign.models.BookResource; import lombok.extern.slf4j.Slf4j; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -20,11 +21,16 @@ import static org.junit.Assert.assertTrue; @Slf4j @RunWith(JUnit4.class) public class BookClientTest { - private Controller controller = new Controller(); + private BookControllerFeignClientBuilder feignClientBuilder; + + @Before + public void setup() { + feignClientBuilder = new BookControllerFeignClientBuilder(); + } @Test public void givenBookClient_shouldRunSuccessfully() throws Exception { - BookClient bookClient = controller.getBookClient(); + BookClient bookClient = feignClientBuilder.getBookClient(); List books = bookClient.findAll().stream() .map(BookResource::getBook) .collect(Collectors.toList()); @@ -34,7 +40,7 @@ public class BookClientTest { @Test public void givenBookClient_shouldFindOneBook() throws Exception { - BookClient bookClient = controller.getBookClient(); + BookClient bookClient = feignClientBuilder.getBookClient(); Book book = bookClient.findByIsbn("0151072558").getBook(); assertThat(book.getAuthor(), containsString("Orwell")); log.info("{}", book); @@ -42,7 +48,7 @@ public class BookClientTest { @Test public void givenBookClient_shouldPostBook() throws Exception { - BookClient bookClient = controller.getBookClient(); + BookClient bookClient = feignClientBuilder.getBookClient(); String isbn = UUID.randomUUID().toString(); Book book = new Book(isbn, "Me", "It's me!", null, null); bookClient.create(book);