@@ -66,6 +66,93 @@ public void setFieldShouldRequireNonBlankValue() {
66
66
parser .setField (anyValidFieldName , nullOrBlank ());
67
67
}
68
68
69
+ @ Test
70
+ public void setFieldShouldSupportSettingName () {
71
+ String expectedName = Random .name ();
72
+
73
+ boolean valid = parser .setField ("name" , expectedName );
74
+
75
+ assertThat (valid , is (true ));
76
+ assertThat (parser .getName (), equalTo (expectedName ));
77
+ }
78
+
79
+ @ Test
80
+ public void setFieldShouldSupportSettingMatchedUrl () {
81
+ String expectedUrl = Random .url ();
82
+
83
+ boolean valid = parser .setField ("matched-url" , expectedUrl );
84
+
85
+ assertThat (valid , is (true ));
86
+ assertThat (parser .getMatchedUrl (), equalTo (expectedUrl ));
87
+ }
88
+
89
+ @ Test
90
+ public void setFieldShouldSupportSettingCategoryLocator () {
91
+ String expectedLocator = Random .jsoupLocator ();
92
+
93
+ boolean valid = parser .setField ("category-locator" , expectedLocator );
94
+
95
+ assertThat (valid , is (true ));
96
+ assertThat (parser .getCategoryLocator (), equalTo (expectedLocator ));
97
+ }
98
+
99
+ @ Test
100
+ public void setFieldShouldSupportSettingCountryLocator () {
101
+ String expectedLocator = Random .jsoupLocator ();
102
+
103
+ boolean valid = parser .setField ("country-locator" , expectedLocator );
104
+
105
+ assertThat (valid , is (true ));
106
+ assertThat (parser .getCountryLocator (), equalTo (expectedLocator ));
107
+ }
108
+
109
+ @ Test
110
+ public void setFieldShouldSupportSettingShortDescriptionLocator () {
111
+ String expectedLocator = Random .jsoupLocator ();
112
+
113
+ boolean valid = parser .setField ("short-description-locator" , expectedLocator );
114
+
115
+ assertThat (valid , is (true ));
116
+ assertThat (parser .getShortDescriptionLocator (), equalTo (expectedLocator ));
117
+ }
118
+
119
+ @ Test
120
+ public void setFieldShouldSupportSettingImageUrlLocator () {
121
+ String expectedLocator = Random .jsoupLocator ();
122
+
123
+ boolean valid = parser .setField ("image-url-locator" , expectedLocator );
124
+
125
+ assertThat (valid , is (true ));
126
+ assertThat (parser .getImageUrlLocator (), equalTo (expectedLocator ));
127
+ }
128
+
129
+ @ Test
130
+ public void setFieldShouldSupportSettingImageUrlAttribute () {
131
+ String expectedAttributeName = Random .tagAttributeName ();
132
+
133
+ boolean valid = parser .setField ("image-url-attribute" , expectedAttributeName );
134
+
135
+ assertThat (valid , is (false ));
136
+ assertThat (parser .getImageUrlAttribute (), equalTo (expectedAttributeName ));
137
+ }
138
+
139
+ @ Test
140
+ public void setFieldShouldSupportSettingIssueDateLocator () {
141
+ String expectedLocator = Random .jsoupLocator ();
142
+
143
+ boolean valid = parser .setField ("issue-date-locator" , expectedLocator );
144
+
145
+ assertThat (valid , is (true ));
146
+ assertThat (parser .getIssueDateLocator (), equalTo (expectedLocator ));
147
+ }
148
+
149
+ @ Test
150
+ public void setFieldShouldIgnoreUnknownField () {
151
+ boolean valid = parser .setField ("unsupported-locator" , Random .jsoupLocator ());
152
+
153
+ assertThat (valid , is (false ));
154
+ }
155
+
69
156
//
70
157
// Tests for isFullyInitialized()
71
158
//
0 commit comments