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()));
}
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()));
}
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()));
}
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());
}
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()));
}
Aggregations