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

package com.azure.resourcemanager.appconfiguration.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.appconfiguration.models.LogSpecification;
import com.azure.resourcemanager.appconfiguration.models.MetricSpecification;
import com.azure.resourcemanager.appconfiguration.models.OperationProperties;
import com.azure.resourcemanager.appconfiguration.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\":{\"logSpecifications\":[{\"name\":\"xuigdtopbobj\",\"displayName\":\"hm\",\"blobDuration\":\"u\"}],\"metricSpecifications\":[{\"name\":\"hrzayvvtpgvdf\",\"displayName\":\"otkftutqxlngx\",\"displayDescription\":\"fgugnxkrxdqmid\",\"unit\":\"hzrvqd\",\"aggregationType\":\"bhj\",\"internalMetricName\":\"igeho\",\"dimensions\":[],\"fillGapWithZero\":true}]}}")
                .toObject(OperationProperties.class);
        Assertions.assertEquals("xuigdtopbobj", model.serviceSpecification().logSpecifications().get(0).name());
        Assertions.assertEquals("hm", model.serviceSpecification().logSpecifications().get(0).displayName());
        Assertions.assertEquals("u", model.serviceSpecification().logSpecifications().get(0).blobDuration());
        Assertions.assertEquals("hrzayvvtpgvdf", model.serviceSpecification().metricSpecifications().get(0).name());
        Assertions
            .assertEquals("otkftutqxlngx", model.serviceSpecification().metricSpecifications().get(0).displayName());
        Assertions
            .assertEquals(
                "fgugnxkrxdqmid", model.serviceSpecification().metricSpecifications().get(0).displayDescription());
        Assertions.assertEquals("hzrvqd", model.serviceSpecification().metricSpecifications().get(0).unit());
        Assertions.assertEquals("bhj", model.serviceSpecification().metricSpecifications().get(0).aggregationType());
        Assertions
            .assertEquals("igeho", model.serviceSpecification().metricSpecifications().get(0).internalMetricName());
        Assertions.assertEquals(true, model.serviceSpecification().metricSpecifications().get(0).fillGapWithZero());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        OperationProperties model =
            new OperationProperties()
                .withServiceSpecification(
                    new ServiceSpecification()
                        .withLogSpecifications(
                            Arrays
                                .asList(
                                    new LogSpecification()
                                        .withName("xuigdtopbobj")
                                        .withDisplayName("hm")
                                        .withBlobDuration("u")))
                        .withMetricSpecifications(
                            Arrays
                                .asList(
                                    new MetricSpecification()
                                        .withName("hrzayvvtpgvdf")
                                        .withDisplayName("otkftutqxlngx")
                                        .withDisplayDescription("fgugnxkrxdqmid")
                                        .withUnit("hzrvqd")
                                        .withAggregationType("bhj")
                                        .withInternalMetricName("igeho")
                                        .withDimensions(Arrays.asList())
                                        .withFillGapWithZero(true))));
        model = BinaryData.fromObject(model).toObject(OperationProperties.class);
        Assertions.assertEquals("xuigdtopbobj", model.serviceSpecification().logSpecifications().get(0).name());
        Assertions.assertEquals("hm", model.serviceSpecification().logSpecifications().get(0).displayName());
        Assertions.assertEquals("u", model.serviceSpecification().logSpecifications().get(0).blobDuration());
        Assertions.assertEquals("hrzayvvtpgvdf", model.serviceSpecification().metricSpecifications().get(0).name());
        Assertions
            .assertEquals("otkftutqxlngx", model.serviceSpecification().metricSpecifications().get(0).displayName());
        Assertions
            .assertEquals(
                "fgugnxkrxdqmid", model.serviceSpecification().metricSpecifications().get(0).displayDescription());
        Assertions.assertEquals("hzrvqd", model.serviceSpecification().metricSpecifications().get(0).unit());
        Assertions.assertEquals("bhj", model.serviceSpecification().metricSpecifications().get(0).aggregationType());
        Assertions
            .assertEquals("igeho", model.serviceSpecification().metricSpecifications().get(0).internalMetricName());
        Assertions.assertEquals(true, model.serviceSpecification().metricSpecifications().get(0).fillGapWithZero());
    }
}
