Search in sources :

Example 1 with LoadOdtFromGoogle

use of org.jbehave.core.io.google.LoadOdtFromGoogle in project jbehave-core by jbehave.

the class GoogleSteps method givenGoogleFeed.

@Given("Google feed $uri")
public void givenGoogleFeed(String feedURI) {
    String username = System.getenv("GOOGLE_USER");
    String password = System.getenv("GOOGLE_PASSWORD");
    storyLoader = new LoadOdtFromGoogle(username, password, feedURI);
}
Also used : LoadOdtFromGoogle(org.jbehave.core.io.google.LoadOdtFromGoogle) Given(org.jbehave.core.annotations.Given)

Example 2 with LoadOdtFromGoogle

use of org.jbehave.core.io.google.LoadOdtFromGoogle in project jbehave-core by jbehave.

the class GoogleOdtLoaderBehaviour method shouldGetResourceFromDocsService.

@Test
public void shouldGetResourceFromDocsService() throws IOException, ServiceException {
    DocsService service = mock(DocsService.class);
    DocumentListFeed feed = mock(DocumentListFeed.class);
    DocumentListEntry entry = mock(DocumentListEntry.class);
    MediaSource mediaSource = mock(MediaSource.class);
    InputStream inputStream = mock(InputStream.class);
    final MediaContent content = mock(MediaContent.class);
    final DocumentQuery query = mock(DocumentQuery.class);
    when(service.getFeed(query, DocumentListFeed.class)).thenReturn(feed);
    when(service.getMedia(content)).thenReturn(mediaSource);
    when(feed.getEntries()).thenReturn(asList(entry));
    when(entry.getContent()).thenReturn(content);
    when(content.getUri()).thenReturn("http://docs.google.com");
    when(mediaSource.getInputStream()).thenReturn(inputStream);
    LoadOdtFromGoogle storyLoader = new LoadOdtFromGoogle("user", "password", "https://docs.google.com/feeds/default/private/full/", service) {

        @Override
        DocumentQuery documentQuery(String title) throws MalformedURLException {
            return query;
        }

        @Override
        protected MediaContent mediaContent(String url) {
            return content;
        }
    };
    InputStream resourceStream = storyLoader.resourceAsStream("a_story");
    MatcherAssert.assertThat(resourceStream, Matchers.equalTo(inputStream));
}
Also used : DocumentQuery(com.google.gdata.client.DocumentQuery) MediaSource(com.google.gdata.data.media.MediaSource) LoadOdtFromGoogle(org.jbehave.core.io.google.LoadOdtFromGoogle) DocumentListEntry(com.google.gdata.data.docs.DocumentListEntry) InputStream(java.io.InputStream) DocumentListFeed(com.google.gdata.data.docs.DocumentListFeed) MediaContent(com.google.gdata.data.MediaContent) DocsService(com.google.gdata.client.docs.DocsService) Test(org.junit.Test)

Aggregations

LoadOdtFromGoogle (org.jbehave.core.io.google.LoadOdtFromGoogle)2 DocumentQuery (com.google.gdata.client.DocumentQuery)1 DocsService (com.google.gdata.client.docs.DocsService)1 MediaContent (com.google.gdata.data.MediaContent)1 DocumentListEntry (com.google.gdata.data.docs.DocumentListEntry)1 DocumentListFeed (com.google.gdata.data.docs.DocumentListFeed)1 MediaSource (com.google.gdata.data.media.MediaSource)1 InputStream (java.io.InputStream)1 Given (org.jbehave.core.annotations.Given)1 Test (org.junit.Test)1