Search in sources :

Example 26 with Agent

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()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) LookupEnvironmentHistoryPagedResponse(com.google.cloud.dialogflow.cx.v3beta1.EnvironmentsClient.LookupEnvironmentHistoryPagedResponse) Test(org.junit.Test)

Example 27 with Agent

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()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListContinuousTestResultsPagedResponse(com.google.cloud.dialogflow.cx.v3beta1.EnvironmentsClient.ListContinuousTestResultsPagedResponse) Test(org.junit.Test)

Example 28 with Agent

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()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListEnvironmentsPagedResponse(com.google.cloud.dialogflow.cx.v3beta1.EnvironmentsClient.ListEnvironmentsPagedResponse) Test(org.junit.Test)

Example 29 with Agent

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()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListEntityTypesPagedResponse(com.google.cloud.dialogflow.cx.v3beta1.EntityTypesClient.ListEntityTypesPagedResponse) Test(org.junit.Test)

Example 30 with Agent

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);
    }
}
Also used : Agent(com.google.cloud.dialogflow.cx.v3beta1.Agent) Empty(com.google.protobuf.Empty) DeleteAgentRequest(com.google.cloud.dialogflow.cx.v3beta1.DeleteAgentRequest) RestoreAgentRequest(com.google.cloud.dialogflow.cx.v3beta1.RestoreAgentRequest) Struct(com.google.protobuf.Struct) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)23 AbstractMessage (com.google.protobuf.AbstractMessage)18 Agent (com.google.cloud.dialogflow.cx.v3.Agent)4 Builder (com.google.cloud.dialogflow.cx.v3.Agent.Builder)4 AgentsClient (com.google.cloud.dialogflow.cx.v3.AgentsClient)4 AgentsSettings (com.google.cloud.dialogflow.cx.v3.AgentsSettings)4 Agent (com.google.cloud.dialogflow.cx.v3beta1.Agent)4 Agent (com.google.cloud.dialogflow.v2.Agent)3 ArrayList (java.util.ArrayList)3 AgentName (com.google.cloud.dialogflow.cx.v3beta1.AgentName)2 ListAgentsPagedResponse (com.google.cloud.dialogflow.cx.v3beta1.AgentsClient.ListAgentsPagedResponse)2 Flow (com.google.cloud.dialogflow.cx.v3beta1.Flow)2 Intent (com.google.cloud.dialogflow.cx.v3beta1.Intent)2 Page (com.google.cloud.dialogflow.cx.v3beta1.Page)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)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