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

package com.azure.resourcemanager.appcontainers.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.appcontainers.fluent.models.ReplicaProperties;
import com.azure.resourcemanager.appcontainers.models.ReplicaContainer;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class ReplicaPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ReplicaProperties model =
            BinaryData
                .fromString(
                    "{\"createdTime\":\"2020-12-22T06:34:17Z\",\"containers\":[{\"name\":\"vyl\",\"containerId\":\"yavluwmncstt\",\"ready\":false,\"started\":true,\"restartCount\":387251402,\"logStreamEndpoint\":\"ekrsgs\",\"execEndpoint\":\"dhuzqgnjdgk\"},{\"name\":\"scliq\",\"containerId\":\"vhxnk\",\"ready\":true,\"started\":false,\"restartCount\":1432155819,\"logStreamEndpoint\":\"ppnvdxz\",\"execEndpoint\":\"ihfrbbcevqa\"},{\"name\":\"ltd\",\"containerId\":\"fkqojpy\",\"ready\":false,\"started\":true,\"restartCount\":1334213198,\"logStreamEndpoint\":\"ifmzzsd\",\"execEndpoint\":\"brn\"}]}")
                .toObject(ReplicaProperties.class);
        Assertions.assertEquals("vyl", model.containers().get(0).name());
        Assertions.assertEquals("yavluwmncstt", model.containers().get(0).containerId());
        Assertions.assertEquals(false, model.containers().get(0).ready());
        Assertions.assertEquals(true, model.containers().get(0).started());
        Assertions.assertEquals(387251402, model.containers().get(0).restartCount());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ReplicaProperties model =
            new ReplicaProperties()
                .withContainers(
                    Arrays
                        .asList(
                            new ReplicaContainer()
                                .withName("vyl")
                                .withContainerId("yavluwmncstt")
                                .withReady(false)
                                .withStarted(true)
                                .withRestartCount(387251402),
                            new ReplicaContainer()
                                .withName("scliq")
                                .withContainerId("vhxnk")
                                .withReady(true)
                                .withStarted(false)
                                .withRestartCount(1432155819),
                            new ReplicaContainer()
                                .withName("ltd")
                                .withContainerId("fkqojpy")
                                .withReady(false)
                                .withStarted(true)
                                .withRestartCount(1334213198)));
        model = BinaryData.fromObject(model).toObject(ReplicaProperties.class);
        Assertions.assertEquals("vyl", model.containers().get(0).name());
        Assertions.assertEquals("yavluwmncstt", model.containers().get(0).containerId());
        Assertions.assertEquals(false, model.containers().get(0).ready());
        Assertions.assertEquals(true, model.containers().get(0).started());
        Assertions.assertEquals(387251402, model.containers().get(0).restartCount());
    }
}
