use of com.blazebit.persistence.view.testsuite.update.subview.nested.immutable.model.FriendPersonView in project blaze-persistence by Blazebit.
the class EntityViewUpdateNestedImmutableSubviewCollectionsTest method testUpdateModifyCollectionElement.
@Test
public void testUpdateModifyCollectionElement() {
// Given
final UpdatableDocumentWithCollectionsView docView = getDoc1View();
FriendPersonView newFriend = getPersonView(p4.getId(), FriendPersonView.class);
clearQueries();
// When
docView.getPeople().get(0).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();
assertNoCollectionUpdateAndReload(docView);
assertEquals(p4.getId(), p1.getFriend().getId());
assertSubviewEquals(doc1.getPeople(), docView.getPeople());
}
use of com.blazebit.persistence.view.testsuite.update.subview.nested.immutable.model.FriendPersonView in project blaze-persistence by Blazebit.
the class EntityViewUpdateNestedImmutableSubviewCollectionsTest method testUpdateModifyCollectionElementCopy.
@Test
public void testUpdateModifyCollectionElementCopy() {
// Given
final UpdatableDocumentWithCollectionsView docView = getDoc1View();
FriendPersonView newFriend = getPersonView(p3.getId(), FriendPersonView.class);
clearQueries();
// When
newFriend.setName("newFriend");
docView.getPeople().get(0).setFriend(newFriend);
update(docView);
// Then
AssertStatementBuilder builder = assertUnorderedQuerySequence();
if (isQueryStrategy()) {
if (isFullMode()) {
assertReplaceAnd(builder).update(Person.class);
versionUpdate(builder);
}
} else {
if (isFullMode()) {
fullFetch(builder);
if (version) {
versionUpdate(builder);
}
}
}
builder.validate();
assertNoCollectionUpdateAndReload(docView);
assertEquals(p3.getId(), p1.getFriend().getId());
assertEquals("pers3", p3.getName());
docView.getPeople().get(0).getFriend().setName("pers3");
assertSubviewEquals(doc1.getPeople(), docView.getPeople());
}
use of com.blazebit.persistence.view.testsuite.update.subview.nested.immutable.model.FriendPersonView in project blaze-persistence by Blazebit.
the class EntityViewUpdateNestedImmutableSubviewTest method testUpdateWithModifySubview.
@Test
public void testUpdateWithModifySubview() {
// Given
final UpdatableDocumentView docView = getDoc1View();
FriendPersonView newFriend = getPersonView(p4.getId(), FriendPersonView.class);
clearQueries();
// When
newFriend.setName("newFriend");
docView.getResponsiblePerson().setFriend(newFriend);
update(docView);
// Then
AssertStatementBuilder builder = assertUnorderedQuerySequence();
if (isQueryStrategy()) {
builder.update(Person.class);
if (isFullMode() || version) {
builder.update(Document.class);
}
} else {
fullFetch(builder);
if (version) {
builder.update(Document.class);
}
builder.update(Person.class);
}
builder.validate();
assertNoUpdateAndReload(docView);
assertEquals(p4.getId(), doc1.getResponsiblePerson().getFriend().getId());
assertEquals("pers4", p4.getName());
}
use of com.blazebit.persistence.view.testsuite.update.subview.nested.immutable.model.FriendPersonView in project blaze-persistence by Blazebit.
the class EntityViewUpdateNestedImmutableSubviewTest method testUpdateWithSubview.
@Test
public void testUpdateWithSubview() {
// Given
final UpdatableDocumentView docView = getDoc1View();
FriendPersonView newFriend = getPersonView(p4.getId(), FriendPersonView.class);
clearQueries();
// When
docView.getResponsiblePerson().setFriend(newFriend);
update(docView);
// Then
AssertStatementBuilder builder = assertUnorderedQuerySequence();
if (isQueryStrategy()) {
builder.update(Person.class);
if (isFullMode() || version) {
builder.update(Document.class);
}
} else {
fullFetch(builder);
if (version) {
builder.update(Document.class);
}
builder.update(Person.class);
}
builder.validate();
assertNoUpdateAndReload(docView);
assertEquals(p4.getId(), doc1.getResponsiblePerson().getFriend().getId());
}
use of com.blazebit.persistence.view.testsuite.update.subview.nested.immutable.model.FriendPersonView in project blaze-persistence by Blazebit.
the class EntityViewUpdateNestedImmutableSubviewCollectionsTest method testUpdateModifyCollectionElementAndModify.
@Test
public void testUpdateModifyCollectionElementAndModify() {
// Given
final UpdatableDocumentWithCollectionsView docView = getDoc1View();
FriendPersonView newFriend = getPersonView(p4.getId(), FriendPersonView.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);
if (version || isFullMode()) {
builder.update(Document.class);
}
} else {
fullFetch(builder);
if (version) {
builder.update(Document.class);
}
builder.update(Person.class);
}
builder.validate();
assertNoCollectionUpdateAndReload(docView);
assertEquals(p4.getId(), p1.getFriend().getId());
assertEquals("pers4", p4.getName());
docView.getPeople().get(0).getFriend().setName("pers4");
assertSubviewEquals(doc1.getPeople(), docView.getPeople());
}
Aggregations