@ -30,9 +30,9 @@ import static org.assertj.core.api.Assertions.assertThat;
@@ -30,9 +30,9 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIOException ;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException ;
import static org.mockito.ArgumentMatchers.any ;
import static org.mockito.ArgumentMatchers.anySet ;
import static org.mockito.BDDMockito.willThrow ;
import static org.mockito.Mockito.mock ;
import static org.mockito.Mockito.times ;
import static org.mockito.Mockito.verify ;
import static org.mockito.Mockito.verifyNoMoreInteractions ;
@ -52,34 +52,33 @@ public class ResponseBodyEmitterTests {
@@ -52,34 +52,33 @@ public class ResponseBodyEmitterTests {
@Test
public void sendBeforeHandlerInitialized ( ) throws Exception {
void sendBeforeHandlerInitialized ( ) throws Exception {
this . emitter . send ( "foo" , MediaType . TEXT_PLAIN ) ;
this . emitter . send ( "bar" , MediaType . TEXT_PLAIN ) ;
this . emitter . complete ( ) ;
verifyNoMoreInteractions ( this . handler ) ;
this . emitter . initialize ( this . handler ) ;
verify ( this . handler ) . send ( "foo" , MediaType . TEXT_PLAIN ) ;
verify ( this . handler ) . send ( "bar" , MediaType . TEXT_PLAIN ) ;
verify ( this . handler ) . send ( anySet ( ) ) ;
verify ( this . handler ) . complete ( ) ;
verifyNoMoreInteractions ( this . handler ) ;
}
@Test
public void sendDuplicateBeforeHandlerInitialized ( ) throws Exception {
void sendDuplicateBeforeHandlerInitialized ( ) throws Exception {
this . emitter . send ( "foo" , MediaType . TEXT_PLAIN ) ;
this . emitter . send ( "foo" , MediaType . TEXT_PLAIN ) ;
this . emitter . complete ( ) ;
verifyNoMoreInteractions ( this . handler ) ;
this . emitter . initialize ( this . handler ) ;
verify ( this . handler , times ( 2 ) ) . send ( "foo" , MediaType . TEXT_PLAIN ) ;
verify ( this . handler ) . send ( anySet ( ) ) ;
verify ( this . handler ) . complete ( ) ;
verifyNoMoreInteractions ( this . handler ) ;
}
@Test
public void sendBeforeHandlerInitializedWithError ( ) throws Exception {
void sendBeforeHandlerInitializedWithError ( ) throws Exception {
IllegalStateException ex = new IllegalStateException ( ) ;
this . emitter . send ( "foo" , MediaType . TEXT_PLAIN ) ;
this . emitter . send ( "bar" , MediaType . TEXT_PLAIN ) ;
@ -87,21 +86,20 @@ public class ResponseBodyEmitterTests {
@@ -87,21 +86,20 @@ public class ResponseBodyEmitterTests {
verifyNoMoreInteractions ( this . handler ) ;
this . emitter . initialize ( this . handler ) ;
verify ( this . handler ) . send ( "foo" , MediaType . TEXT_PLAIN ) ;
verify ( this . handler ) . send ( "bar" , MediaType . TEXT_PLAIN ) ;
verify ( this . handler ) . send ( anySet ( ) ) ;
verify ( this . handler ) . completeWithError ( ex ) ;
verifyNoMoreInteractions ( this . handler ) ;
}
@Test
public void sendFailsAfterComplete ( ) throws Exception {
void sendFailsAfterComplete ( ) throws Exception {
this . emitter . complete ( ) ;
assertThatIllegalStateException ( ) . isThrownBy ( ( ) - >
this . emitter . send ( "foo" ) ) ;
}
@Test
public void sendAfterHandlerInitialized ( ) throws Exception {
void sendAfterHandlerInitialized ( ) throws Exception {
this . emitter . initialize ( this . handler ) ;
verify ( this . handler ) . onTimeout ( any ( ) ) ;
verify ( this . handler ) . onError ( any ( ) ) ;
@ -119,7 +117,7 @@ public class ResponseBodyEmitterTests {
@@ -119,7 +117,7 @@ public class ResponseBodyEmitterTests {
}
@Test
public void sendAfterHandlerInitializedWithError ( ) throws Exception {
void sendAfterHandlerInitializedWithError ( ) throws Exception {
this . emitter . initialize ( this . handler ) ;
verify ( this . handler ) . onTimeout ( any ( ) ) ;
verify ( this . handler ) . onError ( any ( ) ) ;
@ -138,7 +136,7 @@ public class ResponseBodyEmitterTests {
@@ -138,7 +136,7 @@ public class ResponseBodyEmitterTests {
}
@Test
public void sendWithError ( ) throws Exception {
void sendWithError ( ) throws Exception {
this . emitter . initialize ( this . handler ) ;
verify ( this . handler ) . onTimeout ( any ( ) ) ;
verify ( this . handler ) . onError ( any ( ) ) ;
@ -154,7 +152,7 @@ public class ResponseBodyEmitterTests {
@@ -154,7 +152,7 @@ public class ResponseBodyEmitterTests {
}
@Test
public void onTimeoutBeforeHandlerInitialized ( ) throws Exception {
void onTimeoutBeforeHandlerInitialized ( ) throws Exception {
Runnable runnable = mock ( ) ;
this . emitter . onTimeout ( runnable ) ;
this . emitter . initialize ( this . handler ) ;
@ -169,7 +167,7 @@ public class ResponseBodyEmitterTests {
@@ -169,7 +167,7 @@ public class ResponseBodyEmitterTests {
}
@Test
public void onTimeoutAfterHandlerInitialized ( ) throws Exception {
void onTimeoutAfterHandlerInitialized ( ) throws Exception {
this . emitter . initialize ( this . handler ) ;
ArgumentCaptor < Runnable > captor = ArgumentCaptor . forClass ( Runnable . class ) ;
@ -185,7 +183,7 @@ public class ResponseBodyEmitterTests {
@@ -185,7 +183,7 @@ public class ResponseBodyEmitterTests {
}
@Test
public void onCompletionBeforeHandlerInitialized ( ) throws Exception {
void onCompletionBeforeHandlerInitialized ( ) throws Exception {
Runnable runnable = mock ( ) ;
this . emitter . onCompletion ( runnable ) ;
this . emitter . initialize ( this . handler ) ;
@ -200,7 +198,7 @@ public class ResponseBodyEmitterTests {
@@ -200,7 +198,7 @@ public class ResponseBodyEmitterTests {
}
@Test
public void onCompletionAfterHandlerInitialized ( ) throws Exception {
void onCompletionAfterHandlerInitialized ( ) throws Exception {
this . emitter . initialize ( this . handler ) ;
ArgumentCaptor < Runnable > captor = ArgumentCaptor . forClass ( Runnable . class ) ;