use of com.epam.pipeline.entity.pipeline.ToolGroup in project cloud-pipeline by epam.
the class ToolGroupApiServiceTest method testLoadOtherPrivateGroupFails2.
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
@WithMockUser(username = TEST_USER2, roles = TOOL_GROUP_MANAGER_ROLE)
@Test()
public void testLoadOtherPrivateGroupFails2() {
ToolGroup group = toolGroupApiService.load(existingGroup.getId());
Assert.assertTrue(group.getTools().isEmpty());
}
use of com.epam.pipeline.entity.pipeline.ToolGroup in project cloud-pipeline by epam.
the class ToolGroupApiServiceTest method testLoadOtherPrivateGroupFails.
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
@WithMockUser(username = TEST_USER2, roles = TOOL_GROUP_MANAGER_ROLE)
@Test
public void testLoadOtherPrivateGroupFails() {
ToolGroup privateGroup = toolGroupApiService.createPrivate(registry.getId());
List<ToolGroup> groups = toolGroupApiService.loadByRegistryId(registry.getId());
Assert.assertTrue(groups.stream().noneMatch(g -> g.getName().equals(existingGroup.getName())));
Assert.assertTrue(groups.stream().anyMatch(g -> g.getName().equals(privateGroup.getName())));
groups = toolGroupApiService.loadByRegistryNameOrId(registry.getPath());
Assert.assertTrue(groups.stream().noneMatch(g -> g.getName().equals(existingGroup.getName())));
Assert.assertTrue(groups.stream().anyMatch(g -> g.getName().equals(privateGroup.getName())));
}
use of com.epam.pipeline.entity.pipeline.ToolGroup in project cloud-pipeline by epam.
the class ToolGroupMapper method map.
@Override
public XContentBuilder map(final EntityContainer<ToolGroup> container) {
ToolGroup toolGroup = container.getEntity();
try (XContentBuilder jsonBuilder = XContentFactory.jsonBuilder()) {
jsonBuilder.startObject();
jsonBuilder.field(DOC_TYPE_FIELD, SearchDocumentType.TOOL_GROUP.name()).field("id", toolGroup.getId()).field("name", toolGroup.getName()).field("registryId", toolGroup.getRegistryId()).field("createdDate", parseDataToString(toolGroup.getCreatedDate())).field("description", toolGroup.getDescription());
buildUserContent(container.getOwner(), jsonBuilder);
buildMetadata(container.getMetadata(), jsonBuilder);
buildPermissions(container.getPermissions(), jsonBuilder);
jsonBuilder.endObject();
return jsonBuilder;
} catch (IOException e) {
throw new IllegalArgumentException("Failed to create elasticsearch document for tool group: ", e);
}
}
use of com.epam.pipeline.entity.pipeline.ToolGroup in project cloud-pipeline by epam.
the class ToolGroupMapperTest method shouldMapToolGroup.
@Test
void shouldMapToolGroup() throws IOException {
ToolGroupMapper mapper = new ToolGroupMapper();
ToolGroup toolGroup = new ToolGroup();
toolGroup.setId(1L);
toolGroup.setName(TEST_NAME);
toolGroup.setRegistryId(1L);
toolGroup.setDescription(TEST_DESCRIPTION);
EntityContainer<ToolGroup> container = EntityContainer.<ToolGroup>builder().entity(toolGroup).owner(USER).metadata(METADATA).permissions(PERMISSIONS_CONTAINER).build();
XContentBuilder contentBuilder = mapper.map(container);
verifyToolGroup(toolGroup, contentBuilder);
verifyPipelineUser(USER, contentBuilder);
verifyPermissions(PERMISSIONS_CONTAINER, contentBuilder);
verifyMetadata(EXPECTED_METADATA, contentBuilder);
}
use of com.epam.pipeline.entity.pipeline.ToolGroup in project cloud-pipeline by epam.
the class ToolDao method basicInitTool.
private static Tool basicInitTool(ResultSet rs, Tool tool) throws SQLException {
tool.setId(rs.getLong(ToolParameters.ID.name()));
tool.setImage(rs.getString(ToolParameters.IMAGE.name()));
tool.setCpu(rs.getString(ToolParameters.CPU.name()));
tool.setRam(rs.getString(ToolParameters.RAM.name()));
tool.setRegistryId(rs.getLong(ToolParameters.REGISTRY_ID.name()));
tool.setToolGroupId(rs.getLong(ToolParameters.TOOL_GROUP_ID.name()));
tool.setRegistry(rs.getString(ToolParameters.REGISTRY.name()));
tool.setSecretName(rs.getString(ToolParameters.SECRET_NAME.name()));
tool.setDescription(rs.getString(ToolParameters.DESCRIPTION.name()));
tool.setShortDescription(rs.getString(ToolParameters.SHORT_DESCRIPTION.name()));
tool.setDefaultCommand(rs.getString(ToolParameters.DEFAULT_COMMAND.name()));
tool.setOwner(rs.getString(ToolParameters.OWNER.name()));
tool.setDisk(rs.getInt(ToolParameters.DISK.name()));
tool.setInstanceType(rs.getString(ToolParameters.INSTANCE_TYPE.name()));
long longVal = rs.getLong(ToolParameters.ICON_ID.name());
tool.setHasIcon(!rs.wasNull());
tool.setIconId(longVal);
Array labelsSqlArray = rs.getArray(ToolParameters.LABELS.name());
if (labelsSqlArray != null) {
List<String> labels = Arrays.asList((String[]) labelsSqlArray.getArray());
tool.setLabels(labels);
}
Array endpointsSqlArray = rs.getArray(ToolParameters.ENDPOINTS.name());
if (endpointsSqlArray != null) {
List<String> endpoints = Arrays.asList((String[]) endpointsSqlArray.getArray());
tool.setEndpoints(endpoints);
}
// restore parent hierarchy
if (tool.getToolGroupId() != null) {
tool.setParent(new ToolGroup(tool.getToolGroupId()));
if (tool.getRegistryId() != null) {
tool.getParent().setParent(new DockerRegistry(tool.getRegistryId()));
}
}
return tool;
}
Aggregations