BAEL-11: Minor refactorings

This commit is contained in:
slavisa-baeldung 2016-09-15 12:23:14 +02:00
parent 499d51e610
commit ef3b18a717
1 changed files with 3 additions and 5 deletions

View File

@ -21,16 +21,16 @@ import static org.junit.Assert.assertTrue;
@Slf4j @Slf4j
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
public class BookClientTest { public class BookClientTest {
private BookControllerFeignClientBuilder feignClientBuilder; private BookClient bookClient;
@Before @Before
public void setup() { public void setup() {
feignClientBuilder = new BookControllerFeignClientBuilder(); BookControllerFeignClientBuilder feignClientBuilder = new BookControllerFeignClientBuilder();
bookClient = feignClientBuilder.getBookClient();
} }
@Test @Test
public void givenBookClient_shouldRunSuccessfully() throws Exception { public void givenBookClient_shouldRunSuccessfully() throws Exception {
BookClient bookClient = feignClientBuilder.getBookClient();
List<Book> books = bookClient.findAll().stream() List<Book> books = bookClient.findAll().stream()
.map(BookResource::getBook) .map(BookResource::getBook)
.collect(Collectors.toList()); .collect(Collectors.toList());
@ -40,7 +40,6 @@ public class BookClientTest {
@Test @Test
public void givenBookClient_shouldFindOneBook() throws Exception { public void givenBookClient_shouldFindOneBook() throws Exception {
BookClient bookClient = feignClientBuilder.getBookClient();
Book book = bookClient.findByIsbn("0151072558").getBook(); Book book = bookClient.findByIsbn("0151072558").getBook();
assertThat(book.getAuthor(), containsString("Orwell")); assertThat(book.getAuthor(), containsString("Orwell"));
log.info("{}", book); log.info("{}", book);
@ -48,7 +47,6 @@ public class BookClientTest {
@Test @Test
public void givenBookClient_shouldPostBook() throws Exception { public void givenBookClient_shouldPostBook() throws Exception {
BookClient bookClient = feignClientBuilder.getBookClient();
String isbn = UUID.randomUUID().toString(); String isbn = UUID.randomUUID().toString();
Book book = new Book(isbn, "Me", "It's me!", null, null); Book book = new Book(isbn, "Me", "It's me!", null, null);
bookClient.create(book); bookClient.create(book);