示例#1
0
  @Test
  public void registerSuccess() throws UserExistsException, NullJsonContentException {
    Gson gson = new Gson();

    UserDTO userDTO = new UserDTO();
    userDTO.setName("Folea");
    userDTO.setUsername("Folea");
    userDTO.setPassword("1234");

    controller.register(isA(String.class));
    replay(controller);

    register.setController(controller);

    assertEquals(
        gson.toJson("The user has been registered"),
        register.register(gson.toJson(userDTO, UserDTO.class)));
  }
示例#2
0
  @Test
  public void registerFail1() throws UserExistsException, NullJsonContentException {
    Gson gson = new Gson();

    UserDTO userDTO = new UserDTO();
    userDTO.setName("Folea");
    userDTO.setUsername("Folea");
    userDTO.setPassword("1234");

    controller.register(isA(String.class));
    expectLastCall().andThrow(new UserExistsException());
    replay(controller);

    register.setController(controller);

    assertEquals(
        gson.toJson("Register fails"), register.register(gson.toJson(userDTO, UserDTO.class)));
  }
示例#3
0
  @Test
  public void registerFail4() throws UserExistsException, NullJsonContentException {
    Gson gson = new Gson();

    UserDTO userDTO = new UserDTO();
    userDTO.setName("Folea");
    userDTO.setUsername("Folea");
    userDTO.setPassword("1234");

    controller.register("");
    expectLastCall().andThrow(new NullJsonContentException());
    replay(controller);

    register.setController(controller);

    assertEquals(
        gson.toJson("The json doesn't contains the expected information"), register.register(""));
  }