use of com.google.cloud.dialogflow.cx.v3beta1.Agent in project java-dialogflow-cx by googleapis.
the class EnvironmentsClientTest method lookupEnvironmentHistoryTest.
@Test
public void lookupEnvironmentHistoryTest() throws Exception {
Environment responsesElement = Environment.newBuilder().build();
LookupEnvironmentHistoryResponse expectedResponse = LookupEnvironmentHistoryResponse.newBuilder().setNextPageToken("").addAllEnvironments(Arrays.asList(responsesElement)).build();
mockEnvironments.addResponse(expectedResponse);
EnvironmentName name = EnvironmentName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]");
LookupEnvironmentHistoryPagedResponse pagedListResponse = client.lookupEnvironmentHistory(name);
List<Environment> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getEnvironmentsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockEnvironments.getRequests();
Assert.assertEquals(1, actualRequests.size());
LookupEnvironmentHistoryRequest actualRequest = ((LookupEnvironmentHistoryRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.dialogflow.cx.v3beta1.Agent in project java-dialogflow-cx by googleapis.
the class EnvironmentsClientTest method listContinuousTestResultsTest.
@Test
public void listContinuousTestResultsTest() throws Exception {
ContinuousTestResult responsesElement = ContinuousTestResult.newBuilder().build();
ListContinuousTestResultsResponse expectedResponse = ListContinuousTestResultsResponse.newBuilder().setNextPageToken("").addAllContinuousTestResults(Arrays.asList(responsesElement)).build();
mockEnvironments.addResponse(expectedResponse);
EnvironmentName parent = EnvironmentName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]");
ListContinuousTestResultsPagedResponse pagedListResponse = client.listContinuousTestResults(parent);
List<ContinuousTestResult> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getContinuousTestResultsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockEnvironments.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListContinuousTestResultsRequest actualRequest = ((ListContinuousTestResultsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.dialogflow.cx.v3beta1.Agent in project java-dialogflow-cx by googleapis.
the class EnvironmentsClientTest method listEnvironmentsTest.
@Test
public void listEnvironmentsTest() throws Exception {
Environment responsesElement = Environment.newBuilder().build();
ListEnvironmentsResponse expectedResponse = ListEnvironmentsResponse.newBuilder().setNextPageToken("").addAllEnvironments(Arrays.asList(responsesElement)).build();
mockEnvironments.addResponse(expectedResponse);
AgentName parent = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]");
ListEnvironmentsPagedResponse pagedListResponse = client.listEnvironments(parent);
List<Environment> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getEnvironmentsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockEnvironments.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListEnvironmentsRequest actualRequest = ((ListEnvironmentsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.dialogflow.cx.v3beta1.Agent in project java-dialogflow-cx by googleapis.
the class EntityTypesClientTest method listEntityTypesTest.
@Test
public void listEntityTypesTest() throws Exception {
EntityType responsesElement = EntityType.newBuilder().build();
ListEntityTypesResponse expectedResponse = ListEntityTypesResponse.newBuilder().setNextPageToken("").addAllEntityTypes(Arrays.asList(responsesElement)).build();
mockEntityTypes.addResponse(expectedResponse);
AgentName parent = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]");
ListEntityTypesPagedResponse pagedListResponse = client.listEntityTypes(parent);
List<EntityType> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getEntityTypesList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockEntityTypes.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListEntityTypesRequest actualRequest = ((ListEntityTypesRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.dialogflow.cx.v3beta1.Agent in project java-dialogflow-cx by googleapis.
the class ITSystemTest method restoreAgentTest.
@Test
public void restoreAgentTest() throws ExecutionException, InterruptedException {
Agent agent = Agent.newBuilder().setDisplayName("test_agent_" + UUID.randomUUID().toString()).setDescription(DESCRIPTION).setTimeZone(AGENT_TIME_ZONE).setDefaultLanguageCode(DEFAULT_LANGUAGE_CODE).setEnableStackdriverLogging(true).setEnableSpellCorrection(true).build();
Agent response = agentsClient.createAgent(PARENT, agent);
String agentName = response.getName();
try {
/* Replaces the current agent with a new one. Note that all existing resources in agent (e.g.
* intents, entity types, flows) will be removed
*/
RestoreAgentRequest restoreAgentRequest = RestoreAgentRequest.newBuilder().setName(agentName).build();
OperationFuture<Empty, Struct> operationFuture = agentsClient.restoreAgentAsync(restoreAgentRequest);
assertNotEquals(agentName, operationFuture.getName());
} finally {
DeleteAgentRequest deleteAgentRequest = DeleteAgentRequest.newBuilder().setName(agentName).build();
agentsClient.deleteAgent(deleteAgentRequest);
}
}
Aggregations