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

package com.azure.resourcemanager.databoxedge.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.databoxedge.fluent.models.OperationProperties;
import com.azure.resourcemanager.databoxedge.models.MetricAggregationType;
import com.azure.resourcemanager.databoxedge.models.MetricCategory;
import com.azure.resourcemanager.databoxedge.models.MetricSpecificationV1;
import com.azure.resourcemanager.databoxedge.models.MetricUnit;
import com.azure.resourcemanager.databoxedge.models.ServiceSpecification;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class OperationPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        OperationProperties model =
            BinaryData
                .fromString(
                    "{\"serviceSpecification\":{\"metricSpecifications\":[{\"name\":\"pzvgnwzsymglzufc\",\"displayName\":\"kohdbiha\",\"displayDescription\":\"fhfcb\",\"unit\":\"NotSpecified\",\"aggregationType\":\"None\",\"dimensions\":[],\"fillGapWithZero\":false,\"category\":\"Transaction\",\"resourceIdDimensionNameOverride\":\"abifpikxwczbys\",\"supportedTimeGrainTypes\":[],\"supportedAggregationTypes\":[]},{\"name\":\"x\",\"displayName\":\"ivyqniwbybrkxvd\",\"displayDescription\":\"jgrtfwvukxga\",\"unit\":\"Seconds\",\"aggregationType\":\"Maximum\",\"dimensions\":[],\"fillGapWithZero\":false,\"category\":\"Transaction\",\"resourceIdDimensionNameOverride\":\"yejhk\",\"supportedTimeGrainTypes\":[],\"supportedAggregationTypes\":[]},{\"name\":\"napczwlokjy\",\"displayName\":\"kkvnipjox\",\"displayDescription\":\"nchgej\",\"unit\":\"Milliseconds\",\"aggregationType\":\"Average\",\"dimensions\":[],\"fillGapWithZero\":true,\"category\":\"Capacity\",\"resourceIdDimensionNameOverride\":\"eho\",\"supportedTimeGrainTypes\":[],\"supportedAggregationTypes\":[]},{\"name\":\"huxinpmqnj\",\"displayName\":\"wixjsprozvcp\",\"displayDescription\":\"eg\",\"unit\":\"CountPerSecond\",\"aggregationType\":\"NotSpecified\",\"dimensions\":[],\"fillGapWithZero\":false,\"category\":\"Capacity\",\"resourceIdDimensionNameOverride\":\"dvpjhulsuuvmk\",\"supportedTimeGrainTypes\":[],\"supportedAggregationTypes\":[]}]}}")
                .toObject(OperationProperties.class);
        Assertions.assertEquals("pzvgnwzsymglzufc", model.serviceSpecification().metricSpecifications().get(0).name());
        Assertions.assertEquals("kohdbiha", model.serviceSpecification().metricSpecifications().get(0).displayName());
        Assertions
            .assertEquals("fhfcb", model.serviceSpecification().metricSpecifications().get(0).displayDescription());
        Assertions
            .assertEquals(MetricUnit.NOT_SPECIFIED, model.serviceSpecification().metricSpecifications().get(0).unit());
        Assertions
            .assertEquals(
                MetricAggregationType.NONE,
                model.serviceSpecification().metricSpecifications().get(0).aggregationType());
        Assertions.assertEquals(false, model.serviceSpecification().metricSpecifications().get(0).fillGapWithZero());
        Assertions
            .assertEquals(
                MetricCategory.TRANSACTION, model.serviceSpecification().metricSpecifications().get(0).category());
        Assertions
            .assertEquals(
                "abifpikxwczbys",
                model.serviceSpecification().metricSpecifications().get(0).resourceIdDimensionNameOverride());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        OperationProperties model =
            new OperationProperties()
                .withServiceSpecification(
                    new ServiceSpecification()
                        .withMetricSpecifications(
                            Arrays
                                .asList(
                                    new MetricSpecificationV1()
                                        .withName("pzvgnwzsymglzufc")
                                        .withDisplayName("kohdbiha")
                                        .withDisplayDescription("fhfcb")
                                        .withUnit(MetricUnit.NOT_SPECIFIED)
                                        .withAggregationType(MetricAggregationType.NONE)
                                        .withDimensions(Arrays.asList())
                                        .withFillGapWithZero(false)
                                        .withCategory(MetricCategory.TRANSACTION)
                                        .withResourceIdDimensionNameOverride("abifpikxwczbys")
                                        .withSupportedTimeGrainTypes(Arrays.asList())
                                        .withSupportedAggregationTypes(Arrays.asList()),
                                    new MetricSpecificationV1()
                                        .withName("x")
                                        .withDisplayName("ivyqniwbybrkxvd")
                                        .withDisplayDescription("jgrtfwvukxga")
                                        .withUnit(MetricUnit.SECONDS)
                                        .withAggregationType(MetricAggregationType.MAXIMUM)
                                        .withDimensions(Arrays.asList())
                                        .withFillGapWithZero(false)
                                        .withCategory(MetricCategory.TRANSACTION)
                                        .withResourceIdDimensionNameOverride("yejhk")
                                        .withSupportedTimeGrainTypes(Arrays.asList())
                                        .withSupportedAggregationTypes(Arrays.asList()),
                                    new MetricSpecificationV1()
                                        .withName("napczwlokjy")
                                        .withDisplayName("kkvnipjox")
                                        .withDisplayDescription("nchgej")
                                        .withUnit(MetricUnit.MILLISECONDS)
                                        .withAggregationType(MetricAggregationType.AVERAGE)
                                        .withDimensions(Arrays.asList())
                                        .withFillGapWithZero(true)
                                        .withCategory(MetricCategory.CAPACITY)
                                        .withResourceIdDimensionNameOverride("eho")
                                        .withSupportedTimeGrainTypes(Arrays.asList())
                                        .withSupportedAggregationTypes(Arrays.asList()),
                                    new MetricSpecificationV1()
                                        .withName("huxinpmqnj")
                                        .withDisplayName("wixjsprozvcp")
                                        .withDisplayDescription("eg")
                                        .withUnit(MetricUnit.COUNT_PER_SECOND)
                                        .withAggregationType(MetricAggregationType.NOT_SPECIFIED)
                                        .withDimensions(Arrays.asList())
                                        .withFillGapWithZero(false)
                                        .withCategory(MetricCategory.CAPACITY)
                                        .withResourceIdDimensionNameOverride("dvpjhulsuuvmk")
                                        .withSupportedTimeGrainTypes(Arrays.asList())
                                        .withSupportedAggregationTypes(Arrays.asList()))));
        model = BinaryData.fromObject(model).toObject(OperationProperties.class);
        Assertions.assertEquals("pzvgnwzsymglzufc", model.serviceSpecification().metricSpecifications().get(0).name());
        Assertions.assertEquals("kohdbiha", model.serviceSpecification().metricSpecifications().get(0).displayName());
        Assertions
            .assertEquals("fhfcb", model.serviceSpecification().metricSpecifications().get(0).displayDescription());
        Assertions
            .assertEquals(MetricUnit.NOT_SPECIFIED, model.serviceSpecification().metricSpecifications().get(0).unit());
        Assertions
            .assertEquals(
                MetricAggregationType.NONE,
                model.serviceSpecification().metricSpecifications().get(0).aggregationType());
        Assertions.assertEquals(false, model.serviceSpecification().metricSpecifications().get(0).fillGapWithZero());
        Assertions
            .assertEquals(
                MetricCategory.TRANSACTION, model.serviceSpecification().metricSpecifications().get(0).category());
        Assertions
            .assertEquals(
                "abifpikxwczbys",
                model.serviceSpecification().metricSpecifications().get(0).resourceIdDimensionNameOverride());
    }
}
