package model.person;

import static org.junit.Assert.*;
import controllers.MiniProjectController;
import demonstrateur.MiniProject;
import model.MiniProjectException;
import model.SaveLoad;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.GregorianCalendar;
import java.util.List;

/**
 * Created by neowutran on 22/01/14.
 */
public class BorrowTest {

    @BeforeClass
    public static void onlyOnce() {

        try {
            final Method m = MiniProject.class.getDeclaredMethod("loadConfigFile",
                    Path.class);
            m.setAccessible(true);
            m.invoke(null, Paths.get(MiniProject.FOLDER, MiniProject.CONFIG));

        } catch (IllegalAccessException | IllegalArgumentException
                | InvocationTargetException | NoSuchMethodException
                | SecurityException e) {
            e.printStackTrace();
        }

        try {

            SaveLoad.load(SaveLoad.DATA);
        } catch( final MiniProjectException e ) {
            MiniProjectController.LOGGER.severe( java.util.Arrays.toString( e
                    .getStackTrace( ) ) );
        }
    }



    @Test
    public void testCheckExistence() throws Exception {
    	
    	
    }

    @Test
    public void testSetState() throws Exception {

        //TODO

    }

}

@@ -126,16 +126,66 @@
 roject;%0A
+import model.BorrowState;%0Aimport model.Inventory;%0A
 import m
@@ -1528,23 +1528,565 @@
 n %7B%0A
-%0A        //TODO
+    %09model.person.Borrower b = new model.person.Borrower(%22test%22,%221110%22, %22student%22,%22test%22);%0A    %09List%3CString%3E liste = new ArrayList%3CString%3E();%0A    %09liste.add(%22ca072236-8f15-486d-93e4-2b21abb831a5%22);%0A    %09GregorianCalendar date1 = new GregorianCalendar();%0A    %09GregorianCalendar date2 = new GregorianCalendar();%0A    %09date2.add(GregorianCalendar.DAY_OF_YEAR,1);%0A    %09String id = b.borrow(liste, date1, date2);%0A    %09Inventory.findBorrowById(id).setState(BorrowState.ACCEPT, %22000%22);%0A    %09assertEquals(Inventory.findBorrowById(id).getState(), BorrowState.ACCEPT);
 %0A%0A  

test setState