Package org.jboss.aerogear.unifiedpush.api

Examples of org.jboss.aerogear.unifiedpush.api.PushApplication


        assertThat(pushApplicationDao.findByPushApplicationID(pushApplicationID1).getPushApplicationID()).isEqualTo(pushApplicationID1);
    }

    @Test
    public void primaryKeyUnmodifiedAfterUpdate() {
        PushApplication pushApplication1 = new PushApplication ();
        pushApplication1.setName("Push App 1");
        final String id = pushApplication1.getId();
        pushApplicationDao.create(pushApplication1);

        // flush to be sure that it's in the database
        entityManager.flush();
        // clear the cache otherwise finding the entity will not perform a select but get the entity from cache
        entityManager.clear();


        PushApplication pa = pushApplicationDao.find(id);

        assertThat(pa.getId()).isEqualTo(id);

        pushApplication1.setName("Cool Push App 1");
        pushApplicationDao.update(pushApplication1);

        entityManager.flush();
        entityManager.clear();

        pa = pushApplicationDao.find(id);

        assertThat(pa.getName()).isEqualTo("Cool Push App 1");
    }
View Full Code Here


        assertThat(pa.getName()).isEqualTo("Cool Push App 1");
    }

    @Test
    public void deletePushApplicationIncludingVariantAndInstallations() {
        PushApplication pushApplication1 = new PushApplication();
        pushApplication1.setName("Push App 1");
        final String id = pushApplication1.getId();
        pushApplicationDao.create(pushApplication1);

        // flush to be sure that it's in the database
        entityManager.flush();
        // clear the cache otherwise finding the entity will not perform a select but get the entity from cache
        entityManager.clear();

        PushApplication pa = pushApplicationDao.find(id);
        assertThat(pa.getId()).isEqualTo(id);

        AndroidVariant av = new AndroidVariant();
        av.setName("Android Variant");
        av.setGoogleKey("KEY...");
        variantDao.create(av);

        Installation androidInstallation1 = new Installation();
        androidInstallation1.setDeviceToken("1234543212232312345432122323123454321223231234543212232312345432122323123454321223231234543212232312345432122323");
        installationDao.create(androidInstallation1);

        androidInstallation1.setVariant(av);
        variantDao.update(av);

        pa.getVariants().add(av);
        pushApplicationDao.update(pa);

        assertThat(installationDao.find(androidInstallation1.getId())).isNotNull();

        pushApplicationDao.delete(pa);
View Full Code Here

            @MultipartForm iOSApplicationUploadForm form,
            @PathParam("pushAppID") String pushApplicationID,
            @Context UriInfo uriInfo,
            @Context HttpServletRequest request) {
        // find the root push app
        PushApplication pushApp = pushAppService.findByPushApplicationIDForDeveloper(pushApplicationID, extractUsername(request));

        if (pushApp == null) {
            return Response.status(Status.NOT_FOUND).entity("Could not find requested PushApplicationEntity").build();
        }
View Full Code Here

    // READ
    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public Response listAlliOSVariantsForPushApp(@Context HttpServletRequest request,
                                                 @PathParam("pushAppID") String pushApplicationID) {
        final PushApplication application = pushAppService.findByPushApplicationIDForDeveloper(pushApplicationID, extractUsername(request));
        return Response.ok(getVariantsByType(application, iOSVariant.class)).build();
    }
View Full Code Here

        assertThat(pushApplicationDao.find(id)).isNull();
    }

    @Test
    public void shouldCountInstallations() {
        PushApplication pushApplication1 = new PushApplication();
        pushApplication1.setName("Push App 1");
        final String id = pushApplication1.getId();
        pushApplicationDao.create(pushApplication1);

        PushApplication pa = pushApplicationDao.find(id);

        AndroidVariant av = new AndroidVariant();
        av.setName("Android Variant");
        av.setGoogleKey("KEY...");
        variantDao.create(av);

        iOSVariant ios = new iOSVariant();
        ios.setName("spelling is hard");
        ios.setPassphrase("123");
        ios.setCertificate("12".getBytes());
        variantDao.create(ios);

        Installation androidInstallation1 = new Installation();
        androidInstallation1.setDeviceToken("CSPA91bGDWDdlxW3EmSs2bH7Qlo5AOfbCJtmyOukYxVHq8KKUqpPLBLUjettGYoN2nahBbAe3GgmxKPcZnqEIFFxHw3brKOSmeXjZQuEVehSJTUdJuXUCmR3XweZ2MM455fYMcvkUse1DIp1wjxnik2uHYSNl87wrJzLddoC7tPpgch3eJAf");
        installationDao.create(androidInstallation1);

        Installation androidInstallation2 = new Installation();
        androidInstallation2.setDeviceToken("ASPA91bGDWDdlxW3EmSs2bH7Qlo5AOfbCJtmyOukYxVHq8KKUqpPLBLUjettGYoN2nahBbAe3GgmxKPcZnqEIFFxHw3brKOSmeXjZQuEVehSJTUdJuXUCmR3XweZ2MM455fYMcvkUse1DIp1wjxnik2uHYSNl87wrJzLddoC7tPpgch3eJAf");
        installationDao.create(androidInstallation2);

        Installation iosInstallation1 = new Installation();
        iosInstallation1.setDeviceToken("33ee51dad49a77ca7b45924074bcc4f19aea20308f5feda202fbba3baed7073d7");
        installationDao.create(iosInstallation1);

        androidInstallation1.setVariant(av);
        androidInstallation2.setVariant(av);
        iosInstallation1.setVariant(ios);
        variantDao.update(av);
        variantDao.update(ios);

        pa.getVariants().add(av);
        pa.getVariants().add(ios);
        pushApplicationDao.update(pa);

        // flush to be sure that it's in the database
        entityManager.flush();
        // clear the cache otherwise finding the entity will not perform a select but get the entity from cache
View Full Code Here

    }

    @Test
    public void shouldFindPushApplicationNameAndIDbasedOnVariantID() {
        //given
        PushApplication pushApplication1 = new PushApplication();
        final String appName = "Push App 1";
        pushApplication1.setName(appName);
        final String id = pushApplication1.getId();
        pushApplicationDao.create(pushApplication1);

        PushApplication pa = pushApplicationDao.find(id);

        AndroidVariant av = new AndroidVariant();
        av.setName("Android Variant");
        av.setGoogleKey("KEY...");
        variantDao.create(av);

        AndroidVariant ignored = new AndroidVariant();
        ignored.setName("ignored");
        ignored.setGoogleKey("123");
        variantDao.create(ignored);

        iOSVariant iOSVariant = new iOSVariant();
        iOSVariant.setName("ignored");
        iOSVariant.setCertificate(new byte[1]);
        iOSVariant.setPassphrase("123");
        variantDao.create(iOSVariant);

        pa.getVariants().add(av);
        pa.getVariants().add(ignored);
        pa.getVariants().add(iOSVariant);
        pushApplicationDao.update(pa);

        entityManager.flush();
        entityManager.clear();

        //when
        final List<PushApplication> applications = pushApplicationDao.findByVariantIds(Arrays.asList(av.getVariantID()));

        //then
        assertThat(applications).isNotEmpty();
        assertThat(applications.size()).isEqualTo(1);

        final PushApplication application = applications.iterator().next();
        assertThat(application.getName()).isEqualTo(appName);
        assertThat(application.getVariants()).isNotEmpty();
        assertThat(application.getVariants().size()).isEqualTo(1);
        assertThat(application.getVariants().iterator().next().getId()).isEqualTo(av.getId());
    }
