// 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.fluent.models.VirtualNetworkPeeringPropertiesFormat;
import com.azure.resourcemanager.databricks.models.AddressSpace;
import com.azure.resourcemanager.databricks.models.VirtualNetworkPeeringPropertiesFormatDatabricksVirtualNetwork;
import com.azure.resourcemanager.databricks.models.VirtualNetworkPeeringPropertiesFormatRemoteVirtualNetwork;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class VirtualNetworkPeeringPropertiesFormatTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        VirtualNetworkPeeringPropertiesFormat model =
            BinaryData
                .fromString(
                    "{\"allowVirtualNetworkAccess\":true,\"allowForwardedTraffic\":true,\"allowGatewayTransit\":true,\"useRemoteGateways\":true,\"databricksVirtualNetwork\":{\"id\":\"iqzbq\"},\"databricksAddressSpace\":{\"addressPrefixes\":[\"vmyokacspkwl\"]},\"remoteVirtualNetwork\":{\"id\":\"dobpxjmflbvvn\"},\"remoteAddressSpace\":{\"addressPrefixes\":[\"cciw\",\"zjuqkhrsaj\",\"wkuofoskghsauu\",\"mjmvxieduugidyjr\"]},\"peeringState\":\"Disconnected\",\"provisioningState\":\"Succeeded\"}")
                .toObject(VirtualNetworkPeeringPropertiesFormat.class);
        Assertions.assertEquals(true, model.allowVirtualNetworkAccess());
        Assertions.assertEquals(true, model.allowForwardedTraffic());
        Assertions.assertEquals(true, model.allowGatewayTransit());
        Assertions.assertEquals(true, model.useRemoteGateways());
        Assertions.assertEquals("iqzbq", model.databricksVirtualNetwork().id());
        Assertions.assertEquals("vmyokacspkwl", model.databricksAddressSpace().addressPrefixes().get(0));
        Assertions.assertEquals("dobpxjmflbvvn", model.remoteVirtualNetwork().id());
        Assertions.assertEquals("cciw", model.remoteAddressSpace().addressPrefixes().get(0));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        VirtualNetworkPeeringPropertiesFormat model =
            new VirtualNetworkPeeringPropertiesFormat()
                .withAllowVirtualNetworkAccess(true)
                .withAllowForwardedTraffic(true)
                .withAllowGatewayTransit(true)
                .withUseRemoteGateways(true)
                .withDatabricksVirtualNetwork(
                    new VirtualNetworkPeeringPropertiesFormatDatabricksVirtualNetwork().withId("iqzbq"))
                .withDatabricksAddressSpace(new AddressSpace().withAddressPrefixes(Arrays.asList("vmyokacspkwl")))
                .withRemoteVirtualNetwork(
                    new VirtualNetworkPeeringPropertiesFormatRemoteVirtualNetwork().withId("dobpxjmflbvvn"))
                .withRemoteAddressSpace(
                    new AddressSpace()
                        .withAddressPrefixes(
                            Arrays.asList("cciw", "zjuqkhrsaj", "wkuofoskghsauu", "mjmvxieduugidyjr")));
        model = BinaryData.fromObject(model).toObject(VirtualNetworkPeeringPropertiesFormat.class);
        Assertions.assertEquals(true, model.allowVirtualNetworkAccess());
        Assertions.assertEquals(true, model.allowForwardedTraffic());
        Assertions.assertEquals(true, model.allowGatewayTransit());
        Assertions.assertEquals(true, model.useRemoteGateways());
        Assertions.assertEquals("iqzbq", model.databricksVirtualNetwork().id());
        Assertions.assertEquals("vmyokacspkwl", model.databricksAddressSpace().addressPrefixes().get(0));
        Assertions.assertEquals("dobpxjmflbvvn", model.remoteVirtualNetwork().id());
        Assertions.assertEquals("cciw", model.remoteAddressSpace().addressPrefixes().get(0));
    }
}
