Search in sources :

Example 16 with MetadataEntry

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;
}
Also used : EntityVO(com.epam.pipeline.controller.vo.EntityVO) PipeConfValue(com.epam.pipeline.entity.metadata.PipeConfValue) MetadataEntry(com.epam.pipeline.entity.metadata.MetadataEntry) FolderWithMetadata(com.epam.pipeline.entity.metadata.FolderWithMetadata)

Example 17 with MetadataEntry

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);
}
Also used : MetadataEntityVO(com.epam.pipeline.controller.vo.metadata.MetadataEntityVO) EntityVO(com.epam.pipeline.controller.vo.EntityVO) HashMap(java.util.HashMap) MetadataVO(com.epam.pipeline.controller.vo.MetadataVO) PipeConfValue(com.epam.pipeline.entity.metadata.PipeConfValue) MetadataEntry(com.epam.pipeline.entity.metadata.MetadataEntry) PasswordGenerator.generateRandomString(com.epam.pipeline.utils.PasswordGenerator.generateRandomString) Folder(com.epam.pipeline.entity.pipeline.Folder) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 18 with MetadataEntry

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;
}
Also used : EntityVO(com.epam.pipeline.vo.EntityVO) PipeConfValue(com.epam.pipeline.entity.metadata.PipeConfValue) MetadataEntry(com.epam.pipeline.entity.metadata.MetadataEntry)

Example 19 with 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));
}
Also used : ObjectCreationUtils.buildEntityPermissionVO(com.epam.pipeline.elasticsearchagent.ObjectCreationUtils.buildEntityPermissionVO) EntityPermissionVO(com.epam.pipeline.vo.EntityPermissionVO) MetadataEntry(com.epam.pipeline.entity.metadata.MetadataEntry) ObjectCreationUtils.buildMetadataEntry(com.epam.pipeline.elasticsearchagent.ObjectCreationUtils.buildMetadataEntry) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 20 with 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));
}
Also used : ObjectCreationUtils.buildEntityPermissionVO(com.epam.pipeline.elasticsearchagent.ObjectCreationUtils.buildEntityPermissionVO) EntityPermissionVO(com.epam.pipeline.vo.EntityPermissionVO) MetadataEntry(com.epam.pipeline.entity.metadata.MetadataEntry) ObjectCreationUtils.buildMetadataEntry(com.epam.pipeline.elasticsearchagent.ObjectCreationUtils.buildMetadataEntry) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

MetadataEntry (com.epam.pipeline.entity.metadata.MetadataEntry)24 EntityVO (com.epam.pipeline.controller.vo.EntityVO)12 Transactional (org.springframework.transaction.annotation.Transactional)10 ObjectCreationUtils.buildEntityPermissionVO (com.epam.pipeline.elasticsearchagent.ObjectCreationUtils.buildEntityPermissionVO)9 ObjectCreationUtils.buildMetadataEntry (com.epam.pipeline.elasticsearchagent.ObjectCreationUtils.buildMetadataEntry)9 EntityPermissionVO (com.epam.pipeline.vo.EntityPermissionVO)9 BeforeEach (org.junit.jupiter.api.BeforeEach)9 PipeConfValue (com.epam.pipeline.entity.metadata.PipeConfValue)7 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)4 HashMap (java.util.HashMap)4 Test (org.junit.Test)4 Folder (com.epam.pipeline.entity.pipeline.Folder)2 MetadataVO (com.epam.pipeline.controller.vo.MetadataVO)1 MetadataEntityVO (com.epam.pipeline.controller.vo.metadata.MetadataEntityVO)1 Issue (com.epam.pipeline.entity.issue.Issue)1 FolderWithMetadata (com.epam.pipeline.entity.metadata.FolderWithMetadata)1 PasswordGenerator.generateRandomString (com.epam.pipeline.utils.PasswordGenerator.generateRandomString)1 EntityVO (com.epam.pipeline.vo.EntityVO)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1