Projects >> atlas-persistence >>9b38d8630e309c57d9508d6f78375e6bae6e8e01

Chunk
Conflicting content
    }

    @Override
<<<<<<< HEAD
    public void itemChanged(Iterable items, ChangeType changeType) {
        if (changeType == ContentListener.ChangeType.BOOTSTRAP) {
            delegate.itemChanged(items, changeType);
        } else {
        	Iterables.addAll(itemQueue, items);
        }
=======
    public void itemChanged(Collection items, changeType changeType) {
//        if (changeType == ContentListener.changeType.BOOTSTRAP) {
//            delegate.itemChanged(items, changeType);
//        } else {
//            itemQueue.addAll(items);
//        }
>>>>>>> 5022c24c0eab9cff8659a9856f8c8ace7166d8a8
    }

    class BrandChangedJob implements Runnable {
Solution content
    }

    @Override
    public void itemChanged(Iterable items, ChangeType changeType) {
//        if (changeType == ContentListener.ChangeType.BOOTSTRAP) {
//            delegate.itemChanged(items, changeType);
//        } else {
//        	Iterables.addAll(itemQueue, items);
//        }
    }

    class BrandChangedJob implements Runnable {
File
QueueingContentListener.java
Developer's decision
Manual
Kind of conflict
Comment
If statement
Method signature
Chunk
Conflicting content
public interface RetrospectiveContentLister {

<<<<<<< HEAD
	Iterator listAllRoots();
=======
	List listItems(String fromId, int batchSize);
	
	List listPlaylists(String fromId, int batchSize);
>>>>>>> 5022c24c0eab9cff8659a9856f8c8ace7166d8a8
}
Solution content
public interface RetrospectiveContentLister {

	List listAllRoots(String fromId, int batchSize);

}
File
RetrospectiveContentLister.java
Developer's decision
Manual
Kind of conflict
Method interface
Chunk
Conflicting content
import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
<<<<<<< HEAD
import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
=======
>>>>>>> 5022c24c0eab9cff8659a9856f8c8ace7166d8a8

public class MongoDbBackedContentBootstrapper implements InitializingBean {
	
Solution content
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;

public class MongoDbBackedContentBootstrapper implements InitializingBean {
	
File
MongoDbBackedContentBootstrapper.java
Developer's decision
Version 2
Kind of conflict
Import
Chunk
Conflicting content
        if (log.isInfoEnabled()) {
            log.info("Bootstrapping top level content");
        }
<<<<<<< HEAD
        loadAllRoots();
    }

    public void loadAllRoots() {
    	load(contentStore.listAllRoots(), new Function, Void>() {

    		@Override
			@SuppressWarnings("unchecked")
			public Void apply(List batch) {
				contentListener.itemChanged(Iterables.filter(batch, Item.class), ContentListener.ChangeType.BOOTSTRAP);
				contentListener.brandChanged((Iterable>) Iterables.filter(batch, Container.class), ContentListener.ChangeType.BOOTSTRAP);
				return null;
			}
    	});
=======
        loadAllBrands();

//        if (log.isInfoEnabled()) {
//            log.info("Bootstrapping Items");
//        }
//        loadAllItems();
    }

    public void loadAllItems() {
        List items = ImmutableList.of();
        String fromId = null;
        do {
            items = contentStore.listItems(fromId, batchSize);
            load(items, new Function, Void>() {
                @Override
                public Void apply(List batch) {
                    contentListener.itemChanged(batch, ContentListener.changeType.BOOTSTRAP);
                    return null;
                }
            });
            Item lastItem = Iterables.getLast(items, null);
            fromId = lastItem != null ? lastItem.getCanonicalUri() : null;
        } while (! items.isEmpty() && items.size() >= batchSize);
>>>>>>> 5022c24c0eab9cff8659a9856f8c8ace7166d8a8
    }

	private  void load(Iterable contents, final Function, Void> handler) {
Solution content
        if (log.isInfoEnabled()) {
            log.info("Bootstrapping top level content");
        }
        loadAllBrands();
        loadAllItems();
    }

    public void loadAllItems() {
        loadAll(Item.class);
    }
File
MongoDbBackedContentBootstrapper.java
Developer's decision
Manual
Kind of conflict
Comment
Do statement
Method invocation
Method signature
Variable
Chunk
Conflicting content
	}

    public void loadAllBrands() {
<<<<<<< HEAD
    	load(Iterators.filter(contentStore.listAllRoots(), Brand.class), new Function, Void>() {
			@Override
			public Void apply(List batch) {
				contentListener.brandChanged(batch, ContentListener.ChangeType.BOOTSTRAP);
				return null;
			}
    	});
=======
        List playlists = ImmutableList.of();
        String fromId = null;
        do {
            playlists = contentStore.listPlaylists(fromId, batchSize);
            load(Iterables.filter(playlists, Brand.class), new Function, Void>() {
                @Override
                public Void apply(List batch) {
                    contentListener.brandChanged(batch, ContentListener.changeType.BOOTSTRAP);
                    return null;
                }
            });
            Playlist lastPlaylist = Iterables.getLast(playlists, null);
            fromId = lastPlaylist != null ? lastPlaylist.getCanonicalUri() : null;
        } while (! playlists.isEmpty() && playlists.size() >= batchSize);
>>>>>>> 5022c24c0eab9cff8659a9856f8c8ace7166d8a8
    }
    public void loadAllItems() {
    	load(Iterators.filter(contentStore.listAllRoots(), Item.class), new Function, Void>() {
Solution content
    public void loadAllBrands() {
    	loadAll(Container.class);
    }
File
MongoDbBackedContentBootstrapper.java
Developer's decision
Manual
Kind of conflict
Do statement
Method invocation
Variable
Chunk
Conflicting content
import com.google.common.collect.Sets;
import com.google.common.collect.ImmutableList.Builder;
import com.metabroadcast.common.persistence.mongo.DatabasedMongo;
<<<<<<< HEAD
=======
import com.metabroadcast.common.persistence.mongo.MongoConstants;
import com.metabroadcast.common.persistence.mongo.MongoQueryBuilder;
import com.metabroadcast.common.persistence.mongo.MongoSortBuilder;
import com.metabroadcast.common.persistence.mongo.MongoUpdateBuilder;
>>>>>>> 5022c24c0eab9cff8659a9856f8c8ace7166d8a8
import com.metabroadcast.common.query.Selection;
import com.metabroadcast.common.time.Clock;
import com.metabroadcast.common.time.DateTimeZones;
Solution content
import com.google.common.collect.Sets;
import com.metabroadcast.common.persistence.mongo.DatabasedMongo;
import com.metabroadcast.common.persistence.mongo.MongoConstants;
import com.metabroadcast.common.persistence.mongo.MongoQueryBuilder;
import com.metabroadcast.common.persistence.mongo.MongoSortBuilder;
import com.metabroadcast.common.query.Selection;
import com.metabroadcast.common.time.Clock;
import com.metabroadcast.common.time.DateTimeZones;
File
MongoDbBackedContentStore.java
Developer's decision
Combination
Kind of conflict
Import
Chunk
Conflicting content
		return ImmutableList.copyOf(extractCanonical(ImmutableSet.copyOf(uris), findByUriOrAlias(uris, true)));
    }

<<<<<<< HEAD
	@SuppressWarnings("unchecked")
	public List findContentByCanonicalUri(final Iterable uris) {
		return (List) ImmutableList.copyOf(extractCanonical(ImmutableSet.copyOf(uris), findByUriOrAlias(uris, false)));
	}
	
	private static Identified extactItemIfInternalUrl(Identified content, Set uris) {
		if (!(content instanceof Container)) {
			return content; 
		}
		if (!Sets.intersection(DescriptionTranslator.lookupElemsFor(content), uris).isEmpty()) {
			return content;
		}
		Container container = (Container) content;
		for (Item item : container.getContents()) {
			if (!Sets.intersection(DescriptionTranslator.lookupElemsFor(item), uris).isEmpty()) {
				return item;
			}
		}
		throw new IllegalStateException();
	}

    List topLevelElements(DBObject query, Selection selection) {

        DBCursor cur = cursor(contentCollection, query, selection);

        if (cur == null) {
            return ImmutableList.of();
        }
        int loaded = 0;
        List items = Lists.newArrayList();
        
        while (cur.hasNext()) {
            DBObject current = cur.next();
            items.add((Content) toModel(current));
            loaded++;
            if (loaded > MAX_RESULTS) {
                throw new IllegalArgumentException("Too many results for query");
            }
        }
        return items;
    }

=======
    List executeItemQuery(DBObject query, Selection selection) {
        Builder items = ImmutableList.builder();
        List cur = ImmutableList.copyOf(cursor(itemCollection, query, selection));
        if (cur == null || cur.isEmpty()) {
            return items.build();
        }
        if (cur.size() > MAX_RESULTS) {
            LOG.error("Too many results returned for item request. Query was: " + query + ", and Selection: " + selection);
            throw new IllegalArgumentException("Too many results for query");
        }
        
        for (DBObject current: cur) {
            items.add(toItem(current));
        }

        return items.build();
    }

    private MongoDBQueryBuilder queryBuilder = new MongoDBQueryBuilder();

    public List itemsMatching(ContentQuery query) {
        return executeItemQuery(queryBuilder.buildItemQuery(query), query.getSelection());
    }

    @SuppressWarnings("unchecked")
    public List dehydratedBrandsMatching(ContentQuery query) {
        return (List) executePlaylistQuery(queryBuilder.buildBrandQuery(query), Brand.class.getSimpleName(), query
                        .getSelection(), false);
    }

    public List dehydratedPlaylistsMatching(ContentQuery query) {
        return executePlaylistQuery(queryBuilder.buildPlaylistQuery(query), null, query.getSelection(), false);
    }

    List findHydratedPlaylistsByCanonicalUri(Iterable uris) {
        return executePlaylistQuery(where().fieldIn(DescriptionTranslator.CANONICAL_URI, ImmutableSet.copyOf(uris)).build(), null, null, true);
    }

    List executePlaylistQuery(DBObject query, String type, Selection selection, boolean hydrate) {
        Builder playlists = ImmutableList.builder();
        if (type != null) {
            query.put("type", type);
        }
        
        List cur = ImmutableList.copyOf(cursor(playlistCollection, query, selection));
        if (cur == null || cur.isEmpty()) {
            return playlists.build();
        }
        if (cur.size() > MAX_RESULTS) {
            LOG.error("Query resulted in too many results. Query was: " + query + ", and Selection: " + selection);
            throw new IllegalArgumentException("Too many results for query");
        }
        
        for (DBObject current: cur) {
            playlists.add(toPlaylist(current, hydrate));
        }

        return playlists.build();
    }

    @Override
    public List listItems(String fromId, int batchSize) {
        MongoQueryBuilder query = where();
        if (fromId != null) {
            query = query.fieldGreaterThan(MongoConstants.ID, fromId);
        }
        
        return ImmutableList.copyOf(Iterables.transform(query.find(itemCollection, sortIds, batchSize), TO_ITEM));
    }

    private final Function TO_PLAYIST = new Function() {

        @Override
        public Playlist apply(DBObject dbo) {
            return toPlaylist(dbo, false);
        }
    };
>>>>>>> 5022c24c0eab9cff8659a9856f8c8ace7166d8a8
	
	private final Function TO_MODEL = new Function() {
Solution content
		return ImmutableList.copyOf(extractCanonical(ImmutableSet.copyOf(uris), findByUriOrAlias(uris, true)));
    }

	@SuppressWarnings("unchecked")
	public List findContentByCanonicalUri(final Iterable uris) {
		return (List) ImmutableList.copyOf(extractCanonical(ImmutableSet.copyOf(uris), findByUriOrAlias(uris, false)));
	}
	
	private static Identified extactItemIfInternalUrl(Identified content, Set uris) {
		if (!(content instanceof Container)) {
			return content; 
		}
		if (!Sets.intersection(DescriptionTranslator.lookupElemsFor(content), uris).isEmpty()) {
			return content;
		}
		Container container = (Container) content;
		for (Item item : container.getContents()) {
			if (!Sets.intersection(DescriptionTranslator.lookupElemsFor(item), uris).isEmpty()) {
				return item;
			}
		}
		throw new IllegalStateException();
	}

	@SuppressWarnings("unchecked")
	List topLevelElements(DBObject query, Selection selection) {

		Iterable cursor = cursor(contentCollection, query, selection);

		if (cursor == null) {
			return ImmutableList.of();
		}

		List dbos = ImmutableList.copyOf(cursor);

		if (dbos.size() > MAX_RESULTS) {
			throw new IllegalArgumentException("Too many results for query");
		}
		return (List) Lists.transform(dbos, TO_MODEL);
	}


	private final Function TO_MODEL = new Function() {
File
MongoDbBackedContentStore.java
Developer's decision
Manual
Kind of conflict
Annotation
Attribute
Method declaration
Method invocation
Chunk
Conflicting content
		}
	};
    
<<<<<<< HEAD
	@Override
	@SuppressWarnings("unchecked")
    public Iterator listAllRoots() {
        return (Iterator) Iterators.transform(contentCollection.find(), TO_MODEL);
=======
    @Override
    public List listPlaylists(String fromId, int batchSize) {
        MongoQueryBuilder query = where();
        if (fromId != null) {
            query = query.fieldGreaterThan(MongoConstants.ID, fromId);
        }
        
        return ImmutableList.copyOf(Iterables.transform(query.find(playlistCollection, sortIds, batchSize), TO_PLAYIST));
    }

    private Item toItem(DBObject object) {
        Item item = null;
        try {
            if (object.containsField("type") && Episode.class.getSimpleName().equals(object.get("type"))) {
                item = fromDB(object, Episode.class);
            } else if (object.containsField("type") && Clip.class.getSimpleName().equals(object.get("type"))) {
            	item = fromDB(object, Clip.class);
            } else {
            	item = fromDB(object, Item.class);
            }
            removeUriFromAliases(item);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return item;
>>>>>>> 5022c24c0eab9cff8659a9856f8c8ace7166d8a8
    }

	private final MongoDBQueryBuilder queryBuilder = new MongoDBQueryBuilder();
Solution content
		}
	};
	
    @SuppressWarnings("unchecked")
	@Override
    public List listAllRoots(String fromId, int batchSize) {
        MongoQueryBuilder query = where();
        if (fromId != null) {
            query = query.fieldGreaterThan(MongoConstants.ID, fromId);
        }
        
        return (List) ImmutableList.copyOf(Iterables.transform(query.find(contentCollection, sortIds, batchSize), TO_MODEL));
    }
  
	private final MongoDBQueryBuilder queryBuilder = new MongoDBQueryBuilder();
File
MongoDbBackedContentStore.java
Developer's decision
Manual
Kind of conflict
Annotation
Cast expression
Method declaration
Method signature
Return statement
Try statement
Variable
Chunk
Conflicting content
import org.atlasapi.media.entity.Clip;
import org.atlasapi.media.entity.Content;
<<<<<<< HEAD
=======
import org.atlasapi.media.entity.MediaType;
import org.atlasapi.media.entity.Publisher;
import org.atlasapi.media.entity.Specialization;
>>>>>>> 5022c24c0eab9cff8659a9856f8c8ace7166d8a8
import org.atlasapi.persistence.ModelTranslator;

import com.google.common.base.Function;
Solution content
import org.atlasapi.media.entity.Clip;
import org.atlasapi.media.entity.Content;
import org.atlasapi.persistence.ModelTranslator;

import com.google.common.base.Function;
File
ContentTranslator.java
Developer's decision
Version 1
Kind of conflict
Import
Chunk
Conflicting content
        	});
        	entity.setClips(clips);
        }
