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];
}
};
}
}