ApiClientBO { public List<ApiClientInfo> search(ApiClientSearchCriteria criteria) { try(LoginDAO loginDAO = MyJdbi.authz()) { log.debug("Searching for users based on the criteria."); List<ApiClientInfo> list = new ArrayList<>(); if( criteria.enabledEqualTo != null && criteria.statusEqualTo != null ) { List<UserLoginCertificate> userLoginCertificates = loginDAO.findUserLoginCertificatesByStatusAndEnabled(Status.valueOf(criteria.statusEqualTo), criteria.enabledEqualTo); if (userLoginCertificates != null && userLoginCertificates.size() > 0) { for (UserLoginCertificate userLoginCertificate : userLoginCertificates) { list.add(convertToApiClientInfo(userLoginCertificate)); } } } else if (criteria.statusEqualTo != null) { List<UserLoginCertificate> userLoginCertificates = loginDAO.findUserLoginCertificatesByStatus(Status.valueOf(criteria.statusEqualTo)); if (userLoginCertificates != null && userLoginCertificates.size() > 0) { for (UserLoginCertificate userLoginCertificate : userLoginCertificates) { list.add(convertToApiClientInfo(userLoginCertificate)); } } } else if (criteria.enabledEqualTo != null) { List<UserLoginCertificate> userLoginCertificates = loginDAO.findUserLoginCertificatesByEnabled(criteria.enabledEqualTo); if (userLoginCertificates != null && userLoginCertificates.size() > 0) { for (UserLoginCertificate userLoginCertificate : userLoginCertificates) { list.add(convertToApiClientInfo(userLoginCertificate)); } } } else if (criteria.fingerprintEqualTo != null) { UserLoginCertificate userLoginCertificate = loginDAO.findUserLoginCertificateBySha256(criteria.fingerprintEqualTo); if (userLoginCertificate != null) { list.add(convertToApiClientInfo(userLoginCertificate)); } } else if (criteria.nameEqualTo != null) { UserLoginCertificate userLoginCertificate = loginDAO.findUserLoginCertificateByUsername(criteria.nameEqualTo); if (userLoginCertificate != null) { list.add(convertToApiClientInfo(userLoginCertificate)); } } return list; } catch (MSException me) { log.error("Error during searching for the API Client information. " + me.getErrorMessage()); throw me; } catch (Exception ex) { log.error("Error during search for API user. ", ex); throw new MSException(ErrorCode.MS_API_USER_SEARCH_ERROR, ex.getClass().getSimpleName()); } } ApiClientBO(); void create(ApiClientCreateRequest apiClientRequest); void create(ApiClientCreateRequest apiClientRequest, String userUuid, String userCertUuid); ObjectMapper getUserCommentMapper(); void update(ApiClientUpdateRequest apiClientRequest, String uuid); void delete(ApiClientUpdateRequest apiClientRequest, String uuid); void updateV2(ApiClientUpdateRequest apiClientRequest); ApiClientInfo find(byte[] fingerprint); List<ApiClientInfo> search(ApiClientSearchCriteria criteria);  }
@Test public void getApiClientList() { ApiClientSearchCriteria apiSearchObj = new ApiClientSearchCriteria(); apiSearchObj.enabledEqualTo = true; ApiClientBO clientBO = new ApiClientBO(); List<ApiClientInfo> searchResult = clientBO.search(apiSearchObj); for (ApiClientInfo apiObj : searchResult) System.out.println(apiObj.name); }