Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

@Mock \tprivate ResourceResolverFactory resourceResolverFactory;

Avatar

Level 3

    Hi All,

      Can any one help me please how to mock for junit test case  below factory class.

     private ResourceResolverFactory resourceResolverFactory;

 

  Thanks,

  Venkatesham G

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi Venkatesham,

Something like this :)

 

import com.day.cq.dam.api.Asset; import org.apache.sling.api.resource.ResourceResolverFactory; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; /** * Created by Peter.Puzanovs on 17/11/2015. */ @RunWith(MockitoJUnitRunner.class) public class OneHundreadPercentCoverage { @Mock private ResourceResolverFactory resourceResolverFactory; @Test public void test() { Assert.assertNotNull(resourceResolverFactory); } }

Thanks,

Peter

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

Hi Venkatesham,

Something like this :)

 

import com.day.cq.dam.api.Asset; import org.apache.sling.api.resource.ResourceResolverFactory; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; /** * Created by Peter.Puzanovs on 17/11/2015. */ @RunWith(MockitoJUnitRunner.class) public class OneHundreadPercentCoverage { @Mock private ResourceResolverFactory resourceResolverFactory; @Test public void test() { Assert.assertNotNull(resourceResolverFactory); } }

Thanks,

Peter