// 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.fluent.models.ChangeDirectoryResponseInner;
import com.azure.resourcemanager.reservations.models.ChangeDirectoryResult;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class ChangeDirectoryResponseInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ChangeDirectoryResponseInner model =
            BinaryData
                .fromString(
                    "{\"reservationOrder\":{\"id\":\"k\",\"name\":\"oxafn\",\"isSucceeded\":false,\"error\":\"ichkoymkcdyhb\"},\"reservations\":[{\"id\":\"wdreqnovvqfovl\",\"name\":\"ywsuwsy\",\"isSucceeded\":true,\"error\":\"sytgadgvraea\"}]}")
                .toObject(ChangeDirectoryResponseInner.class);
        Assertions.assertEquals("k", model.reservationOrder().id());
        Assertions.assertEquals("oxafn", model.reservationOrder().name());
        Assertions.assertEquals(false, model.reservationOrder().isSucceeded());
        Assertions.assertEquals("ichkoymkcdyhb", model.reservationOrder().error());
        Assertions.assertEquals("wdreqnovvqfovl", model.reservations().get(0).id());
        Assertions.assertEquals("ywsuwsy", model.reservations().get(0).name());
        Assertions.assertEquals(true, model.reservations().get(0).isSucceeded());
        Assertions.assertEquals("sytgadgvraea", model.reservations().get(0).error());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ChangeDirectoryResponseInner model =
            new ChangeDirectoryResponseInner()
                .withReservationOrder(
                    new ChangeDirectoryResult()
                        .withId("k")
                        .withName("oxafn")
                        .withIsSucceeded(false)
                        .withError("ichkoymkcdyhb"))
                .withReservations(
                    Arrays
                        .asList(
                            new ChangeDirectoryResult()
                                .withId("wdreqnovvqfovl")
                                .withName("ywsuwsy")
                                .withIsSucceeded(true)
                                .withError("sytgadgvraea")));
        model = BinaryData.fromObject(model).toObject(ChangeDirectoryResponseInner.class);
        Assertions.assertEquals("k", model.reservationOrder().id());
        Assertions.assertEquals("oxafn", model.reservationOrder().name());
        Assertions.assertEquals(false, model.reservationOrder().isSucceeded());
        Assertions.assertEquals("ichkoymkcdyhb", model.reservationOrder().error());
        Assertions.assertEquals("wdreqnovvqfovl", model.reservations().get(0).id());
        Assertions.assertEquals("ywsuwsy", model.reservations().get(0).name());
        Assertions.assertEquals(true, model.reservations().get(0).isSucceeded());
        Assertions.assertEquals("sytgadgvraea", model.reservations().get(0).error());
    }
}
