Project

General

Profile

Download (1.45 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.logging.log4j.LogManager;import org.apache.logging.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
 * @since 30 Sep 2015
25
 */
26
public class NewEntityListenerTest
27
        implements NewEntityListener {
28

    
29
    private static Logger logger = LogManager.getLogger(NewEntityListenerTest.class);
30
    private Object lastPropValue;
31

    
32
    @Override
33
    public void onCreate(CdmBase cdmBase) {
34
        logger.info("New Entity " + cdmBase + " created");
35
        lastPropValue = cdmBase;
36
    }
37

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

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