@@ -102,6 +102,7 @@ public class JDBCNodeStoreTest {
102102 "user1@server1/resource" );
103103 private static final JID TEST_SERVER1_USER2_JID = new JID ("user2@server1" );
104104 private static final JID TEST_SERVER1_USER3_JID = new JID ("user3@server1" );
105+ private static final JID TEST_SERVER1_OUTCAST_JID = new JID ("outcast@server1" );
105106
106107 private static final JID TEST_SERVER2_USER1_JID = new JID ("user1@server2" );
107108 private static final JID TEST_SERVER2_USER2_JID = new JID ("user2@server2" );
@@ -873,6 +874,38 @@ public void testGetNodeAffiliations() throws Exception {
873874 assertTrue ("Incorrect node affiliations returned" ,
874875 CollectionUtils .isEqualCollection (expected , result ));
875876 }
877+
878+ @ Test
879+ public void testGetNodeAffiliationsByOwnerModerator () throws Exception {
880+ dbTester .loadData ("node_1" );
881+
882+ ResultSet <NodeAffiliation > result = store
883+ .getNodeAffiliations (TEST_SERVER1_NODE1_ID , true );
884+
885+ HashSet <NodeAffiliation > expected = new HashSet <NodeAffiliation >() {
886+ {
887+ add (new NodeAffiliationImpl (TEST_SERVER1_NODE1_ID ,
888+ TEST_SERVER1_USER1_JID , Affiliations .owner , new Date ()));
889+ add (new NodeAffiliationImpl (TEST_SERVER1_NODE1_ID ,
890+ TEST_SERVER1_USER2_JID , Affiliations .publisher ,
891+ new Date ()));
892+ add (new NodeAffiliationImpl (TEST_SERVER1_NODE1_ID ,
893+ TEST_SERVER2_USER1_JID , Affiliations .publisher ,
894+ new Date ()));
895+ add (new NodeAffiliationImpl (TEST_SERVER1_NODE1_ID ,
896+ TEST_SERVER2_USER3_JID , Affiliations .member ,
897+ new Date ()));
898+ add (new NodeAffiliationImpl (TEST_SERVER1_NODE1_ID ,
899+ TEST_SERVER1_OUTCAST_JID , Affiliations .outcast ,
900+ new Date ()));
901+ }
902+ };
903+
904+ assertEquals ("Incorrect number of node affiliations returned" ,
905+ expected .size (), result .size ());
906+ assertTrue ("Incorrect node affiliations returned" ,
907+ CollectionUtils .isEqualCollection (expected , result ));
908+ }
876909
877910 @ Test
878911 public void testCanGetNodeAffiliationsWithRsm () throws Exception {
@@ -897,6 +930,30 @@ public void testCanGetNodeAffiliationsWithRsm() throws Exception {
897930 assertEquals (1 , result1 .size ());
898931 assertEquals (4 , result2 .size ());
899932 }
933+
934+ @ Test
935+ public void testCanGetNodeAffiliationsForOwnerModeratorWithRsm () throws Exception {
936+ dbTester .loadData ("node_1" );
937+
938+ store .setUserAffiliation (TEST_SERVER1_NODE1_ID , TEST_SERVER1_USER2_JID ,
939+ Affiliations .member );
940+ Thread .sleep (1 );
941+ store .setUserAffiliation (TEST_SERVER1_NODE1_ID , TEST_SERVER1_USER3_JID ,
942+ Affiliations .member );
943+
944+ ResultSet <NodeAffiliation > result = store .getNodeAffiliations (
945+ TEST_SERVER1_NODE1_ID , true , TEST_SERVER1_USER3_JID .toBareJID (), 50 );
946+
947+ ResultSet <NodeAffiliation > result1 = store .getNodeAffiliations (
948+ TEST_SERVER1_NODE1_ID , true , TEST_SERVER1_USER2_JID .toBareJID (), 50 );
949+
950+ ResultSet <NodeAffiliation > result2 = store .getNodeAffiliations (
951+ TEST_SERVER1_NODE1_ID , true , TEST_SERVER1_USER1_JID .toBareJID (), 50 );
952+
953+ assertEquals (0 , result .size ());
954+ assertEquals (1 , result1 .size ());
955+ assertEquals (5 , result2 .size ());
956+ }
900957
901958 @ Test
902959 public void testCanRetrictNodeAffiliationCountWithRsm () throws Exception {
@@ -912,12 +969,34 @@ public void testCanRetrictNodeAffiliationCountWithRsm() throws Exception {
912969 TEST_SERVER1_NODE1_ID , false , TEST_SERVER1_USER3_JID .toBareJID (), 1 );
913970 assertEquals (1 , result .size ());
914971 }
972+
973+ @ Test
974+ public void testCanRetrictNodeAffiliationForOwnerModeratorCountWithRsm () throws Exception {
975+ dbTester .loadData ("node_1" );
976+
977+ store .setUserAffiliation (TEST_SERVER1_NODE1_ID , TEST_SERVER1_USER3_JID ,
978+ Affiliations .member );
979+ Thread .sleep (1 );
980+ store .setUserAffiliation (TEST_SERVER1_NODE1_ID , TEST_SERVER1_USER2_JID ,
981+ Affiliations .member );
982+
983+ ResultSet <NodeAffiliation > result = store .getNodeAffiliations (
984+ TEST_SERVER1_NODE1_ID , true , TEST_SERVER1_USER3_JID .toBareJID (), 1 );
985+ assertEquals (1 , result .size ());
986+ }
915987
916988 @ Test
917989 public void testCanGetCountOfNodeAffiliations () throws Exception {
918990 int affiliations = store .countNodeAffiliations (TEST_SERVER1_NODE1_ID , false );
919991 assertEquals (0 , affiliations );
920992 }
993+
994+
995+ @ Test
996+ public void testCanGetCountOfNodeAffiliationsForOwnerModerator () throws Exception {
997+ int affiliations = store .countNodeAffiliations (TEST_SERVER1_NODE1_ID , true );
998+ assertEquals (0 , affiliations );
999+ }
9211000
9221001 @ Test
9231002 public void testCanGetCountOfNodeAffiliationWithResults () throws Exception {
@@ -926,6 +1005,13 @@ public void testCanGetCountOfNodeAffiliationWithResults() throws Exception {
9261005 assertEquals (4 , affiliations );
9271006 }
9281007
1008+ @ Test
1009+ public void testCanGetCountOfNodeAffiliationForOwnerModeratorWithResults () throws Exception {
1010+ dbTester .loadData ("node_1" );
1011+ int affiliations = store .countNodeAffiliations (TEST_SERVER1_NODE1_ID , true );
1012+ assertEquals (5 , affiliations );
1013+ }
1014+
9291015 @ Test
9301016 public void testGetUserSubscription () throws Exception {
9311017 dbTester .loadData ("node_1" );
0 commit comments