@Test public void shouldUpdateiOSVariantSuccessfully_withMultiPartData() { final iOSVariant original = new iOSVariant(); original.setCertificate("Certificate".getBytes()); final iOSApplicationUploadForm update = new iOSApplicationUploadForm(); final PushApplication pushApp = new PushApplication(); update.setName("variant name"); update.setProduction(false); when(searchService.findByPushApplicationIDForDeveloper("push-app-id")).thenReturn(pushApp); when(variantService.findByVariantID("variant-id")).thenReturn(original); when(validator.validate(update)).thenReturn(Collections.EMPTY_SET); when(validator.validate(original)).thenReturn(Collections.EMPTY_SET); final Response response = this.endpoint.updateiOSVariant(update, "push-app-id", "variant-id"); assertEquals(response.getStatus(), 200); assertEquals(original.getName(), "variant name"); assertNotNull(original.getCertificate()); verify(variantService).updateVariant(original); verify(producer).changeAPNClient(original); }
@PATCH @Path("/{iOSID}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response updateiOSVariant( @PathParam("pushAppID") String pushApplicationId, @PathParam("iOSID") String iOSID, iOSVariant updatediOSVariant) { final PushApplication application = getSearch().findByPushApplicationIDForDeveloper(pushApplicationId); if (application == null) { return Response.status(Response.Status.NOT_FOUND).entity(ErrorBuilder.forPushApplications().notFound().build()).build(); } iOSVariant iOSVariant = (iOSVariant) variantService.findByVariantID(iOSID); if (iOSVariant != null) { iOSVariant.setName(updatediOSVariant.getName()); iOSVariant.setDescription(updatediOSVariant.getDescription()); iOSVariant.setProduction(updatediOSVariant.isProduction()); logger.trace("Updating text details on iOS Variant '{}'", iOSID); variantService.updateVariant(iOSVariant); return Response.noContent().build(); } return Response.status(Status.NOT_FOUND).entity(ErrorBuilder.forVariants().notFound().build()).build(); }
iOSVariantEndpoint extends AbstractVariantEndpoint<iOSVariant> { @PATCH @Path("/{iOSID}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response updateiOSVariant( @PathParam("pushAppID") String pushApplicationId, @PathParam("iOSID") String iOSID, iOSVariant updatediOSVariant) { final PushApplication application = getSearch().findByPushApplicationIDForDeveloper(pushApplicationId); if (application == null) { return Response.status(Response.Status.NOT_FOUND).entity(ErrorBuilder.forPushApplications().notFound().build()).build(); } iOSVariant iOSVariant = (iOSVariant) variantService.findByVariantID(iOSID); if (iOSVariant != null) { iOSVariant.setName(updatediOSVariant.getName()); iOSVariant.setDescription(updatediOSVariant.getDescription()); iOSVariant.setProduction(updatediOSVariant.isProduction()); logger.trace("Updating text details on iOS Variant '{}'", iOSID); variantService.updateVariant(iOSVariant); return Response.noContent().build(); } return Response.status(Status.NOT_FOUND).entity(ErrorBuilder.forVariants().notFound().build()).build(); } }
iOSVariantEndpoint extends AbstractVariantEndpoint<iOSVariant> { @PATCH @Path("/{iOSID}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response updateiOSVariant( @PathParam("pushAppID") String pushApplicationId, @PathParam("iOSID") String iOSID, iOSVariant updatediOSVariant) { final PushApplication application = getSearch().findByPushApplicationIDForDeveloper(pushApplicationId); if (application == null) { return Response.status(Response.Status.NOT_FOUND).entity(ErrorBuilder.forPushApplications().notFound().build()).build(); } iOSVariant iOSVariant = (iOSVariant) variantService.findByVariantID(iOSID); if (iOSVariant != null) { iOSVariant.setName(updatediOSVariant.getName()); iOSVariant.setDescription(updatediOSVariant.getDescription()); iOSVariant.setProduction(updatediOSVariant.isProduction()); logger.trace("Updating text details on iOS Variant '{}'", iOSID); variantService.updateVariant(iOSVariant); return Response.noContent().build(); } return Response.status(Status.NOT_FOUND).entity(ErrorBuilder.forVariants().notFound().build()).build(); } iOSVariantEndpoint();   iOSVariantEndpoint(Validator validator, SearchManager searchManager); }
iOSVariantEndpoint extends AbstractVariantEndpoint<iOSVariant> { @PATCH @Path("/{iOSID}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response updateiOSVariant( @PathParam("pushAppID") String pushApplicationId, @PathParam("iOSID") String iOSID, iOSVariant updatediOSVariant) { final PushApplication application = getSearch().findByPushApplicationIDForDeveloper(pushApplicationId); if (application == null) { return Response.status(Response.Status.NOT_FOUND).entity(ErrorBuilder.forPushApplications().notFound().build()).build(); } iOSVariant iOSVariant = (iOSVariant) variantService.findByVariantID(iOSID); if (iOSVariant != null) { iOSVariant.setName(updatediOSVariant.getName()); iOSVariant.setDescription(updatediOSVariant.getDescription()); iOSVariant.setProduction(updatediOSVariant.isProduction()); logger.trace("Updating text details on iOS Variant '{}'", iOSID); variantService.updateVariant(iOSVariant); return Response.noContent().build(); } return Response.status(Status.NOT_FOUND).entity(ErrorBuilder.forVariants().notFound().build()).build(); } iOSVariantEndpoint();   iOSVariantEndpoint(Validator validator, SearchManager searchManager); @POST @Deprecated @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.APPLICATION_JSON) Response registeriOSVariantMultipart(
            @MultipartForm iOSApplicationUploadForm form,
            @PathParam("pushAppID") String pushApplicationID,
            @Context UriInfo uriInfo); @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response registeriOSVariant(
            iOSApplicationUploadForm form,
            @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,
            iOSVariant updatediOSVariant); @PUT @Path("/{iOSID}") @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.APPLICATION_JSON) @Deprecated Response updateiOSVariantMultipart(
            @MultipartForm iOSApplicationUploadForm updatedForm,
            @PathParam("pushAppID") String pushApplicationId,
            @PathParam("iOSID") String iOSID); @PUT @Path("/{iOSID}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response updateiOSVariant(
            iOSApplicationUploadForm updatedForm,
            @PathParam("pushAppID") String pushApplicationId,
            @PathParam("iOSID") String iOSID); }
iOSVariantEndpoint extends AbstractVariantEndpoint<iOSVariant> { @PATCH @Path("/{iOSID}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response updateiOSVariant( @PathParam("pushAppID") String pushApplicationId, @PathParam("iOSID") String iOSID, iOSVariant updatediOSVariant) { final PushApplication application = getSearch().findByPushApplicationIDForDeveloper(pushApplicationId); if (application == null) { return Response.status(Response.Status.NOT_FOUND).entity(ErrorBuilder.forPushApplications().notFound().build()).build(); } iOSVariant iOSVariant = (iOSVariant) variantService.findByVariantID(iOSID); if (iOSVariant != null) { iOSVariant.setName(updatediOSVariant.getName()); iOSVariant.setDescription(updatediOSVariant.getDescription()); iOSVariant.setProduction(updatediOSVariant.isProduction()); logger.trace("Updating text details on iOS Variant '{}'", iOSID); variantService.updateVariant(iOSVariant); return Response.noContent().build(); } return Response.status(Status.NOT_FOUND).entity(ErrorBuilder.forVariants().notFound().build()).build(); } iOSVariantEndpoint();   iOSVariantEndpoint(Validator validator, SearchManager searchManager); @POST @Deprecated @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.APPLICATION_JSON) Response registeriOSVariantMultipart(
            @MultipartForm iOSApplicationUploadForm form,
            @PathParam("pushAppID") String pushApplicationID,
            @Context UriInfo uriInfo); @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response registeriOSVariant(
            iOSApplicationUploadForm form,
            @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,
            iOSVariant updatediOSVariant); @PUT @Path("/{iOSID}") @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.APPLICATION_JSON) @Deprecated Response updateiOSVariantMultipart(
            @MultipartForm iOSApplicationUploadForm updatedForm,
            @PathParam("pushAppID") String pushApplicationId,
            @PathParam("iOSID") String iOSID); @PUT @Path("/{iOSID}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response updateiOSVariant(
            iOSApplicationUploadForm updatedForm,
            @PathParam("pushAppID") String pushApplicationId,
            @PathParam("iOSID") String iOSID);  }