AssetServiceLayer { public Attachment createAttachmentNoContent(String assetId, String name, Attachment attachmentMetadata, UriInfo uriInfo) throws InvalidJsonAssetException, AssetPersistenceException, NonExistentArtefactException { String url = attachmentMetadata.getUrl(); if (url == null) { throw new InvalidJsonAssetException("The URL of the supplied attachment was null"); } String stringType = attachmentMetadata.getLinkType(); if (stringType == null) { throw new InvalidJsonAssetException("The link type for the attachment was not set."); } Attachment.LinkType linkType = Attachment.LinkType.forValue(stringType); if (linkType == null || (linkType != Attachment.LinkType.DIRECT && linkType != Attachment.LinkType.WEB_PAGE)) { throw new InvalidJsonAssetException("The link type for the attachment was set to an invalid value: " + stringType); } return createAttachment(assetId, name, attachmentMetadata, null, null, uriInfo); }  AssetCursor retrieveAllAssets(); AssetCursor retrieveAllAssets(Collection<AssetFilter> filters, String searchTerm, PaginationOptions pagination, SortOptions sortOptions); int countAllAssets(Collection<AssetFilter> filters, String searchTerm); List<Map<String, Object>> summarizeAssets(List<String> fields, Collection<AssetFilter> filters, String searchTerm); Asset createAsset(Asset asset, String creatorName); Asset retrieveAsset(String assetId, UriInfo uriInfo); Asset updateAsset(String assetId, Asset asset); void updateAssetState(Asset.StateAction action, String id); void deleteAsset(String assetId); Attachment createAttachmentWithContent(String assetId, String name, Attachment attachmentMetadata, String contentType,
                                                  InputStream attachmentContentStream, UriInfo uriInfo); Attachment createAttachmentNoContent(String assetId, String name, Attachment attachmentMetadata, UriInfo uriInfo); void deleteAttachment(String attachmentId); Attachment retrieveAttachmentMetadata(String assetId, String attachmentId, UriInfo uriInfo); AttachmentContentResponse retrieveAttachmentContent(String assetId, String attachmentId, String name, UriInfo uriInfo);  }
@Test public void testAddAttachmentInvalidAssetId() throws InvalidJsonAssetException, NonExistentArtefactException, AssetPersistenceException { String attachmentJSON = "{\"url\":\"http: Attachment attachment = Attachment.jsonToAttachment(attachmentJSON); assertThrows("The parent asset for this attachment (id=FFFFFFFFFFFFFFFF) does not exist in the repository.", NonExistentArtefactException.class, () -> service.createAttachmentNoContent("FFFFFFFFFFFFFFFF", "Mr Attachment", attachment, dummyUriInfo)); }