Search in sources :

Example 6 with Agent

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

the class SessionEntityTypesClientTest method listSessionEntityTypesTest.

@Test
public void listSessionEntityTypesTest() throws Exception {
    SessionEntityType responsesElement = SessionEntityType.newBuilder().build();
    ListSessionEntityTypesResponse expectedResponse = ListSessionEntityTypesResponse.newBuilder().setNextPageToken("").addAllSessionEntityTypes(Arrays.asList(responsesElement)).build();
    mockSessionEntityTypes.addResponse(expectedResponse);
    SessionName parent = SessionName.ofProjectLocationAgentSessionName("[PROJECT]", "[LOCATION]", "[AGENT]", "[SESSION]");
    ListSessionEntityTypesPagedResponse pagedListResponse = client.listSessionEntityTypes(parent);
    List<SessionEntityType> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getSessionEntityTypesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockSessionEntityTypes.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListSessionEntityTypesRequest actualRequest = ((ListSessionEntityTypesRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListSessionEntityTypesPagedResponse(com.google.cloud.dialogflow.cx.v3.SessionEntityTypesClient.ListSessionEntityTypesPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Test(org.junit.Test)

Example 7 with Agent

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

the class FlowsClientTest method listFlowsTest.

@Test
public void listFlowsTest() throws Exception {
    Flow responsesElement = Flow.newBuilder().build();
    ListFlowsResponse expectedResponse = ListFlowsResponse.newBuilder().setNextPageToken("").addAllFlows(Arrays.asList(responsesElement)).build();
    mockFlows.addResponse(expectedResponse);
    AgentName parent = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]");
    ListFlowsPagedResponse pagedListResponse = client.listFlows(parent);
    List<Flow> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getFlowsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockFlows.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListFlowsRequest actualRequest = ((ListFlowsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListFlowsPagedResponse(com.google.cloud.dialogflow.cx.v3.FlowsClient.ListFlowsPagedResponse) Test(org.junit.Test)

Example 8 with Agent

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

the class IntentsClientTest method listIntentsTest.

@Test
public void listIntentsTest() throws Exception {
    Intent responsesElement = Intent.newBuilder().build();
    ListIntentsResponse expectedResponse = ListIntentsResponse.newBuilder().setNextPageToken("").addAllIntents(Arrays.asList(responsesElement)).build();
    mockIntents.addResponse(expectedResponse);
    AgentName parent = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]");
    ListIntentsPagedResponse pagedListResponse = client.listIntents(parent);
    List<Intent> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getIntentsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockIntents.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListIntentsRequest actualRequest = ((ListIntentsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListIntentsPagedResponse(com.google.cloud.dialogflow.cx.v3.IntentsClient.ListIntentsPagedResponse) Test(org.junit.Test)

Example 9 with Agent

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

the class ITSystemTest method listAgentsTest.

@Test
public void listAgentsTest() {
    ListAgentsRequest request = ListAgentsRequest.newBuilder().setParent(PARENT.toString()).build();
    Iterable<Agent> agents = agentsClient.listAgents(request).iterateAll();
    boolean isAgentExists = false;
    for (Agent agent : agents) {
        if (agentName.equals(agent.getName())) {
            assertAgentDetails(agent);
            isAgentExists = true;
        }
    }
    assertTrue(isAgentExists);
}
Also used : Agent(com.google.cloud.dialogflow.cx.v3beta1.Agent) ListAgentsRequest(com.google.cloud.dialogflow.cx.v3beta1.ListAgentsRequest) Test(org.junit.Test)

Example 10 with Agent

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

the class ExportAgentIT method setUp.

@Before
public void setUp() throws IOException {
    stdOut = new ByteArrayOutputStream();
    System.setOut(new PrintStream(stdOut));
    Builder build = Agent.newBuilder();
    build.setDefaultLanguageCode("en");
    build.setDisplayName("temp_agent_" + UUID.randomUUID().toString());
    build.setTimeZone("America/Los_Angeles");
    Agent agent = build.build();
    String apiEndpoint = "global-dialogflow.googleapis.com:443";
    String parentPath = "projects/" + PROJECT_ID + "/locations/global";
    AgentsSettings agentsSettings = AgentsSettings.newBuilder().setEndpoint(apiEndpoint).build();
    AgentsClient client = AgentsClient.create(agentsSettings);
    parent = client.createAgent(parentPath, agent).getName();
    ExportAgentIT.agentPath = parent;
    ExportAgentIT.agentID = parent.split("/")[5];
    client.close();
}
Also used : PrintStream(java.io.PrintStream) Agent(com.google.cloud.dialogflow.cx.v3.Agent) AgentsSettings(com.google.cloud.dialogflow.cx.v3.AgentsSettings) AgentsClient(com.google.cloud.dialogflow.cx.v3.AgentsClient) Builder(com.google.cloud.dialogflow.cx.v3.Agent.Builder) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Before(org.junit.Before)

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