Projects >> atom-hopper >>0288e1abce0e7c51046007f7bd9061a3013056c5

Chunk
Conflicting content
package org.atomhopper.postgres.adapter;

<<<<<<< HEAD
=======
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

import static junit.framework.Assert.assertEquals;

>>>>>>> 9481a240e64537c01add3315de44131f27731661
import org.apache.abdera.Abdera;
import org.atomhopper.adapter.request.adapter.GetEntryRequest;
import org.atomhopper.adapter.request.adapter.GetFeedRequest;
Solution content
package org.atomhopper.postgres.adapter;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

import static junit.framework.Assert.assertEquals;

import org.apache.abdera.Abdera;
import org.atomhopper.adapter.request.adapter.GetEntryRequest;
import org.atomhopper.adapter.request.adapter.GetFeedRequest;
File
PostgresFeedSourceTest.java
Developer's decision
Version 2
Kind of conflict
Import
Chunk
Conflicting content
import org.atomhopper.postgres.model.PersistedEntry;
import org.atomhopper.postgres.query.EntryRowMapper;
import org.junit.Before;
<<<<<<< HEAD
import org.junit.Rule;
=======
import org.junit.Ignore;
>>>>>>> 9481a240e64537c01add3315de44131f27731661
import org.junit.Test;
import org.junit.experimental.runners.Enclosed;
import org.junit.rules.ExpectedException;
Solution content
import org.atomhopper.postgres.model.PersistedEntry;
import org.atomhopper.postgres.query.EntryRowMapper;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.runners.Enclosed;
File
PostgresFeedSourceTest.java
Developer's decision
Version 2
Kind of conflict
Import
Chunk
Conflicting content
@RunWith(Enclosed.class)
public class PostgresFeedSourceTest {

<<<<<<< HEAD
    private PostgresFeedSource postgresFeedSource;
    private JdbcTemplate jdbcTemplate;
    private GetFeedRequest getFeedRequest;
    private GetEntryRequest getEntryRequest;
    private PersistedEntry persistedEntry;
    private Abdera abdera;
    private final String MARKER_ID = UUID.randomUUID().toString();
    private final String ENTRY_BODY = "";
    private final String FEED_NAME = "namespace/feed";
    private final String COLLECTION_NAME = "namespace.feed";

    @Rule
    public ExpectedException exception = ExpectedException.none();


    @Before
    public void setUp() throws Exception {
        persistedEntry = new PersistedEntry();
        persistedEntry.setFeed(FEED_NAME);
        persistedEntry.setEntryId(MARKER_ID);
        persistedEntry.setEntryBody(ENTRY_BODY);

        // Mocks
        abdera = mock(Abdera.class);
        getFeedRequest = mock(GetFeedRequest.class);
        getEntryRequest = mock(GetEntryRequest.class);
        jdbcTemplate = mock(JdbcTemplate.class);

        postgresFeedSource = new PostgresFeedSource();
        postgresFeedSource.setJdbcTemplate(jdbcTemplate);

        // Mock GetEntryRequest
        when(getEntryRequest.getFeedName()).thenReturn(FEED_NAME);
        when(getEntryRequest.getEntryId()).thenReturn(MARKER_ID);

        //Mock GetFeedRequest
        when(getFeedRequest.getFeedName()).thenReturn(FEED_NAME);
        when(getFeedRequest.getPageSize()).thenReturn("25");
        when(getFeedRequest.getAbdera()).thenReturn(abdera);
    }
=======
    public static class WhenSourcingFeeds {

        private PostgresFeedSource postgresFeedSource;
        private JdbcTemplate jdbcTemplate;
        private GetFeedRequest getFeedRequest;
        private GetEntryRequest getEntryRequest;
        private PersistedEntry persistedEntry;
        private List entryList;
        private Abdera abdera;
        private final String MARKER_ID = UUID.randomUUID().toString();
        private final String ENTRY_BODY = "";
        private final String FEED_NAME = "namespace/feed";
        private final String COLLECTION_NAME = "namespace.feed";
        private final String FORWARD = "forward";
        private final String BACKWARD = "backward";
        private final String SINGLE_CAT = "+Cat1";
        private final String MULTI_CAT = "+Cat1+Cat2";

