### Question:
LinkFactoryProvider { public LinkFactory getLinkFactory(final LinkType linkType) { Objects.requireNonNull(linkType, "linkType must not be null"); return Optional.ofNullable(this.linkFactories.get(linkType)) .orElseThrow(() -> new LinkException( String.format("No registered LinkFactory linkType=%s", linkType), LinkId.of("n/a")) ); } LinkFactoryProvider();  LinkFactoryProvider(final Map<LinkType, LinkFactory> linkFactories); LinkFactory getLinkFactory(final LinkType linkType); LinkFactory registerLinkFactory(final LinkType linkType, final LinkFactory linkFactory);  }### Answer:
@Test(expected = LinkException.class) public void getUnregisteredLinkFactory() { try { linkFactoryProvider.getLinkFactory(TEST_LINK_TYPE); } catch (LinkException e) { assertThat(e.getMessage()).isEqualTo("No registered LinkFactory linkType=LinkType(FOO)"); throw e; } }