// Path: src/main/java/com/edwise/completespring/entities/Book.java
// @Document(collection = "books")
// @ApiModel(value = "Book entity", description = "Complete info of a entity book")
// @Data
// @Accessors(chain = true)
// @EqualsAndHashCode(exclude = {"id"}, doNotUseGetters = true)
// @ToString(doNotUseGetters = true)
// public class Book {
// 
//     @ApiModelProperty(value = "The id of the book")
//     @Id
//     private Long id;
// 
//     @ApiModelProperty(value = "The title of the book", required = true)
//     @NotEmpty
//     private String title;
// 
//     @ApiModelProperty(value = "The authors of the book", required = true)
//     @Valid
//     private List<Author> authors;
// 
//     @ApiModelProperty(value = "The isbn of the book", required = true)
//     @NotEmpty
//     private String isbn;
// 
//     @ApiModelProperty(value = "The release date of the book", required = true, dataType = "LocalDate")
//     @NotNull
//     private LocalDate releaseDate;
// 
//     @ApiModelProperty(value = "The publisher of the book", required = true)
//     @Valid
//     @NotNull
//     private Publisher publisher;
// 
//     public Book copyFrom(Book other) {
//         this.title = other.title;
//         if (other.authors != null) {
//             this.authors = new ArrayList<>();
//             this.authors.addAll(other.authors.stream().map(new Author()::copyFrom).collect(Collectors.toList()));
//         }
//         this.isbn = other.isbn;
//         this.releaseDate = other.releaseDate;
//         if (other.publisher != null) {
//             this.publisher = new Publisher().copyFrom(other.publisher);
//         }
// 
//         return this;
//     }
// }
// 
// Path: src/main/java/com/edwise/completespring/entities/SequenceId.java
// @Document(collection = "sequences")
// @Setter @Getter
// @Accessors(chain = true)
// @ToString(doNotUseGetters = true)
// public class SequenceId {
//     @Id
//     private String id;
// 
//     private long seq;
// 
// }
// 
// Path: src/main/java/com/edwise/completespring/entities/UserAccount.java
// @Document(collection = "users")
// @Data
// @Accessors(chain = true)
// @EqualsAndHashCode(exclude = {"id"}, doNotUseGetters = true)
// @ToString(doNotUseGetters = true)
// public class UserAccount {
// 
//     @Id
//     private Long id;
// 
//     private String username;
//     private String password;
// 
//     @NonNull
//     private UserAccountType userType = UserAccountType.REST_USER;
// }
// 
// Path: src/main/java/com/edwise/completespring/repositories/BookRepository.java
// public interface BookRepository extends MongoRepository<Book, Long> {
// 
//     List<Book> findByTitle(String title);
//     List<Book> findByReleaseDate(LocalDate releaseDate);
// 
// }
// 
// Path: src/main/java/com/edwise/completespring/repositories/SequenceIdRepository.java
// public interface SequenceIdRepository {
//     void save(SequenceId sequenceId);
// 
//     long getNextSequenceId(String key);
// }
// 
// Path: src/main/java/com/edwise/completespring/repositories/UserAccountRepository.java
// public interface UserAccountRepository extends MongoRepository<UserAccount, Long> {
// 
//     UserAccount findByUsername(String username);
// }


import com.edwise.completespring.entities.Book;
import com.edwise.completespring.entities.SequenceId;
import com.edwise.completespring.entities.UserAccount;
import com.edwise.completespring.repositories.BookRepository;
import com.edwise.completespring.repositories.SequenceIdRepository;
import com.edwise.completespring.repositories.UserAccountRepository;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.security.crypto.password.PasswordEncoder;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
package com.edwise.completespring.dbutils;



@RunWith(MockitoJUnitRunner.class)
public class DataLoaderTest {
    private static final int TWO_TIMES = 2;
    private static final int FOUR_TIMES = 4;

    @Mock
    private BookRepository bookRepository;

    @Mock
    private UserAccountRepository userAccountRepository;

    @Mock
    private SequenceIdRepository sequenceRepository;

    @Mock
    private PasswordEncoder passwordEncoder;

    @InjectMocks
    private DataLoader dataLoader;

    @Test
    public void testFillDBData() {
        dataLoader.fillDBData();

        verifyRepositoriesCalls();
    }

