use of com.epam.pipeline.entity.metadata.MetadataEntry in project cloud-pipeline by epam.
the class FolderDaoTest method createObjectMetadata.
private List<FolderWithMetadata> createObjectMetadata(List<Folder> folders) {
Map<String, PipeConfValue> data = new HashMap<>();
data.put(DATA_KEY_1, new PipeConfValue(DATA_TYPE_1, DATA_VALUE_1));
MetadataEntry metadataToSave = new MetadataEntry();
List<FolderWithMetadata> foldersWithMetadata = new ArrayList<>();
folders.forEach(folder -> {
metadataToSave.setEntity(new EntityVO(folder.getId(), AclClass.FOLDER));
metadataToSave.setData(data);
metadataDao.registerMetadataItem(metadataToSave);
FolderWithMetadata folderWithMetadata = convertToFolderWithMetadata(folder);
folderWithMetadata.setData(data);
foldersWithMetadata.add(folderWithMetadata);
});
return foldersWithMetadata;
}
use of com.epam.pipeline.entity.metadata.MetadataEntry 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.metadata.MetadataEntry in project cloud-pipeline by epam.
the class ObjectCreationUtils method buildMetadataEntry.
public static MetadataEntry buildMetadataEntry(final AclClass aclClass, final Long entityId, final String metadataValue) {
EntityVO entityVO = new EntityVO(entityId, aclClass);
MetadataEntry metadataEntry = new MetadataEntry();
metadataEntry.setEntity(entityVO);
metadataEntry.setData(Collections.singletonMap(TEST_NAME, new PipeConfValue(TEST_NAME, metadataValue)));
return metadataEntry;
}
use of com.epam.pipeline.entity.metadata.MetadataEntry in project cloud-pipeline by epam.
the class FolderLoaderTest method setup.
@BeforeEach
void setup() {
EntityPermissionVO entityPermissionVO = buildEntityPermissionVO(USER_NAME, ALLOWED_USERS, DENIED_USERS, ALLOWED_GROUPS, DENIED_GROUPS);
MetadataEntry metadataEntry = buildMetadataEntry(AclClass.FOLDER, 1L, TEST_KEY + " " + TEST_VALUE);
when(apiClient.loadUserByName(anyString())).thenReturn(USER);
when(apiClient.loadPermissionsForEntity(anyLong(), any())).thenReturn(entityPermissionVO);
when(apiClient.loadMetadataEntry(any())).thenReturn(Collections.singletonList(metadataEntry));
}
use of com.epam.pipeline.entity.metadata.MetadataEntry in project cloud-pipeline by epam.
the class IssueLoaderTest method setup.
@BeforeEach
void setup() {
EntityPermissionVO entityPermissionVO = buildEntityPermissionVO(USER_NAME, ALLOWED_USERS, DENIED_USERS, ALLOWED_GROUPS, DENIED_GROUPS);
MetadataEntry metadataEntry = buildMetadataEntry(AclClass.TOOL, 1L, TEST_KEY + " " + TEST_VALUE);
when(apiClient.loadUserByName(anyString())).thenReturn(USER);
when(apiClient.loadPermissionsForEntity(anyLong(), any())).thenReturn(entityPermissionVO);
when(apiClient.loadMetadataEntry(any())).thenReturn(Collections.singletonList(metadataEntry));
}
Aggregations