diff --git a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/domain/models/MessageAttachment.kt b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/domain/models/MessageAttachment.kt index c29fca708..f655e0a4d 100644 --- a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/domain/models/MessageAttachment.kt +++ b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/domain/models/MessageAttachment.kt @@ -14,6 +14,7 @@ import kotlinx.serialization.json.JsonDecoder import kotlinx.serialization.json.JsonNames import kotlinx.serialization.json.jsonObject import org.hyperledger.identus.apollo.base64.base64UrlDecoded +import org.hyperledger.identus.walletsdk.edgeagent.EdgeAgentError import java.util.UUID import kotlin.jvm.JvmOverloads @@ -27,31 +28,19 @@ sealed class AttachmentData { /** * This method verifies the type of [AttachmentData] and returns the data as a json string. */ - fun getDataAsJsonString(): String? { + fun getDataAsJsonString(): String { return when (this) { - is AttachmentHeader -> { - null - } - - is AttachmentJws -> { - null - } - - is AttachmentJwsData -> { - null - } - is AttachmentBase64 -> { this.base64.base64UrlDecoded } - is AttachmentLinkData -> { - null - } - is AttachmentJsonData -> { this.data } + + else -> { + throw EdgeAgentError.AttachmentTypeNotSupported() + } } } diff --git a/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/edgeagent/EdgeAgentTests.kt b/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/edgeagent/EdgeAgentTests.kt index e73864832..bb48dcf4a 100644 --- a/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/edgeagent/EdgeAgentTests.kt +++ b/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/edgeagent/EdgeAgentTests.kt @@ -85,7 +85,6 @@ import org.junit.runner.RunWith import org.junit.runners.JUnit4 import org.mockito.Mock import org.hyperledger.identus.walletsdk.pollux.models.PresentationSubmission -import org.junit.Assert.assertNull import org.mockito.Mockito.verify import org.mockito.Mockito.`when` import org.mockito.MockitoAnnotations @@ -1632,8 +1631,9 @@ class EdgeAgentTests { ) ) val attachments1 = message1.attachments - val attachmentDataString2 = attachments1.first().data.getDataAsJsonString() - assertNull(attachmentDataString2) + assertFailsWith { + attachments1.first().data.getDataAsJsonString() + } } val getCredentialDefinitionResponse =