16
16
import static org .assertj .core .api .Assertions .assertThat ;
17
17
import static org .assertj .core .api .Assertions .assertThatThrownBy ;
18
18
import static org .assertj .core .api .Assertions .fail ;
19
+ import static org .junit .jupiter .api .Assertions .assertDoesNotThrow ;
19
20
import static tech .pegasys .teku .validator .api .GraffitiManager .GRAFFITI_DIR ;
20
21
21
22
import java .io .File ;
@@ -105,14 +106,12 @@ void setGraffiti_shouldThrowExceptionWhenGraffitiTooBig(@TempDir final Path temp
105
106
}
106
107
107
108
@ Test
108
- void deleteGraffiti_shouldThrowIllegalArgumentWhenNoGraffitiToDelete (
109
- @ TempDir final Path tempDir ) {
109
+ void deleteGraffiti_shouldSucceedWhenNoGraffitiToDelete (@ TempDir final Path tempDir ) {
110
110
dataDirLayout = new SimpleDataDirLayout (tempDir );
111
111
manager = new GraffitiManager (dataDirLayout );
112
112
assertThat (getGraffitiManagementDir ().toFile ().exists ()).isTrue ();
113
- assertThatThrownBy (() -> manager .deleteGraffiti (publicKey ))
114
- .isInstanceOf (IllegalArgumentException .class )
115
- .hasMessage ("Saved graffiti does not exist for validator " + publicKey );
113
+
114
+ assertDoesNotThrow (() -> manager .deleteGraffiti (publicKey ));
116
115
checkNoGraffitiFile (publicKey );
117
116
}
118
117
@@ -124,7 +123,7 @@ void deleteGraffiti_shouldDeleteGraffitiWhenFileExist(@TempDir final Path tempDi
124
123
assertThat (getGraffitiManagementDir ().resolve (getFileName (publicKey )).toFile ().createNewFile ())
125
124
.isTrue ();
126
125
127
- assertThat ( manager .deleteGraffiti (publicKey )). isEmpty ( );
126
+ manager .deleteGraffiti (publicKey );
128
127
checkNoGraffitiFile (publicKey );
129
128
}
130
129
@@ -139,8 +138,7 @@ void deleteGraffiti_shouldReturnErrorMessageWhenUnableToDeleteFile(@TempDir fina
139
138
assertThat (file .createNewFile ()).isTrue ();
140
139
assertThat (file .getParentFile ().setWritable (false )).isTrue ();
141
140
142
- assertThat (manager .deleteGraffiti (publicKey ))
143
- .hasValue ("Unable to delete graffiti for validator " + publicKey );
141
+ assertThatThrownBy (() -> manager .deleteGraffiti (publicKey )).isInstanceOf (IOException .class );
144
142
assertThat (file .exists ()).isTrue ();
145
143
}
146
144
@@ -155,7 +153,7 @@ void shouldSetAndDeleteGraffitiWhenManagementPreexisting(@TempDir final Path tem
155
153
manager .setGraffiti (publicKey , graffiti );
156
154
checkStoredGraffitiFile (publicKey );
157
155
158
- assertThat ( manager .deleteGraffiti (publicKey )). isEmpty ( );
156
+ manager .deleteGraffiti (publicKey );
159
157
checkNoGraffitiFile (publicKey );
160
158
}
161
159
0 commit comments