use of com.epam.pipeline.entity.configuration.RunConfiguration in project cloud-pipeline by epam.
the class ConfigurationEntryMapper method getContentBuilder.
private XContentBuilder getContentBuilder(final EntityContainer<ConfigurationEntryDoc> container) {
RunConfiguration configuration = container.getEntity().getConfiguration();
try (XContentBuilder jsonBuilder = XContentFactory.jsonBuilder()) {
jsonBuilder.startObject();
AbstractRunConfigurationEntry entry = container.getEntity().getEntry();
jsonBuilder.field(DOC_TYPE_FIELD, SearchDocumentType.CONFIGURATION.name()).field("id", container.getEntity().getId()).field("name", Optional.ofNullable(entry).map(AbstractRunConfigurationEntry::getName).orElse(configuration.getName())).field("description", configuration.getName() + " " + StringUtils.defaultIfBlank(configuration.getDescription(), StringUtils.EMPTY)).field("createdDate", parseDataToString(configuration.getCreatedDate())).field("parentId", Optional.ofNullable(configuration.getParent()).map(BaseEntity::getId).orElse(null));
buildUserContent(container.getOwner(), jsonBuilder);
buildMetadata(container.getMetadata(), jsonBuilder);
buildPermissions(container.getPermissions(), jsonBuilder);
if (entry != null) {
buildConfigurationEntry(entry, container.getEntity().getPipeline(), jsonBuilder);
}
jsonBuilder.endObject();
return jsonBuilder;
} catch (IOException e) {
throw new IllegalArgumentException("Failed to create elasticsearch document for run configuration: ", e);
}
}
use of com.epam.pipeline.entity.configuration.RunConfiguration in project cloud-pipeline by epam.
the class ConfigurationMapperTest method buildRunConfiguration.
private static RunConfiguration buildRunConfiguration() {
RunConfiguration runConfiguration = new RunConfiguration();
runConfiguration.setName(TEST_NAME);
return runConfiguration;
}
use of com.epam.pipeline.entity.configuration.RunConfiguration in project cloud-pipeline by epam.
the class ConfigurationMapperTest method shouldMapRunConfiguration.
@Test
void shouldMapRunConfiguration() throws IOException {
ConfigurationEntryMapper mapper = new ConfigurationEntryMapper();
Pipeline pipeline = buildPipeline();
RunConfiguration runConfiguration = buildRunConfiguration();
PipelineConfiguration pipelineConfiguration = new PipelineConfiguration();
pipelineConfiguration.setDockerImage(TEST_PATH);
RunConfigurationEntry entry = new RunConfigurationEntry();
entry.setPipelineVersion(TEST_VERSION);
entry.setName(TEST_NAME);
entry.setConfiguration(pipelineConfiguration);
ConfigurationEntryDoc configuration = buildDoc(pipeline, runConfiguration, entry);
XContentBuilder contentBuilder = mapper.map(buildContainer(configuration));
verifyRunConfiguration(runConfiguration, TEST_NAME + " ", contentBuilder);
verifyRunConfigurationEntry(entry, pipeline, contentBuilder);
verifyPipelineUser(USER, contentBuilder);
verifyPermissions(PERMISSIONS_CONTAINER, contentBuilder);
verifyMetadata(EXPECTED_METADATA, contentBuilder);
}
Aggregations