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

public final class SavingsPlanModelListTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        SavingsPlanModelList model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"sku\":{\"name\":\"zidnsezcxtbzsgfy\"},\"properties\":{\"displayName\":\"newmdwzjeiachbo\",\"provisioningState\":\"Failed\",\"displayProvisioningState\":\"nrosfqpte\",\"billingScopeId\":\"zzvypyqrimzinp\",\"billingProfileId\":\"wjdk\",\"customerId\":\"soodqxhcrmnoh\",\"billingAccountId\":\"ckwhds\",\"term\":\"P3Y\",\"billingPlan\":\"P1M\",\"appliedScopeType\":\"Single\",\"userFriendlyAppliedScopeType\":\"xsqwpgrjbznorc\",\"effectiveDateTime\":\"2021-01-21T21:41:42Z\",\"expiryDateTime\":\"2021-11-07T06:50:55Z\",\"purchaseDateTime\":\"2021-08-08T19:07:21Z\",\"benefitStartTime\":\"2021-05-01T16:18:20Z\",\"renew\":false,\"renewSource\":\"cyshurzafbljjgp\",\"renewDestination\":\"oq\"},\"id\":\"klj\",\"name\":\"vbqid\",\"type\":\"qajzyulpkudjkr\"},{\"sku\":{\"name\":\"hbzhfepg\"},\"properties\":{\"displayName\":\"e\",\"provisioningState\":\"PendingBilling\",\"displayProvisioningState\":\"c\",\"billingScopeId\":\"c\",\"billingProfileId\":\"ierhhbcsglummaj\",\"customerId\":\"aodxo\",\"billingAccountId\":\"bdxkqpxokaj\",\"term\":\"P1Y\",\"billingPlan\":\"P1M\",\"appliedScopeType\":\"ManagementGroup\",\"userFriendlyAppliedScopeType\":\"gstxgcp\",\"effectiveDateTime\":\"2020-12-20T13:07:36Z\",\"expiryDateTime\":\"2021-08-14T01:03:38Z\",\"purchaseDateTime\":\"2021-03-19T19:19:25Z\",\"benefitStartTime\":\"2021-07-18T09:47:03Z\",\"renew\":true,\"renewSource\":\"ovmclwhijcoejct\",\"renewDestination\":\"aqsqsycbkbfk\"},\"id\":\"dkexxppofm\",\"name\":\"axcfjpgddtocjjx\",\"type\":\"vpmouexhdzxib\"}],\"nextLink\":\"ojnxqbzvdd\"}")
                .toObject(SavingsPlanModelList.class);
        Assertions.assertEquals("zidnsezcxtbzsgfy", model.value().get(0).sku().name());
        Assertions.assertEquals("newmdwzjeiachbo", model.value().get(0).displayName());
        Assertions.assertEquals("zzvypyqrimzinp", model.value().get(0).billingScopeId());
        Assertions.assertEquals(Term.P3Y, model.value().get(0).term());
        Assertions.assertEquals(BillingPlan.P1M, model.value().get(0).billingPlan());
        Assertions.assertEquals(AppliedScopeType.SINGLE, model.value().get(0).appliedScopeType());
        Assertions.assertEquals(OffsetDateTime.parse("2021-05-01T16:18:20Z"), model.value().get(0).benefitStartTime());
        Assertions.assertEquals(false, model.value().get(0).renew());
        Assertions.assertEquals("cyshurzafbljjgp", model.value().get(0).renewSource());
        Assertions.assertEquals("oq", model.value().get(0).renewDestination());
        Assertions.assertEquals("ojnxqbzvdd", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        SavingsPlanModelList model =
            new SavingsPlanModelList()
                .withValue(
                    Arrays
                        .asList(
                            new SavingsPlanModelInner()
                                .withSku(new Sku().withName("zidnsezcxtbzsgfy"))
                                .withDisplayName("newmdwzjeiachbo")
                                .withBillingScopeId("zzvypyqrimzinp")
                                .withTerm(Term.P3Y)
                                .withBillingPlan(BillingPlan.P1M)
                                .withAppliedScopeType(AppliedScopeType.SINGLE)
                                .withBenefitStartTime(OffsetDateTime.parse("2021-05-01T16:18:20Z"))
                                .withRenew(false)
                                .withRenewSource("cyshurzafbljjgp")
                                .withRenewDestination("oq"),
                            new SavingsPlanModelInner()
                                .withSku(new Sku().withName("hbzhfepg"))
                                .withDisplayName("e")
                                .withBillingScopeId("c")
                                .withTerm(Term.P1Y)
                                .withBillingPlan(BillingPlan.P1M)
                                .withAppliedScopeType(AppliedScopeType.MANAGEMENT_GROUP)
                                .withBenefitStartTime(OffsetDateTime.parse("2021-07-18T09:47:03Z"))
                                .withRenew(true)
                                .withRenewSource("ovmclwhijcoejct")
                                .withRenewDestination("aqsqsycbkbfk")))
                .withNextLink("ojnxqbzvdd");
        model = BinaryData.fromObject(model).toObject(SavingsPlanModelList.class);
        Assertions.assertEquals("zidnsezcxtbzsgfy", model.value().get(0).sku().name());
        Assertions.assertEquals("newmdwzjeiachbo", model.value().get(0).displayName());
        Assertions.assertEquals("zzvypyqrimzinp", model.value().get(0).billingScopeId());
        Assertions.assertEquals(Term.P3Y, model.value().get(0).term());
        Assertions.assertEquals(BillingPlan.P1M, model.value().get(0).billingPlan());
        Assertions.assertEquals(AppliedScopeType.SINGLE, model.value().get(0).appliedScopeType());
        Assertions.assertEquals(OffsetDateTime.parse("2021-05-01T16:18:20Z"), model.value().get(0).benefitStartTime());
        Assertions.assertEquals(false, model.value().get(0).renew());
        Assertions.assertEquals("cyshurzafbljjgp", model.value().get(0).renewSource());
        Assertions.assertEquals("oq", model.value().get(0).renewDestination());
        Assertions.assertEquals("ojnxqbzvdd", model.nextLink());
    }
}
