Project

General

Profile

Revision 3359fa6d

ID3359fa6d40465e2bf81baa125ce1fdc2066d8918
Parent d221f578
Child 3a18055d

Added by Andreas Müller about 1 year ago

ref #7357 fix test for CategorialData.clone and move it from DescriptionElementTest to CategoricalDataTest

View differences:

cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/description/CategoricalDataTest.java
8 8
*/
9 9
package eu.etaxonomy.cdm.model.description;
10 10

  
11
import static org.junit.Assert.assertEquals;
12
import static org.junit.Assert.assertNotEquals;
13
import static org.junit.Assert.assertNotSame;
14
import static org.junit.Assert.assertSame;
15

  
11 16
import java.util.ArrayList;
12 17
import java.util.Arrays;
13 18
import java.util.List;
14 19

  
15 20
import org.junit.Assert;
16

  
17 21
import org.junit.Before;
18 22
import org.junit.Test;
19 23

  
20 24
import eu.etaxonomy.cdm.model.common.DefinedTerm;
25
import eu.etaxonomy.cdm.model.common.OriginalSourceType;
21 26
import eu.etaxonomy.cdm.model.common.TermType;
22 27
import eu.etaxonomy.cdm.model.common.TermVocabulary;
28
import eu.etaxonomy.cdm.model.media.Media;
29
import eu.etaxonomy.cdm.model.reference.Reference;
30
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
23 31

  
24 32
/**
25 33
 * @author a.mueller
......
28 36
 */
29 37
public class CategoricalDataTest {
30 38

  
39
    private CategoricalData categorialData;
40

  
31 41
    /**
32 42
     * @throws java.lang.Exception
33 43
     */
34 44
    @Before
35 45
    public void setUp() throws Exception {
46
        categorialData = CategoricalData.NewInstance();
47
        Media media = Media.NewInstance(null, 1000, "jpeg", null);
48
        categorialData.addMedia(media);
49

  
50
        DescriptionElementSource source = DescriptionElementSource.NewInstance(OriginalSourceType.Unknown);
51
        Reference citation = ReferenceFactory.newArticle();
52
        citation.setTitle("Test");
53
        source.setCitation(citation);
54
        categorialData.addSource(source );
55
        StateData state = StateData.NewInstance();
56
        categorialData.addStateData(state);
36 57
    }
37 58

  
38 59
//************************ TESTS ********************************************
......
92 113

  
93 114
    }
94 115

  
116
    @Test
117
    public void testCloneCategorialData(){
118
        CategoricalData clone = (CategoricalData)categorialData.clone();
119
        assertNotSame(clone, categorialData);
120
        assertEquals(1, clone.getStateData().size());
121
        assertEquals(clone.getStateData().size(), categorialData.getStateData().size() );
122
        StateData stateOrig = categorialData.getStateData().get(0);
123
        StateData stateClone = clone.getStateData().get(0);
124
        assertNotEquals(stateOrig, stateClone);
125
        assertSame(stateOrig.getState(), stateClone.getState());
126
        assertNotEquals(stateOrig.getCategoricalData(), stateClone.getCategoricalData());
127
    }
128

  
95 129
}
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/description/DescriptionElementTest.java
11 11

  
12 12
import static org.junit.Assert.assertEquals;
13 13
import static org.junit.Assert.assertNotSame;
14
import static org.junit.Assert.assertSame;
15 14
import static org.junit.Assert.assertTrue;
16 15

  
17 16
import java.util.List;
......
26 25
import eu.etaxonomy.cdm.model.common.DefinedTerm;
27 26
import eu.etaxonomy.cdm.model.common.Language;
28 27
import eu.etaxonomy.cdm.model.common.LanguageString;
29
import eu.etaxonomy.cdm.model.common.OriginalSourceType;
30 28
import eu.etaxonomy.cdm.model.common.TermType;
31 29
import eu.etaxonomy.cdm.model.common.TermVocabulary;
32
import eu.etaxonomy.cdm.model.media.Media;
33 30
import eu.etaxonomy.cdm.model.name.Rank;
34 31
import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
35 32
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
36
import eu.etaxonomy.cdm.model.reference.Reference;
37
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
38 33
import eu.etaxonomy.cdm.model.taxon.Taxon;
39 34

  
40 35

  
41 36
/**
42 37
 * @author k.luther
43
 * @created 11.04.2011
44
 * @version 1.0
38
 * @since 11.04.2011
45 39
 */
46 40
public class DescriptionElementTest {
47 41
@SuppressWarnings("unused")
48 42
private static Logger logger = Logger.getLogger(DescriptionElementTest.class);
49 43

  
50

  
51
	private CategoricalData categorialData;
52 44
	private IndividualsAssociation indAssociation;
53 45
	private QuantitativeData quantData;
54 46
	private Taxon taxon;
......
56 48

  
57 49
	@BeforeClass
58 50
	public static void setUpBeforeClass() {
59
		DefaultTermInitializer vocabularyStore = new DefaultTermInitializer();
60
		vocabularyStore.initialize();
51
		if (Language.DEFAULT() == null){
52
		    DefaultTermInitializer vocabularyStore = new DefaultTermInitializer();
53
		    vocabularyStore.initialize();
54
		}
61 55
	}
62 56

  
63 57
	/**
......
65 59
	 */
66 60
	@Before
67 61
	public void setUp() throws Exception {
68
		categorialData = CategoricalData.NewInstance();
69
		Media media = Media.NewInstance(null, 1000, "jpeg", null);
70
		categorialData.addMedia(media);
71

  
72
		DescriptionElementSource source = DescriptionElementSource.NewInstance(OriginalSourceType.Unknown);
73
		Reference citation = ReferenceFactory.newArticle();
74
		citation.setTitle("Test");
75
		source.setCitation(citation);
76
		categorialData.addSource(source );
77
		StateData state = StateData.NewInstance();
78
		categorialData.addStateData(state);
79 62

  
80 63
		indAssociation = IndividualsAssociation.NewInstance();
81 64

  
......
106 89
	}
107 90

  
108 91
/* ************************** TESTS **********************************************************/
109
	@Test
110
	public void testCloneCategorialData(){
111
		CategoricalData clone = (CategoricalData)categorialData.clone();
112
		assertEquals(clone.getStateData().size(),categorialData.getStateData().size() );
113
		assertSame(clone.getStateData().get(0), categorialData.getStateData().get(0));
114
		assertNotSame(clone, categorialData);
115

  
116
	}
117 92

  
118 93
	@Test
119 94
	public void testCloneIndividualAssociation(){

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)