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

package com.azure.resourcemanager.storagecache.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.storagecache.fluent.models.ApiOperationProperties;
import com.azure.resourcemanager.storagecache.models.ApiOperationPropertiesServiceSpecification;
import com.azure.resourcemanager.storagecache.models.LogSpecification;
import com.azure.resourcemanager.storagecache.models.MetricSpecification;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class ApiOperationPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ApiOperationProperties model =
            BinaryData
                .fromString(
                    "{\"serviceSpecification\":{\"metricSpecifications\":[{\"name\":\"cbtwnpzaoqvuh\",\"displayName\":\"cffcyddglmj\",\"displayDescription\":\"jqkwpyeicx\",\"unit\":\"ciwqvhk\",\"aggregationType\":\"xuigdtopbobj\",\"supportedAggregationTypes\":[],\"metricClass\":\"m\",\"dimensions\":[]}],\"logSpecifications\":[{\"name\":\"a\",\"displayName\":\"rzayv\"}]}}")
                .toObject(ApiOperationProperties.class);
        Assertions.assertEquals("cbtwnpzaoqvuh", model.serviceSpecification().metricSpecifications().get(0).name());
        Assertions
            .assertEquals("cffcyddglmj", model.serviceSpecification().metricSpecifications().get(0).displayName());
        Assertions
            .assertEquals(
                "jqkwpyeicx", model.serviceSpecification().metricSpecifications().get(0).displayDescription());
        Assertions.assertEquals("ciwqvhk", model.serviceSpecification().metricSpecifications().get(0).unit());
        Assertions
            .assertEquals("xuigdtopbobj", model.serviceSpecification().metricSpecifications().get(0).aggregationType());
        Assertions.assertEquals("m", model.serviceSpecification().metricSpecifications().get(0).metricClass());
        Assertions.assertEquals("a", model.serviceSpecification().logSpecifications().get(0).name());
        Assertions.assertEquals("rzayv", model.serviceSpecification().logSpecifications().get(0).displayName());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ApiOperationProperties model =
            new ApiOperationProperties()
                .withServiceSpecification(
                    new ApiOperationPropertiesServiceSpecification()
                        .withMetricSpecifications(
                            Arrays
                                .asList(
                                    new MetricSpecification()
                                        .withName("cbtwnpzaoqvuh")
                                        .withDisplayName("cffcyddglmj")
                                        .withDisplayDescription("jqkwpyeicx")
                                        .withUnit("ciwqvhk")
                                        .withAggregationType("xuigdtopbobj")
                                        .withSupportedAggregationTypes(Arrays.asList())
                                        .withMetricClass("m")
                                        .withDimensions(Arrays.asList())))
                        .withLogSpecifications(
                            Arrays.asList(new LogSpecification().withName("a").withDisplayName("rzayv"))));
        model = BinaryData.fromObject(model).toObject(ApiOperationProperties.class);
        Assertions.assertEquals("cbtwnpzaoqvuh", model.serviceSpecification().metricSpecifications().get(0).name());
        Assertions
            .assertEquals("cffcyddglmj", model.serviceSpecification().metricSpecifications().get(0).displayName());
        Assertions
            .assertEquals(
                "jqkwpyeicx", model.serviceSpecification().metricSpecifications().get(0).displayDescription());
        Assertions.assertEquals("ciwqvhk", model.serviceSpecification().metricSpecifications().get(0).unit());
        Assertions
            .assertEquals("xuigdtopbobj", model.serviceSpecification().metricSpecifications().get(0).aggregationType());
        Assertions.assertEquals("m", model.serviceSpecification().metricSpecifications().get(0).metricClass());
        Assertions.assertEquals("a", model.serviceSpecification().logSpecifications().get(0).name());
        Assertions.assertEquals("rzayv", model.serviceSpecification().logSpecifications().get(0).displayName());
    }
}
