Project

General

Profile

Revision c6423b90

IDc6423b9092c9fabb77598431378f6e9c5d080354
Parent 1b2e403a
Child 68ee041d

Added by Andreas Müller almost 6 years ago

test for Amplification labelCache

View differences:

.gitattributes
1163 1163
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/metadata/CdmMetaDataTest.java -text
1164 1164
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/metadata/CdmPreferenceTest.java -text
1165 1165
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/metadata/PreferenceSubjectTest.java -text
1166
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/molecular/AmplificationTest.java -text
1166 1167
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/molecular/MolecularTest.java -text
1167 1168
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/name/BacterialNameTest.java -text
1168 1169
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/name/BotanicalNameTest.java -text
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/molecular/Amplification.java
323 323
	}
324 324

  
325 325

  
326
	/**
327
	 * This method pushes the {@link Amplification#labelCache label cache} update.
328
	 * The cache is otherwise updated during persist in CacheStrategyUpdater. 
329
	 */
326 330
	public void updateCache(){
327 331
        //retrieve data
328 332
		 String institutionName = getInstitution() == null ? "" :getInstitution().getTitleCache();
......
330 334
         String dnaMarkerString = getDnaMarker() == null ? "" :getDnaMarker().getTitleCache();
331 335
         String dateString = getTimeperiod() == null ? "" :getTimeperiod().toString();
332 336

  
333

  
334 337
         //assemble string
335 338
         String designation = CdmUtils.concat("_", new String[]{institutionName, staffName, dnaMarkerString, dateString});
336
//         if( StringUtils.isNotBlank(institutionName)){
337
//             designation += institutionName;
338
//         }
339
//         if(!staffName.equals("")){
340
//             if(!designation.equals("")){
341
//                 designation += "_";
342
//             }
343
//             designation += staffName;
344
//         }
345
//         if(!dnaMarkerString.equals("")){
346
//             if(!designation.equals("")){
347
//                 designation += "_";
348
//             }
349
//             designation += dnaMarkerString;
350
//         }
351
//         if(!dateString.equals("")){
352
//             if(!designation.equals("")){
353
//                 designation += "_";
354
//             }
355
//             designation += dateString;
356
//         }
357 339
         
358
         this.labelCache = designation;
340
         this.labelCache = StringUtils.isBlank(designation) ? "<Amplification:" + getUuid() + ">" : designation ;
359 341
	}
360 342
	
361 343

  
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/molecular/AmplificationTest.java
1
// $Id$
2
/**
3
* Copyright (C) 2009 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.model.molecular;
11

  
12
import java.util.UUID;
13

  
14
import org.apache.log4j.Logger;
15
import org.junit.Assert;
16
import org.junit.Test;
17

  
18
import eu.etaxonomy.cdm.model.agent.Institution;
19
import eu.etaxonomy.cdm.model.agent.Person;
20
import eu.etaxonomy.cdm.model.common.DefinedTerm;
21
import eu.etaxonomy.cdm.strategy.parser.TimePeriodParser;
22

  
23
public class AmplificationTest {
24
	@SuppressWarnings("unused")
25
	private static Logger logger = Logger.getLogger(AmplificationTest.class);
26

  
27
	private UUID uuid = UUID.fromString("11e6b2d5-3eb5-4434-9c56-5bb4c1102147");
28
	
29
	@Test
30
	public void testUpdateCache() {
31
		Amplification amplification = Amplification.NewInstance();
32
		amplification.setUuid(uuid);
33
		
34
		amplification.updateCache();
35
		Assert.assertEquals("<Amplification:11e6b2d5-3eb5-4434-9c56-5bb4c1102147>", amplification.getLabelCache());
36
		
37
		Person author = Person.NewTitledInstance("Person");
38
		Institution institution = Institution.NewInstance();
39
		institution.setName("My institute");
40
		DefinedTerm marker = DefinedTerm.NewDnaMarkerInstance("marker", "marker", "dm");
41
		
42
		amplification.setActor(author);
43
		amplification.setTimeperiod(TimePeriodParser.parseString("2008"));
44
		amplification.setDnaMarker(marker);
45
		amplification.setInstitution(institution);
46
		
47
		amplification.updateCache();
48
		Assert.assertEquals("My institute_Person_marker_2008", amplification.getLabelCache());
49
	}
50

  
51
}
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/molecular/MolecularTest.java
1
// $Id$
2
/**
3
* Copyright (C) 2009 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
*/
1 10
package eu.etaxonomy.cdm.model.molecular;
2 11

  
3 12
import static org.junit.Assert.assertNotNull;

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)