### Question:
EntityUtils { public static boolean isValidQuery(String queryString, String httpMethod) { if (queryString == null || httpMethod == null) { return false; } queryString = queryString.trim(); if (queryString.length() < 6) return false; String firstKeyword = queryString.substring(0, 6); String allowedKeyword = httpMethods.get(httpMethod); if (allowedKeyword != null && firstKeyword.equalsIgnoreCase(allowedKeyword)) { return true; } else { return false; } }  static AbstractManagedType getEntityManagedType(String entityClassName, EntityManager em); static Class<?> getEntityClass(String entityClassName, EntityManager em); static EntityMetadata getEntityMetaData(String entityClassName, EntityManager em); static String getQueryPart(String fullQueryString); static String getParameterPart(String fullQueryString); static void setObjectQueryParameters(String queryString, String parameterString, Query q, EntityManager em,
        String mediaType); static void setQueryParameters(String queryString, String parameterString, Query q); static void setQueryParameters(String queryString, HashMap<String, String> paramsMap, Query q); static boolean isValidQuery(String queryString, String httpMethod); static Map<String, String> httpMethods; }### Answer:
@Test public void testIsValidQuery() { String insertQuery = "Insert into Book values (1, Amresh)"; Assert.assertTrue(EntityUtils.isValidQuery(insertQuery, HttpMethod.POST)); String selectQuery = "Select b from Book b"; Assert.assertTrue(EntityUtils.isValidQuery(selectQuery, HttpMethod.GET)); String updateQuery = "update Book set author=Amresh"; Assert.assertTrue(EntityUtils.isValidQuery(updateQuery, HttpMethod.PUT)); String deleteQuery = "delete from Book"; Assert.assertTrue(EntityUtils.isValidQuery(deleteQuery, HttpMethod.DELETE)); String insertQuery2 = "Insert into Book values (1, Amresh)"; Assert.assertFalse(EntityUtils.isValidQuery(insertQuery2, HttpMethod.GET)); String selectQuery2 = "Select b from Book b"; Assert.assertFalse(EntityUtils.isValidQuery(selectQuery2, HttpMethod.POST)); String updateQuery2 = "update Book set author=Amresh"; Assert.assertFalse(EntityUtils.isValidQuery(updateQuery2, HttpMethod.DELETE)); String deleteQuery2 = "delete from Book"; Assert.assertFalse(EntityUtils.isValidQuery(deleteQuery2, HttpMethod.PUT)); String junkQuery = "Blah Blah Blah"; Assert.assertFalse(EntityUtils.isValidQuery(junkQuery, HttpMethod.GET)); Assert.assertFalse(EntityUtils.isValidQuery(junkQuery, HttpMethod.POST)); Assert.assertFalse(EntityUtils.isValidQuery(junkQuery, HttpMethod.DELETE)); Assert.assertFalse(EntityUtils.isValidQuery(junkQuery, HttpMethod.PUT)); }