// Code generated by azure-service-operator-codegen. DO NOT EDIT.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
package v1api20240815

import (
	"encoding/json"
	storage "github.com/Azure/azure-service-operator/v2/api/documentdb/v1api20240815/storage"
	"github.com/google/go-cmp/cmp"
	"github.com/google/go-cmp/cmp/cmpopts"
	"github.com/kr/pretty"
	"github.com/kylelemons/godebug/diff"
	"github.com/leanovate/gopter"
	"github.com/leanovate/gopter/gen"
	"github.com/leanovate/gopter/prop"
	"os"
	"reflect"
	"testing"
)

func Test_MongodbRoleDefinition_WhenConvertedToHub_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	parameters.MinSuccessfulTests = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from MongodbRoleDefinition to hub returns original",
		prop.ForAll(RunResourceConversionTestForMongodbRoleDefinition, MongodbRoleDefinitionGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

// RunResourceConversionTestForMongodbRoleDefinition tests if a specific instance of MongodbRoleDefinition round trips to the hub storage version and back losslessly
func RunResourceConversionTestForMongodbRoleDefinition(subject MongodbRoleDefinition) string {
	// Copy subject to make sure conversion doesn't modify it
	copied := subject.DeepCopy()

	// Convert to our hub version
	var hub storage.MongodbRoleDefinition
	err := copied.ConvertTo(&hub)
	if err != nil {
		return err.Error()
	}

	// Convert from our hub version
	var actual MongodbRoleDefinition
	err = actual.ConvertFrom(&hub)
	if err != nil {
		return err.Error()
	}

	// Compare actual with what we started with
	match := cmp.Equal(subject, actual, cmpopts.EquateEmpty())
	if !match {
		actualFmt := pretty.Sprint(actual)
		subjectFmt := pretty.Sprint(subject)
		result := diff.Diff(subjectFmt, actualFmt)
		return result
	}

	return ""
}

func Test_MongodbRoleDefinition_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from MongodbRoleDefinition to MongodbRoleDefinition via AssignProperties_To_MongodbRoleDefinition & AssignProperties_From_MongodbRoleDefinition returns original",
		prop.ForAll(RunPropertyAssignmentTestForMongodbRoleDefinition, MongodbRoleDefinitionGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

// RunPropertyAssignmentTestForMongodbRoleDefinition tests if a specific instance of MongodbRoleDefinition can be assigned to storage and back losslessly
func RunPropertyAssignmentTestForMongodbRoleDefinition(subject MongodbRoleDefinition) string {
	// Copy subject to make sure assignment doesn't modify it
	copied := subject.DeepCopy()

	// Use AssignPropertiesTo() for the first stage of conversion
	var other storage.MongodbRoleDefinition
	err := copied.AssignProperties_To_MongodbRoleDefinition(&other)
	if err != nil {
		return err.Error()
	}

	// Use AssignPropertiesFrom() to convert back to our original type
	var actual MongodbRoleDefinition
	err = actual.AssignProperties_From_MongodbRoleDefinition(&other)
	if err != nil {
		return err.Error()
	}

	// Check for a match
	match := cmp.Equal(subject, actual, cmpopts.EquateEmpty())
	if !match {
		actualFmt := pretty.Sprint(actual)
		subjectFmt := pretty.Sprint(subject)
		result := diff.Diff(subjectFmt, actualFmt)
		return result
	}

	return ""
}

func Test_MongodbRoleDefinition_WhenSerializedToJson_DeserializesAsEqual(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MinSuccessfulTests = 20
	parameters.MaxSize = 3
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip of MongodbRoleDefinition via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForMongodbRoleDefinition, MongodbRoleDefinitionGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

// RunJSONSerializationTestForMongodbRoleDefinition runs a test to see if a specific instance of MongodbRoleDefinition round trips to JSON and back losslessly
func RunJSONSerializationTestForMongodbRoleDefinition(subject MongodbRoleDefinition) string {
	// Serialize to JSON
	bin, err := json.Marshal(subject)
	if err != nil {
		return err.Error()
	}

	// Deserialize back into memory
	var actual MongodbRoleDefinition
	err = json.Unmarshal(bin, &actual)
	if err != nil {
		return err.Error()
	}

	// Check for outcome
	match := cmp.Equal(subject, actual, cmpopts.EquateEmpty())
	if !match {
		actualFmt := pretty.Sprint(actual)
		subjectFmt := pretty.Sprint(subject)
		result := diff.Diff(subjectFmt, actualFmt)
		return result
	}

	return ""
}

// Generator of MongodbRoleDefinition instances for property testing - lazily instantiated by
// MongodbRoleDefinitionGenerator()
var mongodbRoleDefinitionGenerator gopter.Gen

// MongodbRoleDefinitionGenerator returns a generator of MongodbRoleDefinition instances for property testing.
func MongodbRoleDefinitionGenerator() gopter.Gen {
	if mongodbRoleDefinitionGenerator != nil {
		return mongodbRoleDefinitionGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddRelatedPropertyGeneratorsForMongodbRoleDefinition(generators)
	mongodbRoleDefinitionGenerator = gen.Struct(reflect.TypeOf(MongodbRoleDefinition{}), generators)

	return mongodbRoleDefinitionGenerator
}

// AddRelatedPropertyGeneratorsForMongodbRoleDefinition is a factory method for creating gopter generators
func AddRelatedPropertyGeneratorsForMongodbRoleDefinition(gens map[string]gopter.Gen) {
	gens["Spec"] = MongodbRoleDefinition_SpecGenerator()
	gens["Status"] = MongodbRoleDefinition_STATUSGenerator()
}

func Test_MongodbRoleDefinitionOperatorSpec_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from MongodbRoleDefinitionOperatorSpec to MongodbRoleDefinitionOperatorSpec via AssignProperties_To_MongodbRoleDefinitionOperatorSpec & AssignProperties_From_MongodbRoleDefinitionOperatorSpec returns original",
		prop.ForAll(RunPropertyAssignmentTestForMongodbRoleDefinitionOperatorSpec, MongodbRoleDefinitionOperatorSpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

// RunPropertyAssignmentTestForMongodbRoleDefinitionOperatorSpec tests if a specific instance of MongodbRoleDefinitionOperatorSpec can be assigned to storage and back losslessly
func RunPropertyAssignmentTestForMongodbRoleDefinitionOperatorSpec(subject MongodbRoleDefinitionOperatorSpec) string {
	// Copy subject to make sure assignment doesn't modify it
	copied := subject.DeepCopy()

	// Use AssignPropertiesTo() for the first stage of conversion
	var other storage.MongodbRoleDefinitionOperatorSpec
	err := copied.AssignProperties_To_MongodbRoleDefinitionOperatorSpec(&other)
	if err != nil {
		return err.Error()
	}

	// Use AssignPropertiesFrom() to convert back to our original type
	var actual MongodbRoleDefinitionOperatorSpec
	err = actual.AssignProperties_From_MongodbRoleDefinitionOperatorSpec(&other)
	if err != nil {
		return err.Error()
	}

	// Check for a match
	match := cmp.Equal(subject, actual, cmpopts.EquateEmpty())
	if !match {
		actualFmt := pretty.Sprint(actual)
		subjectFmt := pretty.Sprint(subject)
		result := diff.Diff(subjectFmt, actualFmt)
		return result
	}

	return ""
}

func Test_MongodbRoleDefinitionOperatorSpec_WhenSerializedToJson_DeserializesAsEqual(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MinSuccessfulTests = 100
	parameters.MaxSize = 3
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip of MongodbRoleDefinitionOperatorSpec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForMongodbRoleDefinitionOperatorSpec, MongodbRoleDefinitionOperatorSpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

// RunJSONSerializationTestForMongodbRoleDefinitionOperatorSpec runs a test to see if a specific instance of MongodbRoleDefinitionOperatorSpec round trips to JSON and back losslessly
func RunJSONSerializationTestForMongodbRoleDefinitionOperatorSpec(subject MongodbRoleDefinitionOperatorSpec) string {
	// Serialize to JSON
	bin, err := json.Marshal(subject)
	if err != nil {
		return err.Error()
	}

	// Deserialize back into memory
	var actual MongodbRoleDefinitionOperatorSpec
	err = json.Unmarshal(bin, &actual)
	if err != nil {
		return err.Error()
	}

	// Check for outcome
	match := cmp.Equal(subject, actual, cmpopts.EquateEmpty())
	if !match {
		actualFmt := pretty.Sprint(actual)
		subjectFmt := pretty.Sprint(subject)
		result := diff.Diff(subjectFmt, actualFmt)
		return result
	}

	return ""
}

// Generator of MongodbRoleDefinitionOperatorSpec instances for property testing - lazily instantiated by
// MongodbRoleDefinitionOperatorSpecGenerator()
var mongodbRoleDefinitionOperatorSpecGenerator gopter.Gen

// MongodbRoleDefinitionOperatorSpecGenerator returns a generator of MongodbRoleDefinitionOperatorSpec instances for property testing.
func MongodbRoleDefinitionOperatorSpecGenerator() gopter.Gen {
	if mongodbRoleDefinitionOperatorSpecGenerator != nil {
		return mongodbRoleDefinitionOperatorSpecGenerator
	}

	generators := make(map[string]gopter.Gen)
	mongodbRoleDefinitionOperatorSpecGenerator = gen.Struct(reflect.TypeOf(MongodbRoleDefinitionOperatorSpec{}), generators)

	return mongodbRoleDefinitionOperatorSpecGenerator
}

func Test_MongodbRoleDefinition_STATUS_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from MongodbRoleDefinition_STATUS to MongodbRoleDefinition_STATUS via AssignProperties_To_MongodbRoleDefinition_STATUS & AssignProperties_From_MongodbRoleDefinition_STATUS returns original",
		prop.ForAll(RunPropertyAssignmentTestForMongodbRoleDefinition_STATUS, MongodbRoleDefinition_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

// RunPropertyAssignmentTestForMongodbRoleDefinition_STATUS tests if a specific instance of MongodbRoleDefinition_STATUS can be assigned to storage and back losslessly
func RunPropertyAssignmentTestForMongodbRoleDefinition_STATUS(subject MongodbRoleDefinition_STATUS) string {
	// Copy subject to make sure assignment doesn't modify it
	copied := subject.DeepCopy()

	// Use AssignPropertiesTo() for the first stage of conversion
	var other storage.MongodbRoleDefinition_STATUS
	err := copied.AssignProperties_To_MongodbRoleDefinition_STATUS(&other)
	if err != nil {
		return err.Error()
	}

	// Use AssignPropertiesFrom() to convert back to our original type
	var actual MongodbRoleDefinition_STATUS
	err = actual.AssignProperties_From_MongodbRoleDefinition_STATUS(&other)
	if err != nil {
		return err.Error()
	}

	// Check for a match
	match := cmp.Equal(subject, actual, cmpopts.EquateEmpty())
	if !match {
		actualFmt := pretty.Sprint(actual)
		subjectFmt := pretty.Sprint(subject)
		result := diff.Diff(subjectFmt, actualFmt)
		return result
	}

	return ""
}

func Test_MongodbRoleDefinition_STATUS_WhenSerializedToJson_DeserializesAsEqual(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MinSuccessfulTests = 80
	parameters.MaxSize = 3
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip of MongodbRoleDefinition_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForMongodbRoleDefinition_STATUS, MongodbRoleDefinition_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

// RunJSONSerializationTestForMongodbRoleDefinition_STATUS runs a test to see if a specific instance of MongodbRoleDefinition_STATUS round trips to JSON and back losslessly
func RunJSONSerializationTestForMongodbRoleDefinition_STATUS(subject MongodbRoleDefinition_STATUS) string {
	// Serialize to JSON
	bin, err := json.Marshal(subject)
	if err != nil {
		return err.Error()
	}

	// Deserialize back into memory
	var actual MongodbRoleDefinition_STATUS
	err = json.Unmarshal(bin, &actual)
	if err != nil {
		return err.Error()
	}

	// Check for outcome
	match := cmp.Equal(subject, actual, cmpopts.EquateEmpty())
	if !match {
		actualFmt := pretty.Sprint(actual)
		subjectFmt := pretty.Sprint(subject)
		result := diff.Diff(subjectFmt, actualFmt)
		return result
	}

	return ""
}

// Generator of MongodbRoleDefinition_STATUS instances for property testing - lazily instantiated by
// MongodbRoleDefinition_STATUSGenerator()
var mongodbRoleDefinition_STATUSGenerator gopter.Gen

// MongodbRoleDefinition_STATUSGenerator returns a generator of MongodbRoleDefinition_STATUS instances for property testing.
// We first initialize mongodbRoleDefinition_STATUSGenerator with a simplified generator based on the
// fields with primitive types then replacing it with a more complex one that also handles complex fields
// to ensure any cycles in the object graph properly terminate.
func MongodbRoleDefinition_STATUSGenerator() gopter.Gen {
	if mongodbRoleDefinition_STATUSGenerator != nil {
		return mongodbRoleDefinition_STATUSGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForMongodbRoleDefinition_STATUS(generators)
	mongodbRoleDefinition_STATUSGenerator = gen.Struct(reflect.TypeOf(MongodbRoleDefinition_STATUS{}), generators)

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForMongodbRoleDefinition_STATUS(generators)
	AddRelatedPropertyGeneratorsForMongodbRoleDefinition_STATUS(generators)
	mongodbRoleDefinition_STATUSGenerator = gen.Struct(reflect.TypeOf(MongodbRoleDefinition_STATUS{}), generators)

	return mongodbRoleDefinition_STATUSGenerator
}

// AddIndependentPropertyGeneratorsForMongodbRoleDefinition_STATUS is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForMongodbRoleDefinition_STATUS(gens map[string]gopter.Gen) {
	gens["DatabaseName"] = gen.PtrOf(gen.AlphaString())
	gens["Id"] = gen.PtrOf(gen.AlphaString())
	gens["Name"] = gen.PtrOf(gen.AlphaString())
	gens["RoleName"] = gen.PtrOf(gen.AlphaString())
	gens["Type"] = gen.PtrOf(gen.AlphaString())
}

// AddRelatedPropertyGeneratorsForMongodbRoleDefinition_STATUS is a factory method for creating gopter generators
func AddRelatedPropertyGeneratorsForMongodbRoleDefinition_STATUS(gens map[string]gopter.Gen) {
	gens["Privileges"] = gen.SliceOf(Privilege_STATUSGenerator())
	gens["Roles"] = gen.SliceOf(Role_STATUSGenerator())
}

func Test_MongodbRoleDefinition_Spec_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from MongodbRoleDefinition_Spec to MongodbRoleDefinition_Spec via AssignProperties_To_MongodbRoleDefinition_Spec & AssignProperties_From_MongodbRoleDefinition_Spec returns original",
		prop.ForAll(RunPropertyAssignmentTestForMongodbRoleDefinition_Spec, MongodbRoleDefinition_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

// RunPropertyAssignmentTestForMongodbRoleDefinition_Spec tests if a specific instance of MongodbRoleDefinition_Spec can be assigned to storage and back losslessly
func RunPropertyAssignmentTestForMongodbRoleDefinition_Spec(subject MongodbRoleDefinition_Spec) string {
	// Copy subject to make sure assignment doesn't modify it
	copied := subject.DeepCopy()

	// Use AssignPropertiesTo() for the first stage of conversion
	var other storage.MongodbRoleDefinition_Spec
	err := copied.AssignProperties_To_MongodbRoleDefinition_Spec(&other)
	if err != nil {
		return err.Error()
	}

	// Use AssignPropertiesFrom() to convert back to our original type
	var actual MongodbRoleDefinition_Spec
	err = actual.AssignProperties_From_MongodbRoleDefinition_Spec(&other)
	if err != nil {
		return err.Error()
	}

	// Check for a match
	match := cmp.Equal(subject, actual, cmpopts.EquateEmpty())
	if !match {
		actualFmt := pretty.Sprint(actual)
		subjectFmt := pretty.Sprint(subject)
		result := diff.Diff(subjectFmt, actualFmt)
		return result
	}

	return ""
}

func Test_MongodbRoleDefinition_Spec_WhenSerializedToJson_DeserializesAsEqual(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MinSuccessfulTests = 80
	parameters.MaxSize = 3
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip of MongodbRoleDefinition_Spec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForMongodbRoleDefinition_Spec, MongodbRoleDefinition_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

// RunJSONSerializationTestForMongodbRoleDefinition_Spec runs a test to see if a specific instance of MongodbRoleDefinition_Spec round trips to JSON and back losslessly
func RunJSONSerializationTestForMongodbRoleDefinition_Spec(subject MongodbRoleDefinition_Spec) string {
	// Serialize to JSON
	bin, err := json.Marshal(subject)
	if err != nil {
		return err.Error()
	}

	// Deserialize back into memory
	var actual MongodbRoleDefinition_Spec
	err = json.Unmarshal(bin, &actual)
	if err != nil {
		return err.Error()
	}

	// Check for outcome
	match := cmp.Equal(subject, actual, cmpopts.EquateEmpty())
	if !match {
		actualFmt := pretty.Sprint(actual)
		subjectFmt := pretty.Sprint(subject)
		result := diff.Diff(subjectFmt, actualFmt)
		return result
	}

	return ""
}

// Generator of MongodbRoleDefinition_Spec instances for property testing - lazily instantiated by
// MongodbRoleDefinition_SpecGenerator()
var mongodbRoleDefinition_SpecGenerator gopter.Gen

// MongodbRoleDefinition_SpecGenerator returns a generator of MongodbRoleDefinition_Spec instances for property testing.
// We first initialize mongodbRoleDefinition_SpecGenerator with a simplified generator based on the
// fields with primitive types then replacing it with a more complex one that also handles complex fields
// to ensure any cycles in the object graph properly terminate.
func MongodbRoleDefinition_SpecGenerator() gopter.Gen {
	if mongodbRoleDefinition_SpecGenerator != nil {
		return mongodbRoleDefinition_SpecGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForMongodbRoleDefinition_Spec(generators)
	mongodbRoleDefinition_SpecGenerator = gen.Struct(reflect.TypeOf(MongodbRoleDefinition_Spec{}), generators)

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForMongodbRoleDefinition_Spec(generators)
	AddRelatedPropertyGeneratorsForMongodbRoleDefinition_Spec(generators)
	mongodbRoleDefinition_SpecGenerator = gen.Struct(reflect.TypeOf(MongodbRoleDefinition_Spec{}), generators)

	return mongodbRoleDefinition_SpecGenerator
}

// AddIndependentPropertyGeneratorsForMongodbRoleDefinition_Spec is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForMongodbRoleDefinition_Spec(gens map[string]gopter.Gen) {
	gens["AzureName"] = gen.AlphaString()
	gens["DatabaseName"] = gen.PtrOf(gen.AlphaString())
	gens["RoleName"] = gen.PtrOf(gen.AlphaString())
	gens["Type"] = gen.PtrOf(gen.OneConstOf(MongoRoleDefinitionResource_Type_BuiltInRole, MongoRoleDefinitionResource_Type_CustomRole))
}

// AddRelatedPropertyGeneratorsForMongodbRoleDefinition_Spec is a factory method for creating gopter generators
func AddRelatedPropertyGeneratorsForMongodbRoleDefinition_Spec(gens map[string]gopter.Gen) {
	gens["OperatorSpec"] = gen.PtrOf(MongodbRoleDefinitionOperatorSpecGenerator())
	gens["Privileges"] = gen.SliceOf(PrivilegeGenerator())
	gens["Roles"] = gen.SliceOf(RoleGenerator())
}

func Test_Privilege_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from Privilege to Privilege via AssignProperties_To_Privilege & AssignProperties_From_Privilege returns original",
		prop.ForAll(RunPropertyAssignmentTestForPrivilege, PrivilegeGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

// RunPropertyAssignmentTestForPrivilege tests if a specific instance of Privilege can be assigned to storage and back losslessly
func RunPropertyAssignmentTestForPrivilege(subject Privilege) string {
	// Copy subject to make sure assignment doesn't modify it
	copied := subject.DeepCopy()

	// Use AssignPropertiesTo() for the first stage of conversion
	var other storage.Privilege
	err := copied.AssignProperties_To_Privilege(&other)
	if err != nil {
		return err.Error()
	}

	// Use AssignPropertiesFrom() to convert back to our original type
	var actual Privilege
	err = actual.AssignProperties_From_Privilege(&other)
	if err != nil {
		return err.Error()
	}

	// Check for a match
	match := cmp.Equal(subject, actual, cmpopts.EquateEmpty())
	if !match {
		actualFmt := pretty.Sprint(actual)
		subjectFmt := pretty.Sprint(subject)
		result := diff.Diff(subjectFmt, actualFmt)
		return result
	}

	return ""
}

func Test_Privilege_WhenSerializedToJson_DeserializesAsEqual(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MinSuccessfulTests = 100
	parameters.MaxSize = 3
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip of Privilege via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForPrivilege, PrivilegeGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

// RunJSONSerializationTestForPrivilege runs a test to see if a specific instance of Privilege round trips to JSON and back losslessly
func RunJSONSerializationTestForPrivilege(subject Privilege) string {
	// Serialize to JSON
	bin, err := json.Marshal(subject)
	if err != nil {
		return err.Error()
	}

	// Deserialize back into memory
	var actual Privilege
	err = json.Unmarshal(bin, &actual)
	if err != nil {
		return err.Error()
	}

	// Check for outcome
	match := cmp.Equal(subject, actual, cmpopts.EquateEmpty())
	if !match {
		actualFmt := pretty.Sprint(actual)
		subjectFmt := pretty.Sprint(subject)
		result := diff.Diff(subjectFmt, actualFmt)
		return result
	}

	return ""
}

// Generator of Privilege instances for property testing - lazily instantiated by PrivilegeGenerator()
var privilegeGenerator gopter.Gen

// PrivilegeGenerator returns a generator of Privilege instances for property testing.
// We first initialize privilegeGenerator with a simplified generator based on the
// fields with primitive types then replacing it with a more complex one that also handles complex fields
// to ensure any cycles in the object graph properly terminate.
func PrivilegeGenerator() gopter.Gen {
	if privilegeGenerator != nil {
		return privilegeGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForPrivilege(generators)
	privilegeGenerator = gen.Struct(reflect.TypeOf(Privilege{}), generators)

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForPrivilege(generators)
	AddRelatedPropertyGeneratorsForPrivilege(generators)
	privilegeGenerator = gen.Struct(reflect.TypeOf(Privilege{}), generators)

	return privilegeGenerator
}

// AddIndependentPropertyGeneratorsForPrivilege is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForPrivilege(gens map[string]gopter.Gen) {
	gens["Actions"] = gen.SliceOf(gen.AlphaString())
}

// AddRelatedPropertyGeneratorsForPrivilege is a factory method for creating gopter generators
func AddRelatedPropertyGeneratorsForPrivilege(gens map[string]gopter.Gen) {
	gens["Resource"] = gen.PtrOf(Privilege_ResourceGenerator())
}

func Test_Privilege_Resource_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from Privilege_Resource to Privilege_Resource via AssignProperties_To_Privilege_Resource & AssignProperties_From_Privilege_Resource returns original",
		prop.ForAll(RunPropertyAssignmentTestForPrivilege_Resource, Privilege_ResourceGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

// RunPropertyAssignmentTestForPrivilege_Resource tests if a specific instance of Privilege_Resource can be assigned to storage and back losslessly
func RunPropertyAssignmentTestForPrivilege_Resource(subject Privilege_Resource) string {
	// Copy subject to make sure assignment doesn't modify it
	copied := subject.DeepCopy()

	// Use AssignPropertiesTo() for the first stage of conversion
	var other storage.Privilege_Resource
	err := copied.AssignProperties_To_Privilege_Resource(&other)
	if err != nil {
		return err.Error()
	}

	// Use AssignPropertiesFrom() to convert back to our original type
	var actual Privilege_Resource
	err = actual.AssignProperties_From_Privilege_Resource(&other)
	if err != nil {
		return err.Error()
	}

	// Check for a match
	match := cmp.Equal(subject, actual, cmpopts.EquateEmpty())
	if !match {
		actualFmt := pretty.Sprint(actual)
		subjectFmt := pretty.Sprint(subject)
		result := diff.Diff(subjectFmt, actualFmt)
		return result
	}

	return ""
}

func Test_Privilege_Resource_WhenSerializedToJson_DeserializesAsEqual(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MinSuccessfulTests = 100
	parameters.MaxSize = 3
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip of Privilege_Resource via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForPrivilege_Resource, Privilege_ResourceGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

// RunJSONSerializationTestForPrivilege_Resource runs a test to see if a specific instance of Privilege_Resource round trips to JSON and back losslessly
func RunJSONSerializationTestForPrivilege_Resource(subject Privilege_Resource) string {
	// Serialize to JSON
	bin, err := json.Marshal(subject)
	if err != nil {
		return err.Error()
	}

	// Deserialize back into memory
	var actual Privilege_Resource
	err = json.Unmarshal(bin, &actual)
	if err != nil {
		return err.Error()
	}

	// Check for outcome
	match := cmp.Equal(subject, actual, cmpopts.EquateEmpty())
	if !match {
		actualFmt := pretty.Sprint(actual)
		subjectFmt := pretty.Sprint(subject)
		result := diff.Diff(subjectFmt, actualFmt)
		return result
	}

	return ""
}

// Generator of Privilege_Resource instances for property testing - lazily instantiated by Privilege_ResourceGenerator()
var privilege_ResourceGenerator gopter.Gen

// Privilege_ResourceGenerator returns a generator of Privilege_Resource instances for property testing.
func Privilege_ResourceGenerator() gopter.Gen {
	if privilege_ResourceGenerator != nil {
		return privilege_ResourceGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForPrivilege_Resource(generators)
	privilege_ResourceGenerator = gen.Struct(reflect.TypeOf(Privilege_Resource{}), generators)

	return privilege_ResourceGenerator
}

// AddIndependentPropertyGeneratorsForPrivilege_Resource is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForPrivilege_Resource(gens map[string]gopter.Gen) {
	gens["Collection"] = gen.PtrOf(gen.AlphaString())
	gens["Db"] = gen.PtrOf(gen.AlphaString())
}

func Test_Privilege_Resource_STATUS_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from Privilege_Resource_STATUS to Privilege_Resource_STATUS via AssignProperties_To_Privilege_Resource_STATUS & AssignProperties_From_Privilege_Resource_STATUS returns original",
		prop.ForAll(RunPropertyAssignmentTestForPrivilege_Resource_STATUS, Privilege_Resource_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

// RunPropertyAssignmentTestForPrivilege_Resource_STATUS tests if a specific instance of Privilege_Resource_STATUS can be assigned to storage and back losslessly
func RunPropertyAssignmentTestForPrivilege_Resource_STATUS(subject Privilege_Resource_STATUS) string {
	// Copy subject to make sure assignment doesn't modify it
	copied := subject.DeepCopy()

	// Use AssignPropertiesTo() for the first stage of conversion
	var other storage.Privilege_Resource_STATUS
	err := copied.AssignProperties_To_Privilege_Resource_STATUS(&other)
	if err != nil {
		return err.Error()
	}

	// Use AssignPropertiesFrom() to convert back to our original type
	var actual Privilege_Resource_STATUS
	err = actual.AssignProperties_From_Privilege_Resource_STATUS(&other)
	if err != nil {
		return err.Error()
	}

	// Check for a match
	match := cmp.Equal(subject, actual, cmpopts.EquateEmpty())
	if !match {
		actualFmt := pretty.Sprint(actual)
		subjectFmt := pretty.Sprint(subject)
		result := diff.Diff(subjectFmt, actualFmt)
		return result
	}

	return ""
}

func Test_Privilege_Resource_STATUS_WhenSerializedToJson_DeserializesAsEqual(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MinSuccessfulTests = 80
	parameters.MaxSize = 3
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip of Privilege_Resource_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForPrivilege_Resource_STATUS, Privilege_Resource_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

// RunJSONSerializationTestForPrivilege_Resource_STATUS runs a test to see if a specific instance of Privilege_Resource_STATUS round trips to JSON and back losslessly
func RunJSONSerializationTestForPrivilege_Resource_STATUS(subject Privilege_Resource_STATUS) string {
	// Serialize to JSON
	bin, err := json.Marshal(subject)
	if err != nil {
		return err.Error()
	}

	// Deserialize back into memory
	var actual Privilege_Resource_STATUS
	err = json.Unmarshal(bin, &actual)
	if err != nil {
		return err.Error()
	}

	// Check for outcome
	match := cmp.Equal(subject, actual, cmpopts.EquateEmpty())
	if !match {
		actualFmt := pretty.Sprint(actual)
		subjectFmt := pretty.Sprint(subject)
		result := diff.Diff(subjectFmt, actualFmt)
		return result
	}

	return ""
}

// Generator of Privilege_Resource_STATUS instances for property testing - lazily instantiated by
// Privilege_Resource_STATUSGenerator()
var privilege_Resource_STATUSGenerator gopter.Gen

// Privilege_Resource_STATUSGenerator returns a generator of Privilege_Resource_STATUS instances for property testing.
func Privilege_Resource_STATUSGenerator() gopter.Gen {
	if privilege_Resource_STATUSGenerator != nil {
		return privilege_Resource_STATUSGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForPrivilege_Resource_STATUS(generators)
	privilege_Resource_STATUSGenerator = gen.Struct(reflect.TypeOf(Privilege_Resource_STATUS{}), generators)

	return privilege_Resource_STATUSGenerator
}

// AddIndependentPropertyGeneratorsForPrivilege_Resource_STATUS is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForPrivilege_Resource_STATUS(gens map[string]gopter.Gen) {
	gens["Collection"] = gen.PtrOf(gen.AlphaString())
	gens["Db"] = gen.PtrOf(gen.AlphaString())
}

func Test_Privilege_STATUS_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from Privilege_STATUS to Privilege_STATUS via AssignProperties_To_Privilege_STATUS & AssignProperties_From_Privilege_STATUS returns original",
		prop.ForAll(RunPropertyAssignmentTestForPrivilege_STATUS, Privilege_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

// RunPropertyAssignmentTestForPrivilege_STATUS tests if a specific instance of Privilege_STATUS can be assigned to storage and back losslessly
func RunPropertyAssignmentTestForPrivilege_STATUS(subject Privilege_STATUS) string {
	// Copy subject to make sure assignment doesn't modify it
	copied := subject.DeepCopy()

	// Use AssignPropertiesTo() for the first stage of conversion
	var other storage.Privilege_STATUS
	err := copied.AssignProperties_To_Privilege_STATUS(&other)
	if err != nil {
		return err.Error()
	}

	// Use AssignPropertiesFrom() to convert back to our original type
	var actual Privilege_STATUS
	err = actual.AssignProperties_From_Privilege_STATUS(&other)
	if err != nil {
		return err.Error()
	}

	// Check for a match
	match := cmp.Equal(subject, actual, cmpopts.EquateEmpty())
	if !match {
		actualFmt := pretty.Sprint(actual)
		subjectFmt := pretty.Sprint(subject)
		result := diff.Diff(subjectFmt, actualFmt)
		return result
	}

	return ""
}

func Test_Privilege_STATUS_WhenSerializedToJson_DeserializesAsEqual(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MinSuccessfulTests = 80
	parameters.MaxSize = 3
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip of Privilege_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForPrivilege_STATUS, Privilege_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

// RunJSONSerializationTestForPrivilege_STATUS runs a test to see if a specific instance of Privilege_STATUS round trips to JSON and back losslessly
func RunJSONSerializationTestForPrivilege_STATUS(subject Privilege_STATUS) string {
	// Serialize to JSON
	bin, err := json.Marshal(subject)
	if err != nil {
		return err.Error()
	}

	// Deserialize back into memory
	var actual Privilege_STATUS
	err = json.Unmarshal(bin, &actual)
	if err != nil {
		return err.Error()
	}

	// Check for outcome
	match := cmp.Equal(subject, actual, cmpopts.EquateEmpty())
	if !match {
		actualFmt := pretty.Sprint(actual)
		subjectFmt := pretty.Sprint(subject)
		result := diff.Diff(subjectFmt, actualFmt)
		return result
	}

	return ""
}

// Generator of Privilege_STATUS instances for property testing - lazily instantiated by Privilege_STATUSGenerator()
var privilege_STATUSGenerator gopter.Gen

// Privilege_STATUSGenerator returns a generator of Privilege_STATUS instances for property testing.
// We first initialize privilege_STATUSGenerator with a simplified generator based on the
// fields with primitive types then replacing it with a more complex one that also handles complex fields
// to ensure any cycles in the object graph properly terminate.
func Privilege_STATUSGenerator() gopter.Gen {
	if privilege_STATUSGenerator != nil {
		return privilege_STATUSGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForPrivilege_STATUS(generators)
	privilege_STATUSGenerator = gen.Struct(reflect.TypeOf(Privilege_STATUS{}), generators)

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForPrivilege_STATUS(generators)
	AddRelatedPropertyGeneratorsForPrivilege_STATUS(generators)
	privilege_STATUSGenerator = gen.Struct(reflect.TypeOf(Privilege_STATUS{}), generators)

	return privilege_STATUSGenerator
}

// AddIndependentPropertyGeneratorsForPrivilege_STATUS is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForPrivilege_STATUS(gens map[string]gopter.Gen) {
	gens["Actions"] = gen.SliceOf(gen.AlphaString())
}

// AddRelatedPropertyGeneratorsForPrivilege_STATUS is a factory method for creating gopter generators
func AddRelatedPropertyGeneratorsForPrivilege_STATUS(gens map[string]gopter.Gen) {
	gens["Resource"] = gen.PtrOf(Privilege_Resource_STATUSGenerator())
}

func Test_Role_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from Role to Role via AssignProperties_To_Role & AssignProperties_From_Role returns original",
		prop.ForAll(RunPropertyAssignmentTestForRole, RoleGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

// RunPropertyAssignmentTestForRole tests if a specific instance of Role can be assigned to storage and back losslessly
func RunPropertyAssignmentTestForRole(subject Role) string {
	// Copy subject to make sure assignment doesn't modify it
	copied := subject.DeepCopy()

	// Use AssignPropertiesTo() for the first stage of conversion
	var other storage.Role
	err := copied.AssignProperties_To_Role(&other)
	if err != nil {
		return err.Error()
	}

	// Use AssignPropertiesFrom() to convert back to our original type
	var actual Role
	err = actual.AssignProperties_From_Role(&other)
	if err != nil {
		return err.Error()
	}

	// Check for a match
	match := cmp.Equal(subject, actual, cmpopts.EquateEmpty())
	if !match {
		actualFmt := pretty.Sprint(actual)
		subjectFmt := pretty.Sprint(subject)
		result := diff.Diff(subjectFmt, actualFmt)
		return result
	}

	return ""
}

func Test_Role_WhenSerializedToJson_DeserializesAsEqual(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MinSuccessfulTests = 100
	parameters.MaxSize = 3
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip of Role via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForRole, RoleGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

// RunJSONSerializationTestForRole runs a test to see if a specific instance of Role round trips to JSON and back losslessly
func RunJSONSerializationTestForRole(subject Role) string {
	// Serialize to JSON
	bin, err := json.Marshal(subject)
	if err != nil {
		return err.Error()
	}

	// Deserialize back into memory
	var actual Role
	err = json.Unmarshal(bin, &actual)
	if err != nil {
		return err.Error()
	}

	// Check for outcome
	match := cmp.Equal(subject, actual, cmpopts.EquateEmpty())
	if !match {
		actualFmt := pretty.Sprint(actual)
		subjectFmt := pretty.Sprint(subject)
		result := diff.Diff(subjectFmt, actualFmt)
		return result
	}

	return ""
}

// Generator of Role instances for property testing - lazily instantiated by RoleGenerator()
var roleGenerator gopter.Gen

// RoleGenerator returns a generator of Role instances for property testing.
func RoleGenerator() gopter.Gen {
	if roleGenerator != nil {
		return roleGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForRole(generators)
	roleGenerator = gen.Struct(reflect.TypeOf(Role{}), generators)

	return roleGenerator
}

// AddIndependentPropertyGeneratorsForRole is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForRole(gens map[string]gopter.Gen) {
	gens["Db"] = gen.PtrOf(gen.AlphaString())
	gens["Role"] = gen.PtrOf(gen.AlphaString())
}

func Test_Role_STATUS_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from Role_STATUS to Role_STATUS via AssignProperties_To_Role_STATUS & AssignProperties_From_Role_STATUS returns original",
		prop.ForAll(RunPropertyAssignmentTestForRole_STATUS, Role_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

// RunPropertyAssignmentTestForRole_STATUS tests if a specific instance of Role_STATUS can be assigned to storage and back losslessly
func RunPropertyAssignmentTestForRole_STATUS(subject Role_STATUS) string {
	// Copy subject to make sure assignment doesn't modify it
	copied := subject.DeepCopy()

	// Use AssignPropertiesTo() for the first stage of conversion
	var other storage.Role_STATUS
	err := copied.AssignProperties_To_Role_STATUS(&other)
	if err != nil {
		return err.Error()
	}

	// Use AssignPropertiesFrom() to convert back to our original type
	var actual Role_STATUS
	err = actual.AssignProperties_From_Role_STATUS(&other)
	if err != nil {
		return err.Error()
	}

	// Check for a match
	match := cmp.Equal(subject, actual, cmpopts.EquateEmpty())
	if !match {
		actualFmt := pretty.Sprint(actual)
		subjectFmt := pretty.Sprint(subject)
		result := diff.Diff(subjectFmt, actualFmt)
		return result
	}

	return ""
}

func Test_Role_STATUS_WhenSerializedToJson_DeserializesAsEqual(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MinSuccessfulTests = 80
	parameters.MaxSize = 3
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip of Role_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForRole_STATUS, Role_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

// RunJSONSerializationTestForRole_STATUS runs a test to see if a specific instance of Role_STATUS round trips to JSON and back losslessly
func RunJSONSerializationTestForRole_STATUS(subject Role_STATUS) string {
	// Serialize to JSON
	bin, err := json.Marshal(subject)
	if err != nil {
		return err.Error()
	}

	// Deserialize back into memory
	var actual Role_STATUS
	err = json.Unmarshal(bin, &actual)
	if err != nil {
		return err.Error()
	}

	// Check for outcome
	match := cmp.Equal(subject, actual, cmpopts.EquateEmpty())
	if !match {
		actualFmt := pretty.Sprint(actual)
		subjectFmt := pretty.Sprint(subject)
		result := diff.Diff(subjectFmt, actualFmt)
		return result
	}

	return ""
}

// Generator of Role_STATUS instances for property testing - lazily instantiated by Role_STATUSGenerator()
var role_STATUSGenerator gopter.Gen

// Role_STATUSGenerator returns a generator of Role_STATUS instances for property testing.
func Role_STATUSGenerator() gopter.Gen {
	if role_STATUSGenerator != nil {
		return role_STATUSGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForRole_STATUS(generators)
	role_STATUSGenerator = gen.Struct(reflect.TypeOf(Role_STATUS{}), generators)

	return role_STATUSGenerator
}

// AddIndependentPropertyGeneratorsForRole_STATUS is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForRole_STATUS(gens map[string]gopter.Gen) {
	gens["Db"] = gen.PtrOf(gen.AlphaString())
	gens["Role"] = gen.PtrOf(gen.AlphaString())
}
