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()));
}
Aggregations