19
19
import static org .mockito .ArgumentMatchers .eq ;
20
20
import static org .mockito .Mockito .doThrow ;
21
21
import static org .mockito .Mockito .mock ;
22
+ import static org .mockito .Mockito .verify ;
23
+ import static org .mockito .Mockito .verifyNoInteractions ;
22
24
import static org .mockito .Mockito .when ;
23
25
import static tech .pegasys .teku .infrastructure .http .HttpStatusCodes .SC_BAD_REQUEST ;
24
26
import static tech .pegasys .teku .infrastructure .http .HttpStatusCodes .SC_FORBIDDEN ;
@@ -67,6 +69,7 @@ void shouldSuccessfullySetGraffiti() throws IOException {
67
69
68
70
handler .handleRequest (request );
69
71
72
+ verify (graffitiManager ).setGraffiti (eq (publicKey ), eq (graffiti ));
70
73
assertThat (request .getResponseCode ()).isEqualTo (SC_NO_CONTENT );
71
74
assertThat (request .getResponseBody ()).isNull ();
72
75
}
@@ -81,6 +84,7 @@ void shouldReturnErrorWhenIssueSetting() throws IOException {
81
84
82
85
handler .handleRequest (request );
83
86
87
+ verify (graffitiManager ).setGraffiti (eq (publicKey ), eq (graffiti ));
84
88
assertThat (request .getResponseCode ()).isEqualTo (SC_INTERNAL_SERVER_ERROR );
85
89
assertThat (request .getResponseBody ())
86
90
.isEqualTo (
@@ -105,14 +109,16 @@ void shouldThrowExceptionWhenInvalidGraffitiInput() throws IOException {
105
109
assertThatThrownBy (() -> handler .handleRequest (request ))
106
110
.isInstanceOf (IllegalArgumentException .class )
107
111
.hasMessage (errorMessage );
112
+ verify (graffitiManager ).setGraffiti (eq (publicKey ), eq (invalidGraffiti ));
108
113
}
109
114
110
115
@ Test
111
- void shouldRespondNotFoundWhenNoValidator () throws JsonProcessingException {
116
+ void shouldRespondNotFoundWhenNoValidator () throws IOException {
112
117
when (keyManager .getValidatorByPublicKey (any ())).thenReturn (Optional .empty ());
113
118
114
119
handler .handleRequest (request );
115
120
121
+ verifyNoInteractions (graffitiManager );
116
122
assertThat (request .getResponseCode ()).isEqualTo (SC_NOT_FOUND );
117
123
}
118
124
0 commit comments