use of com.blazebit.persistence.view.testsuite.update.subview.nested.immutable.model.UpdatableResponsiblePersonView in project blaze-persistence by Blazebit.
the class EntityViewUpdateNestedImmutableSubviewCollectionsTest method testUpdateAddToNewCollection.
@Test
public void testUpdateAddToNewCollection() {
// Given
final UpdatableDocumentWithCollectionsView docView = getDoc1View();
UpdatableResponsiblePersonView newPerson = getP2View(UpdatableResponsiblePersonView.class);
clearQueries();
// When
docView.setPeople(new ArrayList<>(docView.getPeople()));
docView.getPeople().add(newPerson);
update(docView);
// Then
AssertStatementBuilder builder = assertUnorderedQuerySequence();
if (isQueryStrategy()) {
if (isFullMode()) {
assertReplaceAnd(builder);
builder.update(Person.class).update(Person.class);
}
} else {
fullFetch(builder);
if (isFullMode()) {
// In full mode we need to select the added element for cascading the update
builder.select(Person.class);
}
}
if (version || isFullMode() && isQueryStrategy()) {
builder.update(Document.class);
}
builder.assertInsert().forRelation(Document.class, "people").validate();
assertNoUpdateAndReload(docView, true);
assertSubviewEquals(doc1.getPeople(), docView.getPeople());
}
use of com.blazebit.persistence.view.testsuite.update.subview.nested.immutable.model.UpdatableResponsiblePersonView in project blaze-persistence by Blazebit.
the class EntityViewUpdateNestedImmutableSubviewMapsTest method testUpdateAddToNewCollection.
@Test
public void testUpdateAddToNewCollection() {
// Given
final UpdatableDocumentWithMapsView docView = getDoc1View();
UpdatableResponsiblePersonView newPerson = getP2View(UpdatableResponsiblePersonView.class);
clearQueries();
// When
docView.setContacts(new HashMap<>(docView.getContacts()));
docView.getContacts().put(2, newPerson);
update(docView);
// Then
AssertStatementBuilder builder = assertUnorderedQuerySequence();
if (isQueryStrategy()) {
if (isFullMode()) {
builder.update(Person.class).update(Person.class);
assertReplaceAnd(builder);
}
} else {
fullFetch(builder);
if (isFullMode()) {
// In full mode we need to select the added element for cascading the update
builder.select(Person.class);
}
}
if (version || isQueryStrategy() && isFullMode()) {
builder.update(Document.class);
}
builder.insert(Document.class, "contacts").validate();
assertNoUpdateAndReload(docView, true);
assertSubviewEquals(doc1.getContacts(), docView.getContacts());
}
use of com.blazebit.persistence.view.testsuite.update.subview.nested.immutable.model.UpdatableResponsiblePersonView in project blaze-persistence by Blazebit.
the class EntityViewUpdateNestedImmutableSubviewMapsTest method testUpdateAddToNewCollectionAndModify.
@Test
public void testUpdateAddToNewCollectionAndModify() {
// Given
final UpdatableDocumentWithMapsView docView = getDoc1View();
UpdatableResponsiblePersonView newPerson = getP2View(UpdatableResponsiblePersonView.class);
clearQueries();
// When
newPerson.getFriend().setName("newPerson");
docView.setContacts(new HashMap<>(docView.getContacts()));
docView.getContacts().put(2, newPerson);
update(docView);
// Then
AssertStatementBuilder builder = assertUnorderedQuerySequence();
if (isQueryStrategy()) {
if (isFullMode()) {
builder.update(Person.class).update(Person.class);
assertReplaceAnd(builder);
}
} else {
fullFetch(builder);
if (isFullMode()) {
// In full mode we need to select the added element for cascading the update
builder.select(Person.class);
}
}
if (version || isQueryStrategy() && isFullMode()) {
builder.update(Document.class);
}
builder.insert(Document.class, "contacts").validate();
assertNoUpdateAndReload(docView, true);
assertEquals("pers4", p4.getName());
docView.getContacts().get(2).getFriend().setName("pers4");
assertSubviewEquals(doc1.getContacts(), docView.getContacts());
}
use of com.blazebit.persistence.view.testsuite.update.subview.nested.immutable.model.UpdatableResponsiblePersonView in project blaze-persistence by Blazebit.
the class EntityViewUpdateNestedImmutableSubviewMapsTest method testUpdateAddToCollectionAndModify.
@Test
public void testUpdateAddToCollectionAndModify() {
// Given
final UpdatableDocumentWithMapsView docView = getDoc1View();
UpdatableResponsiblePersonView newPerson = getP2View(UpdatableResponsiblePersonView.class);
clearQueries();
// When
newPerson.getFriend().setName("newPerson");
docView.getContacts().put(2, newPerson);
update(docView);
// Then
AssertStatementBuilder builder = assertUnorderedQuerySequence();
if (isQueryStrategy()) {
if (isFullMode()) {
builder.update(Person.class).update(Person.class);
assertReplaceAnd(builder);
}
} else {
fullFetch(builder);
if (isFullMode()) {
// In full mode we need to select the added element for cascading the update
builder.select(Person.class);
}
}
if (version || isQueryStrategy() && isFullMode()) {
builder.update(Document.class);
}
builder.insert(Document.class, "contacts").validate();
assertNoUpdateAndReload(docView, true);
assertEquals("pers4", p4.getName());
docView.getContacts().get(2).getFriend().setName("pers4");
assertSubviewEquals(doc1.getContacts(), docView.getContacts());
}
use of com.blazebit.persistence.view.testsuite.update.subview.nested.immutable.model.UpdatableResponsiblePersonView in project blaze-persistence by Blazebit.
the class EntityViewUpdateNestedImmutableSubviewMapsTest method testUpdateAddToCollection.
@Test
public void testUpdateAddToCollection() {
// Given
final UpdatableDocumentWithMapsView docView = getDoc1View();
UpdatableResponsiblePersonView newPerson = getP2View(UpdatableResponsiblePersonView.class);
clearQueries();
// When
docView.getContacts().put(2, newPerson);
update(docView);
// Then
AssertStatementBuilder builder = assertUnorderedQuerySequence();
if (isQueryStrategy()) {
if (isFullMode()) {
builder.update(Person.class).update(Person.class);
assertReplaceAnd(builder);
}
} else {
fullFetch(builder);
if (isFullMode()) {
// In full mode we need to select the added element for cascading the update
builder.select(Person.class);
}
}
if (version || isQueryStrategy() && isFullMode()) {
builder.update(Document.class);
}
builder.insert(Document.class, "contacts").validate();
assertNoUpdateAndReload(docView, true);
assertSubviewEquals(doc1.getContacts(), docView.getContacts());
}
Aggregations