// 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.EntityHierarchyItemProperties;
import com.azure.resourcemanager.managementgroups.models.EntityHierarchyItem;
import com.azure.resourcemanager.managementgroups.models.Permissions;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class EntityHierarchyItemPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        EntityHierarchyItemProperties model =
            BinaryData
                .fromString(
                    "{\"displayName\":\"dqmh\",\"permissions\":\"edit\",\"children\":[{\"properties\":{\"displayName\":\"wky\",\"permissions\":\"view\",\"children\":[]},\"id\":\"tkncwsc\",\"name\":\"svlxotogtwrup\",\"type\":\"sx\"},{\"properties\":{\"displayName\":\"i\",\"permissions\":\"delete\",\"children\":[]},\"id\":\"ceoveilovno\",\"name\":\"yfjfcnjbkcn\",\"type\":\"dhbt\"},{\"properties\":{\"displayName\":\"h\",\"permissions\":\"delete\",\"children\":[]},\"id\":\"vjtoqnermclfp\",\"name\":\"phoxus\",\"type\":\"rpabg\"}]}")
                .toObject(EntityHierarchyItemProperties.class);
        Assertions.assertEquals("dqmh", model.displayName());
        Assertions.assertEquals(Permissions.EDIT, model.permissions());
        Assertions.assertEquals("wky", model.children().get(0).displayName());
        Assertions.assertEquals(Permissions.VIEW, model.children().get(0).permissions());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        EntityHierarchyItemProperties model =
            new EntityHierarchyItemProperties()
                .withDisplayName("dqmh")
                .withPermissions(Permissions.EDIT)
                .withChildren(
                    Arrays
                        .asList(
                            new EntityHierarchyItem()
                                .withDisplayName("wky")
                                .withPermissions(Permissions.VIEW)
                                .withChildren(Arrays.asList()),
                            new EntityHierarchyItem()
                                .withDisplayName("i")
                                .withPermissions(Permissions.DELETE)
                                .withChildren(Arrays.asList()),
                            new EntityHierarchyItem()
                                .withDisplayName("h")
                                .withPermissions(Permissions.DELETE)
                                .withChildren(Arrays.asList())));
        model = BinaryData.fromObject(model).toObject(EntityHierarchyItemProperties.class);
        Assertions.assertEquals("dqmh", model.displayName());
        Assertions.assertEquals(Permissions.EDIT, model.permissions());
        Assertions.assertEquals("wky", model.children().get(0).displayName());
        Assertions.assertEquals(Permissions.VIEW, model.children().get(0).permissions());
    }
}
