GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Update Discovery test files to use HttpMediaType enums for content type · windofthesky/java-sdk@05d0669

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • discovery/src/test/java/com/ibm/watson/developer_cloud/discovery/v1
    • DiscoveryServiceIT.java
    • DiscoveryServiceTest.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎discovery/src/test/java/com/ibm/watson/developer_cloud/discovery/v1/DiscoveryServiceIT.java‎

Copy file name to clipboardExpand all lines: discovery/src/test/java/com/ibm/watson/developer_cloud/discovery/v1/DiscoveryServiceIT.java
+11-11Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
import com.ibm.watson.developer_cloud.discovery.v1.model.UpdateTrainingExampleOptions;
7878
import com.ibm.watson.developer_cloud.discovery.v1.query.AggregationType;
7979
import com.ibm.watson.developer_cloud.discovery.v1.query.Operator;
80+
import com.ibm.watson.developer_cloud.http.HttpMediaType;
8081
import com.ibm.watson.developer_cloud.service.exception.ForbiddenException;
8182
import com.ibm.watson.developer_cloud.service.exception.NotFoundException;
8283
import com.ibm.watson.developer_cloud.service.exception.UnauthorizedException;
@@ -121,7 +122,6 @@ public class DiscoveryServiceIT extends WatsonServiceTest {
121122
// Constants for enum fields
122123
private static final Long FREE = 0L;
123124

124-
private static final String APPLICATION_JSON = "application/json";
125125
private static final String DISCOVERY_TEST_CONFIG_FILE = "src/test/resources/discovery/test-config.json";
126126
private static final String DISCOVERY1_TEST_CONFIG_FILE = "src/test/resources/discovery/issue517.json";
127127
private static final String DISCOVERY2_TEST_CONFIG_FILE = "src/test/resources/discovery/issue518.json";
@@ -320,7 +320,7 @@ public void exampleIsSuccessful() {
320320

321321
AddDocumentOptions.Builder createDocumentBuilder =
322322
new AddDocumentOptions.Builder(environmentId, collectionId);
323-
createDocumentBuilder.file(documentStream).fileContentType(APPLICATION_JSON);
323+
createDocumentBuilder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON);
324324
DocumentAccepted createDocumentResponse = discovery.addDocument(createDocumentBuilder.build()).execute();
325325
documentId = createDocumentResponse.getDocumentId();
326326
System.out.println("Created a document ID: " + documentId);
@@ -765,7 +765,7 @@ public void addDocumentIsSuccessful() {
765765
AddDocumentOptions.Builder builder = new AddDocumentOptions.Builder();
766766
builder.environmentId(environmentId);
767767
builder.collectionId(collection.getCollectionId());
768-
builder.file(documentStream).fileContentType(APPLICATION_JSON);
768+
builder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON);
769769
DocumentAccepted createResponse = discovery.addDocument(builder.build()).execute();
770770

771771
assertFalse(createResponse.getDocumentId().isEmpty());
@@ -783,7 +783,7 @@ public void addDocumentWithConfigurationIsSuccessful() {
783783
AddDocumentOptions.Builder builder = new AddDocumentOptions.Builder();
784784
builder.environmentId(environmentId);
785785
builder.collectionId(collection.getCollectionId());
786-
builder.file(documentStream).fileContentType(APPLICATION_JSON);
786+
builder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON);
787787
DocumentAccepted createResponse = discovery.addDocument(builder.build()).execute();
788788

789789
assertFalse(createResponse.getDocumentId().isEmpty());
@@ -803,7 +803,7 @@ public void addDocumentWithMetadataIsSuccessful() {
803803
myMetadata.add("foo", new JsonPrimitive("bar"));
804804

805805
AddDocumentOptions.Builder builder = new AddDocumentOptions.Builder(environmentId, collectionId);
806-
builder.file(documentStream).fileContentType(APPLICATION_JSON);
806+
builder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON);
807807
builder.metadata(myMetadata.toString());
808808

809809
DocumentAccepted createResponse = discovery.addDocument(builder.build()).execute();
@@ -855,7 +855,7 @@ public void updateDocumentIsSuccessful() {
855855

856856
UpdateDocumentOptions.Builder updateBuilder =
857857
new UpdateDocumentOptions.Builder(environmentId, collectionId, documentAccepted.getDocumentId());
858-
updateBuilder.file(documentStream).fileContentType(APPLICATION_JSON);
858+
updateBuilder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON);
859859
//updateBuilder.configurationId(testConfig.getConfigurationId());
860860
DocumentAccepted updateResponse = discovery.updateDocument(updateBuilder.build()).execute();
861861

@@ -884,7 +884,7 @@ public void updateAnotherDocumentIsSuccessful() {
884884

885885
UpdateDocumentOptions.Builder updateBuilder =
886886
new UpdateDocumentOptions.Builder(environmentId, collectionId, documentAccepted.getDocumentId());
887-
updateBuilder.file(documentStream).fileContentType(APPLICATION_JSON);
887+
updateBuilder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON);
888888
DocumentAccepted updateResponse = discovery.updateDocument(updateBuilder.build()).execute();
889889

890890
GetDocumentStatusOptions getOptions =
@@ -910,7 +910,7 @@ public void updateDocumentWithMetadataIsSuccessful() {
910910

911911
UpdateDocumentOptions.Builder updateBuilder =
912912
new UpdateDocumentOptions.Builder(environmentId, collectionId, documentAccepted.getDocumentId());
913-
updateBuilder.file(documentStream).fileContentType(APPLICATION_JSON);
913+
updateBuilder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON);
914914
updateBuilder.metadata(myMetadata.toString());
915915
DocumentAccepted updateResponse = discovery.updateDocument(updateBuilder.build()).execute();
916916

@@ -1193,7 +1193,7 @@ public void testConfigurationInEnvironmentIsSuccessful() {
11931193
TestConfigurationInEnvironmentOptions options =
11941194
new TestConfigurationInEnvironmentOptions.Builder(environmentId)
11951195
.configurationId(testConfig.getConfigurationId())
1196-
.file(documentStream).fileContentType(APPLICATION_JSON)
1196+
.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON)
11971197
.build();
11981198
TestDocument testResponse = discovery.testConfigurationInEnvironment(options).execute();
11991199
assertNotNull(testResponse);
@@ -1212,7 +1212,7 @@ public void testConfigurationInEnvironmentWithAllOptionsIsSuccessful() {
12121212
builder.environmentId(environmentId);
12131213
builder.configurationId(testConfig.getConfigurationId());
12141214
builder.step(TestConfigurationInEnvironmentOptions.Step.HTML_OUTPUT);
1215-
builder.file(documentStream).fileContentType(APPLICATION_JSON);
1215+
builder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON);
12161216
builder.metadata(myMetadata.toString());
12171217
TestDocument testResponse = discovery.testConfigurationInEnvironment(builder.build()).execute();
12181218

@@ -1549,7 +1549,7 @@ private DocumentAccepted createTestDocument(String collectionId) {
15491549
private DocumentAccepted createTestDocument(String json, String collectionId) {
15501550
InputStream documentStream = new ByteArrayInputStream(json.getBytes());
15511551
AddDocumentOptions.Builder builder = new AddDocumentOptions.Builder(environmentId, collectionId);
1552-
builder.file(documentStream).fileContentType(APPLICATION_JSON);
1552+
builder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON);
15531553
DocumentAccepted createResponse = discovery.addDocument(builder.build()).execute();
15541554
WaitFor.Condition documentAccepted =
15551555
new WaitForDocumentAccepted(environmentId, collectionId, createResponse.getDocumentId());
Collapse file

‎discovery/src/test/java/com/ibm/watson/developer_cloud/discovery/v1/DiscoveryServiceTest.java‎

Copy file name to clipboardExpand all lines: discovery/src/test/java/com/ibm/watson/developer_cloud/discovery/v1/DiscoveryServiceTest.java
+5-6Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
import com.ibm.watson.developer_cloud.discovery.v1.model.UpdateTrainingExampleOptions;
6262
import com.ibm.watson.developer_cloud.discovery.v1.query.AggregationType;
6363
import com.ibm.watson.developer_cloud.discovery.v1.query.Operator;
64+
import com.ibm.watson.developer_cloud.http.HttpMediaType;
6465
import com.ibm.watson.developer_cloud.util.GsonSingleton;
6566
import okhttp3.mockwebserver.MockResponse;
6667
import okhttp3.mockwebserver.RecordedRequest;
@@ -85,9 +86,7 @@
8586
public class DiscoveryServiceTest extends WatsonServiceUnitTest {
8687
private Discovery discoveryService;
8788

88-
private static final Long FREE = 0L;
8989
private static final Long THREE = 3L;
90-
private static final String APPLICATION_JSON = "application/json";
9190
private static final String VERSION = Discovery.VERSION_DATE_2017_09_01;
9291

9392
private static final String DISCOVERY_TEST_CONFIG_FILE = "src/test/resources/discovery/test-config.json";
@@ -460,7 +459,7 @@ public void addDocumentIsSuccessful() throws InterruptedException {
460459
InputStream documentStream = new ByteArrayInputStream(myDocumentJson.getBytes());
461460

462461
AddDocumentOptions.Builder builder = new AddDocumentOptions.Builder(environmentId, collectionId);
463-
builder.file(documentStream).fileContentType(APPLICATION_JSON);
462+
builder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON);
464463
builder.metadata(myMetadata.toString());
465464
DocumentAccepted response = discoveryService.addDocument(builder.build()).execute();
466465
RecordedRequest request = server.takeRequest();
@@ -498,7 +497,7 @@ public void addDocumentFromInputStreamWithMediaTypeIsSuccessful() throws Interru
498497
InputStream documentStream = new ByteArrayInputStream(myDocumentJson.getBytes());
499498

500499
AddDocumentOptions.Builder builder = new AddDocumentOptions.Builder(environmentId, collectionId);
501-
builder.file(documentStream).fileContentType(APPLICATION_JSON);
500+
builder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON);
502501
builder.metadata(myMetadata.toString());
503502
DocumentAccepted response = discoveryService.addDocument(builder.build()).execute();
504503
RecordedRequest request = server.takeRequest();
@@ -524,7 +523,7 @@ public void addDocumentFromInputStreamWithFileNameAndMediaTypeIsSuccessful() thr
524523
InputStream documentStream = new ByteArrayInputStream(myDocumentJson.getBytes());
525524

526525
AddDocumentOptions.Builder builder = new AddDocumentOptions.Builder(environmentId, collectionId);
527-
builder.file(documentStream).fileContentType(APPLICATION_JSON);
526+
builder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON);
528527
builder.metadata(myMetadata.toString());
529528
DocumentAccepted response = discoveryService.addDocument(builder.build()).execute();
530529
RecordedRequest request = server.takeRequest();
@@ -546,7 +545,7 @@ public void updateDocumentIsSuccessful() throws InterruptedException {
546545
myMetadata.add("foo", new JsonPrimitive("bar"));
547546

548547
InputStream documentStream = new ByteArrayInputStream(myDocumentJson.getBytes());
549-
updateBuilder.file(documentStream).fileContentType(APPLICATION_JSON);
548+
updateBuilder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON);
550549
updateBuilder.metadata(myMetadata.toString());
551550
DocumentAccepted response = discoveryService.updateDocument(updateBuilder.build()).execute();
552551
RecordedRequest request = server.takeRequest();

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.