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

package com.azure.resourcemanager.databricks.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.databricks.fluent.models.WorkspaceProperties;
import com.azure.resourcemanager.databricks.models.CreatedBy;
import com.azure.resourcemanager.databricks.models.EncryptionEntitiesDefinition;
import com.azure.resourcemanager.databricks.models.ManagedIdentityConfiguration;
import com.azure.resourcemanager.databricks.models.PublicNetworkAccess;
import com.azure.resourcemanager.databricks.models.RequiredNsgRules;
import com.azure.resourcemanager.databricks.models.WorkspaceCustomBooleanParameter;
import com.azure.resourcemanager.databricks.models.WorkspaceCustomParameters;
import com.azure.resourcemanager.databricks.models.WorkspaceCustomStringParameter;
import com.azure.resourcemanager.databricks.models.WorkspaceEncryptionParameter;
import com.azure.resourcemanager.databricks.models.WorkspacePropertiesEncryption;
import com.azure.resourcemanager.databricks.models.WorkspaceProviderAuthorization;
import java.util.Arrays;
import java.util.UUID;
import org.junit.jupiter.api.Assertions;

public final class WorkspacePropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        WorkspaceProperties model =
            BinaryData
                .fromString(
                    "{\"managedResourceGroupId\":\"hiv\",\"parameters\":{\"amlWorkspaceId\":{\"type\":\"Bool\",\"value\":\"b\"},\"customVirtualNetworkId\":{\"type\":\"Object\",\"value\":\"xvd\"},\"customPublicSubnetName\":{\"type\":\"Object\",\"value\":\"rtfw\"},\"customPrivateSubnetName\":{\"type\":\"String\",\"value\":\"gaudcc\"},\"enableNoPublicIp\":{\"type\":\"String\",\"value\":false},\"loadBalancerBackendPoolName\":{\"type\":\"Bool\",\"value\":\"ejhkry\"},\"loadBalancerId\":{\"type\":\"Bool\",\"value\":\"pczwlo\"},\"natGatewayName\":{\"type\":\"Object\",\"value\":\"mkkvnip\"},\"publicIpName\":{\"type\":\"String\",\"value\":\"jnchgej\"},\"prepareEncryption\":{\"type\":\"String\",\"value\":true},\"encryption\":{\"type\":\"Object\"},\"requireInfrastructureEncryption\":{\"type\":\"Bool\",\"value\":false},\"storageAccountName\":{\"type\":\"Bool\",\"value\":\"yahux\"},\"storageAccountSkuName\":{\"type\":\"String\",\"value\":\"qnjaqwix\"},\"vnetAddressPrefix\":{\"type\":\"String\",\"value\":\"ozvcput\"},\"resourceTags\":{\"type\":\"Object\",\"value\":\"datawmfdatscmdvpjhul\"}},\"provisioningState\":\"Ready\",\"uiDefinitionUri\":\"mkjozkrwf\",\"authorizations\":[{\"principalId\":\"423825c0-d7b7-43df-9531-f0a89709749a\",\"roleDefinitionId\":\"5ee36843-2071-404d-8a89-ef90b190dfbc\"},{\"principalId\":\"9943af85-f67d-4113-8d2d-ce32b16a7041\",\"roleDefinitionId\":\"158a0eb5-2a85-446f-a91c-3c8cd7b09c4e\"}],\"createdBy\":{\"oid\":\"8757365e-9e99-4485-a785-c82ecd83fe50\",\"puid\":\"pslwejdpvw\",\"applicationId\":\"c8612b79-6663-486e-876e-8cdbdaa4007b\"},\"updatedBy\":{\"oid\":\"fd76275f-1599-46e7-a79a-0311ba4af930\",\"puid\":\"soacctazakl\",\"applicationId\":\"b80d575a-7890-4055-b4cd-a7697defdf0b\"},\"createdDateTime\":\"2021-05-05T03:41:54Z\",\"workspaceId\":\"cr\",\"workspaceUrl\":\"fdfdosygexpa\",\"storageAccountIdentity\":{\"principalId\":\"d7418a12-4ee4-4a80-a3ab-2ab139635f88\",\"tenantId\":\"10f2fbb2-2353-4deb-96de-440f0dc1ef57\",\"type\":\"msbzjhcrz\"},\"managedDiskIdentity\":{\"principalId\":\"47df26cd-98fe-41ba-ae19-790bbbdba738\",\"tenantId\":\"bf8147fe-9bba-456c-95f6-97934ef9f2c9\",\"type\":\"lxaolthqtrgqjbp\"},\"diskEncryptionSetId\":\"fsinzgvfcjrwzoxx\",\"encryption\":{\"entities\":{}},\"privateEndpointConnections\":[{\"properties\":{\"groupIds\":[],\"provisioningState\":\"Creating\"},\"id\":\"it\",\"name\":\"np\",\"type\":\"qfpjk\"},{\"properties\":{\"groupIds\":[],\"provisioningState\":\"Deleting\"},\"id\":\"pdvhpfxxypin\",\"name\":\"nmayhuybb\",\"type\":\"podepoo\"},{\"properties\":{\"groupIds\":[],\"provisioningState\":\"Deleting\"},\"id\":\"amiheognarxz\",\"name\":\"theotusiv\",\"type\":\"evcciqihnhun\"},{\"properties\":{\"groupIds\":[],\"provisioningState\":\"Failed\"},\"id\":\"rnfygxgispem\",\"name\":\"tzfkufubl\",\"type\":\"ofx\"}],\"publicNetworkAccess\":\"Disabled\",\"requiredNsgRules\":\"AllRules\"}")
                .toObject(WorkspaceProperties.class);
        Assertions.assertEquals("hiv", model.managedResourceGroupId());
        Assertions.assertEquals("b", model.parameters().amlWorkspaceId().value());
        Assertions.assertEquals("xvd", model.parameters().customVirtualNetworkId().value());
        Assertions.assertEquals("rtfw", model.parameters().customPublicSubnetName().value());
        Assertions.assertEquals("gaudcc", model.parameters().customPrivateSubnetName().value());
        Assertions.assertEquals(false, model.parameters().enableNoPublicIp().value());
        Assertions.assertEquals("ejhkry", model.parameters().loadBalancerBackendPoolName().value());
        Assertions.assertEquals("pczwlo", model.parameters().loadBalancerId().value());
        Assertions.assertEquals("mkkvnip", model.parameters().natGatewayName().value());
        Assertions.assertEquals("jnchgej", model.parameters().publicIpName().value());
        Assertions.assertEquals(true, model.parameters().prepareEncryption().value());
        Assertions.assertEquals(false, model.parameters().requireInfrastructureEncryption().value());
        Assertions.assertEquals("yahux", model.parameters().storageAccountName().value());
        Assertions.assertEquals("qnjaqwix", model.parameters().storageAccountSkuName().value());
        Assertions.assertEquals("ozvcput", model.parameters().vnetAddressPrefix().value());
        Assertions.assertEquals("mkjozkrwf", model.uiDefinitionUri());
        Assertions
            .assertEquals(
                UUID.fromString("423825c0-d7b7-43df-9531-f0a89709749a"), model.authorizations().get(0).principalId());
        Assertions
            .assertEquals(
                UUID.fromString("5ee36843-2071-404d-8a89-ef90b190dfbc"),
                model.authorizations().get(0).roleDefinitionId());
        Assertions.assertEquals(PublicNetworkAccess.DISABLED, model.publicNetworkAccess());
        Assertions.assertEquals(RequiredNsgRules.ALL_RULES, model.requiredNsgRules());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        WorkspaceProperties model =
            new WorkspaceProperties()
                .withManagedResourceGroupId("hiv")
                .withParameters(
                    new WorkspaceCustomParameters()
                        .withAmlWorkspaceId(new WorkspaceCustomStringParameter().withValue("b"))
                        .withCustomVirtualNetworkId(new WorkspaceCustomStringParameter().withValue("xvd"))
                        .withCustomPublicSubnetName(new WorkspaceCustomStringParameter().withValue("rtfw"))
                        .withCustomPrivateSubnetName(new WorkspaceCustomStringParameter().withValue("gaudcc"))
                        .withEnableNoPublicIp(new WorkspaceCustomBooleanParameter().withValue(false))
                        .withLoadBalancerBackendPoolName(new WorkspaceCustomStringParameter().withValue("ejhkry"))
                        .withLoadBalancerId(new WorkspaceCustomStringParameter().withValue("pczwlo"))
                        .withNatGatewayName(new WorkspaceCustomStringParameter().withValue("mkkvnip"))
                        .withPublicIpName(new WorkspaceCustomStringParameter().withValue("jnchgej"))
                        .withPrepareEncryption(new WorkspaceCustomBooleanParameter().withValue(true))
                        .withEncryption(new WorkspaceEncryptionParameter())
                        .withRequireInfrastructureEncryption(new WorkspaceCustomBooleanParameter().withValue(false))
                        .withStorageAccountName(new WorkspaceCustomStringParameter().withValue("yahux"))
                        .withStorageAccountSkuName(new WorkspaceCustomStringParameter().withValue("qnjaqwix"))
                        .withVnetAddressPrefix(new WorkspaceCustomStringParameter().withValue("ozvcput")))
                .withUiDefinitionUri("mkjozkrwf")
                .withAuthorizations(
                    Arrays
                        .asList(
                            new WorkspaceProviderAuthorization()
                                .withPrincipalId(UUID.fromString("423825c0-d7b7-43df-9531-f0a89709749a"))
                                .withRoleDefinitionId(UUID.fromString("5ee36843-2071-404d-8a89-ef90b190dfbc")),
                            new WorkspaceProviderAuthorization()
                                .withPrincipalId(UUID.fromString("9943af85-f67d-4113-8d2d-ce32b16a7041"))
                                .withRoleDefinitionId(UUID.fromString("158a0eb5-2a85-446f-a91c-3c8cd7b09c4e"))))
                .withCreatedBy(new CreatedBy())
                .withUpdatedBy(new CreatedBy())
                .withStorageAccountIdentity(new ManagedIdentityConfiguration())
                .withManagedDiskIdentity(new ManagedIdentityConfiguration())
                .withEncryption(new WorkspacePropertiesEncryption().withEntities(new EncryptionEntitiesDefinition()))
                .withPublicNetworkAccess(PublicNetworkAccess.DISABLED)
                .withRequiredNsgRules(RequiredNsgRules.ALL_RULES);
        model = BinaryData.fromObject(model).toObject(WorkspaceProperties.class);
        Assertions.assertEquals("hiv", model.managedResourceGroupId());
        Assertions.assertEquals("b", model.parameters().amlWorkspaceId().value());
        Assertions.assertEquals("xvd", model.parameters().customVirtualNetworkId().value());
        Assertions.assertEquals("rtfw", model.parameters().customPublicSubnetName().value());
        Assertions.assertEquals("gaudcc", model.parameters().customPrivateSubnetName().value());
        Assertions.assertEquals(false, model.parameters().enableNoPublicIp().value());
        Assertions.assertEquals("ejhkry", model.parameters().loadBalancerBackendPoolName().value());
        Assertions.assertEquals("pczwlo", model.parameters().loadBalancerId().value());
        Assertions.assertEquals("mkkvnip", model.parameters().natGatewayName().value());
        Assertions.assertEquals("jnchgej", model.parameters().publicIpName().value());
        Assertions.assertEquals(true, model.parameters().prepareEncryption().value());
        Assertions.assertEquals(false, model.parameters().requireInfrastructureEncryption().value());
        Assertions.assertEquals("yahux", model.parameters().storageAccountName().value());
        Assertions.assertEquals("qnjaqwix", model.parameters().storageAccountSkuName().value());
        Assertions.assertEquals("ozvcput", model.parameters().vnetAddressPrefix().value());
        Assertions.assertEquals("mkjozkrwf", model.uiDefinitionUri());
        Assertions
            .assertEquals(
                UUID.fromString("423825c0-d7b7-43df-9531-f0a89709749a"), model.authorizations().get(0).principalId());
        Assertions
            .assertEquals(
                UUID.fromString("5ee36843-2071-404d-8a89-ef90b190dfbc"),
                model.authorizations().get(0).roleDefinitionId());
        Assertions.assertEquals(PublicNetworkAccess.DISABLED, model.publicNetworkAccess());
        Assertions.assertEquals(RequiredNsgRules.ALL_RULES, model.requiredNsgRules());
    }
}