        @Before
        public void setUp() throws Exception {
            persistedEntry = new PersistedEntry();
            persistedEntry.setFeed(FEED_NAME);
            persistedEntry.setEntryId(MARKER_ID);
            persistedEntry.setEntryBody(ENTRY_BODY);

            entryList = new ArrayList();
            entryList.add(persistedEntry);

            // Mocks
            abdera = mock(Abdera.class);
            getFeedRequest = mock(GetFeedRequest.class);
            getEntryRequest = mock(GetEntryRequest.class);
            jdbcTemplate = mock(JdbcTemplate.class);

            postgresFeedSource = new PostgresFeedSource();
            postgresFeedSource.setJdbcTemplate(jdbcTemplate);

            // Mock GetEntryRequest
            when(getEntryRequest.getFeedName()).thenReturn(FEED_NAME);
            when(getEntryRequest.getEntryId()).thenReturn(MARKER_ID);

            //Mock GetFeedRequest
            when(getFeedRequest.getFeedName()).thenReturn(FEED_NAME);
            when(getFeedRequest.getPageSize()).thenReturn("25");
            when(getFeedRequest.getAbdera()).thenReturn(abdera);
        }

        @Test
        public void shouldSetJdbcTemplate() throws Exception {
            PostgresFeedSource tempPostgresFeedSource = mock(PostgresFeedSource.class);
            tempPostgresFeedSource.setJdbcTemplate(jdbcTemplate);
            verify(tempPostgresFeedSource).setJdbcTemplate(jdbcTemplate);
        }

        @Test
        public void shouldNotGetFeedWithMarkerDirectionForward() throws Exception {
            when(getFeedRequest.getPageMarker()).thenReturn(MARKER_ID);
            when(getFeedRequest.getDirection()).thenReturn("FORWARD");
            assertEquals("Should get a 404 response", HttpStatus.NOT_FOUND,
                         postgresFeedSource.getFeed(getFeedRequest).getResponseStatus());
        }

        @Test
        public void shouldNotGetFeedWithMarkerDirectionBackward() throws Exception {
            when(getFeedRequest.getPageMarker()).thenReturn(MARKER_ID);
            when(getFeedRequest.getDirection()).thenReturn("BACKWARD");
            assertEquals("Should get a 404 response", HttpStatus.NOT_FOUND,
                         postgresFeedSource.getFeed(getFeedRequest).getResponseStatus());
        }

        @Test
        public void shouldGetFeedHead() throws Exception {
            Abdera localAbdera = new Abdera();
            when(jdbcTemplate.queryForObject(any(String.class),
                                             any(EntryRowMapper.class),
                                             any(String.class),
                                             any(String.class))).thenReturn(persistedEntry);
            when(getFeedRequest.getAbdera()).thenReturn(localAbdera);
            when(getEntryRequest.getAbdera()).thenReturn(localAbdera);
            when(jdbcTemplate.query(any(String.class), any(Object[].class), any(EntryRowMapper.class))).thenReturn(entryList);
            when(jdbcTemplate.queryForInt(any(String.class), any(Object[].class))).thenReturn(1);
            assertEquals("Should get a 200 response", HttpStatus.OK,
                         postgresFeedSource.getFeed(getFeedRequest).getResponseStatus());
        }

        @Test
        public void shouldGetFeedHeadWithCategory() throws Exception {
            Abdera localAbdera = new Abdera();
            when(getFeedRequest.getSearchQuery()).thenReturn(SINGLE_CAT);
            when(jdbcTemplate.queryForObject(any(String.class),
                                             any(EntryRowMapper.class),
                                             any(String.class),
                                             any(String.class))).thenReturn(persistedEntry);
            when(getFeedRequest.getAbdera()).thenReturn(localAbdera);
            when(getEntryRequest.getAbdera()).thenReturn(localAbdera);
            when(jdbcTemplate.query(any(String.class), any(Object[].class), any(EntryRowMapper.class))).thenReturn(entryList);
            when(jdbcTemplate.queryForInt(any(String.class), any(Object[].class))).thenReturn(1);
            assertEquals("Should get a 200 response", HttpStatus.OK,
                         postgresFeedSource.getFeed(getFeedRequest).getResponseStatus());
        }

