Skip to content
Snippets Groups Projects
Commit ae75ada5 authored by Emmanuel Bruno's avatar Emmanuel Bruno
Browse files

completes unit tests.

parent cd12b7d5
Branches
No related tags found
No related merge requests found
......@@ -144,6 +144,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version>
<configuration>
<!--suppress UnresolvedMavenProperty -->
<argLine>${surefire.jacoco.args}</argLine>
</configuration>
</plugin>
......@@ -153,6 +154,7 @@
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M4</version>
<configuration>
<!--suppress MavenModelInspection -->
<argLine>${failsafe.jacoco.args}</argLine>
</configuration>
<executions>
......
......@@ -16,7 +16,6 @@ import java.io.Serializable;
@Log
@Getter
@Setter
@FieldDefaults(level = AccessLevel.PRIVATE)
@NoArgsConstructor(staticName = "of")
public class BiblioModel {
......
......@@ -14,7 +14,6 @@ import org.glassfish.jersey.message.internal.MediaTypes;
import org.junit.*;
import java.util.Collection;
import java.util.Iterator;
import static org.junit.Assert.*;
......@@ -104,7 +103,6 @@ public class ServerIT {
*/
@Test
public void testGetAuteurs() {
@SuppressWarnings("unchecked")
Collection<Auteur> responseAuteurs = webTarget.path("biblio/auteurs").request(MediaType.APPLICATION_JSON).get(new GenericType<Collection<Auteur>>() {
});
assertEquals(2, responseAuteurs.size());
......@@ -116,7 +114,6 @@ public class ServerIT {
@Test
public void deleteAuteurs() {
webTarget.path("biblio/auteurs").request().delete();
@SuppressWarnings("unchecked")
Collection<Auteur> responseAuteurs = webTarget.path("biblio/auteurs").request(MediaType.APPLICATION_JSON).get(new GenericType<Collection<Auteur>>() {
});
assertEquals(0, responseAuteurs.size());
......@@ -128,7 +125,6 @@ public class ServerIT {
@Test
public void deleteAuteur() {
webTarget.path("biblio/auteurs/1").request().delete();
@SuppressWarnings("unchecked")
Collection<Auteur> responseAuteurs = webTarget.path("biblio/auteurs").request(MediaType.APPLICATION_JSON).get(new GenericType<Collection<Auteur>>() {
});
assertEquals(1, responseAuteurs.size());
......@@ -145,7 +141,6 @@ public class ServerIT {
.request(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON)
.post(Entity.entity("{\"nom\":\"Smith\",\"prenom\":\"John\",\"biographie\":\"My life\"}", MediaType.APPLICATION_JSON));
@SuppressWarnings("unchecked")
Collection<Auteur> responseAuteurs = webTarget.path("biblio/auteurs").request(MediaType.APPLICATION_JSON).get(new GenericType<Collection<Auteur>>() {
});
assertEquals(3, responseAuteurs.size());
......
......@@ -9,17 +9,21 @@ import org.junit.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.samePropertyValuesAs;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
public class BiblioModelTest {
private static final BiblioModel modeleBibliotheque = BiblioModel.of();
private static final BiblioModel.Auteur auteur1 = BiblioModel.Auteur.builder().prenom("Jean").nom("Martin").build();
private static final BiblioModel.Auteur auteur2 = BiblioModel.Auteur.builder().prenom("Marie").nom("Durand").build();
/**
* Adds two authors before each tests.
*/
@Before
public void beforeEach() throws IllegalArgumentException {
modeleBibliotheque.addAuteur(BiblioModel.Auteur.builder().prenom("Jean").nom("Martin").build());
modeleBibliotheque.addAuteur(BiblioModel.Auteur.builder().prenom("Marie").nom("Durand").build());
modeleBibliotheque.addAuteur(SerializationUtils.clone(auteur1));
modeleBibliotheque.addAuteur(SerializationUtils.clone(auteur2));
}
@After
......@@ -42,34 +46,45 @@ public class BiblioModelTest {
}
@Test
public void updateAuteur() {
public void updateAuteur() throws IllegalArgumentException, NotFoundException {
BiblioModel.Auteur auteur = BiblioModel.Auteur.builder().prenom("John").nom("Doe").build();
modeleBibliotheque.updateAuteur(1, SerializationUtils.clone(auteur));
assertThat(auteur, samePropertyValuesAs(modeleBibliotheque.getAuteur(1), "id"));
}
@Test
public void removeAuteur() {
public void removeAuteur() throws NotFoundException {
modeleBibliotheque.removeAuteur(1);
assertEquals(1, modeleBibliotheque.getAuteurSize());
assertEquals(2, modeleBibliotheque.getAuteurs().values().iterator().next().getId());
}
@Test
public void getAuteur() {
public void getAuteur() throws NotFoundException {
BiblioModel.Auteur auteur = modeleBibliotheque.getAuteur(1);
assertThat(auteur, samePropertyValuesAs(auteur1,"id"));
}
@Test
public void getAuteurSize() {
assertEquals(2, modeleBibliotheque.getAuteurSize());
}
@Test
public void supprimerAuteurs() {
modeleBibliotheque.supprimerAuteurs();
assertEquals(0,modeleBibliotheque.getAuteurSize());
assertEquals(0, modeleBibliotheque.getAuteurs().size());
}
@Test
public void of() {
BiblioModel modeleBibliotheque1 = modeleBibliotheque.of();
assertNotNull(modeleBibliotheque1);
}
@Test
public void getAuteurs() {
}
@Test
public void setAuteurs() {
assertNotNull(modeleBibliotheque.getAuteurs());
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment