// 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.IntegrationAccountAgreementProperties;
import com.azure.resourcemanager.logic.models.AS2AgreementContent;
import com.azure.resourcemanager.logic.models.AgreementContent;
import com.azure.resourcemanager.logic.models.AgreementType;
import com.azure.resourcemanager.logic.models.BusinessIdentity;
import com.azure.resourcemanager.logic.models.EdifactAgreementContent;
import com.azure.resourcemanager.logic.models.X12AgreementContent;
import org.junit.jupiter.api.Assertions;

public final class IntegrationAccountAgreementPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        IntegrationAccountAgreementProperties model =
            BinaryData
                .fromString(
                    "{\"createdTime\":\"2021-05-26T11:43:30Z\",\"changedTime\":\"2021-04-10T21:01:23Z\",\"metadata\":\"datajcrxgibbdaxcon\",\"agreementType\":\"Edifact\",\"hostPartner\":\"zauorsuk\",\"guestPartner\":\"kwbqplhlvnuu\",\"hostIdentity\":{\"qualifier\":\"pzlrphw\",\"value\":\"soldweyuqdunv\"},\"guestIdentity\":{\"qualifier\":\"nnrwrbiork\",\"value\":\"alywjhhgdn\"},\"content\":{\"aS2\":{},\"x12\":{},\"edifact\":{}}}")
                .toObject(IntegrationAccountAgreementProperties.class);
        Assertions.assertEquals(AgreementType.EDIFACT, model.agreementType());
        Assertions.assertEquals("zauorsuk", model.hostPartner());
        Assertions.assertEquals("kwbqplhlvnuu", model.guestPartner());
        Assertions.assertEquals("pzlrphw", model.hostIdentity().qualifier());
        Assertions.assertEquals("soldweyuqdunv", model.hostIdentity().value());
        Assertions.assertEquals("nnrwrbiork", model.guestIdentity().qualifier());
        Assertions.assertEquals("alywjhhgdn", model.guestIdentity().value());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        IntegrationAccountAgreementProperties model =
            new IntegrationAccountAgreementProperties()
                .withMetadata("datajcrxgibbdaxcon")
                .withAgreementType(AgreementType.EDIFACT)
                .withHostPartner("zauorsuk")
                .withGuestPartner("kwbqplhlvnuu")
                .withHostIdentity(new BusinessIdentity().withQualifier("pzlrphw").withValue("soldweyuqdunv"))
                .withGuestIdentity(new BusinessIdentity().withQualifier("nnrwrbiork").withValue("alywjhhgdn"))
                .withContent(
                    new AgreementContent()
                        .withAS2(new AS2AgreementContent())
                        .withX12(new X12AgreementContent())
                        .withEdifact(new EdifactAgreementContent()));
        model = BinaryData.fromObject(model).toObject(IntegrationAccountAgreementProperties.class);
        Assertions.assertEquals(AgreementType.EDIFACT, model.agreementType());
        Assertions.assertEquals("zauorsuk", model.hostPartner());
        Assertions.assertEquals("kwbqplhlvnuu", model.guestPartner());
        Assertions.assertEquals("pzlrphw", model.hostIdentity().qualifier());
        Assertions.assertEquals("soldweyuqdunv", model.hostIdentity().value());
        Assertions.assertEquals("nnrwrbiork", model.guestIdentity().qualifier());
        Assertions.assertEquals("alywjhhgdn", model.guestIdentity().value());
    }
}
