NIHVIVO-2343 Create method: UserAccountsDao.setProxyAccountsOnProfile() and use it.
This commit is contained in:
parent
7b581308af
commit
6f651fcf4f
6 changed files with 129 additions and 2 deletions
|
@ -58,6 +58,9 @@ public class UserAccountsDaoJenaTest extends AbstractTestClass {
|
|||
private static final String URI_ROLE2 = NS_MINE + "role2";
|
||||
private static final String URI_ROLE3 = NS_MINE + "role3";
|
||||
|
||||
private static final String URI_PROFILE1 = NS_MINE + "profile1";
|
||||
private static final String URI_PROFILE2 = NS_MINE + "profile2";
|
||||
|
||||
private OntModel ontModel;
|
||||
private WebappDaoFactoryJena wadf;
|
||||
private UserAccountsDaoJena dao;
|
||||
|
@ -65,6 +68,10 @@ public class UserAccountsDaoJenaTest extends AbstractTestClass {
|
|||
private UserAccount user1;
|
||||
private UserAccount userNew;
|
||||
|
||||
private UserAccount userA;
|
||||
private UserAccount userB;
|
||||
private UserAccount userC;
|
||||
|
||||
@Before
|
||||
public void setup() throws IOException {
|
||||
InputStream stream = UserAccountsDaoJenaTest.class
|
||||
|
@ -89,6 +96,16 @@ public class UserAccountsDaoJenaTest extends AbstractTestClass {
|
|||
userNew = userAccount("", "email@here", "Joe", "Blow", "XXXX", "YYYY",
|
||||
0L, false, 1, 0L, Status.ACTIVE, "jblow", false, EMPTY, false,
|
||||
EMPTY);
|
||||
|
||||
userA = userAccount("", "aahern@here", "Alf", "Ahern", "XXXX", "YYYY",
|
||||
0L, false, 1, 0L, Status.ACTIVE, "aahern", false, EMPTY, false,
|
||||
collection(URI_PROFILE1));
|
||||
userB = userAccount("", "email@here", "Betty", "Boop", "XXXX", "YYYY",
|
||||
0L, false, 1, 0L, Status.ACTIVE, "bboop", false, EMPTY, false,
|
||||
collection(URI_PROFILE1, URI_PROFILE2));
|
||||
userC = userAccount("", "ccallas@here", "Charlie", "Callas", "XXXX",
|
||||
"YYYY", 0L, false, 1, 0L, Status.ACTIVE, "ccallas", false,
|
||||
EMPTY, false, collection(URI_PROFILE2));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
@ -232,6 +249,10 @@ public class UserAccountsDaoJenaTest extends AbstractTestClass {
|
|||
assertEqualAccounts(user1, updated);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Tests for proxy-related methods
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@Test
|
||||
public void getProxyEditorsFirst() {
|
||||
String profileOne = NS_MINE + "userNewProxyOne";
|
||||
|
@ -274,6 +295,22 @@ public class UserAccountsDaoJenaTest extends AbstractTestClass {
|
|||
dao.getUserAccountsWhoProxyForPage(bogusProfile));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setProxyEditorsOnProfile() {
|
||||
String uriA = dao.insertUserAccount(userA);
|
||||
String uriB = dao.insertUserAccount(userB);
|
||||
String uriC = dao.insertUserAccount(userC);
|
||||
|
||||
dao.setProxyAccountsOnProfile(URI_PROFILE1, collection(uriB, uriC));
|
||||
|
||||
assertExpectedProxies("userA", collection(),
|
||||
dao.getUserAccountByUri(uriA).getProxiedIndividualUris());
|
||||
assertExpectedProxies("userB", collection(URI_PROFILE1, URI_PROFILE2),
|
||||
dao.getUserAccountByUri(uriB).getProxiedIndividualUris());
|
||||
assertExpectedProxies("userC", collection(URI_PROFILE1, URI_PROFILE2),
|
||||
dao.getUserAccountByUri(uriC).getProxiedIndividualUris());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Tests for PermissionSet methods
|
||||
// ----------------------------------------------------------------------
|
||||
|
@ -448,6 +485,12 @@ public class UserAccountsDaoJenaTest extends AbstractTestClass {
|
|||
assertEqualSets(label, expectedUris, actualUris);
|
||||
}
|
||||
|
||||
private void assertExpectedProxies(String label,
|
||||
Collection<String> expected, Set<String> actual) {
|
||||
Set<String> expectedSet = new HashSet<String>(expected);
|
||||
assertEqualSets(label, expectedSet, actual);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void dumpModelStatements() {
|
||||
StmtIterator stmts = ontModel.listStatements();
|
||||
|
|
|
@ -97,4 +97,11 @@ public class UserAccountsDaoStub implements UserAccountsDao {
|
|||
"UserAccountsDaoStub.getUserAccountsWhoProxyForPage() not implemented.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProxyAccountsOnProfile(String profilePageUri,
|
||||
Collection<String> userAccountUris) {
|
||||
throw new RuntimeException(
|
||||
"UserAccountsDaoStub.setProxyAccountsOnProfile() not implemented.");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue