use of com.blazebit.persistence.testsuite.entity.NameObjectContainer in project blaze-persistence by Blazebit.
the class EntityViewUpdateNestedMutableFlatViewCollectionsTest method assertSubviewEquals.
public static void assertSubviewEquals(Collection<NameObjectContainer> persons, Collection<? extends UpdatableNameObjectContainerView> personSubviews) {
if (persons == null) {
assertNull(personSubviews);
return;
}
assertNotNull(personSubviews);
assertEquals(persons.size(), personSubviews.size());
for (NameObjectContainer p : persons) {
boolean found = false;
for (UpdatableNameObjectContainerView pSub : personSubviews) {
if (p.getNameObject().getPrimaryName().equals(pSub.getNameObject().getPrimaryName())) {
found = true;
break;
}
}
if (!found) {
Assert.fail("Could not find a person subview instance with the name: " + p.getNameObject().getPrimaryName());
}
}
}
use of com.blazebit.persistence.testsuite.entity.NameObjectContainer in project blaze-persistence by Blazebit.
the class ValuesClauseTest method setUpOnce.
@Override
public void setUpOnce() {
cleanDatabase();
transactional(new TxVoidWork() {
@Override
public void work(EntityManager em) {
p1 = new Person("p1");
d1 = new Document("doc1", 1);
d1.setNameObject(new NameObject("123", "abc"));
d1.getNameContainers().add(new NameObjectContainer("test", new NameObject("123", "abc")));
d1.setOwner(p1);
em.persist(p1);
em.persist(d1);
}
});
setUp();
}
use of com.blazebit.persistence.testsuite.entity.NameObjectContainer 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.NameObjectContainer 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.NameObjectContainer in project blaze-persistence by Blazebit.
the class EntityViewUpdateNestedMutableFlatViewMapsTest method assertSubviewEquals.
public static void assertSubviewEquals(Map<String, NameObjectContainer> persons, Map<String, ? extends UpdatableNameObjectContainerView> personSubviews) {
if (persons == null) {
assertNull(personSubviews);
return;
}
assertNotNull(personSubviews);
assertEquals(persons.size(), personSubviews.size());
for (Map.Entry<String, NameObjectContainer> entry : persons.entrySet()) {
NameObjectContainer p = entry.getValue();
boolean found = false;
UpdatableNameObjectContainerView pSub = personSubviews.get(entry.getKey());
if (pSub != null) {
if (p.getNameObject().getPrimaryName().equals(pSub.getNameObject().getPrimaryName())) {
found = true;
break;
}
}
if (!found) {
Assert.fail("Could not find a person subview instance with the name: " + p.getNameObject().getPrimaryName());
}
}
}
Aggregations