diff --git a/src/main/java/ch/puzzle/eft/controller/DemoController.java b/src/main/java/ch/puzzle/eft/controller/DemoController.java deleted file mode 100644 index a22100c31..000000000 --- a/src/main/java/ch/puzzle/eft/controller/DemoController.java +++ /dev/null @@ -1,37 +0,0 @@ -package ch.puzzle.eft.controller; - -import ch.puzzle.eft.service.DemoService; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; - -@Controller -@RequestMapping("") -public class DemoController { - - private final DemoService demoService; - - public DemoController(DemoService demoService) { - this.demoService = demoService; - } - - @GetMapping("/multiplication") - public String multiply(Model model) { - int result = demoService - .multiply(2, 2); - model - .addAttribute("result", result); - return "result"; - } - - @GetMapping("/greeting") - public String greetPerson(@RequestParam String name, Model model) { - String greeting = demoService - .greetByName(name); - model - .addAttribute("greeting", greeting); - return "greeting"; - } -} \ No newline at end of file diff --git a/src/main/java/ch/puzzle/eft/service/DemoService.java b/src/main/java/ch/puzzle/eft/service/DemoService.java deleted file mode 100644 index 43b45ec54..000000000 --- a/src/main/java/ch/puzzle/eft/service/DemoService.java +++ /dev/null @@ -1,14 +0,0 @@ -package ch.puzzle.eft.service; - -import org.springframework.stereotype.Service; - -@Service -public class DemoService { - public String greetByName(String name) { - return "Hello " + name; - } - - public int multiply(int a, int b) { - return a * b; - } -} \ No newline at end of file diff --git a/src/main/resources/templates/greeting.html b/src/main/resources/templates/greeting.html deleted file mode 100644 index 3db8a68e4..000000000 --- a/src/main/resources/templates/greeting.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - Greeting - - -

- - \ No newline at end of file diff --git a/src/main/resources/templates/result.html b/src/main/resources/templates/result.html deleted file mode 100644 index 193dc42dc..000000000 --- a/src/main/resources/templates/result.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - Result - - -

- - \ No newline at end of file diff --git a/src/test/e2e/cypress/e2e/greeting.cy.js b/src/test/e2e/cypress/e2e/greeting.cy.js deleted file mode 100644 index 979ee8457..000000000 --- a/src/test/e2e/cypress/e2e/greeting.cy.js +++ /dev/null @@ -1,7 +0,0 @@ -it('should show greeting according to query param on greeting page', () => { - cy.visit("/greeting?name=Adrian"); - - cy.get('body').then((body) => { - expect(body).to.contain("Hello Adrian") - }) -}) \ No newline at end of file diff --git a/src/test/java/ch/puzzle/eft/controller/DemoControllerTest.java b/src/test/java/ch/puzzle/eft/controller/DemoControllerTest.java deleted file mode 100644 index 669a947b4..000000000 --- a/src/test/java/ch/puzzle/eft/controller/DemoControllerTest.java +++ /dev/null @@ -1,55 +0,0 @@ -package ch.puzzle.eft.controller; - - -import ch.puzzle.eft.service.DemoService; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.test.context.support.WithMockUser; -import org.springframework.test.web.servlet.MockMvc; - -import static org.mockito.Mockito.when; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; - -@WebMvcTest(DemoController.class) -@WithMockUser -class DemoControllerTest { - @Autowired - private MockMvc mockMvc; - - @MockBean - private DemoService demoService; - - @Test - void shouldReceiveGreetingBasedOnName() throws Exception { - when(demoService - .greetByName("Harald")) - .thenReturn("Hello Harald"); - this.mockMvc - .perform(get("/greeting") - .queryParam("name", "Harald")) - .andExpect(status() - .isOk()) - .andExpect(view() - .name("greeting")) - .andExpect(model() - .attribute("greeting", "Hello Harald")); - } - - @Test - void shouldReturnGeneratedRandomNumber() throws Exception { - when(demoService - .multiply(2, 2)) - .thenReturn(4); - this.mockMvc - .perform(get("/multiplication")) - .andExpect(status() - .isOk()) - .andExpect(view() - .name("result")) - .andExpect(model() - .attribute("result", 4)); - } -} \ No newline at end of file diff --git a/src/test/java/ch/puzzle/eft/service/DemoServiceTest.java b/src/test/java/ch/puzzle/eft/service/DemoServiceTest.java deleted file mode 100644 index 012fa00dd..000000000 --- a/src/test/java/ch/puzzle/eft/service/DemoServiceTest.java +++ /dev/null @@ -1,31 +0,0 @@ -package ch.puzzle.eft.service; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.beans.factory.annotation.Autowired; -import static org.junit.jupiter.api.Assertions.assertEquals; - -@SpringBootTest -public class DemoServiceTest { - - DemoService demoService; - - @Autowired - public DemoServiceTest(DemoService demoService) { - this.demoService = demoService; - } - - @Test - public void shouldGenerateGreetingWithGivenName() { - String generatedGreeting = demoService - .greetByName("Balthasar"); - assertEquals("Hello Balthasar", generatedGreeting); - } - - @Test - public void shouldReturnCalculatedNumber() { - int result = demoService - .multiply(2, 2); - assertEquals(4, result); - } -} \ No newline at end of file