View Full Code Here

    @GET
    @Path("/{pushAppID}")
    @Produces(MediaType.APPLICATION_JSON)
    public Response findById(@Context HttpServletRequest request, @PathParam("pushAppID") String pushApplicationID) {

        PushApplication pushApp = pushAppService.findByPushApplicationIDForDeveloper(pushApplicationID, extractUsername(request));

        if (pushApp != null) {
            return Response.ok(pushApp).build();
        }
View Full Code Here

    @Path("/{pushAppID}")
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    public Response updatePushApplication(@Context HttpServletRequest request, @PathParam("pushAppID") String pushApplicationID, PushApplication updatedPushApp) {

        PushApplication pushApp = pushAppService.findByPushApplicationIDForDeveloper(pushApplicationID, extractUsername(request));

        if (pushApp != null) {

            // some validation
            try {
                validateModelClass(updatedPushApp);
            } catch (ConstraintViolationException cve) {

                // Build and return the 400 (Bad Request) response
                ResponseBuilder builder = createBadRequestResponse(cve.getConstraintViolations());

                return builder.build();
            }

            // update name/desc:
            pushApp.setDescription(updatedPushApp.getDescription());
            pushApp.setName(updatedPushApp.getName());
            pushAppService.updatePushApplication(pushApp);

            return Response.noContent().build();
        }
View Full Code Here

    @Path("/{pushAppID}/reset")
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    public Response resetMasterSecret(@Context HttpServletRequest request, @PathParam("pushAppID") String pushApplicationID) {

        PushApplication pushApp = pushAppService.findByPushApplicationIDForDeveloper(pushApplicationID, extractUsername(request));

        if (pushApp != null) {
            // generate the new 'masterSecret' and apply it:
            String newMasterSecret = UUID.randomUUID().toString();
            pushApp.setMasterSecret(newMasterSecret);
            pushAppService.updatePushApplication(pushApp);

            return Response.ok(pushApp).build();
        }
View Full Code Here

    @DELETE
    @Path("/{pushAppID}")
    @Produces(MediaType.APPLICATION_JSON)
    public Response deletePushApplication(@Context HttpServletRequest request, @PathParam("pushAppID") String pushApplicationID) {

        PushApplication pushApp = pushAppService.findByPushApplicationIDForDeveloper(pushApplicationID, extractUsername(request));

        if (pushApp != null) {
            pushAppService.removePushApplication(pushApp);
            return Response.noContent().build();
        }
View Full Code Here

TOP

Related Classes of org.jboss.aerogear.unifiedpush.api.PushApplication

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.