use of com.epam.pipeline.entity.metadata.MetadataEntity in project cloud-pipeline by epam.
the class MetadataUploadManagerTest method testAllNewUpload.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testAllNewUpload() throws IOException {
Folder folder = prepareRequiredEntities();
when(authManager.isAdmin()).thenReturn(true);
try (InputStream inputStream = MetadataFileBuilder.prepareInputData(MetadataParsingUtils.CSV_DELIMITER)) {
List<MetadataEntity> entities = uploadManager.uploadFromFile(folder.getId(), new MockMultipartFile(TEST_CSV_FILE, TEST_CSV_FILE, null, inputStream));
assertEquals(2, entities.size());
assertTrue(entities.stream().allMatch(e -> e.getId() != null));
}
}
use of com.epam.pipeline.entity.metadata.MetadataEntity in project cloud-pipeline by epam.
the class MetadataUploadManagerTest method testUpdateUpload.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testUpdateUpload() throws IOException {
Folder folder = prepareRequiredEntities();
MetadataClass sampleClass = entityManager.createMetadataClass(MetadataFileBuilder.SAMPLE_CLASS_NAME);
MetadataEntity existingSample = entityManager.updateMetadataEntity(createEntityVO(folder.getId(), sampleClass.getId(), MetadataFileBuilder.SAMPLE1_ID));
try (InputStream inputStream = MetadataFileBuilder.prepareInputData(MetadataParsingUtils.TAB_DELIMITER)) {
List<MetadataEntity> entities = uploadManager.uploadFromFile(folder.getId(), new MockMultipartFile(TEST_TAB_FILE, TEST_TAB_FILE, null, inputStream));
assertEquals(2, entities.size());
assertTrue(entities.stream().allMatch(e -> e.getId() != null));
assertTrue(entities.stream().filter(e -> e.getExternalId().equals(MetadataFileBuilder.SAMPLE1_ID)).findAny().orElseThrow(AssertionError::new).getId().equals(existingSample.getId()));
}
}
use of com.epam.pipeline.entity.metadata.MetadataEntity in project cloud-pipeline by epam.
the class MetadataUploadManagerTest method uploadingMetadataWithSeveralMultiValueFields.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void uploadingMetadataWithSeveralMultiValueFields() throws IOException {
Folder folder = prepareRequiredEntities();
entityManager.createMetadataClass(MetadataFileBuilder.SAMPLE_CLASS_NAME);
MetadataClass setClass = entityManager.createMetadataClass(MetadataFileBuilder.SET_CLASS_NAME);
entityManager.updateMetadataEntity(createEntityVO(folder.getId(), setClass.getId(), MetadataFileBuilder.SET1_ID));
entityManager.updateMetadataEntity(createEntityVO(folder.getId(), setClass.getId(), MetadataFileBuilder.SET2_ID));
entityManager.updateMetadataEntity(createEntityVO(folder.getId(), setClass.getId(), MetadataFileBuilder.SET3_ID));
List<String> lines = Arrays.asList(MetadataFileBuilder.MULTIVALUE_HEADER, MetadataFileBuilder.MULTIVALUE_LINE1, MetadataFileBuilder.MULTIVALUE_LINE2, MetadataFileBuilder.MULTIVALUE_LINE3);
try (InputStream inputStream = MetadataFileBuilder.prepareInputData(MetadataParsingUtils.TAB_DELIMITER, lines)) {
List<MetadataEntity> entities = uploadManager.uploadFromFile(folder.getId(), new MockMultipartFile(TEST_TAB_FILE, TEST_TAB_FILE, null, inputStream));
assertEquals(1, entities.size());
String expectedSetField = String.format("[\"%s\",\"%s\",\"%s\"]", MetadataFileBuilder.SET1_ID, MetadataFileBuilder.SET2_ID, MetadataFileBuilder.SET3_ID);
String expectedPairField = String.format("[\"%s\",\"%s\"]", MetadataFileBuilder.PAIR1_ID, MetadataFileBuilder.PAIR2_ID);
assertEquals(expectedSetField, entities.get(0).getData().get("sets").getValue());
assertEquals(expectedPairField, entities.get(0).getData().get("pairs").getValue());
assertTrue(entities.stream().allMatch(e -> e.getId() != null));
}
}
use of com.epam.pipeline.entity.metadata.MetadataEntity in project cloud-pipeline by epam.
the class MetadataEntityConverterTest method shouldFailIfParticipantSetWithoutParticipants.
@Test(expected = IllegalStateException.class)
public void shouldFailIfParticipantSetWithoutParticipants() {
Map<String, PipeConfValue> participantSetData = new HashMap<>();
participantSetData.put(TEST_ARGUMENT1, new PipeConfValue(STRING_TYPE, TEST_VALUE_2));
MetadataEntity participantSet = getEntity(participantSetClass, "HCC_participants", participantSetData);
MetadataEntityConverter.convert(Collections.singletonList(participantSet));
}
use of com.epam.pipeline.entity.metadata.MetadataEntity in project cloud-pipeline by epam.
the class MetadataEntityConverterTest method shouldFailWithMissingColumnInData.
@Test(expected = IllegalStateException.class)
public void shouldFailWithMissingColumnInData() {
Map<String, PipeConfValue> participantData1 = new HashMap<>();
participantData1.put(TEST_ARGUMENT1, new PipeConfValue(STRING_TYPE, TEST_VALUE_1));
participantData1.put(TEST_ARGUMENT2, new PipeConfValue(STRING_TYPE, "F"));
MetadataEntity participant1 = getEntity(participantClass, PARTICIPANT_ENTITY_ID1, participantData1);
Map<String, PipeConfValue> participantData2 = new HashMap<>();
participantData2.put(TEST_ARGUMENT2, new PipeConfValue(STRING_TYPE, "M"));
MetadataEntity participant2 = getEntity(participantClass, PARTICIPANT_ENTITY_ID2, participantData2);
List<MetadataEntity> entities = new ArrayList<>();
entities.add(participant1);
entities.add(participant2);
MetadataEntityConverter.convert(entities);
}
Aggregations