Search in sources :

Example 11 with EntityType

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

the class EntityTypesClientTest method listEntityTypesTest3.

@Test
public void listEntityTypesTest3() throws Exception {
    EntityType responsesElement = EntityType.newBuilder().build();
    ListEntityTypesResponse expectedResponse = ListEntityTypesResponse.newBuilder().setNextPageToken("").addAllEntityTypes(Arrays.asList(responsesElement)).build();
    mockEntityTypes.addResponse(expectedResponse);
    AgentName parent = AgentName.ofProjectName("[PROJECT]");
    String languageCode = "languageCode-2092349083";
    ListEntityTypesPagedResponse pagedListResponse = client.listEntityTypes(parent, languageCode);
    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.assertEquals(languageCode, actualRequest.getLanguageCode());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListEntityTypesPagedResponse(com.google.cloud.dialogflow.v2.EntityTypesClient.ListEntityTypesPagedResponse) Test(org.junit.Test)

Example 12 with EntityType

use of com.google.cloud.dialogflow.v2.EntityType in project java-dialogflow 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.ofProjectName("[PROJECT]");
    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.v2.EntityTypesClient.ListEntityTypesPagedResponse) Test(org.junit.Test)

Example 13 with EntityType

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

the class ITSystemTest method setUp.

@BeforeClass
public static void setUp() throws IOException {
    agentsClient = AgentsClient.create();
    /* create entity */
    entityTypesClient = EntityTypesClient.create();
    EntityType createEntityType = EntityType.newBuilder().setDisplayName(ENTITY_NAME).setKind(EntityType.Kind.KIND_LIST).addEntities(ENTITY).build();
    CreateEntityTypeRequest entityTypeRequest = CreateEntityTypeRequest.newBuilder().setParent(PROJECT_AGENT_NAME.toString()).setEntityType(createEntityType).build();
    entityType = entityTypesClient.createEntityType(entityTypeRequest);
    entityName = entityType.getName().substring(entityType.getName().lastIndexOf("/")).replace("/", "");
    entityTypeName = EntityTypeName.of(PROJECT_ID, entityName);
    /* create intents */
    intentsClient = IntentsClient.create();
    Intent createIntent = Intent.newBuilder().setDisplayName(INTENT_NAME).addEvents(EVENT_NAME).setAction(ACTION_NAME).build();
    CreateIntentRequest intentRequest = CreateIntentRequest.newBuilder().setParent(PROJECT_AGENT_NAME.toString()).setIntent(createIntent).build();
    intent = intentsClient.createIntent(intentRequest);
    intentId = intent.getName().substring(intent.getName().lastIndexOf("/")).replace("/", "");
    intentName = IntentName.of(PROJECT_ID, intentId);
    /* create session */
    sessionsClient = SessionsClient.create();
    /* create context */
    contextsClient = ContextsClient.create();
    Context createContext = Context.newBuilder().setName(CONTEXT_NAME.toString()).setLifespanCount(LIFE_SPAN_COUNT).build();
    CreateContextRequest request = CreateContextRequest.newBuilder().setParent(SESSION_NAME.toString()).setContext(createContext).build();
    context = contextsClient.createContext(request);
}
Also used : EntityType(com.google.cloud.dialogflow.v2.EntityType) Context(com.google.cloud.dialogflow.v2.Context) CreateContextRequest(com.google.cloud.dialogflow.v2.CreateContextRequest) CreateEntityTypeRequest(com.google.cloud.dialogflow.v2.CreateEntityTypeRequest) Intent(com.google.cloud.dialogflow.v2.Intent) CreateIntentRequest(com.google.cloud.dialogflow.v2.CreateIntentRequest) BeforeClass(org.junit.BeforeClass)

Example 14 with EntityType

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

the class ITSystemTest method getEntityTypeTest.

@Test
public void getEntityTypeTest() {
    EntityType actualEntity = entityTypesClient.getEntityType(entityTypeName);
    assertEquals(entityType.getName(), actualEntity.getName());
    assertEquals(ENTITY_NAME, actualEntity.getDisplayName());
    assertEquals(entityType.getEntities(0), actualEntity.getEntities(0));
    assertEquals(1, actualEntity.getEntitiesCount());
}
Also used : EntityType(com.google.cloud.dialogflow.v2.EntityType) Test(org.junit.Test)

Example 15 with EntityType

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

the class ITSystemTest method listEntityTypesTest.

@Test
public void listEntityTypesTest() {
    ListEntityTypesRequest request = ListEntityTypesRequest.newBuilder().setParent(PROJECT_AGENT_NAME.toString()).build();
    for (EntityType actualEntity : entityTypesClient.listEntityTypes(request).iterateAll()) {
        if (entityType.getName().equals(actualEntity.getName())) {
            assertEquals(entityType.getName(), actualEntity.getName());
            assertEquals(ENTITY_NAME, actualEntity.getDisplayName());
            assertEquals(entityType.getEntities(0), actualEntity.getEntities(0));
            assertEquals(1, actualEntity.getEntitiesCount());
        }
    }
}
Also used : EntityType(com.google.cloud.dialogflow.v2.EntityType) ListEntityTypesRequest(com.google.cloud.dialogflow.v2.ListEntityTypesRequest) Test(org.junit.Test)

Aggregations

EntityType (org.openstreetmap.osmosis.core.domain.v0_6.EntityType)12 Test (org.junit.Test)9 RelationMember (org.openstreetmap.osmosis.core.domain.v0_6.RelationMember)9 EntityType (com.google.cloud.dialogflow.cx.v3beta1.EntityType)4 ListEntityTypesPagedResponse (com.google.cloud.dialogflow.v2.EntityTypesClient.ListEntityTypesPagedResponse)4 AbstractMessage (com.google.protobuf.AbstractMessage)4 EntityType (org.hypertrace.entity.type.service.v1.EntityType)4 Test (org.junit.jupiter.api.Test)4 EntityType (com.google.cloud.dialogflow.v2.EntityType)3 ServiceException (com.google.protobuf.ServiceException)3 JSONDocument (org.hypertrace.core.documentstore.JSONDocument)3 EntityType (org.hypertrace.entity.type.service.v2.EntityType)3 Relation (org.openstreetmap.osmosis.core.domain.v0_6.Relation)3 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)2 Osmformat (crosby.binary.Osmformat)2 IOException (java.io.IOException)2 Document (org.hypertrace.core.documentstore.Document)2 SingleValueKey (org.hypertrace.core.documentstore.SingleValueKey)2 BeforeClass (org.junit.BeforeClass)2 Agent (com.google.cloud.dialogflow.cx.v3beta1.Agent)1