use of com.blazebit.persistence.testsuite.entity.NameObject in project blaze-persistence by Blazebit.
the class AbstractEntityViewUpdateNestedEmbeddableEntityTest method prepareData.
@Override
protected void prepareData(EntityManager em) {
entity1 = new EmbeddableTestEntity();
entity1.getId().setKey("e1");
entity1.getId().setValue("e1");
entity1.setVersion(1L);
entity2 = new EmbeddableTestEntity();
entity2.getId().setKey("e2");
entity2.getId().setValue("e2");
entity2.setVersion(1L);
intIdEntity1 = new IntIdEntity("i1", 1);
intIdEntity2 = new IntIdEntity("i2", 2);
em.persist(entity1);
em.persist(entity2);
em.persist(intIdEntity1);
em.persist(intIdEntity2);
entity1.getEmbeddable().setManyToOne(entity1);
entity1.getEmbeddable().getManyToMany().put("a", intIdEntity1);
entity1.getEmbeddable().getOneToMany2().add(entity1);
entity1.getEmbeddable().getElementCollection().put("a", new NameObject("a", "b", intIdEntity1));
entity1.getEmbeddable().getNestedEmbeddable().getNestedOneToMany().add(entity1);
}
use of com.blazebit.persistence.testsuite.entity.NameObject in project blaze-persistence by Blazebit.
the class AbstractEntityViewUpdateEmbeddableMapsTest method updateAddToNewCollection.
public T updateAddToNewCollection() {
// Given
final T docView = getDoc1View();
clearQueries();
// When
docView.setNameMap(new HashMap<>(docView.getNameMap()));
docView.getNameMap().put("newPrimaryName", new NameObject("newPrimaryName", "newSecondaryName"));
return docView;
}
use of com.blazebit.persistence.testsuite.entity.NameObject in project blaze-persistence by Blazebit.
the class AbstractEntityViewUpdateEmbeddableMapsTest method updateAddToCollection.
public T updateAddToCollection() {
// Given
final T docView = getDoc1View();
clearQueries();
// When
docView.getNameMap().put("newPrimaryName", new NameObject("newPrimaryName", "newSecondaryName"));
return docView;
}
use of com.blazebit.persistence.testsuite.entity.NameObject in project blaze-persistence by Blazebit.
the class EntityViewUpdateMutableEmbeddableTest method testUpdateMutable.
@Test
public void testUpdateMutable() {
// Given & When
final UpdatableDocumentEmbeddableView docView = updateMutable();
Long oldVersion = docView.getVersion();
if (!isFullMode()) {
SingularChangeModel<UpdatableDocumentEmbeddableView> changeModel = evm.getChangeModel(docView);
assertTrue(changeModel.isDirty());
assertEquals(ChangeModel.ChangeKind.MUTATED, changeModel.getKind());
ChangeModel<?> nameChange = changeModel.get("nameObject");
assertTrue(nameChange.isDirty());
if (registerType) {
assertEquals(ChangeModel.ChangeKind.UPDATED, nameChange.getKind());
} else {
assertEquals(ChangeModel.ChangeKind.UPDATED, nameChange.getKind());
}
assertEquals(new NameObject("newPrimaryName", "newSecondaryName"), nameChange.getCurrentState());
assertEquals(Arrays.asList(nameChange), changeModel.getDirtyChanges());
}
updateAndAssertChangesFlushed(docView);
// Then
assertVersionDiff(oldVersion, docView.getVersion(), 1, 1);
fullFetchUpdateAndReload(docView);
assertVersionDiff(oldVersion, docView.getVersion(), 1, registerType && !isQueryStrategy() ? 1 : 2);
assertEquals("newPrimaryName", doc1.getNameObject().getPrimaryName());
assertEquals("newSecondaryName", doc1.getNameObject().getSecondaryName());
}
use of com.blazebit.persistence.testsuite.entity.NameObject in project blaze-persistence by Blazebit.
the class EntityViewUpdateMutableEmbeddableTest method testMutateMutable.
@Test
public void testMutateMutable() {
// Given & When
final UpdatableDocumentEmbeddableView docView = mutateMutable();
Long oldVersion = docView.getVersion();
if (!isFullMode()) {
SingularChangeModel<UpdatableDocumentEmbeddableView> changeModel = evm.getChangeModel(docView);
assertTrue(changeModel.isDirty());
assertEquals(ChangeModel.ChangeKind.MUTATED, changeModel.getKind());
ChangeModel<?> nameChange = changeModel.get("nameObject");
assertTrue(nameChange.isDirty());
if (registerType) {
assertEquals(ChangeModel.ChangeKind.UPDATED, nameChange.getKind());
} else {
assertEquals(ChangeModel.ChangeKind.MUTATED, nameChange.getKind());
}
assertEquals(new NameObject("newPrimaryName", "newSecondaryName"), nameChange.getCurrentState());
assertEquals(Arrays.asList(nameChange), changeModel.getDirtyChanges());
}
updateAndAssertChangesFlushed(docView);
// Then
assertVersionDiff(oldVersion, docView.getVersion(), 1, 1);
fullFetchUpdateAndReload(docView);
assertVersionDiff(oldVersion, docView.getVersion(), 1, registerType && !isQueryStrategy() ? 1 : 2);
assertEquals("newPrimaryName", doc1.getNameObject().getPrimaryName());
assertEquals("newSecondaryName", doc1.getNameObject().getSecondaryName());
}
Aggregations