use of com.epam.pipeline.entity.configuration.RunConfigurationEntry in project cloud-pipeline by epam.
the class RunConfigurationDaoTest method testCRUD.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testCRUD() {
// create
RunConfigurationEntry entry = ObjectCreatorUtils.createConfigEntry(TEST_CONFIG_NAME, true, getTestConfig());
RunConfiguration configuration = ObjectCreatorUtils.createConfiguration(TEST_NAME, TEST_DESCRIPTION, null, TEST_OWNER, Collections.singletonList(entry));
RunConfiguration created = runConfigurationDao.create(configuration);
verifyRunConfiguration(configuration, created);
// load
RunConfiguration loaded = runConfigurationDao.load(created.getId());
verifyRunConfiguration(configuration, loaded);
// loadAll
List<RunConfiguration> configurations = runConfigurationDao.loadAll();
Assert.assertEquals(1, configurations.size());
verifyRunConfiguration(configuration, configurations.get(0));
// loadRoot
configurations = runConfigurationDao.loadRootEntities();
Assert.assertEquals(1, configurations.size());
verifyRunConfiguration(configuration, configurations.get(0));
// load with folders
loaded = runConfigurationDao.loadConfigurationWithParents(created.getId());
verifyRunConfiguration(configuration, loaded);
// update
created.setDescription(TEST_DESCRIPTION + TEST_DESCRIPTION);
created.setEntries(Arrays.asList(entry, entry));
runConfigurationDao.update(created);
verifyRunConfiguration(created, runConfigurationDao.load(created.getId()));
// delete
runConfigurationDao.delete(created.getId());
Assert.assertTrue(runConfigurationDao.loadAll().isEmpty());
}
use of com.epam.pipeline.entity.configuration.RunConfigurationEntry in project cloud-pipeline by epam.
the class RunConfigurationDaoTest method shouldLoadRunConfigurationWithFolderTree.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void shouldLoadRunConfigurationWithFolderTree() {
Folder root = buildFolder(TEST_NAME, null);
root.setParentId(0L);
Folder folder = buildFolder(TEST_NAME_1, root.getId());
folder.setParent(root);
Folder parent = buildFolder(TEST_NAME_2, folder.getId());
parent.setParent(folder);
RunConfigurationEntry entry = ObjectCreatorUtils.createConfigEntry(TEST_CONFIG_NAME, true, getTestConfig());
RunConfiguration configuration = ObjectCreatorUtils.createConfiguration(TEST_NAME, TEST_DESCRIPTION, parent.getId(), TEST_OWNER, Collections.singletonList(entry));
RunConfiguration created = runConfigurationDao.create(configuration);
verifyRunConfiguration(configuration, created);
// load with folders
RunConfiguration loaded = runConfigurationDao.loadConfigurationWithParents(created.getId());
verifyRunConfiguration(configuration, loaded);
verifyFolderTree(parent, loaded.getParent());
}
use of com.epam.pipeline.entity.configuration.RunConfigurationEntry in project cloud-pipeline by epam.
the class ObjectCreatorUtils method createConfigEntry.
public static RunConfigurationEntry createConfigEntry(String name, boolean defaultEntry, PipelineConfiguration configuration) {
RunConfigurationEntry entry = new RunConfigurationEntry();
entry.setName(name);
entry.setDefaultConfiguration(defaultEntry);
entry.setConfiguration(configuration);
return entry;
}
use of com.epam.pipeline.entity.configuration.RunConfigurationEntry in project cloud-pipeline by epam.
the class RunConfigurationApiServiceTest method setUp.
@Before
public void setUp() {
// Create SIDs for "test" users
testUserSid1 = new AclTestDao.AclSid(true, TEST_USER_1);
aclTestDao.createAclSid(testUserSid1);
testUserSid2 = new AclTestDao.AclSid(true, TEST_USER_2);
aclTestDao.createAclSid(testUserSid2);
Folder sourceFolder = new Folder();
sourceFolder.setName(TEST_FOLDER_NAME);
sourceFolder.setOwner(TEST_USER_1);
folderDao.createFolder(sourceFolder);
Long folderId = folderDao.loadFolderByName(TEST_FOLDER_NAME).getId();
AclTestDao.AclClass folderAclClass = new AclTestDao.AclClass(Folder.class.getCanonicalName());
aclTestDao.createAclClassIfNotPresent(folderAclClass);
AclTestDao.AclObjectIdentity folderIdentity = new AclTestDao.AclObjectIdentity(testUserSid1, folderId, folderAclClass.getId(), null, true);
aclTestDao.createObjectIdentity(folderIdentity);
AclTestDao.AclEntry folderAclEntry = new AclTestDao.AclEntry(folderIdentity, 1, testUserSid1, AclPermission.WRITE.getMask(), true);
aclTestDao.createAclEntry(folderAclEntry);
Pipeline pipeline = constructPipeline(TEST_NAME, TEST_NAME, folderId);
pipeline.setOwner(TEST_USER_1);
pipelineDao.createPipeline(pipeline);
Pipeline loadPipelineByName = pipelineDao.loadPipelineByName(TEST_NAME);
AclTestDao.AclClass pipelineAclClass = new AclTestDao.AclClass(Pipeline.class.getCanonicalName());
aclTestDao.createAclClassIfNotPresent(pipelineAclClass);
AclTestDao.AclObjectIdentity pipelineIdentity = new AclTestDao.AclObjectIdentity(testUserSid1, loadPipelineByName.getId(), pipelineAclClass.getId(), null, true);
aclTestDao.createObjectIdentity(pipelineIdentity);
AclTestDao.AclEntry pipelineAclEntry = new AclTestDao.AclEntry(pipelineIdentity, 1, testUserSid1, AclPermission.EXECUTE.getMask(), true);
aclTestDao.createAclEntry(pipelineAclEntry);
PipelineConfiguration pipelineConfiguration = new PipelineConfiguration();
RunConfigurationEntry entryWithPipeline = createConfigEntry(TEST_NAME, true, pipelineConfiguration);
entryWithPipeline.setPipelineId(pipeline.getId());
entryWithPipeline.setPipelineVersion(TEST_NAME);
runConfigurationVO = createRunConfigurationVO(TEST_NAME, TEST_DESCRIPTION, sourceFolder.getId(), Collections.singletonList(entryWithPipeline));
ToolGroup toolGroup = createToolGroup();
Tool tool = createTool(toolGroup);
RunConfigurationEntry entryWithTool = createConfigEntry(TEST_NAME, true, pipelineConfiguration);
pipelineConfiguration.setCmdTemplate(TEST_NAME);
pipelineConfiguration.setDockerImage(tool.getImage());
entryWithTool.setConfiguration(pipelineConfiguration);
updatedRunConfigurationVO = createRunConfigurationVO(TEST_NAME, TEST_DESCRIPTION, sourceFolder.getId(), Collections.singletonList(entryWithTool));
}
use of com.epam.pipeline.entity.configuration.RunConfigurationEntry in project cloud-pipeline by epam.
the class FolderManagerTest method shouldCloneWithRunConfiguration.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void shouldCloneWithRunConfiguration() {
Folder sourceFolder = new Folder();
sourceFolder.setName(FOLDER_TO_CLONE);
folderManager.create(sourceFolder);
PipelineConfiguration pipelineConfiguration = new PipelineConfiguration();
pipelineConfiguration.setCmdTemplate(TEST_NAME);
RunConfigurationEntry entry = createConfigEntry(TEST_NAME, true, pipelineConfiguration);
RunConfigurationVO runConfigurationVO = createRunConfigurationVO(TEST_NAME, TEST_DESCRIPTION, sourceFolder.getId(), Collections.singletonList(entry));
RunConfiguration expectedRunConfiguration = runConfigurationManager.create(runConfigurationVO);
Folder childSourceFolder = new Folder();
childSourceFolder.setName(CHILD_FOLDER_TO_CLONE);
childSourceFolder.setParentId(sourceFolder.getId());
folderManager.create(childSourceFolder);
runConfigurationVO.setParentId(childSourceFolder.getId());
runConfigurationManager.create(runConfigurationVO);
Folder destinationFolder = new Folder();
destinationFolder.setName(TEST_NAME);
folderManager.create(destinationFolder);
folderManager.cloneFolder(sourceFolder.getId(), destinationFolder.getId(), TEST_CLONE_PREFIX);
destinationFolder = folderManager.loadByNameOrId(TEST_NAME);
destinationFolder = folderManager.load(destinationFolder.getId());
Folder clonedFolder = destinationFolder.getChildFolders().get(0);
RunConfiguration clonedRunConfiguration = runConfigurationManager.loadAll().stream().filter(conf -> Objects.equals(conf.getParent().getId(), clonedFolder.getId())).collect(Collectors.toList()).get(0);
assertRunConfiguration(expectedRunConfiguration, clonedRunConfiguration);
Folder clonedChildFolder = clonedFolder.getChildFolders().get(0);
clonedRunConfiguration = runConfigurationManager.loadAll().stream().filter(conf -> Objects.equals(conf.getParent().getId(), clonedChildFolder.getId())).collect(Collectors.toList()).get(0);
assertRunConfiguration(expectedRunConfiguration, clonedRunConfiguration);
}
Aggregations