CCM NG: UserRepositoryTest
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@3509 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
34e42a81d5
commit
1ddb4028fb
|
|
@ -45,10 +45,6 @@ public abstract class AbstractEntityRepository<K, E> {
|
|||
*/
|
||||
@Inject
|
||||
private transient EntityManager entityManager;
|
||||
|
||||
@Inject
|
||||
@HibernateValidator
|
||||
private Validator validator;
|
||||
|
||||
/**
|
||||
* Getter method for retrieving the injected {@link EntityManager}.
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public class CcmObjectRepository extends AbstractEntityRepository<Long, CcmObjec
|
|||
@Override
|
||||
public boolean isNew(final CcmObject entity) {
|
||||
if (entity == null) {
|
||||
throw new IllegalArgumentException("Entity can't be null");
|
||||
throw new IllegalArgumentException("Can't save null.");
|
||||
}
|
||||
return entity.getObjectId() == 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (C) 2015 LibreCCM Foundation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*/
|
||||
package org.libreccm.core;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
class MultipleMatchingUserException extends RuntimeException {
|
||||
private static final long serialVersionUID = 100237510055701060L;
|
||||
|
||||
public MultipleMatchingUserException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public MultipleMatchingUserException(final String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public MultipleMatchingUserException(final Exception cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public MultipleMatchingUserException(final String msg,
|
||||
final Exception cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -31,6 +31,7 @@ import javax.persistence.CollectionTable;
|
|||
import javax.persistence.Column;
|
||||
import javax.persistence.ElementCollection;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
|
|
@ -62,7 +63,7 @@ public class Subject implements Serializable {
|
|||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private long subjectId;
|
||||
|
||||
@ElementCollection
|
||||
@ElementCollection(fetch = FetchType.EAGER)
|
||||
@CollectionTable(name = "subject_email_addresses",
|
||||
joinColumns = {
|
||||
@JoinColumn(name = "subject_id")})
|
||||
|
|
@ -81,6 +82,7 @@ public class Subject implements Serializable {
|
|||
public Subject() {
|
||||
super();
|
||||
|
||||
emailAddresses = new ArrayList<>();
|
||||
grantedPermissions = new ArrayList<>();
|
||||
}
|
||||
|
||||
|
|
@ -155,7 +157,7 @@ public class Subject implements Serializable {
|
|||
return false;
|
||||
}
|
||||
|
||||
return (subjectId == other.getSubjectId());
|
||||
return subjectId == other.getSubjectId();
|
||||
}
|
||||
|
||||
public boolean canEqual(final Object obj) {
|
||||
|
|
|
|||
|
|
@ -141,6 +141,7 @@ public class User extends Subject implements Serializable {
|
|||
* the next login.
|
||||
*/
|
||||
@Column(name = "password_reset_required")
|
||||
@SuppressWarnings("PMD.LongVariable") //Name is fine...
|
||||
private boolean passwordResetRequired;
|
||||
|
||||
/**
|
||||
|
|
@ -232,6 +233,7 @@ public class User extends Subject implements Serializable {
|
|||
return passwordResetRequired;
|
||||
}
|
||||
|
||||
@SuppressWarnings("PMD.LongVariable")
|
||||
public void setPasswordResetRequired(final boolean passwordResetRequired) {
|
||||
this.passwordResetRequired = passwordResetRequired;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,9 @@ public class UserRepository extends AbstractEntityRepository<Long, User> {
|
|||
|
||||
@Override
|
||||
public boolean isNew(final User entity) {
|
||||
if (entity == null) {
|
||||
throw new IllegalArgumentException("Can't save null.");
|
||||
}
|
||||
return entity.getSubjectId() == 0;
|
||||
}
|
||||
|
||||
|
|
@ -47,16 +50,14 @@ public class UserRepository extends AbstractEntityRepository<Long, User> {
|
|||
|
||||
final List<User> result = query.getResultList();
|
||||
|
||||
//Check if result list is empty and if not return the first element.
|
||||
//If their ist a result than there can only be one because the
|
||||
//screen_name column has a unique constraint.
|
||||
if (result.isEmpty()) {
|
||||
return null;
|
||||
} else if (result.size() == 1) {
|
||||
} else {
|
||||
return result.get(0);
|
||||
} else {
|
||||
throw new MultipleMatchingUserException(String.format(
|
||||
"Found multipe users identified by screen name '%s'. "
|
||||
+ "Check your database.",
|
||||
screenname));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public User findByEmailAddress(final String emailAddress) {
|
||||
|
|
@ -78,14 +79,5 @@ public class UserRepository extends AbstractEntityRepository<Long, User> {
|
|||
}
|
||||
}
|
||||
|
||||
private class MultipleMatchingUserException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 100237510055701060L;
|
||||
|
||||
public MultipleMatchingUserException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
<menu name="Overview">
|
||||
<item name="The Core module" href="index.html"/>
|
||||
</menu>
|
||||
|
||||
<menu ref="reports"/>
|
||||
</body>
|
||||
<!--<skin>
|
||||
|
|
|
|||
|
|
@ -19,17 +19,21 @@
|
|||
package org.libreccm.core;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
import org.jboss.arquillian.container.test.api.Deployment;
|
||||
import org.jboss.arquillian.container.test.api.ShouldThrowException;
|
||||
import org.jboss.arquillian.junit.Arquillian;
|
||||
import org.jboss.arquillian.junit.InSequence;
|
||||
import org.jboss.arquillian.persistence.PersistenceTest;
|
||||
import org.jboss.arquillian.persistence.ShouldMatchDataSet;
|
||||
import org.jboss.arquillian.persistence.UsingDataSet;
|
||||
import org.jboss.arquillian.transaction.api.annotation.TransactionMode;
|
||||
import org.jboss.arquillian.transaction.api.annotation.Transactional;
|
||||
|
|
@ -49,6 +53,10 @@ import org.junit.experimental.categories.Category;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.libreccm.tests.categories.IntegrationTest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Query;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
|
|
@ -92,10 +100,10 @@ public class UserRepositoryTest {
|
|||
@Deployment
|
||||
public static WebArchive createDeployment() {
|
||||
final PomEquippedResolveStage pom = Maven
|
||||
.resolver()
|
||||
.loadPomFromFile("pom.xml");
|
||||
.resolver()
|
||||
.loadPomFromFile("pom.xml");
|
||||
final PomEquippedResolveStage dependencies = pom.
|
||||
importCompileAndRuntimeDependencies();
|
||||
importCompileAndRuntimeDependencies();
|
||||
final File[] libs = dependencies.resolve().withTransitivity().asFile();
|
||||
|
||||
for (File lib : libs) {
|
||||
|
|
@ -104,26 +112,26 @@ public class UserRepositoryTest {
|
|||
}
|
||||
|
||||
return ShrinkWrap
|
||||
.create(WebArchive.class,
|
||||
"LibreCCM-org.libreccm.core.UserRepositoryTest.war")
|
||||
.addPackage(User.class.getPackage())
|
||||
.addPackage(org.libreccm.web.Application.class.getPackage())
|
||||
.addPackage(org.libreccm.categorization.Category.class.
|
||||
getPackage())
|
||||
.addPackage(org.libreccm.l10n.LocalizedString.class.getPackage()).
|
||||
addPackage(org.libreccm.jpa.EntityManagerProducer.class
|
||||
.getPackage())
|
||||
.addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class
|
||||
.getPackage())
|
||||
.addPackage(org.libreccm.testutils.EqualsVerifier.class.
|
||||
getPackage())
|
||||
.addPackage(org.libreccm.tests.categories.IntegrationTest.class
|
||||
.getPackage())
|
||||
.addAsLibraries(libs)
|
||||
.addAsResource("test-persistence.xml",
|
||||
"META-INF/persistence.xml")
|
||||
.addAsWebInfResource("test-web.xml", "WEB-INF/web.xml")
|
||||
.addAsWebInfResource(EmptyAsset.INSTANCE, "WEB-INF/beans.xml");
|
||||
.create(WebArchive.class,
|
||||
"LibreCCM-org.libreccm.core.UserRepositoryTest.war")
|
||||
.addPackage(User.class.getPackage())
|
||||
.addPackage(org.libreccm.web.Application.class.getPackage())
|
||||
.addPackage(org.libreccm.categorization.Category.class.
|
||||
getPackage())
|
||||
.addPackage(org.libreccm.l10n.LocalizedString.class.getPackage()).
|
||||
addPackage(org.libreccm.jpa.EntityManagerProducer.class
|
||||
.getPackage())
|
||||
.addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class
|
||||
.getPackage())
|
||||
.addPackage(org.libreccm.testutils.EqualsVerifier.class.
|
||||
getPackage())
|
||||
.addPackage(org.libreccm.tests.categories.IntegrationTest.class
|
||||
.getPackage())
|
||||
.addAsLibraries(libs)
|
||||
.addAsResource("test-persistence.xml",
|
||||
"META-INF/persistence.xml")
|
||||
.addAsWebInfResource("test-web.xml", "WEB-INF/web.xml")
|
||||
.addAsWebInfResource(EmptyAsset.INSTANCE, "WEB-INF/beans.xml");
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -137,11 +145,11 @@ public class UserRepositoryTest {
|
|||
assertThat(entityManager, is(not(nullValue())));
|
||||
}
|
||||
|
||||
private void checkUsers(final User jdoe,
|
||||
final User mmuster,
|
||||
final User joe,
|
||||
private void checkUsers(final User jdoe,
|
||||
final User mmuster,
|
||||
final User joe,
|
||||
final User nobody) {
|
||||
assertThat(jdoe, is(not(nullValue())));
|
||||
assertThat(jdoe, is(not(nullValue())));
|
||||
assertThat(jdoe.getSubjectId(), is(-10L));
|
||||
assertThat(jdoe.getScreenName(), is(JDOE));
|
||||
assertThat(jdoe.getName().getFamilyName(), is(equalTo("Doe")));
|
||||
|
|
@ -176,24 +184,23 @@ public class UserRepositoryTest {
|
|||
assertThat(nobody, is(nullValue()));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@UsingDataSet(
|
||||
"datasets/org/libreccm/core/UserRepositoryTest/data.json")
|
||||
@InSequence(10)
|
||||
"datasets/org/libreccm/core/UserRepositoryTest/data.json")
|
||||
@InSequence(100)
|
||||
public void findUserById() {
|
||||
final User jdoe = userRepository.findById(-10L);
|
||||
final User mmuster = userRepository.findById(-20L);
|
||||
final User joe = userRepository.findById(-30L);
|
||||
final User nobody = userRepository.findById(-999L);
|
||||
|
||||
|
||||
checkUsers(jdoe, mmuster, joe, nobody);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@UsingDataSet(
|
||||
"datasets/org/libreccm/core/UserRepositoryTest/data.json")
|
||||
@InSequence(20)
|
||||
@UsingDataSet("datasets/org/libreccm/core/UserRepositoryTest/data.json")
|
||||
@InSequence(200)
|
||||
public void findUserByScreenName() {
|
||||
final User jdoe = userRepository.findByScreenName(JDOE);
|
||||
final User mmuster = userRepository.findByScreenName(MMUSTER);
|
||||
|
|
@ -201,94 +208,130 @@ public class UserRepositoryTest {
|
|||
final User nobody = userRepository.findByScreenName(NOBODY);
|
||||
|
||||
checkUsers(jdoe, mmuster, joe, nobody);
|
||||
|
||||
// assertThat(jdoe, is(not(nullValue())));
|
||||
// assertThat(jdoe.getSubjectId(), is(-10L));
|
||||
// assertThat(jdoe.getScreenName(), is(JDOE));
|
||||
// assertThat(jdoe.getName().getFamilyName(), is(equalTo("Doe")));
|
||||
// assertThat(jdoe.getName().getMiddleName(), is(nullValue()));
|
||||
// assertThat(jdoe.getName().getGivenName(), is(equalTo("John")));
|
||||
// assertThat(jdoe.getHashAlgorithm(), is("MD5"));
|
||||
// assertThat(jdoe.getPassword(), is("604622dc8a888eb093454ebd77ca1675"));
|
||||
// assertThat(jdoe.getSalt(), is("axg8ira8fa"));
|
||||
//
|
||||
// assertThat(mmuster, is(not(nullValue())));
|
||||
// assertThat(mmuster.getSubjectId(), is(-20L));
|
||||
// assertThat(mmuster.getScreenName(), is(equalTo(MMUSTER)));
|
||||
// assertThat(mmuster.getName().getFamilyName(), is(equalTo("Mustermann")));
|
||||
// assertThat(mmuster.getName().getMiddleName(), is(nullValue()));
|
||||
// assertThat(mmuster.getName().getGivenName(), is(equalTo("Max")));
|
||||
// assertThat(mmuster.getHashAlgorithm(), is(equalTo("SHA-512")));
|
||||
// assertThat(mmuster.getPassword(), is(equalTo(
|
||||
// "1c9626af429a6291766d15cbfb38689bd8d49450520765973de70aecaf644b7d4fda711266ba9ec8fb6df30c8ab391d40330829aa85adf371bcde6b4c9bc01e6")));
|
||||
// assertThat(mmuster.getSalt(), is(equalTo("fjiajhigafgapoa")));
|
||||
//
|
||||
// assertThat(joe, is(not(nullValue())));
|
||||
// assertThat(joe.getSubjectId(), is(-30L));
|
||||
// assertThat(joe.getScreenName(), is(equalTo(JOE)));
|
||||
// assertThat(joe.getName().getFamilyName(), is(equalTo("Public")));
|
||||
// assertThat(joe.getName().getMiddleName(), is(nullValue()));
|
||||
// assertThat(joe.getName().getGivenName(), is(equalTo("Joe")));
|
||||
// assertThat(joe.getHashAlgorithm(), is(equalTo("SHA-512")));
|
||||
// assertThat(joe.getPassword(), is(equalTo(
|
||||
// "4e39eba7f2927182a532cd8700bf251e58d4b0359fbb832e6af21db7501d7a49e6d8b950e0d4b15b1841af0f786c8edaa0c09ef7f474804254f7e895969d2975")));
|
||||
// assertThat(joe.getSalt(), is(equalTo("axg8ira8fa")));
|
||||
//
|
||||
// assertThat(nobody, is(nullValue()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@UsingDataSet(
|
||||
"datasets/org/libreccm/core/UserRepositoryTest/data.json")
|
||||
@InSequence(30)
|
||||
@UsingDataSet("datasets/org/libreccm/core/UserRepositoryTest/data.json")
|
||||
@InSequence(300)
|
||||
public void findUserByEmail() {
|
||||
final User jdoe = userRepository.findByEmailAddress("john.doe@example.com");
|
||||
final User mmuster1 = userRepository.findByEmailAddress("max.mustermann@example.org");
|
||||
final User mmuster2 = userRepository.findByEmailAddress("mm@example.com");
|
||||
final User joe = userRepository.findByEmailAddress("joe.public@example.com");
|
||||
final User nobody = userRepository.findByScreenName("nobody@example.org");
|
||||
final User jdoe = userRepository.findByEmailAddress(
|
||||
"john.doe@example.com");
|
||||
final User mmuster1 = userRepository.findByEmailAddress(
|
||||
"max.mustermann@example.org");
|
||||
final User mmuster2 = userRepository
|
||||
.findByEmailAddress("mm@example.com");
|
||||
final User joe = userRepository.findByEmailAddress(
|
||||
"joe.public@example.com");
|
||||
final User nobody = userRepository
|
||||
.findByEmailAddress("nobody@example.org");
|
||||
|
||||
checkUsers(jdoe, mmuster1, joe, nobody);
|
||||
|
||||
assertThat(mmuster2, is(equalTo(mmuster1)));
|
||||
|
||||
// assertThat(jdoe, is(not(nullValue())));
|
||||
// assertThat(jdoe.getSubjectId(), is(-10L));
|
||||
// assertThat(jdoe.getScreenName(), is(JDOE));
|
||||
// assertThat(jdoe.getName().getFamilyName(), is(equalTo("Doe")));
|
||||
// assertThat(jdoe.getName().getMiddleName(), is(nullValue()));
|
||||
// assertThat(jdoe.getName().getGivenName(), is(equalTo("John")));
|
||||
// assertThat(jdoe.getHashAlgorithm(), is("MD5"));
|
||||
// assertThat(jdoe.getPassword(), is("604622dc8a888eb093454ebd77ca1675"));
|
||||
// assertThat(jdoe.getSalt(), is("axg8ira8fa"));
|
||||
//
|
||||
// assertThat(mmuster1, is(not(nullValue())));
|
||||
// assertThat(mmuster1.getSubjectId(), is(-20L));
|
||||
// assertThat(mmuster1.getScreenName(), is(equalTo(MMUSTER)));
|
||||
// assertThat(mmuster1.getName().getFamilyName(), is(equalTo("Mustermann")));
|
||||
// assertThat(mmuster1.getName().getMiddleName(), is(nullValue()));
|
||||
// assertThat(mmuster1.getName().getGivenName(), is(equalTo("Max")));
|
||||
// assertThat(mmuster1.getHashAlgorithm(), is(equalTo("SHA-512")));
|
||||
// assertThat(mmuster1.getPassword(), is(equalTo(
|
||||
// "1c9626af429a6291766d15cbfb38689bd8d49450520765973de70aecaf644b7d4fda711266ba9ec8fb6df30c8ab391d40330829aa85adf371bcde6b4c9bc01e6")));
|
||||
// assertThat(mmuster1.getSalt(), is(equalTo("fjiajhigafgapoa")));
|
||||
//
|
||||
// assertThat(mmuster2, is(equalTo(mmuster1)));
|
||||
// //assertThat(mmuster2.equals(mmuster1), is(true));
|
||||
//
|
||||
// assertThat(joe, is(not(nullValue())));
|
||||
// assertThat(joe.getSubjectId(), is(-30L));
|
||||
// assertThat(joe.getScreenName(), is(equalTo(JOE)));
|
||||
// assertThat(joe.getName().getFamilyName(), is(equalTo("Public")));
|
||||
// assertThat(joe.getName().getMiddleName(), is(nullValue()));
|
||||
// assertThat(joe.getName().getGivenName(), is(equalTo("Joe")));
|
||||
// assertThat(joe.getHashAlgorithm(), is(equalTo("SHA-512")));
|
||||
// assertThat(joe.getPassword(), is(equalTo(
|
||||
// "4e39eba7f2927182a532cd8700bf251e58d4b0359fbb832e6af21db7501d7a49e6d8b950e0d4b15b1841af0f786c8edaa0c09ef7f474804254f7e895969d2975")));
|
||||
// assertThat(joe.getSalt(), is(equalTo("axg8ira8fa")));
|
||||
//
|
||||
// assertThat(nobody, is(nullValue()));
|
||||
|
||||
assertThat(mmuster2, is(equalTo(mmuster1)));
|
||||
}
|
||||
|
||||
@Test(expected = MultipleMatchingUserException.class)
|
||||
@ShouldThrowException(MultipleMatchingUserException.class)
|
||||
@UsingDataSet(
|
||||
"datasets/org/libreccm/core/UserRepositoryTest/data-email-duplicate.json")
|
||||
@InSequence(350)
|
||||
public void findByEmailAddressDuplicate() {
|
||||
userRepository.findByEmailAddress("max.mustermann@example.org");
|
||||
}
|
||||
|
||||
@Test
|
||||
@UsingDataSet("datasets/org/libreccm/core/UserRepositoryTest/data.json")
|
||||
@InSequence(400)
|
||||
public void findAllUsers() {
|
||||
final List<User> users = userRepository.findAll();
|
||||
|
||||
assertThat(users.size(), is(3));
|
||||
}
|
||||
|
||||
@Test
|
||||
@UsingDataSet("datasets/org/libreccm/core/UserRepositoryTest/data.json")
|
||||
@ShouldMatchDataSet(value
|
||||
= "datasets/org/libreccm/core/UserRepositoryTest/after-save-new.json",
|
||||
excludeColumns = {"subject_id"})
|
||||
@InSequence(500)
|
||||
public void saveNewUser() {
|
||||
final User user = new User();
|
||||
|
||||
final PersonName personName = new PersonName();
|
||||
personName.setGivenName("Jane");
|
||||
personName.setMiddleName("Anna");
|
||||
personName.setFamilyName("Doe");
|
||||
personName.setTitlePre("Dr.");
|
||||
user.setName(personName);
|
||||
|
||||
final EmailAddress emailAddress = new EmailAddress();
|
||||
emailAddress.setAddress("jane.doe@example.org");
|
||||
emailAddress.setBouncing(false);
|
||||
emailAddress.setVerified(false);
|
||||
user.addEmailAddress(emailAddress);
|
||||
|
||||
user.setScreenName("jane");
|
||||
user.setPassword(
|
||||
"32d2a830fb03f201bda975ae70a62c207716705a049e054cf6701de1cec546d3a9e03a094be2e98e4d125af996ebbfa5a7754754a1e9d2fe063a0d9921cb201d");
|
||||
user.setHashAlgorithm("SHA-512");
|
||||
user.setSalt("maifgaoapafga9");
|
||||
user.setPasswordResetRequired(false);
|
||||
|
||||
userRepository.save(user);
|
||||
}
|
||||
|
||||
@Test
|
||||
@UsingDataSet("datasets/org/libreccm/core/UserRepositoryTest/data.json")
|
||||
@ShouldMatchDataSet(value
|
||||
= "datasets/org/libreccm/core/UserRepositoryTest/after-save-changed.json",
|
||||
excludeColumns = {"subject_id"})
|
||||
@InSequence(600)
|
||||
public void saveChangedUser() {
|
||||
final User user = userRepository.findById(-10L);
|
||||
|
||||
user.getName().setTitlePre("Dr.");
|
||||
|
||||
user.setHashAlgorithm("SHA-512");
|
||||
user.setPassword(
|
||||
"19f69a0f8eab3e6124d1b40ca2ae1fc3ece311cf86dde4e9560521e881fb8f063817cf1da1234144825f40fc9b9acd1563cafcb35fb8533544a1b6c3615160e3");
|
||||
user.setSalt("fafjiaddfja0a");
|
||||
|
||||
final EmailAddress emailAddress = new EmailAddress();
|
||||
emailAddress.setAddress("jd@example.com");
|
||||
emailAddress.setBouncing(false);
|
||||
emailAddress.setVerified(true);
|
||||
user.addEmailAddress(emailAddress);
|
||||
|
||||
final EmailAddress old = user.getEmailAddresses().get(0);
|
||||
user.removeEmailAddress(old);
|
||||
|
||||
userRepository.save(user);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
@InSequence(700)
|
||||
public void saveNullValue() {
|
||||
userRepository.save(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
@UsingDataSet("datasets/org/libreccm/core/UserRepositoryTest/data.json")
|
||||
@ShouldMatchDataSet(value
|
||||
= "datasets/org/libreccm/core/UserRepositoryTest/after-delete.json",
|
||||
excludeColumns = {"subject_id"})
|
||||
@InSequence(800)
|
||||
public void deleteUser() {
|
||||
final User user = userRepository.findByScreenName("mmuster");
|
||||
|
||||
userRepository.delete(user);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
@InSequence(900)
|
||||
public void deleteNullValue() {
|
||||
userRepository.delete(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,16 +30,10 @@
|
|||
"hash_algorithm": "MD5",
|
||||
"family_name": "Doe",
|
||||
"given_name": "John",
|
||||
"middle_name": null,
|
||||
"title_post": null,
|
||||
"title_pre": null,
|
||||
"password": "604622dc8a888eb093454ebd77ca1675",
|
||||
"password_answer": null,
|
||||
"password_question": null,
|
||||
"password_reset_required": false,
|
||||
"salt": "axg8ira8fa",
|
||||
"screen_name": "jdoe",
|
||||
"sso_login": null,
|
||||
"subject_id": -10
|
||||
},
|
||||
{
|
||||
|
|
@ -47,16 +41,10 @@
|
|||
"hash_algorithm": "SHA-512",
|
||||
"family_name": "Public",
|
||||
"given_name": "Joe",
|
||||
"middle_name": null,
|
||||
"title_post": null,
|
||||
"title_pre": null,
|
||||
"password": "e9db883a56149f7521a00713c4d7b0c967ae42cc3f0dfcf96ccd0180c498abf57209a90db9cb5df3a7d23d4111e87578e09ea610e9c1d95c4695710e28c5ab02",
|
||||
"password_answer": null,
|
||||
"password_question": null,
|
||||
"password": "4e39eba7f2927182a532cd8700bf251e58d4b0359fbb832e6af21db7501d7a49e6d8b950e0d4b15b1841af0f786c8edaa0c09ef7f474804254f7e895969d2975",
|
||||
"password_reset_required": false,
|
||||
"salt": "axg8ira8fa",
|
||||
"screen_name": "joe",
|
||||
"sso_login": null,
|
||||
"subject_id": -30
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
[
|
||||
{
|
||||
"subject_id": -10,
|
||||
"email_address": "john.doe@example.com",
|
||||
"email_address": "jd@example.com",
|
||||
"bouncing": false,
|
||||
"verified": true
|
||||
},
|
||||
|
|
@ -45,16 +45,11 @@
|
|||
"hash_algorithm": "SHA-512",
|
||||
"family_name": "Doe",
|
||||
"given_name": "John",
|
||||
"middle_name": null,
|
||||
"title_post": null,
|
||||
"title_pre": null,
|
||||
"title_pre": "Dr.",
|
||||
"password": "19f69a0f8eab3e6124d1b40ca2ae1fc3ece311cf86dde4e9560521e881fb8f063817cf1da1234144825f40fc9b9acd1563cafcb35fb8533544a1b6c3615160e3",
|
||||
"password_answer": null,
|
||||
"password_question": null,
|
||||
"password_reset_required": false,
|
||||
"salt": "fafjiaddfja0a",
|
||||
"screen_name": "jdoe",
|
||||
"sso_login": null,
|
||||
"subject_id": -10
|
||||
},
|
||||
{
|
||||
|
|
@ -62,16 +57,10 @@
|
|||
"hash_algorithm": "SHA-512",
|
||||
"family_name": "Mustermann",
|
||||
"given_name": "Max",
|
||||
"middle_name": null,
|
||||
"title_post": null,
|
||||
"title_pre": null,
|
||||
"password": "3428dfa9bb199f3372eb73c5feb038aef5bcbbfd4fada24c44026a25c883a9f2af8b84410a3b2684430d359f78400ad92ff8c71634f2c9bf437f0cd56c5d90c3",
|
||||
"password_answer": null,
|
||||
"password_question": null,
|
||||
"password": "1c9626af429a6291766d15cbfb38689bd8d49450520765973de70aecaf644b7d4fda711266ba9ec8fb6df30c8ab391d40330829aa85adf371bcde6b4c9bc01e6",
|
||||
"password_reset_required": false,
|
||||
"salt": "fjiajhigafgapoa",
|
||||
"screen_name": "mmuster",
|
||||
"sso_login": null,
|
||||
"subject_id": -20
|
||||
},
|
||||
{
|
||||
|
|
@ -79,16 +68,10 @@
|
|||
"hash_algorithm": "SHA-512",
|
||||
"family_name": "Public",
|
||||
"given_name": "Joe",
|
||||
"middle_name": null,
|
||||
"title_post": null,
|
||||
"title_pre": null,
|
||||
"password": "e9db883a56149f7521a00713c4d7b0c967ae42cc3f0dfcf96ccd0180c498abf57209a90db9cb5df3a7d23d4111e87578e09ea610e9c1d95c4695710e28c5ab02",
|
||||
"password_answer": null,
|
||||
"password_question": null,
|
||||
"password": "4e39eba7f2927182a532cd8700bf251e58d4b0359fbb832e6af21db7501d7a49e6d8b950e0d4b15b1841af0f786c8edaa0c09ef7f474804254f7e895969d2975",
|
||||
"password_reset_required": false,
|
||||
"salt": "axg8ira8fa",
|
||||
"screen_name": "joe",
|
||||
"sso_login": null,
|
||||
"subject_id": -30
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -54,16 +54,10 @@
|
|||
"hash_algorithm": "MD5",
|
||||
"family_name": "Doe",
|
||||
"given_name": "John",
|
||||
"middle_name": null,
|
||||
"title_post": null,
|
||||
"title_pre": null,
|
||||
"password": "604622dc8a888eb093454ebd77ca1675",
|
||||
"password_answer": null,
|
||||
"password_question": null,
|
||||
"password_reset_required": false,
|
||||
"salt": "axg8ira8fa",
|
||||
"screen_name": "jdoe",
|
||||
"sso_login": null,
|
||||
"subject_id": -10
|
||||
},
|
||||
{
|
||||
|
|
@ -71,16 +65,10 @@
|
|||
"hash_algorithm": "SHA-512",
|
||||
"family_name": "Mustermann",
|
||||
"given_name": "Max",
|
||||
"middle_name": null,
|
||||
"title_post": null,
|
||||
"title_pre": null,
|
||||
"password": "3428dfa9bb199f3372eb73c5feb038aef5bcbbfd4fada24c44026a25c883a9f2af8b84410a3b2684430d359f78400ad92ff8c71634f2c9bf437f0cd56c5d90c3",
|
||||
"password_answer": null,
|
||||
"password_question": null,
|
||||
"password": "1c9626af429a6291766d15cbfb38689bd8d49450520765973de70aecaf644b7d4fda711266ba9ec8fb6df30c8ab391d40330829aa85adf371bcde6b4c9bc01e6",
|
||||
"password_reset_required": false,
|
||||
"salt": "fjiajhigafgapoa",
|
||||
"screen_name": "mmuster",
|
||||
"sso_login": null,
|
||||
"subject_id": -20
|
||||
},
|
||||
{
|
||||
|
|
@ -88,16 +76,10 @@
|
|||
"hash_algorithm": "SHA-512",
|
||||
"family_name": "Public",
|
||||
"given_name": "Joe",
|
||||
"middle_name": null,
|
||||
"title_post": null,
|
||||
"title_pre": null,
|
||||
"password": "e9db883a56149f7521a00713c4d7b0c967ae42cc3f0dfcf96ccd0180c498abf57209a90db9cb5df3a7d23d4111e87578e09ea610e9c1d95c4695710e28c5ab02",
|
||||
"password_answer": null,
|
||||
"password_question": null,
|
||||
"password": "4e39eba7f2927182a532cd8700bf251e58d4b0359fbb832e6af21db7501d7a49e6d8b950e0d4b15b1841af0f786c8edaa0c09ef7f474804254f7e895969d2975",
|
||||
"password_reset_required": false,
|
||||
"salt": "axg8ira8fa",
|
||||
"screen_name": "joe",
|
||||
"sso_login": null,
|
||||
"subject_id": -30
|
||||
},
|
||||
{
|
||||
|
|
@ -106,15 +88,11 @@
|
|||
"family_name": "Doe",
|
||||
"given_name": "Jane",
|
||||
"middle_name": "Anna",
|
||||
"title_post": null,
|
||||
"title_pre": "Dr.",
|
||||
"password": "32d2a830fb03f201bda975ae70a62c207716705a049e054cf6701de1cec546d3a9e03a094be2e98e4d125af996ebbfa5a7754754a1e9d2fe063a0d9921cb201d",
|
||||
"password_answer": null,
|
||||
"password_question": null,
|
||||
"password_reset_required": false,
|
||||
"salt": "maifgaoapafga9",
|
||||
"screen_name": "jane",
|
||||
"sso_login": null,
|
||||
"subject_id": -40
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,77 @@
|
|||
{
|
||||
"subjects":
|
||||
[
|
||||
{
|
||||
"subject_id": -10
|
||||
},
|
||||
{
|
||||
"subject_id": -20
|
||||
},
|
||||
{
|
||||
"subject_id": -30
|
||||
}
|
||||
],
|
||||
"subject_email_addresses":
|
||||
[
|
||||
{
|
||||
"subject_id": -10,
|
||||
"email_address": "john.doe@example.com",
|
||||
"bouncing": false,
|
||||
"verified": true
|
||||
},
|
||||
{
|
||||
"subject_id": -20,
|
||||
"email_address": "max.mustermann@example.org",
|
||||
"bouncing": false,
|
||||
"verified": true
|
||||
},
|
||||
{
|
||||
"subject_id": -20,
|
||||
"email_address": "mm@example.com",
|
||||
"bouncing": false,
|
||||
"verified": true
|
||||
},
|
||||
{
|
||||
"subject_id": -30,
|
||||
"email_address": "max.mustermann@example.org",
|
||||
"bouncing": true,
|
||||
"verified": false
|
||||
}
|
||||
],
|
||||
"ccm_users":
|
||||
[
|
||||
{
|
||||
"banned": false,
|
||||
"hash_algorithm": "MD5",
|
||||
"family_name": "Doe",
|
||||
"given_name": "John",
|
||||
"password": "604622dc8a888eb093454ebd77ca1675",
|
||||
"password_reset_required": false,
|
||||
"salt": "axg8ira8fa",
|
||||
"screen_name": "jdoe",
|
||||
"subject_id": -10
|
||||
},
|
||||
{
|
||||
"banned": false,
|
||||
"hash_algorithm": "SHA-512",
|
||||
"family_name": "Mustermann",
|
||||
"given_name": "Max",
|
||||
"password": "1c9626af429a6291766d15cbfb38689bd8d49450520765973de70aecaf644b7d4fda711266ba9ec8fb6df30c8ab391d40330829aa85adf371bcde6b4c9bc01e6",
|
||||
"password_reset_required": false,
|
||||
"salt": "fjiajhigafgapoa",
|
||||
"screen_name": "mmuster",
|
||||
"subject_id": -20
|
||||
},
|
||||
{
|
||||
"banned": false,
|
||||
"hash_algorithm": "SHA-512",
|
||||
"family_name": "Public",
|
||||
"given_name": "Joe",
|
||||
"password": "4e39eba7f2927182a532cd8700bf251e58d4b0359fbb832e6af21db7501d7a49e6d8b950e0d4b15b1841af0f786c8edaa0c09ef7f474804254f7e895969d2975",
|
||||
"password_reset_required": false,
|
||||
"salt": "axg8ira8fa",
|
||||
"screen_name": "joe",
|
||||
"subject_id": -30
|
||||
}
|
||||
]
|
||||
}
|
||||
Loading…
Reference in New Issue