Search in sources :

Example 26 with EntityType

use of org.openstreetmap.osmosis.core.domain.v0_6.EntityType in project entity-service by hypertrace.

the class EntityTypeCachingClientTest method supportsMultipleConcurrentCacheKeys.

@Test
void supportsMultipleConcurrentCacheKeys() throws Exception {
    EntityType defaultRetrieved = this.grpcTestContext.call(() -> this.typeClient.get("first").blockingGet());
    assertSame(this.type1, defaultRetrieved);
    verify(this.mockTypeService, times(1)).queryEntityTypes(any(), any());
    RequestContext otherMockContext = mock(RequestContext.class);
    when(otherMockContext.getTenantId()).thenReturn(Optional.of("other tenant"));
    Context otherGrpcContext = Context.current().withValue(RequestContext.CURRENT, otherMockContext);
    EntityType otherContextType = EntityType.newBuilder(this.type1).build();
    this.responseTypes = List.of(otherContextType);
    EntityType otherRetrieved = otherGrpcContext.call(() -> this.typeClient.get("first").blockingGet());
    assertSame(otherContextType, otherRetrieved);
    assertNotSame(defaultRetrieved, otherRetrieved);
    verify(this.mockTypeService, times(2)).queryEntityTypes(any(), any());
    verifyNoMoreInteractions(this.mockTypeService);
    assertSame(defaultRetrieved, this.grpcTestContext.call(() -> this.typeClient.get("first").blockingGet()));
    assertSame(otherRetrieved, otherGrpcContext.call(() -> this.typeClient.get("first").blockingGet()));
}
Also used : EntityType(org.hypertrace.entity.type.service.v2.EntityType) RequestContext(org.hypertrace.core.grpcutils.context.RequestContext) Context(io.grpc.Context) RequestContext(org.hypertrace.core.grpcutils.context.RequestContext) Test(org.junit.jupiter.api.Test)

Aggregations

EntityType (org.openstreetmap.osmosis.core.domain.v0_6.EntityType)12 RelationMember (org.openstreetmap.osmosis.core.domain.v0_6.RelationMember)9 Test (org.junit.Test)5 EntityType (com.google.cloud.dialogflow.cx.v3beta1.EntityType)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 CreateEntityTypeRequest (com.google.cloud.dialogflow.cx.v3beta1.CreateEntityTypeRequest)1 CreateFlowRequest (com.google.cloud.dialogflow.cx.v3beta1.CreateFlowRequest)1