Project

General

Profile

Revision f33a82a7

IDf33a82a7e547ddcd3b084d7a6c53b3920f6db5fc
Parent e6044ca7
Child 3c845507

Added by Andreas Kohlbecker almost 3 years ago

fix #7995 set and unset registrationDate when registration status changes

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/Registration.java
179 179
    public void setSpecificIdentifier(String specificIdentifier) {this.specificIdentifier = specificIdentifier;}
180 180

  
181 181
    public RegistrationStatus getStatus() {return status;}
182
    public void setStatus(RegistrationStatus status) {this.status = status;}
182
    public void setStatus(RegistrationStatus status) {
183
        if(status != this.status){
184
            if(status == RegistrationStatus.PUBLISHED){
185
                setRegistrationDate(DateTime.now());
186
            } else if(this.status == RegistrationStatus.PUBLISHED){
187
                setRegistrationDate(null);
188
            }
189
            this.status = status;
190
        }
191
    }
183 192

  
184 193
    public DateTime getRegistrationDate() {return registrationDate;}
185 194
    public void setRegistrationDate(DateTime registrationDate) {this.registrationDate = registrationDate;}
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/name/RegistrationTest.java
8 8
*/
9 9
package eu.etaxonomy.cdm.model.name;
10 10

  
11
import static org.junit.Assert.assertNotNull;
12
import static org.junit.Assert.assertNull;
13
import static org.junit.Assert.assertTrue;
14

  
15
import org.joda.time.DateTime;
11 16
import org.junit.Assert;
12 17
import org.junit.Before;
13 18
import org.junit.Test;
......
71 76

  
72 77
    }
73 78

  
79
    /**
80
     * see https://dev.e-taxonomy.eu/redmine/issues/7995
81
     */
82
    @Test
83
    public void testSetStatus() {
84
        Registration registration = Registration.NewInstance();
85

  
86
        registration.setStatus(RegistrationStatus.CURATION);
87
        assertNull(registration.getRegistrationDate());
88

  
89
        DateTime before = DateTime.now();
90
        registration.setStatus(RegistrationStatus.PUBLISHED);
91
        assertNotNull(registration.getRegistrationDate());
92
        assertTrue(registration.getRegistrationDate().isAfter(registration.getRegistrationDate()) || registration.getRegistrationDate().isEqual(before) );
93
        assertTrue(registration.getRegistrationDate().isBeforeNow() || registration.getRegistrationDate().isEqual(before));
94

  
95
        registration.setStatus(RegistrationStatus.CURATION);
96
        assertNull(registration.getRegistrationDate());
97
    }
98

  
74 99
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)