use of com.blazebit.persistence.testsuite.base.jpa.assertion.AssertStatementBuilder in project blaze-persistence by Blazebit.
the class EntityViewUpdateCreatableEntityCollectionsTest method testUpdateAddToCollection.
@Test
public void testUpdateAddToCollection() {
// Given & When
final UpdatableDocumentEntityWithCollectionsView docView = addToCollection();
// Then
// Assert that the document and the people are loaded i.e. a full fetch
// The added person is not loaded, only a single relation insert is done
AssertStatementBuilder builder = assertUnorderedQuerySequence();
if (isQueryStrategy()) {
if (isFullMode()) {
builder.delete(Document.class, "people").insert(Document.class, "people");
}
} else {
fullFetch(builder);
}
if (version || isQueryStrategy() && isFullMode()) {
builder.update(Document.class);
}
builder.assertInsert().forRelation(Document.class, "people").validate();
assertNoUpdateAndReload(docView, true);
assertEquals(doc1.getPeople(), docView.getPeople());
}
use of com.blazebit.persistence.testsuite.base.jpa.assertion.AssertStatementBuilder in project blaze-persistence by Blazebit.
the class EntityViewUpdateCreatableEntityCollectionsTest method testUpdateAddToNewCollection.
@Test
public void testUpdateAddToNewCollection() {
// Given & When
final UpdatableDocumentEntityWithCollectionsView docView = addToNewCollection();
// Then
// Assert that the document and the people are loaded i.e. a full fetch
// The added person is not loaded, only a single relation insert is done
AssertStatementBuilder builder = assertUnorderedQuerySequence();
if (isQueryStrategy()) {
if (isFullMode()) {
builder.delete(Document.class, "people").insert(Document.class, "people");
}
} else {
fullFetch(builder);
}
if (version || isQueryStrategy() && isFullMode()) {
builder.update(Document.class);
}
builder.assertInsert().forRelation(Document.class, "people").validate();
// No need for an update since it isn't dirty
assertNoUpdateAndReload(docView, true);
assertEquals(doc1.getPeople(), docView.getPeople());
}
use of com.blazebit.persistence.testsuite.base.jpa.assertion.AssertStatementBuilder in project blaze-persistence by Blazebit.
the class EntityViewUpdateCreatableEntityMapsTest method testUpdateAddToCollectionAndModifyEntity.
@Test
public void testUpdateAddToCollectionAndModifyEntity() {
// Given & When
final UpdatableDocumentEntityWithMapsView docView = addToCollectionAndModifyEntity();
// Then
// Assert that the document and the people are loaded i.e. a full fetch
// The added person is not loaded, only 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").validate();
assertNoUpdateAndReload(docView, true);
assertEquals(doc1.getContacts(), docView.getContacts());
assertEquals("pers2", p2.getName());
}
use of com.blazebit.persistence.testsuite.base.jpa.assertion.AssertStatementBuilder in project blaze-persistence by Blazebit.
the class EntityViewUpdateCreatableEntityMapsTest method testUpdateAddToCollection.
@Test
public void testUpdateAddToCollection() {
// Given & When
final UpdatableDocumentEntityWithMapsView docView = addToCollection();
// Then
// Assert that the document and the people are loaded i.e. a full fetch
// The added person is not loaded, only 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").validate();
assertNoUpdateAndReload(docView, true);
assertEquals(doc1.getContacts(), docView.getContacts());
}
use of com.blazebit.persistence.testsuite.base.jpa.assertion.AssertStatementBuilder in project blaze-persistence by Blazebit.
the class EntityViewUpdateMutableOnlyEntityMapsTest 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
AssertStatementBuilder builder = assertUnorderedQuerySequence();
if (isQueryStrategy()) {
builder.select(Person.class);
} else {
fullFetch(builder);
}
if (version || isQueryStrategy() && isFullMode()) {
versionUpdate(builder);
}
builder.update(Person.class).validate();
// Unfortunately, even after an update, we have to reload the entity to merge again
AssertStatementBuilder afterBuilder = assertQueriesAfterUpdate(docView);
if (isQueryStrategy()) {
afterBuilder.select(Person.class);
} else {
fullFetch(afterBuilder);
}
if (version || isQueryStrategy() && isFullMode()) {
versionUpdate(afterBuilder);
}
afterBuilder.validate();
assertEquals(doc1.getContacts(), docView.getContacts());
assertEquals("newPerson", p1.getName());
}
Aggregations