use of com.epam.pipeline.entity.pipeline.Pipeline in project cloud-pipeline by epam.
the class PipelineDaoTest method getPipeline.
private Pipeline getPipeline(String name) {
Pipeline pipeline = new Pipeline();
pipeline.setName(name);
pipeline.setRepository(TEST_REPO);
pipeline.setOwner(TEST_USER);
return pipeline;
}
use of com.epam.pipeline.entity.pipeline.Pipeline in project cloud-pipeline by epam.
the class PipelineDaoTest method testMovePipeline.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testMovePipeline() {
Pipeline pipeline = getPipeline(TEST_NAME);
pipelineDao.createPipeline(pipeline);
assertNull(pipeline.getParentFolderId());
Folder folder = getFolder();
folderDao.createFolder(folder);
pipeline.setParentFolderId(folder.getId());
pipelineDao.updatePipeline(pipeline);
assertEquals(folder.getId(), pipelineDao.loadPipeline(pipeline.getId()).getParentFolderId());
pipeline.setParentFolderId(null);
pipelineDao.updatePipeline(pipeline);
assertNull(pipeline.getParentFolderId());
}
use of com.epam.pipeline.entity.pipeline.Pipeline in project cloud-pipeline by epam.
the class FolderEventServiceTest method shouldAddFolderEvent.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void shouldAddFolderEvent() {
doNothing().when(entityManager).setManagers(anyListOf(SecuredEntityManager.class));
Folder folder2 = new Folder(2L);
Pipeline pipeline = new Pipeline(1L);
S3bucketDataStorage dataStorage = new S3bucketDataStorage(1L, "", "");
RunConfiguration runConfiguration = new RunConfiguration();
runConfiguration.setId(1L);
MetadataEntity metadataEntity = new MetadataEntity();
metadataEntity.setClassEntity(new MetadataClass(1L, METADATA_CLASS_NAME));
metadataEntity.setId(1L);
Folder folder1 = new Folder(1L);
folder1.setChildFolders(Collections.singletonList(folder2));
folder1.setPipelines(Collections.singletonList(pipeline));
folder1.setStorages(Collections.singletonList(dataStorage));
folder1.setConfigurations(Collections.singletonList(runConfiguration));
folder1.setMetadata(Collections.singletonMap(METADATA_CLASS_NAME, 1));
when(issueManager.loadIssuesForEntity(any())).thenReturn(Arrays.asList(Issue.builder().id(1L).build(), Issue.builder().id(2L).build()));
when(pipelineRunManager.loadAllRunsByPipeline(anyLong())).thenReturn(Arrays.asList(new PipelineRun(1L, ""), new PipelineRun(2L, "")));
when(dataStorageManager.load(1L)).thenReturn(dataStorage);
when(folderManager.load(1L)).thenReturn(folder1);
when(folderManager.load(2L)).thenReturn(folder2);
when(metadataEntityManager.loadMetadataEntityByClassNameAndFolderId(anyLong(), anyString())).thenReturn(Collections.singletonList(metadataEntity));
doNothing().when(eventDao).insertUpdateEvent(anyString(), anyLong());
folderEventService.updateEventsWithChildrenAndIssues(1L);
verify(eventDao).insertUpdateEvent("folder", 1L);
verify(eventDao).insertUpdateEvent("folder", 2L);
verify(eventDao).insertUpdateEvent("pipeline", 1L);
verify(eventDao).insertUpdateEvent("run", 1L);
verify(eventDao).insertUpdateEvent("run", 2L);
verify(eventDao).insertUpdateEvent("S3", 1L);
verify(eventDao).insertUpdateEvent("configuration", 1L);
verify(eventDao).insertUpdateEvent("metadata_entity", 1L);
verify(eventDao, times(6)).insertUpdateEvent("issue", 1L);
verify(eventDao, times(6)).insertUpdateEvent("issue", 2L);
verifyNoMoreInteractions(eventDao);
}
use of com.epam.pipeline.entity.pipeline.Pipeline in project cloud-pipeline by epam.
the class GitManagerTest method shouldCreateFolder.
@Test
public void shouldCreateFolder() throws GitClientException {
final Pipeline pipeline = testingPipeline();
final PipelineSourceItemVO folder = new PipelineSourceItemVO();
folder.setPath(DOCS);
folder.setLastCommitId(pipeline.getCurrentVersion().getCommitId());
final GitRepositoryEntry bla = new GitRepositoryEntry();
bla.setName(README_FILE);
bla.setType(BLOB_TYPE);
bla.setPath(DOCS + "/" + README_FILE);
final List<GitRepositoryEntry> tree = singletonList(bla);
givenThat(get(urlPathEqualTo(api(REPOSITORY_TREE))).withQueryParam(REF_NAME, equalTo(GIT_MASTER_REPOSITORY)).withQueryParam(PATH, equalTo(DOCS)).willReturn(okJson(with(tree))));
final GitFile file = new GitFile();
file.setContent(Base64.getEncoder().encodeToString(FILE_CONTENT.getBytes()));
givenThat(get(urlPathEqualTo(api(REPOSITORY_FILES))).withQueryParam(FILE_PATH, equalTo(DOCS + File.separator + ".gitkeep")).withQueryParam(REF, equalTo(GIT_MASTER_REPOSITORY)).willReturn(okJson(with(file))));
final GitCommitEntry expectedCommit = new GitCommitEntry();
givenThat(post(urlPathEqualTo(api(REPOSITORY_COMMITS))).willReturn(okJson(with(expectedCommit))));
final GitCommitEntry resultingCommit = gitManager.createOrRenameFolder(pipeline.getId(), folder);
assertThat(resultingCommit, is(expectedCommit));
}
use of com.epam.pipeline.entity.pipeline.Pipeline in project cloud-pipeline by epam.
the class GitManagerTest method shouldNotFailWhenCreateFile.
@Test
public void shouldNotFailWhenCreateFile() throws GitClientException {
final GitFile gitFile = new GitFile();
gitFile.setContent(Base64.getEncoder().encodeToString(FILE_CONTENT.getBytes()));
givenThat(get(urlPathEqualTo(api(REPOSITORY_FILES))).withQueryParam(FILE_PATH, equalTo(DOCS + "/created_file.txt")).withQueryParam(REF, equalTo(GIT_MASTER_REPOSITORY)).willReturn(okJson(with(gitFile))));
final GitCommitEntry expectedCommit = new GitCommitEntry();
givenThat(post(urlPathEqualTo(api(REPOSITORY_COMMITS))).willReturn(okJson(with(expectedCommit))));
final Pipeline pipeline = testingPipeline();
final GitCommitEntry resultingCommit = gitManager.updateFile(pipeline, DOCS + "/created_file.txt", FILE_CONTENT, "last commit id doesn't matter", "Create file");
assertThat(resultingCommit, is(expectedCommit));
}
Aggregations