// 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.AppliedScopeType;
import com.azure.resourcemanager.billingbenefits.models.BillingPlan;
import com.azure.resourcemanager.billingbenefits.models.PurchaseRequest;
import com.azure.resourcemanager.billingbenefits.models.RenewProperties;
import com.azure.resourcemanager.billingbenefits.models.Sku;
import com.azure.resourcemanager.billingbenefits.models.Term;
import org.junit.jupiter.api.Assertions;

public final class RenewPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        RenewProperties model =
            BinaryData
                .fromString(
                    "{\"purchaseProperties\":{\"sku\":{\"name\":\"lfh\"},\"properties\":{\"displayName\":\"mcy\",\"billingScopeId\":\"wlbjnpgacftade\",\"term\":\"P1Y\",\"billingPlan\":\"P1M\",\"appliedScopeType\":\"ManagementGroup\",\"effectiveDateTime\":\"2021-10-01T21:26:02Z\",\"renew\":false}}}")
                .toObject(RenewProperties.class);
        Assertions.assertEquals("lfh", model.purchaseProperties().sku().name());
        Assertions.assertEquals("mcy", model.purchaseProperties().displayName());
        Assertions.assertEquals("wlbjnpgacftade", model.purchaseProperties().billingScopeId());
        Assertions.assertEquals(Term.P1Y, model.purchaseProperties().term());
        Assertions.assertEquals(BillingPlan.P1M, model.purchaseProperties().billingPlan());
        Assertions.assertEquals(AppliedScopeType.MANAGEMENT_GROUP, model.purchaseProperties().appliedScopeType());
        Assertions.assertEquals(false, model.purchaseProperties().renew());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        RenewProperties model =
            new RenewProperties()
                .withPurchaseProperties(
                    new PurchaseRequest()
                        .withSku(new Sku().withName("lfh"))
                        .withDisplayName("mcy")
                        .withBillingScopeId("wlbjnpgacftade")
                        .withTerm(Term.P1Y)
                        .withBillingPlan(BillingPlan.P1M)
                        .withAppliedScopeType(AppliedScopeType.MANAGEMENT_GROUP)
                        .withRenew(false));
        model = BinaryData.fromObject(model).toObject(RenewProperties.class);
        Assertions.assertEquals("lfh", model.purchaseProperties().sku().name());
        Assertions.assertEquals("mcy", model.purchaseProperties().displayName());
        Assertions.assertEquals("wlbjnpgacftade", model.purchaseProperties().billingScopeId());
        Assertions.assertEquals(Term.P1Y, model.purchaseProperties().term());
        Assertions.assertEquals(BillingPlan.P1M, model.purchaseProperties().billingPlan());
        Assertions.assertEquals(AppliedScopeType.MANAGEMENT_GROUP, model.purchaseProperties().appliedScopeType());
        Assertions.assertEquals(false, model.purchaseProperties().renew());
    }
}
