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

package com.azure.resourcemanager.databricks.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.databricks.models.EndpointDependency;
import com.azure.resourcemanager.databricks.models.EndpointDetail;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class EndpointDependencyTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        EndpointDependency model =
            BinaryData
                .fromString(
                    "{\"domainName\":\"xyqj\",\"endpointDetails\":[{\"ipAddress\":\"t\",\"port\":738552235,\"latency\":89.54885021656311,\"isAccessible\":false},{\"ipAddress\":\"zsqpjhvmdajvny\",\"port\":340667292,\"latency\":0.19355568935980338,\"isAccessible\":false},{\"ipAddress\":\"oaeupfhyhltrpmo\",\"port\":1593902435,\"latency\":34.71437790880483,\"isAccessible\":false},{\"ipAddress\":\"kthfui\",\"port\":1958511129,\"latency\":82.85533213384883,\"isAccessible\":false}]}")
                .toObject(EndpointDependency.class);
        Assertions.assertEquals("xyqj", model.domainName());
        Assertions.assertEquals("t", model.endpointDetails().get(0).ipAddress());
        Assertions.assertEquals(738552235, model.endpointDetails().get(0).port());
        Assertions.assertEquals(89.54885021656311D, model.endpointDetails().get(0).latency());
        Assertions.assertEquals(false, model.endpointDetails().get(0).isAccessible());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        EndpointDependency model =
            new EndpointDependency()
                .withDomainName("xyqj")
                .withEndpointDetails(
                    Arrays
                        .asList(
                            new EndpointDetail()
                                .withIpAddress("t")
                                .withPort(738552235)
                                .withLatency(89.54885021656311D)
                                .withIsAccessible(false),
                            new EndpointDetail()
                                .withIpAddress("zsqpjhvmdajvny")
                                .withPort(340667292)
                                .withLatency(0.19355568935980338D)
                                .withIsAccessible(false),
                            new EndpointDetail()
                                .withIpAddress("oaeupfhyhltrpmo")
                                .withPort(1593902435)
                                .withLatency(34.71437790880483D)
                                .withIsAccessible(false),
                            new EndpointDetail()
                                .withIpAddress("kthfui")
                                .withPort(1958511129)
                                .withLatency(82.85533213384883D)
                                .withIsAccessible(false)));
        model = BinaryData.fromObject(model).toObject(EndpointDependency.class);
        Assertions.assertEquals("xyqj", model.domainName());
        Assertions.assertEquals("t", model.endpointDetails().get(0).ipAddress());
        Assertions.assertEquals(738552235, model.endpointDetails().get(0).port());
        Assertions.assertEquals(89.54885021656311D, model.endpointDetails().get(0).latency());
        Assertions.assertEquals(false, model.endpointDetails().get(0).isAccessible());
    }
}
