|
26 | 26 | import com.ibm.watson.developer_cloud.discovery.v1.model.CreateConfigurationOptions; |
27 | 27 | import com.ibm.watson.developer_cloud.discovery.v1.model.CreateCredentialsOptions; |
28 | 28 | import com.ibm.watson.developer_cloud.discovery.v1.model.CreateEnvironmentOptions; |
| 29 | +import com.ibm.watson.developer_cloud.discovery.v1.model.CreateEventOptions; |
| 30 | +import com.ibm.watson.developer_cloud.discovery.v1.model.CreateEventResponse; |
29 | 31 | import com.ibm.watson.developer_cloud.discovery.v1.model.CreateExpansionsOptions; |
30 | 32 | import com.ibm.watson.developer_cloud.discovery.v1.model.CreateTrainingExampleOptions; |
31 | 33 | import com.ibm.watson.developer_cloud.discovery.v1.model.CredentialDetails; |
|
46 | 48 | import com.ibm.watson.developer_cloud.discovery.v1.model.Enrichment; |
47 | 49 | import com.ibm.watson.developer_cloud.discovery.v1.model.EnrichmentOptions; |
48 | 50 | import com.ibm.watson.developer_cloud.discovery.v1.model.Environment; |
| 51 | +import com.ibm.watson.developer_cloud.discovery.v1.model.EventData; |
49 | 52 | import com.ibm.watson.developer_cloud.discovery.v1.model.Expansion; |
50 | 53 | import com.ibm.watson.developer_cloud.discovery.v1.model.Expansions; |
51 | 54 | import com.ibm.watson.developer_cloud.discovery.v1.model.Filter; |
|
69 | 72 | import com.ibm.watson.developer_cloud.discovery.v1.model.ListEnvironmentsResponse; |
70 | 73 | import com.ibm.watson.developer_cloud.discovery.v1.model.ListExpansionsOptions; |
71 | 74 | import com.ibm.watson.developer_cloud.discovery.v1.model.ListTrainingDataOptions; |
| 75 | +import com.ibm.watson.developer_cloud.discovery.v1.model.LogQueryResponse; |
| 76 | +import com.ibm.watson.developer_cloud.discovery.v1.model.MetricResponse; |
| 77 | +import com.ibm.watson.developer_cloud.discovery.v1.model.MetricTokenResponse; |
72 | 78 | import com.ibm.watson.developer_cloud.discovery.v1.model.Nested; |
73 | 79 | import com.ibm.watson.developer_cloud.discovery.v1.model.NluEnrichmentEmotion; |
74 | 80 | import com.ibm.watson.developer_cloud.discovery.v1.model.NluEnrichmentEntities; |
|
79 | 85 | import com.ibm.watson.developer_cloud.discovery.v1.model.NormalizationOperation; |
80 | 86 | import com.ibm.watson.developer_cloud.discovery.v1.model.NormalizationOperation.Operation; |
81 | 87 | import com.ibm.watson.developer_cloud.discovery.v1.model.QueryAggregation; |
| 88 | +import com.ibm.watson.developer_cloud.discovery.v1.model.QueryLogOptions; |
82 | 89 | import com.ibm.watson.developer_cloud.discovery.v1.model.QueryNoticesOptions; |
83 | 90 | import com.ibm.watson.developer_cloud.discovery.v1.model.QueryNoticesResponse; |
84 | 91 | import com.ibm.watson.developer_cloud.discovery.v1.model.QueryOptions; |
|
143 | 150 | @RunWith(RetryRunner.class) |
144 | 151 | public class DiscoveryServiceIT extends WatsonServiceTest { |
145 | 152 |
|
146 | | - // Constants for enum fields |
147 | | - private static final Long FREE = 0L; |
148 | | - |
149 | 153 | private static final String DISCOVERY_TEST_CONFIG_FILE = "src/test/resources/discovery/test-config.json"; |
150 | 154 | private static final String DISCOVERY1_TEST_CONFIG_FILE = "src/test/resources/discovery/issue517.json"; |
151 | 155 | private static final String DISCOVERY2_TEST_CONFIG_FILE = "src/test/resources/discovery/issue518.json"; |
@@ -207,7 +211,7 @@ public void setup() throws Exception { |
207 | 211 | String username = getProperty("discovery.username"); |
208 | 212 | String password = getProperty("discovery.password"); |
209 | 213 | String url = getProperty("discovery.url"); |
210 | | - discovery = new Discovery("2017-11-07"); |
| 214 | + discovery = new Discovery("2018-05-23"); |
211 | 215 | discovery.setEndPoint(url); |
212 | 216 | discovery.setUsernameAndPassword(username, password); |
213 | 217 |
|
@@ -1821,6 +1825,71 @@ public void credentialsOperationsAreSuccessful() { |
1821 | 1825 | } |
1822 | 1826 | } |
1823 | 1827 |
|
| 1828 | + @Test |
| 1829 | + public void createEventIsSuccessful() { |
| 1830 | + // create test document |
| 1831 | + DocumentAccepted accepted = createTestDocument("event_file", collectionId); |
| 1832 | + |
| 1833 | + // make query to get session_token |
| 1834 | + QueryOptions queryOptions = new QueryOptions.Builder() |
| 1835 | + .environmentId(environmentId) |
| 1836 | + .collectionId(collectionId) |
| 1837 | + .naturalLanguageQuery("field number 1") |
| 1838 | + .build(); |
| 1839 | + QueryResponse queryResponse = discovery.query(queryOptions).execute(); |
| 1840 | + String sessionToken = queryResponse.getSessionToken(); |
| 1841 | + |
| 1842 | + // make createEvent call |
| 1843 | + EventData eventData = new EventData(); |
| 1844 | + eventData.setEnvironmentId(environmentId); |
| 1845 | + eventData.setCollectionId(collectionId); |
| 1846 | + eventData.setDocumentId(accepted.getDocumentId()); |
| 1847 | + eventData.setSessionToken(sessionToken); |
| 1848 | + CreateEventOptions createEventOptions = new CreateEventOptions.Builder() |
| 1849 | + .type(CreateEventOptions.Type.CLICK) |
| 1850 | + .data(eventData) |
| 1851 | + .build(); |
| 1852 | + CreateEventResponse response = discovery.createEvent(createEventOptions).execute(); |
| 1853 | + |
| 1854 | + assertNotNull(response); |
| 1855 | + } |
| 1856 | + |
| 1857 | + @Test |
| 1858 | + public void queryLogIsSuccessful() { |
| 1859 | + LogQueryResponse response = discovery.queryLog().execute(); |
| 1860 | + assertNotNull(response); |
| 1861 | + } |
| 1862 | + |
| 1863 | + @Test |
| 1864 | + public void getMetricsEventRateIsSuccessful() { |
| 1865 | + MetricResponse response = discovery.getMetricsEventRate().execute(); |
| 1866 | + assertNotNull(response); |
| 1867 | + } |
| 1868 | + |
| 1869 | + @Test |
| 1870 | + public void getMetricsQueryIsSuccessful() { |
| 1871 | + MetricResponse response = discovery.getMetricsQuery().execute(); |
| 1872 | + assertNotNull(response); |
| 1873 | + } |
| 1874 | + |
| 1875 | + @Test |
| 1876 | + public void getMetricsQueryEventIsSuccessful() { |
| 1877 | + MetricResponse response = discovery.getMetricsQueryEvent().execute(); |
| 1878 | + assertNotNull(response); |
| 1879 | + } |
| 1880 | + |
| 1881 | + @Test |
| 1882 | + public void getMetricsQueryNoResultsIsSuccessful() { |
| 1883 | + MetricResponse response = discovery.getMetricsQueryNoResults().execute(); |
| 1884 | + assertNotNull(response); |
| 1885 | + } |
| 1886 | + |
| 1887 | + @Test |
| 1888 | + public void getMetricsQueryTokenEventIsSuccessful() { |
| 1889 | + MetricTokenResponse response = discovery.getMetricsQueryTokenEvent().execute(); |
| 1890 | + assertNotNull(response); |
| 1891 | + } |
| 1892 | + |
1824 | 1893 | private Environment createEnvironment(CreateEnvironmentOptions createOptions) { |
1825 | 1894 | Environment createResponse = discovery.createEnvironment(createOptions).execute(); |
1826 | 1895 | return createResponse; |
|
0 commit comments