// Path: spanners-mvc/src/main/java/org/dontpanic/spanners/springmvc/forms/SignupForm.java
// public class SignupForm {
// 
// 	private static final String NOT_BLANK_MESSAGE = "{notBlank.message}";
// 
// 	@NotBlank(message = NOT_BLANK_MESSAGE)
// 	private String name;
// 	@NotBlank(message = NOT_BLANK_MESSAGE)
// 	private String password;
// 
// 	public String getName() {
// 		return name;
// 	}
// 
// 	public void setName(String name) {
// 		this.name = name;
// 	}
// 
// 	public String getPassword() {
// 		return password;
// 	}
// 
// 	public void setPassword(String password) {
// 		this.password = password;
// 	}
// }
// 
// Path: spanners-mvc/src/test/java/org/dontpanic/spanners/springmvc/rules/SystemOutResource.java
// public class SystemOutResource extends ExternalResource {
// 
//     private PrintStream sysOut;
//     private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
// 
//     @Override
//     protected void before() throws Throwable {
//         sysOut = System.out;
//         System.setOut(new PrintStream(outContent));
//     }
// 
//     @Override
//     protected void after() {
//         System.setOut(sysOut);
//     }
// 
//     public String asString() {
//         return outContent.toString();
//     }
// }


import org.dontpanic.spanners.springmvc.forms.SignupForm;
import org.dontpanic.spanners.springmvc.rules.SystemOutResource;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.provisioning.UserDetailsManager;
import org.springframework.validation.DirectFieldBindingResult;
import org.springframework.validation.Errors;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasProperty;
import static org.junit.Assert.assertEquals;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.*;
package org.dontpanic.spanners.springmvc.controllers;



/**
 * Unit tests for the signup controller
 * Created by stevie on 11/08/16.
 */
@RunWith(MockitoJUnitRunner.class)
public class SignupControllerTest {

    private static final String NAME = "smith";
    private static final String PASSWORD = "password";
    private static final String HASHED_PASSWORD = "XXXhashedpasswordXXX";

    @Mock private UserDetailsManager userDetailsManager;
    @Mock private PasswordEncoder passwordEncoder;
    @InjectMocks private SignupController controller = new SignupController();

    @Rule public SystemOutResource sysOut = new SystemOutResource();

    @Test
    public void testSuccessForward() {

// Path: spanners-mvc/src/main/java/org/dontpanic/spanners/springmvc/forms/SignupForm.java
// public class SignupForm {
// 
// 	private static final String NOT_BLANK_MESSAGE = "{notBlank.message}";
// 
// 	@NotBlank(message = NOT_BLANK_MESSAGE)
// 	private String name;
// 	@NotBlank(message = NOT_BLANK_MESSAGE)
// 	private String password;
// 
// 	public String getName() {
// 		return name;
// 	}
// 
// 	public void setName(String name) {
// 		this.name = name;
// 	}
// 
// 	public String getPassword() {
// 		return password;
// 	}
// 
// 	public void setPassword(String password) {
// 		this.password = password;
// 	}
// }
// 
// Path: spanners-mvc/src/test/java/org/dontpanic/spanners/springmvc/rules/SystemOutResource.java
// public class SystemOutResource extends ExternalResource {
// 
//     private PrintStream sysOut;
//     private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
// 
//     @Override
//     protected void before() throws Throwable {
//         sysOut = System.out;
//         System.setOut(new PrintStream(outContent));
//     }
// 
//     @Override
//     protected void after() {
//         System.setOut(sysOut);
//     }
// 
//     public String asString() {
//         return outContent.toString();
//     }
// }


// Path: spanners-mvc/src/test/java/org/dontpanic/spanners/springmvc/controllers/SignupControllerTest.java
import org.dontpanic.spanners.springmvc.forms.SignupForm;
import org.dontpanic.spanners.springmvc.rules.SystemOutResource;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.provisioning.UserDetailsManager;
import org.springframework.validation.DirectFieldBindingResult;
import org.springframework.validation.Errors;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasProperty;
import static org.junit.Assert.assertEquals;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.*;

package org.dontpanic.spanners.springmvc.controllers;



/**
 * Unit tests for the signup controller
 * Created by stevie on 11/08/16.
 */
@RunWith(MockitoJUnitRunner.class)
public class SignupControllerTest {

    private static final String NAME = "smith";
    private static final String PASSWORD = "password";
    private static final String HASHED_PASSWORD = "XXXhashedpasswordXXX";

    @Mock private UserDetailsManager userDetailsManager;
    @Mock private PasswordEncoder passwordEncoder;
    @InjectMocks private SignupController controller = new SignupController();

    @Rule public SystemOutResource sysOut = new SystemOutResource();

    @Test
    public void testSuccessForward() {

        SignupForm form = populateForm(NAME, PASSWORD);