Package com.walters.sms

Source Code of com.walters.sms.UserDataHelper

package com.walters.sms;

import java.util.Date;

import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;

import com.walters.sms.domain.User;

public final class UserDataHelper
{

    private UserDataHelper()
    {
        throw new AssertionError("Can't instantiate " + UserDataHelper.class.getSimpleName());
    }

    public static User createUser(final String username)
    {
        return createUser(null, username, null);
    }

    public static User createUser(final String username, final String password)
    {
        return createUser(null, username, password);
    }

    public static User createUser(final Long id, final String username)
    {
        return createUser(id, username, null);
    }

    public static User createUser(final Long id, final String username, final String password)
    {
        final User user = new User();

        user.setUsername(username);
        user.setPassword(password);
        user.setFirstName("First Name");
        user.setLastName("Last Name");
        user.setActive(true);
        user.setDateCreated(new Date());
        user.setBlocked(false);
        user.setId(id);

        return user;
    }

    public static Answer<User> createUserAnswer()
    {
        return new Answer<User>()
        {

            @Override
            public User answer(final InvocationOnMock invocationOnMock) throws Throwable
            {
                return (User) invocationOnMock.getArguments()[0];
            }
        };
    }
}
TOP

Related Classes of com.walters.sms.UserDataHelper

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.