// Code generated by "gen/generator.go"; DO NOT EDIT.
// In order to regenerate this file execute `go generate` from the repository root.
// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md).

package provider

import (
	"regexp"
	"testing"

	"github.com/hashicorp/terraform-plugin-testing/helper/resource"
)

func TestAccResourceFvRsDomAttWithFvAEPg(t *testing.T) {

	resource.Test(t, resource.TestCase{
		PreCheck:                 func() { testAccPreCheck(t, "apic", "1.0(1e)-") },
		ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
		Steps: []resource.TestStep{
			// Create with minimum config and verify default APIC values
			{
				Config:             testConfigFvRsDomAttMinDependencyWithFvAEPgAllowExisting + testConfigDataSourceSystem,
				ExpectNonEmptyPlan: false,
				Check: resource.ComposeAggregateTestCheckFunc(
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "target_dn", "uni/vmmp-VMware/dom-domain_1"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "target_dn", "uni/vmmp-VMware/dom-domain_1"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "annotation", "orchestrator:terraform"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "annotation", "orchestrator:terraform"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "class_preference", "encap"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "class_preference", "encap"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "delimiter", ""),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "delimiter", ""),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "deployment_immediacy", "lazy"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "deployment_immediacy", "lazy"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "enable_netflow", "disabled"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "enable_netflow", "disabled"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "encapsulation", "unknown"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "encapsulation", "unknown"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "encapsulation_mode", "auto"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "encapsulation_mode", "auto"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "epg_cos", "Cos0"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "epg_cos", "Cos0"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "epg_cos_pref", "disabled"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "epg_cos_pref", "disabled"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "lag_policy_name", ""),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "lag_policy_name", ""),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "netflow_direction", "both"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "netflow_direction", "both"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "primary_encapsulation", "unknown"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "primary_encapsulation", "unknown"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "primary_encapsulation_inner", "unknown"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "primary_encapsulation_inner", "unknown"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "resolution_immediacy", "lazy"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "resolution_immediacy", "lazy"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "secondary_encapsulation_inner", "unknown"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "secondary_encapsulation_inner", "unknown"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "switching_mode", "native"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "switching_mode", "native"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "untagged", "no"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "untagged", "no"),
					composeAggregateTestCheckFuncWithVersion(t, "4.0(1h)-", "inside",
						resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "binding_type", "none"),
						resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "binding_type", "none"),
						resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "number_of_ports", "0"),
						resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "number_of_ports", "0"),
						resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "port_allocation", "none"),
						resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "port_allocation", "none")),
					composeAggregateTestCheckFuncWithVersion(t, "4.2(3j)-", "inside",
						resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "custom_epg_name", ""),
						resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "custom_epg_name", "")),
				),
			},
		},
	})

	setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "false")
	resource.Test(t, resource.TestCase{
		PreCheck:                 func() { testAccPreCheck(t, "apic", "1.0(1e)-") },
		ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
		Steps: []resource.TestStep{
			// Create with minimum config and verify default APIC values
			{
				Config:      testConfigFvRsDomAttMinDependencyWithFvAEPgAllowExisting + testConfigDataSourceSystem,
				ExpectError: regexp.MustCompile("Object Already Exists"),
			},
		},
	})

	setEnvVariable(t, "ACI_ALLOW_EXISTING_ON_CREATE", "true")
	resource.Test(t, resource.TestCase{
		PreCheck:                 func() { testAccPreCheck(t, "apic", "1.0(1e)-") },
		ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
		Steps: []resource.TestStep{
			// Create with minimum config and verify default APIC values
			{
				Config:             testConfigFvRsDomAttMinDependencyWithFvAEPgAllowExisting + testConfigDataSourceSystem,
				ExpectNonEmptyPlan: false,
				Check: resource.ComposeAggregateTestCheckFunc(
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "target_dn", "uni/vmmp-VMware/dom-domain_1"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "target_dn", "uni/vmmp-VMware/dom-domain_1"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "annotation", "orchestrator:terraform"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "annotation", "orchestrator:terraform"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "class_preference", "encap"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "class_preference", "encap"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "delimiter", ""),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "delimiter", ""),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "deployment_immediacy", "lazy"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "deployment_immediacy", "lazy"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "enable_netflow", "disabled"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "enable_netflow", "disabled"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "encapsulation", "unknown"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "encapsulation", "unknown"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "encapsulation_mode", "auto"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "encapsulation_mode", "auto"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "epg_cos", "Cos0"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "epg_cos", "Cos0"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "epg_cos_pref", "disabled"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "epg_cos_pref", "disabled"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "lag_policy_name", ""),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "lag_policy_name", ""),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "netflow_direction", "both"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "netflow_direction", "both"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "primary_encapsulation", "unknown"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "primary_encapsulation", "unknown"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "primary_encapsulation_inner", "unknown"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "primary_encapsulation_inner", "unknown"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "resolution_immediacy", "lazy"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "resolution_immediacy", "lazy"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "secondary_encapsulation_inner", "unknown"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "secondary_encapsulation_inner", "unknown"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "switching_mode", "native"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "switching_mode", "native"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "untagged", "no"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "untagged", "no"),
					composeAggregateTestCheckFuncWithVersion(t, "4.0(1h)-", "inside",
						resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "binding_type", "none"),
						resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "binding_type", "none"),
						resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "number_of_ports", "0"),
						resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "number_of_ports", "0"),
						resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "port_allocation", "none"),
						resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "port_allocation", "none")),
					composeAggregateTestCheckFuncWithVersion(t, "4.2(3j)-", "inside",
						resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test", "custom_epg_name", ""),
						resource.TestCheckResourceAttr("aci_relation_to_domain.allow_test_2", "custom_epg_name", "")),
				),
			},
		},
	})

	resource.Test(t, resource.TestCase{
		PreCheck:                 func() { testAccPreCheck(t, "apic", "1.0(1e)-") },
		ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
		Steps: []resource.TestStep{
			// Create with minimum config and verify default APIC values
			{
				Config:             testConfigFvRsDomAttMinDependencyWithFvAEPg + testConfigDataSourceSystem,
				ExpectNonEmptyPlan: false,
				Check: resource.ComposeAggregateTestCheckFunc(
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "target_dn", "uni/vmmp-VMware/dom-domain_1"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "annotation", "orchestrator:terraform"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "class_preference", "encap"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "delimiter", ""),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "deployment_immediacy", "lazy"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "enable_netflow", "disabled"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "encapsulation", "unknown"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "encapsulation_mode", "auto"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "epg_cos", "Cos0"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "epg_cos_pref", "disabled"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "lag_policy_name", ""),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "netflow_direction", "both"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "primary_encapsulation", "unknown"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "primary_encapsulation_inner", "unknown"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "resolution_immediacy", "lazy"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "secondary_encapsulation_inner", "unknown"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "switching_mode", "native"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "untagged", "no"),
					composeAggregateTestCheckFuncWithVersion(t, "4.0(1h)-", "inside",
						resource.TestCheckResourceAttr("aci_relation_to_domain.test", "binding_type", "none"),
						resource.TestCheckResourceAttr("aci_relation_to_domain.test", "number_of_ports", "0"),
						resource.TestCheckResourceAttr("aci_relation_to_domain.test", "port_allocation", "none")),
					composeAggregateTestCheckFuncWithVersion(t, "4.2(3j)-", "inside",
						resource.TestCheckResourceAttr("aci_relation_to_domain.test", "custom_epg_name", "")),
				),
			},
			// Update with all config and verify default APIC values
			{
				Config:             testConfigFvRsDomAttAllDependencyWithFvAEPg + testConfigDataSourceSystem,
				ExpectNonEmptyPlan: false,
				Check: resource.ComposeAggregateTestCheckFunc(
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "target_dn", "uni/vmmp-VMware/dom-domain_1"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "annotation", "annotation"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "class_preference", "encap"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "delimiter", "@"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "deployment_immediacy", "immediate"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "enable_netflow", "disabled"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "encapsulation", "vlan-100"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "encapsulation_mode", "auto"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "epg_cos", "Cos0"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "epg_cos_pref", "disabled"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "lag_policy_name", "lag_policy_name_1"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "netflow_direction", "both"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "primary_encapsulation", "vlan-200"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "primary_encapsulation_inner", "vlan-300"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "resolution_immediacy", "immediate"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "secondary_encapsulation_inner", "vlan-400"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "switching_mode", "AVE"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "untagged", "no"),
					composeAggregateTestCheckFuncWithVersion(t, "4.0(1h)-", "inside",
						resource.TestCheckResourceAttr("aci_relation_to_domain.test", "binding_type", "dynamicBinding"),
						resource.TestCheckResourceAttr("aci_relation_to_domain.test", "number_of_ports", "1"),
						resource.TestCheckResourceAttr("aci_relation_to_domain.test", "port_allocation", "elastic")),
					composeAggregateTestCheckFuncWithVersion(t, "4.2(3j)-", "inside",
						resource.TestCheckResourceAttr("aci_relation_to_domain.test", "custom_epg_name", "custom_epg_name_1")),
				),
			},
			// Update with minimum config and verify config is unchanged
			{
				Config:             testConfigFvRsDomAttMinDependencyWithFvAEPg + testConfigDataSourceSystem,
				ExpectNonEmptyPlan: false,
				Check: resource.ComposeAggregateTestCheckFunc(
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "target_dn", "uni/vmmp-VMware/dom-domain_1"),
				),
			},
			// Update with empty strings config or default value
			{
				Config:             testConfigFvRsDomAttResetDependencyWithFvAEPg + testConfigDataSourceSystem,
				ExpectNonEmptyPlan: false,
				Check: resource.ComposeAggregateTestCheckFunc(
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "target_dn", "uni/vmmp-VMware/dom-domain_1"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "annotation", "orchestrator:terraform"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "class_preference", "encap"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "delimiter", ""),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "deployment_immediacy", "lazy"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "enable_netflow", "disabled"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "encapsulation", "unknown"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "encapsulation_mode", "auto"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "epg_cos", "Cos0"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "epg_cos_pref", "disabled"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "lag_policy_name", ""),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "netflow_direction", "both"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "primary_encapsulation", "unknown"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "primary_encapsulation_inner", "unknown"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "resolution_immediacy", "lazy"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "secondary_encapsulation_inner", "unknown"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "switching_mode", "native"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "untagged", "no"),
					composeAggregateTestCheckFuncWithVersion(t, "4.0(1h)-", "inside",
						resource.TestCheckResourceAttr("aci_relation_to_domain.test", "binding_type", "none"),
						resource.TestCheckResourceAttr("aci_relation_to_domain.test", "number_of_ports", "0"),
						resource.TestCheckResourceAttr("aci_relation_to_domain.test", "port_allocation", "none")),
					composeAggregateTestCheckFuncWithVersion(t, "4.2(3j)-", "inside",
						resource.TestCheckResourceAttr("aci_relation_to_domain.test", "custom_epg_name", "")),
				),
			},
			// Import testing
			{
				ResourceName:      "aci_relation_to_domain.test",
				ImportState:       true,
				ImportStateVerify: true,
			},
			// Update with children
			{
				Config:             testConfigFvRsDomAttChildrenDependencyWithFvAEPg + testConfigDataSourceSystem,
				ExpectNonEmptyPlan: false,
				Check: resource.ComposeAggregateTestCheckFunc(
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "target_dn", "uni/vmmp-VMware/dom-domain_1"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "annotation", "orchestrator:terraform"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "class_preference", "encap"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "delimiter", ""),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "deployment_immediacy", "lazy"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "enable_netflow", "disabled"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "encapsulation", "unknown"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "encapsulation_mode", "auto"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "epg_cos", "Cos0"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "epg_cos_pref", "disabled"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "lag_policy_name", ""),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "netflow_direction", "both"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "primary_encapsulation", "unknown"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "primary_encapsulation_inner", "unknown"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "resolution_immediacy", "lazy"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "secondary_encapsulation_inner", "unknown"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "switching_mode", "native"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "untagged", "no"),
					composeAggregateTestCheckFuncWithVersion(t, "4.0(1h)-", "inside",
						resource.TestCheckResourceAttr("aci_relation_to_domain.test", "binding_type", "none"),
						resource.TestCheckResourceAttr("aci_relation_to_domain.test", "number_of_ports", "0"),
						resource.TestCheckResourceAttr("aci_relation_to_domain.test", "port_allocation", "none")),
					composeAggregateTestCheckFuncWithVersion(t, "4.2(3j)-", "inside",
						resource.TestCheckResourceAttr("aci_relation_to_domain.test", "custom_epg_name", "")),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "annotations.0.key", "key_0"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "annotations.0.value", "value_1"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "annotations.1.key", "key_1"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "annotations.1.value", "test_value"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "tags.0.key", "key_0"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "tags.0.value", "value_1"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "tags.1.key", "key_1"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "tags.1.value", "test_value"),
				),
			},
			// Refresh State before import testing to ensure that the state is up to date
			{
				RefreshState:       true,
				ExpectNonEmptyPlan: false,
			},
			// Import testing with children
			{
				ResourceName:      "aci_relation_to_domain.test",
				ImportState:       true,
				ImportStateVerify: true,
			},
			// Update with children removed from config
			{
				Config:             testConfigFvRsDomAttChildrenRemoveFromConfigDependencyWithFvAEPg + testConfigDataSourceSystem,
				ExpectNonEmptyPlan: false,
				Check: resource.ComposeAggregateTestCheckFunc(
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "annotations.0.key", "key_0"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "annotations.0.value", "value_1"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "annotations.1.key", "key_1"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "annotations.1.value", "test_value"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "annotations.#", "2"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "tags.0.key", "key_0"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "tags.0.value", "value_1"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "tags.1.key", "key_1"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "tags.1.value", "test_value"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "tags.#", "2"),
				),
			},
			// Update with children first child removed
			{
				Config:             testConfigFvRsDomAttChildrenRemoveOneDependencyWithFvAEPg + testConfigDataSourceSystem,
				ExpectNonEmptyPlan: false,
				Check: resource.ComposeAggregateTestCheckFunc(
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "annotations.0.key", "key_1"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "annotations.0.value", "test_value"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "annotations.#", "1"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "tags.0.key", "key_1"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "tags.0.value", "test_value"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "tags.#", "1"),
				),
			},
			// Update with all children removed
			{
				Config:             testConfigFvRsDomAttChildrenRemoveAllDependencyWithFvAEPg + testConfigDataSourceSystem,
				ExpectNonEmptyPlan: false,
				Check: resource.ComposeAggregateTestCheckFunc(
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "annotations.#", "0"),
					resource.TestCheckResourceAttr("aci_relation_to_domain.test", "tags.#", "0"),
				),
			},
		},
		CheckDestroy: testCheckResourceDestroy,
	})
}

