-
Couldn't load subscription status.
- Fork 528
Fix 668 #671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Parent:
Release v6.2.0
Merged
Fix 668 #671
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
.../ibm/watson/developer_cloud/conversation/v1/model/util/PaginationResponseTypeAdapter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| /* | ||
| * Copyright 2017 IBM Corp. All Rights Reserved. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
| * in compliance with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software distributed under the License | ||
| * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
| * or implied. See the License for the specific language governing permissions and limitations under | ||
| * the License. | ||
| */ | ||
| package com.ibm.watson.developer_cloud.conversation.v1.model.util; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
| import com.google.gson.TypeAdapter; | ||
| import com.google.gson.stream.JsonReader; | ||
| import com.google.gson.stream.JsonToken; | ||
| import com.google.gson.stream.JsonWriter; | ||
| import com.ibm.watson.developer_cloud.conversation.v1.model.PaginationResponse; | ||
| import com.ibm.watson.developer_cloud.util.RequestUtils; | ||
|
|
||
| import okhttp3.HttpUrl; | ||
|
|
||
| /** | ||
| * Type adapter to transform JSON into a {@link PaginationResponse} and vice versa. | ||
| */ | ||
| public class PaginationResponseTypeAdapter extends TypeAdapter<PaginationResponse> { | ||
| private static final String MATCHED = "matched"; | ||
| private static final String TOTAL = "total"; | ||
| private static final String NEXT_URL = "next_url"; | ||
| private static final String REFRESH_URL = "refresh_url"; | ||
| private static final String CURSOR = "cursor"; | ||
|
|
||
| /* (non-Javadoc) | ||
| * @see com.google.gson.TypeAdapter#write(com.google.gson.stream.JsonWriter, java.lang.Object) | ||
| */ | ||
| @Override | ||
| public void write(JsonWriter writer, PaginationResponse pagination) throws IOException { | ||
| writer.beginObject(); | ||
| writer.name(REFRESH_URL).value(pagination.getRefreshUrl()); | ||
| writer.name(NEXT_URL).value(pagination.getNextUrl()); | ||
| writer.name(TOTAL).value(pagination.getTotal()); | ||
| writer.name(MATCHED).value(pagination.getMatched()); | ||
| writer.endObject(); | ||
| writer.flush(); | ||
| } | ||
|
|
||
| /* (non-Javadoc) | ||
| * @see com.google.gson.TypeAdapter#read(com.google.gson.stream.JsonReader) | ||
| */ | ||
| @Override | ||
| public PaginationResponse read(JsonReader reader) throws IOException { | ||
| if (reader.peek() == JsonToken.NULL) { | ||
| reader.nextNull(); | ||
| return null; | ||
| } | ||
| reader.beginObject(); | ||
| PaginationResponse pagination = new PaginationResponse(); | ||
| while (reader.hasNext()) { | ||
| String name = reader.nextName(); | ||
| if (name.equals(REFRESH_URL)) { | ||
| pagination.setRefreshUrl(reader.nextString()); | ||
| } else if (name.equals(NEXT_URL)) { | ||
| String nextUrl = reader.nextString(); | ||
| HttpUrl url = HttpUrl.parse(RequestUtils.DEFAULT_ENDPOINT + nextUrl); | ||
| pagination.setCursor(url.queryParameter(CURSOR)); | ||
| pagination.setNextUrl(nextUrl); | ||
| } else if (name.equals(TOTAL)) { | ||
| pagination.setTotal(reader.nextLong()); | ||
| } else if (name.equals(MATCHED)) { | ||
| pagination.setMatched(reader.nextLong()); | ||
| } else { | ||
| reader.skipValue(); | ||
| } | ||
| } | ||
| reader.endObject(); | ||
|
|
||
| return pagination; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
.../watson/developer_cloud/conversation/v1/model/util/PaginationResponseTypeAdapterTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| /* | ||
| * Copyright 2017 IBM Corp. All Rights Reserved. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
| * in compliance with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software distributed under the License | ||
| * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
| * or implied. See the License for the specific language governing permissions and limitations under | ||
| * the License. | ||
| */ | ||
| package com.ibm.watson.developer_cloud.conversation.v1.model.util; | ||
|
|
||
| import static org.junit.Assert.assertEquals; | ||
| import static org.junit.Assert.assertNotNull; | ||
|
|
||
| import java.io.FileNotFoundException; | ||
| import java.io.IOException; | ||
|
|
||
| import org.junit.Test; | ||
|
|
||
| import com.ibm.watson.developer_cloud.WatsonServiceUnitTest; | ||
| import com.ibm.watson.developer_cloud.conversation.v1.model.PaginationResponse; | ||
| import com.ibm.watson.developer_cloud.util.GsonSingleton; | ||
|
|
||
| /** | ||
| * The Class PaginationResponseTypeAdapterTest. | ||
| */ | ||
| public class PaginationResponseTypeAdapterTest extends WatsonServiceUnitTest { | ||
| private static final String FIXTURE = "src/test/resources/conversation/pagination.json"; | ||
|
|
||
| /* (non-Javadoc) | ||
| * @see com.ibm.watson.developer_cloud.WatsonServiceUnitTest#setUp() | ||
| */ | ||
| @Override | ||
| public void setUp() throws Exception { } | ||
|
|
||
| /* (non-Javadoc) | ||
| * @see com.ibm.watson.developer_cloud.WatsonServiceUnitTest#tearDown() | ||
| */ | ||
| @Override | ||
| public void tearDown() throws IOException { } | ||
|
|
||
| /** | ||
| * Test parse type adapter. | ||
| * | ||
| * @throws FileNotFoundException the file not found exception | ||
| */ | ||
| @Test | ||
| public void testParseTypeAdapter() throws FileNotFoundException { | ||
| PaginationResponse pagination = loadFixture(FIXTURE, PaginationResponse.class); | ||
| assertEquals(pagination.getCursor(), "batman"); | ||
| } | ||
|
|
||
| /** | ||
| * Test write type adapter. | ||
| * | ||
| * @throws FileNotFoundException the file not found exception | ||
| */ | ||
| @Test | ||
| public void testWriteTypeAdapter() throws FileNotFoundException { | ||
| PaginationResponse pagination = loadFixture(FIXTURE, PaginationResponse.class); | ||
| assertNotNull(GsonSingleton.getGson().toJson(pagination), pagination.toString()); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "refresh_url": "/v1/workspaces/pizza_app-e0f3/counterexamples?version=2017-12-18&page_limit=2", | ||
| "next_url": "/v1/workspaces/pizza_app-e0f3/counterexamples?cursor=batman&version=2017-12-18&page_limit=2" | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be "Workspace Status".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😭