<<<<<<< HEAD
		return entity;
=======
        
        // Hack to transfer from the old name to the new
        String cType = (String)dbObject.get("contentType");
        if (cType != null) {
        	entity.setMediaType(MediaType.valueOf(cType.toUpperCase()));
        } else {
            cType = (String)dbObject.get("mediaType");
            if (cType != null) {
                entity.setMediaType(MediaType.valueOf(cType.toUpperCase()));
            }
        }
        
        String specialization = (String) dbObject.get("specialization");
        if (specialization != null) {
            entity.setSpecialization(Specialization.valueOf(specialization.toUpperCase()));
        }
        
       return entity;
>>>>>>> 5022c24c0eab9cff8659a9856f8c8ace7166d8a8
	}

	@Override
Solution content
package org.atlasapi.persistence.media.entity;

import java.util.List;

import org.atlasapi.media.entity.Clip;
import org.atlasapi.media.entity.Content;
import org.atlasapi.persistence.ModelTranslator;

import com.google.common.base.Function;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;

public class ContentTranslator implements ModelTranslator {

	private static String CLIPS_KEY = "clips";
	
	private ClipTranslator clipTranslator;
	private final DescribedTranslator describedTranslator;
	
	public ContentTranslator(boolean useIds) {
		this(new DescribedTranslator(new DescriptionTranslator(useIds)), new ClipTranslator());
	}
	
