|
28 | 28 | import com.ibm.watson.developer_cloud.assistant.v1.model.CreateWorkspaceOptions; |
29 | 29 | import com.ibm.watson.developer_cloud.assistant.v1.model.DeleteUserDataOptions; |
30 | 30 | import com.ibm.watson.developer_cloud.assistant.v1.model.DialogNodeAction; |
| 31 | +import com.ibm.watson.developer_cloud.assistant.v1.model.GetWorkspaceOptions; |
31 | 32 | import com.ibm.watson.developer_cloud.assistant.v1.model.InputData; |
32 | 33 | import com.ibm.watson.developer_cloud.assistant.v1.model.ListAllLogsOptions; |
33 | 34 | import com.ibm.watson.developer_cloud.assistant.v1.model.ListMentionsOptions; |
34 | 35 | import com.ibm.watson.developer_cloud.assistant.v1.model.Mentions; |
| 36 | +import com.ibm.watson.developer_cloud.assistant.v1.model.MessageContextMetadata; |
35 | 37 | import com.ibm.watson.developer_cloud.assistant.v1.model.MessageOptions; |
36 | 38 | import com.ibm.watson.developer_cloud.assistant.v1.model.MessageResponse; |
37 | 39 | import com.ibm.watson.developer_cloud.assistant.v1.model.RuntimeEntity; |
|
61 | 63 | import static org.junit.Assert.assertArrayEquals; |
62 | 64 | import static org.junit.Assert.assertEquals; |
63 | 65 | import static org.junit.Assert.assertNotNull; |
| 66 | +import static org.junit.Assert.assertTrue; |
64 | 67 |
|
65 | 68 | /** |
66 | 69 | * Unit tests for the {@link Assistant}. |
@@ -194,10 +197,15 @@ public void testSendMessageWithAlternateIntents() throws IOException, Interrupte |
194 | 197 | MessageResponse mockResponse = loadFixture(FIXTURE, MessageResponse.class); |
195 | 198 | server.enqueue(jsonResponse(mockResponse)); |
196 | 199 |
|
| 200 | + MessageContextMetadata metadata = new MessageContextMetadata(); |
197 | 201 | Context contextTemp = new Context(); |
198 | 202 | contextTemp.put("name", "Myname"); |
| 203 | + contextTemp.setMetadata(metadata); |
199 | 204 | InputData inputTemp = new InputData.Builder("My text").build(); |
200 | 205 |
|
| 206 | + assertEquals("Myname", contextTemp.get("name")); |
| 207 | + assertEquals(metadata, contextTemp.getMetadata()); |
| 208 | + |
201 | 209 | MessageOptions options = new MessageOptions.Builder(WORKSPACE_ID) |
202 | 210 | .input(inputTemp) |
203 | 211 | .alternateIntents(false) |
@@ -466,6 +474,25 @@ public void testUpdateWorkspaceOptionsBuilder() { |
466 | 474 | assertEquals(options2.dialogNodes().get(0), testDialogNode2); |
467 | 475 | } |
468 | 476 |
|
| 477 | + @Test |
| 478 | + public void testGetWorkspaceOptionsBuilder() { |
| 479 | + String workspaceId = "workspace_id"; |
| 480 | + String sort = GetWorkspaceOptions.Sort.STABLE; |
| 481 | + |
| 482 | + GetWorkspaceOptions getWorkspaceOptions = new GetWorkspaceOptions.Builder() |
| 483 | + .workspaceId(workspaceId) |
| 484 | + .export(true) |
| 485 | + .includeAudit(true) |
| 486 | + .sort(sort) |
| 487 | + .build(); |
| 488 | + getWorkspaceOptions = getWorkspaceOptions.newBuilder().build(); |
| 489 | + |
| 490 | + assertEquals(workspaceId, getWorkspaceOptions.workspaceId()); |
| 491 | + assertTrue(getWorkspaceOptions.export()); |
| 492 | + assertTrue(getWorkspaceOptions.includeAudit()); |
| 493 | + assertEquals(sort, getWorkspaceOptions.sort()); |
| 494 | + } |
| 495 | + |
469 | 496 | @Test |
470 | 497 | public void testCreateExampleOptionsBuilder() { |
471 | 498 | Mentions mentions1 = new Mentions(); |
@@ -889,4 +916,17 @@ public void testListMentionsBuilder() { |
889 | 916 | assertEquals(listMentionsOptions.export(), true); |
890 | 917 | assertEquals(listMentionsOptions.includeAudit(), true); |
891 | 918 | } |
| 919 | + |
| 920 | + @Test |
| 921 | + public void testMessageContextMetadata() { |
| 922 | + String deployment = "deployment"; |
| 923 | + String userId = "user_id"; |
| 924 | + |
| 925 | + MessageContextMetadata messageContextMetadata = new MessageContextMetadata(); |
| 926 | + messageContextMetadata.setDeployment(deployment); |
| 927 | + messageContextMetadata.setUserId(userId); |
| 928 | + |
| 929 | + assertEquals(deployment, messageContextMetadata.getDeployment()); |
| 930 | + assertEquals(userId, messageContextMetadata.getUserId()); |
| 931 | + } |
892 | 932 | } |
0 commit comments