Commit a31ea2b4 authored by Komal Makkar's avatar Komal Makkar
Browse files

adding test file

parent ad9a0a3f
package org.opengroup.osdu.notification.provider.azure.util;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.opengroup.osdu.notification.provider.interfaces.IPubsubHandshakeHandler;
import org.opengroup.osdu.notification.provider.interfaces.IPubsubRequestBodyExtractor;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import static org.mockito.Mockito.*;
@RunWith(MockitoJUnitRunner.class)
public class HandshakeFilterTest {
@Mock
private IPubsubRequestBodyExtractor requestBodyExtractor;
@Mock
private IPubsubHandshakeHandler handshakeHandler;
@Mock
private HttpServletRequest httpServletRequest;
@Mock
private ServletResponse servletResponse;
@Mock
private FilterChain filterChain;
@InjectMocks
private HandshakeFilter sut;
@Test
public void should_CallFiltersIfNotHandshake() throws IOException, ServletException {
doReturn("records-changed").when(httpServletRequest).getServletPath();
doReturn(false).when(this.requestBodyExtractor).isHandshakeRequest();
this.sut.doFilter(this.httpServletRequest, this.servletResponse, this.filterChain);
verify(this.filterChain, times(1)).doFilter(httpServletRequest, servletResponse);
}
}
Supports Markdown
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