Coverage Report - biz.xsoftware.examples.listener2.UserReplicationServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
UserReplicationServiceImpl
100%
7/7
N/A
0
UserReplicationServiceImpl$1
N/A
N/A
0
UserReplicationServiceImpl$MyUserListener
100%
5/5
N/A
0
 
 1  
 package biz.xsoftware.examples.listener2;
 2  
 
 3  
 import java.util.HashSet;
 4  
 
 5  
 /**
 6  
  */
 7  3
 public class UserReplicationServiceImpl implements UserReplicationService
 8  
 {
 9  
 
 10  
     private UserService userSvc;
 11  2
     private HashSet<String> users = new HashSet<String>();
 12  
     
 13  
     /**
 14  
      * Creates an instance of UserReplicationServiceImpl.
 15  
      * @param service
 16  
      */
 17  
     public UserReplicationServiceImpl(UserService service)
 18  2
     {
 19  2
         this.userSvc = service;
 20  2
         userSvc.addUserListener(new MyUserListener());
 21  2
     }
 22  
 
 23  
     
 24  
     /**
 25  
      * @see biz.xsoftware.examples.listener2.UserReplicationService#doesUserExist(java.lang.String)
 26  
      */
 27  
     public boolean doesUserExist(String user)
 28  
     {
 29  5
         return users.contains(user);
 30  
     }
 31  
 
 32  4
     private class MyUserListener implements UserListener {
 33  
 
 34  
         /**
 35  
          * @see biz.xsoftware.examples.listener2.UserListener#userAdded(java.lang.String)
 36  
          */
 37  
         public void userAdded(String userName)
 38  
         {
 39  2
             users.add(userName);
 40  2
         }
 41  
 
 42  
         /**
 43  
          * @see biz.xsoftware.examples.listener2.UserListener#userDeleted(java.lang.String)
 44  
          */
 45  
         public void userDeleted(String userName)
 46  
         {
 47  1
             users.remove(userName);
 48  1
         }
 49  
         
 50  
     }
 51  
 }