@Test public void testGetBinaryBlobs() throws RepositoryException { when(mockNode.getProperty(JCR_DATA)).thenReturn(mockProperty); when(mockStore.toString()).thenReturn("foo"); when(mockKeyFunc.apply(mockProperty)).thenReturn(mockKey); when(mockStoreFunc.apply(mockRepo)).thenReturn(mockStore); final LowLevelStorageService testObj = new LowLevelStorageService(); testObj.setGetBinaryStore(mockStoreFunc); testObj.setGetBinaryKey(mockKeyFunc); testObj.setRepository(mockRepo); final Set<LowLevelCacheEntry> actual = testObj.getLowLevelCacheEntries(mockNode); assertEquals("/foo", actual.iterator().next().getExternalIdentifier()); }
@Test public void testTransformBinaryBlobs() throws RepositoryException { when(mockNode.getProperty(JcrConstants.JCR_DATA)).thenReturn(mockProperty); when(mockStore.toString()).thenReturn("foo"); when(mockKeyFunc.apply(mockProperty)).thenReturn(mockKey); when(mockStoreFunc.apply(mockRepo)).thenReturn(mockStore); final LowLevelStorageService testObj = new LowLevelStorageService(); testObj.setGetBinaryStore(mockStoreFunc); testObj.setGetBinaryKey(mockKeyFunc); testObj.setRepository(mockRepo); @SuppressWarnings("unchecked") final Function<LowLevelCacheEntry, String> testFunc = mock(Function.class); when(testFunc.apply(any(LowLevelCacheEntry.class))).thenReturn("bar"); final Collection<String> actual = testObj.transformLowLevelCacheEntries(mockNode, testFunc); assertEquals("bar", actual.iterator().next()); verify(testFunc).apply(any(LowLevelCacheEntry.class)); }