@@ -0,0 +1,2112 @@
+package ru.pmsoft.twitterkiller.domain.factory;%0A%0Aimport org.testng.annotations.Test;%0Aimport ru.pmsoft.twitterkiller.domain.entity.User;%0Aimport ru.pmsoft.twitterkiller.domain.util.PasswordEncrypter;%0Aimport ru.pmsoft.twitterkiller.domain.util.StringGenerator;%0A%0Aimport java.security.GeneralSecurityException;%0A%0Aimport static org.mockito.Matchers.any;%0Aimport static org.mockito.Matchers.anyString;%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.when;%0Aimport static org.testng.Assert.*;%0A%0Apublic class UserFactoryTest %7B%0A    private static UserFactory createSystemUnderTest(StringGenerator saltGenerator, PasswordEncrypter passwordEncrypter)%0A    %7B%0A%0A        return new UserFactory(saltGenerator == null ? mock(StringGenerator.class) : saltGenerator,%0A                passwordEncrypter == null ? mock(PasswordEncrypter.class) : passwordEncrypter);%0A%0A%0A    %7D%0A    @Test%0A    public void create_ShouldWorkWell() throws GeneralSecurityException%0A    %7B%0A        StringGenerator saltGenerator = mock(StringGenerator.class);%0A        when(saltGenerator.generate()).thenReturn(%22foo%22);%0A        PasswordEncrypter passwordEncrypter = mock(PasswordEncrypter.class);%0A        when(passwordEncrypter.encrypt(any(String.class))).thenReturn(%22bar%22);%0A        UserFactory sut = createSystemUnderTest(saltGenerator, passwordEncrypter) ;%0A        User user = sut.create(%22foo%22, %22bar%22);%0A        assertEquals(user.getSalt(),%22foo%22 );%0A        assertEquals(user.getPasswordHash(), %22bar%22);%0A    %7D%0A    @Test%0A    public void checkPassword_WorkWell() throws GeneralSecurityException%0A    %7B%0A        String s = %22foo%22;%0A        StringGenerator saltGenerator = mock(StringGenerator.class);%0A        when(saltGenerator.generate()).thenReturn(%22foo%22);%0A        PasswordEncrypter passwordEncrypter = mock(PasswordEncrypter.class);%0A        when(passwordEncrypter.encrypt(anyString())).thenReturn(s+%22bar%22);%0A        UserFactory sut = createSystemUnderTest(saltGenerator, passwordEncrypter) ;%0A        User user = sut.create(%22foo%22, s);%0A        user.setPasswordHash(passwordEncrypter.encrypt(s));%0A        assertTrue(sut.checkPassword(user, s));%0A%0A    %7D%0A%0A%7D

add UserFactoryTest