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");
}
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()));
}
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);
}
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());
}
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;
}
Aggregations