use of com.epam.pipeline.entity.pipeline.Tool in project cloud-pipeline by epam.
the class DockerRegistryManagerTest method testLoadingImageTags.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testLoadingImageTags() {
DockerRegistry registry = generateRegistry();
registryDao.createDockerRegistry(registry);
ToolGroup group = generateToolGroup(registry);
toolGroupDao.createToolGroup(group);
Tool tool = generateTool(group);
toolManager.create(tool, true);
DockerClient mockClient = Mockito.mock(DockerClient.class);
when(dockerClientFactoryMock.getDockerClient(any(DockerRegistry.class), any())).thenReturn(mockClient);
List<String> expected = Arrays.asList("TAG1", "TAG2");
when(mockClient.getImageTags(ANOTHER_PATH, TEST_IMAGE)).thenReturn(expected);
Assert.assertEquals(expected, dockerRegistryManager.loadImageTags(registry, tool));
}
use of com.epam.pipeline.entity.pipeline.Tool in project cloud-pipeline by epam.
the class DockerRegistryManagerTest method testDelete.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void testDelete() {
TestUtils.configureDockerClientMock(Mockito.mock(DockerClient.class), dockerClientFactoryMock);
DockerRegistry registry = generateRegistry();
registryDao.createDockerRegistry(registry);
ToolGroup group = generateToolGroup(registry);
toolGroupDao.createToolGroup(group);
Tool tool = generateTool(group);
toolManager.create(tool, true);
dockerRegistryManager.delete(registry.getId(), true);
}
use of com.epam.pipeline.entity.pipeline.Tool in project cloud-pipeline by epam.
the class DockerRegistryManagerTest method testLoadingImageDescription.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testLoadingImageDescription() {
DockerRegistry registry = generateRegistry();
Date date = new Date();
registryDao.createDockerRegistry(registry);
ToolGroup group = generateToolGroup(registry);
toolGroupDao.createToolGroup(group);
Tool tool = generateTool(group);
toolManager.create(tool, true);
DockerClient mockClient = Mockito.mock(DockerClient.class);
when(dockerClientFactoryMock.getDockerClient(any(DockerRegistry.class), any())).thenReturn(mockClient);
ImageDescription expected = new ImageDescription(1L, TEST_IMAGE, TEST_TAG, date);
when(mockClient.getImageDescription(registry, tool.getName(), TEST_TAG)).thenReturn(expected);
Assert.assertEquals(expected, dockerRegistryManager.getImageDescription(registry, tool.getName(), TEST_TAG));
}
use of com.epam.pipeline.entity.pipeline.Tool in project cloud-pipeline by epam.
the class ToolGroupEventServiceTest method shouldAddToolGroupEvent.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void shouldAddToolGroupEvent() {
doNothing().when(entityManager).setManagers(anyListOf(SecuredEntityManager.class));
Tool tool1 = new Tool();
tool1.setId(1L);
Tool tool2 = new Tool();
tool2.setId(2L);
when(issueManager.loadIssuesForEntity(any())).thenReturn(Arrays.asList(Issue.builder().id(1L).build(), Issue.builder().id(2L).build()));
when(toolManager.loadToolsByGroup(anyLong())).thenReturn(Arrays.asList(tool1, tool2));
doNothing().when(eventDao).insertUpdateEvent(anyString(), anyLong());
toolGroupEventService.updateEventsWithChildrenAndIssues(1L);
verify(eventDao).insertUpdateEvent("tool_group", 1L);
verify(eventDao).insertUpdateEvent("tool", 1L);
verify(eventDao).insertUpdateEvent("tool", 2L);
// 1 toolGroup + 2 tool
verify(eventDao, times(3)).insertUpdateEvent("issue", 1L);
verify(eventDao, times(3)).insertUpdateEvent("issue", 2L);
verifyNoMoreInteractions(eventDao);
}
use of com.epam.pipeline.entity.pipeline.Tool in project cloud-pipeline by epam.
the class ToolApiServiceTest method testCreate.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
@WithMockUser(username = TEST_USER)
public void testCreate() {
Tool tool = generateTool();
tool.setToolGroupId(allowedGroup.getId());
tool.setToolGroup(allowedGroup.getName());
toolApiService.create(tool);
}
Aggregations