use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.
the class FolderManagerTest method testGetProjectFolderFromProjectTree.
@Test
public void testGetProjectFolderFromProjectTree() {
Map<String, PipeConfValue> data = new HashMap<>();
data.put(DATA_KEY_1, new PipeConfValue(DATA_TYPE_1, DATA_VALUE_1));
Map<String, PipeConfValue> dataWithIndicator = new HashMap<>();
dataWithIndicator.put(DATA_KEY_1, new PipeConfValue(DATA_TYPE_1, PROJECT_INDICATOR_VALUE));
FolderWithMetadata folder = initFolderWithMetadata(new FolderWithMetadata(), 1L, "folder", null, data);
FolderWithMetadata folder1 = initFolderWithMetadata(new FolderWithMetadata(), 2L, "folder1", folder.getId(), dataWithIndicator);
FolderWithMetadata folder2 = initFolderWithMetadata(new FolderWithMetadata(), 3L, "folder2", folder1.getId(), data);
Map<Long, FolderWithMetadata> folders = new HashMap<>();
folders.put(folder.getId(), folder);
folders.put(folder1.getId(), folder1);
folders.put(folder2.getId(), folder2);
Set<Pair<String, String>> indicators = new HashSet<>();
indicators.add(new ImmutablePair<>(DATA_KEY_1, PROJECT_INDICATOR_VALUE));
// case: single indicator
Folder actualFolder = folderManager.getProjectFolder(folders, folder2.getId(), indicators);
assertEquals(folder1.getId(), actualFolder.getId());
assertEquals(folder1.getName(), actualFolder.getName());
assertEquals(folder1.getParentId(), actualFolder.getParentId());
assertEquals(folder1.getOwner(), actualFolder.getOwner());
// case: several indicators
indicators.add(new ImmutablePair<>(PROJECT_INDICATOR_VALUE, DATA_KEY_1));
dataWithIndicator = new HashMap<>();
dataWithIndicator.put(PROJECT_INDICATOR_VALUE, new PipeConfValue(DATA_TYPE_1, DATA_KEY_1));
folder2.setData(dataWithIndicator);
folders.put(folder2.getId(), folder2);
actualFolder = folderManager.getProjectFolder(folders, folder2.getId(), indicators);
assertEquals(folder2.getId(), actualFolder.getId());
assertEquals(folder2.getName(), actualFolder.getName());
assertEquals(folder2.getParentId(), actualFolder.getParentId());
assertEquals(folder2.getOwner(), actualFolder.getOwner());
// case: no matches (null parent)
folder1.setData(data);
folder2.setData(data);
folders.put(folder1.getId(), folder1);
folders.put(folder2.getId(), folder2);
actualFolder = folderManager.getProjectFolder(folders, folder2.getId(), indicators);
assertNull(actualFolder);
// case: no matches (no null parent)
folders.remove(folder.getId());
actualFolder = folderManager.getProjectFolder(folders, folder2.getId(), indicators);
assertNull(actualFolder);
}
use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.
the class FolderManagerTest method setUp.
@Before
public void setUp() throws Exception {
awsRegionManager.create(AwsRegionVO.builder().name("US").awsRegionName("us-east-1").isDefault(true).build());
doReturn(new MockS3Helper()).when(storageProviderManager).getS3Helper(any());
folder = new Folder();
folder.setName(TEST_NAME);
subFolder = new Folder();
subFolder.setName(TEST_NAME_1);
MockitoAnnotations.initMocks(this);
when(gitManagerMock.getPipelineRevisions(any(Pipeline.class), any(Long.class))).thenReturn(Collections.emptyList());
pipelineManager.setGitManager(gitManagerMock);
}
use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.
the class FolderManagerTest method deleteFolder.
@Test(expected = IllegalArgumentException.class)
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void deleteFolder() throws Exception {
folderManager.create(folder);
Folder loaded = folderManager.load(folder.getId());
assertNotNull(loaded);
folderManager.delete(folder.getId());
folderManager.load(folder.getId());
}
use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.
the class FolderManagerTest method shouldCloneFolderTree.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void shouldCloneFolderTree() {
Folder sourceFolder = new Folder();
sourceFolder.setName(FOLDER_TO_CLONE);
folderManager.create(sourceFolder);
Folder childSourceFolder = new Folder();
childSourceFolder.setName(CHILD_FOLDER_TO_CLONE);
childSourceFolder.setParentId(sourceFolder.getId());
folderManager.create(childSourceFolder);
Folder destinationFolder = new Folder();
destinationFolder.setName(TEST_NAME);
folderManager.create(destinationFolder);
Folder clonedFolder = folderManager.cloneFolder(sourceFolder.getId(), destinationFolder.getId(), TEST_CLONE_PREFIX);
assertTrue(CollectionUtils.isEmpty(clonedFolder.getChildFolders()));
clonedFolder = folderManager.load(clonedFolder.getId());
assertEquals(destinationFolder.getId(), clonedFolder.getParentId());
assertNotNull(clonedFolder);
assertTrue(clonedFolder.getName().startsWith(TEST_CLONE_PREFIX));
Folder clonedChildFolder = clonedFolder.getChildFolders().get(0);
assertNotNull(clonedChildFolder);
assertEquals(CHILD_FOLDER_TO_CLONE, clonedChildFolder.getName());
}
use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.
the class FolderManagerTest method testDataStorageCountInFolder.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testDataStorageCountInFolder() {
Folder sourceFolder = generateFolder(null);
Folder childFolderWithStorage1 = generateFolder(sourceFolder.getId());
generateDataStorage(childFolderWithStorage1.getId());
Folder childFolderWithoutStorage = generateFolder(childFolderWithStorage1.getId());
Folder childFolderWithStorage2 = generateFolder(sourceFolder.getId());
generateDataStorage(childFolderWithStorage2.getId());
Folder childFolderWithStorage3 = generateFolder(childFolderWithStorage2.getId());
generateDataStorage(childFolderWithStorage3.getId());
generateDataStorage(childFolderWithStorage3.getId());
assertEquals(4, folderManager.countDataStorages(folderManager.load(sourceFolder.getId())));
assertEquals(0, folderManager.countDataStorages(folderManager.load(childFolderWithoutStorage.getId())));
assertEquals(1, folderManager.countDataStorages(folderManager.load(childFolderWithStorage1.getId())));
assertEquals(3, folderManager.countDataStorages(folderManager.load(childFolderWithStorage2.getId())));
assertEquals(2, folderManager.countDataStorages(folderManager.load(childFolderWithStorage3.getId())));
}
Aggregations