### Question:
FactorEnrollmentAPIController { @RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public List<Factor> findEnrolledFactors(Authentication auth) throws OktaException { try { LOGGER.info("Retrieving enrolled factors for user [{}]", auth.getName()); OktaUser user = getOktaUserService().getUser(auth.getName()); return getFactorService().listEnrolledFactors(user); } catch (Exception e) { LOGGER.error("Failed to retrieve enrolled factors for user [{}]", auth.getName(), e); throw new OktaException(e.getMessage(), e); } }  @RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody List<Factor> findEnrolledFactors(Authentication auth); @RequestMapping(value = "available", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody List<Factor> findAvailableFactors(Authentication auth); @RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody Factor enrollFactor(@RequestBody Factor enrollRequestDTO, Authentication auth); @RequestMapping(value = "activate", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody Factor activateFactor(@RequestBody ActivateRequestDTO activateRequestDTO, Authentication auth); @RequestMapping(value = "reset", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody void activateFactor(Authentication auth); @RequestMapping(method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody void deleteFactor(@RequestParam("factorId") String id, Authentication auth); FactorService getFactorService(); void setFactorService(FactorService factorService); FactorLifecycleService getFactorLifecycleService(); void setFactorLifecycleService(FactorLifecycleService factorLifecycleService); OktaUserService getOktaUserService(); void setOktaUserService(OktaUserService oktaUserService);  }### Answer:
@Test public void findEnrolledFactorsTest() throws Exception { List<Factor> expectedList = new ArrayList<>(); expectedList.add(expectedFactor); expect(mockAuthentication.getName()).andReturn(expectedUser.getId()).atLeastOnce(); expect(mockOktaUserService.getUser(expectedUser.getId())).andReturn(expectedUser); expect(mockFactorService.listEnrolledFactors(expectedUser)).andReturn(expectedList); replayAll(); MvcResult mvcResult = mockMvc.perform( get("/api/latest/plugin/okta/factor/enrollment") .accept(MediaType.APPLICATION_JSON) .session(mockHttpSession) .principal(mockAuthentication)) .andReturn(); verifyAll(); MockHttpServletResponse response = mvcResult.getResponse(); assertEquals(HttpStatus.OK.value(), response.getStatus()); assertTrue(response.getContentType().startsWith(MediaType.APPLICATION_JSON_VALUE)); ObjectMapper objectMapper = new ObjectMapper(); List<Factor> factors = Arrays.asList(objectMapper.readValue(response.getContentAsString(), Factor[].class)); assertNotNull(factors); assertEquals(1, factors.size()); Factor factor = factors.get(0); assertEquals(expectedFactor.getId(), factor.getId()); assertEquals(expectedFactor.getFactorType(), factor.getFactorType()); assertEquals(expectedFactor.getProvider(), factor.getProvider()); FactorProfile profile = factor.getProfile(); assertNotNull(profile); assertEquals(expectedProfile.getEmail(), profile.getEmail()); }