Project

General

Profile

Download (1.45 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2015 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.cdm.aspectj;
11

    
12
import org.apache.log4j.Logger;
13
import org.junit.Assert;
14
import org.junit.Test;
15

    
16
import eu.etaxonomy.cdm.model.NewEntityListener;
17
import eu.etaxonomy.cdm.model.common.Annotation;
18
import eu.etaxonomy.cdm.model.common.CdmBase;
19
import eu.etaxonomy.cdm.model.name.NonViralName;
20
import eu.etaxonomy.cdm.model.name.Rank;
21

    
22
/**
23
 * @author cmathew
24
 * @date 30 Sep 2015
25
 *
26
 */
27
public class NewEntityListenerTest implements NewEntityListener {
28
    static Logger logger = Logger.getLogger(NewEntityListenerTest.class);
29
    private Object lastPropValue;
30

    
31
    /* (non-Javadoc)
32
     * @see eu.etaxonomy.cdm.model.NewEntityListener#onCreate(eu.etaxonomy.cdm.model.common.CdmBase)
33
     */
34
    @Override
35
    public void onCreate(CdmBase cdmBase) {
36
        logger.warn("New Entity " + cdmBase + " created");
37
        lastPropValue = cdmBase;
38
    }
39

    
40
    @Test
41
    public void testPropertyChange() {
42
        NonViralName.setNewEntityListener(this);
43
        NonViralName b = NonViralName.NewInstance(Rank.SPECIES());
44
        Annotation newAnnotation = Annotation.NewDefaultLanguageInstance("test");
45
        b.addAnnotation(newAnnotation);
46
        Assert.assertEquals(newAnnotation, lastPropValue);
47
    }
48

    
49
}
(1-1/2)