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

package com.azure.resourcemanager.batch.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.batch.models.EndpointAccessDefaultAction;
import com.azure.resourcemanager.batch.models.EndpointAccessProfile;
import com.azure.resourcemanager.batch.models.IpRule;
import com.azure.resourcemanager.batch.models.NetworkProfile;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public final class NetworkProfileTests {
    @Test
    public void testDeserialize() {
        NetworkProfile model =
            BinaryData
                .fromString(
                    "{\"accountAccess\":{\"defaultAction\":\"Allow\",\"ipRules\":[{\"value\":\"dkfo\"},{\"value\":\"knygjofjddeq\"}]},\"nodeManagementAccess\":{\"defaultAction\":\"Deny\",\"ipRules\":[{\"value\":\"pewnw\"},{\"value\":\"eitjz\"},{\"value\":\"flusarhmof\"},{\"value\":\"qhsmyurkdtml\"}]}}")
                .toObject(NetworkProfile.class);
        Assertions.assertEquals(EndpointAccessDefaultAction.ALLOW, model.accountAccess().defaultAction());
        Assertions.assertEquals("dkfo", model.accountAccess().ipRules().get(0).value());
        Assertions.assertEquals(EndpointAccessDefaultAction.DENY, model.nodeManagementAccess().defaultAction());
        Assertions.assertEquals("pewnw", model.nodeManagementAccess().ipRules().get(0).value());
    }

    @Test
    public void testSerialize() {
        NetworkProfile model =
            new NetworkProfile()
                .withAccountAccess(
                    new EndpointAccessProfile()
                        .withDefaultAction(EndpointAccessDefaultAction.ALLOW)
                        .withIpRules(
                            Arrays.asList(new IpRule().withValue("dkfo"), new IpRule().withValue("knygjofjddeq"))))
                .withNodeManagementAccess(
                    new EndpointAccessProfile()
                        .withDefaultAction(EndpointAccessDefaultAction.DENY)
                        .withIpRules(
                            Arrays
                                .asList(
                                    new IpRule().withValue("pewnw"),
                                    new IpRule().withValue("eitjz"),
                                    new IpRule().withValue("flusarhmof"),
                                    new IpRule().withValue("qhsmyurkdtml"))));
        model = BinaryData.fromObject(model).toObject(NetworkProfile.class);
        Assertions.assertEquals(EndpointAccessDefaultAction.ALLOW, model.accountAccess().defaultAction());
        Assertions.assertEquals("dkfo", model.accountAccess().ipRules().get(0).value());
        Assertions.assertEquals(EndpointAccessDefaultAction.DENY, model.nodeManagementAccess().defaultAction());
        Assertions.assertEquals("pewnw", model.nodeManagementAccess().ipRules().get(0).value());
    }
}
