// Copyright © 2023 Cisco Systems, Inc. and its affiliates.
// All rights reserved.
//
// Licensed under the Mozilla Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://mozilla.org/MPL/2.0/
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: MPL-2.0

// Code generated by "gen/generator.go"; DO NOT EDIT.

package provider

// Section below is generated&owned by "gen/generator.go". //template:begin imports
import (
	"fmt"
	"testing"

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

// End of section. //template:end imports

// Section below is generated&owned by "gen/generator.go". //template:begin testAcc

func TestAccIosxeBGPNeighbor(t *testing.T) {
	var checks []resource.TestCheckFunc
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_neighbor.test", "ip", "3.3.3.3"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_neighbor.test", "remote_as", "65000"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_neighbor.test", "description", "BGP Neighbor Description"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_neighbor.test", "shutdown", "false"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_neighbor.test", "cluster_id", "1234"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_neighbor.test", "version", "4"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_neighbor.test", "disable_connected_check", "false"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_neighbor.test", "fall_over_default_enable", "false"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_neighbor.test", "fall_over_default_route_map", "RMAP"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_neighbor.test", "fall_over_bfd", "true"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_neighbor.test", "fall_over_bfd_single_hop", "true"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_neighbor.test", "fall_over_bfd_check_control_plane_failure", "true"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_neighbor.test", "fall_over_bfd_strict_mode", "true"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_neighbor.test", "fall_over_maximum_metric_route_map", "RMAP"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_neighbor.test", "log_neighbor_changes", "true"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_neighbor.test", "timers_keepalive_interval", "655"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_neighbor.test", "timers_holdtime", "866"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_neighbor.test", "timers_minimum_neighbor_hold", "222"))
	checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_neighbor.test", "update_source_loopback", "100"))
	resource.Test(t, resource.TestCase{
		PreCheck:                 func() { testAccPreCheck(t) },
		ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
		Steps: []resource.TestStep{
			{
				Config: testAccIosxeBGPNeighborPrerequisitesConfig + testAccIosxeBGPNeighborConfig_all(),
				Check:  resource.ComposeTestCheckFunc(checks...),
			},
			{
				ResourceName:            "iosxe_bgp_neighbor.test",
				ImportState:             true,
				ImportStateVerify:       true,
				ImportStateIdFunc:       iosxeBGPNeighborImportStateIdFunc("iosxe_bgp_neighbor.test"),
				ImportStateVerifyIgnore: []string{"fall_over_bfd_multi_hop", "local_as_no_prepend", "local_as_replace_as", "local_as_dual_as", "ebgp_multihop"},
				Check:                   resource.ComposeTestCheckFunc(checks...),
			},
		},
	})
}

// End of section. //template:end testAcc

// Section below is generated&owned by "gen/generator.go". //template:begin importStateIdFunc

func iosxeBGPNeighborImportStateIdFunc(resourceName string) resource.ImportStateIdFunc {
	return func(s *terraform.State) (string, error) {
		primary := s.RootModule().Resources[resourceName].Primary
		Asn := primary.Attributes["asn"]
		Ip := primary.Attributes["ip"]

		return fmt.Sprintf("%s,%s", Asn, Ip), nil
	}
}

// End of section. //template:end importStateIdFunc

// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeBGPNeighborPrerequisitesConfig = `
resource "iosxe_restconf" "PreReq0" {
	path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000"
	attributes = {
		"id" = "65000"
	}
}

resource "iosxe_restconf" "PreReq1" {
	path = "Cisco-IOS-XE-native:native/interface/Loopback=100"
	attributes = {
		"name" = "100"
	}
}

`

// End of section. //template:end testPrerequisites

// Section below is generated&owned by "gen/generator.go". //template:begin testAccConfigMinimal

func testAccIosxeBGPNeighborConfig_minimum() string {
	config := `resource "iosxe_bgp_neighbor" "test" {` + "\n"
	config += `	asn = "65000"` + "\n"
	config += `	ip = "3.3.3.3"` + "\n"
	config += `	depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]` + "\n"
	config += `}` + "\n"
	return config
}

// End of section. //template:end testAccConfigMinimal

// Section below is generated&owned by "gen/generator.go". //template:begin testAccConfigAll

func testAccIosxeBGPNeighborConfig_all() string {
	config := `resource "iosxe_bgp_neighbor" "test" {` + "\n"
	config += `	asn = "65000"` + "\n"
	config += `	ip = "3.3.3.3"` + "\n"
	config += `	remote_as = "65000"` + "\n"
	config += `	description = "BGP Neighbor Description"` + "\n"
	config += `	shutdown = false` + "\n"
	config += `	cluster_id = "1234"` + "\n"
	config += `	version = 4` + "\n"
	config += `	disable_connected_check = false` + "\n"
	config += `	fall_over_default_enable = false` + "\n"
	config += `	fall_over_default_route_map = "RMAP"` + "\n"
	config += `	fall_over_bfd = true` + "\n"
	config += `	fall_over_bfd_single_hop = true` + "\n"
	config += `	fall_over_bfd_check_control_plane_failure = true` + "\n"
	config += `	fall_over_bfd_strict_mode = true` + "\n"
	config += `	fall_over_maximum_metric_route_map = "RMAP"` + "\n"
	config += `	log_neighbor_changes = true` + "\n"
	config += `	password_type = 1` + "\n"
	config += `	password = "test1234"` + "\n"
	config += `	timers_keepalive_interval = 655` + "\n"
	config += `	timers_holdtime = 866` + "\n"
	config += `	timers_minimum_neighbor_hold = 222` + "\n"
	config += `	update_source_loopback = 100` + "\n"
	config += `	depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]` + "\n"
	config += `}` + "\n"
	return config
}

// End of section. //template:end testAccConfigAll
