package pingis.services;

import pingis.entities.Challenge;
import pingis.entities.Task;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
import pingis.repositories.TaskRepository;
import pingis.repositories.ChallengeRepository;

@Component
public class DataLoader implements ApplicationRunner {
//CHECKSTYLE:OFF
    private ChallengeRepository cr;
    private TaskRepository tr;

    @Autowired
    public DataLoader(ChallengeRepository cr, TaskRepository tr) {
        this.cr = cr;
        this.tr = tr;
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        
    
          // Challenge 1 Description        
        Challenge challenge1 = new Challenge(
                "Calculator", "Test and implement a simple text-based calculator.");

        // Tasks
        Task task1 = new Task(
                "Test multiplication", "Write a JUnit test case that tests the multiplication method for two integers. \n"
                + "Method should take two integers as arguments and return the product of those as an integer.");
        task1.setCode(
                "@Test\npublic void testMultiplication() {\n//TODO: implement this\n\n}");
        task1.setLevel(1);

        
        Task task2 = new Task(
                "Test addition", "Write a JUnit test case that tests the addition method for two integers. \n"
                + "Method should take two integers as arguments and return the addition of those as an integer.");
        task2.setCode(
                "@Test\npublic void testAddition() {\n//TODO: implement this\n\n}");
        task2.setLevel(1);

        
        Task task3 = new Task(
                "Test substraction", "Write a JUnit test case that tests the substraction method for two integers. \n"
                + "Method should take two integers as arguments and return the substraction of the latter from the former as integer.");
        task3.setCode(
                "@Test\npublic void testSubstraction() {\n//TODO: implement this\n\n}");
        task3.setLevel(1);

        
        Task task4 = new Task(
                "Test integer division", "Write a JUnit test case that tests division method for two integers. \n"
                + "Method should take two integers (former as dividend and latter as divisor) as arguments and return the quotient as integer.");
        task4.setCode(
                "@Test\npublic void testIntegerDivision() {\n//TODO: implement this\n\n}");
        task4.setLevel(2);

        
        Task task5 = new Task(
                "Test integer modulo", "Write a JUnit test case that tests the modulo method for two integers. \n"
                + "Method should take two integers (former as dividend and latter as divisor) as arguments and return the remainder of the division as integer.");
        task5.setCode(
                "@Test\npublic void testIntegerModulo() {\n//TODO: implement this\n\n}");
        task5.setLevel(2);

        
        Task task6 = new Task(
                "Test integer exponentiation", "Write a JUnit test case that tests the exponentiation of two integers. \n"
                + "Method should take two integers (former as base and latter as exponent) as arguments and return the product of the exponentiation as integer.");
        task6.setCode(
                "@Test\npublic void testIntegerExponentiation() {\n//TODO: implement this\n\n}");
        task6.setLevel(2);

        
        Task task7 = new Task(
                "Test euclidean algorithm", "Write a JUnit test case that tests euclidean algorithm. \n"
                + "Method should take two integers as arguments and return their greatest common divisor.");
        task7.setCode(
                "@Test\npublic void testIntegerEuclideanAlgorithm() {\n//TODO: implement this\n\n}");
        task7.setLevel(10);
        // Save tasks

        challenge1.addTask(task1);
        challenge1.addTask(task2);
        task1.setChallenge(challenge1);
        task2.setChallenge(challenge1);
        cr.save(challenge1);
        tr.save(task1);
        tr.save(task2);
        
        // Save Challenge
    
    
        
    }
//CHECKSTYLE:ON
}

@@ -773,24 +773,31 @@
    %0A        
+%0A      
   // Challen
@@ -951,17 +951,33 @@
 ator.%22);
-%0A
+        %0A        
 %0A       
@@ -1148,32 +1148,40 @@
                 
+        
 + %22Method should
@@ -1367,32 +1367,40 @@
 ent this%5Cn%5Cn%7D%22);
+        
 %0A        task1.s
@@ -1403,33 +1403,32 @@
 k1.setLevel(1);%0A
-%0A
         %0A       
@@ -1570,32 +1570,40 @@
                 
+        
 + %22Method should
@@ -1812,33 +1812,32 @@
 k2.setLevel(1);%0A
-%0A
         %0A       
@@ -1833,2221 +1833,8 @@
    %0A
-        Task task3 = new Task(%0A                %22Test substraction%22, %22Write a JUnit test case that tests the substraction method for two integers. %5Cn%22%0A                + %22Method should take two integers as arguments and return the substraction of the latter from the former as integer.%22);%0A        task3.setCode(%0A                %22@Test%5Cnpublic void testSubstraction() %7B%5Cn//TODO: implement this%5Cn%5Cn%7D%22);%0A        task3.setLevel(1);%0A%0A        %0A        Task task4 = new Task(%0A                %22Test integer division%22, %22Write a JUnit test case that tests division method for two integers. %5Cn%22%0A                + %22Method should take two integers (former as dividend and latter as divisor) as arguments and return the quotient as integer.%22);%0A        task4.setCode(%0A                %22@Test%5Cnpublic void testIntegerDivision() %7B%5Cn//TODO: implement this%5Cn%5Cn%7D%22);%0A        task4.setLevel(2);%0A%0A        %0A        Task task5 = new Task(%0A                %22Test integer modulo%22, %22Write a JUnit test case that tests the modulo method for two integers. %5Cn%22%0A                + %22Method should take two integers (former as dividend and latter as divisor) as arguments and return the remainder of the division as integer.%22);%0A        task5.setCode(%0A                %22@Test%5Cnpublic void testIntegerModulo() %7B%5Cn//TODO: implement this%5Cn%5Cn%7D%22);%0A        task5.setLevel(2);%0A%0A        %0A        Task task6 = new Task(%0A                %22Test integer exponentiation%22, %22Write a JUnit test case that tests the exponentiation of two integers. %5Cn%22%0A                + %22Method should take two integers (former as base and latter as exponent) as arguments and return the product of the exponentiation as integer.%22);%0A        task6.setCode(%0A                %22@Test%5Cnpublic void testIntegerExponentiation() %7B%5Cn//TODO: implement this%5Cn%5Cn%7D%22);%0A        task6.setLevel(2);%0A%0A        %0A        Task task7 = new Task(%0A                %22Test euclidean algorithm%22, %22Write a JUnit test case that tests euclidean algorithm. %5Cn%22%0A                + %22Method should take two integers as arguments and return their greatest common divisor.%22);%0A        task7.setCode(%0A                %22@Test%5Cnpublic void testIntegerEuclideanAlgorithm() %7B%5Cn//TODO: implement this%5Cn%5Cn%7D%22);%0A        task7.setLevel(10);%0A
     
@@ -1851,16 +1851,24 @@
 e tasks%0A
+        
 %0A       

Revert "Added dummy-data for Challenge 1 (Calculator)"