}
/**
- * Tests if two objects are equal or both null. Otherwise returns false
- * @param obj1
- * @param obj2
- * @return
+ * Tests if two objects are equal or both null. Otherwise returns <code>false</code>.
*/
public static boolean nullSafeEqual(Object obj1, Object obj2) {
if (obj1 == null){
return obj2 == null;
}
- return (obj1.equals(obj2));
+ return (obj1 == obj2) || (obj1.equals(obj2));
}
/**
*/
public class TaxonNodeNaturalComparator implements Comparator<TaxonNode> {
- public TaxonNodeNaturalComparator(){
- super();
- }
-
@SuppressWarnings("null")
@Override
public int compare(TaxonNode node1, TaxonNode node2) {
return node1.getSortIndex().compareTo(node2.getSortIndex());
}
String lastEqualAncestorTreeIndex = "";
- List<TaxonNode> ancestorAndNode= new ArrayList<>();
- ancestorAndNode.add(node1);
- ancestorAndNode.addAll(node1.getAncestorList());
- java.util.Collections.sort(ancestorAndNode, new TreeIndexComparator());
+ List<TaxonNode> ancestorAndNode1= new ArrayList<>();
+ ancestorAndNode1.add(node1);
+ ancestorAndNode1.addAll(node1.getAncestorList());
+ java.util.Collections.sort(ancestorAndNode1, new TreeIndexComparator());
List<TaxonNode> ancestorAndNode2= new ArrayList<>();
if (lastEqualAncestorTreeIndex != null){
TaxonNode lastEqualTreeIndexAncestorNode1 = null;
TaxonNode lastEqualTreeIndexAncestorNode2 = null;
- for (TaxonNode next1 :ancestorAndNode){
+ for (TaxonNode next1 :ancestorAndNode1){
if (next1.treeIndex().equals(lastEqualAncestorTreeIndex+"#"+splitNode1[i]+ "#") ){
lastEqualTreeIndexAncestorNode1 = next1;
}
throw new RuntimeException(
"Required check for SpecimenOrObservationBase_Media");
} else {
- logger.warn("CHECKS for inconsistent data not running !!!!");
+ logger.info("CHECKS for inconsistent data not running !!!!");
}
List<ISchemaUpdaterStep> stepList = new ArrayList<>();
String uuid = singleFilter.getUuid().toString();
String op = isFirst ? "" : op2Hql(singleFilter.getOperator());
result = String.format("(%s%s(tn.classification.uuid = '%s'))", result, op, uuid);
- System.out.println(result);
isFirst = false;
}
return result;
private Set<T> newEntities;
+
public MergeResult(T mergedEntity, Set<T> newEntities) {
this.mergedEntity = mergedEntity;
this.newEntities = newEntities;
}
- /**
- * @return the mergedEntity
- */
public T getMergedEntity() {
return mergedEntity;
}
- /**
- * @param mergedEntity the mergedEntity to set
- */
public void setMergedEntity(T mergedEntity) {
this.mergedEntity = mergedEntity;
}
}
}
}
- }
+ }
} catch (ClassNotFoundException e) {
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
-
package eu.etaxonomy.cdm.persistence.dao.hibernate.common;
import static org.junit.Assert.assertEquals;
}
@Override
- public void createTestDataSet() throws FileNotFoundException {
- // TODO Auto-generated method stub
-
- }
+ public void createTestDataSet() throws FileNotFoundException {}
}
* The contents of this file are subject to the Mozilla Public License Version 1.1\r
* See LICENSE.TXT at the top of this package for the full license terms.\r
*/\r
-\r
package eu.etaxonomy.cdm.persistence.dao.hibernate.name;\r
\r
import static org.junit.Assert.assertEquals;\r
+/**
+* Copyright (C) 2009 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
package eu.etaxonomy.cdm.persistence.dao.hibernate.occurrence;
import java.io.FileNotFoundException;
import java.util.List;
import java.util.stream.Collectors;
+import org.apache.log4j.Logger;
import org.h2.util.StringUtils;
import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
import org.junit.Test;
import org.unitils.spring.annotation.SpringBeanByType;
public class OccurrenceDaoHibernateImplTest extends CdmIntegrationTest {
- @SpringBeanByType
- private IOccurrenceDao dao;
-
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- }
+ private static final Logger logger = Logger.getLogger(OccurrenceDaoHibernateImplTest.class);
- @Before
- public void setUp() throws Exception {
- }
+ @SpringBeanByType
+ private IOccurrenceDao dao;
//**************** TESTS ************************************************
logger.warn("Not yet implemented");
}
- @Test
- public void testOccurrenceDaoHibernateImpl() {
- logger.warn("Not yet implemented");
- }
-
- @Test
- public void testCountDerivationEvents() {
- logger.warn("Not yet implemented");
- }
-
- @Test
- public void testCountDeterminations() {
- logger.warn("Not yet implemented");
- }
-
@Test
public void testCountMedia() {
MediaSpecimen unit = MediaSpecimen.NewInstance(SpecimenOrObservationType.Media);
Assert.assertEquals(2, dao.countMedia(unit));
}
- @Test
- public void testGetDerivationEvents() {
- logger.warn("Not yet implemented");
- }
-
- @Test
- public void testGetDeterminations() {
- logger.warn("Not yet implemented");
- }
-
- @Test
- public void testCountClassOfQextendsSpecimenOrObservationBaseTaxonBase() {
- logger.warn("Not yet implemented");
- }
-
- @Test
- public void testListClassOfQextendsSpecimenOrObservationBaseTaxonBaseIntegerIntegerListOfOrderHintListOfString() {
- logger.warn("Not yet implemented");
- }
-
- @Test
- public void testGetDerivedUnitUuidAndTitleCache() {
- logger.warn("Not yet implemented");
- }
-
- @Test
- public void testGetFieldUnitUuidAndTitleCache() {
- logger.warn("Not yet implemented");
- }
-
- @Test
- public void testListByAnyAssociation() {
- logger.warn("Not yet implemented");
- }
-
@Test
public void testSaveOriginalLabelData(){
DerivedUnit unit = DerivedUnit.NewInstance(SpecimenOrObservationType.DerivedUnit);
}
System.out.println();
System.out.println("end!");
-
}
- /* (non-Javadoc)
- * @see eu.etaxonomy.cdm.test.integration.CdmIntegrationTest#createTestData()
- */
@Override
- public void createTestDataSet() throws FileNotFoundException {
- // TODO Auto-generated method stub
-
- }
+ public void createTestDataSet() throws FileNotFoundException {}
}
/**
- *
- */
+* Copyright (C) 2009 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
package eu.etaxonomy.cdm.persistence.dao.hibernate.taxon;
import static org.junit.Assert.assertEquals;
/**
* @author a.mueller
* @since 2014/06/13
- *
*/
public class TaxonNodeFilterDaoHibernateImplTest extends CdmTransactionalIntegrationTest {
@SpringBeanByType
private IDefinedTermDao termDao;
-
private final UUID europeUuid = UUID.fromString("e860871c-3a14-4ef2-9367-bbd92586c95b");
private final UUID germanyUuid = UUID.fromString("7b7c2db5-aa44-4302-bdec-6556fd74b0b9");
private final UUID denmarkUuid = UUID.fromString("f818c97e-fd61-42fe-9d75-d433f8cb349c");
private final UUID uuidNode5 = UUID.fromString("e01f56c7-0315-450b-a05b-881d21adf02b");
private final UUID uuidNodeUnpublished = UUID.fromString("96888466-f40e-43ed-a17d-cdc62bdf0ff0");
-
private Classification classification1;
private TaxonNode node1;
private TaxonNode node2;
nodeUnpublished.setUuid(uuidNodeUnpublished);
nodeUnpublished = taxonNodeDao.save(nodeUnpublished);
-
-
//MergeResult result = taxonNodeDao.merge(node5, true);
//node5 = (TaxonNode) result.getMergedEntity();
listUuid = filterDao.listUuids(filter);
Assert.assertEquals("All 3 children should be returned", 3, listUuid.size());
-
filter = TaxonNodeFilter.NewSubtreeInstance(taxon1.getUuid());
listUuid = filterDao.listUuids(filter);
Assert.assertEquals("A NON subtree uuid should not return a result", 0, listUuid.size());
public AbstractHibernateTaxonGraphProcessor taxonGraphProcessor(){
AbstractHibernateTaxonGraphProcessor processor = new AbstractHibernateTaxonGraphProcessor() {
-
@Override
public Session getSession() {
return nameDao.getSession();
}
};
-
return processor;
}
package eu.etaxonomy.cdm.persistence.hibernate;
import org.junit.Before;
-import org.junit.BeforeClass;
import org.junit.Test;
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
-
/**
* @author a.mueller
* @since 04.10.2016
- *
*/
public class CdmPreDataChangeListenerTest /*extends CdmIntegrationTest*/ {
-
- /**
- * @throws java.lang.Exception
- */
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- }
-
- /**
- * @throws java.lang.Exception
- */
@Before
public void setUp() throws Exception {
}
System.out.println(cache);
}
-// /**
-// * {@inheritDoc}
-// */
// @Override
// public void createTestDataSet() throws FileNotFoundException {}
return result;
}
- private UpdateResult swapSynonymAndAcceptedTaxonNewUuid(Synonym synonym, Taxon acceptedTaxon, boolean setNameInSource, SecReferenceHandlingSwapEnum secHandling, Reference newSecAcc, Reference newSecSyn){
+ private UpdateResult swapSynonymAndAcceptedTaxonNewUuid(Synonym oldSynonym, Taxon oldAcceptedTaxon, boolean setNameInSource, SecReferenceHandlingSwapEnum secHandling, Reference newSecAcc, Reference newSecSyn){
UpdateResult result = new UpdateResult();
- acceptedTaxon.removeSynonym(synonym);
- TaxonName synonymName = synonym.getName();
- TaxonName taxonName = HibernateProxyHelper.deproxy(acceptedTaxon.getName());
- String oldTaxonTitleCache = acceptedTaxon.getTitleCache();
+ oldAcceptedTaxon.removeSynonym(oldSynonym);
+ TaxonName synonymName = oldSynonym.getName();
+ TaxonName taxonName = HibernateProxyHelper.deproxy(oldAcceptedTaxon.getName());
+ String oldTaxonTitleCache = oldAcceptedTaxon.getTitleCache();
boolean sameHomotypicGroup = synonymName.getHomotypicalGroup().equals(taxonName.getHomotypicalGroup());
- synonymName.removeTaxonBase(synonym);
+ synonymName.removeTaxonBase(oldSynonym);
List<Synonym> synonyms = new ArrayList<>();
- for (Synonym syn: acceptedTaxon.getSynonyms()){
+ for (Synonym syn: oldAcceptedTaxon.getSynonyms()){
syn = HibernateProxyHelper.deproxy(syn, Synonym.class);
synonyms.add(syn);
}
for (Synonym syn: synonyms){
- acceptedTaxon.removeSynonym(syn);
+ oldAcceptedTaxon.removeSynonym(syn);
}
- Taxon newTaxon = acceptedTaxon.clone(true, true, false, true);
+ Taxon newTaxon = oldAcceptedTaxon.clone(true, true, false, true);
newTaxon.setSec(newSecAcc);
//move descriptions
- Set<TaxonDescription> descriptionsToCopy = new HashSet<>(acceptedTaxon.getDescriptions());
+ Set<TaxonDescription> descriptionsToCopy = new HashSet<>(oldAcceptedTaxon.getDescriptions());
for (TaxonDescription description: descriptionsToCopy){
newTaxon.addDescription(description);
}
newTaxon.setName(synonymName);
- newTaxon.setPublish(synonym.isPublish());
+ newTaxon.setPublish(oldSynonym.isPublish());
for (Synonym syn: synonyms){
if (!syn.getName().equals(newTaxon.getName())){
newTaxon.addSynonym(syn, syn.getType());
newTaxon.removeTaxonRelation(taxonRelationship);
}
- for(TaxonRelationship taxonRelationship : acceptedTaxon.getTaxonRelations()){
+ for(TaxonRelationship taxonRelationship : oldAcceptedTaxon.getTaxonRelations()){
Taxon fromTaxon = HibernateProxyHelper.deproxy(taxonRelationship.getFromTaxon());
Taxon toTaxon = HibernateProxyHelper.deproxy(taxonRelationship.getToTaxon());
- if (fromTaxon == acceptedTaxon){
+ if (fromTaxon == oldAcceptedTaxon){
newTaxon.addTaxonRelation(taxonRelationship.getToTaxon(), taxonRelationship.getType(),
taxonRelationship.getCitation(), taxonRelationship.getCitationMicroReference());
- }else if(toTaxon == acceptedTaxon){
+ }else if(toTaxon == oldAcceptedTaxon){
fromTaxon.addTaxonRelation(newTaxon, taxonRelationship.getType(),
taxonRelationship.getCitation(), taxonRelationship.getCitationMicroReference());
saveOrUpdate(fromTaxon);
}
//taxon nodes
- List<TaxonNode> nodes = new ArrayList<>(acceptedTaxon.getTaxonNodes());
+ List<TaxonNode> nodes = new ArrayList<>(oldAcceptedTaxon.getTaxonNodes());
for (TaxonNode node: nodes){
node = HibernateProxyHelper.deproxy(node);
TaxonNode parent = node.getParent();
- acceptedTaxon.removeTaxonNode(node);
+ oldAcceptedTaxon.removeTaxonNode(node);
node.setTaxon(newTaxon);
if (parent != null){
parent.addChildNode(node, null, null);
}
//synonym
- Synonym newSynonym = synonym.clone();
+ Synonym newSynonym = oldSynonym.clone();
newSynonym.setName(taxonName);
- newSynonym.setPublish(acceptedTaxon.isPublish());
+ newSynonym.setPublish(oldAcceptedTaxon.isPublish());
newSynonym.setSec(newSecSyn);
if (sameHomotypicGroup){
newTaxon.addSynonym(newSynonym, SynonymType.HOMOTYPIC_SYNONYM_OF());
confSyn.setDeleteNameIfPossible(false);
result.setCdmEntity(newTaxon);
- DeleteResult deleteResult = deleteTaxon(acceptedTaxon.getUuid(), conf, null);
- if (synonym.isPersited()){
- synonym.setSecSource(null);
- deleteResult.includeResult(deleteSynonym(synonym.getUuid(), confSyn));
+ DeleteResult deleteResult = deleteTaxon(oldAcceptedTaxon.getUuid(), conf, null);
+ if (oldSynonym.isPersited()){
+ oldSynonym.setSecSource(null);
+ deleteResult.includeResult(deleteSynonym(oldSynonym.getUuid(), confSyn));
}
result.includeResult(deleteResult);
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
+import org.apache.log4j.Logger;
import org.junit.Test;
import org.springframework.core.env.Environment;
import org.springframework.mail.SimpleMailMessage;
public class EmailSendTest extends CdmIntegrationTest {
+ private static final Logger logger = Logger.getLogger(EmailSendTest.class);
private static final String SUBJECT = "eu.etaxonomy.cdm.test.function.EmailSendTest";
}
@Override
- public void createTestDataSet() throws FileNotFoundException {
- // no data needed
- }
+ public void createTestDataSet() throws FileNotFoundException {}
}
import org.apache.log4j.Logger;
import org.hibernate.LazyInitializationException;
import org.junit.Assert;
-import org.junit.Ignore;
import org.junit.Test;
import org.unitils.database.annotations.Transactional;
import org.unitils.database.util.TransactionMode;
};
@Override
- @Ignore
- @Test
@Transactional(TransactionMode.DISABLED)
public final void createTestDataSet() {
Team combAuthor = Team.NewTitledInstance("Avengers", "Avengers");
@HibernateSessionFactory({"/eu/etaxonomy/cdm/hibernate.cfg.xml", "/eu/etaxonomy/cdm/hibernate-test.cfg.xml"})
public abstract class CdmIntegrationTest extends UnitilsJUnit4 {
- protected static final Logger logger = Logger.getLogger(CdmIntegrationTest.class);
+ private static final Logger logger = Logger.getLogger(CdmIntegrationTest.class);
private static final String PROPERTY_H2_SERVER = "h2Server";
private static final String H2_SERVER_RUNNING = "h2ServerIsRunning";