/*
 * Copyright 2012 Shared Learning Collaborative, LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.slc.sli.sif.translation;

import java.util.ArrayList;
import java.util.List;

import openadk.library.ADK;
import openadk.library.ADKException;
import openadk.library.common.PhoneNumberList;
import openadk.library.common.PhoneNumberType;
import openadk.library.student.LEAInfo;
import openadk.library.student.SchoolInfo;
import openadk.library.student.Title1Status;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.slc.sli.sif.domain.converter.AddressListConverter;
import org.slc.sli.sif.domain.converter.OperationalStatusConverter;
import org.slc.sli.sif.domain.converter.PhoneNumberListConverter;
import org.slc.sli.sif.domain.slientity.InstitutionTelephone;
import org.slc.sli.sif.domain.slientity.LEAEntity;

public class LEAInfoTranslationTaskTest
{
    @InjectMocks
    private final LEAInfoTranslationTask translator = new LEAInfoTranslationTask();

    @Mock
    AddressListConverter mockAddressConverter;

    @Mock
    OperationalStatusConverter operationalStatusConverter;

    @Mock
    PhoneNumberListConverter mockPhoneNumberListConverter;

    @Before
    public void beforeTests() {
        try {
            ADK.initialize();
        } catch (ADKException e) {
            e.printStackTrace();
        }
        MockitoAnnotations.initMocks(this);
    }

    @Test
    public void testNotNull() {
        List<LEAEntity> result = translator.translate(new LEAInfo());
        Assert.assertNotNull("Result was null", result);
        Assert.assertEquals(1, result.size());
    }

//    @Test
    public void testBasicFields() {
          SchoolInfo info = new SchoolInfo();
    
          String stateOrgId = "stateOrgId";
          info.setStateProvinceId(stateOrgId);
    
          String schoolName = "schoolName";
          info.setSchoolName(schoolName);
    
          String schoolUrl = "schoolUrl";
          info.setSchoolURL(schoolUrl);
    
          info.setTitle1Status(Title1Status.SCHOOLWIDE);
    
          List<LEAEntity> result = translator.translate(info);
          Assert.assertEquals(1, result.size());
          LEAEntity entity = result.get(0);
    
          Assert.assertEquals(stateOrgId, entity.getStateOrganizationId());
          Assert.assertEquals(schoolName, entity.getNameOfInstitution());
          Assert.assertEquals(schoolUrl, entity.getWebSite());
          Assert.assertEquals("School", entity.getOrganizationCategories().get(0));
          Assert.assertEquals(schoolUrl, entity.getWebSite());
      }

    @Test
    public void testPhoneNumbers() {
        PhoneNumberList phoneNumberList = new PhoneNumberList();
        LEAInfo info = new LEAInfo();
        info.setPhoneNumberList(phoneNumberList);

        List<InstitutionTelephone> telephones = new ArrayList<InstitutionTelephone>();

        Mockito.when(mockPhoneNumberListConverter.convert(phoneNumberList)).thenReturn(telephones);

        List<LEAEntity> result = translator.translate(info);
        Assert.assertEquals(1, result.size());
        LEAEntity entity = result.get(0);

        Mockito.verify(mockPhoneNumberListConverter).convert(phoneNumberList);
        Assert.assertEquals(telephones, entity.getTelephone());
    }


}

@@ -2091,16 +2091,47 @@
 otNull()
+ throws SifTranslationException
  %7B%0A     
@@ -2310,973 +2310,8 @@
  %7D%0A%0A
-//    @Test%0A    public void testBasicFields() %7B%0A          SchoolInfo info = new SchoolInfo();%0A    %0A          String stateOrgId = %22stateOrgId%22;%0A          info.setStateProvinceId(stateOrgId);%0A    %0A          String schoolName = %22schoolName%22;%0A          info.setSchoolName(schoolName);%0A    %0A          String schoolUrl = %22schoolUrl%22;%0A          info.setSchoolURL(schoolUrl);%0A    %0A          info.setTitle1Status(Title1Status.SCHOOLWIDE);%0A    %0A          List%3CLEAEntity%3E result = translator.translate(info);%0A          Assert.assertEquals(1, result.size());%0A          LEAEntity entity = result.get(0);%0A    %0A          Assert.assertEquals(stateOrgId, entity.getStateOrganizationId());%0A          Assert.assertEquals(schoolName, entity.getNameOfInstitution());%0A          Assert.assertEquals(schoolUrl, entity.getWebSite());%0A          Assert.assertEquals(%22School%22, entity.getOrganizationCategories().get(0));%0A          Assert.assertEquals(schoolUrl, entity.getWebSite());%0A      %7D%0A%0A
     
@@ -2350,16 +2350,47 @@
 umbers()
+ throws SifTranslationException
  %7B%0A     

Add unti test for LEAInfoTranslationTask