// 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.models.ApiOperationPropertiesServiceSpecification;
import com.azure.resourcemanager.storagecache.models.LogSpecification;
import com.azure.resourcemanager.storagecache.models.MetricAggregationType;
import com.azure.resourcemanager.storagecache.models.MetricSpecification;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class ApiOperationPropertiesServiceSpecificationTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ApiOperationPropertiesServiceSpecification model =
            BinaryData
                .fromString(
                    "{\"metricSpecifications\":[{\"name\":\"vdfgiotk\",\"displayName\":\"utqxlngx\",\"displayDescription\":\"fgugnxkrxdqmid\",\"unit\":\"hzrvqd\",\"aggregationType\":\"bhj\",\"supportedAggregationTypes\":[\"NotSpecified\",\"Total\"],\"metricClass\":\"oqfbowskanyk\",\"dimensions\":[]},{\"name\":\"u\",\"displayName\":\"wgqyw\",\"displayDescription\":\"drvyn\",\"unit\":\"gpphrcgyn\",\"aggregationType\":\"cpecfvmmcoofs\",\"supportedAggregationTypes\":[\"Maximum\",\"None\"],\"metricClass\":\"bmqj\",\"dimensions\":[]}],\"logSpecifications\":[{\"name\":\"mivkwlzuvcc\",\"displayName\":\"nfnbacfionlebxe\"}]}")
                .toObject(ApiOperationPropertiesServiceSpecification.class);
        Assertions.assertEquals("vdfgiotk", model.metricSpecifications().get(0).name());
        Assertions.assertEquals("utqxlngx", model.metricSpecifications().get(0).displayName());
        Assertions.assertEquals("fgugnxkrxdqmid", model.metricSpecifications().get(0).displayDescription());
        Assertions.assertEquals("hzrvqd", model.metricSpecifications().get(0).unit());
        Assertions.assertEquals("bhj", model.metricSpecifications().get(0).aggregationType());
        Assertions
            .assertEquals(
                MetricAggregationType.NOT_SPECIFIED,
                model.metricSpecifications().get(0).supportedAggregationTypes().get(0));
        Assertions.assertEquals("oqfbowskanyk", model.metricSpecifications().get(0).metricClass());
        Assertions.assertEquals("mivkwlzuvcc", model.logSpecifications().get(0).name());
        Assertions.assertEquals("nfnbacfionlebxe", model.logSpecifications().get(0).displayName());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ApiOperationPropertiesServiceSpecification model =
            new ApiOperationPropertiesServiceSpecification()
                .withMetricSpecifications(
                    Arrays
                        .asList(
                            new MetricSpecification()
                                .withName("vdfgiotk")
                                .withDisplayName("utqxlngx")
                                .withDisplayDescription("fgugnxkrxdqmid")
                                .withUnit("hzrvqd")
                                .withAggregationType("bhj")
                                .withSupportedAggregationTypes(
                                    Arrays.asList(MetricAggregationType.NOT_SPECIFIED, MetricAggregationType.TOTAL))
                                .withMetricClass("oqfbowskanyk")
                                .withDimensions(Arrays.asList()),
                            new MetricSpecification()
                                .withName("u")
                                .withDisplayName("wgqyw")
                                .withDisplayDescription("drvyn")
                                .withUnit("gpphrcgyn")
                                .withAggregationType("cpecfvmmcoofs")
                                .withSupportedAggregationTypes(
                                    Arrays.asList(MetricAggregationType.MAXIMUM, MetricAggregationType.NONE))
                                .withMetricClass("bmqj")
                                .withDimensions(Arrays.asList())))
                .withLogSpecifications(
                    Arrays.asList(new LogSpecification().withName("mivkwlzuvcc").withDisplayName("nfnbacfionlebxe")));
        model = BinaryData.fromObject(model).toObject(ApiOperationPropertiesServiceSpecification.class);
        Assertions.assertEquals("vdfgiotk", model.metricSpecifications().get(0).name());
        Assertions.assertEquals("utqxlngx", model.metricSpecifications().get(0).displayName());
        Assertions.assertEquals("fgugnxkrxdqmid", model.metricSpecifications().get(0).displayDescription());
        Assertions.assertEquals("hzrvqd", model.metricSpecifications().get(0).unit());
        Assertions.assertEquals("bhj", model.metricSpecifications().get(0).aggregationType());
        Assertions
            .assertEquals(
                MetricAggregationType.NOT_SPECIFIED,
                model.metricSpecifications().get(0).supportedAggregationTypes().get(0));
        Assertions.assertEquals("oqfbowskanyk", model.metricSpecifications().get(0).metricClass());
        Assertions.assertEquals("mivkwlzuvcc", model.logSpecifications().get(0).name());
        Assertions.assertEquals("nfnbacfionlebxe", model.logSpecifications().get(0).displayName());
    }
}
