@Test public void getMarkupLanguagesNullName() { MarkupLanguageProvider provider = new MarkupLanguageProvider() { @Override protected Set<MarkupLanguage> loadMarkupLanguages() { MockMarkupLanguage language = new MockMarkupLanguage(); language.setName(null); return ImmutableSet.<MarkupLanguage> of(language); } }; NullPointerException npe = assertThrows(NullPointerException.class, () -> provider.getMarkupLanguages()); assertTrue(npe.getMessage().contains("Provided languages must have a name")); }
public final Set<MarkupLanguage> getMarkupLanguages() { Set<MarkupLanguage> languages = ImmutableSet .copyOf(Objects.requireNonNull(loadMarkupLanguages(), "loadMarkupLanguages() must not return null")); assertLanguageNames(languages); return languages; }
MarkupLanguageProvider { public final Set<MarkupLanguage> getMarkupLanguages() { Set<MarkupLanguage> languages = ImmutableSet .copyOf(Objects.requireNonNull(loadMarkupLanguages(), "loadMarkupLanguages() must not return null")); assertLanguageNames(languages); return languages; } }
MarkupLanguageProvider { public final Set<MarkupLanguage> getMarkupLanguages() { Set<MarkupLanguage> languages = ImmutableSet .copyOf(Objects.requireNonNull(loadMarkupLanguages(), "loadMarkupLanguages() must not return null")); assertLanguageNames(languages); return languages; }  }
MarkupLanguageProvider { public final Set<MarkupLanguage> getMarkupLanguages() { Set<MarkupLanguage> languages = ImmutableSet .copyOf(Objects.requireNonNull(loadMarkupLanguages(), "loadMarkupLanguages() must not return null")); assertLanguageNames(languages); return languages; }  final Set<MarkupLanguage> getMarkupLanguages(); }
MarkupLanguageProvider { public final Set<MarkupLanguage> getMarkupLanguages() { Set<MarkupLanguage> languages = ImmutableSet .copyOf(Objects.requireNonNull(loadMarkupLanguages(), "loadMarkupLanguages() must not return null")); assertLanguageNames(languages); return languages; }  final Set<MarkupLanguage> getMarkupLanguages();  }