// 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.AccessControlListPatchProperties;
import com.azure.resourcemanager.managednetworkfabric.models.AccessControlListConditionProperties;
import com.azure.resourcemanager.managednetworkfabric.models.AddressFamily;
import com.azure.resourcemanager.managednetworkfabric.models.ConditionActionType;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class AccessControlListPatchPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AccessControlListPatchProperties model =
            BinaryData
                .fromString(
                    "{\"addressFamily\":\"ipv6\",\"conditions\":[{\"sequenceNumber\":518831868,\"action\":\"allow\",\"destinationAddress\":\"lahbcryff\",\"destinationPort\":\"fdosyg\",\"sourceAddress\":\"xpaojakhmsbz\",\"sourcePort\":\"hcrzevd\",\"protocol\":656929943,\"annotation\":\"xaolth\"},{\"sequenceNumber\":578472109,\"action\":\"deny\",\"destinationAddress\":\"gqjbpfzfsin\",\"destinationPort\":\"gvfcj\",\"sourceAddress\":\"wzo\",\"sourcePort\":\"xjtfelluwfzit\",\"protocol\":354282788,\"annotation\":\"eqfpj\"}],\"annotation\":\"lxofpdvhpfxxypin\"}")
                .toObject(AccessControlListPatchProperties.class);
        Assertions.assertEquals("lxofpdvhpfxxypin", model.annotation());
        Assertions.assertEquals(AddressFamily.IPV6, model.addressFamily());
        Assertions.assertEquals("xaolth", model.conditions().get(0).annotation());
        Assertions.assertEquals(518831868, model.conditions().get(0).sequenceNumber());
        Assertions.assertEquals(ConditionActionType.ALLOW, model.conditions().get(0).action());
        Assertions.assertEquals("lahbcryff", model.conditions().get(0).destinationAddress());
        Assertions.assertEquals("fdosyg", model.conditions().get(0).destinationPort());
        Assertions.assertEquals("xpaojakhmsbz", model.conditions().get(0).sourceAddress());
        Assertions.assertEquals("hcrzevd", model.conditions().get(0).sourcePort());
        Assertions.assertEquals(656929943, model.conditions().get(0).protocol());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AccessControlListPatchProperties model =
            new AccessControlListPatchProperties()
                .withAnnotation("lxofpdvhpfxxypin")
                .withAddressFamily(AddressFamily.IPV6)
                .withConditions(
                    Arrays
                        .asList(
                            new AccessControlListConditionProperties()
                                .withAnnotation("xaolth")
                                .withSequenceNumber(518831868)
                                .withAction(ConditionActionType.ALLOW)
                                .withDestinationAddress("lahbcryff")
                                .withDestinationPort("fdosyg")
                                .withSourceAddress("xpaojakhmsbz")
                                .withSourcePort("hcrzevd")
                                .withProtocol(656929943),
                            new AccessControlListConditionProperties()
                                .withAnnotation("eqfpj")
                                .withSequenceNumber(578472109)
                                .withAction(ConditionActionType.DENY)
                                .withDestinationAddress("gqjbpfzfsin")
                                .withDestinationPort("gvfcj")
                                .withSourceAddress("wzo")
                                .withSourcePort("xjtfelluwfzit")
                                .withProtocol(354282788)));
        model = BinaryData.fromObject(model).toObject(AccessControlListPatchProperties.class);
        Assertions.assertEquals("lxofpdvhpfxxypin", model.annotation());
        Assertions.assertEquals(AddressFamily.IPV6, model.addressFamily());
        Assertions.assertEquals("xaolth", model.conditions().get(0).annotation());
        Assertions.assertEquals(518831868, model.conditions().get(0).sequenceNumber());
        Assertions.assertEquals(ConditionActionType.ALLOW, model.conditions().get(0).action());
        Assertions.assertEquals("lahbcryff", model.conditions().get(0).destinationAddress());
        Assertions.assertEquals("fdosyg", model.conditions().get(0).destinationPort());
        Assertions.assertEquals("xpaojakhmsbz", model.conditions().get(0).sourceAddress());
        Assertions.assertEquals("hcrzevd", model.conditions().get(0).sourcePort());
        Assertions.assertEquals(656929943, model.conditions().get(0).protocol());
    }
}
