package at.ac.tuwien.inso.integration_tests;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;

@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureMockMvc
@ActiveProfiles("test")
@Transactional
public class StudentRecommendedCoursesTests {

    @Test
    public void studentRecommendedCoursesTest() {
        //TODO
    }

    @Test
    public void dismissCourseTest() {
        //TODO
    }
}

@@ -95,16 +95,79 @@
 unWith;%0A
+import org.springframework.beans.factory.annotation.Autowired;%0A
 import o
@@ -300,24 +300,120 @@
 ngBootTest;%0A
+import org.springframework.http.MediaType;%0Aimport org.springframework.test.annotation.Rollback;%0A
 import org.s
@@ -517,16 +517,69 @@
 Runner;%0A
+import org.springframework.test.web.servlet.MockMvc;%0A
 import o
@@ -636,16 +636,596 @@
 ional;%0A%0A
+import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf;%0Aimport static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.user;%0Aimport static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;%0Aimport static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;%0Aimport static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model;%0Aimport static org.springframework.test.web.servlet.result.MockMvcResultMatchers.redirectedUrl;%0A%0A
 @RunWith
@@ -1370,11 +1370,40 @@
 sts 
+extends AbstractCoursesTests
 %7B%0A%0A
+%0A
     
@@ -1456,32 +1456,228 @@
 sTest() 
-%7B%0A        //TODO
+throws Exception %7B%0A        mockMvc.perform(%0A                get(%22/student/recommended%22).with(user(studentUserAccount))%0A        ).andExpect(%0A                model().attributeExists(%22recommendedCourses%22)%0A        );
 %0A    %7D%0A%0A
@@ -1678,32 +1678,46 @@
    %7D%0A%0A    @Test%0A
+    @Rollback%0A
     public void 
@@ -1740,24 +1740,963 @@
 t() 
-%7B%0A        //TODO
+throws Exception %7B%0A        mockMvc.perform(%0A                post(%22/student/recommended%22)%0A                        .with(user(studentUserAccount))%0A                        .with(csrf())%0A                        .contentType(MediaType.APPLICATION_FORM_URLENCODED_VALUE)%0A                        .content(%22dismissedId=%22+calculusWS2016.getId())%0A        ).andExpect(%0A                result -%3E %7B%0A                    if (studentRepository.findByAccount(studentUserAccount).getDismissedCourses().size() %3C= 0) %7B%0A                        throw new Exception(%22Size of dismissed courses for student %22 + student + %22 is zero%22);%0A                    %7D%0A                    if (!studentRepository.findByAccount(studentUserAccount).getDismissedCourses().contains(calculusWS2016)) %7B%0A                        throw new Exception(%22Wrong dismissed course!%22);%0A                    %7D%0A                %7D%0A        ).andExpect(%0A                redirectedUrl(%22/student/recommended%22)%0A        );
 %0A   

Add tests for RecommendedCourses and Dismiss course