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

package com.azure.resourcemanager.hybridcontainerservice.generated;

import com.azure.core.credential.AccessToken;
import com.azure.core.http.HttpClient;
import com.azure.core.http.HttpHeaders;
import com.azure.core.http.HttpRequest;
import com.azure.core.http.HttpResponse;
import com.azure.core.management.AzureEnvironment;
import com.azure.core.management.profile.AzureProfile;
import com.azure.resourcemanager.hybridcontainerservice.HybridContainerServiceManager;
import com.azure.resourcemanager.hybridcontainerservice.models.LicenseType;
import com.azure.resourcemanager.hybridcontainerservice.models.LoadBalancerSku;
import com.azure.resourcemanager.hybridcontainerservice.models.Mode;
import com.azure.resourcemanager.hybridcontainerservice.models.NetworkPolicy;
import com.azure.resourcemanager.hybridcontainerservice.models.OsType;
import com.azure.resourcemanager.hybridcontainerservice.models.ProvisionedClustersResponse;
import com.azure.resourcemanager.hybridcontainerservice.models.ResourceIdentityType;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.time.OffsetDateTime;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

public final class ProvisionedClustersOperationsGetByResourceGroupWithResponseMockTests {
    @Test
    public void testGetByResourceGroupWithResponse() throws Exception {
        HttpClient httpClient = Mockito.mock(HttpClient.class);
        HttpResponse httpResponse = Mockito.mock(HttpResponse.class);
        ArgumentCaptor<HttpRequest> httpRequest = ArgumentCaptor.forClass(HttpRequest.class);

        String responseStr =
            "{\"identity\":{\"principalId\":\"ayuhqlbjbsy\",\"tenantId\":\"qwrvtldgmfp\",\"type\":\"None\"},\"properties\":{\"enableRbac\":true,\"linuxProfile\":{\"adminUsername\":\"slthaq\"},\"features\":{},\"addonProfiles\":{},\"controlPlane\":{\"name\":\"dsrezpdrhneuyow\",\"count\":150720980,\"availabilityZones\":[],\"maxCount\":110101001,\"maxPods\":174588693,\"minCount\":431891008,\"mode\":\"System\",\"nodeLabels\":{},\"nodeTaints\":[],\"osType\":\"Windows\",\"nodeImageVersion\":\"pzimejzanlfzxi\",\"vmSize\":\"rmbzo\"},\"kubernetesVersion\":\"i\",\"networkProfile\":{\"loadBalancerSku\":\"stacked-kube-vip\",\"dnsServiceIP\":\"rgz\",\"networkPolicy\":\"flannel\",\"podCidr\":\"azszrnwoiindfpw\",\"podCidrs\":[],\"serviceCidr\":\"lwbtlhf\",\"serviceCidrs\":[]},\"nodeResourceGroup\":\"cdhszf\",\"agentPoolProfiles\":[],\"cloudProviderProfile\":{},\"provisioningState\":\"Canceled\",\"status\":{\"addonStatus\":{},\"errorMessage\":\"rqmq\"},\"aadProfile\":{\"adminGroupObjectIDs\":[],\"clientAppID\":\"iiiojnalghf\",\"enableAzureRbac\":true,\"managed\":false,\"serverAppID\":\"xsowu\",\"tenantID\":\"uqhhahhxvrh\"},\"windowsProfile\":{\"adminUsername\":\"wpjgwws\",\"enableCsiProxy\":true,\"licenseType\":\"None\"},\"httpProxyConfig\":{\"httpProxy\":\"sxhqxujx\",\"httpsProxy\":\"ndxdigrjguufzdm\",\"noProxy\":[],\"trustedCa\":\"tfih\",\"username\":\"botzingamvppho\"}},\"extendedLocation\":{\"type\":\"udphqamvdkfwyn\",\"name\":\"vtbvkayh\"},\"location\":\"tnvyqiatkzwp\",\"tags\":{\"jguq\":\"wzcjaesgvvsccy\"},\"id\":\"hwyg\",\"name\":\"lvdnkfx\",\"type\":\"semdwzrmu\"}";

        Mockito.when(httpResponse.getStatusCode()).thenReturn(200);
        Mockito.when(httpResponse.getHeaders()).thenReturn(new HttpHeaders());
        Mockito
            .when(httpResponse.getBody())
            .thenReturn(Flux.just(ByteBuffer.wrap(responseStr.getBytes(StandardCharsets.UTF_8))));
        Mockito
            .when(httpResponse.getBodyAsByteArray())
            .thenReturn(Mono.just(responseStr.getBytes(StandardCharsets.UTF_8)));
        Mockito
            .when(httpClient.send(httpRequest.capture(), Mockito.any()))
            .thenReturn(
                Mono
                    .defer(
                        () -> {
                            Mockito.when(httpResponse.getRequest()).thenReturn(httpRequest.getValue());
                            return Mono.just(httpResponse);
                        }));

        HybridContainerServiceManager manager =
            HybridContainerServiceManager
                .configure()
                .withHttpClient(httpClient)
                .authenticate(
                    tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)),
                    new AzureProfile("", "", AzureEnvironment.AZURE));

        ProvisionedClustersResponse response =
            manager
                .provisionedClustersOperations()
                .getByResourceGroupWithResponse("ffhmouwqlgzr", "zeeyebi", com.azure.core.util.Context.NONE)
                .getValue();

        Assertions.assertEquals("tnvyqiatkzwp", response.location());
        Assertions.assertEquals("wzcjaesgvvsccy", response.tags().get("jguq"));
        Assertions.assertEquals(ResourceIdentityType.NONE, response.identity().type());
        Assertions.assertEquals("iiiojnalghf", response.properties().aadProfile().clientAppId());
        Assertions.assertEquals(true, response.properties().aadProfile().enableAzureRbac());
        Assertions.assertEquals(false, response.properties().aadProfile().managed());
        Assertions.assertEquals("xsowu", response.properties().aadProfile().serverAppId());
        Assertions.assertEquals("uqhhahhxvrh", response.properties().aadProfile().tenantId());
        Assertions.assertEquals("wpjgwws", response.properties().windowsProfile().adminUsername());
        Assertions.assertEquals(true, response.properties().windowsProfile().enableCsiProxy());
        Assertions.assertEquals(LicenseType.NONE, response.properties().windowsProfile().licenseType());
        Assertions.assertEquals("sxhqxujx", response.properties().httpProxyConfig().httpProxy());
        Assertions.assertEquals("ndxdigrjguufzdm", response.properties().httpProxyConfig().httpsProxy());
        Assertions.assertEquals("tfih", response.properties().httpProxyConfig().trustedCa());
        Assertions.assertEquals("botzingamvppho", response.properties().httpProxyConfig().username());
        Assertions.assertEquals(true, response.properties().enableRbac());
        Assertions.assertEquals("slthaq", response.properties().linuxProfile().adminUsername());
        Assertions.assertEquals(150720980, response.properties().controlPlane().count());
        Assertions.assertEquals(110101001, response.properties().controlPlane().maxCount());
        Assertions.assertEquals(174588693, response.properties().controlPlane().maxPods());
        Assertions.assertEquals(431891008, response.properties().controlPlane().minCount());
        Assertions.assertEquals(Mode.SYSTEM, response.properties().controlPlane().mode());
        Assertions.assertEquals(OsType.WINDOWS, response.properties().controlPlane().osType());
        Assertions.assertEquals("pzimejzanlfzxi", response.properties().controlPlane().nodeImageVersion());
        Assertions.assertEquals("rmbzo", response.properties().controlPlane().vmSize());
        Assertions.assertEquals("dsrezpdrhneuyow", response.properties().controlPlane().name());
        Assertions.assertEquals("i", response.properties().kubernetesVersion());
        Assertions
            .assertEquals(LoadBalancerSku.STACKED_KUBE_VIP, response.properties().networkProfile().loadBalancerSku());
        Assertions.assertEquals("rgz", response.properties().networkProfile().dnsServiceIp());
        Assertions.assertEquals(NetworkPolicy.FLANNEL, response.properties().networkProfile().networkPolicy());
        Assertions.assertEquals("azszrnwoiindfpw", response.properties().networkProfile().podCidr());
        Assertions.assertEquals("lwbtlhf", response.properties().networkProfile().serviceCidr());
        Assertions.assertEquals("cdhszf", response.properties().nodeResourceGroup());
        Assertions.assertEquals("udphqamvdkfwyn", response.extendedLocation().type());
        Assertions.assertEquals("vtbvkayh", response.extendedLocation().name());
    }
}
