@Test public void testGetFiles() throws IOException { Date date = new Date(); String encoding = "UTF-8"; String mimetype = "text"; Map<String, byte[]> testFiles = new HashMap<String, byte[]>(); testFiles.put("file1", "file1 contents".getBytes(encoding)); testFiles.put("file2", "contents of file2".getBytes(encoding)); String fileNamesUrl = "/" + HttpEndpointConstants.FILE_URL + "?" + HttpEndpointConstants.STAGE_PARAM + "=" + stageName + "&" + HttpEndpointConstants.DOCID_PARAM + "=" + URLEncoder.encode(doc.getID().toJSON(), "UTF-8"); stubFor(get(urlEqualTo(fileNamesUrl)).willReturn(aResponse().withBody("[\"file2\", \"file1\"]"))); List<DocumentFile<Local>> expected = new ArrayList<DocumentFile<Local>>(); for (Map.Entry<String, byte[]> testFile : testFiles.entrySet()) { final String fileName = testFile.getKey(); final byte[] content = testFile.getValue(); stubFile(fileName, doc.getID(), content, date, encoding, mimetype); DocumentFile<Local> df = new DocumentFile<Local>(doc.getID(), fileName, new ByteArrayInputStream(content), stageName, date); df.setEncoding(encoding); df.setMimetype(mimetype); expected.add(df); } List<DocumentFile<Local>> actual = rp.getFiles(doc.getID()); assertEquals(expected.size(), actual.size()); for (DocumentFile<Local> expectedDf : expected) { DocumentFile<Local> actualDf = actual.get(actual.indexOf(expectedDf)); documentFileEquals(expectedDf, actualDf); } }
public List<DocumentFile<Local>> getFiles(DocumentID<Local> docid) { List<String> fileNames = getFileNames(docid); List<DocumentFile<Local>> files = new ArrayList<DocumentFile<Local>>(); for (String fileName : fileNames) { files.add(getFile(fileName, docid)); } return files; }
HttpRemotePipeline implements RemotePipeline { public List<DocumentFile<Local>> getFiles(DocumentID<Local> docid) { List<String> fileNames = getFileNames(docid); List<DocumentFile<Local>> files = new ArrayList<DocumentFile<Local>>(); for (String fileName : fileNames) { files.add(getFile(fileName, docid)); } return files; } }
HttpRemotePipeline implements RemotePipeline { public List<DocumentFile<Local>> getFiles(DocumentID<Local> docid) { List<String> fileNames = getFileNames(docid); List<DocumentFile<Local>> files = new ArrayList<DocumentFile<Local>>(); for (String fileName : fileNames) { files.add(getFile(fileName, docid)); } return files; } HttpRemotePipeline(String stageName);  HttpRemotePipeline(String hostName, int port, String stageName);  HttpRemotePipeline(String hostName, int port, String stageName, boolean performanceLogging); }
HttpRemotePipeline implements RemotePipeline { public List<DocumentFile<Local>> getFiles(DocumentID<Local> docid) { List<String> fileNames = getFileNames(docid); List<DocumentFile<Local>> files = new ArrayList<DocumentFile<Local>>(); for (String fileName : fileNames) { files.add(getFile(fileName, docid)); } return files; } HttpRemotePipeline(String stageName);  HttpRemotePipeline(String hostName, int port, String stageName);  HttpRemotePipeline(String hostName, int port, String stageName, boolean performanceLogging); @Override LocalDocument getDocument(LocalQuery query); @Override boolean saveFull(LocalDocument d); @Override boolean save(LocalDocument d); @Override boolean markPending(LocalDocument d); @Override boolean markFailed(LocalDocument d); @Override boolean markFailed(LocalDocument d, Throwable t); @Override boolean markProcessed(LocalDocument d); @Override boolean markDiscarded(LocalDocument d); @Override AbstractProcessStage getStageInstance(); DocumentFile<Local> getFile(String fileName, DocumentID<Local> docid); boolean saveFile(DocumentFile<Local> df); boolean deleteFile(String fileName, DocumentID<Local> docid); @SuppressWarnings("unchecked") List<String> getFileNames(DocumentID<?> docid); List<DocumentFile<Local>> getFiles(DocumentID<Local> docid); @Override String getStageName(); @Override boolean isPerformanceLogging(); }
HttpRemotePipeline implements RemotePipeline { public List<DocumentFile<Local>> getFiles(DocumentID<Local> docid) { List<String> fileNames = getFileNames(docid); List<DocumentFile<Local>> files = new ArrayList<DocumentFile<Local>>(); for (String fileName : fileNames) { files.add(getFile(fileName, docid)); } return files; } HttpRemotePipeline(String stageName);  HttpRemotePipeline(String hostName, int port, String stageName);  HttpRemotePipeline(String hostName, int port, String stageName, boolean performanceLogging); @Override LocalDocument getDocument(LocalQuery query); @Override boolean saveFull(LocalDocument d); @Override boolean save(LocalDocument d); @Override boolean markPending(LocalDocument d); @Override boolean markFailed(LocalDocument d); @Override boolean markFailed(LocalDocument d, Throwable t); @Override boolean markProcessed(LocalDocument d); @Override boolean markDiscarded(LocalDocument d); @Override AbstractProcessStage getStageInstance(); DocumentFile<Local> getFile(String fileName, DocumentID<Local> docid); boolean saveFile(DocumentFile<Local> df); boolean deleteFile(String fileName, DocumentID<Local> docid); @SuppressWarnings("unchecked") List<String> getFileNames(DocumentID<?> docid); List<DocumentFile<Local>> getFiles(DocumentID<Local> docid); @Override String getStageName(); @Override boolean isPerformanceLogging();  }