Exemple #1
0
func TestFormatUUID3(t *testing.T) {
	first3 := uuid.NewMD5(uuid.NameSpace_URL, []byte("somewhere.com"))
	other3 := uuid.NewMD5(uuid.NameSpace_URL, []byte("somewhereelse.com"))
	uuid3 := UUID3(first3.String())
	str := string(other3.String())
	b := []byte(str)
	bj := []byte("\"" + str + "\"")

	err := uuid3.UnmarshalText(b)
	assert.NoError(t, err)
	assert.EqualValues(t, UUID3(other3.String()), string(b))

	b, err = uuid3.MarshalText()
	assert.NoError(t, err)
	assert.EqualValues(t, []byte(other3.String()), b)

	err = uuid3.UnmarshalJSON(bj)
	assert.NoError(t, err)
	assert.EqualValues(t, UUID3(str), string(b))

	b, err = uuid3.MarshalJSON()
	assert.NoError(t, err)
	assert.Equal(t, bj, b)

	testValid(t, "uuid3", str)
	testInvalid(t, "uuid3", "not-a-uuid")
}
func (bt *berthaTransformer) authorToPerson(a author) (person, error) {
	uuid := uuid.NewMD5(uuid.UUID{}, []byte(a.TmeIdentifier)).String()
	plainDescription, err := html2text.FromString(a.Biography)

	if err != nil {
		return person{}, err
	}

	altIds := alternativeIdentifiers{
		UUIDS: []string{uuid},
		TME:   []string{a.TmeIdentifier},
	}

	p := person{
		Uuid:                   uuid,
		Name:                   a.Name,
		PrefLabel:              a.Name,
		EmailAddress:           a.Email,
		TwitterHandle:          a.TwitterHandle,
		FacebookProfile:        a.FacebookProfile,
		LinkedinProfile:        a.LinkedinProfile,
		Description:            plainDescription,
		DescriptionXML:         a.Biography,
		ImageUrl:               a.ImageUrl,
		AlternativeIdentifiers: altIds,
	}

	return p, err
}
func transformSubject(tmeTerm term, taxonomyName string) subject {
	tmeIdentifier := buildTmeIdentifier(tmeTerm.RawID, taxonomyName)
	uuid := uuid.NewMD5(uuid.UUID{}, []byte(tmeIdentifier)).String()

	return subject{
		UUID:                   uuid,
		PrefLabel:              tmeTerm.CanonicalName,
		AlternativeIdentifiers: alternativeIdentifiers{TME: []string{tmeIdentifier}, Uuids: []string{uuid}},
		Type: "Subject",
	}
}