Search in sources :

Example 26 with Agent

use of com.google.cloud.dialogflow.cx.v3.Agent in project java-dialogflow by googleapis.

the class SetAgent method setAgent.

public static Agent setAgent(String parent, String displayName) throws IOException {
    AgentsSettings agentsSettings = AgentsSettings.newBuilder().build();
    try (AgentsClient client = AgentsClient.create(agentsSettings)) {
        // Set the details of the Agent to create
        Builder build = Agent.newBuilder();
        build.setDefaultLanguageCode("en");
        build.setDisplayName(displayName);
        Agent agent = build.build();
        // Make API request to create agent
        Agent response = client.setAgent(agent);
        System.out.println(response);
        return response;
    }
}
Also used : Agent(com.google.cloud.dialogflow.v2.Agent) AgentsSettings(com.google.cloud.dialogflow.v2.AgentsSettings) AgentsClient(com.google.cloud.dialogflow.v2.AgentsClient) Builder(com.google.cloud.dialogflow.v2.Agent.Builder)

Example 27 with Agent

use of com.google.cloud.dialogflow.cx.v3.Agent in project java-dialogflow by googleapis.

the class ITSystemTest method getAgentTest.

@Test
public void getAgentTest() {
    GetAgentRequest request = GetAgentRequest.newBuilder().setParent(PROJECT_NAME.toString()).build();
    Agent actualAgent = agentsClient.getAgent(request);
    assertEquals(PROJECT_NAME.toString(), actualAgent.getParent());
    assertEquals(DISPLAY_NAME, actualAgent.getDisplayName());
    assertEquals(DEFAULT_LANGUAGE_CODE, actualAgent.getDefaultLanguageCode());
    assertEquals(TIME_ZONE, actualAgent.getTimeZone());
    assertEquals(Agent.MatchMode.MATCH_MODE_HYBRID, actualAgent.getMatchMode());
    assertEquals(Agent.ApiVersion.API_VERSION_V2, actualAgent.getApiVersion());
    assertEquals(Agent.Tier.TIER_STANDARD, actualAgent.getTier());
}
Also used : Agent(com.google.cloud.dialogflow.v2.Agent) GetAgentRequest(com.google.cloud.dialogflow.v2.GetAgentRequest) Test(org.junit.Test)

Example 28 with Agent

use of com.google.cloud.dialogflow.cx.v3.Agent in project java-dialogflow-cx by googleapis.

the class TestCasesClientTest method listTestCasesTest.

@Test
public void listTestCasesTest() throws Exception {
    TestCase responsesElement = TestCase.newBuilder().build();
    ListTestCasesResponse expectedResponse = ListTestCasesResponse.newBuilder().setNextPageToken("").addAllTestCases(Arrays.asList(responsesElement)).build();
    mockTestCases.addResponse(expectedResponse);
    AgentName parent = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]");
    ListTestCasesPagedResponse pagedListResponse = client.listTestCases(parent);
    List<TestCase> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getTestCasesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockTestCases.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListTestCasesRequest actualRequest = ((ListTestCasesRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListTestCasesPagedResponse(com.google.cloud.dialogflow.cx.v3.TestCasesClient.ListTestCasesPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Test(org.junit.Test)

Example 29 with Agent

use of com.google.cloud.dialogflow.cx.v3.Agent in project java-dialogflow-cx by googleapis.

the class WebhooksClientTest method listWebhooksTest.

@Test
public void listWebhooksTest() throws Exception {
    Webhook responsesElement = Webhook.newBuilder().build();
    ListWebhooksResponse expectedResponse = ListWebhooksResponse.newBuilder().setNextPageToken("").addAllWebhooks(Arrays.asList(responsesElement)).build();
    mockWebhooks.addResponse(expectedResponse);
    AgentName parent = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]");
    ListWebhooksPagedResponse pagedListResponse = client.listWebhooks(parent);
    List<Webhook> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getWebhooksList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockWebhooks.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListWebhooksRequest actualRequest = ((ListWebhooksRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListWebhooksPagedResponse(com.google.cloud.dialogflow.cx.v3.WebhooksClient.ListWebhooksPagedResponse) Test(org.junit.Test)

Example 30 with Agent

use of com.google.cloud.dialogflow.cx.v3.Agent in project java-dialogflow-cx by googleapis.

the class AgentsClientTest method listAgentsTest.

@Test
public void listAgentsTest() throws Exception {
    Agent responsesElement = Agent.newBuilder().build();
    ListAgentsResponse expectedResponse = ListAgentsResponse.newBuilder().setNextPageToken("").addAllAgents(Arrays.asList(responsesElement)).build();
    mockAgents.addResponse(expectedResponse);
    LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    ListAgentsPagedResponse pagedListResponse = client.listAgents(parent);
    List<Agent> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getAgentsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockAgents.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListAgentsRequest actualRequest = ((ListAgentsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListAgentsPagedResponse(com.google.cloud.dialogflow.cx.v3.AgentsClient.ListAgentsPagedResponse) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)23 AbstractMessage (com.google.protobuf.AbstractMessage)18 AgentsClient (com.google.cloud.dialogflow.cx.v3.AgentsClient)5 AgentsSettings (com.google.cloud.dialogflow.cx.v3.AgentsSettings)5 Agent (com.google.cloud.dialogflow.cx.v3.Agent)4 Builder (com.google.cloud.dialogflow.cx.v3.Agent.Builder)4 Agent (com.google.cloud.dialogflow.cx.v3beta1.Agent)4 Agent (com.google.cloud.dialogflow.v2.Agent)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 ListAgentsPagedResponse (com.google.cloud.dialogflow.cx.v3.AgentsClient.ListAgentsPagedResponse)2 Struct (com.google.protobuf.Struct)2 PrintStream (java.io.PrintStream)2 Agent (lcm2.Agent)2 Action (lcm2.simulation.Action)2 NamespaceBinding (org.sbolstandard.core.datatree.Datatree.NamespaceBinding)2 NamespaceBinding (org.sbolstandard.core.datatree.NamespaceBinding)2 Activity (org.sbolstandard.core2.Activity)2 Agent (org.sbolstandard.core2.Agent)2 ComponentDefinition (org.sbolstandard.core2.ComponentDefinition)2 SBOLDocument (org.sbolstandard.core2.SBOLDocument)2