// 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.ExportExecutionListResultInner;
import com.azure.resourcemanager.costmanagement.fluent.models.ExportInner;
import com.azure.resourcemanager.costmanagement.models.ExportDefinition;
import com.azure.resourcemanager.costmanagement.models.ExportDeliveryInfo;
import com.azure.resourcemanager.costmanagement.models.ExportSchedule;
import com.azure.resourcemanager.costmanagement.models.ExportType;
import com.azure.resourcemanager.costmanagement.models.FormatType;
import com.azure.resourcemanager.costmanagement.models.RecurrenceType;
import com.azure.resourcemanager.costmanagement.models.StatusType;
import com.azure.resourcemanager.costmanagement.models.TimeframeType;
import org.junit.jupiter.api.Assertions;

public final class ExportInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ExportInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"schedule\":{\"status\":\"Inactive\",\"recurrence\":\"Annually\"},\"format\":\"Csv\",\"deliveryInfo\":{},\"definition\":{\"type\":\"AmortizedCost\",\"timeframe\":\"TheLastBillingMonth\"},\"runHistory\":{\"value\":[]},\"partitionData\":false,\"nextRunTimeEstimate\":\"2021-10-03T18:37:42Z\"},\"eTag\":\"brqubp\",\"id\":\"xhexiilivpdti\",\"name\":\"r\",\"type\":\"tdqoaxoruzfgsq\"}")
                .toObject(ExportInner.class);
        Assertions.assertEquals("brqubp", model.etag());
        Assertions.assertEquals(StatusType.INACTIVE, model.schedule().status());
        Assertions.assertEquals(RecurrenceType.ANNUALLY, model.schedule().recurrence());
        Assertions.assertEquals(FormatType.CSV, model.format());
        Assertions.assertEquals(ExportType.AMORTIZED_COST, model.definition().type());
        Assertions.assertEquals(TimeframeType.THE_LAST_BILLING_MONTH, model.definition().timeframe());
        Assertions.assertEquals(false, model.partitionData());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ExportInner model =
            new ExportInner()
                .withEtag("brqubp")
                .withSchedule(
                    new ExportSchedule().withStatus(StatusType.INACTIVE).withRecurrence(RecurrenceType.ANNUALLY))
                .withFormat(FormatType.CSV)
                .withDeliveryInfo(new ExportDeliveryInfo())
                .withDefinition(
                    new ExportDefinition()
                        .withType(ExportType.AMORTIZED_COST)
                        .withTimeframe(TimeframeType.THE_LAST_BILLING_MONTH))
                .withRunHistory(new ExportExecutionListResultInner())
                .withPartitionData(false);
        model = BinaryData.fromObject(model).toObject(ExportInner.class);
        Assertions.assertEquals("brqubp", model.etag());
        Assertions.assertEquals(StatusType.INACTIVE, model.schedule().status());
        Assertions.assertEquals(RecurrenceType.ANNUALLY, model.schedule().recurrence());
        Assertions.assertEquals(FormatType.CSV, model.format());
        Assertions.assertEquals(ExportType.AMORTIZED_COST, model.definition().type());
        Assertions.assertEquals(TimeframeType.THE_LAST_BILLING_MONTH, model.definition().timeframe());
        Assertions.assertEquals(false, model.partitionData());
    }
}