	public ContentTranslator(DescribedTranslator describedTranslator, ClipTranslator clipTranslator) {
		this.describedTranslator = describedTranslator;
		this.clipTranslator = clipTranslator;
	}
	
	public void setClipTranslator(ClipTranslator clipTranslator) {
		this.clipTranslator = clipTranslator;
	}
	
	@Override
	@SuppressWarnings("unchecked")
	public Content fromDBObject(DBObject dbObject, Content entity) {
		describedTranslator.fromDBObject(dbObject, entity);

		if (dbObject.containsField(CLIPS_KEY)) {
			Iterable clipsDbos = (Iterable) dbObject.get(CLIPS_KEY);
			Iterable clips = Iterables.transform(clipsDbos, new Function() {

				@Override
				public Clip apply(DBObject dbo) {
					return clipTranslator.fromDBObject(dbo, null);
				}
			});
			entity.setClips(clips);
		}

		return entity;
	}

	@Override
File
ContentTranslator.java
Developer's decision
Manual
Kind of conflict
Cast expression
Comment
If statement
Return statement
Variable
Chunk
Conflicting content
<<<<<<< HEAD
		return dbObject;
		}
			dbObject.put(CLIPS_KEY, clipDbos);
				}
			});
=======
        }
        
        if (entity.getMediaType() != null) {
        	TranslatorUtils.from(dbObject, "mediaType", entity.getMediaType().toString().toLowerCase());
        }
        if (entity.getSpecialization() != null) {
            TranslatorUtils.from(dbObject, "specialization", entity.getSpecialization().toString().toLowerCase());
        }
        
        return dbObject;
