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

package com.azure.resourcemanager.netapp.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.netapp.fluent.models.SnapshotPolicyInner;
import com.azure.resourcemanager.netapp.models.SnapshotPoliciesList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class SnapshotPoliciesListTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        SnapshotPoliciesList model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"etag\":\"yaw\",\"properties\":{\"enabled\":true,\"provisioningState\":\"yjpkiidzyexz\"},\"location\":\"lixhnrztfol\",\"tags\":{\"dtpnapnyiropuhp\":\"xknalaulppg\",\"gqgitxmedjvcsl\":\"gvpgy\",\"wwncwzzhxgk\":\"n\"},\"id\":\"rmgucnap\",\"name\":\"t\",\"type\":\"oellwp\"},{\"etag\":\"d\",\"properties\":{\"enabled\":true,\"provisioningState\":\"ceopzfqrhhuaopp\"},\"location\":\"qeqxo\",\"tags\":{\"moizpos\":\"ahzxctobgbk\",\"rmfqjhhkxbpvj\":\"mgrcfbu\",\"xjyngudivk\":\"mjh\"},\"id\":\"tswb\",\"name\":\"qzvszjf\",\"type\":\"uvjfdxxive\"},{\"etag\":\"t\",\"properties\":{\"enabled\":true,\"provisioningState\":\"mcbxvwvxysl\"},\"location\":\"hsfxoblytkb\",\"tags\":{\"hqjohxcrsbfova\":\"ewwwfbkrvrnsv\"},\"id\":\"rruvwbhsq\",\"name\":\"sub\",\"type\":\"gjb\"}]}")
                .toObject(SnapshotPoliciesList.class);
        Assertions.assertEquals("lixhnrztfol", model.value().get(0).location());
        Assertions.assertEquals("xknalaulppg", model.value().get(0).tags().get("dtpnapnyiropuhp"));
        Assertions.assertEquals(true, model.value().get(0).enabled());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        SnapshotPoliciesList model =
            new SnapshotPoliciesList()
                .withValue(
                    Arrays
                        .asList(
                            new SnapshotPolicyInner()
                                .withLocation("lixhnrztfol")
                                .withTags(
                                    mapOf(
                                        "dtpnapnyiropuhp",
                                        "xknalaulppg",
                                        "gqgitxmedjvcsl",
                                        "gvpgy",
                                        "wwncwzzhxgk",
                                        "n"))
                                .withEnabled(true),
                            new SnapshotPolicyInner()
                                .withLocation("qeqxo")
                                .withTags(
                                    mapOf("moizpos", "ahzxctobgbk", "rmfqjhhkxbpvj", "mgrcfbu", "xjyngudivk", "mjh"))
                                .withEnabled(true),
                            new SnapshotPolicyInner()
                                .withLocation("hsfxoblytkb")
                                .withTags(mapOf("hqjohxcrsbfova", "ewwwfbkrvrnsv"))
                                .withEnabled(true)));
        model = BinaryData.fromObject(model).toObject(SnapshotPoliciesList.class);
        Assertions.assertEquals("lixhnrztfol", model.value().get(0).location());
        Assertions.assertEquals("xknalaulppg", model.value().get(0).tags().get("dtpnapnyiropuhp"));
        Assertions.assertEquals(true, model.value().get(0).enabled());
    }

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