package com.drumonii.loltrollbuild.admin;

import com.drumonii.loltrollbuild.BaseSpringTestRunner;
import com.drumonii.loltrollbuild.annotation.WithMockAdminUser;
import org.junit.Test;

import static com.drumonii.loltrollbuild.config.WebSecurityConfig.ADMIN_ROLE;
import static com.drumonii.loltrollbuild.config.WebSecurityConfig.WebDevTestingSecurityConfig.IN_MEM_PASSWORD;
import static com.drumonii.loltrollbuild.config.WebSecurityConfig.WebDevTestingSecurityConfig.IN_MEM_USERNAME;
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestBuilders.formLogin;
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestBuilders.logout;
import static org.springframework.security.test.web.servlet.response.SecurityMockMvcResultMatchers.authenticated;
import static org.springframework.security.test.web.servlet.response.SecurityMockMvcResultMatchers.unauthenticated;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.redirectedUrl;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;

public class AdminLoginControllerTest extends BaseSpringTestRunner {

	@Test
	public void adminCanLoginAndLogout() throws Exception {
		mockMvc.perform(formLogin("/admin/login").user(IN_MEM_USERNAME).password(IN_MEM_PASSWORD))
				.andExpect(authenticated().withRoles(ADMIN_ROLE))
				.andExpect(redirectedUrl("/admin"));
		mockMvc.perform(logout("/admin/logout"))
				.andExpect(unauthenticated())
				.andExpect(redirectedUrl("/admin/login?logout"));
	}

	@Test
	public void getLoginAsNotLoggedIn() throws Exception {
		mockMvc.perform(get("/admin/login"))
				.andExpect(status().isOk())
				.andExpect(view().name("admin/login"));
	}

	@WithMockAdminUser
	@Test
	public void getLoginAsLoggedIn() throws Exception {
		mockMvc.perform(get("/admin/login"))
				.andExpect(status().is3xxRedirection())
				.andExpect(redirectedUrl("/admin"));
	}

}
@@ -70,34 +70,42 @@
 llbuild.
-BaseSpringTestRunn
+annotation.WithMockAdminUs
 er;%0Aimpo
@@ -138,61 +138,727 @@
 ild.
-annotation.WithMockAdminUser;%0Aimport org.junit.Test;%0A
+config.WebSecurityConfig;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;%0Aimport org.springframework.context.annotation.ComponentScan.Filter;%0Aimport org.springframework.context.annotation.Import;%0Aimport org.springframework.security.test.context.support.WithAnonymousUser;%0Aimport org.springframework.test.context.ActiveProfiles;%0Aimport org.springframework.test.context.junit4.SpringRunner;%0Aimport org.springframework.test.web.servlet.MockMvc;%0Aimport org.springframework.web.bind.annotation.ControllerAdvice;%0A%0Aimport static com.drumonii.loltrollbuild.config.Profiles.TESTING;
 %0Aimp
@@ -1962,77 +1962,296 @@
 w;%0A%0A
-public class AdminLoginControllerTest extends BaseSpringTestRunner %7B%0A
+@RunWith(SpringRunner.class)%0A@WebMvcTest(value = AdminLoginController.class, excludeFilters = @Filter(ControllerAdvice.class))%0A@Import(WebSecurityConfig.class)%0A@ActiveProfiles(%7B TESTING %7D)%0Apublic class AdminLoginControllerTest %7B%0A%0A%09@Autowired%0A%09private MockMvc mockMvc;%0A%0A%09@WithAnonymousUser
 %0A%09@T
@@ -2284,17 +2284,8 @@
 ogin
-AndLogout
 () t
@@ -2490,16 +2490,96 @@
 min%22));%0A
+%09%7D%0A%0A%09@WithMockAdminUser%0A%09@Test%0A%09public void adminCanLogout() throws Exception %7B%0A
 %09%09mockMv
@@ -2705,16 +2705,36 @@
 ));%0A%09%7D%0A%0A
+%09@WithAnonymousUser%0A
 %09@Test%0A%09

Convert AdminLoginControllerTest to @WebMvcTest