@@ -128,9 +128,8 @@ public void testProvidingInvalidStanzaReturnsError() throws Exception {
128128 Mockito .when (channelManagerMock .nodeExists (node )).thenReturn (true );
129129 itemDelete .setChannelManager (channelManagerMock );
130130
131- request = toIq (readStanzaAsString (
132- "/iq/pubsub/item/delete/request.stanza" ).replaceFirst (
133- "<item id='item-id' notify='true' />" , "" ));
131+ IQ request = toIq (readStanzaAsString ("/iq/pubsub/item/delete/request.stanza" ));
132+ request .getChildElement ().element ("retract" ).element ("item" ).detach ();
134133 itemDelete .process (element , jid , request , null );
135134
136135 Packet response = queue .poll (100 , TimeUnit .MILLISECONDS );
@@ -148,9 +147,9 @@ public void testNotProvidingItemIdReturnsError() throws Exception {
148147 Mockito .when (channelManagerMock .nodeExists (node )).thenReturn (true );
149148 itemDelete .setChannelManager (channelManagerMock );
150149
151- request = toIq (readStanzaAsString (
152- "/iq/pubsub/item/delete/ request.stanza" ). replaceFirst (
153- "id='item-id'" , "" ) );
150+ IQ request = toIq (readStanzaAsString ("/iq/pubsub/item/delete/request.stanza" ));
151+ request .getChildElement (). element ( "retract" ). element ( "item" )
152+ . attribute ( "id" ). detach ( );
154153 itemDelete .process (element , jid , request , null );
155154
156155 Packet response = queue .poll (100 , TimeUnit .MILLISECONDS );
@@ -348,7 +347,7 @@ public void testRequestingNotificationsSendsRetractionNotifications()
348347 itemDelete .process (element , jid , request , null );
349348
350349 Mockito .verify (channelManagerMock ).deleteNodeItemById (node , "item-id" );
351- IQ response = (IQ ) queue .poll (100 , TimeUnit . MILLISECONDS );
350+ IQ response = (IQ ) queue .poll ();
352351
353352 Assert .assertEquals (IQ .Type .result .toString (), response .getElement ()
354353 .attribute ("type" ).getValue ());
@@ -361,4 +360,47 @@ public void testRequestingNotificationsSendsRetractionNotifications()
361360 notification .getElement ().element ("event" ).element ("items" )
362361 .element ("retract" ).attributeValue ("id" ));
363362 }
363+
364+ @ Test
365+ public void testNoNotifyAttributeStillSendsNotifications () throws Exception {
366+ NodeAffiliation affiliation = new NodeAffiliationImpl (node , jid ,
367+ Affiliations .member , new Date ());
368+
369+ NodeItem nodeItem = new NodeItemImpl (node , "item-id" , new Date (),
370+ payload .replaceAll ("romeo@shakespeare.lit" ,
371+ "juliet@shakespeare.lit" ));
372+
373+ IQ request = toIq (readStanzaAsString ("/iq/pubsub/item/delete/request.stanza" ));
374+ request .getChildElement ().element ("retract" ).element ("item" )
375+ .attribute ("notify" ).detach ();
376+
377+ ArrayList <NodeSubscription > subscriptions = new ArrayList <NodeSubscription >();
378+ NodeSubscriptionImpl subscription1 = new NodeSubscriptionImpl (node ,
379+ new JID ("romeo@shakespeare.lit" ), Subscriptions .pending );
380+ NodeSubscriptionImpl subscription2 = new NodeSubscriptionImpl (node ,
381+ new JID ("juliet@shakespeare.lit" ), Subscriptions .subscribed );
382+ subscriptions .add (subscription1 );
383+ subscriptions .add (subscription2 );
384+
385+ Mockito .when (channelManagerMock .isLocalNode (node )).thenReturn (true );
386+ Mockito .when (channelManagerMock .nodeExists (node )).thenReturn (true );
387+ Mockito .when (channelManagerMock .getNodeItem (node , "item-id" ))
388+ .thenReturn (nodeItem );
389+ Mockito .when (
390+ channelManagerMock .getUserAffiliation (Mockito .anyString (),
391+ Mockito .any (JID .class ))).thenReturn (affiliation );
392+
393+ Mockito .doReturn (new ResultSetImpl <NodeSubscription >(subscriptions ))
394+ .when (channelManagerMock ).getNodeSubscriptionListeners (node );
395+
396+ itemDelete .setChannelManager (channelManagerMock );
397+
398+ itemDelete .process (element , jid , request , null );
399+
400+ Mockito .verify (channelManagerMock ).deleteNodeItemById (node , "item-id" );
401+
402+ // Check that one notification is sent (on subscriber + 2 admins)
403+ Assert .assertEquals (4 , queue .size ());
404+
405+ }
364406}
0 commit comments