### Question:
PacketRejector { public InterledgerRejectPacket reject( final LinkId rejectingLinkId, final InterledgerPreparePacket preparePacket, final InterledgerErrorCode errorCode, final String errorMessage ) { Objects.requireNonNull(rejectingLinkId, "rejectingLinkId must not be null"); Objects.requireNonNull(preparePacket, "preparePacket must not be null"); Objects.requireNonNull(errorCode, "errorCode must not be null"); Objects.requireNonNull(errorMessage, "errorMessage must not be null"); final InterledgerRejectPacket rejectPacket = InterledgerRejectPacket.builder() .triggeredBy(operatorAddressSupplier.get()) .code(errorCode) .message(errorMessage) .build(); logger.debug( "Rejecting inside linkId={}: PreparePacket={} RejectPacket={}", rejectingLinkId, preparePacket, rejectPacket ); return rejectPacket; } PacketRejector(final Supplier<InterledgerAddress> operatorAddressSupplier); InterledgerRejectPacket reject(
      final LinkId rejectingLinkId, final InterledgerPreparePacket preparePacket,
      final InterledgerErrorCode errorCode, final String errorMessage
  );  }### Answer:
@Test(expected = NullPointerException.class) public void nullLinkId() { try { packetRejector.reject(null, PREPARE_PACKET, InterledgerErrorCode.T02_PEER_BUSY, ""); fail(); } catch (NullPointerException e) { assertThat(e.getMessage()).isEqualTo("rejectingLinkId must not be null"); throw e; } }
@Test(expected = NullPointerException.class) public void nullPreparePacket() { try { packetRejector.reject(LINK_ID, null, InterledgerErrorCode.T02_PEER_BUSY, ""); fail(); } catch (NullPointerException e) { assertThat(e.getMessage()).isEqualTo("preparePacket must not be null"); throw e; } }
@Test(expected = NullPointerException.class) public void nullErrorCode() { try { packetRejector.reject(LINK_ID, PREPARE_PACKET, null, ""); fail(); } catch (NullPointerException e) { assertThat(e.getMessage()).isEqualTo("errorCode must not be null"); throw e; } }
@Test(expected = NullPointerException.class) public void nullErrorMessage() { try { packetRejector.reject(LINK_ID, PREPARE_PACKET, InterledgerErrorCode.T02_PEER_BUSY, null); fail(); } catch (NullPointerException e) { assertThat(e.getMessage()).isEqualTo("errorMessage must not be null"); throw e; } }
@Test public void testReject() { InterledgerRejectPacket reject = packetRejector .reject(LINK_ID, PREPARE_PACKET, InterledgerErrorCode.T02_PEER_BUSY, "the error"); assertThat(reject.getCode()).isEqualTo(InterledgerErrorCode.T02_PEER_BUSY); assertThat(reject.getTriggeredBy().get()).isEqualTo(OPERATOR_ADDRESS); assertThat(reject.getMessage()).isEqualTo("the error"); assertThat(reject.getData().length).isEqualTo(0); }