Search in sources :

Example 1 with EntityContainer

use of com.epam.pipeline.elasticsearchagent.model.EntityContainer in project cloud-pipeline by epam.

the class FolderLoaderTest method shouldLoadFolder.

@Test
void shouldLoadFolder() throws EntityNotFoundException {
    Folder expectedFolder = new Folder(1L);
    expectedFolder.setName(TEST_NAME);
    expectedFolder.setParentId(1L);
    expectedFolder.setOwner(TEST_NAME);
    FolderLoader loader = new FolderLoader(apiClient);
    when(apiClient.loadPipelineFolder(anyLong())).thenReturn(expectedFolder);
    Optional<EntityContainer<Folder>> container = loader.loadEntity(1L);
    EntityContainer<Folder> folderEntityContainer = container.orElseThrow(AssertionError::new);
    Folder actualFolder = folderEntityContainer.getEntity();
    assertNotNull(actualFolder);
    assertEquals(expectedFolder.getName(), actualFolder.getName());
    assertEquals(expectedFolder.getId(), actualFolder.getId());
    assertEquals(expectedFolder.getParentId(), actualFolder.getParentId());
    verifyPipelineUser(folderEntityContainer.getOwner());
    verifyPermissions(PERMISSIONS_CONTAINER_WITH_OWNER, folderEntityContainer.getPermissions());
    verifyMetadata(EXPECTED_METADATA, new ArrayList<>(folderEntityContainer.getMetadata().values()));
}
Also used : EntityContainer(com.epam.pipeline.elasticsearchagent.model.EntityContainer) Folder(com.epam.pipeline.entity.pipeline.Folder) Test(org.junit.jupiter.api.Test)

Example 2 with EntityContainer

use of com.epam.pipeline.elasticsearchagent.model.EntityContainer in project cloud-pipeline by epam.

the class IssueLoaderTest method shouldLoadIssueTest.

@Test
void shouldLoadIssueTest() throws EntityNotFoundException {
    Attachment attachment = new Attachment();
    attachment.setPath(TEST_PATH);
    attachment.setOwner(USER_NAME);
    IssueComment comment = IssueComment.builder().author(USER_NAME).text(TEST_DESCRIPTION).build();
    EntityVO entity = new EntityVO(1L, AclClass.TOOL);
    Issue expectedIssue = Issue.builder().id(1L).name(TEST_NAME).text(TEST_DESCRIPTION).status(IssueStatus.OPEN).labels(Collections.singletonList(TEST_LABEL)).attachments(Collections.singletonList(attachment)).comments(Collections.singletonList(comment)).entity(entity).author(TEST_NAME).build();
    IssueLoader issueLoader = new IssueLoader(apiClient);
    when(apiClient.loadIssue(anyLong())).thenReturn(expectedIssue);
    Optional<EntityContainer<Issue>> container = issueLoader.loadEntity(1L);
    EntityContainer<Issue> issueEntityContainer = container.orElseThrow(AssertionError::new);
    Issue actualIssue = issueEntityContainer.getEntity();
    assertNotNull(actualIssue);
    verifyIssue(expectedIssue, actualIssue);
    verifyPipelineUser(issueEntityContainer.getOwner());
    verifyPermissions(PERMISSIONS_CONTAINER_WITH_OWNER, issueEntityContainer.getPermissions());
    verifyMetadata(EXPECTED_METADATA, new ArrayList<>(issueEntityContainer.getMetadata().values()));
}
Also used : EntityVO(com.epam.pipeline.vo.EntityVO) LoaderVerificationUtils.verifyIssue(com.epam.pipeline.elasticsearchagent.LoaderVerificationUtils.verifyIssue) Issue(com.epam.pipeline.entity.issue.Issue) IssueComment(com.epam.pipeline.entity.issue.IssueComment) EntityContainer(com.epam.pipeline.elasticsearchagent.model.EntityContainer) Attachment(com.epam.pipeline.entity.issue.Attachment) Test(org.junit.jupiter.api.Test)

Example 3 with EntityContainer

