|
17 | 17 | import org.junit.jupiter.api.Assertions; |
18 | 18 | import org.junit.jupiter.api.BeforeEach; |
19 | 19 | import org.junit.jupiter.api.Test; |
20 | | -import org.mockito.Mock; |
21 | 20 | import org.mockito.Mockito; |
22 | 21 |
|
23 | 22 | import java.time.Instant; |
|
35 | 34 | public class FileClientImplTest { |
36 | 35 | ProtocolLayerClient protocolLayerClient; |
37 | 36 | FileClientImpl fileClientImpl; |
38 | | - |
39 | | - @Mock |
40 | | - private FileClientImpl fileClient; |
41 | 37 |
|
42 | 38 | @BeforeEach |
43 | 39 | void setup() { |
44 | 40 | protocolLayerClient = Mockito.mock(ProtocolLayerClient.class); |
45 | 41 | fileClientImpl = new FileClientImpl(protocolLayerClient); |
46 | | - fileClient = new FileClientImpl(protocolLayerClient); |
47 | 42 | } |
48 | 43 |
|
49 | 44 | @Test |
@@ -277,47 +272,47 @@ void testGetFileSizeThrowsExceptionForNullId() { |
277 | 272 | } |
278 | 273 |
|
279 | 274 |
|
280 | | -//tests for deletefile method |
281 | | -@Test |
282 | | -public void testIsDeleted_FileIsDeleted() throws HieroException { |
283 | | - // Given |
284 | | - FileId fileId = FileId.fromString("0.0.123"); |
285 | | - FileInfoResponse response = mock(FileInfoResponse.class); |
286 | | - when(protocolLayerClient.executeFileInfoQuery(any(FileInfoRequest.class))).thenReturn(response); |
287 | | - when(response.deleted()).thenReturn(true); |
288 | | - |
289 | | - // When |
290 | | - boolean result = fileClient.isDeleted(fileId); |
291 | | - |
292 | | - // Then |
293 | | - assertTrue(result); |
294 | | -} |
295 | | - |
296 | | -@Test |
297 | | -public void testIsDeleted_FileIsNotDeleted() throws HieroException { |
298 | | - // Given |
299 | | - FileId fileId = FileId.fromString("0.0.123"); |
300 | | - FileInfoResponse response = mock(FileInfoResponse.class); |
301 | | - when(protocolLayerClient.executeFileInfoQuery(any(FileInfoRequest.class))).thenReturn(response); |
302 | | - when(response.deleted()).thenReturn(false); |
303 | | - |
304 | | - // When |
305 | | - boolean result = fileClient.isDeleted(fileId); |
306 | | - |
307 | | - // Then |
308 | | - assertFalse(result); |
309 | | -} |
| 275 | + //tests for deletefile method |
| 276 | + @Test |
| 277 | + public void testIsDeleted_FileIsDeleted() throws HieroException { |
| 278 | + // Given |
| 279 | + FileId fileId = FileId.fromString("0.0.123"); |
| 280 | + FileInfoResponse response = mock(FileInfoResponse.class); |
| 281 | + when(protocolLayerClient.executeFileInfoQuery(any(FileInfoRequest.class))).thenReturn(response); |
| 282 | + when(response.deleted()).thenReturn(true); |
| 283 | + |
| 284 | + // When |
| 285 | + boolean result = fileClientImpl.isDeleted(fileId); |
| 286 | + |
| 287 | + // Then |
| 288 | + assertTrue(result); |
| 289 | + } |
310 | 290 |
|
311 | | -@Test |
312 | | -public void testIsDeleted_NullFileId() { |
313 | | - // When |
314 | | - NullPointerException exception = assertThrows(NullPointerException.class, () -> { |
315 | | - fileClient.isDeleted(null); |
316 | | - }); |
| 291 | + @Test |
| 292 | + public void testIsDeleted_FileIsNotDeleted() throws HieroException { |
| 293 | + // Given |
| 294 | + FileId fileId = FileId.fromString("0.0.123"); |
| 295 | + FileInfoResponse response = mock(FileInfoResponse.class); |
| 296 | + when(protocolLayerClient.executeFileInfoQuery(any(FileInfoRequest.class))).thenReturn(response); |
| 297 | + when(response.deleted()).thenReturn(false); |
| 298 | + |
| 299 | + // When |
| 300 | + boolean result = fileClientImpl.isDeleted(fileId); |
| 301 | + |
| 302 | + // Then |
| 303 | + assertFalse(result); |
| 304 | + } |
317 | 305 |
|
318 | | - // Then |
319 | | - assertEquals("fileId must not be null", exception.getMessage()); |
320 | | -} |
| 306 | + @Test |
| 307 | + public void testIsDeleted_NullFileId() { |
| 308 | + // When |
| 309 | + NullPointerException exception = assertThrows(NullPointerException.class, () -> { |
| 310 | + fileClientImpl.isDeleted(null); |
| 311 | + }); |
| 312 | + |
| 313 | + // Then |
| 314 | + assertEquals("fileId must not be null", exception.getMessage()); |
| 315 | + } |
321 | 316 |
|
322 | 317 |
|
323 | 318 | @Test |
|
0 commit comments