// 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.fluent.models.AccessPolicyResourceProperties;
import com.azure.resourcemanager.timeseriesinsights.models.AccessPolicyRole;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

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

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