/** Tests a sync operation if no songs can be found. */
  @Test
  public void testProduceResultsNoSongs() {
    initMocks();
    List<SongEntity> songs = Collections.emptyList();
    List<Command> syncCmds = Collections.emptyList();
    controller.startSynchronization(0);
    Command endCmd = EasyMock.createMock(Command.class);
    queue.execute(endCmd);
    EasyMock.replay(endCmd, observer, controller, queue);
    SyncCommandTestImpl cmd =
        new SyncCommandTestImpl(init, observer, controller, queue, null) {
          @Override
          protected EntityManager getEntityManager() {
            return jpaHelper.getEM();
          }

          @Override
          OAuthTemplate createOAuthTemplate() {
            throw new UnsupportedOperationException("Unexpected method call!");
          }
        };
    cmd.installMockEndCommand(endCmd);
    cmd.installMockEntities(songs, syncCmds);
    cmd.produceResults(jpaHelper.getEM());
    EasyMock.verify(endCmd, observer, controller, queue);
  }
 /** Tests the execution of a sync command. */
 @Test
 public void testExecute() throws Exception {
   SyncCommandTestImpl cmd = createCommand(null);
   List<SongEntity> songs = new LinkedList<SongEntity>();
   List<Command> syncCmds = new LinkedList<Command>();
   Command endCmd = EasyMock.createMock(Command.class);
   for (int i = 1; i <= SONG_COUNT; i++) {
     SongEntity song = createTestSong(i);
     songs.add(song);
     Command sc = EasyMock.createMock(Command.class);
     EasyMock.replay(sc);
     queue.execute(sc);
     syncCmds.add(sc);
   }
   observer.commandCompletedBackground(songs);
   controller.startSynchronization(SONG_COUNT);
   queue.execute(endCmd);
   EasyMock.replay(endCmd, observer, controller, queue);
   cmd.installMockEndCommand(endCmd);
   cmd.installMockEntities(new ArrayList<SongEntity>(songs), syncCmds);
   cmd.execute();
   EasyMock.verify(endCmd, observer, controller, queue);
 }