Guest User

Untitled

a guest
Mar 21st, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. package friendsofmine;
  2.  
  3. import friendsofmine.domain.Article;
  4. import friendsofmine.repositories.ArticleRepositoryInt;
  5. import friendsofmine.repositories.ArticleRepositoryWithJdbc;
  6. import friendsofmine.services.ArticleService;
  7. import org.junit.Test;
  8. import org.junit.runner.RunWith;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.boot.test.context.SpringBootTest;
  11. import org.springframework.dao.InvalidDataAccessApiUsageException;
  12. import org.springframework.test.context.junit4.SpringRunner;
  13.  
  14. import static org.hamcrest.Matchers.instanceOf;
  15. import static org.junit.Assert.*;
  16.  
  17. @RunWith(SpringRunner.class)
  18. @SpringBootTest
  19. public class ArticleServiceTest {
  20.  
  21. @Autowired
  22. private ArticleService articleService;
  23.  
  24. @Test
  25. public void testTypeRepository() {
  26. assertThat(articleService.getArticleRepository(), instanceOf(ArticleRepositoryWithJdbc.class));
  27. assertThat(articleService.getArticleRepository(), instanceOf(ArticleRepositoryInt.class));
  28. }
  29.  
  30. @Test
  31. public void testFindAllCardinal() {
  32. assertEquals(9, (articleService.findAllArticles().size()));
  33. }
  34.  
  35. @Test
  36. public void testFindAllPremiereCategorie() {
  37. assertEquals("Sport", (articleService.findAllArticles().get(0).getCategorie()));
  38. }
  39.  
  40. @Test
  41. public void testFindByIdOk() {
  42. assertEquals(0, (articleService.findArticlesById(0)).getArticleId());
  43. }
  44.  
  45. @Test
  46. public void testFindByIdInconnuIsNull() {
  47. assertNull(articleService.findArticlesById(9999));
  48. }
  49. }
Add Comment
Please, Sign In to add comment