Search in sources :

Example 36 with PipeConfValue

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

the class FolderManagerGetProjectTest method setUp.

@Before
public void setUp() {
    data.put(DATA_KEY_1, new PipeConfValue(DATA_TYPE_1, DATA_VALUE_1));
    dataWithIndicator.put(DATA_KEY_1, new PipeConfValue(DATA_TYPE_1, PROJECT_INDICATOR_VALUE));
    folder1 = initFolderWithMetadata(folder1, 1L, "folder1", null, data);
    folder2 = initFolderWithMetadata(folder2, 2L, "folder2", folder1.getId(), dataWithIndicator);
    folder3 = initFolderWithMetadata(folder3, 3L, "folder3", folder2.getId(), data);
    Mockito.when(folderDao.loadParentFolders(Matchers.any(Long.class))).thenReturn(Stream.of(folder1, folder2, folder3).collect(Collectors.toList()));
    PreferenceManager preferenceManager = mock(PreferenceManager.class);
    ReflectionTestUtils.setField(folderManager, "preferenceManager", preferenceManager);
    Mockito.when(preferenceManager.getPreference(SystemPreferences.UI_PROJECT_INDICATOR)).thenReturn("tag=project,other=indicator");
}
Also used : PipeConfValue(com.epam.pipeline.entity.metadata.PipeConfValue) PreferenceManager(com.epam.pipeline.manager.preference.PreferenceManager) Before(org.junit.Before)

Example 37 with PipeConfValue

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

the class FolderManagerTest method testListProjectsShouldReturnFolderWithIndicatorSet.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testListProjectsShouldReturnFolderWithIndicatorSet() {
    folderManager.create(folder);
    MetadataVO metadataVO = new MetadataVO();
    metadataVO.setEntity(new EntityVO(folder.getId(), AclClass.FOLDER));
    metadataVO.setData(Collections.singletonMap(PROJECT_INDICATOR_TYPE, new PipeConfValue(DEFAULT_PARAM_TYPE, PROJECT_INDICATOR_VALUE)));
    metadataManager.updateMetadataItem(metadataVO);
    List<Folder> folders = folderManager.loadAllProjects().getChildFolders();
    assertThat(folders.size(), is(1));
    assertThat(folders.get(0).getId(), is(folder.getId()));
}
Also used : MetadataEntityVO(com.epam.pipeline.controller.vo.metadata.MetadataEntityVO) EntityVO(com.epam.pipeline.controller.vo.EntityVO) MetadataVO(com.epam.pipeline.controller.vo.MetadataVO) 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 38 with PipeConfValue

use of com.epam.pipeline.entity.metadata.PipeConfValue 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 39 with PipeConfValue

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

the class ParameterMapperTest method mapParameters.

@Test
public void mapParameters() throws Exception {
    Map<String, PipeConfValueVO> parametersToResolve = new HashMap<>();
    parametersToResolve.put(PATIENT_PIPE_PARAM, new PipeConfValueVO("this.Patient.Patient_ID"));
    parametersToResolve.put(SAMPLE_PIPE_PARAM, new PipeConfValueVO("this.Sample_Name"));
    parametersToResolve.put(REFERENCE_PIPE_PARAM, new PipeConfValueVO(SCALAR_VALUE));
    parametersToResolve.put(BATCHES_PIPE_PARAM, new PipeConfValueVO("this.Patient.Batch.Batch_Name"));
    Map<ParameterMapper.MetadataKey, MetadataEntity> references = new HashMap<>();
    MetadataEntity sample = new MetadataEntity();
    sample.setExternalId(SAMPLE_ID);
    Map<String, PipeConfValue> sampleData = new HashMap<>();
    sampleData.put("Patient", new PipeConfValue("Participant:ID", PATIENT_ID));
    sampleData.put("Sample_Name", new PipeConfValue(PipeConfValueVO.DEFAULT_TYPE, SAMPLE_NAME));
    sample.setData(sampleData);
    references.put(new ParameterMapper.MetadataKey("Sample", SAMPLE_ID), sample);
    MetadataEntity patient = new MetadataEntity();
    patient.setExternalId(PATIENT_ID);
    Map<String, PipeConfValue> patientData = new HashMap<>();
    patientData.put("Patient_ID", new PipeConfValue(PipeConfValueVO.DEFAULT_TYPE, PATIENT_UID));
    patientData.put("Batch", new PipeConfValue("Array[Batch]", "[\"b1\", \"b2\"]"));
    patient.setData(patientData);
    references.put(new ParameterMapper.MetadataKey("Participant", PATIENT_ID), patient);
    MetadataEntity batch1 = new MetadataEntity();
    batch1.setExternalId(BATCH1_ID);
    Map<String, PipeConfValue> batch1Data = new HashMap<>();
    batch1Data.put(BATCH_NAME_PARAMETER, new PipeConfValue(PipeConfValueVO.DEFAULT_TYPE, BATCH1_NAME));
    batch1.setData(batch1Data);
    references.put(new ParameterMapper.MetadataKey(BATCH_CLASS, BATCH1_ID), batch1);
    MetadataEntity batch2 = new MetadataEntity();
    batch2.setExternalId(BATCH2_ID);
    Map<String, PipeConfValue> batch2Data = new HashMap<>();
    batch2Data.put(BATCH_NAME_PARAMETER, new PipeConfValue(PipeConfValueVO.DEFAULT_TYPE, BATCH2_NAME));
    batch2.setData(batch2Data);
    references.put(new ParameterMapper.MetadataKey(BATCH_CLASS, BATCH2_ID), batch2);
    Map<String, PipeConfValueVO> result = parameterMapper.mapParameters(sample, null, parametersToResolve, references);
    assertEquals(SAMPLE_NAME, result.get(SAMPLE_PIPE_PARAM).getValue());
    assertEquals(PATIENT_UID, result.get(PATIENT_PIPE_PARAM).getValue());
    assertEquals(SCALAR_VALUE, result.get(REFERENCE_PIPE_PARAM).getValue());
    assertEquals(BATCH1_NAME + "," + BATCH2_NAME, result.get(BATCHES_PIPE_PARAM).getValue());
}
Also used : MetadataEntity(com.epam.pipeline.entity.metadata.MetadataEntity) PipeConfValueVO(com.epam.pipeline.entity.configuration.PipeConfValueVO) HashMap(java.util.HashMap) PipeConfValue(com.epam.pipeline.entity.metadata.PipeConfValue) AbstractManagerTest(com.epam.pipeline.manager.AbstractManagerTest) Test(org.junit.Test)

Example 40 with PipeConfValue

use of com.epam.pipeline.entity.metadata.PipeConfValue 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)

Aggregations

PipeConfValue (com.epam.pipeline.entity.metadata.PipeConfValue)41 Test (org.junit.Test)24 MetadataEntity (com.epam.pipeline.entity.metadata.MetadataEntity)21 HashMap (java.util.HashMap)11 Transactional (org.springframework.transaction.annotation.Transactional)11 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)9 EntityVO (com.epam.pipeline.controller.vo.EntityVO)9 Folder (com.epam.pipeline.entity.pipeline.Folder)9 MetadataEntry (com.epam.pipeline.entity.metadata.MetadataEntry)8 FolderWithMetadata (com.epam.pipeline.entity.metadata.FolderWithMetadata)5 MetadataClass (com.epam.pipeline.entity.metadata.MetadataClass)5 PasswordGenerator.generateRandomString (com.epam.pipeline.utils.PasswordGenerator.generateRandomString)5 Map (java.util.Map)5 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 MetadataEntityVO (com.epam.pipeline.controller.vo.metadata.MetadataEntityVO)3 MessageConstants (com.epam.pipeline.common.MessageConstants)2 MessageHelper (com.epam.pipeline.common.MessageHelper)2 MetadataVO (com.epam.pipeline.controller.vo.MetadataVO)2 BaseEntity (com.epam.pipeline.entity.BaseEntity)2