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