// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.reservations.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.reservations.models.AppliedScopeType;
import com.azure.resourcemanager.reservations.models.BillingPlan;
import com.azure.resourcemanager.reservations.models.CalculateExchangeRequestProperties;
import com.azure.resourcemanager.reservations.models.PurchaseRequest;
import com.azure.resourcemanager.reservations.models.ReservationBillingPlan;
import com.azure.resourcemanager.reservations.models.ReservationTerm;
import com.azure.resourcemanager.reservations.models.ReservationToReturn;
import com.azure.resourcemanager.reservations.models.ReservedResourceType;
import com.azure.resourcemanager.reservations.models.SavingsPlanPurchaseRequest;
import com.azure.resourcemanager.reservations.models.SavingsPlanTerm;
import com.azure.resourcemanager.reservations.models.SkuName;
import java.time.OffsetDateTime;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class CalculateExchangeRequestPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        CalculateExchangeRequestProperties model =
            BinaryData
                .fromString(
                    "{\"reservationsToPurchase\":[{\"sku\":{\"name\":\"jdauwhvy\"},\"location\":\"zbtd\",\"properties\":{\"reservedResourceType\":\"AVS\",\"billingScopeId\":\"nbmpowuwprzq\",\"term\":\"P5Y\",\"billingPlan\":\"Upfront\",\"quantity\":1056372950,\"displayName\":\"j\",\"appliedScopeType\":\"ManagementGroup\",\"appliedScopes\":[],\"renew\":true,\"reviewDateTime\":\"2021-07-16T11:10Z\"}},{\"sku\":{\"name\":\"rtjriplrbpbew\"},\"location\":\"hfgblc\",\"properties\":{\"reservedResourceType\":\"AzureFiles\",\"billingScopeId\":\"lvqhjkbegibtnmx\",\"term\":\"P3Y\",\"billingPlan\":\"Monthly\",\"quantity\":2134442960,\"displayName\":\"ayqcgw\",\"appliedScopeType\":\"ManagementGroup\",\"appliedScopes\":[],\"renew\":false,\"reviewDateTime\":\"2021-09-03T04:43:16Z\"}},{\"sku\":{\"name\":\"txon\"},\"location\":\"ts\",\"properties\":{\"reservedResourceType\":\"AppService\",\"billingScopeId\":\"pwxqp\",\"term\":\"P1Y\",\"billingPlan\":\"Upfront\",\"quantity\":810124654,\"displayName\":\"vriuhprwmdyvx\",\"appliedScopeType\":\"Shared\",\"appliedScopes\":[],\"renew\":false,\"reviewDateTime\":\"2021-09-24T13:27:45Z\"}},{\"sku\":{\"name\":\"bexrmcq\"},\"location\":\"ycnojvknmefqsg\",\"properties\":{\"reservedResourceType\":\"VirtualMachines\",\"billingScopeId\":\"pjyzhpv\",\"term\":\"P3Y\",\"billingPlan\":\"Upfront\",\"quantity\":1630309887,\"displayName\":\"djzlmwlx\",\"appliedScopeType\":\"Shared\",\"appliedScopes\":[],\"renew\":false,\"reviewDateTime\":\"2021-10-22T04:54:45Z\"}}],\"savingsPlansToPurchase\":[{\"sku\":{\"name\":\"u\"},\"properties\":{\"displayName\":\"thnnpr\",\"billingScopeId\":\"i\",\"term\":\"P3Y\",\"billingPlan\":\"P1M\",\"appliedScopeType\":\"ManagementGroup\"}},{\"sku\":{\"name\":\"xdult\"},\"properties\":{\"displayName\":\"bbtdzumvee\",\"billingScopeId\":\"pwo\",\"term\":\"P1Y\",\"billingPlan\":\"P1M\",\"appliedScopeType\":\"Single\"}},{\"sku\":{\"name\":\"f\"},\"properties\":{\"displayName\":\"uusdttouwa\",\"billingScopeId\":\"ekqvkeln\",\"term\":\"P3Y\",\"billingPlan\":\"P1M\",\"appliedScopeType\":\"ManagementGroup\"}}],\"reservationsToExchange\":[{\"reservationId\":\"hcaalnjix\",\"quantity\":1143509001}]}")
                .toObject(CalculateExchangeRequestProperties.class);
        Assertions.assertEquals("jdauwhvy", model.reservationsToPurchase().get(0).sku().name());
        Assertions.assertEquals("zbtd", model.reservationsToPurchase().get(0).location());
        Assertions.assertEquals(ReservedResourceType.AVS, model.reservationsToPurchase().get(0).reservedResourceType());
        Assertions.assertEquals("nbmpowuwprzq", model.reservationsToPurchase().get(0).billingScopeId());
        Assertions.assertEquals(ReservationTerm.P5Y, model.reservationsToPurchase().get(0).term());
        Assertions.assertEquals(ReservationBillingPlan.UPFRONT, model.reservationsToPurchase().get(0).billingPlan());
        Assertions.assertEquals(1056372950, model.reservationsToPurchase().get(0).quantity());
        Assertions.assertEquals("j", model.reservationsToPurchase().get(0).displayName());
        Assertions
            .assertEquals(AppliedScopeType.MANAGEMENT_GROUP, model.reservationsToPurchase().get(0).appliedScopeType());
        Assertions.assertEquals(true, model.reservationsToPurchase().get(0).renew());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-07-16T11:10Z"), model.reservationsToPurchase().get(0).reviewDateTime());
        Assertions.assertEquals("u", model.savingsPlansToPurchase().get(0).sku().name());
        Assertions.assertEquals("thnnpr", model.savingsPlansToPurchase().get(0).displayName());
        Assertions.assertEquals("i", model.savingsPlansToPurchase().get(0).billingScopeId());
        Assertions.assertEquals(SavingsPlanTerm.P3Y, model.savingsPlansToPurchase().get(0).term());
        Assertions.assertEquals(BillingPlan.P1M, model.savingsPlansToPurchase().get(0).billingPlan());
        Assertions
            .assertEquals(AppliedScopeType.MANAGEMENT_GROUP, model.savingsPlansToPurchase().get(0).appliedScopeType());
        Assertions.assertEquals("hcaalnjix", model.reservationsToExchange().get(0).reservationId());
        Assertions.assertEquals(1143509001, model.reservationsToExchange().get(0).quantity());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        CalculateExchangeRequestProperties model =
            new CalculateExchangeRequestProperties()
                .withReservationsToPurchase(
                    Arrays
                        .asList(
                            new PurchaseRequest()
                                .withSku(new SkuName().withName("jdauwhvy"))
                                .withLocation("zbtd")
                                .withReservedResourceType(ReservedResourceType.AVS)
                                .withBillingScopeId("nbmpowuwprzq")
                                .withTerm(ReservationTerm.P5Y)
                                .withBillingPlan(ReservationBillingPlan.UPFRONT)
                                .withQuantity(1056372950)
                                .withDisplayName("j")
                                .withAppliedScopeType(AppliedScopeType.MANAGEMENT_GROUP)
                                .withAppliedScopes(Arrays.asList())
                                .withRenew(true)
                                .withReviewDateTime(OffsetDateTime.parse("2021-07-16T11:10Z")),
                            new PurchaseRequest()
                                .withSku(new SkuName().withName("rtjriplrbpbew"))
                                .withLocation("hfgblc")
                                .withReservedResourceType(ReservedResourceType.AZURE_FILES)
                                .withBillingScopeId("lvqhjkbegibtnmx")
                                .withTerm(ReservationTerm.P3Y)
                                .withBillingPlan(ReservationBillingPlan.MONTHLY)
                                .withQuantity(2134442960)
                                .withDisplayName("ayqcgw")
                                .withAppliedScopeType(AppliedScopeType.MANAGEMENT_GROUP)
                                .withAppliedScopes(Arrays.asList())
                                .withRenew(false)
                                .withReviewDateTime(OffsetDateTime.parse("2021-09-03T04:43:16Z")),
                            new PurchaseRequest()
                                .withSku(new SkuName().withName("txon"))
                                .withLocation("ts")
                                .withReservedResourceType(ReservedResourceType.APP_SERVICE)
                                .withBillingScopeId("pwxqp")
                                .withTerm(ReservationTerm.P1Y)
                                .withBillingPlan(ReservationBillingPlan.UPFRONT)
                                .withQuantity(810124654)
                                .withDisplayName("vriuhprwmdyvx")
                                .withAppliedScopeType(AppliedScopeType.SHARED)
                                .withAppliedScopes(Arrays.asList())
                                .withRenew(false)
                                .withReviewDateTime(OffsetDateTime.parse("2021-09-24T13:27:45Z")),
                            new PurchaseRequest()
                                .withSku(new SkuName().withName("bexrmcq"))
                                .withLocation("ycnojvknmefqsg")
                                .withReservedResourceType(ReservedResourceType.VIRTUAL_MACHINES)
                                .withBillingScopeId("pjyzhpv")
                                .withTerm(ReservationTerm.P3Y)
                                .withBillingPlan(ReservationBillingPlan.UPFRONT)
                                .withQuantity(1630309887)
                                .withDisplayName("djzlmwlx")
                                .withAppliedScopeType(AppliedScopeType.SHARED)
                                .withAppliedScopes(Arrays.asList())
                                .withRenew(false)
                                .withReviewDateTime(OffsetDateTime.parse("2021-10-22T04:54:45Z"))))
                .withSavingsPlansToPurchase(
                    Arrays
                        .asList(
                            new SavingsPlanPurchaseRequest()
                                .withSku(new SkuName().withName("u"))
                                .withDisplayName("thnnpr")
                                .withBillingScopeId("i")
                                .withTerm(SavingsPlanTerm.P3Y)
                                .withBillingPlan(BillingPlan.P1M)
                                .withAppliedScopeType(AppliedScopeType.MANAGEMENT_GROUP),
                            new SavingsPlanPurchaseRequest()
                                .withSku(new SkuName().withName("xdult"))
                                .withDisplayName("bbtdzumvee")
                                .withBillingScopeId("pwo")
                                .withTerm(SavingsPlanTerm.P1Y)
                                .withBillingPlan(BillingPlan.P1M)
                                .withAppliedScopeType(AppliedScopeType.SINGLE),
                            new SavingsPlanPurchaseRequest()
                                .withSku(new SkuName().withName("f"))
                                .withDisplayName("uusdttouwa")
                                .withBillingScopeId("ekqvkeln")
                                .withTerm(SavingsPlanTerm.P3Y)
                                .withBillingPlan(BillingPlan.P1M)
                                .withAppliedScopeType(AppliedScopeType.MANAGEMENT_GROUP)))
                .withReservationsToExchange(
                    Arrays.asList(new ReservationToReturn().withReservationId("hcaalnjix").withQuantity(1143509001)));
        model = BinaryData.fromObject(model).toObject(CalculateExchangeRequestProperties.class);
        Assertions.assertEquals("jdauwhvy", model.reservationsToPurchase().get(0).sku().name());
        Assertions.assertEquals("zbtd", model.reservationsToPurchase().get(0).location());
        Assertions.assertEquals(ReservedResourceType.AVS, model.reservationsToPurchase().get(0).reservedResourceType());
        Assertions.assertEquals("nbmpowuwprzq", model.reservationsToPurchase().get(0).billingScopeId());
        Assertions.assertEquals(ReservationTerm.P5Y, model.reservationsToPurchase().get(0).term());
        Assertions.assertEquals(ReservationBillingPlan.UPFRONT, model.reservationsToPurchase().get(0).billingPlan());
        Assertions.assertEquals(1056372950, model.reservationsToPurchase().get(0).quantity());
        Assertions.assertEquals("j", model.reservationsToPurchase().get(0).displayName());
        Assertions
            .assertEquals(AppliedScopeType.MANAGEMENT_GROUP, model.reservationsToPurchase().get(0).appliedScopeType());
        Assertions.assertEquals(true, model.reservationsToPurchase().get(0).renew());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-07-16T11:10Z"), model.reservationsToPurchase().get(0).reviewDateTime());
        Assertions.assertEquals("u", model.savingsPlansToPurchase().get(0).sku().name());
        Assertions.assertEquals("thnnpr", model.savingsPlansToPurchase().get(0).displayName());
        Assertions.assertEquals("i", model.savingsPlansToPurchase().get(0).billingScopeId());
        Assertions.assertEquals(SavingsPlanTerm.P3Y, model.savingsPlansToPurchase().get(0).term());
        Assertions.assertEquals(BillingPlan.P1M, model.savingsPlansToPurchase().get(0).billingPlan());
        Assertions
            .assertEquals(AppliedScopeType.MANAGEMENT_GROUP, model.savingsPlansToPurchase().get(0).appliedScopeType());
        Assertions.assertEquals("hcaalnjix", model.reservationsToExchange().get(0).reservationId());
        Assertions.assertEquals(1143509001, model.reservationsToExchange().get(0).quantity());
    }
}
