BlueprintDAO { @RequiresSession public List<BlueprintEntity> findAll() { TypedQuery<BlueprintEntity> query = entityManagerProvider.get(). createNamedQuery("allBlueprints", BlueprintEntity.class); return query.getResultList(); }  @RequiresSession BlueprintEntity findByName(String blueprint_name); @RequiresSession List<BlueprintEntity> findAll(); @Transactional void refresh(BlueprintEntity blueprintEntity); @Transactional void create(BlueprintEntity blueprintEntity); @Transactional BlueprintEntity merge(BlueprintEntity blueprintEntity); @Transactional void remove(BlueprintEntity blueprintEntity); @Transactional void removeByName(String blueprint_name);  }
@Test public void testFindAll() { BlueprintEntity entity = new BlueprintEntity(); TypedQuery<BlueprintEntity> query = createStrictMock(TypedQuery.class); expect(entityManager.createNamedQuery(eq("allBlueprints"), eq(BlueprintEntity.class))).andReturn(query); expect(query.getResultList()).andReturn(Collections.singletonList(entity)); replay(entityManager, query); BlueprintDAO dao = new BlueprintDAO(); dao.entityManagerProvider = entityManagerProvider; List<BlueprintEntity> results = dao.findAll(); assertEquals(1, results.size()); assertSame(entity, results.get(0)); verify(entityManagerProvider, entityManager, query); }