@Test public void test320NotNotAll() throws Exception { System.out.println("===[ test320NotNotAll ]==="); // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); // WHEN ObjectFilter filter = prismContext.queryFor(UserType.class) .not().block().not().all().endBlock() .buildFilter(); System.out.println("Original filter:\n" + filter.debugDump()); // THEN ObjectFilter simplified = ObjectQueryUtil.simplify(filter, prismContext); System.out.println("Simplified filter:\n" + DebugUtil.debugDump(simplified)); assertTrue("Wrong simplified filter: " + simplified, simplified == null || simplified instanceof AllFilter); }
@Test public void test330NotNotNone() throws Exception { System.out.println("===[ test330NotNotNone ]==="); // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); // WHEN ObjectFilter filter = prismContext.queryFor(UserType.class) .not().block().not().none().endBlock() .buildFilter(); System.out.println("Original filter:\n" + filter.debugDump()); // THEN ObjectFilter simplified = ObjectQueryUtil.simplify(filter, prismContext); System.out.println("Simplified filter:\n" + DebugUtil.debugDump(simplified)); assertTrue("Wrong simplified filter: " + simplified, simplified instanceof NoneFilter); }
private ObjectQuery createQueryBySecondaryIdentifier(ShadowType shadow) throws SchemaException { // TODO TODO TODO set matching rule instead of null in equlas filter Collection<ResourceAttribute<?>> secondaryIdentifiers = ShadowUtil.getSecondaryIdentifiers(shadow); S_AtomicFilterEntry q = prismContext.queryFor(ShadowType.class); q = q.block(); if (secondaryIdentifiers.isEmpty()) { for (ResourceAttribute<?> primaryIdentifier: ShadowUtil.getPrimaryIdentifiers(shadow)) { q = q.itemAs(primaryIdentifier).or(); } } else { // secondary identifiers connected by 'or' clause for (ResourceAttribute<?> secondaryIdentifier : secondaryIdentifiers) { q = q.itemAs(secondaryIdentifier).or(); } } q = q.none().endBlock().and(); // resource + object class q = q.item(ShadowType.F_RESOURCE_REF).ref(shadow.getResourceRef().getOid()).and(); return q.item(ShadowType.F_OBJECT_CLASS).eq(shadow.getObjectClass()).build(); }
@Test public void test590Logicals() throws Exception { final String TEST_NAME = "test590Logicals"; displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class) .block() .all() .or().none() .or().undefined() .endBlock() .and().none() .and() .not() .block() .all() .and().undefined() .endBlock() .build(); checkQueryRoundtripFile(UserType.class, q, TEST_NAME); }