        @Test
        public void shouldGetFeedWithMarkerForward() throws Exception {
            when(getFeedRequest.getPageMarker()).thenReturn(MARKER_ID);
            when(getFeedRequest.getDirection()).thenReturn(FORWARD);
            Abdera localAbdera = new Abdera();
            when(jdbcTemplate.queryForObject(any(String.class),
                                             any(EntryRowMapper.class),
                                             any(String.class),
                                             any(String.class))).thenReturn(persistedEntry);
            when(getFeedRequest.getAbdera()).thenReturn(localAbdera);
            when(getEntryRequest.getAbdera()).thenReturn(localAbdera);
            when(jdbcTemplate.query(any(String.class), any(Object[].class), any(EntryRowMapper.class))).thenReturn(entryList);
            assertEquals("Should get a 200 response", HttpStatus.OK,
                         postgresFeedSource.getFeed(getFeedRequest).getResponseStatus());
        }

        @Test
        public void shouldGetFeedWithMarkerBackward() throws Exception {
            when(getFeedRequest.getPageMarker()).thenReturn(MARKER_ID);
            when(getFeedRequest.getDirection()).thenReturn(BACKWARD);
            Abdera localAbdera = new Abdera();
            when(jdbcTemplate.queryForObject(any(String.class),
                                             any(EntryRowMapper.class),
                                             any(String.class),
                                             any(String.class))).thenReturn(persistedEntry);
            when(getFeedRequest.getAbdera()).thenReturn(localAbdera);
            when(getEntryRequest.getAbdera()).thenReturn(localAbdera);
            when(jdbcTemplate.query(any(String.class), any(Object[].class), any(EntryRowMapper.class))).thenReturn(entryList);
            assertEquals("Should get a 200 response", HttpStatus.OK,
                         postgresFeedSource.getFeed(getFeedRequest).getResponseStatus());
        }

        @Test
        public void shouldGetFeedWithCategoryWithMarkerForward() throws Exception {
            when(getFeedRequest.getPageMarker()).thenReturn(MARKER_ID);
            when(getFeedRequest.getDirection()).thenReturn(FORWARD);
            when(getFeedRequest.getSearchQuery()).thenReturn(SINGLE_CAT);
            Abdera localAbdera = new Abdera();
            when(jdbcTemplate.queryForObject(any(String.class),
                                             any(EntryRowMapper.class),
                                             any(String.class),
                                             any(String.class))).thenReturn(persistedEntry);
            when(getFeedRequest.getAbdera()).thenReturn(localAbdera);
            when(getEntryRequest.getAbdera()).thenReturn(localAbdera);
            when(jdbcTemplate.query(any(String.class), any(Object[].class), any(EntryRowMapper.class))).thenReturn(entryList);
            assertEquals("Should get a 200 response", HttpStatus.OK,
                         postgresFeedSource.getFeed(getFeedRequest).getResponseStatus());
        }

        @Test
        public void shouldGetFeedWithCategoryWithMarkerBackward() throws Exception {
            when(getFeedRequest.getPageMarker()).thenReturn(MARKER_ID);
            when(getFeedRequest.getDirection()).thenReturn(BACKWARD);
            when(getFeedRequest.getSearchQuery()).thenReturn(SINGLE_CAT);
            Abdera localAbdera = new Abdera();
            when(jdbcTemplate.queryForObject(any(String.class),
                                             any(EntryRowMapper.class),
                                             any(String.class),
                                             any(String.class))).thenReturn(persistedEntry);
            when(getFeedRequest.getAbdera()).thenReturn(localAbdera);
            when(getEntryRequest.getAbdera()).thenReturn(localAbdera);
            when(jdbcTemplate.query(any(String.class), any(Object[].class), any(EntryRowMapper.class))).thenReturn(entryList);
            assertEquals("Should get a 200 response", HttpStatus.OK,
                         postgresFeedSource.getFeed(getFeedRequest).getResponseStatus());
        }

