// Path: provider/src/main/java/com/cloudera/director/aws/common/ResourceBundleLocalizationContext.java
// public static class ResourceBundleLocalizationContextFactory implements Factory {
// 
//   /**
//    * The resource bundle resolver.
//    */
//   private final ResourceBundleResolver resourceBundleResolver;
// 
//   /**
//    * Creates a resource bundle localization context factory with the specified parameters.
//    *
//    * @param resourceBundleResolver the resource bundle resolver
//    */
//   public ResourceBundleLocalizationContextFactory(ResourceBundleResolver resourceBundleResolver) {
//     this.resourceBundleResolver = resourceBundleResolver;
//   }
// 
//   @Override
//   public LocalizationContext createRootLocalizationContext(Locale locale) {
//     return new ResourceBundleLocalizationContext(
//         locale, "", resourceBundleResolver.getBundle(BUNDLE_BASE_NAME, locale));
//   }
// }
// 
// Path: provider/src/main/java/com/cloudera/director/aws/common/ResourceBundleLocalizationContext.java
// public interface ResourceBundleResolver {
// 
//   /**
//    * The default resource bundle resolver.
//    */
//   ResourceBundleResolver DEFAULT = (baseName, locale) -> {
//     try {
//       return ResourceBundle.getBundle("com.cloudera.director.aws." + baseName, locale);
//     } catch (MissingResourceException e) {
//       LOG.warn("Could not load resource bundle '{}' for locale {}", baseName, locale);
//       return null;
//     }
//   };
// 
//   /**
//    * Returns the specified resource bundle for the specified locale, or {@code null} if there
//    * is no such resource bundle.
//    *
//    * @param baseName the base name of the resource bundle
//    * @param locale   the locale
//    * @return the specified resource bundle for the specified locale, or {@code null} if there
//    * is no such resource bundle
//    */
//   ResourceBundle getBundle(String baseName, Locale locale);
// }


