formatting work
This commit is contained in:
@@ -17,13 +17,12 @@ public class MainController {
|
||||
@Autowired
|
||||
private ITutorialsService tutService;
|
||||
|
||||
@RequestMapping(value ="/", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/", method = RequestMethod.GET)
|
||||
public String welcomePage() {
|
||||
return "index";
|
||||
return "index";
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value ="/list", method = RequestMethod.GET)
|
||||
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
public String listTutorialsPage(Model model) {
|
||||
List<Tutorial> list = tutService.listTutorials();
|
||||
model.addAttribute("tutorials", list);
|
||||
@@ -37,6 +36,5 @@ public class MainController {
|
||||
public void setTutService(ITutorialsService tutService) {
|
||||
this.tutService = tutService;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -6,5 +6,5 @@ import java.util.List;
|
||||
|
||||
public interface ITutorialsService {
|
||||
|
||||
List<Tutorial> listTutorials();
|
||||
List<Tutorial> listTutorials();
|
||||
}
|
||||
|
||||
@@ -10,9 +10,6 @@ import java.util.List;
|
||||
public class TutorialsService implements ITutorialsService {
|
||||
|
||||
public List<Tutorial> listTutorials() {
|
||||
return Arrays.asList(
|
||||
new Tutorial(1, "Guava", "Introduction to Guava", "GuavaAuthor"),
|
||||
new Tutorial(2, "Android", "Introduction to Android", "AndroidAuthor")
|
||||
);
|
||||
return Arrays.asList(new Tutorial(1, "Guava", "Introduction to Guava", "GuavaAuthor"), new Tutorial(2, "Android", "Introduction to Android", "AndroidAuthor"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import org.springframework.web.servlet.view.velocity.VelocityLayoutViewResolver;
|
||||
|
||||
@Configuration
|
||||
@EnableWebMvc
|
||||
@ComponentScan(basePackages = { "com.baeldung.mvc.velocity.controller", "com.baeldung.mvc.velocity.service"})
|
||||
@ComponentScan(basePackages = { "com.baeldung.mvc.velocity.controller", "com.baeldung.mvc.velocity.service" })
|
||||
public class WebConfig extends WebMvcConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -38,7 +38,6 @@ public class DataContentControllerTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
|
||||
|
||||
mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
|
||||
}
|
||||
@@ -53,9 +52,9 @@ public class DataContentControllerTest {
|
||||
mockMvc.perform(get("/list")).andExpect(xpath("//table").exists());
|
||||
mockMvc.perform(get("/list")).andExpect(xpath("//td[@id='tutId_1']").exists());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void whenCallingIndex_thenViewOK() throws Exception{
|
||||
public void whenCallingIndex_thenViewOK() throws Exception {
|
||||
mockMvc.perform(get("/")).andExpect(status().isOk()).andExpect(view().name("index")).andExpect(model().size(0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import org.springframework.web.servlet.view.velocity.VelocityLayoutViewResolver;
|
||||
|
||||
@Configuration
|
||||
public class TestConfig {
|
||||
|
||||
|
||||
@Bean
|
||||
public ViewResolver viewResolver() {
|
||||
@@ -19,14 +18,12 @@ public class TestConfig {
|
||||
bean.setSuffix(".vm");
|
||||
return bean;
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public VelocityConfigurer velocityConfig() {
|
||||
VelocityConfigurer velocityConfigurer = new VelocityConfigurer();
|
||||
velocityConfigurer.setResourceLoaderPath("/");
|
||||
return velocityConfigurer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user