Project

General

Profile

Download (1.38 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2015 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.aspectj;
10

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

    
15
import eu.etaxonomy.cdm.model.NewEntityListener;
16
import eu.etaxonomy.cdm.model.common.Annotation;
17
import eu.etaxonomy.cdm.model.common.CdmBase;
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

    
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
    @Override
32
    public void onCreate(CdmBase cdmBase) {
33
        logger.info("New Entity " + cdmBase + " created");
34
        lastPropValue = cdmBase;
35
    }
36

    
37
    @Test
38
    public void testPropertyChange() {
39
        CdmBase.setNewEntityListener(this);
40

    
41
        INonViralName nvn = TaxonNameFactory.NewNonViralInstance(Rank.SPECIES());
42
        Annotation newAnnotation = Annotation.NewDefaultLanguageInstance("test");
43
        nvn.addAnnotation(newAnnotation);
44
        Assert.assertEquals(newAnnotation, lastPropValue);
45
    }
46

    
47
}
(1-1/2)