1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
|
11
|
package eu.etaxonomy.cdm.strategy.match;
|
12
|
|
13
|
import org.apache.log4j.Logger;
|
14
|
import org.joda.time.DateTime;
|
15
|
import org.junit.After;
|
16
|
import org.junit.AfterClass;
|
17
|
import org.junit.Assert;
|
18
|
import org.junit.Before;
|
19
|
import org.junit.BeforeClass;
|
20
|
import org.junit.Test;
|
21
|
|
22
|
import eu.etaxonomy.cdm.model.agent.Contact;
|
23
|
import eu.etaxonomy.cdm.model.agent.Person;
|
24
|
import eu.etaxonomy.cdm.model.agent.Team;
|
25
|
import eu.etaxonomy.cdm.model.common.AnnotatableEntity;
|
26
|
import eu.etaxonomy.cdm.model.common.Annotation;
|
27
|
import eu.etaxonomy.cdm.model.common.DefaultTermInitializer;
|
28
|
import eu.etaxonomy.cdm.model.common.LSID;
|
29
|
import eu.etaxonomy.cdm.model.common.TimePeriod;
|
30
|
import eu.etaxonomy.cdm.model.location.Point;
|
31
|
import eu.etaxonomy.cdm.model.location.ReferenceSystem;
|
32
|
import eu.etaxonomy.cdm.model.location.WaterbodyOrCountry;
|
33
|
import eu.etaxonomy.cdm.model.name.BotanicalName;
|
34
|
import eu.etaxonomy.cdm.model.name.Rank;
|
35
|
import eu.etaxonomy.cdm.model.reference.IBook;
|
36
|
import eu.etaxonomy.cdm.model.reference.IBookSection;
|
37
|
import eu.etaxonomy.cdm.model.reference.IPrintSeries;
|
38
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
39
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
40
|
|
41
|
/**
|
42
|
* @author a.mueller
|
43
|
* @created 03.08.2009
|
44
|
* @version 1.0
|
45
|
*/
|
46
|
public class DefaultMatchStrategyTest {
|
47
|
@SuppressWarnings("unused")
|
48
|
private static final Logger logger = Logger.getLogger(DefaultMatchStrategyTest.class);
|
49
|
|
50
|
private DefaultMatchStrategy matchStrategy;
|
51
|
private IBook book1;
|
52
|
private String editionString1 ="Ed.1";
|
53
|
private String volumeString1 ="Vol.1";
|
54
|
private Team team1;
|
55
|
private IPrintSeries printSeries1;
|
56
|
private Annotation annotation1;
|
57
|
private String title1 = "Title1";
|
58
|
private TimePeriod datePublished1 = TimePeriod.NewInstance(2000);
|
59
|
private int hasProblem1 = 1;
|
60
|
private LSID lsid1;
|
61
|
|
62
|
private IBook book2;
|
63
|
private String editionString2 ="Ed.2";
|
64
|
private String volumeString2 ="Vol.2";
|
65
|
private Team team2;
|
66
|
private IPrintSeries printSeries2;
|
67
|
private Annotation annotation2;
|
68
|
private String annotationString2;
|
69
|
private String title2 = "Title2";
|
70
|
private DateTime created2 = new DateTime(1999, 3, 1, 0, 0, 0, 0);
|
71
|
private TimePeriod datePublished2 = TimePeriod.NewInstance(2002);
|
72
|
private int hasProblem2 = 1;
|
73
|
private LSID lsid2;
|
74
|
|
75
|
private IBook book3;
|
76
|
|
77
|
/**
|
78
|
* @throws java.lang.Exception
|
79
|
*/
|
80
|
@BeforeClass
|
81
|
public static void setUpBeforeClass() throws Exception {
|
82
|
DefaultTermInitializer termInitializer = new DefaultTermInitializer();
|
83
|
termInitializer.initialize();
|
84
|
}
|
85
|
|
86
|
/**
|
87
|
* @throws java.lang.Exception
|
88
|
*/
|
89
|
@AfterClass
|
90
|
public static void tearDownAfterClass() throws Exception {
|
91
|
}
|
92
|
|
93
|
/**
|
94
|
* @throws java.lang.Exception
|
95
|
*/
|
96
|
@Before
|
97
|
public void setUp() throws Exception {
|
98
|
team1 = Team.NewInstance();
|
99
|
team1.setTitleCache("Team1",true);
|
100
|
team2 = Team.NewInstance();
|
101
|
team2.setTitleCache("Team2",true);
|
102
|
printSeries1 = ReferenceFactory.newPrintSeries("Series1");
|
103
|
printSeries1.setTitle("print series");
|
104
|
printSeries2 = ReferenceFactory.newPrintSeries("Series2");
|
105
|
annotation1 = Annotation.NewInstance("Annotation1", null);
|
106
|
annotationString2 = "Annotation2";
|
107
|
annotation2 = Annotation.NewInstance(annotationString2, null);
|
108
|
|
109
|
book1 = ReferenceFactory.newBook();
|
110
|
book1.setAuthorTeam(team1);
|
111
|
book1.setTitle(title1);
|
112
|
book1.setEdition(editionString1);
|
113
|
book1.setVolume(volumeString1);
|
114
|
book1.setInSeries(printSeries1);
|
115
|
((AnnotatableEntity) book1).addAnnotation(annotation1);
|
116
|
book1.setDatePublished(datePublished1);
|
117
|
book1.setParsingProblem(hasProblem1);
|
118
|
lsid1 = new LSID("authority1", "namespace1", "object1", "revision1");
|
119
|
book1.setLsid(lsid1);
|
120
|
((Reference) book1).setNomenclaturallyRelevant(false);
|
121
|
|
122
|
book2 = ReferenceFactory.newBook();
|
123
|
book2.setAuthorTeam(team2);
|
124
|
book2.setTitle(title2);
|
125
|
book2.setEdition(editionString2);
|
126
|
book2.setVolume(volumeString2);
|
127
|
book2.setInSeries(printSeries2);
|
128
|
( (AnnotatableEntity) book2).addAnnotation(annotation2);
|
129
|
book2.setCreated(created2);
|
130
|
book2.setDatePublished(datePublished2);
|
131
|
book2.setParsingProblem(hasProblem2);
|
132
|
lsid2 = new LSID("authority2", "namespace2", "object2", "revision2");
|
133
|
book2.setLsid(lsid2);
|
134
|
((Reference) book2).setNomenclaturallyRelevant(true);
|
135
|
|
136
|
}
|
137
|
|
138
|
/**
|
139
|
* @throws java.lang.Exception
|
140
|
*/
|
141
|
@After
|
142
|
public void tearDown() throws Exception {
|
143
|
}
|
144
|
|
145
|
//********************* TEST *********************************************/
|
146
|
|
147
|
/**
|
148
|
* Test method for {@link eu.etaxonomy.cdm.strategy.match.DefaultMatchStrategy#NewInstance(java.lang.Class)}.
|
149
|
*/
|
150
|
@Test
|
151
|
public void testNewInstance() {
|
152
|
matchStrategy = DefaultMatchStrategy.NewInstance(Reference.class);
|
153
|
Assert.assertNotNull(matchStrategy);
|
154
|
Assert.assertEquals(Reference.class, matchStrategy.getMatchClass());
|
155
|
}
|
156
|
|
157
|
/**
|
158
|
* Test method for {@link eu.etaxonomy.cdm.strategy.match.DefaultMatchStrategy#getMatchMode(java.lang.String)}.
|
159
|
*/
|
160
|
@Test
|
161
|
public void testGetMatchMode() {
|
162
|
matchStrategy = DefaultMatchStrategy.NewInstance(Reference.class);
|
163
|
Assert.assertEquals("Match mode for isbn should be MatchMode.EQUAL_", MatchMode.EQUAL, matchStrategy.getMatchMode("isbn"));
|
164
|
Assert.assertEquals("Match mode for title should be MatchMode.EQUAL", MatchMode.EQUAL_REQUIRED, matchStrategy.getMatchMode("title"));
|
165
|
}
|
166
|
|
167
|
/**
|
168
|
* Test method for {@link eu.etaxonomy.cdm.strategy.match.DefaultMatchStrategy#getMatchMode(java.lang.String)}.
|
169
|
*/
|
170
|
@Test
|
171
|
public void testGetSetMatchMode() {
|
172
|
//legal value
|
173
|
try {
|
174
|
matchStrategy = DefaultMatchStrategy.NewInstance(Reference.class);
|
175
|
matchStrategy.setMatchMode("edition", MatchMode.EQUAL_REQUIRED);
|
176
|
Assert.assertEquals("Match mode for edition should be", MatchMode.EQUAL_REQUIRED, matchStrategy.getMatchMode("edition"));
|
177
|
} catch (MatchException e1) {
|
178
|
Assert.fail();
|
179
|
}
|
180
|
//illegalValue
|
181
|
try {
|
182
|
matchStrategy.setMatchMode("xxx", MatchMode.EQUAL_REQUIRED);
|
183
|
Assert.fail("A property name must exist, otherwise an exception must be thrown");
|
184
|
} catch (Exception e) {
|
185
|
//ok
|
186
|
}
|
187
|
//illegalValue
|
188
|
try {
|
189
|
matchStrategy.setMatchMode("cacheStrategy", MatchMode.EQUAL_REQUIRED);
|
190
|
Assert.fail("CacheStrategy is transient and therefore not a legal match parameter");
|
191
|
} catch (Exception e) {
|
192
|
//ok
|
193
|
}
|
194
|
}
|
195
|
|
196
|
@Test
|
197
|
public void testInvokeCache() throws MatchException {
|
198
|
matchStrategy = DefaultMatchStrategy.NewInstance(Reference.class);
|
199
|
Assert.assertTrue("Same object should always match", matchStrategy.invoke(book1, book1));
|
200
|
|
201
|
IBook bookClone = (IBook) ((Reference) book1).clone();
|
202
|
Assert.assertTrue("Cloned book should match", matchStrategy.invoke(book1, bookClone));
|
203
|
book1.setTitleCache("cache1",true);
|
204
|
Assert.assertFalse("Cached book should not match", matchStrategy.invoke(book1, bookClone));
|
205
|
|
206
|
bookClone.setTitleCache("cache1",true);
|
207
|
Assert.assertTrue("Cached book with same cache should match", matchStrategy.invoke(book1, bookClone));
|
208
|
|
209
|
bookClone.setTitleCache("cache2",true);
|
210
|
Assert.assertFalse("Cached book with differings caches should not match", matchStrategy.invoke(book1, bookClone));
|
211
|
bookClone.setTitleCache("cache1",true); //restore
|
212
|
|
213
|
bookClone.setEdition(null);
|
214
|
Assert.assertTrue("Cached book with a defined and a null edition should match", matchStrategy.invoke(book1, bookClone));
|
215
|
|
216
|
matchStrategy = DefaultMatchStrategy.NewInstance(BotanicalName.class);
|
217
|
BotanicalName botName1 = BotanicalName.NewInstance(Rank.GENUS());
|
218
|
BotanicalName botName2 = BotanicalName.NewInstance(Rank.GENUS());
|
219
|
Assert.assertNotNull("Rank should not be null", botName1.getRank());
|
220
|
|
221
|
botName1.setGenusOrUninomial("Genus1");
|
222
|
botName2.setGenusOrUninomial("Genus1");
|
223
|
Assert.assertTrue("Names with equal genus should match", matchStrategy.invoke(botName1, botName2));
|
224
|
|
225
|
botName1.setCombinationAuthorTeam(team1);
|
226
|
botName2.setCombinationAuthorTeam(null);
|
227
|
Assert.assertFalse("Names one having an author the other one not should not match", matchStrategy.invoke(botName1, botName2));
|
228
|
|
229
|
botName1.setAuthorshipCache("authorCache1");
|
230
|
botName2.setAuthorshipCache("authorCache1");
|
231
|
Assert.assertTrue("Names with cached authors should match", matchStrategy.invoke(botName1, botName2));
|
232
|
|
233
|
}
|
234
|
|
235
|
|
236
|
@Test
|
237
|
public void testInvokeReferences() throws MatchException {
|
238
|
matchStrategy = DefaultMatchStrategy.NewInstance(Reference.class);
|
239
|
Assert.assertTrue("Same object should always match", matchStrategy.invoke(book1, book1));
|
240
|
|
241
|
IBook bookClone = (IBook) ((Reference) book1).clone();
|
242
|
Assert.assertTrue("Cloned book should match", matchStrategy.invoke(book1, bookClone));
|
243
|
bookClone.setTitle("Any title");
|
244
|
Assert.assertFalse("Books with differing titles should not match", matchStrategy.invoke(book1, bookClone));
|
245
|
String originalTitle = book1.getTitle();
|
246
|
bookClone.setTitle(originalTitle);
|
247
|
Assert.assertTrue("Cloned book should match", matchStrategy.invoke(book1, bookClone));
|
248
|
book1.setTitle(null);
|
249
|
bookClone.setTitle(null);
|
250
|
Assert.assertFalse("Books with no title should not match", matchStrategy.invoke(book1, bookClone));
|
251
|
book1.setTitle(originalTitle);
|
252
|
bookClone.setTitle(originalTitle);
|
253
|
|
254
|
|
255
|
bookClone.setInSeries(printSeries2);
|
256
|
Assert.assertFalse("Cloned book with differing print series should not match", matchStrategy.invoke(book1, bookClone));
|
257
|
IPrintSeries seriesClone = (IPrintSeries)((Reference)printSeries1).clone();
|
258
|
bookClone.setInSeries(seriesClone);
|
259
|
Assert.assertTrue("Cloned book with cloned bookSeries should match", matchStrategy.invoke(book1, bookClone));
|
260
|
seriesClone.setTitle("Another title");
|
261
|
Assert.assertFalse("Cloned book should not match with differing series title", matchStrategy.invoke(book1, bookClone));
|
262
|
bookClone.setInSeries(printSeries1);
|
263
|
Assert.assertTrue("Original printSeries should match", matchStrategy.invoke(book1, bookClone));
|
264
|
|
265
|
IBook bookTitle1 = ReferenceFactory.newBook();
|
266
|
IBook bookTitle2 = ReferenceFactory.newBook();
|
267
|
Assert.assertFalse("Books without title should not match", matchStrategy.invoke(bookTitle1, bookTitle2));
|
268
|
String title = "Any title";
|
269
|
bookTitle1.setTitle(title);
|
270
|
bookTitle2.setTitle(title);
|
271
|
Assert.assertTrue("Books with same title (not empty) should match", matchStrategy.invoke(bookTitle1, bookTitle2));
|
272
|
bookTitle1.setTitle("");
|
273
|
bookTitle2.setTitle("");
|
274
|
Assert.assertFalse("Books with empty title should not match", matchStrategy.invoke(bookTitle1, bookTitle2));
|
275
|
|
276
|
//Time period
|
277
|
bookTitle1.setTitle(title);
|
278
|
bookTitle2.setTitle(title);
|
279
|
bookTitle1.setDatePublished(TimePeriod.NewInstance(1999, 2002));
|
280
|
Assert.assertFalse("Books with differing publication dates should not match", matchStrategy.invoke(bookTitle1, bookTitle2));
|
281
|
bookTitle2.setDatePublished(TimePeriod.NewInstance(1998));
|
282
|
Assert.assertFalse("Books with differing publication dates should not match", matchStrategy.invoke(bookTitle1, bookTitle2));
|
283
|
bookTitle2.setDatePublished(TimePeriod.NewInstance(1999));
|
284
|
Assert.assertFalse("Books with differing publication dates should not match", matchStrategy.invoke(bookTitle1, bookTitle2));
|
285
|
bookTitle2.setDatePublished(TimePeriod.NewInstance(1999, 2002));
|
286
|
Assert.assertTrue("Books with same publication dates should match", matchStrategy.invoke(bookTitle1, bookTitle2));
|
287
|
|
288
|
//BookSection
|
289
|
IBookSection section1 = ReferenceFactory.newBookSection();
|
290
|
section1.setInBook(bookTitle1);
|
291
|
section1.setTitle("SecTitle");
|
292
|
section1.setPages("22-33");
|
293
|
IBookSection section2 = ReferenceFactory.newBookSection();
|
294
|
section2.setInBook(bookTitle1);
|
295
|
section2.setTitle("SecTitle");
|
296
|
section2.setPages("22-33");
|
297
|
|
298
|
|
299
|
IMatchStrategy bookSectionMatchStrategy = DefaultMatchStrategy.NewInstance(Reference.class);
|
300
|
Assert.assertTrue("Equal BookSections should match", bookSectionMatchStrategy.invoke(section1, section2));
|
301
|
section2.setInBook(bookTitle2);
|
302
|
Assert.assertTrue("Matching books should result in matching book sections", bookSectionMatchStrategy.invoke(section1, section2));
|
303
|
bookTitle2.setPages("xx");
|
304
|
Assert.assertFalse("Sections with differing books should not match", bookSectionMatchStrategy.invoke(section1, section2));
|
305
|
//restore
|
306
|
bookTitle2.setPages(null);
|
307
|
Assert.assertTrue("Matching books should result in matching book sections", bookSectionMatchStrategy.invoke(section1, section2));
|
308
|
printSeries2.setTitle("A new series title");
|
309
|
IMatchStrategy printSeriesMatchStrategy = DefaultMatchStrategy.NewInstance(Reference.class);
|
310
|
Assert.assertFalse("Print series with differing titles should not match", printSeriesMatchStrategy.invoke(printSeries1, printSeries2));
|
311
|
bookTitle1.setInSeries(printSeries1);
|
312
|
bookTitle2.setInSeries(printSeries2);
|
313
|
Assert.assertFalse("Books with not matching in series should not match", matchStrategy.invoke(bookTitle1, bookTitle2));
|
314
|
Assert.assertFalse("Sections with differing print series should not match", bookSectionMatchStrategy.invoke(section1, section2));
|
315
|
|
316
|
//authorTeam
|
317
|
Person person1 = Person.NewTitledInstance("person");
|
318
|
Person person2 = Person.NewTitledInstance("person");
|
319
|
|
320
|
person1.setPrefix("pre1");
|
321
|
person2.setPrefix("pre2");
|
322
|
book2= (IBook) ((Reference) book1).clone();
|
323
|
|
324
|
Assert.assertTrue("Equal books should match", matchStrategy.invoke(book1, book2));
|
325
|
|
326
|
book1.setAuthorTeam(person1);
|
327
|
book2.setAuthorTeam(person1);
|
328
|
Assert.assertTrue("Books with same author should match", matchStrategy.invoke(book1, book2));
|
329
|
|
330
|
book2.setAuthorTeam(person2);
|
331
|
Assert.assertFalse("Books with different authors should not match", matchStrategy.invoke(book1, book2));
|
332
|
|
333
|
person2.setPrefix("pre1");
|
334
|
Assert.assertTrue("Books with matching authors should not match", matchStrategy.invoke(book1, book2));
|
335
|
}
|
336
|
|
337
|
|
338
|
/**
|
339
|
* Test method for {@link eu.etaxonomy.cdm.strategy.match.DefaultMatchStrategy#invoke(eu.etaxonomy.cdm.strategy.match.IMergable, eu.etaxonomy.cdm.strategy.match.IMergable)}.
|
340
|
* @throws MatchException
|
341
|
*/
|
342
|
@Test
|
343
|
public void testInvokeTaxonNames() throws MatchException {
|
344
|
matchStrategy = DefaultMatchStrategy.NewInstance(BotanicalName.class);
|
345
|
|
346
|
BotanicalName botName1 = BotanicalName.NewInstance(Rank.SPECIES());
|
347
|
BotanicalName botName2 = BotanicalName.NewInstance(Rank.SPECIES());
|
348
|
BotanicalName botName3 = BotanicalName.NewInstance(Rank.SPECIES());
|
349
|
|
350
|
Assert.assertFalse("Names without title should not match", matchStrategy.invoke(botName1, botName2));
|
351
|
|
352
|
botName1.setGenusOrUninomial("Genus1");
|
353
|
botName1.setSpecificEpithet("species1");
|
354
|
|
355
|
botName2.setGenusOrUninomial("Genus1");
|
356
|
botName2.setSpecificEpithet("species1");
|
357
|
Assert.assertTrue("Similar names with titles set should match", matchStrategy.invoke(botName1, botName2));
|
358
|
|
359
|
|
360
|
botName1.setAnamorphic(true);
|
361
|
botName2.setAnamorphic(false);
|
362
|
Assert.assertFalse("Similar names with differing boolean marker values should not match", matchStrategy.invoke(botName1, botName2));
|
363
|
botName2.setAnamorphic(true);
|
364
|
Assert.assertTrue("Similar names with same boolean marker values should match", matchStrategy.invoke(botName1, botName2));
|
365
|
|
366
|
|
367
|
|
368
|
// //name relations
|
369
|
// botName2.addBasionym(botName3, book1, "p.22", null);
|
370
|
// Specimen specimen1 = Specimen.NewInstance();
|
371
|
// botName2.addSpecimenTypeDesignation(specimen1, SpecimenTypeDesignationStatus.HOLOTYPE(), book2, "p.56", "originalNameString", false, true);
|
372
|
//
|
373
|
// //descriptions
|
374
|
// TaxonNameDescription description1 = TaxonNameDescription.NewInstance();
|
375
|
// botName1.addDescription(description1);
|
376
|
// TaxonNameDescription description2 = TaxonNameDescription.NewInstance();
|
377
|
// botName2.addDescription(description2);
|
378
|
|
379
|
//authors
|
380
|
Team team1 = Team.NewInstance();
|
381
|
Team team2 = Team.NewInstance();
|
382
|
botName1.setCombinationAuthorTeam(team1);
|
383
|
botName2.setCombinationAuthorTeam(team2);
|
384
|
Assert.assertTrue("Similar teams should match", DefaultMatchStrategy.NewInstance(Team.class).invoke(team1, team2));
|
385
|
Assert.assertTrue("Similar names with matching authors should match", matchStrategy.invoke(botName1, botName2));
|
386
|
|
387
|
}
|
388
|
|
389
|
/**
|
390
|
* Test method for {@link eu.etaxonomy.cdm.strategy.match.DefaultMatchStrategy#invoke(IMatchable, IMatchable), eu.etaxonomy.cdm.strategy.match.IMatchable)}.
|
391
|
* @throws MatchException
|
392
|
*/
|
393
|
@Test
|
394
|
public void testInvokeAgents() throws MatchException {
|
395
|
IMatchStrategy matchStrategy = DefaultMatchStrategy.NewInstance(Team.class);
|
396
|
|
397
|
Team team1 = Team.NewInstance();
|
398
|
Team team2 = Team.NewInstance();
|
399
|
Team team3 = Team.NewInstance();
|
400
|
|
401
|
Assert.assertTrue("Teams should match", matchStrategy.invoke(team1, team2));
|
402
|
Assert.assertTrue("Teams should match", matchStrategy.invoke(team1, team3));
|
403
|
|
404
|
String street1 = "Strasse1";
|
405
|
team1.setContact(Contact.NewInstance(street1, "12345", "Berlin", WaterbodyOrCountry.ARGENTINAARGENTINEREPUBLIC(),"pobox" , "Region", "a@b.de", "f12345", "+49-30-123456", "www.abc.de", Point.NewInstance(2.4, 3.2, ReferenceSystem.WGS84(), 3)));
|
406
|
team2.setContact(Contact.NewInstance("Street2", null, "London", null, null, null, null, "874599873", null, null, null));
|
407
|
Assert.assertTrue("Contacts should be ignoredin default match strategy", matchStrategy.invoke(team1, team2));
|
408
|
|
409
|
team1.setNomenclaturalTitle("nomTitle1");
|
410
|
team2.setNomenclaturalTitle("nomTitle2");
|
411
|
Assert.assertFalse("Agents with differing nomenclatural titles should not match", matchStrategy.invoke(team1, team2));
|
412
|
//restore
|
413
|
team2.setNomenclaturalTitle("nomTitle1");
|
414
|
Assert.assertTrue("Agents with equal nomenclatural titles should match", matchStrategy.invoke(team1, team2));
|
415
|
|
416
|
|
417
|
Person person1 = Person.NewTitledInstance("person1");
|
418
|
person1.setProtectedTitleCache(true);
|
419
|
Person person2 = Person.NewTitledInstance("person2");
|
420
|
person2.setProtectedTitleCache(true);
|
421
|
Person person3 = Person.NewTitledInstance("person3");
|
422
|
person3.setProtectedTitleCache(true);
|
423
|
|
424
|
team1.addTeamMember(person1);
|
425
|
team2.addTeamMember(person1);
|
426
|
Assert.assertTrue("Teams with same team members should match", matchStrategy.invoke(team1, team2));
|
427
|
|
428
|
team1.addTeamMember(person2);
|
429
|
Assert.assertFalse("Teams with differing team members should not match", matchStrategy.invoke(team1, team2));
|
430
|
team2.addTeamMember(person2);
|
431
|
Assert.assertTrue("Teams with same team members should match", matchStrategy.invoke(team1, team2));
|
432
|
team2.removeTeamMember(person2);
|
433
|
person3.setPrefix("pre3");
|
434
|
team2.addTeamMember(person3);
|
435
|
Assert.assertFalse("Teams with differing team members should not match", matchStrategy.invoke(team1, team2));
|
436
|
person3.setTitleCache(person2.getTitleCache(),true);
|
437
|
person2.setPrefix("pre3");
|
438
|
Assert.assertTrue("Teams with matching members in right order should match", matchStrategy.invoke(team1, team2));
|
439
|
team2.removeTeamMember(person1);
|
440
|
team2.addTeamMember(person1);
|
441
|
Assert.assertFalse("Teams with matching members in wrong order should not match", matchStrategy.invoke(team1, team2));
|
442
|
|
443
|
}
|
444
|
|
445
|
@Test
|
446
|
public void testInvokeTeamOrPersonBase(){
|
447
|
|
448
|
}
|
449
|
|
450
|
}
|