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

package com.azure.resourcemanager.managednetworkfabric.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.managednetworkfabric.fluent.models.NetworkTapProperties;
import com.azure.resourcemanager.managednetworkfabric.models.DestinationType;
import com.azure.resourcemanager.managednetworkfabric.models.Encapsulation;
import com.azure.resourcemanager.managednetworkfabric.models.IsolationDomainProperties;
import com.azure.resourcemanager.managednetworkfabric.models.NetworkTapPropertiesDestinationsItem;
import com.azure.resourcemanager.managednetworkfabric.models.PollingType;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class NetworkTapPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        NetworkTapProperties model =
            BinaryData
                .fromString(
                    "{\"networkPacketBrokerId\":\"zpvqewflwzhxzuxe\",\"sourceTapRuleId\":\"hywlrkqsq\",\"destinations\":[{\"name\":\"kfpfjdajdqx\",\"destinationType\":\"Direct\",\"destinationId\":\"yfrdjidcetfvg\",\"isolationDomainProperties\":{\"encapsulation\":\"GRE\",\"neighborGroupIds\":[\"igwouppvyddqsvc\",\"rsnxfrp\"]},\"destinationTapRuleId\":\"wqclmdmtfxxepzpx\"},{\"name\":\"lcqzfxai\",\"destinationType\":\"Direct\",\"destinationId\":\"cj\",\"isolationDomainProperties\":{\"encapsulation\":\"None\",\"neighborGroupIds\":[\"pqnip\",\"dmhk\",\"omeobwkeuzltenlb\"]},\"destinationTapRuleId\":\"lmxoz\"},{\"name\":\"ndoduom\",\"destinationType\":\"Direct\",\"destinationId\":\"ri\",\"isolationDomainProperties\":{\"encapsulation\":\"None\",\"neighborGroupIds\":[\"kk\",\"yvurhwishy\",\"mrzcqfevnkyakc\",\"tehognsddjk\"]},\"destinationTapRuleId\":\"edesuazogfcnx\"}],\"pollingType\":\"Pull\",\"configurationState\":\"Accepted\",\"provisioningState\":\"Accepted\",\"administrativeState\":\"RMA\",\"annotation\":\"myvkxix\"}")
                .toObject(NetworkTapProperties.class);
        Assertions.assertEquals("myvkxix", model.annotation());
        Assertions.assertEquals("zpvqewflwzhxzuxe", model.networkPacketBrokerId());
        Assertions.assertEquals("kfpfjdajdqx", model.destinations().get(0).name());
        Assertions.assertEquals(DestinationType.DIRECT, model.destinations().get(0).destinationType());
        Assertions.assertEquals("yfrdjidcetfvg", model.destinations().get(0).destinationId());
        Assertions
            .assertEquals(Encapsulation.GRE, model.destinations().get(0).isolationDomainProperties().encapsulation());
        Assertions
            .assertEquals(
                "igwouppvyddqsvc", model.destinations().get(0).isolationDomainProperties().neighborGroupIds().get(0));
        Assertions.assertEquals("wqclmdmtfxxepzpx", model.destinations().get(0).destinationTapRuleId());
        Assertions.assertEquals(PollingType.PULL, model.pollingType());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        NetworkTapProperties model =
            new NetworkTapProperties()
                .withAnnotation("myvkxix")
                .withNetworkPacketBrokerId("zpvqewflwzhxzuxe")
                .withDestinations(
                    Arrays
                        .asList(
                            new NetworkTapPropertiesDestinationsItem()
                                .withName("kfpfjdajdqx")
                                .withDestinationType(DestinationType.DIRECT)
                                .withDestinationId("yfrdjidcetfvg")
                                .withIsolationDomainProperties(
                                    new IsolationDomainProperties()
                                        .withEncapsulation(Encapsulation.GRE)
                                        .withNeighborGroupIds(Arrays.asList("igwouppvyddqsvc", "rsnxfrp")))
                                .withDestinationTapRuleId("wqclmdmtfxxepzpx"),
                            new NetworkTapPropertiesDestinationsItem()
                                .withName("lcqzfxai")
                                .withDestinationType(DestinationType.DIRECT)
                                .withDestinationId("cj")
                                .withIsolationDomainProperties(
                                    new IsolationDomainProperties()
                                        .withEncapsulation(Encapsulation.NONE)
                                        .withNeighborGroupIds(Arrays.asList("pqnip", "dmhk", "omeobwkeuzltenlb")))
                                .withDestinationTapRuleId("lmxoz"),
                            new NetworkTapPropertiesDestinationsItem()
                                .withName("ndoduom")
                                .withDestinationType(DestinationType.DIRECT)
                                .withDestinationId("ri")
                                .withIsolationDomainProperties(
                                    new IsolationDomainProperties()
                                        .withEncapsulation(Encapsulation.NONE)
                                        .withNeighborGroupIds(
                                            Arrays.asList("kk", "yvurhwishy", "mrzcqfevnkyakc", "tehognsddjk")))
                                .withDestinationTapRuleId("edesuazogfcnx")))
                .withPollingType(PollingType.PULL);
        model = BinaryData.fromObject(model).toObject(NetworkTapProperties.class);
        Assertions.assertEquals("myvkxix", model.annotation());
        Assertions.assertEquals("zpvqewflwzhxzuxe", model.networkPacketBrokerId());
        Assertions.assertEquals("kfpfjdajdqx", model.destinations().get(0).name());
        Assertions.assertEquals(DestinationType.DIRECT, model.destinations().get(0).destinationType());
        Assertions.assertEquals("yfrdjidcetfvg", model.destinations().get(0).destinationId());
        Assertions
            .assertEquals(Encapsulation.GRE, model.destinations().get(0).isolationDomainProperties().encapsulation());
        Assertions
            .assertEquals(
                "igwouppvyddqsvc", model.destinations().get(0).isolationDomainProperties().neighborGroupIds().get(0));
        Assertions.assertEquals("wqclmdmtfxxepzpx", model.destinations().get(0).destinationTapRuleId());
        Assertions.assertEquals(PollingType.PULL, model.pollingType());
    }
}
