- Improved test of UserRepository
- Cleanup script for MySQL git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@3504 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
fe84be3340
commit
e1e7d936be
|
|
@ -135,7 +135,6 @@ public class Subject implements Serializable {
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int hash = 7;
|
int hash = 7;
|
||||||
hash = 53 * hash + (int) (subjectId ^ (subjectId >>> 32));
|
hash = 53 * hash + (int) (subjectId ^ (subjectId >>> 32));
|
||||||
hash = 53 * hash + Objects.hashCode(emailAddresses);
|
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -156,7 +155,7 @@ public class Subject implements Serializable {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Objects.equals(emailAddresses, other.getEmailAddresses());
|
return (subjectId == other.getSubjectId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canEqual(final Object obj) {
|
public boolean canEqual(final Object obj) {
|
||||||
|
|
@ -172,7 +171,8 @@ public class Subject implements Serializable {
|
||||||
return String.format("%s{ "
|
return String.format("%s{ "
|
||||||
+ "subjectId = %d, "
|
+ "subjectId = %d, "
|
||||||
+ "emailAddresses = %s"
|
+ "emailAddresses = %s"
|
||||||
+ "%s}",
|
+ "%s"
|
||||||
|
+ " }",
|
||||||
super.toString(),
|
super.toString(),
|
||||||
subjectId,
|
subjectId,
|
||||||
Objects.toString(emailAddresses),
|
Objects.toString(emailAddresses),
|
||||||
|
|
|
||||||
|
|
@ -351,8 +351,8 @@ public class User extends Subject implements Serializable {
|
||||||
return super.toString(String.format(", name = %s, "
|
return super.toString(String.format(", name = %s, "
|
||||||
+ "screenName = \"%s\", "
|
+ "screenName = \"%s\", "
|
||||||
+ "banned = %b, "
|
+ "banned = %b, "
|
||||||
+ "ssoLogin = \"%s\""
|
+ "ssoLogin = \"%s\" "
|
||||||
+ "hashAlgorithm = \"%s\""
|
+ "hashAlgorithm = \"%s\" "
|
||||||
+ "passwordResetRequired = %b%s",
|
+ "passwordResetRequired = %b%s",
|
||||||
Objects.toString(name),
|
Objects.toString(name),
|
||||||
screenName,
|
screenName,
|
||||||
|
|
|
||||||
|
|
@ -137,17 +137,11 @@ public class UserRepositoryTest {
|
||||||
assertThat(entityManager, is(not(nullValue())));
|
assertThat(entityManager, is(not(nullValue())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
private void checkUsers(final User jdoe,
|
||||||
@UsingDataSet(
|
final User mmuster,
|
||||||
"datasets/org/libreccm/core/UserRepositoryTest/data.json")
|
final User joe,
|
||||||
@InSequence(10)
|
final User nobody) {
|
||||||
public void findUserByScreenName() {
|
assertThat(jdoe, is(not(nullValue())));
|
||||||
final User jdoe = userRepository.findByScreenName(JDOE);
|
|
||||||
final User mmuster = userRepository.findByScreenName(MMUSTER);
|
|
||||||
final User joe = userRepository.findByScreenName(JOE);
|
|
||||||
final User nobody = userRepository.findByScreenName(NOBODY);
|
|
||||||
|
|
||||||
assertThat(jdoe, is(not(nullValue())));
|
|
||||||
assertThat(jdoe.getSubjectId(), is(-10L));
|
assertThat(jdoe.getSubjectId(), is(-10L));
|
||||||
assertThat(jdoe.getScreenName(), is(JDOE));
|
assertThat(jdoe.getScreenName(), is(JDOE));
|
||||||
assertThat(jdoe.getName().getFamilyName(), is(equalTo("Doe")));
|
assertThat(jdoe.getName().getFamilyName(), is(equalTo("Doe")));
|
||||||
|
|
@ -180,12 +174,73 @@ public class UserRepositoryTest {
|
||||||
assertThat(joe.getSalt(), is(equalTo("axg8ira8fa")));
|
assertThat(joe.getSalt(), is(equalTo("axg8ira8fa")));
|
||||||
|
|
||||||
assertThat(nobody, is(nullValue()));
|
assertThat(nobody, is(nullValue()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@UsingDataSet(
|
||||||
|
"datasets/org/libreccm/core/UserRepositoryTest/data.json")
|
||||||
|
@InSequence(10)
|
||||||
|
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)
|
||||||
|
public void findUserByScreenName() {
|
||||||
|
final User jdoe = userRepository.findByScreenName(JDOE);
|
||||||
|
final User mmuster = userRepository.findByScreenName(MMUSTER);
|
||||||
|
final User joe = userRepository.findByScreenName(JOE);
|
||||||
|
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
|
@Test
|
||||||
@UsingDataSet(
|
@UsingDataSet(
|
||||||
"datasets/org/libreccm/core/UserRepositoryTest/data.json")
|
"datasets/org/libreccm/core/UserRepositoryTest/data.json")
|
||||||
@InSequence(20)
|
@InSequence(30)
|
||||||
public void findUserByEmail() {
|
public void findUserByEmail() {
|
||||||
final User jdoe = userRepository.findByEmailAddress("john.doe@example.com");
|
final User jdoe = userRepository.findByEmailAddress("john.doe@example.com");
|
||||||
final User mmuster1 = userRepository.findByEmailAddress("max.mustermann@example.org");
|
final User mmuster1 = userRepository.findByEmailAddress("max.mustermann@example.org");
|
||||||
|
|
@ -193,41 +248,46 @@ public class UserRepositoryTest {
|
||||||
final User joe = userRepository.findByEmailAddress("joe.public@example.com");
|
final User joe = userRepository.findByEmailAddress("joe.public@example.com");
|
||||||
final User nobody = userRepository.findByScreenName("nobody@example.org");
|
final User nobody = userRepository.findByScreenName("nobody@example.org");
|
||||||
|
|
||||||
assertThat(jdoe, is(not(nullValue())));
|
checkUsers(jdoe, mmuster1, joe, nobody);
|
||||||
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, is(equalTo(mmuster1)));
|
||||||
|
|
||||||
assertThat(joe, is(not(nullValue())));
|
// assertThat(jdoe, is(not(nullValue())));
|
||||||
assertThat(joe.getSubjectId(), is(-30L));
|
// assertThat(jdoe.getSubjectId(), is(-10L));
|
||||||
assertThat(joe.getScreenName(), is(equalTo(JOE)));
|
// assertThat(jdoe.getScreenName(), is(JDOE));
|
||||||
assertThat(joe.getName().getFamilyName(), is(equalTo("Public")));
|
// assertThat(jdoe.getName().getFamilyName(), is(equalTo("Doe")));
|
||||||
assertThat(joe.getName().getMiddleName(), is(nullValue()));
|
// assertThat(jdoe.getName().getMiddleName(), is(nullValue()));
|
||||||
assertThat(joe.getName().getGivenName(), is(equalTo("Joe")));
|
// assertThat(jdoe.getName().getGivenName(), is(equalTo("John")));
|
||||||
assertThat(joe.getHashAlgorithm(), is(equalTo("SHA-512")));
|
// assertThat(jdoe.getHashAlgorithm(), is("MD5"));
|
||||||
assertThat(joe.getPassword(), is(equalTo(
|
// assertThat(jdoe.getPassword(), is("604622dc8a888eb093454ebd77ca1675"));
|
||||||
"axg8ira8fa")));
|
// assertThat(jdoe.getSalt(), is("axg8ira8fa"));
|
||||||
assertThat(joe.getSalt(), is(equalTo("fjiajhigafgapoa")));
|
//
|
||||||
|
// assertThat(mmuster1, is(not(nullValue())));
|
||||||
assertThat(nobody, is(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()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
<extension qualifier="persistence-script">
|
<extension qualifier="persistence-script">
|
||||||
<property name="scriptsToExecuteAfterTest">scripts/pgsql-cleanup.sql</property>
|
<property name="scriptsToExecuteAfterTest">scripts/mysql-cleanup.sql</property>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1 +1,7 @@
|
||||||
DELETE FROM ccm_objects;
|
DELETE FROM ccm_objects;
|
||||||
|
|
||||||
|
DELETE FROM subject_email_addresses;
|
||||||
|
|
||||||
|
DELETE FROM ccm_users;
|
||||||
|
|
||||||
|
DELETE FROM subjects;
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
DELETE FROM ccm_objects;
|
||||||
|
|
||||||
|
DELETE FROM subject_email_addresses;
|
||||||
|
|
||||||
|
DELETE FROM ccm_users;
|
||||||
|
|
||||||
|
DELETE FROM subjects;
|
||||||
|
|
@ -1 +1,7 @@
|
||||||
DELETE FROM ccm_objects;
|
DELETE FROM ccm_objects;
|
||||||
|
|
||||||
|
DELETE FROM subject_email_addresses;
|
||||||
|
|
||||||
|
DELETE FROM ccm_users;
|
||||||
|
|
||||||
|
DELETE FROM subjects;
|
||||||
7
pom.xml
7
pom.xml
|
|
@ -15,6 +15,13 @@
|
||||||
|
|
||||||
<name>LibreCCM 3.0.0</name>
|
<name>LibreCCM 3.0.0</name>
|
||||||
<url>http://www.libreccm.org</url>
|
<url>http://www.libreccm.org</url>
|
||||||
|
<distributionManagement>
|
||||||
|
<site>
|
||||||
|
<id>libreccm-site</id>
|
||||||
|
<name>LibreCCM</name>
|
||||||
|
<url>http://www.libreccm.org/project-sites/</url>
|
||||||
|
</site>
|
||||||
|
</distributionManagement>
|
||||||
|
|
||||||
<organization>
|
<organization>
|
||||||
<name>LibreCCM Foundation</name>
|
<name>LibreCCM Foundation</name>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue