// 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.SavingsPlanOrderAliasModelInner;
import com.azure.resourcemanager.billingbenefits.models.AppliedScopeType;
import com.azure.resourcemanager.billingbenefits.models.BillingPlan;
import com.azure.resourcemanager.billingbenefits.models.SavingsPlanPurchaseValidateRequest;
import com.azure.resourcemanager.billingbenefits.models.Sku;
import com.azure.resourcemanager.billingbenefits.models.Term;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class SavingsPlanPurchaseValidateRequestTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        SavingsPlanPurchaseValidateRequest model =
            BinaryData
                .fromString(
                    "{\"benefits\":[{\"sku\":{\"name\":\"ok\"},\"kind\":\"ljyoxgvcltb\",\"properties\":{\"displayName\":\"c\",\"savingsPlanOrderId\":\"kjeszz\",\"provisioningState\":\"ConfirmedBilling\",\"billingScopeId\":\"htxfvgxbfsmxnehm\",\"term\":\"P1Y\",\"billingPlan\":\"P1M\",\"appliedScopeType\":\"ManagementGroup\"},\"id\":\"fqkkr\",\"name\":\"mpukgriw\",\"type\":\"lzlfbxzpuz\"},{\"sku\":{\"name\":\"ispnqzahmgkbrp\"},\"kind\":\"dhibnuq\",\"properties\":{\"displayName\":\"ik\",\"savingsPlanOrderId\":\"rgvtqag\",\"provisioningState\":\"Created\",\"billingScopeId\":\"nhijggmebfsi\",\"term\":\"P5Y\",\"billingPlan\":\"P1M\",\"appliedScopeType\":\"Single\"},\"id\":\"azzmhjrunmpxt\",\"name\":\"dbhrbnlankxm\",\"type\":\"skpbhenbtkcxywn\"}]}")
                .toObject(SavingsPlanPurchaseValidateRequest.class);
        Assertions.assertEquals("ok", model.benefits().get(0).sku().name());
        Assertions.assertEquals("ljyoxgvcltb", model.benefits().get(0).kind());
        Assertions.assertEquals("c", model.benefits().get(0).displayName());
        Assertions.assertEquals("htxfvgxbfsmxnehm", model.benefits().get(0).billingScopeId());
        Assertions.assertEquals(Term.P1Y, model.benefits().get(0).term());
        Assertions.assertEquals(BillingPlan.P1M, model.benefits().get(0).billingPlan());
        Assertions.assertEquals(AppliedScopeType.MANAGEMENT_GROUP, model.benefits().get(0).appliedScopeType());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        SavingsPlanPurchaseValidateRequest model =
            new SavingsPlanPurchaseValidateRequest()
                .withBenefits(
                    Arrays
                        .asList(
                            new SavingsPlanOrderAliasModelInner()
                                .withSku(new Sku().withName("ok"))
                                .withKind("ljyoxgvcltb")
                                .withDisplayName("c")
                                .withBillingScopeId("htxfvgxbfsmxnehm")
                                .withTerm(Term.P1Y)
                                .withBillingPlan(BillingPlan.P1M)
                                .withAppliedScopeType(AppliedScopeType.MANAGEMENT_GROUP),
                            new SavingsPlanOrderAliasModelInner()
                                .withSku(new Sku().withName("ispnqzahmgkbrp"))
                                .withKind("dhibnuq")
                                .withDisplayName("ik")
                                .withBillingScopeId("nhijggmebfsi")
                                .withTerm(Term.P5Y)
                                .withBillingPlan(BillingPlan.P1M)
                                .withAppliedScopeType(AppliedScopeType.SINGLE)));
        model = BinaryData.fromObject(model).toObject(SavingsPlanPurchaseValidateRequest.class);
        Assertions.assertEquals("ok", model.benefits().get(0).sku().name());
        Assertions.assertEquals("ljyoxgvcltb", model.benefits().get(0).kind());
        Assertions.assertEquals("c", model.benefits().get(0).displayName());
        Assertions.assertEquals("htxfvgxbfsmxnehm", model.benefits().get(0).billingScopeId());
        Assertions.assertEquals(Term.P1Y, model.benefits().get(0).term());
        Assertions.assertEquals(BillingPlan.P1M, model.benefits().get(0).billingPlan());
        Assertions.assertEquals(AppliedScopeType.MANAGEMENT_GROUP, model.benefits().get(0).appliedScopeType());
    }
}
