before_filter :admin_required, :only => [ :create, :delete, :update, :close, :open ]
- #
- # GET /api/action_plan/show?key=<key>
- #
- # -- Example
- # curl -v -u 'http://localhost:9000/api/action_plans/show?key=9b6f89c0-3347-46f6-a6d1-dd6c761240e0'
- #
- def show
- require_parameters :key
-
- action_plan = Internal.issues.findActionPlan(params[:key])
- hash = {}
- hash[:actionPlan] = action_plan_to_hash(action_plan) if action_plan
-
- respond_to do |format|
- format.json { render :json => jsonp(hash) }
- format.xml { render :xml => hash.to_xml(:skip_types => true, :root => 'actionPlan') }
- end
- end
-
-
#
# GET /api/action_plans/search?project=<project>
#
return result;
}
- @Override
- public ActionPlan get(String actionPlanKey) {
- HttpRequest request = requestFactory.get("/api/action_plans/show", EncodingUtils.toMap("key", actionPlanKey));
- if (!request.ok()) {
- throw new IllegalStateException("Fail to search action plan. Bad HTTP response status: " + request.code());
- }
- return createActionPlanResult(request);
- }
-
@Override
public ActionPlan create(NewActionPlan newActionPlan) {
HttpRequest request = requestFactory.post(NewActionPlan.BASE_URL, newActionPlan.urlParams());
assertThat(actionPlan.updatedAt()).isNotNull();
}
- @Test
- public void should_find_action_plan() {
- HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url(), null, null);
- httpServer.doReturnBody("{\"actionPlan\": {\"key\": \"382f6f2e-ad9d-424a-b973-9b065e04348a\",\n" +
- "\"name\": \"Long term\",\n" +
- "\"status\": \"CLOSED\",\n" +
- "\"project\": \"com.sonarsource.it.samples:simple-sample\",\n" +
- "\"userLogin\": \"admin\",\n" +
- "\"deadLine\": \"2013-05-30T00:00:00+0200\",\n" +
- "\"totalIssues\": 0,\n" +
- "\"openIssues\": 0,\n" +
- "\"createdAt\": \"2013-05-13T12:50:29+0200\",\n" +
- "\"updatedAt\": \"2013-05-13T12:50:44+0200\"}}");
-
- ActionPlanClient client = new DefaultActionPlanClient(requestFactory);
- ActionPlan actionPlan = client.get("382f6f2e-ad9d-424a-b973-9b065e04348a");
-
- assertThat(httpServer.requestedPath()).isEqualTo("/api/action_plans/show?key=382f6f2e-ad9d-424a-b973-9b065e04348a");
- assertThat(actionPlan).isNotNull();
- assertThat(actionPlan.key()).isEqualTo("382f6f2e-ad9d-424a-b973-9b065e04348a");
- assertThat(actionPlan.name()).isEqualTo("Long term");
- assertThat(actionPlan.project()).isEqualTo("com.sonarsource.it.samples:simple-sample");
- assertThat(actionPlan.status()).isEqualTo("CLOSED");
- assertThat(actionPlan.userLogin()).isEqualTo("admin");
- assertThat(actionPlan.deadLine()).isNotNull();
- assertThat(actionPlan.totalIssues()).isEqualTo(0);
- assertThat(actionPlan.openIssues()).isEqualTo(0);
- assertThat(actionPlan.createdAt()).isNotNull();
- assertThat(actionPlan.updatedAt()).isNotNull();
- }
-
@Test
public void should_create_action_plan() {
HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url(), null, null);