Skip to content

Commit 8222162

Browse files
committed
test(discovery-v2): update IT for discovery-v2
1 parent e8f160a commit 8222162

File tree

2 files changed

+134
-12
lines changed

2 files changed

+134
-12
lines changed

src/IBM.Watson.Discovery.v2/Test/Integration/DiscoveryIntegrationTests.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class DiscoveryIntegrationTests
3232
{
3333
private DiscoveryService service;
3434
private string versionDate = "2019-11-22";
35-
private string filepathToIngest = @"DiscoveryTestData/watson_beats_jeopardy.html";
35+
private string filepathToIngest = @"DiscoveryTestData/problem.json";
3636
private string enrichmentFile = @"DiscoveryTestData/test.csv";
3737
private string metadata = "{\"Creator\": \".NET SDK Test\",\"Subject\": \"Discovery service\"}";
3838
private string bearerToken = "";
@@ -43,11 +43,12 @@ public class DiscoveryIntegrationTests
4343
[TestInitialize]
4444
public void Setup()
4545
{
46-
//Authenticator discoveryAuthenticator = new BearerTokenAuthenticator(bearerToken: bearerToken);
47-
//service = new DiscoveryService(versionDate: versionDate, authenticator: discoveryAuthenticator);
48-
//service.SetServiceUrl(serviceUrl: serviceUrl);
49-
//service.DisableSslVerification(true);
50-
service = new DiscoveryService(versionDate);
46+
Authenticator discoveryAuthenticator = new BearerTokenAuthenticator(bearerToken: bearerToken);
47+
service = new DiscoveryService(version: versionDate, authenticator: discoveryAuthenticator);
48+
service.SetServiceUrl(serviceUrl: serviceUrl);
49+
service.DisableSslVerification(true);
50+
//service = new DiscoveryService(versionDate);
51+
//service.SetServiceUrl(serviceUrl);
5152
var creds = CredentialUtils.GetServiceProperties("discovery");
5253
creds.TryGetValue("PROJECT_ID", out projectId);
5354
creds.TryGetValue("COLLECTION_ID", out collectionId);
@@ -61,7 +62,7 @@ public void TestQueryPassagesPerDocument()
6162
projectId: projectId,
6263
collectionIds: new List<string> { collectionId },
6364
passages: new QueryLargePassages() { PerDocument = true },
64-
query: "text:IBM",
65+
query: "text:document",
6566
count: 2);
6667

6768
Assert.IsNotNull(queryResult.Result.Results[0].DocumentPassages[0].PassageText);
@@ -74,7 +75,7 @@ public void TestQueryPassages()
7475
projectId: projectId,
7576
collectionIds: new List<string> { collectionId },
7677
passages: new QueryLargePassages() { PerDocument = false },
77-
query: "text:IBM",
78+
query: "text:document",
7879
count: 2);
7980

8081
Assert.IsNotNull(queryResult.Result.Passages[0].CollectionId);
@@ -186,7 +187,7 @@ public void TestGetAutocompletion()
186187
service.WithHeader("X-Watson-Test", "1");
187188
var getAutocompletionResult = service.GetAutocompletion(
188189
projectId: projectId,
189-
prefix: "ha"
190+
prefix: "pd"
190191
);
191192

192193
Assert.IsNotNull(getAutocompletionResult.Result);
@@ -320,14 +321,13 @@ public void TestAnalyzeDocument()
320321
using (MemoryStream ms = new MemoryStream())
321322
{
322323
fs.CopyTo(ms);
323-
324324
service.WithHeader("X-Watson-Test", "1");
325325
var response = service.AnalyzeDocument(
326326
projectId: projectId,
327327
collectionId: collectionId,
328328
file: ms,
329-
filename: "watson_beats_jeopardy.html",
330-
fileContentType: DiscoveryService.AnalyzeDocumentEnums.FileContentTypeValue.TEXT_HTML,
329+
filename: "problem.json",
330+
fileContentType: DiscoveryService.AnalyzeDocumentEnums.FileContentTypeValue.APPLICATION_JSON,
331331
metadata: "{ \"metadata\": \"value\" }"
332332
);
333333
Assert.IsNotNull(response);
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
{
2+
"subject": "phones",
3+
"columns": [
4+
{
5+
"key": "price",
6+
"type": "numeric",
7+
"goal": "min",
8+
"is_objective": true,
9+
"full_name": "Price",
10+
"range": {
11+
"low": 0,
12+
"high": 400
13+
},
14+
"format": "number:2"
15+
},
16+
{
17+
"key": "weight",
18+
"type": "numeric",
19+
"goal": "min",
20+
"is_objective": true,
21+
"full_name": "Weight",
22+
"format": "number:0"
23+
},
24+
{
25+
"key": "brand",
26+
"type": "categorical",
27+
"goal": "min",
28+
"is_objective": true,
29+
"full_name": "Brand",
30+
"range": [
31+
"Apple",
32+
"HTC",
33+
"Samsung",
34+
"Sony"
35+
],
36+
"preference": [
37+
"Samsung",
38+
"Apple",
39+
"HTC"
40+
]
41+
},
42+
{
43+
"key": "rDate",
44+
"type": "datetime",
45+
"goal": "max",
46+
"full_name": "Release Date",
47+
"format": "date: 'MMM dd, yyyy'"
48+
}
49+
],
50+
"options": [
51+
{
52+
"key": "1",
53+
"name": "Samsung Galaxy S4",
54+
"values": {
55+
"price": 249,
56+
"weight": 130,
57+
"brand": "Samsung",
58+
"rDate": "2013-04-29T00:00:00Z"
59+
}
60+
},
61+
{
62+
"key": "2",
63+
"name": "Apple iPhone 5",
64+
"values": {
65+
"price": 349,
66+
"weight": 112,
67+
"brand": "Apple",
68+
"rDate": "2012-09-21T00:00:00Z"
69+
}
70+
},
71+
{
72+
"key": "3",
73+
"name": "HTC One",
74+
"values": {
75+
"price": 299,
76+
"weight": 112,
77+
"brand": "HTC",
78+
"rDate": "2013-03-01T00:00:00Z"
79+
}
80+
},
81+
{
82+
"key": "4",
83+
"name": "Samsung Galaxy S5",
84+
"values": {
85+
"price": 349,
86+
"weight": 135,
87+
"brand": "Samsung",
88+
"rDate": "2014-04-29T00:00:00Z"
89+
}
90+
},
91+
{
92+
"key": "5",
93+
"name": "Apple iPhone 6",
94+
"values": {
95+
"price": 399,
96+
"weight": 118,
97+
"brand": "Apple",
98+
"rDate": "2013-09-21T00:00:00Z"
99+
}
100+
},
101+
{
102+
"key": "6",
103+
"name": "Apple iPhone 7",
104+
"values": {
105+
"price": 499,
106+
"weight": 118,
107+
"brand": "Apple",
108+
"rDate": "2014-09-21T00:00:00Z"
109+
}
110+
},
111+
{
112+
"key": "7",
113+
"name": "Sony Xperia",
114+
"values": {
115+
"price": 199,
116+
"weight": 120,
117+
"brand": "Sony",
118+
"rDate": "2014-08-21T00:00:00Z"
119+
}
120+
}
121+
]
122+
}

0 commit comments

Comments
 (0)