public ModelAndView handle(Request request, Response response) throws Exception {
    // On regarde si l'utilisateur a accès
    ModelAndView modelAndView = Authentification.checkEnseignant(request, response);
    if (modelAndView != null) return modelAndView;

    Map<String, Object> attributes = new HashMap<String, Object>();
    attributes.put("title", "Inscription au créneau");
    attributes.put("connected", (request.session().attribute("email") != null));
    attributes.put("labo", (request.session().attribute("labo") != null));
    attributes.put("enseignant", (request.session().attribute("enseignant") != null));

    Integer idEnseignant = request.session().attribute("enseignant");

    if (idEnseignant == null) response.redirect("/enseignant");

    return new ModelAndView(attributes, "inscription-creneau.ftl");
  }
Example #2
0
  @Test
  public void testSession_whenCreateIsFalse() {

    when(servletRequest.getSession(true)).thenReturn(httpSession);

    assertEquals(
        "A Session should not have been created because create parameter was set to false",
        null,
        request.session(false));
  }
Example #3
0
  @Test
  public void testSessionNoParams_whenSessionIsNull() {

    when(servletRequest.getSession()).thenReturn(httpSession);

    assertEquals(
        "A Session with an HTTPSession from the Request should have been created",
        httpSession,
        request.session().raw());
  }
Example #4
0
  @Test
  public void testSession_whenCreateIsTrue() {

    when(servletRequest.getSession(true)).thenReturn(httpSession);

    assertEquals(
        "A Session with an HTTPSession from the Request should have been created because create parameter "
            + "was set to true",
        httpSession,
        request.session(true).raw());
  }