DocumentDownloadLinkGenerator { public static String generateDownloadLink(String serverTemplateId, String documentIdentifier) { if (serverTemplateId == null) { throw new IllegalArgumentException("ServerTemplateId cannot be null"); } if (documentIdentifier == null) { throw new IllegalArgumentException("DocumentIdentifier cannot be null"); } return PATTERN.replace(TEMPLATE_ID_TOKEN, serverTemplateId).replace(DOCUMENT_ID_TOKEN, documentIdentifier); }  static String generateDownloadLink(String serverTemplateId,
                                              String documentIdentifier); static final String TEMPLATE_ID_TOKEN; static final String DOCUMENT_ID_TOKEN; }
@Test public void testLinkGenerationFailure() { Assertions.assertThatThrownBy(() -> DocumentDownloadLinkGenerator.generateDownloadLink(null, DOC_ID)) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("ServerTemplateId cannot be null"); Assertions.assertThatThrownBy(() -> DocumentDownloadLinkGenerator.generateDownloadLink(TEMPLATE_ID, null)) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("DocumentIdentifier cannot be null"); }
@Test public void testLinkGeneration() { Assertions.assertThat(DocumentDownloadLinkGenerator.generateDownloadLink(TEMPLATE_ID, DOC_ID)) .doesNotContain(DocumentDownloadLinkGenerator.TEMPLATE_ID_TOKEN) .doesNotContain(DocumentDownloadLinkGenerator.DOCUMENT_ID_TOKEN) .contains(TEMPLATE_ID) .contains(DOC_ID); }