private ObjectQuery toObjectQuery(Class type, SearchFilterType filterType) throws Exception { ObjectQuery query = getPrismContext().getQueryConverter().createObjectQuery(type, filterType ); return query; }
@Test public void testUserConstruction() throws Exception { System.out.println("\n\n ===[ testUserConstruction ]===\n"); // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); // WHEN PrismObject<UserType> user = prismContext.createObject(UserType.class); // THEN assertNotNull(user); SchemaTestUtil.assertUserDefinition(user.getDefinition()); }
private PrismContainer<AssignmentType> parseUserAssignmentContainer() throws SchemaException, IOException { PrismContext prismContext = getPrismContext(); PrismObject<UserType> user = prismContext.parseObject(USER_FILE); System.out.println("Parsed user:"); System.out.println(user.debugDump()); return user.findContainer(ItemPath.create(UserType.F_ASSIGNMENT, USER_ASSIGNMENT_1_ID, AssignmentType.F_EXTENSION)); }
@Test public void testParseSchema() throws Exception { System.out.println("===[ testParseSchema ]==="); // GIVEN Document schemaDom = DOMUtil.parseFile(RESOURCE_SCHEMA_SIMPLE_FILENAME); // WHEN ResourceSchema schema = ResourceSchemaImpl.parse(DOMUtil.getFirstChildElement(schemaDom), RESOURCE_SCHEMA_SIMPLE_FILENAME, PrismTestUtil.getPrismContext()); // THEN assertSimpleSchema(schema, RESOURCE_SCHEMA_SIMPLE_FILENAME); }
@Test public void test350SerializeToXml() throws Exception { System.out.println("===[ test350SerializeToXml ]==="); PrismObject<UserType> jack = getJack(); measure("serialize to XML", () -> getPrismContext().xmlSerializer().serialize(jack)); }
@Test public void test100EmptyFilter() throws Exception{ ObjectQuery actual = getPrismContext().queryFor(UserType.class).build(); ObjectQuery expected = ObjectQueryImpl.createObjectQuery((ObjectFilter) null); compare(actual, expected); }
@Test public void test120ObjectModifyName() throws Exception { System.out.println("===[ test120ObjectModifyName ]===="); ObjectDelta<?> delta = getPrismContext().deltaFor(UserType.class) .item(UserType.F_NAME).replace(PolyString.fromOrig("jack")) .asObjectDelta("123456"); roundTrip(delta); }
@Test public void test400OrgFilterRoot() throws Exception { final String TEST_NAME = "test400OrgFilterRoot"; displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(OrgType.class).isRoot().build(); checkQueryRoundtripFile(OrgType.class, q, TEST_NAME); }
@Test public void test200CheckEncryptedSystemConfiguration() throws Exception { final String TEST_NAME = "test200CheckEncryptedSystemConfiguration"; TestUtil.displayTestTitle(TEST_NAME); // GIVEN PrismContext prismContext = getPrismContext(); PrismObject<SystemConfigurationType> config = prismContext.parserFor(FILE_SYSTEM_CONFIGURATION).xml().parse(); // WHEN+THEN checkEncryptedObject(config); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testEmptyParameters() { PrismPropertyValue<String> value = getPrismContext().itemFactory().createPropertyValue(input); value = filter.apply(value); AssertJUnit.assertEquals(expected, value.getValue()); }
@Test public void test110EmptyBlock() throws Exception{ ObjectQuery actual = getPrismContext().queryFor(UserType.class).block().endBlock().build(); ObjectQuery expected = ObjectQueryImpl.createObjectQuery((ObjectFilter) null); compare(actual, expected); }
@Test // MID-4173 public void testExistsAnyPositive() throws Exception { PrismObject<UserType> user = PrismTestUtil.parseObject(PrismInternalTestUtil.USER_JACK_FILE_XML); ObjectFilter filter = getPrismContext().queryFor(UserType.class) .exists(UserType.F_ASSIGNMENT) .buildFilter(); boolean match = ObjectQuery.match(user, filter, matchingRuleRegistry); AssertJUnit.assertTrue("filter does not match object, but it should", match); }
@Test(expectedExceptions = IllegalStateException.class) public void test113BlocksLeftOpen() throws Exception{ getPrismContext().queryFor(UserType.class) .block() .block() .block() .endBlock() .endBlock() .build(); }
@Test(expectedExceptions = IllegalStateException.class) public void test114NoOpenBlocks() throws Exception{ getPrismContext().queryFor(UserType.class) .block() .block() .endBlock() .endBlock() .endBlock() .build(); }
@Test public void test130SingleEquals() throws Exception{ ObjectQuery actual = getPrismContext().queryFor(UserType.class).item(UserType.F_LOCALITY).eq("Caribbean").build(); ObjectQuery expected = ObjectQueryImpl.createObjectQuery(createEqual(UserType.F_LOCALITY, UserType.class, null, "Caribbean")); compare(actual, expected); }
@Test public void testValue() { List<Object> parameters = createGoodParameters(); filter.setParameters(parameters); PrismPropertyValue<String> value = getPrismContext().itemFactory().createPropertyValue(input); value = filter.apply(value); AssertJUnit.assertEquals(expected, value.getValue()); }
@Test public void testMatchEqualNonEmptyAgainstEmptyItem() 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).eq("some") .buildFilter(); boolean match = ObjectQuery.match(user, filter, matchingRuleRegistry); AssertJUnit.assertFalse("filter matches object, but it should not", match); }
@Test // MID-4217 public void testRefNegative() throws Exception { PrismObject<UserType> user = PrismTestUtil.parseObject(PrismInternalTestUtil.USER_JACK_FILE_XML); ObjectFilter filter = getPrismContext().queryFor(UserType.class) .item(UserType.F_ACCOUNT_REF).ref("xxxxxxxxxxxxxx") .buildFilter(); boolean match = ObjectQuery.match(user, filter, matchingRuleRegistry); AssertJUnit.assertFalse("filter matches object, but it should not", match); }
@Test public void test122AllInBlock() throws Exception{ ObjectQuery actual = getPrismContext().queryFor(UserType.class).block().all().endBlock().build(); ObjectQuery expected = ObjectQueryImpl.createObjectQuery(AllFilterImpl.createAll()); compare(actual, expected); }
@Test public void testMatchAndFilter() throws Exception { PrismObject<UserType> user = PrismTestUtil.parseObject(PrismInternalTestUtil.USER_JACK_FILE_XML); ObjectFilter filter = getPrismContext().queryFor(UserType.class) .item(UserType.F_GIVEN_NAME).eq("Jack").matchingCaseIgnore() .and().item(UserType.F_FULL_NAME).contains("arr") .buildFilter(); boolean match = ObjectQuery.match(user, filter, matchingRuleRegistry); AssertJUnit.assertTrue("filter does not match object", match); }