public class AlbumTest {
@Test
public void testCreateAlbum() throws JitcaException {
UserLibraryImpl libraryMock = EasyMock.createMock(UserLibraryImpl.class);
TrackFactory trackFactoryMock = EasyMock.createMock(TrackFactory.class);
TrackCollectionImpl trackCollectionMock = EasyMock.createMock(TrackCollectionImpl.class);
EasyMock.expect(libraryMock.isLazy()).andReturn(true).anyTimes();
EasyMock.expect(libraryMock.getTracksOfArtist("Nelly Furtado")).andReturn(trackCollectionMock);
EasyMock.expect(trackFactoryMock.getTracksOfArtist("Nelly Furtado")).andReturn(trackCollectionMock);
EasyMock.expect(libraryMock.getTracksOfComposer("Nelly Furtado")).andReturn(trackCollectionMock);
EasyMock.expect(trackFactoryMock.getTracksOfComposer("Nelly Furtado")).andReturn(trackCollectionMock);
EasyMock.expect(libraryMock.getTracksOfAlbum("Loose")).andReturn(trackCollectionMock).anyTimes();
EasyMock.expect(libraryMock.getTracksOfAlbum("Folklore")).andReturn(trackCollectionMock);
EasyMock.expect(libraryMock.getTrackFactory()).andReturn(trackFactoryMock).anyTimes();
EasyMock.expect(trackCollectionMock.iterator()).andReturn(new LinkedList<Track>().iterator()).anyTimes();
EasyMock.replay(libraryMock);
EasyMock.replay(trackCollectionMock);
EasyMock.replay(trackFactoryMock);
Artist albumArtist = ArtistImpl.create("Nelly Furtado", libraryMock);
Album loose = new AlbumImpl("Loose", albumArtist, libraryMock);
Album folklore = new AlbumImpl("Folklore", albumArtist, libraryMock);
EasyMock.reset(libraryMock);
EasyMock.expect(libraryMock.getAlbum("Loose", albumArtist)).andReturn(loose);
EasyMock.expect(libraryMock.getAlbum("Loose", albumArtist)).andReturn(loose);
EasyMock.expect(libraryMock.getAlbum("Folklore", albumArtist)).andReturn(folklore);
EasyMock.replay(libraryMock);
Album album1 = libraryMock.getAlbum("Loose", albumArtist);
assertTrue(album1.getName().equals("Loose"));
assertTrue(album1.getAlbumArtist().getName().equals("Nelly Furtado"));
Album album2 = libraryMock.getAlbum("Loose", albumArtist);
assertTrue(album1.equals(album2));
assertTrue(album1.equals(album1));
Album album3 = libraryMock.getAlbum("Folklore", albumArtist);
assertTrue(!album1.equals(album3));
}