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

package com.azure.resourcemanager.networkcloud.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.networkcloud.fluent.models.CloudServicesNetworkInner;
import com.azure.resourcemanager.networkcloud.models.CloudServicesNetworkEnableDefaultEgressEndpoints;
import com.azure.resourcemanager.networkcloud.models.EgressEndpoint;
import com.azure.resourcemanager.networkcloud.models.ExtendedLocation;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class CloudServicesNetworkInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        CloudServicesNetworkInner model =
            BinaryData
                .fromString(
                    "{\"extendedLocation\":{\"name\":\"pmivkwlzu\",\"type\":\"ccfwnfnbacfion\"},\"properties\":{\"additionalEgressEndpoints\":[{\"category\":\"etqgtzxdpnq\",\"endpoints\":[]}],\"associatedResourceIds\":[\"wxrjfeallnwsub\",\"snjampmng\",\"zscxaqwo\"],\"clusterId\":\"hcbonqvpkvlr\",\"detailedStatus\":\"Provisioning\",\"detailedStatusMessage\":\"ase\",\"enableDefaultEgressEndpoints\":\"False\",\"enabledEgressEndpoints\":[{\"category\":\"f\",\"endpoints\":[]},{\"category\":\"okeyyienj\",\"endpoints\":[]}],\"hybridAksClustersAssociatedIds\":[\"wtgrhpdjpj\",\"masxazjpqyegu\",\"lhbxxhejjzzvdud\"],\"interfaceName\":\"dslfhotwmcy\",\"provisioningState\":\"Provisioning\",\"virtualMachinesAssociatedIds\":[\"jnpg\",\"cftadeh\"]},\"location\":\"ltyfsop\",\"tags\":{\"xzdmohctb\":\"uesnzwdejbavo\",\"ndnvo\":\"vudwx\"},\"id\":\"gujjugwdkcglh\",\"name\":\"lazjdyggdtjixhbk\",\"type\":\"ofqweykhmenevfye\"}")
                .toObject(CloudServicesNetworkInner.class);
        Assertions.assertEquals("ltyfsop", model.location());
        Assertions.assertEquals("uesnzwdejbavo", model.tags().get("xzdmohctb"));
        Assertions.assertEquals("pmivkwlzu", model.extendedLocation().name());
        Assertions.assertEquals("ccfwnfnbacfion", model.extendedLocation().type());
        Assertions.assertEquals("etqgtzxdpnq", model.additionalEgressEndpoints().get(0).category());
        Assertions
            .assertEquals(CloudServicesNetworkEnableDefaultEgressEndpoints.FALSE, model.enableDefaultEgressEndpoints());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        CloudServicesNetworkInner model =
            new CloudServicesNetworkInner()
                .withLocation("ltyfsop")
                .withTags(mapOf("xzdmohctb", "uesnzwdejbavo", "ndnvo", "vudwx"))
                .withExtendedLocation(new ExtendedLocation().withName("pmivkwlzu").withType("ccfwnfnbacfion"))
                .withAdditionalEgressEndpoints(
                    Arrays.asList(new EgressEndpoint().withCategory("etqgtzxdpnq").withEndpoints(Arrays.asList())))
                .withEnableDefaultEgressEndpoints(CloudServicesNetworkEnableDefaultEgressEndpoints.FALSE);
        model = BinaryData.fromObject(model).toObject(CloudServicesNetworkInner.class);
        Assertions.assertEquals("ltyfsop", model.location());
        Assertions.assertEquals("uesnzwdejbavo", model.tags().get("xzdmohctb"));
        Assertions.assertEquals("pmivkwlzu", model.extendedLocation().name());
        Assertions.assertEquals("ccfwnfnbacfion", model.extendedLocation().type());
        Assertions.assertEquals("etqgtzxdpnq", model.additionalEgressEndpoints().get(0).category());
        Assertions
            .assertEquals(CloudServicesNetworkEnableDefaultEgressEndpoints.FALSE, model.enableDefaultEgressEndpoints());
    }

    @SuppressWarnings("unchecked")
    private static <T> Map<String, T> mapOf(Object... inputs) {
        Map<String, T> map = new HashMap<>();
        for (int i = 0; i < inputs.length; i += 2) {
            String key = (String) inputs[i];
            T value = (T) inputs[i + 1];
            map.put(key, value);
        }
        return map;
    }
}
