### Question:
UserProfileManagerAspect { @AfterReturning(pointcut = "execution(* com.agiletec.aps.system.services.user.IUserManager.removeUser(..)) && args(key)") public void deleteProfile(Object key) { String username = null; if (key instanceof String) { username = key.toString(); } else if (key instanceof UserDetails) { UserDetails userDetails = (UserDetails) key; username = userDetails.getUsername(); } if (username != null) { try { this.getUserProfileManager().deleteProfile(username); } catch (Throwable t) { logger.error("Error deleting profile. user: {}", username, 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 testDeleteProfile_1() throws ApsSystemException { User user = new User(); user.setUsername("test"); userProfileManagerAspect.deleteProfile(user); Mockito.verify(userProfileManager, Mockito.times(1)).deleteProfile("test"); }
@Test public void testDeleteProfile_2() throws ApsSystemException { userProfileManagerAspect.deleteProfile("test"); Mockito.verify(userProfileManager, Mockito.times(1)).deleteProfile("test"); }
@Test public void testDeleteProfile_3() throws ApsSystemException { userProfileManagerAspect.deleteProfile(null); Mockito.verify(userProfileManager, Mockito.times(0)).deleteProfile("test"); }