@Test public void shouldRegisteriOSTokenVariantSuccessfully() { final ResteasyUriInfo uriInfo = new ResteasyUriInfo("http: final PushApplication pushApp = new PushApplication(); final iOSTokenVariant form = new iOSTokenVariant(); form.setName("variant name"); form.setPrivateKey("privateKey"); form.setTeamId("team id"); form.setKeyId("key id"); form.setBundleId("test.my.toe"); form.setProduction(false); when(searchService.findByPushApplicationIDForDeveloper("push-app-id")).thenReturn(pushApp); when(validator.validate(form)).thenReturn(Collections.EMPTY_SET); final Response response = this.endpoint.registeriOSVariant(form, "push-app-id", uriInfo); assertEquals(response.getStatus(), 201); final iOSTokenVariant createdVariant = (iOSTokenVariant) response.getEntity(); assertEquals(createdVariant.getName(), "variant name"); assertEquals(createdVariant.getPrivateKey(), "privateKey"); assertEquals(createdVariant.getTeamId(), "team id"); assertEquals(createdVariant.getKeyId(), "key id"); assertEquals(createdVariant.getBundleId(), "test.my.toe"); assertEquals(response.getMetadata().get("location").get(0).toString(), "http: verify(variantService).addVariant(createdVariant); verify(pushAppService).addVariant(pushApp, createdVariant); }
@POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response registeriOSVariant( iOSTokenVariant iOSVariant, @PathParam("pushAppID") String pushApplicationID, @Context UriInfo uriInfo) { PushApplication pushApp = getSearch().findByPushApplicationIDForDeveloper(pushApplicationID); if (pushApp == null) { return Response.status(Status.NOT_FOUND).entity(ErrorBuilder.forPushApplications().notFound().build()).build(); } try { validateModelClass(iOSVariant); } catch (ConstraintViolationException cve) { logger.trace("Unable to create iOS variant entity"); ResponseBuilder builder = createBadRequestResponse(cve.getConstraintViolations()); return builder.build(); } logger.trace("Register iOS token variant with Push Application '{}'", pushApplicationID); variantService.addVariant(iOSVariant); pushAppService.addVariant(pushApp, iOSVariant); return Response.created(uriInfo.getAbsolutePathBuilder().path(String.valueOf(iOSVariant.getVariantID())).build()).entity(iOSVariant).build(); }
iOSTokenVariantEndpoint extends AbstractVariantEndpoint<iOSTokenVariant> { @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response registeriOSVariant( iOSTokenVariant iOSVariant, @PathParam("pushAppID") String pushApplicationID, @Context UriInfo uriInfo) { PushApplication pushApp = getSearch().findByPushApplicationIDForDeveloper(pushApplicationID); if (pushApp == null) { return Response.status(Status.NOT_FOUND).entity(ErrorBuilder.forPushApplications().notFound().build()).build(); } try { validateModelClass(iOSVariant); } catch (ConstraintViolationException cve) { logger.trace("Unable to create iOS variant entity"); ResponseBuilder builder = createBadRequestResponse(cve.getConstraintViolations()); return builder.build(); } logger.trace("Register iOS token variant with Push Application '{}'", pushApplicationID); variantService.addVariant(iOSVariant); pushAppService.addVariant(pushApp, iOSVariant); return Response.created(uriInfo.getAbsolutePathBuilder().path(String.valueOf(iOSVariant.getVariantID())).build()).entity(iOSVariant).build(); } }
iOSTokenVariantEndpoint extends AbstractVariantEndpoint<iOSTokenVariant> { @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response registeriOSVariant( iOSTokenVariant iOSVariant, @PathParam("pushAppID") String pushApplicationID, @Context UriInfo uriInfo) { PushApplication pushApp = getSearch().findByPushApplicationIDForDeveloper(pushApplicationID); if (pushApp == null) { return Response.status(Status.NOT_FOUND).entity(ErrorBuilder.forPushApplications().notFound().build()).build(); } try { validateModelClass(iOSVariant); } catch (ConstraintViolationException cve) { logger.trace("Unable to create iOS variant entity"); ResponseBuilder builder = createBadRequestResponse(cve.getConstraintViolations()); return builder.build(); } logger.trace("Register iOS token variant with Push Application '{}'", pushApplicationID); variantService.addVariant(iOSVariant); pushAppService.addVariant(pushApp, iOSVariant); return Response.created(uriInfo.getAbsolutePathBuilder().path(String.valueOf(iOSVariant.getVariantID())).build()).entity(iOSVariant).build(); } iOSTokenVariantEndpoint();   iOSTokenVariantEndpoint(Validator validator, SearchManager searchManager); }
iOSTokenVariantEndpoint extends AbstractVariantEndpoint<iOSTokenVariant> { @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response registeriOSVariant( iOSTokenVariant iOSVariant, @PathParam("pushAppID") String pushApplicationID, @Context UriInfo uriInfo) { PushApplication pushApp = getSearch().findByPushApplicationIDForDeveloper(pushApplicationID); if (pushApp == null) { return Response.status(Status.NOT_FOUND).entity(ErrorBuilder.forPushApplications().notFound().build()).build(); } try { validateModelClass(iOSVariant); } catch (ConstraintViolationException cve) { logger.trace("Unable to create iOS variant entity"); ResponseBuilder builder = createBadRequestResponse(cve.getConstraintViolations()); return builder.build(); } logger.trace("Register iOS token variant with Push Application '{}'", pushApplicationID); variantService.addVariant(iOSVariant); pushAppService.addVariant(pushApp, iOSVariant); return Response.created(uriInfo.getAbsolutePathBuilder().path(String.valueOf(iOSVariant.getVariantID())).build()).entity(iOSVariant).build(); } iOSTokenVariantEndpoint();   iOSTokenVariantEndpoint(Validator validator, SearchManager searchManager); @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response registeriOSVariant(
            iOSTokenVariant iOSVariant,
            @PathParam("pushAppID") String pushApplicationID,
            @Context UriInfo uriInfo); @GET @Produces(MediaType.APPLICATION_JSON) Response listAlliOSVariantsForPushApp(@PathParam("pushAppID") String pushApplicationID); @PATCH @Path("/{iOSID}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response updateiOSVariant(
            @PathParam("pushAppID") String pushApplicationId,
            @PathParam("iOSID") String iOSID,
            iOSTokenVariant updatediOSVariant); @PUT @Path("/{iOSID}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response updateiOSVariant(
            iOSTokenVariant updatediOSVariant,
            @PathParam("pushAppID") String pushApplicationId,
            @PathParam("iOSID") String iOSID); }
iOSTokenVariantEndpoint extends AbstractVariantEndpoint<iOSTokenVariant> { @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response registeriOSVariant( iOSTokenVariant iOSVariant, @PathParam("pushAppID") String pushApplicationID, @Context UriInfo uriInfo) { PushApplication pushApp = getSearch().findByPushApplicationIDForDeveloper(pushApplicationID); if (pushApp == null) { return Response.status(Status.NOT_FOUND).entity(ErrorBuilder.forPushApplications().notFound().build()).build(); } try { validateModelClass(iOSVariant); } catch (ConstraintViolationException cve) { logger.trace("Unable to create iOS variant entity"); ResponseBuilder builder = createBadRequestResponse(cve.getConstraintViolations()); return builder.build(); } logger.trace("Register iOS token variant with Push Application '{}'", pushApplicationID); variantService.addVariant(iOSVariant); pushAppService.addVariant(pushApp, iOSVariant); return Response.created(uriInfo.getAbsolutePathBuilder().path(String.valueOf(iOSVariant.getVariantID())).build()).entity(iOSVariant).build(); } iOSTokenVariantEndpoint();   iOSTokenVariantEndpoint(Validator validator, SearchManager searchManager); @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response registeriOSVariant(
            iOSTokenVariant iOSVariant,
            @PathParam("pushAppID") String pushApplicationID,
            @Context UriInfo uriInfo); @GET @Produces(MediaType.APPLICATION_JSON) Response listAlliOSVariantsForPushApp(@PathParam("pushAppID") String pushApplicationID); @PATCH @Path("/{iOSID}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response updateiOSVariant(
            @PathParam("pushAppID") String pushApplicationId,
            @PathParam("iOSID") String iOSID,
            iOSTokenVariant updatediOSVariant); @PUT @Path("/{iOSID}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response updateiOSVariant(
            iOSTokenVariant updatediOSVariant,
            @PathParam("pushAppID") String pushApplicationId,
            @PathParam("iOSID") String iOSID);  }