Skip to content

Commit 8689b64

Browse files
committed
chore(Integration tests): Added try catch to integration tests
1 parent b56eb51 commit 8689b64

File tree

2 files changed

+153
-104
lines changed

2 files changed

+153
-104
lines changed

Tests/DiscoveryV1IntegrationTests.cs

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,7 +1535,7 @@ public IEnumerator TestUpdateCredentials()
15351535
},
15361536
environmentId: environmentId,
15371537
credentialId: credentialId,
1538-
sourceType: "box",
1538+
sourceType: "box",
15391539
credentialDetails: credentialDetails,
15401540
customData: customData
15411541
);
@@ -1973,7 +1973,9 @@ private IEnumerator CheckTokenizationDictionaryStatus(string environmentId, stri
19731973
yield return new WaitForSeconds(30f);
19741974

19751975
TokenDictStatusResponse getTokenizationDictionaryStatusResponse = null;
1976-
service.GetTokenizationDictionaryStatus(
1976+
try
1977+
{
1978+
service.GetTokenizationDictionaryStatus(
19771979
callback: (DetailedResponse<TokenDictStatusResponse> response, IBMError error, Dictionary<string, object> customResponseData) =>
19781980
{
19791981
Log.Debug("DiscoveryServiceV1IntegrationTests", "GetTokenizationDictionaryStatus result: {0}", customResponseData["json"].ToString());
@@ -1991,6 +1993,11 @@ private IEnumerator CheckTokenizationDictionaryStatus(string environmentId, stri
19911993
collectionId: collectionId,
19921994
customData: customData
19931995
);
1996+
}
1997+
catch
1998+
{
1999+
Runnable.Run(CheckTokenizationDictionaryStatus(environmentId, collectionId));
2000+
}
19942001

19952002
while (getTokenizationDictionaryStatusResponse == null)
19962003
yield return null;
@@ -2003,12 +2010,19 @@ private IEnumerator CheckStopwordsListStatus()
20032010
Log.Debug("DiscoveryServiceV1IntegrationTests", "Checking stopword list status in 30 sec...");
20042011
yield return new WaitForSeconds(30f);
20052012

2006-
service.GetStopwordListStatus(
2007-
callback: OnCheckStopwordsListStatus,
2008-
environmentId: environmentId,
2009-
collectionId: collectionId,
2010-
customData: customData
2011-
);
2013+
try
2014+
{
2015+
service.GetStopwordListStatus(
2016+
callback: OnCheckStopwordsListStatus,
2017+
environmentId: environmentId,
2018+
collectionId: collectionId,
2019+
customData: customData
2020+
);
2021+
}
2022+
catch
2023+
{
2024+
Runnable.Run(CheckStopwordsListStatus());
2025+
}
20122026
}
20132027

20142028
private void OnCheckStopwordsListStatus(DetailedResponse<TokenDictStatusResponse> response, IBMError error, Dictionary<string, object> customResponseData)
@@ -2052,23 +2066,23 @@ public IEnumerator DeleteUnityCollections()
20522066

20532067
List<string> collectionIdsToDelete = new List<string>();
20542068
int count = 0;
2055-
foreach(Collection collection in listCollectionsResponse.Collections)
2069+
foreach (Collection collection in listCollectionsResponse.Collections)
20562070
{
2057-
if(!string.IsNullOrEmpty(collection.Description) && collection.Description.Contains("Unity"))
2071+
if (!string.IsNullOrEmpty(collection.Description) && collection.Description.Contains("Unity"))
20582072
collectionIdsToDelete.Add(collection.CollectionId);
20592073
}
20602074

2061-
foreach(string collectionId in collectionIdsToDelete)
2062-
service.DeleteCollection(
2063-
callback: (DetailedResponse<DeleteCollectionResponse> response, IBMError error, Dictionary<string, object> customResponseData) =>
2064-
{
2065-
Log.Debug("DiscoveryServiceV1IntegrationTests", "DeleteCollection result: {0}", customResponseData["json"].ToString());
2066-
count++;
2067-
},
2068-
environmentId: environmentId,
2069-
collectionId: collectionId,
2070-
customData: customData
2071-
);
2075+
foreach (string collectionId in collectionIdsToDelete)
2076+
service.DeleteCollection(
2077+
callback: (DetailedResponse<DeleteCollectionResponse> response, IBMError error, Dictionary<string, object> customResponseData) =>
2078+
{
2079+
Log.Debug("DiscoveryServiceV1IntegrationTests", "DeleteCollection result: {0}", customResponseData["json"].ToString());
2080+
count++;
2081+
},
2082+
environmentId: environmentId,
2083+
collectionId: collectionId,
2084+
customData: customData
2085+
);
20722086

20732087
while (count < collectionIdsToDelete.Count)
20742088
yield return null;

Tests/SpeechToTextV1IntegrationTests.cs

Lines changed: 118 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,23 +1318,30 @@ private IEnumerator CheckLanguageModelStatus()
13181318

13191319
Log.Debug("SpeechToTextServiceV1IntegrationTests", "Attempting to GetLanguageModel...");
13201320
LanguageModel getLanguageModelResponse = null;
1321-
service.GetLanguageModel(
1322-
callback: (DetailedResponse<LanguageModel> response, IBMError error, Dictionary<string, object> customResponseData) =>
1323-
{
1324-
getLanguageModelResponse = response.Result;
1325-
Log.Debug("SpeechToTextServiceV1IntegrationTests", "CheckLanguageModelStatus: {0}", getLanguageModelResponse.Status);
1326-
if (getLanguageModelResponse.Status == LanguageModel.StatusValue.TRAINING)
1327-
{
1328-
Runnable.Run(CheckLanguageModelStatus());
1329-
}
1330-
else
1321+
try
1322+
{
1323+
service.GetLanguageModel(
1324+
callback: (DetailedResponse<LanguageModel> response, IBMError error, Dictionary<string, object> customResponseData) =>
13311325
{
1332-
isLanguageModelReady = true;
1333-
}
1334-
},
1335-
customizationId: customizationId,
1336-
customData: customData
1337-
);
1326+
getLanguageModelResponse = response.Result;
1327+
Log.Debug("SpeechToTextServiceV1IntegrationTests", "CheckLanguageModelStatus: {0}", getLanguageModelResponse.Status);
1328+
if (getLanguageModelResponse.Status == LanguageModel.StatusValue.TRAINING)
1329+
{
1330+
Runnable.Run(CheckLanguageModelStatus());
1331+
}
1332+
else
1333+
{
1334+
isLanguageModelReady = true;
1335+
}
1336+
},
1337+
customizationId: customizationId,
1338+
customData: customData
1339+
);
1340+
}
1341+
catch
1342+
{
1343+
Runnable.Run(CheckLanguageModelStatus());
1344+
}
13381345

13391346
while (getLanguageModelResponse == null)
13401347
yield return null;
@@ -1349,24 +1356,31 @@ private IEnumerator CheckCorpusStatus()
13491356

13501357
Log.Debug("SpeechToTextServiceV1IntegrationTests", "Attempting to GetCorpus...");
13511358
Corpus getCorpusResponse = null;
1352-
service.GetCorpus(
1353-
callback: (DetailedResponse<Corpus> response, IBMError error, Dictionary<string, object> customResponseData) =>
1354-
{
1355-
getCorpusResponse = response.Result;
1356-
Log.Debug("SpeechToTextServiceV1IntegrationTests", "CheckCorpusStatus: {0}", getCorpusResponse.Status);
1357-
if (getCorpusResponse.Status != Corpus.StatusValue.ANALYZED)
1358-
{
1359-
Runnable.Run(CheckCorpusStatus());
1360-
}
1361-
else
1359+
try
1360+
{
1361+
service.GetCorpus(
1362+
callback: (DetailedResponse<Corpus> response, IBMError error, Dictionary<string, object> customResponseData) =>
13621363
{
1363-
isCorpusReady = true;
1364-
}
1365-
},
1366-
customizationId: customizationId,
1367-
corpusName: corpusName,
1368-
customData: customData
1369-
);
1364+
getCorpusResponse = response.Result;
1365+
Log.Debug("SpeechToTextServiceV1IntegrationTests", "CheckCorpusStatus: {0}", getCorpusResponse.Status);
1366+
if (getCorpusResponse.Status != Corpus.StatusValue.ANALYZED)
1367+
{
1368+
Runnable.Run(CheckCorpusStatus());
1369+
}
1370+
else
1371+
{
1372+
isCorpusReady = true;
1373+
}
1374+
},
1375+
customizationId: customizationId,
1376+
corpusName: corpusName,
1377+
customData: customData
1378+
);
1379+
}
1380+
catch
1381+
{
1382+
Runnable.Run(CheckCorpusStatus());
1383+
}
13701384

13711385
while (getCorpusResponse == null)
13721386
yield return null;
@@ -1381,23 +1395,30 @@ private IEnumerator CheckGrammarsStatus()
13811395

13821396
Log.Debug("SpeechToTextServiceV1IntegrationTests", "Attempting to GetGrammar...");
13831397
Grammar getGrammarResponse = null;
1384-
service.GetGrammar(
1385-
callback: (DetailedResponse<Grammar> response, IBMError error, Dictionary<string, object> customResponseData) =>
1386-
{
1387-
getGrammarResponse = response.Result;
1388-
if (getGrammarResponse.Status != Grammar.StatusValue.ANALYZED)
1389-
{
1390-
Runnable.Run(CheckGrammarsStatus());
1391-
}
1392-
else
1398+
try
1399+
{
1400+
service.GetGrammar(
1401+
callback: (DetailedResponse<Grammar> response, IBMError error, Dictionary<string, object> customResponseData) =>
13931402
{
1394-
isGrammarsReady = true;
1395-
}
1396-
},
1397-
customizationId: customizationId,
1398-
grammarName: grammarName,
1399-
customData: customData
1400-
);
1403+
getGrammarResponse = response.Result;
1404+
if (getGrammarResponse.Status != Grammar.StatusValue.ANALYZED)
1405+
{
1406+
Runnable.Run(CheckGrammarsStatus());
1407+
}
1408+
else
1409+
{
1410+
isGrammarsReady = true;
1411+
}
1412+
},
1413+
customizationId: customizationId,
1414+
grammarName: grammarName,
1415+
customData: customData
1416+
);
1417+
}
1418+
catch
1419+
{
1420+
Runnable.Run(CheckGrammarsStatus());
1421+
}
14011422

