@@ -77,6 +77,8 @@ public class JDBCNodeStoreTest {
7777 private static final String TEST_SERVER1_HOSTNAME = "server1" ;
7878 private static final String TEST_SERVER2_HOSTNAME = "server2" ;
7979
80+ private static final String UNKNOWN_NODE = "/user/unknown@example.com/posts" ;
81+
8082 private static final HashMap <String , String > TEST_SERVER1_NODE1_CONF = new HashMap <String , String >() {
8183 {
8284 put ("config1" , "Value of config1" );
@@ -1322,16 +1324,18 @@ public void testGetNodeItemsWithPaging() throws Exception {
13221324 dbTester .loadData ("node_1" );
13231325
13241326 long start = System .currentTimeMillis ();
1325-
1327+
13261328 NodeItem [] items = new NodeItem [20 ];
1327-
1329+
13281330 for (int i = 0 ; i < 20 ; i ++) {
1329- items [i ] = new NodeItemImpl (TEST_SERVER1_NODE1_ID , String
1330- .valueOf (i ), new Date (start + i * 10 ), "payload" + String .valueOf (i ));
1331+ items [i ] = new NodeItemImpl (TEST_SERVER1_NODE1_ID ,
1332+ String .valueOf (i ), new Date (start + i * 10 ), "payload"
1333+ + String .valueOf (i ));
13311334 store .addNodeItem (items [i ]);
13321335 }
13331336
1334- CloseableIterator <NodeItem > result = store .getNodeItems (TEST_SERVER1_NODE1_ID , "15" , 3 );
1337+ CloseableIterator <NodeItem > result = store .getNodeItems (
1338+ TEST_SERVER1_NODE1_ID , "15" , 3 );
13351339
13361340 assertEquals ("Incorrect node item returned" , items [14 ], result .next ());
13371341 assertEquals ("Incorrect node item returned" , items [13 ], result .next ());
@@ -1565,7 +1569,7 @@ public void testGetRecentItemsCanBePaged() throws Exception {
15651569 store .addUserSubscription (new NodeSubscriptionImpl (
15661570 TEST_SERVER1_NODE2_ID , TEST_SERVER1_USER1_JID ,
15671571 Subscriptions .subscribed ));
1568-
1572+
15691573 long now = System .currentTimeMillis ();
15701574
15711575 NodeItem nodeItem1 = new NodeItemImpl (TEST_SERVER1_NODE1_ID , "123" ,
@@ -1585,7 +1589,9 @@ public void testGetRecentItemsCanBePaged() throws Exception {
15851589 store .addNodeItem (nodeItem4 );
15861590
15871591 CloseableIterator <NodeItem > items = store .getRecentItems (
1588- TEST_SERVER1_USER1_JID , since , -1 , 2 , new GlobalItemIDImpl (TEST_SERVER1_CHANNELS_JID , TEST_SERVER1_NODE1_ID , "124" ), null );
1592+ TEST_SERVER1_USER1_JID , since , -1 , 2 ,
1593+ new GlobalItemIDImpl (TEST_SERVER1_CHANNELS_JID ,
1594+ TEST_SERVER1_NODE1_ID , "124" ), null );
15891595
15901596 assertSameNodeItem (items .next (), nodeItem3 );
15911597 assertSameNodeItem (items .next (), nodeItem1 );
@@ -1646,7 +1652,7 @@ public void testCanPageGetRecentItemsUsingResultSetManagement()
16461652 dbTester .loadData ("node_1" );
16471653
16481654 Date since = new Date ();
1649-
1655+
16501656 Thread .sleep (10 );
16511657
16521658 store .addRemoteNode (TEST_SERVER1_NODE2_ID );
@@ -1659,8 +1665,9 @@ public void testCanPageGetRecentItemsUsingResultSetManagement()
16591665 store .addNodeItem (new NodeItemImpl (TEST_SERVER1_NODE1_ID , String
16601666 .valueOf (i ), new Date (), "payload" + String .valueOf (i )));
16611667 }
1662-
1663- GlobalItemID itemID = new GlobalItemIDImpl (TEST_SERVER1_CHANNELS_JID , TEST_SERVER1_NODE1_ID , "15" );
1668+
1669+ GlobalItemID itemID = new GlobalItemIDImpl (TEST_SERVER1_CHANNELS_JID ,
1670+ TEST_SERVER1_NODE1_ID , "15" );
16641671
16651672 CloseableIterator <NodeItem > items = store .getRecentItems (
16661673 TEST_SERVER1_USER1_JID , since , -1 , 10 , itemID , null );
@@ -1785,8 +1792,8 @@ public void testCanGetItemThread() throws Exception {
17851792 @ Test
17861793 public void testCanGetItemThreadWithResultSetManagement () throws Exception {
17871794 dbTester .loadData ("node_1" );
1788- NodeItem testItemParent = new NodeItemImpl (TEST_SERVER1_NODE1_ID , "a100" ,
1789- new Date (100 ), "<entry>payload parent</entry>" );
1795+ NodeItem testItemParent = new NodeItemImpl (TEST_SERVER1_NODE1_ID ,
1796+ "a100" , new Date (100 ), "<entry>payload parent</entry>" );
17901797 NodeItem testItem1 = new NodeItemImpl (TEST_SERVER1_NODE1_ID , "a6" ,
17911798 new Date (20 ), "<entry>payload</entry>" , "a100" );
17921799 NodeItem testItem2 = new NodeItemImpl (TEST_SERVER1_NODE1_ID , "a7" ,
@@ -2319,16 +2326,35 @@ private void assertSameNodeItem(NodeItem actual, NodeItem expected) {
23192326 assertEquals (expected .getPayload (), actual .getPayload ());
23202327 assertEquals (expected .getInReplyTo (), actual .getInReplyTo ());
23212328 }
2322-
2329+
23232330 @ Test
23242331 public void testSelectNodeThreads () throws Exception {
23252332 dbTester .loadData ("node_1" );
2326- assertEquals (5 , store .getNodeThreads (TEST_SERVER1_NODE1_ID , null , 10 ).size ());
2333+ assertEquals (5 , store .getNodeThreads (TEST_SERVER1_NODE1_ID , null , 10 )
2334+ .size ());
23272335 }
2328-
2336+
23292337 @ Test
23302338 public void testCountNodeThreads () throws Exception {
23312339 dbTester .loadData ("node_1" );
23322340 assertEquals (5 , store .countNodeThreads (TEST_SERVER1_NODE1_ID ));
23332341 }
2342+
2343+ @ Test
2344+ public void testNoNodeOwnersReturnsEmptyList () throws Exception {
2345+ dbTester .loadData ("node_1" );
2346+ assertEquals (0 , store .getNodeOwners (UNKNOWN_NODE ).size ());
2347+ }
2348+
2349+ @ Test
2350+ public void testNodeOwnersReturnsExpectedList () throws Exception {
2351+ dbTester .loadData ("node_1" );
2352+
2353+ store .addUserSubscription (new NodeSubscriptionImpl (TEST_SERVER1_NODE1_ID , TEST_SERVER1_USER2_JID , Subscriptions .subscribed ));
2354+ store .setUserAffiliation (TEST_SERVER1_NODE1_ID , TEST_SERVER1_USER2_JID , Affiliations .owner );
2355+
2356+ assertEquals (2 , store .getNodeOwners (TEST_SERVER1_NODE1_ID ).size ());
2357+ assertEquals (TEST_SERVER1_USER1_JID , store .getNodeOwners (TEST_SERVER1_NODE1_ID ).get (0 ));
2358+ assertEquals (TEST_SERVER1_USER2_JID , store .getNodeOwners (TEST_SERVER1_NODE1_ID ).get (1 ));
2359+ }
23342360}
0 commit comments