@Override public LensContext createModelContext(Task task, OperationResult result) throws Exception { LensContext<OrgType> context = createLensContext(OrgType.class); addFocusDeltaToContext(context, (ObjectDelta) DeltaFactory.Object.createAddDelta(PrismTestUtil.parseObject(TEST1_FILE))); return context; }
@Override public PrismObject<ShadowType> get() { try { PrismObject<ShadowType> account = PrismTestUtil.parseObject(ACCOUNT_JACK_DUMMY_FILE); account.removeContainer(ShadowType.F_ATTRIBUTES); return account; } catch (SchemaException|IOException e) { throw new IllegalStateException(e.getMessage(),e); } } };
@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 testParseResource() throws Exception { System.out.println("===[ testParseResource ]==="); // WHEN PrismObject<ResourceType> resource = PrismTestUtil.parseObject(new File("src/test/resources/common/xml/ns/resource-opendj.xml")); // THEN assertCapabilities(resource.asObjectable()); }
@SuppressWarnings("unchecked") public static void mockGetSystemConfiguration(RepositoryService repository, File file) throws JAXBException, ObjectNotFoundException, SchemaException, IOException { SystemConfigurationType systemConfiguration = (SystemConfigurationType) PrismTestUtil.parseObject(file).asObjectable(); when( repository.getObject(eq(SystemConfigurationType.class), eq(SystemObjectsType.SYSTEM_CONFIGURATION.value()), any(Collection.class), any(OperationResult.class))).thenReturn( systemConfiguration.asPrismObject()); }
@SuppressWarnings("unchecked") public static ObjectType addObjectToRepo(RepositoryService repositoryService, String fileString) throws Exception { ObjectType object = (ObjectType) PrismTestUtil.parseObject(new File(fileString)).asObjectable(); repositoryService.addObject(object.asPrismObject(), null, new OperationResult("Add Object")); return object; }
private String addAccount(File file) throws SchemaException, ObjectAlreadyExistsException, CommunicationException, ObjectNotFoundException, ConfigurationException, SecurityViolationException, IOException, ExpressionEvaluationException, PolicyViolationException { Task task = taskManager.createTaskInstance(TestDummyResourceAndSchemaCaching.class.getName() + ".addAccount"); OperationResult result = task.getResult(); PrismObject<ShadowType> account = PrismTestUtil.parseObject(file); String oid = provisioningService.addObject(account, null, null, task, result); result.computeStatus(); TestUtil.assertSuccess(result); return oid; }
private void assertAddDummyResourceAllow(File file) throws SchemaException, IOException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { PrismObject<ResourceType> resource = PrismTestUtil.parseObject(file); resource.asObjectable() .connectorRef(dummyConnector.getOid(), ConnectorType.COMPLEX_TYPE); assertAddAllow(resource, null); }
private void assertAddDummyResourceDeny(File file) throws SchemaException, IOException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { PrismObject<ResourceType> resource = PrismTestUtil.parseObject(file); resource.asObjectable() .connectorRef(dummyConnector.getOid(), ConnectorType.COMPLEX_TYPE); assertAddDeny(resource, null); }
@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 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); }
@Test public void testMatchEqualEmptyAgainstNonEmptyItem() 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_NAME).isNull() .buildFilter(); boolean match = ObjectQuery.match(user, filter, matchingRuleRegistry); AssertJUnit.assertFalse("filter matches object, but it should not", match); }
@Test // MID-4217 public void testRefPositive() throws Exception { PrismObject<UserType> user = PrismTestUtil.parseObject(PrismInternalTestUtil.USER_JACK_FILE_XML); ObjectFilter filter = getPrismContext().queryFor(UserType.class) .item(UserType.F_ACCOUNT_REF).ref("c0c010c0-d34d-b33f-f00d-aaaaaaaa1113") .buildFilter(); boolean match = ObjectQuery.match(user, filter, matchingRuleRegistry); AssertJUnit.assertTrue("filter does not match object, but it should", match); }
protected PrismObject<UserType> getUserOld() throws SchemaException, EncryptionException, IOException { PrismObject<UserType> user = PrismTestUtil.parseObject(USER_OLD_FILE); ProtectedStringType passwordPs = user.asObjectable().getCredentials().getPassword().getValue(); protector.encrypt(passwordPs); return user; }
@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 testPolystringMatchEqualFilter() throws Exception { PrismObject<UserType> user = PrismTestUtil.parseObject(PrismInternalTestUtil.USER_JACK_FILE_XML); PolyString name = new PolyString("jack", "jack"); ObjectFilter filter = getPrismContext().queryFor(UserType.class) .item(UserType.F_NAME).eq(name) .buildFilter(); boolean match = ObjectQuery.match(user, filter, matchingRuleRegistry); AssertJUnit.assertTrue("filter does not match object", match); }
@Test public void testMatchOrFilter() 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") .or().item(UserType.F_GIVEN_NAME).eq("Jackie") .buildFilter(); boolean match = ObjectQuery.match(user, filter, matchingRuleRegistry); AssertJUnit.assertTrue("filter does not match object", match); }
@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); }
protected <F extends FocusType> ObjectDelta<F> addModificationToContextAddProjection( LensContext<F> context, Class<F> focusType, File file) throws JAXBException, SchemaException, IOException { PrismObject<ShadowType> account = PrismTestUtil.parseObject(file); account.trim(); account.checkConsistence(); LensFocusContext<F> focusContext = context.getOrCreateFocusContext(); ObjectDelta<F> userDelta = prismContext.deltaFactory().object().createModificationAddReference(focusType, focusContext .getObjectOld().getOid(), FocusType.F_LINK_REF, account); focusContext.addPrimaryDelta(userDelta); return userDelta; }