use of biblemulticonverter.schema.usx3.ObjectFactory in project midpoint by Evolveum.
the class TestConsistencyMechanism method test511AssignAccountMorgan.
/**
* assign account to the user morgan. Account with the same 'uid' (not dn, nut other secondary identifier already exists)
* account should be linked to the user.
*/
@Test
public void test511AssignAccountMorgan() throws Exception {
// GIVEN
openDJController.assumeRunning();
Task task = getTestTask();
OperationResult result = task.getResult();
dummyAuditService.clear();
// prepare new OU in opendj
openDJController.addEntryFromLdifFile(LDIF_CREATE_USERS_OU_FILE);
PrismObject<UserType> user = repositoryService.getObject(UserType.class, USER_MORGAN_OID, null, result);
display("User Morgan: ", user);
ExpressionType expression = new ExpressionType();
ObjectFactory of = new ObjectFactory();
RawType raw = new RawType(prismContext.xnodeFactory().primitive("uid=morgan,ou=users,dc=example,dc=com").frozen(), prismContext);
JAXBElement<?> val = of.createValue(raw);
expression.getExpressionEvaluator().add(val);
MappingType mapping = new MappingType();
mapping.setExpression(expression);
ResourceAttributeDefinitionType attrDefType = new ResourceAttributeDefinitionType();
attrDefType.setRef(new ItemPathType(ItemPath.create(getOpenDjSecondaryIdentifierQName())));
attrDefType.setOutbound(mapping);
ConstructionType construction = new ConstructionType();
construction.getAttribute().add(attrDefType);
construction.setResourceRef(ObjectTypeUtil.createObjectRef(resourceTypeOpenDjrepo, prismContext));
AssignmentType assignment = new AssignmentType();
assignment.setConstruction(construction);
// noinspection unchecked
ObjectDelta<UserType> userDelta = prismContext.deltaFactory().object().createModificationAddContainer(UserType.class, USER_MORGAN_OID, UserType.F_ASSIGNMENT, assignment.asPrismContainerValue());
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(userDelta);
// WHEN
when();
modelService.executeChanges(deltas, null, task, result);
// THEN
then();
result.computeStatus();
// assertEquals("Expected handled error but got: " + result.getStatus(), OperationResultStatus.HANDLED_ERROR, result.getStatus());
PrismObject<UserType> userMorgan = modelService.getObject(UserType.class, USER_MORGAN_OID, null, task, result);
display("User morgan after", userMorgan);
UserType userMorganType = userMorgan.asObjectable();
assertEquals("Unexpected number of accountRefs", 1, userMorganType.getLinkRef().size());
String accountOid = userMorganType.getLinkRef().iterator().next().getOid();
// Check shadow
PrismObject<ShadowType> accountShadow = repositoryService.getObject(ShadowType.class, accountOid, null, result);
provisioningService.applyDefinition(accountShadow, task, result);
assertShadowRepo(accountShadow, accountOid, "uid=morgan,ou=users,dc=example,dc=com", resourceTypeOpenDjrepo, RESOURCE_OPENDJ_ACCOUNT_OBJECTCLASS);
// Check account
PrismObject<ShadowType> accountModel = modelService.getObject(ShadowType.class, accountOid, null, task, result);
assertShadowModel(accountModel, accountOid, "uid=morgan,ou=users,dc=example,dc=com", resourceTypeOpenDjrepo, RESOURCE_OPENDJ_ACCOUNT_OBJECTCLASS);
ResourceAttribute<?> attributes = ShadowUtil.getAttribute(accountModel, new QName(MidPointConstants.NS_RI, "uid"));
assertEquals("morgan", attributes.getAnyRealValue());
// TODO: check OpenDJ Account
}
use of biblemulticonverter.schema.usx3.ObjectFactory in project midpoint by Evolveum.
the class TestPlentyOfAssignments method initSystem.
@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
super.initSystem(initTask, initResult);
initDummyResourcePirate(null, RESOURCE_DUMMY_FILE, RESOURCE_DUMMY_OID, initTask, initResult);
importObjectFromFile(ROLE_BASIC_FILE, initResult);
ObjectFactory objectFactory = new ObjectFactory();
generateRoles(NUMBER_OF_GENERATED_EMPTY_ROLES, "Empty Role %04d", GENERATED_EMPTY_ROLE_OID_FORMAT, null, initResult);
generateRoles(NUMBER_OF_GENERATED_DUMMY_ROLES, "Dummy Role %04d", GENERATED_DUMMY_ROLE_OID_FORMAT, (role, i) -> {
ItemPathType attrPath = new ItemPathType(ItemPath.create(new QName(RESOURCE_DUMMY_NS, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME)));
JAXBElement<Object> evaluator = objectFactory.createValue(formatRum(i));
role.beginInducement().beginConstruction().resourceRef(RESOURCE_DUMMY_OID, ResourceType.COMPLEX_TYPE).kind(ShadowKindType.ACCOUNT).beginAttribute().ref(attrPath).beginOutbound().beginExpression().expressionEvaluator(evaluator);
}, initResult);
inspector = new CountingInspector();
InternalMonitor.setInspector(inspector);
}
use of biblemulticonverter.schema.usx3.ObjectFactory in project midpoint by Evolveum.
the class TestPlentyOfAssignments method test200DummyGroups.
/**
* Create dummy groups that can be used for associationTargetSearch later on.
* Create them from midPoint so they have shadows.
* <p>
* MID-3938 #8
*/
@Test
public void test200DummyGroups() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
// WHEN
when();
PrismObjectDefinition<ShadowType> shadowDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ShadowType.class);
PrismObjectDefinition<RoleType> roleDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(RoleType.class);
ResourceSchema rSchema = ResourceSchemaFactory.getCompleteSchema(getDummyResourceObject());
ResourceObjectClassDefinition rOcDef = rSchema.findObjectClassDefinition(getDummyResourceController().getGroupObjectClass());
ObjectFactory objectFactory = new ObjectFactory();
ItemPath nameAttributePath = ItemPath.create(ShadowType.F_ATTRIBUTES, SchemaConstants.ICFS_NAME);
for (int i = 0; i < NUMBER_OF_GENERATED_DUMMY_GROUPS; i++) {
PrismObject<ShadowType> shadow = shadowDef.instantiate();
ShadowType shadowType = shadow.asObjectable();
shadowType.resourceRef(RESOURCE_DUMMY_OID, ResourceType.COMPLEX_TYPE).objectClass(rOcDef.getTypeName());
ResourceAttributeContainer attributesContainer = ShadowUtil.getOrCreateAttributesContainer(shadow, rOcDef);
ResourceAttribute<String> nameAttribute = attributesContainer.findOrCreateAttribute(SchemaConstants.ICFS_NAME);
String groupName = formatGroupName(i);
nameAttribute.setRealValue(groupName);
display("Group shadow " + i, shadow);
addObject(shadow, task, result);
PrismObject<RoleType> role = roleDef.instantiate();
RoleType roleType = role.asObjectable();
ItemPathType assPath = new ItemPathType(ItemPath.create(RESOURCE_DUMMY_ASSOCIATION_GROUP_QNAME));
SearchObjectExpressionEvaluatorType associationTargetSearchType = new SearchObjectExpressionEvaluatorType();
EqualFilter<String> filter = prismContext.queryFactory().createEqual(nameAttributePath, null, null, prismContext, groupName);
SearchFilterType filterType = prismContext.getQueryConverter().createSearchFilterType(filter);
associationTargetSearchType.setFilter(filterType);
associationTargetSearchType.setSearchStrategy(ObjectSearchStrategyType.IN_REPOSITORY);
JAXBElement<SearchObjectExpressionEvaluatorType> evaluator = objectFactory.createAssociationTargetSearch(associationTargetSearchType);
roleType.oid(generateRoleOid(GENERATED_DUMMY_GROUP_ROLE_OID_FORMAT, i)).name(String.format("Group role %04d", i)).beginInducement().beginConstruction().resourceRef(RESOURCE_DUMMY_OID, ResourceType.COMPLEX_TYPE).kind(ShadowKindType.ACCOUNT).beginAssociation().ref(assPath).beginOutbound().beginExpression().expressionEvaluator(evaluator);
try {
IntegrationTestTools.displayXml("RRRRRRRRR group", role);
} catch (SchemaException e) {
throw new SystemException(e);
}
addObject(role, task, result);
}
// THEN
then();
assertSuccess(result);
Collection<DummyGroup> dummyGroups = getDummyResource().listGroups();
assertEquals("Wrong number of dummy groups", NUMBER_OF_GENERATED_DUMMY_GROUPS, dummyGroups.size());
assertShadows(NUMBER_OF_GENERATED_DUMMY_GROUPS);
assertObjects(RoleType.class, NUMBER_OF_GENERATED_EMPTY_ROLES + NUMBER_OF_GENERATED_DUMMY_ROLES + NUMBER_OF_ORDINARY_ROLES + NUMBER_OF_GENERATED_DUMMY_GROUPS);
}
use of biblemulticonverter.schema.usx3.ObjectFactory in project ddf by codice.
the class CswQueryFactoryTest method setUp.
@org.junit.Before
public void setUp() throws URISyntaxException, SourceUnavailableException, UnsupportedQueryException, FederationException, ParseException, IngestException {
FilterBuilder filterBuilder = new GeotoolsFilterBuilder();
FilterAdapter filterAdapter = new GeotoolsFilterAdapterImpl();
CswRecordMap cswRecordMap = new MetacardCswRecordMap();
queryFactory = new CswQueryFactory(cswRecordMap, filterBuilder, filterAdapter, new PermissionsImpl());
AttributeRegistryImpl attributeRegistry = new AttributeRegistryImpl();
attributeRegistry.registerMetacardType(getCswMetacardType());
queryFactory.setAttributeRegistry(attributeRegistry);
polygon = new WKTReader().read(POLYGON_STR);
gmlObjectFactory = new net.opengis.gml.v_3_1_1.ObjectFactory();
filterObjectFactory = new ObjectFactory();
queryFilterTransformerProvider = mock(QueryFilterTransformerProvider.class);
QueryFilterTransformer cswQueryFilter = new CswQueryFilterTransformer(new MetacardCswRecordMap(), attributeRegistry);
when(queryFilterTransformerProvider.getTransformer(new QName(CswConstants.CSW_OUTPUT_SCHEMA, "Record"))).thenReturn(Optional.of(cswQueryFilter));
when(queryFilterTransformerProvider.getTransformer(anyString())).thenReturn(Optional.of(cswQueryFilter));
queryFactory.setQueryFilterTransformerProvider(queryFilterTransformerProvider);
}
use of biblemulticonverter.schema.usx3.ObjectFactory in project ddf by codice.
the class CswSubscriptionEndpointTest method testCreateOrUpdateSubscriptionPersitanceFalse.
@Test
public void testCreateOrUpdateSubscriptionPersitanceFalse() throws Exception {
ObjectFactory objectFactory = new ObjectFactory();
GetRecordsType getRecordsType = createDefaultGetRecordsRequest().get202RecordsType();
QueryType queryType = new QueryType();
getRecordsType.setAbstractQuery(objectFactory.createQuery(queryType));
cswSubscriptionEndpoint.createOrUpdateSubscription(getRecordsType, subscriptionId, false);
verify(mockContext).registerService(eq(Subscription.class.getName()), any(Subscription.class), any(Dictionary.class));
}
Aggregations