minor formatting cleanup

This commit is contained in:
Eugen Paraschiv
2019-01-27 14:25:36 +02:00
parent 8ccec9a413
commit 2e733c3867
18 changed files with 122 additions and 132 deletions
@@ -9,21 +9,21 @@ import static org.mockito.Mockito.mock;
public class AuthorEventHandlerUnitTest {
@Test
public void whenCreateAuthorThenSuccess() {
Author author = mock(Author.class);
AuthorEventHandler authorEventHandler = new AuthorEventHandler();
authorEventHandler.handleAuthorBeforeCreate(author);
Mockito.verify(author,Mockito.times(1)).getName();
@Test
public void whenCreateAuthorThenSuccess() {
Author author = mock(Author.class);
AuthorEventHandler authorEventHandler = new AuthorEventHandler();
authorEventHandler.handleAuthorBeforeCreate(author);
Mockito.verify(author, Mockito.times(1)).getName();
}
}
@Test
public void whenDeleteAuthorThenSuccess() {
Author author = mock(Author.class);
AuthorEventHandler authorEventHandler = new AuthorEventHandler();
authorEventHandler.handleAuthorAfterDelete(author);
Mockito.verify(author,Mockito.times(1)).getName();
@Test
public void whenDeleteAuthorThenSuccess() {
Author author = mock(Author.class);
AuthorEventHandler authorEventHandler = new AuthorEventHandler();
authorEventHandler.handleAuthorAfterDelete(author);
Mockito.verify(author, Mockito.times(1)).getName();
}
}
}
@@ -8,21 +8,21 @@ import org.mockito.Mockito;
import static org.mockito.Mockito.mock;
public class BookEventHandlerUnitTest {
@Test
public void whenCreateBookThenSuccess() {
Book book = mock(Book.class);
BookEventHandler bookEventHandler = new BookEventHandler();
bookEventHandler.handleBookBeforeCreate(book);
Mockito.verify(book,Mockito.times(1)).getAuthors();
@Test
public void whenCreateBookThenSuccess() {
Book book = mock(Book.class);
BookEventHandler bookEventHandler = new BookEventHandler();
bookEventHandler.handleBookBeforeCreate(book);
Mockito.verify(book, Mockito.times(1)).getAuthors();
}
}
@Test
public void whenCreateAuthorThenSuccess() {
Author author = mock(Author.class);
BookEventHandler bookEventHandler = new BookEventHandler();
bookEventHandler.handleAuthorBeforeCreate(author);
Mockito.verify(author,Mockito.times(1)).getBooks();
@Test
public void whenCreateAuthorThenSuccess() {
Author author = mock(Author.class);
BookEventHandler bookEventHandler = new BookEventHandler();
bookEventHandler.handleAuthorBeforeCreate(author);
Mockito.verify(author, Mockito.times(1)).getBooks();
}
}
}
@@ -29,16 +29,15 @@ public class SpringDataProjectionLiveTest {
private static final String BOOK_ENDPOINT = "http://localhost:8080/books";
private static final String AUTHOR_ENDPOINT = "http://localhost:8080/authors";
@Autowired
private BookRepository bookRepo;
@Autowired
private AuthorRepository authorRepo;
@Before
public void setup(){
if(bookRepo.findById(1L) == null){
public void setup() {
if (bookRepo.findById(1L) == null) {
Book book = new Book("Animal Farm");
book.setIsbn("978-1943138425");
book = bookRepo.save(book);
@@ -48,45 +47,44 @@ public class SpringDataProjectionLiveTest {
author = authorRepo.save(author);
}
}
@Test
public void whenGetBook_thenOK(){
final Response response = RestAssured.get(BOOK_ENDPOINT+"/1");
public void whenGetBook_thenOK() {
final Response response = RestAssured.get(BOOK_ENDPOINT + "/1");
assertEquals(200, response.getStatusCode());
assertTrue(response.asString().contains("isbn"));
assertFalse(response.asString().contains("authorCount"));
// System.out.println(response.asString());
// System.out.println(response.asString());
}
@Test
public void whenGetBookProjection_thenOK(){
final Response response = RestAssured.get(BOOK_ENDPOINT+"/1?projection=customBook");
public void whenGetBookProjection_thenOK() {
final Response response = RestAssured.get(BOOK_ENDPOINT + "/1?projection=customBook");
assertEquals(200, response.getStatusCode());
assertFalse(response.asString().contains("isbn"));
assertTrue(response.asString().contains("authorCount"));
// System.out.println(response.asString());
assertTrue(response.asString().contains("authorCount"));
// System.out.println(response.asString());
}
@Test
public void whenGetAllBooks_thenOK(){
public void whenGetAllBooks_thenOK() {
final Response response = RestAssured.get(BOOK_ENDPOINT);
assertEquals(200, response.getStatusCode());
assertFalse(response.asString().contains("isbn"));
assertTrue(response.asString().contains("authorCount"));
// System.out.println(response.asString());
assertTrue(response.asString().contains("authorCount"));
// System.out.println(response.asString());
}
@Test
public void whenGetAuthorBooks_thenOK(){
final Response response = RestAssured.get(AUTHOR_ENDPOINT+"/1/books");
public void whenGetAuthorBooks_thenOK() {
final Response response = RestAssured.get(AUTHOR_ENDPOINT + "/1/books");
assertEquals(200, response.getStatusCode());
assertFalse(response.asString().contains("isbn"));
assertTrue(response.asString().contains("authorCount"));
assertTrue(response.asString().contains("authorCount"));
System.out.println(response.asString());
}
}