use of com.tvd12.calabash.persist.factory.BytesMapPersistFactory in project calabash by youngmonkeys.
the class LocalMapPersistExample method test.
@SuppressWarnings("rawtypes")
public void test() {
EzyEntityCodec entityCodec = newEntityCodec();
SimpleSettings settings = new SimpleSettings();
SimpleMapPersistSetting mapPersistSetting = new SimpleMapPersistSetting();
SimpleMapSetting mapSetting = new SimpleMapSetting();
mapSetting.setMapName(CollectionNames.PERSON);
mapSetting.setPersistSetting(mapPersistSetting);
settings.addMapSetting(mapSetting);
EzyBeanContext beanContext = newBeanContext();
SimpleEntityMapPersistFactory.Builder mapPersistFactoryBuilder = SimpleEntityMapPersistFactory.builder();
List mapPersistenceList = beanContext.getSingletons(MapPersistence.class);
for (Object mapPersist : mapPersistenceList) {
String mapName = MapPersistenceAnnotations.getMapName(mapPersist);
mapPersistFactoryBuilder.addMapPersist(mapName, (EntityMapPersist) mapPersist);
}
BytesMapPersistFactory bytesMapPersistFactory = EntityBytesMapPersistFactory.builder().entityCodec(entityCodec).entityMapPersistFactory(mapPersistFactoryBuilder.build()).build();
Calabash calabash = CalabashServerContext.builder().settings(settings).bytesMapPersistFactory(bytesMapPersistFactory).build();
ByteArray keyBytes = new ByteArray(entityCodec.serialize(1L));
byte[] values = entityCodec.serialize(new Person(9L, "bar", 29));
BytesMap bytesMap = calabash.getBytesMap(CollectionNames.PERSON);
bytesMap.put(keyBytes, values);
}
Aggregations