diff --git a/pom.xml b/pom.xml index e5beb63314b033179a9939fd33ffc1a6949b24d9..73cd47cf7fd1375e4d0f66510428a26c65090a94 100644 --- a/pom.xml +++ b/pom.xml @@ -24,10 +24,11 @@ <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> + <!-- remove to avoid 401 for the moment <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> - </dependency> + </dependency> --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> @@ -59,11 +60,13 @@ <artifactId>spring-restdocs-mockmvc</artifactId> <scope>test</scope> </dependency> + <!-- removed to avoid 401 <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-test</artifactId> <scope>test</scope> </dependency> + --> </dependencies> <build> diff --git a/src/main/java/fr/ulille/iut/pizzaland/controller/IngredientController.java b/src/main/java/fr/ulille/iut/pizzaland/controller/IngredientController.java new file mode 100644 index 0000000000000000000000000000000000000000..3d004d45e0fd7398218a464d0c8b820b3057c302 --- /dev/null +++ b/src/main/java/fr/ulille/iut/pizzaland/controller/IngredientController.java @@ -0,0 +1,19 @@ +package fr.ulille.iut.pizzaland.controller; + +import java.util.ArrayList; +import java.util.List; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import fr.ulille.iut.pizzaland.representation.Ingredient; + +@RestController +public class IngredientController { + + @GetMapping("/ingredients") + public List<Ingredient> getIngredients() { + return new ArrayList<Ingredient>(); + } + +} \ No newline at end of file diff --git a/src/main/java/fr/ulille/iut/pizzaland/representation/Ingredient.java b/src/main/java/fr/ulille/iut/pizzaland/representation/Ingredient.java new file mode 100644 index 0000000000000000000000000000000000000000..2ba4fa2da083fb265e4f70acf2812ad2bb91b641 --- /dev/null +++ b/src/main/java/fr/ulille/iut/pizzaland/representation/Ingredient.java @@ -0,0 +1,31 @@ +package fr.ulille.iut.pizzaland.representation; + +public class Ingredient { + private long id; + private String name; + + public Ingredient() { + } + + public Ingredient(long id, String name) { + this.id = id; + this.name = name; + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + +} \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 8b137891791fe96927ad78e64b0aad7bded08bdc..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1 +0,0 @@ - diff --git a/src/test/java/fr/ulille/iut/pizzaland/IngredientTests.java b/src/test/java/fr/ulille/iut/pizzaland/IngredientTests.java new file mode 100644 index 0000000000000000000000000000000000000000..1a6fe86553821c4999ea4282af5126363e60a992 --- /dev/null +++ b/src/test/java/fr/ulille/iut/pizzaland/IngredientTests.java @@ -0,0 +1,21 @@ +package fr.ulille.iut.pizzaland; + +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.test.web.servlet.MockMvc; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import fr.ulille.iut.pizzaland.controller.IngredientController; + +@WebMvcTest(IngredientController.class) +public class IngredientTests { + @Autowired + private MockMvc mvc; + + @Test + public void atStartup_shouldGetemptyList() throws Exception { + mvc.perform(get("/ingredients")).andExpect(status().isOk()).andExpect(content().json("[]")); + } +} \ No newline at end of file