Search in sources :

Example 21 with RunConfiguration

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);
    }
}
Also used : RunConfiguration(com.epam.pipeline.entity.configuration.RunConfiguration) BaseEntity(com.epam.pipeline.entity.BaseEntity) AbstractRunConfigurationEntry(com.epam.pipeline.entity.configuration.AbstractRunConfigurationEntry) IOException(java.io.IOException) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder)

Example 22 with RunConfiguration

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;
}
Also used : MapperVerificationUtils.verifyRunConfiguration(com.epam.pipeline.elasticsearchagent.MapperVerificationUtils.verifyRunConfiguration) RunConfiguration(com.epam.pipeline.entity.configuration.RunConfiguration)

Example 23 with 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);
}
Also used : MapperVerificationUtils.verifyRunConfiguration(com.epam.pipeline.elasticsearchagent.MapperVerificationUtils.verifyRunConfiguration) RunConfiguration(com.epam.pipeline.entity.configuration.RunConfiguration) PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) AbstractRunConfigurationEntry(com.epam.pipeline.entity.configuration.AbstractRunConfigurationEntry) RunConfigurationEntry(com.epam.pipeline.entity.configuration.RunConfigurationEntry) MapperVerificationUtils.verifyRunConfigurationEntry(com.epam.pipeline.elasticsearchagent.MapperVerificationUtils.verifyRunConfigurationEntry) FirecloudRunConfigurationEntry(com.epam.pipeline.entity.configuration.FirecloudRunConfigurationEntry) ConfigurationEntryDoc(com.epam.pipeline.elasticsearchagent.model.ConfigurationEntryDoc) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) Test(org.junit.jupiter.api.Test)

Aggregations

RunConfiguration (com.epam.pipeline.entity.configuration.RunConfiguration)23 Folder (com.epam.pipeline.entity.pipeline.Folder)10 Transactional (org.springframework.transaction.annotation.Transactional)9 Test (org.junit.Test)8 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)7 RunConfigurationEntry (com.epam.pipeline.entity.configuration.RunConfigurationEntry)6 Pipeline (com.epam.pipeline.entity.pipeline.Pipeline)6 FirecloudRunConfigurationEntry (com.epam.pipeline.entity.configuration.FirecloudRunConfigurationEntry)5 PipelineConfiguration (com.epam.pipeline.entity.configuration.PipelineConfiguration)4 MapperVerificationUtils.verifyRunConfiguration (com.epam.pipeline.elasticsearchagent.MapperVerificationUtils.verifyRunConfiguration)3 AbstractRunConfigurationEntry (com.epam.pipeline.entity.configuration.AbstractRunConfigurationEntry)3 AbstractDataStorage (com.epam.pipeline.entity.datastorage.AbstractDataStorage)3 XContentBuilder (org.elasticsearch.common.xcontent.XContentBuilder)3 ConfigurationEntryDoc (com.epam.pipeline.elasticsearchagent.model.ConfigurationEntryDoc)2 MetadataClass (com.epam.pipeline.entity.metadata.MetadataClass)2 MetadataEntity (com.epam.pipeline.entity.metadata.MetadataEntity)2 AclClass (com.epam.pipeline.entity.security.acl.AclClass)2 PasswordGenerator.generateRandomString (com.epam.pipeline.utils.PasswordGenerator.generateRandomString)2 Test (org.junit.jupiter.api.Test)2 AwsRegionVO (com.epam.pipeline.controller.vo.AwsRegionVO)1