use of com.epam.pipeline.elasticsearchagent.model.EntityContainer in project cloud-pipeline by epam.

the class MetadataEntityLoaderTest method shouldLoadMetadataEntityTest.

@Test
void shouldLoadMetadataEntityTest() throws EntityNotFoundException {
    MetadataClass metadataClass = new MetadataClass(1L, "Sample");
    MetadataEntity expectedMetadataEntity = new MetadataEntity();
    expectedMetadataEntity.setClassEntity(metadataClass);
    expectedMetadataEntity.setId(1L);
    expectedMetadataEntity.setExternalId("external");
    expectedMetadataEntity.setParent(new Folder(1L));
    expectedMetadataEntity.setName(TEST_NAME);
    expectedMetadataEntity.setOwner(TEST_NAME);
    expectedMetadataEntity.setData(Collections.singletonMap(TEST_KEY, new PipeConfValue("string", TEST_VALUE)));
    MetadataEntityLoader metadataEntityLoader = new MetadataEntityLoader(apiClient);
    when(apiClient.loadMetadataEntity(anyLong())).thenReturn(expectedMetadataEntity);
    Optional<EntityContainer<MetadataEntity>> container = metadataEntityLoader.loadEntity(1L);
    EntityContainer<MetadataEntity> metadataEntityContainer = container.orElseThrow(AssertionError::new);
    MetadataEntity actualMetadataEntity = metadataEntityContainer.getEntity();
    assertNotNull(actualMetadataEntity);
    verifyMetadataEntity(expectedMetadataEntity, actualMetadataEntity);
    verifyPermissions(PERMISSIONS_CONTAINER_WITH_OWNER, metadataEntityContainer.getPermissions());
    verifyMetadata(EXPECTED_METADATA, new ArrayList<>(metadataEntityContainer.getMetadata().values()));
}
Also used : LoaderVerificationUtils.verifyMetadataEntity(com.epam.pipeline.elasticsearchagent.LoaderVerificationUtils.verifyMetadataEntity) MetadataEntity(com.epam.pipeline.entity.metadata.MetadataEntity) MetadataClass(com.epam.pipeline.entity.metadata.MetadataClass) PipeConfValue(com.epam.pipeline.entity.metadata.PipeConfValue) EntityContainer(com.epam.pipeline.elasticsearchagent.model.EntityContainer) Folder(com.epam.pipeline.entity.pipeline.Folder) Test(org.junit.jupiter.api.Test)

Example 4 with EntityContainer

use of com.epam.pipeline.elasticsearchagent.model.EntityContainer in project cloud-pipeline by epam.

the class PipelineRunLoaderTest method shouldLoadPipelineRunTest.