14021423
while (getGrammarResponse == null)
14031424
yield return null;
@@ -1412,23 +1433,30 @@ private IEnumerator CheckAcousticModelStatus()
14121433

14131434
Log.Debug("SpeechToTextServiceV1IntegrationTests", "Attempting to GetAcousticModel...");
14141435
AcousticModel getAcousticModelResponse = null;
1415-
service.GetAcousticModel(
1416-
callback: (DetailedResponse<AcousticModel> response, IBMError error, Dictionary<string, object> customResponseData) =>
1417-
{
1418-
getAcousticModelResponse = response.Result;
1419-
Log.Debug("SpeechToTextServiceV1IntegrationTests", "CheckAcousticModelStatus: {0}", getAcousticModelResponse.Status);
1420-
if (getAcousticModelResponse.Status != AcousticModel.StatusValue.READY)
1421-
{
1422-
Runnable.Run(CheckAcousticModelStatus());
1423-
}
1424-
else
1436+
try
1437+
{
1438+
service.GetAcousticModel(
1439+
callback: (DetailedResponse<AcousticModel> response, IBMError error, Dictionary<string, object> customResponseData) =>
14251440
{
1426-
isAcousticModelReady = true;
1427-
}
1428-
},
1429-
customizationId: acousticModelCustomizationId,
1430-
customData: customData
1431-
);
1441+
getAcousticModelResponse = response.Result;
1442+
Log.Debug("SpeechToTextServiceV1IntegrationTests", "CheckAcousticModelStatus: {0}", getAcousticModelResponse.Status);
1443+
if (getAcousticModelResponse.Status != AcousticModel.StatusValue.READY)
1444+
{
1445+
Runnable.Run(CheckAcousticModelStatus());
1446+
}
1447+
else
1448+
{
1449+
isAcousticModelReady = true;
1450+
}
1451+
},
1452+
customizationId: acousticModelCustomizationId,
1453+
customData: customData
1454+
);
1455+
}
1456+
catch
1457+
{
1458+
Runnable.Run(CheckAcousticModelStatus());
1459+
}
14321460

