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

package com.azure.resourcemanager.appcontainers.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.appcontainers.models.AllowedPrincipals;
import com.azure.resourcemanager.appcontainers.models.AzureActiveDirectoryValidation;
import com.azure.resourcemanager.appcontainers.models.DefaultAuthorizationPolicy;
import com.azure.resourcemanager.appcontainers.models.JwtClaimChecks;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class AzureActiveDirectoryValidationTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AzureActiveDirectoryValidation model =
            BinaryData
                .fromString(
                    "{\"jwtClaimChecks\":{\"allowedGroups\":[\"nuvamiheogna\",\"xzxtheo\",\"usivye\"],\"allowedClientApplications\":[\"iqihn\",\"un\",\"bwjzr\"]},\"allowedAudiences\":[\"gxg\",\"spemvtzfk\",\"fublj\"],\"defaultAuthorizationPolicy\":{\"allowedPrincipals\":{\"groups\":[\"ofjaeqjhqjb\",\"s\",\"msmjqulngsntn\"],\"identities\":[\"kzgcwrwcl\",\"xwrljdouskcqvkoc\",\"cjdkwtnhxbnjbi\"]},\"allowedApplications\":[\"rglssainqpj\",\"nzl\",\"jfm\",\"pee\"]}}")
                .toObject(AzureActiveDirectoryValidation.class);
        Assertions.assertEquals("nuvamiheogna", model.jwtClaimChecks().allowedGroups().get(0));
        Assertions.assertEquals("iqihn", model.jwtClaimChecks().allowedClientApplications().get(0));
        Assertions.assertEquals("gxg", model.allowedAudiences().get(0));
        Assertions.assertEquals("ofjaeqjhqjb", model.defaultAuthorizationPolicy().allowedPrincipals().groups().get(0));
        Assertions
            .assertEquals("kzgcwrwcl", model.defaultAuthorizationPolicy().allowedPrincipals().identities().get(0));
        Assertions.assertEquals("rglssainqpj", model.defaultAuthorizationPolicy().allowedApplications().get(0));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AzureActiveDirectoryValidation model =
            new AzureActiveDirectoryValidation()
                .withJwtClaimChecks(
                    new JwtClaimChecks()
                        .withAllowedGroups(Arrays.asList("nuvamiheogna", "xzxtheo", "usivye"))
                        .withAllowedClientApplications(Arrays.asList("iqihn", "un", "bwjzr")))
                .withAllowedAudiences(Arrays.asList("gxg", "spemvtzfk", "fublj"))
                .withDefaultAuthorizationPolicy(
                    new DefaultAuthorizationPolicy()
                        .withAllowedPrincipals(
                            new AllowedPrincipals()
                                .withGroups(Arrays.asList("ofjaeqjhqjb", "s", "msmjqulngsntn"))
                                .withIdentities(Arrays.asList("kzgcwrwcl", "xwrljdouskcqvkoc", "cjdkwtnhxbnjbi")))
                        .withAllowedApplications(Arrays.asList("rglssainqpj", "nzl", "jfm", "pee")));
        model = BinaryData.fromObject(model).toObject(AzureActiveDirectoryValidation.class);
        Assertions.assertEquals("nuvamiheogna", model.jwtClaimChecks().allowedGroups().get(0));
        Assertions.assertEquals("iqihn", model.jwtClaimChecks().allowedClientApplications().get(0));
        Assertions.assertEquals("gxg", model.allowedAudiences().get(0));
        Assertions.assertEquals("ofjaeqjhqjb", model.defaultAuthorizationPolicy().allowedPrincipals().groups().get(0));
        Assertions
            .assertEquals("kzgcwrwcl", model.defaultAuthorizationPolicy().allowedPrincipals().identities().get(0));
        Assertions.assertEquals("rglssainqpj", model.defaultAuthorizationPolicy().allowedApplications().get(0));
    }
}
