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

public final class ManagementGroupChildInfoTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ManagementGroupChildInfo model =
            BinaryData
                .fromString(
                    "{\"type\":\"/subscriptions\",\"id\":\"qgoulznd\",\"name\":\"kwy\",\"displayName\":\"gfgibm\",\"children\":[{\"type\":\"/subscriptions\",\"id\":\"qsrxybzqqed\",\"name\":\"tbciqfouflmm\",\"displayName\":\"zsm\",\"children\":[]},{\"type\":\"Microsoft.Management/managementGroups\",\"id\":\"ugpbkw\",\"name\":\"utduqktapspwgcu\",\"displayName\":\"tumkdosvqwhbm\",\"children\":[]}]}")
                .toObject(ManagementGroupChildInfo.class);
        Assertions.assertEquals(ManagementGroupChildType.SUBSCRIPTIONS, model.type());
        Assertions.assertEquals("qgoulznd", model.id());
        Assertions.assertEquals("kwy", model.name());
        Assertions.assertEquals("gfgibm", model.displayName());
        Assertions.assertEquals(ManagementGroupChildType.SUBSCRIPTIONS, model.children().get(0).type());
        Assertions.assertEquals("qsrxybzqqed", model.children().get(0).id());
        Assertions.assertEquals("tbciqfouflmm", model.children().get(0).name());
        Assertions.assertEquals("zsm", model.children().get(0).displayName());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ManagementGroupChildInfo model =
            new ManagementGroupChildInfo()
                .withType(ManagementGroupChildType.SUBSCRIPTIONS)
                .withId("qgoulznd")
                .withName("kwy")
                .withDisplayName("gfgibm")
                .withChildren(
                    Arrays
                        .asList(
                            new ManagementGroupChildInfo()
                                .withType(ManagementGroupChildType.SUBSCRIPTIONS)
                                .withId("qsrxybzqqed")
                                .withName("tbciqfouflmm")
                                .withDisplayName("zsm")
                                .withChildren(Arrays.asList()),
                            new ManagementGroupChildInfo()
                                .withType(ManagementGroupChildType.MICROSOFT_MANAGEMENT_MANAGEMENT_GROUPS)
                                .withId("ugpbkw")
                                .withName("utduqktapspwgcu")
                                .withDisplayName("tumkdosvqwhbm")
                                .withChildren(Arrays.asList())));
        model = BinaryData.fromObject(model).toObject(ManagementGroupChildInfo.class);
        Assertions.assertEquals(ManagementGroupChildType.SUBSCRIPTIONS, model.type());
        Assertions.assertEquals("qgoulznd", model.id());
        Assertions.assertEquals("kwy", model.name());
        Assertions.assertEquals("gfgibm", model.displayName());
        Assertions.assertEquals(ManagementGroupChildType.SUBSCRIPTIONS, model.children().get(0).type());
        Assertions.assertEquals("qsrxybzqqed", model.children().get(0).id());
        Assertions.assertEquals("tbciqfouflmm", model.children().get(0).name());
        Assertions.assertEquals("zsm", model.children().get(0).displayName());
    }
}
