|
101 | 101 | import com.ibm.watson.discovery.v1.model.QueryOptions; |
102 | 102 | import com.ibm.watson.discovery.v1.model.QueryResponse; |
103 | 103 | import com.ibm.watson.discovery.v1.model.Source; |
| 104 | +import com.ibm.watson.discovery.v1.model.SourceOptions; |
| 105 | +import com.ibm.watson.discovery.v1.model.SourceOptionsBuckets; |
| 106 | +import com.ibm.watson.discovery.v1.model.SourceOptionsFolder; |
| 107 | +import com.ibm.watson.discovery.v1.model.SourceOptionsObject; |
| 108 | +import com.ibm.watson.discovery.v1.model.SourceOptionsSiteColl; |
104 | 109 | import com.ibm.watson.discovery.v1.model.SourceOptionsWebCrawl; |
105 | 110 | import com.ibm.watson.discovery.v1.model.TokenDictRule; |
106 | 111 | import com.ibm.watson.discovery.v1.model.TokenDictStatusResponse; |
@@ -461,6 +466,66 @@ public void updateEnvironmentIsSuccessful() throws InterruptedException { |
461 | 466 | assertEquals(updateEnvResp, response); |
462 | 467 | } |
463 | 468 |
|
| 469 | + @Test |
| 470 | + public void testSourceOptions() { |
| 471 | + String folderOwnerUserId = "folder_owner_user_id"; |
| 472 | + String folderId = "folder_id"; |
| 473 | + Long limit = 10L; |
| 474 | + String objectName = "object_name"; |
| 475 | + String siteCollectionPath = "site_collection_path"; |
| 476 | + String url = "url"; |
| 477 | + Long maximumHops = 5L; |
| 478 | + Long requestTimeout = 2L; |
| 479 | + String bucketName = "bucket_name"; |
| 480 | + |
| 481 | + SourceOptions sourceOptions = new SourceOptions(); |
| 482 | + SourceOptionsFolder folder = new SourceOptionsFolder(); |
| 483 | + folder.setOwnerUserId(folderOwnerUserId); |
| 484 | + folder.setFolderId(folderId); |
| 485 | + folder.setLimit(limit); |
| 486 | + sourceOptions.setFolders(Collections.singletonList(folder)); |
| 487 | + SourceOptionsObject object = new SourceOptionsObject(); |
| 488 | + object.setName(objectName); |
| 489 | + object.setLimit(limit); |
| 490 | + sourceOptions.setObjects(Collections.singletonList(object)); |
| 491 | + SourceOptionsSiteColl siteColl = new SourceOptionsSiteColl(); |
| 492 | + siteColl.setSiteCollectionPath(siteCollectionPath); |
| 493 | + siteColl.setLimit(limit); |
| 494 | + sourceOptions.setSiteCollections(Collections.singletonList(siteColl)); |
| 495 | + SourceOptionsWebCrawl webCrawl = new SourceOptionsWebCrawl(); |
| 496 | + webCrawl.setUrl(url); |
| 497 | + webCrawl.setLimitToStartingHosts(true); |
| 498 | + webCrawl.setCrawlSpeed(SourceOptionsWebCrawl.CrawlSpeed.AGGRESSIVE); |
| 499 | + webCrawl.setAllowUntrustedCertificate(true); |
| 500 | + webCrawl.setMaximumHops(maximumHops); |
| 501 | + webCrawl.setRequestTimeout(requestTimeout); |
| 502 | + webCrawl.setOverrideRobotsTxt(true); |
| 503 | + sourceOptions.setUrls(Collections.singletonList(webCrawl)); |
| 504 | + SourceOptionsBuckets buckets = new SourceOptionsBuckets(); |
| 505 | + buckets.setName(bucketName); |
| 506 | + buckets.setLimit(limit); |
| 507 | + sourceOptions.setBuckets(Collections.singletonList(buckets)); |
| 508 | + sourceOptions.setCrawlAllBuckets(true); |
| 509 | + |
| 510 | + assertEquals(folderOwnerUserId, sourceOptions.getFolders().get(0).getOwnerUserId()); |
| 511 | + assertEquals(folderId, sourceOptions.getFolders().get(0).getFolderId()); |
| 512 | + assertEquals(limit, sourceOptions.getFolders().get(0).getLimit()); |
| 513 | + assertEquals(objectName, sourceOptions.getObjects().get(0).getName()); |
| 514 | + assertEquals(limit, sourceOptions.getObjects().get(0).getLimit()); |
| 515 | + assertEquals(siteCollectionPath, sourceOptions.getSiteCollections().get(0).getSiteCollectionPath()); |
| 516 | + assertEquals(limit, sourceOptions.getSiteCollections().get(0).getLimit()); |
| 517 | + assertEquals(url, sourceOptions.getUrls().get(0).getUrl()); |
| 518 | + assertTrue(sourceOptions.getUrls().get(0).isLimitToStartingHosts()); |
| 519 | + assertEquals(SourceOptionsWebCrawl.CrawlSpeed.AGGRESSIVE, sourceOptions.getUrls().get(0).getCrawlSpeed()); |
| 520 | + assertTrue(sourceOptions.getUrls().get(0).isAllowUntrustedCertificate()); |
| 521 | + assertEquals(maximumHops, sourceOptions.getUrls().get(0).getMaximumHops()); |
| 522 | + assertEquals(requestTimeout, sourceOptions.getUrls().get(0).getRequestTimeout()); |
| 523 | + assertTrue(sourceOptions.getUrls().get(0).isOverrideRobotsTxt()); |
| 524 | + assertEquals(bucketName, sourceOptions.getBuckets().get(0).getName()); |
| 525 | + assertEquals(limit, sourceOptions.getBuckets().get(0).getLimit()); |
| 526 | + assertTrue(sourceOptions.isCrawlAllBuckets()); |
| 527 | + } |
| 528 | + |
464 | 529 | // Configuration tests |
465 | 530 | @Test |
466 | 531 | public void testCreateConfigurationOptions() { |
@@ -1110,27 +1175,76 @@ public void deleteUserDataIsSuccessful() throws InterruptedException { |
1110 | 1175 | assertEquals(DELETE, request.getMethod()); |
1111 | 1176 | } |
1112 | 1177 |
|
| 1178 | + @Test |
| 1179 | + public void testCredentialDetails() { |
| 1180 | + String clientId = "client_id"; |
| 1181 | + String clientSecret = "client_secret"; |
| 1182 | + String enterpriseId = "enterprise_id"; |
| 1183 | + String organizationUrl = "organization_url"; |
| 1184 | + String passphrase = "passphrase"; |
| 1185 | + String password = "password"; |
| 1186 | + String privateKey = "private_key"; |
| 1187 | + String publicKeyId = "public_key_id"; |
| 1188 | + String siteCollectionPath = "site_collection_path"; |
| 1189 | + String url = "url"; |
| 1190 | + String username = "username"; |
| 1191 | + String gatewayId = "gateway_id"; |
| 1192 | + String sourceVersion = "source_version"; |
| 1193 | + String webApplicationUrl = "web_application_url"; |
| 1194 | + String domain = "domain"; |
| 1195 | + String endpoint = "endpoint"; |
| 1196 | + String accessKeyId = "access_key"; |
| 1197 | + String secretAccessKey = "secret_access_key"; |
| 1198 | + |
| 1199 | + CredentialDetails details = new CredentialDetails(); |
| 1200 | + details.setClientId(clientId); |
| 1201 | + details.setClientSecret(clientSecret); |
| 1202 | + details.setCredentialType(CredentialDetails.CredentialType.USERNAME_PASSWORD); |
| 1203 | + details.setEnterpriseId(enterpriseId); |
| 1204 | + details.setOrganizationUrl(organizationUrl); |
| 1205 | + details.setPassphrase(passphrase); |
| 1206 | + details.setPassword(password); |
| 1207 | + details.setPrivateKey(privateKey); |
| 1208 | + details.setPublicKeyId(publicKeyId); |
| 1209 | + details.setSiteCollectionPath(siteCollectionPath); |
| 1210 | + details.setUrl(url); |
| 1211 | + details.setUsername(username); |
| 1212 | + details.setGatewayId(gatewayId); |
| 1213 | + details.setSourceVersion(sourceVersion); |
| 1214 | + details.setWebApplicationUrl(webApplicationUrl); |
| 1215 | + details.setDomain(domain); |
| 1216 | + details.setEndpoint(endpoint); |
| 1217 | + details.setAccessKeyId(accessKeyId); |
| 1218 | + details.setSecretAccessKey(secretAccessKey); |
| 1219 | + |
| 1220 | + assertEquals(clientId, details.getClientId()); |
| 1221 | + assertEquals(clientSecret, details.getClientSecret()); |
| 1222 | + assertEquals(CredentialDetails.CredentialType.USERNAME_PASSWORD, details.getCredentialType()); |
| 1223 | + assertEquals(enterpriseId, details.getEnterpriseId()); |
| 1224 | + assertEquals(organizationUrl, details.getOrganizationUrl()); |
| 1225 | + assertEquals(passphrase, details.getPassphrase()); |
| 1226 | + assertEquals(password, details.getPassword()); |
| 1227 | + assertEquals(privateKey, details.getPrivateKey()); |
| 1228 | + assertEquals(publicKeyId, details.getPublicKeyId()); |
| 1229 | + assertEquals(siteCollectionPath, details.getSiteCollectionPath()); |
| 1230 | + assertEquals(url, details.getUrl()); |
| 1231 | + assertEquals(username, details.getUsername()); |
| 1232 | + assertEquals(gatewayId, details.getGatewayId()); |
| 1233 | + assertEquals(sourceVersion, details.getSourceVersion()); |
| 1234 | + assertEquals(webApplicationUrl, details.getWebApplicationUrl()); |
| 1235 | + assertEquals(domain, details.getDomain()); |
| 1236 | + assertEquals(accessKeyId, details.getAccessKeyId()); |
| 1237 | + assertEquals(secretAccessKey, details.getSecretAccessKey()); |
| 1238 | + } |
| 1239 | + |
1113 | 1240 | @Test |
1114 | 1241 | public void createCredentialsIsSuccessful() throws InterruptedException { |
1115 | 1242 | server.enqueue(jsonResponse(credentialsResp)); |
1116 | 1243 |
|
1117 | 1244 | CredentialDetails details = new CredentialDetails(); |
1118 | | - details.setClientId("client_id"); |
1119 | | - details.setClientSecret("client_secret"); |
1120 | 1245 | details.setCredentialType(CredentialDetails.CredentialType.USERNAME_PASSWORD); |
1121 | | - details.setEnterpriseId("enterprise_id"); |
1122 | | - details.setOrganizationUrl("organization_url"); |
1123 | | - details.setPassphrase("passphrase"); |
1124 | | - details.setPassword("password"); |
1125 | | - details.setPrivateKey("private_key"); |
1126 | | - details.setPublicKeyId("public_key_id"); |
1127 | | - details.setSiteCollectionPath("site_collection_path"); |
1128 | 1246 | details.setUrl("url"); |
1129 | 1247 | details.setUsername("username"); |
1130 | | - details.setGatewayId("gateway_id"); |
1131 | | - details.setSourceVersion("source_version"); |
1132 | | - details.setWebApplicationUrl("web_application_url"); |
1133 | | - details.setDomain("domain"); |
1134 | 1248 | Credentials credentials = new Credentials(); |
1135 | 1249 | credentials.setSourceType(Credentials.SourceType.SALESFORCE); |
1136 | 1250 | credentials.setCredentialDetails(details); |
|
0 commit comments