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

package com.azure.resourcemanager.mediaservices.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.mediaservices.models.IpAccessControl;
import com.azure.resourcemanager.mediaservices.models.IpRange;
import com.azure.resourcemanager.mediaservices.models.LiveEventInputAccessControl;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class LiveEventInputAccessControlTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        LiveEventInputAccessControl model =
            BinaryData
                .fromString(
                    "{\"ip\":{\"allow\":[{\"name\":\"gvraeaen\",\"address\":\"nzar\",\"subnetPrefixLength\":1854977873},{\"name\":\"uu\",\"address\":\"fqka\",\"subnetPrefixLength\":1905366329},{\"name\":\"ipfpubji\",\"address\":\"wifto\",\"subnetPrefixLength\":2124677941}]}}")
                .toObject(LiveEventInputAccessControl.class);
        Assertions.assertEquals("gvraeaen", model.ip().allow().get(0).name());
        Assertions.assertEquals("nzar", model.ip().allow().get(0).address());
        Assertions.assertEquals(1854977873, model.ip().allow().get(0).subnetPrefixLength());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        LiveEventInputAccessControl model =
            new LiveEventInputAccessControl()
                .withIp(
                    new IpAccessControl()
                        .withAllow(
                            Arrays
                                .asList(
                                    new IpRange()
                                        .withName("gvraeaen")
                                        .withAddress("nzar")
                                        .withSubnetPrefixLength(1854977873),
                                    new IpRange().withName("uu").withAddress("fqka").withSubnetPrefixLength(1905366329),
                                    new IpRange()
                                        .withName("ipfpubji")
                                        .withAddress("wifto")
                                        .withSubnetPrefixLength(2124677941))));
        model = BinaryData.fromObject(model).toObject(LiveEventInputAccessControl.class);
        Assertions.assertEquals("gvraeaen", model.ip().allow().get(0).name());
        Assertions.assertEquals("nzar", model.ip().allow().get(0).address());
        Assertions.assertEquals(1854977873, model.ip().allow().get(0).subnetPrefixLength());
    }
}