@Test
void shouldLoadPipelineRunTest() throws EntityNotFoundException {
    RunInstance instance = new RunInstance();
    instance.setNodeType("type");
    instance.setAwsRegionId(TEST_REGION);
    instance.setSpot(true);
    instance.setNodeDisk(NODE_DISK);
    instance.setNodeId("id");
    instance.setNodeImage(TEST_PATH);
    instance.setNodeName(TEST_NAME);
    RunStatus runStatus = new RunStatus();
    runStatus.setRunId(1L);
    runStatus.setStatus(TaskStatus.SUCCESS);
    PipelineRunParameter parameter = new PipelineRunParameter();
    parameter.setName(TEST_NAME);
    parameter.setValue(TEST_VALUE);
    PipelineRun expectedPipelineRun = new PipelineRun();
    expectedPipelineRun.setId(1L);
    expectedPipelineRun.setName(TEST_NAME);
    expectedPipelineRun.setPipelineName(TEST_NAME);
    expectedPipelineRun.setPipelineId(1L);
    expectedPipelineRun.setInstance(instance);
    expectedPipelineRun.setStatus(TaskStatus.SUCCESS);
    expectedPipelineRun.setVersion(TEST_VERSION);
    expectedPipelineRun.setRunStatuses(Collections.singletonList(runStatus));
    expectedPipelineRun.setPricePerHour(PRICE);
    expectedPipelineRun.setOwner(TEST_NAME);
    expectedPipelineRun.setPipelineRunParameters(Collections.singletonList(parameter));
    RunLog runLog = new RunLog();
    runLog.setLogText(TEST_DESCRIPTION);
    runLog.setStatus(TaskStatus.SUCCESS);
    runLog.setTask(new PipelineTask(TEST_NAME));
    List<RunLog> runLogs = Collections.singletonList(runLog);
    PipelineRunWithLog expectedPipelineRunWithLog = new PipelineRunWithLog();
    expectedPipelineRunWithLog.setPipelineRun(expectedPipelineRun);
    expectedPipelineRunWithLog.setRunOwner(USER);
    expectedPipelineRunWithLog.setRunLogs(runLogs);
    PipelineRunLoader pipelineRunLoader = new PipelineRunLoader(apiClient);
    when(apiClient.loadPipelineRunWithLogs(anyLong())).thenReturn(expectedPipelineRunWithLog);
    when(apiClient.loadPipelineRun(anyLong())).thenReturn(expectedPipelineRun);
    Optional<EntityContainer<PipelineRunWithLog>> container = pipelineRunLoader.loadEntity(1L);
    EntityContainer<PipelineRunWithLog> pipelineRunEntityContainer = container.orElseThrow(AssertionError::new);
    PipelineRunWithLog actualPipelineRunWithLog = pipelineRunEntityContainer.getEntity();
    assertNotNull(actualPipelineRunWithLog);
    PipelineRun actualPipelineRun = actualPipelineRunWithLog.getPipelineRun();
    assertNotNull(actualPipelineRun);
    List<RunLog> actualRunLogs = actualPipelineRunWithLog.getRunLogs();
    assertNotNull(actualRunLogs);
    verifyPipelineRun(expectedPipelineRun, actualPipelineRun);
    verifyRunInstance(expectedPipelineRun.getInstance(), actualPipelineRun.getInstance());
    verifyRunStatuses(expectedPipelineRun.getRunStatuses(), actualPipelineRun.getRunStatuses());
    verifyRunParameters(expectedPipelineRun.getPipelineRunParameters(), actualPipelineRun.getPipelineRunParameters());
    verifyRunLogs(runLogs, actualRunLogs);
    verifyPipelineUser(pipelineRunEntityContainer.getOwner());
    verifyPermissions(PERMISSIONS_CONTAINER_WITH_OWNER, pipelineRunEntityContainer.getPermissions());
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) LoaderVerificationUtils.verifyPipelineRun(com.epam.pipeline.elasticsearchagent.LoaderVerificationUtils.verifyPipelineRun) RunStatus(com.epam.pipeline.entity.pipeline.run.RunStatus) RunLog(com.epam.pipeline.entity.pipeline.RunLog) EntityContainer(com.epam.pipeline.elasticsearchagent.model.EntityContainer) LoaderVerificationUtils.verifyRunInstance(com.epam.pipeline.elasticsearchagent.LoaderVerificationUtils.verifyRunInstance) RunInstance(com.epam.pipeline.entity.pipeline.RunInstance) PipelineTask(com.epam.pipeline.entity.pipeline.PipelineTask) PipelineRunWithLog(com.epam.pipeline.elasticsearchagent.model.PipelineRunWithLog) PipelineRunParameter(com.epam.pipeline.entity.pipeline.run.parameter.PipelineRunParameter) Test(org.junit.jupiter.api.Test)

Example 5 with EntityContainer

use of com.epam.pipeline.elasticsearchagent.model.EntityContainer in project cloud-pipeline by epam.

the class DataStorageLoaderTest method shouldLoadDataStorageTest.

