Commit 4a7afd7e authored by Killian LUCAS's avatar Killian LUCAS
Browse files

DataStoreTest

parent 496a8022
......@@ -17,7 +17,7 @@ public class PlaceCard {
//Only for JPA
protected PlaceCard(){}
public PlaceCard( String name, String description, int number, String imageUrl, String color){
public PlaceCard( String name, String description, int number, String color,String imageUrl){
this.name = name;
this.description = description;
this.number = number;
......
......@@ -3,6 +3,10 @@ import static org.assertj.core.api.Assertions.assertThat;
import fr.univnantes.alma.data.item.User;
import fr.univnantes.alma.data.item.UserRepository;
import fr.univnantes.alma.data.item.card.PlaceCard;
import fr.univnantes.alma.data.item.card.PlaceCardRepository;
import fr.univnantes.alma.data.item.card.SurvivalCard;
import fr.univnantes.alma.data.item.card.SurvivalCardRepository;
import org.assertj.core.api.Assertions;
import org.junit.Test;
import org.junit.runner.RunWith;
......@@ -19,22 +23,53 @@ public class DataStoreTest {
@Autowired
private TestEntityManager entityManager;
@Autowired
UserRepository repository;
UserRepository userRepository;
@Autowired
PlaceCardRepository placeCardRepository;
@Autowired
SurvivalCardRepository survivalCardRepository;
@Test
public void no_User(){
Iterable<User> customers = repository.findAll();
Assertions.assertThat(customers).isEmpty();
Iterable<User> users = userRepository.findAll();
Assertions.assertThat(users).isEmpty();
}
@Test
public void should_store(){
User u = new User("ok","Jetecarryenadc","ok");
User user = repository.save(new User("JackyLove@world.net", "Jetecarryenadc","JackyLove"));
public void testUserRepository__store(){
User user = userRepository.save(new User("JackyLove@world.net", "Jetecarryenadc","JackyLove"));
Assertions.assertThat(user).hasFieldOrPropertyWithValue("mail","JackyLove@world.net");
// assertThat(user).hasFieldOrPropertyWithValue("password",u.getPasswordHash());
Assertions.assertThat(user).hasFieldOrPropertyWithValue("pseudo","JackyLove");
}
@Test
public void no_PlaceCard(){
Iterable<PlaceCard> placeCards = placeCardRepository.findAll();
Assertions.assertThat(placeCards).isEmpty();
}
@Test
public void testPlaceCardRepository_store(){
PlaceCard placeCard = placeCardRepository.save(new PlaceCard("Antre", "purple Place",1,"purple","watchThat.com"));
Assertions.assertThat(placeCard).hasFieldOrPropertyWithValue("name","Antre");
Assertions.assertThat(placeCard).hasFieldOrPropertyWithValue("description","purple Place");
Assertions.assertThat(placeCard).hasFieldOrPropertyWithValue("number",1);
Assertions.assertThat(placeCard).hasFieldOrPropertyWithValue("color","purple");
Assertions.assertThat(placeCard).hasFieldOrPropertyWithValue("imageUrl","watchThat.com");
}
@Test
public void No_SurvivalCard(){
Iterable<SurvivalCard> survivalCards = survivalCardRepository.findAll();
Assertions.assertThat(survivalCards).isEmpty();
}
@Test
public void testSurvivalCardRepository_store(){
SurvivalCard survivalCard = survivalCardRepository.save(new SurvivalCard("wrong track", "Move the Creature token to an adjacent place"));
Assertions.assertThat(survivalCard).hasFieldOrPropertyWithValue("name","wrong track");
Assertions.assertThat(survivalCard).hasFieldOrPropertyWithValue("description","Move the Creature token to an adjacent place");
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment