UserAgentImpl implements UserAgent, ProviderScanner { static Provider scanProviders(final String userAgentProvider, final List<Provider> providers, final Map<Provider, List<String>> destinationUnmetRequirements, final boolean checkOverrideIsCompatible) { Provider result = null; if (userAgentProvider != null) { for (final Provider provider : providers) { if (provider.getClassName().equals(userAgentProvider)) { if (checkOverrideIsCompatible) { final List<String> requirements = provider.checkRequirements(); if (requirements == null || requirements.size() == 0) { result = provider; } } else { result = provider; } break; } } } for (final Provider provider : providers) { final List<String> requirements = provider.checkRequirements(); if (requirements == null || requirements.size() == 0) { if (result == null) { result = provider; } } else { destinationUnmetRequirements.put(provider, requirements); } } return result; } UserAgentImpl();   UserAgentImpl(final TestableProcessFactory processFactory, final Provider provider, final List<Provider> candidateProviders); @Override Provider findCompatibleProvider(); @Override Provider findCompatibleProvider(final String userAgentProvider); @Override Map<Provider, List<String>> getUnmetProviderRequirements(); @Override boolean hasCompatibleProvider(); @Override boolean hasCompatibleProvider(final String userAgentProvider); @Override AuthorizationResponse requestAuthorizationCode(final URI authorizationEndpoint, final URI redirectUri); static StringBuilder buildUnsupportedMessage(Map<Provider, List<String>> unmetRequirements); static void describeUnmetRequirements(final Map<Provider, List<String>> unmetRequirements, final StringBuilder destination);  }
@Test public void scanProviders_Compatible() { final Provider compatibleProvider = new CompatibleProvider(); final List<Provider> providers = Arrays.asList(compatibleProvider); final LinkedHashMap<Provider, List<String>> unmetReqs = new LinkedHashMap<Provider, List<String>>(); final Provider actual = UserAgentImpl.scanProviders(null, providers, unmetReqs, true); Assert.assertEquals(compatibleProvider, actual); }