}
@Test
public void testLongFieldRangeMapping() throws Exception {
byte[] mappingData = IOUtils.toByteArray(getClass().getClassLoader().getResourceAsStream(BASE_PATH + "shardingconfig3.json"));
ShardSelector selector = JsonShardSelectorBuilder.build(mappingData);
IdGenerator idGenerator = new IdGeneratorImpl();
RecordId recordId = idGenerator.newRecordId(Collections.singletonMap("weight", "400"));
String shardName = selector.getShard(recordId);
assertEquals("shard1", shardName);
recordId = idGenerator.newRecordId(Collections.singletonMap("weight", "1000"));
shardName = selector.getShard(recordId);
assertEquals("shard2", shardName);
recordId = idGenerator.newRecordId(Collections.singletonMap("weight", "1200"));
shardName = selector.getShard(recordId);
assertEquals("shard2", shardName);
recordId = idGenerator.newRecordId(Collections.singletonMap("weight", "341234123"));
shardName = selector.getShard(recordId);
assertEquals("shard3", shardName);
recordId = idGenerator.newRecordId(Collections.singletonMap("weight", "abc"));
try {
shardName = selector.getShard(recordId);
fail("Expected an exception");
} catch (ShardSelectorException e) {
// expected
}
}