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