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