14
14
package tech .pegasys .teku .validator .api ;
15
15
16
16
import static org .assertj .core .api .Assertions .assertThat ;
17
+ import static org .assertj .core .api .Assertions .assertThatThrownBy ;
17
18
import static org .assertj .core .api .Assertions .fail ;
18
19
import static tech .pegasys .teku .validator .api .GraffitiManager .GRAFFITI_DIR ;
19
20
@@ -75,7 +76,7 @@ void setGraffiti_shouldSetGraffitiWhenFileExist(@TempDir final Path tempDir) thr
75
76
76
77
@ Test
77
78
@ DisabledOnOs (OS .WINDOWS ) // Can't set permissions on Windows
78
- void setGraffiti_shouldThrowExceptionWhenUnableToWriteFile (@ TempDir final Path tempDir )
79
+ void setGraffiti_shouldReturnErrorMessageWhenUnableToWriteFile (@ TempDir final Path tempDir )
79
80
throws IOException {
80
81
dataDirLayout = new SimpleDataDirLayout (tempDir );
81
82
manager = new GraffitiManager (dataDirLayout );
@@ -85,7 +86,7 @@ void setGraffiti_shouldThrowExceptionWhenUnableToWriteFile(@TempDir final Path t
85
86
assertThat (file .setWritable (false )).isTrue ();
86
87
87
88
assertThat (manager .setGraffiti (publicKey , graffiti ))
88
- .hasValue ("java.nio.file.AccessDeniedException: " + file );
89
+ .hasValue ("Unable to update graffiti for validator " + publicKey );
89
90
}
90
91
91
92
@ Test
@@ -95,10 +96,10 @@ void setGraffiti_shouldThrowExceptionWhenGraffitiTooBig(@TempDir final Path temp
95
96
manager = new GraffitiManager (dataDirLayout );
96
97
assertThat (getGraffitiManagementDir ().toFile ().exists ()).isTrue ();
97
98
98
- assertThat ( manager .setGraffiti (publicKey , invalidGraffiti ))
99
- .hasValue (
100
- "java.lang.IllegalArgumentException: "
101
- + "'This graffiti is a bit too long!!' converts to 33 bytes. Input must be 32 bytes or less." );
99
+ assertThatThrownBy (() -> manager .setGraffiti (publicKey , invalidGraffiti ))
100
+ .isInstanceOf ( IllegalArgumentException . class )
101
+ . hasMessage (
102
+ "'This graffiti is a bit too long!!' converts to 33 bytes. Input must be 32 bytes or less." );
102
103
}
103
104
104
105
@ Test
@@ -137,7 +138,7 @@ void deleteGraffiti_shouldSetGraffitiWhenFileExist(@TempDir final Path tempDir)
137
138
}
138
139
139
140
@ Test
140
- void deleteGraffiti_shouldThrowExceptionWhenUnableToWriteFile (@ TempDir final Path tempDir )
141
+ void deleteGraffiti_shouldReturnErrorMessageWhenUnableToWriteFile (@ TempDir final Path tempDir )
141
142
throws IOException {
142
143
dataDirLayout = new SimpleDataDirLayout (tempDir );
143
144
manager = new GraffitiManager (dataDirLayout );
@@ -147,7 +148,7 @@ void deleteGraffiti_shouldThrowExceptionWhenUnableToWriteFile(@TempDir final Pat
147
148
assertThat (file .setWritable (false )).isTrue ();
148
149
149
150
assertThat (manager .deleteGraffiti (publicKey ))
150
- .hasValue ("java.nio.file.AccessDeniedException: " + file );
151
+ .hasValue ("Unable to update graffiti for validator " + publicKey );
151
152
}
152
153
153
154
@ Test
0 commit comments