@Test public void testPrecommit() throws Exception { DataStore store1 = mock(DataStore.class); DataStore store2 = mock(DataStore.class); DataStoreTransaction tx1 = mock(DataStoreTransaction.class); DataStoreTransaction tx2 = mock(DataStoreTransaction.class); when(store1.beginReadTransaction()).thenReturn(tx1); when(store2.beginReadTransaction()).thenReturn(tx2); MultiplexManager store = new MultiplexManager(store1, store2); DataStoreTransaction multiplexTx = store.beginReadTransaction(); multiplexTx.preCommit(); verify(tx1).preCommit(); verify(tx2).preCommit(); }
@Override public void preCommit() { transactions.values().forEach(DataStoreTransaction::preCommit); }
MultiplexTransaction implements DataStoreTransaction { @Override public void preCommit() { transactions.values().forEach(DataStoreTransaction::preCommit); } }
MultiplexTransaction implements DataStoreTransaction { @Override public void preCommit() { transactions.values().forEach(DataStoreTransaction::preCommit); } MultiplexTransaction(MultiplexManager multiplexManager); }
MultiplexTransaction implements DataStoreTransaction { @Override public void preCommit() { transactions.values().forEach(DataStoreTransaction::preCommit); } MultiplexTransaction(MultiplexManager multiplexManager); @Override User accessUser(Object opaqueUser); @Override void createObject(Object entity, RequestScope scope); @Override Object loadObject(Class<?> entityClass,
                             Serializable id,
                             Optional<FilterExpression> filterExpression,
                             RequestScope scope); @Override Iterable<Object> loadObjects(
            Class<?> entityClass,
            Optional<FilterExpression> filterExpression,
            Optional<Sorting> sorting,
            Optional<Pagination> pagination,
            RequestScope scope); @Override void flush(RequestScope requestScope); @Override void preCommit(); @Override void commit(RequestScope scope); @Override void close(); @Override Object getRelation(DataStoreTransaction relationTx,
                              Object entity,
                              String relationName,
                              Optional<FilterExpression> filter,
                              Optional<Sorting> sorting,
                              Optional<Pagination> pagination,
                              RequestScope scope); @Override void updateToManyRelation(DataStoreTransaction relationTx,
                                     Object entity, String relationName,
                                     Set<Object> newRelationships,
                                     Set<Object> deletedRelationships,
                                     RequestScope scope); @Override void updateToOneRelation(DataStoreTransaction relationTx, Object entity,
                                    String relationName, Object relationshipValue, RequestScope scope); @Override Object getAttribute(Object entity,
                               String attributeName, RequestScope scope); @Override void setAttribute(Object entity, String attributeName, Object attributeValue, RequestScope scope); @Override FeatureSupport supportsFiltering(Class<?> entityClass, FilterExpression expression); @Override boolean supportsSorting(Class<?> entityClass, Sorting sorting); @Override boolean supportsPagination(Class<?> entityClass); }
MultiplexTransaction implements DataStoreTransaction { @Override public void preCommit() { transactions.values().forEach(DataStoreTransaction::preCommit); } MultiplexTransaction(MultiplexManager multiplexManager); @Override User accessUser(Object opaqueUser); @Override void createObject(Object entity, RequestScope scope); @Override Object loadObject(Class<?> entityClass,
                             Serializable id,
                             Optional<FilterExpression> filterExpression,
                             RequestScope scope); @Override Iterable<Object> loadObjects(
            Class<?> entityClass,
            Optional<FilterExpression> filterExpression,
            Optional<Sorting> sorting,
            Optional<Pagination> pagination,
            RequestScope scope); @Override void flush(RequestScope requestScope); @Override void preCommit(); @Override void commit(RequestScope scope); @Override void close(); @Override Object getRelation(DataStoreTransaction relationTx,
                              Object entity,
                              String relationName,
                              Optional<FilterExpression> filter,
                              Optional<Sorting> sorting,
                              Optional<Pagination> pagination,
                              RequestScope scope); @Override void updateToManyRelation(DataStoreTransaction relationTx,
                                     Object entity, String relationName,
                                     Set<Object> newRelationships,
                                     Set<Object> deletedRelationships,
                                     RequestScope scope); @Override void updateToOneRelation(DataStoreTransaction relationTx, Object entity,
                                    String relationName, Object relationshipValue, RequestScope scope); @Override Object getAttribute(Object entity,
                               String attributeName, RequestScope scope); @Override void setAttribute(Object entity, String attributeName, Object attributeValue, RequestScope scope); @Override FeatureSupport supportsFiltering(Class<?> entityClass, FilterExpression expression); @Override boolean supportsSorting(Class<?> entityClass, Sorting sorting); @Override boolean supportsPagination(Class<?> entityClass);  }