// 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.CalculateExchangeRequest;
import com.azure.resourcemanager.reservations.models.CalculateExchangeRequestProperties;
import com.azure.resourcemanager.reservations.models.PurchaseRequest;
import com.azure.resourcemanager.reservations.models.ReservationToReturn;
import com.azure.resourcemanager.reservations.models.SavingsPlanPurchaseRequest;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class CalculateExchangeRequestTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        CalculateExchangeRequest model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"reservationsToPurchase\":[{\"location\":\"jgjrwjueiotwm\"},{\"location\":\"dxwitx\"},{\"location\":\"wgqwgxhn\"}],\"savingsPlansToPurchase\":[{}],\"reservationsToExchange\":[{\"reservationId\":\"cg\",\"quantity\":1567456771}]}}")
                .toObject(CalculateExchangeRequest.class);
        Assertions.assertEquals("jgjrwjueiotwm", model.properties().reservationsToPurchase().get(0).location());
        Assertions.assertEquals("cg", model.properties().reservationsToExchange().get(0).reservationId());
        Assertions.assertEquals(1567456771, model.properties().reservationsToExchange().get(0).quantity());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        CalculateExchangeRequest model =
            new CalculateExchangeRequest()
                .withProperties(
                    new CalculateExchangeRequestProperties()
                        .withReservationsToPurchase(
                            Arrays
                                .asList(
                                    new PurchaseRequest().withLocation("jgjrwjueiotwm"),
                                    new PurchaseRequest().withLocation("dxwitx"),
                                    new PurchaseRequest().withLocation("wgqwgxhn")))
                        .withSavingsPlansToPurchase(Arrays.asList(new SavingsPlanPurchaseRequest()))
                        .withReservationsToExchange(
                            Arrays.asList(new ReservationToReturn().withReservationId("cg").withQuantity(1567456771))));
        model = BinaryData.fromObject(model).toObject(CalculateExchangeRequest.class);
        Assertions.assertEquals("jgjrwjueiotwm", model.properties().reservationsToPurchase().get(0).location());
        Assertions.assertEquals("cg", model.properties().reservationsToExchange().get(0).reservationId());
        Assertions.assertEquals(1567456771, model.properties().reservationsToExchange().get(0).quantity());
    }
}
