// 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.IoTSecuritySolutionModelInner;
import com.azure.resourcemanager.security.models.IoTSecuritySolutionsList;
import com.azure.resourcemanager.security.models.SecuritySolutionStatus;
import com.azure.resourcemanager.security.models.UnmaskedIpLoggingStatus;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class IoTSecuritySolutionsListTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        IoTSecuritySolutionsList model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"location\":\"dgwdslfhot\",\"properties\":{\"workspace\":\"ynpwlbj\",\"displayName\":\"pgacftadehxnlty\",\"status\":\"Disabled\",\"export\":[],\"disabledDataSources\":[],\"iotHubs\":[],\"autoDiscoveredResources\":[],\"recommendationsConfiguration\":[],\"unmaskedIpLoggingStatus\":\"Disabled\",\"additionalWorkspaces\":[]},\"tags\":{\"avo\":\"ej\",\"vudwx\":\"xzdmohctb\"},\"id\":\"ndnvo\",\"name\":\"gujjugwdkcglh\",\"type\":\"lazjdyggdtjixhbk\"},{\"location\":\"fqweykhmene\",\"properties\":{\"workspace\":\"exfwhy\",\"displayName\":\"cibvyvdcsitynn\",\"status\":\"Disabled\",\"export\":[],\"disabledDataSources\":[],\"iotHubs\":[],\"autoDiscoveredResources\":[],\"recommendationsConfiguration\":[],\"unmaskedIpLoggingStatus\":\"Disabled\",\"additionalWorkspaces\":[]},\"tags\":{\"hezrkgq\":\"jeyp\"},\"id\":\"c\",\"name\":\"refovgmkqsleyyvx\",\"type\":\"qjpkcattpngjcrc\"},{\"location\":\"sqpjhvmdajvn\",\"properties\":{\"workspace\":\"unqecanoae\",\"displayName\":\"pfhyhl\",\"status\":\"Enabled\",\"export\":[],\"disabledDataSources\":[],\"iotHubs\":[],\"autoDiscoveredResources\":[],\"recommendationsConfiguration\":[],\"unmaskedIpLoggingStatus\":\"Disabled\",\"additionalWorkspaces\":[]},\"tags\":{\"aodsfcpkv\":\"kthfui\"},\"id\":\"odpuozmyzydag\",\"name\":\"uaxbezyiuokkt\",\"type\":\"hrdxwzywqsmbs\"}],\"nextLink\":\"exim\"}")
                .toObject(IoTSecuritySolutionsList.class);
        Assertions.assertEquals("dgwdslfhot", model.value().get(0).location());
        Assertions.assertEquals("ej", model.value().get(0).tags().get("avo"));
        Assertions.assertEquals("ynpwlbj", model.value().get(0).workspace());
        Assertions.assertEquals("pgacftadehxnlty", model.value().get(0).displayName());
        Assertions.assertEquals(SecuritySolutionStatus.DISABLED, model.value().get(0).status());
        Assertions.assertEquals(UnmaskedIpLoggingStatus.DISABLED, model.value().get(0).unmaskedIpLoggingStatus());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        IoTSecuritySolutionsList model =
            new IoTSecuritySolutionsList()
                .withValue(
                    Arrays
                        .asList(
                            new IoTSecuritySolutionModelInner()
                                .withLocation("dgwdslfhot")
                                .withTags(mapOf("avo", "ej", "vudwx", "xzdmohctb"))
                                .withWorkspace("ynpwlbj")
                                .withDisplayName("pgacftadehxnlty")
                                .withStatus(SecuritySolutionStatus.DISABLED)
                                .withExport(Arrays.asList())
                                .withDisabledDataSources(Arrays.asList())
                                .withIotHubs(Arrays.asList())
                                .withRecommendationsConfiguration(Arrays.asList())
                                .withUnmaskedIpLoggingStatus(UnmaskedIpLoggingStatus.DISABLED)
                                .withAdditionalWorkspaces(Arrays.asList()),
                            new IoTSecuritySolutionModelInner()
                                .withLocation("fqweykhmene")
                                .withTags(mapOf("hezrkgq", "jeyp"))
                                .withWorkspace("exfwhy")
                                .withDisplayName("cibvyvdcsitynn")
                                .withStatus(SecuritySolutionStatus.DISABLED)
                                .withExport(Arrays.asList())
                                .withDisabledDataSources(Arrays.asList())
                                .withIotHubs(Arrays.asList())
                                .withRecommendationsConfiguration(Arrays.asList())
                                .withUnmaskedIpLoggingStatus(UnmaskedIpLoggingStatus.DISABLED)
                                .withAdditionalWorkspaces(Arrays.asList()),
                            new IoTSecuritySolutionModelInner()
                                .withLocation("sqpjhvmdajvn")
                                .withTags(mapOf("aodsfcpkv", "kthfui"))
                                .withWorkspace("unqecanoae")
                                .withDisplayName("pfhyhl")
                                .withStatus(SecuritySolutionStatus.ENABLED)
                                .withExport(Arrays.asList())
                                .withDisabledDataSources(Arrays.asList())
                                .withIotHubs(Arrays.asList())
                                .withRecommendationsConfiguration(Arrays.asList())
                                .withUnmaskedIpLoggingStatus(UnmaskedIpLoggingStatus.DISABLED)
                                .withAdditionalWorkspaces(Arrays.asList())));
        model = BinaryData.fromObject(model).toObject(IoTSecuritySolutionsList.class);
        Assertions.assertEquals("dgwdslfhot", model.value().get(0).location());
        Assertions.assertEquals("ej", model.value().get(0).tags().get("avo"));
        Assertions.assertEquals("ynpwlbj", model.value().get(0).workspace());
        Assertions.assertEquals("pgacftadehxnlty", model.value().get(0).displayName());
        Assertions.assertEquals(SecuritySolutionStatus.DISABLED, model.value().get(0).status());
        Assertions.assertEquals(UnmaskedIpLoggingStatus.DISABLED, model.value().get(0).unmaskedIpLoggingStatus());
    }

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