From a40bc2cb31ef274821bfa0216d65c59ce4ade555 Mon Sep 17 00:00:00 2001 From: boddissattva <58807088+boddissattva@users.noreply.github.com> Date: Tue, 27 Feb 2024 18:59:02 +0100 Subject: [PATCH] chore(jira): Clean service log --- .../jira/api/JiraModuleController.java | 22 ++++----- .../jira/domain/JiraRepository.java | 4 +- ...tion.java => JiraServerConfiguration.java} | 8 ++-- .../jira/domain/JiraXrayClientFactory.java | 2 +- .../jira/domain/JiraXrayService.java | 28 ++++++++--- .../jira/infra/HttpJiraXrayImpl.java | 48 +++++++++---------- .../jira/infra/JiraFileRepository.java | 20 ++++---- .../jira/infra/JiraXrayFactoryImpl.java | 6 +-- .../jira/api/JiraModuleControllerTest.java | 14 +++--- .../jira/api/JiraXrayEmbeddedApiTest.java | 6 +-- .../jira/infra/HttpJiraXrayImplTest.java | 14 +++--- 11 files changed, 95 insertions(+), 77 deletions(-) rename chutney/jira/src/main/java/com/chutneytesting/jira/domain/{JiraTargetConfiguration.java => JiraServerConfiguration.java} (89%) diff --git a/chutney/jira/src/main/java/com/chutneytesting/jira/api/JiraModuleController.java b/chutney/jira/src/main/java/com/chutneytesting/jira/api/JiraModuleController.java index 8460df40a..aa0c7af69 100644 --- a/chutney/jira/src/main/java/com/chutneytesting/jira/api/JiraModuleController.java +++ b/chutney/jira/src/main/java/com/chutneytesting/jira/api/JiraModuleController.java @@ -17,7 +17,7 @@ package com.chutneytesting.jira.api; import com.chutneytesting.jira.domain.JiraRepository; -import com.chutneytesting.jira.domain.JiraTargetConfiguration; +import com.chutneytesting.jira.domain.JiraServerConfiguration; import com.chutneytesting.jira.domain.JiraXrayService; import com.chutneytesting.jira.xrayapi.XrayTestExecTest; import java.util.ArrayList; @@ -167,22 +167,22 @@ public void removeForCampaign(@PathVariable String campaignId) { @PreAuthorize("hasAuthority('ADMIN_ACCESS')") @GetMapping(path = BASE_CONFIGURATION_URL, produces = MediaType.APPLICATION_JSON_VALUE) public JiraConfigurationDto getConfiguration() { - JiraTargetConfiguration jiraTargetConfiguration = jiraRepository.loadServerConfiguration(); + JiraServerConfiguration jiraServerConfiguration = jiraRepository.loadServerConfiguration(); return ImmutableJiraConfigurationDto.builder() - .url(jiraTargetConfiguration.url()) - .username(jiraTargetConfiguration.username()) - .password(jiraTargetConfiguration.password()) - .urlProxy(jiraTargetConfiguration.urlProxy()) - .userProxy(jiraTargetConfiguration.userProxy()) - .passwordProxy(jiraTargetConfiguration.passwordProxy()) + .url(jiraServerConfiguration.url()) + .username(jiraServerConfiguration.username()) + .password(jiraServerConfiguration.password()) + .urlProxy(jiraServerConfiguration.urlProxy()) + .userProxy(jiraServerConfiguration.userProxy()) + .passwordProxy(jiraServerConfiguration.passwordProxy()) .build(); } @PreAuthorize("hasAuthority('SCENARIO_READ') or hasAuthority('CAMPAIGN_READ')") @GetMapping(path = BASE_CONFIGURATION_URL + "/url", produces = MediaType.TEXT_PLAIN_VALUE) public String getConfigurationUrl() { - JiraTargetConfiguration jiraTargetConfiguration = jiraRepository.loadServerConfiguration(); - return jiraTargetConfiguration.url(); + JiraServerConfiguration jiraServerConfiguration = jiraRepository.loadServerConfiguration(); + return jiraServerConfiguration.url(); } @PreAuthorize("hasAuthority('ADMIN_ACCESS')") @@ -191,7 +191,7 @@ public String getConfigurationUrl() { produces = MediaType.APPLICATION_JSON_VALUE) public void saveConfiguration(@RequestBody JiraConfigurationDto jiraConfigurationDto) { jiraRepository.saveServerConfiguration( - new JiraTargetConfiguration( + new JiraServerConfiguration( jiraConfigurationDto.url(), jiraConfigurationDto.username(), jiraConfigurationDto.password(), diff --git a/chutney/jira/src/main/java/com/chutneytesting/jira/domain/JiraRepository.java b/chutney/jira/src/main/java/com/chutneytesting/jira/domain/JiraRepository.java index 37a088d29..670e356f5 100644 --- a/chutney/jira/src/main/java/com/chutneytesting/jira/domain/JiraRepository.java +++ b/chutney/jira/src/main/java/com/chutneytesting/jira/domain/JiraRepository.java @@ -48,7 +48,7 @@ public interface JiraRepository { void removeForCampaignExecution(String campaignExecutionId); - JiraTargetConfiguration loadServerConfiguration(); + JiraServerConfiguration loadServerConfiguration(); - void saveServerConfiguration(JiraTargetConfiguration jiraTargetConfiguration); + void saveServerConfiguration(JiraServerConfiguration jiraServerConfiguration); } diff --git a/chutney/jira/src/main/java/com/chutneytesting/jira/domain/JiraTargetConfiguration.java b/chutney/jira/src/main/java/com/chutneytesting/jira/domain/JiraServerConfiguration.java similarity index 89% rename from chutney/jira/src/main/java/com/chutneytesting/jira/domain/JiraTargetConfiguration.java rename to chutney/jira/src/main/java/com/chutneytesting/jira/domain/JiraServerConfiguration.java index 5ced19ae4..98c8a26c0 100644 --- a/chutney/jira/src/main/java/com/chutneytesting/jira/domain/JiraTargetConfiguration.java +++ b/chutney/jira/src/main/java/com/chutneytesting/jira/domain/JiraServerConfiguration.java @@ -18,12 +18,14 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank; -import org.apache.commons.lang3.StringUtils; - -public record JiraTargetConfiguration( +public record JiraServerConfiguration( String url, String username, String password, String urlProxy, String userProxy, String passwordProxy ) { + public JiraServerConfiguration() { + this(null, null, null, null, null, null); + } + public boolean isValid() { return isNotBlank(url); } diff --git a/chutney/jira/src/main/java/com/chutneytesting/jira/domain/JiraXrayClientFactory.java b/chutney/jira/src/main/java/com/chutneytesting/jira/domain/JiraXrayClientFactory.java index 9940a9b70..7055d7a37 100644 --- a/chutney/jira/src/main/java/com/chutneytesting/jira/domain/JiraXrayClientFactory.java +++ b/chutney/jira/src/main/java/com/chutneytesting/jira/domain/JiraXrayClientFactory.java @@ -18,6 +18,6 @@ public interface JiraXrayClientFactory { - JiraXrayApi create(JiraTargetConfiguration jiraTargetConfiguration); + JiraXrayApi create(JiraServerConfiguration jiraServerConfiguration); } diff --git a/chutney/jira/src/main/java/com/chutneytesting/jira/domain/JiraXrayService.java b/chutney/jira/src/main/java/com/chutneytesting/jira/domain/JiraXrayService.java index b1c5dd817..cc7bfab79 100644 --- a/chutney/jira/src/main/java/com/chutneytesting/jira/domain/JiraXrayService.java +++ b/chutney/jira/src/main/java/com/chutneytesting/jira/domain/JiraXrayService.java @@ -44,10 +44,12 @@ public class JiraXrayService { private final JiraRepository jiraRepository; private final JiraXrayClientFactory jiraXrayImplFactory; + private JiraServerConfiguration jiraServerConfiguration; public JiraXrayService(JiraRepository jiraRepository, JiraXrayClientFactory jiraXrayImplFactory) { this.jiraRepository = jiraRepository; this.jiraXrayImplFactory = jiraXrayImplFactory; + loadJiraServerConfiguration(); } public void updateTestExecution(Long campaignId, Long campaignExecutionId, String scenarioId, ReportForJira report) { @@ -95,17 +97,17 @@ public void updateScenarioStatus(String testExecId, String chutneyId, String exe List testExecutionScenarios = getTestExecutionScenarios(testExecId); Optional foundTest = testExecutionScenarios.stream().filter(test -> scenarioJiraId.equals(test.getKey())).findFirst(); - foundTest.ifPresent(xrayTestExecTest -> jiraXrayApi.updateStatusByTestRunId(xrayTestExecTest.getId(), executionStatus)); + foundTest.ifPresent(xrayTestExecTest -> { + LOGGER.info("Update xray test execution {} status to {}", testExecId, executionStatus); + jiraXrayApi.updateStatusByTestRunId(xrayTestExecTest.getId(), executionStatus); + }); } private JiraXrayApi createHttpJiraXrayImpl() { - JiraTargetConfiguration jiraTargetConfiguration = jiraRepository.loadServerConfiguration(); - if (!jiraTargetConfiguration.isValid()) { - LOGGER.error("Unable to create xray http service, jira url is undefined"); + if (!loadJiraServerConfiguration()) { throw new NoJiraConfigurationException(); - } else { - return jiraXrayImplFactory.create(jiraTargetConfiguration); } + return jiraXrayImplFactory.create(jiraServerConfiguration); } private List getErrors(ReportForJira report) { @@ -150,4 +152,18 @@ private String formatEvidenceFilename(String parentStep, String stepName) { + (parentStep.trim().isEmpty() ? "" : "_") + stepName.trim().replace(" ", "-"); } + + private boolean loadJiraServerConfiguration() { + JiraServerConfiguration currentConfiguration = jiraRepository.loadServerConfiguration(); + boolean hasConfigurationChanged = !currentConfiguration.equals(this.jiraServerConfiguration); + if (hasConfigurationChanged) { + LOGGER.info("Jira server configuration has changed"); + this.jiraServerConfiguration = currentConfiguration; + } + boolean isConfigurationValid = this.jiraServerConfiguration.isValid(); + if (hasConfigurationChanged && !isConfigurationValid) { + LOGGER.warn("Jira server configuration is not valid"); + } + return isConfigurationValid; + } } diff --git a/chutney/jira/src/main/java/com/chutneytesting/jira/infra/HttpJiraXrayImpl.java b/chutney/jira/src/main/java/com/chutneytesting/jira/infra/HttpJiraXrayImpl.java index 43a84ec93..713d026ee 100644 --- a/chutney/jira/src/main/java/com/chutneytesting/jira/infra/HttpJiraXrayImpl.java +++ b/chutney/jira/src/main/java/com/chutneytesting/jira/infra/HttpJiraXrayImpl.java @@ -26,7 +26,7 @@ import com.atlassian.jira.rest.client.api.domain.input.IssueInputBuilder; import com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClient; import com.atlassian.jira.rest.client.internal.async.DisposableHttpClient; -import com.chutneytesting.jira.domain.JiraTargetConfiguration; +import com.chutneytesting.jira.domain.JiraServerConfiguration; import com.chutneytesting.jira.domain.JiraXrayApi; import com.chutneytesting.jira.domain.exception.NoJiraConfigurationException; import com.chutneytesting.jira.infra.atlassian.httpclient.api.factory.HttpClientOptions; @@ -75,18 +75,18 @@ public class HttpJiraXrayImpl implements JiraXrayApi { private static final int MS_TIMEOUT = 10 * 1000; // 10 s - private final JiraTargetConfiguration jiraTargetConfiguration; + private final JiraServerConfiguration jiraServerConfiguration; - public HttpJiraXrayImpl(JiraTargetConfiguration jiraTargetConfiguration) { - this.jiraTargetConfiguration = jiraTargetConfiguration; - if (!jiraTargetConfiguration.isValid()) { + public HttpJiraXrayImpl(JiraServerConfiguration jiraServerConfiguration) { + this.jiraServerConfiguration = jiraServerConfiguration; + if (!jiraServerConfiguration.isValid()) { throw new NoJiraConfigurationException(); } } @Override public void updateRequest(Xray xray) { - String updateUri = jiraTargetConfiguration.url() + "/rest/raven/1.0/import/execution"; + String updateUri = jiraServerConfiguration.url() + "/rest/raven/1.0/import/execution"; RestTemplate restTemplate = buildRestTemplate(); @@ -107,7 +107,7 @@ public void updateRequest(Xray xray) { public List getTestExecutionScenarios(String xrayId) { List tests = new ArrayList<>(); - String uriTemplate = jiraTargetConfiguration.url() + "/rest/raven/1.0/api/%s/%s/test"; + String uriTemplate = jiraServerConfiguration.url() + "/rest/raven/1.0/api/%s/%s/test"; String uri = String.format(uriTemplate, isTestPlan(xrayId) ? "testplan" : "testexec", xrayId); RestTemplate restTemplate = buildRestTemplate(); @@ -127,7 +127,7 @@ public List getTestExecutionScenarios(String xrayId) { @Override public void updateStatusByTestRunId(String testRuntId, String executionStatus) { - String uriTemplate = jiraTargetConfiguration.url() + "/rest/raven/1.0/api/testrun/%s/status?status=%s"; + String uriTemplate = jiraServerConfiguration.url() + "/rest/raven/1.0/api/testrun/%s/status?status=%s"; String uri = String.format(uriTemplate, testRuntId, executionStatus); RestTemplate restTemplate = buildRestTemplate(); @@ -140,7 +140,7 @@ public void updateStatusByTestRunId(String testRuntId, String executionStatus) { @Override public void associateTestExecutionFromTestPlan(String testPlanId, String testExecutionId) { - String uriTemplate = jiraTargetConfiguration.url() + "/rest/raven/1.0/api/testplan/%s/testexecution"; + String uriTemplate = jiraServerConfiguration.url() + "/rest/raven/1.0/api/testplan/%s/testexecution"; String uri = String.format(uriTemplate, testPlanId); RestTemplate restTemplate = buildRestTemplate(); @@ -192,7 +192,7 @@ private Issue getIssue(String issueKey) { } private JiraIssueType getIssueTypeByName(String issueTypeName) { - String uri = jiraTargetConfiguration.url() + "/rest/api/latest/issuetype"; + String uri = jiraServerConfiguration.url() + "/rest/api/latest/issuetype"; Optional issueTypeOptional = Optional.empty(); RestTemplate restTemplate = buildRestTemplate(); @@ -222,21 +222,21 @@ private RestTemplate buildRestTemplate() { } private HttpClient buildHttpClient() throws URISyntaxException { - HttpHost httpHost = HttpHost.create(new URI(jiraTargetConfiguration.url())); - HttpHost proxyHttpHost = HttpHost.create(new URI(jiraTargetConfiguration.urlProxy())); + HttpHost httpHost = HttpHost.create(new URI(jiraServerConfiguration.url())); + HttpHost proxyHttpHost = HttpHost.create(new URI(jiraServerConfiguration.urlProxy())); HttpClientBuilder httpClientBuilder = HttpClients.custom() .setConnectionManager(buildConnectionManager()) .setDefaultCredentialsProvider(getBasicCredentialsProvider(httpHost, proxyHttpHost)); var defaultHeaders = new ArrayList(); - String authorization = basicAuthHeaderEncodedValue(jiraTargetConfiguration.username(), jiraTargetConfiguration.password()); + String authorization = basicAuthHeaderEncodedValue(jiraServerConfiguration.username(), jiraServerConfiguration.password()); defaultHeaders.add(new BasicHeader(HttpHeaders.AUTHORIZATION, authorization)); - if (jiraTargetConfiguration.hasProxy()) { + if (jiraServerConfiguration.hasProxy()) { httpClientBuilder.setProxy(proxyHttpHost); - if (jiraTargetConfiguration.hasProxyWithAuth()) { - String proxyAuthorization = basicAuthHeaderEncodedValue(jiraTargetConfiguration.userProxy(), jiraTargetConfiguration.passwordProxy()); + if (jiraServerConfiguration.hasProxyWithAuth()) { + String proxyAuthorization = basicAuthHeaderEncodedValue(jiraServerConfiguration.userProxy(), jiraServerConfiguration.passwordProxy()); defaultHeaders.add(new BasicHeader(HttpHeaders.PROXY_AUTHORIZATION, proxyAuthorization)); } } @@ -273,26 +273,26 @@ private BasicCredentialsProvider getBasicCredentialsProvider(HttpHost httpHost, BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider(); credentialsProvider.setCredentials( new AuthScope(httpHost), - new UsernamePasswordCredentials(jiraTargetConfiguration.username(), jiraTargetConfiguration.password().toCharArray()) + new UsernamePasswordCredentials(jiraServerConfiguration.username(), jiraServerConfiguration.password().toCharArray()) ); - if (jiraTargetConfiguration.hasProxyWithAuth()) { + if (jiraServerConfiguration.hasProxyWithAuth()) { credentialsProvider.setCredentials( new AuthScope(proxyHttpHost), - new UsernamePasswordCredentials(jiraTargetConfiguration.userProxy(), jiraTargetConfiguration.passwordProxy().toCharArray()) + new UsernamePasswordCredentials(jiraServerConfiguration.userProxy(), jiraServerConfiguration.passwordProxy().toCharArray()) ); } return credentialsProvider; } private JiraRestClient getJiraRestClient() throws URISyntaxException { - URI serverUri = URI.create(jiraTargetConfiguration.url()); + URI serverUri = URI.create(jiraServerConfiguration.url()); return new AsynchronousJiraRestClient( serverUri, buildJiraHttpClient( serverUri, new BasicHttpAuthenticationHandler( - jiraTargetConfiguration.username(), jiraTargetConfiguration.password(), - jiraTargetConfiguration.userProxy(), jiraTargetConfiguration.passwordProxy() + jiraServerConfiguration.username(), jiraServerConfiguration.password(), + jiraServerConfiguration.userProxy(), jiraServerConfiguration.passwordProxy() ) ) ); @@ -305,8 +305,8 @@ private DisposableHttpClient buildJiraHttpClient( final HttpClientOptions options = new HttpClientOptions(); options.setTrustSelfSignedCertificates(true); - if (jiraTargetConfiguration.hasProxy()) { - HttpHost proxyHttpHost = HttpHost.create(new URI(jiraTargetConfiguration.urlProxy())); + if (jiraServerConfiguration.hasProxy()) { + HttpHost proxyHttpHost = HttpHost.create(new URI(jiraServerConfiguration.urlProxy())); options.setProxyOptions( ProxyOptions.ProxyOptionsBuilder.create() .withProxy(Scheme.valueOf(serverUri.getScheme().toUpperCase()), proxyHttpHost) diff --git a/chutney/jira/src/main/java/com/chutneytesting/jira/infra/JiraFileRepository.java b/chutney/jira/src/main/java/com/chutneytesting/jira/infra/JiraFileRepository.java index 2b1282aee..c36a98de2 100644 --- a/chutney/jira/src/main/java/com/chutneytesting/jira/infra/JiraFileRepository.java +++ b/chutney/jira/src/main/java/com/chutneytesting/jira/infra/JiraFileRepository.java @@ -19,7 +19,7 @@ import static com.chutneytesting.tools.file.FileUtils.initFolder; import com.chutneytesting.jira.domain.JiraRepository; -import com.chutneytesting.jira.domain.JiraTargetConfiguration; +import com.chutneytesting.jira.domain.JiraServerConfiguration; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; @@ -117,20 +117,20 @@ public void removeForCampaignExecution(String campaignExecutionId) { } @Override - public JiraTargetConfiguration loadServerConfiguration() { + public JiraServerConfiguration loadServerConfiguration() { JiraTargetConfigurationDto dto = doLoadServerConfiguration(); - return new JiraTargetConfiguration(dto.url, dto.username, dto.password, dto.urlProxy, dto.userProxy, dto.passwordProxy); + return new JiraServerConfiguration(dto.url, dto.username, dto.password, dto.urlProxy, dto.userProxy, dto.passwordProxy); } @Override - public void saveServerConfiguration(JiraTargetConfiguration jiraTargetConfiguration) { + public void saveServerConfiguration(JiraServerConfiguration jiraServerConfiguration) { JiraTargetConfigurationDto jiraTargetConfigurationDto = new JiraTargetConfigurationDto( - jiraTargetConfiguration.url(), - jiraTargetConfiguration.username(), - jiraTargetConfiguration.password(), - jiraTargetConfiguration.urlProxy(), - jiraTargetConfiguration.userProxy(), - jiraTargetConfiguration.passwordProxy() + jiraServerConfiguration.url(), + jiraServerConfiguration.username(), + jiraServerConfiguration.password(), + jiraServerConfiguration.urlProxy(), + jiraServerConfiguration.userProxy(), + jiraServerConfiguration.passwordProxy() ); Path resolvedFilePath = storeFolderPath.resolve(CONFIGURATION_FILE); doSave(resolvedFilePath, jiraTargetConfigurationDto); diff --git a/chutney/jira/src/main/java/com/chutneytesting/jira/infra/JiraXrayFactoryImpl.java b/chutney/jira/src/main/java/com/chutneytesting/jira/infra/JiraXrayFactoryImpl.java index 23646e6bd..abacfbe56 100644 --- a/chutney/jira/src/main/java/com/chutneytesting/jira/infra/JiraXrayFactoryImpl.java +++ b/chutney/jira/src/main/java/com/chutneytesting/jira/infra/JiraXrayFactoryImpl.java @@ -16,15 +16,15 @@ package com.chutneytesting.jira.infra; -import com.chutneytesting.jira.domain.JiraTargetConfiguration; +import com.chutneytesting.jira.domain.JiraServerConfiguration; import com.chutneytesting.jira.domain.JiraXrayApi; import com.chutneytesting.jira.domain.JiraXrayClientFactory; public class JiraXrayFactoryImpl implements JiraXrayClientFactory { @Override - public JiraXrayApi create(JiraTargetConfiguration jiraTargetConfiguration) { - return new HttpJiraXrayImpl(jiraTargetConfiguration); + public JiraXrayApi create(JiraServerConfiguration jiraServerConfiguration) { + return new HttpJiraXrayImpl(jiraServerConfiguration); } } diff --git a/chutney/jira/src/test/java/com/chutneytesting/jira/api/JiraModuleControllerTest.java b/chutney/jira/src/test/java/com/chutneytesting/jira/api/JiraModuleControllerTest.java index c067bb024..224ef3f9a 100644 --- a/chutney/jira/src/test/java/com/chutneytesting/jira/api/JiraModuleControllerTest.java +++ b/chutney/jira/src/test/java/com/chutneytesting/jira/api/JiraModuleControllerTest.java @@ -30,7 +30,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import com.chutneytesting.jira.domain.JiraRepository; -import com.chutneytesting.jira.domain.JiraTargetConfiguration; +import com.chutneytesting.jira.domain.JiraServerConfiguration; import com.chutneytesting.jira.domain.JiraXrayApi; import com.chutneytesting.jira.domain.JiraXrayClientFactory; import com.chutneytesting.jira.domain.JiraXrayService; @@ -67,7 +67,7 @@ public void setUp() throws IOException { when(jiraXrayFactory.create(any())).thenReturn(mockJiraXrayApi); - jiraRepository.saveServerConfiguration(new JiraTargetConfiguration("an url", "a username", "a password", null, null, null)); + jiraRepository.saveServerConfiguration(new JiraServerConfiguration("an url", "a username", "a password", null, null, null)); jiraRepository.saveForCampaign("10", "JIRA-10"); jiraRepository.saveForCampaign("20", "JIRA-20"); jiraRepository.saveForScenario("1", "SCE-1"); @@ -80,7 +80,7 @@ public void setUp() throws IOException { @Test void should_not_create_HttpJiraXrayImpl_if_url_not_exist(){ - jiraRepository.saveServerConfiguration(new JiraTargetConfiguration("", "a username", "a password", null, null, null)); + jiraRepository.saveServerConfiguration(new JiraServerConfiguration("", "a username", "a password", null, null, null)); assertThatExceptionOfType(RuntimeException.class) .isThrownBy(() -> getJiraController("/api/ui/jira/v1/testexec/JIRA-10", new TypeReference<>() {})) @@ -224,16 +224,16 @@ void getConfigurationUrl() throws Exception { void loadServerConfigurationWithoutProxy() { JiraRepository repository = new JiraFileRepository(Paths.get("src", "test", "resources", "jira").toAbsolutePath().toString()); - JiraTargetConfiguration expectedConfiguration = new JiraTargetConfiguration("an url", "a username", "a password", "", "", ""); + JiraServerConfiguration expectedConfiguration = new JiraServerConfiguration("an url", "a username", "a password", "", "", ""); - JiraTargetConfiguration expected = repository.loadServerConfiguration(); + JiraServerConfiguration expected = repository.loadServerConfiguration(); assertThat(expected).usingRecursiveComparison().isEqualTo(expectedConfiguration); } @Test void saveConfiguration() throws Exception { - JiraTargetConfiguration newConfiguration = new JiraTargetConfiguration("a new url", "a new username", "a new password", "url proxy", "user proxy", "password proxy"); + JiraServerConfiguration newConfiguration = new JiraServerConfiguration("a new url", "a new username", "a new password", "url proxy", "user proxy", "password proxy"); mockMvc.perform(MockMvcRequestBuilders.post("/api/ui/jira/v1/configuration") .contentType(MediaType.APPLICATION_JSON_VALUE) @@ -242,7 +242,7 @@ void saveConfiguration() throws Exception { .andDo(print()) .andExpect(MockMvcResultMatchers.status().isOk()); - JiraTargetConfiguration expected = jiraRepository.loadServerConfiguration(); + JiraServerConfiguration expected = jiraRepository.loadServerConfiguration(); assertThat(expected).usingRecursiveComparison().isEqualTo(newConfiguration); } diff --git a/chutney/jira/src/test/java/com/chutneytesting/jira/api/JiraXrayEmbeddedApiTest.java b/chutney/jira/src/test/java/com/chutneytesting/jira/api/JiraXrayEmbeddedApiTest.java index 32fcf7697..df96c0b5e 100644 --- a/chutney/jira/src/test/java/com/chutneytesting/jira/api/JiraXrayEmbeddedApiTest.java +++ b/chutney/jira/src/test/java/com/chutneytesting/jira/api/JiraXrayEmbeddedApiTest.java @@ -28,7 +28,7 @@ import static org.mockito.Mockito.when; import com.chutneytesting.jira.domain.JiraRepository; -import com.chutneytesting.jira.domain.JiraTargetConfiguration; +import com.chutneytesting.jira.domain.JiraServerConfiguration; import com.chutneytesting.jira.domain.JiraXrayApi; import com.chutneytesting.jira.domain.JiraXrayClientFactory; import com.chutneytesting.jira.domain.JiraXrayService; @@ -53,7 +53,7 @@ class JiraXrayEmbeddedApiTest { private final JiraXrayApi jiraXrayApiMock = mock(JiraXrayApi.class); private final JiraXrayClientFactory jiraXrayFactory = mock(JiraXrayClientFactory.class); private final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssZZZZZ"); - private final JiraTargetConfiguration jiraTargetConfiguration = new JiraTargetConfiguration("an url", "a username", "a password", null, null, null); + private final JiraServerConfiguration jiraServerConfiguration = new JiraServerConfiguration("an url", "a username", "a password", null, null, null); private JiraXrayEmbeddedApi jiraXrayEmbeddedApi; private JiraRepository jiraRepository; @@ -61,7 +61,7 @@ class JiraXrayEmbeddedApiTest { @BeforeEach public void setUp() throws IOException { jiraRepository = new JiraFileRepository(Files.createTempDirectory("jira").toString()); - jiraRepository.saveServerConfiguration(jiraTargetConfiguration); + jiraRepository.saveServerConfiguration(jiraServerConfiguration); JiraXrayService jiraXrayService = new JiraXrayService(jiraRepository, jiraXrayFactory); diff --git a/chutney/jira/src/test/java/com/chutneytesting/jira/infra/HttpJiraXrayImplTest.java b/chutney/jira/src/test/java/com/chutneytesting/jira/infra/HttpJiraXrayImplTest.java index dce845288..229377748 100644 --- a/chutney/jira/src/test/java/com/chutneytesting/jira/infra/HttpJiraXrayImplTest.java +++ b/chutney/jira/src/test/java/com/chutneytesting/jira/infra/HttpJiraXrayImplTest.java @@ -26,7 +26,7 @@ import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; import static org.assertj.core.api.Assertions.assertThat; -import com.chutneytesting.jira.domain.JiraTargetConfiguration; +import com.chutneytesting.jira.domain.JiraServerConfiguration; import com.chutneytesting.jira.xrayapi.Xray; import com.chutneytesting.jira.xrayapi.XrayInfo; import com.github.tomakehurst.wiremock.junit5.WireMockExtension; @@ -55,7 +55,7 @@ class ProxyWithoutAuth { @Test void update_xray_execution() { // Given - JiraTargetConfiguration config = new JiraTargetConfiguration( + JiraServerConfiguration config = new JiraServerConfiguration( "http://fake-server-jira", "user", "password", @@ -86,7 +86,7 @@ void test_issue_as_test_plan() { // Given String issueId = "PRJ-666"; - var config = new JiraTargetConfiguration( + var config = new JiraServerConfiguration( "http://fake-server-jira", "user", "password", @@ -174,7 +174,7 @@ class ProxyWithAuth { @Test void update_xray_execution() { // Given - JiraTargetConfiguration config = new JiraTargetConfiguration( + JiraServerConfiguration config = new JiraServerConfiguration( "http://fake-server-jira", "user", "password", @@ -205,7 +205,7 @@ void test_issue_as_test_plan() { // Given String issueId = "PRJ-666"; - var config = new JiraTargetConfiguration( + var config = new JiraServerConfiguration( "http://fake-server-jira", "user", "password", @@ -287,12 +287,12 @@ void test_issue_as_test_plan() { } } - private static String expectedProxyAuthorization(JiraTargetConfiguration config) { + private static String expectedProxyAuthorization(JiraServerConfiguration config) { return "Basic " + Base64.getEncoder() .encodeToString((config.userProxy() + ":" + config.passwordProxy()).getBytes()); } - private static String expectedAuthorization(JiraTargetConfiguration config) { + private static String expectedAuthorization(JiraServerConfiguration config) { return "Basic " + Base64.getEncoder() .encodeToString((config.username() + ":" + config.password()).getBytes()); }