package org.atlasapi.system.legacy;

import org.atlasapi.entity.Id;
import org.atlasapi.entity.util.Resolved;
import org.atlasapi.media.entity.Organisation;
import org.atlasapi.persistence.content.organisation.OrganisationStore;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

import static org.mockito.Mockito.when;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.hamcrest.Matchers.sameInstance;

import com.google.common.base.Optional;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.ListenableFuture;

@RunWith(MockitoJUnitRunner.class)
public class LegacyOrganisationResolverTest {
    private @Mock OrganisationStore store;
    private @Mock LegacyOrganisationTransformer transformer;
    private @Mock Organisation legacyOrganisation;
    private @Mock org.atlasapi.organisation.Organisation organisation;

    private LegacyOrganisationResolver resolver;

    @Before
    public void setUp() {
        resolver = new LegacyOrganisationResolver(store, transformer);
    }

    @Test
    public void testResolvingOrganisations() throws Throwable {
        when(transformer.apply(legacyOrganisation)).thenReturn(organisation);
        when(store.organisation(1l)).thenReturn(Optional.of(legacyOrganisation));
        ListenableFuture<Resolved<org.atlasapi.organisation.Organisation>> resources = resolver.resolveIds(ImmutableList.of(Id.valueOf(1L)));
        FluentIterable<org.atlasapi.organisation.Organisation> organisations = resources.get().getResources();
        assertThat(organisations.size(), is(1));
        assertThat(organisations.first().get(), sameInstance(organisation));
    }
}
@@ -30,16 +30,50 @@
 egacy;%0A%0A
+import org.atlasapi.entity.Alias;%0A
 import o
@@ -95,16 +95,16 @@
 ity.Id;%0A
-
 import o
@@ -411,16 +411,152 @@
 unner;%0A%0A
+import static org.hamcrest.Matchers.sameInstance;%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.mockito.Matchers.same;%0A
 import s
@@ -673,58 +673,8 @@
 hat;
-%0Aimport static org.hamcrest.Matchers.sameInstance;
 %0A%0Aim
@@ -1057,38 +1057,32 @@
 er;%0A    private 
-@Mock 
 Organisation leg
@@ -1110,22 +1110,16 @@
 private 
-@Mock 
 org.atla
@@ -1252,16 +1252,76 @@
 tUp() %7B%0A
+        transformer =  new LegacyOrganisationTransformer();%0A
         
@@ -1476,75 +1476,202 @@
     
-when(transformer.apply(legacyOrganisation)).thenReturn(organisation
+organisation = new org.atlasapi.organisation.Organisation();%0A        legacyOrganisation = new Organisation();%0A        legacyOrganisation.setAlternativeTitles(ImmutableList.of(%22title1%22, %22title2%22)
 );%0A 
@@ -2103,35 +2103,77 @@
 et()
-, sameInstance(organisation
+.getAlternativeTitles(), is(legacyOrganisation.getAlternativeTitles()
 ));%0A

fix test for organisation resolver