Package com.commafeed.backend.opml

Source Code of com.commafeed.backend.opml.OPMLImporterTest

package com.commafeed.backend.opml;

import java.io.IOException;

import org.apache.commons.io.IOUtils;
import org.junit.Test;
import org.mockito.Mockito;

import com.commafeed.backend.cache.CacheService;
import com.commafeed.backend.dao.FeedCategoryDAO;
import com.commafeed.backend.model.FeedCategory;
import com.commafeed.backend.model.User;
import com.commafeed.backend.service.FeedSubscriptionService;

public class OPMLImporterTest {

  @Test
  public void testOpmlV10() throws IOException {
    testOpmlVersion("/opml/opml_v1.0.xml");
  }

  @Test
  public void testOpmlV11() throws IOException {
    testOpmlVersion("/opml/opml_v1.1.xml");
  }

  @Test
  public void testOpmlV20() throws IOException {
    testOpmlVersion("/opml/opml_v2.0.xml");
  }

  @Test
  public void testOpmlNoVersion() throws IOException {
    testOpmlVersion("/opml/opml_noversion.xml");
  }

  private void testOpmlVersion(String fileName) throws IOException {
    FeedCategoryDAO feedCategoryDAO = Mockito.mock(FeedCategoryDAO.class);
    FeedSubscriptionService feedSubscriptionService = Mockito.mock(FeedSubscriptionService.class);
    CacheService cacheService = Mockito.mock(CacheService.class);
    User user = Mockito.mock(User.class);

    String xml = IOUtils.toString(getClass().getResourceAsStream(fileName));

    OPMLImporter importer = new OPMLImporter(feedCategoryDAO, feedSubscriptionService, cacheService);
    importer.importOpml(user, xml);

    Mockito.verify(feedSubscriptionService).subscribe(Mockito.eq(user), Mockito.anyString(), Mockito.anyString(),
        Mockito.any(FeedCategory.class));
  }

}
TOP

Related Classes of com.commafeed.backend.opml.OPMLImporterTest

TOP
Copyright © 2018 www.massapi.com. 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.