private void putActivityIntoResponseHeaders(PushApplication app, ResponseBuilder response) { response.header( "activity_app_" + app.getPushApplicationID(), metricsService.countMessagesForPushApplication(app.getPushApplicationID())); for (Variant variant : app.getVariants()) { response.header( "activity_variant_" + variant.getVariantID(), metricsService.countMessagesForVariant(variant.getVariantID())); } }
/** * Create Push Application * * @param pushApp new {@link PushApplication} * @return created {@link PushApplication} * @statuscode 201 The PushApplication Variant created successfully * @statuscode 400 The format of the client request was incorrect */ @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @ReturnType("org.jboss.aerogear.unifiedpush.api.PushApplication") public Response registerPushApplication(PushApplication pushApp) { // some validation try { validateModelClass(pushApp); } catch (ConstraintViolationException cve) { // Build and return the 400 (Bad Request) response ResponseBuilder builder = createBadRequestResponse(cve.getConstraintViolations()); return builder.build(); } pushAppService.addPushApplication(pushApp); return Response.created( UriBuilder.fromResource(PushApplicationEndpoint.class) .path(String.valueOf(pushApp.getPushApplicationID())) .build()) .entity(pushApp) .build(); }
private void putDeviceCountIntoResponseHeaders(PushApplication app, ResponseBuilder response) { long appCount = 0; for (Variant variant : app.getVariants()) { long variantCount = installationDao.getNumberOfDevicesForVariantID(variant.getVariantID()); appCount += variantCount; response.header("deviceCount_variant_" + variant.getVariantID(), variantCount); } response.header("deviceCount_app_" + app.getPushApplicationID(), appCount); }
@Test public void primaryKeyUnmodifiedAfterUpdate() { final String id = "1"; PushApplication pa = pushApplicationDao.find(id); assertThat(pa.getId()).isEqualTo(id); final PushApplication pushApplication1 = pushApplicationDao.findByPushApplicationID(pa.getPushApplicationID()); 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"); }