@Test public void testUnmarshallResource() throws Exception { System.out.println("===[ testUnmarshallResource ]==="); // WHEN ResourceType resourceType = (ResourceType) PrismTestUtil.parseObject(new File("src/test/resources/common/xml/ns/resource-opendj.xml")).asObjectable(); // THEN assertCapabilities(resourceType); }
@Test public void test120Undefined() throws Exception { final String TEST_NAME = "test120Undefined"; displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class).undefined().build(); checkQueryRoundtripFile(UserType.class, q, TEST_NAME); }
protected void assertModifyAllow() throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { // self-modify, common property assertModifyAllow(UserType.class, USER_JACK_OID, UserType.F_HONORIFIC_PREFIX, PrismTestUtil.createPolyString("Captain")); // TODO: self-modify password assertModifyAllow(UserType.class, USER_GUYBRUSH_OID, UserType.F_HONORIFIC_PREFIX, PrismTestUtil.createPolyString("Pirate")); // TODO: modify other objects }
@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); }
@BeforeSuite public void setup() throws SchemaException, SAXException, IOException { PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); }
@Test public void testParseValueFilterWithAny() throws Exception { PrismContext prismContext = PrismTestUtil.getPrismContext(); Document doc = DOMUtil.parseFile(new File(TestConstants.COMMON_DIR, "value-filter-with-any.xml")); Element rootElement = DOMUtil.getFirstChildElement(doc); // WHEN Object parsedObject = prismContext.parserFor(rootElement).parseRealValue(); // THEN System.out.println("Parsed object: " + parsedObject); }
@Test public void testExpressionPolyStringEqualsStringify122() throws Exception { evaluateAndAssertBooleanScalarExpresssion( "expression-polystring-equals-stringify-1.xml", "testExpressionPolyStringEqualsStringify122", ExpressionVariables.create( new QName(NS_X, "foo"), PrismTestUtil.createPolyStringType("FOOBAR"), new QName(NS_Y, "bar"), "BAR" ), Boolean.FALSE); }
@BeforeSuite public void setup() throws SchemaException, SAXException, IOException { PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); protector = KeyStoreBasedProtectorBuilder.create(getPrismContext()) .keyStorePath("src/test/resources/keystore.jceks") .keyStorePassword("changeit") .initialize(); clock = new Clock(); }
private ExpressionVariables createVariablesOdo() throws SchemaException, IOException { ExpressionVariables variables = new ExpressionVariables(); PrismObject<UserType> userOld = createUser(); ObjectDelta<UserType> delta = PrismTestUtil.getPrismContext().deltaFactory().object().createModificationReplaceProperty(UserType.class, userOld.getOid(), UserType.F_FULL_NAME, PrismTestUtil.createPolyString("Captain Jack Sparrow")); ObjectDeltaObject<UserType> odo = new ObjectDeltaObject<>(userOld, delta, null); odo.recompute(); variables.addVariableDefinition(ExpressionConstants.VAR_USER, odo); return variables; }
private ScriptExpressionEvaluatorType parseScriptType(String fileName) throws SchemaException, IOException, JAXBException { ScriptExpressionEvaluatorType expressionType = PrismTestUtil.parseAtomicValue( new File(TEST_DIR, fileName), ScriptExpressionEvaluatorType.COMPLEX_TYPE); return expressionType; }
@BeforeSuite public void setup() throws SchemaException, SAXException, IOException { PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); prismContext = PrismTestUtil.createInitializedPrismContext(); ObjectResolver resolver = new DirectoryFileObjectResolver(MidPointTestConstants.OBJECTS_DIR); Protector protector = ExpressionTestUtil.createInitializedProtector(prismContext); Clock clock = new Clock(); expressionFactory = ExpressionTestUtil.createInitializedExpressionFactory(resolver, protector, prismContext, clock, null, null); }
public static void displayXml(String message, PrismObject<? extends ObjectType> object) throws SchemaException { String xml = PrismTestUtil.serializeObjectToString(object, PrismContext.LANG_XML); display(message, xml); }
@Test public void testRefRelationNegative() throws Exception { PrismObject<UserType> user = PrismTestUtil.parseObject(PrismInternalTestUtil.USER_JACK_FILE_XML); ObjectFilter filter = getPrismContext().queryFor(UserType.class) .item(UserType.F_ACCOUNT_REF).ref(new QName("a-relation")) .buildFilter(); boolean match = ObjectQuery.match(user, filter, matchingRuleRegistry); AssertJUnit.assertFalse("filter matches object, but it should not", match); } }
@BeforeSuite public void setup() throws SchemaException, SAXException, IOException { PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); resetPrismContext(MidPointPrismContextFactory.FACTORY); }
private void single(final String TEST_NAME, File file, QName elementName) throws Exception { System.out.println("\n\n===[ "+TEST_NAME+" ]===\n"); // GIVEN PrismContext prismContext = getPrismContext(); // WHEN PrismObject<ObjectTemplateType> object = prismContext.parseObject(file); // THEN System.out.println("Parsed object:"); System.out.println(object.debugDump()); assertObjectTemplate(object, elementName); assertObjectTemplateInternals(object, elementName); }
@Test public void testExpressionPolyStringEquals121() throws Exception { evaluateAndAssertBooleanScalarExpresssion( "expression-polystring-equals-1.xml", "testExpressionPolyStringEquals121", ExpressionVariables.create( new QName(NS_X, "foo"), PrismTestUtil.createPolyStringType("FOO"), new QName(NS_Y, "bar"), "BAR" ), Boolean.TRUE); // velocity calls '==' on toString value }
private ScriptExpressionEvaluatorType parseScriptType(String fileName) throws SchemaException, IOException, JAXBException { ScriptExpressionEvaluatorType expressionType = PrismTestUtil.parseAtomicValue( new File(TEST_DIR, fileName), ScriptExpressionEvaluatorType.COMPLEX_TYPE); return expressionType; }
@Override public <T extends Objectable> EventResult postMarshall(PrismObject<T> object, Element objectElement, OperationResult objectResult) { // Try to marshall it back. This may detect some JAXB miscofiguration problems. try { String serializedString = PrismTestUtil.serializeObjectToString(object, PrismContext.LANG_XML); } catch (SchemaException e) { objectResult.recordFatalError("Object serialization failed", e); } return EventResult.cont(); }
@Test public void testDontMatchEqualFilter() throws Exception { PrismObject<UserType> user = PrismTestUtil.parseObject(PrismInternalTestUtil.USER_JACK_FILE_XML); ObjectFilter filter = getPrismContext().queryFor(UserType.class) .item(UserType.F_GIVEN_NAME).eq("Jackie") .buildFilter(); boolean match = ObjectQuery.match(user, filter, matchingRuleRegistry); AssertJUnit.assertFalse("filter matches object, but it should not", match); }
@BeforeSuite public void setup() throws SchemaException, SAXException, IOException { PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); }