Search in sources :

Example 1 with EntityType

use of com.google.cloud.dialogflow.v2.EntityType 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 2 with EntityType

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

the class ITSystemTest method updateEntityTypeTest.

@Test
public void updateEntityTypeTest() {
    EntityType entityType = EntityType.newBuilder().setName(entityTypesName).setKind(EntityType.Kind.KIND_LIST).setDisplayName(DISPLAY_NAME).setKindValue(2).build();
    UpdateEntityTypeRequest updateEntityTypeRequest = UpdateEntityTypeRequest.newBuilder().setEntityType(entityType).build();
    EntityType response = entityTypesClient.updateEntityType(updateEntityTypeRequest);
    assertEquals(2, response.getKindValue());
}
Also used : EntityType(com.google.cloud.dialogflow.cx.v3beta1.EntityType) UpdateEntityTypeRequest(com.google.cloud.dialogflow.cx.v3beta1.UpdateEntityTypeRequest) Test(org.junit.Test)

Example 3 with EntityType

use of com.google.cloud.dialogflow.v2.EntityType in project entity-service by hypertrace.

the class EntityTypeServiceTest method testUpsertAndQueryEntityType.

@Test
public void testUpsertAndQueryEntityType() {
    EntityType entityType1 = EntityType.newBuilder().setName("EntityType1").setTenantId(TENANT_ID).addAttributeType(AttributeType.newBuilder().setName("attr1").setIdentifyingAttribute(true).setValueKind(AttributeKind.TYPE_STRING).build()).addAttributeType(AttributeType.newBuilder().setName("someattr").setValueKind(AttributeKind.TYPE_STRING).build()).build();
    EntityType entityType2 = EntityType.newBuilder().setName("EntityType2").setTenantId(TENANT_ID).addAttributeType(AttributeType.newBuilder().setName("attr2").setIdentifyingAttribute(true).setValueKind(AttributeKind.TYPE_INT64).build()).build();
    client.upsertEntityType(TENANT_ID, entityType1);
    client.upsertEntityType(TENANT_ID, entityType2);
    List<EntityType> entityTypes = client.getAllEntityTypes(TENANT_ID);
    Assertions.assertEquals(2, entityTypes.size());
    Assertions.assertTrue(entityTypes.containsAll(List.of(entityType1, entityType2)));
    entityTypes = client.queryEntityTypes(TENANT_ID, EntityTypeFilter.newBuilder().addName(entityType1.getName()).build());
    Assertions.assertEquals(1, entityTypes.size());
    Assertions.assertTrue(entityTypes.contains(entityType1));
}
Also used : EntityType(org.hypertrace.entity.type.service.v1.EntityType) Test(org.junit.jupiter.api.Test)

Example 4 with EntityType

use of com.google.cloud.dialogflow.v2.EntityType in project entity-service by hypertrace.

the class EntityTypeServiceImpl method queryEntityTypes.

@Override
public void queryEntityTypes(EntityTypeFilter request, StreamObserver<EntityType> responseObserver) {
    Optional<String> tenantId = RequestContext.CURRENT.get().getTenantId();
    if (tenantId.isEmpty()) {
        responseObserver.onError(new ServiceException("Tenant id is missing in the request."));
        return;
    }
    Iterator<Document> entityTypes = entityTypeCol.search(transform(tenantId.get(), request, true));
    while (entityTypes.hasNext()) {
        Document entityType = entityTypes.next();
        EntityType.Builder builder = EntityType.newBuilder();
        try {
            PARSER.merge(entityType.toJson(), builder);
            // Populate the tenant id field with the tenant id that's received for backward
            // compatibility.
            builder.setTenantId(tenantId.get());
        } catch (InvalidProtocolBufferException e) {
            LOG.error("Error processing entityType: {}", entityType.toJson(), e);
            responseObserver.onError(e);
            return;
        }
        responseObserver.onNext(builder.build());
    }
    responseObserver.onCompleted();
}
Also used : EntityType(org.hypertrace.entity.type.service.v1.EntityType) ServiceException(com.google.protobuf.ServiceException) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) Document(org.hypertrace.core.documentstore.Document) JSONDocument(org.hypertrace.core.documentstore.JSONDocument)

Example 5 with EntityType

use of com.google.cloud.dialogflow.v2.EntityType in project osmosis by openstreetmap.

the class RelationMemberElementProcessor method begin.

/**
 * {@inheritDoc}
 */
public void begin(Attributes attributes) {
    long id;
    EntityType type;
    String role;
    id = Long.parseLong(attributes.getValue(ATTRIBUTE_NAME_ID));
    type = memberTypeParser.parse(attributes.getValue(ATTRIBUTE_NAME_TYPE));
    role = attributes.getValue(ATTRIBUTE_NAME_ROLE);
    if (role == null) {
        // this may actually happen
        role = "";
    }
    relationMember = new RelationMember(id, type, role);
}
Also used : EntityType(org.openstreetmap.osmosis.core.domain.v0_6.EntityType) RelationMember(org.openstreetmap.osmosis.core.domain.v0_6.RelationMember)

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