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

package com.azure.resourcemanager.appconfiguration.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.appconfiguration.fluent.models.OperationDefinitionInner;
import com.azure.resourcemanager.appconfiguration.models.OperationDefinitionDisplay;
import com.azure.resourcemanager.appconfiguration.models.OperationDefinitionListResult;
import com.azure.resourcemanager.appconfiguration.models.OperationProperties;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class OperationDefinitionListResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        OperationDefinitionListResult model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"name\":\"pgrjbz\",\"isDataAction\":true,\"display\":{\"provider\":\"xv\",\"resource\":\"byxqabn\",\"operation\":\"cpc\",\"description\":\"hurzafblj\"},\"origin\":\"pbtoqcjmkl\",\"properties\":{}},{\"name\":\"qidtqajzyu\",\"isDataAction\":true,\"display\":{\"provider\":\"jkrlkhbzhfepg\",\"resource\":\"qex\",\"operation\":\"ocxscpaierhhbcs\",\"description\":\"ummajtjaod\"},\"origin\":\"bnbdxkqpxokajion\",\"properties\":{}},{\"name\":\"xg\",\"isDataAction\":false,\"display\":{\"provider\":\"po\",\"resource\":\"maajrmvdjwzrlo\",\"operation\":\"clwhijcoejctbz\",\"description\":\"s\"},\"origin\":\"y\",\"properties\":{}}],\"nextLink\":\"fkgukdkexxppof\"}")
                .toObject(OperationDefinitionListResult.class);
        Assertions.assertEquals("pgrjbz", model.value().get(0).name());
        Assertions.assertEquals(true, model.value().get(0).isDataAction());
        Assertions.assertEquals("byxqabn", model.value().get(0).display().resource());
        Assertions.assertEquals("cpc", model.value().get(0).display().operation());
        Assertions.assertEquals("hurzafblj", model.value().get(0).display().description());
        Assertions.assertEquals("pbtoqcjmkl", model.value().get(0).origin());
        Assertions.assertEquals("fkgukdkexxppof", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        OperationDefinitionListResult model =
            new OperationDefinitionListResult()
                .withValue(
                    Arrays
                        .asList(
                            new OperationDefinitionInner()
                                .withName("pgrjbz")
                                .withIsDataAction(true)
                                .withDisplay(
                                    new OperationDefinitionDisplay()
                                        .withResource("byxqabn")
                                        .withOperation("cpc")
                                        .withDescription("hurzafblj"))
                                .withOrigin("pbtoqcjmkl")
                                .withProperties(new OperationProperties()),
                            new OperationDefinitionInner()
                                .withName("qidtqajzyu")
                                .withIsDataAction(true)
                                .withDisplay(
                                    new OperationDefinitionDisplay()
                                        .withResource("qex")
                                        .withOperation("ocxscpaierhhbcs")
                                        .withDescription("ummajtjaod"))
                                .withOrigin("bnbdxkqpxokajion")
                                .withProperties(new OperationProperties()),
                            new OperationDefinitionInner()
                                .withName("xg")
                                .withIsDataAction(false)
                                .withDisplay(
                                    new OperationDefinitionDisplay()
                                        .withResource("maajrmvdjwzrlo")
                                        .withOperation("clwhijcoejctbz")
                                        .withDescription("s"))
                                .withOrigin("y")
                                .withProperties(new OperationProperties())))
                .withNextLink("fkgukdkexxppof");
        model = BinaryData.fromObject(model).toObject(OperationDefinitionListResult.class);
        Assertions.assertEquals("pgrjbz", model.value().get(0).name());
        Assertions.assertEquals(true, model.value().get(0).isDataAction());
        Assertions.assertEquals("byxqabn", model.value().get(0).display().resource());
        Assertions.assertEquals("cpc", model.value().get(0).display().operation());
        Assertions.assertEquals("hurzafblj", model.value().get(0).display().description());
        Assertions.assertEquals("pbtoqcjmkl", model.value().get(0).origin());
        Assertions.assertEquals("fkgukdkexxppof", model.nextLink());
    }
}
