use of com.blazebit.persistence.view.testsuite.update.entity.creatable.model.UpdatableDocumentEntityWithCollectionsView 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.view.testsuite.update.entity.creatable.model.UpdatableDocumentEntityWithCollectionsView in project blaze-persistence by Blazebit.
the class EntityViewUpdateCreatableEntityCollectionsTest method testUpdateModifyEntityInCollection.
@Test
public void testUpdateModifyEntityInCollection() {
// Given & When
final UpdatableDocumentEntityWithCollectionsView 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
validateNoChange(docView);
assertEquals(doc1.getPeople(), docView.getPeople());
assertEquals("pers1", p1.getName());
}
use of com.blazebit.persistence.view.testsuite.update.entity.creatable.model.UpdatableDocumentEntityWithCollectionsView 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.view.testsuite.update.entity.creatable.model.UpdatableDocumentEntityWithCollectionsView in project blaze-persistence by Blazebit.
the class EntityViewUpdateCreatableEntityCollectionsTest method testUpdateReplaceCollection.
@Test
public void testUpdateReplaceCollection() {
// Given & When
final UpdatableDocumentEntityWithCollectionsView docView = replaceCollection();
// Then
// We only fetch the document and the collection in full mode
// During dirty detection we can figure out that effectively nothing changed
AssertStatementBuilder builder = assertUnorderedQuerySequence();
if (isFullMode()) {
if (isQueryStrategy()) {
builder.delete(Document.class, "people").insert(Document.class, "people");
} else {
fullFetch(builder);
}
if (version || isQueryStrategy()) {
versionUpdate(builder);
}
}
builder.validate();
// No need for an update since it isn't dirty
assertNoUpdateAndReload(docView, true);
assertEquals(doc1.getPeople(), docView.getPeople());
}
use of com.blazebit.persistence.view.testsuite.update.entity.creatable.model.UpdatableDocumentEntityWithCollectionsView in project blaze-persistence by Blazebit.
the class EntityViewUpdateCreatableEntityCollectionsTest method testUpdateAddToCollectionAndModifyEntity.
@Test
public void testUpdateAddToCollectionAndModifyEntity() {
// Given & When
final UpdatableDocumentEntityWithCollectionsView 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()) {
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());
assertEquals("pers2", p2.getName());
}
Aggregations