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()));
}
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()));
}
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()));
}
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);
}
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();
}
Aggregations