@Bean("Languages")
  public Languages provide(Optional<List<Language>> languages) {
    if (languages.isPresent()) {
      return new Languages(languages.get().toArray(new Language[0]));
    } else {
      return new Languages();
    }
  }
@Test
  public void should_provide_instance_when_languages() {
    Language A = mock(Language.class);
    when(A.getKey()).thenReturn("a");
    Language B = mock(Language.class);
    when(B.getKey()).thenReturn("b");

    LanguagesProvider provider = new LanguagesProvider();
    List<Language> languageList = Arrays.asList(A, B);
    Languages languages = provider.provide(Optional.of(languageList));

    assertThat(languages).isNotNull();
    assertThat(languages.all())
      .hasSize(2)
      .contains(A, B);
  }