>>>>>>> 5022c24c0eab9cff8659a9856f8c8ace7166d8a8
	}
}
Solution content
				}
			});
			dbObject.put(CLIPS_KEY, clipDbos);
		}
        return dbObject;
	}
}
File
ContentTranslator.java
Developer's decision
Version 1
Kind of conflict
If statement
Return statement
Variable
Chunk
Conflicting content
        scheduler.tick(120, TimeUnit.SECONDS);
    }
    
<<<<<<< HEAD
    @Test
    public void testBootstrap() throws Exception {
        final List items = Lists.newArrayList();
        items.add(new Item("uri", "curie", anyPublisher));
        
        context.checking(new Expectations() {{ 
            one(delegate).itemChanged(items, ContentListener.ChangeType.BOOTSTRAP);
        }});
        
        contentListener.itemChanged(items, ContentListener.ChangeType.BOOTSTRAP);
    }
=======
//    @Test
//    public void testBootstrap() throws Exception {
//        final List items = Lists.newArrayList();
//        items.add(new Item("uri", "curie", anyPublisher));
//        
//        context.checking(new Expectations() {{ 
//            one(delegate).itemChanged(items, ContentListener.changeType.BOOTSTRAP);
//        }});
//        
//        contentListener.itemChanged(items, ContentListener.changeType.BOOTSTRAP);
//    }
>>>>>>> 5022c24c0eab9cff8659a9856f8c8ace7166d8a8
}
Solution content
        scheduler.tick(120, TimeUnit.SECONDS);
    }
    
