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

package com.azure.resourcemanager.devtestlabs.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.devtestlabs.fluent.models.NotificationChannelInner;
import com.azure.resourcemanager.devtestlabs.models.NotificationChannelList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class NotificationChannelListTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        NotificationChannelList model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"webHookUrl\":\"tedltmmj\",\"emailRecipient\":\"yeozphvwauyqncy\",\"notificationLocale\":\"p\",\"description\":\"ipmdscwx\",\"events\":[],\"createdDate\":\"2021-06-13T19:10:51Z\",\"provisioningState\":\"zhfstot\",\"uniqueIdentifier\":\"ojujbyp\"},\"location\":\"lmcuvhixb\",\"tags\":{\"yl\":\"fw\",\"ujrywvtyl\":\"coolsttpkiwkkb\"},\"id\":\"fpncurdo\",\"name\":\"wiithtywub\",\"type\":\"cbihwqk\"}],\"nextLink\":\"dntwjchrdgo\"}")
                .toObject(NotificationChannelList.class);
        Assertions.assertEquals("lmcuvhixb", model.value().get(0).location());
        Assertions.assertEquals("fw", model.value().get(0).tags().get("yl"));
        Assertions.assertEquals("tedltmmj", model.value().get(0).webhookUrl());
        Assertions.assertEquals("yeozphvwauyqncy", model.value().get(0).emailRecipient());
        Assertions.assertEquals("p", model.value().get(0).notificationLocale());
        Assertions.assertEquals("ipmdscwx", model.value().get(0).description());
        Assertions.assertEquals("dntwjchrdgo", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        NotificationChannelList model =
            new NotificationChannelList()
                .withValue(
                    Arrays
                        .asList(
                            new NotificationChannelInner()
                                .withLocation("lmcuvhixb")
                                .withTags(mapOf("yl", "fw", "ujrywvtyl", "coolsttpkiwkkb"))
                                .withWebhookUrl("tedltmmj")
                                .withEmailRecipient("yeozphvwauyqncy")
                                .withNotificationLocale("p")
                                .withDescription("ipmdscwx")
                                .withEvents(Arrays.asList())))
                .withNextLink("dntwjchrdgo");
        model = BinaryData.fromObject(model).toObject(NotificationChannelList.class);
        Assertions.assertEquals("lmcuvhixb", model.value().get(0).location());
        Assertions.assertEquals("fw", model.value().get(0).tags().get("yl"));
        Assertions.assertEquals("tedltmmj", model.value().get(0).webhookUrl());
        Assertions.assertEquals("yeozphvwauyqncy", model.value().get(0).emailRecipient());
        Assertions.assertEquals("p", model.value().get(0).notificationLocale());
        Assertions.assertEquals("ipmdscwx", model.value().get(0).description());
        Assertions.assertEquals("dntwjchrdgo", model.nextLink());
    }

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