diff --git a/annotations/cypher.go b/annotations/cypher.go index 59ff205..3ec49e0 100644 --- a/annotations/cypher.go +++ b/annotations/cypher.go @@ -191,10 +191,6 @@ func createAnnotationRelationship(relation string) (statement string) { } func getRelationshipFromPredicate(predicate string) (string, error) { - if predicate == "" { - return relations["mentions"], nil - } - r, ok := relations[predicate] if !ok { return "", UnsupportedPredicateErr diff --git a/annotations/cypher_integration_test.go b/annotations/cypher_integration_test.go index 519cdb7..7bb60f2 100644 --- a/annotations/cypher_integration_test.go +++ b/annotations/cypher_integration_test.go @@ -372,6 +372,7 @@ func TestWriteAndReadMultipleAnnotations(t *testing.T) { "http://www.ft.com/ontology/core/Thing", "http://www.ft.com/ontology/concept/Concept", }, + Predicate: "mentions", }, Provenances: []Provenance{ { diff --git a/annotations/cypher_test.go b/annotations/cypher_test.go index b086648..db78f57 100644 --- a/annotations/cypher_test.go +++ b/annotations/cypher_test.go @@ -1,6 +1,7 @@ package annotations import ( + "errors" "fmt" "testing" @@ -99,6 +100,16 @@ func TestCreateAnnotationQueryWithPredicate(t *testing.T) { } } +func TestCreateAnnotationQueryWithoutPredicate(t *testing.T) { + assert := assert.New(t) + logger.InitDefaultLogger("annotations-rw") + annotation := exampleConcept(oldConceptUUID) + annotation.Thing.Predicate = "" + + _, err := createAnnotationQuery(contentUUID, annotation, v2PlatformVersion, v2AnnotationLifecycle) + assert.True(errors.Is(err, UnsupportedPredicateErr), "Creating annotation without predicate is not allowed.") +} + func TestGetRelationshipFromPredicate(t *testing.T) { var tests = []struct { predicate string @@ -106,9 +117,13 @@ func TestGetRelationshipFromPredicate(t *testing.T) { }{ {"mentions", "MENTIONS"}, {"isClassifiedBy", "IS_CLASSIFIED_BY"}, - {"", "MENTIONS"}, + {"implicitlyClassifiedBy", "IMPLICITLY_CLASSIFIED_BY"}, {"about", "ABOUT"}, + {"isPrimarilyClassifiedBy", "IS_PRIMARILY_CLASSIFIED_BY"}, + {"majorMentions", "MAJOR_MENTIONS"}, {"hasAuthor", "HAS_AUTHOR"}, + {"hasContributor", "HAS_CONTRIBUTOR"}, + {"hasDisplayTag", "HAS_DISPLAY_TAG"}, {"hasBrand", "HAS_BRAND"}, } diff --git a/annotations/example_data_test.go b/annotations/example_data_test.go index f2024fc..ed15647 100644 --- a/annotations/example_data_test.go +++ b/annotations/example_data_test.go @@ -20,7 +20,9 @@ var ( "http://www.ft.com/ontology/organisation/Organisation", "http://www.ft.com/ontology/core/Thing", "http://www.ft.com/ontology/concept/Concept", - }}, + }, + Predicate: "mentions", + }, Provenances: []Provenance{ { Scores: []Score{ @@ -192,7 +194,9 @@ func exampleConcept(uuid string) Annotation { "http://www.ft.com/ontology/organisation/Organisation", "http://www.ft.com/ontology/core/Thing", "http://www.ft.com/ontology/concept/Concept", - }}, + }, + Predicate: "mentions", + }, Provenances: []Provenance{ { Scores: []Score{