private ReferencedData storeOrSerialize(InputStream stream, String dataStoreRef, DataStore store, int dataSize, int resultSizeLimit) throws IOException, DataStoreException { if (dataSize < resultSizeLimit) { return ReferencedData.getWrappedData(IOUtils.toByteArray(stream)); } else { return ReferencedData.getReferencedData(store.store(stream, dataStoreRef)); } } }
private String storeDocument(InputStream contentToStore) throws DataStoreException { DataStore store = getFsDataStore(); return store.store(contentToStore, properties.getDataStorePartialReference()); }
/** * Either wraps or store in the data store the selected content. * * @param content the content to wrap or store. * @return A ReferencedData object containing either the wrapped bytes or data store reference. * @throws DataStoreException */ public ReferencedData wrapOrStoreData(byte[] content) throws DataStoreException { if (content.length > resultSizeLimit) { return ReferencedData.getReferencedData(dataStore.store(content, dataStoreReference)); } else { return ReferencedData.getWrappedData(content); } }
@Override public TTask createTask(TestItem<TInput, TExpected> testItem) throws Exception { ReferencedData sourceData; if (!Strings.isNullOrEmpty(overrideReference)) { testItem.getInputData().setStorageReference(overrideReference); sourceData = ReferencedData.getReferencedData(overrideReference); } else if (!Strings.isNullOrEmpty(testItem.getInputData().getStorageReference())) { sourceData = ReferencedData.getReferencedData(testItem.getInputData().getStorageReference()); } else { Path inputFile = Paths.get(testItem.getInputData().getInputFile()); if (Files.notExists(inputFile) && !Strings.isNullOrEmpty(testSourcefileBaseFolder)) { inputFile = Paths.get(testSourcefileBaseFolder, testItem.getInputData().getInputFile()); } if (Files.notExists(inputFile)) { inputFile = Paths.get(testFilesFolder, testItem.getInputData().getInputFile()); } if (testItem.getInputData().isUseDataStore()) { try (InputStream inputStream = Files.newInputStream(inputFile)) { String reference = dataStore.store(inputStream, containerId); sourceData = ReferencedData.getReferencedData(reference); inputStream.close(); } } else { byte[] fileContent = Files.readAllBytes(inputFile); sourceData = ReferencedData.getWrappedData(fileContent); } } return createTask(testItem, sourceData); }
metadata.put("content", String.valueOf(1L)); String storedDataLocation = store.store(new ByteArrayInputStream(condition.value.getBytes()), properties.getDataStorePartialReference());