In the below code FieldSetter.SetField was used for the test case but now as I have up upgraded to mockito-core 4.3.1. This no longer works. Can you please suggest to me what can I replace it with?
This is throwing an error as it is deprecated in mockito 4.3.1
import org.mockito.internal.util.reflection.FieldSetter;
@Rule
public AemContext context = new AemContext();
private FareRulesRequestProcessor fareRulesRequestProcessor = new FareRulesRequestProcessorImpl();
private FareRulesPathInfo pathInfo;
@Mock
private SlingHttpServletRequest mockRequest;
private FareRulesDataService mockFareRulesDataService;
@Before
public void before() throws Exception {
mockFareRulesDataService = new FareRulesDataServiceImpl();
mockFareRulesDataService = mock(FareRulesDataService.class);
PrivateAccessor.setField(fareRulesRequestProcessor, "fareRulesDataService", mockFareRulesDataService);
}
@Test
public void testFareRulesDataForRequest() throws NoSuchFieldException {
when(mockRequest.getPathInfo()).thenReturn(FARE_RULES_PAGE_URL);
FieldSetter.setField(fareRulesRequestProcessor, fareRulesRequestProcessor.getClass().getDeclaredField("validFareRulesDataMap"), getFareRulesDataMap());
FareRulesData fareRulesData = fareRulesRequestProcessor.getFareRulesData(mockRequest);
assertEquals(FROM, fareRulesData.getDestinationFrom());
assertEquals(TO, fareRulesData.getDestinationTo());
assertEquals(MARKET, fareRulesData.getMarket());
assertTrue(fareRulesData.isFareRulesByMarket());
}