// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.sps;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

@RunWith(JUnit4.class)
public final class SchedulingTest {

    @Test
    public void noFailTest() {
        Assert.assertEquals(true, true);
    }

}

@@ -607,16 +607,73 @@
 e.sps;%0A%0A
+import java.io.StringWriter;%0Aimport java.io.PrintWriter;%0A
 import o
@@ -782,148 +782,2494 @@
 t4;%0A
-%0A@RunWith(JUnit4.class)%0Apublic final class SchedulingTest %7B%0A%0A    @Test%0A    public void noFailTest() %7B%0A        Assert.assertEquals(true, true
+import static org.mockito.Mockito.*;%0Aimport javax.servlet.http.HttpServlet;%0Aimport javax.servlet.http.HttpServletRequest;%0Aimport javax.servlet.http.HttpServletResponse;%0Aimport javax.servlet.*;%0Aimport com.google.sps.servlets.SchedulingServlet;%0Aimport com.google.sps.data.SampleData;%0Aimport com.google.sps.data.TutorSession;%0A%0A@RunWith(JUnit4.class)%0Apublic final class SchedulingTest %7B%0A%0A    @Test%0A    public void testDoPost() throws Exception %7B%0A        HttpServletRequest request = mock(HttpServletRequest.class);       %0A        HttpServletResponse response = mock(HttpServletResponse.class);%0A        ServletConfig config = mock(ServletConfig.class);%0A%0A        when(request.getParameter(%22tutorID%22)).thenReturn(%22btrevisan@google.com%22);%0A        when(request.getParameter(%22start%22)).thenReturn(%22480%22);%0A        when(request.getParameter(%22end%22)).thenReturn(%22600%22);%0A        when(request.getParameter(%22studentEmail%22)).thenReturn(%22test@gmail.com%22);%0A        when(request.getParameter(%22subtopics%22)).thenReturn(%22algebra%22);%0A        when(request.getParameter(%22questions%22)).thenReturn(%22How does it work?%22);%0A%0A        StringWriter stringWriter = new StringWriter();%0A        PrintWriter writer = new PrintWriter(stringWriter);%0A        when(response.getWriter()).thenReturn(writer);%0A        when(request.getContentType()).thenReturn(%22application/json%22);%0A%0A        SchedulingServlet servlet = new SchedulingServlet();%0A        servlet.init(config);%0A        servlet.doPost(request, response);%0A%0A        verify(request, atLeast(1)).getParameter(%22tutorID%22);%0A        verify(request, atLeast(1)).getParameter(%22start%22);%0A        verify(request, atLeast(1)).getParameter(%22end%22);%0A        verify(request, atLeast(1)).getParameter(%22studentEmail%22);%0A        verify(request, atLeast(1)).getParameter(%22subtopics%22);%0A        verify(request, atLeast(1)).getParameter(%22questions%22);%0A%0A        writer.flush();%0A        // Tutoring session should have been scheduled%0A        Assert.assertTrue(stringWriter.toString().contains(%22%7B%5C%22studentEmail%5C%22:%5C%22test@gmail.com%5C%22,%5C%22tutorEmail%5C%22:%5C%22btrevisan@google.com%5C%22,%5C%22subtopics%5C%22:%5C%22algebra%5C%22,%5C%22questions%5C%22:%5C%22How does it work?%5C%22,%5C%22timeslot%5C%22:%7B%5C%22start%5C%22:480,%5C%22duration%5C%22:120,%5C%22end%5C%22:600%7D%7D%22));%0A        // Previously available timeslot should no longer be available%0A        Assert.assertFalse(stringWriter.toString().contains(%22%7B%5C%22name%5C%22:%5C%22Bernardo Eilert Trevisan%5C%22,%5C%22email%5C%22:%5C%22btrevisan@google.com%5C%22,%5C%22skills%5C%22:%5B%5C%22English%5C%22,%5C%22Physics%5C%22%5D,%5C%22availability%5C%22:%5B%7B%5C%22start%5C%22:480,%5C%22duration%5C%22:120,%5C%22end%5C%22:600%7D%5D%22)
 );%0A 

Add java tests to scheduling servlet