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

public final class IntegrationAccountAgreementInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        IntegrationAccountAgreementInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"createdTime\":\"2021-07-18T04:19:58Z\",\"changedTime\":\"2021-10-19T17:51:06Z\",\"metadata\":\"dataavyvnqqyba\",\"agreementType\":\"NotSpecified\",\"hostPartner\":\"euayjkqabqgzsles\",\"guestPartner\":\"cbhernntiewdj\",\"hostIdentity\":{\"qualifier\":\"vbquwr\",\"value\":\"ehwagoh\"},\"guestIdentity\":{\"qualifier\":\"uffkmrqemvvh\",\"value\":\"xtdr\"},\"content\":{}},\"location\":\"acoebj\",\"tags\":{\"draufactkah\":\"zcjznmwcpmgua\",\"neekulfg\":\"ovajjziuxxps\",\"d\":\"lqubkwdlen\",\"pjuohminyfl\":\"utujba\"},\"id\":\"orwmduvwpklv\",\"name\":\"w\",\"type\":\"ygdxpgpqchis\"}")
                .toObject(IntegrationAccountAgreementInner.class);
        Assertions.assertEquals("acoebj", model.location());
        Assertions.assertEquals("zcjznmwcpmgua", model.tags().get("draufactkah"));
        Assertions.assertEquals(AgreementType.NOT_SPECIFIED, model.agreementType());
        Assertions.assertEquals("euayjkqabqgzsles", model.hostPartner());
        Assertions.assertEquals("cbhernntiewdj", model.guestPartner());
        Assertions.assertEquals("vbquwr", model.hostIdentity().qualifier());
        Assertions.assertEquals("ehwagoh", model.hostIdentity().value());
        Assertions.assertEquals("uffkmrqemvvh", model.guestIdentity().qualifier());
        Assertions.assertEquals("xtdr", model.guestIdentity().value());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        IntegrationAccountAgreementInner model =
            new IntegrationAccountAgreementInner()
                .withLocation("acoebj")
                .withTags(
                    mapOf(
                        "draufactkah",
                        "zcjznmwcpmgua",
                        "neekulfg",
                        "ovajjziuxxps",
                        "d",
                        "lqubkwdlen",
                        "pjuohminyfl",
                        "utujba"))
                .withMetadata("dataavyvnqqyba")
                .withAgreementType(AgreementType.NOT_SPECIFIED)
                .withHostPartner("euayjkqabqgzsles")
                .withGuestPartner("cbhernntiewdj")
                .withHostIdentity(new BusinessIdentity().withQualifier("vbquwr").withValue("ehwagoh"))
                .withGuestIdentity(new BusinessIdentity().withQualifier("uffkmrqemvvh").withValue("xtdr"))
                .withContent(new AgreementContent());
        model = BinaryData.fromObject(model).toObject(IntegrationAccountAgreementInner.class);
        Assertions.assertEquals("acoebj", model.location());
        Assertions.assertEquals("zcjznmwcpmgua", model.tags().get("draufactkah"));
        Assertions.assertEquals(AgreementType.NOT_SPECIFIED, model.agreementType());
        Assertions.assertEquals("euayjkqabqgzsles", model.hostPartner());
        Assertions.assertEquals("cbhernntiewdj", model.guestPartner());
        Assertions.assertEquals("vbquwr", model.hostIdentity().qualifier());
        Assertions.assertEquals("ehwagoh", model.hostIdentity().value());
        Assertions.assertEquals("uffkmrqemvvh", model.guestIdentity().qualifier());
        Assertions.assertEquals("xtdr", model.guestIdentity().value());
    }

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