Project

General

Profile

« Previous | Next » 

Revision c4c9bb2c

Added by Markus Döring almost 17 years ago

View differences:

.gitattributes
260 260
musiclib-hibernatetest/src/main/resources/log4j.properties -text
261 261
musiclib-hibernatetest/src/main/resources/sessionfactory.xml -text
262 262
musiclib-hibernatetest/src/site/site.xml -text
263
musiclib-hibernatetest/src/test/java/org/bgbm/persistence/dao/RecordDaoImplTest.java -text
263 264
musiclib-hibernatetest/target/mvn-eclipse-cache.properties -text
264 265
updateSite/.project -text
265 266
updateSite/features/eu.etaxonomy.cdmLibrary_0.2.5.jar -text
musiclib-hibernatetest/src/main/java/org/bgbm/model/Artist.java
19 19
	//private Set<Record> records = new HashSet();
20 20
	private Set<Person> musicians;
21 21

  
22
	public Artist(String title) {
23
		name=title;
24
	}
25

  
22 26
	public String getName() {
23 27
		return name;
24 28
	}
musiclib-hibernatetest/src/main/java/org/bgbm/model/MetaBase.java
13 13
import javax.persistence.Temporal;
14 14
import javax.persistence.TemporalType;
15 15

  
16
import org.apache.log4j.Logger;
17

  
16 18
@MappedSuperclass
17 19
//@Inheritance(strategy=InheritanceType.JOINED)
18 20
public abstract class MetaBase {
21
	static Logger logger = Logger.getLogger(MetaBase.class);
22

  
19 23
	private int id;
20 24
	private String uuid;
21 25
	private Calendar created;
musiclib-hibernatetest/src/main/java/org/bgbm/model/Record.java
22 22
	public List<Track> getTracks() {
23 23
		return tracks;
24 24
	}
25
	public void setTracks(List<Track> tracks) {
25
	protected void setTracks(List<Track> tracks) {
26 26
		this.tracks = tracks;
27 27
	}
28
	public void addTrack(String title, Artist artist, double d){
29
		Track track=new Track(title,artist,d);
30
		track.setRecord(this);
31
		this.tracks.add(track);
32
	}
28 33
	public String getTitle() {
29 34
		return title;
30 35
	}
musiclib-hibernatetest/src/main/java/org/bgbm/model/Track.java
10 10
public class Track extends MetaBase {
11 11
	static Logger logger = Logger.getLogger(Track.class);
12 12
	private String name;
13
	private float duration;
13
	private double duration;
14 14
	private Record record;
15 15
	private Artist artist;
16 16
	
17
	public Track(String title, Artist artist2, double duration) {
18
		this.name=title;
19
		this.artist=artist2;
20
		this.duration=duration;
21
	}
22
	
23
	
17 24
	public String getName() {
18 25
		return name;
19 26
	}
20 27
	public void setName(String name) {
21 28
		this.name = name;
22 29
	}
23
	public float getDuration() {
30
	public double getDuration() {
24 31
		return duration;
25 32
	}
26
	public void setDuration(float duration) {
33
	public void setDuration(double duration) {
27 34
		this.duration = duration;
28 35
	}
29 36
	@ManyToOne(cascade=CascadeType.PERSIST)
musiclib-hibernatetest/src/test/java/org/bgbm/persistence/dao/RecordDaoImplTest.java
1
package org.bgbm.persistence.dao;
2

  
3

  
4
import static org.junit.Assert.*;
5

  
6
import org.apache.log4j.Logger;
7
import org.bgbm.model.Artist;
8
import org.bgbm.model.Label;
9
import org.bgbm.model.Record;
10
import org.bgbm.model.Track;
11
import org.junit.Before;
12
import org.junit.Test;
13
import org.junit.runner.RunWith;
14
import org.springframework.beans.factory.annotation.Autowired;
15
import org.springframework.test.context.ContextConfiguration;
16
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
17
import org.springframework.test.context.transaction.TransactionConfiguration;
18
import org.springframework.transaction.annotation.Transactional;
19

  
20
import eu.etaxonomy.cdm.model.common.Enumeration;
21
import eu.etaxonomy.cdm.model.common.Keyword;
22
import eu.etaxonomy.cdm.persistence.dao.EnumerationDaoHibernateImplTest;
23

  
24

  
25
@RunWith(SpringJUnit4ClassRunner.class)
26
@ContextConfiguration(locations={"/applicationContext.xml"})
27
@TransactionConfiguration(defaultRollback=false)
28
@Transactional
29
public class RecordDaoImplTest {
30
	static Logger logger = Logger.getLogger(RecordDaoImplTest.class);
31
	
32
	@Autowired
33
	private RecordDaoImpl dao;
34
	private Record record;
35
	private Artist artist;
36
	
37
	@Before
38
	public void setUp() throws Exception {
39
		logger.debug(RecordDaoImplTest.class.getSimpleName() + " setup()");
40
		this.record = new Record();
41
		this.artist = new Artist("Sons of Austria");
42
		String [] songs = {"beat me","hello world","love you always","tear me apart","knock me down"};
43
		for (String s : songs){
44
			record.addTrack(s, artist, 1.56);			
45
		}
46
	}
47

  
48
	@Test
49
	public void testSave() {
50
		dao.save(this.record);
51
		this.record.addTrack("beat me (reprise)", artist, 3.34);
52
		dao.save(this.record);
53
	}
54

  
55
	@Test
56
	public void testFindById() {
57
		fail("Not yet implemented");
58
	}
59

  
60
}

Also available in: Unified diff