@Ignore @Test public void testSaveEvaluationOK(){ Request<Evaluation> request = buildSaveEvaluationRequest(); Response<Evaluation> response = controller.saveEvaluation(said, request); assertNotNull(response); Evaluation ev = response.getMessage().getData().getEntries().iterator().next(); assertNotNull(ev); assertEquals(ev.getTenantId(),"hashedTenant"); assertEquals(ev.getCreated(),12345678); assertEquals(ev.getClientId(),"0.1.1"); assertEquals(ev.getAction(),"add people to group"); assertEquals(ev.getCurrPlace(),"hashedPlace"); assertEquals(ev.getCurrSituationId(),"hashedSituation"); assertEquals(ev.getType(),"evaluation"); assertEquals(ev.getGuid(),"dumbGUID"); }
@POST @Path("/@me") @Consumes(MediaType.APPLICATION_JSON + ";charset=UTF-8") @Produces(MediaType.APPLICATION_JSON + ";charset=UTF-8") public Response<Evaluation> saveEvaluation(@PathParam("said") String said, Request<Evaluation> request) { try { RequestValidator.validateRequest(request); Data<Evaluation> data = request.getMessage().getData(); Evaluation ev = (Evaluation) data.getEntries().iterator().next(); User user = userManager.getCurrentUser(); boolean saved = false; if (userManager.validateUserCanLogEvaluationData(user)){ if (evaluationManager.saveEvaluation(ev, said)){ return Response.ok(data); }else{ return Response.serverError("Could not save evaluation due to invalid data. Check server logs", null); } } return Response.serverError("Evaluation not saved, evaluation omitted for user.", null); } catch (Exception e) { return Response.serverError(e.getMessage(), e); } }
PSEvaluationController { @POST @Path("/@me") @Consumes(MediaType.APPLICATION_JSON + ";charset=UTF-8") @Produces(MediaType.APPLICATION_JSON + ";charset=UTF-8") public Response<Evaluation> saveEvaluation(@PathParam("said") String said, Request<Evaluation> request) { try { RequestValidator.validateRequest(request); Data<Evaluation> data = request.getMessage().getData(); Evaluation ev = (Evaluation) data.getEntries().iterator().next(); User user = userManager.getCurrentUser(); boolean saved = false; if (userManager.validateUserCanLogEvaluationData(user)){ if (evaluationManager.saveEvaluation(ev, said)){ return Response.ok(data); }else{ return Response.serverError("Could not save evaluation due to invalid data. Check server logs", null); } } return Response.serverError("Evaluation not saved, evaluation omitted for user.", null); } catch (Exception e) { return Response.serverError(e.getMessage(), e); } } }
PSEvaluationController { @POST @Path("/@me") @Consumes(MediaType.APPLICATION_JSON + ";charset=UTF-8") @Produces(MediaType.APPLICATION_JSON + ";charset=UTF-8") public Response<Evaluation> saveEvaluation(@PathParam("said") String said, Request<Evaluation> request) { try { RequestValidator.validateRequest(request); Data<Evaluation> data = request.getMessage().getData(); Evaluation ev = (Evaluation) data.getEntries().iterator().next(); User user = userManager.getCurrentUser(); boolean saved = false; if (userManager.validateUserCanLogEvaluationData(user)){ if (evaluationManager.saveEvaluation(ev, said)){ return Response.ok(data); }else{ return Response.serverError("Could not save evaluation due to invalid data. Check server logs", null); } } return Response.serverError("Evaluation not saved, evaluation omitted for user.", null); } catch (Exception e) { return Response.serverError(e.getMessage(), e); } }  }
PSEvaluationController { @POST @Path("/@me") @Consumes(MediaType.APPLICATION_JSON + ";charset=UTF-8") @Produces(MediaType.APPLICATION_JSON + ";charset=UTF-8") public Response<Evaluation> saveEvaluation(@PathParam("said") String said, Request<Evaluation> request) { try { RequestValidator.validateRequest(request); Data<Evaluation> data = request.getMessage().getData(); Evaluation ev = (Evaluation) data.getEntries().iterator().next(); User user = userManager.getCurrentUser(); boolean saved = false; if (userManager.validateUserCanLogEvaluationData(user)){ if (evaluationManager.saveEvaluation(ev, said)){ return Response.ok(data); }else{ return Response.serverError("Could not save evaluation due to invalid data. Check server logs", null); } } return Response.serverError("Evaluation not saved, evaluation omitted for user.", null); } catch (Exception e) { return Response.serverError(e.getMessage(), e); } }  @Autowired void setEvaluationManager(EvaluationManager em); @Autowired void setUserManager(UserManager userManager); @POST @Path("/@me") @Consumes(MediaType.APPLICATION_JSON + ";charset=UTF-8") @Produces(MediaType.APPLICATION_JSON + ";charset=UTF-8") Response<Evaluation> saveEvaluation(@PathParam("said") String said, Request<Evaluation> request); }
PSEvaluationController { @POST @Path("/@me") @Consumes(MediaType.APPLICATION_JSON + ";charset=UTF-8") @Produces(MediaType.APPLICATION_JSON + ";charset=UTF-8") public Response<Evaluation> saveEvaluation(@PathParam("said") String said, Request<Evaluation> request) { try { RequestValidator.validateRequest(request); Data<Evaluation> data = request.getMessage().getData(); Evaluation ev = (Evaluation) data.getEntries().iterator().next(); User user = userManager.getCurrentUser(); boolean saved = false; if (userManager.validateUserCanLogEvaluationData(user)){ if (evaluationManager.saveEvaluation(ev, said)){ return Response.ok(data); }else{ return Response.serverError("Could not save evaluation due to invalid data. Check server logs", null); } } return Response.serverError("Evaluation not saved, evaluation omitted for user.", null); } catch (Exception e) { return Response.serverError(e.getMessage(), e); } }  @Autowired void setEvaluationManager(EvaluationManager em); @Autowired void setUserManager(UserManager userManager); @POST @Path("/@me") @Consumes(MediaType.APPLICATION_JSON + ";charset=UTF-8") @Produces(MediaType.APPLICATION_JSON + ";charset=UTF-8") Response<Evaluation> saveEvaluation(@PathParam("said") String said, Request<Evaluation> request);  }