### Question:
MarkupLanguageProvider { public final Set<MarkupLanguage> getMarkupLanguages() { Set<MarkupLanguage> languages = ImmutableSet .copyOf(checkNotNull(loadMarkupLanguages(), "loadMarkupLanguages() must not return null")); assertLanguageNames(languages); return languages; }  final Set<MarkupLanguage> getMarkupLanguages();  }### Answer:
@Test public void getMarkupLanguages() { MarkupLanguageProvider provider = new TestLanguageProvider(); assertNotNull(provider.getMarkupLanguages()); assertEquals(1, provider.getMarkupLanguages().size()); assertEquals("Test", provider.getMarkupLanguages().iterator().next().getName()); }
@Test public void getMarkupLanguagesNull() { MarkupLanguageProvider provider = new MarkupLanguageProvider() { @Override protected Set<MarkupLanguage> loadMarkupLanguages() { return null; } }; thrown.expect(NullPointerException.class); thrown.expectMessage("loadMarkupLanguages() must not return null"); provider.getMarkupLanguages(); }
@Test public void getMarkupLanguagesDuplicatedNames() { MarkupLanguageProvider provider = new MarkupLanguageProvider() { @Override protected Set<MarkupLanguage> loadMarkupLanguages() { return ImmutableSet.<MarkupLanguage> of(new MockMarkupLanguage("Test"), new MockMarkupLanguage("Test")); } }; thrown.expect(IllegalStateException.class); thrown.expectMessage("Language name 'Test' must not be provided more than once"); provider.getMarkupLanguages(); }
@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); } }; thrown.expect(NullPointerException.class); thrown.expectMessage("Provided languages must have a name"); provider.getMarkupLanguages(); }