Skip to content

Commit

Permalink
Remove second unused file upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Janelle Law committed Jul 26, 2021
1 parent 50350ef commit 7ef984b
Showing 1 changed file with 18 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,32 +179,23 @@ void shouldProcessGoodRequest() throws Exception {
HttpServerResponse resp = Mockito.mock(HttpServerResponse.class);
Mockito.when(ctx.response()).thenReturn(resp);

FileUpload upload1 = Mockito.mock(FileUpload.class);
Mockito.when(upload1.name()).thenReturn("template");
Mockito.when(upload1.uploadedFileName()).thenReturn("/file-uploads/abcd-1234");

FileUpload upload2 = Mockito.mock(FileUpload.class);
Mockito.when(upload2.name()).thenReturn("unused");
Mockito.when(upload2.uploadedFileName()).thenReturn("/file-uploads/wxyz-9999");
FileUpload upload = Mockito.mock(FileUpload.class);
Mockito.when(upload.name()).thenReturn("template");
Mockito.when(upload.uploadedFileName()).thenReturn("/file-uploads/abcd-1234");

Mockito.when(ctx.fileUploads()).thenReturn(Set.of(upload1, upload2));
Mockito.when(ctx.fileUploads()).thenReturn(Set.of(upload));

Path uploadPath1 = Mockito.mock(Path.class);
Path uploadPath2 = Mockito.mock(Path.class);
Mockito.when(fs.pathOf("/file-uploads/abcd-1234")).thenReturn(uploadPath1);
Mockito.when(fs.pathOf("/file-uploads/wxyz-9999")).thenReturn(uploadPath2);
Path uploadPath = Mockito.mock(Path.class);
Mockito.when(fs.pathOf("/file-uploads/abcd-1234")).thenReturn(uploadPath);

InputStream stream1 = Mockito.mock(InputStream.class);
InputStream stream2 = Mockito.mock(InputStream.class);
Mockito.when(fs.newInputStream(uploadPath1)).thenReturn(stream1);
Mockito.when(fs.newInputStream(uploadPath2)).thenReturn(stream2);
InputStream stream = Mockito.mock(InputStream.class);
Mockito.when(fs.newInputStream(uploadPath)).thenReturn(stream);

handler.handleAuthenticated(ctx);

Mockito.verify(templateService).addTemplate(stream1);
Mockito.verify(templateService).addTemplate(stream);
Mockito.verifyNoMoreInteractions(templateService);
Mockito.verify(fs).deleteIfExists(uploadPath1);
Mockito.verify(fs).deleteIfExists(uploadPath2);
Mockito.verify(fs).deleteIfExists(uploadPath);
Mockito.verify(ctx).response();
Mockito.verify(resp).end();
}
Expand All @@ -216,25 +207,17 @@ void shouldSendNotifcationOnTemplateDeletion() throws Exception {
HttpServerResponse resp = Mockito.mock(HttpServerResponse.class);
Mockito.when(ctx.response()).thenReturn(resp);

FileUpload upload1 = Mockito.mock(FileUpload.class);
Mockito.when(upload1.name()).thenReturn("template");
Mockito.when(upload1.uploadedFileName()).thenReturn("/file-uploads/abcd-1234");

FileUpload upload2 = Mockito.mock(FileUpload.class);
Mockito.when(upload2.name()).thenReturn("unused");
Mockito.when(upload2.uploadedFileName()).thenReturn("/file-uploads/wxyz-9999");
FileUpload upload = Mockito.mock(FileUpload.class);
Mockito.when(upload.name()).thenReturn("template");
Mockito.when(upload.uploadedFileName()).thenReturn("/file-uploads/abcd-1234");

Mockito.when(ctx.fileUploads()).thenReturn(Set.of(upload1, upload2));
Mockito.when(ctx.fileUploads()).thenReturn(Set.of(upload));

Path uploadPath1 = Mockito.mock(Path.class);
Path uploadPath2 = Mockito.mock(Path.class);
Mockito.when(fs.pathOf("/file-uploads/abcd-1234")).thenReturn(uploadPath1);
Mockito.when(fs.pathOf("/file-uploads/wxyz-9999")).thenReturn(uploadPath2);
Path uploadPath = Mockito.mock(Path.class);
Mockito.when(fs.pathOf("/file-uploads/abcd-1234")).thenReturn(uploadPath);

InputStream stream1 = Mockito.mock(InputStream.class);
InputStream stream2 = Mockito.mock(InputStream.class);
Mockito.when(fs.newInputStream(uploadPath1)).thenReturn(stream1);
Mockito.when(fs.newInputStream(uploadPath2)).thenReturn(stream2);
InputStream stream = Mockito.mock(InputStream.class);
Mockito.when(fs.newInputStream(uploadPath)).thenReturn(stream);

handler.handleAuthenticated(ctx);

Expand Down

0 comments on commit 7ef984b

Please sign in to comment.