<commit_before>package testfixture

import (
	"fmt"
	"math/rand"
	"strings"

	"github.com/fabric8-services/fabric8-wit/account"
	"github.com/fabric8-services/fabric8-wit/area"
	"github.com/fabric8-services/fabric8-wit/codebase"
	"github.com/fabric8-services/fabric8-wit/comment"
	"github.com/fabric8-services/fabric8-wit/iteration"
	"github.com/fabric8-services/fabric8-wit/label"
	"github.com/fabric8-services/fabric8-wit/query"
	"github.com/fabric8-services/fabric8-wit/remoteworkitem"
	"github.com/fabric8-services/fabric8-wit/rendering"
	"github.com/fabric8-services/fabric8-wit/space"
	testsupport "github.com/fabric8-services/fabric8-wit/test"
	"github.com/fabric8-services/fabric8-wit/workitem"
	"github.com/fabric8-services/fabric8-wit/workitem/link"
	errs "github.com/pkg/errors"
	uuid "github.com/satori/go.uuid"
)

func makeIdentities(fxt *TestFixture) error {
	if fxt.info[kindIdentities] == nil {
		return nil
	}
	fxt.Identities = make([]*account.Identity, fxt.info[kindIdentities].numInstances)
	for i := range fxt.Identities {
		fxt.Identities[i] = &account.Identity{
			Username:     testsupport.CreateRandomValidTestName("<NAME> "),
			ProviderType: "test provider", // alternatively: account.KeycloakIDP
		}
		if err := fxt.runCustomizeEntityFuncs(i, kindIdentities); err != nil {
			return errs.WithStack(err)
		}
		err := testsupport.CreateTestIdentityForAccountIdentity(fxt.db, fxt.Identities[i])
		if err != nil {
			return errs.Wrapf(err, "failed to create identity: %+v", fxt.Identities[i])
		}
	}
	return nil
}

func makeWorkItemLinkCategories(fxt *TestFixture) error {
	if fxt.info[kindWorkItemLinkCategories] == nil {
		return nil
	}
	fxt.WorkItemLinkCategories = make([]*link.WorkItemLinkCategory, fxt.info[kindWorkItemLinkCategories].numInstances)
	wilcRepo := link.NewWorkItemLinkCategoryRepository(fxt.db)
	for i := range fxt.WorkItemLinkCategories {
		desc := "some description"
		fxt.WorkItemLinkCategories[i] = &link.WorkItemLinkCategory{
			Name:        testsupport.CreateRandomValidTestName("link category "),
			Description: &desc,
		}
		if err := fxt.runCustomizeEntityFuncs(i, kindWorkItemLinkCategories); err != nil {
			return errs.WithStack(err)
		}
		_, err := wilcRepo.Create(fxt.ctx, fxt.WorkItemLinkCategories[i])<commit_msg>Use account.KeycloakIDP instead of "test provider" (#2000)<commit_after>package testfixture

import (
	"fmt"
	"math/rand"
	"strings"

	"github.com/fabric8-services/fabric8-wit/account"
	"github.com/fabric8-services/fabric8-wit/area"
	"github.com/fabric8-services/fabric8-wit/codebase"
	"github.com/fabric8-services/fabric8-wit/comment"
	"github.com/fabric8-services/fabric8-wit/iteration"
	"github.com/fabric8-services/fabric8-wit/label"
	"github.com/fabric8-services/fabric8-wit/query"
	"github.com/fabric8-services/fabric8-wit/remoteworkitem"
	"github.com/fabric8-services/fabric8-wit/rendering"
	"github.com/fabric8-services/fabric8-wit/space"
	testsupport "github.com/fabric8-services/fabric8-wit/test"
	"github.com/fabric8-services/fabric8-wit/workitem"
	"github.com/fabric8-services/fabric8-wit/workitem/link"
	errs "github.com/pkg/errors"
	uuid "github.com/satori/go.uuid"
)

func makeIdentities(fxt *TestFixture) error {
	if fxt.info[kindIdentities] == nil {
		return nil
	}
	fxt.Identities = make([]*account.Identity, fxt.info[kindIdentities].numInstances)
	for i := range fxt.Identities {
		fxt.Identities[i] = &account.Identity{
			Username:     testsupport.CreateRandomValidTestName("<NAME> "),
			ProviderType: account.KeycloakIDP,
		}
		if err := fxt.runCustomizeEntityFuncs(i, kindIdentities); err != nil {
			return errs.WithStack(err)
		}
		err := testsupport.CreateTestIdentityForAccountIdentity(fxt.db, fxt.Identities[i])
		if err != nil {
			return errs.Wrapf(err, "failed to create identity: %+v", fxt.Identities[i])
		}
	}
	return nil
}

func makeWorkItemLinkCategories(fxt *TestFixture) error {
	if fxt.info[kindWorkItemLinkCategories] == nil {
		return nil
	}
	fxt.WorkItemLinkCategories = make([]*link.WorkItemLinkCategory, fxt.info[kindWorkItemLinkCategories].numInstances)
	wilcRepo := link.NewWorkItemLinkCategoryRepository(fxt.db)
	for i := range fxt.WorkItemLinkCategories {
		desc := "some description"
		fxt.WorkItemLinkCategories[i] = &link.WorkItemLinkCategory{
			Name:        testsupport.CreateRandomValidTestName("link category "),
			Description: &desc,
		}
		if err := fxt.runCustomizeEntityFuncs(i, kindWorkItemLinkCategories); err != nil {
			return errs.WithStack(err)
		}
		_, err := wilcRepo.Create(fxt.ctx, fxt.WorkItemLinkCategories[i])
{'fraction_non_alphanumeric': 0.13419723259389413, 'fraction_numerical': 0.012299582692730068, 'mean_word_length': 5.154054054054054, 'pattern_counts': {'":': 0, '<': 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': '2536929', 'n_tokens_mistral': 1789, 'n_tokens_neox': 1653, 'n_words': 226}