Search in sources :

Example 1 with WrapperMutableMetaDocPart

use of com.torodb.core.transaction.metainf.WrapperMutableMetaDocPart in project torodb by torodb.

the class BatchMetaDocPartTest method setUp.

@Before
@SuppressWarnings("unchecked")
public void setUp() throws Exception {
    testChangeConsumer = mock(Consumer.class);
    delegateChangeConsumer = mock(Consumer.class);
    delegate = new WrapperMutableMetaDocPart(new ImmutableMetaDocPart(tableRefFactory.createRoot(), "docPartId"), delegateChangeConsumer);
    docPart = new BatchMetaDocPart(delegate, testChangeConsumer, true);
}
Also used : WrapperMutableMetaDocPart(com.torodb.core.transaction.metainf.WrapperMutableMetaDocPart) Consumer(java.util.function.Consumer) ImmutableMetaDocPart(com.torodb.core.transaction.metainf.ImmutableMetaDocPart) Before(org.junit.Before)

Example 2 with WrapperMutableMetaDocPart

use of com.torodb.core.transaction.metainf.WrapperMutableMetaDocPart in project torodb by torodb.

the class DefaultToBackendFunctionTest method testNoBatchMetaDocPart.

@Test
public void testNoBatchMetaDocPart() {
    CollectionData collectionData = mock(CollectionData.class);
    DocPartData data1 = mock(DocPartData.class);
    given(data1.getMetaDocPart()).willReturn(new WrapperMutableMetaDocPart(new ImmutableMetaDocPart(tableRefFactory.createRoot(), "aDocPartName"), (o) -> {
    }));
    given(collectionData.orderedDocPartData()).willReturn(Collections.singleton(data1));
    //when
    try {
        fun.apply(collectionData);
        //then
        fail("An exception was expected when a metadoc part which is not a " + BatchMetaDocPart.class + " is used");
    } catch (AssertionError | ClassCastException ex) {
    }
}
Also used : CollectionData(com.torodb.core.d2r.CollectionData) Iterables(com.google.common.collect.Iterables) ImmutableMetaScalar(com.torodb.core.transaction.metainf.ImmutableMetaScalar) Mockito.spy(org.mockito.Mockito.spy) MockSettingsImpl(org.mockito.internal.creation.MockSettingsImpl) BackendTransactionJobFactory(com.torodb.core.dsl.backend.BackendTransactionJobFactory) BackendTransactionJob(com.torodb.core.dsl.backend.BackendTransactionJob) RollbackException(com.torodb.core.transaction.RollbackException) ArrayList(java.util.ArrayList) TableRefFactory(com.torodb.core.TableRefFactory) ImmutableMetaDocPart(com.torodb.core.transaction.metainf.ImmutableMetaDocPart) Lists(com.google.common.collect.Lists) MetaDatabase(com.torodb.core.transaction.metainf.MetaDatabase) BDDMockito.given(org.mockito.BDDMockito.given) MetaScalar(com.torodb.core.transaction.metainf.MetaScalar) WriteBackendTransaction(com.torodb.core.backend.WriteBackendTransaction) Assert.fail(org.junit.Assert.fail) CollectionData(com.torodb.core.d2r.CollectionData) Mockito.doReturn(org.mockito.Mockito.doReturn) TableRefFactoryImpl(com.torodb.core.impl.TableRefFactoryImpl) AddCollectionDdlJob(com.torodb.core.dsl.backend.AddCollectionDdlJob) Before(org.junit.Before) MetaCollection(com.torodb.core.transaction.metainf.MetaCollection) WrapperMutableMetaDocPart(com.torodb.core.transaction.metainf.WrapperMutableMetaDocPart) MockSettings(org.mockito.MockSettings) Assert.assertTrue(org.junit.Assert.assertTrue) FieldType(com.torodb.core.transaction.metainf.FieldType) ImmutableMetaCollection(com.torodb.core.transaction.metainf.ImmutableMetaCollection) Test(org.junit.Test) UserException(com.torodb.core.exceptions.user.UserException) MutableMetaDocPart(com.torodb.core.transaction.metainf.MutableMetaDocPart) AddFieldDdlJob(com.torodb.core.dsl.backend.AddFieldDdlJob) AddDocPartDdlJob(com.torodb.core.dsl.backend.AddDocPartDdlJob) MetaField(com.torodb.core.transaction.metainf.MetaField) AddScalarDddlJob(com.torodb.core.dsl.backend.AddScalarDddlJob) DocPartData(com.torodb.core.d2r.DocPartData) ImmutableMetaField(com.torodb.core.transaction.metainf.ImmutableMetaField) Optional(java.util.Optional) ImmutableMetaDatabase(com.torodb.core.transaction.metainf.ImmutableMetaDatabase) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) InsertBackendJob(com.torodb.core.dsl.backend.InsertBackendJob) MetaDocPart(com.torodb.core.transaction.metainf.MetaDocPart) Mockito.mock(org.mockito.Mockito.mock) AddDatabaseDdlJob(com.torodb.core.dsl.backend.AddDatabaseDdlJob) DocPartData(com.torodb.core.d2r.DocPartData) WrapperMutableMetaDocPart(com.torodb.core.transaction.metainf.WrapperMutableMetaDocPart) ImmutableMetaDocPart(com.torodb.core.transaction.metainf.ImmutableMetaDocPart) Test(org.junit.Test)

Aggregations

ImmutableMetaDocPart (com.torodb.core.transaction.metainf.ImmutableMetaDocPart)2 WrapperMutableMetaDocPart (com.torodb.core.transaction.metainf.WrapperMutableMetaDocPart)2 Before (org.junit.Before)2 Iterables (com.google.common.collect.Iterables)1 Lists (com.google.common.collect.Lists)1 TableRefFactory (com.torodb.core.TableRefFactory)1 WriteBackendTransaction (com.torodb.core.backend.WriteBackendTransaction)1 CollectionData (com.torodb.core.d2r.CollectionData)1 DocPartData (com.torodb.core.d2r.DocPartData)1 AddCollectionDdlJob (com.torodb.core.dsl.backend.AddCollectionDdlJob)1 AddDatabaseDdlJob (com.torodb.core.dsl.backend.AddDatabaseDdlJob)1 AddDocPartDdlJob (com.torodb.core.dsl.backend.AddDocPartDdlJob)1 AddFieldDdlJob (com.torodb.core.dsl.backend.AddFieldDdlJob)1 AddScalarDddlJob (com.torodb.core.dsl.backend.AddScalarDddlJob)1 BackendTransactionJob (com.torodb.core.dsl.backend.BackendTransactionJob)1 BackendTransactionJobFactory (com.torodb.core.dsl.backend.BackendTransactionJobFactory)1 InsertBackendJob (com.torodb.core.dsl.backend.InsertBackendJob)1 UserException (com.torodb.core.exceptions.user.UserException)1 TableRefFactoryImpl (com.torodb.core.impl.TableRefFactoryImpl)1 RollbackException (com.torodb.core.transaction.RollbackException)1