use of com.epam.pipeline.entity.metadata.MetadataEntity in project cloud-pipeline by epam.
the class MetadataWriterTest method entity.
private MetadataEntity entity(final String entityClass, final String id, final Map<String, PipeConfValue> data) {
final MetadataEntity metadataEntity = new MetadataEntity();
metadataEntity.setExternalId(id);
metadataEntity.setData(data);
final MetadataClass metadataClass = new MetadataClass();
metadataClass.setName(entityClass);
metadataEntity.setClassEntity(metadataClass);
return metadataEntity;
}
use of com.epam.pipeline.entity.metadata.MetadataEntity 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.MetadataEntity in project cloud-pipeline by epam.
the class MetadataEntityMapperTest method shouldMapMetadataEntity.
@Test
void shouldMapMetadataEntity() throws IOException {
MetadataEntityMapper mapper = new MetadataEntityMapper();
MetadataClass metadataClass = new MetadataClass(1L, "Sample");
MetadataEntity metadataEntity = new MetadataEntity();
metadataEntity.setClassEntity(metadataClass);
metadataEntity.setId(1L);
metadataEntity.setExternalId("external");
metadataEntity.setParent(new Folder(1L));
metadataEntity.setName(TEST_NAME);
metadataEntity.setData(Collections.singletonMap(TEST_KEY, new PipeConfValue("string", TEST_VALUE)));
EntityContainer<MetadataEntity> container = EntityContainer.<MetadataEntity>builder().entity(metadataEntity).permissions(PERMISSIONS_CONTAINER).build();
XContentBuilder contentBuilder = mapper.map(container);
verifyMetadataEntity(metadataEntity, EXPECTED_METADATA, contentBuilder);
verifyPermissions(PERMISSIONS_CONTAINER, contentBuilder);
}
Aggregations