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