for (String prefix : content.getPrefix()) { prefixFilters.add(prismContext.queryFor(type) .item(discriminator, discriminatorDefinition).startsWith(prefix).matching(matchingRuleName) .buildFilter());
@Test public void test350Substring() throws Exception { final String TEST_NAME = "test350Substring"; displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class) .item(UserType.F_EMPLOYEE_TYPE).contains("A") .or().item(UserType.F_EMPLOYEE_TYPE).startsWith("B") .or().item(UserType.F_EMPLOYEE_TYPE).endsWith("C") .or().item(UserType.F_NAME).startsWithPoly("john", "john").matchingOrig() .build(); checkQueryRoundtripFile(UserType.class, q, TEST_NAME); }
@Test // MID-4120 public void testMatchSubstringAgainstEmptyItem() throws Exception { PrismObject<UserType> user = PrismTestUtil.parseObject(PrismInternalTestUtil.USER_JACK_FILE_XML); // jack has no locality ObjectFilter filter = getPrismContext().queryFor(UserType.class) .item(UserType.F_LOCALITY).startsWith("C") .buildFilter(); boolean match = ObjectQuery.match(user, filter, matchingRuleRegistry); AssertJUnit.assertFalse("filter matches object, but it should not", match); }
@Test public void test1280ApplicableDistinctWithCount() throws Exception { Session session = open(); try { ObjectQuery query = prismContext.queryFor(UserType.class) .item(UserType.F_EMPLOYEE_TYPE).startsWith("a") .build(); String real = getInterpretedQuery2(session, UserType.class, query, true, distinct()); String expected = "select count(distinct u.oid) from RUser u left join u.employeeType e where e like :e"; assertEqualsIgnoreWhitespace(expected, real); } finally { close(session); } }
@Test public void test1230ApplicableDistinctAndOrderBy() throws Exception { ObjectQuery query = prismContext.queryFor(UserType.class) .item(UserType.F_EMPLOYEE_TYPE).startsWith("e") .asc(UserType.F_NAME) .build();
@Test public void test150ExistsWithEquals() throws Exception{ ObjectQuery actual = getPrismContext().queryFor(UserType.class) .exists(UserType.F_ASSIGNMENT) .item(AssignmentType.F_DESCRIPTION).startsWith("desc1") .build(); ComplexTypeDefinition assCtd = getPrismContext().getSchemaRegistry().findComplexTypeDefinitionByCompileTimeClass(AssignmentType.class); PrismContainerDefinition userPcd = getPrismContext().getSchemaRegistry().findContainerDefinitionByCompileTimeClass(UserType.class); ObjectQuery expected = ObjectQueryImpl.createObjectQuery( ExistsFilterImpl.createExists( UserType.F_ASSIGNMENT, userPcd, SubstringFilterImpl.createSubstring( AssignmentType.F_DESCRIPTION, assCtd.findPropertyDefinition(AssignmentType.F_DESCRIPTION), getPrismContext(), null, "desc1", true, false) ) ); compare(actual, expected); }
.item(F_NAME).startsWith("a").matchingOrig() .build();
display("narrowed query (1)", narrowedQuery); ObjectQuery expectedQuery = prismContext.queryFor(UserType.class) .item(UserType.F_NAME).startsWith("a00").matchingNorm() .build(); PrismAsserts.assertQueriesEquivalent("Wrong narrowed query (1)", expectedQuery, narrowedQuery);