const testDependencyConfigFvRsDomAtt = `
`

const testConfigFvRsDomAttMinDependencyWithFvAEPgAllowExisting = testDependencyConfigFvRsDomAtt + testConfigFvAEPgMinDependencyWithFvAp + `
resource "aci_relation_to_domain" "allow_test" {
  parent_dn = aci_application_epg.test.id
  target_dn = "uni/vmmp-VMware/dom-domain_1"
}
resource "aci_relation_to_domain" "allow_test_2" {
  parent_dn = aci_application_epg.test.id
  target_dn = "uni/vmmp-VMware/dom-domain_1"
  depends_on = [aci_relation_to_domain.allow_test]
}
`

const testConfigFvRsDomAttMinDependencyWithFvAEPg = testDependencyConfigFvRsDomAtt + testConfigFvAEPgMinDependencyWithFvAp + `
resource "aci_relation_to_domain" "test" {
  parent_dn = aci_application_epg.test.id
  target_dn = "uni/vmmp-VMware/dom-domain_1"
}
`

const testConfigFvRsDomAttAllDependencyWithFvAEPg = testDependencyConfigFvRsDomAtt + testConfigFvAEPgMinDependencyWithFvAp + `
resource "aci_relation_to_domain" "test" {
  parent_dn = aci_application_epg.test.id
  target_dn = "uni/vmmp-VMware/dom-domain_1"
  annotation = "annotation"
  class_preference = "encap"
  delimiter = "@"
  deployment_immediacy = "immediate"
  enable_netflow = "disabled"
  encapsulation = "vlan-100"
  encapsulation_mode = "auto"
  epg_cos = "Cos0"
  epg_cos_pref = "disabled"
  lag_policy_name = "lag_policy_name_1"
  netflow_direction = "both"
  primary_encapsulation = "vlan-200"
  primary_encapsulation_inner = "vlan-300"
  resolution_immediacy = "immediate"
  secondary_encapsulation_inner = "vlan-400"
  switching_mode = "AVE"
  untagged = "no"
  binding_type = provider::aci::compare_versions(data.aci_system.version.version,"inside","4.0(1h)-") ? "dynamicBinding" : null
  number_of_ports = provider::aci::compare_versions(data.aci_system.version.version,"inside","4.0(1h)-") ? "1" : null
  port_allocation = provider::aci::compare_versions(data.aci_system.version.version,"inside","4.0(1h)-") ? "elastic" : null
  custom_epg_name = provider::aci::compare_versions(data.aci_system.version.version,"inside","4.2(3j)-") ? "custom_epg_name_1" : null
}
`

