@Test public void testValidateQuery() { String query = " Select p from MappedPerson p"; try { em.createQuery(query); Assert.fail("Should have gone to catch block!"); } catch (QueryHandlerException qhex) { Assert.assertEquals("No entity found by the name: MappedPerson", qhex.getMessage()); } }
private void findByNameAndAgeWithOrClause() { EntityManager em; String query; Query q; List<StudentMongoBooleanWrapper> students; int count; em = emf.createEntityManager(); query = "Select s From StudentMongoBooleanWrapper s where s.name = Kuldeep or s.age > " + getMinValue(short.class); try { q = em.createQuery(query); students = q.getResultList(); Assert.assertNotNull(students); Assert.assertEquals(2, students.size()); count = 0; for (StudentMongoBooleanWrapper student : students) { Assert.assertEquals("Kuldeep", student.getName()); count++; } Assert.assertEquals(2, count); em.close(); } catch (QueryHandlerException qhe) { Assert.assertEquals("unsupported clause OR for Mongo", qhe.getMessage()); } }
private void findByNameAndAgeWithOrClause() { EntityManager em; String query; Query q; List<StudentMongoBooleanPrimitive> students; int count; em = emf.createEntityManager(); query = "Select s From StudentMongoBooleanPrimitive s where s.name = Kuldeep or s.age > " + getMinValue(short.class); try { q = em.createQuery(query); students = q.getResultList(); Assert.assertNotNull(students); Assert.assertEquals(2, students.size()); count = 0; for (StudentMongoBooleanPrimitive student : students) { Assert.assertEquals("Kuldeep", student.getName()); count++; } Assert.assertEquals(2, count); em.close(); } catch (QueryHandlerException qhe) { Assert.assertEquals("unsupported clause OR for Mongo", qhe.getMessage()); } }
@Test public void testCreateQueryWithNull() { PersistenceDelegator pd = ((EntityManagerImpl) em).getPersistenceDelegator(); try { pd.createQuery(null); Assert.fail("Should have gone to catch block!"); } catch (QueryHandlerException qhex) { Assert.assertEquals("Query String should not be null ", qhex.getMessage()); } }
Assert.assertEquals("unsupported clause OR for cassandra", qhe.getMessage());
Assert.assertEquals("unsupported clause OR for cassandra", qhe.getMessage());
Assert.assertNotNull(qhe.getMessage());
Assert.assertNotNull(qhe.getMessage());
Assert.assertEquals("unsupported clause OR for cassandra", qhe.getMessage());
Assert.assertEquals("unsupported clause OR for cassandra", qhe.getMessage());
Assert.assertNotNull(qhe.getMessage());
Assert.assertNotNull(qhe.getMessage());
Assert.assertEquals("unsupported clause OR for Hbase", qhe.getMessage());
Assert.assertEquals("unsupported clause OR for Hbase", qhe.getMessage());
Assert.assertEquals("unsupported clause OR for Hbase", qhe.getMessage());
Assert.assertEquals("unsupported clause OR for cassandra", qhe.getMessage());
Assert.assertEquals("unsupported clause OR for cassandra", qhe.getMessage());
qhe.getMessage().trim());
Assert.assertEquals("No entity found by the name: invalidPerson", qhex.getMessage());