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

package com.azure.resourcemanager.timeseriesinsights.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.timeseriesinsights.models.Dimension;
import com.azure.resourcemanager.timeseriesinsights.models.MetricAvailability;
import com.azure.resourcemanager.timeseriesinsights.models.MetricSpecification;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class MetricSpecificationTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        MetricSpecification model =
            BinaryData
                .fromString(
                    "{\"name\":\"wjzrnfygxgisp\",\"displayName\":\"vtz\",\"displayDescription\":\"ufubl\",\"unit\":\"fxqeof\",\"dimensions\":[{\"name\":\"jhqjbasvmsmjqul\",\"displayName\":\"sntnbybkzgcw\"}],\"aggregationType\":\"clxxwrljdo\",\"availabilities\":[{\"timeGrain\":\"qvkoc\",\"blobDuration\":\"jdkwtnhxbnjb\"},{\"timeGrain\":\"sqrglssainq\",\"blobDuration\":\"wnzlljfmppeeb\"},{\"timeGrain\":\"gxsabkyq\",\"blobDuration\":\"ujitcjcz\"}],\"category\":\"evndh\",\"resourceIdDimensionNameOverride\":\"wpdappdsbdkv\"}")
                .toObject(MetricSpecification.class);
        Assertions.assertEquals("wjzrnfygxgisp", model.name());
        Assertions.assertEquals("vtz", model.displayName());
        Assertions.assertEquals("ufubl", model.displayDescription());
        Assertions.assertEquals("fxqeof", model.unit());
        Assertions.assertEquals("jhqjbasvmsmjqul", model.dimensions().get(0).name());
        Assertions.assertEquals("sntnbybkzgcw", model.dimensions().get(0).displayName());
        Assertions.assertEquals("clxxwrljdo", model.aggregationType());
        Assertions.assertEquals("qvkoc", model.availabilities().get(0).timeGrain());
        Assertions.assertEquals("jdkwtnhxbnjb", model.availabilities().get(0).blobDuration());
        Assertions.assertEquals("evndh", model.category());
        Assertions.assertEquals("wpdappdsbdkv", model.resourceIdDimensionNameOverride());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        MetricSpecification model =
            new MetricSpecification()
                .withName("wjzrnfygxgisp")
                .withDisplayName("vtz")
                .withDisplayDescription("ufubl")
                .withUnit("fxqeof")
                .withDimensions(
                    Arrays.asList(new Dimension().withName("jhqjbasvmsmjqul").withDisplayName("sntnbybkzgcw")))
                .withAggregationType("clxxwrljdo")
                .withAvailabilities(
                    Arrays
                        .asList(
                            new MetricAvailability().withTimeGrain("qvkoc").withBlobDuration("jdkwtnhxbnjb"),
                            new MetricAvailability().withTimeGrain("sqrglssainq").withBlobDuration("wnzlljfmppeeb"),
                            new MetricAvailability().withTimeGrain("gxsabkyq").withBlobDuration("ujitcjcz")))
                .withCategory("evndh")
                .withResourceIdDimensionNameOverride("wpdappdsbdkv");
        model = BinaryData.fromObject(model).toObject(MetricSpecification.class);
        Assertions.assertEquals("wjzrnfygxgisp", model.name());
        Assertions.assertEquals("vtz", model.displayName());
        Assertions.assertEquals("ufubl", model.displayDescription());
        Assertions.assertEquals("fxqeof", model.unit());
        Assertions.assertEquals("jhqjbasvmsmjqul", model.dimensions().get(0).name());
        Assertions.assertEquals("sntnbybkzgcw", model.dimensions().get(0).displayName());
        Assertions.assertEquals("clxxwrljdo", model.aggregationType());
        Assertions.assertEquals("qvkoc", model.availabilities().get(0).timeGrain());
        Assertions.assertEquals("jdkwtnhxbnjb", model.availabilities().get(0).blobDuration());
        Assertions.assertEquals("evndh", model.category());
        Assertions.assertEquals("wpdappdsbdkv", model.resourceIdDimensionNameOverride());
    }
}
