// 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.ReservationOrderAliasRequestProperties;
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.ReservationOrderAliasRequestPropertiesReservedResourceProperties;
import com.azure.resourcemanager.billingbenefits.models.ReservedResourceType;
import com.azure.resourcemanager.billingbenefits.models.Term;
import java.time.OffsetDateTime;
import org.junit.jupiter.api.Assertions;

public final class ReservationOrderAliasRequestPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ReservationOrderAliasRequestProperties model =
            BinaryData
                .fromString(
                    "{\"displayName\":\"cuh\",\"billingScopeId\":\"tcty\",\"term\":\"P1Y\",\"billingPlan\":\"P1M\",\"appliedScopeType\":\"ManagementGroup\",\"appliedScopeProperties\":{\"tenantId\":\"lwzbhvgyugu\",\"managementGroupId\":\"vmkfssxqu\",\"subscriptionId\":\"fpl\",\"resourceGroupId\":\"gsxnkjzkdeslpv\",\"displayName\":\"pwiyig\"},\"quantity\":2017228559,\"renew\":false,\"reservedResourceType\":\"NetAppStorage\",\"reviewDateTime\":\"2021-11-18T13:59:23Z\",\"reservedResourceProperties\":{\"instanceFlexibility\":\"On\"}}")
                .toObject(ReservationOrderAliasRequestProperties.class);
        Assertions.assertEquals("cuh", model.displayName());
        Assertions.assertEquals("tcty", model.billingScopeId());
        Assertions.assertEquals(Term.P1Y, model.term());
        Assertions.assertEquals(BillingPlan.P1M, model.billingPlan());
        Assertions.assertEquals(AppliedScopeType.MANAGEMENT_GROUP, model.appliedScopeType());
        Assertions.assertEquals("lwzbhvgyugu", model.appliedScopeProperties().tenantId());
        Assertions.assertEquals("vmkfssxqu", model.appliedScopeProperties().managementGroupId());
        Assertions.assertEquals("fpl", model.appliedScopeProperties().subscriptionId());
        Assertions.assertEquals("gsxnkjzkdeslpv", model.appliedScopeProperties().resourceGroupId());
        Assertions.assertEquals("pwiyig", model.appliedScopeProperties().displayName());
        Assertions.assertEquals(2017228559, model.quantity());
        Assertions.assertEquals(false, model.renew());
        Assertions.assertEquals(ReservedResourceType.NET_APP_STORAGE, model.reservedResourceType());
        Assertions.assertEquals(OffsetDateTime.parse("2021-11-18T13:59:23Z"), model.reviewDateTime());
        Assertions.assertEquals(InstanceFlexibility.ON, model.reservedResourceProperties().instanceFlexibility());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ReservationOrderAliasRequestProperties model =
            new ReservationOrderAliasRequestProperties()
                .withDisplayName("cuh")
                .withBillingScopeId("tcty")
                .withTerm(Term.P1Y)
                .withBillingPlan(BillingPlan.P1M)
                .withAppliedScopeType(AppliedScopeType.MANAGEMENT_GROUP)
                .withAppliedScopeProperties(
                    new AppliedScopeProperties()
                        .withTenantId("lwzbhvgyugu")
                        .withManagementGroupId("vmkfssxqu")
                        .withSubscriptionId("fpl")
                        .withResourceGroupId("gsxnkjzkdeslpv")
                        .withDisplayName("pwiyig"))
                .withQuantity(2017228559)
                .withRenew(false)
                .withReservedResourceType(ReservedResourceType.NET_APP_STORAGE)
                .withReviewDateTime(OffsetDateTime.parse("2021-11-18T13:59:23Z"))
                .withReservedResourceProperties(
                    new ReservationOrderAliasRequestPropertiesReservedResourceProperties()
                        .withInstanceFlexibility(InstanceFlexibility.ON));
        model = BinaryData.fromObject(model).toObject(ReservationOrderAliasRequestProperties.class);
        Assertions.assertEquals("cuh", model.displayName());
        Assertions.assertEquals("tcty", model.billingScopeId());
        Assertions.assertEquals(Term.P1Y, model.term());
        Assertions.assertEquals(BillingPlan.P1M, model.billingPlan());
        Assertions.assertEquals(AppliedScopeType.MANAGEMENT_GROUP, model.appliedScopeType());
        Assertions.assertEquals("lwzbhvgyugu", model.appliedScopeProperties().tenantId());
        Assertions.assertEquals("vmkfssxqu", model.appliedScopeProperties().managementGroupId());
        Assertions.assertEquals("fpl", model.appliedScopeProperties().subscriptionId());
        Assertions.assertEquals("gsxnkjzkdeslpv", model.appliedScopeProperties().resourceGroupId());
        Assertions.assertEquals("pwiyig", model.appliedScopeProperties().displayName());
        Assertions.assertEquals(2017228559, model.quantity());
        Assertions.assertEquals(false, model.renew());
        Assertions.assertEquals(ReservedResourceType.NET_APP_STORAGE, model.reservedResourceType());
        Assertions.assertEquals(OffsetDateTime.parse("2021-11-18T13:59:23Z"), model.reviewDateTime());
        Assertions.assertEquals(InstanceFlexibility.ON, model.reservedResourceProperties().instanceFlexibility());
    }
}
