use of com.blazebit.persistence.view.testsuite.update.entity.creatable.model.UpdatableDocumentEntityWithMapsView 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.view.testsuite.update.entity.creatable.model.UpdatableDocumentEntityWithMapsView 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.view.testsuite.update.entity.creatable.model.UpdatableDocumentEntityWithMapsView in project blaze-persistence by Blazebit.
the class EntityViewUpdateCreatableEntityMapsTest method testUpdateReplaceCollection.
@Test
public void testUpdateReplaceCollection() {
// Given & When
final UpdatableDocumentEntityWithMapsView 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()) {
assertReplaceAnd(builder);
} 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.getContacts(), docView.getContacts());
}
use of com.blazebit.persistence.view.testsuite.update.entity.creatable.model.UpdatableDocumentEntityWithMapsView in project blaze-persistence by Blazebit.
the class EntityViewUpdateCreatableEntityMapsTest method testUpdateSetCollectionToNull.
@Test
public void testUpdateSetCollectionToNull() {
// Given & When
final UpdatableDocumentEntityWithMapsView docView = setCollectionToNull();
// Then
// Assert that only the document is loaded
// Since only an existing person was update, only a single update is generated
AssertStatementBuilder builder = assertUnorderedQuerySequence();
if (isQueryStrategy()) {
} else {
if (isFullMode()) {
fullFetch(builder);
} else {
builder.select(Document.class);
}
}
if (version || isQueryStrategy() && isFullMode()) {
versionUpdate(builder);
}
builder.delete(Document.class, "contacts").validate();
// Since we don't need to merge elements, no need reload the collection
assertNoUpdateAndReload(docView, true);
assertNullMap(docView.getContacts());
assertEquals(0, doc1.getContacts().size());
}
use of com.blazebit.persistence.view.testsuite.update.entity.creatable.model.UpdatableDocumentEntityWithMapsView in project blaze-persistence by Blazebit.
the class EntityViewUpdateCreatableEntityMapsTest method testUpdateAddToNewCollection.
@Test
public void testUpdateAddToNewCollection() {
// Given & When
final UpdatableDocumentEntityWithMapsView 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()) {
assertReplaceAnd(builder);
}
} else {
fullFetch(builder);
}
if (version || isQueryStrategy() && isFullMode()) {
versionUpdate(builder);
}
builder.insert(Document.class, "contacts").validate();
// No need for an update since it isn't dirty
assertNoUpdateAndReload(docView, true);
assertEquals(doc1.getContacts(), docView.getContacts());
}
Aggregations