use of com.epam.pipeline.manager.security.AuthManager in project cloud-pipeline by epam.
the class AttachmentFileManagerTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
attachmentFileManager = new AttachmentFileManager(dataStorageManager, preferenceManager, attachmentManager, messageHelper, authManager);
Preference systemDataStorage = SystemPreferences.DATA_STORAGE_SYSTEM_DATA_STORAGE_NAME.toPreference();
systemDataStorage.setName(TEST_SYSTEM_DATA_STORAGE);
when(preferenceManager.getPreference(SystemPreferences.DATA_STORAGE_SYSTEM_DATA_STORAGE_NAME)).thenReturn(TEST_SYSTEM_DATA_STORAGE);
when(dataStorageManager.loadByNameOrId(TEST_SYSTEM_DATA_STORAGE)).thenReturn(testSystemDataStorage);
when(dataStorageManager.createDataStorageFile(Mockito.eq(1L), Mockito.anyString(), Mockito.anyString(), Mockito.any(InputStream.class))).then((Answer<DataStorageFile>) invocation -> {
String path = invocation.getArgumentAt(1, String.class);
String name = invocation.getArgumentAt(2, String.class);
DataStorageFile file = new DataStorageFile();
file.setPath(path + "/" + name);
return file;
});
when(attachmentManager.load(Mockito.anyLong())).thenAnswer(invocation -> {
Attachment attachment = new Attachment();
attachment.setId(invocation.getArgumentAt(0, Long.class));
attachment.setName(TEST_ATTACHMENT_NAME);
attachment.setPath(TEST_ATTACHMENT_PATH);
return attachment;
});
DataStorageStreamingContent content = new DataStorageStreamingContent(new ByteArrayInputStream(new byte[] { 1 }), TEST_ATTACHMENT_NAME);
when(dataStorageManager.getStreamingContent(testSystemDataStorage.getId(), TEST_ATTACHMENT_PATH, null)).thenReturn(content);
when(authManager.getAuthorizedUser()).thenReturn(TEST_USER);
}
Aggregations