public void cadastraUsuariologin(Map<String, String> form) { FakeRequest fakeRequest = new FakeRequest(); form.put("nome", "joao"); form.put("email", "[email protected]"); form.put("login", "joooao"); form.put("pass", "tchutchu"); fakeRequest.withFormUrlEncodedBody(form); result = callAction(controllers.routes.ref.Register.register(), fakeRequest); }
/** Testa se realmente não se pode registrar um usuário com e-mail já usado. */ @Test public void deveNaoPermitirCadastroDeUsuariosComMesmoEmail() { FakeRequest fakeRequest1 = new FakeRequest(); Map<String, String> form1 = new HashMap<String, String>(); form1.put("nome", "joao"); form1.put("email", "*****@*****.**"); form1.put("login", "mimimimi"); form1.put("pass", "tchutchu"); fakeRequest1.withFormUrlEncodedBody(form1); result = callAction(controllers.routes.ref.Register.register(), fakeRequest1); assertThat(status(result)).isEqualTo(Http.Status.SEE_OTHER); List<User> users = dao.findAllByClassName("User"); assertThat(users.size()).isEqualTo(11); FakeRequest fakeRequest2 = new FakeRequest(); Map<String, String> form2 = new HashMap<String, String>(); form2.put("nome", "joao"); form2.put("email", "*****@*****.**"); form2.put("login", "herbert"); form2.put("pass", "tchutchu"); fakeRequest2.withFormUrlEncodedBody(form2); result = callAction(controllers.routes.ref.Register.register(), fakeRequest2); assertThat(status(result)).isEqualTo(Http.Status.BAD_REQUEST); users = dao.findAllByClassName("User"); assertThat(users.size()).isEqualTo(11); Map<String, String> flash = new HashMap<String, String>(); flash.put("fail", "E-mail em uso"); assertThat(flash(result)).isEqualTo(flash); }