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

package com.azure.resourcemanager.costmanagement.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.costmanagement.fluent.models.ViewInner;
import com.azure.resourcemanager.costmanagement.models.AccumulatedType;
import com.azure.resourcemanager.costmanagement.models.ChartType;
import com.azure.resourcemanager.costmanagement.models.KpiProperties;
import com.azure.resourcemanager.costmanagement.models.KpiType;
import com.azure.resourcemanager.costmanagement.models.MetricType;
import com.azure.resourcemanager.costmanagement.models.PivotProperties;
import com.azure.resourcemanager.costmanagement.models.PivotType;
import com.azure.resourcemanager.costmanagement.models.ReportTimeframeType;
import com.azure.resourcemanager.costmanagement.models.ReportType;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class ViewInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ViewInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"displayName\":\"jzrnf\",\"scope\":\"xgispemvtzfkufu\",\"createdOn\":\"2021-04-27T12:55:33Z\",\"modifiedOn\":\"2021-02-25T05:54:32Z\",\"dateRange\":\"qeof\",\"currency\":\"e\",\"query\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"includeMonetaryCommitment\":false},\"chart\":\"StackedColumn\",\"accumulated\":\"false\",\"metric\":\"ActualCost\",\"kpis\":[{\"type\":\"Budget\",\"id\":\"ntnbybkzg\",\"enabled\":true},{\"type\":\"Budget\",\"id\":\"xxwr\",\"enabled\":true},{\"type\":\"Budget\",\"id\":\"kcqvkocrc\",\"enabled\":false},{\"type\":\"Forecast\",\"id\":\"hxbnjbiksqrg\",\"enabled\":true}],\"pivots\":[{\"type\":\"TagKey\",\"name\":\"jwnzlljfmp\"},{\"type\":\"TagKey\",\"name\":\"vmgxsab\"},{\"type\":\"TagKey\",\"name\":\"uujitcjc\"}]},\"eTag\":\"zevndhkrwpdappds\",\"id\":\"dkvwrwjfe\",\"name\":\"snhu\",\"type\":\"je\"}")
                .toObject(ViewInner.class);
        Assertions.assertEquals("zevndhkrwpdappds", model.etag());
        Assertions.assertEquals("jzrnf", model.displayName());
        Assertions.assertEquals("xgispemvtzfkufu", model.scope());
        Assertions.assertEquals(ChartType.STACKED_COLUMN, model.chart());
        Assertions.assertEquals(AccumulatedType.FALSE, model.accumulated());
        Assertions.assertEquals(MetricType.ACTUAL_COST, model.metric());
        Assertions.assertEquals(KpiType.BUDGET, model.kpis().get(0).type());
        Assertions.assertEquals("ntnbybkzg", model.kpis().get(0).id());
        Assertions.assertEquals(true, model.kpis().get(0).enabled());
        Assertions.assertEquals(PivotType.TAG_KEY, model.pivots().get(0).type());
        Assertions.assertEquals("jwnzlljfmp", model.pivots().get(0).name());
        Assertions.assertEquals(ReportType.USAGE, model.typePropertiesType());
        Assertions.assertEquals(ReportTimeframeType.MONTH_TO_DATE, model.timeframe());
        Assertions.assertEquals(false, model.includeMonetaryCommitment());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ViewInner model =
            new ViewInner()
                .withEtag("zevndhkrwpdappds")
                .withDisplayName("jzrnf")
                .withScope("xgispemvtzfkufu")
                .withChart(ChartType.STACKED_COLUMN)
                .withAccumulated(AccumulatedType.FALSE)
                .withMetric(MetricType.ACTUAL_COST)
                .withKpis(
                    Arrays
                        .asList(
                            new KpiProperties().withType(KpiType.BUDGET).withId("ntnbybkzg").withEnabled(true),
                            new KpiProperties().withType(KpiType.BUDGET).withId("xxwr").withEnabled(true),
                            new KpiProperties().withType(KpiType.BUDGET).withId("kcqvkocrc").withEnabled(false),
                            new KpiProperties().withType(KpiType.FORECAST).withId("hxbnjbiksqrg").withEnabled(true)))
                .withPivots(
                    Arrays
                        .asList(
                            new PivotProperties().withType(PivotType.TAG_KEY).withName("jwnzlljfmp"),
                            new PivotProperties().withType(PivotType.TAG_KEY).withName("vmgxsab"),
                            new PivotProperties().withType(PivotType.TAG_KEY).withName("uujitcjc")))
                .withTypePropertiesType(ReportType.USAGE)
                .withTimeframe(ReportTimeframeType.MONTH_TO_DATE)
                .withIncludeMonetaryCommitment(false);
        model = BinaryData.fromObject(model).toObject(ViewInner.class);
        Assertions.assertEquals("zevndhkrwpdappds", model.etag());
        Assertions.assertEquals("jzrnf", model.displayName());
        Assertions.assertEquals("xgispemvtzfkufu", model.scope());
        Assertions.assertEquals(ChartType.STACKED_COLUMN, model.chart());
        Assertions.assertEquals(AccumulatedType.FALSE, model.accumulated());
        Assertions.assertEquals(MetricType.ACTUAL_COST, model.metric());
        Assertions.assertEquals(KpiType.BUDGET, model.kpis().get(0).type());
        Assertions.assertEquals("ntnbybkzg", model.kpis().get(0).id());
        Assertions.assertEquals(true, model.kpis().get(0).enabled());
        Assertions.assertEquals(PivotType.TAG_KEY, model.pivots().get(0).type());
        Assertions.assertEquals("jwnzlljfmp", model.pivots().get(0).name());
        Assertions.assertEquals(ReportType.USAGE, model.typePropertiesType());
        Assertions.assertEquals(ReportTimeframeType.MONTH_TO_DATE, model.timeframe());
        Assertions.assertEquals(false, model.includeMonetaryCommitment());
    }
}
