Revision 4dbcb616
Added by Andreas Müller over 3 years ago
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/CdmTypeScanner.java | ||
---|---|---|
20 | 20 |
/** |
21 | 21 |
* @author a.kohlbecker |
22 | 22 |
* @since Jul 31, 2014 |
23 |
* |
|
24 | 23 |
*/ |
25 | 24 |
public class CdmTypeScanner<T> extends ClassPathScanningCandidateComponentProvider { |
26 | 25 |
|
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/HomotypicalGroup.java | ||
---|---|---|
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.model.name; |
11 | 10 |
|
12 | 11 |
import java.util.HashSet; |
... | ... | |
30 | 29 |
import eu.etaxonomy.cdm.model.common.AnnotatableEntity; |
31 | 30 |
import eu.etaxonomy.cdm.model.reference.Reference; |
32 | 31 |
|
33 |
|
|
34 | 32 |
/** |
35 | 33 |
* The homotypical group class represents a set of {@link TaxonName taxon names} associated |
36 | 34 |
* on the base of their typifications. Since it can be asserted that two taxon |
... | ... | |
376 | 374 |
|
377 | 375 |
/** |
378 | 376 |
* Returns all taxon names in the homotypical group that have a 'is_basionym_for' (zool.: 'is_original_combination_for') relationship. |
379 |
* @return |
|
380 | 377 |
*/ |
381 | 378 |
@Transient |
382 | 379 |
public Set<TaxonName> getBasionyms(){ |
... | ... | |
390 | 387 |
|
391 | 388 |
/** |
392 | 389 |
* Returns all taxon names in the homotypical group that have a 'is_replaced_synonym_for' relationship. |
393 |
* @return |
|
394 | 390 |
*/ |
395 | 391 |
@Transient |
396 | 392 |
public Set<TaxonName> getReplacedSynonym(){ |
... | ... | |
405 | 401 |
/** |
406 | 402 |
* Returns the name relationships that represent either a basionym (original combination) relationship or |
407 | 403 |
* a replaced synonym relationship. |
408 |
* @return |
|
409 | 404 |
*/ |
410 | 405 |
@Transient |
411 | 406 |
public Set<NameRelationship> getBasionymAndReplacedSynonymRelations(){ |
... | ... | |
466 | 461 |
return false; |
467 | 462 |
} |
468 | 463 |
} |
469 |
|
|
470 |
|
|
471 |
} |
|
464 |
} |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/term/DefaultTermInitializer.java | ||
---|---|---|
21 | 21 |
|
22 | 22 |
/** |
23 | 23 |
* @author a.mueller |
24 |
* |
|
25 | 24 |
*/ |
26 | 25 |
public class DefaultTermInitializer implements ITermInitializer { |
27 |
@SuppressWarnings("unused") |
|
26 |
|
|
27 |
@SuppressWarnings("unused") |
|
28 | 28 |
private static final Logger logger = Logger.getLogger(DefaultTermInitializer.class); |
29 | 29 |
protected ITermLoader termLoader = new TermLoader(); |
30 | 30 |
|
... | ... | |
47 | 47 |
TermVocabulary<?> voc = termLoader.loadTerms(vocabularyEnum, terms); |
48 | 48 |
setDefinedTerms(vocabularyEnum.getClazz(),voc); |
49 | 49 |
} |
50 |
|
|
51 | 50 |
} |
52 | 51 |
|
53 | 52 |
protected void setDefinedTerms(Class<? extends DefinedTermBase<?>> clazz, TermVocabulary<?> vocabulary) { |
... | ... | |
67 | 66 |
} |
68 | 67 |
} |
69 | 68 |
|
70 |
|
|
71 | 69 |
public void setOmit(boolean omit) { |
72 | 70 |
this.omit = omit; |
73 | 71 |
} |
... | ... | |
75 | 73 |
public boolean isOmit() { |
76 | 74 |
return omit; |
77 | 75 |
} |
78 |
|
|
79 |
|
|
80 |
} |
|
76 |
} |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/datagenerator/TaxonGenerator.java | ||
---|---|---|
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.datagenerator; |
11 | 10 |
|
12 | 11 |
import eu.etaxonomy.cdm.model.agent.Person; |
... | ... | |
29 | 28 |
* This class offers functionality to create test taxa and descriptions. |
30 | 29 |
* |
31 | 30 |
* @author m.doering |
32 |
* |
|
33 | 31 |
*/ |
34 | 32 |
public class TaxonGenerator { |
33 |
|
|
35 | 34 |
private static String[] genera = {"Carex", "Abies", "Belladonna", "Dracula", "Maria", "Calendula", "Polygala", "Vincia"}; |
36 | 35 |
private static String[] epitheta = {"vulgaris", "magdalena", "officinalis", "alba", "negra", "communa", "alpina", "rotundifolia", "greutheriana", "helventica", "allemania", "franca"}; |
37 | 36 |
private static String[] ranks = {"subsp", "var", "f"}; |
... | ... | |
77 | 76 |
Synonym homoSynonym = Synonym.NewInstance(botSpecies4, sec); |
78 | 77 |
childTaxon.addSynonym(homoSynonym, SynonymType.HOMOTYPIC_SYNONYM_OF()); |
79 | 78 |
|
80 |
|
|
81 | 79 |
//2nd child species taxon that is the child of genus taxon |
82 | 80 |
IBotanicalName botSpecies2= TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES()); |
83 | 81 |
botSpecies2.setTitleCache("Hieracium wolffii Zahn", true); |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/format/description/CategoricalDataFormatterTest.java | ||
---|---|---|
10 | 10 |
|
11 | 11 |
import org.junit.Assert; |
12 | 12 |
import org.junit.Before; |
13 |
import org.junit.BeforeClass; |
|
14 | 13 |
import org.junit.Test; |
15 | 14 |
|
16 |
import eu.etaxonomy.cdm.format.ICdmFormatter; |
|
17 | 15 |
import eu.etaxonomy.cdm.format.ICdmFormatter.FormatKey; |
18 |
import eu.etaxonomy.cdm.format.description.CategoricalDataFormatter; |
|
19 |
import eu.etaxonomy.cdm.model.common.Language; |
|
20 | 16 |
import eu.etaxonomy.cdm.model.description.CategoricalData; |
21 | 17 |
import eu.etaxonomy.cdm.model.description.Feature; |
22 | 18 |
import eu.etaxonomy.cdm.model.description.State; |
23 | 19 |
import eu.etaxonomy.cdm.model.description.StateData; |
24 |
import eu.etaxonomy.cdm.model.term.DefaultTermInitializer;
|
|
20 |
import eu.etaxonomy.cdm.test.TermTestBase;
|
|
25 | 21 |
|
26 | 22 |
/** |
27 | 23 |
* Test for {@link CategoricalDataFormatter}. |
... | ... | |
29 | 25 |
* @author a.mueller |
30 | 26 |
* @since 11.03.2020 |
31 | 27 |
*/ |
32 |
public class CategoricalDataFormatterTest { |
|
28 |
public class CategoricalDataFormatterTest extends TermTestBase {
|
|
33 | 29 |
|
34 | 30 |
private State state1; |
35 | 31 |
private State state2; |
... | ... | |
48 | 44 |
stateData3 = StateData.NewInstance(state3); |
49 | 45 |
} |
50 | 46 |
|
51 |
@BeforeClass |
|
52 |
public static void setUpBeforeClass() throws Exception { |
|
53 |
if (Language.DEFAULT() == null){ |
|
54 |
new DefaultTermInitializer().initialize(); |
|
55 |
} |
|
56 |
} |
|
57 |
|
|
58 | 47 |
@Test |
59 | 48 |
public void testFormat() { |
60 | 49 |
CategoricalData catData = CategoricalData.NewInstance(Feature.HABITAT()); |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/format/description/QuantitativeDataFormatterTest.java | ||
---|---|---|
12 | 12 |
|
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 |
import eu.etaxonomy.cdm.format.ICdmFormatter; |
|
19 | 17 |
import eu.etaxonomy.cdm.format.ICdmFormatter.FormatKey; |
20 |
import eu.etaxonomy.cdm.format.description.QuantitativeDataFormatter; |
|
21 |
import eu.etaxonomy.cdm.model.common.Language; |
|
22 | 18 |
import eu.etaxonomy.cdm.model.description.Feature; |
23 | 19 |
import eu.etaxonomy.cdm.model.description.MeasurementUnit; |
24 | 20 |
import eu.etaxonomy.cdm.model.description.QuantitativeData; |
25 | 21 |
import eu.etaxonomy.cdm.model.description.StatisticalMeasure; |
26 | 22 |
import eu.etaxonomy.cdm.model.description.StatisticalMeasurementValue; |
27 |
import eu.etaxonomy.cdm.model.term.DefaultTermInitializer;
|
|
23 |
import eu.etaxonomy.cdm.test.TermTestBase;
|
|
28 | 24 |
|
29 | 25 |
/** |
30 | 26 |
* Test for {@link QuantitativeDataFormatter}. |
... | ... | |
32 | 28 |
* @author a.mueller |
33 | 29 |
* @since 12.03.2020 |
34 | 30 |
*/ |
35 |
public class QuantitativeDataFormatterTest { |
|
31 |
public class QuantitativeDataFormatterTest extends TermTestBase {
|
|
36 | 32 |
|
37 | 33 |
private StatisticalMeasurementValue min1; |
38 | 34 |
private StatisticalMeasurementValue max1; |
... | ... | |
45 | 41 |
n1 = StatisticalMeasurementValue.NewInstance(StatisticalMeasure.SAMPLE_SIZE(), new BigDecimal("2")); |
46 | 42 |
} |
47 | 43 |
|
48 |
@BeforeClass |
|
49 |
public static void setUpBeforeClass() throws Exception { |
|
50 |
if (Language.DEFAULT() == null){ |
|
51 |
new DefaultTermInitializer().initialize(); |
|
52 |
} |
|
53 |
} |
|
54 |
|
|
55 | 44 |
@Test |
56 | 45 |
public void testFormat() { |
57 | 46 |
QuantitativeData quantData = QuantitativeData.NewInstance(Feature.CHROMOSOME_NUMBER()); |
... | ... | |
70 | 59 |
text = formatter.format(quantData, formatKey); |
71 | 60 |
Assert.assertEquals("0.1-1.3 m [n=2]", text); |
72 | 61 |
} |
73 |
} |
|
62 |
} |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/format/taxon/TaxonRelationshipFormatterTest.java | ||
---|---|---|
12 | 12 |
|
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 |
import eu.etaxonomy.cdm.format.taxon.TaxonRelationshipFormatter; |
|
19 | 17 |
import eu.etaxonomy.cdm.model.agent.Person; |
20 | 18 |
import eu.etaxonomy.cdm.model.agent.Team; |
21 | 19 |
import eu.etaxonomy.cdm.model.common.Language; |
... | ... | |
28 | 26 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
29 | 27 |
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship; |
30 | 28 |
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType; |
31 |
import eu.etaxonomy.cdm.model.term.DefaultTermInitializer; |
|
32 | 29 |
import eu.etaxonomy.cdm.strategy.cache.TaggedCacheHelper; |
33 | 30 |
import eu.etaxonomy.cdm.strategy.cache.TaggedText; |
31 |
import eu.etaxonomy.cdm.test.TermTestBase; |
|
34 | 32 |
|
35 | 33 |
/** |
36 | 34 |
* Test to test the {@link TaxonRelationshipFormatter}. |
... | ... | |
38 | 36 |
* @author a.mueller |
39 | 37 |
* @since 14.08.2018 |
40 | 38 |
*/ |
41 |
public class TaxonRelationshipFormatterTest { |
|
39 |
public class TaxonRelationshipFormatterTest extends TermTestBase{
|
|
42 | 40 |
|
43 | 41 |
private static boolean WITHOUT_NAME = true; |
44 | 42 |
|
... | ... | |
62 | 60 |
private Person toSecAuthor; |
63 | 61 |
private List<Language> languages; |
64 | 62 |
|
65 |
@BeforeClass |
|
66 |
public static void setUpBeforeClass() throws Exception { |
|
67 |
if (Language.DEFAULT() == null){ |
|
68 |
new DefaultTermInitializer().initialize(); |
|
69 |
} |
|
70 |
} |
|
71 |
|
|
72 | 63 |
@Before |
73 | 64 |
public void setUp() throws Exception { |
74 | 65 |
fromName = TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES()); |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/hibernate/HHH_9751_UtilTest.java | ||
---|---|---|
16 | 16 |
/** |
17 | 17 |
* @author a.kohlbecker |
18 | 18 |
* @since Jun 13, 2016 |
19 |
* |
|
20 | 19 |
*/ |
21 | 20 |
public class HHH_9751_UtilTest extends Assert { |
22 | 21 |
|
23 | 22 |
@Test |
24 | 23 |
public void testNullRemoval() { |
25 |
ArrayList<String> list = new ArrayList<String>();
|
|
24 |
ArrayList<String> list = new ArrayList<>(); |
|
26 | 25 |
list.add("1"); |
27 | 26 |
list.add("2"); |
28 | 27 |
list.add(null); |
... | ... | |
34 | 33 |
assertEquals(3, list.size()); |
35 | 34 |
assertNotNull(list.get(2)); |
36 | 35 |
} |
37 |
|
|
38 |
} |
|
36 |
} |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/hibernate/PartialUserTypeTest.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2016 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
1 | 9 |
package eu.etaxonomy.cdm.hibernate; |
2 | 10 |
|
3 | 11 |
import static org.junit.Assert.assertTrue; |
... | ... | |
12 | 20 |
import org.junit.Before; |
13 | 21 |
import org.junit.Test; |
14 | 22 |
|
15 |
|
|
16 | 23 |
public class PartialUserTypeTest { |
17 | 24 |
private static final Logger logger = Logger.getLogger(PartialUserTypeTest.class); |
18 | 25 |
|
cdmlib-model/src/test/java/eu/etaxonomy/cdm/hibernate/ShiftUsertTypeTest.java | ||
---|---|---|
1 | 1 |
/** |
2 |
* |
|
3 |
*/ |
|
2 |
* Copyright (C) 2016 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
4 | 9 |
package eu.etaxonomy.cdm.hibernate; |
5 | 10 |
|
6 | 11 |
import java.io.Serializable; |
12 |
import java.sql.Types; |
|
7 | 13 |
|
8 | 14 |
import org.junit.Assert; |
9 | 15 |
import org.junit.Before; |
... | ... | |
13 | 19 |
|
14 | 20 |
/** |
15 | 21 |
* @author a.mueller |
16 |
* |
|
17 | 22 |
*/ |
18 | 23 |
public class ShiftUsertTypeTest { |
19 | 24 |
|
20 | 25 |
private ShiftUserType shiftUserType; |
21 |
|
|
22 |
/** |
|
23 |
* @throws java.lang.Exception |
|
24 |
*/ |
|
26 |
|
|
25 | 27 |
@Before |
26 | 28 |
public void setUp() throws Exception { |
27 | 29 |
shiftUserType = new ShiftUserType(); |
28 | 30 |
} |
29 | 31 |
|
30 |
/** |
|
31 |
* Test method for {@link eu.etaxonomy.cdm.hibernate.ShiftUserType#deepCopy(java.lang.Object)}. |
|
32 |
*/ |
|
33 | 32 |
@Test |
34 | 33 |
public void testDeepCopyObject() { |
35 | 34 |
//TODO |
36 | 35 |
} |
37 | 36 |
|
38 |
/** |
|
39 |
* Test method for {@link eu.etaxonomy.cdm.hibernate.ShiftUserType#disassemble(java.lang.Object)}. |
|
40 |
*/ |
|
41 | 37 |
@Test |
42 | 38 |
public void testDisassembleObject() { |
43 | 39 |
Serializable nullValue = this.shiftUserType.disassemble(null); |
... | ... | |
50 | 46 |
Assert.assertEquals("2,3;3,-1", twoValues); |
51 | 47 |
} |
52 | 48 |
|
53 |
/** |
|
54 |
* Test method for {@link eu.etaxonomy.cdm.hibernate.ShiftUserType#nullSafeGet(java.sql.ResultSet, java.lang.String[], org.hibernate.engine.spi.SessionImplementor, java.lang.Object)}. |
|
55 |
*/ |
|
56 | 49 |
@Test |
57 | 50 |
public void testNullSafeGetString() { |
58 | 51 |
Shift[] emptyResult = shiftUserType.nullSafeGet(""); |
... | ... | |
61 | 54 |
Assert.assertEquals(1, singleResult.length); |
62 | 55 |
} |
63 | 56 |
|
64 |
/** |
|
65 |
* Test method for {@link eu.etaxonomy.cdm.hibernate.ShiftUserType#nullSafeSet(java.sql.PreparedStatement, java.lang.Object, int, org.hibernate.engine.spi.SessionImplementor)}. |
|
66 |
*/ |
|
67 | 57 |
@Test |
68 | 58 |
public void testNullSafeSet() { |
69 | 59 |
//TODO |
70 | 60 |
} |
71 | 61 |
|
72 |
/** |
|
73 |
* Test method for {@link eu.etaxonomy.cdm.hibernate.ShiftUserType#returnedClass()}. |
|
74 |
*/ |
|
75 | 62 |
@Test |
76 | 63 |
public void testReturnedClass() { |
77 | 64 |
Class<?> returnedClass = new ShiftUserType().returnedClass(); |
78 | 65 |
Assert.assertEquals(Shift[].class, returnedClass); |
79 | 66 |
} |
80 | 67 |
|
81 |
/** |
|
82 |
* Test method for {@link eu.etaxonomy.cdm.hibernate.ShiftUserType#sqlTypes()}. |
|
83 |
*/ |
|
84 | 68 |
@Test |
85 | 69 |
public void testSqlTypes() { |
86 | 70 |
int[] sqlTypes = new ShiftUserType().sqlTypes(); |
87 |
// Assert.assertEquals(new int[]{ Types.CLOB }, sqlTypes);
|
|
71 |
Assert.assertArrayEquals(new int[]{Types.CLOB}, sqlTypes);
|
|
88 | 72 |
} |
89 |
|
|
90 |
} |
|
73 |
} |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/CdmTypeScannerTest.java | ||
---|---|---|
22 | 22 |
/** |
23 | 23 |
* @author a.kohlbecker |
24 | 24 |
* @since Jul 31, 2014 |
25 |
* |
|
26 | 25 |
*/ |
27 | 26 |
public class CdmTypeScannerTest { |
28 | 27 |
|
29 | 28 |
@Test |
30 |
public void testCdmModelTypes() throws ClassNotFoundException {
|
|
29 |
public void testCdmModelTypes() { |
|
31 | 30 |
|
32 | 31 |
boolean includeAbstract = true; |
33 | 32 |
boolean includeInterfaces = false; |
34 | 33 |
|
35 |
CdmTypeScanner scanner = new CdmTypeScanner<CdmBase>(includeAbstract, includeInterfaces);
|
|
34 |
CdmTypeScanner<CdmBase> scanner = new CdmTypeScanner<>(includeAbstract, includeInterfaces);
|
|
36 | 35 |
|
37 | 36 |
scanner.addIncludeFilter(new CdmAssignableTypeFilter(IdentifiableEntity.class, includeAbstract, includeInterfaces)); |
38 | 37 |
|
... | ... | |
40 | 39 |
assertTrue(classes.contains(TaxonDescription.class)); |
41 | 40 |
assertTrue("abstract base classes are missing", classes.contains(DescriptionBase.class)); |
42 | 41 |
} |
43 |
} |
|
42 |
} |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/DatabaseInitialiser.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2007 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
|
|
10 |
package eu.etaxonomy.cdm.model; |
|
11 |
|
|
12 |
import org.apache.log4j.Logger; |
|
13 |
import org.hibernate.Session; |
|
14 |
import org.hibernate.SessionFactory; |
|
15 |
import org.hibernate.Transaction; |
|
16 |
import org.springframework.context.support.ClassPathXmlApplicationContext; |
|
17 |
|
|
18 |
import eu.etaxonomy.cdm.model.name.INonViralName; |
|
19 |
import eu.etaxonomy.cdm.model.name.Rank; |
|
20 |
import eu.etaxonomy.cdm.model.name.TaxonNameFactory; |
|
21 |
//import eu.etaxonomy.cdm.model.reference.Journal; |
|
22 |
import eu.etaxonomy.cdm.model.reference.IJournal; |
|
23 |
import eu.etaxonomy.cdm.model.reference.Reference; |
|
24 |
import eu.etaxonomy.cdm.model.reference.ReferenceFactory; |
|
25 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
|
26 |
|
|
27 |
|
|
28 |
public class DatabaseInitialiser { |
|
29 |
private static final Logger logger = Logger.getLogger(DatabaseInitialiser.class); |
|
30 |
|
|
31 |
private static SessionFactory factory; |
|
32 |
private static ClassPathXmlApplicationContext applicationContext; |
|
33 |
|
|
34 |
public DatabaseInitialiser() { |
|
35 |
applicationContext = new ClassPathXmlApplicationContext("appInitContext.xml"); |
|
36 |
factory = (SessionFactory)applicationContext.getBean("sessionFactory"); |
|
37 |
} |
|
38 |
|
|
39 |
public static Integer insertTaxon(String speciesname){ |
|
40 |
logger.info("Populate database with a taxon"); |
|
41 |
IJournal sec = ReferenceFactory.newJournal(); |
|
42 |
INonViralName nvName = TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES()); |
|
43 |
Taxon tax = Taxon.NewInstance(nvName, (Reference)sec); |
|
44 |
nvName.setNameCache(speciesname); |
|
45 |
nvName.setTitleCache(speciesname, true); |
|
46 |
save(tax); |
|
47 |
return tax.getId(); |
|
48 |
} |
|
49 |
|
|
50 |
private static void save(Object obj){ |
|
51 |
Session s = factory.openSession(); |
|
52 |
Transaction tx = s.beginTransaction(); |
|
53 |
s.saveOrUpdate(obj); |
|
54 |
tx.commit(); |
|
55 |
s.close(); |
|
56 |
} |
|
57 |
|
|
58 |
public static void main(String[] args) { |
|
59 |
DatabaseInitialiser dbInit = new DatabaseInitialiser(); |
|
60 |
DatabaseInitialiser.insertTaxon("Abies alba"); |
|
61 |
DatabaseInitialiser.insertTaxon("Polygala vulgaris"); |
|
62 |
} |
|
63 |
} |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/agent/AgentValidationTest.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2009 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.cdm.model.agent; |
|
10 |
|
|
11 |
import java.util.Set; |
|
12 |
|
|
13 |
import javax.validation.ConstraintViolation; |
|
14 |
import javax.validation.Validation; |
|
15 |
import javax.validation.Validator; |
|
16 |
import javax.validation.ValidatorFactory; |
|
17 |
|
|
18 |
import org.junit.BeforeClass; |
|
19 |
import org.junit.Test; |
|
20 |
|
|
21 |
/** |
|
22 |
* @author b.clark |
|
23 |
*/ |
|
24 |
public class AgentValidationTest { |
|
25 |
|
|
26 |
private static Validator validator; |
|
27 |
|
|
28 |
@BeforeClass |
|
29 |
public static void onSetUp() throws Exception { |
|
30 |
ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); |
|
31 |
validator = factory.getValidator(); |
|
32 |
} |
|
33 |
|
|
34 |
@Test |
|
35 |
public void testNullTitleCache() { |
|
36 |
Person person = Person.NewInstance(); |
|
37 |
Set<ConstraintViolation<Person>> constraintViolations = validator.validate(person); |
|
38 |
|
|
39 |
for(ConstraintViolation<Person> constraintViolation : constraintViolations) { |
|
40 |
System.out.println(constraintViolation.getMessage()); |
|
41 |
} |
|
42 |
} |
|
43 |
} |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/agent/InstitutionalMembershipTest.java | ||
---|---|---|
5 | 5 |
* |
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 |
*/ |
|
9 |
|
|
8 |
*/ |
|
10 | 9 |
package eu.etaxonomy.cdm.model.agent; |
11 | 10 |
|
12 | 11 |
import java.util.GregorianCalendar; |
13 | 12 |
|
14 | 13 |
import org.junit.Assert; |
15 |
|
|
16 | 14 |
import org.junit.Before; |
17 | 15 |
import org.junit.Test; |
18 | 16 |
|
... | ... | |
20 | 18 |
|
21 | 19 |
/** |
22 | 20 |
* @author a.babadshanjan |
23 |
* |
|
24 | 21 |
*/ |
25 | 22 |
public class InstitutionalMembershipTest { |
26 | 23 |
|
... | ... | |
28 | 25 |
|
29 | 26 |
@Before |
30 | 27 |
public void onSetUp() throws Exception { |
31 |
|
|
28 |
|
|
32 | 29 |
mship = InstitutionalMembership.NewInstance(); |
33 |
|
|
30 |
|
|
34 | 31 |
mship.setPerson(new Person("Steve", "Miller", "Mil.")); |
35 | 32 |
GregorianCalendar joined = new GregorianCalendar(1967, 4, 23); |
36 | 33 |
GregorianCalendar resigned = new GregorianCalendar(1999, 0, 10); |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/common/ExtensionTypeTest.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
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.model.common; |
11 | 10 |
|
12 |
|
|
13 | 11 |
import static org.junit.Assert.assertEquals; |
14 | 12 |
|
15 | 13 |
import java.util.UUID; |
16 | 14 |
|
17 | 15 |
import org.apache.log4j.Logger; |
18 |
import org.junit.After; |
|
19 |
import org.junit.AfterClass; |
|
20 |
import org.junit.Before; |
|
21 |
import org.junit.BeforeClass; |
|
22 | 16 |
import org.junit.Test; |
23 | 17 |
import org.springframework.util.Assert; |
24 | 18 |
|
25 |
import eu.etaxonomy.cdm.model.term.DefaultTermInitializer; |
|
26 |
|
|
19 |
import eu.etaxonomy.cdm.test.unit.EntityTestBase; |
|
27 | 20 |
|
28 | 21 |
/** |
29 | 22 |
* @author a.mueller |
30 | 23 |
* @since 08.06.2009 |
31 | 24 |
*/ |
32 |
public class ExtensionTypeTest { |
|
33 |
@SuppressWarnings("unused") |
|
34 |
private static final Logger logger = Logger.getLogger(ExtensionTypeTest.class); |
|
35 |
|
|
36 |
/** |
|
37 |
* @throws java.lang.Exception |
|
38 |
*/ |
|
39 |
@BeforeClass |
|
40 |
public static void setUpBeforeClass() throws Exception { |
|
41 |
DefaultTermInitializer initializer = new DefaultTermInitializer(); |
|
42 |
initializer.initialize(); |
|
43 |
} |
|
25 |
public class ExtensionTypeTest extends EntityTestBase { |
|
44 | 26 |
|
45 |
/** |
|
46 |
* @throws java.lang.Exception |
|
47 |
*/ |
|
48 |
@AfterClass |
|
49 |
public static void tearDownAfterClass() throws Exception { |
|
50 |
} |
|
27 |
@SuppressWarnings("unused") |
|
28 |
private static final Logger logger = Logger.getLogger(ExtensionTypeTest.class); |
|
51 | 29 |
|
52 |
/** |
|
53 |
* @throws java.lang.Exception |
|
54 |
*/ |
|
55 |
@Before |
|
56 |
public void setUp() throws Exception { |
|
57 |
} |
|
30 |
//****************** TESTS *******************************************************/ |
|
58 | 31 |
|
59 |
/** |
|
60 |
* @throws java.lang.Exception |
|
61 |
*/ |
|
62 |
@After |
|
63 |
public void tearDown() throws Exception { |
|
64 |
} |
|
65 |
|
|
66 |
//****************** TESTS *******************************************************/ |
|
67 |
|
|
68 | 32 |
@Test |
69 | 33 |
public void testRDF(){ |
70 | 34 |
UUID uuidRdf = UUID.fromString("f3684e25-dcad-4c1e-a5d8-16cddf1c4f5b"); |
... | ... | |
72 | 36 |
Assert.notNull(rdfExtension, "RdfExtension must not be null"); |
73 | 37 |
assertEquals("Wrong label for extension type rdf", "RDF",rdfExtension.getRepresentation(Language.ENGLISH()).getAbbreviatedLabel()); |
74 | 38 |
} |
75 |
|
|
39 |
|
|
76 | 40 |
@Test |
77 | 41 |
public void testDOI(){ |
78 |
UUID uuidDoi = UUID.fromString("f079aacc-ab08-4cc4-90a0-6d3958fb0dbf"); |
|
79 | 42 |
ExtensionType doiExtension = ExtensionType.DOI(); |
80 | 43 |
Assert.notNull(doiExtension, "DoiExtension must not be null"); |
81 | 44 |
assertEquals("Wrong label for extension type rdf", "DOI",doiExtension.getLabel()); |
82 | 45 |
} |
83 |
|
|
84 |
} |
|
46 |
} |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/common/IdentifiableEntityTest.java | ||
---|---|---|
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.model.common; |
11 | 10 |
|
12 | 11 |
import static org.junit.Assert.assertEquals; |
... | ... | |
14 | 13 |
import static org.junit.Assert.assertNotNull; |
15 | 14 |
import static org.junit.Assert.assertTrue; |
16 | 15 |
|
17 |
import org.junit.After; |
|
18 |
import org.junit.AfterClass; |
|
19 | 16 |
import org.junit.Before; |
20 |
import org.junit.BeforeClass; |
|
21 | 17 |
import org.junit.Test; |
22 | 18 |
|
23 | 19 |
import eu.etaxonomy.cdm.model.agent.Person; |
... | ... | |
28 | 24 |
import eu.etaxonomy.cdm.model.reference.Reference; |
29 | 25 |
import eu.etaxonomy.cdm.model.reference.ReferenceFactory; |
30 | 26 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
31 |
import eu.etaxonomy.cdm.model.term.DefaultTermInitializer;
|
|
27 |
import eu.etaxonomy.cdm.test.unit.EntityTestBase;
|
|
32 | 28 |
|
33 | 29 |
/** |
34 | 30 |
* @author a.babadshanjan |
35 | 31 |
* @since 02.02.2009 |
36 | 32 |
*/ |
37 |
public class IdentifiableEntityTest { |
|
33 |
public class IdentifiableEntityTest extends EntityTestBase {
|
|
38 | 34 |
|
39 | 35 |
private TaxonName abies; |
40 | 36 |
private TaxonName abiesMill; |
... | ... | |
53 | 49 |
private TaxonName abiesBalsamea; |
54 | 50 |
private Taxon abiesBalsameaTaxon; |
55 | 51 |
// private Taxon abiesAlbaxPinusBetaTaxon; |
56 |
/** |
|
57 |
* @throws java.lang.Exception |
|
58 |
*/ |
|
59 |
|
|
60 |
@BeforeClass |
|
61 |
public static void setUpBeforeClass() { |
|
62 |
DefaultTermInitializer vocabularyStore = new DefaultTermInitializer(); |
|
63 |
vocabularyStore.initialize(); |
|
64 |
|
|
65 |
} |
|
66 |
/** |
|
67 |
* @throws java.lang.Exception |
|
68 |
*/ |
|
69 |
@AfterClass |
|
70 |
public static void tearDownAfterClass() throws Exception { |
|
71 |
} |
|
72 | 52 |
|
73 |
/** |
|
74 |
* @throws java.lang.Exception |
|
75 |
*/ |
|
76 | 53 |
@Before |
77 | 54 |
public void setUp() throws Exception { |
78 | 55 |
|
... | ... | |
123 | 100 |
abiesAlbaxPinusBeta.setHybridFormula(true); |
124 | 101 |
abiesAlbaxPinusBeta.addHybridParent(abiesAlba, HybridRelationshipType.FIRST_PARENT(), null); |
125 | 102 |
abiesAlbaxPinusBeta.addHybridParent(pinusBeta, HybridRelationshipType.SECOND_PARENT(), null); |
126 |
|
|
127 |
} |
|
128 |
|
|
129 |
/** |
|
130 |
* @throws java.lang.Exception |
|
131 |
*/ |
|
132 |
@After |
|
133 |
public void tearDown() throws Exception { |
|
134 | 103 |
} |
135 | 104 |
|
136 |
|
|
137 |
/** |
|
138 |
* Test method for {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity#addCredit(eu.etaxonomy.cdm.model.common.IdentifiableEntity)}. |
|
139 |
*/ |
|
140 | 105 |
@Test |
141 | 106 |
public void testAddCredit() { |
142 | 107 |
assertNotNull("A list should always be returned",abies.getCredits()); |
... | ... | |
154 | 119 |
assertEquals("Credit0 should be last in list", text3, abies.getCredits(2).getText()); |
155 | 120 |
} |
156 | 121 |
|
157 |
/** |
|
158 |
* Test method for {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity#addCredit(eu.etaxonomy.cdm.model.common.IdentifiableEntity)}. |
|
159 |
*/ |
|
160 | 122 |
@Test |
161 | 123 |
public void testRemoveCredit() { |
162 | 124 |
assertNotNull("A list should always be returned",abies.getCredits()); |
... | ... | |
180 | 142 |
|
181 | 143 |
@Test |
182 | 144 |
public void testClone(){ |
183 |
IdentifiableEntity<?> clone = (IdentifiableEntity<?>)abies.clone();
|
|
145 |
IdentifiableEntity<?> clone = abies.clone(); |
|
184 | 146 |
assertNotNull(clone); |
185 | 147 |
assertEquals(clone.annotations, abies.annotations); |
186 | 148 |
assertEquals(clone.markers, abies.markers); |
187 | 149 |
assertFalse(clone.uuid.equals(abies.uuid)); |
188 | 150 |
} |
189 |
}
|
|
151 |
} |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/common/LanguageTest.java | ||
---|---|---|
1 | 1 |
/** |
2 |
* |
|
3 |
*/ |
|
2 |
* Copyright (C) 2009 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
4 | 9 |
package eu.etaxonomy.cdm.model.common; |
5 | 10 |
|
6 |
|
|
7 | 11 |
import org.apache.log4j.Logger; |
8 | 12 |
import org.junit.Assert; |
9 |
import org.junit.Before; |
|
10 |
import org.junit.BeforeClass; |
|
11 | 13 |
import org.junit.Test; |
12 | 14 |
|
13 | 15 |
import eu.etaxonomy.cdm.model.term.DefaultTermInitializer; |
14 |
|
|
16 |
import eu.etaxonomy.cdm.test.unit.EntityTestBase; |
|
15 | 17 |
|
16 | 18 |
/** |
17 | 19 |
* @author a.mueller |
18 |
* |
|
19 | 20 |
*/ |
20 |
public class LanguageTest { |
|
21 |
private static final Logger logger = Logger.getLogger(LanguageTest.class); |
|
22 |
|
|
23 |
/** |
|
24 |
* @throws java.lang.Exception |
|
25 |
*/ |
|
26 |
@BeforeClass |
|
27 |
public static void setUpBeforeClass() throws Exception { |
|
28 |
new DefaultTermInitializer().initialize(); |
|
29 |
} |
|
21 |
public class LanguageTest extends EntityTestBase { |
|
30 | 22 |
|
31 |
/** |
|
32 |
* @throws java.lang.Exception |
|
33 |
*/ |
|
34 |
@Before |
|
35 |
public void setUp() throws Exception { |
|
36 |
} |
|
23 |
@SuppressWarnings("unused") |
|
24 |
private static final Logger logger = Logger.getLogger(LanguageTest.class); |
|
25 |
|
|
26 |
// ************************** TESTS **********************************************/ |
|
37 | 27 |
|
38 |
// ************************** TESTS **********************************************/ |
|
39 |
|
|
40 |
/** |
|
41 |
* Test method for {@link eu.etaxonomy.cdm.model.common.Language#toString()}. |
|
42 |
*/ |
|
43 | 28 |
@Test |
44 | 29 |
public void testToString() { |
45 | 30 |
Language lang = Language.ENGLISH(); |
46 | 31 |
Assert.assertEquals("English should return 'English' by toString()", "English", lang.toString()); |
47 | 32 |
} |
48 | 33 |
|
49 |
/** |
|
50 |
* Test method for {@link eu.etaxonomy.cdm.model.common.Language#resetTerms()}. |
|
51 |
*/ |
|
52 | 34 |
@Test |
53 | 35 |
public void testResetTerms() { |
54 | 36 |
Language lang = Language.ENGLISH(); |
... | ... | |
61 | 43 |
new DefaultTermInitializer().initialize(); |
62 | 44 |
} |
63 | 45 |
|
64 |
|
|
65 |
/** |
|
66 |
* Test method for {@link eu.etaxonomy.cdm.model.common.Language#getTermByUuid(java.util.UUID)}. |
|
67 |
*/ |
|
68 | 46 |
@Test |
69 | 47 |
public void testGetTermByUuid() { |
70 | 48 |
Language lang = Language.getTermByUuid(Language.uuidZaza_Dimili_Dimli_Kirdki_Kirmanjki_Zazaki); |
... | ... | |
72 | 50 |
Assert.assertEquals("Uuid must be the equal", "e4bf2ec8-4c1a-4ece-9df1-4890a7f18457", lang.getUuid().toString()); |
73 | 51 |
} |
74 | 52 |
|
75 |
/** |
|
76 |
* Test method for {@link eu.etaxonomy.cdm.model.common.Language#ENGLISH()}. |
|
77 |
*/ |
|
78 | 53 |
@Test |
79 | 54 |
public void testENGLISH() { |
80 | 55 |
Language lang = Language.ENGLISH(); |
81 | 56 |
Assert.assertNotNull("'English' should exist", lang); |
82 | 57 |
} |
83 | 58 |
|
84 |
/** |
|
85 |
* Test method for {@link eu.etaxonomy.cdm.model.common.Language#UNKNOWN_LANGUAGE()}. |
|
86 |
*/ |
|
87 | 59 |
@Test |
88 | 60 |
public void testUNKNOWN_LANGUAGE() { |
89 | 61 |
Language unknown = Language.UNKNOWN_LANGUAGE(); |
90 | 62 |
Assert.assertNotNull("'Unknown Language' of undefinedLanguages vocabulary should exist", unknown); |
91 | 63 |
} |
92 | 64 |
|
93 |
/** |
|
94 |
* Test method for {@link eu.etaxonomy.cdm.model.common.Language#ORIGINAL_LANGUAGE()}. |
|
95 |
*/ |
|
96 | 65 |
@Test |
97 | 66 |
public void testORIGINAL_LANGUAGE() { |
98 | 67 |
Language original = Language.UNKNOWN_LANGUAGE(); |
99 | 68 |
Assert.assertNotNull("'Original Language' of undefinedLanguages vocabulary should exist", original); |
100 | 69 |
} |
101 | 70 |
|
102 |
/** |
|
103 |
* Test method for {@link eu.etaxonomy.cdm.model.common.Language#DEFAULT()}. |
|
104 |
*/ |
|
105 | 71 |
@Test |
106 | 72 |
public void testDEFAULT() { |
107 | 73 |
Language lang = Language.DEFAULT(); |
... | ... | |
109 | 75 |
Assert.assertEquals("Uuid of defautl language should be 'e9f8cdb7-6819-44e8-95d3-e2d0690c3523'(english)", Language.uuidEnglish, lang.getUuid()); |
110 | 76 |
} |
111 | 77 |
|
112 |
/** |
|
113 |
* Test method for {@link eu.etaxonomy.cdm.model.common.Language#CSV_LANGUAGE()}. |
|
114 |
*/ |
|
115 | 78 |
@Test |
116 | 79 |
public void testCSV_LANGUAGE() { |
117 | 80 |
Language lang = Language.CSV_LANGUAGE(); |
118 | 81 |
Assert.assertNotNull("The csv language must not be null", lang); |
119 | 82 |
Assert.assertEquals("Uuid of csv language should be 'e9f8cdb7-6819-44e8-95d3-e2d0690c3523'(english)", Language.uuidEnglish, lang.getUuid()); |
120 |
|
|
121 | 83 |
} |
122 | 84 |
|
123 |
/** |
|
124 |
* Test method for {@link eu.etaxonomy.cdm.model.common.Language#getLanguageByDescription(java.lang.String)}. |
|
125 |
*/ |
|
126 | 85 |
//once the descriptioin for languages are more explaining texts this test must be adapted |
127 | 86 |
@Test |
128 | 87 |
public void testGetLanguageByDescription() { |
129 |
Language lang = Language.getLanguageByDescription("English");
|
|
88 |
Language lang = Language.getLanguageByDescription("English"); |
|
130 | 89 |
Assert.assertNotNull("A language should be found for label 'English'", lang); |
131 | 90 |
Assert.assertEquals("Uuid of language 'English' should be 'e9f8cdb7-6819-44e8-95d3-e2d0690c3523'", Language.uuidEnglish, lang.getUuid()); |
132 | 91 |
} |
133 | 92 |
|
134 |
/** |
|
135 |
* Test method for {@link eu.etaxonomy.cdm.model.common.Language#getLanguageByLabel(java.lang.String)}. |
|
136 |
*/ |
|
137 | 93 |
@Test |
138 | 94 |
public void testGetLanguageByLabel() { |
139 |
Language lang = Language.getLanguageByLabel("English");
|
|
95 |
Language lang = Language.getLanguageByLabel("English"); |
|
140 | 96 |
Assert.assertNotNull("A language should be found for label 'English'", lang); |
141 | 97 |
Assert.assertEquals("Uuid of language 'English' should be 'e9f8cdb7-6819-44e8-95d3-e2d0690c3523'", Language.uuidEnglish, lang.getUuid()); |
142 | 98 |
} |
143 |
|
|
144 |
} |
|
99 |
} |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/common/MarkerTypeTest.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
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.model.common; |
11 | 10 |
|
12 | 11 |
import static org.junit.Assert.assertEquals; |
... | ... | |
15 | 14 |
import java.util.UUID; |
16 | 15 |
|
17 | 16 |
import org.apache.log4j.Logger; |
18 |
import org.junit.BeforeClass; |
|
19 | 17 |
import org.junit.Test; |
20 | 18 |
|
21 |
import eu.etaxonomy.cdm.model.term.DefaultTermInitializer; |
|
22 |
|
|
19 |
import eu.etaxonomy.cdm.test.unit.EntityTestBase; |
|
23 | 20 |
|
24 | 21 |
/** |
25 | 22 |
* @author a.mueller |
26 | 23 |
* @since 23.04.2008 |
27 |
* @version 1.0 |
|
28 | 24 |
*/ |
29 |
public class MarkerTypeTest { |
|
25 |
public class MarkerTypeTest extends EntityTestBase {
|
|
30 | 26 |
@SuppressWarnings("unused") |
31 | 27 |
private static Logger logger = Logger.getLogger(MarkerTypeTest.class); |
32 |
|
|
28 |
|
|
33 | 29 |
private static final UUID uuidImported = UUID.fromString("96878790-4ceb-42a2-9738-a2242079b679"); |
34 | 30 |
private static final UUID uuidToBeChecked = UUID.fromString("34204192-b41d-4857-a1d4-28992bef2a2a"); |
35 | 31 |
private static final UUID uuidIsDoubtful = UUID.fromString("b51325c8-05fe-421a-832b-d86fc249ef6e"); |
36 | 32 |
private static final UUID uuidComplete = UUID.fromString("b4b1b2ab-89a8-4ce6-8110-d60b8b1bc433"); |
37 | 33 |
|
38 |
@BeforeClass |
|
39 |
public static void setUp() { |
|
40 |
DefaultTermInitializer vocabularyStore = new DefaultTermInitializer(); |
|
41 |
vocabularyStore.initialize(); |
|
42 |
} |
|
43 |
|
|
44 | 34 |
/* ************ TESTS **********************************/ |
45 |
|
|
46 |
/** |
|
47 |
* Test method for {@link eu.etaxonomy.cdm.model.common.MarkerType#MarkerType(java.lang.String, java.lang.String)}. |
|
48 |
*/ |
|
35 |
|
|
49 | 36 |
@Test |
50 | 37 |
public void testNewInstanceStringString() { |
51 | 38 |
String term = "term"; |
... | ... | |
56 | 43 |
assertEquals(term, markerType.getRepresentation(Language.DEFAULT()).getText()); |
57 | 44 |
} |
58 | 45 |
|
59 |
/** |
|
60 |
* Test method for {@link eu.etaxonomy.cdm.model.common.MarkerType#IMPORTED()}. |
|
61 |
*/ |
|
62 | 46 |
@Test |
63 | 47 |
public void testIMPORTED() { |
64 | 48 |
assertNotNull(MarkerType.IMPORTED()); |
65 | 49 |
assertEquals(uuidImported, MarkerType.IMPORTED().getUuid()); |
66 | 50 |
} |
67 | 51 |
|
68 |
/** |
|
69 |
* Test method for {@link eu.etaxonomy.cdm.model.common.MarkerType#TO_BE_CHECKED()}. |
|
70 |
*/ |
|
71 | 52 |
@Test |
72 | 53 |
public void testTO_BE_CHECKED() { |
73 | 54 |
assertEquals(uuidToBeChecked, MarkerType.TO_BE_CHECKED().getUuid()); |
74 | 55 |
} |
75 | 56 |
|
76 |
/** |
|
77 |
* Test method for {@link eu.etaxonomy.cdm.model.common.MarkerType#IS_DOUBTFUL()}. |
|
78 |
*/ |
|
79 | 57 |
@Test |
80 | 58 |
public void testIS_DOUBTFUL() { |
81 | 59 |
assertEquals(uuidIsDoubtful, MarkerType.IS_DOUBTFUL().getUuid()); |
82 | 60 |
} |
83 | 61 |
|
84 |
/** |
|
85 |
* Test method for {@link eu.etaxonomy.cdm.model.common.MarkerType#COMPLETE()}. |
|
86 |
*/ |
|
87 | 62 |
@Test |
88 | 63 |
public void testCOMPLETE() { |
89 | 64 |
assertEquals(uuidComplete, MarkerType.COMPLETE().getUuid()); |
90 | 65 |
} |
91 |
}
|
|
66 |
} |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/description/DescriptionElementTest.java | ||
---|---|---|
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.model.description; |
11 | 10 |
|
12 | 11 |
import java.util.List; |
13 | 12 |
|
14 | 13 |
import org.apache.log4j.Logger; |
15 | 14 |
import org.junit.Assert; |
16 |
import org.junit.Before; |
|
17 |
import org.junit.BeforeClass; |
|
18 | 15 |
import org.junit.Test; |
19 | 16 |
|
20 |
import eu.etaxonomy.cdm.model.common.Language; |
|
21 |
import eu.etaxonomy.cdm.model.term.DefaultTermInitializer; |
|
22 | 17 |
import eu.etaxonomy.cdm.model.term.DefinedTerm; |
23 | 18 |
import eu.etaxonomy.cdm.model.term.TermType; |
24 | 19 |
import eu.etaxonomy.cdm.model.term.TermVocabulary; |
25 |
|
|
20 |
import eu.etaxonomy.cdm.test.unit.EntityTestBase; |
|
26 | 21 |
|
27 | 22 |
/** |
28 | 23 |
* @author k.luther |
29 | 24 |
* @since 11.04.2011 |
30 | 25 |
*/ |
31 |
public class DescriptionElementTest { |
|
32 |
@SuppressWarnings("unused") |
|
33 |
private static Logger logger = Logger.getLogger(DescriptionElementTest.class); |
|
26 |
public class DescriptionElementTest extends EntityTestBase { |
|
34 | 27 |
|
35 |
|
|
36 |
@BeforeClass |
|
37 |
public static void setUpBeforeClass() { |
|
38 |
if (Language.DEFAULT() == null){ |
|
39 |
DefaultTermInitializer vocabularyStore = new DefaultTermInitializer(); |
|
40 |
vocabularyStore.initialize(); |
|
41 |
} |
|
42 |
} |
|
43 |
|
|
44 |
/** |
|
45 |
* @throws java.lang.Exception |
|
46 |
*/ |
|
47 |
@Before |
|
48 |
public void setUp() throws Exception { |
|
49 |
|
|
50 |
} |
|
28 |
@SuppressWarnings("unused") |
|
29 |
private static Logger logger = Logger.getLogger(DescriptionElementTest.class); |
|
51 | 30 |
|
52 | 31 |
/* ************************** TESTS **********************************************************/ |
53 | 32 |
|
54 |
|
|
55 | 33 |
@Test |
56 | 34 |
public void testGetModifiersVocabulary(){ |
57 | 35 |
TaxonDescription desc = TaxonDescription.NewInstance(); |
... | ... | |
78 | 56 |
ethnicGroupVoc.addTerm(scots); |
79 | 57 |
data.addModifier(scots); |
80 | 58 |
|
81 |
|
|
82 | 59 |
List<DefinedTerm> modifiers = data.getModifiers(plantPartVoc); |
83 | 60 |
Assert.assertEquals("There should be 2 modifiers of type 'plant part'", 2, modifiers.size()); |
84 | 61 |
Assert.assertEquals("There should be 3 terms in the 'plant part' vocabulary", 3, plantPartVoc.size()); |
85 | 62 |
Assert.assertEquals("There should be 1 modifiers of type 'ethnic group'", 1, data.getModifiers(ethnicGroupVoc).size()); |
86 | 63 |
Assert.assertEquals("There should be 3 modifiers all together", 3, data.getModifiers().size()); |
87 |
|
|
88 | 64 |
} |
89 |
|
|
90 |
} |
|
91 |
|
|
92 |
|
|
65 |
} |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/description/IndividualsAssociationTest.java | ||
---|---|---|
12 | 12 |
import static org.junit.Assert.assertNotSame; |
13 | 13 |
|
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.model.common.Language; |
19 | 18 |
import eu.etaxonomy.cdm.model.common.LanguageString; |
20 | 19 |
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit; |
21 |
import eu.etaxonomy.cdm.model.term.DefaultTermInitializer;
|
|
20 |
import eu.etaxonomy.cdm.test.unit.EntityTestBase;
|
|
22 | 21 |
|
23 | 22 |
/** |
24 | 23 |
* @author a.mueller |
25 | 24 |
* @since 23.04.2018 |
26 | 25 |
*/ |
27 |
public class IndividualsAssociationTest { |
|
26 |
public class IndividualsAssociationTest extends EntityTestBase {
|
|
28 | 27 |
|
29 | 28 |
private IndividualsAssociation indAssociation; |
30 |
/** |
|
31 |
* @throws java.lang.Exception |
|
32 |
*/ |
|
29 |
|
|
33 | 30 |
@Before |
34 | 31 |
public void setUp() throws Exception { |
35 | 32 |
indAssociation = IndividualsAssociation.NewInstance(); |
... | ... | |
42 | 39 |
indAssociation.putDescription(langString); |
43 | 40 |
} |
44 | 41 |
|
45 |
@BeforeClass |
|
46 |
public static void setUpBeforeClass() { |
|
47 |
if (Language.DEFAULT() == null){ |
|
48 |
DefaultTermInitializer vocabularyStore = new DefaultTermInitializer(); |
|
49 |
vocabularyStore.initialize(); |
|
50 |
} |
|
51 |
} |
|
52 |
|
|
53 |
/** |
|
54 |
* Test method for {@link eu.etaxonomy.cdm.model.description.IndividualsAssociation#clone()}. |
|
55 |
*/ |
|
56 | 42 |
@Test |
57 | 43 |
public void testClone() { |
58 |
IndividualsAssociation clone = (IndividualsAssociation) indAssociation.clone();
|
|
44 |
IndividualsAssociation clone = indAssociation.clone(); |
|
59 | 45 |
assertEquals(clone.getFeature(), indAssociation.getFeature()); |
60 | 46 |
assertNotSame(clone.getDescription().get(Language.ENGLISH()), indAssociation.getDescription().get(Language.ENGLISH())); |
61 | 47 |
} |
62 |
|
|
63 |
} |
|
48 |
} |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/description/PolytomousKeyNodeTest.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2018 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
1 | 9 |
package eu.etaxonomy.cdm.model.description; |
2 | 10 |
|
3 | 11 |
import static org.junit.Assert.assertEquals; |
... | ... | |
7 | 15 |
import org.apache.log4j.Logger; |
8 | 16 |
import org.junit.Assert; |
9 | 17 |
import org.junit.Before; |
10 |
import org.junit.BeforeClass; |
|
11 | 18 |
import org.junit.Test; |
12 | 19 |
|
13 | 20 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
14 |
import eu.etaxonomy.cdm.model.term.DefaultTermInitializer; |
|
21 |
import eu.etaxonomy.cdm.test.unit.EntityTestBase; |
|
22 |
|
|
23 |
public class PolytomousKeyNodeTest extends EntityTestBase { |
|
15 | 24 |
|
16 |
public class PolytomousKeyNodeTest { |
|
17 | 25 |
@SuppressWarnings("unused") |
18 | 26 |
private static Logger logger = Logger.getLogger(PolytomousKeyNodeTest.class); |
19 | 27 |
|
20 | 28 |
private PolytomousKey key1; |
21 | 29 |
private Taxon taxon1; |
22 | 30 |
|
23 |
@BeforeClass |
|
24 |
public static void setUpBeforeClass() { |
|
25 |
DefaultTermInitializer vocabularyStore = new DefaultTermInitializer(); |
|
26 |
vocabularyStore.initialize(); |
|
27 |
} |
|
28 |
|
|
29 | 31 |
@Before |
30 | 32 |
public void setUp() throws Exception { |
31 | 33 |
key1 = PolytomousKey.NewInstance(); |
32 | 34 |
key1.setTitleCache("My Test Key", true); |
33 | 35 |
PolytomousKeyNode root = key1.getRoot(); |
34 | 36 |
root.setQuestion(KeyStatement.NewInstance("Is this Aus bus?")); |
35 |
|
|
37 |
|
|
36 | 38 |
// child1 |
37 | 39 |
taxon1 = Taxon.NewInstance(null, null); |
38 | 40 |
taxon1.setTitleCache("Aus bus L.", true); |
... | ... | |
47 | 49 |
PolytomousKeyNode child2 = PolytomousKeyNode.NewInstance("No"); |
48 | 50 |
child2.setTaxon(taxon2); |
49 | 51 |
root.addChild(child2); |
50 |
|
|
52 |
|
|
51 | 53 |
// child3 |
52 | 54 |
Taxon taxon3 = Taxon.NewInstance(null, null); |
53 | 55 |
taxon3.setTitleCache("Cus dus subs. rus L.", true); |
54 | 56 |
PolytomousKeyNode child3 = PolytomousKeyNode.NewInstance("Long and wide"); |
55 | 57 |
child3.setTaxon(taxon3); |
56 | 58 |
child1.addChild(child3); |
57 |
|
|
59 |
|
|
58 | 60 |
// child4 |
59 | 61 |
Taxon taxon4 = Taxon.NewInstance(null, null); |
60 | 62 |
taxon4.setTitleCache("Cus dus subs. zus L.", true); |
... | ... | |
66 | 68 |
child3.setSubkey(key2); |
67 | 69 |
|
68 | 70 |
child4.setOtherNode(key2.getRoot()); |
69 |
|
|
71 |
|
|
70 | 72 |
PolytomousKeyNode child5 = PolytomousKeyNode.NewInstance("Long and narrow"); |
71 | 73 |
child3.addChild(child5); |
72 | 74 |
|
73 | 75 |
} |
74 | 76 |
|
75 |
// ********************* Tests |
|
76 |
// *******************************************************/ |
|
77 |
// ********************* Tests ***************************************/ |
|
77 | 78 |
|
78 | 79 |
@Test |
79 | 80 |
public void testNodeNumber() { |
... | ... | |
86 | 87 |
PolytomousKeyNode child3 = child1.getChildAt(0); |
87 | 88 |
Assert.assertEquals("Child3 should have node number = 3", Integer.valueOf(3),child3.getNodeNumber()); |
88 | 89 |
PolytomousKeyNode child4 = child1.getChildAt(1); |
89 |
Assert.assertEquals("Child4 should have node number = null", null,child4.getNodeNumber()); |
|
90 |
|
|
90 |
Assert.assertEquals("Child4 should have node number = null", null,child4.getNodeNumber()); |
|
91 | 91 |
} |
92 |
|
|
92 |
|
|
93 | 93 |
@Test |
94 | 94 |
public void testClone(){ |
95 | 95 |
PolytomousKeyNode rootNode = key1.getRoot(); |
96 |
PolytomousKeyNode clone = (PolytomousKeyNode)rootNode.clone();
|
|
96 |
PolytomousKeyNode clone = rootNode.clone(); |
|
97 | 97 |
assertNotNull(clone); |
98 | 98 |
assertEquals(clone.getFeature(), rootNode.getFeature()); |
99 | 99 |
assertEquals(clone.getKey(), rootNode.getKey()); |
100 | 100 |
assertTrue(clone.getChildren().size() == 0); |
101 | 101 |
assertTrue(rootNode.getChildren().size()>0); |
102 |
|
|
103 | 102 |
} |
104 | 103 |
|
105 | 104 |
@Test |
... | ... | |
115 | 114 |
|
116 | 115 |
Assert.assertEquals("Parent node should have no children", 0, parent.getChildren().size()); |
117 | 116 |
} |
118 |
|
|
119 |
} |
|
117 |
} |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/description/PolytomousKeyTest.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2018 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
1 | 9 |
package eu.etaxonomy.cdm.model.description; |
2 | 10 |
|
3 | 11 |
import static org.junit.Assert.assertNotNull; |
... | ... | |
9 | 17 |
import org.apache.log4j.Logger; |
10 | 18 |
import org.junit.Assert; |
11 | 19 |
import org.junit.Before; |
12 |
import org.junit.BeforeClass; |
|
13 | 20 |
import org.junit.Test; |
14 | 21 |
|
15 | 22 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
16 |
import eu.etaxonomy.cdm.model.term.DefaultTermInitializer; |
|
23 |
import eu.etaxonomy.cdm.test.unit.EntityTestBase; |
|
24 |
|
|
25 |
public class PolytomousKeyTest extends EntityTestBase { |
|
17 | 26 |
|
18 |
public class PolytomousKeyTest { |
|
19 | 27 |
private static Logger logger = Logger.getLogger(PolytomousKeyTest.class); |
20 | 28 |
|
21 | 29 |
private PolytomousKey key1; |
22 | 30 |
private Taxon taxon1; |
23 | 31 |
|
24 |
@BeforeClass |
|
25 |
public static void setUpBeforeClass() { |
|
26 |
DefaultTermInitializer vocabularyStore = new DefaultTermInitializer(); |
|
27 |
vocabularyStore.initialize(); |
|
28 |
} |
|
29 |
|
|
30 | 32 |
@Before |
31 | 33 |
public void setUp() throws Exception { |
32 | 34 |
key1 = PolytomousKey.NewInstance(); |
... | ... | |
110 | 112 |
|
111 | 113 |
@Test |
112 | 114 |
public void testClone() { |
113 |
PolytomousKey clone = (PolytomousKey) key1.clone();
|
|
115 |
PolytomousKey clone = key1.clone(); |
|
114 | 116 |
assertNotNull(clone.getRoot()); |
115 | 117 |
assertNotSame(clone.getRoot(), key1.getRoot()); |
116 | 118 |
assertTrue(clone.getRoot().getChildren().size() == 0); |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/description/PresenceAbsenceTermTest.java | ||
---|---|---|
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.model.description; |
11 | 10 |
|
12 | 11 |
import java.util.ArrayList; |
... | ... | |
15 | 14 |
|
16 | 15 |
import org.apache.log4j.Logger; |
17 | 16 |
import org.junit.Assert; |
18 |
import org.junit.BeforeClass; |
|
19 | 17 |
import org.junit.Test; |
20 | 18 |
|
21 |
import eu.etaxonomy.cdm.model.term.DefaultTermInitializer; |
|
22 |
|
|
23 |
public class PresenceAbsenceTermTest { |
|
24 |
private static final Logger logger = Logger.getLogger(PresenceAbsenceTermTest.class); |
|
19 |
import eu.etaxonomy.cdm.test.unit.EntityTestBase; |
|
25 | 20 |
|
26 |
@BeforeClass |
|
27 |
public static void setUpBeforeClass() { |
|
28 |
DefaultTermInitializer vocabularyStore = new DefaultTermInitializer(); |
|
29 |
vocabularyStore.initialize(); |
|
30 |
} |
|
31 |
@Test |
|
32 |
public void testPresenceAbsenceTermBase() { |
|
33 |
logger.warn("Not yet implemented"); |
|
34 |
} |
|
21 |
public class PresenceAbsenceTermTest extends EntityTestBase { |
|
35 | 22 |
|
36 |
@Test |
|
37 |
public void testPresenceAbsenceTermBaseStringStringString() { |
|
38 |
logger.warn("Not yet implemented"); |
|
39 |
} |
|
23 |
private static final Logger logger = Logger.getLogger(PresenceAbsenceTermTest.class); |
|
40 | 24 |
|
41 | 25 |
@Test |
42 | 26 |
public void testReadCsvLineList() { |
... | ... | |
51 | 35 |
PresenceAbsenceTerm paTermNotExist = PresenceAbsenceTerm.getPresenceAbsenceTermByAbbreviation("slkjlsl�"); |
52 | 36 |
Assert.assertNull(paTermNotExist); |
53 | 37 |
} |
54 |
|
|
38 |
|
|
55 | 39 |
@Test |
56 | 40 |
public void testCompareTo(){ |
57 | 41 |
PresenceAbsenceTerm term1 = PresenceAbsenceTerm.CULTIVATED(); |
... | ... | |
59 | 43 |
PresenceAbsenceTerm term3 = PresenceAbsenceTerm.ABSENT(); |
60 | 44 |
PresenceAbsenceTerm term4 = PresenceAbsenceTerm.NATIVE_REPORTED_IN_ERROR(); |
61 | 45 |
|
62 |
List<PresenceAbsenceTerm> list = new ArrayList<PresenceAbsenceTerm>();
|
|
46 |
List<PresenceAbsenceTerm> list = new ArrayList<>(); |
|
63 | 47 |
list.add(term4); |
64 | 48 |
list.add(term2); |
65 | 49 |
list.add(term3); |
... | ... | |
69 | 53 |
for (PresenceAbsenceTerm t: list){ |
70 | 54 |
System.out.println(t.getTitleCache()); |
71 | 55 |
} |
72 |
|
|
73 |
|
|
74 |
|
|
75 | 56 |
} |
76 |
|
|
77 |
} |
|
57 |
} |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/description/QuantitativeDataTest.java | ||
---|---|---|
14 | 14 |
import java.math.BigDecimal; |
15 | 15 |
|
16 | 16 |
import org.junit.Before; |
17 |
import org.junit.BeforeClass; |
|
18 | 17 |
import org.junit.Test; |
19 | 18 |
|
20 |
import eu.etaxonomy.cdm.model.common.Language; |
|
21 |
import eu.etaxonomy.cdm.model.term.DefaultTermInitializer; |
Also available in: Unified diff
cleanup and use TermTestBase for model tests