Commit bc1576da by apoorvnaik

UT fixes

parent 9d6ad848
......@@ -17,7 +17,6 @@
*/
package org.apache.atlas.services;
import org.apache.atlas.TestModules.TestOnlyModule;
import org.apache.atlas.discovery.EntityDiscoveryService;
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.typedef.AtlasEntityDef;
......@@ -25,14 +24,12 @@ import org.apache.atlas.type.AtlasTypeRegistry;
import org.apache.commons.lang.StringUtils;
import org.powermock.reflect.Whitebox;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
@Guice(modules = TestOnlyModule.class)
public class EntityDiscoveryServiceTest {
private final String TEST_TYPE = "test";
......
......@@ -24,6 +24,7 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.verify;
......@@ -42,13 +43,15 @@ public class AtlasCSRFPreventionFilterTest {
// Objects to verify interactions based on request
HttpServletResponse mockRes = Mockito.mock(HttpServletResponse.class);
PrintWriter mockWriter = Mockito.mock(PrintWriter.class);
Mockito.when(mockRes.getWriter()).thenReturn(mockWriter);
FilterChain mockChain = Mockito.mock(FilterChain.class);
// Object under test
AtlasCSRFPreventionFilter filter = new AtlasCSRFPreventionFilter();
filter.doFilter(mockReq, mockRes, mockChain);
verify(mockRes, atLeastOnce()).sendError(HttpServletResponse.SC_BAD_REQUEST, EXPECTED_MESSAGE);
verify(mockRes, atLeastOnce()).setStatus(HttpServletResponse.SC_BAD_REQUEST);
Mockito.verifyZeroInteractions(mockChain);
}
......@@ -96,6 +99,8 @@ public class AtlasCSRFPreventionFilterTest {
// Objects to verify interactions based on request
HttpServletResponse mockRes = Mockito.mock(HttpServletResponse.class);
PrintWriter mockWriter = Mockito.mock(PrintWriter.class);
Mockito.when(mockRes.getWriter()).thenReturn(mockWriter);
FilterChain mockChain = Mockito.mock(FilterChain.class);
// Object under test
......@@ -137,6 +142,9 @@ public class AtlasCSRFPreventionFilterTest {
// Objects to verify interactions based on request
HttpServletResponse mockRes = Mockito.mock(HttpServletResponse.class);
PrintWriter mockWriter = Mockito.mock(PrintWriter.class);
Mockito.when(mockRes.getWriter()).thenReturn(mockWriter);
FilterChain mockChain = Mockito.mock(FilterChain.class);
// Object under test
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment