use of usercodedeployment.Person in project hazelcast by hazelcast.
the class ClientUserCodeDeploymentTest method testCustomAttributeExtractor.
@Test
public void testCustomAttributeExtractor() {
String mapName = randomMapName();
// this attribute does not exist in the domain class
String attributeName = "syntheticAttribute";
ClientConfig clientConfig = new ClientConfig();
ClientUserCodeDeploymentConfig clientUserCodeDeploymentConfig = new ClientUserCodeDeploymentConfig();
clientUserCodeDeploymentConfig.addClass(CapitalizingFirstNameExtractor.class);
clientUserCodeDeploymentConfig.addClass(Person.class);
clientConfig.setUserCodeDeploymentConfig(clientUserCodeDeploymentConfig.setEnabled(true));
Config config = createNodeConfig();
config.getMapConfig(mapName).addAttributeConfig(new AttributeConfig(attributeName, "usercodedeployment.CapitalizingFirstNameExtractor"));
factory.newHazelcastInstance(config);
factory.newHazelcastInstance(config);
HazelcastInstance client = factory.newHazelcastClient(clientConfig);
IMap<Integer, Person> map = client.getMap(mapName);
map.put(0, new Person("ada"));
map.put(1, new Person("non-ada"));
Set<Map.Entry<Integer, Person>> results = map.entrySet(equal(attributeName, "ADA"));
assertEquals(1, results.size());
assertEquals("ada", results.iterator().next().getValue().getName());
}
Aggregations