use of com.blazebit.persistence.testsuite.base.jpa.assertion.AssertStatementBuilder in project blaze-persistence by Blazebit.
the class EntityViewUpdateBlobTest method testUpdateBlob.
@Test
// NOTE: No Datanucleus support yet
@Category({ NoDatanucleus.class, NoEclipselink.class, NoOracle.class, NoH2.class })
public void testUpdateBlob() throws Exception {
// Given
{
final UpdatableBlobEntityView docView = getBlobView();
docView.setBlob(new BlobImpl(new byte[1]));
update(docView);
clearPersistenceContextAndReload();
}
final UpdatableBlobEntityView docView = getBlobView();
clearQueries();
// When
docView.getBlob().setBytes(1, new byte[2]);
transactional(new TxVoidWork() {
@Override
public void work(EntityManager em) {
em.clear();
clearQueries();
evm.save(em, docView);
em.flush();
}
});
// Then
AssertStatementBuilder builder = assertUnorderedQuerySequence();
if (!isQueryStrategy()) {
fullFetch(builder);
}
builder.update(BlobEntity.class);
builder.validate();
assertEquals(2, docView.getBlob().length());
clearPersistenceContextAndReload();
assertEquals(2, entity.getBlob().length());
}
use of com.blazebit.persistence.testsuite.base.jpa.assertion.AssertStatementBuilder in project blaze-persistence by Blazebit.
the class EntityViewUpdateCorrelatedCreatableSubviewTest method testUpdateWithModifyExisting.
@Test
public void testUpdateWithModifyExisting() {
// Given
final UpdatableDocumentView docView = getDoc1View();
clearQueries();
// When
docView.getResponsiblePerson().setName("newPerson");
update(docView);
// Then
AssertStatementBuilder builder = assertUnorderedQuerySequence();
if (isQueryStrategy()) {
if (isFullMode()) {
fullUpdate(builder);
}
} else {
if (isFullMode()) {
fullFetch(builder);
}
}
builder.validate();
assertNoUpdateAndReload(docView);
assertEquals(p1.getId(), doc1.getResponsiblePerson().getId());
assertEquals("pers1", p1.getName());
}
use of com.blazebit.persistence.testsuite.base.jpa.assertion.AssertStatementBuilder in project blaze-persistence by Blazebit.
the class EntityViewUpdateCorrelatedCreatableSubviewTest method testUpdateWithSubview.
@Test
public void testUpdateWithSubview() {
// Given
final UpdatableDocumentView docView = getDoc1View();
UpdatablePersonView newPerson = getP2View(UpdatablePersonView.class);
clearQueries();
// When
docView.setResponsiblePerson(newPerson);
update(docView);
// Then
AssertStatementBuilder builder = assertUnorderedQuerySequence();
if (isFullMode()) {
if (!isQueryStrategy()) {
fullFetch(builder);
}
if (isQueryStrategy() || version) {
builder.update(Document.class);
}
}
builder.validate();
assertNoUpdateAndReload(docView);
assertEquals(p1.getId(), doc1.getResponsiblePerson().getId());
}
use of com.blazebit.persistence.testsuite.base.jpa.assertion.AssertStatementBuilder in project blaze-persistence by Blazebit.
the class EntityViewUpdateBlobTest method testUpdateNothingWhenExistingBlob.
@Test
public void testUpdateNothingWhenExistingBlob() throws Exception {
// Given
{
final UpdatableBlobEntityView docView = getBlobView();
docView.setBlob(new BlobImpl(new byte[1]));
update(docView);
clearPersistenceContextAndReload();
}
final UpdatableBlobEntityView docView = getBlobView();
clearQueries();
// When
update(docView);
// Then
AssertStatementBuilder builder = assertUnorderedQuerySequence();
if (isFullMode()) {
if (!isQueryStrategy()) {
fullFetch(builder);
}
builder.update(BlobEntity.class);
}
builder.validate();
clearPersistenceContextAndReload();
assertEquals("doc1", docView.getName());
assertEquals(entity.getName(), docView.getName());
}
use of com.blazebit.persistence.testsuite.base.jpa.assertion.AssertStatementBuilder in project blaze-persistence by Blazebit.
the class EntityViewUpdateMutableBasicTest method fullFetchUpdateAndReload.
private void fullFetchUpdateAndReload(UpdatableDocumentBasicView docView) {
// Assert that not only the document is loaded and finally also updated
AssertStatementBuilder builder = assertUnorderedQuerySequence();
if (!isQueryStrategy()) {
fullFetch(builder);
}
builder.update(Document.class).validate();
assertNoUpdateAndReload(docView);
}
Aggregations