Project

General

Profile

Download (1.33 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
    @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
        NonViralName<?> b = NonViralName.NewInstance(Rank.SPECIES());
42
        Annotation newAnnotation = Annotation.NewDefaultLanguageInstance("test");
43
        b.addAnnotation(newAnnotation);
44
        Assert.assertEquals(newAnnotation, lastPropValue);
45
    }
46

    
47
}
(1-1/2)