// 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.IntegrationAccountSchemaInner;
import com.azure.resourcemanager.logic.models.SchemaType;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class IntegrationAccountSchemaInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        IntegrationAccountSchemaInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"schemaType\":\"NotSpecified\",\"targetNamespace\":\"tjivfxzsjabib\",\"documentName\":\"stawfsdjpvkv\",\"fileName\":\"jxbkzbzkdvn\",\"createdTime\":\"2021-04-26T00:18:09Z\",\"changedTime\":\"2021-03-23T01:16:39Z\",\"metadata\":\"dataurgkakmokzhjjk\",\"content\":\"fhmouwq\",\"contentType\":\"zrfze\",\"contentLink\":{\"uri\":\"bizikayuhq\",\"contentVersion\":\"jbsybbqw\",\"contentSize\":629489002910902814,\"metadata\":\"datamfpgv\"}},\"location\":\"pip\",\"tags\":{\"wbdsr\":\"thaqfxssmwu\"},\"id\":\"zpdrhneu\",\"name\":\"owqkdwytisi\",\"type\":\"ircgpikpz\"}")
                .toObject(IntegrationAccountSchemaInner.class);
        Assertions.assertEquals("pip", model.location());
        Assertions.assertEquals("thaqfxssmwu", model.tags().get("wbdsr"));
        Assertions.assertEquals(SchemaType.NOT_SPECIFIED, model.schemaType());
        Assertions.assertEquals("tjivfxzsjabib", model.targetNamespace());
        Assertions.assertEquals("stawfsdjpvkv", model.documentName());
        Assertions.assertEquals("jxbkzbzkdvn", model.fileName());
        Assertions.assertEquals("fhmouwq", model.content());
        Assertions.assertEquals("zrfze", model.contentType());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        IntegrationAccountSchemaInner model =
            new IntegrationAccountSchemaInner()
                .withLocation("pip")
                .withTags(mapOf("wbdsr", "thaqfxssmwu"))
                .withSchemaType(SchemaType.NOT_SPECIFIED)
                .withTargetNamespace("tjivfxzsjabib")
                .withDocumentName("stawfsdjpvkv")
                .withFileName("jxbkzbzkdvn")
                .withMetadata("dataurgkakmokzhjjk")
                .withContent("fhmouwq")
                .withContentType("zrfze");
        model = BinaryData.fromObject(model).toObject(IntegrationAccountSchemaInner.class);
        Assertions.assertEquals("pip", model.location());
        Assertions.assertEquals("thaqfxssmwu", model.tags().get("wbdsr"));
        Assertions.assertEquals(SchemaType.NOT_SPECIFIED, model.schemaType());
        Assertions.assertEquals("tjivfxzsjabib", model.targetNamespace());
        Assertions.assertEquals("stawfsdjpvkv", model.documentName());
        Assertions.assertEquals("jxbkzbzkdvn", model.fileName());
        Assertions.assertEquals("fhmouwq", model.content());
        Assertions.assertEquals("zrfze", 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;
    }
}
