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

package com.azure.resourcemanager.logic.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.logic.fluent.models.IntegrationAccountMapInner;
import com.azure.resourcemanager.logic.models.IntegrationAccountMapPropertiesParametersSchema;
import com.azure.resourcemanager.logic.models.MapType;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class IntegrationAccountMapInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        IntegrationAccountMapInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"mapType\":\"NotSpecified\",\"parametersSchema\":{\"ref\":\"nai\"},\"createdTime\":\"2021-09-08T02:56:48Z\",\"changedTime\":\"2021-07-11T23:25:50Z\",\"content\":\"dreaxh\",\"contentType\":\"xdrrvqahqkghtp\",\"contentLink\":{\"uri\":\"nhyjsv\",\"contentVersion\":\"cxzbfvoowvr\",\"contentSize\":278153886100525858,\"metadata\":\"datappyostronzmyhgf\"},\"metadata\":\"datansxkmcwaekrrjr\"},\"location\":\"afxtsgum\",\"tags\":{\"xwslolbqpv\":\"lik\",\"crpw\":\"zlmvfelfktgp\",\"brnjwmw\":\"xeznoi\"},\"id\":\"pn\",\"name\":\"saz\",\"type\":\"jjoqkagf\"}")
                .toObject(IntegrationAccountMapInner.class);
        Assertions.assertEquals("afxtsgum", model.location());
        Assertions.assertEquals("lik", model.tags().get("xwslolbqpv"));
        Assertions.assertEquals(MapType.NOT_SPECIFIED, model.mapType());
        Assertions.assertEquals("nai", model.parametersSchema().ref());
        Assertions.assertEquals("dreaxh", model.content());
        Assertions.assertEquals("xdrrvqahqkghtp", model.contentType());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        IntegrationAccountMapInner model =
            new IntegrationAccountMapInner()
                .withLocation("afxtsgum")
                .withTags(mapOf("xwslolbqpv", "lik", "crpw", "zlmvfelfktgp", "brnjwmw", "xeznoi"))
                .withMapType(MapType.NOT_SPECIFIED)
                .withParametersSchema(new IntegrationAccountMapPropertiesParametersSchema().withRef("nai"))
                .withContent("dreaxh")
                .withContentType("xdrrvqahqkghtp")
                .withMetadata("datansxkmcwaekrrjr");
        model = BinaryData.fromObject(model).toObject(IntegrationAccountMapInner.class);
        Assertions.assertEquals("afxtsgum", model.location());
        Assertions.assertEquals("lik", model.tags().get("xwslolbqpv"));
        Assertions.assertEquals(MapType.NOT_SPECIFIED, model.mapType());
        Assertions.assertEquals("nai", model.parametersSchema().ref());
        Assertions.assertEquals("dreaxh", model.content());
        Assertions.assertEquals("xdrrvqahqkghtp", model.contentType());
    }

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