diff options
author | Arne H Juul <arnej@yahooinc.com> | 2022-03-24 13:40:28 +0000 |
---|---|---|
committer | Arne H Juul <arnej@yahooinc.com> | 2022-03-24 13:49:11 +0000 |
commit | 3c1c5151a631221dfbb0aaee36a2e25f4ba967c1 (patch) | |
tree | b1a2124187904fe31c8cbf0338b1d8355dedcdd8 /document/src/test | |
parent | a905bb7584c4057f59cf77a354492b140cac1a77 (diff) |
avoid DocumentTypeManager.getDataType(name)
Diffstat (limited to 'document/src/test')
6 files changed, 36 insertions, 28 deletions
diff --git a/document/src/test/java/com/yahoo/document/annotation/Bug4259784TestCase.java b/document/src/test/java/com/yahoo/document/annotation/Bug4259784TestCase.java index afe327b7179..20f7c38cb5f 100644 --- a/document/src/test/java/com/yahoo/document/annotation/Bug4259784TestCase.java +++ b/document/src/test/java/com/yahoo/document/annotation/Bug4259784TestCase.java @@ -39,6 +39,7 @@ public class Bug4259784TestCase { private void annotate(Document document, DocumentTypeManager manager) { + DocumentType docType = manager.getDocumentType("blog"); AnnotationTypeRegistry registry = manager.getAnnotationTypeRegistry(); AnnotationType company = registry.getType("company"); @@ -81,25 +82,25 @@ public class Bug4259784TestCase { Annotation compAn = new Annotation(company, companyValue); tree.annotate(span2, compAn); - Struct locationVal = new Struct(manager.getDataType("annotation.location")); + Struct locationVal = new Struct(location.getDataType()); locationVal.setFieldValue("lat", 37.774929); locationVal.setFieldValue("lon", -122.419415); Annotation locAnnotation = new Annotation(location, locationVal); tree.annotate(span3, locAnnotation); - Struct dirValue1 = new Struct(manager.getDataType("annotation.person")); + Struct dirValue1 = new Struct(person.getDataType()); dirValue1.setFieldValue("name", "Jonathan Schwartz"); Annotation dirAnnotation1 = new Annotation(person, dirValue1); tree.annotate(span5, dirAnnotation1); - Struct dirValue2 = new Struct(manager.getDataType("annotation.person")); + Struct dirValue2 = new Struct(person.getDataType()); dirValue2.setFieldValue("name", "Scott Mcnealy"); Annotation dirAnnotation2 = new Annotation(person, dirValue2); tree.annotate(span6, dirAnnotation2); - Struct indValue = new Struct(manager.getDataType("annotation.industry")); + Struct indValue = new Struct(industry.getDataType()); indValue.setFieldValue("vertical", "Manufacturing"); Annotation indAn = new Annotation(industry, indValue); tree.annotate(span4, indAn); diff --git a/document/src/test/java/com/yahoo/document/annotation/Bug4261985TestCase.java b/document/src/test/java/com/yahoo/document/annotation/Bug4261985TestCase.java index b98c916862c..dc4db0f06ed 100644 --- a/document/src/test/java/com/yahoo/document/annotation/Bug4261985TestCase.java +++ b/document/src/test/java/com/yahoo/document/annotation/Bug4261985TestCase.java @@ -38,6 +38,7 @@ public class Bug4261985TestCase { } public void annotate(Document document, DocumentTypeManager manager) { + DocumentType docType = manager.getDocumentType("blog"); AnnotationTypeRegistry registry = manager.getAnnotationTypeRegistry(); AnnotationType company = registry.getType("company"); @@ -90,7 +91,7 @@ public class Bug4261985TestCase { Struct companyValue = (Struct) company.getDataType().createFieldValue(); companyValue.setFieldValue("name", "Sun"); - Struct locationVal = new Struct(manager.getDataType("annotation.location")); + Struct locationVal = new Struct(location.getDataType()); locationVal.setFieldValue("lat", 37.774929); locationVal.setFieldValue("lon", -122.419415); Annotation locAnnotation = new Annotation(location, locationVal); @@ -142,7 +143,7 @@ public class Bug4261985TestCase { tree.annotate(span5, dirAnnotation1); tree.annotate(span6, dirAnnotation2); - Struct indValue = new Struct(manager.getDataType("annotation.industry")); + Struct indValue = new Struct(industry.getDataType()); indValue.setFieldValue("vertical", "Manufacturing"); Annotation indAn = new Annotation(industry, indValue); tree.annotate(span4, indAn); diff --git a/document/src/test/java/com/yahoo/document/annotation/Bug4475379TestCase.java b/document/src/test/java/com/yahoo/document/annotation/Bug4475379TestCase.java index 69003ebd036..e6afeedd7f1 100755 --- a/document/src/test/java/com/yahoo/document/annotation/Bug4475379TestCase.java +++ b/document/src/test/java/com/yahoo/document/annotation/Bug4475379TestCase.java @@ -37,6 +37,8 @@ public class Bug4475379TestCase { } public void annotate(DocumentTypeManager manager, Document document) { + DocumentType docType = manager.getDocumentType("blog"); + AnnotationTypeRegistry registry = manager.getAnnotationTypeRegistry(); AnnotationType company = registry.getType("company"); @@ -64,17 +66,17 @@ public class Bug4475379TestCase { compAn1 = new Annotation(company, companyValue1); } { - Struct personValue1 = new Struct(manager.getDataType("annotation.person")); + Struct personValue1 = new Struct(person.getDataType()); personValue1.setFieldValue("name", new StringFieldValue("Richard Bair")); personAn1 = new Annotation(person, personValue1); } { - Struct locValue1 = new Struct(manager.getDataType("annotation.location")); + Struct locValue1 = new Struct(location.getDataType()); locValue1.setFieldValue("name", new StringFieldValue("Prinsens Gate")); locAn1 = new Annotation(location, locValue1); } { - Struct indValue1 = new Struct(manager.getDataType("annotation.industry")); + Struct indValue1 = new Struct(industry.getDataType()); indValue1.setFieldValue("vertical", new StringFieldValue("Software Services")); indAn1 = new Annotation(industry, indValue1); } @@ -89,17 +91,17 @@ public class Bug4475379TestCase { compAn2 = new Annotation(company, companyValue2); } { - Struct personValue2 = new Struct(manager.getDataType("annotation.person")); + Struct personValue2 = new Struct(person.getDataType()); personValue2.setFieldValue("name", new StringFieldValue("Kim Johansen")); personAn2 = new Annotation(person, personValue2); } { - Struct locValue2 = new Struct(manager.getDataType("annotation.location")); + Struct locValue2 = new Struct(location.getDataType()); locValue2.setFieldValue("name", new StringFieldValue("RT Nagar")); locAn2 = new Annotation(location, locValue2); } { - Struct indValue2 = new Struct(manager.getDataType("annotation.industry")); + Struct indValue2 = new Struct(industry.getDataType()); indValue2.setFieldValue("vertical", new StringFieldValue("Software Consulting")); indAn2 = new Annotation(industry, indValue2); } diff --git a/document/src/test/java/com/yahoo/document/annotation/DocTestCase.java b/document/src/test/java/com/yahoo/document/annotation/DocTestCase.java index fafca72ba7c..e260754bd5d 100644 --- a/document/src/test/java/com/yahoo/document/annotation/DocTestCase.java +++ b/document/src/test/java/com/yahoo/document/annotation/DocTestCase.java @@ -242,7 +242,8 @@ public class DocTestCase { SpanList root = new SpanList(); SpanTree tree = new SpanTree("html", root); - StructDataType positionType = (StructDataType) dtm.getDataType("position"); + var docType = dtm.getDocumentType("blogpost"); + StructDataType positionType = docType.getDeclaredStructType("position"); AnnotationType textType = atr.getType("text"); AnnotationType beginTag = atr.getType("begintag"); diff --git a/document/src/test/java/com/yahoo/document/annotation/SystemTestCase.java b/document/src/test/java/com/yahoo/document/annotation/SystemTestCase.java index 678639c89d9..fa2e6108afb 100755 --- a/document/src/test/java/com/yahoo/document/annotation/SystemTestCase.java +++ b/document/src/test/java/com/yahoo/document/annotation/SystemTestCase.java @@ -5,6 +5,7 @@ import com.yahoo.document.Document; import com.yahoo.document.DocumentType; import com.yahoo.document.DocumentTypeManager; import com.yahoo.document.DocumentTypeManagerConfigurer; +import com.yahoo.document.StructDataType; import com.yahoo.document.datatypes.StringFieldValue; import com.yahoo.document.datatypes.Struct; import com.yahoo.document.serialization.*; @@ -42,33 +43,35 @@ public class SystemTestCase { root.add(dateSpan); root.add(placeSpan); - Struct personValue = new Struct(manager.getDataType("annotation.person")); + DocumentType docType = document.getDataType(); + Struct personValue = new Struct(personType.getDataType()); personValue.setFieldValue("name", "george washington"); Annotation person = new Annotation(personType, personValue); tree.annotate(personSpan, person); - Struct artistValue = new Struct(manager.getDataType("annotation.artist")); + Struct artistValue = new Struct((StructDataType) artistType.getDataType()); artistValue.setFieldValue("name", "elvis presley"); artistValue.setFieldValue("instrument", 20); Annotation artist = new Annotation(artistType, artistValue); tree.annotate(artistSpan, artist); - Struct dateValue = new Struct(manager.getDataType("annotation.date")); + Struct dateValue = new Struct((StructDataType) dateType.getDataType()); dateValue.setFieldValue("exacttime", 123456789L); Annotation date = new Annotation(dateType, dateValue); tree.annotate(dateSpan, date); - Struct placeValue = new Struct(manager.getDataType("annotation.place")); + Struct placeValue = new Struct((StructDataType) placeType.getDataType()); placeValue.setFieldValue("lat", 1467L); placeValue.setFieldValue("lon", 789L); Annotation place = new Annotation(placeType, placeValue); tree.annotate(placeSpan, place); - Struct eventValue = new Struct(manager.getDataType("annotation.event")); + var eventStruct = (StructDataType) eventType.getDataType(); + Struct eventValue = new Struct(eventStruct); eventValue.setFieldValue("description", "Big concert"); - eventValue.setFieldValue("person", new AnnotationReference((AnnotationReferenceDataType) manager.getDataType("annotationreference<person>"), person)); - eventValue.setFieldValue("date", new AnnotationReference((AnnotationReferenceDataType) manager.getDataType("annotationreference<date>"), date)); - eventValue.setFieldValue("place", new AnnotationReference((AnnotationReferenceDataType) manager.getDataType("annotationreference<place>"), place)); + eventValue.setFieldValue("person", new AnnotationReference((AnnotationReferenceDataType) eventStruct.getField("person").getDataType(), person)); + eventValue.setFieldValue("date", new AnnotationReference((AnnotationReferenceDataType) eventStruct.getField("date").getDataType(), date)); + eventValue.setFieldValue("place", new AnnotationReference((AnnotationReferenceDataType) eventStruct.getField("place").getDataType(), place)); Annotation event = new Annotation(eventType, eventValue); tree.annotate(root, event); diff --git a/document/src/test/java/com/yahoo/document/datatypes/StringTestCase.java b/document/src/test/java/com/yahoo/document/datatypes/StringTestCase.java index fe52e3e8485..9c38656a984 100644 --- a/document/src/test/java/com/yahoo/document/datatypes/StringTestCase.java +++ b/document/src/test/java/com/yahoo/document/datatypes/StringTestCase.java @@ -256,17 +256,17 @@ public class StringTestCase extends AbstractTypesTest { Annotation compAn = new Annotation(company, companyValue); tree.annotate(companySpan, compAn); - Struct personValue = new Struct(manager.getDataType("annotation.person")); + Struct personValue = new Struct(person.getDataType()); personValue.setFieldValue("name", new StringFieldValue("Richard Bair")); Annotation personAn = new Annotation(person, personValue); tree.annotate(personSpan, personAn); - Struct locValue = new Struct(manager.getDataType("annotation.location")); + Struct locValue = new Struct(location.getDataType()); locValue.setFieldValue("name", new StringFieldValue("Prinsens Gate")); Annotation loc = new Annotation(location, locValue); tree.annotate(locationSpan, loc); - Struct locValue2 = new Struct(manager.getDataType("annotation.location")); + Struct locValue2 = new Struct(location.getDataType()); locValue2.setFieldValue("name", new StringFieldValue("Kongens Gate")); Annotation locAn = new Annotation(location, locValue2); tree.annotate(locationSpan, locAn); @@ -281,17 +281,17 @@ public class StringTestCase extends AbstractTypesTest { branch.add(span3); branch.add(span2); - Struct industryValue = new Struct(manager.getDataType("annotation.industry")); + Struct industryValue = new Struct(industry.getDataType()); industryValue.setFieldValue("vertical", new StringFieldValue("Manufacturing")); Annotation ind = new Annotation(industry, industryValue); tree.annotate(span1, ind); - Struct pValue = new Struct(manager.getDataType("annotation.person")); + Struct pValue = new Struct(person.getDataType()); pValue.setFieldValue("name", new StringFieldValue("Praveen Mohan")); Annotation pAn = new Annotation(person, pValue); tree.annotate(span2, pAn); - Struct lValue = new Struct(manager.getDataType("annotation.location")); + Struct lValue = new Struct(location.getDataType()); lValue.setFieldValue("name", new StringFieldValue("Embassy Golf Links")); Annotation locn = new Annotation(location, lValue); tree.annotate(span3, locn); @@ -305,7 +305,7 @@ public class StringTestCase extends AbstractTypesTest { Annotation cAn = new Annotation(company, cValue); tree.annotate(branch, cAn); - Struct pVal = new Struct(manager.getDataType("annotation.person")); + Struct pVal = new Struct(person.getDataType()); pVal.setFieldValue("name", new StringFieldValue("Kim Omar")); Annotation an = new Annotation(person, pVal); tree.annotate(root, an); |