title: java.lang.VerifyError in while running a JUNIT mockito and powermock for maven project
body: <p>This is the exception when I am running <code>clean cobertura:cobertura</code>. 
  I tried running this as JUNIT from eclipse but still no luck.<br>
  I am using the following dependencies for My project.</p>
  
  <ul>
  <li>org.mockito mockito-all 1.10.19</li>
  <li>org.mockito mockito-core 1.10.19</li>
  <li>junit junit 4.11</li>
  <li>junit-addons junit-addons 1.4</li>
  <li>org.powermock powermock-module-junit4 1.6.2</li>
  <li>org.powermock powermock-api-mockito 1.6.2</li>
  </ul>
  
  <p>POM file changes:</p>
  
  <pre><code>&lt;cobertura-maven-plugin.version&gt;2.6&lt;/cobertura-maven-plugin.version&gt;
  &lt;maven-surefire-plugin.version&gt;2.12.2&lt;/maven-surefire-plugin.version&gt;
              &lt;plugin&gt;
                      &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
                      &lt;artifactId&gt;cobertura-maven-plugin&lt;/artifactId&gt;
                      &lt;version&gt;${cobertura-maven-plugin.version}&lt;/version&gt;
                      &lt;configuration&gt;
                          &lt;formats&gt;
                              &lt;!-- Comment out any output formats you dont need (will put in a profile later) --&gt;
                              &lt;format&gt;html&lt;/format&gt;       
                              &lt;!-- &lt;format&gt;xml&lt;/format&gt;--&gt;
                          &lt;/formats&gt;
                          &lt;outputDirectory&gt;${project.build.directory}/coverage-reports&lt;/outputDirectory&gt;      
                          &lt;!-- &lt;instrumentation&gt;
                              &lt;ignoreTrivial&gt;true&lt;/ignoreTrivial&gt;         
                              &lt;ignores&gt;
                                  &lt;ignore&gt;org.slf4j.Logger.*&lt;/ignore&gt;     
                              &lt;/ignores&gt;
                              &lt;excludes&gt;
                                  &lt;exclude&gt;**/Example.class&lt;/exclude&gt;     
                              &lt;/excludes&gt;
                          &lt;/instrumentation&gt; --&gt;
                      &lt;/configuration&gt;
                      &lt;executions&gt;
                          &lt;!-- &lt;execution&gt;
                              &lt;id&gt;clean-coverage-report&lt;/id&gt;
                              &lt;phase&gt;clean&lt;/phase&gt;            
                              &lt;goals&gt;
                                  &lt;goal&gt;clean&lt;/goal&gt;
                              &lt;/goals&gt;
                          &lt;/execution&gt; --&gt;
                          &lt;execution&gt;
                              &lt;id&gt;create-coverage-report&lt;/id&gt;
                              &lt;phase&gt;package&lt;/phase&gt;          
                              &lt;goals&gt;
                                  &lt;goal&gt;cobertura&lt;/goal&gt;
                              &lt;/goals&gt;
                          &lt;/execution&gt;
                      &lt;/executions&gt;
                  &lt;/plugin&gt;
                  &lt;plugin&gt;
                      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                      &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
                      &lt;version&gt;${maven-surefire-plugin.version}&lt;/version&gt;
                      &lt;configuration&gt;
                          &lt;skipTests&gt;false&lt;/skipTests&gt;
                          &lt;testFailureIgnore&gt;true&lt;/testFailureIgnore&gt;
                          &lt;forkMode&gt;once&lt;/forkMode&gt;
                          &lt;argLine&gt;-Xms512m -Xmx1024m -XX:MaxPermSize=512m&lt;/argLine&gt;
                      &lt;/configuration&gt;
                  &lt;/plugin&gt;
                  &lt;!-- test dependencies --&gt;
              &lt;!-- Mocking &amp; Testing Code --&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.mockito&lt;/groupId&gt;
                  &lt;artifactId&gt;mockito-all&lt;/artifactId&gt;
                  &lt;version&gt;1.10.19&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.mockito&lt;/groupId&gt;
                  &lt;artifactId&gt;mockito-core&lt;/artifactId&gt;
                  &lt;version&gt;1.10.19&lt;/version&gt;
                  &lt;scope&gt;test&lt;/scope&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;junit&lt;/groupId&gt;
                  &lt;artifactId&gt;junit&lt;/artifactId&gt;
                  &lt;version&gt;4.11&lt;/version&gt;
                  &lt;scope&gt;test&lt;/scope&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;junit-addons&lt;/groupId&gt;
                  &lt;artifactId&gt;junit-addons&lt;/artifactId&gt;
                  &lt;version&gt;1.4&lt;/version&gt;
              &lt;/dependency&gt;   
              &lt;dependency&gt;
                  &lt;groupId&gt;org.powermock&lt;/groupId&gt;
                  &lt;artifactId&gt;powermock-module-junit4&lt;/artifactId&gt;
                  &lt;version&gt;1.6.2&lt;/version&gt;
                  &lt;scope&gt;test&lt;/scope&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.powermock&lt;/groupId&gt;
                  &lt;artifactId&gt;powermock-api-mockito&lt;/artifactId&gt;
                  &lt;version&gt;1.6.2&lt;/version&gt;
                  &lt;scope&gt;test&lt;/scope&gt;
              &lt;/dependency&gt;
  </code></pre>
  
  <p>Exception:</p>
  
  <pre><code>java.lang.VerifyError: (class: com/day/cq/search/Predicate, method: &lt;init&gt; signature: (Ljava/lang/String;Ljava/lang/String;)V) Constructor must call super() or this()
              at java.lang.Class.getDeclaredConstructors0(Native Method)
              at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
              at java.lang.Class.getDeclaredConstructors(Unknown Source)
              at org.powermock.api.mockito.repackaged.ClassImposterizer.setConstructorsAccessible(ClassImposterizer.java:85)
              at org.powermock.api.mockito.repackaged.ClassImposterizer.imposterise(ClassImposterizer.java:71)
              at org.powermock.api.mockito.repackaged.ClassImposterizer.imposterise(ClassImposterizer.java:49)
              at org.powermock.api.mockito.repackaged.CglibMockMaker.createMock(CglibMockMaker.java:24)
              at org.powermock.api.mockito.internal.mockmaker.PowerMockMaker.createMock(PowerMockMaker.java:45)
              at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:33)
              at org.mockito.internal.MockitoCore.mock(MockitoCore.java:59)
              at org.mockito.Mockito.mock(Mockito.java:1285)
              at org.mockito.Mockito.mock(Mockito.java:1163)
              at com.ftc.digital.services.search.impl.SearchServiceImplTest.setUp(SearchServiceImplTest.java:62)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
              at java.lang.reflect.Method.invoke(Unknown Source)
              at org.junit.internal.runners.MethodRoadie.runBefores(MethodRoadie.java:132)
              at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:95)
              at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.executeTest(PowerMockJUnit44RunnerDelegateImpl.java:294)
              at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTestInSuper(PowerMockJUnit47RunnerDelegateImpl.java:127)
              at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTest(PowerMockJUnit47RunnerDelegateImpl.java:82)
              at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runBeforesThenTestThenAfters(PowerMockJUnit44RunnerDelegateImpl.java:282)
              at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:86)
              at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:49)
              at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.invokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:207)
              at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.runMethods(PowerMockJUnit44RunnerDelegateImpl.java:146)
              at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.run(PowerMockJUnit44RunnerDelegateImpl.java:120)
              at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:33)
              at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:45)
              at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.run(PowerMockJUnit44RunnerDelegateImpl.java:122)
              at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:106)
              at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:53)
              at org.powermock.modules.junit4.PowerMockRunner.run(PowerMockRunner.java:59)
              at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
              at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
              at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
              at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
              at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
              at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
  </code></pre>
  
  <p>Update:
  Search Class code:</p>
  
  <pre><code>@Service(SearchService.class)
  @Component(label = "Search Service", metatype = true, immediate = true)
  public class SearchServiceImpl implements SearchService
  {
      private final Logger logger = LoggerFactory.getLogger(getClass());
      @Override
      public final SearchResult getResult(final SlingHttpServletRequest slingRequest, final Map&lt;String,
           String&gt; predicateParameterMap, final String searchRootPath, final int startPage, final int resultsPerPage)
      {
          // Add additional predicates
          logger.info("resultsPerPage" + resultsPerPage);
          predicateParameterMap.put("path", searchRootPath);
          predicateParameterMap.put("p.offset", Long.toString(calculateOffset(startPage, resultsPerPage)));
          predicateParameterMap.put("p.limit", Integer.toString(resultsPerPage));
          predicateParameterMap.put("orderby", "@jcr:score");
          predicateParameterMap.put("orderby.sort", "desc");
  
          // Create query and get result
          final com.day.cq.search.result.SearchResult result = createQuery(slingRequest.getResourceResolver(),
                  predicateParameterMap).getResult();
  
          // Populate search result
          final SearchResult searchResult = new SearchResult();
          searchResult.setCurrentPage(calculateCurrentPage(result.getStartIndex(), result.getHitsPerPage()));
          searchResult.setTotalPages(calculateTotalPages(result.getTotalMatches(), result.getHitsPerPage()));
          searchResult.setTotalResults(result.getTotalMatches());
          searchResult.setResultsPerPage((int) result.getHitsPerPage());
          searchResult.setResults(result.getHits());
          return searchResult;
      }
  
      @Override
      public final long calculateOffset(final int startPage, final int resultsPerPage)
      {
          if (startPage &lt;= 1)
          {
              return 0;
          }
  
          return ((startPage * resultsPerPage) - resultsPerPage);
      }
  
      /**
       * Calculates the current page number.
       * 
       * @param startIndex The start index of the search results.
       * @param hitsPerPage The results to show per page.
       * @return The calculated current page number.
       */
      private int calculateCurrentPage(final long startIndex, final long hitsPerPage)
      {
          if (startIndex == 0L)
          {
              return 1;
          }
  
          return (int) Math.ceil((double) (startIndex + 1) / hitsPerPage);
      }
  
      /**
       * Calculates the total pages for the search results.
       * 
       * @param totalMatches The total search results.
       * @param hitsPerPage The results to show per page.
       * @return The calculated total number of pages.
       */
      private int calculateTotalPages(final long totalMatches, final long hitsPerPage)
      {
          if (totalMatches == 0)
          {
              return 0;
          }
  
          final int totalPages = (int) (Math.ceil((double) totalMatches / hitsPerPage));
          return totalPages;
      }
  
      /**
       * Create the search query either using predicateMap.
       * 
       * @param resourceResolver The resource resolver.
       * @param predicateParamMap The parameters to use for the query.
       * @return The search query.
       */
      private Query createQuery(final ResourceResolver resourceResolver, final Map&lt;String, String&gt; predicateParamMap)
      {
          final QueryBuilder queryBuilder = resourceResolver.adaptTo(QueryBuilder.class);
          final Session session = (Session) resourceResolver.adaptTo(Session.class);
  
          Query query = null;
          query = queryBuilder.createQuery(PredicateGroup.create(predicateParamMap), session);
          return query;
      }
  
  }
  </code></pre>
  
  <p>Test Class for the above source class:</p>
  
  <pre><code>public class SearchServiceImplTest
  {
  
      private SearchServiceImpl searchService;
      private SearchResult result;
      private HashMap&lt;String, String&gt; predicateParameterMap;
      private ResourceResolver resourceResolver;
      private QueryBuilder queryBuilder;
      private Session session;
      private Query query;
      private PredicateGroup predicateGroup;
      private java.util.List&lt;Hit&gt; hits;
      private SlingHttpServletRequest request = null;
      private com.project.digital.models.SearchResult searchResult;
      private static long TEST_START_INDEX = 0;
      private static long TEST_HITS_PER_PAGE = 2;
      private static long TEST_TOTAL_MATCHES = 5;
  
      private static String TEST_SEARCH_ROOT_PATH = "/content/testSite/en";
  
      @SuppressWarnings("unchecked")
      @Before
      public void setUp() throws Exception
      {
          searchService= spy(new SearchServiceImpl());
          predicateParameterMap = mock(HashMap.class);
          result = mock(SearchResult.class);
          request = mock(SlingHttpServletRequest.class);
          resourceResolver = mock(ResourceResolver.class);
          queryBuilder = mock(QueryBuilder.class);
          session = mock(Session.class);
          query = mock(Query.class);
          predicateGroup = mock(PredicateGroup.class);
          hits = (java.util.List&lt;Hit&gt;) mock(List.class);
  
          searchResult = new com.project.digital.models.SearchResult();
  
          Mockito.when(new com.project.digital.models.SearchResult()).thenReturn(searchResult);
          when(request.getResourceResolver()).thenReturn(resourceResolver);
          when(resourceResolver.adaptTo(QueryBuilder.class)).thenReturn(queryBuilder);
          when(resourceResolver.adaptTo(Session.class)).thenReturn(session);
          when(PredicateGroup.create(predicateParameterMap)).thenReturn(predicateGroup);
          when(queryBuilder.createQuery(predicateGroup, session)).thenReturn(query);
          when(query.getResult()).thenReturn(result);
      }
  
  
      private void mockSearchResult(long startIndex, long hitsPerPage, long totalMatches, List&lt;Hit&gt; hits)
      {
          when(result.getStartIndex()).thenReturn(startIndex);
          when(result.getHitsPerPage()).thenReturn(hitsPerPage);
          when(result.getTotalMatches()).thenReturn(totalMatches);
          when(result.getHits()).thenReturn(hits);
  
      }
  }
  </code></pre>
  
  <p>When I am using the PredicateGroup in my test class than I am getting this exception.</p>