package org.slc.sli.ingestion.tool;

import java.io.File;
import java.io.IOException;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.slc.sli.ingestion.BatchJob;
import org.slc.sli.ingestion.FaultsReport;
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 Test for ZipValidation
 *
 * @author npandey
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "/spring/applicationContext.xml" })
public class ZipValidationTest {

    @Autowired
    private ZipValidation zipValidation;
    @Test
    public void testValidate() throws IOException {
        Resource zipFileResource = new ClassPathResource("Session1.zip");
        File zipFile = zipFileResource.getFile();
        BatchJob job = BatchJob.createDefault("Test.zip");
        FaultsReport fr = Mockito.mock(FaultsReport.class);
        File ctlFile = zipValidation.validate(zipFile, job);
        Assert.assertNotNull(ctlFile);
    }
    @Test
    public void testInValidZip() throws IOException {
        Resource zipFileResource = new ClassPathResource("SessionInValid.zip");
        File zipFile = zipFileResource.getFile();
        BatchJob job = BatchJob.createDefault("Test.zip");
        FaultsReport fr = Mockito.mock(FaultsReport.class);
        File ctlFile = zipValidation.validate(zipFile, job);
        Assert.assertNull(ctlFile);
    }
}

@@ -75,24 +75,25 @@
 OException;%0A
+%0A
 import org.j
@@ -165,118 +165,8 @@
 th;%0A
-import org.mockito.Mockito;%0Aimport org.slc.sli.ingestion.BatchJob;%0Aimport org.slc.sli.ingestion.FaultsReport;%0A
 impo
@@ -461,14 +461,126 @@
 er;%0A
+%0Aimport org.slc.sli.ingestion.BatchJob;%0Aimport org.slc.sli.ingestion.landingzone.validation.ZipFileValidator;%0A%0A
 /**%0A *
+ 
 Unit
@@ -632,17 +632,16 @@
 %0A *%0A */%0A
-%0A
 @RunWith
@@ -834,16 +834,21 @@
 dation;%0A
+    %0A
     @Tes
@@ -884,269 +884,439 @@
 e() 
-throws IOException %7B%0A        Resource zipFileResource = new ClassPathResource(%22Session1.zip%22);%0A        File zipFile = zipFileResource.getFile();%0A        BatchJob job = BatchJob.createDefault(%22Test.zip%22);%0A        FaultsReport fr = Mockito.mock(FaultsReport.class
+%7B%0A        %0A        ZipFileValidator zv = zipValidation.getValidator();%0A        Assert.assertNotNull(zv);%0A        %0A        Resource zipFileResource = new ClassPathResource(%22Session1.zip%22);%0A        File zipFile = null;%0A        %0A        try %7B%0A            zipFile = zipFileResource.getFile();%0A        %7D catch (IOException e) %7B%0A            e.printStackTrace();%0A        %7D%0A        %0A        BatchJob job = BatchJob.createDefault(%22Test.zip%22
 );%0A 
@@ -1416,24 +1416,29 @@
 ile);%0A    %7D%0A
+    %0A
     @Test%0A  
@@ -1471,27 +1471,8 @@
 ip()
- throws IOException
  %7B%0A 
@@ -1577,151 +1577,219 @@
 e = 
-zipFileResource.getFile();%0A        BatchJob job = BatchJob.createDefault(%22Test.zip%22);%0A        FaultsReport fr = Mockito.mock(FaultsReport.class
+null;%0A        %0A        try %7B%0A            zipFile = zipFileResource.getFile();%0A        %7D catch (IOException e) %7B%0A            e.printStackTrace();%0A        %7D%0A        BatchJob job = BatchJob.createDefault(%22Test.zip%22
 );%0A 

test refactoring