// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.databox.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.databox.models.IdentityProperties;
import com.azure.resourcemanager.databox.models.KekType;
import com.azure.resourcemanager.databox.models.KeyEncryptionKey;
import com.azure.resourcemanager.databox.models.UserAssignedProperties;
import org.junit.jupiter.api.Assertions;

public final class KeyEncryptionKeyTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        KeyEncryptionKey model =
            BinaryData
                .fromString(
                    "{\"kekType\":\"CustomerManaged\",\"identityProperties\":{\"type\":\"ruwiqzbqjvsov\",\"userAssigned\":{\"resourceId\":\"kacspkw\"}},\"kekUrl\":\"zdobpxjmflbvvnch\",\"kekVaultResourceID\":\"cciw\"}")
                .toObject(KeyEncryptionKey.class);
        Assertions.assertEquals(KekType.CUSTOMER_MANAGED, model.kekType());
        Assertions.assertEquals("ruwiqzbqjvsov", model.identityProperties().type());
        Assertions.assertEquals("kacspkw", model.identityProperties().userAssigned().resourceId());
        Assertions.assertEquals("zdobpxjmflbvvnch", model.kekUrl());
        Assertions.assertEquals("cciw", model.kekVaultResourceId());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        KeyEncryptionKey model =
            new KeyEncryptionKey()
                .withKekType(KekType.CUSTOMER_MANAGED)
                .withIdentityProperties(
                    new IdentityProperties()
                        .withType("ruwiqzbqjvsov")
                        .withUserAssigned(new UserAssignedProperties().withResourceId("kacspkw")))
                .withKekUrl("zdobpxjmflbvvnch")
                .withKekVaultResourceId("cciw");
        model = BinaryData.fromObject(model).toObject(KeyEncryptionKey.class);
        Assertions.assertEquals(KekType.CUSTOMER_MANAGED, model.kekType());
        Assertions.assertEquals("ruwiqzbqjvsov", model.identityProperties().type());
        Assertions.assertEquals("kacspkw", model.identityProperties().userAssigned().resourceId());
        Assertions.assertEquals("zdobpxjmflbvvnch", model.kekUrl());
        Assertions.assertEquals("cciw", model.kekVaultResourceId());
    }
}
