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

public final class IntegrationAccountPartnerInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        IntegrationAccountPartnerInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"partnerType\":\"B2B\",\"createdTime\":\"2021-06-14T15:38:54Z\",\"changedTime\":\"2021-03-22T22:49:04Z\",\"metadata\":\"dataxnbkfezzxscyhwzd\",\"content\":{}},\"location\":\"rujbzbomvzzbtdc\",\"tags\":{\"ylwdshfssn\":\"niyujv\",\"rymsgaojfmw\":\"bgye\",\"hirctymoxoftpipi\":\"cotmr\"},\"id\":\"yczuhxacpq\",\"name\":\"lihhyuspskasdvlm\",\"type\":\"wdgzxulucv\"}")
                .toObject(IntegrationAccountPartnerInner.class);
        Assertions.assertEquals("rujbzbomvzzbtdc", model.location());
        Assertions.assertEquals("niyujv", model.tags().get("ylwdshfssn"));
        Assertions.assertEquals(PartnerType.B2B, model.partnerType());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        IntegrationAccountPartnerInner model =
            new IntegrationAccountPartnerInner()
                .withLocation("rujbzbomvzzbtdc")
                .withTags(mapOf("ylwdshfssn", "niyujv", "rymsgaojfmw", "bgye", "hirctymoxoftpipi", "cotmr"))
                .withPartnerType(PartnerType.B2B)
                .withMetadata("dataxnbkfezzxscyhwzd")
                .withContent(new PartnerContent());
        model = BinaryData.fromObject(model).toObject(IntegrationAccountPartnerInner.class);
        Assertions.assertEquals("rujbzbomvzzbtdc", model.location());
        Assertions.assertEquals("niyujv", model.tags().get("ylwdshfssn"));
        Assertions.assertEquals(PartnerType.B2B, model.partnerType());
    }

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