//    @Test
//    public void testBootstrap() throws Exception {
//        final List items = Lists.newArrayList();
//        items.add(new Item("uri", "curie", anyPublisher));
//        
//        context.checking(new Expectations() {{ 
//            one(delegate).itemChanged(items, ContentListener.ChangeType.BOOTSTRAP);
//        }});
//        
//        contentListener.itemChanged(items, ContentListener.ChangeType.BOOTSTRAP);
//    }
}
File
QueueingContentListenerTest.java
Developer's decision
Manual
Kind of conflict
Annotation
Comment
Method declaration
Chunk
Conflicting content
        final List items2 = ImmutableList.of(data.everyoneNeedsAnEel);
        
        context.checking(new Expectations() {{
<<<<<<< HEAD
            one(store).listAllRoots(); will(returnValue(items.iterator()));
=======
            one(store).listItems(null, 2); will(returnValue(items1));
            one(store).listItems(data.englishForCats.getCanonicalUri(), 2); will(returnValue(items2));
>>>>>>> 5022c24c0eab9cff8659a9856f8c8ace7166d8a8
        }});
        
        context.checking(new Expectations() {{
Solution content
}
       bootstrapper.loadAllItems();
    }
package org.atlasapi.persistence.content.mongo;

import java.util.List;

import org.atlasapi.media.entity.Item;
import org.atlasapi.media.entity.Publisher;
import org.atlasapi.persistence.content.ContentListener;
import org.atlasapi.persistence.content.RetrospectiveContentLister;
import org.jmock.Expectations;
import org.jmock.Mockery;
import org.jmock.integration.junit4.JMock;
import org.junit.Test;
import org.junit.runner.RunWith;

import com.google.common.collect.ImmutableList;

@RunWith(JMock.class)
public class MongoDbBackedContentListenerTest  {
   
	private final Mockery context = new Mockery();
	
	private RetrospectiveContentLister store = context.mock(RetrospectiveContentLister.class);
    private ContentListener listener = context.mock(ContentListener.class);
   
    private MongoDbBackedContentBootstrapper bootstrapper = new MongoDbBackedContentBootstrapper(listener, store);
    
    private final Item item1 = new Item("1", "1", Publisher.ARCHIVE_ORG);
    private final Item item2 = new Item("2", "2", Publisher.ARCHIVE_ORG);
    private final Item item3 = new Item("3", "3", Publisher.ARCHIVE_ORG);
    
    @Test
    public void testShouldLoadItems() throws Exception {
        bootstrapper.setBatchSize(2);
        
        final List items1 = ImmutableList.of(item1, item2);
        final List items2 = ImmutableList.of(item3);
        
        context.checking(new Expectations() {{
            one(store).listAllRoots(null, 2); will(returnValue(items1));
            one(store).listAllRoots(item2.getCanonicalUri(), 2); will(returnValue(items2));
        }});
        
        context.checking(new Expectations() {{
            one(listener).itemChanged(ImmutableList.of(item1, item2), ContentListener.ChangeType.BOOTSTRAP);
            one(listener).itemChanged(ImmutableList.of(item3), ContentListener.ChangeType.BOOTSTRAP);
        }});
        
File
MongoDbBackedContentListenerTest.java
Developer's decision
Manual
Kind of conflict
Method invocation
Variable
Chunk
Conflicting content
    	bootstrapper.setBatchSize(2);
        
<<<<<<< HEAD
        final List playlists = ImmutableList.of(data.eastenders, data.dispatches);
        
        context.checking(new Expectations() {{
            one(store).listAllRoots(); will(returnValue(playlists.iterator()));
        }});
        
        context.checking(new Expectations() {{
            one(listener).brandChanged(ImmutableList.of(data.eastenders, data.dispatches), ContentListener.ChangeType.BOOTSTRAP);
=======
        final List playlists1 = ImmutableList.of(data.eastenders, data.goodEastendersEpisodes);
        final List playlists2 = ImmutableList.of(data.dispatches);
        
        context.checking(new Expectations() {{
            one(store).listPlaylists(null, 2); will(returnValue(playlists1));
            one(store).listPlaylists(data.goodEastendersEpisodes.getCanonicalUri(), 2); will(returnValue(playlists2));
        }});
        
        context.checking(new Expectations() {{
            one(listener).brandChanged(ImmutableList.of(data.eastenders), ContentListener.changeType.BOOTSTRAP);
            one(listener).brandChanged(ImmutableList.of(data.dispatches), ContentListener.changeType.BOOTSTRAP);
>>>>>>> 5022c24c0eab9cff8659a9856f8c8ace7166d8a8
        }});
        
        bootstrapper.loadAllBrands();
Solution content
        
        context.checking(new Expectations() {{
            one(store).listAllRoots(null, 2); will(returnValue(items1));
            one(store).listAllRoots(item2.getCanonicalUri(), 2); will(returnValue(items2));
        }});
        
        context.checking(new Expectations() {{
            one(listener).itemChanged(ImmutableList.of(item1, item2), ContentListener.ChangeType.BOOTSTRAP);
            one(listener).itemChanged(ImmutableList.of(item3), ContentListener.ChangeType.BOOTSTRAP);
        }});
        
File
MongoDbBackedContentListenerTest.java
Developer's decision
Manual
Kind of conflict
Method invocation
Variable
Chunk
Conflicting content
        
        List playlists = store.findByCanonicalUri(ImmutableList.of(data.goodEastendersEpisodes.getCanonicalUri()));
        assertEquals(1, playlists.size());
<<<<<<< HEAD
        
        ContentGroup group = (ContentGroup) playlists.get(0);
        assertEquals(ImmutableList.of(data.dotCottonsBigAdventure, data.neighbours), group.getContents());
    }
    
    public void testShouldListAllRoots() throws Exception {
        store.createOrUpdate(data.dispatches, true);
        store.createOrUpdate(data.eastenders, true);
        store.createOrUpdate(data.englishForCats);

        ImmutableList items = ImmutableList.copyOf(store.listAllRoots());
        assertEquals(ImmutableList.of(data.dispatches, data.eastenders, data.englishForCats), items);
=======
        Collection subPlaylists = playlists.get(0).getPlaylists();
        assertEquals(1, subPlaylists.size());
        assertTrue(subPlaylists.iterator().next() instanceof Brand);
    }
    
    public void testShouldListAllItems() throws Exception {
        store.createOrUpdateItem(data.eggsForBreakfast);
        store.createOrUpdateItem(data.englishForCats);
        store.createOrUpdateItem(data.fossils);
        
        List items = ImmutableList.copyOf(store.listItems(null, 2));
        
        assertEquals(ImmutableList.of(data.fossils, data.englishForCats), items);
        
        items = ImmutableList.copyOf(store.listItems(data.englishForCats.getCanonicalUri(), 2));
        
        assertEquals(ImmutableList.of(data.eggsForBreakfast), items);
    }
    
    public void testShouldListAllPlaylists() throws Exception {
        store.createOrUpdatePlaylist(data.dispatches, false);
        store.createOrUpdatePlaylist(data.eastenders, false);
        
        List items = ImmutableList.copyOf(store.listPlaylists(null, 2));
        assertEquals(ImmutableList.of(data.eastenders, data.dispatches), items);
>>>>>>> 5022c24c0eab9cff8659a9856f8c8ace7166d8a8
    }
    
    public void testThatItemsAreNotRemovedFromTheirBrands() throws Exception {
Solution content
        
        List playlists = store.findByCanonicalUri(ImmutableList.of(data.goodEastendersEpisodes.getCanonicalUri()));
        assertEquals(1, playlists.size());
        
        ContentGroup group = (ContentGroup) playlists.get(0);
        assertEquals(ImmutableList.of(data.dotCottonsBigAdventure, data.neighbours), group.getContents());
    }
    
    public void testShouldListAllItems() throws Exception {
        store.createOrUpdate(data.eggsForBreakfast);
        store.createOrUpdate(data.englishForCats);
        
        ImmutableList items = ImmutableList.copyOf(store.listAllRoots(null, 2));
        
        assertEquals(ImmutableList.of(data.fossils, data.englishForCats), items);
        
        items = ImmutableList.copyOf(store.listAllRoots(data.englishForCats.getCanonicalUri(), 2));
        
        assertEquals(ImmutableList.of(data.eggsForBreakfast), items);
    }
    
    public void testShouldListAllPlaylists() throws Exception {
        store.createOrUpdate(data.dispatches, false);
        store.createOrUpdate(data.eastenders, false);
        
        List items = ImmutableList.copyOf(store.listAllRoots(null, 2));
        assertEquals(ImmutableList.of(data.eastenders, data.dispatches), items);
    }
    
    public void testThatItemsAreNotRemovedFromTheirBrands() throws Exception {
File
MongoDbBackedContentStoreTest.java
Developer's decision
Manual
Kind of conflict
Cast expression
Method declaration
Method invocation
Method signature
Variable