### Question:
StatelessSpspReceiverLinkFactory implements LinkFactory { @Override public Link<?> constructLink( final Supplier<InterledgerAddress> operatorAddressSupplier, final LinkSettings linkSettings ) { Objects.requireNonNull(operatorAddressSupplier, "operatorAddressSupplier must not be null"); Objects.requireNonNull(linkSettings, "linkSettings must not be null"); if (!this.supports(linkSettings.getLinkType())) { throw new LinkException( String.format("LinkType not supported by this factory. linkType=%s", linkSettings.getLinkType()), LinkId.of("n/a") ); } Preconditions.checkArgument( StatelessSpspReceiverLinkSettings.class.isAssignableFrom(linkSettings.getClass()), "Constructing an instance of StatelessSpspReceiverLink requires an instance of StatelessSpspReceiverLinkSettings" ); return new StatelessSpspReceiverLink( operatorAddressSupplier, (StatelessSpspReceiverLinkSettings) linkSettings, statelessStreamReceiver ); } StatelessSpspReceiverLinkFactory(
      final PacketRejector packetRejector, final StatelessStreamReceiver statelessStreamReceiver
  ); @Override Link<?> constructLink(
      final Supplier<InterledgerAddress> operatorAddressSupplier, final LinkSettings linkSettings
  ); @Override boolean supports(LinkType linkType);  }### Answer:
@Test public void constructLinkWithNullOperator() { expectedException.expect(NullPointerException.class); expectedException.expectMessage("operatorAddressSupplier must not be null"); statelessSpspReceiverLinkFactory.constructLink(null, linkSettingsMock); }
@Test public void constructLinkWithNullLinkSettings() { expectedException.expect(NullPointerException.class); expectedException.expectMessage("linkSettings must not be null"); statelessSpspReceiverLinkFactory.constructLink(() -> OPERATOR_ADDRESS, null); }
@Test public void constructLinkWithUnsupportedLinkType() { expectedException.expect(LinkException.class); expectedException.expectMessage("LinkType not supported by this factory. linkType=LinkType(FOO)"); LinkSettings linkSettings = LinkSettings.builder() .linkType(LinkType.of("foo")) .build(); statelessSpspReceiverLinkFactory.constructLink(() -> OPERATOR_ADDRESS, linkSettings); }
@Test public void constructLink() { LinkSettings linkSettings = StatelessSpspReceiverLinkSettings.builder() .assetCode("USD") .assetScale((short) 9) .build(); StatelessSpspReceiverLink link = (StatelessSpspReceiverLink) statelessSpspReceiverLinkFactory .constructLink(() -> OPERATOR_ADDRESS, linkSettings); assertThat(link.getLinkSettings().assetCode()).isEqualTo("USD"); assertThat(link.getLinkSettings().assetScale()).isEqualTo(9); assertThat(link.getOperatorAddressSupplier().get()).isEqualTo(OPERATOR_ADDRESS); }