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

package com.azure.resourcemanager.mediaservices.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.mediaservices.fluent.models.ContentKeyPolicyPropertiesInner;
import com.azure.resourcemanager.mediaservices.models.ContentKeyPolicyConfiguration;
import com.azure.resourcemanager.mediaservices.models.ContentKeyPolicyOption;
import com.azure.resourcemanager.mediaservices.models.ContentKeyPolicyRestriction;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class ContentKeyPolicyPropertiesInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ContentKeyPolicyPropertiesInner model =
            BinaryData
                .fromString(
                    "{\"policyId\":\"d74dd1bf-60e8-4184-a78d-3c5b7acb1ef7\",\"created\":\"2021-04-20T00:02:54Z\",\"lastModified\":\"2021-11-02T08:41:46Z\",\"description\":\"bnbbeldawkz\",\"options\":[{\"policyOptionId\":\"032636e8-063e-4335-94af-e4bc26e3c4e9\",\"name\":\"ourqhakau\",\"configuration\":{\"@odata.type\":\"ContentKeyPolicyConfiguration\"},\"restriction\":{\"@odata.type\":\"ContentKeyPolicyRestriction\"}}]}")
                .toObject(ContentKeyPolicyPropertiesInner.class);
        Assertions.assertEquals("bnbbeldawkz", model.description());
        Assertions.assertEquals("ourqhakau", model.options().get(0).name());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ContentKeyPolicyPropertiesInner model =
            new ContentKeyPolicyPropertiesInner()
                .withDescription("bnbbeldawkz")
                .withOptions(
                    Arrays
                        .asList(
                            new ContentKeyPolicyOption()
                                .withName("ourqhakau")
                                .withConfiguration(new ContentKeyPolicyConfiguration())
                                .withRestriction(new ContentKeyPolicyRestriction())));
        model = BinaryData.fromObject(model).toObject(ContentKeyPolicyPropertiesInner.class);
        Assertions.assertEquals("bnbbeldawkz", model.description());
        Assertions.assertEquals("ourqhakau", model.options().get(0).name());
    }
}
