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

package com.azure.resourcemanager.managementgroups.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.managementgroups.fluent.models.EntityInfoInner;
import com.azure.resourcemanager.managementgroups.models.EntityParentGroupInfo;
import com.azure.resourcemanager.managementgroups.models.Permissions;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class EntityInfoInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        EntityInfoInner model =
            BinaryData
                .fromString(
                    "{\"id\":\"jggmebfsiarbu\",\"type\":\"cvpnazzmhjrunmpx\",\"name\":\"dbhrbnlankxm\",\"properties\":{\"tenantId\":\"pbh\",\"displayName\":\"btkcxywnytnrsyn\",\"parent\":{\"id\":\"dybyxczfclhaa\"},\"permissions\":\"edit\",\"inheritedPermissions\":\"noaccess\",\"numberOfDescendants\":393084907,\"numberOfChildren\":1346758763,\"numberOfChildGroups\":77204722,\"parentDisplayNameChain\":[\"ktsthsucocmny\"],\"parentNameChain\":[\"t\"]}}")
                .toObject(EntityInfoInner.class);
        Assertions.assertEquals("pbh", model.tenantId());
        Assertions.assertEquals("btkcxywnytnrsyn", model.displayName());
        Assertions.assertEquals("dybyxczfclhaa", model.parent().id());
        Assertions.assertEquals(Permissions.EDIT, model.permissions());
        Assertions.assertEquals(Permissions.NOACCESS, model.inheritedPermissions());
        Assertions.assertEquals(393084907, model.numberOfDescendants());
        Assertions.assertEquals(1346758763, model.numberOfChildren());
        Assertions.assertEquals(77204722, model.numberOfChildGroups());
        Assertions.assertEquals("ktsthsucocmny", model.parentDisplayNameChain().get(0));
        Assertions.assertEquals("t", model.parentNameChain().get(0));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        EntityInfoInner model =
            new EntityInfoInner()
                .withTenantId("pbh")
                .withDisplayName("btkcxywnytnrsyn")
                .withParent(new EntityParentGroupInfo().withId("dybyxczfclhaa"))
                .withPermissions(Permissions.EDIT)
                .withInheritedPermissions(Permissions.NOACCESS)
                .withNumberOfDescendants(393084907)
                .withNumberOfChildren(1346758763)
                .withNumberOfChildGroups(77204722)
                .withParentDisplayNameChain(Arrays.asList("ktsthsucocmny"))
                .withParentNameChain(Arrays.asList("t"));
        model = BinaryData.fromObject(model).toObject(EntityInfoInner.class);
        Assertions.assertEquals("pbh", model.tenantId());
        Assertions.assertEquals("btkcxywnytnrsyn", model.displayName());
        Assertions.assertEquals("dybyxczfclhaa", model.parent().id());
        Assertions.assertEquals(Permissions.EDIT, model.permissions());
        Assertions.assertEquals(Permissions.NOACCESS, model.inheritedPermissions());
        Assertions.assertEquals(393084907, model.numberOfDescendants());
        Assertions.assertEquals(1346758763, model.numberOfChildren());
        Assertions.assertEquals(77204722, model.numberOfChildGroups());
        Assertions.assertEquals("ktsthsucocmny", model.parentDisplayNameChain().get(0));
        Assertions.assertEquals("t", model.parentNameChain().get(0));
    }
}
