// Path: spring-boot-mapped-supertype/src/main/java/de/chclaus/example/domain/User.java
// @Entity
// @Table(name = "t_user")
// @Where(clause = "deleted='false'")
// @SQLDelete(sql = "UPDATE t_user SET deleted = true WHERE id = ? and version = ?")
// public class User extends BaseEntity {
// 
//   @Column(length = 100)
//   private String username;
// 
//   @Column(length = 100)
//   private String password;
// 
//   public String getUsername() {
//     return username;
//   }
// 
//   public void setUsername(String username) {
//     this.username = username;
//   }
// 
//   public String getPassword() {
//     return password;
//   }
// 
//   public void setPassword(String password) {
//     this.password = password;
//   }
// }
// 
// Path: spring-boot-mapped-supertype/src/main/java/de/chclaus/example/domain/UserRepository.java
// public interface UserRepository extends JpaRepository<User, Integer> {
// 
//   @Query(value = "SELECT count(u.id) FROM t_user u WHERE u.deleted='true'", nativeQuery = true)
//   long countDeletedEntries();
// }


import de.chclaus.example.domain.User;
import de.chclaus.example.domain.UserRepository;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import static org.junit.Assert.*;
package de.chclaus.example;



/**
 * Test to validate the correctness of the soft-delete implementation.
 *
 * @author Christian Claus (ch.claus@me.com)
 */
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = MappedSupertypeApplication.class)
public class DeleteRepositoryTest {

  @Autowired
  private UserRepository userRepository;

  @Test
  public void testDeletion() throws Exception {
    // Validates if there are no users in the repository.
    assertEquals(0, userRepository.count());
    assertEquals(0, userRepository.countDeletedEntries());

    // Creates a new user and saves it.
    User user = new User();
    user.setUsername("foo");
    user.setPassword("bar");
// Path: spring-boot-mapped-supertype/src/main/java/de/chclaus/example/domain/User.java
// @Entity
// @Table(name = "t_user")
// @Where(clause = "deleted='false'")
// @SQLDelete(sql = "UPDATE t_user SET deleted = true WHERE id = ? and version = ?")
// public class User extends BaseEntity {
// 
//   @Column(length = 100)
//   private String username;
// 
//   @Column(length = 100)
//   private String password;
// 
//   public String getUsername() {
//     return username;
//   }
// 
//   public void setUsername(String username) {
//     this.username = username;
//   }
// 
//   public String getPassword() {
//     return password;
//   }
// 
//   public void setPassword(String password) {
//     this.password = password;
//   }
// }
// 
// Path: spring-boot-mapped-supertype/src/main/java/de/chclaus/example/domain/UserRepository.java
// public interface UserRepository extends JpaRepository<User, Integer> {
// 
//   @Query(value = "SELECT count(u.id) FROM t_user u WHERE u.deleted='true'", nativeQuery = true)
//   long countDeletedEntries();
// }


// Path: spring-boot-mapped-supertype/src/test/java/de/chclaus/example/DeleteRepositoryTest.java
import de.chclaus.example.domain.User;
import de.chclaus.example.domain.UserRepository;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import static org.junit.Assert.*;

package de.chclaus.example;



/**
 * Test to validate the correctness of the soft-delete implementation.
 *
 * @author Christian Claus (ch.claus@me.com)
 */
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = MappedSupertypeApplication.class)
public class DeleteRepositoryTest {

  @Autowired
  private UserRepository userRepository;

  @Test
  public void testDeletion() throws Exception {
    // Validates if there are no users in the repository.
    assertEquals(0, userRepository.count());
    assertEquals(0, userRepository.countDeletedEntries());

    // Creates a new user and saves it.
    User user = new User();
    user.setUsername("foo");
    user.setPassword("bar");
    User dbUser = userRepository.saveAndFlush(user);