@Test public void testGetAttachmentUrl() throws Exception { Long tokenId = new Long(456); String entityId = "132"; String expectedPath = S3TokenManagerImpl.createAttachmentPathSlash(entityId, tokenId.toString()); String expectePreSigneUrl = "I am a presigned url! whooot!"; when(mockUuserManager.getUserInfo(userId)).thenReturn(mockUser); when(mockPermissionsManager.hasAccess(entityId, ACCESS_TYPE.READ, mockUser)).thenReturn(true); when(mocKLocationHelper.presignS3GETUrlShortLived(userId, expectedPath)) .thenReturn(expectePreSigneUrl); when(mockS3Utilitiy.doesExist(any(String.class))).thenReturn(true); // Make the actual call when(mockUuserManager.getUserInfo(userId)).thenReturn(mockUser); PresignedUrl url = manager.getAttachmentUrl(userId, entityId, tokenId.toString()); assertNotNull(url); assertEquals(expectePreSigneUrl, url.getPresignedUrl()); assertEquals(URLStatus.READ_FOR_DOWNLOAD, url.getStatus()); }