// 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.PatchPropertiesRenewProperties;
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.ReservedResourceType;
import com.azure.resourcemanager.reservations.models.SkuName;
import java.time.OffsetDateTime;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class PatchPropertiesRenewPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        PatchPropertiesRenewProperties model =
            BinaryData
                .fromString(
                    "{\"purchaseProperties\":{\"sku\":{\"name\":\"pdkzjancuxr\"},\"location\":\"wbavxbniwdj\",\"properties\":{\"reservedResourceType\":\"VirtualMachineSoftware\",\"billingScopeId\":\"dbpgnxytxhp\",\"term\":\"P5Y\",\"billingPlan\":\"Upfront\",\"quantity\":686718071,\"displayName\":\"b\",\"appliedScopeType\":\"Shared\",\"appliedScopes\":[\"xwtctyqiklbbovpl\"],\"renew\":true,\"reviewDateTime\":\"2021-01-10T00:04:32Z\"}}}")
                .toObject(PatchPropertiesRenewProperties.class);
        Assertions.assertEquals("pdkzjancuxr", model.purchaseProperties().sku().name());
        Assertions.assertEquals("wbavxbniwdj", model.purchaseProperties().location());
        Assertions
            .assertEquals(
                ReservedResourceType.VIRTUAL_MACHINE_SOFTWARE, model.purchaseProperties().reservedResourceType());
        Assertions.assertEquals("dbpgnxytxhp", model.purchaseProperties().billingScopeId());
        Assertions.assertEquals(ReservationTerm.P5Y, model.purchaseProperties().term());
        Assertions.assertEquals(ReservationBillingPlan.UPFRONT, model.purchaseProperties().billingPlan());
        Assertions.assertEquals(686718071, model.purchaseProperties().quantity());
        Assertions.assertEquals("b", model.purchaseProperties().displayName());
        Assertions.assertEquals(AppliedScopeType.SHARED, model.purchaseProperties().appliedScopeType());
        Assertions.assertEquals("xwtctyqiklbbovpl", model.purchaseProperties().appliedScopes().get(0));
        Assertions.assertEquals(true, model.purchaseProperties().renew());
        Assertions
            .assertEquals(OffsetDateTime.parse("2021-01-10T00:04:32Z"), model.purchaseProperties().reviewDateTime());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        PatchPropertiesRenewProperties model =
            new PatchPropertiesRenewProperties()
                .withPurchaseProperties(
                    new PurchaseRequest()
                        .withSku(new SkuName().withName("pdkzjancuxr"))
                        .withLocation("wbavxbniwdj")
                        .withReservedResourceType(ReservedResourceType.VIRTUAL_MACHINE_SOFTWARE)
                        .withBillingScopeId("dbpgnxytxhp")
                        .withTerm(ReservationTerm.P5Y)
                        .withBillingPlan(ReservationBillingPlan.UPFRONT)
                        .withQuantity(686718071)
                        .withDisplayName("b")
                        .withAppliedScopeType(AppliedScopeType.SHARED)
                        .withAppliedScopes(Arrays.asList("xwtctyqiklbbovpl"))
                        .withRenew(true)
                        .withReviewDateTime(OffsetDateTime.parse("2021-01-10T00:04:32Z")));
        model = BinaryData.fromObject(model).toObject(PatchPropertiesRenewProperties.class);
        Assertions.assertEquals("pdkzjancuxr", model.purchaseProperties().sku().name());
        Assertions.assertEquals("wbavxbniwdj", model.purchaseProperties().location());
        Assertions
            .assertEquals(
                ReservedResourceType.VIRTUAL_MACHINE_SOFTWARE, model.purchaseProperties().reservedResourceType());
        Assertions.assertEquals("dbpgnxytxhp", model.purchaseProperties().billingScopeId());
        Assertions.assertEquals(ReservationTerm.P5Y, model.purchaseProperties().term());
        Assertions.assertEquals(ReservationBillingPlan.UPFRONT, model.purchaseProperties().billingPlan());
        Assertions.assertEquals(686718071, model.purchaseProperties().quantity());
        Assertions.assertEquals("b", model.purchaseProperties().displayName());
        Assertions.assertEquals(AppliedScopeType.SHARED, model.purchaseProperties().appliedScopeType());
        Assertions.assertEquals("xwtctyqiklbbovpl", model.purchaseProperties().appliedScopes().get(0));
        Assertions.assertEquals(true, model.purchaseProperties().renew());
        Assertions
            .assertEquals(OffsetDateTime.parse("2021-01-10T00:04:32Z"), model.purchaseProperties().reviewDateTime());
    }
}
