Package com.jitcaforwin.extended.impl.collections

Examples of com.jitcaforwin.extended.impl.collections.GenreCollectionImpl


*
*/
public final class PlaylistUtilities {

  public static GenreCollection getAllGenres(Playlist playlist) {
    GenreCollection genres = new GenreCollectionImpl();

    for (Track track : playlist.getTracks()) {
      if (!genres.contains(track.getGenre())) {
        genres.add(track.getGenre());
      }
    }
    return genres;
  }
View Full Code Here


    }
    return genres;
  }
 
  public static GenreCollection getId3Genres(Playlist playlist){
    GenreCollection genres = new GenreCollectionImpl();

    for (Track track : playlist.getTracks()) {
      if (track.getGenre().isId3TagGenre() && !genres.contains(track.getGenre())) {
        genres.add(track.getGenre());
      }
    }
    return genres;
  }
View Full Code Here

    }
    return genres;
  }

  public static GenreCollection getNonId3Genres(Playlist playlist) {
    GenreCollection genres = new GenreCollectionImpl();

    for (Track track : playlist.getTracks()) {
      if (!track.getGenre().isId3TagGenre() && !genres.contains(track.getGenre())) {
        genres.add(track.getGenre());
      }
    }
    return genres;
  }
View Full Code Here

    }
    return genres;
  }
 
  public static GenreCollection getNonId3BasicGenres(Playlist playlist){
    GenreCollection genres = new GenreCollectionImpl();

    for (Track track : playlist.getTracks()) {
      if (!track.getGenre().isBasicId3TagGenre() && !genres.contains(track.getGenre())) {
        genres.add(track.getGenre());
      }
    }
    return genres;
  }
View Full Code Here

    return this.getPlaylist().getTracks().analyzeTrackInfo();
  }

  @Override
  public GenreCollection getAllGenres() {
    GenreCollection genres = new GenreCollectionImpl();
   
    for(Track track : this.getPlaylist().getTracks()){
      if (!genres.contains(track.getGenre())){
        genres.add(track.getGenre());
      }
    }
   
    return genres;
  }
View Full Code Here

public class GenreCollectionTest {

  @Test
  public void testLazy() {
    GenreCollection collection = new GenreCollectionImpl();
    assertTrue(collection.isLazy());
  }
View Full Code Here

    assertTrue(collection.isLazy());
  }

  @Test
  public void testAddRemoveSize() throws JCollectionException {
    GenreCollection collection = new GenreCollectionImpl();
    Genre genreMock1 = EasyMock.createMock(Genre.class);
    Genre genreMock2 = EasyMock.createMock(Genre.class);
    Genre genreMock3 = EasyMock.createMock(Genre.class);
       
    assertEquals(0, collection.size());

    collection.add(genreMock1);
    assertEquals(1, collection.size());
   
    collection.add(genreMock2);
    assertEquals(2, collection.size());
   
    collection.add(genreMock3);
    assertEquals(3, collection.size());

    collection.remove(genreMock2);
    assertEquals(2, collection.size());
   
    for(Genre genre : collection){
      assertTrue(genre.equals(genreMock1) || genre.equals(genreMock3));
    }
  }
View Full Code Here

    }
  }
 
  @Test
  public void testGet(){
    GenreCollection collection = new GenreCollectionImpl();
    Genre genreMock1 = EasyMock.createMock(Genre.class);
    Genre genreMock2 = EasyMock.createMock(Genre.class);
   
    EasyMock.expect(genreMock1.getName()).andReturn("Genre1").times(2, 3); // times is 2 or 3, because we do not know the sorting inside the Set
    EasyMock.expect(genreMock1.getId()).andReturn(1).times(2, 3);
    EasyMock.expect(genreMock2.getName()).andReturn("Genre2").times(2, 3);
    EasyMock.expect(genreMock2.getId()).andReturn(2).times(2, 3);
   
    EasyMock.replay(genreMock1, genreMock2);
   
    collection.add(genreMock1);
    collection.add(genreMock2);
   
    assertEquals(genreMock1, collection.get("Genre1"));
    assertEquals(genreMock1, collection.get(1));
    assertEquals(genreMock2, collection.get("Genre2"));
    assertEquals(genreMock2, collection.get(2));
    assertEquals(null, collection.get("Unkown Genre"));
    assertEquals(null, collection.get(3));
   
    EasyMock.verify(genreMock1, genreMock2);
   
  }
View Full Code Here

   
  }

  @Test(expected=JCollectionException.class)
  public void testRemove() throws JCollectionException{
    GenreCollection collection = new GenreCollectionImpl();
    Genre genreMock = EasyMock.createMock(Genre.class);
   
    collection.remove(genreMock);
  }
View Full Code Here

TOP

Related Classes of com.jitcaforwin.extended.impl.collections.GenreCollectionImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.