getWcmMode() is a final method in WCMUsePojo, mockito does not support mocking final methods by default.
you will have to enable it by creating a file named org.mockito.plugins.MockMaker in classpath (put it in the test resources/mockito-extensions folder) and put the following single line
mock-maker-inline
then you can use when to specify function return values as usual-
@Test
public void testSomeComponetnInNOTEDITMode() {
//setup wcmmode
SightlyWCMMode fakeDisabledMode = mock(SightlyWCMMode.class);
when(fakeDisabledMode.isEdit()).thenReturn(false);
//ComponentUseClass extends WCMUsePojo
ComponentUseClass fakeComponent = mock(ComponentUseClass.class);
when(fakeComponent.getWcmMode()).thenReturn(fakeDisabledMode);
assertFalse(fakeComponent.getWcmMode().isEdit());
//do some more not Edit mode testing on fakeComponent.
}
getWcmMode()is a final method inWCMUsePojo, mockito does not support mocking final methods by default.you will have to enable it by creating a file named
org.mockito.plugins.MockMakerin classpath (put it in the test resources/mockito-extensions folder) and put the following single linethen you can use
whento specify function return values as usual-