### Question:
UserProfileManagerAspect { @AfterReturning(pointcut = "execution(* com.agiletec.aps.system.services.user.IUserManager.addUser(..)) && args(user,..)") public void addProfile(Object user) { if (user != null) { UserDetails userDetails = (UserDetails) user; Object profile = userDetails.getProfile(); if (null != profile) { try { this.getUserProfileManager().addProfile(userDetails.getUsername(), (IUserProfile) profile); } catch (Throwable t) { logger.error("Error adding profile on user {}", userDetails.getUsername(), t); } } } }  @AfterReturning(pointcut = "execution(* com.agiletec.aps.system.services.user.IUserManager.getUser(..))", returning = "user") void injectProfile(Object user); @AfterReturning(pointcut = "execution(* com.agiletec.aps.system.services.user.IUserManager.addUser(..)) && args(user,..)") void addProfile(Object user); @AfterReturning(pointcut = "execution(* com.agiletec.aps.system.services.user.IUserManager.updateUser(..)) && args(user,..)") void updateProfile(Object user); @AfterReturning(pointcut = "execution(* com.agiletec.aps.system.services.user.IUserManager.removeUser(..)) && args(key)") void deleteProfile(Object key); void setUserProfileManager(IUserProfileManager userProfileManager);  }### Answer:
@Test public void testAddProfile_1() throws ApsSystemException { IUserProfile profile = this.createFakeProfile("test", SystemConstants.DEFAULT_PROFILE_TYPE_CODE); User user = new User(); user.setUsername("test"); user.setProfile(profile); userProfileManagerAspect.addProfile(user); Mockito.verify(userProfileManager, Mockito.times(1)).addProfile("test", profile); }
@Test public void testAddProfile_2() throws ApsSystemException { User user = new User(); user.setUsername("test"); userProfileManagerAspect.addProfile(user); Mockito.verify(userProfileManager, Mockito.times(0)).addProfile(Mockito.anyString(), Mockito.any(IUserProfile.class)); }