// 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.DatabasePrincipalAssignmentListResult;
import com.azure.resourcemanager.kusto.models.DatabasePrincipalRole;
import com.azure.resourcemanager.kusto.models.PrincipalType;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class DatabasePrincipalAssignmentListResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        DatabasePrincipalAssignmentListResult model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"principalId\":\"cykvceo\",\"role\":\"User\",\"tenantId\":\"lo\",\"principalType\":\"Group\",\"tenantName\":\"tyfjfcnjbkcnxdhb\",\"principalName\":\"kphywpnvjto\",\"provisioningState\":\"Moving\",\"aadObjectId\":\"mclfplphoxuscr\"},\"id\":\"abgy\",\"name\":\"psbjta\",\"type\":\"qugxywpmueefjzwf\"},{\"properties\":{\"principalId\":\"q\",\"role\":\"Monitor\",\"tenantId\":\"dsuyonobgla\",\"principalType\":\"User\",\"tenantName\":\"xtccmg\",\"principalName\":\"dxyt\",\"provisioningState\":\"Canceled\",\"aadObjectId\":\"rxv\"},\"id\":\"fudwpznt\",\"name\":\"hdzhlrqj\",\"type\":\"hckfrlhrx\"},{\"properties\":{\"principalId\":\"kyv\",\"role\":\"User\",\"tenantId\":\"anuzbpzkafkuw\",\"principalType\":\"Group\",\"tenantName\":\"nwbmeh\",\"principalName\":\"eyvjusrtslhspkde\",\"provisioningState\":\"Succeeded\",\"aadObjectId\":\"fm\"},\"id\":\"ag\",\"name\":\"vt\",\"type\":\"elmqk\"},{\"properties\":{\"principalId\":\"ahvljuaha\",\"role\":\"UnrestrictedViewer\",\"tenantId\":\"c\",\"principalType\":\"Group\",\"tenantName\":\"duala\",\"principalName\":\"qpv\",\"provisioningState\":\"Creating\",\"aadObjectId\":\"ws\"},\"id\":\"crgvxpvgom\",\"name\":\"lf\",\"type\":\"isgwbnbbeldawkz\"}]}")
                .toObject(DatabasePrincipalAssignmentListResult.class);
        Assertions.assertEquals("cykvceo", model.value().get(0).principalId());
        Assertions.assertEquals(DatabasePrincipalRole.USER, model.value().get(0).role());
        Assertions.assertEquals("lo", model.value().get(0).tenantId());
        Assertions.assertEquals(PrincipalType.GROUP, model.value().get(0).principalType());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        DatabasePrincipalAssignmentListResult model =
            new DatabasePrincipalAssignmentListResult()
                .withValue(
                    Arrays
                        .asList(
                            new DatabasePrincipalAssignmentInner()
                                .withPrincipalId("cykvceo")
                                .withRole(DatabasePrincipalRole.USER)
                                .withTenantId("lo")
                                .withPrincipalType(PrincipalType.GROUP),
                            new DatabasePrincipalAssignmentInner()
                                .withPrincipalId("q")
                                .withRole(DatabasePrincipalRole.MONITOR)
                                .withTenantId("dsuyonobgla")
                                .withPrincipalType(PrincipalType.USER),
                            new DatabasePrincipalAssignmentInner()
                                .withPrincipalId("kyv")
                                .withRole(DatabasePrincipalRole.USER)
                                .withTenantId("anuzbpzkafkuw")
                                .withPrincipalType(PrincipalType.GROUP),
                            new DatabasePrincipalAssignmentInner()
                                .withPrincipalId("ahvljuaha")
                                .withRole(DatabasePrincipalRole.UNRESTRICTED_VIEWER)
                                .withTenantId("c")
                                .withPrincipalType(PrincipalType.GROUP)));
        model = BinaryData.fromObject(model).toObject(DatabasePrincipalAssignmentListResult.class);
        Assertions.assertEquals("cykvceo", model.value().get(0).principalId());
        Assertions.assertEquals(DatabasePrincipalRole.USER, model.value().get(0).role());
        Assertions.assertEquals("lo", model.value().get(0).tenantId());
        Assertions.assertEquals(PrincipalType.GROUP, model.value().get(0).principalType());
    }
}
