6 |
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7 |
7 |
* See LICENSE.TXT at the top of this package for the full license terms.
|
8 |
8 |
*/
|
9 |
|
|
10 |
9 |
package eu.etaxonomy.cdm.strategy.match;
|
11 |
10 |
|
12 |
11 |
import java.net.URI;
|
... | ... | |
30 |
29 |
import eu.etaxonomy.cdm.strategy.parser.TimePeriodParser;
|
31 |
30 |
|
32 |
31 |
/**
|
|
32 |
* Test class for {@link MatchStrategyFactory}
|
|
33 |
*
|
33 |
34 |
* @author a.mueller
|
34 |
35 |
* @since 03.08.2009
|
35 |
36 |
*/
|
36 |
37 |
public class MatchStrategyFactoryTest {
|
|
38 |
|
37 |
39 |
@SuppressWarnings("unused")
|
38 |
40 |
private static final Logger logger = Logger.getLogger(MatchStrategyFactoryTest.class);
|
39 |
41 |
|
40 |
42 |
private static boolean FAIL_ALL = true;
|
41 |
43 |
|
42 |
44 |
private IMatchStrategyEqual matchStrategy;
|
43 |
|
// private IBook book1;
|
44 |
|
// private String editionString1 ="Ed.1";
|
45 |
|
// private String volumeString1 ="Vol.1";
|
46 |
|
// private Team team1;
|
47 |
|
// private IPrintSeries printSeries1;
|
48 |
|
// private Annotation annotation1;
|
49 |
|
// private String title1 = "Title1";
|
50 |
|
// private VerbatimTimePeriod datePublished1 = VerbatimTimePeriod.NewVerbatimInstance(2000);
|
51 |
|
// private int hasProblem1 = 1;
|
52 |
|
// private LSID lsid1;
|
53 |
|
//
|
54 |
|
// private IBook book2;
|
55 |
|
// private String editionString2 ="Ed.2";
|
56 |
|
// private String volumeString2 ="Vol.2";
|
57 |
|
// private Team team2;
|
58 |
|
// private IPrintSeries printSeries2;
|
59 |
|
// private Annotation annotation2;
|
60 |
|
// private String annotationString2;
|
61 |
|
// private String title2 = "Title2";
|
62 |
|
// private DateTime created2 = new DateTime(1999, 3, 1, 0, 0, 0, 0);
|
63 |
|
// private VerbatimTimePeriod datePublished2 = VerbatimTimePeriod.NewVerbatimInstance(2002);
|
64 |
|
// private int hasProblem2 = 1;
|
65 |
|
// private LSID lsid2;
|
66 |
|
//
|
67 |
|
// private IBook book3;
|
68 |
45 |
|
69 |
46 |
private Institution institution1;
|
70 |
47 |
|
... | ... | |
76 |
53 |
|
77 |
54 |
@Before
|
78 |
55 |
public void setUp() throws Exception {
|
79 |
|
// team1 = Team.NewInstance();
|
80 |
|
// team1.setTitleCache("Team1",true);
|
81 |
|
// team2 = Team.NewInstance();
|
82 |
|
// team2.setTitleCache("Team2",true);
|
83 |
|
// printSeries1 = ReferenceFactory.newPrintSeries("Series1");
|
84 |
|
// printSeries1.setTitle("print series");
|
85 |
|
// printSeries2 = ReferenceFactory.newPrintSeries("Series2");
|
86 |
|
// annotation1 = Annotation.NewInstance("Annotation1", null);
|
87 |
|
// annotationString2 = "Annotation2";
|
88 |
|
// annotation2 = Annotation.NewInstance(annotationString2, null);
|
89 |
|
//
|
90 |
|
// book1 = ReferenceFactory.newBook();
|
91 |
|
// book1.setAuthorship(team1);
|
92 |
|
// book1.setTitle(title1);
|
93 |
|
// book1.setEdition(editionString1);
|
94 |
|
// book1.setVolume(volumeString1);
|
95 |
|
// book1.setInSeries(printSeries1);
|
96 |
|
// ((AnnotatableEntity) book1).addAnnotation(annotation1);
|
97 |
|
// book1.setDatePublished(datePublished1);
|
98 |
|
// book1.setParsingProblem(hasProblem1);
|
99 |
|
// lsid1 = new LSID("authority1", "namespace1", "object1", "revision1");
|
100 |
|
// book1.setLsid(lsid1);
|
101 |
|
// ((Reference) book1).setNomenclaturallyRelevant(false);
|
102 |
|
//
|
103 |
|
// book2 = ReferenceFactory.newBook();
|
104 |
|
// book2.setAuthorship(team2);
|
105 |
|
// book2.setTitle(title2);
|
106 |
|
// book2.setEdition(editionString2);
|
107 |
|
// book2.setVolume(volumeString2);
|
108 |
|
// book2.setInSeries(printSeries2);
|
109 |
|
// ( (AnnotatableEntity) book2).addAnnotation(annotation2);
|
110 |
|
// book2.setCreated(created2);
|
111 |
|
// book2.setDatePublished(datePublished2);
|
112 |
|
// book2.setParsingProblem(hasProblem2);
|
113 |
|
// lsid2 = new LSID("authority2", "namespace2", "object2", "revision2");
|
114 |
|
// book2.setLsid(lsid2);
|
115 |
|
// ((Reference) book2).setNomenclaturallyRelevant(true);
|
116 |
|
//
|
|
56 |
|
117 |
57 |
institution1 = Institution.NewNamedInstance("Institution1");
|
118 |
58 |
|
119 |
59 |
}
|
... | ... | |
147 |
87 |
parsedPerson.setNomenclaturalTitle("Wrong");
|
148 |
88 |
result = matchStrategy.invoke(fullPerson, parsedPerson, FAIL_ALL);
|
149 |
89 |
System.out.println(result);
|
150 |
|
Assert.assertFalse("Differing nom.title. should not match", matchStrategy.invoke(parsedPerson, fullPerson).isSuccessful());
|
|
90 |
Assert.assertFalse("Differing nom.title. should not match",
|
|
91 |
matchStrategy.invoke(parsedPerson, fullPerson).isSuccessful());
|
151 |
92 |
|
152 |
93 |
//differing family
|
153 |
94 |
parsedPerson = getDefaultParsedPerson();
|
154 |
95 |
parsedPerson.setFamilyName("Wrong");
|
155 |
|
Assert.assertFalse("Differing family name should not match", matchStrategy.invoke(parsedPerson, fullPerson).isSuccessful());
|
|
96 |
Assert.assertFalse("Differing family name should not match",
|
|
97 |
matchStrategy.invoke(parsedPerson, fullPerson).isSuccessful());
|
156 |
98 |
fullPerson.setFamilyName(null);
|
157 |
|
Assert.assertFalse("Only parsed with family name should not match. Wrong direction.", matchStrategy.invoke(parsedPerson, fullPerson).isSuccessful());
|
|
99 |
Assert.assertFalse("Only parsed with family name should not match. Wrong direction.",
|
|
100 |
matchStrategy.invoke(parsedPerson, fullPerson).isSuccessful());
|
158 |
101 |
|
159 |
102 |
//
|
160 |
103 |
parsedPerson = getDefaultParsedPerson();
|
161 |
104 |
parsedPerson.setInitials("D.");
|
162 |
|
Assert.assertFalse("Differing nom. title should not match", matchStrategy.invoke(fullPerson, parsedPerson).isSuccessful());
|
|
105 |
Assert.assertFalse("Differing nom. title should not match",
|
|
106 |
matchStrategy.invoke(fullPerson, parsedPerson).isSuccessful());
|
163 |
107 |
|
164 |
108 |
//nom. title. (2)
|
165 |
109 |
fullPerson = getDefaultFullPerson();
|
166 |
110 |
parsedPerson = getDefaultParsedPerson();
|
167 |
111 |
fullPerson.setNomenclaturalTitle("Wro.");
|
168 |
|
Assert.assertFalse("Differing nom. title should not match", matchStrategy.invoke(fullPerson, parsedPerson).isSuccessful());
|
|
112 |
Assert.assertFalse("Differing nom. title should not match",
|
|
113 |
matchStrategy.invoke(fullPerson, parsedPerson).isSuccessful());
|
169 |
114 |
|
170 |
115 |
//fullPerson protected
|
171 |
116 |
fullPerson = getDefaultFullPerson();
|
172 |
117 |
parsedPerson = getDefaultParsedPerson();
|
173 |
118 |
fullPerson.setTitleCache(fullPerson.getTitleCache(), true);
|
174 |
|
Assert.assertFalse("Differing protected title should not match", matchStrategy.invoke(fullPerson, parsedPerson).isSuccessful());
|
|
119 |
Assert.assertFalse("Differing protected title should not match",
|
|
120 |
matchStrategy.invoke(fullPerson, parsedPerson).isSuccessful());
|
175 |
121 |
|
176 |
122 |
//parsedPerson protected
|
177 |
123 |
fullPerson = getDefaultFullPerson();
|
... | ... | |
179 |
125 |
parsedPerson.setTitleCache(parsedPerson.getTitleCache(), true);
|
180 |
126 |
// System.out.println(fullPerson.getTitleCache());
|
181 |
127 |
// System.out.println(parsedPerson.getTitleCache());
|
182 |
|
Assert.assertFalse("Differing nom. title should not match", matchStrategy.invoke(fullPerson, parsedPerson).isSuccessful());
|
|
128 |
Assert.assertFalse("Differing nom. title should not match",
|
|
129 |
matchStrategy.invoke(fullPerson, parsedPerson).isSuccessful());
|
183 |
130 |
}
|
184 |
131 |
|
185 |
132 |
protected Person getDefaultFullPerson() {
|
... | ... | |
202 |
149 |
return parsedPerson;
|
203 |
150 |
}
|
204 |
151 |
|
205 |
|
/**
|
206 |
|
* Test method for {@link eu.etaxonomy.cdm.strategy.match.DefaultMatchStrategy#invoke(IMatchable, IMatchable), eu.etaxonomy.cdm.strategy.match.IMatchable)}.
|
207 |
|
* @throws MatchException
|
208 |
|
*/
|
209 |
152 |
@Test
|
210 |
153 |
public void testParsedTeam() throws MatchException {
|
211 |
154 |
IParsedMatchStrategy matchStrategy = MatchStrategyFactory.NewParsedTeamInstance();
|
... | ... | |
218 |
161 |
parsedTeam = getDefaultParsedTeam();
|
219 |
162 |
|
220 |
163 |
//should match
|
221 |
|
Assert.assertTrue("Same nom.title. should match", matchStrategy.invoke(parsedTeam, fullTeam).isSuccessful());
|
|
164 |
Assert.assertTrue("Same nom.title. should match",
|
|
165 |
matchStrategy.invoke(parsedTeam, fullTeam).isSuccessful());
|
222 |
166 |
|
223 |
167 |
//differing nom. title.
|
224 |
168 |
parsedTeam.setNomenclaturalTitle("Wrong");
|
225 |
|
Assert.assertFalse("Differing nom.title. should not match", matchStrategy.invoke(parsedTeam, fullTeam).isSuccessful());
|
|
169 |
Assert.assertFalse("Differing nom.title. should not match",
|
|
170 |
matchStrategy.invoke(parsedTeam, fullTeam).isSuccessful());
|
226 |
171 |
|
227 |
172 |
//differing family
|
228 |
173 |
parsedTeam = getDefaultParsedTeam();
|
... | ... | |
237 |
182 |
//
|
238 |
183 |
parsedTeam = getDefaultParsedTeam();
|
239 |
184 |
parsedTeam.getTeamMembers().get(0).setInitials("D.");
|
240 |
|
Assert.assertFalse("Differing nom. title should not match", matchStrategy.invoke(parsedTeam, fullTeam).isSuccessful());
|
|
185 |
Assert.assertFalse("Differing nom. title should not match",
|
|
186 |
matchStrategy.invoke(parsedTeam, fullTeam).isSuccessful());
|
241 |
187 |
|
242 |
188 |
//nom. title. (2)
|
243 |
189 |
fullTeam = getDefaultFullTeam();
|
244 |
190 |
parsedTeam = getDefaultParsedTeam();
|
245 |
191 |
fullTeam.setNomenclaturalTitle("Wro.");
|
246 |
|
Assert.assertFalse("Differing nom. title should not match", matchStrategy.invoke(parsedTeam, fullTeam).isSuccessful());
|
|
192 |
Assert.assertFalse("Differing nom. title should not match",
|
|
193 |
matchStrategy.invoke(parsedTeam, fullTeam).isSuccessful());
|
247 |
194 |
|
248 |
195 |
//fullPerson protected
|
249 |
196 |
fullTeam = getDefaultFullTeam();
|
250 |
197 |
parsedTeam = getDefaultParsedTeam();
|
251 |
198 |
fullTeam.setTitleCache(fullTeam.getTitleCache(), true);
|
252 |
|
Assert.assertFalse("Differing protected title should not match", matchStrategy.invoke(parsedTeam, fullTeam).isSuccessful());
|
|
199 |
Assert.assertFalse("Differing protected title should not match",
|
|
200 |
matchStrategy.invoke(parsedTeam, fullTeam).isSuccessful());
|
253 |
201 |
|
254 |
202 |
//parsedPerson protected
|
255 |
203 |
fullTeam = getDefaultFullTeam();
|
256 |
204 |
parsedTeam = getDefaultParsedTeam();
|
257 |
205 |
parsedTeam.setTitleCache(parsedTeam.getTitleCache(), true);
|
258 |
|
Assert.assertFalse("Differing nom. title should not match", matchStrategy.invoke(parsedTeam, fullTeam).isSuccessful());
|
|
206 |
Assert.assertFalse("Differing nom. title should not match",
|
|
207 |
matchStrategy.invoke(parsedTeam, fullTeam).isSuccessful());
|
259 |
208 |
|
260 |
209 |
fullTeam = getDefaultFullTeam();
|
261 |
210 |
parsedTeam = getDefaultParsedTeam();
|
262 |
211 |
fullTeam.setHasMoreMembers(true);
|
263 |
|
Assert.assertFalse("Differing nom. title should not match", matchStrategy.invoke(parsedTeam, fullTeam).isSuccessful());
|
|
212 |
Assert.assertFalse("Differing nom. title should not match",
|
|
213 |
matchStrategy.invoke(parsedTeam, fullTeam).isSuccessful());
|
264 |
214 |
}
|
265 |
215 |
|
266 |
216 |
private Team getDefaultFullTeam() {
|
... | ... | |
308 |
258 |
|
309 |
259 |
//should match
|
310 |
260 |
parsedBook = getDefaultParsedBook();
|
311 |
|
Assert.assertTrue("Same abbrev. title should match", matchStrategy.invoke(parsedBook, fullBook).isSuccessful());
|
|
261 |
Assert.assertTrue("Same abbrev. title should match",
|
|
262 |
matchStrategy.invoke(parsedBook, fullBook).isSuccessful());
|
312 |
263 |
|
313 |
264 |
//differing nom. title.
|
314 |
265 |
parsedBook.setAbbrevTitle("Wrong");
|
315 |
|
Assert.assertFalse("Differing abbrev. title. should not match", matchStrategy.invoke(parsedBook, fullBook).isSuccessful());
|
|
266 |
Assert.assertFalse("Differing abbrev. title. should not match",
|
|
267 |
matchStrategy.invoke(parsedBook, fullBook).isSuccessful());
|
316 |
268 |
|
317 |
269 |
//differing family
|
318 |
270 |
parsedBook = getDefaultParsedBook();
|
319 |
271 |
parsedBook.setTitle("Wrong title");
|
320 |
|
Assert.assertFalse("Differing title should not match", matchStrategy.invoke(parsedBook, fullBook).isSuccessful());
|
|
272 |
Assert.assertFalse("Differing title should not match",
|
|
273 |
matchStrategy.invoke(parsedBook, fullBook).isSuccessful());
|
321 |
274 |
fullBook.setTitle(null);
|
322 |
|
Assert.assertFalse("Title only for parsed book should not match. Wrong direction.", matchStrategy.invoke(parsedBook, fullBook).isSuccessful());
|
|
275 |
Assert.assertFalse("Title only for parsed book should not match. Wrong direction.",
|
|
276 |
matchStrategy.invoke(parsedBook, fullBook).isSuccessful());
|
323 |
277 |
|
324 |
278 |
//change author
|
325 |
279 |
fullBook = getDefaultFullBook();
|
326 |
280 |
parsedBook = getDefaultParsedBook();
|
327 |
281 |
((Team)fullBook.getAuthorship()).getTeamMembers().get(0).setNomenclaturalTitle("Wrong");
|
328 |
|
Assert.assertFalse("Differing author in nomencl. title should not match", matchStrategy.invoke(parsedBook, fullBook).isSuccessful());
|
|
282 |
Assert.assertFalse("Differing author in nomencl. title should not match",
|
|
283 |
matchStrategy.invoke(parsedBook, fullBook).isSuccessful());
|
329 |
284 |
|
330 |
285 |
//change author
|
331 |
286 |
fullBook = getDefaultFullBook();
|
332 |
287 |
parsedBook = getDefaultParsedBook();
|
333 |
288 |
((Team)fullBook.getAuthorship()).getTeamMembers().get(0).setFamilyName("Changed");
|
334 |
|
Assert.assertTrue("Full book family name author changed should still match", matchStrategy.invoke(parsedBook, fullBook).isSuccessful());
|
|
289 |
Assert.assertTrue("Full book family name author changed should still match",
|
|
290 |
matchStrategy.invoke(parsedBook, fullBook).isSuccessful());
|
335 |
291 |
}
|
336 |
292 |
|
337 |
293 |
@Test
|
... | ... | |
343 |
299 |
|
344 |
300 |
fullBookSection = getMatchingFullBookSection();
|
345 |
301 |
parsedBookSection = getDefaultParsedBookSection();
|
346 |
|
Assert.assertTrue("Only author, book and date published should match", matchStrategy.invoke(parsedBookSection, fullBookSection).isSuccessful() );
|
|
302 |
Assert.assertTrue("Only author, book and date published should match",
|
|
303 |
matchStrategy.invoke(parsedBookSection, fullBookSection).isSuccessful() );
|
347 |
304 |
|
348 |
305 |
//should match
|
349 |
306 |
fullBookSection = getDefaultFullBookSection();
|
350 |
|
Assert.assertFalse("Abbrev. title must be equal or null", matchStrategy.invoke(fullBookSection, parsedBookSection).isSuccessful());
|
|
307 |
Assert.assertFalse("Abbrev. title must be equal or null",
|
|
308 |
matchStrategy.invoke(fullBookSection, parsedBookSection).isSuccessful());
|
351 |
309 |
parsedBookSection.setAbbrevTitle(fullBookSection.getAbbrevTitle());
|
352 |
|
Assert.assertFalse("Still not match because pages are not equal (parsed is null)", matchStrategy.invoke(parsedBookSection, fullBookSection).isSuccessful());
|
|
310 |
Assert.assertFalse("Still not match because pages are not equal (parsed is null)",
|
|
311 |
matchStrategy.invoke(parsedBookSection, fullBookSection).isSuccessful());
|
353 |
312 |
parsedBookSection.setPages(fullBookSection.getPages());
|
354 |
|
Assert.assertFalse("Now they should match", matchStrategy.invoke(parsedBookSection, fullBookSection).isSuccessful());
|
|
313 |
Assert.assertFalse("Now they should match",
|
|
314 |
matchStrategy.invoke(parsedBookSection, fullBookSection).isSuccessful());
|
355 |
315 |
|
356 |
316 |
//differing nom. title.
|
357 |
317 |
parsedBookSection.setAbbrevTitle("Wrong");
|
358 |
|
Assert.assertFalse("Differing abbrev. title. should not match", matchStrategy.invoke(parsedBookSection, fullBookSection).isSuccessful());
|
|
318 |
Assert.assertFalse("Differing abbrev. title. should not match",
|
|
319 |
matchStrategy.invoke(parsedBookSection, fullBookSection).isSuccessful());
|
359 |
320 |
|
360 |
321 |
//differing family
|
361 |
322 |
parsedBookSection = getDefaultParsedBookSection();
|
362 |
323 |
parsedBookSection.setTitle("Wrong title");
|
363 |
|
Assert.assertFalse("Differing title should not match", matchStrategy.invoke(parsedBookSection, fullBookSection).isSuccessful());
|
|
324 |
Assert.assertFalse("Differing title should not match",
|
|
325 |
matchStrategy.invoke(parsedBookSection, fullBookSection).isSuccessful());
|
364 |
326 |
fullBookSection.setTitle(null);
|
365 |
|
Assert.assertFalse("Title only for parsed book should not match. Wrong direction.", matchStrategy.invoke(parsedBookSection, fullBookSection).isSuccessful());
|
|
327 |
Assert.assertFalse("Title only for parsed book should not match. Wrong direction.",
|
|
328 |
matchStrategy.invoke(parsedBookSection, fullBookSection).isSuccessful());
|
366 |
329 |
|
367 |
330 |
//change author
|
368 |
331 |
fullBookSection = getMatchingFullBookSection();
|
369 |
332 |
parsedBookSection = getDefaultParsedBookSection();
|
370 |
333 |
fullBookSection.getAuthorship().setNomenclaturalTitle("Wrong");
|
371 |
|
Assert.assertFalse("Differing author in nomencl. title should not match", matchStrategy.invoke(parsedBookSection, fullBookSection).isSuccessful());
|
|
334 |
Assert.assertFalse("Differing author in nomencl. title should not match",
|
|
335 |
matchStrategy.invoke(parsedBookSection, fullBookSection).isSuccessful());
|
372 |
336 |
|
373 |
337 |
//change author
|
374 |
338 |
fullBookSection = getMatchingFullBookSection();
|
375 |
339 |
parsedBookSection = getDefaultParsedBookSection();
|
376 |
340 |
((Person)fullBookSection.getAuthorship()).setFamilyName("Changed");
|
377 |
|
Assert.assertTrue("Full book family name author changed should still match", matchStrategy.invoke(parsedBookSection, fullBookSection).isSuccessful());
|
|
341 |
Assert.assertTrue("Full book family name author changed should still match",
|
|
342 |
matchStrategy.invoke(parsedBookSection, fullBookSection).isSuccessful());
|
378 |
343 |
}
|
379 |
344 |
|
380 |
345 |
private IBook getDefaultFullBook() {
|
... | ... | |
426 |
391 |
|
427 |
392 |
@Test
|
428 |
393 |
public void testParsedArticle() throws MatchException {
|
|
394 |
|
429 |
395 |
IParsedMatchStrategy matchStrategy = MatchStrategyFactory.NewParsedArticleInstance();
|
430 |
396 |
Assert.assertNotNull(matchStrategy);
|
431 |
397 |
IArticle fullArticle;
|
... | ... | |
433 |
399 |
|
434 |
400 |
fullArticle = getMatchingFullArticle();
|
435 |
401 |
parsedArticle = getDefaultParsedArticle();
|
436 |
|
Assert.assertTrue("Only author, book and date published should match", matchStrategy.invoke(parsedArticle, fullArticle).isSuccessful() );
|
|
402 |
Assert.assertTrue("Only author, book and date published should match",
|
|
403 |
matchStrategy.invoke(parsedArticle, fullArticle).isSuccessful() );
|
437 |
404 |
|
438 |
405 |
//should match
|
439 |
406 |
fullArticle = getDefaultFullArticle();
|
440 |
|
Assert.assertFalse("Abbrev. title must be equal or null", matchStrategy.invoke(parsedArticle, fullArticle).isSuccessful());
|
|
407 |
Assert.assertFalse("Abbrev. title must be equal or null", matchStrategy.invoke(parsedArticle,
|
|
408 |
fullArticle).isSuccessful());
|
441 |
409 |
parsedArticle.setAbbrevTitle(fullArticle.getAbbrevTitle());
|
442 |
|
Assert.assertFalse("Still not match because pages are not equal (parsed is null)", matchStrategy.invoke(parsedArticle, fullArticle).isSuccessful());
|
|
410 |
Assert.assertFalse("Still not match because pages are not equal (parsed is null)",
|
|
411 |
matchStrategy.invoke(parsedArticle, fullArticle).isSuccessful());
|
443 |
412 |
parsedArticle.setPages(fullArticle.getPages());
|
444 |
|
Assert.assertFalse("Now they should match", matchStrategy.invoke(parsedArticle, fullArticle).isSuccessful());
|
|
413 |
Assert.assertFalse("Now they should match",
|
|
414 |
matchStrategy.invoke(parsedArticle, fullArticle).isSuccessful());
|
445 |
415 |
|
446 |
416 |
//differing nom. title.
|
447 |
417 |
parsedArticle.setAbbrevTitle("Wrong");
|
448 |
|
Assert.assertFalse("Differing abbrev. title. should not match", matchStrategy.invoke(parsedArticle, fullArticle).isSuccessful());
|
|
418 |
Assert.assertFalse("Differing abbrev. title. should not match",
|
|
419 |
matchStrategy.invoke(parsedArticle, fullArticle).isSuccessful());
|
449 |
420 |
|
450 |
421 |
//differing family
|
451 |
422 |
parsedArticle = getDefaultParsedArticle();
|
452 |
423 |
parsedArticle.setTitle("Wrong title");
|
453 |
|
Assert.assertFalse("Differing title should not match", matchStrategy.invoke(parsedArticle, fullArticle).isSuccessful());
|
|
424 |
Assert.assertFalse("Differing title should not match",
|
|
425 |
matchStrategy.invoke(parsedArticle, fullArticle).isSuccessful());
|
454 |
426 |
fullArticle.setTitle(null);
|
455 |
|
Assert.assertFalse("Title only for parsed book should not match. Wrong direction.", matchStrategy.invoke(parsedArticle, fullArticle).isSuccessful());
|
|
427 |
Assert.assertFalse("Title only for parsed book should not match. Wrong direction.",
|
|
428 |
matchStrategy.invoke(parsedArticle, fullArticle).isSuccessful());
|
456 |
429 |
|
457 |
430 |
//change author
|
458 |
431 |
fullArticle = getMatchingFullArticle();
|
459 |
432 |
parsedArticle = getDefaultParsedArticle();
|
460 |
433 |
fullArticle.getAuthorship().setNomenclaturalTitle("Wrong");
|
461 |
|
Assert.assertFalse("Differing author in nomencl. title should not match", matchStrategy.invoke(parsedArticle, fullArticle).isSuccessful());
|
|
434 |
Assert.assertFalse("Differing author in nomencl. title should not match",
|
|
435 |
matchStrategy.invoke(parsedArticle, fullArticle).isSuccessful());
|
462 |
436 |
|
463 |
437 |
//change author
|
464 |
438 |
fullArticle = getMatchingFullArticle();
|
465 |
439 |
parsedArticle = getDefaultParsedArticle();
|
466 |
440 |
((Team)fullArticle.getAuthorship()).getTeamMembers().get(0).setFamilyName("Changed");
|
467 |
|
Assert.assertTrue("Full book family name author changed should still match", matchStrategy.invoke(parsedArticle, fullArticle).isSuccessful());
|
|
441 |
Assert.assertTrue("Full book family name author changed should still match",
|
|
442 |
matchStrategy.invoke(parsedArticle, fullArticle).isSuccessful());
|
468 |
443 |
}
|
469 |
444 |
|
|
445 |
/**
|
|
446 |
* Like {@link #getMatchingFullArticle() matching full article} with additional
|
|
447 |
* title, abbrevTitle and pages
|
|
448 |
*/
|
470 |
449 |
private IArticle getDefaultFullArticle() {
|
471 |
450 |
IArticle article = getMatchingFullArticle();
|
472 |
451 |
article.setTitle("Article title");
|
... | ... | |
475 |
454 |
return article;
|
476 |
455 |
}
|
477 |
456 |
|
|
457 |
/**
|
|
458 |
* Article with {@link #getDefaultFullTeam() full team},
|
|
459 |
* {@link #getDefaultFullJournal() full journal} and date published
|
|
460 |
*/
|
478 |
461 |
private IArticle getMatchingFullArticle() {
|
479 |
462 |
IArticle article = ReferenceFactory.newArticle();
|
480 |
463 |
article.setAuthorship(getDefaultFullTeam());
|
... | ... | |
483 |
466 |
return article;
|
484 |
467 |
}
|
485 |
468 |
|
|
469 |
/**
|
|
470 |
* Article with {@link #getDefaultParsedTeam() parsed authorship},
|
|
471 |
* {@link #getDefaultParsedJournal() parsed journal} and date published.
|
|
472 |
*/
|
486 |
473 |
private IArticle getDefaultParsedArticle() {
|
487 |
474 |
IArticle article = ReferenceFactory.newArticle();
|
488 |
475 |
article.setAuthorship(getDefaultParsedTeam());
|
cleanup