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

package com.azure.resourcemanager.attestation.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.attestation.fluent.models.AttestationProviderInner;
import com.azure.resourcemanager.attestation.fluent.models.AttestationProviderListResultInner;
import com.azure.resourcemanager.attestation.models.AttestationServiceStatus;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class AttestationProviderListResultInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AttestationProviderListResultInner model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"trustModel\":\"xyqj\",\"status\":\"Error\",\"attestUri\":\"t\",\"privateEndpointConnections\":[]},\"location\":\"ngj\",\"tags\":{\"ajvnysounqe\":\"czsqpjhvm\",\"oaeupfhyhltrpmo\":\"a\"},\"id\":\"jmcmatuokthfu\",\"name\":\"uaodsfcpk\",\"type\":\"xodpuozmyzydagfu\"},{\"properties\":{\"trustModel\":\"zyiuokk\",\"status\":\"Ready\",\"attestUri\":\"dxwzywqsmbsurexi\",\"privateEndpointConnections\":[]},\"location\":\"ryocfsfksymdd\",\"tags\":{\"qn\":\"kiiuxhqyudxor\"},\"id\":\"poczvyifqrvkdvjs\",\"name\":\"lrmv\",\"type\":\"d\"},{\"properties\":{\"trustModel\":\"kpnpulexxbczwtr\",\"status\":\"Ready\",\"attestUri\":\"zb\",\"privateEndpointConnections\":[]},\"location\":\"vsovmyokac\",\"tags\":{\"hzdobpxjmflbvvnc\":\"w\",\"rsa\":\"rkcciwwzjuqk\"},\"id\":\"iwkuofos\",\"name\":\"ghsauuimjmvxied\",\"type\":\"ugidyjrr\"},{\"properties\":{\"trustModel\":\"osvexcsonpclhoc\",\"status\":\"Error\",\"attestUri\":\"kevle\",\"privateEndpointConnections\":[]},\"location\":\"zfbuhf\",\"tags\":{\"th\":\"axkffei\",\"shxmzsbbzoggigrx\":\"vmezy\",\"ptkoenkoukn\":\"burvjxxjnspy\"},\"id\":\"udwtiukbl\",\"name\":\"ngkpocipazy\",\"type\":\"o\"}]}")
                .toObject(AttestationProviderListResultInner.class);
        Assertions.assertEquals("ngj", model.value().get(0).location());
        Assertions.assertEquals("czsqpjhvm", model.value().get(0).tags().get("ajvnysounqe"));
        Assertions.assertEquals("xyqj", model.value().get(0).trustModel());
        Assertions.assertEquals(AttestationServiceStatus.ERROR, model.value().get(0).status());
        Assertions.assertEquals("t", model.value().get(0).attestUri());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AttestationProviderListResultInner model =
            new AttestationProviderListResultInner()
                .withValue(
                    Arrays
                        .asList(
                            new AttestationProviderInner()
                                .withLocation("ngj")
                                .withTags(mapOf("ajvnysounqe", "czsqpjhvm", "oaeupfhyhltrpmo", "a"))
                                .withTrustModel("xyqj")
                                .withStatus(AttestationServiceStatus.ERROR)
                                .withAttestUri("t"),
                            new AttestationProviderInner()
                                .withLocation("ryocfsfksymdd")
                                .withTags(mapOf("qn", "kiiuxhqyudxor"))
                                .withTrustModel("zyiuokk")
                                .withStatus(AttestationServiceStatus.READY)
                                .withAttestUri("dxwzywqsmbsurexi"),
                            new AttestationProviderInner()
                                .withLocation("vsovmyokac")
                                .withTags(mapOf("hzdobpxjmflbvvnc", "w", "rsa", "rkcciwwzjuqk"))
                                .withTrustModel("kpnpulexxbczwtr")
                                .withStatus(AttestationServiceStatus.READY)
                                .withAttestUri("zb"),
                            new AttestationProviderInner()
                                .withLocation("zfbuhf")
                                .withTags(
                                    mapOf("th", "axkffei", "shxmzsbbzoggigrx", "vmezy", "ptkoenkoukn", "burvjxxjnspy"))
                                .withTrustModel("osvexcsonpclhoc")
                                .withStatus(AttestationServiceStatus.ERROR)
                                .withAttestUri("kevle")));
        model = BinaryData.fromObject(model).toObject(AttestationProviderListResultInner.class);
        Assertions.assertEquals("ngj", model.value().get(0).location());
        Assertions.assertEquals("czsqpjhvm", model.value().get(0).tags().get("ajvnysounqe"));
        Assertions.assertEquals("xyqj", model.value().get(0).trustModel());
        Assertions.assertEquals(AttestationServiceStatus.ERROR, model.value().get(0).status());
        Assertions.assertEquals("t", model.value().get(0).attestUri());
    }

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