14331461
while (getAcousticModelResponse == null)
14341462
yield return null;
@@ -1443,25 +1471,32 @@ private IEnumerator CheckAudioStatus()
14431471

14441472
Log.Debug("SpeechToTextServiceV1IntegrationTests", "Attempting to GetAudio...");
14451473
AudioListing getAudioResponse = null;
1446-
service.GetAudio(
1447-
callback: (DetailedResponse<AudioListing> response, IBMError error, Dictionary<string, object> customResponseData) =>
1448-
{
1449-
getAudioResponse = response.Result;
1450-
Log.Debug("SpeechToTextServiceV1IntegrationTests", "CheckAudioStatus: {0}", getAudioResponse.Status);
1451-
1452-
if (getAudioResponse.Status != AudioListing.StatusValue.OK)
1453-
{
1454-
Runnable.Run(CheckAudioStatus());
1455-
}
1456-
else
1474+
try
1475+
{
1476+
service.GetAudio(
1477+
callback: (DetailedResponse<AudioListing> response, IBMError error, Dictionary<string, object> customResponseData) =>
14571478
{
1458-
isAudioReady = true;
1459-
}
1460-
},
1461-
customizationId: acousticModelCustomizationId,
1462-
audioName: acousticResourceName,
1463-
customData: customData
1464-
);
1479+
getAudioResponse = response.Result;
1480+
Log.Debug("SpeechToTextServiceV1IntegrationTests", "CheckAudioStatus: {0}", getAudioResponse.Status);
1481+
1482+
if (getAudioResponse.Status != AudioListing.StatusValue.OK)
1483+
{
1484+
Runnable.Run(CheckAudioStatus());
1485+
}
1486+
else
1487+
{
1488+
isAudioReady = true;
1489+
}
1490+
},
1491+
customizationId: acousticModelCustomizationId,
1492+
audioName: acousticResourceName,
1493+
customData: customData
1494+
);
1495+
}
1496+
catch
1497+
{
1498+
Runnable.Run(CheckAudioStatus());
1499+
}
14651500

14661501
while (getAudioResponse == null)
14671502
yield return null;

0 commit comments

Comments
 (0)