Search in sources :

Example 66 with Folder

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

the class DataStorageDaoTest method shouldReturnStorageWithParents.

@Test
public void shouldReturnStorageWithParents() {
    Folder childFolder = new Folder();
    childFolder.setName("childFolder");
    childFolder.setOwner(TEST_OWNER);
    childFolder.setParentId(testFolder.getId());
    folderDao.createFolder(childFolder);
    s3Bucket.setParentFolderId(childFolder.getId());
    dataStorageDao.createDataStorage(s3Bucket);
    Collection<AbstractDataStorage> storages = dataStorageDao.loadAllWithParents(1, 10);
    assertThat(storages).hasSize(1).containsOnly(s3Bucket).extracting(AbstractDataStorage::getParent).containsOnly(childFolder).extracting(Folder::getParent).containsOnly(testFolder);
}
Also used : AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) Folder(com.epam.pipeline.entity.pipeline.Folder) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest)

Example 67 with Folder

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

the class FolderDaoTest method testCreateAndLoadFolderWithMetadata.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testCreateAndLoadFolderWithMetadata() {
    Folder folder = getFolder();
    // create
    folderDao.createFolder(folder);
    Map<String, Integer> metadata = new HashMap<>();
    metadata.put(CLASS_NAME_1, 1);
    folder.setMetadata(metadata);
    // add metadata
    MetadataEntity metadataEntity = new MetadataEntity();
    metadataEntity.setName(TEST_ENTITY_NAME_1);
    MetadataClass metadataClass = createMetadataClass();
    metadataEntity.setClassEntity(metadataClass);
    metadataEntity.setParent(folder);
    Map<String, PipeConfValue> data = new HashMap<>();
    data.put(DATA_KEY_1, new PipeConfValue(DATA_TYPE_1, DATA_VALUE_1));
    metadataEntity.setData(data);
    metadataEntityDao.createMetadataEntity(metadataEntity);
    Folder loaded = folderDao.loadFolder(folder.getId());
    assertEquals(folder.getId(), loaded.getId());
    assertEquals(folder.getName(), loaded.getName());
    assertEquals(folder.getMetadata(), loaded.getMetadata());
    assertNull(folder.getParentId());
    Map<String, Integer> loadedMetadata = loaded.getMetadata();
    assertTrue(!loadedMetadata.isEmpty() && loadedMetadata.size() == 1);
    assertEquals(metadataEntity.getClassEntity().getName(), loadedMetadata.keySet().toArray()[0]);
    assertEquals(1, loadedMetadata.get(CLASS_NAME_1).intValue());
}
Also used : MetadataEntity(com.epam.pipeline.entity.metadata.MetadataEntity) MetadataClass(com.epam.pipeline.entity.metadata.MetadataClass) PipeConfValue(com.epam.pipeline.entity.metadata.PipeConfValue) Folder(com.epam.pipeline.entity.pipeline.Folder) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 68 with Folder

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

the class FolderDaoTest method testCreateAndLoadFolderWithConfigurations.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testCreateAndLoadFolderWithConfigurations() {
    Folder folder = getFolder();
    AbstractDataStorage storage = addStorage(folder);
    RunConfiguration configuration = addConfiguration(folder);
    Folder loaded = folderDao.loadFolder(folder.getId());
    assertEquals(folder.getId(), loaded.getId());
    assertEquals(folder.getName(), loaded.getName());
    assertNull(folder.getParentId());
    checkStorageIsPresent(storage, loaded);
    checkConfigIsPresent(configuration, loaded);
}
Also used : AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) RunConfiguration(com.epam.pipeline.entity.configuration.RunConfiguration) Folder(com.epam.pipeline.entity.pipeline.Folder) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 69 with Folder

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

the class FolderDaoTest method createFolderWithParent.

private Folder createFolderWithParent(Folder parent, String name) {
    Folder folder = new Folder();
    folder.setName(name);
    folder.setOwner(TEST_USER);
    folder.setParentId(parent.getId());
    // create
    folderDao.createFolder(folder);
    return folder;
}
Also used : Folder(com.epam.pipeline.entity.pipeline.Folder)

Example 70 with Folder

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

the class FolderDaoTest method getFolder.

public Folder getFolder() {
    Folder folder = new Folder();
    folder.setName(TEST_NAME);
    folder.setOwner(TEST_USER);
    // create
    folderDao.createFolder(folder);
    return folder;
}
Also used : Folder(com.epam.pipeline.entity.pipeline.Folder)

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