package com.drumonii.loltrollbuild.admin;

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

import static org.hamcrest.Matchers.is;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;

public class ActuatorControllerTest extends BaseSpringTestRunner {

	@Before
	public void before() {
		super.before();

		versionsRepository.save(versions.get(0));
	}

	@WithMockAdminUser
	@Test
	public void env() throws Exception {
		mockMvc.perform(get("/admin/env"))
				.andExpect(status().isOk())
				.andExpect(model().attributeExists("activeTab", "accordion", "latestSavedPatch"))
				.andExpect(model().attribute("activeTab", is("actuator")))
				.andExpect(model().attribute("accordion", is("env")))
				.andExpect(view().name("admin/actuator/env"));
	}

	@WithMockAdminUser
	@Test
	public void flyway() throws Exception {
		mockMvc.perform(get("/admin/flyway"))
				.andExpect(status().isOk())
				.andExpect(model().attributeExists("activeTab", "accordion", "latestSavedPatch"))
				.andExpect(model().attribute("activeTab", is("actuator")))
				.andExpect(model().attribute("accordion", is("flyway")))
				.andExpect(view().name("admin/actuator/flyway"));
	}

	@WithMockAdminUser
	@Test
	public void health() throws Exception {
		mockMvc.perform(get("/admin/health"))
				.andExpect(status().isOk())
				.andExpect(model().attributeExists("activeTab", "accordion", "latestSavedPatch"))
				.andExpect(model().attribute("activeTab", is("actuator")))
				.andExpect(model().attribute("accordion", is("health")))
				.andExpect(view().name("admin/actuator/health"));
	}

	@WithMockAdminUser
	@Test
	public void metrics() throws Exception {
		mockMvc.perform(get("/admin/metrics"))
				.andExpect(status().isOk())
				.andExpect(model().attributeExists("activeTab", "accordion", "latestSavedPatch"))
				.andExpect(model().attribute("activeTab", is("actuator")))
				.andExpect(model().attribute("accordion", is("metrics")))
				.andExpect(view().name("admin/actuator/metrics"));
	}

}
@@ -74,692 +74,1590 @@
 ild.
-BaseSpringTestRunner;%0Aimport com.drumonii.loltrollbuild.annotation.WithMockAdminUser;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0Aimport static org.hamcrest.Matchers.is;%0Aimport static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;%0Aimport static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model;%0Aimport static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;%0Aimport static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;%0A%0Apublic class ActuatorControllerTest extends BaseSpringTestRunner %7B%0A%0A%09@Before%0A%09public void before() %7B%0A%09%09super.before();%0A%0A%09%09versionsRepository.save(versions.get(0
+annotation.WithMockAdminUser;%0Aimport com.drumonii.loltrollbuild.config.WebSecurityConfig;%0Aimport com.drumonii.loltrollbuild.model.Version;%0Aimport com.drumonii.loltrollbuild.repository.VersionsRepository;%0Aimport org.junit.Before;%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.boot.test.mock.mockito.MockBean;%0Aimport org.springframework.context.annotation.Import;%0Aimport org.springframework.test.context.ActiveProfiles;%0Aimport org.springframework.test.context.junit4.SpringRunner;%0Aimport org.springframework.test.web.servlet.MockMvc;%0A%0Aimport static com.drumonii.loltrollbuild.config.Profiles.TESTING;%0Aimport static org.hamcrest.Matchers.is;%0Aimport static org.mockito.BDDMockito.given;%0Aimport static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;%0Aimport static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model;%0Aimport static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;%0Aimport static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;%0A%0A@RunWith(SpringRunner.class)%0A@WebMvcTest(ActuatorController.class)%0A@Import(WebSecurityConfig.class)%0A@ActiveProfiles(%7B TESTING %7D)%0Apublic class ActuatorControllerTest %7B%0A%0A%09@Autowired%0A%09private MockMvc mockMvc;%0A%0A%09@MockBean%0A%09private VersionsRepository versionsRepository;%0A%0A%09@Before%0A%09public void before() %7B%0A%09%09given(versionsRepository.latestVersion()).willReturn(new Version(%227.17.2%22
 ));%0A

Convert ActuatorControllerTest to @WebMvcTest