<commit_before>package oci

import (
	"fmt"
	"testing"

	"github.com/hashicorp/terraform/helper/resource"
	"github.com/hashicorp/terraform/terraform"

	"github.com/terraform-providers/terraform-provider-oci/httpreplay"
)

var (
	adbDedicatedName       = randomString(1, charsetWithoutDigits) + randomString(13, charset)
	adbDedicatedUpdateName = randomString(1, charsetWithoutDigits) + randomString(13, charset)
	adbDedicatedCloneName  = randomString(1, charsetWithoutDigits) + randomString(13, charset)
	adDedicatedName        = randomString(1, charsetWithoutDigits) + randomString(13, charset)
	adDedicatedUpdateName  = randomString(1, charsetWithoutDigits) + randomString(13, charset)

	AutonomousDatabaseDedicatedRequiredOnlyResource = AutonomousDatabaseDedicatedResourceDependencies +
		generateResourceFromRepresentationMap("oci_database_autonomous_database", "test_autonomous_database", Required, Create, autonomousDatabaseDedicatedRepresentation)

	AutonomousDatabaseDedicatedResourceConfig = AutonomousDatabaseDedicatedResourceDependencies +
		generateResourceFromRepresentationMap("oci_database_autonomous_database", "test_autonomous_database", Optional, Update, autonomousDatabaseDedicatedRepresentation)

	autonomousDatabaseDedicatedDataSourceRepresentation = representationCopyWithNewProperties(
		autonomousDatabaseDataSourceRepresentation,
		map[string]interface{}{
			"autonomous_container_database_id": Representation{repType: Optional, create: `${oci_database_autonomous_container_database.test_autonomous_container_database.id}`},
			"display_name":                     Representation{repType: Optional, create: adDedicatedName, update: adDedicatedUpdateName},
		})

	autonomousDatabaseDedicatedRepresentation = representationCopyWithNewProperties(
		representationCopyWithRemovedProperties(getUpdatedRepresentationCopy("db_name", Representation{repType: Required, create: adbDedicatedName}, autonomousDatabaseRepresentation), []string{"license_model", "whitelisted_ips"}),
		map[string]interface{}{
			"autonomous_container_database_id": Representation{repType: Optional, create: `${oci_database_autonomous_container_database.test_autonomous_container_database.id}`},
			"is_dedicated":                     Representation{repType: Optional, create: `true`},
			"display_name":                     Representation{repType: Optional, create: adDedicatedName, update: adDedicatedUpdateName},
		})

	autonomousDatabaseDedicatedRepresentationForClone = representationCopyWithNewProperties(
		representationCopyWithRemovedProperties(getUpdatedRepresentationCopy("db_name", Representation{repType: Required, create: adbDedicatedCloneName}, autonomousDatabaseDedicatedRepresentation), []string{"license_model"}),
		map[string]interface{}{
			"clone_type":   Representation{repType: Optional, create: `FULL`},
			"display_name": Representation{repType: Optional, create: "example_autonomous_database_dedicated"},
			"source":       Representation{repType: Optional, create: `DATABASE`},
			"source_id":    Representation{repType: Optional, create: `${oci_database_autonomous_database.test_autonomous_database_source.id}`},
		})

	autonomousDatabaseDtaSafeStatusRepresentation = map[string]interface{}{
		"admin_password":           Representation{repType: Required, create: `<PASSWORD>`, update: `<PASSWORD>`},
		"compartment_id":           Representation{repType: Required, create: `${var.compartment_id}`},
		"cpu_core_count":           Representation{repType: Required, create: `1`},
		"data_storage_size_in_tbs": Representation{repType: Required, create: `1`},
		"db_name":                  Representation{repType: Required, create: adbName},
		"db_workload":              Representation{repType: Optional, create: `OLTP`},
		"defined_tags":             Representation{repType: Optional, create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
		"display_name":             Representation{repType: Optional, create: `example_autonomous_database`, update: `displayName2`},
		"freeform_tags":            Representation{repType: Optional, create: map[string]string{"Department": "Finance"}, update: map[string]string{"Department": "Accounting"}},
		"is_auto_scaling_enabled":  Representation{repType: Optional, create: `false`},
		"is_dedicated":             Representation{repType: Optional, create: `false`},
		"is_preview_version_with_service_terms_accepted": Representation{repType: Optional, create: `false`},
		"license_model":    Representation{repType: Optional, create: `LICENSE_INCLUDED`},
		"data_safe_status": Representation{repType: Optional, create: `REGISTERED`, update: `not_REGISTERED`},
	}

	AutonomousDatabaseDedicatedResourceDependencies = AutonomousContainerDatabaseResourceConfig
)

func TestResourceDatabaseAutonomousDatabaseDedicated(t *testing.T) {
	httpreplay.SetScenario("TestResourceDatabaseAutonomousDatabaseDedicated")
	defer httpreplay.SaveScenario()
<commit_msg>setting destroy timeout for 10 minutes till deregister the autonomous database with data safe is updated<commit_after>package oci

import (
	"fmt"
	"testing"

	"github.com/hashicorp/terraform/helper/resource"
	"github.com/hashicorp/terraform/terraform"

	"github.com/terraform-providers/terraform-provider-oci/httpreplay"
)

var (
	adbDedicatedName       = randomString(1, charsetWithoutDigits) + randomString(13, charset)
	adbDedicatedUpdateName = randomString(1, charsetWithoutDigits) + randomString(13, charset)
	adbDedicatedCloneName  = randomString(1, charsetWithoutDigits) + randomString(13, charset)
	adDedicatedName        = randomString(1, charsetWithoutDigits) + randomString(13, charset)
	adDedicatedUpdateName  = randomString(1, charsetWithoutDigits) + randomString(13, charset)

	AutonomousDatabaseDedicatedRequiredOnlyResource = AutonomousDatabaseDedicatedResourceDependencies +
		generateResourceFromRepresentationMap("oci_database_autonomous_database", "test_autonomous_database", Required, Create, autonomousDatabaseDedicatedRepresentation)

	AutonomousDatabaseDedicatedResourceConfig = AutonomousDatabaseDedicatedResourceDependencies +
		generateResourceFromRepresentationMap("oci_database_autonomous_database", "test_autonomous_database", Optional, Update, autonomousDatabaseDedicatedRepresentation)

	autonomousDatabaseDedicatedDataSourceRepresentation = representationCopyWithNewProperties(
		autonomousDatabaseDataSourceRepresentation,
		map[string]interface{}{
			"autonomous_container_database_id": Representation{repType: Optional, create: `${oci_database_autonomous_container_database.test_autonomous_container_database.id}`},
			"display_name":                     Representation{repType: Optional, create: adDedicatedName, update: adDedicatedUpdateName},
		})

	autonomousDatabaseDedicatedRepresentation = representationCopyWithNewProperties(
		representationCopyWithRemovedProperties(getUpdatedRepresentationCopy("db_name", Representation{repType: Required, create: adbDedicatedName}, autonomousDatabaseRepresentation), []string{"license_model", "whitelisted_ips"}),
		map[string]interface{}{
			"autonomous_container_database_id": Representation{repType: Optional, create: `${oci_database_autonomous_container_database.test_autonomous_container_database.id}`},
			"is_dedicated":                     Representation{repType: Optional, create: `true`},
			"display_name":                     Representation{repType: Optional, create: adDedicatedName, update: adDedicatedUpdateName},
		})

	autonomousDatabaseDedicatedRepresentationForClone = representationCopyWithNewProperties(
		representationCopyWithRemovedProperties(getUpdatedRepresentationCopy("db_name", Representation{repType: Required, create: adbDedicatedCloneName}, autonomousDatabaseDedicatedRepresentation), []string{"license_model"}),
		map[string]interface{}{
			"clone_type":   Representation{repType: Optional, create: `FULL`},
			"display_name": Representation{repType: Optional, create: "example_autonomous_database_dedicated"},
			"source":       Representation{repType: Optional, create: `DATABASE`},
			"source_id":    Representation{repType: Optional, create: `${oci_database_autonomous_database.test_autonomous_database_source.id}`},
		})

	autonomousDatabaseDtaSafeStatusRepresentation = map[string]interface{}{
		"admin_password":           Representation{repType: Required, create: `BEstrO0ng_#11`, update: `BEstrO0ng_#12`},
		"compartment_id":           Representation{repType: Required, create: `${var.compartment_id}`},
		"cpu_core_count":           Representation{repType: Required, create: `1`},
		"data_storage_size_in_tbs": Representation{repType: Required, create: `1`},
		"db_name":                  Representation{repType: Required, create: adbName},
		"db_workload":              Representation{repType: Optional, create: `OLTP`},
		"defined_tags":             Representation{repType: Optional, create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
		"display_name":             Representation{repType: Optional, create: `example_autonomous_database`, update: `displayName2`},
		"freeform_tags":            Representation{repType: Optional, create: map[string]string{"Department": "Finance"}, update: map[string]string{"Department": "Accounting"}},
		"is_auto_scaling_enabled":  Representation{repType: Optional, create: `false`},
		"is_dedicated":             Representation{repType: Optional, create: `false`},
		"is_preview_version_with_service_terms_accepted": Representation{repType: Optional, create: `false`},
		"license_model":    Representation{repType: Optional, create: `LICENSE_INCLUDED`},
		"data_safe_status": Representation{repType: Optional, create: `REGISTERED`, update: `not_REGISTERED`},
		"timeouts":         RepresentationGroup{Required, autonomousDatabaseDtaSafeStatusTimeoutsRepresentation},
	}

	autonomousDatabaseDtaSafeStatusTimeoutsRepresentation = map[string]interface{}{
		"delete": Representation{repType: Required, create: `10m`},
	}

	AutonomousDatabaseDedicatedResourceDependencies = AutonomousContainerDatabaseResourceConfig
)

func TestResourceDatabaseAutonomousDatabaseDedicated(t *testing.T) {
	httpreplay.SetScenario("TestResourceDatabaseAutonomousDatabaseDedicated")
	defer httpreplay.SaveScenario()

{'fraction_non_alphanumeric': 0.10555872834570722, 'fraction_numerical': 0.005139920045688178, 'mean_word_length': 7.619360131255127, 'pattern_counts': {'":': 52, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4434529', 'n_tokens_mistral': 3150, 'n_tokens_neox': 2948, 'n_words': 457}