Search in sources :

Example 6 with KnowledgeBaseName

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);
}
Also used : PrintStream(java.io.PrintStream) KnowledgeBase(com.google.cloud.dialogflow.v2beta1.KnowledgeBase) ProjectName(com.google.cloud.dialogflow.v2beta1.ProjectName) KnowledgeBasesClient(com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Before(org.junit.Before)

Example 7 with KnowledgeBaseName

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()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListDocumentsPagedResponse(com.google.cloud.dialogflow.v2beta1.DocumentsClient.ListDocumentsPagedResponse) Test(org.junit.Test)

Example 8 with KnowledgeBaseName

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);
}
Also used : KnowledgeBase(com.google.cloud.dialogflow.v2beta1.KnowledgeBase) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 KnowledgeAnswers (com.google.cloud.dialogflow.v2beta1.KnowledgeAnswers)2 Answer (com.google.cloud.dialogflow.v2beta1.KnowledgeAnswers.Answer)2 KnowledgeBase (com.google.cloud.dialogflow.v2beta1.KnowledgeBase)2 KnowledgeBasesClient (com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient)2 ConversationProfile (com.google.cloud.dialogflow.v2.ConversationProfile)1 ConversationProfilesClient (com.google.cloud.dialogflow.v2.ConversationProfilesClient)1 SuggestionConfig (com.google.cloud.dialogflow.v2.HumanAgentAssistantConfig.SuggestionConfig)1 SuggestionFeatureConfig (com.google.cloud.dialogflow.v2.HumanAgentAssistantConfig.SuggestionFeatureConfig)1 KnowledgeBaseName (com.google.cloud.dialogflow.v2.KnowledgeBaseName)1 LocationName (com.google.cloud.dialogflow.v2.LocationName)1 CreateDocumentRequest (com.google.cloud.dialogflow.v2beta1.CreateDocumentRequest)1 DeleteKnowledgeBaseRequest (com.google.cloud.dialogflow.v2beta1.DeleteKnowledgeBaseRequest)1 DetectIntentRequest (com.google.cloud.dialogflow.v2beta1.DetectIntentRequest)1 DetectIntentResponse (com.google.cloud.dialogflow.v2beta1.DetectIntentResponse)1 Document (com.google.cloud.dialogflow.v2beta1.Document)1 KnowledgeType (com.google.cloud.dialogflow.v2beta1.Document.KnowledgeType)1 DocumentName (com.google.cloud.dialogflow.v2beta1.DocumentName)1 DocumentsClient (com.google.cloud.dialogflow.v2beta1.DocumentsClient)1 ListDocumentsPagedResponse (com.google.cloud.dialogflow.v2beta1.DocumentsClient.ListDocumentsPagedResponse)1