Skip to content

Commit

Permalink
Fix after code review
Browse files Browse the repository at this point in the history
Signed-off-by: CatalinStratu <catalinstratu45@gmail.com>
  • Loading branch information
CatalinStratu committed Jan 2, 2023
1 parent 639a8ba commit d773abf
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions rdfloader/parser2v2/parse_annotation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ func Test_setAnnotationToParser(t *testing.T) {
func Test_rdfParser2_2_parseAnnotationFromNode(t *testing.T) {
// TestCase 1: invalid annotator must raise an error
parser, _ := parserFromBodyContent(`
<spdx:Annotation>
<spdx:annotationDate>2010-01-29T18:30:22Z</spdx:annotationDate>
<rdfs:comment>Document level annotation</rdfs:comment>
<spdx:annotator>Company: some company</spdx:annotator>
<spdx:annotationType rdf:resource="http://spdx.org/rdf/terms#annotationType_other"/>
</spdx:Annotation>
`)
<spdx:Annotation>
<spdx:annotationDate>2010-01-29T18:30:22Z</spdx:annotationDate>
<rdfs:comment>Document level annotation</rdfs:comment>
<spdx:annotator>Company: some company</spdx:annotator>
<spdx:annotationType rdf:resource="http://spdx.org/rdf/terms#annotationType_other"/>
</spdx:Annotation>
`)
node := parser.gordfParserObj.Triples[0].Subject
err := parser.parseAnnotationFromNode(node)
if err == nil {
Expand All @@ -113,13 +113,13 @@ func Test_rdfParser2_2_parseAnnotationFromNode(t *testing.T) {

// TestCase 2: wrong annotation type should raise an error
parser, _ = parserFromBodyContent(`
<spdx:Annotation>
<spdx:annotationDate>2010-01-29T18:30:22Z</spdx:annotationDate>
<rdfs:comment>Document level annotation</rdfs:comment>
<spdx:annotator>Person: Jane Doe</spdx:annotator>
<spdx:annotationType rdf:resource="http://spdx.org/rdf/terms#annotationType_unknown"/>
</spdx:Annotation>
`)
<spdx:Annotation>
<spdx:annotationDate>2010-01-29T18:30:22Z</spdx:annotationDate>
<rdfs:comment>Document level annotation</rdfs:comment>
<spdx:annotator>Person: Jane Doe</spdx:annotator>
<spdx:annotationType rdf:resource="http://spdx.org/rdf/terms#annotationType_unknown"/>
</spdx:Annotation>
`)
node = parser.gordfParserObj.Triples[0].Subject
err = parser.parseAnnotationFromNode(node)
if err == nil {
Expand All @@ -128,14 +128,14 @@ func Test_rdfParser2_2_parseAnnotationFromNode(t *testing.T) {

// TestCase 3: unknown predicate should also raise an error
parser, _ = parserFromBodyContent(`
<spdx:Annotation>
<spdx:annotationDate>2010-01-29T18:30:22Z</spdx:annotationDate>
<rdfs:comment>Document level annotation</rdfs:comment>
<spdx:annotator>Person: Jane Doe</spdx:annotator>
<spdx:annotationType rdf:resource="http://spdx.org/rdf/terms#annotationType_unknown"/>
<spdx:unknownPredicate />
</spdx:Annotation>
`)
<spdx:Annotation>
<spdx:annotationDate>2010-01-29T18:30:22Z</spdx:annotationDate>
<rdfs:comment>Document level annotation</rdfs:comment>
<spdx:annotator>Person: Jane Doe</spdx:annotator>
<spdx:annotationType rdf:resource="http://spdx.org/rdf/terms#annotationType_unknown"/>
<spdx:unknownPredicate />
</spdx:Annotation>
`)
node = parser.gordfParserObj.Triples[0].Subject
err = parser.parseAnnotationFromNode(node)
if err == nil {
Expand All @@ -144,13 +144,13 @@ func Test_rdfParser2_2_parseAnnotationFromNode(t *testing.T) {

// TestCase 4: completely valid annotation
parser, _ = parserFromBodyContent(`
<spdx:Annotation>
<spdx:annotationDate>2010-01-29T18:30:22Z</spdx:annotationDate>
<rdfs:comment>Document level annotation</rdfs:comment>
<spdx:annotator>Person: Jane Doe</spdx:annotator>
<spdx:annotationType rdf:resource="http://spdx.org/rdf/terms#annotationType_other"/>
</spdx:Annotation>
`)
<spdx:Annotation>
<spdx:annotationDate>2010-01-29T18:30:22Z</spdx:annotationDate>
<rdfs:comment>Document level annotation</rdfs:comment>
<spdx:annotator>Person: Jane Doe</spdx:annotator>
<spdx:annotationType rdf:resource="http://spdx.org/rdf/terms#annotationType_other"/>
</spdx:Annotation>
`)
node = parser.gordfParserObj.Triples[0].Subject
err = parser.parseAnnotationFromNode(node)
if err != nil {
Expand Down

0 comments on commit d773abf

Please sign in to comment.