use of org.openstreetmap.osmosis.core.domain.v0_6.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);
}
use of org.openstreetmap.osmosis.core.domain.v0_6.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());
}
use of org.openstreetmap.osmosis.core.domain.v0_6.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));
}
use of org.openstreetmap.osmosis.core.domain.v0_6.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();
}
use of org.openstreetmap.osmosis.core.domain.v0_6.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);
}
Aggregations