ContentStoreImpl implements ContentStore { @Override public Content getContent(String spaceId, String contentId, Long startByte, Long endByte) throws ContentStoreException { if (startByte == null || startByte < 0) { throw new IllegalArgumentException("startByte must be equal to or greater than zero."); } else if (endByte != null && endByte <= startByte) { throw new IllegalArgumentException("endByte must be null or greater than the startByte."); } return execute(() -> { try { final HttpResponse response = doGetContent(spaceId, contentId, startByte, endByte); return toContent(response, spaceId, contentId, startByte, endByte); } catch (IOException ex) { throw new ContentStoreException(ex.getMessage(), ex); } }); } ContentStoreImpl(String baseURL,
                            StorageProviderType type,
                            String storeId,
                            boolean writable,
                            RestHttpHelper restHelper);  ContentStoreImpl(String baseURL,
                            StorageProviderType type,
                            String storeId,
                            boolean writable,
                            RestHttpHelper restHelper,
                            int maxRetries); @Override void setRetryExceptionHandler(ExceptionHandler retryExceptionHandler); String getBaseURL(); @Override String getStoreId(); @Override boolean isWritable(); @Override String getStorageProviderType(); @Override List<String> getSpaces(); @Override Iterator<String> getSpaceContents(String spaceId); @Override Iterator<String> getSpaceContents(final String spaceId,
                                             final String prefix); @Override Space getSpace(final String spaceId,
                          final String prefix,
                          final long maxResults,
                          final String marker); @Override void createSpace(final String spaceId); @Override void deleteSpace(final String spaceId); @Override Map<String, String> getSpaceProperties(final String spaceId); @Override Map<String, AclType> getSpaceACLs(final String spaceId); @Override void setSpaceACLs(final String spaceId,
                             final Map<String, AclType> spaceACLs); @Override boolean spaceExists(String spaceId); @Override String addContent(final String spaceId,
                             final String contentId,
                             final InputStream content,
                             final long contentSize,
                             final String contentMimeType,
                             final String contentChecksum,
                             final Map<String, String> contentProperties); @Override String copyContent(final String srcSpaceId,
                              final String srcContentId,
                              final String destStoreId,
                              final String destSpaceId,
                              final String destContentId); @Override String copyContent(String srcSpaceId,
                              String srcContentId,
                              String destSpaceId,
                              String destContentId); @Override String moveContent(String srcSpaceId,
                              String srcContentId,
                              String destSpaceId,
                              String destContentId); @Override String moveContent(String srcSpaceId,
                              String srcContentId,
                              String destStoreId,
                              String destSpaceId,
                              String destContentId); @Override Content getContent(String spaceId, String contentId, Long startByte, Long endByte); @Override Content getContent(final String spaceId, final String contentId); @Override void deleteContent(final String spaceId, final String contentId); @Override void setContentProperties(final String spaceId,
                                     final String contentId,
                                     final Map<String, String> contentProperties); @Override Map<String, String> getContentProperties(final String spaceId,
                                                    final String contentId); @Override boolean contentExists(String spaceId, String contentId); void validateStoreId(String storeId); @Override void validateSpaceId(String spaceId); @Override void validateContentId(String contentId); @Override List<String> getSupportedTasks(); @Override String performTask(final String taskName,
                              final String taskParameters); @Override String performTaskWithNoRetries(final String taskName,
                                           final String taskParameters); @Override InputStream getManifest(String spaceId, ManifestFormat format); @Override InputStream getAuditLog(String spaceId); @Override BitIntegrityReport getBitIntegrityReport(String spaceId); @Override BitIntegrityReportProperties getBitIntegrityReportProperties(String spaceId); @Override SpaceStatsDTOList getSpaceStats(String spaceId, Date start, Date end); @Override SpaceStatsDTOList getStorageProviderStats(Date start, Date end); @Override SpaceStatsDTOList getStorageProviderStatsByDay(Date date); @Override String toString();  }
@Test public void testGetContent() throws Exception { String streamContent = "content"; InputStream stream = IOUtils.toInputStream(streamContent); String fullURL = baseURL + "/" + spaceId + "/" + contentId + "?storeID=" + storeId; EasyMock.expect(response.getStatusCode()).andReturn(200); EasyMock.expect(response.getResponseHeaders()) .andReturn(new Header[0]).times(2); EasyMock.expect(response.getResponseStream()).andReturn(stream); EasyMock.expect(restHelper.get(fullURL)).andReturn(response); replayMocks(); Content content = contentStore.getContent(spaceId, contentId); Assert.assertNotNull(content); Assert.assertEquals(contentId, content.getId()); Assert.assertEquals(streamContent, IOUtils.toString(content.getStream())); }
@Test(expected = IllegalArgumentException.class) public void testGetContentWithInvalidRange1() throws Exception { replayMocks(); contentStore.getContent(spaceId, contentId, null, 1l); }
@Test(expected = IllegalArgumentException.class) public void testGetContentWithInvalidRange2() throws Exception { replayMocks(); contentStore.getContent(spaceId, contentId, 10l, 1l); }
@Test(expected = IllegalArgumentException.class) public void testGetContentWithInvalidRange3() throws Exception { replayMocks(); contentStore.getContent(spaceId, contentId, 10l, 10l); }