Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

@Mock private 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