package org.onap.dmaap.service;
 
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+import static org.mockito.Matchers.any;
+
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.Vector;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-
 import org.mockito.InjectMocks;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.onap.dmaap.dmf.mr.CambriaApiException;
-
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.when;
-
+import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
+import org.onap.dmaap.dmf.mr.service.AdminService;
+import org.onap.dmaap.dmf.mr.utils.ConfigurationReader;
 import org.powermock.api.mockito.PowerMockito;
 import org.powermock.core.classloader.annotations.PrepareForTest;
 import org.powermock.modules.junit4.PowerMockRunner;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
-
-import java.io.IOException;
-import java.util.Enumeration;
-import org.onap.dmaap.dmf.mr.service.AdminService;
 import com.att.nsa.configs.ConfigDbException;
 import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;
-import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
-import org.onap.dmaap.dmf.mr.utils.ConfigurationReader;
-import org.powermock.core.classloader.annotations.PrepareForTest;
 
 @RunWith(PowerMockRunner.class)
 @PrepareForTest({ ServiceUtil.class })
 
        @Test
        public void testGetBlacklist() throws CambriaApiException, AccessDeniedException {
+               Vector headers = new Vector();
+               headers.add("Content-type");
+               Enumeration headerNms = headers.elements();
 
                when(dmaapContext.getRequest()).thenReturn(httpServReq);
-               when(httpServReq.getHeaderNames()).thenReturn(headerNames);
+               when(httpServReq.getHeaderNames()).thenReturn(headerNms);
                when(headerNames.nextElement()).thenReturn("key");
                when(httpServReq.getHeader("key")).thenReturn("value");
 
 
        }
        
-       //@Test
+       @Test
        public void testGetBlacklist_error() throws CambriaApiException, AccessDeniedException,IOException {
                
-               PowerMockito.mockStatic(ServiceUtil.class);
-               PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaaPContext);
-               PowerMockito.doThrow(new IOException("error")).when(adminService).getBlacklist(dmaaPContext);
+               PowerMockito.doThrow(new IOException("error")).when(adminService).getBlacklist(any(DMaaPContext.class));
                when(dmaapContext.getRequest()).thenReturn(httpServReq);
                when(httpServReq.getHeaderNames()).thenReturn(headerNames);
                when(headerNames.nextElement()).thenReturn("key");
                when(httpServReq.getHeader("key")).thenReturn("value");
-               when(headerNames.hasMoreElements()).thenReturn(false);
+
                try {
                adminRestService.getBlacklist();
                }
                catch (CambriaApiException e) {
                        assertTrue(true);
                }
-
        }
        
-       ////@Test
+       @Test
        public void testGetBlacklist_error1() throws CambriaApiException, AccessDeniedException,IOException {
                
-               PowerMockito.mockStatic(ServiceUtil.class);
-               PowerMockito.when(ServiceUtil.getDMaaPContext(configReader, httpServReq, response)).thenReturn(dmaaPContext);
-               PowerMockito.doThrow(new AccessDeniedException("error")).when(adminService).getBlacklist(dmaaPContext);
+               PowerMockito.doThrow(new AccessDeniedException("error")).when(adminService).getBlacklist(any(DMaaPContext.class));
                when(dmaapContext.getRequest()).thenReturn(httpServReq);
                when(httpServReq.getHeaderNames()).thenReturn(headerNames);
                when(headerNames.nextElement()).thenReturn("key");
                when(httpServReq.getHeader("key")).thenReturn("value");
-               when(headerNames.hasMoreElements()).thenReturn(false);
+
                try {
                adminRestService.getBlacklist();
                }
 
                assertTrue(true);
        }
        
+       @Test
+       public void testAllowOrRejectChunked() throws Exception {
+               PowerMockito.when(req.getHeader("Transfer-Encoding")).thenReturn("chunked");
+               PowerMockito.when(req.getHeader("Content-Length")).thenReturn("1027");
+               System.setProperty("maxcontentlength", "1024");
+
+               interceptor.allowOrReject(req, res, map);
+               assertTrue(true);
+       }       
+       
+       @Test
+       public void testAllowOrRejectNullTransferEncoding() throws Exception {
+               PowerMockito.when(req.getHeader("Transfer-Encoding")).thenReturn(null);
+               PowerMockito.when(req.getHeader("Content-Length")).thenReturn("1027");
+               System.setProperty("maxcontentlength", "1024");
+
+               interceptor.allowOrReject(req, res, map);
+               assertTrue(true);
+       }               
        //@Test(expected = NullPointerException.class) 
        public void testAllowOrRejectWithException() throws Exception {
                PowerMockito.when(req.getHeader("Transfer-Encoding")).thenThrow(new NumberFormatException());