exceptionfactory commented on code in PR #11303:
URL: https://github.com/apache/nifi/pull/11303#discussion_r3342918747
##########
nifi-extension-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/test/java/org/apache/nifi/web/controller/StandardContentViewerControllerTest.java:
##########
@@ -67,8 +75,39 @@ class StandardContentViewerControllerTest {
@Mock
private ContentAccess contentAccess;
+ @Captor
+ private ArgumentCaptor<String> errorMessageCaptor;
+
private final StandardContentViewerController controller = new
StandardContentViewerController();
+ @Test
+ void testDoGetFormattedContentTypeNotSupported() throws IOException {
+ final InputStream contentStream = new
ByteArrayInputStream(XML_DOCUMENT.getBytes(StandardCharsets.UTF_8));
+ final DownloadableContent downloadableContent = new
DownloadableContent(FILENAME, APPLICATION_OCTET_STREAM, contentStream);
+ setDownloadableContent(downloadableContent);
+
when(request.getParameter(eq(FORMATTED_PARAMETER))).thenReturn(Boolean.TRUE.toString());
+
when(request.getParameter(eq(CLIENT_ID_PARAMETER))).thenReturn(UUID.randomUUID().toString());
+
+ controller.doGet(request, response);
+
+ verify(response).sendError(eq(HttpServletResponse.SC_NOT_ACCEPTABLE),
anyString());
+ }
+
+ @Test
+ void testDoGetNotFormattedPartialContent() throws IOException {
+ final InputStream contentStream = new
ByteArrayInputStream(XML_DOCUMENT.getBytes(StandardCharsets.UTF_8));
+ final DownloadableContent downloadableContent = new
DownloadableContent(FILENAME, APPLICATION_OCTET_STREAM, contentStream);
+ setDownloadableContent(downloadableContent);
+
+ final MockServletOutputStream mockServletOutputStream = new
MockServletOutputStream();
+ when(response.getOutputStream()).thenReturn(mockServletOutputStream);
+
+ final LimitedStandardContentViewerController limitedController = new
LimitedStandardContentViewerController();
+ limitedController.doGet(request, response);
+
+ verify(response).setStatus(eq(HttpServletResponse.SC_PARTIAL_CONTENT));
Review Comment:
Thanks for pointing this out, I reworked the implementation to set the
response status earlier.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]