@Test public void testCreateNewDeploymentGroup() { final Response response = resource.createDeploymentGroup(mock(DeploymentGroup.class)); assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); assertEquals(new CreateDeploymentGroupResponse( CreateDeploymentGroupResponse.Status.CREATED), response.getEntity()); }
@POST @Produces(APPLICATION_JSON) @Timed @ExceptionMetered public Response createDeploymentGroup(@Valid final DeploymentGroup deploymentGroup) { try { model.addDeploymentGroup(deploymentGroup); return Response.ok(CREATED_RESPONSE).build(); } catch (DeploymentGroupExistsException ignored) { final DeploymentGroup existing; try { existing = model.getDeploymentGroup(deploymentGroup.getName()); } catch (DeploymentGroupDoesNotExistException e) { return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } if (!Objects.equals(existing.getHostSelectors(), deploymentGroup.getHostSelectors())) { return Response.ok(DEPLOYMENT_GROUP_ALREADY_EXISTS_RESPONSE).build(); } return Response.ok(NOT_MODIFIED_RESPONSE).build(); } }
DeploymentGroupResource { @POST @Produces(APPLICATION_JSON) @Timed @ExceptionMetered public Response createDeploymentGroup(@Valid final DeploymentGroup deploymentGroup) { try { model.addDeploymentGroup(deploymentGroup); return Response.ok(CREATED_RESPONSE).build(); } catch (DeploymentGroupExistsException ignored) { final DeploymentGroup existing; try { existing = model.getDeploymentGroup(deploymentGroup.getName()); } catch (DeploymentGroupDoesNotExistException e) { return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } if (!Objects.equals(existing.getHostSelectors(), deploymentGroup.getHostSelectors())) { return Response.ok(DEPLOYMENT_GROUP_ALREADY_EXISTS_RESPONSE).build(); } return Response.ok(NOT_MODIFIED_RESPONSE).build(); } } }
DeploymentGroupResource { @POST @Produces(APPLICATION_JSON) @Timed @ExceptionMetered public Response createDeploymentGroup(@Valid final DeploymentGroup deploymentGroup) { try { model.addDeploymentGroup(deploymentGroup); return Response.ok(CREATED_RESPONSE).build(); } catch (DeploymentGroupExistsException ignored) { final DeploymentGroup existing; try { existing = model.getDeploymentGroup(deploymentGroup.getName()); } catch (DeploymentGroupDoesNotExistException e) { return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } if (!Objects.equals(existing.getHostSelectors(), deploymentGroup.getHostSelectors())) { return Response.ok(DEPLOYMENT_GROUP_ALREADY_EXISTS_RESPONSE).build(); } return Response.ok(NOT_MODIFIED_RESPONSE).build(); } } DeploymentGroupResource(final MasterModel model); }
DeploymentGroupResource { @POST @Produces(APPLICATION_JSON) @Timed @ExceptionMetered public Response createDeploymentGroup(@Valid final DeploymentGroup deploymentGroup) { try { model.addDeploymentGroup(deploymentGroup); return Response.ok(CREATED_RESPONSE).build(); } catch (DeploymentGroupExistsException ignored) { final DeploymentGroup existing; try { existing = model.getDeploymentGroup(deploymentGroup.getName()); } catch (DeploymentGroupDoesNotExistException e) { return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } if (!Objects.equals(existing.getHostSelectors(), deploymentGroup.getHostSelectors())) { return Response.ok(DEPLOYMENT_GROUP_ALREADY_EXISTS_RESPONSE).build(); } return Response.ok(NOT_MODIFIED_RESPONSE).build(); } } DeploymentGroupResource(final MasterModel model); @POST @Produces(APPLICATION_JSON) @Timed @ExceptionMetered Response createDeploymentGroup(@Valid final DeploymentGroup deploymentGroup); @GET @Path("/{name}") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered Response getDeploymentGroup(@PathParam("name") final String name); @GET @Produces(APPLICATION_JSON) @Timed @ExceptionMetered List<String> getDeploymentGroup(); @DELETE @Path("/{name}") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered Response removeDeploymentGroup(@PathParam("name") @Valid final String name); @POST @Path("/{name}/rolling-update") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered Response rollingUpdate(@PathParam("name") @Valid final String name,
                                @Valid final RollingUpdateRequest args); @POST @Path("/{name}/stop") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered Response stopDeploymentGroup(@PathParam("name") @Valid final String name); @GET @Path("/{name}/status") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered Response getDeploymentGroupStatus(@PathParam("name") @Valid final String name); }
DeploymentGroupResource { @POST @Produces(APPLICATION_JSON) @Timed @ExceptionMetered public Response createDeploymentGroup(@Valid final DeploymentGroup deploymentGroup) { try { model.addDeploymentGroup(deploymentGroup); return Response.ok(CREATED_RESPONSE).build(); } catch (DeploymentGroupExistsException ignored) { final DeploymentGroup existing; try { existing = model.getDeploymentGroup(deploymentGroup.getName()); } catch (DeploymentGroupDoesNotExistException e) { return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } if (!Objects.equals(existing.getHostSelectors(), deploymentGroup.getHostSelectors())) { return Response.ok(DEPLOYMENT_GROUP_ALREADY_EXISTS_RESPONSE).build(); } return Response.ok(NOT_MODIFIED_RESPONSE).build(); } } DeploymentGroupResource(final MasterModel model); @POST @Produces(APPLICATION_JSON) @Timed @ExceptionMetered Response createDeploymentGroup(@Valid final DeploymentGroup deploymentGroup); @GET @Path("/{name}") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered Response getDeploymentGroup(@PathParam("name") final String name); @GET @Produces(APPLICATION_JSON) @Timed @ExceptionMetered List<String> getDeploymentGroup(); @DELETE @Path("/{name}") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered Response removeDeploymentGroup(@PathParam("name") @Valid final String name); @POST @Path("/{name}/rolling-update") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered Response rollingUpdate(@PathParam("name") @Valid final String name,
                                @Valid final RollingUpdateRequest args); @POST @Path("/{name}/stop") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered Response stopDeploymentGroup(@PathParam("name") @Valid final String name); @GET @Path("/{name}/status") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered Response getDeploymentGroupStatus(@PathParam("name") @Valid final String name);  }