use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class PingActionTest method returns_pong_as_plain_text.
@Test
public void returns_pong_as_plain_text() {
TestResponse response = tester.newRequest().execute();
assertThat(response.getMediaType()).isEqualTo("text/plain");
assertThat(response.getInput()).isEqualTo("pong");
assertThat(response.getInput()).isEqualTo(tester.getDef().responseExampleAsString());
}
use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class InfoActionTest method write_json.
@Test
public void write_json() {
logInAsSystemAdministrator();
Map<String, Object> attributes1 = new LinkedHashMap<>();
attributes1.put("foo", "bar");
Map<String, Object> attributes2 = new LinkedHashMap<>();
attributes2.put("one", 1);
attributes2.put("two", 2);
when(monitor1.name()).thenReturn("Monitor One");
when(monitor1.attributes()).thenReturn(attributes1);
when(monitor2.name()).thenReturn("Monitor Two");
when(monitor2.attributes()).thenReturn(attributes2);
when(ceHttpClient.retrieveSystemInfo()).thenReturn(Optional.empty());
TestResponse response = actionTester.newRequest().execute();
// response does not contain empty "Monitor Three"
assertThat(response.getInput()).isEqualTo("{\"Monitor One\":{\"foo\":\"bar\"},\"Monitor Two\":{\"one\":1,\"two\":2}}");
}
use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class LogsActionTest method return_404_not_found_if_file_does_not_exist.
@Test
public void return_404_not_found_if_file_does_not_exist() throws IOException {
logInAsSystemAdministrator();
createLogsDir();
TestResponse response = actionTester.newRequest().execute();
assertThat(response.getStatus()).isEqualTo(404);
}
use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class GhostsActionTest method ghost_projects_without_analyzed_projects.
@Test
public void ghost_projects_without_analyzed_projects() throws Exception {
OrganizationDto organization = db.organizations().insert();
ComponentDto ghost1 = insertGhostProject(organization);
ComponentDto ghost2 = insertGhostProject(organization);
ComponentDto activeProject = insertActiveProject(organization);
userSessionRule.logIn().addPermission(ADMINISTER, organization);
TestResponse result = underTest.newRequest().setParam("organization", organization.getKey()).execute();
String json = result.getInput();
assertJson(json).isSimilarTo("{" + " \"projects\": [" + " {" + " \"uuid\": \"" + ghost1.uuid() + "\"," + " \"key\": \"" + ghost1.key() + "\"," + " \"name\": \"" + ghost1.name() + "\"" + " }," + " {" + " \"uuid\": \"" + ghost2.uuid() + "\"," + " \"key\": \"" + ghost2.key() + "\"," + " \"name\": \"" + ghost2.name() + "\"" + " }" + " ]" + "}");
assertThat(json).doesNotContain(activeProject.uuid());
}
use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class GhostsActionTest method ghost_projects_base_on_json_example.
@Test
public void ghost_projects_base_on_json_example() throws Exception {
OrganizationDto organization = db.organizations().insert();
ComponentDto hBaseProject = ComponentTesting.newProjectDto(organization, "ce4c03d6-430f-40a9-b777-ad877c00aa4d").setKey("org.apache.hbas:hbase").setName("HBase").setCreatedAt(DateUtils.parseDateTime("2015-03-04T23:03:44+0100"));
dbClient.componentDao().insert(db.getSession(), hBaseProject);
dbClient.snapshotDao().insert(db.getSession(), SnapshotTesting.newAnalysis(hBaseProject).setStatus(STATUS_UNPROCESSED));
ComponentDto roslynProject = ComponentTesting.newProjectDto(organization, "c526ef20-131b-4486-9357-063fa64b5079").setKey("com.microsoft.roslyn:roslyn").setName("Roslyn").setCreatedAt(DateUtils.parseDateTime("2013-03-04T23:03:44+0100"));
dbClient.componentDao().insert(db.getSession(), roslynProject);
dbClient.snapshotDao().insert(db.getSession(), SnapshotTesting.newAnalysis(roslynProject).setStatus(STATUS_UNPROCESSED));
db.getSession().commit();
userSessionRule.logIn().addPermission(ADMINISTER, organization);
TestResponse result = underTest.newRequest().setParam("organization", organization.getKey()).execute();
assertJson(result.getInput()).isSimilarTo(Resources.getResource(getClass(), "projects-example-ghosts.json"));
}
Aggregations