// 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 java.util.Arrays;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public final class EndpointAccessProfileTests {
    @Test
    public void testDeserialize() {
        EndpointAccessProfile model =
            BinaryData
                .fromString(
                    "{\"defaultAction\":\"Allow\",\"ipRules\":[{\"value\":\"uksjtxukcdmp\"},{\"value\":\"rcryuanzwuxzdxta\"},{\"value\":\"rlhm\"}]}")
                .toObject(EndpointAccessProfile.class);
        Assertions.assertEquals(EndpointAccessDefaultAction.ALLOW, model.defaultAction());
        Assertions.assertEquals("uksjtxukcdmp", model.ipRules().get(0).value());
    }

    @Test
    public void testSerialize() {
        EndpointAccessProfile model =
            new EndpointAccessProfile()
                .withDefaultAction(EndpointAccessDefaultAction.ALLOW)
                .withIpRules(
                    Arrays
                        .asList(
                            new IpRule().withValue("uksjtxukcdmp"),
                            new IpRule().withValue("rcryuanzwuxzdxta"),
                            new IpRule().withValue("rlhm")));
        model = BinaryData.fromObject(model).toObject(EndpointAccessProfile.class);
        Assertions.assertEquals(EndpointAccessDefaultAction.ALLOW, model.defaultAction());
        Assertions.assertEquals("uksjtxukcdmp", model.ipRules().get(0).value());
    }
}