        @Test
        public void shouldGetFeedWithCategoriesWithMarkerForward() throws Exception {
            when(getFeedRequest.getPageMarker()).thenReturn(MARKER_ID);
            when(getFeedRequest.getDirection()).thenReturn(FORWARD);
            when(getFeedRequest.getSearchQuery()).thenReturn(MULTI_CAT);
            Abdera localAbdera = new Abdera();
            when(jdbcTemplate.queryForObject(any(String.class),
                                             any(EntryRowMapper.class),
                                             any(String.class),
                                             any(String.class))).thenReturn(persistedEntry);
            when(getFeedRequest.getAbdera()).thenReturn(localAbdera);
            when(getEntryRequest.getAbdera()).thenReturn(localAbdera);
            when(jdbcTemplate.query(any(String.class), any(Object[].class), any(EntryRowMapper.class))).thenReturn(entryList);
            assertEquals("Should get a 200 response", HttpStatus.OK,
                         postgresFeedSource.getFeed(getFeedRequest).getResponseStatus());
        }

        @Test
        public void shouldGetFeedWithCategoriesWithMarkerBackward() throws Exception {
            when(getFeedRequest.getPageMarker()).thenReturn(MARKER_ID);
            when(getFeedRequest.getDirection()).thenReturn(BACKWARD);
            when(getFeedRequest.getSearchQuery()).thenReturn(MULTI_CAT);
            Abdera localAbdera = new Abdera();
            when(jdbcTemplate.queryForObject(any(String.class),
                                             any(EntryRowMapper.class),
                                             any(String.class),
                                             any(String.class))).thenReturn(persistedEntry);
            when(getFeedRequest.getAbdera()).thenReturn(localAbdera);
            when(getEntryRequest.getAbdera()).thenReturn(localAbdera);
            when(jdbcTemplate.query(any(String.class), any(Object[].class), any(EntryRowMapper.class))).thenReturn(entryList);
            assertEquals("Should get a 200 response", HttpStatus.OK,
                         postgresFeedSource.getFeed(getFeedRequest).getResponseStatus());
        }

        @Test
        public void shouldReturnBadRequestWhenMarkerUsed() throws Exception {
            when(getFeedRequest.getPageMarker()).thenReturn(MARKER_ID);
            when(getFeedRequest.getDirection()).thenReturn("");
            assertEquals("Should return HTTP 400 (Bad Request)", HttpStatus.BAD_REQUEST,
                         postgresFeedSource.getFeed(getFeedRequest).getResponseStatus());
        }

        @Test
        @Ignore
        public void shouldReturnBadRequest() throws Exception {
            assertEquals("Should return HTTP 400 (Bad Request)", HttpStatus.BAD_REQUEST,
                         postgresFeedSource.getFeed(getFeedRequest).getResponseStatus());

        }

        @Test(expected = UnsupportedOperationException.class)
        public void shouldGetFeedInformation() throws Exception {
            postgresFeedSource.getFeedInformation();
        }

        @Test(expected = UnsupportedOperationException.class)
        public void shouldSetParameters() throws Exception {
            Map map = new HashMap();
            map.put("test1", "test2");
            postgresFeedSource.setParameters(map);
        }

        @Test
        public void shouldNotGetEntry() throws Exception {
            when(jdbcTemplate.queryForObject(any(String.class), any(Class.class),
                                             any(String.class), any(String.class))).thenReturn(null);
            assertEquals("Should get a 404 response", HttpStatus.NOT_FOUND,
                         postgresFeedSource.getEntry(getEntryRequest).getResponseStatus());

        }

        @Test
        public void shouldGetEntry() throws Exception {
            Abdera localAbdera = new Abdera();
            when(jdbcTemplate.queryForObject(any(String.class),
                                             any(EntryRowMapper.class),
                                             any(String.class),
                                             any(String.class))).thenReturn(persistedEntry);
            when(getEntryRequest.getAbdera()).thenReturn(localAbdera);
            assertEquals("Should get a 200 response", HttpStatus.OK,
                         postgresFeedSource.getEntry(getEntryRequest).getResponseStatus());
>>>>>>> 9481a240e64537c01add3315de44131f27731661

        }
    }
Solution content
        @Test
        }
    }
@RunWith(Enclosed.class)
public class PostgresFeedSourceTest {

    public static class WhenSourcingFeeds {

