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

package com.azure.resourcemanager.timeseriesinsights.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.timeseriesinsights.models.AccessPolicyCreateOrUpdateParameters;
import com.azure.resourcemanager.timeseriesinsights.models.AccessPolicyRole;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class AccessPolicyCreateOrUpdateParametersTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AccessPolicyCreateOrUpdateParameters model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"principalObjectId\":\"jrefovgmkqsle\",\"description\":\"vxyqjpkcattpngjc\",\"roles\":[\"Contributor\",\"Contributor\",\"Reader\"]}}")
                .toObject(AccessPolicyCreateOrUpdateParameters.class);
        Assertions.assertEquals("jrefovgmkqsle", model.principalObjectId());
        Assertions.assertEquals("vxyqjpkcattpngjc", model.description());
        Assertions.assertEquals(AccessPolicyRole.CONTRIBUTOR, model.roles().get(0));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AccessPolicyCreateOrUpdateParameters model =
            new AccessPolicyCreateOrUpdateParameters()
                .withPrincipalObjectId("jrefovgmkqsle")
                .withDescription("vxyqjpkcattpngjc")
                .withRoles(
                    Arrays.asList(AccessPolicyRole.CONTRIBUTOR, AccessPolicyRole.CONTRIBUTOR, AccessPolicyRole.READER));
        model = BinaryData.fromObject(model).toObject(AccessPolicyCreateOrUpdateParameters.class);
        Assertions.assertEquals("jrefovgmkqsle", model.principalObjectId());
        Assertions.assertEquals("vxyqjpkcattpngjc", model.description());
        Assertions.assertEquals(AccessPolicyRole.CONTRIBUTOR, model.roles().get(0));
    }
}
