// Path: src/test/java/com/jipasoft/config/ApplicationTests.java
// @RunWith(SpringRunner.class)
// @SpringBootTest(classes = Application.class, webEnvironment = WebEnvironment.NONE)
// public class ApplicationTests {
// 
// 	@Test
// 	public void contextsLoad() {
// 
// 	}
// }
// 
// Path: src/main/java/com/jipasoft/domain/Authority.java
// @Data
// @Entity
// @Document(collection = "role")
// @NoArgsConstructor
// @AllArgsConstructor
// @Table(name = "role")
// public class Authority implements Serializable {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	@Id
// 	@NotNull
// 	@org.springframework.data.annotation.Id
// 	@Size(min = 1, max = 50)
// 	private String name;
// 
// }
// 
// Path: src/main/java/com/jipasoft/domain/User.java
// @Data
// @Entity
// @Document(collection = "account")
// @Table(name = "account")
// @ToString(exclude = { "password", "authorities" })
// @EqualsAndHashCode(callSuper = true)
// public class User extends AbstractAuditEntity implements Serializable {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	@Id
// 	@org.springframework.data.annotation.Id
// 	@GeneratedValue(generator = "uuid2")
// 	@GenericGenerator(name = "uuid2", strategy = "uuid2")
// 	private String id;
// 
// 	@NotNull
// 	@Pattern(regexp = "^[a-z0-9]*$|(anonymousUser)")
// 	@Size(min = 1, max = 100)
// 	@Column(unique = true)
// 	private String login;
// 
// 	@NotNull
// 	@Size(min = 60, max = 60)
// 	@Column(name = "password_hash")
// 	@JsonIgnore
// 	private String password;
// 
// 	@Size(max = 50)
// 	@Field("first_name")
// 	private String firstName;
// 
// 	@Size(max = 50)
// 	@Field("last_name")
// 	private String lastName;
// 
// 	@NotNull
// 	@Size(min = 1, max = 100)
// 	@Column(unique = true)
// 	private String email;
// 
// 	@NotNull
// 	private boolean activated = false;
// 
// 	@Size(max = 20)
// 	@Field("activation_key")
// 	@JsonIgnore
// 	private String activationKey;
// 
// 	@Size(max = 20)
// 	@Field("reset_key")
// 	@JsonIgnore
// 	private String resetKey;
// 
// 	@Field("reset_date")
// 	private ZonedDateTime resetDate = null;
// 
// 	@ManyToMany
// 	//@formatter:off
// 	@JoinTable(name = "user_role", inverseJoinColumns = {
// 			@JoinColumn(name = "role_name")
// 		}, joinColumns = {
// 			@JoinColumn(name = "account_id")
// 		}
// 	)
// 	//@formatter:on
// 	private Set<Authority> authorities;
// }
// 
// Path: src/main/java/com/jipasoft/util/Profiles.java
// public class Profiles {
// 	public static final String H2 = "h2";
// 	public static final String POSTGRES = "postgres";
// 	public static final String MYSQL = "mysql";
// 	public static final String MONGO = "mongo";
// 	public static final String EMAIL = "email";
// 	public static final String HEROKU = "heroku";
// 	public static final String ASPECT = "aspect";
// }


