use of com.epam.pipeline.entity.metadata.MetadataClass in project cloud-pipeline by epam.
the class MetadataUploadManagerTest method prepareRequiredEntities.
private Folder prepareRequiredEntities() {
when(authManager.getAuthorizedUser()).thenReturn("user");
Folder folder = createFolder();
MetadataClass participantClass = entityManager.createMetadataClass(MetadataFileBuilder.PARTICIPANT_CLASS_NAME);
MetadataClass pairClass = entityManager.createMetadataClass(MetadataFileBuilder.PAIR_CLASS_NAME);
entityManager.updateMetadataEntity(createEntityVO(folder.getId(), participantClass.getId(), MetadataFileBuilder.PARTICIPANT1_ID));
entityManager.updateMetadataEntity(createEntityVO(folder.getId(), participantClass.getId(), MetadataFileBuilder.PARTICIPANT2_ID));
entityManager.updateMetadataEntity(createEntityVO(folder.getId(), pairClass.getId(), MetadataFileBuilder.PAIR1_ID));
entityManager.updateMetadataEntity(createEntityVO(folder.getId(), pairClass.getId(), MetadataFileBuilder.PAIR2_ID));
return folder;
}
use of com.epam.pipeline.entity.metadata.MetadataClass 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.MetadataClass 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.MetadataClass in project cloud-pipeline by epam.
the class MetadataEntityConverterTest method shouldFailIfFireCloudClassIsNull.
@Test(expected = IllegalArgumentException.class)
public void shouldFailIfFireCloudClassIsNull() {
MetadataClass entityClass = new MetadataClass();
entityClass.setName(PARTICIPANT_TYPE_NAME);
Map<String, PipeConfValue> participantData = new HashMap<>();
participantData.put(TEST_ARGUMENT1, new PipeConfValue(STRING_TYPE, TEST_VALUE_1));
MetadataEntity participant = getEntity(entityClass, PARTICIPANT_ENTITY_ID1, participantData);
MetadataEntityConverter.convert(Collections.singletonList(participant));
}
use of com.epam.pipeline.entity.metadata.MetadataClass in project cloud-pipeline by epam.
the class FolderManagerTest method shouldCloneFolderWithMetadataEntities.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void shouldCloneFolderWithMetadataEntities() {
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));
MetadataClass metadataClass = metadataEntityManager.createMetadataClass(TEST_NAME);
MetadataEntityVO metadataEntity = new MetadataEntityVO();
metadataEntity.setParentId(sourceFolder.getId());
metadataEntity.setClassName(metadataClass.getName());
metadataEntity.setClassId(metadataClass.getId());
metadataEntity.setData(metadata);
metadataEntity.setEntityName(TEST_NAME);
MetadataEntity expectedMetadata = metadataEntityManager.updateMetadataEntity(metadataEntity);
Folder childSourceFolder = new Folder();
childSourceFolder.setName(CHILD_FOLDER_TO_CLONE);
childSourceFolder.setParentId(sourceFolder.getId());
folderManager.create(childSourceFolder);
metadataEntity.setParentId(childSourceFolder.getId());
metadataEntityManager.updateMetadataEntity(metadataEntity);
Folder destinationFolder = new Folder();
destinationFolder.setName(TEST_NAME);
folderManager.create(destinationFolder);
folderManager.cloneFolder(sourceFolder.getId(), destinationFolder.getId(), TEST_CLONE_PREFIX);
destinationFolder = folderManager.loadByNameOrId(TEST_NAME);
destinationFolder = folderManager.load(destinationFolder.getId());
Folder clonedFolder = destinationFolder.getChildFolders().get(0);
MetadataEntity clonedMetadata = metadataEntityManager.loadMetadataEntityByClassNameAndFolderId(clonedFolder.getId(), metadataClass.getName()).get(0);
assertMetadataEntity(expectedMetadata, clonedMetadata);
Folder clonedChildFolder = clonedFolder.getChildFolders().get(0);
clonedMetadata = metadataEntityManager.loadMetadataEntityByClassNameAndFolderId(clonedChildFolder.getId(), metadataClass.getName()).get(0);
assertMetadataEntity(expectedMetadata, clonedMetadata);
}
Aggregations