RedisLastKnownValueStoreProvider provider = new RedisLastKnownValueStoreProvider();
provider.setServer(REDIS_SERVER);
provider.setGlobalPrefix(generatePrefix("testBasicFunctionality"));
provider.setWriteThrough(true);
MutableFudgeMsg msg = OpenGammaFudgeContext.getInstance().newMessage();
LastKnownValueStore store = provider.newInstance(ExternalId.of("Test", "testBasicFunctionality"), "no-norm");
FudgeMsg currFields = store.getFields();
assertTrue(currFields.isEmpty());
msg.add("bid", 1.0d);
msg.add("ask", 2.0d);
store.updateFields(msg);
currFields = store.getFields();
assertEquals(1.0d, currFields.getDouble("bid"), 0.0005d);
assertEquals(2.0d, currFields.getDouble("ask"), 0.0005d);
// Reset the store.
store = provider.newInstance(ExternalId.of("Test", "testBasicFunctionality"), "no-norm");
currFields = store.getFields();
assertEquals(1.0d, currFields.getDouble("bid"), 0.0005d);
assertEquals(2.0d, currFields.getDouble("ask"), 0.0005d);
// Write through another value and confirm it works.
msg = OpenGammaFudgeContext.getInstance().newMessage();
msg.add("bid", 5.0d);
store.updateFields(msg);
store = provider.newInstance(ExternalId.of("Test", "testBasicFunctionality"), "no-norm");
currFields = store.getFields();
assertEquals(5.0d, currFields.getDouble("bid"), 0.0005d);
assertEquals(2.0d, currFields.getDouble("ask"), 0.0005d);
// Reset the store. This time don't write through.
provider.setWriteThrough(false);
store = provider.newInstance(ExternalId.of("Test", "testBasicFunctionality"), "no-norm");
currFields = store.getFields();
assertEquals(5.0d, currFields.getDouble("bid"), 0.0005d);
assertEquals(2.0d, currFields.getDouble("ask"), 0.0005d);
msg = OpenGammaFudgeContext.getInstance().newMessage();
msg.add("bid", 3.0d);
msg.add("ask", 4.0d);
store.updateFields(msg);
currFields = store.getFields();
assertEquals(3.0d, currFields.getDouble("bid"), 0.0005d);
assertEquals(4.0d, currFields.getDouble("ask"), 0.0005d);