Search in sources :

Example 11 with PipeConfValue

use of com.epam.pipeline.entity.metadata.PipeConfValue 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));
}
Also used : MetadataEntity(com.epam.pipeline.entity.metadata.MetadataEntity) MetadataClass(com.epam.pipeline.entity.metadata.MetadataClass) PipeConfValue(com.epam.pipeline.entity.metadata.PipeConfValue) Test(org.junit.Test)

Example 12 with PipeConfValue

use of com.epam.pipeline.entity.metadata.PipeConfValue in project cloud-pipeline by epam.

the class BucketPostProcessorImplTest method shouldHandleSimpleBucketName.

@Test
public void shouldHandleSimpleBucketName() {
    PipeConfValue value = new PipeConfValue(bucketPostProcessor.supportedType(), BUCKET_NAME_ORIGINAL);
    bucketPostProcessor.process(PARAM_NAME, value);
    assertEquals(BUCKET_NAME_NORMALIZED, value.getValue());
}
Also used : PipeConfValue(com.epam.pipeline.entity.metadata.PipeConfValue) Test(org.junit.Test)

Example 13 with PipeConfValue

use of com.epam.pipeline.entity.metadata.PipeConfValue in project cloud-pipeline by epam.

the class MetadataManagerTest method setup.

@Before
public void setup() {
    expectedData.put(KEY_1, new PipeConfValue(TYPE, VALUE_1));
    expectedData.put(KEY_2, new PipeConfValue(TYPE, VALUE_2));
    metadataEntry.setEntity(entityVO);
    metadataEntry.setData(expectedData);
}
Also used : PipeConfValue(com.epam.pipeline.entity.metadata.PipeConfValue) Before(org.junit.Before)

Example 14 with PipeConfValue

use of com.epam.pipeline.entity.metadata.PipeConfValue in project cloud-pipeline by epam.

the class MetadataManagerTest method assertFileContent.

private void assertFileContent(String exampleContent, String fileName) throws IOException {
    try (InputStream inputStream = IOUtils.toInputStream(exampleContent, "UTF-8")) {
        Map<String, PipeConfValue> actualData = metadataManager.convertFileContentToMetadata(new MockMultipartFile(fileName, fileName, null, inputStream));
        Assert.assertEquals(expectedData, actualData);
    }
}
Also used : MockMultipartFile(org.springframework.mock.web.MockMultipartFile) InputStream(java.io.InputStream) PipeConfValue(com.epam.pipeline.entity.metadata.PipeConfValue)

Example 15 with PipeConfValue

use of com.epam.pipeline.entity.metadata.PipeConfValue in project cloud-pipeline by epam.

the class FolderManagerTest method testGetProjectFolderFromProjectTree.

@Test
public void testGetProjectFolderFromProjectTree() {
    Map<String, PipeConfValue> data = new HashMap<>();
    data.put(DATA_KEY_1, new PipeConfValue(DATA_TYPE_1, DATA_VALUE_1));
    Map<String, PipeConfValue> dataWithIndicator = new HashMap<>();
    dataWithIndicator.put(DATA_KEY_1, new PipeConfValue(DATA_TYPE_1, PROJECT_INDICATOR_VALUE));
    FolderWithMetadata folder = initFolderWithMetadata(new FolderWithMetadata(), 1L, "folder", null, data);
    FolderWithMetadata folder1 = initFolderWithMetadata(new FolderWithMetadata(), 2L, "folder1", folder.getId(), dataWithIndicator);
    FolderWithMetadata folder2 = initFolderWithMetadata(new FolderWithMetadata(), 3L, "folder2", folder1.getId(), data);
    Map<Long, FolderWithMetadata> folders = new HashMap<>();
    folders.put(folder.getId(), folder);
    folders.put(folder1.getId(), folder1);
    folders.put(folder2.getId(), folder2);
    Set<Pair<String, String>> indicators = new HashSet<>();
    indicators.add(new ImmutablePair<>(DATA_KEY_1, PROJECT_INDICATOR_VALUE));
    // case: single indicator
    Folder actualFolder = folderManager.getProjectFolder(folders, folder2.getId(), indicators);
    assertEquals(folder1.getId(), actualFolder.getId());
    assertEquals(folder1.getName(), actualFolder.getName());
    assertEquals(folder1.getParentId(), actualFolder.getParentId());
    assertEquals(folder1.getOwner(), actualFolder.getOwner());
    // case: several indicators
    indicators.add(new ImmutablePair<>(PROJECT_INDICATOR_VALUE, DATA_KEY_1));
    dataWithIndicator = new HashMap<>();
    dataWithIndicator.put(PROJECT_INDICATOR_VALUE, new PipeConfValue(DATA_TYPE_1, DATA_KEY_1));
    folder2.setData(dataWithIndicator);
    folders.put(folder2.getId(), folder2);
    actualFolder = folderManager.getProjectFolder(folders, folder2.getId(), indicators);
    assertEquals(folder2.getId(), actualFolder.getId());
    assertEquals(folder2.getName(), actualFolder.getName());
    assertEquals(folder2.getParentId(), actualFolder.getParentId());
    assertEquals(folder2.getOwner(), actualFolder.getOwner());
    // case: no matches (null parent)
    folder1.setData(data);
    folder2.setData(data);
    folders.put(folder1.getId(), folder1);
    folders.put(folder2.getId(), folder2);
    actualFolder = folderManager.getProjectFolder(folders, folder2.getId(), indicators);
    assertNull(actualFolder);
    // case: no matches (no null parent)
    folders.remove(folder.getId());
    actualFolder = folderManager.getProjectFolder(folders, folder2.getId(), indicators);
    assertNull(actualFolder);
}
Also used : HashMap(java.util.HashMap) PasswordGenerator.generateRandomString(com.epam.pipeline.utils.PasswordGenerator.generateRandomString) Folder(com.epam.pipeline.entity.pipeline.Folder) FolderWithMetadata(com.epam.pipeline.entity.metadata.FolderWithMetadata) PipeConfValue(com.epam.pipeline.entity.metadata.PipeConfValue) Pair(org.apache.commons.lang3.tuple.Pair) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) HashSet(java.util.HashSet) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test)

Aggregations

PipeConfValue (com.epam.pipeline.entity.metadata.PipeConfValue)41 Test (org.junit.Test)24 MetadataEntity (com.epam.pipeline.entity.metadata.MetadataEntity)21 HashMap (java.util.HashMap)11 Transactional (org.springframework.transaction.annotation.Transactional)11 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)9 EntityVO (com.epam.pipeline.controller.vo.EntityVO)9 Folder (com.epam.pipeline.entity.pipeline.Folder)9 MetadataEntry (com.epam.pipeline.entity.metadata.MetadataEntry)8 FolderWithMetadata (com.epam.pipeline.entity.metadata.FolderWithMetadata)5 MetadataClass (com.epam.pipeline.entity.metadata.MetadataClass)5 PasswordGenerator.generateRandomString (com.epam.pipeline.utils.PasswordGenerator.generateRandomString)5 Map (java.util.Map)5 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 MetadataEntityVO (com.epam.pipeline.controller.vo.metadata.MetadataEntityVO)3 MessageConstants (com.epam.pipeline.common.MessageConstants)2 MessageHelper (com.epam.pipeline.common.MessageHelper)2 MetadataVO (com.epam.pipeline.controller.vo.MetadataVO)2 BaseEntity (com.epam.pipeline.entity.BaseEntity)2