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

public final class MetricSpecificationV1Tests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        MetricSpecificationV1 model =
            BinaryData
                .fromString(
                    "{\"name\":\"oxxjtfelluwf\",\"displayName\":\"tonpe\",\"displayDescription\":\"pjkjlxofpdv\",\"unit\":\"CountPerSecond\",\"aggregationType\":\"NotSpecified\",\"dimensions\":[{\"name\":\"ninmayhuyb\",\"displayName\":\"podepoo\",\"toBeExportedForShoebox\":true}],\"fillGapWithZero\":false,\"category\":\"Capacity\",\"resourceIdDimensionNameOverride\":\"heognarxzxtheo\",\"supportedTimeGrainTypes\":[\"PT1D\"],\"supportedAggregationTypes\":[\"Count\"]}")
                .toObject(MetricSpecificationV1.class);
        Assertions.assertEquals("oxxjtfelluwf", model.name());
        Assertions.assertEquals("tonpe", model.displayName());
        Assertions.assertEquals("pjkjlxofpdv", model.displayDescription());
        Assertions.assertEquals(MetricUnit.COUNT_PER_SECOND, model.unit());
        Assertions.assertEquals(MetricAggregationType.NOT_SPECIFIED, model.aggregationType());
        Assertions.assertEquals("ninmayhuyb", model.dimensions().get(0).name());
        Assertions.assertEquals("podepoo", model.dimensions().get(0).displayName());
        Assertions.assertEquals(true, model.dimensions().get(0).toBeExportedForShoebox());
        Assertions.assertEquals(false, model.fillGapWithZero());
        Assertions.assertEquals(MetricCategory.CAPACITY, model.category());
        Assertions.assertEquals("heognarxzxtheo", model.resourceIdDimensionNameOverride());
        Assertions.assertEquals(TimeGrain.PT1D, model.supportedTimeGrainTypes().get(0));
        Assertions.assertEquals(MetricAggregationType.COUNT, model.supportedAggregationTypes().get(0));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        MetricSpecificationV1 model =
            new MetricSpecificationV1()
                .withName("oxxjtfelluwf")
                .withDisplayName("tonpe")
                .withDisplayDescription("pjkjlxofpdv")
                .withUnit(MetricUnit.COUNT_PER_SECOND)
                .withAggregationType(MetricAggregationType.NOT_SPECIFIED)
                .withDimensions(
                    Arrays
                        .asList(
                            new MetricDimensionV1()
                                .withName("ninmayhuyb")
                                .withDisplayName("podepoo")
                                .withToBeExportedForShoebox(true)))
                .withFillGapWithZero(false)
                .withCategory(MetricCategory.CAPACITY)
                .withResourceIdDimensionNameOverride("heognarxzxtheo")
                .withSupportedTimeGrainTypes(Arrays.asList(TimeGrain.PT1D))
                .withSupportedAggregationTypes(Arrays.asList(MetricAggregationType.COUNT));
        model = BinaryData.fromObject(model).toObject(MetricSpecificationV1.class);
        Assertions.assertEquals("oxxjtfelluwf", model.name());
        Assertions.assertEquals("tonpe", model.displayName());
        Assertions.assertEquals("pjkjlxofpdv", model.displayDescription());
        Assertions.assertEquals(MetricUnit.COUNT_PER_SECOND, model.unit());
        Assertions.assertEquals(MetricAggregationType.NOT_SPECIFIED, model.aggregationType());
        Assertions.assertEquals("ninmayhuyb", model.dimensions().get(0).name());
        Assertions.assertEquals("podepoo", model.dimensions().get(0).displayName());
        Assertions.assertEquals(true, model.dimensions().get(0).toBeExportedForShoebox());
        Assertions.assertEquals(false, model.fillGapWithZero());
        Assertions.assertEquals(MetricCategory.CAPACITY, model.category());
        Assertions.assertEquals("heognarxzxtheo", model.resourceIdDimensionNameOverride());
        Assertions.assertEquals(TimeGrain.PT1D, model.supportedTimeGrainTypes().get(0));
        Assertions.assertEquals(MetricAggregationType.COUNT, model.supportedAggregationTypes().get(0));
    }
}