    private void verifyRepositoriesCalls() {
        verify(sequenceRepository, times(TWO_TIMES)).save(any(SequenceId.class));
        verify(bookRepository).deleteAll();
// Path: src/main/java/com/edwise/completespring/entities/Book.java
// @Document(collection = "books")
// @ApiModel(value = "Book entity", description = "Complete info of a entity book")
// @Data
// @Accessors(chain = true)
// @EqualsAndHashCode(exclude = {"id"}, doNotUseGetters = true)
// @ToString(doNotUseGetters = true)
// public class Book {
// 
//     @ApiModelProperty(value = "The id of the book")
//     @Id
//     private Long id;
// 
//     @ApiModelProperty(value = "The title of the book", required = true)
//     @NotEmpty
//     private String title;
// 
//     @ApiModelProperty(value = "The authors of the book", required = true)
//     @Valid
//     private List<Author> authors;
// 
//     @ApiModelProperty(value = "The isbn of the book", required = true)
//     @NotEmpty
//     private String isbn;
// 
//     @ApiModelProperty(value = "The release date of the book", required = true, dataType = "LocalDate")
//     @NotNull
//     private LocalDate releaseDate;
// 
//     @ApiModelProperty(value = "The publisher of the book", required = true)
//     @Valid
//     @NotNull
//     private Publisher publisher;
// 
//     public Book copyFrom(Book other) {
//         this.title = other.title;
//         if (other.authors != null) {
//             this.authors = new ArrayList<>();
//             this.authors.addAll(other.authors.stream().map(new Author()::copyFrom).collect(Collectors.toList()));
//         }
//         this.isbn = other.isbn;
//         this.releaseDate = other.releaseDate;
//         if (other.publisher != null) {
//             this.publisher = new Publisher().copyFrom(other.publisher);
//         }
// 
//         return this;
//     }
// }
// 
// Path: src/main/java/com/edwise/completespring/entities/SequenceId.java
// @Document(collection = "sequences")
// @Setter @Getter
// @Accessors(chain = true)
// @ToString(doNotUseGetters = true)
// public class SequenceId {
//     @Id
//     private String id;
// 
//     private long seq;
// 
// }
// 
// Path: src/main/java/com/edwise/completespring/entities/UserAccount.java
// @Document(collection = "users")
// @Data
// @Accessors(chain = true)
// @EqualsAndHashCode(exclude = {"id"}, doNotUseGetters = true)
// @ToString(doNotUseGetters = true)
// public class UserAccount {
// 
//     @Id
//     private Long id;
// 
//     private String username;
//     private String password;
// 
//     @NonNull
//     private UserAccountType userType = UserAccountType.REST_USER;
// }
// 
// Path: src/main/java/com/edwise/completespring/repositories/BookRepository.java
// public interface BookRepository extends MongoRepository<Book, Long> {
// 
//     List<Book> findByTitle(String title);
//     List<Book> findByReleaseDate(LocalDate releaseDate);
// 
// }
// 
// Path: src/main/java/com/edwise/completespring/repositories/SequenceIdRepository.java
// public interface SequenceIdRepository {
//     void save(SequenceId sequenceId);
// 
//     long getNextSequenceId(String key);
// }
// 
// Path: src/main/java/com/edwise/completespring/repositories/UserAccountRepository.java
// public interface UserAccountRepository extends MongoRepository<UserAccount, Long> {
// 
//     UserAccount findByUsername(String username);
// }


// Path: src/test/java/com/edwise/completespring/dbutils/DataLoaderTest.java
import com.edwise.completespring.entities.Book;
import com.edwise.completespring.entities.SequenceId;
import com.edwise.completespring.entities.UserAccount;
import com.edwise.completespring.repositories.BookRepository;
import com.edwise.completespring.repositories.SequenceIdRepository;
import com.edwise.completespring.repositories.UserAccountRepository;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.security.crypto.password.PasswordEncoder;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

package com.edwise.completespring.dbutils;



@RunWith(MockitoJUnitRunner.class)
public class DataLoaderTest {
    private static final int TWO_TIMES = 2;
    private static final int FOUR_TIMES = 4;

    @Mock
    private BookRepository bookRepository;

    @Mock
    private UserAccountRepository userAccountRepository;

    @Mock
    private SequenceIdRepository sequenceRepository;

    @Mock
    private PasswordEncoder passwordEncoder;

    @InjectMocks
    private DataLoader dataLoader;

    @Test
    public void testFillDBData() {
        dataLoader.fillDBData();

        verifyRepositoriesCalls();
    }

    private void verifyRepositoriesCalls() {
        verify(sequenceRepository, times(TWO_TIMES)).save(any(SequenceId.class));
        verify(bookRepository).deleteAll();
        verify(bookRepository, times(FOUR_TIMES)).save(any(Book.class));