* modes for the same property path in short cut methods like {@link #getMatching()}
* or {@link #getMatchMode(String)}. Are these needed at all?
*
- *
- *
* @author a.mueller
* @since 15.10.2018
*/
updateMatching();
}
- /**
- * @throws MatchException
- *
- */
private void updateMatching() throws MatchException {
for (IMatchStrategy strategy : strategies.values()){
matching = new Matching();
return uuid;
}
-// /**
-// * {@inheritDoc}
-// */
// @Override
// public MatchMode getMatchMode(String propertyName) {
// //Copied from DefaultMatchStrategy
/**
* {@inheritDoc}
- * * @deprecated deprecated in this class, use {@link #setMatchMode(String, MatchMode, IMatchStrategyEqual)}
+ * @deprecated deprecated in this class, use {@link #setMatchMode(String, MatchMode, IMatchStrategyEqual)}
* instead.
*/
@Deprecated
}
}
-
/**
* {@inheritDoc}
* @throws MatchException
getBestMatchingStrategy(clazz).setMatchMode(propertyName, matchMode, matchStrategy);
}
- /**
- * @param clazz
- */
private IMatchStrategy getBestMatchingStrategy(Class<? extends T> clazz) {
IMatchStrategy result = strategies.get(clazz);
//TODO use subclass hierarchie
return result;
}
- /**
- * {@inheritDoc}
- */
@Override
public <S extends IMatchable> MatchResult invoke(S matchFirst, S matchSecond) throws MatchException {
return invoke(matchFirst, matchSecond, false);
}
-
@Override
public <T extends IMatchable> MatchResult invoke(T matchFirst, T matchSecond, boolean failAll)
throws MatchException {
matchResult.addClass(clazz);
}
-
strategy.invoke(matchFirst, matchSecond, matchResult, failAll);
}
- /**
- * @return
- */
private IMatchStrategy getBaseClassStrategy() {
return strategies.get(baseClass);
}
- /**
- * {@inheritDoc}
- */
@Override
public Matching getMatching() {
//preliminary not yet implemented
// return baseClass;
// }
//
-// /**
-// * {@inheritDoc}
-// */
// @Override
// public Set<String> getMatchFieldPropertyNames() {
// //preliminary not implemented. Simply aggregate, or change signature to xxx(clazz), or .. ?
// throw new RuntimeException("getMatchFieldPropertyNames not yet implemented in " + getClass().getName());
// }
//
-// /**
-// * {@inheritDoc}
-// */
// @Override
// public void setDefaultMatchMode(MatchMode defaultMatchMode) {
// for (IMatchStrategy matchStrategy : strategies.values()){
// }
// }
//
-// /**
-// * {@inheritDoc}
-// */
// @Override
// public void setDefaultCollectionMatchMode(MatchMode defaultCollectionMatchMode) {
// for (IMatchStrategy matchStrategy : strategies.values()){
// }
// }
//
-// /**
-// * {@inheritDoc}
-// */
// @Override
// public void setDefaultMatchMatchMode(MatchMode defaultMatchMatchMode) {
// for (IMatchStrategy matchStrategy : strategies.values()){
private Institution institution1;
- /**
- * @throws java.lang.Exception
- */
@BeforeClass
public static void setUpBeforeClass() throws Exception {
DefaultTermInitializer termInitializer = new DefaultTermInitializer();
termInitializer.initialize();
}
-
- /**
- * @throws java.lang.Exception
- */
@Before
public void setUp() throws Exception {
// team1 = Team.NewInstance();
}
-
//********************* TEST *********************************************/
- /**
- * Test method for {@link eu.etaxonomy.cdm.strategy.match.DefaultMatchStrategy#NewInstance(java.lang.Class)}.
- */
@Test
public void testNewInstance() {
matchStrategy = MatchStrategyFactory.NewDefaultInstance(Reference.class);
// Assert.assertEquals(Reference.class, matchStrategy.getMatchClass());
}
- /**
- * Test method for {@link eu.etaxonomy.cdm.strategy.match.DefaultMatchStrategy#invoke(IMatchable, IMatchable), eu.etaxonomy.cdm.strategy.match.IMatchable)}.
- * @throws MatchException
- */
@Test
public void testParsedPerson() throws MatchException {
IParsedMatchStrategy matchStrategy = MatchStrategyFactory.NewParsedPersonInstance();
// System.out.println(fullPerson.getTitleCache());
// System.out.println(parsedPerson.getTitleCache());
Assert.assertFalse("Differing nom. title should not match", matchStrategy.invoke(fullPerson, parsedPerson).isSuccessful());
-
-
}
-
- /**
- * @return
- */
protected Person getDefaultFullPerson() {
Person fullPerson = Person.NewInstance();
fullPerson.setInitials("F.G.");
return fullPerson;
}
-
-
-
-
- /**
- * @return
- */
protected Person getDefaultParsedPerson() {
Person parsedPerson = Person.NewInstance();
parsedPerson.setNomenclaturalTitle("Nam.");
* Test method for {@link eu.etaxonomy.cdm.strategy.match.DefaultMatchStrategy#invoke(IMatchable, IMatchable), eu.etaxonomy.cdm.strategy.match.IMatchable)}.
* @throws MatchException
*/
- @Test
- public void testParsedTeam() throws MatchException {
- IParsedMatchStrategy matchStrategy = MatchStrategyFactory.NewParsedTeamInstance();
- Assert.assertNotNull(matchStrategy);
- Team fullTeam;
- Team parsedTeam;
- MatchResult matchResult;
-
- fullTeam = getDefaultFullTeam();
- parsedTeam = getDefaultParsedTeam();
-
- //should match
- Assert.assertTrue("Same nom.title. should match", matchStrategy.invoke(fullTeam, parsedTeam).isSuccessful());
-
- //differing nom. title.
- parsedTeam.setNomenclaturalTitle("Wrong");
- Assert.assertFalse("Differing nom.title. should not match", matchStrategy.invoke(fullTeam, parsedTeam).isSuccessful());
-
- //differing family
- parsedTeam = getDefaultParsedTeam();
- parsedTeam.getTeamMembers().get(0).setFamilyName("Wrong");
- matchResult = matchStrategy.invoke(fullTeam, parsedTeam, true);
- Assert.assertFalse("Differing family name should not match", matchResult.isSuccessful());
- parsedTeam.getTeamMembers().get(0).setNomenclaturalTitle("Wrong.");
- matchResult = matchStrategy.invoke(fullTeam, parsedTeam, true);
- System.out.println(matchResult);
- Assert.assertFalse("Differing family name should not match", matchResult.isSuccessful());
-
-
- //
- parsedTeam = getDefaultParsedTeam();
- parsedTeam.getTeamMembers().get(0).setInitials("D.");
- Assert.assertFalse("Differing nom. title should not match", matchStrategy.invoke(fullTeam, parsedTeam).isSuccessful());
-
- //nom. title. (2)
- fullTeam = getDefaultFullTeam();
- parsedTeam = getDefaultParsedTeam();
- fullTeam.setNomenclaturalTitle("Wro.");
- Assert.assertFalse("Differing nom. title should not match", matchStrategy.invoke(fullTeam, parsedTeam).isSuccessful());
-
- //fullPerson protected
- fullTeam = getDefaultFullTeam();
- parsedTeam = getDefaultParsedTeam();
- fullTeam.setTitleCache(fullTeam.getTitleCache(), true);
- Assert.assertFalse("Differing protected title should not match", matchStrategy.invoke(fullTeam, parsedTeam).isSuccessful());
-
- //parsedPerson protected
- fullTeam = getDefaultFullTeam();
- parsedTeam = getDefaultParsedTeam();
- parsedTeam.setTitleCache(parsedTeam.getTitleCache(), true);
- Assert.assertFalse("Differing nom. title should not match", matchStrategy.invoke(fullTeam, parsedTeam).isSuccessful());
-
- fullTeam = getDefaultFullTeam();
- parsedTeam = getDefaultParsedTeam();
- fullTeam.setHasMoreMembers(true);
- Assert.assertFalse("Differing nom. title should not match", matchStrategy.invoke(fullTeam, parsedTeam).isSuccessful());
-
-
- }
+ @Test
+ public void testParsedTeam() throws MatchException {
+ IParsedMatchStrategy matchStrategy = MatchStrategyFactory.NewParsedTeamInstance();
+ Assert.assertNotNull(matchStrategy);
+ Team fullTeam;
+ Team parsedTeam;
+ MatchResult matchResult;
+ fullTeam = getDefaultFullTeam();
+ parsedTeam = getDefaultParsedTeam();
+
+ //should match
+ Assert.assertTrue("Same nom.title. should match", matchStrategy.invoke(fullTeam, parsedTeam).isSuccessful());
+
+ //differing nom. title.
+ parsedTeam.setNomenclaturalTitle("Wrong");
+ Assert.assertFalse("Differing nom.title. should not match", matchStrategy.invoke(fullTeam, parsedTeam).isSuccessful());
+
+ //differing family
+ parsedTeam = getDefaultParsedTeam();
+ parsedTeam.getTeamMembers().get(0).setFamilyName("Wrong");
+ matchResult = matchStrategy.invoke(fullTeam, parsedTeam, true);
+ Assert.assertFalse("Differing family name should not match", matchResult.isSuccessful());
+ parsedTeam.getTeamMembers().get(0).setNomenclaturalTitle("Wrong.");
+ matchResult = matchStrategy.invoke(fullTeam, parsedTeam, true);
+ System.out.println(matchResult);
+ Assert.assertFalse("Differing family name should not match", matchResult.isSuccessful());
+
+ //
+ parsedTeam = getDefaultParsedTeam();
+ parsedTeam.getTeamMembers().get(0).setInitials("D.");
+ Assert.assertFalse("Differing nom. title should not match", matchStrategy.invoke(fullTeam, parsedTeam).isSuccessful());
+
+ //nom. title. (2)
+ fullTeam = getDefaultFullTeam();
+ parsedTeam = getDefaultParsedTeam();
+ fullTeam.setNomenclaturalTitle("Wro.");
+ Assert.assertFalse("Differing nom. title should not match", matchStrategy.invoke(fullTeam, parsedTeam).isSuccessful());
+
+ //fullPerson protected
+ fullTeam = getDefaultFullTeam();
+ parsedTeam = getDefaultParsedTeam();
+ fullTeam.setTitleCache(fullTeam.getTitleCache(), true);
+ Assert.assertFalse("Differing protected title should not match", matchStrategy.invoke(fullTeam, parsedTeam).isSuccessful());
+
+ //parsedPerson protected
+ fullTeam = getDefaultFullTeam();
+ parsedTeam = getDefaultParsedTeam();
+ parsedTeam.setTitleCache(parsedTeam.getTitleCache(), true);
+ Assert.assertFalse("Differing nom. title should not match", matchStrategy.invoke(fullTeam, parsedTeam).isSuccessful());
+
+ fullTeam = getDefaultFullTeam();
+ parsedTeam = getDefaultParsedTeam();
+ fullTeam.setHasMoreMembers(true);
+ Assert.assertFalse("Differing nom. title should not match", matchStrategy.invoke(fullTeam, parsedTeam).isSuccessful());
+ }
- /**
- * @return
- */
private Team getDefaultFullTeam() {
Team team = Team.NewInstance();
team.addTeamMember(getDefaultFullPerson());
parsedBook = getDefaultParsedBook();
((Team)fullBook.getAuthorship()).getTeamMembers().get(0).setFamilyName("Changed");
Assert.assertTrue("Full book family name author changed should still match", matchStrategy.invoke(fullBook, parsedBook).isSuccessful());
-
-
}
-
@Test
public void testParsedBookSection() throws MatchException {
IParsedMatchStrategy matchStrategy = MatchStrategyFactory.NewParsedBookSectionInstance();
Assert.assertTrue("Full book family name author changed should still match", matchStrategy.invoke(fullBookSection, parsedBookSection).isSuccessful());
}
-
- /**
- * @return
- */
private IBook getDefaultFullBook() {
IBook book = getDefaultParsedBook();
book.setAuthorship(getDefaultFullTeam());
return book;
}
-
- /**
- * @return
- */
private IBook getDefaultParsedBook() {
IBook book = ReferenceFactory.newBook();
book.setAbbrevTitle("Fl. Hell.");
return book;
}
-
- /**
- * @return
- */
private IBookSection getDefaultFullBookSection() {
IBookSection bookSection = getMatchingFullBookSection();
bookSection.setTitle("Book section title");
return bookSection;
}
- /**
- * @return
- */
private IBookSection getDefaultParsedBookSection() {
IBookSection bookSection = ReferenceFactory.newBookSection();
bookSection.setAuthorship(getDefaultParsedPerson());
return bookSection;
}
-
@Test
public void testParsedArticle() throws MatchException {
IParsedMatchStrategy matchStrategy = MatchStrategyFactory.NewParsedArticleInstance();
return article;
}
- /**
- * @return
- */
private IArticle getDefaultParsedArticle() {
IArticle article = ReferenceFactory.newArticle();
article.setAuthorship(getDefaultParsedTeam());
return journal;
}
-
- /**
- * @return
- */
private IJournal getDefaultParsedJournal() {
IJournal journal = ReferenceFactory.newJournal();
journal.setAbbrevTitle("Fl. Hell.");
((Team)fullArticle.getAuthorship()).getTeamMembers().get(0).setFamilyName("Changed");
Assert.assertTrue("Full book family name author changed should still match", matchStrategy.invoke(fullArticle, parsedArticle).isSuccessful());
}
-
-
}