@Test
void shouldLoadDataStorageTest() throws EntityNotFoundException {
    StoragePolicy policy = new StoragePolicy();
    policy.setBackupDuration(DURATION);
    policy.setLongTermStorageDuration(DURATION);
    policy.setShortTermStorageDuration(DURATION);
    S3bucketDataStorage expectedDataStorage = new S3bucketDataStorage();
    expectedDataStorage.setId(1L);
    expectedDataStorage.setParentFolderId(1L);
    expectedDataStorage.setName(TEST_NAME);
    expectedDataStorage.setPath(TEST_PATH);
    expectedDataStorage.setOwner(TEST_NAME);
    expectedDataStorage.setStoragePolicy(policy);
    DataStorageLoader dataStorageLoader = new DataStorageLoader(apiClient);
    when(apiClient.loadDataStorage(anyLong())).thenReturn(expectedDataStorage);
    Optional<EntityContainer<DataStorageDoc>> container = dataStorageLoader.loadEntity(1L);
    EntityContainer<DataStorageDoc> storageDocEntityContainer = container.orElseThrow(AssertionError::new);
    DataStorageDoc actualDataStorageDoc = storageDocEntityContainer.getEntity();
    assertNotNull(actualDataStorageDoc);
    AbstractDataStorage actualDataStorage = actualDataStorageDoc.getStorage();
    verifyDataStorage(expectedDataStorage, actualDataStorage);
    verifyPipelineUser(storageDocEntityContainer.getOwner());
    verifyPermissions(PERMISSIONS_CONTAINER_WITH_OWNER, storageDocEntityContainer.getPermissions());
    verifyMetadata(EXPECTED_METADATA, new ArrayList<>(storageDocEntityContainer.getMetadata().values()));
}
Also used : AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) DataStorageDoc(com.epam.pipeline.elasticsearchagent.model.DataStorageDoc) EntityContainer(com.epam.pipeline.elasticsearchagent.model.EntityContainer) S3bucketDataStorage(com.epam.pipeline.entity.datastorage.S3bucketDataStorage) StoragePolicy(com.epam.pipeline.entity.datastorage.StoragePolicy) Test(org.junit.jupiter.api.Test)

Aggregations

EntityContainer (com.epam.pipeline.elasticsearchagent.model.EntityContainer)11 Test (org.junit.jupiter.api.Test)10 Pipeline (com.epam.pipeline.entity.pipeline.Pipeline)3 PipelineDoc (com.epam.pipeline.elasticsearchagent.model.PipelineDoc)2 Folder (com.epam.pipeline.entity.pipeline.Folder)2 Revision (com.epam.pipeline.entity.pipeline.Revision)2 LoaderVerificationUtils.verifyIssue (com.epam.pipeline.elasticsearchagent.LoaderVerificationUtils.verifyIssue)1 LoaderVerificationUtils.verifyMetadataEntity (com.epam.pipeline.elasticsearchagent.LoaderVerificationUtils.verifyMetadataEntity)1 LoaderVerificationUtils.verifyPipeline (com.epam.pipeline.elasticsearchagent.LoaderVerificationUtils.verifyPipeline)1 LoaderVerificationUtils.verifyPipelineRun (com.epam.pipeline.elasticsearchagent.LoaderVerificationUtils.verifyPipelineRun)1 LoaderVerificationUtils.verifyRunInstance (com.epam.pipeline.elasticsearchagent.LoaderVerificationUtils.verifyRunInstance)1 LoaderVerificationUtils.verifyTool (com.epam.pipeline.elasticsearchagent.LoaderVerificationUtils.verifyTool)1 LoaderVerificationUtils.verifyToolGroup (com.epam.pipeline.elasticsearchagent.LoaderVerificationUtils.verifyToolGroup)1 PipelineEventDao (com.epam.pipeline.elasticsearchagent.dao.PipelineEventDao)1 EntityNotFoundException (com.epam.pipeline.elasticsearchagent.exception.EntityNotFoundException)1 DataStorageDoc (com.epam.pipeline.elasticsearchagent.model.DataStorageDoc)1 EventType (com.epam.pipeline.elasticsearchagent.model.EventType)1 PipelineEvent (com.epam.pipeline.elasticsearchagent.model.PipelineEvent)1 PipelineRunWithLog (com.epam.pipeline.elasticsearchagent.model.PipelineRunWithLog)1 RunConfigurationDoc (com.epam.pipeline.elasticsearchagent.model.RunConfigurationDoc)1