Search in sources :

Example 31 with Folder

use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.

the class RunConfigurationManager method update.

@Transactional(propagation = Propagation.REQUIRED)
public RunConfiguration update(RunConfigurationVO configuration) {
    validateConfiguration(runConfigurationMapper.toRunConfiguration(configuration));
    RunConfiguration dbConfiguration = load(configuration.getId());
    dbConfiguration.setName(configuration.getName());
    dbConfiguration.setDescription(configuration.getDescription());
    dbConfiguration.setEntries(configuration.getEntries());
    if (configuration.getParentId() != null) {
        dbConfiguration.setParent(new Folder(configuration.getParentId()));
    } else {
        dbConfiguration.setParent(null);
    }
    return runConfigurationDao.update(dbConfiguration);
}
Also used : RunConfiguration(com.epam.pipeline.entity.configuration.RunConfiguration) Folder(com.epam.pipeline.entity.pipeline.Folder) Transactional(org.springframework.transaction.annotation.Transactional)

Example 32 with Folder

use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.

the class FolderApiServiceTest method testCreateUpdateCloneDeleteFolderByAllowedUser.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
@WithMockUser(username = TEST_USER, roles = FOLDER_MANAGER_ROLE)
public void testCreateUpdateCloneDeleteFolderByAllowedUser() {
    Folder folder = new Folder();
    folder.setName(FOLDER_NAME);
    folder.setParentId(parent.getId());
    folder.setId(parent.getId());
    when(folderManager.create(folder)).thenReturn(folder);
    folderApiService.create(folder);
    when(folderManager.load(anyLong())).thenReturn(folder);
    folderApiService.load(folder.getId());
    String newName = "New name";
    folder.setName(newName);
    when(folderManager.update(folder)).thenReturn(folder);
    folderApiService.update(folder);
    assertEquals(newName, folderApiService.load(folder.getId()).getName());
    when(folderManager.lockFolder(anyLong())).thenReturn(folder);
    folderApiService.lockFolder(folder.getId());
    when(folderManager.unlockFolder(anyLong())).thenReturn(folder);
    folderApiService.unlockFolder(folder.getId());
    when(folderManager.cloneFolder(anyLong(), anyLong(), anyString())).thenReturn(folder);
    folderApiService.cloneFolder(folder.getId(), parent.getId(), "Name");
    when(folderManager.delete(anyLong())).thenReturn(folder);
    folderApiService.delete(folder.getId());
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) Folder(com.epam.pipeline.entity.pipeline.Folder) WithMockUser(org.springframework.security.test.context.support.WithMockUser) AbstractManagerTest(com.epam.pipeline.manager.AbstractManagerTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 33 with Folder

use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.

the class FolderApiServiceTest method testDeleteFolderByAdmin.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
@WithMockUser(username = TEST_USER2, roles = ADMIN_ROLE)
public void testDeleteFolderByAdmin() {
    Folder folder = new Folder();
    folder.setName(FOLDER_NAME);
    folder.setParentId(parent.getId());
    when(folderManager.create(folder)).thenReturn(folder);
    Folder createdFolder = folderApiService.create(folder);
    when(folderManager.delete(anyLong())).thenReturn(folder);
    folderApiService.delete(createdFolder.getId());
}
Also used : Folder(com.epam.pipeline.entity.pipeline.Folder) WithMockUser(org.springframework.security.test.context.support.WithMockUser) AbstractManagerTest(com.epam.pipeline.manager.AbstractManagerTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 34 with Folder

use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.

the class FolderManagerGetProjectTest method getProjectShouldWorkWithDataStorageAsInputEntity.

@Test
public void getProjectShouldWorkWithDataStorageAsInputEntity() {
    S3bucketDataStorage dataStorage = new S3bucketDataStorage(1L, "dataStorage", "path_to_bucket");
    dataStorage.setParent(folder3);
    Mockito.when(entityManager.load(Matchers.any(AclClass.class), Matchers.any(Long.class))).thenReturn(dataStorage);
    Folder actualFolder = folderManager.getProject(dataStorage.getId(), AclClass.DATA_STORAGE);
    assertFolders(folder2, actualFolder);
}
Also used : S3bucketDataStorage(com.epam.pipeline.entity.datastorage.aws.S3bucketDataStorage) Folder(com.epam.pipeline.entity.pipeline.Folder) AclClass(com.epam.pipeline.entity.security.acl.AclClass) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test)

Example 35 with Folder

use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.

the class FolderManagerGetProjectTest method getProjectShouldWorkWithMetadataAsInputEntity.

@Test
public void getProjectShouldWorkWithMetadataAsInputEntity() {
    MetadataEntity metadataEntity = new MetadataEntity();
    metadataEntity.setId(1L);
    metadataEntity.setParent(folder3);
    Mockito.when(entityManager.load(Matchers.any(AclClass.class), Matchers.any(Long.class))).thenReturn(metadataEntity);
    Folder actualFolder = folderManager.getProject(metadataEntity.getId(), AclClass.METADATA_ENTITY);
    assertFolders(folder2, actualFolder);
}
Also used : MetadataEntity(com.epam.pipeline.entity.metadata.MetadataEntity) Folder(com.epam.pipeline.entity.pipeline.Folder) AclClass(com.epam.pipeline.entity.security.acl.AclClass) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test)

Aggregations

Folder (com.epam.pipeline.entity.pipeline.Folder)102 Transactional (org.springframework.transaction.annotation.Transactional)53 Test (org.junit.Test)52 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)48 EntityVO (com.epam.pipeline.controller.vo.EntityVO)14 AbstractDataStorage (com.epam.pipeline.entity.datastorage.AbstractDataStorage)14 Pipeline (com.epam.pipeline.entity.pipeline.Pipeline)14 MetadataClass (com.epam.pipeline.entity.metadata.MetadataClass)13 RunConfiguration (com.epam.pipeline.entity.configuration.RunConfiguration)11 MetadataEntity (com.epam.pipeline.entity.metadata.MetadataEntity)11 PipeConfValue (com.epam.pipeline.entity.metadata.PipeConfValue)10 AclClass (com.epam.pipeline.entity.security.acl.AclClass)10 Autowired (org.springframework.beans.factory.annotation.Autowired)8 Propagation (org.springframework.transaction.annotation.Propagation)8 MetadataEntityVO (com.epam.pipeline.controller.vo.metadata.MetadataEntityVO)7 PasswordGenerator.generateRandomString (com.epam.pipeline.utils.PasswordGenerator.generateRandomString)6 FolderWithMetadata (com.epam.pipeline.entity.metadata.FolderWithMetadata)5 DataStorageVO (com.epam.pipeline.controller.vo.DataStorageVO)4 AbstractManagerTest (com.epam.pipeline.manager.AbstractManagerTest)4 Collectors (java.util.stream.Collectors)4