Search in sources :

Example 6 with UpdatableDocumentEntityWithMapsView

use of com.blazebit.persistence.view.testsuite.update.entity.creatable.model.UpdatableDocumentEntityWithMapsView in project blaze-persistence by Blazebit.

the class EntityViewUpdateCreatableEntityMapsTest method testUpdateAddNullToCollection.

@Test
public void testUpdateAddNullToCollection() {
    // Given & When
    final UpdatableDocumentEntityWithMapsView docView = addNullToCollection();
    // Then
    // Assert that the document and the people are loaded i.e. a full fetch
    // Finally a single relation insert is done for the null element if supported
    AssertStatementBuilder builder = assertUnorderedQuerySequence();
    if (isQueryStrategy()) {
        if (isFullMode()) {
            assertReplaceAnd(builder);
        }
    } else {
        fullFetch(builder);
    }
    if (version || isQueryStrategy() && isFullMode()) {
        versionUpdate(builder);
    }
    if (supportsNullCollectionElements()) {
        builder.insert(Document.class, "contacts");
    }
    builder.validate();
    // Since we don't need to merge elements, no need reload the collection
    assertNoUpdateAndReload(docView, true);
    if (supportsNullCollectionElements()) {
        assertEquals(doc1.getContacts(), docView.getContacts());
    }
}
Also used : AssertStatementBuilder(com.blazebit.persistence.testsuite.base.jpa.assertion.AssertStatementBuilder) UpdatableDocumentEntityWithMapsView(com.blazebit.persistence.view.testsuite.update.entity.creatable.model.UpdatableDocumentEntityWithMapsView) Test(org.junit.Test) AbstractEntityViewUpdateEntityMapsTest(com.blazebit.persistence.view.testsuite.update.entity.AbstractEntityViewUpdateEntityMapsTest)

Example 7 with UpdatableDocumentEntityWithMapsView

use of com.blazebit.persistence.view.testsuite.update.entity.creatable.model.UpdatableDocumentEntityWithMapsView in project blaze-persistence by Blazebit.

the class EntityViewUpdateCreatableEntityMapsTest method testUpdateAddNewEntityToCollection.

@Test
public void testUpdateAddNewEntityToCollection() {
    // Given & When
    final UpdatableDocumentEntityWithMapsView docView = addNewEntityToCollection();
    // Then
    // Assert that the document and the people are loaded i.e. a full fetch
    // In addition, the new person is loaded because of the merge invocation
    // Finally the person is persisted and a single relation insert is done
    AssertStatementBuilder builder = assertUnorderedQuerySequence();
    if (isQueryStrategy()) {
        if (isFullMode()) {
            assertReplaceAnd(builder);
        }
    } else {
        fullFetch(builder);
    }
    if (version || isQueryStrategy() && isFullMode()) {
        versionUpdate(builder);
    }
    builder.insert(Document.class, "contacts").insert(Person.class).validate();
    // Since we don't need to merge elements, no need reload the collection
    assertNoUpdateAndReload(docView, true);
    assertEquals(doc1.getContacts(), docView.getContacts());
}
Also used : AssertStatementBuilder(com.blazebit.persistence.testsuite.base.jpa.assertion.AssertStatementBuilder) UpdatableDocumentEntityWithMapsView(com.blazebit.persistence.view.testsuite.update.entity.creatable.model.UpdatableDocumentEntityWithMapsView) Person(com.blazebit.persistence.testsuite.entity.Person) Test(org.junit.Test) AbstractEntityViewUpdateEntityMapsTest(com.blazebit.persistence.view.testsuite.update.entity.AbstractEntityViewUpdateEntityMapsTest)

Example 8 with UpdatableDocumentEntityWithMapsView

use of com.blazebit.persistence.view.testsuite.update.entity.creatable.model.UpdatableDocumentEntityWithMapsView in project blaze-persistence by Blazebit.

the class EntityViewUpdateCreatableEntityMapsTest method testUpdateAddToNewCollectionAndModifyEntity.

@Test
public void testUpdateAddToNewCollectionAndModifyEntity() {
    // Given & When
    final UpdatableDocumentEntityWithMapsView docView = addToNewCollectionAndModifyEntity();
    // Then
    // Assert that the document and the people are loaded i.e. a full fetch
    // Finally a single relation insert is done but without an update
    AssertStatementBuilder builder = assertUnorderedQuerySequence();
    if (isQueryStrategy()) {
        if (isFullMode()) {
            assertReplaceAnd(builder);
        }
    } else {
        fullFetch(builder);
    }
    if (version || isQueryStrategy() && isFullMode()) {
        versionUpdate(builder);
    }
    builder.insert(Document.class, "contacts").validate();
    // No need for an update since it isn't dirty
    assertNoUpdateAndReload(docView, true);
    assertEquals(doc1.getContacts(), docView.getContacts());
    assertEquals("pers2", p2.getName());
}
Also used : AssertStatementBuilder(com.blazebit.persistence.testsuite.base.jpa.assertion.AssertStatementBuilder) UpdatableDocumentEntityWithMapsView(com.blazebit.persistence.view.testsuite.update.entity.creatable.model.UpdatableDocumentEntityWithMapsView) Document(com.blazebit.persistence.testsuite.entity.Document) Test(org.junit.Test) AbstractEntityViewUpdateEntityMapsTest(com.blazebit.persistence.view.testsuite.update.entity.AbstractEntityViewUpdateEntityMapsTest)

Example 9 with UpdatableDocumentEntityWithMapsView

use of com.blazebit.persistence.view.testsuite.update.entity.creatable.model.UpdatableDocumentEntityWithMapsView in project blaze-persistence by Blazebit.

the class EntityViewUpdateCreatableEntityMapsTest method testUpdateModifyEntityInCollection.

@Test
public void testUpdateModifyEntityInCollection() {
    // Given & When
    final UpdatableDocumentEntityWithMapsView docView = modifyEntityInCollection();
    // Then
    // Assert that the document and the people are loaded i.e. a full fetch
    // Since only an existing person was update, only a single update is generated
    validateNoChange(docView);
    assertEquals(doc1.getContacts(), docView.getContacts());
    assertEquals("pers1", p1.getName());
}
Also used : UpdatableDocumentEntityWithMapsView(com.blazebit.persistence.view.testsuite.update.entity.creatable.model.UpdatableDocumentEntityWithMapsView) Test(org.junit.Test) AbstractEntityViewUpdateEntityMapsTest(com.blazebit.persistence.view.testsuite.update.entity.AbstractEntityViewUpdateEntityMapsTest)

Aggregations

AbstractEntityViewUpdateEntityMapsTest (com.blazebit.persistence.view.testsuite.update.entity.AbstractEntityViewUpdateEntityMapsTest)9 UpdatableDocumentEntityWithMapsView (com.blazebit.persistence.view.testsuite.update.entity.creatable.model.UpdatableDocumentEntityWithMapsView)9 Test (org.junit.Test)9 AssertStatementBuilder (com.blazebit.persistence.testsuite.base.jpa.assertion.AssertStatementBuilder)8 Document (com.blazebit.persistence.testsuite.entity.Document)5 Person (com.blazebit.persistence.testsuite.entity.Person)1