|
77 | 77 | import com.ibm.watson.developer_cloud.discovery.v1.model.UpdateTrainingExampleOptions; |
78 | 78 | import com.ibm.watson.developer_cloud.discovery.v1.query.AggregationType; |
79 | 79 | import com.ibm.watson.developer_cloud.discovery.v1.query.Operator; |
| 80 | +import com.ibm.watson.developer_cloud.http.HttpMediaType; |
80 | 81 | import com.ibm.watson.developer_cloud.service.exception.ForbiddenException; |
81 | 82 | import com.ibm.watson.developer_cloud.service.exception.NotFoundException; |
82 | 83 | import com.ibm.watson.developer_cloud.service.exception.UnauthorizedException; |
@@ -121,7 +122,6 @@ public class DiscoveryServiceIT extends WatsonServiceTest { |
121 | 122 | // Constants for enum fields |
122 | 123 | private static final Long FREE = 0L; |
123 | 124 |
|
124 | | - private static final String APPLICATION_JSON = "application/json"; |
125 | 125 | private static final String DISCOVERY_TEST_CONFIG_FILE = "src/test/resources/discovery/test-config.json"; |
126 | 126 | private static final String DISCOVERY1_TEST_CONFIG_FILE = "src/test/resources/discovery/issue517.json"; |
127 | 127 | private static final String DISCOVERY2_TEST_CONFIG_FILE = "src/test/resources/discovery/issue518.json"; |
@@ -320,7 +320,7 @@ public void exampleIsSuccessful() { |
320 | 320 |
|
321 | 321 | AddDocumentOptions.Builder createDocumentBuilder = |
322 | 322 | new AddDocumentOptions.Builder(environmentId, collectionId); |
323 | | - createDocumentBuilder.file(documentStream).fileContentType(APPLICATION_JSON); |
| 323 | + createDocumentBuilder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON); |
324 | 324 | DocumentAccepted createDocumentResponse = discovery.addDocument(createDocumentBuilder.build()).execute(); |
325 | 325 | documentId = createDocumentResponse.getDocumentId(); |
326 | 326 | System.out.println("Created a document ID: " + documentId); |
@@ -765,7 +765,7 @@ public void addDocumentIsSuccessful() { |
765 | 765 | AddDocumentOptions.Builder builder = new AddDocumentOptions.Builder(); |
766 | 766 | builder.environmentId(environmentId); |
767 | 767 | builder.collectionId(collection.getCollectionId()); |
768 | | - builder.file(documentStream).fileContentType(APPLICATION_JSON); |
| 768 | + builder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON); |
769 | 769 | DocumentAccepted createResponse = discovery.addDocument(builder.build()).execute(); |
770 | 770 |
|
771 | 771 | assertFalse(createResponse.getDocumentId().isEmpty()); |
@@ -783,7 +783,7 @@ public void addDocumentWithConfigurationIsSuccessful() { |
783 | 783 | AddDocumentOptions.Builder builder = new AddDocumentOptions.Builder(); |
784 | 784 | builder.environmentId(environmentId); |
785 | 785 | builder.collectionId(collection.getCollectionId()); |
786 | | - builder.file(documentStream).fileContentType(APPLICATION_JSON); |
| 786 | + builder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON); |
787 | 787 | DocumentAccepted createResponse = discovery.addDocument(builder.build()).execute(); |
788 | 788 |
|
789 | 789 | assertFalse(createResponse.getDocumentId().isEmpty()); |
@@ -803,7 +803,7 @@ public void addDocumentWithMetadataIsSuccessful() { |
803 | 803 | myMetadata.add("foo", new JsonPrimitive("bar")); |
804 | 804 |
|
805 | 805 | AddDocumentOptions.Builder builder = new AddDocumentOptions.Builder(environmentId, collectionId); |
806 | | - builder.file(documentStream).fileContentType(APPLICATION_JSON); |
| 806 | + builder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON); |
807 | 807 | builder.metadata(myMetadata.toString()); |
808 | 808 |
|
809 | 809 | DocumentAccepted createResponse = discovery.addDocument(builder.build()).execute(); |
@@ -855,7 +855,7 @@ public void updateDocumentIsSuccessful() { |
855 | 855 |
|
856 | 856 | UpdateDocumentOptions.Builder updateBuilder = |
857 | 857 | new UpdateDocumentOptions.Builder(environmentId, collectionId, documentAccepted.getDocumentId()); |
858 | | - updateBuilder.file(documentStream).fileContentType(APPLICATION_JSON); |
| 858 | + updateBuilder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON); |
859 | 859 | //updateBuilder.configurationId(testConfig.getConfigurationId()); |
860 | 860 | DocumentAccepted updateResponse = discovery.updateDocument(updateBuilder.build()).execute(); |
861 | 861 |
|
@@ -884,7 +884,7 @@ public void updateAnotherDocumentIsSuccessful() { |
884 | 884 |
|
885 | 885 | UpdateDocumentOptions.Builder updateBuilder = |
886 | 886 | new UpdateDocumentOptions.Builder(environmentId, collectionId, documentAccepted.getDocumentId()); |
887 | | - updateBuilder.file(documentStream).fileContentType(APPLICATION_JSON); |
| 887 | + updateBuilder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON); |
888 | 888 | DocumentAccepted updateResponse = discovery.updateDocument(updateBuilder.build()).execute(); |
889 | 889 |
|
890 | 890 | GetDocumentStatusOptions getOptions = |
@@ -910,7 +910,7 @@ public void updateDocumentWithMetadataIsSuccessful() { |
910 | 910 |
|
911 | 911 | UpdateDocumentOptions.Builder updateBuilder = |
912 | 912 | new UpdateDocumentOptions.Builder(environmentId, collectionId, documentAccepted.getDocumentId()); |
913 | | - updateBuilder.file(documentStream).fileContentType(APPLICATION_JSON); |
| 913 | + updateBuilder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON); |
914 | 914 | updateBuilder.metadata(myMetadata.toString()); |
915 | 915 | DocumentAccepted updateResponse = discovery.updateDocument(updateBuilder.build()).execute(); |
916 | 916 |
|
@@ -1193,7 +1193,7 @@ public void testConfigurationInEnvironmentIsSuccessful() { |
1193 | 1193 | TestConfigurationInEnvironmentOptions options = |
1194 | 1194 | new TestConfigurationInEnvironmentOptions.Builder(environmentId) |
1195 | 1195 | .configurationId(testConfig.getConfigurationId()) |
1196 | | - .file(documentStream).fileContentType(APPLICATION_JSON) |
| 1196 | + .file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON) |
1197 | 1197 | .build(); |
1198 | 1198 | TestDocument testResponse = discovery.testConfigurationInEnvironment(options).execute(); |
1199 | 1199 | assertNotNull(testResponse); |
@@ -1212,7 +1212,7 @@ public void testConfigurationInEnvironmentWithAllOptionsIsSuccessful() { |
1212 | 1212 | builder.environmentId(environmentId); |
1213 | 1213 | builder.configurationId(testConfig.getConfigurationId()); |
1214 | 1214 | builder.step(TestConfigurationInEnvironmentOptions.Step.HTML_OUTPUT); |
1215 | | - builder.file(documentStream).fileContentType(APPLICATION_JSON); |
| 1215 | + builder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON); |
1216 | 1216 | builder.metadata(myMetadata.toString()); |
1217 | 1217 | TestDocument testResponse = discovery.testConfigurationInEnvironment(builder.build()).execute(); |
1218 | 1218 |
|
@@ -1549,7 +1549,7 @@ private DocumentAccepted createTestDocument(String collectionId) { |
1549 | 1549 | private DocumentAccepted createTestDocument(String json, String collectionId) { |
1550 | 1550 | InputStream documentStream = new ByteArrayInputStream(json.getBytes()); |
1551 | 1551 | AddDocumentOptions.Builder builder = new AddDocumentOptions.Builder(environmentId, collectionId); |
1552 | | - builder.file(documentStream).fileContentType(APPLICATION_JSON); |
| 1552 | + builder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON); |
1553 | 1553 | DocumentAccepted createResponse = discovery.addDocument(builder.build()).execute(); |
1554 | 1554 | WaitFor.Condition documentAccepted = |
1555 | 1555 | new WaitForDocumentAccepted(environmentId, collectionId, createResponse.getDocumentId()); |
|