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

package com.azure.resourcemanager.frontdoor.generated;

import com.azure.core.management.SubResource;
import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.frontdoor.models.Backend;
import com.azure.resourcemanager.frontdoor.models.BackendEnabledState;
import com.azure.resourcemanager.frontdoor.models.BackendPoolUpdateParameters;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class BackendPoolUpdateParametersTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        BackendPoolUpdateParameters model =
            BinaryData
                .fromString(
                    "{\"backends\":[{\"address\":\"crailvpn\",\"privateLinkAlias\":\"fuflrwdmhdlx\",\"privateLinkResourceId\":\"rxsagafcnihgwqa\",\"privateLinkLocation\":\"edgfbcvkcvq\",\"privateEndpointStatus\":\"Rejected\",\"privateLinkApprovalMessage\":\"qdcvdrhvoo\",\"httpPort\":800082776,\"httpsPort\":1475281926,\"enabledState\":\"Enabled\",\"priority\":138973043,\"weight\":1257406932,\"backendHostHeader\":\"j\"},{\"address\":\"nhdldwmgxcx\",\"privateLinkAlias\":\"lpmutwuoegrpkhj\",\"privateLinkResourceId\":\"iyq\",\"privateLinkLocation\":\"uicpd\",\"privateEndpointStatus\":\"Pending\",\"privateLinkApprovalMessage\":\"zl\",\"httpPort\":553521281,\"httpsPort\":1708563012,\"enabledState\":\"Enabled\",\"priority\":950726192,\"weight\":488174706,\"backendHostHeader\":\"uefywsbpfvmwy\"},{\"address\":\"fouyf\",\"privateLinkAlias\":\"akcp\",\"privateLinkResourceId\":\"yzvqt\",\"privateLinkLocation\":\"ubex\",\"privateEndpointStatus\":\"Disconnected\",\"privateLinkApprovalMessage\":\"smond\",\"httpPort\":1007666972,\"httpsPort\":628279381,\"enabledState\":\"Disabled\",\"priority\":336917419,\"weight\":2111065372,\"backendHostHeader\":\"opkwhojv\"}],\"loadBalancingSettings\":{\"id\":\"qgxy\"},\"healthProbeSettings\":{\"id\":\"cmbqfqvmk\"}}")
                .toObject(BackendPoolUpdateParameters.class);
        Assertions.assertEquals("crailvpn", model.backends().get(0).address());
        Assertions.assertEquals("fuflrwdmhdlx", model.backends().get(0).privateLinkAlias());
        Assertions.assertEquals("rxsagafcnihgwqa", model.backends().get(0).privateLinkResourceId());
        Assertions.assertEquals("edgfbcvkcvq", model.backends().get(0).privateLinkLocation());
        Assertions.assertEquals("qdcvdrhvoo", model.backends().get(0).privateLinkApprovalMessage());
        Assertions.assertEquals(800082776, model.backends().get(0).httpPort());
        Assertions.assertEquals(1475281926, model.backends().get(0).httpsPort());
        Assertions.assertEquals(BackendEnabledState.ENABLED, model.backends().get(0).enabledState());
        Assertions.assertEquals(138973043, model.backends().get(0).priority());
        Assertions.assertEquals(1257406932, model.backends().get(0).weight());
        Assertions.assertEquals("j", model.backends().get(0).backendHostHeader());
        Assertions.assertEquals("qgxy", model.loadBalancingSettings().id());
        Assertions.assertEquals("cmbqfqvmk", model.healthProbeSettings().id());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        BackendPoolUpdateParameters model =
            new BackendPoolUpdateParameters()
                .withBackends(
                    Arrays
                        .asList(
                            new Backend()
                                .withAddress("crailvpn")
                                .withPrivateLinkAlias("fuflrwdmhdlx")
                                .withPrivateLinkResourceId("rxsagafcnihgwqa")
                                .withPrivateLinkLocation("edgfbcvkcvq")
                                .withPrivateLinkApprovalMessage("qdcvdrhvoo")
                                .withHttpPort(800082776)
                                .withHttpsPort(1475281926)
                                .withEnabledState(BackendEnabledState.ENABLED)
                                .withPriority(138973043)
                                .withWeight(1257406932)
                                .withBackendHostHeader("j"),
                            new Backend()
                                .withAddress("nhdldwmgxcx")
                                .withPrivateLinkAlias("lpmutwuoegrpkhj")
                                .withPrivateLinkResourceId("iyq")
                                .withPrivateLinkLocation("uicpd")
                                .withPrivateLinkApprovalMessage("zl")
                                .withHttpPort(553521281)
                                .withHttpsPort(1708563012)
                                .withEnabledState(BackendEnabledState.ENABLED)
                                .withPriority(950726192)
                                .withWeight(488174706)
                                .withBackendHostHeader("uefywsbpfvmwy"),
                            new Backend()
                                .withAddress("fouyf")
                                .withPrivateLinkAlias("akcp")
                                .withPrivateLinkResourceId("yzvqt")
                                .withPrivateLinkLocation("ubex")
                                .withPrivateLinkApprovalMessage("smond")
                                .withHttpPort(1007666972)
                                .withHttpsPort(628279381)
                                .withEnabledState(BackendEnabledState.DISABLED)
                                .withPriority(336917419)
                                .withWeight(2111065372)
                                .withBackendHostHeader("opkwhojv")))
                .withLoadBalancingSettings(new SubResource().withId("qgxy"))
                .withHealthProbeSettings(new SubResource().withId("cmbqfqvmk"));
        model = BinaryData.fromObject(model).toObject(BackendPoolUpdateParameters.class);
        Assertions.assertEquals("crailvpn", model.backends().get(0).address());
        Assertions.assertEquals("fuflrwdmhdlx", model.backends().get(0).privateLinkAlias());
        Assertions.assertEquals("rxsagafcnihgwqa", model.backends().get(0).privateLinkResourceId());
        Assertions.assertEquals("edgfbcvkcvq", model.backends().get(0).privateLinkLocation());
        Assertions.assertEquals("qdcvdrhvoo", model.backends().get(0).privateLinkApprovalMessage());
        Assertions.assertEquals(800082776, model.backends().get(0).httpPort());
        Assertions.assertEquals(1475281926, model.backends().get(0).httpsPort());
        Assertions.assertEquals(BackendEnabledState.ENABLED, model.backends().get(0).enabledState());
        Assertions.assertEquals(138973043, model.backends().get(0).priority());
        Assertions.assertEquals(1257406932, model.backends().get(0).weight());
        Assertions.assertEquals("j", model.backends().get(0).backendHostHeader());
        Assertions.assertEquals("qgxy", model.loadBalancingSettings().id());
        Assertions.assertEquals("cmbqfqvmk", model.healthProbeSettings().id());
    }
}
