use of org.janusgraph.diskstorage.keycolumnvalue.StoreFeatures in project janusgraph by JanusGraph.
the class ExpectedValueCheckingTest method setupMocks.
@Before
public void setupMocks() throws BackendException {
// Initialize mock controller
ctrl = EasyMock.createStrictControl();
ctrl.checkOrder(true);
// Setup some config mocks and objects
backingManager = ctrl.createMock(KeyColumnValueStoreManager.class);
LockerProvider lockerProvider = ctrl.createMock(LockerProvider.class);
ModifiableConfiguration globalConfig = GraphDatabaseConfiguration.buildGraphConfiguration();
ModifiableConfiguration localConfig = GraphDatabaseConfiguration.buildGraphConfiguration();
ModifiableConfiguration defaultConfig = GraphDatabaseConfiguration.buildGraphConfiguration();
// Set some properties on the configs, just so that global/local/default can be easily distinguished
globalConfig.set(GraphDatabaseConfiguration.UNIQUE_INSTANCE_ID, "global");
localConfig.set(GraphDatabaseConfiguration.UNIQUE_INSTANCE_ID, "local");
defaultConfig.set(GraphDatabaseConfiguration.UNIQUE_INSTANCE_ID, "default");
BaseTransactionConfig defaultTxConfig = new StandardBaseTransactionConfig.Builder().customOptions(defaultConfig).timestampProvider(TimestampProviders.MICRO).build();
StoreFeatures backingFeatures = new StandardStoreFeatures.Builder().keyConsistent(globalConfig, localConfig).build();
// Setup behavior specification starts below this line
// 1. Construct manager
// The EVCSManager ctor retrieves the backing store's features and stores it in an instance field
expect(backingManager.getFeatures()).andReturn(backingFeatures).once();
// 2. Begin transaction
// EVCTx begins two transactions on the backingManager: one with globalConfig and one with localConfig
// The capture is used in the @After method to check the config
txConfigCapture = EasyMock.newCapture(CaptureType.ALL);
inconsistentTx = ctrl.createMock(StoreTransaction.class);
consistentTx = ctrl.createMock(StoreTransaction.class);
expect(backingManager.beginTransaction(capture(txConfigCapture))).andReturn(inconsistentTx);
expect(backingManager.beginTransaction(capture(txConfigCapture))).andReturn(consistentTx);
// 3. Open a database
backingLocker = ctrl.createMock(Locker.class);
backingStore = ctrl.createMock(KeyColumnValueStore.class);
expect(backingManager.openDatabase(STORE_NAME)).andReturn(backingStore);
expect(backingStore.getName()).andReturn(STORE_NAME);
expect(lockerProvider.getLocker(LOCKER_NAME)).andReturn(backingLocker);
// Carry out setup behavior against mocks
ctrl.replay();
// 1. Construct manager
expectManager = new ExpectedValueCheckingStoreManager(backingManager, LOCK_SUFFIX, lockerProvider, Duration.ofSeconds(1L));
// 2. Begin transaction
expectTx = expectManager.beginTransaction(defaultTxConfig);
// 3. Open a database
expectStore = expectManager.openDatabase(STORE_NAME);
// Verify behavior and reset the mocks for test methods to use
ctrl.verify();
ctrl.reset();
}
Aggregations