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

package com.azure.resourcemanager.billingbenefits.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.billingbenefits.fluent.models.ReservationOrderAliasResponseInner;
import com.azure.resourcemanager.billingbenefits.models.AppliedScopeProperties;
import com.azure.resourcemanager.billingbenefits.models.AppliedScopeType;
import com.azure.resourcemanager.billingbenefits.models.BillingPlan;
import com.azure.resourcemanager.billingbenefits.models.InstanceFlexibility;
import com.azure.resourcemanager.billingbenefits.models.ReservationOrderAliasResponsePropertiesReservedResourceProperties;
import com.azure.resourcemanager.billingbenefits.models.ReservedResourceType;
import com.azure.resourcemanager.billingbenefits.models.Sku;
import com.azure.resourcemanager.billingbenefits.models.Term;
import java.time.OffsetDateTime;
import org.junit.jupiter.api.Assertions;

public final class ReservationOrderAliasResponseInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ReservationOrderAliasResponseInner model =
            BinaryData
                .fromString(
                    "{\"sku\":{\"name\":\"umnyqu\"},\"location\":\"deoj\",\"properties\":{\"displayName\":\"ckhsmtxpsieb\",\"reservationOrderId\":\"hvpesapskrdqm\",\"provisioningState\":\"Cancelled\",\"billingScopeId\":\"htldwk\",\"term\":\"P1Y\",\"billingPlan\":\"P1M\",\"appliedScopeType\":\"Single\",\"appliedScopeProperties\":{\"tenantId\":\"ws\",\"managementGroupId\":\"svlxotogtwrup\",\"subscriptionId\":\"xvnmicykvceov\",\"resourceGroupId\":\"lo\",\"displayName\":\"oty\"},\"quantity\":914615331,\"renew\":true,\"reservedResourceType\":\"AppService\",\"reviewDateTime\":\"2021-08-21T09:13:10Z\",\"reservedResourceProperties\":{\"instanceFlexibility\":\"On\"}},\"id\":\"bttk\",\"name\":\"h\",\"type\":\"wpn\"}")
                .toObject(ReservationOrderAliasResponseInner.class);
        Assertions.assertEquals("umnyqu", model.sku().name());
        Assertions.assertEquals("deoj", model.location());
        Assertions.assertEquals("ckhsmtxpsieb", model.displayName());
        Assertions.assertEquals("htldwk", model.billingScopeId());
        Assertions.assertEquals(Term.P1Y, model.term());
        Assertions.assertEquals(BillingPlan.P1M, model.billingPlan());
        Assertions.assertEquals(AppliedScopeType.SINGLE, model.appliedScopeType());
        Assertions.assertEquals("ws", model.appliedScopeProperties().tenantId());
        Assertions.assertEquals("svlxotogtwrup", model.appliedScopeProperties().managementGroupId());
        Assertions.assertEquals("xvnmicykvceov", model.appliedScopeProperties().subscriptionId());
        Assertions.assertEquals("lo", model.appliedScopeProperties().resourceGroupId());
        Assertions.assertEquals("oty", model.appliedScopeProperties().displayName());
        Assertions.assertEquals(914615331, model.quantity());
        Assertions.assertEquals(true, model.renew());
        Assertions.assertEquals(ReservedResourceType.APP_SERVICE, model.reservedResourceType());
        Assertions.assertEquals(OffsetDateTime.parse("2021-08-21T09:13:10Z"), model.reviewDateTime());
        Assertions.assertEquals(InstanceFlexibility.ON, model.reservedResourceProperties().instanceFlexibility());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ReservationOrderAliasResponseInner model =
            new ReservationOrderAliasResponseInner()
                .withSku(new Sku().withName("umnyqu"))
                .withLocation("deoj")
                .withDisplayName("ckhsmtxpsieb")
                .withBillingScopeId("htldwk")
                .withTerm(Term.P1Y)
                .withBillingPlan(BillingPlan.P1M)
                .withAppliedScopeType(AppliedScopeType.SINGLE)
                .withAppliedScopeProperties(
                    new AppliedScopeProperties()
                        .withTenantId("ws")
                        .withManagementGroupId("svlxotogtwrup")
                        .withSubscriptionId("xvnmicykvceov")
                        .withResourceGroupId("lo")
                        .withDisplayName("oty"))
                .withQuantity(914615331)
                .withRenew(true)
                .withReservedResourceType(ReservedResourceType.APP_SERVICE)
                .withReviewDateTime(OffsetDateTime.parse("2021-08-21T09:13:10Z"))
                .withReservedResourceProperties(
                    new ReservationOrderAliasResponsePropertiesReservedResourceProperties()
                        .withInstanceFlexibility(InstanceFlexibility.ON));
        model = BinaryData.fromObject(model).toObject(ReservationOrderAliasResponseInner.class);
        Assertions.assertEquals("umnyqu", model.sku().name());
        Assertions.assertEquals("deoj", model.location());
        Assertions.assertEquals("ckhsmtxpsieb", model.displayName());
        Assertions.assertEquals("htldwk", model.billingScopeId());
        Assertions.assertEquals(Term.P1Y, model.term());
        Assertions.assertEquals(BillingPlan.P1M, model.billingPlan());
        Assertions.assertEquals(AppliedScopeType.SINGLE, model.appliedScopeType());
        Assertions.assertEquals("ws", model.appliedScopeProperties().tenantId());
        Assertions.assertEquals("svlxotogtwrup", model.appliedScopeProperties().managementGroupId());
        Assertions.assertEquals("xvnmicykvceov", model.appliedScopeProperties().subscriptionId());
        Assertions.assertEquals("lo", model.appliedScopeProperties().resourceGroupId());
        Assertions.assertEquals("oty", model.appliedScopeProperties().displayName());
        Assertions.assertEquals(914615331, model.quantity());
        Assertions.assertEquals(true, model.renew());
        Assertions.assertEquals(ReservedResourceType.APP_SERVICE, model.reservedResourceType());
        Assertions.assertEquals(OffsetDateTime.parse("2021-08-21T09:13:10Z"), model.reviewDateTime());
        Assertions.assertEquals(InstanceFlexibility.ON, model.reservedResourceProperties().instanceFlexibility());
    }
}
