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());
}
}
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());
}
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());
}
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());
}
Aggregations