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

package com.azure.resourcemanager.security.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.security.fluent.models.AutomationInner;
import com.azure.resourcemanager.security.models.AutomationList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class AutomationListTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AutomationList model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"description\":\"jpqqmted\",\"isEnabled\":false,\"scopes\":[],\"sources\":[],\"actions\":[]},\"location\":\"hyeozphvwau\",\"tags\":{\"gupkvipmdscwxq\":\"c\"},\"id\":\"pevzhfst\",\"name\":\"txhojujb\",\"type\":\"pelmcuvhixbjxyf\"},{\"properties\":{\"description\":\"lrcoolsttpki\",\"isEnabled\":false,\"scopes\":[],\"sources\":[],\"actions\":[]},\"location\":\"jrywvtylbfpnc\",\"tags\":{\"cbihwqk\":\"oiwiithtywub\",\"umwctondz\":\"fdntwjchrdgoih\"},\"id\":\"luudfdlwggytsb\",\"name\":\"tov\",\"type\":\"tgseinqfiufxqkn\"},{\"properties\":{\"description\":\"gnepttwqmsni\",\"isEnabled\":false,\"scopes\":[],\"sources\":[],\"actions\":[]},\"location\":\"nrojlpijnkr\",\"tags\":{\"nasx\":\"ddhcratizzr\"},\"id\":\"ft\",\"name\":\"zq\",\"type\":\"zh\"},{\"properties\":{\"description\":\"esgogc\",\"isEnabled\":true,\"scopes\":[],\"sources\":[],\"actions\":[]},\"location\":\"krlgnyhm\",\"tags\":{\"thrrgh\":\"xkk\",\"gf\":\"jbdhqxvc\"},\"id\":\"pdso\",\"name\":\"bshrnsvbuswd\",\"type\":\"z\"}],\"nextLink\":\"bycnunvjsrtkf\"}")
                .toObject(AutomationList.class);
        Assertions.assertEquals("hyeozphvwau", model.value().get(0).location());
        Assertions.assertEquals("c", model.value().get(0).tags().get("gupkvipmdscwxq"));
        Assertions.assertEquals("jpqqmted", model.value().get(0).description());
        Assertions.assertEquals(false, model.value().get(0).isEnabled());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AutomationList model =
            new AutomationList()
                .withValue(
                    Arrays
                        .asList(
                            new AutomationInner()
                                .withLocation("hyeozphvwau")
                                .withTags(mapOf("gupkvipmdscwxq", "c"))
                                .withDescription("jpqqmted")
                                .withIsEnabled(false)
                                .withScopes(Arrays.asList())
                                .withSources(Arrays.asList())
                                .withActions(Arrays.asList()),
                            new AutomationInner()
                                .withLocation("jrywvtylbfpnc")
                                .withTags(mapOf("cbihwqk", "oiwiithtywub", "umwctondz", "fdntwjchrdgoih"))
                                .withDescription("lrcoolsttpki")
                                .withIsEnabled(false)
                                .withScopes(Arrays.asList())
                                .withSources(Arrays.asList())
                                .withActions(Arrays.asList()),
                            new AutomationInner()
                                .withLocation("nrojlpijnkr")
                                .withTags(mapOf("nasx", "ddhcratizzr"))
                                .withDescription("gnepttwqmsni")
                                .withIsEnabled(false)
                                .withScopes(Arrays.asList())
                                .withSources(Arrays.asList())
                                .withActions(Arrays.asList()),
                            new AutomationInner()
                                .withLocation("krlgnyhm")
                                .withTags(mapOf("thrrgh", "xkk", "gf", "jbdhqxvc"))
                                .withDescription("esgogc")
                                .withIsEnabled(true)
                                .withScopes(Arrays.asList())
                                .withSources(Arrays.asList())
                                .withActions(Arrays.asList())));
        model = BinaryData.fromObject(model).toObject(AutomationList.class);
        Assertions.assertEquals("hyeozphvwau", model.value().get(0).location());
        Assertions.assertEquals("c", model.value().get(0).tags().get("gupkvipmdscwxq"));
        Assertions.assertEquals("jpqqmted", model.value().get(0).description());
        Assertions.assertEquals(false, model.value().get(0).isEnabled());
    }

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