        private PostgresFeedSource postgresFeedSource;
        private JdbcTemplate jdbcTemplate;
        private GetFeedRequest getFeedRequest;
        private GetEntryRequest getEntryRequest;
        private PersistedEntry persistedEntry;
        private List entryList;
        private Abdera abdera;
        private final String MARKER_ID = UUID.randomUUID().toString();
        private final String ENTRY_BODY = "";
        private final String FEED_NAME = "namespace/feed";
        private final String COLLECTION_NAME = "namespace.feed";
        private final String FORWARD = "forward";
        private final String BACKWARD = "backward";
        private final String SINGLE_CAT = "+Cat1";
        private final String MULTI_CAT = "+Cat1+Cat2";

        @Before
        public void setUp() throws Exception {
            persistedEntry = new PersistedEntry();
            persistedEntry.setFeed(FEED_NAME);
            persistedEntry.setEntryId(MARKER_ID);
            persistedEntry.setEntryBody(ENTRY_BODY);

            entryList = new ArrayList();
            entryList.add(persistedEntry);

            // Mocks
            abdera = mock(Abdera.class);
            getFeedRequest = mock(GetFeedRequest.class);
            getEntryRequest = mock(GetEntryRequest.class);
            jdbcTemplate = mock(JdbcTemplate.class);

            postgresFeedSource = new PostgresFeedSource();
            postgresFeedSource.setJdbcTemplate(jdbcTemplate);

            // Mock GetEntryRequest
            when(getEntryRequest.getFeedName()).thenReturn(FEED_NAME);
            when(getEntryRequest.getEntryId()).thenReturn(MARKER_ID);

            //Mock GetFeedRequest
            when(getFeedRequest.getFeedName()).thenReturn(FEED_NAME);
            when(getFeedRequest.getPageSize()).thenReturn("25");
            when(getFeedRequest.getAbdera()).thenReturn(abdera);
        }

        @Test
        public void shouldSetJdbcTemplate() throws Exception {
            PostgresFeedSource tempPostgresFeedSource = mock(PostgresFeedSource.class);
            tempPostgresFeedSource.setJdbcTemplate(jdbcTemplate);
            verify(tempPostgresFeedSource).setJdbcTemplate(jdbcTemplate);
        }

        @Test
        public void shouldNotGetFeedWithMarkerDirectionForward() throws Exception {
            when(getFeedRequest.getPageMarker()).thenReturn(MARKER_ID);
            when(getFeedRequest.getDirection()).thenReturn("FORWARD");
            assertEquals("Should get a 404 response", HttpStatus.NOT_FOUND,
        public void shouldGetFeedWithCategoryWithMarkerForward() throws Exception {
        }
        @Test
                         postgresFeedSource.getFeed(getFeedRequest).getResponseStatus());
        }

        @Test
        public void shouldNotGetFeedWithMarkerDirectionBackward() throws Exception {
            when(getFeedRequest.getPageMarker()).thenReturn(MARKER_ID);
            when(getFeedRequest.getDirection()).thenReturn("BACKWARD");
            assertEquals("Should get a 404 response", HttpStatus.NOT_FOUND,
                         postgresFeedSource.getFeed(getFeedRequest).getResponseStatus());
        }

        @Test
        public void shouldGetFeedHead() throws Exception {
            Abdera localAbdera = new Abdera();
            when(jdbcTemplate.queryForObject(any(String.class),
                                             any(EntryRowMapper.class),
                                             any(String.class),
                                             any(String.class))).thenReturn(persistedEntry);
            when(getFeedRequest.getAbdera()).thenReturn(localAbdera);
            when(getEntryRequest.getAbdera()).thenReturn(localAbdera);
            when(jdbcTemplate.query(any(String.class), any(Object[].class), any(EntryRowMapper.class))).thenReturn(entryList);
            when(jdbcTemplate.queryForInt(any(String.class), any(Object[].class))).thenReturn(1);
            assertEquals("Should get a 200 response", HttpStatus.OK,
                         postgresFeedSource.getFeed(getFeedRequest).getResponseStatus());
        }

        @Test
        public void shouldGetFeedHeadWithCategory() throws Exception {
            Abdera localAbdera = new Abdera();
            when(getFeedRequest.getSearchQuery()).thenReturn(SINGLE_CAT);
            when(jdbcTemplate.queryForObject(any(String.class),
                                             any(EntryRowMapper.class),
                                             any(String.class),

                                             any(String.class))).thenReturn(persistedEntry);
            when(getFeedRequest.getAbdera()).thenReturn(localAbdera);
            when(getEntryRequest.getAbdera()).thenReturn(localAbdera);
            when(jdbcTemplate.query(any(String.class), any(Object[].class), any(EntryRowMapper.class))).thenReturn(entryList);
            when(jdbcTemplate.queryForInt(any(String.class), any(Object[].class))).thenReturn(1);
            assertEquals("Should get a 200 response", HttpStatus.OK,
                         postgresFeedSource.getFeed(getFeedRequest).getResponseStatus());
        }

