/** * Creates a target map on a substrate. */ private <N, E extends N> void createTargetOn(ValueContext<N, E> context) { DocumentBasedBasicMap<E, String, Integer> target = DocumentBasedBasicMap.create(DefaultDocumentEventRouter.create(context.doc), context.container, Serializer.STRING, Serializer.INTEGER, ENTRY_TAG, KEY_ATTR, VALUE_ATTR); // Eventually, the target map and the substrate should be sufficient state for all tests. // However, in order to simulate document events, the two need to be wrapped together in a // FungeStack so that Java knows that the element type-parameters match. stack = new FungeStack<N, E, String, Integer>( context, target, Serializer.STRING, Serializer.INTEGER); }
/** * Adds an entry to the target map's underlying state. This simulates a * concurrent modification by some other agent. * * @param key * @param value */ private void addEntry(String key, Integer value) { stack.addEntry(key, value); }
/** * Asserts that the test-target's document substrate is in an expected state. * * @param expected list of entries describing the expected state */ private void assertSubstrateEquals(ListBuilder<String, Integer> expected) { stack.assertSubstrateEquals(expected); }
/** * Creates a target map on a substrate. */ private <N, E extends N> void createTargetOn(ValueContext<N, E> context) { DocumentBasedBasicMap<E, String, Integer> target = DocumentBasedBasicMap.create(DefaultDocumentEventRouter.create(context.doc), context.container, Serializer.STRING, Serializer.INTEGER, ENTRY_TAG, KEY_ATTR, VALUE_ATTR); // Eventually, the target map and the substrate should be sufficient state for all tests. // However, in order to simulate document events, the two need to be wrapped together in a // FungeStack so that Java knows that the element type-parameters match. stack = new FungeStack<N, E, String, Integer>( context, target, Serializer.STRING, Serializer.INTEGER); }
/** * Adds an entry to the target map's underlying state. This simulates a * concurrent modification by some other agent. * * @param key * @param value */ private void addEntry(String key, Integer value) { stack.addEntry(key, value); }
/** * Remove entries with the specified keys from the target map's underlying state. * This simulates a concurrent modification by some other agent. */ private void removeEntries(String key) { stack.removeEntries(key); }
/** * Remove entries with the specified keys from the target map's underlying state. * This simulates a concurrent modification by some other agent. */ private void removeEntries(String key) { stack.removeEntries(key); }
/** * Asserts that the test-target's document substrate is in an expected state. * * @param expected list of entries describing the expected state */ private void assertSubstrateEquals(ListBuilder<String, Integer> expected) { stack.assertSubstrateEquals(expected); }