use of com.google.cloud.dialogflow.v2beta1.KnowledgeBaseName in project java-dialogflow by googleapis.
the class CreateDocumentTest method setUp.
@Before
public void setUp() throws IOException {
// Create a knowledge base for the document
try (KnowledgeBasesClient client = KnowledgeBasesClient.create()) {
KnowledgeBase knowledgeBase = KnowledgeBase.newBuilder().setDisplayName(KNOWLEDGE_DISPLAY_NAME).build();
ProjectName projectName = ProjectName.of(PROJECT_ID);
KnowledgeBase response = client.createKnowledgeBase(projectName, knowledgeBase);
// Save the full name for deletion
knowledgeBaseName = response.getName();
}
bout = new ByteArrayOutputStream();
out = new PrintStream(bout);
System.setOut(out);
}
use of com.google.cloud.dialogflow.v2beta1.KnowledgeBaseName in project java-dialogflow by googleapis.
the class DocumentsClientTest method listDocumentsTest.
@Test
public void listDocumentsTest() throws Exception {
Document responsesElement = Document.newBuilder().build();
ListDocumentsResponse expectedResponse = ListDocumentsResponse.newBuilder().setNextPageToken("").addAllDocuments(Arrays.asList(responsesElement)).build();
mockDocuments.addResponse(expectedResponse);
KnowledgeBaseName parent = KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]");
ListDocumentsPagedResponse pagedListResponse = client.listDocuments(parent);
List<Document> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getDocumentsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockDocuments.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListDocumentsRequest actualRequest = ((ListDocumentsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.dialogflow.v2beta1.KnowledgeBaseName in project java-dialogflow by googleapis.
the class CreateKnowledgeBaseTest method testCreateKnowledgeBase.
@Test
public void testCreateKnowledgeBase() throws Exception {
KnowledgeBase knowledgeBase = KnowledgeBaseManagement.createKnowledgeBase(PROJECT_ID, KNOWLEDGE_DISPLAY_NAME);
knowledgeBaseName = knowledgeBase.getName();
String got = bout.toString();
assertThat(got).contains(KNOWLEDGE_DISPLAY_NAME);
}
Aggregations