package org.slc.sli.ingestion.tool;

import static org.junit.Assert.fail;

import java.io.IOException;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

/**
 * Unit Tests for ValidationController
 *
 * @author tke
 *
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "/spring/applicationContext.xml" })
public class ValidationControllerTest {

    final String controlFileName = "test/MainControlFile.ctl";
    final String zipFileName = "controller_test/zipFile/Session1.zip";

    @Autowired
    private ValidationController validationController;

    /**
     * Test zip file validation
     */
    @Test
    public void testDoValidationZipFile() {
        Resource zipFileResource = new ClassPathResource(zipFileName);
        try {
           validationController.doValidation(zipFileResource.getFile().getParent());
        } catch (IOException e) {
            fail("IO exception");
        }
        //TODO: add assert
    }

    /**
     * Test invalid zip file
     */
    @Test
    public void testDovalidationInvalidZip() {
        Resource invalidFileResource = new ClassPathResource("controller_test/invalidZip/SessionInValid.zip");
        try {
           validationController.doValidation(invalidFileResource.getFile().getParent());
        } catch (IOException e) {
            fail("IO exception");
        }
        //TODO: add assert
    }

    /**
     * Test invalid control file
     */
    @Test
    public void testDovalidationInvalidCtl() {
        Resource invalidFileResource = new ClassPathResource("controller_test/invalidCtl/MainControlFile.ctl");
        try {
           validationController.doValidation(invalidFileResource.getFile().getParent());
        } catch (IOException e) {
            fail("IO exception");
        }
        //TODO: add assert
    }


    /**
     * Test situation when there are multiple zip and control files
     * in the same folder
     */

    @Test
    public void testDovalidationInvalid() {
        Resource invalidFileResource = new ClassPathResource("controller_test/invalid/Session1.zip");
        try {
           validationController.doValidation(invalidFileResource.getFile().getParent());
        } catch (IOException e) {
            fail("IO exception");
        }
        //TODO: add assert
    }

    /**
     * Test control file validation
     */
    @Test
    public void testDoValidationCtrFile() {
        Resource ctlFileResource = new ClassPathResource(controlFileName);
        try {
            validationController.doValidation(ctlFileResource.getFile().getParent());
        } catch (IOException e) {
            fail("IO exception");
        }
        //TODO: add assert
    }

}

@@ -1693,442 +1693,8 @@
  %7D%0A%0A
-    /**%0A     * Test invalid control file%0A     */%0A    @Test%0A    public void testDovalidationInvalidCtl() %7B%0A        Resource invalidFileResource = new ClassPathResource(%22controller_test/invalidCtl/MainControlFile.ctl%22);%0A        try %7B%0A           validationController.doValidation(invalidFileResource.getFile().getParent());%0A        %7D catch (IOException e) %7B%0A            fail(%22IO exception%22);%0A        %7D%0A        //TODO: add assert%0A    %7D%0A%0A%0A
     

drop unnecessary unit test