use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.
the class FolderManagerTest method generateFolder.
private Folder generateFolder(Long parentId) {
Folder folder = new Folder();
folder.setName(TEST_NAME + generateRandomString(10));
folder.setParentId(parentId);
folderManager.create(folder);
return folder;
}
use of com.epam.pipeline.entity.pipeline.Folder 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);
}
use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.
the class FolderManagerTest method shouldCloneFolderWithFolderMetadata.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void shouldCloneFolderWithFolderMetadata() {
Folder sourceFolder = new Folder();
sourceFolder.setName(FOLDER_TO_CLONE);
folderManager.create(sourceFolder);
Map<String, PipeConfValue> metadata = new HashMap<>();
metadata.put(DATA_KEY_1, new PipeConfValue(DATA_TYPE_1, DATA_VALUE_1));
MetadataVO metadataVO = new MetadataVO();
metadataVO.setEntity(new EntityVO(sourceFolder.getId(), AclClass.FOLDER));
metadataVO.setData(metadata);
MetadataEntry expectedMetadata = metadataManager.updateMetadataItem(metadataVO);
Folder childSourceFolder = new Folder();
childSourceFolder.setName(CHILD_FOLDER_TO_CLONE);
childSourceFolder.setParentId(sourceFolder.getId());
folderManager.create(childSourceFolder);
metadataVO.setEntity(new EntityVO(childSourceFolder.getId(), AclClass.FOLDER));
metadataManager.updateMetadataItem(metadataVO);
Folder destinationFolder = new Folder();
destinationFolder.setName(TEST_NAME);
folderManager.create(destinationFolder);
folderManager.cloneFolder(sourceFolder.getId(), destinationFolder.getId(), TEST_CLONE_PREFIX);
destinationFolder = folderManager.load(folderManager.loadByNameOrId(TEST_NAME).getId());
Folder clonedFolder = destinationFolder.getChildFolders().get(0);
MetadataEntry clonedFolderMetadata = metadataManager.loadMetadataItem(clonedFolder.getId(), AclClass.FOLDER);
assertEquals(clonedFolder.getId(), clonedFolderMetadata.getEntity().getEntityId());
assertFolderMetadata(expectedMetadata, clonedFolderMetadata);
Folder clonedChildFolder = clonedFolder.getChildFolders().get(0);
clonedFolderMetadata = metadataManager.loadMetadataItem(clonedChildFolder.getId(), AclClass.FOLDER);
assertEquals(clonedChildFolder.getId(), clonedFolderMetadata.getEntity().getEntityId());
assertFolderMetadata(expectedMetadata, clonedFolderMetadata);
}
use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.
the class PipelineRunManagerTest method testResolveProjectFiltering.
@Test
@WithMockUser(roles = "ADMIN")
public void testResolveProjectFiltering() {
Folder project = new Folder();
project.setId(1L);
Folder child = new Folder();
project.setId(2L);
project.getChildFolders().add(child);
Pipeline pipeline1 = new Pipeline();
pipeline1.setId(2L);
project.getPipelines().add(pipeline1);
Pipeline pipeline2 = new Pipeline();
pipeline2.setId(3L);
child.getPipelines().add(pipeline2);
RunConfiguration configuration1 = new RunConfiguration();
configuration1.setId(4L);
project.getConfigurations().add(configuration1);
RunConfiguration configuration2 = new RunConfiguration();
configuration2.setId(5L);
child.getConfigurations().add(configuration2);
when(folderManager.load(project.getId())).thenReturn(project);
PagingRunFilterVO filterVO = new PagingRunFilterVO();
filterVO.setProjectIds(Collections.singletonList(project.getId()));
PipelineRunFilterVO.ProjectFilter projectFilter = pipelineRunManager.resolveProjectFiltering(filterVO);
Assert.assertEquals(2, projectFilter.getPipelineIds().size());
Assert.assertEquals(2, projectFilter.getConfigurationIds().size());
}
use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.
the class PipelineWithPermissionsTest method getFolder.
private Folder getFolder(String name, String owner) {
Folder folder = new Folder();
folder.setName(name);
folder.setOwner(owner);
return folder;
}
Aggregations