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

package com.azure.resourcemanager.policyinsights.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.policyinsights.models.CheckRestrictionsRequest;
import com.azure.resourcemanager.policyinsights.models.CheckRestrictionsResourceDetails;
import com.azure.resourcemanager.policyinsights.models.PendingField;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public final class CheckRestrictionsRequestTests {
    @Test
    public void testDeserialize() {
        CheckRestrictionsRequest model =
            BinaryData
                .fromString(
                    "{\"resourceDetails\":{\"apiVersion\":\"gxqquezik\",\"scope\":\"ggxkallatmelwuip\"},\"pendingFields\":[{\"field\":\"jzkzi\",\"values\":[\"vc\",\"ayrhyrnx\"]},{\"field\":\"mueedndrdvstk\",\"values\":[\"tchealmf\"]},{\"field\":\"tdaaygdvwvg\",\"values\":[\"hgwxrtfudx\",\"pxgy\",\"agvrvmnpkuk\",\"himdbl\"]},{\"field\":\"gwimfn\",\"values\":[\"j\",\"wmszkk\"]}]}")
                .toObject(CheckRestrictionsRequest.class);
        Assertions.assertEquals("gxqquezik", model.resourceDetails().apiVersion());
        Assertions.assertEquals("ggxkallatmelwuip", model.resourceDetails().scope());
        Assertions.assertEquals("jzkzi", model.pendingFields().get(0).field());
        Assertions.assertEquals("vc", model.pendingFields().get(0).values().get(0));
    }

    @Test
    public void testSerialize() {
        CheckRestrictionsRequest model =
            new CheckRestrictionsRequest()
                .withResourceDetails(
                    new CheckRestrictionsResourceDetails().withApiVersion("gxqquezik").withScope("ggxkallatmelwuip"))
                .withPendingFields(
                    Arrays
                        .asList(
                            new PendingField().withField("jzkzi").withValues(Arrays.asList("vc", "ayrhyrnx")),
                            new PendingField().withField("mueedndrdvstk").withValues(Arrays.asList("tchealmf")),
                            new PendingField()
                                .withField("tdaaygdvwvg")
                                .withValues(Arrays.asList("hgwxrtfudx", "pxgy", "agvrvmnpkuk", "himdbl")),
                            new PendingField().withField("gwimfn").withValues(Arrays.asList("j", "wmszkk"))));
        model = BinaryData.fromObject(model).toObject(CheckRestrictionsRequest.class);
        Assertions.assertEquals("gxqquezik", model.resourceDetails().apiVersion());
        Assertions.assertEquals("ggxkallatmelwuip", model.resourceDetails().scope());
        Assertions.assertEquals("jzkzi", model.pendingFields().get(0).field());
        Assertions.assertEquals("vc", model.pendingFields().get(0).values().get(0));
    }
}
