Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
m4102_tp3
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Benjamin Tellier
m4102_tp3
Commits
9f47b58e
Commit
9f47b58e
authored
5 years ago
by
Yvan Peter
Browse files
Options
Downloads
Patches
Plain Diff
typo Readme
parent
c54ce452
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
README.md
+20
-18
20 additions, 18 deletions
README.md
with
20 additions
and
18 deletions
README.md
+
20
−
18
View file @
9f47b58e
...
@@ -487,7 +487,7 @@ détruire la base de données entre chaque test.
...
@@ -487,7 +487,7 @@ détruire la base de données entre chaque test.
public void testGetExistingIngredient() {
public void testGetExistingIngredient() {
Ingredient ingredient = new Ingredient();
Ingredient ingredient = new Ingredient();
ingredient.setName("
Chorizo
");
ingredient.setName("
mozzarella
");
long id = dao.insert(ingredient.getName());
long id = dao.insert(ingredient.getName());
ingredient.setId(id);
ingredient.setId(id);
...
@@ -579,7 +579,7 @@ de deux ingrédients identiques et création d'ingrédient sans nom.
...
@@ -579,7 +579,7 @@ de deux ingrédients identiques et création d'ingrédient sans nom.
@Test
@Test
public void testCreateIngredient() {
public void testCreateIngredient() {
IngredientCreateDto ingredientCreateDto = new IngredientCreateDto();
IngredientCreateDto ingredientCreateDto = new IngredientCreateDto();
ingredientCreateDto.setName("
Chorizo
");
ingredientCreateDto.setName("
mozzarella
");
Response response = target("/ingredients")
Response response = target("/ingredients")
.request()
.request()
...
@@ -602,7 +602,7 @@ de deux ingrédients identiques et création d'ingrédient sans nom.
...
@@ -602,7 +602,7 @@ de deux ingrédients identiques et création d'ingrédient sans nom.
@Test
@Test
public void testCreateSameIngredient() {
public void testCreateSameIngredient() {
IngredientCreateDto ingredientCreateDto = new IngredientCreateDto();
IngredientCreateDto ingredientCreateDto = new IngredientCreateDto();
ingredientCreateDto.setName("
Chorizo
");
ingredientCreateDto.setName("
mozzarella
");
dao.insert(ingredientCreateDto.getName());
dao.insert(ingredientCreateDto.getName());
Response response = target("/ingredients")
Response response = target("/ingredients")
...
@@ -692,7 +692,7 @@ Nous pouvons maintenant implémenter notre méthode POST dans la
...
@@ -692,7 +692,7 @@ Nous pouvons maintenant implémenter notre méthode POST dans la
}
}
Comme nous vérifions qu'il n'y a pas déjà un ingrédient avec le nom
Comme nous vérifions qu'il n'y a pas déjà un ingrédient avec le nom
fourni, nous devont ajouter une méthode
`findbyName`
à notre DA
P
fourni, nous devont ajouter une méthode
`findbyName`
à notre DA
O
@SqlQuery("SELECT * FROM ingredients WHERE name = :name")
@SqlQuery("SELECT * FROM ingredients WHERE name = :name")
@RegisterBeanMapper(Ingredient.class)
@RegisterBeanMapper(Ingredient.class)
...
@@ -735,7 +735,7 @@ Les tests liés à la méthode DELETE sont les suivants :
...
@@ -735,7 +735,7 @@ Les tests liés à la méthode DELETE sont les suivants :
@Test
@Test
public void testDeleteExistingIngredient() {
public void testDeleteExistingIngredient() {
Ingredient ingredient = new Ingredient();
Ingredient ingredient = new Ingredient();
ingredient.setName("
Chorizo
");
ingredient.setName("
mozzarella
");
long id = dao.insert(ingredient.getName());
long id = dao.insert(ingredient.getName());
ingredient.setId(id);
ingredient.setId(id);
...
@@ -786,14 +786,14 @@ Commençons par les tests correspondant à cette URI (GET
...
@@ -786,14 +786,14 @@ Commençons par les tests correspondant à cette URI (GET
@Test
@Test
public void testGetIngredientName() {
public void testGetIngredientName() {
Ingredient ingredient = new Ingredient();
Ingredient ingredient = new Ingredient();
ingredient.setName("
Chorizo
");
ingredient.setName("
mozzarella
");
long id = dao.insert(ingredient.getName());
long id = dao.insert(ingredient.getName());
Response response = target("ingredients/" + id + "/name").request().get();
Response response = target("ingredients/" + id + "/name").request().get();
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
assertEquals("
Chorizo
", response.readEntity(String.class));
assertEquals("
mozzarella
", response.readEntity(String.class));
}
}
@Test
@Test
...
@@ -840,15 +840,17 @@ base au démarrage avec le code suivant :
...
@@ -840,15 +840,17 @@ base au démarrage avec le code suivant :
@ApplicationPath("api/v1/")
@ApplicationPath("api/v1/")
public class ApiV1 extends ResourceConfig {
public class ApiV1 extends ResourceConfig {
packages("fr.ulille.iut.pizzaland");
String environment = System.getenv("PIZZAENV");
public ApiV1() {
packages("fr.ulille.iut.pizzaland");
String environment = System.getenv("PIZZAENV");
if ( environment != null && environment.equals("withdb") ) {
if ( environment != null && environment.equals("withdb") ) {
LOGGER.info("Loading with database");
LOGGER.info("Loading with database");
Jsonb jsonb = JsonbBuilder.create();
Jsonb jsonb = JsonbBuilder.create();
try {
try {
FileReader reader = new FileReader( getClass().getClassLoader().getResource("ingredients.json").getFile() );
FileReader reader = new FileReader( getClass().getClassLoader().getResource("ingredients.json").getFile() );
List<Ingredient> ingredients = JsonbBuilder.create().fromJson(reader, new ArrayList<Ingredient>(){}.getClass().getGenericSuperclass());
List<Ingredient> ingredients = JsonbBuilder.create().fromJson(reader, new ArrayList<Ingredient>(){}.getClass().getGenericSuperclass());
IngredientDao ingredientDao = BDDFactory.buildDao(IngredientDao.class);
IngredientDao ingredientDao = BDDFactory.buildDao(IngredientDao.class);
...
@@ -857,12 +859,12 @@ base au démarrage avec le code suivant :
...
@@ -857,12 +859,12 @@ base au démarrage avec le code suivant :
for ( Ingredient ingredient: ingredients) {
for ( Ingredient ingredient: ingredients) {
ingredientDao.insert(ingredient.getName());
ingredientDao.insert(ingredient.getName());
}
}
} catch ( Exception ex ) {
} catch ( Exception ex ) {
throw new IllegalStateException(ex);
throw new IllegalStateException(ex);
}
}
}
}
}
}
}
Dans un terminal, nous pouvons maintenant fixer la variable
Dans un terminal, nous pouvons maintenant fixer la variable
d'environnemnet et démarrer notre serveur REST au moyen de la
d'environnemnet et démarrer notre serveur REST au moyen de la
commande
`mvn jetty:run`
:
commande
`mvn jetty:run`
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment