@Test public void testUnregister() throws Exception { Credentials user = AuthenticationEndpointTest.signUpUser(this); PublicKey key = AuthenticationEndpointTest.getPublicKey(this); Response tokenResponse = registerToken(user, key, this); String newAuthToken = tokenResponse.getHeaderString("Authorization"); Response response = target("/push") .request() .header(ContainerRequest.AUTHORIZATION, "CUSTOM " + newAuthToken) .delete(); int statusCode = response.getStatus(); assertEquals(200,statusCode); Collection<TransientObject> list = container.serverDao.get(Query.safeTable(Credentials.class),user.getObjectKey()); TransientObject o = ObjectUtils.get1stOrNull(list); user = TestUtils.convert(o,Credentials.class); assertNotNull(user); assertEquals("", user.getPushMessagingKey()); }
@DELETE public Response unregister(@Context Session session){ try{ Credentials credentials = session.getUser(); credentials.setPushMessagingKey(""); dao.save(credentials); } catch (ServerDAO.DAOException e) { logger.severe(ExceptionUtils.getStackTrace(e)); return fromDAOExpection(e); } return Response.ok().build(); }
PushEndpoint { @DELETE public Response unregister(@Context Session session){ try{ Credentials credentials = session.getUser(); credentials.setPushMessagingKey(""); dao.save(credentials); } catch (ServerDAO.DAOException e) { logger.severe(ExceptionUtils.getStackTrace(e)); return fromDAOExpection(e); } return Response.ok().build(); } }
PushEndpoint { @DELETE public Response unregister(@Context Session session){ try{ Credentials credentials = session.getUser(); credentials.setPushMessagingKey(""); dao.save(credentials); } catch (ServerDAO.DAOException e) { logger.severe(ExceptionUtils.getStackTrace(e)); return fromDAOExpection(e); } return Response.ok().build(); }  }
PushEndpoint { @DELETE public Response unregister(@Context Session session){ try{ Credentials credentials = session.getUser(); credentials.setPushMessagingKey(""); dao.save(credentials); } catch (ServerDAO.DAOException e) { logger.severe(ExceptionUtils.getStackTrace(e)); return fromDAOExpection(e); } return Response.ok().build(); }  @POST @Consumes(MediaType.APPLICATION_JSON) Response register(@Context Session session,EncryptedEntity.Reader entity); @DELETE Response unregister(@Context Session session); @GET @Path("/test/{email}/{data}") @Produces(MediaType.TEXT_HTML) Response pushToDevice(@PathParam("email")String userId, @PathParam("data")String data); }
PushEndpoint { @DELETE public Response unregister(@Context Session session){ try{ Credentials credentials = session.getUser(); credentials.setPushMessagingKey(""); dao.save(credentials); } catch (ServerDAO.DAOException e) { logger.severe(ExceptionUtils.getStackTrace(e)); return fromDAOExpection(e); } return Response.ok().build(); }  @POST @Consumes(MediaType.APPLICATION_JSON) Response register(@Context Session session,EncryptedEntity.Reader entity); @DELETE Response unregister(@Context Session session); @GET @Path("/test/{email}/{data}") @Produces(MediaType.TEXT_HTML) Response pushToDevice(@PathParam("email")String userId, @PathParam("data")String data);  }