import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import com.cloudera.director.aws.common.ResourceBundleLocalizationContext.ResourceBundleLocalizationContextFactory;
import com.cloudera.director.aws.common.ResourceBundleLocalizationContext.ResourceBundleResolver;
import com.cloudera.director.spi.v2.model.LocalizationContext;
import com.google.common.collect.Maps;
import java.util.Enumeration;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;
    assertThat(localizationContext.localize("y")).isEqualTo("y");
    assertThat(localizationContext.localize("yam", "y")).isEqualTo("xylophone");
    assertThat(localizationContext.localize("yam", "y", "z")).isEqualTo("eggzaktly");
    assertThat(localizationContext.localize("yam", "z")).isEqualTo("yam");
  }

  @Test
  public void testWithResourceNoBundle() {
    ResourceBundleLocalizationContext localizationContext =
        new ResourceBundleLocalizationContext(Locale.getDefault(), "x", null);
    assertThat(localizationContext.localize(null)).isNull();
    assertThat(localizationContext.localize("")).isEqualTo("");
    assertThat(localizationContext.localize("foo")).isEqualTo("foo");
    assertThat(localizationContext.localize("y")).isEqualTo("y");
    assertThat(localizationContext.localize("yam", "y")).isEqualTo("yam");
    assertThat(localizationContext.localize("yam", "y", "z")).isEqualTo("yam");
    assertThat(localizationContext.localize("yam", "z")).isEqualTo("yam");
  }

  @Test
  public void testLocalization() {
    Locale locale1 = new Locale("en");
    MockStringResourceBundle resourceBundle1 = new MockStringResourceBundle();
    resourceBundle1.put("y", "xylophone");
    resourceBundle1.put("y.z", "eggzaktly");

    Locale locale2 = new Locale("fr");
    MockStringResourceBundle resourceBundle2 = new MockStringResourceBundle(resourceBundle1);
    resourceBundle2.put("y.z", "not eggzaktly");

// Path: provider/src/main/java/com/cloudera/director/aws/common/ResourceBundleLocalizationContext.java
// public static class ResourceBundleLocalizationContextFactory implements Factory {
// 
//   /**
//    * The resource bundle resolver.
//    */
//   private final ResourceBundleResolver resourceBundleResolver;
// 
//   /**
//    * Creates a resource bundle localization context factory with the specified parameters.
//    *
//    * @param resourceBundleResolver the resource bundle resolver
//    */
//   public ResourceBundleLocalizationContextFactory(ResourceBundleResolver resourceBundleResolver) {
//     this.resourceBundleResolver = resourceBundleResolver;
//   }
// 
//   @Override
//   public LocalizationContext createRootLocalizationContext(Locale locale) {
//     return new ResourceBundleLocalizationContext(
//         locale, "", resourceBundleResolver.getBundle(BUNDLE_BASE_NAME, locale));
//   }
// }
// 
// Path: provider/src/main/java/com/cloudera/director/aws/common/ResourceBundleLocalizationContext.java
// public interface ResourceBundleResolver {
// 
//   /**
//    * The default resource bundle resolver.
//    */
//   ResourceBundleResolver DEFAULT = (baseName, locale) -> {
//     try {
//       return ResourceBundle.getBundle("com.cloudera.director.aws." + baseName, locale);
//     } catch (MissingResourceException e) {
//       LOG.warn("Could not load resource bundle '{}' for locale {}", baseName, locale);
//       return null;
//     }
//   };
// 
//   /**
//    * Returns the specified resource bundle for the specified locale, or {@code null} if there
//    * is no such resource bundle.
//    *
//    * @param baseName the base name of the resource bundle
//    * @param locale   the locale
//    * @return the specified resource bundle for the specified locale, or {@code null} if there
//    * is no such resource bundle
//    */
//   ResourceBundle getBundle(String baseName, Locale locale);
// }


// Path: tests/src/test/java/com/cloudera/director/aws/common/ResourceBundleLocalizationContextTest.java
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import com.cloudera.director.aws.common.ResourceBundleLocalizationContext.ResourceBundleLocalizationContextFactory;
import com.cloudera.director.aws.common.ResourceBundleLocalizationContext.ResourceBundleResolver;
import com.cloudera.director.spi.v2.model.LocalizationContext;
import com.google.common.collect.Maps;
import java.util.Enumeration;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;

    assertThat(localizationContext.localize("y")).isEqualTo("y");
    assertThat(localizationContext.localize("yam", "y")).isEqualTo("xylophone");
    assertThat(localizationContext.localize("yam", "y", "z")).isEqualTo("eggzaktly");
    assertThat(localizationContext.localize("yam", "z")).isEqualTo("yam");
  }

  @Test
  public void testWithResourceNoBundle() {
    ResourceBundleLocalizationContext localizationContext =
        new ResourceBundleLocalizationContext(Locale.getDefault(), "x", null);
    assertThat(localizationContext.localize(null)).isNull();
    assertThat(localizationContext.localize("")).isEqualTo("");
    assertThat(localizationContext.localize("foo")).isEqualTo("foo");
    assertThat(localizationContext.localize("y")).isEqualTo("y");
    assertThat(localizationContext.localize("yam", "y")).isEqualTo("yam");
    assertThat(localizationContext.localize("yam", "y", "z")).isEqualTo("yam");
    assertThat(localizationContext.localize("yam", "z")).isEqualTo("yam");
  }

  @Test
  public void testLocalization() {
    Locale locale1 = new Locale("en");
    MockStringResourceBundle resourceBundle1 = new MockStringResourceBundle();
    resourceBundle1.put("y", "xylophone");
    resourceBundle1.put("y.z", "eggzaktly");

    Locale locale2 = new Locale("fr");
    MockStringResourceBundle resourceBundle2 = new MockStringResourceBundle(resourceBundle1);
    resourceBundle2.put("y.z", "not eggzaktly");

    ResourceBundleResolver resolver = mock(ResourceBundleResolver.class);