        @Test
        public void shouldGetFeedWithMarkerForward() throws Exception {
            when(getFeedRequest.getPageMarker()).thenReturn(MARKER_ID);
            when(getFeedRequest.getDirection()).thenReturn(FORWARD);
            Abdera localAbdera = new Abdera();
            when(jdbcTemplate.queryForObject(any(String.class),
                                             any(EntryRowMapper.class),
                                             any(String.class),
                                             any(String.class))).thenReturn(persistedEntry);
            when(getFeedRequest.getAbdera()).thenReturn(localAbdera);
            when(getEntryRequest.getAbdera()).thenReturn(localAbdera);
            when(jdbcTemplate.query(any(String.class), any(Object[].class), any(EntryRowMapper.class))).thenReturn(entryList);
            assertEquals("Should get a 200 response", HttpStatus.OK,
                         postgresFeedSource.getFeed(getFeedRequest).getResponseStatus());
        }

        @Test
        public void shouldGetFeedWithMarkerBackward() throws Exception {
            when(getFeedRequest.getPageMarker()).thenReturn(MARKER_ID);
            when(getFeedRequest.getDirection()).thenReturn(BACKWARD);
            Abdera localAbdera = new Abdera();
            when(jdbcTemplate.queryForObject(any(String.class),
                                             any(EntryRowMapper.class),
                                             any(String.class),
                                             any(String.class))).thenReturn(persistedEntry);
            when(getFeedRequest.getAbdera()).thenReturn(localAbdera);
            when(getEntryRequest.getAbdera()).thenReturn(localAbdera);
            when(jdbcTemplate.query(any(String.class), any(Object[].class), any(EntryRowMapper.class))).thenReturn(entryList);
            assertEquals("Should get a 200 response", HttpStatus.OK,
                         postgresFeedSource.getFeed(getFeedRequest).getResponseStatus());
        }

        @Test
        @Ignore
            when(getFeedRequest.getPageMarker()).thenReturn(MARKER_ID);
            when(getFeedRequest.getDirection()).thenReturn(FORWARD);
            when(getFeedRequest.getSearchQuery()).thenReturn(SINGLE_CAT);
            Abdera localAbdera = new Abdera();
            when(jdbcTemplate.queryForObject(any(String.class),
                                             any(EntryRowMapper.class),
                                             any(String.class),
                                             any(String.class))).thenReturn(persistedEntry);
            when(getFeedRequest.getAbdera()).thenReturn(localAbdera);
            when(getEntryRequest.getAbdera()).thenReturn(localAbdera);
            when(jdbcTemplate.query(any(String.class), any(Object[].class), any(EntryRowMapper.class))).thenReturn(entryList);
            assertEquals("Should get a 200 response", HttpStatus.OK,
                         postgresFeedSource.getFeed(getFeedRequest).getResponseStatus());
        }

