### Question:
FactorServiceImpl implements FactorService { @Override public List<Factor> listAvailableFactors(OktaUser user) throws OktaException { if (user != null) { String apiPath = String.format(OktaAPIConstants.LIST_AVAILABLE_ENROLLED_FACTORS, user.getId()); ResponseEntity<Factor[]> exchange = oktaRestService.doRestCall(apiPath, HttpMethod.GET, Factor[].class, "parameters"); if (!exchange.getStatusCode().is2xxSuccessful()) { throw new OktaException(exchange.toString()); } if (exchange.getBody().length > 0) { List<Factor> factorCatalog = Arrays.asList(exchange.getBody()); List<Factor> factorsAlreadyEnrolled = listEnrolledFactors(user); if (factorsAlreadyEnrolled != null) { if (!factorsAlreadyEnrolled.isEmpty()) { List<FactorType> factorTypes = factorsAlreadyEnrolled.stream() .filter(factor -> FactorStatus.ACTIVE.equals(factor.getStatus()) || FactorStatus.ENROLLED.equals(factor.getStatus())) .map(Factor::getFactorType) .collect(Collectors.toList()); return factorCatalog.stream().filter(factor -> !factorTypes.contains(factor.getFactorType())) .collect(Collectors.toList()); } else { return factorCatalog; } } } } return Collections.emptyList(); }  @Override Factor getFactor(String factorId, OktaUser user); @Override Factor getFactor(FactorType factorType, OktaUser user); @Override List<Factor> listEnrolledFactors(OktaUser user); @Override List<Factor> listAvailableFactors(OktaUser user); @Override List<SecurityQuestion> listSecurityQuestions(OktaUser user); @Override void deleteFactor(String factorId, OktaUser user); @Override void deleteFactor(FactorType factorType, OktaUser user); OktaRestService getOktaRestService(); void setOktaRestService(OktaRestService oktaRestService);  }### Answer:
@Test public void listAvailableFactorsTest() throws OktaException { Factor[] expectedFactors = { expectedFactor }; ResponseEntity<Factor[]> responseEntity = new ResponseEntity<>(expectedFactors, HttpStatus.OK); expect(mockOktaRestService.doRestCall("/api/v1/users/" + expectedUser.getId() + "/factors/catalog", HttpMethod.GET, Factor[].class, "parameters")).andReturn(responseEntity).atLeastOnce(); expect(mockOktaRestService.doRestCall("/api/v1/users/" + expectedUser.getId() + "/factors", HttpMethod.GET, Factor[].class, "parameters")).andReturn(new ResponseEntity<>(new Factor[] { new Factor() }, HttpStatus.OK)) .times(1); replayAll(); List<Factor> factors = unit.listAvailableFactors(expectedUser); verifyAll(); 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()); }