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
be8fb1da
Commit
be8fb1da
authored
5 years ago
by
Yvan Peter
Browse files
Options
Downloads
Patches
Plain Diff
evolution readme
parent
52f3ecb6
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
README.md
+49
-2
49 additions, 2 deletions
README.md
with
49 additions
and
2 deletions
README.md
+
49
−
2
View file @
be8fb1da
...
...
@@ -24,9 +24,9 @@ proxy, vous devrez mettre la configuration suivante dans le fichier
</proxies>
</settings>
En local, vous pouvez également recopier le fichier
~
/home/public/peter/maven/settings.xml
~
.
En local, vous pouvez également recopier le fichier
`
/home/public/peter/maven/settings.xml
`
.
**
Récupération du projet initial
##
Récupération du projet initial
.
├── pom.xml
...
...
@@ -57,3 +57,50 @@ En local, vous pouvez également recopier le fichier ~/home/public/peter/maven/s
│ └── IngredientResourceTest.java
└── resources
└── logback-test.xml
## Développement d'une ressource `Ingredient`
Nous pouvons tout d'abord réfléchir à l'API REST que nous allons offrir pour la ressource ~Ingredient~. Celle-ci devrait répondre aux URI suivantes :
| Opération | URI | Action réalisée | Retour |
|-----------|-------------|-----------------------------------------------|-----------------------------------------------|
| GET | /ingredients | récupère l'ensemble des ingrédients | 200 et un tableau d'ingrédients |
|-----------|-------------|-----------------------------------------------|-----------------------------------------------|
| GET | /ingredients/{id} | récupère l'ingrédient d'identifiant id | 200 et l'ingrédient |
| | | | 404 si id est inconnu |
|-----------|-------------|-----------------------------------------------|-----------------------------------------------|
| GET | /ingredients/{id}/name | récupère le nom de l'ingrédient | 200 et le nom de l'ingrédient |
| | | d'identifiant id | 404 si id est inconnu |
|-----------|-------------|-----------------------------------------------|-----------------------------------------------|
| POST | /ingredients | création d'un ingrédient | 201 et l'URI de la ressource créée + représentation |
| | | | 400 si les informations ne sont pas correctes |
| | | | 409 si l'ingrédient existe déjà (même nom) |
|-----------|-------------|-----------------------------------------------|-----------------------------------------------|
| DELETE | /ingredients/{id} | destruction de l'ingrédient d'identifiant id | 204 si l'opération à réussi |
| | | | 404 si id est inconnu |
|-----------|-------------|-----------------------------------------------|-----------------------------------------------|
## Mise en œuvre
### Une première implémentation : récupérer les ingrédients existants
Nous allons réaliser un développement dirigé par les tests. Dans un
premier temps, nous allons commencer par un test qui récupère une
liste d'ingrédients vide qui sera matérialisée par un tableau JSON
vide
`[]`
.
Le code suivant qui se trouve dans la classe
`IngredientResourceTest`
montre la mise en place de l'environnement (
`configure()`
) et l'amorce
d'un premier test.
public class IngredientResourceTest extends JerseyTest {
@Override
protected Application configure() {
return new ApiV1();
}
@Test
public void testGetEmptyList() {
Response response = target("/ingredients").request().get();
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
}
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