const testConfigFvRsDomAttResetDependencyWithFvAEPg = testDependencyConfigFvRsDomAtt + testConfigFvAEPgMinDependencyWithFvAp + `
resource "aci_relation_to_domain" "test" {
  parent_dn = aci_application_epg.test.id
  target_dn = "uni/vmmp-VMware/dom-domain_1"
  annotation = "orchestrator:terraform"
  class_preference = "encap"
  delimiter = ""
  deployment_immediacy = "lazy"
  enable_netflow = "disabled"
  encapsulation = "unknown"
  encapsulation_mode = "auto"
  epg_cos = "Cos0"
  epg_cos_pref = "disabled"
  lag_policy_name = ""
  netflow_direction = "both"
  primary_encapsulation = "unknown"
  primary_encapsulation_inner = "unknown"
  resolution_immediacy = "lazy"
  secondary_encapsulation_inner = "unknown"
  switching_mode = "native"
  untagged = "no"
  binding_type = provider::aci::compare_versions(data.aci_system.version.version,"inside","4.0(1h)-") ? "none" : null
  number_of_ports = provider::aci::compare_versions(data.aci_system.version.version,"inside","4.0(1h)-") ? "0" : null
  port_allocation = provider::aci::compare_versions(data.aci_system.version.version,"inside","4.0(1h)-") ? "none" : null
  custom_epg_name = provider::aci::compare_versions(data.aci_system.version.version,"inside","4.2(3j)-") ? "" : null
}
`
const testConfigFvRsDomAttChildrenDependencyWithFvAEPg = testDependencyConfigFvRsDomAtt + testConfigFvAEPgMinDependencyWithFvAp + `
resource "aci_relation_to_domain" "test" {
  parent_dn = aci_application_epg.test.id
  target_dn = "uni/vmmp-VMware/dom-domain_1"
  annotations = [
    {
      key = "key_0"
      value = "value_1"
    },
    {
      key = "key_1"
      value = "test_value"
    },
  ]
  tags = [
    {
      key = "key_0"
      value = "value_1"
    },
    {
      key = "key_1"
      value = "test_value"
    },
  ]
}
`

