Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Commit

Permalink
Merge pull request #21 from Financial-Times/revert-18-concept-depreca…
Browse files Browse the repository at this point in the history
…tion-phase2

Revert "Concept deprecation phase2"
  • Loading branch information
bsocaciu committed Aug 31, 2018
2 parents 0aa9ec8 + 2038497 commit 74b8318
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 71 deletions.
30 changes: 0 additions & 30 deletions test-data/term.xml

This file was deleted.

2 changes: 0 additions & 2 deletions tme/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ type BasicConcept struct {
AuthorityValue string `json:"authorityValue,omitempty"`
Aliases []string `json:"aliases,omitempty"`
IsAuthor bool `json:"isAuthor,omitempty"`
IsDeprecated bool `json:"isDeprecated,omitempty"`
}

type ConceptUUID struct {
Expand All @@ -25,7 +24,6 @@ type Term struct {
CanonicalName string `xml:"name"`
RawID string `xml:"id"`
Aliases aliases `xml:"variations"`
Enabled bool `xml:"enabled,omitempty"`
}

type aliases struct {
Expand Down
2 changes: 1 addition & 1 deletion tme/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

var (
GetAllConceptsResult string = "{\"uuid\":\"14fa0405-c625-3061-a1a0-a00643fc073f\",\"prefLabel\":\"Fred\",\"type\":\"Topic\",\"authority\":\"TME\",\"authorityValue\":\"ZnJlZA==-VG9waWNz\",\"isDeprecated\":true}\n{\"uuid\":\"c0e2b109-2212-35c1-8645-2a13bc2cc3db\",\"prefLabel\":\"Bob\",\"type\":\"Topic\",\"authority\":\"TME\",\"authorityValue\":\"Ym9i-VG9waWNz\",\"isDeprecated\":true}\n"
GetAllConceptsResult string = "{\"uuid\":\"14fa0405-c625-3061-a1a0-a00643fc073f\",\"prefLabel\":\"Fred\",\"type\":\"Topic\",\"authority\":\"TME\",\"authorityValue\":\"ZnJlZA==-VG9waWNz\"}\n{\"uuid\":\"c0e2b109-2212-35c1-8645-2a13bc2cc3db\",\"prefLabel\":\"Bob\",\"type\":\"Topic\",\"authority\":\"TME\",\"authorityValue\":\"Ym9i-VG9waWNz\"}\n"
GetConceptUUIDsResult string = "{\"uuid\":\"14fa0405-c625-3061-a1a0-a00643fc073f\"}\n{\"uuid\":\"c0e2b109-2212-35c1-8645-2a13bc2cc3db\"}\n"
RepoSleepDuration time.Duration = 5 * time.Second
)
Expand Down
5 changes: 1 addition & 4 deletions tme/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (*Transformer) UnMarshallTaxonomy(contents []byte) ([]interface{}, error) {
}

func (*Transformer) UnMarshallTerm(content []byte) (interface{}, error) {
term := Term{Enabled: true}
term := Term{}
err := xml.Unmarshal(content, &term)
if err != nil {
return nil, err
Expand All @@ -57,9 +57,6 @@ func transformConcept(tmeTerm Term, endpoint string) *BasicConcept {
AuthorityValue: identifier,
Aliases: aliasList,
}
if tmeTerm.Enabled == false {
basicConcept.IsDeprecated = true
}
if (EndpointTypeMappings[endpoint]["taxonomy"].(string)) == "Brands" {
basicConcept.ParentUUIDs = []string{financialTimesBrandUuid}
} else if (EndpointTypeMappings[endpoint]["taxonomy"].(string)) == "Authors" {
Expand Down
51 changes: 17 additions & 34 deletions tme/transformer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,34 @@ import (

func TestTransformer_transformConcept(t *testing.T) {
type testStruct struct {
testName string
testTerm Term
endpoint string
expectedUuid string
expectedPrefLabel string
expectedType string
expectedParentUuid string
expectedAuthority string
expectedAuthValue string
expectedAliases []string
expectedIsAuthor bool
expectedIsDeprecated bool
testName string
testTerm Term
endpoint string
expectedUuid string
expectedPrefLabel string
expectedType string
expectedParentUuid string
expectedAuthority string
expectedAuthValue string
expectedAliases []string
expectedIsAuthor bool
}

//Tme terms
exampleGenre := Term{CanonicalName: "NewGenre", RawID: "newGenre", Enabled: true}
examplePersonWithAliases := Term{CanonicalName: "John Smith", RawID: "johnSmith", Aliases: aliases{Alias: []alias{{Name: "Johnny Boy"}, {Name: "Smithy"}}}, Enabled: true}
examplePersonWithoutAliases := Term{CanonicalName: "Jane Doe", RawID: "janeDoe", Enabled: true}
exampleBrand := Term{CanonicalName: "NewBrand", RawID: "newBrand", Enabled: true}
exampleAuthor := Term{CanonicalName: "Author McAuthorface", RawID: "mcAuthorFace", Aliases: aliases{Alias: []alias{{Name: "John"}, {Name: "Bob"}}}, Enabled: true}
exampleDeprecatedGenre := Term{CanonicalName: "OldGenre", RawID: "oldGenre", Enabled: false}
exampleGenre := Term{CanonicalName: "NewGenre", RawID: "newGenre"}
examplePersonWithAliases := Term{CanonicalName: "John Smith", RawID: "johnSmith", Aliases: aliases{Alias: []alias{{Name: "Johnny Boy"}, {Name: "Smithy"}}}}
examplePersonWithoutAliases := Term{CanonicalName: "Jane Doe", RawID: "janeDoe"}
exampleBrand := Term{CanonicalName: "NewBrand", RawID: "newBrand"}
exampleAuthor := Term{CanonicalName: "Author McAuthorface", RawID: "mcAuthorFace", Aliases: aliases{Alias: []alias{{Name: "John"}, {Name: "Bob"}}}}

//Scenarios
genreTest := testStruct{testName: "genreTest", testTerm: exampleGenre, endpoint: "genres", expectedUuid: "7c80229b-3ad4-3bee-bb7a-45eaafe3f83a", expectedType: "Genre", expectedPrefLabel: "NewGenre", expectedAliases: []string{}, expectedParentUuid: "", expectedAuthority: "TME", expectedAuthValue: "bmV3R2VucmU=-R2VucmVz", expectedIsAuthor: false}
personWithAliases := testStruct{testName: "personWithAliases", testTerm: examplePersonWithAliases, endpoint: "people", expectedUuid: "05d18aac-9d8e-35d6-9a50-a950fc10aa0e", expectedType: "Person", expectedPrefLabel: "John Smith", expectedAliases: []string{"Johnny Boy", "Smithy"}, expectedParentUuid: "", expectedAuthority: "TME", expectedAuthValue: "am9oblNtaXRo-UE4=", expectedIsAuthor: false}
personNoAliases := testStruct{testName: "personNoAliases", testTerm: examplePersonWithoutAliases, endpoint: "people", expectedUuid: "ee34e2fd-f363-339b-aa25-191483cb909e", expectedType: "Person", expectedPrefLabel: "Jane Doe", expectedAliases: []string{}, expectedParentUuid: "", expectedAuthority: "TME", expectedAuthValue: "amFuZURvZQ==-UE4=", expectedIsAuthor: false}
brandTest := testStruct{testName: "brandTest", testTerm: exampleBrand, endpoint: "brands", expectedUuid: "dcb6cc7c-0e5b-3537-8c98-5405a52484f3", expectedType: "Brand", expectedPrefLabel: "NewBrand", expectedAliases: []string{}, expectedParentUuid: financialTimesBrandUuid, expectedAuthority: "TME", expectedAuthValue: "bmV3QnJhbmQ=-QnJhbmRz", expectedIsAuthor: false}
authorTest := testStruct{testName: "authorTest", testTerm: exampleAuthor, endpoint: "authors", expectedUuid: "829f073f-6666-338f-abd6-d69c37f2e5d0", expectedType: "Person", expectedPrefLabel: "Author McAuthorface", expectedAliases: []string{"John", "Bob"}, expectedParentUuid: "", expectedAuthority: "TME", expectedAuthValue: "bWNBdXRob3JGYWNl-QXV0aG9ycw==", expectedIsAuthor: true}
deprecatedGenreTest := testStruct{testName: "deprecatedGenreTest", testTerm: exampleDeprecatedGenre, endpoint: "genres", expectedUuid: "0f2b2e49-74a2-3357-ba22-80a353922dab", expectedType: "Genre", expectedPrefLabel: "OldGenre", expectedAliases: []string{}, expectedParentUuid: "", expectedAuthority: "TME", expectedAuthValue: "b2xkR2VucmU=-R2VucmVz", expectedIsAuthor: false, expectedIsDeprecated: true}

testScenarios := []testStruct{genreTest, personWithAliases, personNoAliases, brandTest, authorTest, deprecatedGenreTest}
testScenarios := []testStruct{genreTest, personWithAliases, personNoAliases, brandTest, authorTest}

for _, scenario := range testScenarios {
result := transformConcept(scenario.testTerm, scenario.endpoint)
Expand All @@ -56,7 +53,6 @@ func TestTransformer_transformConcept(t *testing.T) {
assert.Equal(t, scenario.expectedAuthority, result.Authority, "Scenario "+scenario.testName+" failed")
assert.Equal(t, scenario.expectedAuthValue, result.AuthorityValue, "Scenario "+scenario.testName+" failed")
assert.Equal(t, scenario.expectedIsAuthor, result.IsAuthor, "Scenario "+scenario.testName+" failed")
assert.Equal(t, scenario.expectedIsDeprecated, result.IsDeprecated, "Scenario "+scenario.testName+" failed")
}
}

Expand Down Expand Up @@ -102,16 +98,3 @@ func TestTransformer_UnMarshallTerm(t *testing.T) {
assert.Nil(t, iFace)
assert.Error(t, err, errors.New("Not Implemented"))
}

func TestTransformer_UnMarshallTermEnabledDefault(t *testing.T) {
t.Run("Test term XML", func(t *testing.T) {
content, err := ioutil.ReadFile("../test-data/term.xml")
if err != nil {
log.Errorf("Failed to read test file: %s", err)
}
tr := Transformer{}
term, err := tr.UnMarshallTerm(content)
assert.Equal(t, "'Ar'ara", term.(Term).CanonicalName)
assert.Equal(t, true, term.(Term).Enabled)
})
}

0 comments on commit 74b8318

Please sign in to comment.