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

package com.azure.resourcemanager.sqlvirtualmachine.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.sqlvirtualmachine.fluent.models.AvailabilityGroupListenerInner;
import com.azure.resourcemanager.sqlvirtualmachine.models.AgConfiguration;
import com.azure.resourcemanager.sqlvirtualmachine.models.LoadBalancerConfiguration;
import com.azure.resourcemanager.sqlvirtualmachine.models.MultiSubnetIpConfiguration;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class AvailabilityGroupListenerInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AvailabilityGroupListenerInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"provisioningState\":\"hq\",\"availabilityGroupName\":\"gjxpybczmehmt\",\"loadBalancerConfigurations\":[{\"publicIpAddressResourceId\":\"phrupidgsybbejhp\",\"loadBalancerResourceId\":\"ycm\",\"probePort\":501010271,\"sqlVirtualMachineInstances\":[]},{\"publicIpAddressResourceId\":\"dxbmtqioq\",\"loadBalancerResourceId\":\"ehtbm\",\"probePort\":261903418,\"sqlVirtualMachineInstances\":[]},{\"publicIpAddressResourceId\":\"oizh\",\"loadBalancerResourceId\":\"rxybqsoq\",\"probePort\":1262663343,\"sqlVirtualMachineInstances\":[]}],\"multiSubnetIpConfigurations\":[{\"sqlVirtualMachineInstance\":\"bpazlobcufpdzn\"},{\"sqlVirtualMachineInstance\":\"btcqq\"},{\"sqlVirtualMachineInstance\":\"nq\"},{\"sqlVirtualMachineInstance\":\"lhqgnufooojy\"}],\"createDefaultAvailabilityGroupIfNotExist\":true,\"port\":609105572,\"availabilityGroupConfiguration\":{\"replicas\":[]}},\"id\":\"gdf\",\"name\":\"glzlhjxrifkwmrv\",\"type\":\"tsizntocipaoua\"}")
                .toObject(AvailabilityGroupListenerInner.class);
        Assertions.assertEquals("gjxpybczmehmt", model.availabilityGroupName());
        Assertions
            .assertEquals("phrupidgsybbejhp", model.loadBalancerConfigurations().get(0).publicIpAddressResourceId());
        Assertions.assertEquals("ycm", model.loadBalancerConfigurations().get(0).loadBalancerResourceId());
        Assertions.assertEquals(501010271, model.loadBalancerConfigurations().get(0).probePort());
        Assertions
            .assertEquals("bpazlobcufpdzn", model.multiSubnetIpConfigurations().get(0).sqlVirtualMachineInstance());
        Assertions.assertEquals(true, model.createDefaultAvailabilityGroupIfNotExist());
        Assertions.assertEquals(609105572, model.port());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AvailabilityGroupListenerInner model =
            new AvailabilityGroupListenerInner()
                .withAvailabilityGroupName("gjxpybczmehmt")
                .withLoadBalancerConfigurations(
                    Arrays
                        .asList(
                            new LoadBalancerConfiguration()
                                .withPublicIpAddressResourceId("phrupidgsybbejhp")
                                .withLoadBalancerResourceId("ycm")
                                .withProbePort(501010271)
                                .withSqlVirtualMachineInstances(Arrays.asList()),
                            new LoadBalancerConfiguration()
                                .withPublicIpAddressResourceId("dxbmtqioq")
                                .withLoadBalancerResourceId("ehtbm")
                                .withProbePort(261903418)
                                .withSqlVirtualMachineInstances(Arrays.asList()),
                            new LoadBalancerConfiguration()
                                .withPublicIpAddressResourceId("oizh")
                                .withLoadBalancerResourceId("rxybqsoq")
                                .withProbePort(1262663343)
                                .withSqlVirtualMachineInstances(Arrays.asList())))
                .withMultiSubnetIpConfigurations(
                    Arrays
                        .asList(
                            new MultiSubnetIpConfiguration().withSqlVirtualMachineInstance("bpazlobcufpdzn"),
                            new MultiSubnetIpConfiguration().withSqlVirtualMachineInstance("btcqq"),
                            new MultiSubnetIpConfiguration().withSqlVirtualMachineInstance("nq"),
                            new MultiSubnetIpConfiguration().withSqlVirtualMachineInstance("lhqgnufooojy")))
                .withCreateDefaultAvailabilityGroupIfNotExist(true)
                .withPort(609105572)
                .withAvailabilityGroupConfiguration(new AgConfiguration().withReplicas(Arrays.asList()));
        model = BinaryData.fromObject(model).toObject(AvailabilityGroupListenerInner.class);
        Assertions.assertEquals("gjxpybczmehmt", model.availabilityGroupName());
        Assertions
            .assertEquals("phrupidgsybbejhp", model.loadBalancerConfigurations().get(0).publicIpAddressResourceId());
        Assertions.assertEquals("ycm", model.loadBalancerConfigurations().get(0).loadBalancerResourceId());
        Assertions.assertEquals(501010271, model.loadBalancerConfigurations().get(0).probePort());
        Assertions
            .assertEquals("bpazlobcufpdzn", model.multiSubnetIpConfigurations().get(0).sqlVirtualMachineInstance());
        Assertions.assertEquals(true, model.createDefaultAvailabilityGroupIfNotExist());
        Assertions.assertEquals(609105572, model.port());
    }
}
