use of com.epam.pipeline.entity.pipeline.Folder 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.pipeline.Folder 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.pipeline.Folder in project cloud-pipeline by epam.
the class MetadataUploadManagerTest method uploadingMetadataWithConstantFieldTypesPerformsProperly.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void uploadingMetadataWithConstantFieldTypesPerformsProperly() throws IOException {
Folder folder = prepareRequiredEntities();
entityManager.createMetadataClass(MetadataFileBuilder.SAMPLE_CLASS_NAME);
assertEquals(1, uploadMetadata(folder, Arrays.asList(HEADER1, LINE1)).size());
assertEquals(1, uploadMetadata(folder, Arrays.asList(HEADER2, LINE2)).size());
}
use of com.epam.pipeline.entity.pipeline.Folder 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.pipeline.Folder in project cloud-pipeline by epam.
the class MetadataUploadManagerTest method createFolder.
private Folder createFolder() {
Folder folder = new Folder();
folder.setName("test");
folderManager.create(folder);
return folder;
}
Aggregations