Search in sources :

Example 26 with Folder

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));
    }
}
Also used : MockMultipartFile(org.springframework.mock.web.MockMultipartFile) Arrays(java.util.Arrays) MetadataEntityVO(com.epam.pipeline.controller.vo.metadata.MetadataEntityVO) SpyBean(org.springframework.boot.test.mock.mockito.SpyBean) FolderManager(com.epam.pipeline.manager.pipeline.FolderManager) MetadataParsingUtils(com.epam.pipeline.manager.utils.MetadataParsingUtils) com.epam.pipeline.manager.metadata.parser(com.epam.pipeline.manager.metadata.parser) Assert.assertTrue(org.junit.Assert.assertTrue) Autowired(org.springframework.beans.factory.annotation.Autowired) IOException(java.io.IOException) MetadataReadingException(com.epam.pipeline.exception.MetadataReadingException) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) MockMultipartFile(org.springframework.mock.web.MockMultipartFile) List(java.util.List) Folder(com.epam.pipeline.entity.pipeline.Folder) MetadataEntity(com.epam.pipeline.entity.metadata.MetadataEntity) Propagation(org.springframework.transaction.annotation.Propagation) AuthManager(com.epam.pipeline.manager.security.AuthManager) MetadataClass(com.epam.pipeline.entity.metadata.MetadataClass) Assert.assertEquals(org.junit.Assert.assertEquals) InputStream(java.io.InputStream) Transactional(org.springframework.transaction.annotation.Transactional) MetadataEntity(com.epam.pipeline.entity.metadata.MetadataEntity) InputStream(java.io.InputStream) Folder(com.epam.pipeline.entity.pipeline.Folder) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 27 with Folder

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()));
    }
}
Also used : MockMultipartFile(org.springframework.mock.web.MockMultipartFile) Arrays(java.util.Arrays) MetadataEntityVO(com.epam.pipeline.controller.vo.metadata.MetadataEntityVO) SpyBean(org.springframework.boot.test.mock.mockito.SpyBean) FolderManager(com.epam.pipeline.manager.pipeline.FolderManager) MetadataParsingUtils(com.epam.pipeline.manager.utils.MetadataParsingUtils) com.epam.pipeline.manager.metadata.parser(com.epam.pipeline.manager.metadata.parser) Assert.assertTrue(org.junit.Assert.assertTrue) Autowired(org.springframework.beans.factory.annotation.Autowired) IOException(java.io.IOException) MetadataReadingException(com.epam.pipeline.exception.MetadataReadingException) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) MockMultipartFile(org.springframework.mock.web.MockMultipartFile) List(java.util.List) Folder(com.epam.pipeline.entity.pipeline.Folder) MetadataEntity(com.epam.pipeline.entity.metadata.MetadataEntity) Propagation(org.springframework.transaction.annotation.Propagation) AuthManager(com.epam.pipeline.manager.security.AuthManager) MetadataClass(com.epam.pipeline.entity.metadata.MetadataClass) Assert.assertEquals(org.junit.Assert.assertEquals) InputStream(java.io.InputStream) Transactional(org.springframework.transaction.annotation.Transactional) MetadataEntity(com.epam.pipeline.entity.metadata.MetadataEntity) MetadataClass(com.epam.pipeline.entity.metadata.MetadataClass) InputStream(java.io.InputStream) Folder(com.epam.pipeline.entity.pipeline.Folder) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 28 with Folder

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());
}
Also used : Folder(com.epam.pipeline.entity.pipeline.Folder) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 29 with Folder

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));
    }
}
Also used : MockMultipartFile(org.springframework.mock.web.MockMultipartFile) Arrays(java.util.Arrays) MetadataEntityVO(com.epam.pipeline.controller.vo.metadata.MetadataEntityVO) SpyBean(org.springframework.boot.test.mock.mockito.SpyBean) FolderManager(com.epam.pipeline.manager.pipeline.FolderManager) MetadataParsingUtils(com.epam.pipeline.manager.utils.MetadataParsingUtils) com.epam.pipeline.manager.metadata.parser(com.epam.pipeline.manager.metadata.parser) Assert.assertTrue(org.junit.Assert.assertTrue) Autowired(org.springframework.beans.factory.annotation.Autowired) IOException(java.io.IOException) MetadataReadingException(com.epam.pipeline.exception.MetadataReadingException) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) MockMultipartFile(org.springframework.mock.web.MockMultipartFile) List(java.util.List) Folder(com.epam.pipeline.entity.pipeline.Folder) MetadataEntity(com.epam.pipeline.entity.metadata.MetadataEntity) Propagation(org.springframework.transaction.annotation.Propagation) AuthManager(com.epam.pipeline.manager.security.AuthManager) MetadataClass(com.epam.pipeline.entity.metadata.MetadataClass) Assert.assertEquals(org.junit.Assert.assertEquals) InputStream(java.io.InputStream) Transactional(org.springframework.transaction.annotation.Transactional) MetadataEntity(com.epam.pipeline.entity.metadata.MetadataEntity) MetadataClass(com.epam.pipeline.entity.metadata.MetadataClass) InputStream(java.io.InputStream) Folder(com.epam.pipeline.entity.pipeline.Folder) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 30 with Folder

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;
}
Also used : Folder(com.epam.pipeline.entity.pipeline.Folder)

Aggregations

Folder (com.epam.pipeline.entity.pipeline.Folder)102 Transactional (org.springframework.transaction.annotation.Transactional)53 Test (org.junit.Test)52 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)48 EntityVO (com.epam.pipeline.controller.vo.EntityVO)14 AbstractDataStorage (com.epam.pipeline.entity.datastorage.AbstractDataStorage)14 Pipeline (com.epam.pipeline.entity.pipeline.Pipeline)14 MetadataClass (com.epam.pipeline.entity.metadata.MetadataClass)13 RunConfiguration (com.epam.pipeline.entity.configuration.RunConfiguration)11 MetadataEntity (com.epam.pipeline.entity.metadata.MetadataEntity)11 PipeConfValue (com.epam.pipeline.entity.metadata.PipeConfValue)10 AclClass (com.epam.pipeline.entity.security.acl.AclClass)10 Autowired (org.springframework.beans.factory.annotation.Autowired)8 Propagation (org.springframework.transaction.annotation.Propagation)8 MetadataEntityVO (com.epam.pipeline.controller.vo.metadata.MetadataEntityVO)7 PasswordGenerator.generateRandomString (com.epam.pipeline.utils.PasswordGenerator.generateRandomString)6 FolderWithMetadata (com.epam.pipeline.entity.metadata.FolderWithMetadata)5 DataStorageVO (com.epam.pipeline.controller.vo.DataStorageVO)4 AbstractManagerTest (com.epam.pipeline.manager.AbstractManagerTest)4 Collectors (java.util.stream.Collectors)4