// 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.CookieExpiration;
import com.azure.resourcemanager.appcontainers.models.CookieExpirationConvention;
import com.azure.resourcemanager.appcontainers.models.Login;
import com.azure.resourcemanager.appcontainers.models.LoginRoutes;
import com.azure.resourcemanager.appcontainers.models.Nonce;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class LoginTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        Login model =
            BinaryData
                .fromString(
                    "{\"routes\":{\"logoutEndpoint\":\"qwpgrjbzn\"},\"preserveUrlFragmentsForLogins\":true,\"allowedExternalRedirectUrls\":[\"vsnb\"],\"cookieExpiration\":{\"convention\":\"IdentityProviderDerived\",\"timeToExpiration\":\"nmoc\"},\"nonce\":{\"validateNonce\":true,\"nonceExpirationInterval\":\"urzafb\"}}")
                .toObject(Login.class);
        Assertions.assertEquals("qwpgrjbzn", model.routes().logoutEndpoint());
        Assertions.assertEquals(true, model.preserveUrlFragmentsForLogins());
        Assertions.assertEquals("vsnb", model.allowedExternalRedirectUrls().get(0));
        Assertions
            .assertEquals(CookieExpirationConvention.IDENTITY_PROVIDER_DERIVED, model.cookieExpiration().convention());
        Assertions.assertEquals("nmoc", model.cookieExpiration().timeToExpiration());
        Assertions.assertEquals(true, model.nonce().validateNonce());
        Assertions.assertEquals("urzafb", model.nonce().nonceExpirationInterval());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        Login model =
            new Login()
                .withRoutes(new LoginRoutes().withLogoutEndpoint("qwpgrjbzn"))
                .withPreserveUrlFragmentsForLogins(true)
                .withAllowedExternalRedirectUrls(Arrays.asList("vsnb"))
                .withCookieExpiration(
                    new CookieExpiration()
                        .withConvention(CookieExpirationConvention.IDENTITY_PROVIDER_DERIVED)
                        .withTimeToExpiration("nmoc"))
                .withNonce(new Nonce().withValidateNonce(true).withNonceExpirationInterval("urzafb"));
        model = BinaryData.fromObject(model).toObject(Login.class);
        Assertions.assertEquals("qwpgrjbzn", model.routes().logoutEndpoint());
        Assertions.assertEquals(true, model.preserveUrlFragmentsForLogins());
        Assertions.assertEquals("vsnb", model.allowedExternalRedirectUrls().get(0));
        Assertions
            .assertEquals(CookieExpirationConvention.IDENTITY_PROVIDER_DERIVED, model.cookieExpiration().convention());
        Assertions.assertEquals("nmoc", model.cookieExpiration().timeToExpiration());
        Assertions.assertEquals(true, model.nonce().validateNonce());
        Assertions.assertEquals("urzafb", model.nonce().nonceExpirationInterval());
    }
}
