}
/**
- * Used by Pico is no {@link ProfileExporter} is found
+ * Used by Pico if no {@link ProfileExporter} is found
*/
public ExportersAction() {
this(new ProfileExporter[0]);
context.createAction("exporters")
.setDescription("Lists available profile export formats.")
.setHandler(this)
- .setResponseExample(getClass().getResource("example-exporters.json"))
+ .setResponseExample(getClass().getResource("exporters-example.json"))
.setSince("5.2");
}
+++ /dev/null
-{
- "exporters": [
- {"key": "pmd", "name": "PMD", "languages": ["java"]},
- {"key": "checkstyle", "name": "Checkstyle", "languages": ["java"]},
- {"key": "js-lint", "name": "JS Lint", "languages": ["js"]},
- {"key": "android-lint", "name": "Android Lint", "languages": ["xml", "java"]}
- ]
-}
import org.junit.Test;
import org.sonar.api.profiles.ProfileExporter;
import org.sonar.api.profiles.RulesProfile;
-import org.sonar.server.ws.WsTester;
+import org.sonar.server.ws.WsActionTester;
+
+import static org.sonar.test.JsonAssert.assertJson;
public class ExportersActionTest {
+ private WsActionTester ws = new WsActionTester(new ExportersAction(createExporters()));
@Test
public void importers_nominal() throws Exception {
- WsTester wsTester = new WsTester(new QProfilesWs(
- new ExportersAction(createExporters())));
+ String result = ws.newRequest().execute().getInput();
- wsTester.newGetRequest("api/qualityprofiles", "exporters").execute().assertJson(getClass(), "exporters.json");
+ assertJson(result).isSimilarTo(ws.getDef().responseExampleAsString());
}
private ProfileExporter[] createExporters() {
}
return new ProfileExporter[] {
- new NoopImporter("findbugs", "FindBugs", "java"),
- new NoopImporter("jslint", "JS Lint", "js"),
- new NoopImporter("vaadin", "Vaadin", "java", "js")
+ new NoopImporter("pmd", "PMD", "java"),
+ new NoopImporter("checkstyle", "Checkstyle", "java"),
+ new NoopImporter("js-lint", "JS Lint", "js"),
+ new NoopImporter("android-lint", "Android Lint", "xml", "java")
};
}
}
+++ /dev/null
-{
- "exporters": [
- {"key": "findbugs", "name": "FindBugs", "languages": ["java"]},
- {"key": "jslint", "name": "JS Lint", "languages": ["js"]},
- {"key": "vaadin", "name": "Vaadin", "languages": ["java", "js"]}
- ]
-}