@Test public void testEmpty() throws Exception { BaleenPipeline pipeline = new BaleenPipeline( "name", new YamlPipelineConfiguration(), new NoOpOrderer(), null, Collections.emptyList(), Collections.emptyList()); doReturn(Optional.of(pipeline)).when(manager).get(anyString()); ServletCaller caller = new ServletCaller(); caller.addParameter("name", "name"); caller.doGet(new PipelineConfigServlet(manager)); assertEquals("", caller.getResponseBody()); }
@Override protected void get(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String name = req.getParameter("name"); if (name == null) { respondWithBadArguments(resp); return; } Optional<BaleenPipeline> pipeline = manager.get(name); if (!pipeline.isPresent()) { respondWithNotFound(resp); } else { String servletPath = req.getRequestURI(); if (servletPath == null) servletPath = ""; while (servletPath.endsWith("/")) servletPath = servletPath.substring(0, servletPath.length() - 1); String[] parts = servletPath.split("/"); String action = ""; if (parts.length > 0) action = parts[parts.length - 1]; if ("ordered".equals(action)) { respond(resp, MediaType.PLAIN_TEXT_UTF_8, pipeline.get().orderedConfig()); } else { respond(resp, MediaType.PLAIN_TEXT_UTF_8, pipeline.get().originalConfig()); } } }
PipelineConfigServlet extends AbstractApiServlet { @Override protected void get(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String name = req.getParameter("name"); if (name == null) { respondWithBadArguments(resp); return; } Optional<BaleenPipeline> pipeline = manager.get(name); if (!pipeline.isPresent()) { respondWithNotFound(resp); } else { String servletPath = req.getRequestURI(); if (servletPath == null) servletPath = ""; while (servletPath.endsWith("/")) servletPath = servletPath.substring(0, servletPath.length() - 1); String[] parts = servletPath.split("/"); String action = ""; if (parts.length > 0) action = parts[parts.length - 1]; if ("ordered".equals(action)) { respond(resp, MediaType.PLAIN_TEXT_UTF_8, pipeline.get().orderedConfig()); } else { respond(resp, MediaType.PLAIN_TEXT_UTF_8, pipeline.get().originalConfig()); } } } }
PipelineConfigServlet extends AbstractApiServlet { @Override protected void get(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String name = req.getParameter("name"); if (name == null) { respondWithBadArguments(resp); return; } Optional<BaleenPipeline> pipeline = manager.get(name); if (!pipeline.isPresent()) { respondWithNotFound(resp); } else { String servletPath = req.getRequestURI(); if (servletPath == null) servletPath = ""; while (servletPath.endsWith("/")) servletPath = servletPath.substring(0, servletPath.length() - 1); String[] parts = servletPath.split("/"); String action = ""; if (parts.length > 0) action = parts[parts.length - 1]; if ("ordered".equals(action)) { respond(resp, MediaType.PLAIN_TEXT_UTF_8, pipeline.get().orderedConfig()); } else { respond(resp, MediaType.PLAIN_TEXT_UTF_8, pipeline.get().originalConfig()); } } } PipelineConfigServlet(BaleenPipelineManager manager); }
PipelineConfigServlet extends AbstractApiServlet { @Override protected void get(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String name = req.getParameter("name"); if (name == null) { respondWithBadArguments(resp); return; } Optional<BaleenPipeline> pipeline = manager.get(name); if (!pipeline.isPresent()) { respondWithNotFound(resp); } else { String servletPath = req.getRequestURI(); if (servletPath == null) servletPath = ""; while (servletPath.endsWith("/")) servletPath = servletPath.substring(0, servletPath.length() - 1); String[] parts = servletPath.split("/"); String action = ""; if (parts.length > 0) action = parts[parts.length - 1]; if ("ordered".equals(action)) { respond(resp, MediaType.PLAIN_TEXT_UTF_8, pipeline.get().orderedConfig()); } else { respond(resp, MediaType.PLAIN_TEXT_UTF_8, pipeline.get().originalConfig()); } } } PipelineConfigServlet(BaleenPipelineManager manager); @Override WebPermission[] getPermissions(); }
PipelineConfigServlet extends AbstractApiServlet { @Override protected void get(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String name = req.getParameter("name"); if (name == null) { respondWithBadArguments(resp); return; } Optional<BaleenPipeline> pipeline = manager.get(name); if (!pipeline.isPresent()) { respondWithNotFound(resp); } else { String servletPath = req.getRequestURI(); if (servletPath == null) servletPath = ""; while (servletPath.endsWith("/")) servletPath = servletPath.substring(0, servletPath.length() - 1); String[] parts = servletPath.split("/"); String action = ""; if (parts.length > 0) action = parts[parts.length - 1]; if ("ordered".equals(action)) { respond(resp, MediaType.PLAIN_TEXT_UTF_8, pipeline.get().orderedConfig()); } else { respond(resp, MediaType.PLAIN_TEXT_UTF_8, pipeline.get().originalConfig()); } } } PipelineConfigServlet(BaleenPipelineManager manager); @Override WebPermission[] getPermissions();  }