Search in sources :

Example 31 with Tool

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

the class PipelineVersionManagerTest method getMockTool.

private Tool getMockTool(String repo, String image) {
    Tool tool = new Tool();
    tool.setRegistry(repo);
    tool.setImage(image);
    return tool;
}
Also used : Tool(com.epam.pipeline.entity.pipeline.Tool)

Example 32 with Tool

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

the class PipelineVersionManagerTest method testDockerImageSetFromConfig.

@Test
public void testDockerImageSetFromConfig() throws GitClientException, IOException {
    Tool mockTool = getMockTool(TEST_REPOSITORY, IMAGE_FROM_CONFIG);
    Mockito.when(gitManager.getConfigFileContent(Mockito.any(Pipeline.class), Mockito.anyString())).thenReturn(getFileContent(WITH_IMAGE_CONFIG));
    Mockito.when(toolManager.loadByNameOrId(IMAGE_FROM_CONFIG)).thenReturn(mockTool);
    PipelineConfiguration configuration = pipelineVersionManager.loadParametersFromScript(1L, "");
    Assert.assertEquals(TEST_REPOSITORY + "/" + IMAGE_FROM_CONFIG, configuration.getDockerImage());
}
Also used : PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) Tool(com.epam.pipeline.entity.pipeline.Tool) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) Test(org.junit.Test) AbstractManagerTest(com.epam.pipeline.manager.AbstractManagerTest)

Example 33 with Tool

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

the class PipelineVersionManagerTest method testImageWithValidRepository.

@Test
public void testImageWithValidRepository() throws GitClientException, IOException {
    Mockito.when(preferenceManager.getPreference(SystemPreferences.LAUNCH_DOCKER_IMAGE)).thenReturn(TEST_REPOSITORY + "/" + IMAGE_FROM_PROPERTIES);
    Tool mockTool = getMockTool(TEST_REPOSITORY, IMAGE_FROM_PROPERTIES);
    Mockito.when(gitManager.getConfigFileContent(Mockito.any(Pipeline.class), Mockito.anyString())).thenReturn(getFileContent(WITHOUT_IMAGE_CONFIG));
    Mockito.when(toolManager.loadByNameOrId(TEST_REPOSITORY + "/" + IMAGE_FROM_PROPERTIES)).thenReturn(mockTool);
    PipelineConfiguration configuration = pipelineVersionManager.loadParametersFromScript(1L, "");
    Assert.assertEquals(TEST_REPOSITORY + "/" + IMAGE_FROM_PROPERTIES, configuration.getDockerImage());
}
Also used : PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) Tool(com.epam.pipeline.entity.pipeline.Tool) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) Test(org.junit.Test) AbstractManagerTest(com.epam.pipeline.manager.AbstractManagerTest)

Example 34 with Tool

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

the class RunConfigurationProviderTest method setUp.

@Before
public void setUp() {
    when(instanceOfferManager.isToolInstanceAllowed(eq(ALLOWED_INSTANCE_TYPE), any())).thenReturn(true);
    when(instanceOfferManager.isToolInstanceAllowed(eq(NOT_ALLOWED_INSTANCE_TYPE), any())).thenReturn(false);
    final Tool tool = new Tool();
    tool.setName(TOOL_IMAGE);
    tool.setId(Long.valueOf(TOOL_ID));
    when(toolManager.loadByNameOrId(TOOL_IMAGE)).thenReturn(tool);
}
Also used : Tool(com.epam.pipeline.entity.pipeline.Tool) Before(org.junit.Before)

Example 35 with Tool

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

the class ToolDao method loadTool.

@Transactional(propagation = Propagation.SUPPORTS)
public Tool loadTool(Long registryId, String image) {
    MapSqlParameterSource params = new MapSqlParameterSource();
    params.addValue(ToolParameters.IMAGE.name(), image);
    params.addValue(ToolParameters.REGISTRY_ID.name(), registryId, Types.BIGINT);
    List<Tool> items = getNamedParameterJdbcTemplate().query(loadToolByRegistryAndImageQuery, params, getRowMapper());
    Assert.isTrue(items.size() <= 1, messageHelper.getMessage(MessageConstants.ERROR_NUMBER_OF_TOOLS_WITH_IMAGE_GREATER_THEN_ONE, items.stream().map(Tool::getRegistry).collect(Collectors.toList())));
    return !items.isEmpty() ? items.get(0) : null;
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) Tool(com.epam.pipeline.entity.pipeline.Tool) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Tool (com.epam.pipeline.entity.pipeline.Tool)72 Transactional (org.springframework.transaction.annotation.Transactional)28 DockerRegistry (com.epam.pipeline.entity.pipeline.DockerRegistry)24 Test (org.junit.Test)22 ToolGroup (com.epam.pipeline.entity.pipeline.ToolGroup)14 AbstractManagerTest (com.epam.pipeline.manager.AbstractManagerTest)11 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)9 DockerClient (com.epam.pipeline.manager.docker.DockerClient)9 List (java.util.List)9 PipelineConfiguration (com.epam.pipeline.entity.configuration.PipelineConfiguration)8 MessageHelper (com.epam.pipeline.common.MessageHelper)7 PipelineRun (com.epam.pipeline.entity.pipeline.PipelineRun)7 ToolVersionScanResult (com.epam.pipeline.entity.scan.ToolVersionScanResult)7 ToolScanExternalServiceException (com.epam.pipeline.exception.ToolScanExternalServiceException)7 DockerRegistryManager (com.epam.pipeline.manager.docker.DockerRegistryManager)7 Optional (java.util.Optional)7 MessageConstants (com.epam.pipeline.common.MessageConstants)6 ManifestV2 (com.epam.pipeline.entity.docker.ManifestV2)6 ToolScanStatus (com.epam.pipeline.entity.pipeline.ToolScanStatus)6 DockerClientFactory (com.epam.pipeline.manager.docker.DockerClientFactory)6