use of com.blazebit.persistence.testsuite.entity.NameObject in project blaze-persistence by Blazebit.
the class EntityViewUpdateMutableEmbeddableTest method assertEmptyChangeModel.
protected void assertEmptyChangeModel(UpdatableDocumentEmbeddableView docView) {
if (!isFullMode()) {
SingularChangeModel<UpdatableDocumentEmbeddableView> changeModel = evm.getChangeModel(docView);
ChangeModel<?> nameChange = changeModel.get("nameObject");
if (registerType) {
assertFalse(changeModel.isDirty());
assertEquals(ChangeModel.ChangeKind.NONE, changeModel.getKind());
assertFalse(nameChange.isDirty());
assertEquals(ChangeModel.ChangeKind.NONE, nameChange.getKind());
assertTrue(changeModel.getDirtyChanges().isEmpty());
} else {
assertTrue(changeModel.isDirty());
assertEquals(ChangeModel.ChangeKind.MUTATED, changeModel.getKind());
assertTrue(nameChange.isDirty());
assertEquals(ChangeModel.ChangeKind.MUTATED, nameChange.getKind());
assertEquals(Arrays.asList(nameChange), changeModel.getDirtyChanges());
}
assertEquals(new NameObject("newPrimaryName", "newSecondaryName"), nameChange.getCurrentState());
}
}
use of com.blazebit.persistence.testsuite.entity.NameObject in project blaze-persistence by Blazebit.
the class AbstractEntityViewUpdateDocumentTest method prepareData.
@Override
protected void prepareData(EntityManager em) {
doc1 = new Document("doc1", 10);
doc1.setVersion(1L);
doc1.setLastModified(new Date(EPOCH_2K));
doc1.getNameObject().setPrimaryName("doc1");
doc1.getNames().add(new NameObject("doc1", "doc1"));
doc1.getNameMap().put("doc1", new NameObject("doc1", "doc1"));
doc1.getNameContainers().add(new NameObjectContainer("doc1", new NameObject("doc1", "doc1")));
doc1.getNameContainerMap().put("doc1", new NameObjectContainer("doc1", new NameObject("doc1", "doc1")));
doc2 = new Document("doc2");
doc2.setVersion(1L);
doc2.setLastModified(new Date(EPOCH_2K));
doc2.setNameObject(new NameObject("doc2", "doc2"));
doc2.getNames().add(new NameObject("doc2", "doc2"));
doc2.getNameMap().put("doc1", new NameObject("doc2", "doc2"));
doc2.getNameContainers().add(new NameObjectContainer("doc2", new NameObject("doc2", "doc2")));
doc2.getNameContainerMap().put("doc2", new NameObjectContainer("doc2", new NameObject("doc2", "doc2")));
p1 = new Person("pers1");
p1.getNameObject().setPrimaryName("pers1");
p1.getLocalized().put(1, "localized1");
p2 = new Person("pers2");
p2.getNameObject().setPrimaryName("pers2");
p2.getLocalized().put(1, "localized2");
p3 = new Person("pers3");
p3.getNameObject().setPrimaryName("pers3");
p3.getLocalized().put(1, "localized3");
p4 = new Person("pers4");
p4.getNameObject().setPrimaryName("pers4");
p4.getLocalized().put(1, "localized4");
doc1.setOwner(p1);
doc1.setResponsiblePerson(p1);
doc1.getPeople().add(p1);
doc1.getContacts().put(1, p1);
doc1.getContacts2().put(2, p1);
doc1.getStrings().add("asd");
doc1.getStringMap().put("doc1", "doc1");
doc2.setOwner(p2);
doc2.setResponsiblePerson(p2);
em.persist(p1);
em.persist(p2);
em.persist(p3);
em.persist(p4);
em.persist(doc1);
em.persist(doc2);
p1.setPartnerDocument(doc1);
p1.setFriend(p3);
p2.setFriend(p4);
}
use of com.blazebit.persistence.testsuite.entity.NameObject in project blaze-persistence by Blazebit.
the class AbstractEntityViewRemoveDocumentTest method prepareData.
@Override
protected void prepareData(EntityManager em) {
doc1 = new Document("doc1", null, new Version());
doc1.setVersion(1L);
doc1.setLastModified(new Date(EPOCH_2K));
doc1.getNameObject().setPrimaryName("doc1");
doc1.getNames().add(new NameObject("doc1", "doc1"));
doc1.getNameMap().put("doc1", new NameObject("doc1", "doc1"));
doc1.getNameContainers().add(new NameObjectContainer("doc1", new NameObject("doc1", "doc1")));
doc1.getNameContainerMap().put("doc1", new NameObjectContainer("doc1", new NameObject("doc1", "doc1")));
doc2 = new Document("doc2");
doc2.setVersion(1L);
doc2.setLastModified(new Date(EPOCH_2K));
doc2.setNameObject(new NameObject("doc2", "doc2"));
doc2.getNames().add(new NameObject("doc2", "doc2"));
doc2.getNameMap().put("doc1", new NameObject("doc2", "doc2"));
doc2.getNameContainers().add(new NameObjectContainer("doc2", new NameObject("doc2", "doc2")));
doc2.getNameContainerMap().put("doc2", new NameObjectContainer("doc2", new NameObject("doc2", "doc2")));
p1 = new Person("pers1");
p1.getNameObject().setPrimaryName("pers1");
p1.getLocalized().put(1, "localized1");
p2 = new Person("pers2");
p2.getNameObject().setPrimaryName("pers2");
p2.getLocalized().put(1, "localized2");
p3 = new Person("pers3");
p3.getNameObject().setPrimaryName("pers3");
p3.getLocalized().put(1, "localized3");
p4 = new Person("pers4");
p4.getNameObject().setPrimaryName("pers4");
p4.getLocalized().put(1, "localized4");
p5 = new Person("pers3");
p5.getNameObject().setPrimaryName("pers3");
p5.getLocalized().put(1, "localized3");
p6 = new Person("pers4");
p6.getNameObject().setPrimaryName("pers4");
p6.getLocalized().put(1, "localized4");
doc1.setOwner(p5);
doc1.setResponsiblePerson(p1);
doc1.getPeople().add(p1);
doc1.getContacts().put(1, p1);
doc1.getContacts2().put(2, p1);
doc1.getStrings().add("asd");
doc1.getStringMap().put("doc1", "doc1");
doc1.getVersions().iterator().next().getLocalized().put(1, "1");
doc2.setOwner(p6);
doc2.setResponsiblePerson(p2);
em.persist(p1);
em.persist(p2);
em.persist(p3);
em.persist(p4);
em.persist(p5);
em.persist(p6);
em.persist(doc1);
em.persist(doc2);
p1.setFriend(p3);
p2.setFriend(p4);
}
use of com.blazebit.persistence.testsuite.entity.NameObject in project blaze-persistence by Blazebit.
the class EntityViewUpdateSimpleMutableSubtypeFlatViewMapsTest method assertSubviewEquals.
public static void assertSubviewEquals(Map<String, NameObject> persons, Map<String, ? extends ReadonlyNameObjectView> personSubviews) {
if (persons == null) {
assertNull(personSubviews);
return;
}
assertNotNull(personSubviews);
assertEquals(persons.size(), personSubviews.size());
for (Map.Entry<String, NameObject> entry : persons.entrySet()) {
NameObject p = entry.getValue();
boolean found = false;
ReadonlyNameObjectView pSub = personSubviews.get(entry.getKey());
if (pSub != null) {
if (p.getPrimaryName().equals(pSub.getPrimaryName())) {
found = true;
break;
}
}
if (!found) {
Assert.fail("Could not find a UpdatableNameObjectView with the name: " + p.getPrimaryName());
}
}
}
use of com.blazebit.persistence.testsuite.entity.NameObject in project blaze-persistence by Blazebit.
the class EntityViewUpdateSimpleMutableFlatViewCollectionsTest method assertSubviewEquals.
public static void assertSubviewEquals(Collection<NameObject> persons, Collection<? extends UpdatableNameObjectView> personSubviews) {
if (persons == null) {
assertNull(personSubviews);
return;
}
assertNotNull(personSubviews);
assertEquals(persons.size(), personSubviews.size());
for (NameObject p : persons) {
boolean found = false;
for (UpdatableNameObjectView pSub : personSubviews) {
if (p.getPrimaryName().equals(pSub.getPrimaryName())) {
found = true;
break;
}
}
if (!found) {
Assert.fail("Could not find a UpdatableNameObjectView with the name: " + p.getPrimaryName());
}
}
}
Aggregations