@@ -57,7 +57,7 @@ interface InsightAttachmentOperatorTest {
5757 assertThat(firstAttachment.created, endsWith(" :06:08.208Z" )) // 7 works fine locally and should be correct,
5858 assertThat(firstAttachment.created, startsWith(" 2023-02-21T0" )) // but github pipeline insists on 8 o'clock
5959
60- val downloadContent = insightAttachmentOperator.downloadAttachment(attachments.first().url).orNull ()!!
60+ val downloadContent = insightAttachmentOperator.downloadAttachment(attachments.first().url).getOrNull ()!!
6161 val sha256HashIS = calculateSha256(downloadContent.readBytes())
6262 assertThat(sha256HashIS, equalTo(" fd411837a51c43670e8d7367e64f72dbbcda5016f59988547c12d067505ef75b" ))
6363 }
@@ -67,34 +67,39 @@ interface InsightAttachmentOperatorTest {
6767
6868 @Test
6969 fun attachmentTestAttachmentCRUD () = runBlocking {
70- insightObjectOperator.makeSureObjectWithNameDoesNotExist(Country .id, " Attachistan" )
71- try {
72- val disclaimer = " created by Test and should only exist during test run. Deutsches ß und ä."
73- val country = insightObjectOperator.createObject(
74- Country .id,
75- CountryName .attributeId toValue " Attachistan" ,
76- CountryShortName .attributeId toValue disclaimer,
77- toDomain = ::identity
78- ).orFail()
79-
80- val attachment = insightAttachmentOperator.uploadAttachment(
81- country.id, " attachistan.txt" , " content" .byteInputStream()
82- ).orFail()
83-
84- assertThat(attachment.filename, equalTo(" attachistan.txt" ))
85-
86- val downloadContent = insightAttachmentOperator.downloadAttachment(attachment.url).orFail()
87- val downloadContentString = String (downloadContent.readBytes())
88- assertThat(downloadContentString, equalTo(" content" ))
89-
90- insightAttachmentOperator.deleteAttachment(attachment.id).orFail()
91- assertThat(insightAttachmentOperator.downloadAttachment(attachment.url).isLeft(), equalTo(true ))
92- } finally {
93- insightObjectOperator.makeSureObjectWithNameDoesNotExist(Country .id, " Attachistan" )
70+ mapOf (
71+ " AttachmentWithSimpleName" to " simple.txt" ,
72+ " AttachmentWithNumber" to " 01231515_a_1241.txt" ,
73+ " AttachmentWithImg" to " cover-L.jpg" ,
74+ ).forEach { (attachmentName, fileName) ->
75+ insightObjectOperator.makeSureObjectWithNameDoesNotExist(Country .id, attachmentName)
76+ try {
77+ val disclaimer = " created by Test and should only exist during test run. Deutsches ß und ä."
78+ val country = insightObjectOperator.createObject(
79+ Country .id,
80+ CountryName .attributeId toValue attachmentName,
81+ CountryShortName .attributeId toValue disclaimer,
82+ toDomain = ::identity
83+ ).orFail()
84+
85+ val attachment = insightAttachmentOperator.uploadAttachment(
86+ country.id, fileName, " content" .byteInputStream()
87+ ).orFail()
88+
89+ assertThat(attachment.filename, equalTo(fileName))
90+
91+ val downloadContent = insightAttachmentOperator.downloadAttachment(attachment.url).orFail()
92+ val downloadContentString = String (downloadContent.readBytes())
93+ assertThat(downloadContentString, equalTo(" content" ))
94+
95+ insightAttachmentOperator.deleteAttachment(attachment.id).orFail()
96+ assertThat(insightAttachmentOperator.downloadAttachment(attachment.url).isLeft(), equalTo(true ))
97+ } finally {
98+ insightObjectOperator.makeSureObjectWithNameDoesNotExist(Country .id, attachmentName)
99+ }
94100 }
95101 }
96102
97-
98103 @Test
99104 fun attachmentTestGetAttachmentsForNotExistingObject () = runBlocking {
100105 val responseError = insightAttachmentOperator.getAttachments(InsightObjectId .notPersistedObjectId).asError()
0 commit comments