// 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.fluent.models.OperationsListResultsInner;
import com.azure.resourcemanager.policyinsights.models.Operation;
import com.azure.resourcemanager.policyinsights.models.OperationDisplay;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public final class OperationsListResultsInnerTests {
    @Test
    public void testDeserialize() {
        OperationsListResultsInner model =
            BinaryData
                .fromString(
                    "{\"@odata.count\":964392835,\"value\":[{\"name\":\"tbhjpglkfgohdneu\",\"display\":{\"provider\":\"phsdyhto\",\"resource\":\"ikdowwquuvx\",\"operation\":\"clvit\",\"description\":\"qzonosggbhcohf\"}},{\"name\":\"sjnkal\",\"display\":{\"provider\":\"iiswacffgdkzze\",\"resource\":\"fvhqc\",\"operation\":\"ilvpnppfuflrwd\",\"description\":\"dlxyjrxs\"}}]}")
                .toObject(OperationsListResultsInner.class);
        Assertions.assertEquals("tbhjpglkfgohdneu", model.value().get(0).name());
        Assertions.assertEquals("phsdyhto", model.value().get(0).display().provider());
        Assertions.assertEquals("ikdowwquuvx", model.value().get(0).display().resource());
        Assertions.assertEquals("clvit", model.value().get(0).display().operation());
        Assertions.assertEquals("qzonosggbhcohf", model.value().get(0).display().description());
    }

    @Test
    public void testSerialize() {
        OperationsListResultsInner model =
            new OperationsListResultsInner()
                .withValue(
                    Arrays
                        .asList(
                            new Operation()
                                .withName("tbhjpglkfgohdneu")
                                .withDisplay(
                                    new OperationDisplay()
                                        .withProvider("phsdyhto")
                                        .withResource("ikdowwquuvx")
                                        .withOperation("clvit")
                                        .withDescription("qzonosggbhcohf")),
                            new Operation()
                                .withName("sjnkal")
                                .withDisplay(
                                    new OperationDisplay()
                                        .withProvider("iiswacffgdkzze")
                                        .withResource("fvhqc")
                                        .withOperation("ilvpnppfuflrwd")
                                        .withDescription("dlxyjrxs"))));
        model = BinaryData.fromObject(model).toObject(OperationsListResultsInner.class);
        Assertions.assertEquals("tbhjpglkfgohdneu", model.value().get(0).name());
        Assertions.assertEquals("phsdyhto", model.value().get(0).display().provider());
        Assertions.assertEquals("ikdowwquuvx", model.value().get(0).display().resource());
        Assertions.assertEquals("clvit", model.value().get(0).display().operation());
        Assertions.assertEquals("qzonosggbhcohf", model.value().get(0).display().description());
    }
}
