### Question:
ContributorProfileService { protected ContributorProfile takeProfileFromProvider(String contributorCodeType, String contributorCodeValue) { if (!isContributorCodeTypesSupported(contributorCodeType)) { throw new IllegalArgumentException("Unsupported contributorCodeType " + contributorCodeType); } ContributorProfile profile = contributorProfileProvider.getProfile(contributorCodeValue); if (profile == null) { log.log(Level.WARNING, "User not found in contributor profile provider for {0}={1}", new String[] { contributorCodeType, contributorCodeValue }); } return profile; }  boolean isContributorCodeTypesSupported(String contributorCodeType); String getContributorId(String contributorCodeType, String contributorCodeValue, boolean forceCreate); String createOrUpdateProfile(String contributorCodeType, String contributorCodeValue, boolean forceUpdate); SearchResponse findByContributorCode(String contributorCode); boolean deleteByContributorCode(String code); @TransactionAttribute(TransactionAttributeType.NEVER) int fullSynContributorsAndProfiles(String contributorCodeType, Integer start, Integer size); @TransactionAttribute(TransactionAttributeType.NEVER) int createOrUpdateAllProfiles(String contributorCodeType); void contributorDeletedEventHandler(@Observes ContributorDeletedEvent event); void contributorMergedEventHandler(@Observes ContributorMergedEvent event); void contributorCodeChangedEventHandler(@Observes ContributorCodeChangedEvent event); static final String FIELD_TSC_JBOSSORG_USERNAME; static final String FIELD_TSC_GITHUB_USERNAME; static final String SEARCH_INDEX_NAME; static final String SEARCH_INDEX_TYPE; }### Answer:
@Test public void takeProfileFromProvider() { ContributorProfileService tested = getTested(null); Mockito.when(tested.contributorProfileProvider.getProfile("aaa")).thenReturn(null); Assert.assertNull(tested.takeProfileFromProvider(ContributorProfileService.FIELD_TSC_JBOSSORG_USERNAME, "aaa")); Mockito.reset(tested.contributorProfileProvider); ContributorProfile pm = Mockito.mock(ContributorProfile.class); Mockito.when(tested.contributorProfileProvider.getProfile("aaa")).thenReturn(pm); Assert.assertEquals(pm, tested.takeProfileFromProvider(ContributorProfileService.FIELD_TSC_JBOSSORG_USERNAME, "aaa")); try { tested.takeProfileFromProvider(ContributorProfileService.FIELD_TSC_GITHUB_USERNAME, "aaa"); Assert.fail("IllegalArgumentException expected"); } catch (IllegalArgumentException e) { } }