Search in sources :

Example 71 with Folder

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

the class MetadataEntityDaoTest method createFolder.

private Folder createFolder(Long parentId) {
    Folder folder = new Folder();
    folder.setName(TEST_NAME);
    folder.setOwner(TEST_USER);
    folder.setParentId(parentId);
    folderDao.createFolder(folder);
    return folder;
}
Also used : Folder(com.epam.pipeline.entity.pipeline.Folder)

Example 72 with Folder

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

the class MetadataEntityDaoTest method testLoadReferenceQueryWithParticipantsOnly.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testLoadReferenceQueryWithParticipantsOnly() {
    Folder folder = createFolder();
    MetadataClass participantClass = createMetadataClass(CLASS_NAME_2);
    MetadataClass sampleClass = createMetadataClass(CLASS_NAME_1);
    Map<String, PipeConfValue> data = new HashMap<>();
    data.put(DATA_KEY_1, new PipeConfValue(DATA_TYPE_1, DATA_VALUE_1));
    MetadataEntity participant1 = createMetadataEntity(folder, participantClass, EXTERNAL_ID_1, data);
    MetadataEntity participant2 = createMetadataEntity(folder, participantClass, EXTERNAL_ID_2, data);
    data = new HashMap<>();
    data.put(DATA_KEY_1, new PipeConfValue(DATA_TYPE_1, DATA_VALUE_1));
    data.put("Participants", new PipeConfValue("Array[Participant]", String.format("[\"%s\",\"%s\"]", participant1.getExternalId(), participant2.getExternalId())));
    createMetadataEntity(folder, sampleClass, EXTERNAL_ID_1, data);
    List<MetadataEntity> links = metadataEntityDao.loadAllReferences(Arrays.asList(participant1.getId(), participant2.getId()), folder.getId());
    Assert.assertEquals(new HashSet<>(Arrays.asList(participant1, participant2)), new HashSet<>(links));
}
Also used : Folder(com.epam.pipeline.entity.pipeline.Folder) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 73 with Folder

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

the class MetadataEntityDaoTest method testGetKeys.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testGetKeys() {
    MetadataClass metadataClass = createMetadataClass(CLASS_NAME_1);
    Map<String, PipeConfValue> data1 = new HashMap<>();
    data1.put(DATA_KEY_1, new PipeConfValue(DATA_TYPE_1, DATA_VALUE_1));
    Folder folder = createFolder();
    MetadataEntity entity = createMetadataEntity(folder, metadataClass, EXTERNAL_ID_1, data1);
    Set<MetadataField> defaultKeys = new HashSet<>(MetadataEntityDao.MetadataEntityParameters.fieldNames.values());
    checkGetKeys(metadataClass, folder, defaultKeys, getDataField(DATA_KEY_1));
    Map<String, PipeConfValue> data2 = new HashMap<>();
    data2.put(DATA_KEY_2, new PipeConfValue(DATA_TYPE_1, DATA_VALUE_1));
    createMetadataEntity(folder, metadataClass, EXTERNAL_ID_2, data2);
    checkGetKeys(metadataClass, folder, defaultKeys, getDataField(DATA_KEY_1), getDataField(DATA_KEY_2));
    metadataEntityDao.deleteMetadataEntity(entity.getId());
    checkGetKeys(metadataClass, folder, defaultKeys, getDataField(DATA_KEY_2));
}
Also used : Folder(com.epam.pipeline.entity.pipeline.Folder) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 74 with Folder

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

the class MetadataEntityDaoTest method testGetMetadataKeys.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testGetMetadataKeys() {
    MetadataClass metadataClass1 = createMetadataClass(CLASS_NAME_1);
    MetadataClass metadataClass2 = createMetadataClass(CLASS_NAME_2);
    Folder parent = createFolder();
    Folder child = createFolder(parent.getId());
    Map<String, PipeConfValue> data1 = new HashMap<>();
    data1.put(DATA_KEY_1, new PipeConfValue(DATA_TYPE_1, DATA_VALUE_1));
    createMetadataEntity(child, metadataClass1, EXTERNAL_ID_1, data1);
    Map<String, PipeConfValue> data2 = new HashMap<>();
    data2.put(DATA_KEY_2, new PipeConfValue(DATA_TYPE_2, DATA_VALUE_1));
    createMetadataEntity(parent, metadataClass2, EXTERNAL_ID_1, data2);
    Collection<MetadataClassDescription> metadataFields = metadataEntityDao.getMetadataFields(parent.getId());
    Assert.assertEquals(2, metadataFields.size());
    Map<Long, MetadataClassDescription> results = metadataFields.stream().collect(Collectors.toMap(e -> e.getMetadataClass().getId(), Function.identity()));
    Assert.assertEquals(Collections.singletonList(new EntityTypeField(DATA_KEY_1, DATA_TYPE_1)), results.get(metadataClass1.getId()).getFields());
    Assert.assertEquals(Collections.singletonList(new EntityTypeField(DATA_KEY_2, CLASS_NAME_2)), results.get(metadataClass2.getId()).getFields());
}
Also used : BaseEntity(com.epam.pipeline.entity.BaseEntity) EntityTypeField(com.epam.pipeline.manager.metadata.parser.EntityTypeField) java.util(java.util) Autowired(org.springframework.beans.factory.annotation.Autowired) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) Folder(com.epam.pipeline.entity.pipeline.Folder) Stream(java.util.stream.Stream) Propagation(org.springframework.transaction.annotation.Propagation) com.epam.pipeline.entity.metadata(com.epam.pipeline.entity.metadata) ObjectCreatorUtils(com.epam.pipeline.manager.ObjectCreatorUtils) FolderDao(com.epam.pipeline.dao.pipeline.FolderDao) Assert(org.junit.Assert) Transactional(org.springframework.transaction.annotation.Transactional) EntityTypeField(com.epam.pipeline.manager.metadata.parser.EntityTypeField) Folder(com.epam.pipeline.entity.pipeline.Folder) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 75 with Folder

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

the class MetadataEntityDaoTest method testSearchWithUnderscore.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testSearchWithUnderscore() {
    MetadataClass metadataClass = createMetadataClass(CLASS_NAME_1);
    Map<String, PipeConfValue> data = new HashMap<>();
    data.put(DATA_KEY_1, new PipeConfValue(DATA_TYPE_1, DATA_VALUE_1 + "1"));
    Folder folder = createFolder();
    // sample with "OWNER1" data, shouldn't be returned in search results
    createMetadataEntity(folder, metadataClass, EXTERNAL_ID_1, data);
    Map<String, PipeConfValue> dataUnderscore = new HashMap<>();
    dataUnderscore.put(DATA_KEY_1, new PipeConfValue(DATA_TYPE_1, DATA_VALUE_1 + "_1"));
    // sample with "OWNER_1" data, should  be returned in search results
    MetadataEntity sampleUnderscore = createMetadataEntity(folder, metadataClass, EXTERNAL_ID_2, dataUnderscore);
    MetadataFilter filter = createFilter(folder.getId(), metadataClass.getName(), Collections.singletonList(DATA_VALUE_1 + "_"), Collections.emptyList(), null, false);
    checkFilterRequest(filter, Collections.singletonList(sampleUnderscore));
}
Also used : Folder(com.epam.pipeline.entity.pipeline.Folder) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Transactional(org.springframework.transaction.annotation.Transactional)

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