Search in sources :

Example 1 with RunConfigurationDoc

use of com.epam.pipeline.elasticsearchagent.model.RunConfigurationDoc in project cloud-pipeline by epam.

the class RunConfigurationLoaderTest method shouldLoadRunConfigurationTest.

@Test
void shouldLoadRunConfigurationTest() throws EntityNotFoundException {
    Pipeline pipeline = new Pipeline();
    pipeline.setId(1L);
    pipeline.setName(TEST_NAME);
    PipelineConfiguration pipelineConfiguration = new PipelineConfiguration();
    pipelineConfiguration.setDockerImage(TEST_PATH);
    RunConfigurationEntry entry = new RunConfigurationEntry();
    entry.setPipelineId(pipeline.getId());
    entry.setPipelineVersion(TEST_VERSION);
    entry.setName(TEST_NAME);
    entry.setConfiguration(pipelineConfiguration);
    RunConfiguration runConfiguration = new RunConfiguration();
    runConfiguration.setId(1L);
    runConfiguration.setName(TEST_NAME);
    runConfiguration.setDescription(TEST_VALUE);
    runConfiguration.setOwner(TEST_NAME);
    runConfiguration.setEntries(Collections.singletonList(entry));
    RunConfigurationDoc expectedConfiguration = RunConfigurationDoc.builder().configuration(runConfiguration).pipelines(Collections.singletonList(pipeline)).build();
    RunConfigurationLoader runConfigurationLoader = new RunConfigurationLoader(apiClient);
    when(apiClient.loadRunConfiguration(anyLong())).thenReturn(runConfiguration);
    when(apiClient.loadPipeline(anyString())).thenReturn(pipeline);
    Optional<EntityContainer<RunConfigurationDoc>> container = runConfigurationLoader.loadEntity(1L);
    EntityContainer<RunConfigurationDoc> configurationDocContainer = container.orElseThrow(AssertionError::new);
    RunConfigurationDoc actualConfiguration = configurationDocContainer.getEntity();
    assertNotNull(actualConfiguration);
    verifyConfiguration(expectedConfiguration.getConfiguration(), actualConfiguration.getConfiguration());
    verifyPipeline(expectedConfiguration.getPipelines(), actualConfiguration.getPipelines());
    verifyPipelineUser(configurationDocContainer.getOwner());
    verifyPermissions(PERMISSIONS_CONTAINER_WITH_OWNER, configurationDocContainer.getPermissions());
    verifyMetadata(EXPECTED_METADATA, new ArrayList<>(configurationDocContainer.getMetadata().values()));
}
Also used : RunConfiguration(com.epam.pipeline.entity.configuration.RunConfiguration) RunConfigurationDoc(com.epam.pipeline.elasticsearchagent.model.RunConfigurationDoc) EntityContainer(com.epam.pipeline.elasticsearchagent.model.EntityContainer) PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) RunConfigurationEntry(com.epam.pipeline.entity.configuration.RunConfigurationEntry) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) LoaderVerificationUtils.verifyPipeline(com.epam.pipeline.elasticsearchagent.LoaderVerificationUtils.verifyPipeline) Test(org.junit.jupiter.api.Test)

Aggregations

LoaderVerificationUtils.verifyPipeline (com.epam.pipeline.elasticsearchagent.LoaderVerificationUtils.verifyPipeline)1 EntityContainer (com.epam.pipeline.elasticsearchagent.model.EntityContainer)1 RunConfigurationDoc (com.epam.pipeline.elasticsearchagent.model.RunConfigurationDoc)1 PipelineConfiguration (com.epam.pipeline.entity.configuration.PipelineConfiguration)1 RunConfiguration (com.epam.pipeline.entity.configuration.RunConfiguration)1 RunConfigurationEntry (com.epam.pipeline.entity.configuration.RunConfigurationEntry)1 Pipeline (com.epam.pipeline.entity.pipeline.Pipeline)1 Test (org.junit.jupiter.api.Test)1