Search in sources :

Example 1 with AgentName

use of com.google.cloud.dialogflow.cx.v3beta1.AgentName in project java-dialogflow-cx by googleapis.

the class ChangelogsClientTest method listChangelogsTest.

@Test
public void listChangelogsTest() throws Exception {
    Changelog responsesElement = Changelog.newBuilder().build();
    ListChangelogsResponse expectedResponse = ListChangelogsResponse.newBuilder().setNextPageToken("").addAllChangelogs(Arrays.asList(responsesElement)).build();
    mockChangelogs.addResponse(expectedResponse);
    AgentName parent = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]");
    ListChangelogsPagedResponse pagedListResponse = client.listChangelogs(parent);
    List<Changelog> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getChangelogsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockChangelogs.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListChangelogsRequest actualRequest = ((ListChangelogsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListChangelogsPagedResponse(com.google.cloud.dialogflow.cx.v3beta1.ChangelogsClient.ListChangelogsPagedResponse) Test(org.junit.Test)

Example 2 with AgentName

use of com.google.cloud.dialogflow.cx.v3beta1.AgentName in project java-dialogflow-cx by googleapis.

the class ITSystemTest method tearDown.

@AfterClass
public static void tearDown() {
    /* delete version */
    DeleteVersionRequest deleteVersionRequest = DeleteVersionRequest.newBuilder().setName(versionName).build();
    versionsClient.deleteVersion(deleteVersionRequest);
    versionsClient.close();
    /* delete transition route groups */
    DeleteTransitionRouteGroupRequest deleteTransitionRouteGroupRequest = DeleteTransitionRouteGroupRequest.newBuilder().setName(transitionRouteGroupName).build();
    transitionRouteGroupsClient.deleteTransitionRouteGroup(deleteTransitionRouteGroupRequest);
    transitionRouteGroupsClient.close();
    /* delete session */
    sessionsClient.close();
    /* delete pages */
    DeletePageRequest deletePageRequest = DeletePageRequest.newBuilder().setName(pageName).build();
    pagesClient.deletePage(deletePageRequest);
    pagesClient.close();
    /* delete intents */
    DeleteIntentRequest deleteIntentRequest = DeleteIntentRequest.newBuilder().setName(intentsName).build();
    intentsClient.deleteIntent(deleteIntentRequest);
    intentsClient.close();
    /* delete flows */
    DeleteFlowRequest deleteFlowRequest = DeleteFlowRequest.newBuilder().setName(flowName).build();
    flowsClient.deleteFlow(deleteFlowRequest);
    DeleteFlowRequest deleteTrainFlowRequest = DeleteFlowRequest.newBuilder().setName(trainFlowName).build();
    flowsClient.deleteFlow(deleteTrainFlowRequest);
    flowsClient.close();
    /* delete entity types */
    DeleteEntityTypeRequest deleteEntityTypeRequest = DeleteEntityTypeRequest.newBuilder().setName(entityTypesName).build();
    entityTypesClient.deleteEntityType(deleteEntityTypeRequest);
    entityTypesClient.close();
    /* delete agents */
    DeleteAgentRequest deleteAgentRequest = DeleteAgentRequest.newBuilder().setName(agentName).build();
    agentsClient.deleteAgent(deleteAgentRequest);
    agentsClient.close();
}
Also used : DeleteFlowRequest(com.google.cloud.dialogflow.cx.v3beta1.DeleteFlowRequest) DeleteTransitionRouteGroupRequest(com.google.cloud.dialogflow.cx.v3beta1.DeleteTransitionRouteGroupRequest) DeletePageRequest(com.google.cloud.dialogflow.cx.v3beta1.DeletePageRequest) DeleteEntityTypeRequest(com.google.cloud.dialogflow.cx.v3beta1.DeleteEntityTypeRequest) DeleteAgentRequest(com.google.cloud.dialogflow.cx.v3beta1.DeleteAgentRequest) DeleteVersionRequest(com.google.cloud.dialogflow.cx.v3beta1.DeleteVersionRequest) DeleteIntentRequest(com.google.cloud.dialogflow.cx.v3beta1.DeleteIntentRequest) AfterClass(org.junit.AfterClass)

Example 3 with AgentName

use of com.google.cloud.dialogflow.cx.v3beta1.AgentName in project java-dialogflow-cx by googleapis.

the class ITSystemTest method matchIntentTest.

@Test
public void matchIntentTest() {
    String session = String.format("%s/sessions/%s", agentName, ID);
    MatchIntentRequest request = MatchIntentRequest.newBuilder().setSession(session).setQueryInput(QUERY_INPUT).build();
    MatchIntentResponse matchIntentResponse = sessionsClient.matchIntent(request);
    assertTrue(matchIntentResponse.getMatchesList().size() > 0);
    assertEquals(TEXT, matchIntentResponse.getText());
}
Also used : MatchIntentRequest(com.google.cloud.dialogflow.cx.v3beta1.MatchIntentRequest) MatchIntentResponse(com.google.cloud.dialogflow.cx.v3beta1.MatchIntentResponse) Test(org.junit.Test)

Example 4 with AgentName

use of com.google.cloud.dialogflow.cx.v3beta1.AgentName in project java-dialogflow-cx by googleapis.

the class ITSystemTest method listEntityTypesTest.

@Test
public void listEntityTypesTest() {
    ListEntityTypesRequest request = ListEntityTypesRequest.newBuilder().setParent(agentName).build();
    Iterable<EntityType> entityTypes = entityTypesClient.listEntityTypes(request).iterateAll();
    boolean isEntityTypeExists = false;
    for (EntityType entityType : entityTypes) {
        if (entityTypesName.equals(entityType.getName())) {
            assertEntityTypesDetails(entityType);
            isEntityTypeExists = true;
        }
    }
    assertTrue(isEntityTypeExists);
}
Also used : EntityType(com.google.cloud.dialogflow.cx.v3beta1.EntityType) ListEntityTypesRequest(com.google.cloud.dialogflow.cx.v3beta1.ListEntityTypesRequest) Test(org.junit.Test)

Example 5 with AgentName

use of com.google.cloud.dialogflow.cx.v3beta1.AgentName in project java-dialogflow-cx by googleapis.

the class ITSystemTest method listFlowsTest.

@Test
public void listFlowsTest() {
    ListFlowsRequest request = ListFlowsRequest.newBuilder().setParent(agentName).build();
    FlowsClient.ListFlowsPagedResponse pagedListResponse = flowsClient.listFlows(request);
    List<Flow> flows = Lists.newArrayList(pagedListResponse.iterateAll());
    boolean isFlowExists = false;
    for (Flow flow : flows) {
        if (flow.getName().equals(flowName)) {
            assertFlowDetails(flow);
            isFlowExists = true;
        }
    }
    assertTrue(isFlowExists);
}
Also used : FlowsClient(com.google.cloud.dialogflow.cx.v3beta1.FlowsClient) ListFlowsRequest(com.google.cloud.dialogflow.cx.v3beta1.ListFlowsRequest) Flow(com.google.cloud.dialogflow.cx.v3beta1.Flow) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)15 AbstractMessage (com.google.protobuf.AbstractMessage)7 ArrayList (java.util.ArrayList)4 Agent (com.google.cloud.dialogflow.cx.v3beta1.Agent)3 Flow (com.google.cloud.dialogflow.cx.v3beta1.Flow)3 Intent (com.google.cloud.dialogflow.cx.v3beta1.Intent)3 AgentName (com.google.cloud.dialogflow.v2.AgentName)3 Intent (com.google.cloud.dialogflow.v2.Intent)3 IntentsClient (com.google.cloud.dialogflow.v2.IntentsClient)3 AgentName (com.google.cloud.dialogflow.cx.v3beta1.AgentName)2 DeleteAgentRequest (com.google.cloud.dialogflow.cx.v3beta1.DeleteAgentRequest)2 EntityType (com.google.cloud.dialogflow.cx.v3beta1.EntityType)2 FlowsClient (com.google.cloud.dialogflow.cx.v3beta1.FlowsClient)2 IntentsClient (com.google.cloud.dialogflow.cx.v3beta1.IntentsClient)2 ListChangelogsPagedResponse (com.google.cloud.dialogflow.cx.v3beta1.ChangelogsClient.ListChangelogsPagedResponse)1 CreateEntityTypeRequest (com.google.cloud.dialogflow.cx.v3beta1.CreateEntityTypeRequest)1 CreateFlowRequest (com.google.cloud.dialogflow.cx.v3beta1.CreateFlowRequest)1 CreateIntentRequest (com.google.cloud.dialogflow.cx.v3beta1.CreateIntentRequest)1 CreatePageRequest (com.google.cloud.dialogflow.cx.v3beta1.CreatePageRequest)1 CreateTransitionRouteGroupRequest (com.google.cloud.dialogflow.cx.v3beta1.CreateTransitionRouteGroupRequest)1