Skip to content
Snippets Groups Projects
Commit 65575918 authored by Paul Ripault's avatar Paul Ripault
Browse files

fin tp2

parent 593a2bed
No related branches found
No related tags found
No related merge requests found
**Partie PIZZAS **
# **Partie PIZZAS**
Dans un premier temps j'ai simplement reproduit ce qui a été avec les ingrédients avant de l'adapter à la classe Pizza
\ No newline at end of file
......@@ -54,7 +54,7 @@
<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-grizzly2</artifactId>
<version>${jersey.version}</version>
<version>${jersey.version}</version><!--$NO-MVN-MAN-VER$-->
</dependency>
<!-- https://mvnrepository.com/artifact/org.xerial/sqlite-jdbc -->
<dependency>
......@@ -78,7 +78,7 @@
<dependency>
<groupId>org.jdbi</groupId>
<artifactId>jdbi3-testing</artifactId>
<version>3.12.0</version>
<version>3.12.0</version><!--$NO-MVN-MAN-VER$-->
<scope>test</scope>
</dependency>
<dependency>
......
......@@ -18,6 +18,7 @@ import java.util.logging.Logger;
import jakarta.json.bind.JsonbBuilder;
import jakarta.ws.rs.ApplicationPath;
@SuppressWarnings("unused")
@ApplicationPath("api/v1/")
public class ApiV1 extends ResourceConfig {
private static final Logger LOGGER = Logger.getLogger(ApiV1.class.getName());
......
......@@ -15,6 +15,7 @@ import org.glassfish.jersey.server.ResourceConfig;
* Main class.
*
*/
@SuppressWarnings("unused")
public class Main {
// Base URI the Grizzly HTTP server will listen on
public static final String BASE_URI = "http://localhost:8080/api/v1/";
......
......@@ -15,7 +15,7 @@ import fr.ulille.iut.pizzaland.beans.Pizza;
public interface PizzaDao {
@SqlUpdate("CREATE TABLE IF NOT EXISTS Pizzas "+
"(id vARCHAR(128) PRIMARY KEY, name VARCHAR UNIQUE NOT NULL)")
"(id VARCHAR(128) PRIMARY KEY, name VARCHAR UNIQUE NOT NULL)")
void createPizzaTable();
@SqlUpdate("CREATE TABLE IF NOT EXISTS PizzaIngredientsAssociation "+
......@@ -36,7 +36,8 @@ public interface PizzaDao {
@SqlUpdate("DELETE FROM Pizzas WHERE id = :id")
void remove(@Bind("id") UUID id);
@SqlUpdate("SELECT * FROM Pizzas WHERE id = :id")
@SqlQuery("SELECT * FROM Pizzas WHERE id = :id")
@RegisterBeanMapper(Pizza.class)
Pizza findById(@Bind("id") UUID id);
@SqlQuery("SELECT * FROM Pizzas WHERE name = :name")
......
......@@ -59,11 +59,11 @@ public class PizzaResource {
try {
Pizza pizza = Pizza.fromPizzaCreateDto(pizzaCreateDto);
pizzas.insert(pizza);
PizzaDto ingredientDto = Pizza.toDto(pizza);
PizzaDto pizzaDto = Pizza.toDto(pizza);
URI uri = uriInfo.getAbsolutePathBuilder().path(pizza.getId().toString()).build();
return Response.created(uri).entity(ingredientDto).build();
return Response.created(uri).entity(pizzaDto).build();
} catch (Exception e) {
e.printStackTrace();
throw new WebApplicationException(Response.Status.NOT_ACCEPTABLE);
......
......@@ -31,9 +31,9 @@ import java.util.logging.Logger;
* méthodes de l'interface jakarta.ws.rs.client.Client.
* la méthode configure() permet de démarrer la ressource à tester
*/
@SuppressWarnings("unused")
public class IngredientResourceTest extends JerseyTest {
private IngredientDao dao;
@SuppressWarnings("unused")
private static final Logger LOGGER = Logger.getLogger(IngredientResourceTest.class.getName());
@Override
......
......@@ -28,9 +28,9 @@ import java.util.List;
import java.util.UUID;
import java.util.logging.Logger;
@SuppressWarnings("unused")
public class PizzaResourceTest extends JerseyTest {
private PizzaDao dao;
@SuppressWarnings("unused")
private static final Logger LOGGER = Logger.getLogger(PizzaResourceTest.class.getName());
@Override
......@@ -86,7 +86,7 @@ public class PizzaResourceTest extends JerseyTest {
@Test
public void testGetNotExistingPizza() {
Response response = target("/ingredients").path(UUID.randomUUID().toString()).request().get();
Response response = target("/pizas").path(UUID.randomUUID().toString()).request().get();
assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatus());
}
@Test
......@@ -110,8 +110,8 @@ public class PizzaResourceTest extends JerseyTest {
pizza.setName("Chorizo");
dao.insert(pizza);
PizzaCreateDto ingredientCreateDto = Pizza.toCreateDto(pizza);
Response response = target("/pizzas").request().post(Entity.json(ingredientCreateDto));
PizzaCreateDto pizzaCreateDto = Pizza.toCreateDto(pizza);
Response response = target("/pizzas").request().post(Entity.json(pizzaCreateDto));
assertEquals(Response.Status.CONFLICT.getStatusCode(), response.getStatus());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment