use of com.epam.pipeline.entity.preference.Preference in project cloud-pipeline by epam.
the class DataStorageManagerTest method testGenerateSharedURLForSharedStorage.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testGenerateSharedURLForSharedStorage() {
Preference preference = SystemPreferences.BASE_API_SHARED.toPreference();
preference.setValue(SHARED_BASE_URL_TEMPLATE);
preferenceManager.update(Collections.singletonList(preference));
DataStorageVO storageVO = ObjectCreatorUtils.constructDataStorageVO(NAME, DESCRIPTION, DataStorageType.S3, PATH, STS_DURATION, LTS_DURATION, WITHOUT_PARENT_ID, TEST_MOUNT_POINT, TEST_MOUNT_OPTIONS);
storageVO.setShared(true);
AbstractDataStorage saved = storageManager.create(storageVO, false, false, false);
String url = storageManager.generateSharedUrlForStorage(saved.getId());
Assert.assertEquals(SHARED_BASE_URL + saved.getId(), url);
}
use of com.epam.pipeline.entity.preference.Preference 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);
}
use of com.epam.pipeline.entity.preference.Preference in project cloud-pipeline by epam.
the class PipelineRunManagerTest method testRunCmdFailed.
/**
* Tests that Aspect will deny PipelineRunManager::runCmd method execution
*/
@Test(expected = ToolExecutionDeniedException.class)
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void testRunCmdFailed() {
PipelineStart startVO = new PipelineStart();
preferenceManager.update(Arrays.asList(new Preference(SystemPreferences.DOCKER_SECURITY_TOOL_POLICY_DENY_NOT_SCANNED.getKey(), Boolean.toString(true))));
startVO.setDockerImage(TEST_IMAGE);
pipelineRunManager.runCmd(startVO);
}
use of com.epam.pipeline.entity.preference.Preference in project cloud-pipeline by epam.
the class PreferenceManagerTest method fetchTest.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void fetchTest() {
Preference preference = new Preference(NAME, VALUE, GROUP, "", PreferenceType.STRING, true);
preferenceManager.update(Collections.singletonList(preference));
Preference load = preferenceManager.load(NAME).get();
String fetch = preferenceManager.getStringPreference(NAME);
Assert.assertEquals(fetch, load.getValue());
preference.setValue(NEW_VALUE);
preferenceManager.update(Collections.singletonList(preference));
load = preferenceManager.load(NAME).get();
fetch = preferenceManager.getStringPreference(NAME);
Assert.assertEquals(fetch, load.getValue());
}
use of com.epam.pipeline.entity.preference.Preference in project cloud-pipeline by epam.
the class PreferenceManagerTest method deleteTest.
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void deleteTest() {
Preference preference = new Preference(NAME, VALUE, GROUP, "", PreferenceType.STRING, true);
preferenceManager.update(Collections.singletonList(preference));
String load = preferenceManager.getStringPreference(NAME);
Assert.assertEquals(VALUE, load);
preferenceManager.delete(NAME);
Assert.assertNull(preferenceManager.getStringPreference(NAME));
}
Aggregations