// 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.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.ReservationOrderAliasRequest;
import com.azure.resourcemanager.billingbenefits.models.ReservationOrderAliasRequestPropertiesReservedResourceProperties;
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 ReservationOrderAliasRequestTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ReservationOrderAliasRequest model =
            BinaryData
                .fromString(
                    "{\"sku\":{\"name\":\"nrs\"},\"location\":\"lqidyby\",\"properties\":{\"displayName\":\"fclhaaxdbabphlwr\",\"billingScopeId\":\"fkts\",\"term\":\"P1Y\",\"billingPlan\":\"P1M\",\"appliedScopeType\":\"Single\",\"appliedScopeProperties\":{\"tenantId\":\"yyazttbt\",\"managementGroupId\":\"rq\",\"subscriptionId\":\"edckzywbiexzfey\",\"resourceGroupId\":\"axibxujw\",\"displayName\":\"qwalmuzyoxaepd\"},\"quantity\":1101011494,\"renew\":true,\"reservedResourceType\":\"SuseLinux\",\"reviewDateTime\":\"2021-07-09T15:19:21Z\",\"reservedResourceProperties\":{\"instanceFlexibility\":\"Off\"}},\"id\":\"avxbniwdjswztsdb\",\"name\":\"gnxytxhpzxbz\",\"type\":\"fzab\"}")
                .toObject(ReservationOrderAliasRequest.class);
        Assertions.assertEquals("nrs", model.sku().name());
        Assertions.assertEquals("lqidyby", model.location());
        Assertions.assertEquals("fclhaaxdbabphlwr", model.displayName());
        Assertions.assertEquals("fkts", model.billingScopeId());
        Assertions.assertEquals(Term.P1Y, model.term());
        Assertions.assertEquals(BillingPlan.P1M, model.billingPlan());
        Assertions.assertEquals(AppliedScopeType.SINGLE, model.appliedScopeType());
        Assertions.assertEquals("yyazttbt", model.appliedScopeProperties().tenantId());
        Assertions.assertEquals("rq", model.appliedScopeProperties().managementGroupId());
        Assertions.assertEquals("edckzywbiexzfey", model.appliedScopeProperties().subscriptionId());
        Assertions.assertEquals("axibxujw", model.appliedScopeProperties().resourceGroupId());
        Assertions.assertEquals("qwalmuzyoxaepd", model.appliedScopeProperties().displayName());
        Assertions.assertEquals(1101011494, model.quantity());
        Assertions.assertEquals(true, model.renew());
        Assertions.assertEquals(ReservedResourceType.SUSE_LINUX, model.reservedResourceType());
        Assertions.assertEquals(OffsetDateTime.parse("2021-07-09T15:19:21Z"), model.reviewDateTime());
        Assertions.assertEquals(InstanceFlexibility.OFF, model.reservedResourceProperties().instanceFlexibility());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ReservationOrderAliasRequest model =
            new ReservationOrderAliasRequest()
                .withSku(new Sku().withName("nrs"))
                .withLocation("lqidyby")
                .withDisplayName("fclhaaxdbabphlwr")
                .withBillingScopeId("fkts")
                .withTerm(Term.P1Y)
                .withBillingPlan(BillingPlan.P1M)
                .withAppliedScopeType(AppliedScopeType.SINGLE)
                .withAppliedScopeProperties(
                    new AppliedScopeProperties()
                        .withTenantId("yyazttbt")
                        .withManagementGroupId("rq")
                        .withSubscriptionId("edckzywbiexzfey")
                        .withResourceGroupId("axibxujw")
                        .withDisplayName("qwalmuzyoxaepd"))
                .withQuantity(1101011494)
                .withRenew(true)
                .withReservedResourceType(ReservedResourceType.SUSE_LINUX)
                .withReviewDateTime(OffsetDateTime.parse("2021-07-09T15:19:21Z"))
                .withReservedResourceProperties(
                    new ReservationOrderAliasRequestPropertiesReservedResourceProperties()
                        .withInstanceFlexibility(InstanceFlexibility.OFF));
        model = BinaryData.fromObject(model).toObject(ReservationOrderAliasRequest.class);
        Assertions.assertEquals("nrs", model.sku().name());
        Assertions.assertEquals("lqidyby", model.location());
        Assertions.assertEquals("fclhaaxdbabphlwr", model.displayName());
        Assertions.assertEquals("fkts", model.billingScopeId());
        Assertions.assertEquals(Term.P1Y, model.term());
        Assertions.assertEquals(BillingPlan.P1M, model.billingPlan());
        Assertions.assertEquals(AppliedScopeType.SINGLE, model.appliedScopeType());
        Assertions.assertEquals("yyazttbt", model.appliedScopeProperties().tenantId());
        Assertions.assertEquals("rq", model.appliedScopeProperties().managementGroupId());
        Assertions.assertEquals("edckzywbiexzfey", model.appliedScopeProperties().subscriptionId());
        Assertions.assertEquals("axibxujw", model.appliedScopeProperties().resourceGroupId());
        Assertions.assertEquals("qwalmuzyoxaepd", model.appliedScopeProperties().displayName());
        Assertions.assertEquals(1101011494, model.quantity());
        Assertions.assertEquals(true, model.renew());
        Assertions.assertEquals(ReservedResourceType.SUSE_LINUX, model.reservedResourceType());
        Assertions.assertEquals(OffsetDateTime.parse("2021-07-09T15:19:21Z"), model.reviewDateTime());
        Assertions.assertEquals(InstanceFlexibility.OFF, model.reservedResourceProperties().instanceFlexibility());
    }
}