const testConfigFvRsDomAttChildrenRemoveFromConfigDependencyWithFvAEPg = testDependencyConfigFvRsDomAtt + testConfigFvAEPgMinDependencyWithFvAp + `
resource "aci_relation_to_domain" "test" {
  parent_dn = aci_application_epg.test.id
  target_dn = "uni/vmmp-VMware/dom-domain_1"
}
`

const testConfigFvRsDomAttChildrenRemoveOneDependencyWithFvAEPg = testDependencyConfigFvRsDomAtt + testConfigFvAEPgMinDependencyWithFvAp + `
resource "aci_relation_to_domain" "test" {
  parent_dn = aci_application_epg.test.id
  target_dn = "uni/vmmp-VMware/dom-domain_1"
  annotations = [ 
	{
	  key = "key_1"
	  value = "test_value"
	},
  ]
  tags = [ 
	{
	  key = "key_1"
	  value = "test_value"
	},
  ]
}
`

const testConfigFvRsDomAttChildrenRemoveAllDependencyWithFvAEPg = testDependencyConfigFvRsDomAtt + testConfigFvAEPgMinDependencyWithFvAp + `
resource "aci_relation_to_domain" "test" {
  parent_dn = aci_application_epg.test.id
  target_dn = "uni/vmmp-VMware/dom-domain_1"
  annotations = []
  tags = []
}
`
