@Test
 public void testConvertToIssueLinkContextsSurvivesPluginThrowingExceptionFromGetInitialHtml()
     throws Exception {
   Mockito.when(renderer.shouldDisplay(Mockito.<RemoteIssueLink>any())).thenReturn(true);
   Mockito.when(goodDescriptorRenderer.getInitialHtml(Mockito.<RemoteIssueLink>any()))
       .thenThrow(new RuntimeException("Misbehaving plugin exception"));
   final Map<String, List<IssueLinkContext>> contexts =
       RemoteIssueLinkUtils.convertToIssueLinkContexts(
           ImmutableList.of(link), 1L, "", new MockI18nHelper(), pluginAccessor);
   Assert.assertEquals(Collections.<String, List<IssueLinkContext>>emptyMap(), contexts);
 }
  @Test
  public void testConvertToIssueLinkContexts() throws Exception {
    Mockito.when(renderer.shouldDisplay(Mockito.<RemoteIssueLink>any())).thenReturn(true);
    Mockito.when(renderer.requiresAsyncLoading(link)).thenReturn(true);
    Mockito.when(goodDescriptorRenderer.getInitialHtml(link)).thenReturn("valid html");

    final Map<String, List<IssueLinkContext>> contextMap =
        RemoteIssueLinkUtils.convertToIssueLinkContexts(
            ImmutableList.of(link), 1L, "", new MockI18nHelper(), pluginAccessor);

    Assert.assertEquals(1, contextMap.size());
    final List<IssueLinkContext> contexts = contextMap.values().iterator().next();
    final IssueLinkContext context = Iterables.getOnlyElement(contexts);
    Assert.assertTrue(context.isRequiresAsyncLoading());
    Assert.assertEquals("valid html", context.getHtml());
  }