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

package com.azure.resourcemanager.kusto.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.kusto.fluent.models.DatabasePrincipalAssignmentInner;
import com.azure.resourcemanager.kusto.models.DatabasePrincipalRole;
import com.azure.resourcemanager.kusto.models.PrincipalType;
import org.junit.jupiter.api.Assertions;

public final class DatabasePrincipalAssignmentInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        DatabasePrincipalAssignmentInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"principalId\":\"aq\",\"role\":\"UnrestrictedViewer\",\"tenantId\":\"yjpkiidzyexz\",\"principalType\":\"App\",\"tenantName\":\"ixhnrztf\",\"principalName\":\"hb\",\"provisioningState\":\"Canceled\",\"aadObjectId\":\"alaulppggdtpnapn\"},\"id\":\"iropuhpigvpgylg\",\"name\":\"git\",\"type\":\"medjvcslynqwwncw\"}")
                .toObject(DatabasePrincipalAssignmentInner.class);
        Assertions.assertEquals("aq", model.principalId());
        Assertions.assertEquals(DatabasePrincipalRole.UNRESTRICTED_VIEWER, model.role());
        Assertions.assertEquals("yjpkiidzyexz", model.tenantId());
        Assertions.assertEquals(PrincipalType.APP, model.principalType());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        DatabasePrincipalAssignmentInner model =
            new DatabasePrincipalAssignmentInner()
                .withPrincipalId("aq")
                .withRole(DatabasePrincipalRole.UNRESTRICTED_VIEWER)
                .withTenantId("yjpkiidzyexz")
                .withPrincipalType(PrincipalType.APP);
        model = BinaryData.fromObject(model).toObject(DatabasePrincipalAssignmentInner.class);
        Assertions.assertEquals("aq", model.principalId());
        Assertions.assertEquals(DatabasePrincipalRole.UNRESTRICTED_VIEWER, model.role());
        Assertions.assertEquals("yjpkiidzyexz", model.tenantId());
        Assertions.assertEquals(PrincipalType.APP, model.principalType());
    }
}
