Revision 4dbcb616
Added by Andreas Müller over 3 years ago
cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/match/DefaultMatchStrategyTest.java | ||
---|---|---|
12 | 12 |
import org.joda.time.DateTime; |
13 | 13 |
import org.junit.Assert; |
14 | 14 |
import org.junit.Before; |
15 |
import org.junit.BeforeClass; |
|
16 | 15 |
import org.junit.Test; |
17 | 16 |
|
18 | 17 |
import eu.etaxonomy.cdm.common.URI; |
... | ... | |
35 | 34 |
import eu.etaxonomy.cdm.model.reference.IPrintSeries; |
36 | 35 |
import eu.etaxonomy.cdm.model.reference.Reference; |
37 | 36 |
import eu.etaxonomy.cdm.model.reference.ReferenceFactory; |
38 |
import eu.etaxonomy.cdm.model.term.DefaultTermInitializer;
|
|
37 |
import eu.etaxonomy.cdm.test.TermTestBase;
|
|
39 | 38 |
|
40 | 39 |
/** |
41 | 40 |
* @author a.mueller |
42 | 41 |
* @since 03.08.2009 |
43 | 42 |
*/ |
44 |
public class DefaultMatchStrategyTest { |
|
45 |
@SuppressWarnings("unused") |
|
43 |
public class DefaultMatchStrategyTest extends TermTestBase { |
|
44 |
|
|
45 |
@SuppressWarnings("unused") |
|
46 | 46 |
private static final Logger logger = Logger.getLogger(DefaultMatchStrategyTest.class); |
47 | 47 |
|
48 | 48 |
private DefaultMatchStrategy matchStrategy; |
... | ... | |
72 | 72 |
|
73 | 73 |
private IBook book3; |
74 | 74 |
|
75 |
@BeforeClass |
|
76 |
public static void setUpBeforeClass() throws Exception { |
|
77 |
DefaultTermInitializer termInitializer = new DefaultTermInitializer(); |
|
78 |
termInitializer.initialize(); |
|
79 |
} |
|
80 |
|
|
81 | 75 |
@Before |
82 | 76 |
public void setUp() throws Exception { |
83 | 77 |
team1 = Team.NewInstance(); |
... | ... | |
122 | 116 |
|
123 | 117 |
//********************* TEST *********************************************/ |
124 | 118 |
|
125 |
/** |
|
126 |
* Test method for {@link eu.etaxonomy.cdm.strategy.match.DefaultMatchStrategy#NewInstance(java.lang.Class)}. |
|
127 |
*/ |
|
128 | 119 |
@Test |
129 | 120 |
public void testNewInstance() { |
130 | 121 |
matchStrategy = DefaultMatchStrategy.NewInstance(Reference.class); |
... | ... | |
132 | 123 |
// Assert.assertEquals(Reference.class, matchStrategy.getMatchClass()); |
133 | 124 |
} |
134 | 125 |
|
135 |
/** |
|
136 |
* Test method for {@link eu.etaxonomy.cdm.strategy.match.DefaultMatchStrategy#getMatchMode(java.lang.String)}. |
|
137 |
*/ |
|
138 | 126 |
@Test |
139 | 127 |
public void testGetMatchMode() { |
140 | 128 |
matchStrategy = DefaultMatchStrategy.NewInstance(Reference.class); |
... | ... | |
142 | 130 |
// Assert.assertEquals("Match mode for title should be MatchMode.EQUAL_REQUIRED", MatchMode.EQUAL_REQUIRED, matchStrategy.getMatchMode("title")); |
143 | 131 |
} |
144 | 132 |
|
145 |
/** |
|
146 |
* Test method for {@link eu.etaxonomy.cdm.strategy.match.DefaultMatchStrategy#getMatchMode(java.lang.String)}. |
|
147 |
*/ |
|
148 | 133 |
@Test |
149 | 134 |
public void testGetSetMatchMode() { |
150 | 135 |
//legal value |
... | ... | |
209 | 194 |
botName1.setAuthorshipCache("authorCache1"); |
210 | 195 |
botName2.setAuthorshipCache("authorCache1"); |
211 | 196 |
Assert.assertTrue("Names with cached authors should match", matchStrategy.invoke(botName1, botName2).isSuccessful()); |
212 |
|
|
213 | 197 |
} |
214 | 198 |
|
215 |
|
|
216 | 199 |
@Test |
217 | 200 |
public void testInvokeReferences() throws MatchException { |
218 | 201 |
matchStrategy = DefaultMatchStrategy.NewInstance(Reference.class); |
... | ... | |
231 | 214 |
book1.setTitle(originalTitle); |
232 | 215 |
bookClone.setTitle(originalTitle); |
233 | 216 |
|
234 |
|
|
235 | 217 |
bookClone.setInSeries(printSeries2); |
236 | 218 |
Assert.assertFalse("Cloned book with differing print series should not match", matchStrategy.invoke(book1, bookClone).isSuccessful()); |
237 | 219 |
IPrintSeries seriesClone = ((Reference)printSeries1).clone(); |
... | ... | |
275 | 257 |
section2.setTitle("SecTitle"); |
276 | 258 |
section2.setPages("22-33"); |
277 | 259 |
|
278 |
|
|
279 | 260 |
IMatchStrategyEqual bookSectionMatchStrategy = DefaultMatchStrategy.NewInstance(Reference.class); |
280 | 261 |
Assert.assertTrue("Equal BookSections should match", bookSectionMatchStrategy.invoke(section1, section2).isSuccessful()); |
281 | 262 |
section2.setInBook(bookTitle2); |
... | ... | |
314 | 295 |
Assert.assertTrue("Books with matching authors should not match", matchStrategy.invoke(book1, book2).isSuccessful()); |
315 | 296 |
} |
316 | 297 |
|
317 |
|
|
318 |
/** |
|
319 |
* Test method for {@link eu.etaxonomy.cdm.strategy.match.DefaultMatchStrategy#invoke(eu.etaxonomy.cdm.strategy.match.IMergable, eu.etaxonomy.cdm.strategy.match.IMergable)}. |
|
320 |
* @throws MatchException |
|
321 |
*/ |
|
322 | 298 |
@Test |
323 | 299 |
public void testInvokeTaxonNames() throws MatchException { |
324 | 300 |
matchStrategy = DefaultMatchStrategy.NewInstance(TaxonName.class); |
... | ... | |
336 | 312 |
botName2.setSpecificEpithet("species1"); |
337 | 313 |
Assert.assertTrue("Similar names with titles set should match", matchStrategy.invoke(botName1, botName2).isSuccessful()); |
338 | 314 |
|
339 |
|
|
340 | 315 |
botName1.setAnamorphic(true); |
341 | 316 |
botName2.setAnamorphic(false); |
342 | 317 |
Assert.assertFalse("Similar names with differing boolean marker values should not match", matchStrategy.invoke(botName1, botName2).isSuccessful()); |
343 | 318 |
botName2.setAnamorphic(true); |
344 | 319 |
Assert.assertTrue("Similar names with same boolean marker values should match", matchStrategy.invoke(botName1, botName2).isSuccessful()); |
345 | 320 |
|
346 |
|
|
347 |
|
|
348 | 321 |
// //name relations |
349 | 322 |
// botName2.addBasionym(botName3, book1, "p.22", null); |
350 | 323 |
// Specimen specimen1 = Specimen.NewInstance(); |
... | ... | |
363 | 336 |
botName2.setCombinationAuthorship(team2); |
364 | 337 |
Assert.assertTrue("Similar teams should match", DefaultMatchStrategy.NewInstance(Team.class).invoke(team1, team2).isSuccessful()); |
365 | 338 |
Assert.assertTrue("Similar names with matching authors should match", matchStrategy.invoke(botName1, botName2).isSuccessful()); |
366 |
|
|
367 | 339 |
} |
368 | 340 |
|
369 |
/** |
|
370 |
* Test method for {@link eu.etaxonomy.cdm.strategy.match.DefaultMatchStrategy#invoke(IMatchable, IMatchable), eu.etaxonomy.cdm.strategy.match.IMatchable)}. |
|
371 |
* @throws MatchException |
|
372 |
*/ |
|
373 | 341 |
@Test |
374 | 342 |
public void testInvokeAgents() throws MatchException { |
375 | 343 |
IMatchStrategyEqual matchStrategy = DefaultMatchStrategy.NewInstance(Team.class); |
... | ... | |
393 | 361 |
team2.setNomenclaturalTitle("nomTitle1"); |
394 | 362 |
Assert.assertTrue("Agents with equal nomenclatural titles should match", matchStrategy.invoke(team1, team2).isSuccessful()); |
395 | 363 |
|
396 |
|
|
397 | 364 |
Person person1 = Person.NewTitledInstance("person1"); |
398 | 365 |
person1.setProtectedTitleCache(true); |
399 | 366 |
Person person2 = Person.NewTitledInstance("person2"); |
... | ... | |
419 | 386 |
team2.removeTeamMember(person1); |
420 | 387 |
team2.addTeamMember(person1); |
421 | 388 |
Assert.assertFalse("Teams with matching members in wrong order should not match", matchStrategy.invoke(team1, team2).isSuccessful()); |
422 |
|
|
423 | 389 |
} |
424 |
|
|
425 |
@Test |
|
426 |
public void testInvokeTeamOrPersonBase(){ |
|
427 |
|
|
428 |
} |
|
429 |
|
|
430 |
} |
|
390 |
} |
Also available in: Unified diff
cleanup and use TermTestBase for model tests