import com.jipasoft.domain.Authority;
import com.jipasoft.domain.User;
import com.jipasoft.util.Profiles;
import lombok.extern.slf4j.Slf4j;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertNotNull;
import java.time.ZonedDateTime;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.transaction.annotation.Transactional;
import com.jipasoft.config.ApplicationTests;
	@Before
	public void setUp() {
		userRepository.deleteAll();

		User user = new User();
		user.setEmail("juliuskrah@gmail.com");
		user.setLogin("julius");
		user.setResetKey("aw55asa7d5Sdcs8dAsa8");
		user.setCreatedBy("system");
		user.setPassword("$2a$10$mE.qmcV0mFU5NcKh73TZx.z4ueI/.bDWbj0T1BYyqP481kGGarKLG");
		user.setAuthorities(Stream.of(new Authority("ROLE_ADMIN"), new Authority("ROLE_USER")).collect(Collectors.toSet()));

		userRepository.save(user);
	}

	@Test
	public void testFindByLogin() {
		User user = userRepository.findOneByLogin("julius").get();
		assertNotNull(user);
		log.debug("user: {} was created on {} with id {}", user.getLogin(), user.getCreatedDate(), user.getId());
		assertThat(user.getLogin()).isEqualTo("julius");
	}

	@Test
	public void testUpdate() {
		Optional<User> user = userRepository.findOneByEmail("juliuskrah@gmail.com");
		assertNotNull(user);
		log.debug("updating user: {} with email: {} and id: {} created on: {}", user.get().getLogin(), user.get().getEmail(),
				user.get().getId(), user.get().getCreatedDate());

// Path: src/test/java/com/jipasoft/config/ApplicationTests.java
// @RunWith(SpringRunner.class)
// @SpringBootTest(classes = Application.class, webEnvironment = WebEnvironment.NONE)
// public class ApplicationTests {
// 
// 	@Test
// 	public void contextsLoad() {
// 
// 	}
// }
// 
// Path: src/main/java/com/jipasoft/domain/Authority.java
// @Data
// @Entity
// @Document(collection = "role")
// @NoArgsConstructor
// @AllArgsConstructor
// @Table(name = "role")
// public class Authority implements Serializable {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	@Id
// 	@NotNull
// 	@org.springframework.data.annotation.Id
// 	@Size(min = 1, max = 50)
// 	private String name;
// 
// }
// 
// Path: src/main/java/com/jipasoft/domain/User.java
// @Data
// @Entity
// @Document(collection = "account")
// @Table(name = "account")
// @ToString(exclude = { "password", "authorities" })
// @EqualsAndHashCode(callSuper = true)
// public class User extends AbstractAuditEntity implements Serializable {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	@Id
// 	@org.springframework.data.annotation.Id
// 	@GeneratedValue(generator = "uuid2")
// 	@GenericGenerator(name = "uuid2", strategy = "uuid2")
// 	private String id;
// 
// 	@NotNull
// 	@Pattern(regexp = "^[a-z0-9]*$|(anonymousUser)")
// 	@Size(min = 1, max = 100)
// 	@Column(unique = true)
// 	private String login;
// 
// 	@NotNull
// 	@Size(min = 60, max = 60)
// 	@Column(name = "password_hash")
// 	@JsonIgnore
// 	private String password;
// 
// 	@Size(max = 50)
// 	@Field("first_name")
// 	private String firstName;
// 
// 	@Size(max = 50)
// 	@Field("last_name")
// 	private String lastName;
// 
// 	@NotNull
// 	@Size(min = 1, max = 100)
// 	@Column(unique = true)
// 	private String email;
// 
// 	@NotNull
// 	private boolean activated = false;
// 
// 	@Size(max = 20)
// 	@Field("activation_key")
// 	@JsonIgnore
// 	private String activationKey;
// 
// 	@Size(max = 20)
// 	@Field("reset_key")
// 	@JsonIgnore
// 	private String resetKey;
// 
// 	@Field("reset_date")
// 	private ZonedDateTime resetDate = null;
// 
// 	@ManyToMany
// 	//@formatter:off
// 	@JoinTable(name = "user_role", inverseJoinColumns = {
// 			@JoinColumn(name = "role_name")
// 		}, joinColumns = {
// 			@JoinColumn(name = "account_id")
// 		}
// 	)
// 	//@formatter:on
// 	private Set<Authority> authorities;
// }
// 
// Path: src/main/java/com/jipasoft/util/Profiles.java
// public class Profiles {
// 	public static final String H2 = "h2";
// 	public static final String POSTGRES = "postgres";
// 	public static final String MYSQL = "mysql";
// 	public static final String MONGO = "mongo";
// 	public static final String EMAIL = "email";
// 	public static final String HEROKU = "heroku";
// 	public static final String ASPECT = "aspect";
// }


// Path: src/test/java/com/jipasoft/repository/UserRepositoryTests.java
import com.jipasoft.domain.Authority;
import com.jipasoft.domain.User;
import com.jipasoft.util.Profiles;
import lombok.extern.slf4j.Slf4j;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertNotNull;
import java.time.ZonedDateTime;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.transaction.annotation.Transactional;
import com.jipasoft.config.ApplicationTests;

	@Before
	public void setUp() {
		userRepository.deleteAll();

		User user = new User();
		user.setEmail("juliuskrah@gmail.com");
		user.setLogin("julius");
		user.setResetKey("aw55asa7d5Sdcs8dAsa8");
		user.setCreatedBy("system");
		user.setPassword("$2a$10$mE.qmcV0mFU5NcKh73TZx.z4ueI/.bDWbj0T1BYyqP481kGGarKLG");
		user.setAuthorities(Stream.of(new Authority("ROLE_ADMIN"), new Authority("ROLE_USER")).collect(Collectors.toSet()));

		userRepository.save(user);
	}

	@Test
	public void testFindByLogin() {
		User user = userRepository.findOneByLogin("julius").get();
		assertNotNull(user);
		log.debug("user: {} was created on {} with id {}", user.getLogin(), user.getCreatedDate(), user.getId());
		assertThat(user.getLogin()).isEqualTo("julius");
	}

	@Test
	public void testUpdate() {
		Optional<User> user = userRepository.findOneByEmail("juliuskrah@gmail.com");
		assertNotNull(user);
		log.debug("updating user: {} with email: {} and id: {} created on: {}", user.get().getLogin(), user.get().getEmail(),
				user.get().getId(), user.get().getCreatedDate());

		User u = user.get();