### Question:
FactorEnrollmentAPIController { @RequestMapping(value = "activate", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public Factor activateFactor(@RequestBody ActivateRequestDTO activateRequestDTO, Authentication auth) throws OktaException { Preconditions.checkNotNull(activateRequestDTO, "activateRequestDTO is null"); Preconditions.checkNotNull(activateRequestDTO.getFactorId(), "factor id is null"); Preconditions.checkNotNull(activateRequestDTO.getActivationCode(), "activation code is null"); try { LOGGER.info("Activating factor [{}] for user [{}]", activateRequestDTO.getFactorId(), auth.getName()); OktaUser user = getOktaUserService().getUser(auth.getName()); return getFactorLifecycleService().activate(activateRequestDTO.getFactorId(), activateRequestDTO.getActivationCode(), user); } catch (Exception e) { LOGGER.error("Failed to activate factor [{}] for user [{}]", activateRequestDTO.getFactorId(), 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 activateFactorTest() throws Exception { ActivateRequestDTO requestDTO = new ActivateRequestDTO(); requestDTO.setFactorId(expectedFactor.getId()); requestDTO.setActivationCode("872925"); expect(mockAuthentication.getName()).andReturn(expectedUser.getId()).atLeastOnce(); expect(mockOktaUserService.getUser(expectedUser.getId())).andReturn(expectedUser); expect(mockFactorLifecycleService.activate(requestDTO.getFactorId(), requestDTO.getActivationCode(), expectedUser)) .andReturn(expectedFactor); ObjectMapper objectMapper = new ObjectMapper(); String requestBody = objectMapper.writeValueAsString(requestDTO); replayAll(); MvcResult mvcResult = mockMvc.perform( post("/api/latest/plugin/okta/factor/enrollment/activate") .content(requestBody) .contentType(MediaType.APPLICATION_JSON) .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)); Factor factor = objectMapper.readValue(response.getContentAsString(), Factor.class); assertNotNull(factor); 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()); }