        @Test
        public void shouldGetFeedWithCategoryWithMarkerBackward() throws Exception {
            when(getFeedRequest.getPageMarker()).thenReturn(MARKER_ID);
            when(getFeedRequest.getDirection()).thenReturn(BACKWARD);
            when(getFeedRequest.getSearchQuery()).thenReturn(SINGLE_CAT);
            Abdera localAbdera = new Abdera();
            when(jdbcTemplate.queryForObject(any(String.class),
                                             any(EntryRowMapper.class),
                                             any(String.class),
                                             any(String.class))).thenReturn(persistedEntry);
            when(getFeedRequest.getAbdera()).thenReturn(localAbdera);
            when(getEntryRequest.getAbdera()).thenReturn(localAbdera);
            when(jdbcTemplate.query(any(String.class), any(Object[].class), any(EntryRowMapper.class))).thenReturn(entryList);
            assertEquals("Should get a 200 response", HttpStatus.OK,
                         postgresFeedSource.getFeed(getFeedRequest).getResponseStatus());
        public void shouldGetFeedWithCategoriesWithMarkerForward() throws Exception {
            when(getFeedRequest.getPageMarker()).thenReturn(MARKER_ID);
            when(getFeedRequest.getDirection()).thenReturn(FORWARD);
            when(getFeedRequest.getSearchQuery()).thenReturn(MULTI_CAT);
            Abdera localAbdera = new Abdera();
            when(jdbcTemplate.queryForObject(any(String.class),
                                             any(EntryRowMapper.class),
                                             any(String.class),
                                             any(String.class))).thenReturn(persistedEntry);
            when(getFeedRequest.getAbdera()).thenReturn(localAbdera);
            when(getEntryRequest.getAbdera()).thenReturn(localAbdera);
            when(jdbcTemplate.query(any(String.class), any(Object[].class), any(EntryRowMapper.class))).thenReturn(entryList);
            assertEquals("Should get a 200 response", HttpStatus.OK,
                         postgresFeedSource.getFeed(getFeedRequest).getResponseStatus());
        }

        @Test
        public void shouldGetFeedWithCategoriesWithMarkerBackward() throws Exception {
            when(getFeedRequest.getPageMarker()).thenReturn(MARKER_ID);
            when(getFeedRequest.getDirection()).thenReturn(BACKWARD);
            when(getFeedRequest.getSearchQuery()).thenReturn(MULTI_CAT);
            Abdera localAbdera = new Abdera();
            when(jdbcTemplate.queryForObject(any(String.class),
                                             any(EntryRowMapper.class),
                                             any(String.class),
                                             any(String.class))).thenReturn(persistedEntry);
            when(getFeedRequest.getAbdera()).thenReturn(localAbdera);
            when(getEntryRequest.getAbdera()).thenReturn(localAbdera);
            when(jdbcTemplate.query(any(String.class), any(Object[].class), any(EntryRowMapper.class))).thenReturn(entryList);
            assertEquals("Should get a 200 response", HttpStatus.OK,
                         postgresFeedSource.getFeed(getFeedRequest).getResponseStatus());
        }

        @Test
        public void shouldReturnBadRequestWhenMarkerUsed() throws Exception {
            when(getFeedRequest.getPageMarker()).thenReturn(MARKER_ID);
            when(getFeedRequest.getDirection()).thenReturn("");
            assertEquals("Should return HTTP 400 (Bad Request)", HttpStatus.BAD_REQUEST,
                         postgresFeedSource.getFeed(getFeedRequest).getResponseStatus());
        }

        public void shouldReturnBadRequest() throws Exception {
            assertEquals("Should return HTTP 400 (Bad Request)", HttpStatus.BAD_REQUEST,
                         postgresFeedSource.getFeed(getFeedRequest).getResponseStatus());

        }

        @Test(expected = UnsupportedOperationException.class)
        public void shouldGetFeedInformation() throws Exception {
            postgresFeedSource.getFeedInformation();
        }

        @Test(expected = UnsupportedOperationException.class)
        public void shouldSetParameters() throws Exception {
            Map map = new HashMap();
            map.put("test1", "test2");
            postgresFeedSource.setParameters(map);
        }

        @Test
        public void shouldNotGetEntry() throws Exception {
            when(jdbcTemplate.queryForObject(any(String.class), any(Class.class),
                                             any(String.class), any(String.class))).thenReturn(null);
            assertEquals("Should get a 404 response", HttpStatus.NOT_FOUND,
                         postgresFeedSource.getEntry(getEntryRequest).getResponseStatus());

        }

        @Test
        public void shouldGetEntry() throws Exception {
            Abdera localAbdera = new Abdera();
            when(jdbcTemplate.queryForObject(any(String.class),
                                             any(EntryRowMapper.class),
                                             any(String.class),
                                             any(String.class))).thenReturn(persistedEntry);
            when(getEntryRequest.getAbdera()).thenReturn(localAbdera);
            assertEquals("Should get a 200 response", HttpStatus.OK,
                         postgresFeedSource.getEntry(getEntryRequest).getResponseStatus());
File
PostgresFeedSourceTest.java
Developer's decision
Version 2
Kind of conflict
Annotation
Attribute
Class signature
Method declaration
Method invocation
Method signature
Variable