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

package com.azure.resourcemanager.mediaservices.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.mediaservices.fluent.models.StreamingEndpointInner;
import com.azure.resourcemanager.mediaservices.models.ArmStreamingEndpointCurrentSku;
import com.azure.resourcemanager.mediaservices.models.StreamingEndpointListResult;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class StreamingEndpointListResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        StreamingEndpointListResult model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"description\":\"wkyhkobopgxe\",\"scaleUnits\":222452990,\"availabilitySetName\":\"wep\",\"maxCacheAge\":2106784928647085013,\"customHostNames\":[],\"hostName\":\"bwccsnjvcdwxlpqe\",\"cdnEnabled\":false,\"cdnProvider\":\"khtj\",\"cdnProfile\":\"i\",\"provisioningState\":\"wfqatmtd\",\"resourceState\":\"Scaling\",\"freeTrialEndTime\":\"2021-07-31T11:53:57Z\",\"created\":\"2021-08-05T12:13:03Z\",\"lastModified\":\"2021-01-21T23:13:20Z\"},\"sku\":{\"name\":\"zywkb\",\"capacity\":1291517950},\"location\":\"yuzhlhkjoqrvq\",\"tags\":{\"inrvgoupmfi\":\"t\",\"x\":\"bfggjioolvr\",\"kkgll\":\"v\",\"uhbxvvy\":\"wjygvjayvblmhvk\"},\"id\":\"gsopbyrqufegxu\",\"name\":\"wz\",\"type\":\"bnhlmc\"},{\"properties\":{\"description\":\"dn\",\"scaleUnits\":1262930280,\"availabilitySetName\":\"vgbmhr\",\"maxCacheAge\":2057644320658284812,\"customHostNames\":[],\"hostName\":\"jejveg\",\"cdnEnabled\":true,\"cdnProvider\":\"nai\",\"cdnProfile\":\"xccbdreaxhcex\",\"provisioningState\":\"rvqahqkghtpwi\",\"resourceState\":\"Stopping\",\"freeTrialEndTime\":\"2021-01-19T12:23:33Z\",\"created\":\"2021-01-08T14:12:57Z\",\"lastModified\":\"2021-03-13T14:46:48Z\"},\"sku\":{\"name\":\"fvoow\",\"capacity\":12517918},\"location\":\"mtg\",\"tags\":{\"nsxkmcwaekrrjr\":\"pyostronzmyhgfi\",\"jglikkxwslolb\":\"afxtsgum\",\"elfk\":\"pvuzlmv\",\"njwmwkpnbsazejj\":\"gplcrpwjxeznoigb\"},\"id\":\"qkagfhsxt\",\"name\":\"augzxnfaazpxdtn\",\"type\":\"dm\"},{\"properties\":{\"description\":\"jlwuenvrkp\",\"scaleUnits\":438145341,\"availabilitySetName\":\"aibrebqaaysjkixq\",\"maxCacheAge\":6681231920346117539,\"customHostNames\":[],\"hostName\":\"lwfffi\",\"cdnEnabled\":true,\"cdnProvider\":\"pqqmted\",\"cdnProfile\":\"mmji\",\"provisioningState\":\"eozphv\",\"resourceState\":\"Running\",\"freeTrialEndTime\":\"2021-08-16T03:21:06Z\",\"created\":\"2021-10-02T04:16:44Z\",\"lastModified\":\"2021-10-28T19:56:48Z\"},\"sku\":{\"name\":\"ipmdscwx\",\"capacity\":2130918233},\"location\":\"evzhfsto\",\"tags\":{\"lmcuvhixb\":\"ojujbyp\",\"ttpkiwkkbnujrywv\":\"xyfwnylrcool\",\"bfpncurdo\":\"y\",\"cbihwqk\":\"wiithtywub\"},\"id\":\"fdntwjchrdgoih\",\"name\":\"umwctondz\",\"type\":\"luudfdlwggytsb\"},{\"properties\":{\"description\":\"vvt\",\"scaleUnits\":10157721,\"availabilitySetName\":\"inqfiufxqknpirgn\",\"maxCacheAge\":7308969915106347578,\"customHostNames\":[],\"hostName\":\"sniffc\",\"cdnEnabled\":true,\"cdnProvider\":\"r\",\"cdnProfile\":\"lpijnkrxfrd\",\"provisioningState\":\"c\",\"resourceState\":\"Deleting\",\"freeTrialEndTime\":\"2021-08-13T20:41:57Z\",\"created\":\"2021-06-27T16:40:41Z\",\"lastModified\":\"2021-05-12T01:29:29Z\"},\"sku\":{\"name\":\"ft\",\"capacity\":1206467391},\"location\":\"yzhftwesgogczh\",\"tags\":{\"gnyhmossxkkg\":\"xkr\",\"rghxjb\":\"h\",\"rnsvbuswd\":\"hqxvcxgfrpdsofbs\",\"ybycnunvj\":\"z\"},\"id\":\"rtkfawnopq\",\"name\":\"ikyzirtxdy\",\"type\":\"x\"}],\"@odata.count\":1444158285,\"@odata.nextLink\":\"tpsew\"}")
                .toObject(StreamingEndpointListResult.class);
        Assertions.assertEquals("yuzhlhkjoqrvq", model.value().get(0).location());
        Assertions.assertEquals("t", model.value().get(0).tags().get("inrvgoupmfi"));
        Assertions.assertEquals(1291517950, model.value().get(0).sku().capacity());
        Assertions.assertEquals("wkyhkobopgxe", model.value().get(0).description());
        Assertions.assertEquals(222452990, model.value().get(0).scaleUnits());
        Assertions.assertEquals("wep", model.value().get(0).availabilitySetName());
        Assertions.assertEquals(2106784928647085013L, model.value().get(0).maxCacheAge());
        Assertions.assertEquals(false, model.value().get(0).cdnEnabled());
        Assertions.assertEquals("khtj", model.value().get(0).cdnProvider());
        Assertions.assertEquals("i", model.value().get(0).cdnProfile());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        StreamingEndpointListResult model =
            new StreamingEndpointListResult()
                .withValue(
                    Arrays
                        .asList(
                            new StreamingEndpointInner()
                                .withLocation("yuzhlhkjoqrvq")
                                .withTags(
                                    mapOf(
                                        "inrvgoupmfi",
                                        "t",
                                        "x",
                                        "bfggjioolvr",
                                        "kkgll",
                                        "v",
                                        "uhbxvvy",
                                        "wjygvjayvblmhvk"))
                                .withSku(new ArmStreamingEndpointCurrentSku().withCapacity(1291517950))
                                .withDescription("wkyhkobopgxe")
                                .withScaleUnits(222452990)
                                .withAvailabilitySetName("wep")
                                .withMaxCacheAge(2106784928647085013L)
                                .withCustomHostNames(Arrays.asList())
                                .withCdnEnabled(false)
                                .withCdnProvider("khtj")
                                .withCdnProfile("i"),
                            new StreamingEndpointInner()
                                .withLocation("mtg")
                                .withTags(
                                    mapOf(
                                        "nsxkmcwaekrrjr",
                                        "pyostronzmyhgfi",
                                        "jglikkxwslolb",
                                        "afxtsgum",
                                        "elfk",
                                        "pvuzlmv",
                                        "njwmwkpnbsazejj",
                                        "gplcrpwjxeznoigb"))
                                .withSku(new ArmStreamingEndpointCurrentSku().withCapacity(12517918))
                                .withDescription("dn")
                                .withScaleUnits(1262930280)
                                .withAvailabilitySetName("vgbmhr")
                                .withMaxCacheAge(2057644320658284812L)
                                .withCustomHostNames(Arrays.asList())
                                .withCdnEnabled(true)
                                .withCdnProvider("nai")
                                .withCdnProfile("xccbdreaxhcex"),
                            new StreamingEndpointInner()
                                .withLocation("evzhfsto")
                                .withTags(
                                    mapOf(
                                        "lmcuvhixb",
                                        "ojujbyp",
                                        "ttpkiwkkbnujrywv",
                                        "xyfwnylrcool",
                                        "bfpncurdo",
                                        "y",
                                        "cbihwqk",
                                        "wiithtywub"))
                                .withSku(new ArmStreamingEndpointCurrentSku().withCapacity(2130918233))
                                .withDescription("jlwuenvrkp")
                                .withScaleUnits(438145341)
                                .withAvailabilitySetName("aibrebqaaysjkixq")
                                .withMaxCacheAge(6681231920346117539L)
                                .withCustomHostNames(Arrays.asList())
                                .withCdnEnabled(true)
                                .withCdnProvider("pqqmted")
                                .withCdnProfile("mmji"),
                            new StreamingEndpointInner()
                                .withLocation("yzhftwesgogczh")
                                .withTags(
                                    mapOf(
                                        "gnyhmossxkkg",
                                        "xkr",
                                        "rghxjb",
                                        "h",
                                        "rnsvbuswd",
                                        "hqxvcxgfrpdsofbs",
                                        "ybycnunvj",
                                        "z"))
                                .withSku(new ArmStreamingEndpointCurrentSku().withCapacity(1206467391))
                                .withDescription("vvt")
                                .withScaleUnits(10157721)
                                .withAvailabilitySetName("inqfiufxqknpirgn")
                                .withMaxCacheAge(7308969915106347578L)
                                .withCustomHostNames(Arrays.asList())
                                .withCdnEnabled(true)
                                .withCdnProvider("r")
                                .withCdnProfile("lpijnkrxfrd")));
        model = BinaryData.fromObject(model).toObject(StreamingEndpointListResult.class);
        Assertions.assertEquals("yuzhlhkjoqrvq", model.value().get(0).location());
        Assertions.assertEquals("t", model.value().get(0).tags().get("inrvgoupmfi"));
        Assertions.assertEquals(1291517950, model.value().get(0).sku().capacity());
        Assertions.assertEquals("wkyhkobopgxe", model.value().get(0).description());
        Assertions.assertEquals(222452990, model.value().get(0).scaleUnits());
        Assertions.assertEquals("wep", model.value().get(0).availabilitySetName());
        Assertions.assertEquals(2106784928647085013L, model.value().get(0).maxCacheAge());
        Assertions.assertEquals(false, model.value().get(0).cdnEnabled());
        Assertions.assertEquals("khtj", model.value().get(0).cdnProvider());
        Assertions.assertEquals("i", model.value().get(0).cdnProfile());
    }

    @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;
    }
}
