Minor refactorings and code style changes (#807)
* Made minor changes in some patterns such as removed throws clause where not needed, changed incorrect order of arguments in assertEquals * Minor refactorings and code style changes. 1) Removed several use of raw types 2) Removed unnecessary throws clauses 3) Used lambda expressions wherever applicable 4) Used apt assertion methods for readability 5) Use of try with resources wherever applicable 6) Corrected incorrect order of assertXXX arguments * Removed unused import from Promise * Addressed review comments * Addressed checkstyle issue
This commit is contained in:
@ -34,7 +34,7 @@ import java.util.concurrent.ExecutionException;
|
||||
public class AppTest {
|
||||
|
||||
@Test
|
||||
public void test() throws InterruptedException, ExecutionException {
|
||||
public void test() {
|
||||
App.main(null);
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
*/
|
||||
package com.iluwatar.halfsynchalfasync;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.InOrder;
|
||||
|
||||
@ -44,11 +45,17 @@ import static org.mockito.Mockito.when;
|
||||
* @author Jeroen Meulemeester
|
||||
*/
|
||||
public class AsynchronousServiceTest {
|
||||
private AsynchronousService service;
|
||||
private AsyncTask<Object> task;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
service = new AsynchronousService(new LinkedBlockingQueue<>());
|
||||
task = mock(AsyncTask.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPerfectExecution() throws Exception {
|
||||
final AsynchronousService service = new AsynchronousService(new LinkedBlockingQueue<>());
|
||||
final AsyncTask<Object> task = mock(AsyncTask.class);
|
||||
final Object result = new Object();
|
||||
when(task.call()).thenReturn(result);
|
||||
service.execute(task);
|
||||
@ -65,8 +72,6 @@ public class AsynchronousServiceTest {
|
||||
|
||||
@Test
|
||||
public void testCallException() throws Exception {
|
||||
final AsynchronousService service = new AsynchronousService(new LinkedBlockingQueue<>());
|
||||
final AsyncTask<Object> task = mock(AsyncTask.class);
|
||||
final IOException exception = new IOException();
|
||||
when(task.call()).thenThrow(exception);
|
||||
service.execute(task);
|
||||
@ -82,9 +87,7 @@ public class AsynchronousServiceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPreCallException() throws Exception {
|
||||
final AsynchronousService service = new AsynchronousService(new LinkedBlockingQueue<>());
|
||||
final AsyncTask<Object> task = mock(AsyncTask.class);
|
||||
public void testPreCallException() {
|
||||
final IllegalStateException exception = new IllegalStateException();
|
||||
doThrow(exception).when(task).onPreCall();
|
||||
service.execute(task);
|
||||
|
Reference in New Issue
Block a user