Projects >> atlas >>cf85e53917cb32c726526e9b53f61fc6ecc57077

Chunk
Conflicting content
import org.atlasapi.remotesite.opta.events.soccer.OptaSoccerDataTransformer;
import org.atlasapi.remotesite.opta.events.sports.OptaSportsDataHandler;
import org.atlasapi.remotesite.opta.events.sports.OptaSportsDataTransformer;
<<<<<<< HEAD
import org.atlasapi.remotesite.opta.events.sports.model.OptaFixture;
import org.atlasapi.remotesite.opta.events.sports.model.OptaSportsTeam;
import org.atlasapi.remotesite.util.RestS3ServiceSupplier;
import org.jets3t.service.security.AWSCredentials;
=======
import org.atlasapi.remotesite.opta.events.sports.model.SportsMatchData;
import org.atlasapi.remotesite.opta.events.sports.model.SportsTeam;
>>>>>>> 0c72450955f6981360612438e83d3e2da844f4ef
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Solution content
import org.atlasapi.remotesite.opta.events.soccer.OptaSoccerDataTransformer;
import org.atlasapi.remotesite.opta.events.sports.OptaSportsDataHandler;
import org.atlasapi.remotesite.opta.events.sports.OptaSportsDataTransformer;
import org.atlasapi.remotesite.opta.events.sports.model.SportsMatchData;
import org.atlasapi.remotesite.opta.events.sports.model.SportsTeam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
File
OptaEventsModule.java
Developer's decision
Version 2
Kind of conflict
Import
Chunk
Conflicting content
    private @Autowired SimpleScheduler scheduler;
    private @Autowired EventStore eventStore;
    private @Autowired OrganisationStore organisationStore;
<<<<<<< HEAD
    private @Autowired EventTopicResolver topicResolver;
=======
    private @Autowired @Qualifier("topicStore") TopicStore topicStore;
>>>>>>> 0c72450955f6981360612438e83d3e2da844f4ef
    
    private @Value("${opta.events.http.baseUrl}") String baseUrl;
    private @Value("${opta.events.http.username}") String username;
Solution content
    private @Autowired SimpleScheduler scheduler;
    private @Autowired EventStore eventStore;
    private @Autowired OrganisationStore organisationStore;
    private @Autowired @Qualifier("topicStore") TopicStore topicStore;
    
    private @Value("${opta.events.http.baseUrl}") String baseUrl;
    private @Value("${opta.events.http.username}") String username;
File
OptaEventsModule.java
Developer's decision
Version 2
Kind of conflict
Attribute
Chunk
Conflicting content
        return new OptaEventsIngestTask(fetcher, dataHandler());
    }

<<<<<<< HEAD
    private OptaEventsFetcher soccerFetcher() {
        return new CombiningOptaEventsFetcher<>(ImmutableList.>of(
                new S3OptaEventsFetcher<>(s3FileFetcher(), soccerFileNames(), soccerTransformer(), s3BucketName),
                new HttpOptaEventsFetcher<>(
                        sportConfig(), 
                        HttpClients.webserviceClient(), 
                        soccerTransformer(), 
                        new UsernameAndPassword(username, password), baseUrl)
        ));
    }
    
    private S3FileFetcher s3FileFetcher() {
        AWSCredentials credentials = new AWSCredentials(s3AccessKey, s3SecretAccessKey);
        return new S3FileFetcher(new RestS3ServiceSupplier(credentials));
    }
    
    private OptaDataTransformer soccerTransformer() {
=======
    private OptaEventsFetcher soccerFetcher() {
        return httpEventsFetcher(OPTA_HTTP_SOCCER_CONFIG_PREFIX, soccerTransformer());
    }
    
    private OptaDataTransformer soccerTransformer() {
>>>>>>> 0c72450955f6981360612438e83d3e2da844f4ef
        return new OptaSoccerDataTransformer();
    }
    
Solution content
        return new OptaEventsIngestTask(fetcher, dataHandler());
    }

    private OptaEventsFetcher soccerFetcher() {
        return httpEventsFetcher(OPTA_HTTP_SOCCER_CONFIG_PREFIX, soccerTransformer());
    }
    
    private OptaDataTransformer soccerTransformer() {
        return new OptaSoccerDataTransformer();
    }
    
File
OptaEventsModule.java
Developer's decision
Version 2
Kind of conflict
Method declaration
Method signature
Chunk
Conflicting content
        return new OptaEventsUriCreator();
    }

