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

package com.azure.resourcemanager.paloaltonetworks.ngfw.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.EndpointConfiguration;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.FrontendSetting;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.IpAddress;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.ProtocolType;
import org.junit.jupiter.api.Assertions;

public final class FrontendSettingTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        FrontendSetting model =
            BinaryData
                .fromString(
                    "{\"name\":\"jabudurgkakmo\",\"protocol\":\"UDP\",\"frontendConfiguration\":{\"port\":\"hjjklff\",\"address\":{\"resourceId\":\"ouw\",\"address\":\"gzrf\"}},\"backendConfiguration\":{\"port\":\"eeyebi\",\"address\":{\"resourceId\":\"kayuhqlbjbs\",\"address\":\"bqwrvtldgm\"}}}")
                .toObject(FrontendSetting.class);
        Assertions.assertEquals("jabudurgkakmo", model.name());
        Assertions.assertEquals(ProtocolType.UDP, model.protocol());
        Assertions.assertEquals("hjjklff", model.frontendConfiguration().port());
        Assertions.assertEquals("ouw", model.frontendConfiguration().address().resourceId());
        Assertions.assertEquals("gzrf", model.frontendConfiguration().address().address());
        Assertions.assertEquals("eeyebi", model.backendConfiguration().port());
        Assertions.assertEquals("kayuhqlbjbs", model.backendConfiguration().address().resourceId());
        Assertions.assertEquals("bqwrvtldgm", model.backendConfiguration().address().address());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        FrontendSetting model =
            new FrontendSetting()
                .withName("jabudurgkakmo")
                .withProtocol(ProtocolType.UDP)
                .withFrontendConfiguration(
                    new EndpointConfiguration()
                        .withPort("hjjklff")
                        .withAddress(new IpAddress().withResourceId("ouw").withAddress("gzrf")))
                .withBackendConfiguration(
                    new EndpointConfiguration()
                        .withPort("eeyebi")
                        .withAddress(new IpAddress().withResourceId("kayuhqlbjbs").withAddress("bqwrvtldgm")));
        model = BinaryData.fromObject(model).toObject(FrontendSetting.class);
        Assertions.assertEquals("jabudurgkakmo", model.name());
        Assertions.assertEquals(ProtocolType.UDP, model.protocol());
        Assertions.assertEquals("hjjklff", model.frontendConfiguration().port());
        Assertions.assertEquals("ouw", model.frontendConfiguration().address().resourceId());
        Assertions.assertEquals("gzrf", model.frontendConfiguration().address().address());
        Assertions.assertEquals("eeyebi", model.backendConfiguration().port());
        Assertions.assertEquals("kayuhqlbjbs", model.backendConfiguration().address().resourceId());
        Assertions.assertEquals("bqwrvtldgm", model.backendConfiguration().address().address());
    }
}
