package com.aemreunal.controller;

import org.junit.Test;
import com.aemreunal.domain.user.UserCreator;
import com.aemreunal.domain.user.UserGetter;
import com.aemreunal.domain.user.UserInfo;
import com.aemreunal.domain.user.UserRemover;

import static org.junit.Assert.assertTrue;

/*
 ***************************
 * Copyright (c) 2014      *
 *                         *
 * This code belongs to:   *
 *                         *
 * @author Ahmet Emre Ünal *
 * S001974                 *
 *                         *
 * aemreunal@gmail.com     *
 * emre.unal@ozu.edu.tr    *
 *                         *
 * aemreunal.com           *
 ***************************
 */

/*
 * https://code.google.com/p/rest-assured/
 *
 * Documentation: http://code.google.com/p/rest-assured/wiki/Usage
 */

public class UserTest {
    @Test
    public void testCreateUser() {
        UserInfo userInfo = UserCreator.createRandomUser();
        System.out.println(userInfo);
    }

    @Test
    public void testGetUser() {
        UserInfo createdUserInfo = UserCreator.createRandomUser();
        // TODO add expected status code for 404 not found assertion post-delete
        UserInfo requestedUserInfo = UserGetter.getUser(createdUserInfo.username);
        assertTrue("The created and requested objects do not match!", createdUserInfo.equals(requestedUserInfo));
    }

    @Test
    public void testDeleteUser() {
        UserInfo createdUserInfo = UserCreator.createRandomUser();
        UserRemover.removeUser(createdUserInfo.username);
        UserGetter.failToGetUser(createdUserInfo.username);
        UserRemover.failToRemoveUser(createdUserInfo.username);
    }
}

@@ -1649,11 +1649,965 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void testFailToGetUserWithValidUsername() %7B%0A        UserGetter.failToGetUser(%22nonExistantUser%22);%0A    %7D%0A%0A    @Test%0A    public void testFailToGetUserWithInvalidUsername() %7B%0A        UserGetter.failToGetUser(%22Non-Existant User%22);%0A    %7D%0A%0A    @Test%0A    public void testFailToCreateUserDueToLongUsername() %7B%0A        UserCreator.failToCreateUser(%22aUsernameWithMoreThanTheMaximumNumberOfCharactersAllowedForTheField%22);%0A    %7D%0A%0A    @Test%0A    public void testFailToCreateUserDueToSpaceInUsername() %7B%0A        UserCreator.failToCreateUser(%22Hello world!%22);%0A    %7D%0A%0A    @Test%0A    public void testFailToCreateUserDueToIllegalUsername() %7B%0A        UserCreator.failToCreateUser(%22HelloWorld!%22);%0A        UserCreator.failToCreateUser(%22Hell%C3%B6%22);%0A        UserCreator.failToCreateUser(%22H%C3%A9llo%22);%0A        UserCreator.failToCreateUser(%22H%C5%9Fi%C4%9F%C3%BC%C3%A7%C3%B6%C4%B1WOrlasda%22);%0A        UserCreator.failToCreateUser(%22123Hello%22);%0A        UserCreator.failToCreateUser(%22123 Hello%22);%0A    %7D
 %0A%7D%0A

Add username tests