<<<<<<< HEAD
    private Map sportConfig() {
        Builder configMapping = 
                ImmutableMap.builder();
        
        Iterable> matchingParams = 
                Configurer.getParamsWithKeyMatching(Predicates.containsPattern(OPTA_HTTP_CONFIG_PREFIX));
        for (Entry property : matchingParams) {
            String sportKey = property.getKey().substring(OPTA_HTTP_CONFIG_PREFIX.length());
=======
    private OptaEventsFetcher sportsFetcher() {
        return httpEventsFetcher(OPTA_HTTP_RUGBY_CONFIG_PREFIX, sportsTransformer());
    }
    
    private OptaDataTransformer sportsTransformer() {
        return new OptaSportsDataTransformer();
    }

    private OptaEventsFetcher httpEventsFetcher(String sportPrefix, OptaDataTransformer dataTransformer) {
        return new HttpOptaEventsFetcher<>(sportConfig(sportPrefix), HttpClients.webserviceClient(), dataTransformer, new UsernameAndPassword(username, password), baseUrl);
    }

    private OptaSportsDataHandler dataHandler() {
        return new OptaSportsDataHandler(organisationStore, eventStore, utility());
    }

    /**
     * Opta Sports are configured through three parameters: feed type, a competition id, and a season. Each sport is
     * held in an environment param suffixed with the sport's enum value, and the three parameters are joined with the | character.
     * This method reads any environment params with the supplied suffix and splits out the three config params into a special
     * holding type, and returns a map of sport -> configuration
     * 
     * @param sportPrefix the environment parameter prefix for the sport subset desired
     * @return
     */
    private Map sportConfig(String sportPrefix) {
        Builder configMapping = ImmutableMap.builder();
        for (Entry property : Configurer.getParamsWithKeyMatching(Predicates.containsPattern(sportPrefix))) {
            String sportKey = property.getKey().substring(sportPrefix.length());
>>>>>>> 0c72450955f6981360612438e83d3e2da844f4ef
            String sportConfig = property.getValue().get();
            
            if (!Strings.isNullOrEmpty(sportConfig)) {
Solution content
        return new OptaEventsUriCreator();
    }

    private OptaEventsFetcher sportsFetcher() {
        return httpEventsFetcher(OPTA_HTTP_RUGBY_CONFIG_PREFIX, sportsTransformer());
    }
    
    private OptaDataTransformer sportsTransformer() {
        return new OptaSportsDataTransformer();
    }

    private OptaEventsFetcher httpEventsFetcher(String sportPrefix, OptaDataTransformer dataTransformer) {
        return new HttpOptaEventsFetcher<>(sportConfig(sportPrefix), HttpClients.webserviceClient(), dataTransformer, new UsernameAndPassword(username, password), baseUrl);
    }

    private OptaSportsDataHandler dataHandler() {
        return new OptaSportsDataHandler(organisationStore, eventStore, utility());
    }

    /**
     * Opta Sports are configured through three parameters: feed type, a competition id, and a season. Each sport is
     * held in an environment param suffixed with the sport's enum value, and the three parameters are joined with the | character.
     * This method reads any environment params with the supplied suffix and splits out the three config params into a special
     * holding type, and returns a map of sport -> configuration
     * 
     * @param sportPrefix the environment parameter prefix for the sport subset desired
     * @return
     */
    private Map sportConfig(String sportPrefix) {
        Builder configMapping = ImmutableMap.builder();
        for (Entry property : Configurer.getParamsWithKeyMatching(Predicates.containsPattern(sportPrefix))) {
            String sportKey = property.getKey().substring(sportPrefix.length());
            String sportConfig = property.getValue().get();
            
            if (!Strings.isNullOrEmpty(sportConfig)) {
File
OptaEventsModule.java
Developer's decision
Version 2
Kind of conflict
Comment
For statement
Method declaration
Method invocation
Method signature
Variable
Chunk
Conflicting content
    private OptaSoccerDataHandler soccerDataHandler() {
                .build();
    }

<<<<<<< HEAD
    private Map soccerFileNames() {
        return ImmutableMap.of(
                OptaSportType.FOOTBALL_SCOTTISH_PREMIER_LEAGUE, SCOTTISH_PREMIER_LEAGUE_FILENAME,
                OptaSportType.FOOTBALL_GERMAN_BUNDESLIGA, GERMAN_BUNDESLIGA_FILENAME
        );
    }

    @Bean
        return new OptaSoccerDataHandler(organisationStore, eventStore, topicResolver, new OptaEventsMapper(), uriCreator());
    }

    private OptaEventsIngestTask sportsIngestTask() {
        return new OptaEventsIngestTask<>(sportsFetcher(), sportsDataHandler());
    }

    private OptaEventsFetcher sportsFetcher() {
        return new S3OptaEventsFetcher<>(s3FileFetcher(), sportFileNames(), sportsTransformer(), s3BucketName);
    }
    
    private OptaDataTransformer sportsTransformer() {
        return new OptaSportsDataTransformer();
    }

    private Map sportFileNames() {
        return ImmutableMap.of(
                OptaSportType.RUGBY, RUGBY_LEAGUE_FILENAME
        );
    }

    private OptaSportsDataHandler sportsDataHandler() {
        return new OptaSportsDataHandler(organisationStore, eventStore, topicResolver, new OptaEventsMapper(), uriCreator());
    }
=======
    @Bean
    private OptaEventsUtility utility() {
        return new OptaEventsUtility(topicStore);
    }
>>>>>>> 0c72450955f6981360612438e83d3e2da844f4ef
}
Solution content
                .build();
    }

    @Bean
    private OptaEventsUtility utility() {
        return new OptaEventsUtility(topicStore);
    }
}
File
OptaEventsModule.java
Developer's decision
Version 2
Kind of conflict
Annotation
Method declaration
Chunk
Conflicting content
import static com.google.api.client.util.Preconditions.checkNotNull;

<<<<<<< HEAD
=======
import java.util.List;
import java.util.Set;

>>>>>>> 0c72450955f6981360612438e83d3e2da844f4ef
import org.atlasapi.media.entity.Event;
import org.atlasapi.media.entity.Organisation;
import org.atlasapi.media.entity.Publisher;
Solution content
import static com.google.api.client.util.Preconditions.checkNotNull;

import java.util.List;
import java.util.Set;

import org.atlasapi.media.entity.Event;
import org.atlasapi.media.entity.Organisation;
import org.atlasapi.media.entity.Publisher;
File
OptaSportsDataHandler.java
Developer's decision
Version 2
Kind of conflict
Import
Chunk
Conflicting content
    }

    @Override
<<<<<<< HEAD
    public Optional parseOrganisation(OptaSportsTeam team, OptaSportType sport) {
        Organisation organisation = new Organisation();

        if (mapper.fetchIgnoredTeams().contains(team.attributes().name())) {
            log.warn("Found team with ignored name {}", team.attributes().name());
            return Optional.absent();
        }
        organisation.setCanonicalUri(uriCreator.createTeamUri(team.attributes().id()));
        organisation.setPublisher(Publisher.OPTA);
        organisation.setTitle(team.attributes().name());
        organisation.setEventGroups(resolveOrCreateEventGroups(sport));
=======
    public Optional parseOrganisation(SportsTeam team) {
        Organisation organisation = new Organisation();

        organisation.setCanonicalUri(utility.createTeamUri(team.attributes().uId()));
        organisation.setPublisher(Publisher.OPTA);
        organisation.setTitle(team.name());
>>>>>>> 0c72450955f6981360612438e83d3e2da844f4ef

        return Optional.of(organisation);
    }
Solution content
    }

    @Override
    public Optional parseOrganisation(SportsTeam team) {
        Organisation organisation = new Organisation();

        organisation.setCanonicalUri(utility.createTeamUri(team.attributes().uId()));
        organisation.setPublisher(Publisher.OPTA);
        organisation.setTitle(team.name());

        return Optional.of(organisation);
    }
File
OptaSportsDataHandler.java
Developer's decision
Version 2
Kind of conflict
If statement
Method invocation
Method signature
Variable
Chunk
Conflicting content
                .withEventGroups(resolveOrCreateEventGroups(sport))
                .build();

<<<<<<< HEAD
        event.setCanonicalUri(uriCreator.createEventUri(match.attributes().id()));
=======
        event.setCanonicalUri(utility.createEventUri(match.attributes().uId()));
>>>>>>> 0c72450955f6981360612438e83d3e2da844f4ef
        
        return Optional.of(event);
    }
Solution content
                .withEventGroups(resolveOrCreateEventGroups(sport))
                .build();

        event.setCanonicalUri(utility.createEventUri(match.attributes().uId()));
        
        return Optional.of(event);
    }
