use of com.blazebit.persistence.view.testsuite.update.subview.nested.mutable.model.UpdatableFriendPersonView in project blaze-persistence by Blazebit.
the class EntityViewUpdateNestedMutableSubviewMapsTest method testUpdateModifyCollectionElement.
@Test
public void testUpdateModifyCollectionElement() {
// Given
final UpdatableDocumentWithMapsView docView = getDoc1View();
UpdatableFriendPersonView newFriend = getPersonView(p4.getId(), UpdatableFriendPersonView.class);
clearQueries();
// When
docView.getContacts().get(1).setFriend(newFriend);
update(docView);
// Then
AssertStatementBuilder builder = assertUnorderedQuerySequence();
if (isQueryStrategy()) {
if (isFullMode()) {
builder.update(Person.class);
assertReplaceAnd(builder);
}
builder.update(Person.class);
} else {
if (isFullMode()) {
fullFetch(builder);
if (isFullMode()) {
builder.assertSelect().fetching(Person.class).and();
}
} else {
builder.assertSelect().fetching(Document.class).fetching(Document.class, "contacts").fetching(Person.class).and();
if (isFullMode()) {
builder.assertSelect().fetching(Person.class).fetching(Person.class).and();
}
}
builder.update(Person.class);
}
if (version || isQueryStrategy() && isFullMode()) {
builder.update(Document.class);
}
builder.validate();
assertNoUpdateAndReload(docView, true);
assertSubviewEquals(doc1.getContacts(), docView.getContacts());
assertEquals(p4.getId(), p1.getFriend().getId());
}
use of com.blazebit.persistence.view.testsuite.update.subview.nested.mutable.model.UpdatableFriendPersonView in project blaze-persistence by Blazebit.
the class EntityViewUpdateNestedMutableSubviewMapsTest method testUpdateModifyCollectionElementAndModify.
@Test
public void testUpdateModifyCollectionElementAndModify() {
// Given
final UpdatableDocumentWithMapsView docView = getDoc1View();
UpdatableFriendPersonView newFriend = getPersonView(p4.getId(), UpdatableFriendPersonView.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);
builder.update(Person.class);
} else {
if (isFullMode()) {
fullFetch(builder);
} else {
builder.assertSelect().fetching(Document.class).fetching(Document.class, "contacts").fetching(Person.class).and();
}
builder.assertSelect().fetching(Person.class).and();
builder.update(Person.class);
builder.update(Person.class);
}
if (version || isQueryStrategy() && isFullMode()) {
builder.update(Document.class);
}
builder.validate();
assertNoUpdateAndReload(docView, true);
assertSubviewEquals(doc1.getContacts(), docView.getContacts());
assertEquals(p4.getId(), p1.getFriend().getId());
assertEquals("newFriend", p4.getName());
}
use of com.blazebit.persistence.view.testsuite.update.subview.nested.mutable.model.UpdatableFriendPersonView in project blaze-persistence by Blazebit.
the class EntityViewUpdateNestedMutableSubviewCollectionsTest method testUpdateModifyCollectionElementAndModify.
@Test
public void testUpdateModifyCollectionElementAndModify() {
// Given
final UpdatableDocumentWithCollectionsView docView = getDoc1View();
UpdatableFriendPersonView newFriend = getPersonView(p4.getId(), UpdatableFriendPersonView.class);
clearQueries();
// When
newFriend.setName("newFriend");
docView.getPeople().get(0).setFriend(newFriend);
update(docView);
// Then
AssertStatementBuilder builder = assertUnorderedQuerySequence();
if (isQueryStrategy()) {
if (isFullMode()) {
assertReplaceAnd(builder);
}
builder.update(Person.class).update(Person.class);
if (version || isFullMode()) {
builder.update(Document.class);
}
} else {
if (isFullMode()) {
fullFetch(builder);
} else {
builder.assertSelect().fetching(Document.class).fetching(Document.class, "people").fetching(Person.class).and();
}
builder.select(Person.class);
if (version) {
builder.update(Document.class);
}
builder.update(Person.class).update(Person.class);
}
builder.validate();
assertNoCollectionUpdateFullAndReload(docView);
assertSubviewEquals(doc1.getPeople(), docView.getPeople());
assertEquals(p4.getId(), p1.getFriend().getId());
assertEquals("newFriend", p4.getName());
}
use of com.blazebit.persistence.view.testsuite.update.subview.nested.mutable.model.UpdatableFriendPersonView in project blaze-persistence by Blazebit.
the class EntityViewUpdateNestedMutableSubviewCollectionsTest method testUpdateModifyCollectionElement.
@Test
public void testUpdateModifyCollectionElement() {
// Given
final UpdatableDocumentWithCollectionsView docView = getDoc1View();
UpdatableFriendPersonView newFriend = getPersonView(p4.getId(), UpdatableFriendPersonView.class);
clearQueries();
// When
docView.getPeople().get(0).setFriend(newFriend);
update(docView);
// Then
AssertStatementBuilder builder = assertUnorderedQuerySequence();
if (isQueryStrategy()) {
if (isFullMode()) {
assertReplaceAnd(builder).update(Person.class);
}
builder.update(Person.class);
if (version || isFullMode()) {
builder.update(Document.class);
}
} else {
if (isFullMode()) {
fullFetch(builder).select(Person.class);
} else {
builder.assertSelect().fetching(Document.class).fetching(Document.class, "people").fetching(Person.class).and();
}
if (version) {
builder.update(Document.class);
}
builder.update(Person.class);
}
builder.validate();
assertNoCollectionUpdateFullAndReload(docView);
assertSubviewEquals(doc1.getPeople(), docView.getPeople());
assertEquals(p4.getId(), p1.getFriend().getId());
}
use of com.blazebit.persistence.view.testsuite.update.subview.nested.mutable.model.UpdatableFriendPersonView in project blaze-persistence by Blazebit.
the class EntityViewUpdateNestedMutableSubviewMapsTest method testUpdateModifyCollectionElementCopy.
@Test
public void testUpdateModifyCollectionElementCopy() {
// Given
final UpdatableDocumentWithMapsView docView = getDoc1View();
UpdatableFriendPersonView newFriend = getPersonView(p3.getId(), UpdatableFriendPersonView.class);
clearQueries();
// When
newFriend.setName("newFriend");
docView.getContacts().get(1).setFriend(newFriend);
update(docView);
// Then
AssertStatementBuilder builder = assertUnorderedQuerySequence();
if (isQueryStrategy()) {
if (isFullMode()) {
builder.update(Person.class);
assertReplaceAnd(builder);
}
builder.update(Person.class);
} else {
fullFetch(builder);
builder.update(Person.class);
}
if (version || isQueryStrategy() && isFullMode()) {
builder.update(Document.class);
}
builder.validate();
assertNoUpdateAndReload(docView, true);
assertEquals(p3.getId(), p1.getFriend().getId());
assertEquals("newFriend", p3.getName());
assertSubviewEquals(doc1.getContacts(), docView.getContacts());
}
Aggregations