// 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.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 com.azure.resourcemanager.databoxedge.models.TimeGrain;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class ServiceSpecificationTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ServiceSpecification model =
            BinaryData
                .fromString(
                    "{\"metricSpecifications\":[{\"name\":\"f\",\"displayName\":\"iodjp\",\"displayDescription\":\"w\",\"unit\":\"CountPerSecond\",\"aggregationType\":\"Maximum\",\"dimensions\":[],\"fillGapWithZero\":false,\"category\":\"Transaction\",\"resourceIdDimensionNameOverride\":\"oacctaza\",\"supportedTimeGrainTypes\":[\"PT1H\"],\"supportedAggregationTypes\":[\"Average\",\"None\",\"None\",\"NotSpecified\"]},{\"name\":\"fdfdosygexpa\",\"displayName\":\"akhmsbzjhcrz\",\"displayDescription\":\"dphlxaolt\",\"unit\":\"Percent\",\"aggregationType\":\"Average\",\"dimensions\":[],\"fillGapWithZero\":true,\"category\":\"Transaction\",\"resourceIdDimensionNameOverride\":\"s\",\"supportedTimeGrainTypes\":[\"PT15M\",\"PT1M\",\"PT1M\"],\"supportedAggregationTypes\":[\"Total\",\"Maximum\"]}]}")
                .toObject(ServiceSpecification.class);
        Assertions.assertEquals("f", model.metricSpecifications().get(0).name());
        Assertions.assertEquals("iodjp", model.metricSpecifications().get(0).displayName());
        Assertions.assertEquals("w", model.metricSpecifications().get(0).displayDescription());
        Assertions.assertEquals(MetricUnit.COUNT_PER_SECOND, model.metricSpecifications().get(0).unit());
        Assertions.assertEquals(MetricAggregationType.MAXIMUM, model.metricSpecifications().get(0).aggregationType());
        Assertions.assertEquals(false, model.metricSpecifications().get(0).fillGapWithZero());
        Assertions.assertEquals(MetricCategory.TRANSACTION, model.metricSpecifications().get(0).category());
        Assertions.assertEquals("oacctaza", model.metricSpecifications().get(0).resourceIdDimensionNameOverride());
        Assertions.assertEquals(TimeGrain.PT1H, model.metricSpecifications().get(0).supportedTimeGrainTypes().get(0));
        Assertions
            .assertEquals(
                MetricAggregationType.AVERAGE, model.metricSpecifications().get(0).supportedAggregationTypes().get(0));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ServiceSpecification model =
            new ServiceSpecification()
                .withMetricSpecifications(
                    Arrays
                        .asList(
                            new MetricSpecificationV1()
                                .withName("f")
                                .withDisplayName("iodjp")
                                .withDisplayDescription("w")
                                .withUnit(MetricUnit.COUNT_PER_SECOND)
                                .withAggregationType(MetricAggregationType.MAXIMUM)
                                .withDimensions(Arrays.asList())
                                .withFillGapWithZero(false)
                                .withCategory(MetricCategory.TRANSACTION)
                                .withResourceIdDimensionNameOverride("oacctaza")
                                .withSupportedTimeGrainTypes(Arrays.asList(TimeGrain.PT1H))
                                .withSupportedAggregationTypes(
                                    Arrays
                                        .asList(
                                            MetricAggregationType.AVERAGE,
                                            MetricAggregationType.NONE,
                                            MetricAggregationType.NONE,
                                            MetricAggregationType.NOT_SPECIFIED)),
                            new MetricSpecificationV1()
                                .withName("fdfdosygexpa")
                                .withDisplayName("akhmsbzjhcrz")
                                .withDisplayDescription("dphlxaolt")
                                .withUnit(MetricUnit.PERCENT)
                                .withAggregationType(MetricAggregationType.AVERAGE)
                                .withDimensions(Arrays.asList())
                                .withFillGapWithZero(true)
                                .withCategory(MetricCategory.TRANSACTION)
                                .withResourceIdDimensionNameOverride("s")
                                .withSupportedTimeGrainTypes(
                                    Arrays.asList(TimeGrain.PT15M, TimeGrain.PT1M, TimeGrain.PT1M))
                                .withSupportedAggregationTypes(
                                    Arrays.asList(MetricAggregationType.TOTAL, MetricAggregationType.MAXIMUM))));
        model = BinaryData.fromObject(model).toObject(ServiceSpecification.class);
        Assertions.assertEquals("f", model.metricSpecifications().get(0).name());
        Assertions.assertEquals("iodjp", model.metricSpecifications().get(0).displayName());
        Assertions.assertEquals("w", model.metricSpecifications().get(0).displayDescription());
        Assertions.assertEquals(MetricUnit.COUNT_PER_SECOND, model.metricSpecifications().get(0).unit());
        Assertions.assertEquals(MetricAggregationType.MAXIMUM, model.metricSpecifications().get(0).aggregationType());
        Assertions.assertEquals(false, model.metricSpecifications().get(0).fillGapWithZero());
        Assertions.assertEquals(MetricCategory.TRANSACTION, model.metricSpecifications().get(0).category());
        Assertions.assertEquals("oacctaza", model.metricSpecifications().get(0).resourceIdDimensionNameOverride());
        Assertions.assertEquals(TimeGrain.PT1H, model.metricSpecifications().get(0).supportedTimeGrainTypes().get(0));
        Assertions
            .assertEquals(
                MetricAggregationType.AVERAGE, model.metricSpecifications().get(0).supportedAggregationTypes().get(0));
    }
}
