@@ -86,7 +86,8 @@ public void setUp() throws Exception {
8686 Affiliations .member , new Date ()));
8787
8888 Mockito .doReturn (new ResultSetImpl <NodeAffiliation >(affiliations ))
89- .when (channelManager ).getNodeAffiliations (Mockito .anyString (), Mockito .anyBoolean ());
89+ .when (channelManager )
90+ .getNodeAffiliations (Mockito .anyString (), Mockito .anyBoolean ());
9091
9192 ArrayList <NodeSubscription > subscribers = new ArrayList <NodeSubscription >();
9293 subscribers .add (new NodeSubscriptionImpl (node , jid ,
@@ -229,4 +230,44 @@ public void testRemoteUserGetsPendingSubscriptionToLocalAccessModelNode()
229230
230231 }
231232
233+ @ Test
234+ public void testNoDefaultAffiliationConfigurationResultsInMemberAffiliation ()
235+ throws Exception {
236+
237+ Mockito .when (channelManager .getNodeConf (Mockito .anyString ()))
238+ .thenReturn (new HashMap <String , String >());
239+
240+ subscribe .process (element , new JID ("francisco@denmark.lit" ), request ,
241+ null );
242+
243+ Mockito .verify (channelManager ).setUserAffiliation (Mockito .anyString (),
244+ Mockito .any (JID .class ), Mockito .eq (Affiliations .member ));
245+
246+ IQ response = (IQ ) queue .poll ();
247+ Assert .assertEquals (IQ .Type .result , response .getType ());
248+
249+ }
250+
251+ @ Test
252+ public void testDefaultAffiliationConfigurationResultsInCorrectAffiliation ()
253+ throws Exception {
254+
255+ Map <String , String > configuration = new HashMap <String , String >();
256+ configuration .put (Conf .ACCESS_MODEL , AccessModel .open .toString ());
257+ configuration .put (Conf .DEFAULT_AFFILIATION ,
258+ Affiliations .publisher .toString ());
259+ Mockito .when (channelManager .getNodeConf (Mockito .anyString ()))
260+ .thenReturn (configuration );
261+
262+ subscribe .process (element , new JID ("francisco@denmark.lit" ), request ,
263+ null );
264+
265+ Mockito .verify (channelManager ).setUserAffiliation (Mockito .anyString (),
266+ Mockito .any (JID .class ), Mockito .eq (Affiliations .publisher ));
267+
268+ IQ response = (IQ ) queue .poll ();
269+ Assert .assertEquals (IQ .Type .result , response .getType ());
270+
271+ }
272+
232273}
0 commit comments