Search in sources :

Example 71 with Tool

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

the class ToolLoaderTest method shouldLoadToolTest.

@Test
void shouldLoadToolTest() throws EntityNotFoundException {
    Tool expectedTool = new Tool();
    expectedTool.setId(1L);
    expectedTool.setOwner(TEST_NAME);
    expectedTool.setRegistry(TEST_NAME);
    expectedTool.setRegistryId(1L);
    expectedTool.setImage(TEST_PATH);
    expectedTool.setDescription(TEST_DESCRIPTION);
    expectedTool.setDefaultCommand(TEST_CMD);
    expectedTool.setToolGroupId(1L);
    expectedTool.setLabels(Collections.singletonList(TEST_LABEL));
    ToolLoader toolLoader = new ToolLoader(apiClient);
    when(apiClient.loadTool(anyString())).thenReturn(expectedTool);
    Optional<EntityContainer<Tool>> container = toolLoader.loadEntity(1L);
    EntityContainer<Tool> toolEntityContainer = container.orElseThrow(AssertionError::new);
    Tool actualTool = toolEntityContainer.getEntity();
    assertNotNull(actualTool);
    verifyTool(expectedTool, actualTool);
    verifyPipelineUser(toolEntityContainer.getOwner());
    verifyPermissions(PERMISSIONS_CONTAINER_WITH_OWNER, toolEntityContainer.getPermissions());
    verifyMetadata(EXPECTED_METADATA, new ArrayList<>(toolEntityContainer.getMetadata().values()));
}
Also used : EntityContainer(com.epam.pipeline.elasticsearchagent.model.EntityContainer) LoaderVerificationUtils.verifyTool(com.epam.pipeline.elasticsearchagent.LoaderVerificationUtils.verifyTool) Tool(com.epam.pipeline.entity.pipeline.Tool) Test(org.junit.jupiter.api.Test)

Example 72 with Tool

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

the class ToolMapperTest method shouldMapTool.

@Test
void shouldMapTool() throws IOException {
    ToolMapper mapper = new ToolMapper();
    Tool tool = new Tool();
    tool.setId(1L);
    tool.setRegistry(TEST_NAME);
    tool.setRegistryId(1L);
    tool.setImage(TEST_PATH);
    tool.setDescription(TEST_DESCRIPTION);
    tool.setDefaultCommand(TEST_CMD);
    tool.setToolGroupId(1L);
    tool.setLabels(Collections.singletonList(TEST_LABEL));
    EntityContainer<Tool> container = EntityContainer.<Tool>builder().entity(tool).owner(USER).metadata(METADATA).permissions(PERMISSIONS_CONTAINER).build();
    XContentBuilder contentBuilder = mapper.map(container);
    verifyTool(tool, contentBuilder);
    verifyPipelineUser(USER, contentBuilder);
    verifyPermissions(PERMISSIONS_CONTAINER, contentBuilder);
    verifyMetadata(EXPECTED_METADATA, contentBuilder);
}
Also used : XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) Tool(com.epam.pipeline.entity.pipeline.Tool) MapperVerificationUtils.verifyTool(com.epam.pipeline.elasticsearchagent.MapperVerificationUtils.verifyTool) Test(org.junit.jupiter.api.Test)

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