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

package com.azure.resourcemanager.apimanagement.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.apimanagement.models.BodyDiagnosticSettings;
import com.azure.resourcemanager.apimanagement.models.DataMasking;
import com.azure.resourcemanager.apimanagement.models.DataMaskingEntity;
import com.azure.resourcemanager.apimanagement.models.DataMaskingMode;
import com.azure.resourcemanager.apimanagement.models.HttpMessageDiagnostic;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class HttpMessageDiagnosticTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        HttpMessageDiagnostic model =
            BinaryData
                .fromString(
                    "{\"headers\":[\"eluclvdjj\",\"kyrdnqodx\",\"hhxhq\"],\"body\":{\"bytes\":1091282824},\"dataMasking\":{\"queryParams\":[{\"value\":\"gyipem\",\"mode\":\"Hide\"},{\"value\":\"v\",\"mode\":\"Mask\"},{\"value\":\"ejdtxptl\",\"mode\":\"Hide\"},{\"value\":\"homewjjstliu\",\"mode\":\"Mask\"}],\"headers\":[{\"value\":\"aiancznvodr\",\"mode\":\"Hide\"},{\"value\":\"lxydkxrxv\",\"mode\":\"Hide\"}]}}")
                .toObject(HttpMessageDiagnostic.class);
        Assertions.assertEquals("eluclvdjj", model.headers().get(0));
        Assertions.assertEquals(1091282824, model.body().bytes());
        Assertions.assertEquals("gyipem", model.dataMasking().queryParams().get(0).value());
        Assertions.assertEquals(DataMaskingMode.HIDE, model.dataMasking().queryParams().get(0).mode());
        Assertions.assertEquals("aiancznvodr", model.dataMasking().headers().get(0).value());
        Assertions.assertEquals(DataMaskingMode.HIDE, model.dataMasking().headers().get(0).mode());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        HttpMessageDiagnostic model =
            new HttpMessageDiagnostic()
                .withHeaders(Arrays.asList("eluclvdjj", "kyrdnqodx", "hhxhq"))
                .withBody(new BodyDiagnosticSettings().withBytes(1091282824))
                .withDataMasking(
                    new DataMasking()
                        .withQueryParams(
                            Arrays
                                .asList(
                                    new DataMaskingEntity().withValue("gyipem").withMode(DataMaskingMode.HIDE),
                                    new DataMaskingEntity().withValue("v").withMode(DataMaskingMode.MASK),
                                    new DataMaskingEntity().withValue("ejdtxptl").withMode(DataMaskingMode.HIDE),
                                    new DataMaskingEntity().withValue("homewjjstliu").withMode(DataMaskingMode.MASK)))
                        .withHeaders(
                            Arrays
                                .asList(
                                    new DataMaskingEntity().withValue("aiancznvodr").withMode(DataMaskingMode.HIDE),
                                    new DataMaskingEntity().withValue("lxydkxrxv").withMode(DataMaskingMode.HIDE))));
        model = BinaryData.fromObject(model).toObject(HttpMessageDiagnostic.class);
        Assertions.assertEquals("eluclvdjj", model.headers().get(0));
        Assertions.assertEquals(1091282824, model.body().bytes());
        Assertions.assertEquals("gyipem", model.dataMasking().queryParams().get(0).value());
        Assertions.assertEquals(DataMaskingMode.HIDE, model.dataMasking().queryParams().get(0).mode());
        Assertions.assertEquals("aiancznvodr", model.dataMasking().headers().get(0).value());
        Assertions.assertEquals(DataMaskingMode.HIDE, model.dataMasking().headers().get(0).mode());
    }
}
