package at.ac.tuwien.inso.integration_tests;

import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.user;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model;

import org.junit.Test;

public class LecturerCoursesTests extends AbstractCoursesTests {

    @Test
    public void itListsAllCoursesForCurrentSemesterAndLecturer() throws Exception {

        mockMvc.perform(
                get("/lecturer/courses").with(user(user1))
        ).andExpect(
                model().attribute("allCourses", expectedCoursesForLecturer1)
        );
    }

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

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

@@ -39,16 +39,111 @@
 tests;%0A%0A
+import static junit.framework.TestCase.assertFalse;%0Aimport static org.junit.Assert.assertTrue;%0A
 import s
@@ -423,29 +423,172 @@
 el;%0A
-%0Aimport org.junit.Tes
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;%0A%0Aimport org.junit.Test;%0Aimport org.springframework.test.web.servlet.MvcResul
 t;%0A%0A
@@ -996,98 +996,1711 @@
 t() 
-%7B%0A        //TODO%0A    %7D%0A%0A    @Test%0A    public void tagsForCourseJsonTest() %7B%0A        //TODO
+throws Exception %7B%0A%0A        // given 5 tags%0A%0A        MvcResult result =  mockMvc.perform(%0A                get(%22/lecturer/courses/json/tags%22)%0A                        .with(user(user1))%0A        ).andExpect((status().isOk())%0A        ).andReturn();%0A%0A        // the response should contain all these tags%0A        assertTrue(result.getResponse().getContentAsString().contains(tag1.getName()));%0A        assertTrue(result.getResponse().getContentAsString().contains(tag2.getName()));%0A        assertTrue(result.getResponse().getContentAsString().contains(tag3.getName()));%0A        assertTrue(result.getResponse().getContentAsString().contains(tag4.getName()));%0A        assertTrue(result.getResponse().getContentAsString().contains(tag5.getName()));%0A    %7D%0A%0A    @Test%0A    public void tagsForCourseJsonTest() throws Exception %7B%0A%0A        // given 5 tags%0A        // given course ase with 2 of these tags%0A        aseWS2016.addTags(tag3, tag5);%0A%0A        MvcResult result =  mockMvc.perform(%0A                get(%22/lecturer/courses/json/tags%22)%0A                        .with(user(user1))%0A                        .param(%22courseId%22, aseWS2016.getId().toString())%0A        ).andExpect((status().isOk())%0A        ).andReturn();%0A%0A        // the response should contain only these 2 tags%0A        assertFalse(result.getResponse().getContentAsString().contains(tag1.getName()));%0A        assertFalse(result.getResponse().getContentAsString().contains(tag2.getName()));%0A        assertTrue(result.getResponse().getContentAsString().contains(tag3.getName()));%0A        assertFalse(result.getResponse().getContentAsString().contains(tag4.getName()));%0A        assertTrue(result.getResponse().getContentAsString().contains(tag5.getName()));
 %0A   

add 2 tests