Search in sources :

Example 1 with QueueRuleKey

use of dk.dbc.search.solrdocstore.jpa.QueueRuleKey in project solr-document-store by DBCDK.

the class QueueRuleEntityIT method storeAndLoadEntity.

@Test
public void storeAndLoadEntity() {
    System.out.println("storeAndLoadEntity");
    EntityManager em = env().getEntityManager();
    EnumSet.allOf(QueueType.class).forEach(type -> {
        System.out.println(" - testing: " + type);
        env().getPersistenceContext().run(() -> {
            em.persist(new QueueRuleEntity("foo", type, -456));
        });
        env().clearEntityManagerCache();
        QueueRuleEntity qr = env().getPersistenceContext().run(() -> em.find(QueueRuleEntity.class, new QueueRuleKey("foo", type)));
        assertThat(qr.getQueue(), is("foo"));
        assertThat(qr.getSupplier(), is(type));
        assertThat(qr.getPostpone(), is(-456));
        env().getPersistenceContext().run(() -> em.remove(em.find(QueueRuleEntity.class, new QueueRuleKey("foo", type))));
    });
}
Also used : EntityManager(javax.persistence.EntityManager) QueueRuleEntity(dk.dbc.search.solrdocstore.jpa.QueueRuleEntity) QueueRuleKey(dk.dbc.search.solrdocstore.jpa.QueueRuleKey) QueueType(dk.dbc.search.solrdocstore.jpa.QueueType) Test(org.junit.Test)

Aggregations

QueueRuleEntity (dk.dbc.search.solrdocstore.jpa.QueueRuleEntity)1 QueueRuleKey (dk.dbc.search.solrdocstore.jpa.QueueRuleKey)1 QueueType (dk.dbc.search.solrdocstore.jpa.QueueType)1 EntityManager (javax.persistence.EntityManager)1 Test (org.junit.Test)1