@Test public void selectProfile_ShouldReturnProfile_OfFirstMatcher() throws Exception { when(matcher1.apply(candidate)).thenReturn(Optional.of(profile)); Profile result = subject.selectProfile(candidate).get(); assertThat(result).isEqualTo(profile); verify(matcher1).apply(candidate); verify(matcher2, never()).apply(any()); }
@Override public Optional<Profile> selectProfile(Media candidate) { log.entry(candidate); log.debug("Selecting a profile..."); for (ProfileMatcher profileMatcher : profileMatcherMap.values()) { Optional<Profile> result = profileMatcher.apply(candidate); if (result.isPresent()) { log.info("Selected profile {} for {}.", result.get().getLocation(), candidate); return log.exit(result); } } log.info("Could not find a suitable profile for {}.", candidate); return log.exit(Optional.empty()); }
ProfileScanServiceImpl implements ProfileScanService { @Override public Optional<Profile> selectProfile(Media candidate) { log.entry(candidate); log.debug("Selecting a profile..."); for (ProfileMatcher profileMatcher : profileMatcherMap.values()) { Optional<Profile> result = profileMatcher.apply(candidate); if (result.isPresent()) { log.info("Selected profile {} for {}.", result.get().getLocation(), candidate); return log.exit(result); } } log.info("Could not find a suitable profile for {}.", candidate); return log.exit(Optional.empty()); } }
ProfileScanServiceImpl implements ProfileScanService { @Override public Optional<Profile> selectProfile(Media candidate) { log.entry(candidate); log.debug("Selecting a profile..."); for (ProfileMatcher profileMatcher : profileMatcherMap.values()) { Optional<Profile> result = profileMatcher.apply(candidate); if (result.isPresent()) { log.info("Selected profile {} for {}.", result.get().getLocation(), candidate); return log.exit(result); } } log.info("Could not find a suitable profile for {}.", candidate); return log.exit(Optional.empty()); } @Inject  ProfileScanServiceImpl(Map<ProfileMatchers, ProfileMatcher> profileMatcherMap); }
ProfileScanServiceImpl implements ProfileScanService { @Override public Optional<Profile> selectProfile(Media candidate) { log.entry(candidate); log.debug("Selecting a profile..."); for (ProfileMatcher profileMatcher : profileMatcherMap.values()) { Optional<Profile> result = profileMatcher.apply(candidate); if (result.isPresent()) { log.info("Selected profile {} for {}.", result.get().getLocation(), candidate); return log.exit(result); } } log.info("Could not find a suitable profile for {}.", candidate); return log.exit(Optional.empty()); } @Inject  ProfileScanServiceImpl(Map<ProfileMatchers, ProfileMatcher> profileMatcherMap); @Override Optional<Profile> selectProfile(Media candidate); }
ProfileScanServiceImpl implements ProfileScanService { @Override public Optional<Profile> selectProfile(Media candidate) { log.entry(candidate); log.debug("Selecting a profile..."); for (ProfileMatcher profileMatcher : profileMatcherMap.values()) { Optional<Profile> result = profileMatcher.apply(candidate); if (result.isPresent()) { log.info("Selected profile {} for {}.", result.get().getLocation(), candidate); return log.exit(result); } } log.info("Could not find a suitable profile for {}.", candidate); return log.exit(Optional.empty()); } @Inject  ProfileScanServiceImpl(Map<ProfileMatchers, ProfileMatcher> profileMatcherMap); @Override Optional<Profile> selectProfile(Media candidate);  }