use of com.linkedin.d2.balancer.util.partitions.HashBasedPartitionAccessor in project rest.li by linkedin.
the class URIMapperTestUtil method createHashBasedPartitionInfoProvider.
/**
* Create a mock PartitionInfoProvider that returns {@link HashBasedPartitionAccessor} for testing
*/
public static PartitionInfoProvider createHashBasedPartitionInfoProvider(int partitionCount, String regex) throws ServiceUnavailableException {
PartitionInfoProvider infoProvider = Mockito.mock(PartitionInfoProvider.class);
HashBasedPartitionProperties properties = new HashBasedPartitionProperties(regex, partitionCount, HashBasedPartitionProperties.HashAlgorithm.MODULO);
HashBasedPartitionAccessor accessor = new HashBasedPartitionAccessor(properties);
Mockito.when(infoProvider.getPartitionAccessor(anyObject())).thenReturn(accessor);
return infoProvider;
}
Aggregations