use of com.blazebit.persistence.view.testsuite.update.subview.nested.immutable.model.UpdatableDocumentWithMapsView in project blaze-persistence by Blazebit.
the class EntityViewUpdateNestedImmutableSubviewMapsTest method testUpdateModifyCollectionElementSetToNull.
@Test
public void testUpdateModifyCollectionElementSetToNull() {
// Given
final UpdatableDocumentWithMapsView docView = getDoc1View();
clearQueries();
// When
docView.getContacts().get(1).setFriend(null);
update(docView);
// Then
AssertStatementBuilder builder = assertUnorderedQuerySequence();
if (isQueryStrategy()) {
if (isFullMode()) {
assertReplaceAnd(builder);
}
builder.update(Person.class);
if (version || isFullMode()) {
builder.update(Document.class);
}
} else {
fullFetch(builder);
if (version) {
builder.update(Document.class);
}
builder.update(Person.class);
}
builder.validate();
assertNoUpdateAndReload(docView, true);
assertNull(p1.getFriend());
assertSubviewEquals(doc1.getContacts(), docView.getContacts());
}
use of com.blazebit.persistence.view.testsuite.update.subview.nested.immutable.model.UpdatableDocumentWithMapsView in project blaze-persistence by Blazebit.
the class EntityViewUpdateNestedImmutableSubviewMapsTest method testUpdateModifyCollectionElementAndModify.
@Test
public void testUpdateModifyCollectionElementAndModify() {
// Given
final UpdatableDocumentWithMapsView docView = getDoc1View();
FriendPersonView newFriend = getPersonView(p4.getId(), FriendPersonView.class);
clearQueries();
// When
newFriend.setName("newFriend");
docView.getContacts().get(1).setFriend(newFriend);
update(docView);
// Then
AssertStatementBuilder builder = assertUnorderedQuerySequence();
if (isQueryStrategy()) {
if (isFullMode()) {
assertReplaceAnd(builder);
}
builder.update(Person.class);
if (version || isFullMode()) {
builder.update(Document.class);
}
} else {
fullFetch(builder);
if (version) {
builder.update(Document.class);
}
builder.update(Person.class);
}
builder.validate();
assertNoUpdateAndReload(docView, true);
assertEquals(p4.getId(), p1.getFriend().getId());
assertEquals("pers4", p4.getName());
docView.getContacts().get(1).getFriend().setName("pers4");
assertSubviewEquals(doc1.getContacts(), docView.getContacts());
}
use of com.blazebit.persistence.view.testsuite.update.subview.nested.immutable.model.UpdatableDocumentWithMapsView in project blaze-persistence by Blazebit.
the class EntityViewUpdateNestedImmutableSubviewMapsTest method testUpdateModifyCollectionElement.
@Test
public void testUpdateModifyCollectionElement() {
// Given
final UpdatableDocumentWithMapsView docView = getDoc1View();
FriendPersonView newFriend = getPersonView(p4.getId(), FriendPersonView.class);
clearQueries();
// When
docView.getContacts().get(1).setFriend(newFriend);
update(docView);
// Then
AssertStatementBuilder builder = assertUnorderedQuerySequence();
if (isQueryStrategy()) {
if (isFullMode()) {
assertReplaceAnd(builder);
}
builder.update(Person.class);
if (version || isFullMode()) {
builder.update(Document.class);
}
} else {
fullFetch(builder);
if (version) {
builder.update(Document.class);
}
builder.update(Person.class);
}
builder.validate();
assertNoUpdateAndReload(docView, true);
assertEquals(p4.getId(), p1.getFriend().getId());
assertSubviewEquals(doc1.getContacts(), docView.getContacts());
}
Aggregations