private static final String PARAM_PROFILE_NAME = "name";
private static final String PARAM_LANGUAGE = "language";
- private static final String PARAM_FORMAT = "format";
+ private static final String PARAM_FORMAT = "exporterKey";
private final DbClient dbClient;
}
if (!exporterKeys.isEmpty()) {
create.createParam(PARAM_FORMAT)
- .setDescription("Output format. If left empty, the same format as api/qualityprofiles/backup is used.")
+ .setDescription("Output format. If left empty, the same format as api/qualityprofiles/backup is used. " +
+ "Possible values are described by api/qualityprofiles/exporters.")
.setPossibleValues(exporterKeys);
}
}
session.commit();
Result result = wsTester.newGetRequest("api/qualityprofiles", "export")
- .setParam("language", profile.getLanguage()).setParam("name", profile.getName()).setParam("format", "polop").execute();
+ .setParam("language", profile.getLanguage()).setParam("name", profile.getName()).setParam("exporterKey", "polop").execute();
assertThat(result.outputAsString()).isEqualTo("Profile " + profile.getName() + " exported by polop");
}
session.commit();
Result result = wsTester.newGetRequest("api/qualityprofiles", "export")
- .setParam("language", "xoo").setParam("format", "polop").execute();
+ .setParam("language", "xoo").setParam("exporterKey", "polop").execute();
assertThat(result.outputAsString()).isEqualTo("Profile " + profile2.getName() + " exported by polop");
}
@Test(expected = NotFoundException.class)
public void fail_on_unknown_profile() throws Exception {
wsTester.newGetRequest("api/qualityprofiles", "export")
- .setParam("language", "xoo").setParam("format", "polop").execute();
+ .setParam("language", "xoo").setParam("exporterKey", "polop").execute();
}
@Test(expected = IllegalArgumentException.class)
session.commit();
wsTester.newGetRequest("api/qualityprofiles", "export")
- .setParam("language", "xoo").setParam("format", "unknown").execute();
+ .setParam("language", "xoo").setParam("exporterKey", "unknown").execute();
}
@Test
public void do_not_fail_when_no_exporters() throws Exception {
- exporters = new QProfileExporters(null, null, null, new ProfileExporter[0], null);
- wsTester = new WsTester(new QProfilesWs(mock(RuleActivationActions.class),
+ QProfileExporters myExporters = new QProfileExporters(null, null, null, new ProfileExporter[0], null);
+ WsTester myWsTester = new WsTester(new QProfilesWs(mock(RuleActivationActions.class),
mock(BulkRuleActivationActions.class),
mock(ProjectAssociationActions.class),
- new QProfileExportAction(dbClient, new QProfileFactory(dbClient), backuper, exporters, LanguageTesting.newLanguages("xoo"))));
+ new QProfileExportAction(dbClient, new QProfileFactory(dbClient), backuper, myExporters, LanguageTesting.newLanguages("xoo"))));
- Action export = wsTester.controller("api/qualityprofiles").action("export");
+ Action export = myWsTester.controller("api/qualityprofiles").action("export");
assertThat(export.params()).hasSize(2);
QualityProfileDto profile = QProfileTesting.newXooP1();
qualityProfileDao.insert(session, profile);
session.commit();
- wsTester.newGetRequest("api/qualityprofiles", "export").setParam("language", "xoo").setParam("name", profile.getName()).execute();
+ myWsTester.newGetRequest("api/qualityprofiles", "export").setParam("language", "xoo").setParam("name", profile.getName()).execute();
}
}