// 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.SavingsPlanOrderModelInner;
import com.azure.resourcemanager.billingbenefits.models.BillingPlan;
import com.azure.resourcemanager.billingbenefits.models.SavingsPlanOrderModelList;
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 SavingsPlanOrderModelListTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        SavingsPlanOrderModelList model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"sku\":{\"name\":\"kbasyypn\"},\"properties\":{\"displayName\":\"sgcbac\",\"provisioningState\":\"PendingBilling\",\"billingScopeId\":\"koty\",\"billingProfileId\":\"gou\",\"customerId\":\"ndlik\",\"billingAccountId\":\"qkgfgibma\",\"term\":\"P3Y\",\"billingPlan\":\"P1M\",\"expiryDateTime\":\"2021-01-01T02:28:26Z\",\"benefitStartTime\":\"2021-06-20T22:32:23Z\",\"savingsPlans\":[]},\"id\":\"qedqytbciqfoufl\",\"name\":\"mnkzsmod\",\"type\":\"glougpbk\"},{\"sku\":{\"name\":\"mutduqktaps\"},\"properties\":{\"displayName\":\"cuertu\",\"provisioningState\":\"Failed\",\"billingScopeId\":\"svqwhbmdgbbjfd\",\"billingProfileId\":\"mbmbexppbh\",\"customerId\":\"qrolfpf\",\"billingAccountId\":\"algbquxigjyjg\",\"term\":\"P5Y\",\"billingPlan\":\"P1M\",\"expiryDateTime\":\"2021-02-03T09:13:07Z\",\"benefitStartTime\":\"2021-01-31T08:01:03Z\",\"savingsPlans\":[]},\"id\":\"erkujys\",\"name\":\"l\",\"type\":\"juvf\"},{\"sku\":{\"name\":\"wrlyxwjkcprb\"},\"properties\":{\"displayName\":\"xgjvtbv\",\"provisioningState\":\"Created\",\"billingScopeId\":\"zdn\",\"billingProfileId\":\"jq\",\"customerId\":\"hmuouqfprwzwbn\",\"billingAccountId\":\"itnwuizgazxufi\",\"term\":\"P1Y\",\"billingPlan\":\"P1M\",\"expiryDateTime\":\"2021-11-21T17:04:29Z\",\"benefitStartTime\":\"2021-05-30T20:21:31Z\",\"savingsPlans\":[]},\"id\":\"vzwdzuhtymwis\",\"name\":\"kfthwxmntei\",\"type\":\"aop\"}],\"nextLink\":\"mijcmmxdcufufs\"}")
                .toObject(SavingsPlanOrderModelList.class);
        Assertions.assertEquals("kbasyypn", model.value().get(0).sku().name());
        Assertions.assertEquals("sgcbac", model.value().get(0).displayName());
        Assertions.assertEquals("koty", 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(OffsetDateTime.parse("2021-06-20T22:32:23Z"), model.value().get(0).benefitStartTime());
        Assertions.assertEquals("mijcmmxdcufufs", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        SavingsPlanOrderModelList model =
            new SavingsPlanOrderModelList()
                .withValue(
                    Arrays
                        .asList(
                            new SavingsPlanOrderModelInner()
                                .withSku(new Sku().withName("kbasyypn"))
                                .withDisplayName("sgcbac")
                                .withBillingScopeId("koty")
                                .withTerm(Term.P3Y)
                                .withBillingPlan(BillingPlan.P1M)
                                .withBenefitStartTime(OffsetDateTime.parse("2021-06-20T22:32:23Z"))
                                .withSavingsPlans(Arrays.asList()),
                            new SavingsPlanOrderModelInner()
                                .withSku(new Sku().withName("mutduqktaps"))
                                .withDisplayName("cuertu")
                                .withBillingScopeId("svqwhbmdgbbjfd")
                                .withTerm(Term.P5Y)
                                .withBillingPlan(BillingPlan.P1M)
                                .withBenefitStartTime(OffsetDateTime.parse("2021-01-31T08:01:03Z"))
                                .withSavingsPlans(Arrays.asList()),
                            new SavingsPlanOrderModelInner()
                                .withSku(new Sku().withName("wrlyxwjkcprb"))
                                .withDisplayName("xgjvtbv")
                                .withBillingScopeId("zdn")
                                .withTerm(Term.P1Y)
                                .withBillingPlan(BillingPlan.P1M)
                                .withBenefitStartTime(OffsetDateTime.parse("2021-05-30T20:21:31Z"))
                                .withSavingsPlans(Arrays.asList())))
                .withNextLink("mijcmmxdcufufs");
        model = BinaryData.fromObject(model).toObject(SavingsPlanOrderModelList.class);
        Assertions.assertEquals("kbasyypn", model.value().get(0).sku().name());
        Assertions.assertEquals("sgcbac", model.value().get(0).displayName());
        Assertions.assertEquals("koty", 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(OffsetDateTime.parse("2021-06-20T22:32:23Z"), model.value().get(0).benefitStartTime());
        Assertions.assertEquals("mijcmmxdcufufs", model.nextLink());
    }
}
