@@ -181,16 +181,17 @@ public void testProvidingEmptyItemIdReturnsError() throws Exception {
181181 }
182182
183183 @ Test
184- public void testItemWhichDoesntExistReturnsItemNotFoundError ()
184+ public void itemWhichDoesntExistReturnsItemNotFoundError ()
185185 throws Exception {
186+
186187 Mockito .when (channelManager .nodeExists (node )).thenReturn (true );
187188 Mockito .when (channelManager .getNodeItem (node , "item-id" )).thenReturn (
188189 null );
189190 itemDelete .setChannelManager (channelManager );
190191
191192 itemDelete .process (element , jid , request , null );
192193
193- Packet response = queue .poll (100 , TimeUnit . MILLISECONDS );
194+ Packet response = queue .poll ();
194195
195196 PacketError error = response .getError ();
196197 Assert .assertNotNull (error );
@@ -285,12 +286,12 @@ public void testSuccessfulRequestSendsResponseStanza() throws Exception {
285286 itemDelete .process (element , jid , request , null );
286287
287288 Mockito .verify (channelManager ).deleteNodeItemById (node , "item-id" );
288- IQ response = (IQ ) queue .poll (100 , TimeUnit . MILLISECONDS );
289+ IQ response = (IQ ) queue .poll ();
289290
290291 Assert .assertEquals (IQ .Type .result .toString (), response .getElement ()
291292 .attribute ("type" ).getValue ());
292293 // Check that no notifications are sent
293- Packet notification = queue .poll (100 , TimeUnit . MILLISECONDS );
294+ Packet notification = queue .poll ();
294295 Assert .assertNull (notification );
295296 }
296297
@@ -485,4 +486,32 @@ public void requestsThreadWhenDeletingParentPost() throws Exception {
485486 notification .getElement ().element ("event" ).element ("items" )
486487 .element ("retract" ).attributeValue ("id" ));
487488 }
489+
490+ @ Test
491+ public void canDeleteItemUsingAFullItemId () throws Exception {
492+
493+ NodeItem nodeItem = new NodeItemImpl (node , "item-id" , new Date (),
494+ payload .replaceAll ("romeo@shakespeare.lit" ,
495+ "juliet@shakespeare.lit" ), "item-id" );
496+
497+ Mockito .when (channelManager .nodeExists (node )).thenReturn (true );
498+ Mockito .when (
499+ channelManager .getNodeItem (Mockito .eq ("/user/capulet@shakespeare.lit/posts" ),
500+ Mockito .eq ("item-id" ))).thenReturn (nodeItem );
501+
502+ IQ request = toIq (readStanzaAsString ("/iq/pubsub/item/delete/request-full-id.stanza" ));
503+
504+ itemDelete .setChannelManager (channelManager );
505+
506+ itemDelete .process (element , jid , request , null );
507+
508+ Mockito .verify (channelManager ).deleteNodeItemById (node , "item-id" );
509+ IQ response = (IQ ) queue .poll ();
510+
511+ Assert .assertEquals (IQ .Type .result .toString (), response .getElement ()
512+ .attribute ("type" ).getValue ());
513+ // Check that no notifications are sent
514+ Packet notification = queue .poll ();
515+ Assert .assertNull (notification );
516+ }
488517}
0 commit comments