Import kontor-spring into directory springboot
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package de.thpeetz.kontor;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class ApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package de.thpeetz.kontor.bookshelf;
|
||||
|
||||
public class TestConstants {
|
||||
|
||||
public static final Integer ARTICLEAUTHOR_COUNT = 0;
|
||||
public static final Integer ARTICLE_COUNT = 0;
|
||||
public static final Integer AUTHOR_COUNT = 1;
|
||||
public static final Integer BOOKAUTHOR_COUNT = 0;
|
||||
public static final Integer BOOK_COUNT = 0;
|
||||
public static final Integer PUBLISHER_COUNT = 0;
|
||||
public static final String ARTICLE_TITLE = "Title";
|
||||
public static final String AUTHOR_FIRSTNAME = "Firstname";
|
||||
public static final String AUTHOR_LASTNAME = "Lastname";
|
||||
public static final String PUBLISHER_NIKOL = "Nikol Verlags GmbH";
|
||||
public static final String PUBLISHER_NAME = "Publisher";
|
||||
public static final String PUBLISHER_SEARCH = "kol";
|
||||
public static final String BOOK_TITLE = "Book Title";
|
||||
public static final String BOOK_ISBN = "978-3-123-467-890";
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
package de.thpeetz.kontor.bookshelf.data;
|
||||
|
||||
import de.thpeetz.kontor.bookshelf.TestConstants;
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@SpringBootTest
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
@Disabled
|
||||
class ArticleAuthorRepositoryTest {
|
||||
|
||||
@Autowired
|
||||
ArticleAuthorRepository articleAuthorRepository;
|
||||
|
||||
@Autowired
|
||||
AuthorRepository authorRepository;
|
||||
|
||||
@Autowired
|
||||
ArticleRepository articleRepository;
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void saveArticleAuthor() {
|
||||
Author author = new Author();
|
||||
author.setFirstName(TestConstants.AUTHOR_FIRSTNAME);
|
||||
author.setLastName(TestConstants.AUTHOR_LASTNAME);
|
||||
Author savedAuthor = authorRepository.save(author);
|
||||
assertEquals(TestConstants.AUTHOR_COUNT+1, authorRepository.findAll().size());
|
||||
Article article = new Article();
|
||||
article.setTitle(TestConstants.ARTICLE_TITLE);
|
||||
Article savedArticle = articleRepository.save(article);
|
||||
ArticleAuthor articleAuthor = new ArticleAuthor();
|
||||
articleAuthor.setArticle(article);
|
||||
articleAuthor.setAuthor(author);
|
||||
ArticleAuthor savedArticleAuthor = articleAuthorRepository.save(articleAuthor);
|
||||
assertEquals(TestConstants.ARTICLEAUTHOR_COUNT+1, articleAuthorRepository.findAll().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
void testFindByArticle() {
|
||||
Article article = articleRepository.findByTitle(TestConstants.ARTICLE_TITLE).get(0);
|
||||
assertEquals(1, articleAuthorRepository.findByArticle(article).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
void testFindByAuthor() {
|
||||
Author author = authorRepository.findByFirstNameAndLastName(TestConstants.AUTHOR_FIRSTNAME, TestConstants.AUTHOR_LASTNAME);
|
||||
assertEquals(1, articleAuthorRepository.findByAuthor(author).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
void deleteArticleAuthor() {
|
||||
assertEquals(1, articleAuthorRepository.findAll().size());
|
||||
ArticleAuthor articleAuthor = articleAuthorRepository.findAll().get(0);
|
||||
Author author = articleAuthor.getAuthor();
|
||||
author.getArticleAuthors().remove(articleAuthor);
|
||||
author = authorRepository.save(author);
|
||||
Article article = articleAuthor.getArticle();
|
||||
article.getAuthors().remove(articleAuthor);
|
||||
article = articleRepository.save(article);
|
||||
articleAuthorRepository.delete(articleAuthor);
|
||||
assertEquals(TestConstants.ARTICLEAUTHOR_COUNT, articleAuthorRepository.findAll().size());
|
||||
authorRepository.delete(author);
|
||||
assertEquals(TestConstants.AUTHOR_COUNT, authorRepository.findAll().size());
|
||||
articleRepository.delete(article);
|
||||
assertEquals(TestConstants.ARTICLE_COUNT, articleRepository.findAll().size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package de.thpeetz.kontor.bookshelf.data;
|
||||
|
||||
import de.thpeetz.kontor.bookshelf.TestConstants;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
import org.springframework.transaction.TransactionSystemException;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
@SpringBootTest
|
||||
@TestMethodOrder(OrderAnnotation.class)
|
||||
@Disabled
|
||||
class ArticleAuthorTest {
|
||||
|
||||
@Autowired
|
||||
ArticleRepository articleRepository;
|
||||
|
||||
@Autowired
|
||||
AuthorRepository authorRepository;
|
||||
|
||||
@Autowired
|
||||
ArticleAuthorRepository articleAuthorRepository;
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void checkInitialLoad() {
|
||||
assertEquals(TestConstants.ARTICLEAUTHOR_COUNT, articleAuthorRepository.findAll().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
void exceptionThrownWhenSavingEmptyValues() {
|
||||
ArticleAuthor articleAuthor = new ArticleAuthor();
|
||||
assertThrows(TransactionSystemException.class, () -> {
|
||||
articleAuthorRepository.save(articleAuthor);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
void exceptionThrownWhenSavingIdenticalEntry() {
|
||||
Author author = new Author();
|
||||
author.setFirstName(TestConstants.AUTHOR_FIRSTNAME);
|
||||
author.setLastName(TestConstants.AUTHOR_LASTNAME);
|
||||
Author savedAuthor = authorRepository.save(author);
|
||||
Article article = new Article();
|
||||
article.setTitle(TestConstants.ARTICLE_TITLE);
|
||||
Article savedArticle = articleRepository.save(article);
|
||||
ArticleAuthor articleAuthor = new ArticleAuthor();
|
||||
articleAuthor.setArticle(article);
|
||||
articleAuthor.setAuthor(author);
|
||||
ArticleAuthor savedArticleAuthor = articleAuthorRepository.save(articleAuthor);
|
||||
ArticleAuthor articleAuthor1 = new ArticleAuthor();
|
||||
articleAuthor1.setArticle(article);
|
||||
articleAuthor1.setAuthor(author);
|
||||
assertThrows(DataIntegrityViolationException.class, () -> {
|
||||
articleAuthorRepository.save(articleAuthor1);
|
||||
});
|
||||
articleAuthorRepository.delete(savedArticleAuthor);
|
||||
assertEquals(TestConstants.ARTICLEAUTHOR_COUNT, articleAuthorRepository.findAll().size());
|
||||
savedAuthor.getArticleAuthors().remove(savedArticleAuthor);
|
||||
authorRepository.save(savedAuthor);
|
||||
authorRepository.delete(savedAuthor);
|
||||
assertEquals(TestConstants.AUTHOR_COUNT, authorRepository.findAll().size());
|
||||
savedArticle.getAuthors().remove(savedArticleAuthor);
|
||||
articleRepository.save(savedArticle);
|
||||
articleRepository.delete(savedArticle);
|
||||
assertEquals(TestConstants.ARTICLE_COUNT, articleRepository.findAll().size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package de.thpeetz.kontor.bookshelf.data;
|
||||
|
||||
import de.thpeetz.kontor.bookshelf.TestConstants;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@SpringBootTest
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
class ArticleRepositoryTest {
|
||||
|
||||
@Autowired
|
||||
ArticleRepository articleRepository;
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void checkInitialLoad() {
|
||||
assertEquals(TestConstants.ARTICLE_COUNT, articleRepository.findAll().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
void saveArticle() {
|
||||
Article article = new Article();
|
||||
article.setTitle(TestConstants.ARTICLE_TITLE);
|
||||
articleRepository.save(article);
|
||||
assertEquals(TestConstants.ARTICLE_COUNT+1, articleRepository.findAll().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
void search() {
|
||||
List<Article> articles = articleRepository.search(TestConstants.ARTICLE_TITLE.substring(2,5));
|
||||
assertEquals(1, articles.size());
|
||||
assertEquals(0, articleRepository.search(TestConstants.BOOK_TITLE).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
void findByTitle() {
|
||||
List<Article> articles = articleRepository.search(TestConstants.ARTICLE_TITLE);
|
||||
assertEquals(1, articles.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(5)
|
||||
void deleteArticle() {
|
||||
List<Article> articles = articleRepository.findAll();
|
||||
assertEquals(1, articles.size());
|
||||
assertEquals(0, articles.get(0).getAuthors().size());
|
||||
articleRepository.delete(articles.get(0));
|
||||
assertEquals(TestConstants.ARTICLE_COUNT, articleRepository.findAll().size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package de.thpeetz.kontor.bookshelf.data;
|
||||
|
||||
import de.thpeetz.kontor.bookshelf.TestConstants;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
import org.springframework.transaction.TransactionSystemException;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
@SpringBootTest
|
||||
class ArticleTest {
|
||||
|
||||
@Autowired
|
||||
ArticleRepository articleRepository;
|
||||
|
||||
@Test
|
||||
void checkInitialLoad() {
|
||||
assertEquals(TestConstants.BOOK_COUNT, articleRepository.findAll().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void exceptionThrownWhenSavingEmptyFields() {
|
||||
Article article = new Article();
|
||||
assertThrows(TransactionSystemException.class, () -> {
|
||||
articleRepository.save(article);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void exceptionThrownWhenSavingIdenticalTitle() {
|
||||
Article article = new Article();
|
||||
article.setTitle(TestConstants.ARTICLE_TITLE);
|
||||
Article savedArticle = articleRepository.save(article);
|
||||
Article article1 = new Article();
|
||||
article1.setTitle(article.getTitle());
|
||||
assertThrows(DataIntegrityViolationException.class, ()-> {
|
||||
articleRepository.save(article1);
|
||||
});
|
||||
articleRepository.delete(savedArticle);
|
||||
assertEquals(TestConstants.ARTICLE_COUNT, articleRepository.findAll().size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package de.thpeetz.kontor.bookshelf.data;
|
||||
|
||||
import de.thpeetz.kontor.bookshelf.TestConstants;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
@SpringBootTest
|
||||
@TestMethodOrder(OrderAnnotation.class)
|
||||
@Disabled
|
||||
class AuthorRepositoryTest {
|
||||
|
||||
@Autowired
|
||||
AuthorRepository authorRepository;
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void checkInitialLoad() {
|
||||
assertEquals(TestConstants.AUTHOR_COUNT, authorRepository.findAll().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
void saveAutor() {
|
||||
Author author = new Author();
|
||||
author.setFirstName(TestConstants.AUTHOR_FIRSTNAME);
|
||||
author.setLastName(TestConstants.AUTHOR_LASTNAME);
|
||||
authorRepository.save(author);
|
||||
assertEquals(TestConstants.AUTHOR_COUNT+1, authorRepository.findAll().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
void findAuthor() {
|
||||
Author existingAuthor = authorRepository.findAll().get(0);
|
||||
assertNotNull(existingAuthor);
|
||||
Author found = authorRepository.findByFirstNameAndLastName(existingAuthor.getFirstName(), existingAuthor.getLastName());
|
||||
assertEquals(existingAuthor, found);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
void searchAuthor() {
|
||||
List<Author> authors = authorRepository.search("glas");
|
||||
assertEquals(1, authors.size());
|
||||
assertEquals("Douglas", authors.get(0).getFirstName());
|
||||
List<Author> authors2 = authorRepository.search("dams");
|
||||
assertEquals(1, authors2.size());
|
||||
assertEquals("Adams", authors2.get(0).getLastName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(5)
|
||||
void deleteAuthor() {
|
||||
Author existingAuthor = authorRepository.findByFirstNameAndLastName(TestConstants.AUTHOR_FIRSTNAME, TestConstants.AUTHOR_LASTNAME);
|
||||
assertNotNull(existingAuthor);
|
||||
authorRepository.delete(existingAuthor);
|
||||
assertEquals(TestConstants.AUTHOR_COUNT, authorRepository.findAll().size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package de.thpeetz.kontor.bookshelf.data;
|
||||
|
||||
import de.thpeetz.kontor.bookshelf.TestConstants;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
import org.springframework.transaction.TransactionSystemException;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@SpringBootTest
|
||||
class AuthorTest {
|
||||
|
||||
@Autowired
|
||||
private AuthorRepository authorRepository;
|
||||
|
||||
@Test
|
||||
void throwExceptionWhenPlayerSavedWithEmptyName() {
|
||||
Author author = new Author();
|
||||
assertThrows(TransactionSystemException.class, () -> {
|
||||
authorRepository.save(author);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void throwExceptionWhenPlayerSavedWithExistingName() {
|
||||
assertEquals(TestConstants.AUTHOR_COUNT, authorRepository.findAll().size());
|
||||
Author existingAuthor = new Author();
|
||||
existingAuthor.setFirstName(TestConstants.AUTHOR_FIRSTNAME);
|
||||
existingAuthor.setLastName(TestConstants.AUTHOR_LASTNAME);
|
||||
existingAuthor = authorRepository.save(existingAuthor);
|
||||
assertEquals(TestConstants.AUTHOR_COUNT+1, authorRepository.findAll().size());
|
||||
Author author = new Author();
|
||||
author.setFirstName(existingAuthor.getFirstName());
|
||||
author.setLastName(existingAuthor.getLastName());
|
||||
assertThrows(DataIntegrityViolationException.class, () -> {
|
||||
authorRepository.save(author);
|
||||
});
|
||||
assertNotNull(existingAuthor);
|
||||
authorRepository.delete(existingAuthor);
|
||||
assertEquals(TestConstants.AUTHOR_COUNT, authorRepository.findAll().size());
|
||||
}
|
||||
}
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
package de.thpeetz.kontor.bookshelf.data;
|
||||
|
||||
import de.thpeetz.kontor.bookshelf.TestConstants;
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@SpringBootTest
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
@Disabled
|
||||
class BookAuthorRepositoryTest {
|
||||
|
||||
@Autowired
|
||||
BookRepository bookRepository;
|
||||
|
||||
@Autowired
|
||||
AuthorRepository authorRepository;
|
||||
|
||||
@Autowired
|
||||
BookAuthorRepository bookAuthorRepository;
|
||||
|
||||
@Autowired
|
||||
BookshelfPublisherRepository bookshelfPublisherRepository;
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void saveBookAuthor() {
|
||||
Author author = new Author();
|
||||
author.setFirstName(TestConstants.AUTHOR_FIRSTNAME);
|
||||
author.setLastName(TestConstants.AUTHOR_LASTNAME);
|
||||
Author savedAuthor = authorRepository.save(author);
|
||||
assertEquals(TestConstants.AUTHOR_COUNT+1, authorRepository.findAll().size());
|
||||
BookshelfPublisher publisher = new BookshelfPublisher();
|
||||
publisher.setName(TestConstants.PUBLISHER_NAME);
|
||||
BookshelfPublisher savedPublisher = bookshelfPublisherRepository.save(publisher);
|
||||
assertEquals(TestConstants.PUBLISHER_COUNT+1, bookshelfPublisherRepository.findAll().size());
|
||||
Book book = new Book();
|
||||
book.setTitle(TestConstants.ARTICLE_TITLE);
|
||||
book.setIsbn(TestConstants.BOOK_ISBN);
|
||||
book.setPublisher(savedPublisher);
|
||||
Book savedBook = bookRepository.save(book);
|
||||
assertEquals(TestConstants.BOOK_COUNT+1, bookRepository.findAll().size());
|
||||
BookAuthor bookAuthor = new BookAuthor();
|
||||
bookAuthor.setBook(savedBook);
|
||||
bookAuthor.setAuthor(savedAuthor);
|
||||
BookAuthor savedBookAuthor = bookAuthorRepository.save(bookAuthor);
|
||||
assertEquals(TestConstants.BOOKAUTHOR_COUNT+1, bookAuthorRepository.findAll().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
void testFindByBook() {
|
||||
List<BookAuthor> bookAuthors = bookAuthorRepository.findAll();
|
||||
assertEquals(1, bookAuthors.size());
|
||||
Book book = bookAuthors.get(0).getBook();
|
||||
assertEquals(1, bookAuthorRepository.findByBook(book).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
void testFindByAuthor() {
|
||||
List<BookAuthor> bookAuthors = bookAuthorRepository.findAll();
|
||||
assertEquals(1, bookAuthors.size());
|
||||
Author author = bookAuthors.get(0).getAuthor();
|
||||
assertEquals(1, bookAuthorRepository.findByAuthor(author).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
void deleteBookAuthor() {
|
||||
BookAuthor bookAuthor = bookAuthorRepository.findAll().get(0);
|
||||
Author author = bookAuthor.getAuthor();
|
||||
author.getBookAuthors().remove(bookAuthor);
|
||||
author = authorRepository.save(author);
|
||||
Book book = bookAuthor.getBook();
|
||||
book.getAuthors().remove(bookAuthor);
|
||||
BookshelfPublisher publisher = book.getPublisher();
|
||||
publisher.getBooks().remove(book);
|
||||
bookshelfPublisherRepository.save(publisher);
|
||||
book = bookRepository.save(book);
|
||||
bookshelfPublisherRepository.delete(publisher);
|
||||
assertEquals(TestConstants.PUBLISHER_COUNT, bookshelfPublisherRepository.findAll().size());
|
||||
bookAuthorRepository.delete(bookAuthor);
|
||||
assertEquals(TestConstants.BOOKAUTHOR_COUNT, bookAuthorRepository.findAll().size());
|
||||
authorRepository.delete(author);
|
||||
assertEquals(TestConstants.AUTHOR_COUNT, authorRepository.findAll().size());
|
||||
bookRepository.delete(book);
|
||||
assertEquals(TestConstants.BOOK_COUNT, bookRepository.findAll().size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package de.thpeetz.kontor.bookshelf.data;
|
||||
|
||||
import de.thpeetz.kontor.bookshelf.TestConstants;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
import org.springframework.transaction.TransactionSystemException;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
@SpringBootTest
|
||||
@Disabled
|
||||
class BookAuthorTest {
|
||||
|
||||
@Autowired
|
||||
BookRepository bookRepository;
|
||||
|
||||
@Autowired
|
||||
AuthorRepository authorRepository;
|
||||
|
||||
@Autowired
|
||||
BookAuthorRepository bookAuthorRepository;
|
||||
|
||||
@Autowired
|
||||
BookshelfPublisherRepository bookshelfPublisherRepository;
|
||||
|
||||
@Test
|
||||
void checkInitialLoad() {
|
||||
assertEquals(TestConstants.BOOKAUTHOR_COUNT, bookAuthorRepository.findAll().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void exceptionThrownWhenSavingEmptyValues() {
|
||||
BookAuthor bookAuthor = new BookAuthor();
|
||||
assertThrows(TransactionSystemException.class, () -> {
|
||||
bookAuthorRepository.save(bookAuthor);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void exceptionThrownWhenSavingIdenticalEntry() {
|
||||
Author author = new Author();
|
||||
author.setFirstName(TestConstants.AUTHOR_FIRSTNAME);
|
||||
author.setLastName(TestConstants.AUTHOR_LASTNAME);
|
||||
Author savedAuthor = authorRepository.save(author);
|
||||
BookshelfPublisher publisher = new BookshelfPublisher();
|
||||
publisher.setName(TestConstants.PUBLISHER_NAME);
|
||||
BookshelfPublisher savedPublisher = bookshelfPublisherRepository.save(publisher);
|
||||
Book book = new Book();
|
||||
book.setTitle(TestConstants.BOOK_TITLE);
|
||||
book.setIsbn(TestConstants.BOOK_ISBN);
|
||||
book.setPublisher(publisher);
|
||||
Book savedBook = bookRepository.save(book);
|
||||
BookAuthor bookAuthor = new BookAuthor();
|
||||
bookAuthor.setBook(book);
|
||||
bookAuthor.setAuthor(author);
|
||||
BookAuthor savedBookAuthor = bookAuthorRepository.save(bookAuthor);
|
||||
BookAuthor bookAuthor1 = new BookAuthor();
|
||||
bookAuthor1.setBook(book);
|
||||
bookAuthor1.setAuthor(author);
|
||||
assertThrows(DataIntegrityViolationException.class, () -> {
|
||||
bookAuthorRepository.save(bookAuthor1);
|
||||
});
|
||||
savedAuthor.getBookAuthors().remove(savedBookAuthor);
|
||||
authorRepository.save(savedAuthor);
|
||||
savedBook.getAuthors().remove(savedBookAuthor);
|
||||
bookRepository.save(savedBook);
|
||||
savedPublisher.getBooks().remove(savedBook);
|
||||
bookshelfPublisherRepository.save(savedPublisher);
|
||||
authorRepository.delete(savedAuthor);
|
||||
assertEquals(TestConstants.AUTHOR_COUNT, authorRepository.findAll().size());
|
||||
bookRepository.delete(savedBook);
|
||||
assertEquals(TestConstants.ARTICLE_COUNT, bookRepository.findAll().size());
|
||||
bookshelfPublisherRepository.delete(savedPublisher);
|
||||
assertEquals(TestConstants.PUBLISHER_COUNT, bookshelfPublisherRepository.findAll().size());
|
||||
bookAuthorRepository.delete(savedBookAuthor);
|
||||
assertEquals(TestConstants.ARTICLEAUTHOR_COUNT, bookAuthorRepository.findAll().size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package de.thpeetz.kontor.bookshelf.data;
|
||||
|
||||
import de.thpeetz.kontor.bookshelf.TestConstants;
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@SpringBootTest
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
@Disabled
|
||||
class BookRepositoryTest {
|
||||
|
||||
@Autowired
|
||||
BookRepository bookRepository;
|
||||
|
||||
@Autowired
|
||||
BookshelfPublisherRepository bookshelfPublisherRepository;
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void checkInitialLoad(){
|
||||
assertEquals(TestConstants.BOOK_COUNT, bookRepository.findAll().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
void saveBook() {
|
||||
BookshelfPublisher publisher = new BookshelfPublisher();
|
||||
publisher.setName(TestConstants.PUBLISHER_NAME);
|
||||
bookshelfPublisherRepository.save(publisher);
|
||||
Book book = new Book();
|
||||
book.setTitle(TestConstants.BOOK_TITLE);
|
||||
book.setIsbn(TestConstants.BOOK_ISBN);
|
||||
book.setPublisher(publisher);
|
||||
bookRepository.save(book);
|
||||
assertEquals(TestConstants.BOOK_COUNT+1, bookRepository.findAll().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
void search() {
|
||||
List<Book> books = bookRepository.search(TestConstants.BOOK_TITLE.substring(2,5));
|
||||
assertEquals(1, books.size());
|
||||
assertEquals(1, bookRepository.search(TestConstants.BOOK_ISBN.substring(3,7)).size());
|
||||
assertEquals(0, bookRepository.search("Article").size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
void findByTitle() {
|
||||
List<Book> books = bookRepository.findByTitle(TestConstants.BOOK_TITLE);
|
||||
assertEquals(1, books.size());
|
||||
assertEquals(TestConstants.BOOK_ISBN, books.get(0).getIsbn());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(5)
|
||||
void findByTitleIgnoreCase() {
|
||||
List<Book> books = bookRepository.findByTitleIgnoreCase(TestConstants.BOOK_TITLE.toLowerCase());
|
||||
assertEquals(1, books.size());
|
||||
assertEquals(TestConstants.BOOK_ISBN, books.get(0).getIsbn());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(6)
|
||||
void findByIsbn() {
|
||||
List<Book> books = bookRepository.findByIsbn(TestConstants.BOOK_ISBN);
|
||||
assertEquals(1, books.size());
|
||||
assertEquals(TestConstants.BOOK_TITLE, books.get(0).getTitle());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(7)
|
||||
void deleteBook() {
|
||||
List<Book> books = bookRepository.findByIsbn(TestConstants.BOOK_ISBN);
|
||||
Book book = books.get(0);
|
||||
BookshelfPublisher publisher = book.getPublisher();
|
||||
bookshelfPublisherRepository.delete(publisher);
|
||||
bookRepository.delete(book);
|
||||
assertEquals(TestConstants.BOOK_COUNT, bookRepository.findAll().size());
|
||||
assertEquals(TestConstants.PUBLISHER_COUNT, bookshelfPublisherRepository.findAll().size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package de.thpeetz.kontor.bookshelf.data;
|
||||
|
||||
import de.thpeetz.kontor.bookshelf.TestConstants;
|
||||
import de.thpeetz.kontor.comics.data.Publisher;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.orm.jpa.JpaSystemException;
|
||||
import org.springframework.transaction.TransactionSystemException;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@SpringBootTest
|
||||
class BookTest {
|
||||
|
||||
@Autowired
|
||||
BookRepository bookRepository;
|
||||
|
||||
@Autowired
|
||||
BookshelfPublisherRepository bookshelfPublisherRepository;
|
||||
|
||||
@Test
|
||||
void checkInitialLoad() {
|
||||
assertEquals(TestConstants.BOOK_COUNT, bookRepository.findAll().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void exceptionThrownWhenSavingEmptyFields() {
|
||||
Book book = new Book();
|
||||
assertThrows(TransactionSystemException.class, () -> {
|
||||
bookRepository.save(book);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void exceptionThrownWhenSavingIdenticalISBN() {
|
||||
BookshelfPublisher publisher = new BookshelfPublisher();
|
||||
publisher.setName(TestConstants.PUBLISHER_NAME);
|
||||
BookshelfPublisher savedPublisher = bookshelfPublisherRepository.save(publisher);
|
||||
Book book = new Book();
|
||||
book.setTitle(TestConstants.BOOK_TITLE);
|
||||
book.setIsbn(TestConstants.BOOK_ISBN);
|
||||
book.setPublisher(savedPublisher);
|
||||
Book savedBook = bookRepository.save(book);
|
||||
Book book1 = new Book();
|
||||
book1.setTitle(book.getTitle());
|
||||
book1.setIsbn(book.getIsbn());
|
||||
assertThrows(TransactionSystemException.class, ()-> {
|
||||
bookRepository.save(book1);
|
||||
});
|
||||
bookRepository.delete(book);
|
||||
assertEquals(TestConstants.BOOK_COUNT, bookRepository.findAll().size());
|
||||
bookshelfPublisherRepository.delete(savedPublisher);
|
||||
assertEquals(TestConstants.PUBLISHER_COUNT, bookshelfPublisherRepository.findAll().size());
|
||||
}
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
package de.thpeetz.kontor.bookshelf.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import de.thpeetz.kontor.bookshelf.TestConstants;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@SpringBootTest
|
||||
@TestMethodOrder(OrderAnnotation.class)
|
||||
class BookshelfPublisherRepositoryTest {
|
||||
|
||||
@Autowired
|
||||
private BookshelfPublisherRepository publisherRepository;
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void checkInitialLoad() {
|
||||
assertEquals(TestConstants.PUBLISHER_COUNT, publisherRepository.findAll().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
void savePublisher() {
|
||||
BookshelfPublisher publisher = new BookshelfPublisher();
|
||||
publisher.setName(TestConstants.PUBLISHER_NAME);
|
||||
publisherRepository.save(publisher);
|
||||
assertEquals(TestConstants.PUBLISHER_COUNT + 1, publisherRepository.findAll().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
void findPublisherByName() {
|
||||
assertEquals(TestConstants.PUBLISHER_COUNT + 1, publisherRepository.findAll().size());
|
||||
log.info("Liste der Publisher: {}", publisherRepository.findAll());
|
||||
BookshelfPublisher publisher = publisherRepository.findByName(TestConstants.PUBLISHER_NAME);
|
||||
assertNotNull(publisher);
|
||||
assertEquals(TestConstants.PUBLISHER_NAME, publisher.getName());
|
||||
BookshelfPublisher notFound = publisherRepository.findByName(TestConstants.PUBLISHER_SEARCH);
|
||||
assertNull(notFound);
|
||||
List<BookshelfPublisher> publishers = publisherRepository
|
||||
.findByNameIgnoreCase(TestConstants.PUBLISHER_NAME.toLowerCase());
|
||||
assertEquals(1, publishers.size());
|
||||
assertEquals(TestConstants.PUBLISHER_NAME, publishers.get(0).getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
void searchPublisher() {
|
||||
List<BookshelfPublisher> publishers = publisherRepository.search(TestConstants.PUBLISHER_NAME.substring(2, 6));
|
||||
assertEquals(1, publishers.size());
|
||||
assertEquals(TestConstants.PUBLISHER_NAME, publishers.get(0).getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(5)
|
||||
void deletePublisher() {
|
||||
BookshelfPublisher publisher = publisherRepository.findByName(TestConstants.PUBLISHER_NAME);
|
||||
assertNotNull(publisher);
|
||||
publisherRepository.delete(publisher);
|
||||
assertEquals(TestConstants.PUBLISHER_COUNT, publisherRepository.findAll().size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package de.thpeetz.kontor.bookshelf.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
import org.springframework.transaction.TransactionSystemException;
|
||||
|
||||
import de.thpeetz.kontor.bookshelf.TestConstants;
|
||||
|
||||
@SpringBootTest
|
||||
class BookshelfPublisherTest {
|
||||
|
||||
@Autowired
|
||||
private BookshelfPublisherRepository publisherRepository;
|
||||
|
||||
@Test
|
||||
void checkInitialDataLoad() {
|
||||
assertEquals(TestConstants.PUBLISHER_COUNT, publisherRepository.findAll().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void throwExceptionWhenPublisherSavedWithEmptyName() {
|
||||
BookshelfPublisher publisher = new BookshelfPublisher();
|
||||
assertThrows(TransactionSystemException.class, () -> {
|
||||
publisherRepository.save(publisher);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void savePublisherWithIdenticalName() {
|
||||
BookshelfPublisher publisher1 = new BookshelfPublisher();
|
||||
publisher1.setName(TestConstants.PUBLISHER_NAME);
|
||||
publisherRepository.save(publisher1);
|
||||
BookshelfPublisher publisher2 = new BookshelfPublisher();
|
||||
publisher2.setName(TestConstants.PUBLISHER_NAME);
|
||||
assertThrows(DataIntegrityViolationException.class, () -> {
|
||||
publisherRepository.save(publisher2);
|
||||
});
|
||||
publisherRepository.delete(publisher1);
|
||||
assertEquals(TestConstants.PUBLISHER_COUNT, publisherRepository.findAll().size());
|
||||
}
|
||||
}
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
package de.thpeetz.kontor.bookshelf.services;
|
||||
|
||||
import de.thpeetz.kontor.bookshelf.TestConstants;
|
||||
import de.thpeetz.kontor.bookshelf.data.Author;
|
||||
import de.thpeetz.kontor.bookshelf.data.Book;
|
||||
import de.thpeetz.kontor.bookshelf.data.BookshelfPublisher;
|
||||
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
@SpringBootTest
|
||||
@TestMethodOrder(OrderAnnotation.class)
|
||||
class BookshelfServiceTest {
|
||||
|
||||
@Autowired
|
||||
private BookshelfService bookshelfService;
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void testFindAllPublishers() {
|
||||
List<BookshelfPublisher> publishers = bookshelfService.findAllPublishers(null);
|
||||
assertEquals(TestConstants.PUBLISHER_COUNT, publishers.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
void testSavePublisher() {
|
||||
BookshelfPublisher publisher = new BookshelfPublisher();
|
||||
publisher.setName(TestConstants.PUBLISHER_NAME);
|
||||
bookshelfService.savePublisher(publisher);
|
||||
assertEquals(TestConstants.PUBLISHER_COUNT + 1, bookshelfService.findAllPublishers(null).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
void testFindPublisherByName() {
|
||||
assertEquals(TestConstants.PUBLISHER_COUNT + 1, bookshelfService.findAllPublishers(null).size());
|
||||
BookshelfPublisher publisher = bookshelfService.findPublisherByName(TestConstants.PUBLISHER_NAME);
|
||||
assertNotNull(publisher);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
void testDeletePublisher() {
|
||||
List<BookshelfPublisher> publishers = bookshelfService.findAllPublishers(TestConstants.PUBLISHER_NAME);
|
||||
assertEquals(1, publishers.size());
|
||||
bookshelfService.deletePublisher(publishers.get(0));
|
||||
assertEquals(TestConstants.PUBLISHER_COUNT, bookshelfService.findAllPublishers(null).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(5)
|
||||
void testFindAllAuthors() {
|
||||
assertEquals(TestConstants.AUTHOR_COUNT, bookshelfService.findAllAuthors(null).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(6)
|
||||
void testSaveAuthor() {
|
||||
Author author = new Author();
|
||||
author.setFirstName(TestConstants.AUTHOR_FIRSTNAME);
|
||||
author.setLastName(TestConstants.AUTHOR_LASTNAME);
|
||||
bookshelfService.saveAuthor(author);
|
||||
assertEquals(TestConstants.AUTHOR_COUNT+1, bookshelfService.findAllAuthors(null).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(7)
|
||||
void testDeleteAuthor() {
|
||||
List<Author> authors = bookshelfService.findAllAuthors(TestConstants.AUTHOR_FIRSTNAME);
|
||||
assertEquals(1, authors.size());
|
||||
bookshelfService.deleteAuthor(authors.get(0));
|
||||
assertEquals(TestConstants.AUTHOR_COUNT, bookshelfService.findAllAuthors(null).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(8)
|
||||
void findAllBooks() {
|
||||
assertEquals(TestConstants.BOOK_COUNT, bookshelfService.findAllBooks(null).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(9)
|
||||
void saveBook() {
|
||||
assertEquals(TestConstants.BOOK_COUNT, bookshelfService.findAllBooks(null).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(10)
|
||||
void deleteBook() {
|
||||
List<Book> books = bookshelfService.findAllBooks(null);
|
||||
assertEquals(0, books.size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package de.thpeetz.kontor.comics;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class ComicConstantsTest {
|
||||
|
||||
@Test
|
||||
void getArtistConstants() {
|
||||
assertEquals("Artist", ComicConstants.ARTIST);
|
||||
assertEquals("comics/artist", ComicConstants.ARTIST_ROUTE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package de.thpeetz.kontor.comics;
|
||||
|
||||
import de.thpeetz.kontor.comics.data.Artist;
|
||||
import de.thpeetz.kontor.comics.data.Comic;
|
||||
import de.thpeetz.kontor.comics.data.Publisher;
|
||||
import de.thpeetz.kontor.comics.data.Worktype;
|
||||
import de.thpeetz.kontor.comics.services.ComicService;
|
||||
|
||||
public class TestConstants {
|
||||
public static final String ARTIST_NAME = "Lastname, Firstname";
|
||||
public static final String COMIC_TITLE = "TestComic";
|
||||
public static final String WORKTYPE_INKER = "Inker";
|
||||
public static final String ISSUE_ISSUENUMBER = "Issuenumber";
|
||||
public static final String PUBLISHER_NAME = "Publisher";
|
||||
public static final String SOJOURN_TPB_COMIC_TITLE = "Sojourn";
|
||||
public static final String SOJOURN_TPB_NAME = "The Dragons Tale";
|
||||
public static final String STORYARC_NAME = "StoryArc";
|
||||
public static final String TRADEPAPERBACK_NAME = "TradePaperback";
|
||||
public static final String VOLUME_NAME = "Volume";
|
||||
public static final String WORKTYPE_NAME = "Worktype";
|
||||
public static final int ARTIST_COUNT = 5;
|
||||
public static final int BATTLE_POPE_ISSUE_COUNT = 12;
|
||||
public static final int COMIC_COUNT = 169;
|
||||
public static final int COMICWORK_COUNT = 18;
|
||||
public static final int ISSUE_COUNT = 750;
|
||||
public static final int MARVEL_COMIC_COUNT = 50;
|
||||
public static final int PUBLISHER_COUNT = 18;
|
||||
public static final int SOJOURN_TPB_COUNT = 4;
|
||||
public static final int SOJOURN_TPB_START = 7;
|
||||
public static final int SOJOURN_TPB_END = 12;
|
||||
public static final int STORYARC_COUNT = 3;
|
||||
public static final int TRADEPAPERBACK_COUNT = 40;
|
||||
public static final int VOLUME_COUNT = 0;
|
||||
public static final int WORKTYPE_COUNT = 3;
|
||||
|
||||
public static Comic getComicWithStoryArcs(ComicService service) {
|
||||
return service.findComicByTitle("Emma Frost");
|
||||
}
|
||||
|
||||
public static Comic getComicWithTradePaperbacks(ComicService service) {
|
||||
return service.findComicByTitle(SOJOURN_TPB_COMIC_TITLE);
|
||||
}
|
||||
|
||||
public static Comic getComicWithIssues(ComicService service) {
|
||||
return service.findComicByTitle("Battle Pope");
|
||||
}
|
||||
|
||||
public static Comic getComicWithoutReferences(ComicService service) {
|
||||
return service.findComicByTitle("Gen13");
|
||||
}
|
||||
|
||||
public static Artist getArtistWithoutReferences(ComicService service) {
|
||||
return service.findArtistByName("Marz, Ron");
|
||||
}
|
||||
|
||||
public static Worktype getWorktypeWithoutReferences(ComicService service) {
|
||||
return service.findWorktypeByName(WORKTYPE_INKER);
|
||||
}
|
||||
|
||||
public static Publisher getPublisherForComicTests(ComicService service) {
|
||||
return service.findPublisherByName("Marvel");
|
||||
}
|
||||
|
||||
public static Publisher getAnotherPublisherForComicTests(ComicService service) {
|
||||
return service.findPublisherByName("DC");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package de.thpeetz.kontor.comics.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
@TestMethodOrder(OrderAnnotation.class)
|
||||
class ArtistRepositoryTest {
|
||||
|
||||
private Artist stanLee;
|
||||
private static final String ARTISTNAME = "Lee, Stan";
|
||||
|
||||
@Autowired
|
||||
ArtistRepository artistRepository;
|
||||
|
||||
@BeforeEach
|
||||
void setupData() {
|
||||
stanLee = new Artist();
|
||||
stanLee.setName(ARTISTNAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void checkInitialLoad() {
|
||||
int count = artistRepository.findAll().size();
|
||||
assertEquals(5, count);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
void saveArtist() {
|
||||
int count = artistRepository.findAll().size();
|
||||
artistRepository.save(stanLee);
|
||||
assertEquals(count+1, artistRepository.findAll().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
void findArtist() {
|
||||
List<Artist> artists = artistRepository.findByNameIgnoreCase("lEE, sTAN");
|
||||
assertTrue(artists.size() > 0);
|
||||
assertEquals(artists.get(0).getName(), stanLee.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
void searchArtist() {
|
||||
List<Artist> artists = artistRepository.search("Lee");
|
||||
assertEquals(1, artists.size());
|
||||
assertEquals(ARTISTNAME, artists.get(0).getName());
|
||||
List<Artist> artists2 = artistRepository.search("Stan");
|
||||
assertEquals(1, artists2.size());
|
||||
assertEquals(ARTISTNAME, artists2.get(0).getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(5)
|
||||
void deleteArtist() {
|
||||
int count = artistRepository.findAll().size();
|
||||
Artist artist = artistRepository.findByName(ARTISTNAME);
|
||||
artistRepository.delete(artist);
|
||||
assertEquals(count-1, artistRepository.findAll().size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package de.thpeetz.kontor.comics.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
import org.springframework.transaction.TransactionSystemException;
|
||||
|
||||
import de.thpeetz.kontor.comics.TestConstants;
|
||||
|
||||
@SpringBootTest
|
||||
class ArtistTest {
|
||||
|
||||
@Autowired
|
||||
private ArtistRepository artistRepository;
|
||||
|
||||
@Test
|
||||
void checkInitialDataLoad() {
|
||||
List<Artist> artists = artistRepository.findAll();
|
||||
assertEquals(TestConstants.ARTIST_COUNT, artists.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void throwExceptionWhenArtistSavedWithEmptyName() {
|
||||
Artist artist1 = new Artist();
|
||||
assertThrows(TransactionSystemException.class, () -> {
|
||||
artistRepository.save(artist1);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void saveArtistWithIdenticalName() {
|
||||
String artistName = "Lastname, Firstname";
|
||||
Artist artist1 = new Artist();
|
||||
artist1.setName(artistName);
|
||||
artistRepository.save(artist1);
|
||||
Artist artist2 = new Artist();
|
||||
artist2.setName(artistName);
|
||||
assertThrows(DataIntegrityViolationException.class, () -> {
|
||||
artistRepository.save(artist2);
|
||||
});
|
||||
artistRepository.delete(artist1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package de.thpeetz.kontor.comics.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class ComicRepositoryTest {
|
||||
|
||||
@Autowired
|
||||
private ComicRepository comicRepository;
|
||||
|
||||
@Autowired
|
||||
private PublisherRepository publisherRepository;
|
||||
|
||||
@Test
|
||||
void testFindByTitle() {
|
||||
List<Comic> comics = comicRepository.findByTitle("Emma Frost");
|
||||
assertEquals(1, comics.size());
|
||||
assertEquals("Emma Frost", comics.get(0).getTitle());
|
||||
Publisher publisher = comics.get(0).getPublisher();
|
||||
assertEquals("Marvel", publisher.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFindByTitleIgnoreCase() {
|
||||
List<Comic> comics = comicRepository.findByTitleIgnoreCase("x-men");
|
||||
assertEquals(1, comics.size());
|
||||
assertEquals("X-Men", comics.get(0).getTitle());
|
||||
}
|
||||
@Test
|
||||
void testFindByTitleAndPublisher() {
|
||||
Publisher publisher = publisherRepository.findByName("Marvel");
|
||||
assertNotNull(publisher);
|
||||
Comic found = comicRepository.findByTitleAndPublisher("Emma Frost", publisher);
|
||||
assertNotNull(found);
|
||||
assertEquals("Emma Frost", found.getTitle());
|
||||
assertEquals("Marvel", found.getPublisher().getName());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSearch() {
|
||||
List<Comic> comics = comicRepository.search("X-men");
|
||||
assertEquals(11, comics.size());
|
||||
assertTrue(comics.stream().map(comic -> comic.getTitle()).collect(Collectors.toList()).contains("Astonishing X-Men"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package de.thpeetz.kontor.comics.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
import org.springframework.orm.jpa.JpaSystemException;
|
||||
import org.springframework.transaction.TransactionSystemException;
|
||||
|
||||
import de.thpeetz.kontor.comics.TestConstants;
|
||||
import de.thpeetz.kontor.comics.services.ComicService;
|
||||
|
||||
@SpringBootTest
|
||||
@TestMethodOrder(OrderAnnotation.class)
|
||||
class ComicTest {
|
||||
|
||||
@Autowired
|
||||
private ComicRepository comicRepository;
|
||||
|
||||
@Autowired
|
||||
private ComicService comicService;
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void checkInitialDataLoad() {
|
||||
List<Comic> comics = comicRepository.findAll();
|
||||
assertEquals(TestConstants.COMIC_COUNT, comics.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
void exceptionThrownWhenSavingComicWithoutPublisher() {
|
||||
Comic comic = new Comic();
|
||||
comic.setTitle(TestConstants.COMIC_TITLE);
|
||||
assertThrows(TransactionSystemException.class, () -> {
|
||||
comicRepository.save(comic);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
void exceptionThrownWhenSavingComicWithEmptyTitle() {
|
||||
Comic comic = new Comic();
|
||||
Publisher publisher = TestConstants.getPublisherForComicTests(comicService);
|
||||
comic.setPublisher(publisher);
|
||||
assertNull(comic.getTitle());
|
||||
assertThrows(TransactionSystemException.class, () -> {
|
||||
comicRepository.save(comic);
|
||||
});
|
||||
comic.setTitle("");
|
||||
assertTrue(comic.getTitle().isEmpty());
|
||||
assertThrows(TransactionSystemException.class, () -> {
|
||||
comicRepository.save(comic);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
void exceptionThrownWhenSavingComicWithSameNameFromDifferentPublishers() {
|
||||
Publisher publisher = TestConstants.getPublisherForComicTests(comicService);
|
||||
Comic comic = new Comic();
|
||||
comic.setTitle(TestConstants.SOJOURN_TPB_COMIC_TITLE);
|
||||
comic.setPublisher(publisher);
|
||||
assertThrows(DataIntegrityViolationException.class, () -> {
|
||||
comicRepository.save(comic);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package de.thpeetz.kontor.comics.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import de.thpeetz.kontor.comics.services.ComicService;
|
||||
|
||||
@SpringBootTest
|
||||
@TestMethodOrder(OrderAnnotation.class)
|
||||
class ComicWorkRepositoryTest {
|
||||
|
||||
@Autowired
|
||||
private ComicWorkRepository comicWorkRepository;
|
||||
|
||||
@Autowired
|
||||
private ComicRepository comicRepository;
|
||||
|
||||
@Autowired
|
||||
private WorktypeRepository worktypeRepository;
|
||||
|
||||
@Autowired
|
||||
private ArtistRepository artistRepository;
|
||||
|
||||
@Autowired
|
||||
private ComicService comicService;
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void checkInitialLoad() {
|
||||
int count = comicWorkRepository.findAll().size();
|
||||
assertEquals(18, count);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
void saveComicWork() {
|
||||
int count = comicWorkRepository.findAll().size();
|
||||
Artist artist = artistRepository.findByName("Turner, Michael");
|
||||
Worktype worktype = worktypeRepository.findByName("Writer");
|
||||
Comic comic = comicRepository.findByTitle("Emma Frost").get(0);
|
||||
ComicWork comicWork = new ComicWork();
|
||||
comicWork.setArtist(artist);
|
||||
comicWork.setComic(comic);
|
||||
comicWork.setWorkType(worktype);
|
||||
comicWorkRepository.save(comicWork);
|
||||
assertEquals(count + 1, comicWorkRepository.findAll().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
void findByComicAndArtistAndComicWork() {
|
||||
assertEquals(19, comicWorkRepository.count());
|
||||
Artist artist = artistRepository.findByName("Turner, Michael");
|
||||
Worktype worktype = worktypeRepository.findByName("Writer");
|
||||
Comic comic = comicRepository.findByTitle("Emma Frost").get(0);
|
||||
ComicWork comicWork = comicWorkRepository.findbyComicAndArtistAndWorktype(comic, artist, worktype);
|
||||
assertNotNull(comicWork);
|
||||
assertEquals(comicWork.getArtist().getName(), artist.getName());
|
||||
assertEquals(comicWork.getComic().getTitle(), comic.getTitle());
|
||||
assertEquals(comicWork.getWorkType().getName(), worktype.getName());
|
||||
ComicWork notFound = comicWorkRepository.findbyComicAndArtistAndWorktype(comic, artist, null);
|
||||
assertNull(notFound);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
void deleteComicWork() {
|
||||
long count = comicWorkRepository.count();
|
||||
Artist artist = artistRepository.findByName("Turner, Michael");
|
||||
Worktype worktype = worktypeRepository.findByName("Writer");
|
||||
Comic comic = comicRepository.findByTitle("Emma Frost").get(0);
|
||||
ComicWork comicWork = comicWorkRepository.findbyComicAndArtistAndWorktype(comic, artist, worktype);
|
||||
assertNotNull(comicWork);
|
||||
comicService.deleteComicWork(comicWork);
|
||||
assertEquals(count - 1, comicWorkRepository.count());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package de.thpeetz.kontor.comics.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import de.thpeetz.kontor.comics.services.ComicService;
|
||||
|
||||
@SpringBootTest
|
||||
public class ComicWorkTest {
|
||||
|
||||
@Autowired
|
||||
private ComicService comicService;
|
||||
|
||||
@Test
|
||||
void checkInitialDataLoad() {
|
||||
List<ComicWork> comicWorks = comicService.findAllComicWorks();
|
||||
assertEquals(18, comicWorks.size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package de.thpeetz.kontor.comics.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import de.thpeetz.kontor.comics.TestConstants;
|
||||
import de.thpeetz.kontor.comics.services.ComicService;
|
||||
|
||||
@SpringBootTest
|
||||
class IssueRepositoryTest {
|
||||
|
||||
@Autowired
|
||||
private IssueRepository issueRepository;
|
||||
|
||||
@Autowired
|
||||
private ComicService comicService;
|
||||
|
||||
@Test
|
||||
void testFindByComic() {
|
||||
Comic comic = TestConstants.getComicWithIssues(comicService);
|
||||
List<Issue> issues = issueRepository.findByComic(comic);
|
||||
assertEquals(TestConstants.BATTLE_POPE_ISSUE_COUNT, issues.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFindByComicAndIssueNumber() {
|
||||
Comic comic = TestConstants.getComicWithIssues(comicService);
|
||||
Issue issue = issueRepository.findByComicAndIssueNumber(comic, "12");
|
||||
assertNotNull(issue);
|
||||
assertFalse(issue.getIsRead());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSearch() {
|
||||
List<Issue> issues = issueRepository.search("2");
|
||||
assertEquals(187, issues.size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package de.thpeetz.kontor.comics.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.transaction.TransactionSystemException;
|
||||
|
||||
import de.thpeetz.kontor.comics.TestConstants;
|
||||
import de.thpeetz.kontor.comics.services.ComicService;
|
||||
|
||||
@SpringBootTest
|
||||
class IssueTest {
|
||||
|
||||
@Autowired
|
||||
private IssueRepository issueRepository;
|
||||
|
||||
@Autowired
|
||||
private ComicService comicService;
|
||||
|
||||
@Test
|
||||
void checkInitialDataLoad() {
|
||||
List<Issue> issues = comicService.findAllIssues();
|
||||
assertEquals(TestConstants.ISSUE_COUNT, issues.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void exceptionThrownWhenSavingIssueWithEmptyNumber() {
|
||||
Comic comic = TestConstants.getComicWithoutReferences(comicService);
|
||||
assertNotNull(comic);
|
||||
Issue issue = new Issue();
|
||||
issue.setComic(comic);
|
||||
assertThrows(TransactionSystemException.class, () -> {
|
||||
issueRepository.save(issue);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void exceptionThrownWhenSavingStoryArcWithoutComic() {
|
||||
Issue issue = new Issue();
|
||||
issue.setIssueNumber(TestConstants.ISSUE_ISSUENUMBER);
|
||||
assertThrows(TransactionSystemException.class, () -> {
|
||||
issueRepository.save(issue);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void saveStoryArc() {
|
||||
Comic comic = TestConstants.getComicWithoutReferences(comicService);
|
||||
assertEquals(0, comic.getStoryArcs().size());
|
||||
Issue issue = new Issue();
|
||||
issue.setComic(comic);
|
||||
issue.setIssueNumber(TestConstants.ISSUE_ISSUENUMBER);
|
||||
Issue savedInstance = issueRepository.save(issue);
|
||||
assertNotNull(savedInstance);
|
||||
comicService.deleteIssue(savedInstance);
|
||||
assertEquals(0, comic.getStoryArcs().size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package de.thpeetz.kontor.comics.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import de.thpeetz.kontor.comics.TestConstants;
|
||||
|
||||
@SpringBootTest
|
||||
@TestMethodOrder(OrderAnnotation.class)
|
||||
class PublisherRepositoryTest {
|
||||
|
||||
@Autowired
|
||||
private PublisherRepository publisherRepository;
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void checkInitialLoad() {
|
||||
assertEquals(TestConstants.PUBLISHER_COUNT, publisherRepository.findAll().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
void savePublisher() {
|
||||
Publisher publisher = new Publisher();
|
||||
publisher.setName(TestConstants.PUBLISHER_NAME);
|
||||
publisherRepository.save(publisher);
|
||||
assertEquals(TestConstants.PUBLISHER_COUNT + 1, publisherRepository.findAll().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
void findPublisherByName() {
|
||||
Publisher publisher = publisherRepository.findByName(TestConstants.PUBLISHER_NAME);
|
||||
assertNotNull(publisher);
|
||||
assertEquals(TestConstants.PUBLISHER_NAME, publisher.getName());
|
||||
Publisher notFound = publisherRepository.findByName("Cow");
|
||||
assertNull(notFound);
|
||||
List<Publisher> publishers = publisherRepository
|
||||
.findByNameIgnoreCase(TestConstants.PUBLISHER_NAME.toLowerCase());
|
||||
assertEquals(1, publishers.size());
|
||||
assertEquals(TestConstants.PUBLISHER_NAME, publishers.get(0).getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
void searchPublisher() {
|
||||
List<Publisher> publishers = publisherRepository.search("Cow");
|
||||
assertEquals(1, publishers.size());
|
||||
assertEquals("Top Cow Productions", publishers.get(0).getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(5)
|
||||
void deletePublisher() {
|
||||
Publisher publisher = publisherRepository.findByName(TestConstants.PUBLISHER_NAME);
|
||||
assertNotNull(publisher);
|
||||
publisherRepository.delete(publisher);
|
||||
assertEquals(TestConstants.PUBLISHER_COUNT, publisherRepository.findAll().size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package de.thpeetz.kontor.comics.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
import org.springframework.transaction.TransactionSystemException;
|
||||
|
||||
import de.thpeetz.kontor.comics.TestConstants;
|
||||
|
||||
@SpringBootTest
|
||||
class PublisherTest {
|
||||
|
||||
@Autowired
|
||||
private PublisherRepository publisherRepository;
|
||||
|
||||
@Test
|
||||
void checkInitialDataLoad() {
|
||||
assertEquals(TestConstants.PUBLISHER_COUNT, publisherRepository.findAll().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void throwExceptionWhenPublisherSavedWithEmptyName() {
|
||||
Publisher publisher = new Publisher();
|
||||
assertThrows(TransactionSystemException.class, () -> {
|
||||
publisherRepository.save(publisher);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void savePublisherWithIdenticalName() {
|
||||
Publisher publisher1 = new Publisher();
|
||||
publisher1.setName(TestConstants.PUBLISHER_NAME);
|
||||
publisherRepository.save(publisher1);
|
||||
Publisher publisher2 = new Publisher();
|
||||
publisher2.setName(TestConstants.PUBLISHER_NAME);
|
||||
assertThrows(DataIntegrityViolationException.class, () -> {
|
||||
publisherRepository.save(publisher2);
|
||||
});
|
||||
publisherRepository.delete(publisher1);
|
||||
assertEquals(TestConstants.PUBLISHER_COUNT, publisherRepository.findAll().size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package de.thpeetz.kontor.comics.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import de.thpeetz.kontor.comics.TestConstants;
|
||||
import de.thpeetz.kontor.comics.services.ComicService;
|
||||
|
||||
@SpringBootTest
|
||||
class StoryArcRepositoryTest {
|
||||
|
||||
@Autowired
|
||||
private StoryArcRepository storyArcRepository;
|
||||
|
||||
@Autowired
|
||||
private ComicService comicService;
|
||||
|
||||
@Test
|
||||
void testSearch() {
|
||||
List<StoryArc> storyArcs = storyArcRepository.search("Learn");
|
||||
assertNotNull(storyArcs);
|
||||
assertEquals(1, storyArcs.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void findByComic() {
|
||||
Comic comic = TestConstants.getComicWithStoryArcs(comicService);
|
||||
List<StoryArc> storyArcs = storyArcRepository.findByComic(comic);
|
||||
assertNotNull(storyArcs);
|
||||
assertEquals(3, storyArcs.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void findByNameAndComic() {
|
||||
Comic comic = TestConstants.getComicWithStoryArcs(comicService);
|
||||
StoryArc storyArc = storyArcRepository.findByNameAndComic("Higher Learning", comic);
|
||||
assertNotNull(storyArc);
|
||||
assertEquals("Emma Frost", storyArc.getComic().getTitle());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package de.thpeetz.kontor.comics.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.transaction.TransactionSystemException;
|
||||
|
||||
import de.thpeetz.kontor.comics.TestConstants;
|
||||
import de.thpeetz.kontor.comics.services.ComicService;
|
||||
|
||||
@SpringBootTest
|
||||
class StoryArcTest {
|
||||
|
||||
@Autowired
|
||||
private StoryArcRepository storyArcRepository;
|
||||
|
||||
@Autowired
|
||||
private ComicService comicService;
|
||||
|
||||
@Test
|
||||
void checkInitialLoad() {
|
||||
assertEquals(TestConstants.STORYARC_COUNT, storyArcRepository.findAll().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void exceptionThrownWhenSavingStoryArcWithEmptyName() {
|
||||
Comic comic = TestConstants.getComicWithoutReferences(comicService);
|
||||
assertNotNull(comic);
|
||||
StoryArc storyArc = new StoryArc();
|
||||
storyArc.setComic(comic);
|
||||
assertThrows(TransactionSystemException.class, () -> {
|
||||
storyArcRepository.save(storyArc);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void exceptionThrownWhenSavingStoryArcWithoutComic() {
|
||||
StoryArc storyArc = new StoryArc();
|
||||
storyArc.setName(TestConstants.STORYARC_NAME);
|
||||
assertThrows(TransactionSystemException.class, () -> {
|
||||
storyArcRepository.save(storyArc);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void saveStoryArc() {
|
||||
Comic comic = TestConstants.getComicWithoutReferences(comicService);
|
||||
assertEquals(0, comic.getStoryArcs().size());
|
||||
StoryArc storyArc = new StoryArc();
|
||||
storyArc.setName(TestConstants.STORYARC_NAME);
|
||||
storyArc.setComic(comic);
|
||||
StoryArc savedInstance = storyArcRepository.save(storyArc);
|
||||
assertNotNull(savedInstance);
|
||||
comicService.deleteStoryArc(savedInstance);
|
||||
assertEquals(0, comic.getStoryArcs().size());
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
package de.thpeetz.kontor.comics.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import de.thpeetz.kontor.comics.TestConstants;
|
||||
import de.thpeetz.kontor.comics.services.ComicService;
|
||||
|
||||
@SpringBootTest
|
||||
class TradePaperbackRepositoryTest {
|
||||
|
||||
@Autowired
|
||||
private TradePaperbackRepository tradePaperbackRepository;
|
||||
|
||||
@Autowired
|
||||
private ComicService comicService;
|
||||
|
||||
@Test
|
||||
void testSearch() {
|
||||
List<TradePaperback> tradePaperbacks = tradePaperbackRepository.search("Dragon");
|
||||
assertNotNull(tradePaperbacks);
|
||||
assertEquals(1, tradePaperbacks.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFindByComic() {
|
||||
Comic comic = TestConstants.getComicWithTradePaperbacks(comicService);
|
||||
List<TradePaperback> tradePaperbacks = tradePaperbackRepository.findByComic(comic);
|
||||
assertNotNull(tradePaperbacks);
|
||||
assertEquals(TestConstants.SOJOURN_TPB_COUNT, tradePaperbacks.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFindByNameAndComic() {
|
||||
Comic comic = TestConstants.getComicWithTradePaperbacks(comicService);
|
||||
List<TradePaperback> tradePaperbacks = tradePaperbackRepository
|
||||
.findByNameAndComic(TestConstants.SOJOURN_TPB_NAME, comic);
|
||||
assertNotNull(tradePaperbacks);
|
||||
assertTrue(tradePaperbacks.size() > 0);
|
||||
assertEquals(TestConstants.SOJOURN_TPB_COMIC_TITLE, tradePaperbacks.get(0).getComic().getTitle());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFindByFields() {
|
||||
Comic comic = TestConstants.getComicWithTradePaperbacks(comicService);
|
||||
TradePaperback tradePaperback = tradePaperbackRepository.findByFields(TestConstants.SOJOURN_TPB_NAME,
|
||||
comic, TestConstants.SOJOURN_TPB_START, TestConstants.SOJOURN_TPB_END);
|
||||
assertNotNull(tradePaperback);
|
||||
assertEquals(TestConstants.SOJOURN_TPB_COMIC_TITLE, tradePaperback.getComic().getTitle());
|
||||
assertEquals(TestConstants.SOJOURN_TPB_END, tradePaperback.getIssueEnd());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package de.thpeetz.kontor.comics.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.transaction.TransactionSystemException;
|
||||
|
||||
import de.thpeetz.kontor.comics.TestConstants;
|
||||
import de.thpeetz.kontor.comics.services.ComicService;
|
||||
|
||||
@SpringBootTest
|
||||
class TradePaperbackTest {
|
||||
|
||||
@Autowired
|
||||
private TradePaperbackRepository tradePaperbackRepository;
|
||||
|
||||
@Autowired
|
||||
private ComicService comicService;
|
||||
|
||||
@Test
|
||||
void checkInitialDataLoad() {
|
||||
assertEquals(TestConstants.TRADEPAPERBACK_COUNT, tradePaperbackRepository.findAll().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void exceptionThrownWhenSavingTradePaperbackWithEmptyName() {
|
||||
Comic comic = TestConstants.getComicWithoutReferences(comicService);
|
||||
assertNotNull(comic);
|
||||
TradePaperback tradePaperback = new TradePaperback();
|
||||
tradePaperback.setComic(comic);
|
||||
assertThrows(TransactionSystemException.class, () -> {
|
||||
tradePaperbackRepository.save(tradePaperback);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void exceptionThrownWhenSavingTradePaperbackWithoutComic() {
|
||||
TradePaperback tradePaperback = new TradePaperback();
|
||||
tradePaperback.setName(TestConstants.TRADEPAPERBACK_NAME);
|
||||
assertThrows(TransactionSystemException.class, () -> {
|
||||
tradePaperbackRepository.save(tradePaperback);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void saveTradePaperback() {
|
||||
Comic comic = TestConstants.getComicWithoutReferences(comicService);
|
||||
assertEquals(0, comic.getTradePaperbacks().size());
|
||||
TradePaperback tradePaperback = new TradePaperback();
|
||||
tradePaperback.setName(TestConstants.TRADEPAPERBACK_NAME);
|
||||
tradePaperback.setComic(comic);
|
||||
TradePaperback savedInstance = tradePaperbackRepository.save(tradePaperback);
|
||||
assertNotNull(savedInstance);
|
||||
comicService.deleteTradePaperBack(savedInstance);
|
||||
assertEquals(0, comic.getTradePaperbacks().size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package de.thpeetz.kontor.comics.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import de.thpeetz.kontor.comics.TestConstants;
|
||||
import de.thpeetz.kontor.comics.services.ComicService;
|
||||
|
||||
@SpringBootTest
|
||||
class VolumeRepositoryTest {
|
||||
|
||||
@Autowired
|
||||
private VolumeRepository volumeRepository;
|
||||
|
||||
@Autowired
|
||||
private ComicRepository comicRepository;
|
||||
|
||||
@Autowired
|
||||
private ComicService comicService;
|
||||
|
||||
@Test
|
||||
void testFindByComic() {
|
||||
Comic comic = TestConstants.getComicWithoutReferences(comicService);
|
||||
assertEquals(0, comic.getVolumes().size());
|
||||
Volume volume = new Volume();
|
||||
volume.setName(TestConstants.VOLUME_NAME);
|
||||
volume.setComic(comic);
|
||||
Volume savedInstance = volumeRepository.save(volume);
|
||||
assertNotNull(savedInstance);
|
||||
|
||||
List<Volume> found = volumeRepository.findByComic(comic);
|
||||
assertEquals(1, found.size());
|
||||
|
||||
comicService.deleteVolume(found.get(0));
|
||||
assertEquals(0, comic.getVolumes().size());
|
||||
assertEquals(TestConstants.VOLUME_COUNT, volumeRepository.count());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFindByName() {
|
||||
Comic comic = TestConstants.getComicWithoutReferences(comicService);
|
||||
assertEquals(0, comic.getVolumes().size());
|
||||
Volume volume = new Volume();
|
||||
volume.setName(TestConstants.VOLUME_NAME);
|
||||
volume.setComic(comic);
|
||||
Volume savedInstance = volumeRepository.save(volume);
|
||||
assertNotNull(savedInstance);
|
||||
|
||||
List<Volume> found = volumeRepository.findByName(TestConstants.VOLUME_NAME);
|
||||
assertEquals(1, found.size());
|
||||
|
||||
comicService.deleteVolume(found.get(0));
|
||||
assertEquals(0, comic.getVolumes().size());
|
||||
assertEquals(TestConstants.VOLUME_COUNT, volumeRepository.count());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package de.thpeetz.kontor.comics.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.transaction.TransactionSystemException;
|
||||
|
||||
import de.thpeetz.kontor.comics.TestConstants;
|
||||
import de.thpeetz.kontor.comics.services.ComicService;
|
||||
|
||||
@SpringBootTest
|
||||
class VolumeTest {
|
||||
|
||||
@Autowired
|
||||
private VolumeRepository volumeRepository;
|
||||
|
||||
@Autowired
|
||||
private ComicRepository comicRepository;
|
||||
|
||||
@Autowired
|
||||
private ComicService comicService;
|
||||
|
||||
@Test
|
||||
void checkInitialDataLoad() {
|
||||
assertEquals(TestConstants.VOLUME_COUNT, volumeRepository.count());
|
||||
}
|
||||
|
||||
@Test
|
||||
void exceptionThrownWhenSavingVolumeWithEmptyName() {
|
||||
Comic comic = TestConstants.getComicWithoutReferences(comicService);
|
||||
Volume volume = new Volume();
|
||||
volume.setComic(comic);
|
||||
assertThrows(TransactionSystemException.class, () -> {
|
||||
volumeRepository.save(volume);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void exceptionThrownWhenSavingVolumeWithoutComic() {
|
||||
Volume volume = new Volume();
|
||||
volume.setName(TestConstants.VOLUME_NAME);
|
||||
assertThrows(TransactionSystemException.class, () -> {
|
||||
volumeRepository.save(volume);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void saveVolume() {
|
||||
Comic comic = TestConstants.getComicWithoutReferences(comicService);
|
||||
assertEquals(0, comic.getVolumes().size());
|
||||
Volume volume = new Volume();
|
||||
volume.setName(TestConstants.VOLUME_NAME);
|
||||
volume.setComic(comic);
|
||||
Volume savedInstance = volumeRepository.save(volume);
|
||||
assertNotNull(savedInstance);
|
||||
comicService.deleteVolume(savedInstance);
|
||||
assertEquals(0, comic.getVolumes().size());
|
||||
assertEquals(TestConstants.VOLUME_COUNT, volumeRepository.count());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package de.thpeetz.kontor.comics.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import de.thpeetz.kontor.comics.TestConstants;
|
||||
|
||||
@SpringBootTest
|
||||
class WorktypeRepositoryTest {
|
||||
|
||||
@Autowired
|
||||
private WorktypeRepository worktypeRepository;
|
||||
|
||||
@Test
|
||||
void findWorktypeByName() {
|
||||
Worktype found = worktypeRepository.findByName("Writer");
|
||||
assertNotNull(found);
|
||||
Worktype notFound = worktypeRepository.findByName("er");
|
||||
assertNull(notFound);
|
||||
}
|
||||
|
||||
@Test
|
||||
void findWorktypeByNameIgnoreCase() {
|
||||
List<Worktype> worktypes = worktypeRepository.findByNameIgnoreCase("Writer".toLowerCase());
|
||||
assertNotNull(worktypes);
|
||||
assertEquals(1, worktypes.size());
|
||||
assertEquals("Writer", worktypes.get(0).getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
void searchWorktype() {
|
||||
List<Worktype> worktypes = worktypeRepository.search("er");
|
||||
assertEquals(3, worktypes.size());
|
||||
assertTrue(worktypes.stream().map(worktype -> worktype.getName()).collect(Collectors.toList()).contains("Writer"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package de.thpeetz.kontor.comics.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
import org.springframework.orm.jpa.JpaSystemException;
|
||||
import org.springframework.transaction.TransactionSystemException;
|
||||
|
||||
import de.thpeetz.kontor.comics.TestConstants;
|
||||
|
||||
@SpringBootTest
|
||||
@TestMethodOrder(OrderAnnotation.class)
|
||||
class WorktypeTest {
|
||||
|
||||
@Autowired
|
||||
private WorktypeRepository worktypeRepository;
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void checkInitialDataLoad() {
|
||||
List<Worktype> worktypes = worktypeRepository.findAll();
|
||||
assertEquals(3, worktypes.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
void findWorktypeByName() {
|
||||
Worktype found = worktypeRepository.findByName(TestConstants.WORKTYPE_INKER);
|
||||
assertNotNull(found);
|
||||
assertEquals(TestConstants.WORKTYPE_INKER, found.getName());
|
||||
Worktype notFound = worktypeRepository.findByName("er");
|
||||
assertNull(notFound);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
void throwExceptionWhenArtistSavedWithEmptyName() {
|
||||
Worktype worktype1 = new Worktype();
|
||||
assertThrows(TransactionSystemException.class, () -> {
|
||||
worktypeRepository.save(worktype1);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
void saveWorktypeWithIdenticalName() {
|
||||
Worktype worktype1 = new Worktype();
|
||||
worktype1.setName(TestConstants.WORKTYPE_NAME);
|
||||
worktypeRepository.save(worktype1);
|
||||
Worktype worktype2 = new Worktype();
|
||||
worktype2.setName(TestConstants.WORKTYPE_NAME);
|
||||
assertThrows(DataIntegrityViolationException.class, () -> {
|
||||
worktypeRepository.save(worktype2);
|
||||
});
|
||||
worktypeRepository.delete(worktype1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(5)
|
||||
void saveWorktype() {
|
||||
Worktype worktype = new Worktype();
|
||||
worktype.setName(TestConstants.WORKTYPE_NAME);
|
||||
worktypeRepository.save(worktype);
|
||||
assertEquals(TestConstants.WORKTYPE_COUNT + 1, worktypeRepository.count());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(6)
|
||||
void deleteWorktype() {
|
||||
Worktype worktype = worktypeRepository.findByName(TestConstants.WORKTYPE_NAME);
|
||||
assertNotNull(worktype);
|
||||
worktypeRepository.delete(worktype);
|
||||
assertEquals(TestConstants.WORKTYPE_COUNT, worktypeRepository.count());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,350 @@
|
||||
package de.thpeetz.kontor.comics.services;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import de.thpeetz.kontor.comics.TestConstants;
|
||||
import de.thpeetz.kontor.comics.data.Artist;
|
||||
import de.thpeetz.kontor.comics.data.Comic;
|
||||
import de.thpeetz.kontor.comics.data.ComicWork;
|
||||
import de.thpeetz.kontor.comics.data.Issue;
|
||||
import de.thpeetz.kontor.comics.data.Publisher;
|
||||
import de.thpeetz.kontor.comics.data.StoryArc;
|
||||
import de.thpeetz.kontor.comics.data.TradePaperback;
|
||||
import de.thpeetz.kontor.comics.data.Volume;
|
||||
import de.thpeetz.kontor.comics.data.Worktype;
|
||||
|
||||
@SpringBootTest
|
||||
@TestMethodOrder(OrderAnnotation.class)
|
||||
class ComicServiceTest {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ComicServiceTest.class);
|
||||
@Autowired
|
||||
private ComicService comicService;
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void testFindAllArtists() {
|
||||
assertEquals(TestConstants.ARTIST_COUNT, comicService.findAllArtists(null).size());
|
||||
assertEquals(1, comicService.findAllArtists("Turn").size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void testFindArtistByName() {
|
||||
assertNull(comicService.findArtistByName("Lee, Stan"));
|
||||
Artist artist = comicService.findArtistByName("Turner, Michael");
|
||||
assertNotNull(artist);
|
||||
assertNotNull(artist.getComicWorks());
|
||||
assertFalse(artist.getComicWorks().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
void testSaveArtist() {
|
||||
Artist artist = new Artist();
|
||||
artist.setName(TestConstants.ARTIST_NAME);
|
||||
comicService.saveArtist(artist);
|
||||
assertEquals(TestConstants.ARTIST_COUNT + 1, comicService.findAllArtists(null).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
void testDeleteArtist() {
|
||||
List<Artist> artists = comicService.findAllArtists(TestConstants.ARTIST_NAME);
|
||||
assertEquals(1, artists.size());
|
||||
comicService.deleteArtist(artists.get(0));
|
||||
assertEquals(TestConstants.ARTIST_COUNT, comicService.findAllArtists(null).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
void testFindAllPublishers() {
|
||||
assertEquals(TestConstants.PUBLISHER_COUNT, comicService.findAllPublishers(null).size());
|
||||
assertEquals(1, comicService.findAllPublishers("Cow").size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
void testFindPublisherByName() {
|
||||
Publisher publisher = comicService.findPublisherByName("Marvel");
|
||||
assertNotNull(publisher);
|
||||
assertNotNull(publisher.getComics());
|
||||
assertEquals(TestConstants.MARVEL_COMIC_COUNT, publisher.getComics().size());
|
||||
assertNull(comicService.findPublisherByName(TestConstants.PUBLISHER_NAME));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(5)
|
||||
void testSavePublisher() {
|
||||
Publisher publisher = new Publisher();
|
||||
publisher.setName(TestConstants.PUBLISHER_NAME);
|
||||
comicService.savePublisher(publisher);
|
||||
assertEquals(TestConstants.PUBLISHER_COUNT + 1, comicService.findAllPublishers(null).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(6)
|
||||
void testDeletePublisher() {
|
||||
List<Publisher> publishers = comicService.findAllPublishers(TestConstants.PUBLISHER_NAME);
|
||||
assertEquals(1, publishers.size());
|
||||
comicService.deletePublisher(publishers.get(0));
|
||||
assertEquals(TestConstants.PUBLISHER_COUNT, comicService.findAllPublishers(null).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(7)
|
||||
void testFindAllWorktypes() {
|
||||
assertEquals(TestConstants.WORKTYPE_COUNT, comicService.findAllWorktypes(null).size());
|
||||
assertEquals(1, comicService.findAllWorktypes("ite").size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(7)
|
||||
void testFindWorktypeByName() {
|
||||
Worktype worktype = comicService.findWorktypeByName("Writer");
|
||||
assertNotNull(worktype);
|
||||
assertNotNull(worktype.getComicWorks());
|
||||
assertFalse(worktype.getComicWorks().isEmpty());
|
||||
worktype = comicService.findWorktypeByName("Inker");
|
||||
assertNotNull(worktype);
|
||||
assertNotNull(worktype.getComicWorks());
|
||||
assertTrue(worktype.getComicWorks().isEmpty());
|
||||
assertNull(comicService.findWorktypeByName(TestConstants.WORKTYPE_NAME));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(8)
|
||||
void testSaveWorktype() {
|
||||
Worktype worktype = new Worktype();
|
||||
worktype.setName(TestConstants.WORKTYPE_NAME);
|
||||
comicService.saveWorktype(worktype);
|
||||
assertEquals(TestConstants.WORKTYPE_COUNT + 1, comicService.findAllWorktypes(null).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(9)
|
||||
void testDeleteWorktype() {
|
||||
List<Worktype> worktypes = comicService.findAllWorktypes(TestConstants.WORKTYPE_NAME);
|
||||
assertEquals(1, worktypes.size());
|
||||
comicService.deleteWorktype(worktypes.get(0));
|
||||
assertEquals(TestConstants.WORKTYPE_COUNT, comicService.findAllWorktypes(null).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(10)
|
||||
void testFindComicByTitle() {
|
||||
assertNull(comicService.findComicByTitle(null));
|
||||
assertNotNull(comicService.findComicByTitle("Danger Girl"));
|
||||
assertNull(comicService.findComicByTitle("x-men"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(11)
|
||||
void testSaveComic() {
|
||||
Publisher marvel = comicService.findAllPublishers("Marvel").get(0);
|
||||
Comic comic = new Comic();
|
||||
comic.setTitle(TestConstants.COMIC_TITLE);
|
||||
comic.setPublisher(marvel);
|
||||
comicService.saveComic(comic);
|
||||
assertEquals(TestConstants.COMIC_COUNT + 1, comicService.findAllComics(null).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(12)
|
||||
void testDeleteComic() {
|
||||
assertEquals(TestConstants.COMIC_COUNT + 1, comicService.findAllComics(null).size());
|
||||
List<Comic> comics = comicService.findAllComics(TestConstants.COMIC_TITLE);
|
||||
assertEquals(1, comics.size());
|
||||
Comic comic = comicService.findComicByTitle(TestConstants.COMIC_TITLE);
|
||||
assertNotNull(comic);
|
||||
comicService.deleteComic(comic);
|
||||
Publisher marvel = comicService.findPublisherByName("Marvel");
|
||||
assertNotNull(marvel.getComics());
|
||||
assertEquals(TestConstants.MARVEL_COMIC_COUNT, marvel.getComics().size());
|
||||
assertEquals(0, comicService.findAllComics(TestConstants.COMIC_TITLE).size());
|
||||
assertEquals(TestConstants.COMIC_COUNT, comicService.findAllComics(null).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(13)
|
||||
void testFindAllIssues() {
|
||||
assertEquals(TestConstants.ISSUE_COUNT, comicService.findAllIssues().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(14)
|
||||
void testFindAllIssuesForComic() {
|
||||
Comic comic = TestConstants.getComicWithIssues(comicService);
|
||||
List<Issue> issues = comicService.findAllIssuesForComic(comic);
|
||||
assertEquals(12, issues.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(15)
|
||||
void testSaveIssue() {
|
||||
Comic comic = TestConstants.getComicWithoutReferences(comicService);
|
||||
Issue issue = new Issue();
|
||||
issue.setComic(comic);
|
||||
issue.setIssueNumber(TestConstants.ISSUE_ISSUENUMBER);
|
||||
comicService.saveIssue(issue);
|
||||
assertEquals(TestConstants.ISSUE_COUNT + 1, comicService.findAllIssues().size());
|
||||
comic = TestConstants.getComicWithoutReferences(comicService);
|
||||
assertNotNull(comic.getIssues());
|
||||
assertEquals(1, comic.getIssues().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(16)
|
||||
void testDeleteIssue() {
|
||||
Comic comic = TestConstants.getComicWithoutReferences(comicService);
|
||||
List<Issue> issues = comicService.findAllIssuesForComic(comic);
|
||||
assertEquals(1, issues.size());
|
||||
comicService.deleteIssue(issues.get(0));
|
||||
assertEquals(TestConstants.ISSUE_COUNT, comicService.findAllIssues().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(17)
|
||||
void testFindAllTradePaperbacks() {
|
||||
assertEquals(TestConstants.TRADEPAPERBACK_COUNT, comicService.findAllTradePaperbacks(null).size());
|
||||
assertEquals(7, comicService.findAllTradePaperbacks("of").size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(18)
|
||||
void testSaveTradePaperBack() {
|
||||
Comic comic = TestConstants.getComicWithoutReferences(comicService);
|
||||
TradePaperback tradePaperback = new TradePaperback();
|
||||
tradePaperback.setComic(comic);
|
||||
tradePaperback.setName(TestConstants.TRADEPAPERBACK_NAME);
|
||||
comicService.saveTradePaperBack(tradePaperback);
|
||||
assertEquals(TestConstants.TRADEPAPERBACK_COUNT + 1, comicService.findAllTradePaperbacks(null).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(19)
|
||||
void testDeleteTradePaperBack() {
|
||||
List<TradePaperback> tradePaperbacks = comicService.findAllTradePaperbacks(TestConstants.TRADEPAPERBACK_NAME);
|
||||
assertEquals(1, tradePaperbacks.size());
|
||||
comicService.deleteTradePaperBack(tradePaperbacks.get(0));
|
||||
assertEquals(TestConstants.TRADEPAPERBACK_COUNT, comicService.findAllTradePaperbacks(null).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(20)
|
||||
void testFindAllStoryArcs() {
|
||||
assertEquals(TestConstants.STORYARC_COUNT, comicService.findAllStoryArcs().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(21)
|
||||
void testFindAllStoryArcsForComic() {
|
||||
assertEquals(TestConstants.STORYARC_COUNT, comicService.findAllStoryArcsForComic(null).size());
|
||||
Comic comic = TestConstants.getComicWithStoryArcs(comicService);
|
||||
assertEquals(3, comicService.findAllStoryArcsForComic(comic).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(22)
|
||||
void testSaveStoryArc() {
|
||||
Comic comic = TestConstants.getComicWithoutReferences(comicService);
|
||||
StoryArc storyArc = new StoryArc();
|
||||
storyArc.setName(TestConstants.STORYARC_NAME);
|
||||
storyArc.setComic(comic);
|
||||
comicService.saveStoryArc(storyArc);
|
||||
assertEquals(TestConstants.STORYARC_COUNT + 1, comicService.findAllStoryArcs().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(23)
|
||||
void testDeleteStoryArc() {
|
||||
Comic comic = TestConstants.getComicWithoutReferences(comicService);
|
||||
List<StoryArc> storyArcs = comicService.findAllStoryArcsForComic(comic);
|
||||
assertEquals(1, storyArcs.size());
|
||||
comicService.deleteStoryArc(storyArcs.get(0));
|
||||
assertEquals(TestConstants.STORYARC_COUNT, comicService.findAllStoryArcs().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(24)
|
||||
void testFindAllVolumes() {
|
||||
assertEquals(TestConstants.VOLUME_COUNT, comicService.findAllVolumes().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(25)
|
||||
void testSaveVolume() {
|
||||
Comic comic = TestConstants.getComicWithoutReferences(comicService);
|
||||
Volume volume = new Volume();
|
||||
volume.setName(TestConstants.VOLUME_NAME);
|
||||
volume.setComic(comic);
|
||||
comicService.saveVolume(volume);
|
||||
assertEquals(TestConstants.VOLUME_COUNT + 1, comicService.findAllVolumes().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(26)
|
||||
void testFindAllVolumesForComic() {
|
||||
Comic comic = TestConstants.getComicWithoutReferences(comicService);
|
||||
List<Volume> volumes = comicService.findAllVolumesForComic(comic);
|
||||
assertEquals(1, volumes.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(27)
|
||||
void testDeleteVolume() {
|
||||
Comic comic = TestConstants.getComicWithoutReferences(comicService);
|
||||
List<Volume> volumes = comicService.findAllVolumesForComic(comic);
|
||||
comicService.deleteVolume(volumes.get(0));
|
||||
assertEquals(TestConstants.VOLUME_COUNT, comicService.findAllVolumes().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(28)
|
||||
void testFindAllComicWorks() {
|
||||
assertEquals(TestConstants.COMICWORK_COUNT, comicService.findAllComicWorks().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(29)
|
||||
void testSaveComicWork() {
|
||||
Comic comic = TestConstants.getComicWithoutReferences(comicService);
|
||||
Artist artist = TestConstants.getArtistWithoutReferences(comicService);
|
||||
Worktype worktype = TestConstants.getWorktypeWithoutReferences(comicService);
|
||||
ComicWork comicWork = new ComicWork();
|
||||
comicWork.setComic(comic);
|
||||
comicWork.setArtist(artist);
|
||||
comicWork.setWorkType(worktype);
|
||||
comicService.saveComicWork(comicWork);
|
||||
assertEquals(TestConstants.COMICWORK_COUNT + 1, comicService.findAllComicWorks().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(30)
|
||||
void testDeleteComicWork() {
|
||||
Comic comic = TestConstants.getComicWithoutReferences(comicService);
|
||||
Artist artist = TestConstants.getArtistWithoutReferences(comicService);
|
||||
Worktype worktype = TestConstants.getWorktypeWithoutReferences(comicService);
|
||||
List<ComicWork> comicWorks = comic.getComicWorks();
|
||||
assertNotNull(comicWorks);
|
||||
assertNotNull(artist.getComicWorks());
|
||||
assertNotNull(worktype.getComicWorks());
|
||||
assertEquals(1, comicWorks.size());
|
||||
assertEquals(1, artist.getComicWorks().size());
|
||||
assertEquals(1, worktype.getComicWorks().size());
|
||||
ComicWork comicWork = comicWorks.get(0);
|
||||
comicService.deleteComicWork(comicWork);
|
||||
assertEquals(TestConstants.COMICWORK_COUNT, comicService.findAllComicWorks().size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package de.thpeetz.kontor.media;
|
||||
|
||||
public class TestConstants {
|
||||
public static final String URL = "https://example.com/link.mp4";
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package de.thpeetz.kontor.media.data;
|
||||
|
||||
import de.thpeetz.kontor.media.services.MediaArticleService;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
|
||||
@SpringBootTest
|
||||
public class MediaArticleTest {
|
||||
|
||||
@Autowired
|
||||
private MediaArticleRepository mediaArticleRepository;
|
||||
|
||||
@Test
|
||||
void checkInitialLoad() {
|
||||
assertTrue(mediaArticleRepository.findAll().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void checkDefaultValues() {
|
||||
MediaArticle mediaArticle = new MediaArticle();
|
||||
assertNull(mediaArticle.getUrl());
|
||||
assertNull(mediaArticle.getTitle());
|
||||
assertNull(mediaArticle.getCreatedDate());
|
||||
assertNull(mediaArticle.getLastModifiedDate());
|
||||
assertNull(mediaArticle.getId());
|
||||
assertFalse(mediaArticle.isReview());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package de.thpeetz.kontor.media.data;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@SpringBootTest
|
||||
public class MediaFileTest {
|
||||
|
||||
@Autowired
|
||||
private MediaFileRepository mediaFileRepository;
|
||||
|
||||
@Test
|
||||
void checkInitialDataLoad() {
|
||||
List<MediaFile> mediaFileList = mediaFileRepository.findAll();
|
||||
assertTrue(mediaFileList.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void checkDefaultValues() {
|
||||
MediaFile mediaFile = new MediaFile();
|
||||
assertNull(mediaFile.getUrl());
|
||||
assertNull(mediaFile.getTitle());
|
||||
assertNull(mediaFile.getFileName());
|
||||
assertNull(mediaFile.getPath());
|
||||
assertNull(mediaFile.getCloudLink());
|
||||
assertNull(mediaFile.getCreatedDate());
|
||||
assertNull(mediaFile.getLastModifiedDate());
|
||||
assertNull(mediaFile.getId());
|
||||
assertFalse(mediaFile.isReview());
|
||||
assertFalse(mediaFile.isShouldDownload());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package de.thpeetz.kontor.media.data;
|
||||
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
|
||||
@SpringBootTest
|
||||
public class MediaVideoTest {
|
||||
|
||||
@Autowired
|
||||
private MediaVideoRepository mediaVideoRepository;
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void checkInitialLoad() {
|
||||
assertTrue(mediaVideoRepository.findAll().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
void checkDefaultValues() {
|
||||
MediaVideo mediaVideo = new MediaVideo();
|
||||
assertNull(mediaVideo.getUrl());
|
||||
assertNull(mediaVideo.getTitle());
|
||||
assertNull(mediaVideo.getFileName());
|
||||
assertNull(mediaVideo.getPath());
|
||||
assertNull(mediaVideo.getCloudLink());
|
||||
assertNull(mediaVideo.getCreatedDate());
|
||||
assertNull(mediaVideo.getLastModifiedDate());
|
||||
assertNull(mediaVideo.getId());
|
||||
assertFalse(mediaVideo.isReview());
|
||||
assertFalse(mediaVideo.isShouldDownload());
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
package de.thpeetz.kontor.media.services;
|
||||
|
||||
import de.thpeetz.kontor.media.TestConstants;
|
||||
import de.thpeetz.kontor.media.data.MediaArticle;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@Slf4j
|
||||
@SpringBootTest
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
class MediaArticleServiceTest {
|
||||
|
||||
@Autowired
|
||||
MediaArticleService mediaArticleService;
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void findAllMediaArticles() {
|
||||
assertTrue(mediaArticleService.findAllMediaArticles(null).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
void saveMediaArticle() {
|
||||
int mediaArticleCount = mediaArticleService.findAllMediaArticles(null).size();
|
||||
MediaArticle mediaArticle = new MediaArticle();
|
||||
mediaArticle.setUrl(TestConstants.URL);
|
||||
mediaArticleService.saveMediaArticle(mediaArticle);
|
||||
assertEquals(++mediaArticleCount, mediaArticleService.findAllMediaArticles(null).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
void deleteMediaArticle() {
|
||||
int mediaArticleCount = mediaArticleService.findAllMediaArticles(null).size();
|
||||
List<MediaArticle> mediaArticleList = mediaArticleService.findAllMediaArticles(TestConstants.URL);
|
||||
assertEquals(1, mediaArticleService.findAllMediaArticles(null).size());
|
||||
mediaArticleService.deleteMediaArticle(mediaArticleList.get(0));
|
||||
assertEquals(--mediaArticleCount, mediaArticleService.findAllMediaArticles(null).size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package de.thpeetz.kontor.media.services;
|
||||
|
||||
import de.thpeetz.kontor.media.TestConstants;
|
||||
import de.thpeetz.kontor.media.data.MediaFile;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@SpringBootTest
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
public class MediaFileServiceTest {
|
||||
|
||||
@Autowired
|
||||
private MediaFileService mediaFileService;
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void testFindAllMediaFiles() {
|
||||
assertTrue(mediaFileService.findAllMediaFiles(null).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
void testSaveMediaFile() {
|
||||
int mediaFileCount = mediaFileService.findAllMediaFiles(null).size();
|
||||
MediaFile mediaFile = new MediaFile();
|
||||
mediaFile.setUrl(TestConstants.URL);
|
||||
mediaFileService.saveMediaFile(mediaFile);
|
||||
assertEquals(mediaFileCount +1, mediaFileService.findAllMediaFiles(null).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
void testDeleteMediaFile() {
|
||||
int mediaFileCount = mediaFileService.findAllMediaFiles(null).size();
|
||||
List<MediaFile> mediaFileList = mediaFileService.findAllMediaFiles(TestConstants.URL);
|
||||
assertEquals(1, mediaFileList.size());
|
||||
mediaFileService.deleteMediaFile(mediaFileList.get(0));
|
||||
assertEquals(--mediaFileCount, mediaFileService.findAllMediaFiles(null).size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package de.thpeetz.kontor.media.services;
|
||||
|
||||
import de.thpeetz.kontor.media.TestConstants;
|
||||
import de.thpeetz.kontor.media.data.MediaArticle;
|
||||
import de.thpeetz.kontor.media.data.MediaVideo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@Slf4j
|
||||
@SpringBootTest
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
public class MediaVideoServiceTest {
|
||||
|
||||
@Autowired
|
||||
private MediaVideoService mediaVideoService;
|
||||
|
||||
@Test
|
||||
void findAllMediaVideos() {
|
||||
assertTrue(mediaVideoService.findAllMediaVideos(null).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void saveMediaVideo() {
|
||||
int mediaVideoCount = mediaVideoService.findAllMediaVideos(null).size();
|
||||
MediaVideo mediaVideo = new MediaVideo();
|
||||
mediaVideo.setUrl(TestConstants.URL);
|
||||
mediaVideoService.saveMediaVideo(mediaVideo);
|
||||
assertEquals(++mediaVideoCount, mediaVideoService.findAllMediaVideos(null).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void deleteMediaVideo() {
|
||||
int mediaVideoCount = mediaVideoService.findAllMediaVideos(null).size();
|
||||
List<MediaVideo> mediaVideoList = mediaVideoService.findAllMediaVideos(TestConstants.URL);
|
||||
assertEquals(1, mediaVideoList.size());
|
||||
mediaVideoService.deleteMediaVideo(mediaVideoList.get(0));
|
||||
assertEquals(--mediaVideoCount, mediaVideoService.findAllMediaVideos(null).size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package de.thpeetz.kontor.tysc;
|
||||
|
||||
public class TestConstants {
|
||||
|
||||
public static final Integer CARD_COUNT = 10;
|
||||
public static final Integer CARD_CARDNUMBER = 999;
|
||||
public static final Integer CARD_YEAR = 2000;
|
||||
public static final Integer CARDSET_COUNT = 15;
|
||||
public static final Integer FOOTBALL_TEAM_COUNT = 33;
|
||||
public static final Integer FOOTBALL_POSITION_COUNT = 25;
|
||||
public static final Integer PLAYER_COUNT = 38;
|
||||
public static final Integer PLAYER_CHRIS_COUNT = 3;
|
||||
public static final Integer POSITION_COUNT = 44;
|
||||
public static final Integer POSITION_CENTER_COUNT = 3;
|
||||
public static final Integer ROOSTER_COUNT = 11;
|
||||
public static final Integer ROOSTER_YEAR = 1900;
|
||||
public static final Integer SPORT_COUNT = 4;
|
||||
public static final Integer TEAM_COUNT = 122;
|
||||
public static final Integer VENDOR_COUNT = 9;
|
||||
public static final String CARDSET_NAME = "CardSet";
|
||||
public static final String CARDSET_MYSTIQUE_NAME = "Mystique";
|
||||
public static final String DOLPHINS_NAME = "Miami Dolphins";
|
||||
public static final Object DOLPHINS_SHORT = "Dolphins";
|
||||
public static final String FOOTBALL_NAME = "Football";
|
||||
public static final String PLAYER_FIRSTNAME = "FirstName";
|
||||
public static final String PLAYER_LASTNAME = "LastName";
|
||||
public static final String PLAYER_CHRIS_NAME = "Chris";
|
||||
public static final String POSITION_CENTER = "Center";
|
||||
public static final String POSITION_NAME = "Position";
|
||||
public static final String POSITION_SHORTNAME = "POS";
|
||||
public static final String QUARTERBACK_NAME = "Quarterback";
|
||||
public static final String QUARTERBACK_SHORTNAME = "QB";
|
||||
public static final String SPORT_NAME = "Sport";
|
||||
public static final String TEAM_NAME = "Musterstadt Team";
|
||||
public static final String TEAM_SHORTNAME = "Team";
|
||||
public static final String TOPPS_NAME = "Topps";
|
||||
public static final String VENDOR_FLEER = "Fleer";
|
||||
public static final String VENDOR_NAME = "Vendor";
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package de.thpeetz.kontor.tysc.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class CardRepositoryTest {
|
||||
|
||||
@Autowired
|
||||
private CardRepository cardRepository;
|
||||
|
||||
@Test
|
||||
void testSearchByFields() {
|
||||
List<Card> cards = cardRepository.findAll();
|
||||
Card existingCard = cards.get(3);
|
||||
Vendor vendor = existingCard.getVendor();
|
||||
CardSet cardSet = existingCard.getCardSet();
|
||||
Rooster rooster = existingCard.getRooster();
|
||||
int cardNumber = existingCard.getCardNumber();
|
||||
int year = existingCard.getYear();
|
||||
Card card = cardRepository.search(vendor, cardSet, rooster, cardNumber, year);
|
||||
assertNotNull(card);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSearch() {
|
||||
assertEquals(2, cardRepository.search("2").size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package de.thpeetz.kontor.tysc.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import de.thpeetz.kontor.tysc.TestConstants;
|
||||
|
||||
@SpringBootTest
|
||||
class CardSetRepositoryTest {
|
||||
|
||||
@Autowired
|
||||
private CardSetRepository cardSetRepository;
|
||||
|
||||
@Autowired
|
||||
private VendorRepository vendorRepository;
|
||||
|
||||
@Test
|
||||
void testFindByName() {
|
||||
List<CardSet> cardSets = cardSetRepository.findByName(TestConstants.CARDSET_MYSTIQUE_NAME);
|
||||
assertEquals(1, cardSets.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFindByNameAndVendor() {
|
||||
Vendor fleer = vendorRepository.findByName(TestConstants.VENDOR_FLEER);
|
||||
assertNotNull(fleer);
|
||||
CardSet cardSet = cardSetRepository.findByNameAndVendor(TestConstants.CARDSET_MYSTIQUE_NAME, fleer);
|
||||
assertNotNull(cardSet);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSearch() {
|
||||
List<CardSet> cardSets = cardSetRepository.search("SP");
|
||||
assertEquals(3, cardSets.size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package de.thpeetz.kontor.tysc.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import de.thpeetz.kontor.tysc.TestConstants;
|
||||
import de.thpeetz.kontor.tysc.services.CardService;
|
||||
|
||||
@SpringBootTest
|
||||
class CardSetTest {
|
||||
|
||||
@Autowired
|
||||
private CardService cardService;
|
||||
|
||||
@Test
|
||||
void checkInitialDataLoad() {
|
||||
assertEquals(TestConstants.CARDSET_COUNT, cardService.findAllCardSets(null).size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package de.thpeetz.kontor.tysc.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import de.thpeetz.kontor.tysc.TestConstants;
|
||||
import de.thpeetz.kontor.tysc.services.CardService;
|
||||
|
||||
@SpringBootTest
|
||||
class CardTest {
|
||||
|
||||
@Autowired
|
||||
private CardService cardService;
|
||||
|
||||
@Test
|
||||
void checkInitialDataLoad() {
|
||||
assertEquals(TestConstants.CARD_COUNT, cardService.findAllCards(null).size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package de.thpeetz.kontor.tysc.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import de.thpeetz.kontor.tysc.TestConstants;
|
||||
|
||||
@SpringBootTest
|
||||
class FieldPositionRepositoryTest {
|
||||
|
||||
@Autowired
|
||||
private FieldPositionRepository fieldPositionRepository;
|
||||
|
||||
@Autowired
|
||||
private SportRepository sportRepository;
|
||||
|
||||
@Test
|
||||
void testFindByShortName() {
|
||||
FieldPosition position = fieldPositionRepository.findByShortName(TestConstants.QUARTERBACK_SHORTNAME);
|
||||
assertNotNull(position);
|
||||
assertEquals(TestConstants.QUARTERBACK_NAME, position.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFindByShortNameAndSport() {
|
||||
Sport sport = sportRepository.findByName(TestConstants.FOOTBALL_NAME);
|
||||
FieldPosition position = fieldPositionRepository.findByShortNameAndSport(TestConstants.QUARTERBACK_SHORTNAME, sport);
|
||||
assertNotNull(position);
|
||||
assertEquals(TestConstants.QUARTERBACK_NAME, position.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFindByShortNameIgnoreCase() {
|
||||
List<FieldPosition> positions = fieldPositionRepository
|
||||
.findByShortNameIgnoreCase(TestConstants.QUARTERBACK_SHORTNAME.toLowerCase());
|
||||
assertNotNull(positions);
|
||||
assertEquals(1, positions.size());
|
||||
assertEquals(TestConstants.QUARTERBACK_NAME, positions.get(0).getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFindBySport() {
|
||||
Sport sport = sportRepository.findByName(TestConstants.FOOTBALL_NAME);
|
||||
List<FieldPosition> positions = fieldPositionRepository.findBySport(sport);
|
||||
assertEquals(TestConstants.FOOTBALL_POSITION_COUNT, positions.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSearch() {
|
||||
List<FieldPosition> positions = fieldPositionRepository.search("back");
|
||||
assertEquals(8, positions.size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package de.thpeetz.kontor.tysc.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.transaction.TransactionSystemException;
|
||||
|
||||
import de.thpeetz.kontor.tysc.TestConstants;
|
||||
|
||||
@SpringBootTest
|
||||
class FieldPositionTest {
|
||||
|
||||
@Autowired
|
||||
private FieldPositionRepository fieldPositionRepository;
|
||||
|
||||
@Test
|
||||
void checkInitialDataLoad() {
|
||||
assertEquals(Integer.toUnsignedLong(TestConstants.POSITION_COUNT), fieldPositionRepository.count());
|
||||
}
|
||||
|
||||
@Test
|
||||
void throwExceptionWhenPositionSavedWithEmptyName() {
|
||||
FieldPosition fieldPosition = new FieldPosition();
|
||||
assertThrows(TransactionSystemException.class, () -> {
|
||||
fieldPositionRepository.save(fieldPosition);
|
||||
});
|
||||
fieldPosition.setName("Position");
|
||||
assertThrows(TransactionSystemException.class, () -> {
|
||||
fieldPositionRepository.save(fieldPosition);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void throwExceptionWhenPositionSavedWithExistingName() {
|
||||
FieldPosition existingFieldPosition = fieldPositionRepository.findAll().get(11);
|
||||
FieldPosition fieldPosition = new FieldPosition();
|
||||
fieldPosition.setName(existingFieldPosition.getName());
|
||||
assertThrows(TransactionSystemException.class, () -> {
|
||||
fieldPositionRepository.save(fieldPosition);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package de.thpeetz.kontor.tysc.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class PlayerRepositoryTest {
|
||||
|
||||
@Autowired
|
||||
private PlayerRepository playerRepository;
|
||||
|
||||
@Test
|
||||
void testFindByFirstNameAndLastName() {
|
||||
Player existingPlayer = playerRepository.findAll().get(11);
|
||||
String firstName = existingPlayer.getFirstName();
|
||||
String lastName = existingPlayer.getLastName();
|
||||
Player found = playerRepository.findByFirstNameAndLastName(firstName, lastName);
|
||||
assertEquals(existingPlayer.getFullName(), found.getFullName());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSearch() {
|
||||
List<Player> players = playerRepository.search("can");
|
||||
assertEquals(1, players.size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package de.thpeetz.kontor.tysc.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
import org.springframework.transaction.TransactionSystemException;
|
||||
|
||||
import de.thpeetz.kontor.tysc.TestConstants;
|
||||
|
||||
@SpringBootTest
|
||||
@TestMethodOrder(OrderAnnotation.class)
|
||||
class PlayerTest {
|
||||
|
||||
@Autowired
|
||||
private PlayerRepository playerRepository;
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void checkInitialDataLoad() {
|
||||
List<Player> players = playerRepository.findAll();
|
||||
assertEquals(TestConstants.PLAYER_COUNT, players.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
void throwExceptionWhenPlayerSavedWithEmptyName() {
|
||||
Player player = new Player();
|
||||
assertThrows(TransactionSystemException.class, () -> {
|
||||
playerRepository.save(player);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
void throwExceptionWhenPlayerSavedWithExistingName() {
|
||||
Player existingPlayer = playerRepository.findAll().get(10);
|
||||
assertNotNull(existingPlayer);
|
||||
Player player = new Player();
|
||||
player.setFirstName(existingPlayer.getFirstName());
|
||||
player.setLastName(existingPlayer.getLastName());
|
||||
assertThrows(DataIntegrityViolationException.class, () -> {
|
||||
playerRepository.save(player);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package de.thpeetz.kontor.tysc.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class RoosterRepositoryTest {
|
||||
|
||||
@Autowired
|
||||
private RoosterRepository roosterRepository;
|
||||
|
||||
@Test
|
||||
void testFindByReferences() {
|
||||
List<Rooster> roosters = roosterRepository.findAll();
|
||||
Rooster existingRooster = roosters.get(4);
|
||||
Team team = existingRooster.getTeam();
|
||||
Player player = existingRooster.getPlayer();
|
||||
FieldPosition position = existingRooster.getPosition();
|
||||
int year = existingRooster.getYear();
|
||||
Rooster rooster = roosterRepository.findByReferences(player, team, position, year);
|
||||
assertNotNull(rooster);
|
||||
assertEquals(existingRooster.getId(), rooster.getId());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package de.thpeetz.kontor.tysc.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
|
||||
import de.thpeetz.kontor.tysc.TestConstants;
|
||||
|
||||
@SpringBootTest
|
||||
class RoosterTest {
|
||||
|
||||
@Autowired
|
||||
private RoosterRepository roosterRepository;
|
||||
|
||||
@Test
|
||||
void checkInitialDataLoad() {
|
||||
List<Rooster> roosters = roosterRepository.findAll();
|
||||
assertEquals(TestConstants.ROOSTER_COUNT, roosters.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void checkFetchingData() {
|
||||
Rooster rooster = roosterRepository.findAll().get(4);
|
||||
assertNotNull(rooster.getTeam());
|
||||
assertNotNull(rooster.getPlayer());
|
||||
assertNotNull(rooster.getPosition());
|
||||
}
|
||||
|
||||
@Test
|
||||
void exceptionThrownWhenSavingDuplicateRooster() {
|
||||
List<Rooster> roosters = roosterRepository.findAll();
|
||||
Rooster existingRooster = roosters.get(5);
|
||||
Rooster rooster = new Rooster();
|
||||
rooster.setPlayer(existingRooster.getPlayer());
|
||||
rooster.setTeam(existingRooster.getTeam());
|
||||
rooster.setPosition(existingRooster.getPosition());
|
||||
rooster.setYear(existingRooster.getYear());
|
||||
assertThrows(DataIntegrityViolationException.class, () -> {
|
||||
roosterRepository.save(rooster);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package de.thpeetz.kontor.tysc.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import de.thpeetz.kontor.tysc.TestConstants;
|
||||
|
||||
@SpringBootTest
|
||||
class SportRepositoryTest {
|
||||
|
||||
@Autowired
|
||||
private SportRepository sportRepository;
|
||||
|
||||
@Test
|
||||
void testFindByName() {
|
||||
Sport sport = sportRepository.findByName(TestConstants.FOOTBALL_NAME);
|
||||
assertNotNull(sport);
|
||||
assertEquals(TestConstants.FOOTBALL_TEAM_COUNT, sport.getTeams().size());
|
||||
assertEquals(TestConstants.FOOTBALL_POSITION_COUNT, sport.getPositions().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFindByNameIgnoreCase() {
|
||||
List<Sport> sports = sportRepository.findByNameIgnoreCase(TestConstants.FOOTBALL_NAME.toLowerCase());
|
||||
assertNotNull(sports);
|
||||
assertEquals(TestConstants.FOOTBALL_TEAM_COUNT, sports.get(0).getTeams().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSearch() {
|
||||
List<Sport> sports = sportRepository.search("ball");
|
||||
assertEquals(3, sports.size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package de.thpeetz.kontor.tysc.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
import org.springframework.transaction.TransactionSystemException;
|
||||
|
||||
import de.thpeetz.kontor.tysc.TestConstants;
|
||||
|
||||
@SpringBootTest
|
||||
class SportTest {
|
||||
|
||||
@Autowired
|
||||
private SportRepository sportRepository;
|
||||
|
||||
@Test
|
||||
void checkInitialDataLoad() {
|
||||
List<Sport> sports = sportRepository.findAll();
|
||||
assertEquals(TestConstants.SPORT_COUNT, sports.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void exceptionThrownWhenSavingSportWithEmptyName() {
|
||||
Sport sport = new Sport();
|
||||
assertThrows(TransactionSystemException.class, () -> {
|
||||
sportRepository.save(sport);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void exceptionThrownWhenSavingSportWithExistingName() {
|
||||
Sport existingSport = sportRepository.findAll().get(0);
|
||||
Sport sport = new Sport();
|
||||
sport.setName(existingSport.getName());
|
||||
assertThrows(DataIntegrityViolationException.class, () -> {
|
||||
sportRepository.save(sport);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package de.thpeetz.kontor.tysc.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import de.thpeetz.kontor.tysc.TestConstants;
|
||||
|
||||
@SpringBootTest
|
||||
class TeamRepositoryTest {
|
||||
|
||||
@Autowired
|
||||
private TeamRepository teamRepository;
|
||||
|
||||
@Test
|
||||
void testFindByName() {
|
||||
Team team = teamRepository.findByName(TestConstants.DOLPHINS_NAME);
|
||||
assertEquals(TestConstants.DOLPHINS_SHORT, team.getShortName());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFindByNameIgnoreCase() {
|
||||
List<Team> teams = teamRepository.findByNameIgnoreCase(TestConstants.DOLPHINS_NAME.toLowerCase());
|
||||
assertEquals(1, teams.size());
|
||||
assertEquals(TestConstants.DOLPHINS_SHORT, teams.get(0).getShortName());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSearch() {
|
||||
List<Team> teams = teamRepository.search("dol");
|
||||
assertEquals(1, teams.size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package de.thpeetz.kontor.tysc.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.transaction.TransactionSystemException;
|
||||
|
||||
import de.thpeetz.kontor.tysc.TestConstants;
|
||||
|
||||
@SpringBootTest
|
||||
class TeamTest {
|
||||
|
||||
@Autowired
|
||||
private TeamRepository teamRepository;
|
||||
|
||||
@Test
|
||||
void checkInitialDataLoad() {
|
||||
List<Team> teams = teamRepository.findAll();
|
||||
assertEquals(TestConstants.TEAM_COUNT, teams.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void throwExceptionWhenTeamSavedWithEmptyName() {
|
||||
Team team = new Team();
|
||||
assertThrows(TransactionSystemException.class, () -> {
|
||||
teamRepository.save(team);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void throwExceptionWhenTeamSavedWithoutSport() {
|
||||
Team team = new Team();
|
||||
team.setName(TestConstants.TEAM_NAME);
|
||||
assertThrows(TransactionSystemException.class, () -> {
|
||||
teamRepository.save(team);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void throwExceptionWhenTeamSavedWithExistingName() {
|
||||
Team existingTeam = teamRepository.findAll().get(11);
|
||||
Team team = new Team();
|
||||
team.setName(existingTeam.getName());
|
||||
team.setSport(existingTeam.getSport());
|
||||
assertThrows(TransactionSystemException.class, () -> {
|
||||
teamRepository.save(team);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package de.thpeetz.kontor.tysc.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import de.thpeetz.kontor.tysc.TestConstants;
|
||||
|
||||
@SpringBootTest
|
||||
class VendorRepositoryTest {
|
||||
|
||||
@Autowired
|
||||
private VendorRepository vendorRepository;
|
||||
|
||||
@Test
|
||||
void testFindByName() {
|
||||
Vendor vendor = vendorRepository.findByName(TestConstants.TOPPS_NAME);
|
||||
assertNotNull(vendor);
|
||||
assertEquals(TestConstants.TOPPS_NAME, vendor.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFindByNameIgnoreCase() {
|
||||
List<Vendor> vendors = vendorRepository.findByNameIgnoreCase(TestConstants.TOPPS_NAME.toLowerCase());
|
||||
assertNotNull(vendors);
|
||||
assertEquals(1, vendors.size());
|
||||
assertEquals(TestConstants.TOPPS_NAME, vendors.get(0).getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSearch() {
|
||||
List<Vendor> vendors = vendorRepository.search("pp");
|
||||
assertNotNull(vendors);
|
||||
assertEquals(2, vendors.size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package de.thpeetz.kontor.tysc.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
import org.springframework.transaction.TransactionSystemException;
|
||||
|
||||
import de.thpeetz.kontor.tysc.TestConstants;
|
||||
|
||||
@SpringBootTest
|
||||
class VendorTest {
|
||||
|
||||
@Autowired
|
||||
private VendorRepository vendorRepository;
|
||||
|
||||
@Test
|
||||
void checkInitialDataLoad() {
|
||||
List<Vendor> vendors = vendorRepository.findAll();
|
||||
assertEquals(TestConstants.VENDOR_COUNT, vendors.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void exceptionThrownWhenSavingVendortWithEmptyName() {
|
||||
Vendor vendor = new Vendor();
|
||||
assertThrows(TransactionSystemException.class, () -> {
|
||||
vendorRepository.save(vendor);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void exceptionThrownWhenSavingSportWithExistingName() {
|
||||
Vendor vendor = new Vendor();
|
||||
vendor.setName(TestConstants.TOPPS_NAME);
|
||||
assertThrows(DataIntegrityViolationException.class, () -> {
|
||||
vendorRepository.save(vendor);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package de.thpeetz.kontor.tysc.services;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import de.thpeetz.kontor.tysc.TestConstants;
|
||||
import de.thpeetz.kontor.tysc.data.Card;
|
||||
import de.thpeetz.kontor.tysc.data.CardSet;
|
||||
import de.thpeetz.kontor.tysc.data.Rooster;
|
||||
import de.thpeetz.kontor.tysc.data.Vendor;
|
||||
|
||||
@SpringBootTest
|
||||
@TestMethodOrder(OrderAnnotation.class)
|
||||
class CardServiceTest {
|
||||
|
||||
@Autowired
|
||||
private CardService cardService;
|
||||
|
||||
@Autowired
|
||||
private SportService sportService;
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void testFindAllVendors() {
|
||||
assertEquals(TestConstants.VENDOR_COUNT, cardService.findAllVendors(null).size());
|
||||
assertEquals(2, cardService.findAllVendors("pp").size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
void testSaveVendor() {
|
||||
Vendor vendor = new Vendor();
|
||||
vendor.setName(TestConstants.VENDOR_NAME);
|
||||
vendor = cardService.saveVendor(vendor);
|
||||
assertNotNull(vendor);
|
||||
assertEquals(TestConstants.VENDOR_COUNT + 1, cardService.findAllVendors(null).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
void testDeleteVendor() {
|
||||
List<Vendor> vendors = cardService.findAllVendors(TestConstants.VENDOR_NAME);
|
||||
assertEquals(1, vendors.size());
|
||||
Vendor vendor = vendors.get(0);
|
||||
cardService.deleteVendor(vendor);
|
||||
assertEquals(TestConstants.VENDOR_COUNT, cardService.findAllVendors(null).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
void testFindAllCardSets() {
|
||||
assertEquals(TestConstants.CARDSET_COUNT, cardService.findAllCardSets(null).size());
|
||||
assertEquals(1, cardService.findAllCardSets("Ultra").size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(5)
|
||||
void testSaveCardSet() {
|
||||
List<Vendor> vendors = cardService.findAllVendors(TestConstants.VENDOR_FLEER);
|
||||
assertEquals(1, vendors.size());
|
||||
Vendor vendor = vendors.get(0);
|
||||
CardSet cardSet = new CardSet();
|
||||
cardSet.setName(TestConstants.CARDSET_NAME);
|
||||
cardSet.setVendor(vendor);
|
||||
cardSet.setInsertSet(false);
|
||||
cardSet.setParallelSet(false);
|
||||
cardService.saveCardSet(cardSet);
|
||||
assertEquals(TestConstants.CARDSET_COUNT + 1, cardService.findAllCardSets(null).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(6)
|
||||
void testDeleteCardSet() {
|
||||
List<CardSet> cardSets = cardService.findAllCardSets(TestConstants.CARDSET_NAME);
|
||||
assertEquals(1, cardSets.size());
|
||||
CardSet cardSet = cardSets.get(0);
|
||||
cardService.deleteCardSet(cardSet);
|
||||
assertEquals(TestConstants.CARDSET_COUNT, cardService.findAllCardSets(null).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(7)
|
||||
void testFindAllCards() {
|
||||
assertEquals(TestConstants.CARD_COUNT, cardService.findAllCards(null).size());
|
||||
assertEquals(1, cardService.findAllCards("112").size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(8)
|
||||
void testSaveCard() {
|
||||
List<Vendor> vendors = cardService.findAllVendors(TestConstants.VENDOR_FLEER);
|
||||
assertEquals(1, vendors.size());
|
||||
Vendor vendor = vendors.get(0);
|
||||
List<CardSet> cardSets = cardService.findAllCardSets(TestConstants.CARDSET_MYSTIQUE_NAME);
|
||||
assertEquals(3, cardSets.size());
|
||||
CardSet cardSet = cardSets.get(0);
|
||||
List<Rooster> roosters = sportService.findAllRoosters();
|
||||
Rooster rooster = roosters.get(0);
|
||||
Card card = new Card();
|
||||
card.setCardNumber(TestConstants.CARD_CARDNUMBER);
|
||||
card.setCardSet(cardSet);
|
||||
card.setVendor(vendor);
|
||||
card.setRooster(rooster);
|
||||
card.setYear(TestConstants.CARD_YEAR);
|
||||
cardService.saveCard(card);
|
||||
assertEquals(TestConstants.CARD_COUNT + 1, cardService.findAllCards(null).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(9)
|
||||
void testDeleteCard() {
|
||||
List<Card> cards = cardService.findAllCards(TestConstants.CARD_CARDNUMBER.toString());
|
||||
assertEquals(1, cards.size());
|
||||
Card card = cards.get(0);
|
||||
cardService.deleteCard(card);
|
||||
assertEquals(TestConstants.CARD_COUNT, cardService.findAllCards(null).size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
package de.thpeetz.kontor.tysc.services;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.thpeetz.kontor.tysc.data.FieldPosition;
|
||||
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import de.thpeetz.kontor.tysc.TestConstants;
|
||||
import de.thpeetz.kontor.tysc.data.Player;
|
||||
import de.thpeetz.kontor.tysc.data.Rooster;
|
||||
import de.thpeetz.kontor.tysc.data.Sport;
|
||||
import de.thpeetz.kontor.tysc.data.Team;
|
||||
|
||||
@SpringBootTest
|
||||
@TestMethodOrder(OrderAnnotation.class)
|
||||
class SportServiceTest {
|
||||
|
||||
@Autowired
|
||||
private SportService sportService;
|
||||
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void testFindAllSports() {
|
||||
List<Sport> sports = sportService.findAllSports(null);
|
||||
assertEquals(TestConstants.SPORT_COUNT, sports.size());
|
||||
assertEquals(3, sportService.findAllSports("ball").size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
void testSaveSport() {
|
||||
Sport sport = new Sport();
|
||||
sport.setName(TestConstants.SPORT_NAME);
|
||||
sport = sportService.saveSport(sport);
|
||||
assertNotNull(sport);
|
||||
assertEquals(TestConstants.SPORT_COUNT+1, sportService.findAllSports(null).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
void testDeleteSport() {
|
||||
List<Sport> sports = sportService.findAllSports(TestConstants.SPORT_NAME);
|
||||
assertEquals(1, sports.size());
|
||||
Sport sport = sports.get(0);
|
||||
sportService.deleteSport(sport);
|
||||
assertEquals(TestConstants.SPORT_COUNT, sportService.findAllSports(null).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
void testFindAllPlayers() {
|
||||
assertEquals(TestConstants.PLAYER_COUNT, sportService.findAllPlayers(null).size());
|
||||
assertEquals(TestConstants.PLAYER_CHRIS_COUNT, sportService.findAllPlayers(TestConstants.PLAYER_CHRIS_NAME).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(5)
|
||||
void testSavePlayer() {
|
||||
Player player = new Player();
|
||||
player.setFirstName(TestConstants.PLAYER_FIRSTNAME);
|
||||
player.setLastName(TestConstants.PLAYER_LASTNAME);
|
||||
player = sportService.savePlayer(player);
|
||||
assertNotNull(player);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(6)
|
||||
void testDeletePlayer() {
|
||||
List<Player> players = sportService.findAllPlayers(TestConstants.PLAYER_LASTNAME);
|
||||
assertEquals(1, players.size());
|
||||
Player player = players.get(0);
|
||||
sportService.deletePlayer(player);
|
||||
assertEquals(TestConstants.PLAYER_COUNT, sportService.findAllPlayers(null).size());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Order(7)
|
||||
void testFindAllPositions() {
|
||||
assertEquals(TestConstants.POSITION_COUNT, sportService.findAllPositions(null).size());
|
||||
assertEquals(TestConstants.POSITION_CENTER_COUNT, sportService.findAllPositions(TestConstants.POSITION_CENTER).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(8)
|
||||
void testFindAllPositionsForSport() {
|
||||
List<Sport> sports = sportService.findAllSports(TestConstants.FOOTBALL_NAME);
|
||||
assertEquals(1, sports.size());
|
||||
Sport football = sports.get(0);
|
||||
assertEquals(TestConstants.FOOTBALL_POSITION_COUNT, sportService.findAllPositionsForSport(football).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(9)
|
||||
void testSavePosition() {
|
||||
List<Sport> sports = sportService.findAllSports(TestConstants.FOOTBALL_NAME);
|
||||
Sport football = sports.get(0);
|
||||
FieldPosition position = new FieldPosition();
|
||||
position.setSport(football);
|
||||
position.setName(TestConstants.POSITION_NAME);
|
||||
position.setShortName(TestConstants.POSITION_SHORTNAME);
|
||||
sportService.savePosition(position);
|
||||
assertEquals(TestConstants.POSITION_COUNT+1, sportService.findAllPositions(null).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(10)
|
||||
void testDeletePosition() {
|
||||
List<FieldPosition> positions = sportService.findAllPositions(TestConstants.POSITION_NAME);
|
||||
assertEquals(1, positions.size());
|
||||
FieldPosition position = positions.get(0);
|
||||
sportService.deletePosition(position);
|
||||
assertEquals(TestConstants.POSITION_COUNT, sportService.findAllPositions(null).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(11)
|
||||
void testFindAllTeams() {
|
||||
assertEquals(TestConstants.TEAM_COUNT, sportService.findAllTeams(null).size());
|
||||
assertEquals(1, sportService.findAllTeams("sharks").size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(12)
|
||||
void testSaveTeam() {
|
||||
List<Sport> sports = sportService.findAllSports(TestConstants.FOOTBALL_NAME);
|
||||
Sport football = sports.get(0);
|
||||
Team team = new Team();
|
||||
team.setSport(football);
|
||||
team.setName(TestConstants.TEAM_NAME);
|
||||
team.setShortName(TestConstants.TEAM_SHORTNAME);
|
||||
sportService.saveTeam(team);
|
||||
assertEquals(TestConstants.TEAM_COUNT+1, sportService.findAllTeams(null).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(13)
|
||||
void testDeleteTeam() {
|
||||
List<Team> teams = sportService.findAllTeams(TestConstants.TEAM_NAME);
|
||||
assertEquals(1, teams.size());
|
||||
Team team = teams.get(0);
|
||||
sportService.deleteTeam(team);
|
||||
assertEquals(TestConstants.TEAM_COUNT, sportService.findAllTeams(null).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(14)
|
||||
void testFindAllRoosters() {
|
||||
assertEquals(TestConstants.ROOSTER_COUNT, sportService.findAllRoosters().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(15)
|
||||
void testFindRoosterByFields() {
|
||||
List<Rooster> roosters = sportService.findAllRoosters();
|
||||
Rooster existingRooster = roosters.get(4);
|
||||
Team team = existingRooster.getTeam();
|
||||
Player player = existingRooster.getPlayer();
|
||||
FieldPosition position = existingRooster.getPosition();
|
||||
int year = existingRooster.getYear();
|
||||
Rooster rooster = sportService.findRoosterByFields(team, player, position, year);
|
||||
assertNotNull(rooster);
|
||||
assertEquals(existingRooster.getId(), rooster.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(16)
|
||||
void testSaveRooster() {
|
||||
Rooster rooster = new Rooster();
|
||||
Player player = sportService.findAllPlayers(TestConstants.PLAYER_CHRIS_NAME).get(0);
|
||||
rooster.setPlayer(player);
|
||||
Team team = sportService.findAllTeams(TestConstants.DOLPHINS_NAME).get(0);
|
||||
rooster.setTeam(team);
|
||||
FieldPosition position = sportService.findAllPositions(TestConstants.QUARTERBACK_NAME).get(0);
|
||||
rooster.setPosition(position);
|
||||
rooster.setYear(TestConstants.ROOSTER_YEAR);
|
||||
sportService.saveRooster(rooster);
|
||||
assertEquals(TestConstants.ROOSTER_COUNT+1, sportService.findAllRoosters().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(17)
|
||||
void testDeleteRooster() {
|
||||
Team team = sportService.findAllTeams(TestConstants.DOLPHINS_NAME).get(0);
|
||||
Player player = sportService.findAllPlayers(TestConstants.PLAYER_CHRIS_NAME).get(0);
|
||||
FieldPosition position = sportService.findAllPositions(TestConstants.QUARTERBACK_NAME).get(0);
|
||||
Rooster rooster = sportService.findRoosterByFields(team, player, position, TestConstants.ROOSTER_YEAR);
|
||||
assertNotNull(rooster);
|
||||
sportService.deleteRooster(rooster);
|
||||
assertEquals(TestConstants.ROOSTER_COUNT, sportService.findAllRoosters().size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
server.port=8085
|
||||
|
||||
spring.hibernate.dialect=org.hibernate.dialect.HSQLDialect
|
||||
spring.jpa.database-platform=org.hibernate.dialect.HSQLDialect
|
||||
spring.datasource.driverClassName=org.hsqldb.jdbc.JDBCDriver
|
||||
spring.datasource.url=jdbc:hsqldb:mem:testDb
|
||||
spring.datasource.username=sa
|
||||
spring.datasource.password=sa
|
||||
|
||||
#spring.jpa.database-platform=org.hibernate.community.dialect.SQLiteDialect
|
||||
#spring.datasource.driverClassName=org.sqlite.JDBC
|
||||
#spring.datasource.url=jdbc:sqlite:file:./kontorTesrDb?cache=shared
|
||||
#spring.datasource.username=sa
|
||||
#spring.datasource.password=sa
|
||||
|
||||
spring.jpa.defer-datasource-initialization = true
|
||||
#spring.jpa.hibernate.ddl-auto=create-drop
|
||||
spring.jpa.hibernate.ddl-auto=update
|
||||
spring.jpa.show-sql=false
|
||||
spring.sql.init.mode=always
|
||||
|
||||
spring.mustache.check-template-location = false
|
||||
|
||||
logging.level.org.atmosphere=INFO
|
||||
logging.level.org.springframework.web=INFO
|
||||
logging.level.guru.springframework.controllers=DEBUG
|
||||
logging.level.org.hibernate=INFO
|
||||
logging.level.de.thpeetz=DEBUG
|
||||
|
||||
jwt.auth.secret=J6GOtcwC2NJI1l0VkHu20PacPFGTxpirBxWwynoHjsc=
|
||||
Reference in New Issue
Block a user