File
OptaSportsDataHandler.java
Developer's decision
Version 2
Kind of conflict
Method invocation
Chunk
Conflicting content
        return Optional.of(team1.get() + " vs " + team2.get());
    }
    
<<<<<<< HEAD
    private Optional fetchTeamName(OptaFixtureTeam teamData) {
        Optional team = getTeamByUri(uriCreator.createTeamUri(teamData.attributes().teamId()));
=======
    private Optional fetchTeamName(SportsTeamData teamData) {
        String teamId = teamData.attributes().teamRef();
        Optional team = getTeamByUri(utility.createTeamUri(teamId));
>>>>>>> 0c72450955f6981360612438e83d3e2da844f4ef
        if (!team.isPresent()) {
            log.error("team {} not present in teams list", teamId);
            return Optional.absent();
Solution content
        return Optional.of(team1.get() + " vs " + team2.get());
    }
    
    private Optional fetchTeamName(SportsTeamData teamData) {
        String teamId = teamData.attributes().teamRef();
        Optional team = getTeamByUri(utility.createTeamUri(teamId));
        if (!team.isPresent()) {
            log.error("team {} not present in teams list", teamId);
            return Optional.absent();
File
OptaSportsDataHandler.java
Developer's decision
Version 2
Kind of conflict
Method invocation
Method signature
Variable
Chunk
Conflicting content
        return Optional.of(team.get().getTitle());
    }
    
<<<<<<< HEAD
    private DateTime parseStartTime(OptaFixture fixture, OptaSportType sport) {
        DateTimeZone timeZone = mapper.fetchTimeZone(sport);
        return TIME_FORMATTER.withZone(timeZone)
                        .parseDateTime(fixture.attributes().gameDate() + " " + fixture.attributes().time());
=======
    private Optional parseStartTime(SportsMatchData match, OptaSportType sport) {
        String dateStr = match.matchInformation().date().date();
        Optional timeZone = utility.fetchTimeZone(sport);
        if (!timeZone.isPresent()) {
            log.error("No time zone mapping found for sport {}", sport);
            return Optional.absent();
        }
        
        return Optional.of(
                DATE_TIME_FORMATTER.withZone(timeZone.get())
                        .parseDateTime(dateStr)
        );
    }
    
    private Optional createOrResolveVenue(SportsMatchData match) {
        String location = getVenueData(match.stats());
        Optional value = utility.createOrResolveVenue(location);
        if (!value.isPresent()) {
            log.error("Unable to resolve location: {}", location);
        }
        return value;
>>>>>>> 0c72450955f6981360612438e83d3e2da844f4ef
    }
    
    private String getVenueData(List stats) {
Solution content
        return Optional.of(team.get().getTitle());
    }
    
    private Optional parseStartTime(SportsMatchData match, OptaSportType sport) {
        String dateStr = match.matchInformation().date().date();
        Optional timeZone = utility.fetchTimeZone(sport);
        if (!timeZone.isPresent()) {
            log.error("No time zone mapping found for sport {}", sport);
            return Optional.absent();
        }
        
        return Optional.of(
                DATE_TIME_FORMATTER.withZone(timeZone.get())
                        .parseDateTime(dateStr)
        );
    }
    
    private Optional createOrResolveVenue(SportsMatchData match) {
        String location = getVenueData(match.stats());
        Optional value = utility.createOrResolveVenue(location);
        if (!value.isPresent()) {
            log.error("Unable to resolve location: {}", location);
        }
        return value;
    }
    
    private String getVenueData(List stats) {
File
OptaSportsDataHandler.java
Developer's decision
Version 2
Kind of conflict
If statement
Method declaration
Method invocation
Method signature
Return statement
Variable
Chunk
Conflicting content
    private Iterable parseOrganisations(SportsMatchData match) {
        Iterable organisations = Iterables.transform(match.teamData(), new Function() {
            @Override
<<<<<<< HEAD
            public Organisation apply(OptaFixtureTeam input) {
                return getTeamByUri(uriCreator.createTeamUri(input.attributes().teamId())).orNull();
=======
            public Organisation apply(SportsTeamData input) {
                return getTeamByUri(utility.createTeamUri(input.attributes().teamRef())).orNull();
>>>>>>> 0c72450955f6981360612438e83d3e2da844f4ef
            }
        });
        return Iterables.filter(organisations, Predicates.notNull());
Solution content
    private Iterable parseOrganisations(SportsMatchData match) {
        Iterable organisations = Iterables.transform(match.teamData(), new Function() {
            @Override
            public Organisation apply(SportsTeamData input) {
                return getTeamByUri(utility.createTeamUri(input.attributes().teamRef())).orNull();
            }
        });
        return Iterables.filter(organisations, Predicates.notNull());
File
OptaSportsDataHandler.java
Developer's decision
Version 2
Kind of conflict
Method invocation
Method signature
Return statement
Chunk
Conflicting content
@RunWith(MockitoJUnitRunner.class)
public class ContentMergerTest {
    
<<<<<<< HEAD
    private static Publisher PUBLISHER = Publisher.METABROADCAST;
    
=======
    private static final Publisher PUBLISHER = Publisher.METABROADCAST;

>>>>>>> 0c72450955f6981360612438e83d3e2da844f4ef
    @Test
    public void testVersionMerger() {
        ContentMerger contentMerger = new ContentMerger(MergeStrategy.MERGE, MergeStrategy.KEEP, MergeStrategy.REPLACE);
Solution content
@RunWith(MockitoJUnitRunner.class)
public class ContentMergerTest {
    
    private static final Publisher PUBLISHER = Publisher.METABROADCAST;

    @Test
    public void testVersionMerger() {
        ContentMerger contentMerger = new ContentMerger(MergeStrategy.MERGE, MergeStrategy.KEEP, MergeStrategy.REPLACE);
File
ContentMergerTest.java
Developer's decision
Version 2
Kind of conflict
Attribute
Chunk
Conflicting content
    @Test
    public void testItemItemMergingProducesItem() {
<<<<<<< HEAD
        ContentMerger contentMerger = new ContentMerger(MergeStrategy.MERGE, MergeStrategy.KEEP, MergeStrategy.REPLACE);
=======
        ContentMerger contentMerger = new ContentMerger(MergeStrategy.MERGE, MergeStrategy.KEEP);
>>>>>>> 0c72450955f6981360612438e83d3e2da844f4ef
        
        Item current = createItem("old title", PUBLISHER);
        Item extracted = createItem("new title", PUBLISHER);
Solution content
    @Test
    public void testItemItemMergingProducesItem() {
        ContentMerger contentMerger = new ContentMerger(MergeStrategy.MERGE, MergeStrategy.KEEP, MergeStrategy.REPLACE);
        
        Item current = createItem("old title", PUBLISHER);
        Item extracted = createItem("new title", PUBLISHER);
File
ContentMergerTest.java
Developer's decision
Version 1
Kind of conflict
Method invocation
Variable
Chunk
Conflicting content
<<<<<<< HEAD
    
    @Test
    public void testEpisodeItemMergingProducesItem() {
        ContentMerger contentMerger = new ContentMerger(MergeStrategy.MERGE, MergeStrategy.KEEP, MergeStrategy.REPLACE);
=======
        ContentMerger contentMerger = new ContentMerger(MergeStrategy.MERGE, MergeStrategy.KEEP);
>>>>>>> 0c72450955f6981360612438e83d3e2da844f4ef
        
        Episode current = createEpisode("old title", PUBLISHER, 3);
        Item extracted = createItem("new title", PUBLISHER);
Solution content
    
    @Test
    public void testEpisodeItemMergingProducesItem() {
        ContentMerger contentMerger = new ContentMerger(MergeStrategy.MERGE, MergeStrategy.KEEP, MergeStrategy.REPLACE);
        
        Episode current = createEpisode("old title", PUBLISHER, 3);
        Item extracted = createItem("new title", PUBLISHER);
File
ContentMergerTest.java
Developer's decision
Version 1
Kind of conflict
Method invocation
Variable
Chunk
Conflicting content
    
    @Test
    public void testItemEpisodeMergingProducesEpisode() {
<<<<<<< HEAD
        ContentMerger contentMerger = new ContentMerger(MergeStrategy.MERGE, MergeStrategy.KEEP, MergeStrategy.REPLACE);
=======
        ContentMerger contentMerger = new ContentMerger(MergeStrategy.MERGE, MergeStrategy.KEEP);
>>>>>>> 0c72450955f6981360612438e83d3e2da844f4ef
        
        String extractedTitle = "new title";
        Integer extractedEpisodeNum = 5;
Solution content
    
    @Test
    public void testItemEpisodeMergingProducesEpisode() {
        ContentMerger contentMerger = new ContentMerger(MergeStrategy.MERGE, MergeStrategy.KEEP, MergeStrategy.REPLACE);
        
        String extractedTitle = "new title";
        Integer extractedEpisodeNum = 5;
File
ContentMergerTest.java
Developer's decision
Version 1
Kind of conflict
Method invocation
Variable
Chunk
Conflicting content
    
    @Test
    public void testEpisodeEpisodeMergingProducesEpisode() {
<<<<<<< HEAD
        ContentMerger contentMerger = new ContentMerger(MergeStrategy.MERGE, MergeStrategy.KEEP, MergeStrategy.REPLACE);
=======
        ContentMerger contentMerger = new ContentMerger(MergeStrategy.MERGE, MergeStrategy.KEEP);
>>>>>>> 0c72450955f6981360612438e83d3e2da844f4ef
        
        String extractedTitle = "new title";
        Integer extractedEpisodeNum = 5;
Solution content
    
    @Test
    public void testEpisodeEpisodeMergingProducesEpisode() {
        ContentMerger contentMerger = new ContentMerger(MergeStrategy.MERGE, MergeStrategy.KEEP, MergeStrategy.REPLACE);
        
        String extractedTitle = "new title";
        Integer extractedEpisodeNum = 5;
File
ContentMergerTest.java
Developer's decision
Version 1
Kind of conflict
Method invocation
Variable
Chunk
Conflicting content
        assertEquals(extractedTitle, merged.getTitle());
        assertEquals(extractedEpisodeNum, merged.getEpisodeNumber());
    }
<<<<<<< HEAD
    
    @Test
    public void testAliasMergeStrategyInvoked() {
        AliasMergeStrategy aliasMergeStrategy = mock(AliasMergeStrategy.class);
        ContentMerger contentMerger = new ContentMerger(MergeStrategy.MERGE, MergeStrategy.KEEP, aliasMergeStrategy);
        
        Item current = createItem("title", Publisher.METABROADCAST);
        Item extracted = createItem("title", Publisher.METABROADCAST);
        when(aliasMergeStrategy.mergeAliases(current, extracted)).thenReturn(current);
        
        contentMerger.merge(current, extracted);
        verify(aliasMergeStrategy).mergeAliases(current, extracted);
    }
    
    @Test
    public void testMergeAliasesMergeStrategy() {
        ContentMerger contentMerger = new ContentMerger(MergeStrategy.MERGE, MergeStrategy.KEEP, MergeStrategy.MERGE);
        Item current = createItem("title", Publisher.METABROADCAST);
        Item extracted = createItem("title", Publisher.METABROADCAST);
        
        current.setAliases(ImmutableSet.of(new Alias("1", "2"), new Alias("2", "3")));
        extracted.setAliases(ImmutableSet.of(new Alias("3", "4")));
        
        current.setAliasUrls(ImmutableSet.of("http://a.com/b", "http://b.com/c"));
        extracted.setAliasUrls(ImmutableSet.of("http://c.com/d"));
        
        Item merged = contentMerger.merge(current, extracted);
        
        assertEquals(3, merged.getAliases().size());
        assertEquals(3, merged.getAliasUrls().size());
    }
    
    @Test
    public void testReplaceAliasesMergeStrategy() {
        ContentMerger contentMerger = new ContentMerger(MergeStrategy.MERGE, MergeStrategy.KEEP, MergeStrategy.REPLACE);
        Item current = createItem("title", Publisher.METABROADCAST);
        Item extracted = createItem("title", Publisher.METABROADCAST);
        
        current.setAliases(ImmutableSet.of(new Alias("1", "2"), new Alias("2", "3")));
        extracted.setAliases(ImmutableSet.of(new Alias("3", "4")));
        
        current.setAliasUrls(ImmutableSet.of("http://a.com/b", "http://b.com/c"));
        extracted.setAliasUrls(ImmutableSet.of("http://c.com/d"));
        
        Item merged = contentMerger.merge(current, extracted);
        
        assertEquals("3", Iterables.getOnlyElement(merged.getAliases()).getNamespace());
        assertEquals("http://c.com/d", Iterables.getOnlyElement(merged.getAliasUrls()));
    }
    
    @Test
    public void testKeepAliasesMergeStrategy() {
        ContentMerger contentMerger = new ContentMerger(MergeStrategy.MERGE, MergeStrategy.KEEP, MergeStrategy.KEEP);
        Item current = createItem("title", Publisher.METABROADCAST);
        Item extracted = createItem("title", Publisher.METABROADCAST);
        
        current.setAliases(ImmutableSet.of(new Alias("1", "2"), new Alias("2", "3")));
        extracted.setAliases(ImmutableSet.of(new Alias("3", "4")));
        
        current.setAliasUrls(ImmutableSet.of("http://a.com/b", "http://b.com/c"));
        extracted.setAliasUrls(ImmutableSet.of("http://c.com/d"));
        
        Item merged = contentMerger.merge(current, extracted);
        
        assertEquals(2, merged.getAliases().size());
        assertEquals(2, merged.getAliasUrls().size());
        assertEquals("1", Iterables.getFirst(merged.getAliases(), null).getNamespace());
        assertEquals("http://a.com/b", Iterables.getFirst(merged.getAliasUrls(), null));
    }
=======
>>>>>>> 0c72450955f6981360612438e83d3e2da844f4ef

    private Item createItem(String title, Publisher publisher) {
        Item item = new Item("item", "curie", publisher);
Solution content
        assertEquals(extractedTitle, merged.getTitle());
        assertEquals(extractedEpisodeNum, merged.getEpisodeNumber());
    }
    
    @Test
    public void testAliasMergeStrategyInvoked() {
        AliasMergeStrategy aliasMergeStrategy = mock(AliasMergeStrategy.class);
        ContentMerger contentMerger = new ContentMerger(MergeStrategy.MERGE, MergeStrategy.KEEP, aliasMergeStrategy);
        
        Item current = createItem("title", Publisher.METABROADCAST);
        Item extracted = createItem("title", Publisher.METABROADCAST);
        when(aliasMergeStrategy.mergeAliases(current, extracted)).thenReturn(current);
        
        contentMerger.merge(current, extracted);
        verify(aliasMergeStrategy).mergeAliases(current, extracted);
    }
    
    @Test
    public void testMergeAliasesMergeStrategy() {
        ContentMerger contentMerger = new ContentMerger(MergeStrategy.MERGE, MergeStrategy.KEEP, MergeStrategy.MERGE);
        Item current = createItem("title", Publisher.METABROADCAST);
        Item extracted = createItem("title", Publisher.METABROADCAST);
        
        current.setAliases(ImmutableSet.of(new Alias("1", "2"), new Alias("2", "3")));
        extracted.setAliases(ImmutableSet.of(new Alias("3", "4")));
        
        current.setAliasUrls(ImmutableSet.of("http://a.com/b", "http://b.com/c"));
        extracted.setAliasUrls(ImmutableSet.of("http://c.com/d"));
        
        Item merged = contentMerger.merge(current, extracted);
        
        assertEquals(3, merged.getAliases().size());
        assertEquals(3, merged.getAliasUrls().size());
    }
    
    @Test
    public void testReplaceAliasesMergeStrategy() {
        ContentMerger contentMerger = new ContentMerger(MergeStrategy.MERGE, MergeStrategy.KEEP, MergeStrategy.REPLACE);
        Item current = createItem("title", Publisher.METABROADCAST);
        Item extracted = createItem("title", Publisher.METABROADCAST);
        
        current.setAliases(ImmutableSet.of(new Alias("1", "2"), new Alias("2", "3")));
        extracted.setAliases(ImmutableSet.of(new Alias("3", "4")));
        
        current.setAliasUrls(ImmutableSet.of("http://a.com/b", "http://b.com/c"));
        extracted.setAliasUrls(ImmutableSet.of("http://c.com/d"));
        
        Item merged = contentMerger.merge(current, extracted);
        
        assertEquals("3", Iterables.getOnlyElement(merged.getAliases()).getNamespace());
        assertEquals("http://c.com/d", Iterables.getOnlyElement(merged.getAliasUrls()));
    }
    
    @Test
    public void testKeepAliasesMergeStrategy() {
        ContentMerger contentMerger = new ContentMerger(MergeStrategy.MERGE, MergeStrategy.KEEP, MergeStrategy.KEEP);
        Item current = createItem("title", Publisher.METABROADCAST);
        Item extracted = createItem("title", Publisher.METABROADCAST);
        
        current.setAliases(ImmutableSet.of(new Alias("1", "2"), new Alias("2", "3")));
        extracted.setAliases(ImmutableSet.of(new Alias("3", "4")));
        
        current.setAliasUrls(ImmutableSet.of("http://a.com/b", "http://b.com/c"));
        extracted.setAliasUrls(ImmutableSet.of("http://c.com/d"));
        
        Item merged = contentMerger.merge(current, extracted);
        
        assertEquals(2, merged.getAliases().size());
        assertEquals(2, merged.getAliasUrls().size());
        assertEquals("1", Iterables.getFirst(merged.getAliases(), null).getNamespace());
        assertEquals("http://a.com/b", Iterables.getFirst(merged.getAliasUrls(), null));
    }

    private Item createItem(String title, Publisher publisher) {
        Item item = new Item("item", "curie", publisher);
File
ContentMergerTest.java
Developer's decision
Version 1
Kind of conflict
Annotation
Method declaration
Chunk
Conflicting content
        Mockito.when(testEvent.getCanonicalUri()).thenReturn("eventUri");
        Mockito.when(eventStore.fetch("eventUri")).thenReturn(Optional.absent());
        
<<<<<<< HEAD
        handler.handleMatch(matchData, OptaSportType.RUGBY);
=======
        handler.handle(matchData, OptaSportType.RUGBY_AVIVA_PREMIERSHIP);
>>>>>>> 0c72450955f6981360612438e83d3e2da844f4ef
        
        Mockito.verify(eventStore).createOrUpdate(testEvent);
    }
Solution content
        Mockito.when(testEvent.getCanonicalUri()).thenReturn("eventUri");
        Mockito.when(eventStore.fetch("eventUri")).thenReturn(Optional.absent());
        
        handler.handle(matchData, OptaSportType.RUGBY_AVIVA_PREMIERSHIP);
        
        Mockito.verify(eventStore).createOrUpdate(testEvent);
    }
File
EventParsingDataHandlerTest.java
Developer's decision
Version 2
Kind of conflict
Method invocation
Chunk
Conflicting content
    @Test
    public void testTimeZoneMapping() {
<<<<<<< HEAD
        DateTimeZone fetched = mapper.fetchTimeZone(OptaSportType.RUGBY);
=======
        Optional fetched = utility.fetchTimeZone(OptaSportType.RUGBY_AVIVA_PREMIERSHIP);
        
        assertEquals(DateTimeZone.forID("Europe/London"), fetched.get());
    }

    @Test
    public void testReturnsAbsentForUnmappedValue() {
        Optional fetched = utility.fetchTimeZone(null);
>>>>>>> 0c72450955f6981360612438e83d3e2da844f4ef
        
        assertEquals(DateTimeZone.forID("Europe/London"), fetched);
    }
Solution content
    @Test
    public void testTimeZoneMapping() {
        Optional fetched = utility.fetchTimeZone(OptaSportType.RUGBY_AVIVA_PREMIERSHIP);
        
        assertEquals(DateTimeZone.forID("Europe/London"), fetched.get());
    }

    @Test
    public void testReturnsAbsentForUnmappedValue() {
        Optional fetched = utility.fetchTimeZone(null);
        
        assertFalse(fetched.isPresent());
    }
File
OptaEventsUtilityTest.java
Developer's decision
Version 2
Kind of conflict
Annotation
Method invocation
Method signature
Variable
Chunk
Conflicting content
    
    @Test
    public void testTeamParsing() {
<<<<<<< HEAD
        OptaSportsTeam team = Iterables.getFirst(feedData.teams(), null);
        Optional parsed = handler.parseOrganisation(team, SPORT);
=======
        SportsTeam team = Iterables.getFirst(feedData.teams(), null);
        Optional parsed = handler.parseOrganisation(team);
>>>>>>> 0c72450955f6981360612438e83d3e2da844f4ef
        
        Organisation parsedTeam = parsed.get();
        
Solution content
    
    @Test
    public void testTeamParsing() {
        SportsTeam team = Iterables.getFirst(feedData.teams(), null);
        Optional parsed = handler.parseOrganisation(team);
        
        Organisation parsedTeam = parsed.get();
        
File
OptaSportsDataHandlerTest.java
Developer's decision
Version 2
Kind of conflict
Method invocation
Variable
Chunk
Conflicting content
        assertEquals("http://optasports.com/events/" + match.attributes().uId(), parsedEvent.getCanonicalUri());
        assertEquals("Northampton vs Gloucester", parsedEvent.title());
        assertEquals(Publisher.OPTA, parsedEvent.publisher());
<<<<<<< HEAD
        assertEquals(mapper.fetchLocationUrl(match.attributes().venue()).get(), parsedEvent.venue().getValue());
=======
        
        String location = Iterables.getOnlyElement(match.stats()).value();
        assertEquals(utility.createOrResolveVenue(location).get().getValue(), parsedEvent.venue().getValue());
        
>>>>>>> 0c72450955f6981360612438e83d3e2da844f4ef
        assertEquals(startTime, parsedEvent.startTime());
        assertEquals(startTime.plus(mapper.fetchDuration(SPORT)), parsedEvent.endTime());
        assertEquals(expectedTeamUris, transformToUris(parsedEvent.organisations()));
Solution content
        assertEquals("http://optasports.com/events/" + match.attributes().uId(), parsedEvent.getCanonicalUri());
        assertEquals("Northampton vs Gloucester", parsedEvent.title());
        assertEquals(Publisher.OPTA, parsedEvent.publisher());
        
        String location = Iterables.getOnlyElement(match.stats()).value();
        assertEquals(utility.createOrResolveVenue(location).get().getValue(), parsedEvent.venue().getValue());
        
        assertEquals(startTime, parsedEvent.startTime());
        assertEquals(startTime.plus(mapper.fetchDuration(SPORT)), parsedEvent.endTime());
        assertEquals(expectedTeamUris, transformToUris(parsedEvent.organisations()));
File
OptaSportsDataHandlerTest.java
Developer's decision
Version 2
Kind of conflict
Method invocation
Variable
Chunk
Conflicting content
    }

    }

    private void parseTeams() {
<<<<<<< HEAD
        for (OptaSportsTeam team : feedData.teams()) {
            handler.handleTeam(team, SPORT);
=======
        for (SportsTeam team : feedData.teams()) {
            handler.handle(team);
>>>>>>> 0c72450955f6981360612438e83d3e2da844f4ef
        }
Solution content
    }

    private void parseTeams() {
        for (SportsTeam team : feedData.teams()) {
            handler.handle(team);
        }
    }
File
OptaSportsDataHandlerTest.java
Developer's decision
Version 2
Kind of conflict
For statement
Method invocation