@Test public void log_public_url_if_defined() throws IOException { when(server.getPublicRootUrl()).thenReturn("https://publicserver/sonarqube"); ReportPublisher underTest = new ReportPublisher( settings, wsClient, server, contextPublisher, reactor, mode, mock(TempFolder.class), new ReportPublisherStep[0]); underTest.logSuccess("TASK-123"); assertThat(logTester.logs(LoggerLevel.INFO)) .contains( "ANALYSIS SUCCESSFUL, you can browse https://publicserver/sonarqube/dashboard/index/struts") .contains( "More about the report processing at https://publicserver/sonarqube/api/ce/task?id=TASK-123"); File detailsFile = new File(temp.getRoot(), "report-task.txt"); assertThat(readFileToString(detailsFile)) .isEqualTo( "projectKey=struts\n" + "serverUrl=https://publicserver/sonarqube\n" + "dashboardUrl=https://publicserver/sonarqube/dashboard/index/struts\n" + "ceTaskId=TASK-123\n" + "ceTaskUrl=https://publicserver/sonarqube/api/ce/task?id=TASK-123\n"); }
@Test public void fail_if_public_url_malformed() throws IOException { when(server.getPublicRootUrl()).thenReturn("invalid"); ReportPublisher underTest = new ReportPublisher( settings, wsClient, server, contextPublisher, reactor, mode, mock(TempFolder.class), new ReportPublisherStep[0]); exception.expect(MessageException.class); exception.expectMessage("Failed to parse public URL set in SonarQube server: invalid"); underTest.start(); }
@Before public void setUp() { root = ProjectDefinition.create().setKey("struts").setWorkDir(temp.getRoot()); when(reactor.getRoot()).thenReturn(root); when(server.getPublicRootUrl()).thenReturn("https://localhost"); }