Search in sources :

Example 1 with SearchAgentsRequest

use of com.google.cloud.dialogflow.v2.SearchAgentsRequest in project java-dialogflow by googleapis.

the class AgentsClientTest method searchAgentsTest3.

@Test
public void searchAgentsTest3() throws Exception {
    Agent responsesElement = Agent.newBuilder().build();
    SearchAgentsResponse expectedResponse = SearchAgentsResponse.newBuilder().setNextPageToken("").addAllAgents(Arrays.asList(responsesElement)).build();
    mockAgents.addResponse(expectedResponse);
    String parent = "parent-995424086";
    SearchAgentsPagedResponse pagedListResponse = client.searchAgents(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());
    SearchAgentsRequest actualRequest = ((SearchAgentsRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) SearchAgentsPagedResponse(com.google.cloud.dialogflow.v2.AgentsClient.SearchAgentsPagedResponse) Test(org.junit.Test)

Example 2 with SearchAgentsRequest

use of com.google.cloud.dialogflow.v2.SearchAgentsRequest in project java-dialogflow by googleapis.

the class ITSystemTest method searchAgentsTest.

@Test
public void searchAgentsTest() {
    SearchAgentsRequest request = SearchAgentsRequest.newBuilder().setParent(PROJECT_NAME.toString()).build();
    for (Agent actualAgent : agentsClient.searchAgents(request).iterateAll()) {
        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());
    }
}
Also used : Agent(com.google.cloud.dialogflow.v2.Agent) SearchAgentsRequest(com.google.cloud.dialogflow.v2.SearchAgentsRequest) Test(org.junit.Test)

Example 3 with SearchAgentsRequest

use of com.google.cloud.dialogflow.v2.SearchAgentsRequest in project java-dialogflow by googleapis.

the class AgentsClientTest method searchAgentsTest2.

@Test
public void searchAgentsTest2() throws Exception {
    Agent responsesElement = Agent.newBuilder().build();
    SearchAgentsResponse expectedResponse = SearchAgentsResponse.newBuilder().setNextPageToken("").addAllAgents(Arrays.asList(responsesElement)).build();
    mockAgents.addResponse(expectedResponse);
    ProjectName parent = ProjectName.of("[PROJECT]");
    SearchAgentsPagedResponse pagedListResponse = client.searchAgents(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());
    SearchAgentsRequest actualRequest = ((SearchAgentsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) SearchAgentsPagedResponse(com.google.cloud.dialogflow.v2.AgentsClient.SearchAgentsPagedResponse) Test(org.junit.Test)

Example 4 with SearchAgentsRequest

use of com.google.cloud.dialogflow.v2.SearchAgentsRequest in project java-dialogflow by googleapis.

the class AgentsClientTest method searchAgentsTest.

@Test
public void searchAgentsTest() throws Exception {
    Agent responsesElement = Agent.newBuilder().build();
    SearchAgentsResponse expectedResponse = SearchAgentsResponse.newBuilder().setNextPageToken("").addAllAgents(Arrays.asList(responsesElement)).build();
    mockAgents.addResponse(expectedResponse);
    LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    SearchAgentsPagedResponse pagedListResponse = client.searchAgents(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());
    SearchAgentsRequest actualRequest = ((SearchAgentsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) SearchAgentsPagedResponse(com.google.cloud.dialogflow.v2.AgentsClient.SearchAgentsPagedResponse) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 SearchAgentsPagedResponse (com.google.cloud.dialogflow.v2.AgentsClient.SearchAgentsPagedResponse)3 AbstractMessage (com.google.protobuf.AbstractMessage)3 Agent (com.google.cloud.dialogflow.v2.Agent)1 SearchAgentsRequest (com.google.cloud.dialogflow.v2.SearchAgentsRequest)1