public static void assertPropertyDefinition(PrismProperty property, QName type, int minOccurs, int maxOccurs, Boolean indexed) { assertDefinition(property, type, minOccurs, maxOccurs); PrismPropertyDefinition definition = property.getDefinition(); assert equals(indexed, definition.isIndexed()) : "Property should have indexed=" + indexed + ", but it has indexed=" + definition.isIndexed(); }
public static void assertPropertyDefinition(PrismContainerDefinition<?> containerDef, QName propertyName, QName type, int minOccurs, int maxOccurs, boolean indexed) { assertPropertyDefinition(containerDef, propertyName, type, minOccurs, maxOccurs); PrismPropertyDefinition definition = containerDef.findPropertyDefinition(ItemName.fromQName(propertyName)); assert equals(indexed, definition.isIndexed()) : "Property should have indexed=" + indexed + ", but it has indexed=" + definition.isIndexed(); }
public static void assertIndexed(PrismContainerDefinition<? extends Containerable> containerDef, QName itemQName, Boolean expected) { PrismPropertyDefinition propertyDefinition = containerDef.findPropertyDefinition(ItemName.fromQName(itemQName)); assertEquals("Wrong value of 'indexed' in property '"+PrettyPrinter.prettyPrint(itemQName)+" in "+containerDef, expected, propertyDefinition.isIndexed()); }
private static boolean isIndexed(ItemDefinition definition, QName elementName, boolean indexAlsoDynamics, PrismContext prismContext) throws SchemaException { if (definition instanceof PrismContainerDefinition) { return false; } if (definition instanceof PrismReferenceDefinition) { return true; // TODO make reference indexing configurable } if (!(definition instanceof PrismPropertyDefinition)) { throw new UnsupportedOperationException("Unknown definition type '" + definition + "', can't say if '" + elementName + "' is indexed or not."); } PrismPropertyDefinition pDefinition = (PrismPropertyDefinition) definition; Boolean isIndexed = pDefinition.isIndexed(); if (definition.isDynamic() && !indexAlsoDynamics && BooleanUtils.isNotTrue(isIndexed)) { return false; } if (isIndexed != null) { if (isIndexed && !isIndexedByDefault(definition, prismContext)) { throw new SchemaException("Item is marked as indexed (definition " + definition.debugDump() + ") but definition type (" + definition.getTypeName() + ") doesn't support indexing"); } return isIndexed; } return isIndexedByDefault(definition, prismContext); }
PrismPropertyDefinition singleStringTypePropertyDef = singleStringType.getDefinition(); PrismAsserts.assertDefinition(singleStringTypePropertyDef, EXTENSION_SINGLE_STRING_TYPE_ELEMENT, DOMUtil.XSD_STRING, 0, 1); assertNull("'Indexed' attribute on 'singleStringType' property is not null", singleStringTypePropertyDef.isIndexed()); assertEquals("'Indexed' attribute on 'singleStringType' property is wrong", Boolean.FALSE, indexedStringPropertyDef.isIndexed()); assertNotNull("No definition for bar", barPropertyDef); PrismAsserts.assertDefinitionTypeLoose(barPropertyDef, EXTENSION_BAR_ELEMENT, DOMUtil.XSD_STRING, 1, -1); assertNull("'Indexed' attribute on 'bar' property is not null", barPropertyDef.isIndexed()); assertNull("'Indexed' attribute on 'multi' property is not null", multiPropertyDef.isIndexed());
PrismPropertyDefinition stringTypePropertyDef = stringType.getDefinition(); PrismAsserts.assertDefinition(stringTypePropertyDef, EXTENSION_STRING_TYPE_ELEMENT, DOMUtil.XSD_STRING, 0, -1); assertNull("'Indexed' attribute on 'stringType' property is not null", stringTypePropertyDef.isIndexed()); PrismPropertyDefinition singleStringTypePropertyDef = singleStringType.getDefinition(); PrismAsserts.assertDefinition(singleStringTypePropertyDef, EXTENSION_SINGLE_STRING_TYPE_ELEMENT, DOMUtil.XSD_STRING, 0, 1); assertNull("'Indexed' attribute on 'singleStringType' property is not null", singleStringTypePropertyDef.isIndexed()); PrismPropertyDefinition doubleTypePropertyDef = doubleType.getDefinition(); PrismAsserts.assertDefinition(doubleTypePropertyDef, EXTENSION_DOUBLE_TYPE_ELEMENT, DOMUtil.XSD_DOUBLE, 0, -1); assertNull("'Indexed' attribute on 'doubleType' property is not null", doubleTypePropertyDef.isIndexed()); PrismPropertyDefinition intTypePropertyDef = intType.getDefinition(); PrismAsserts.assertDefinition(intTypePropertyDef, EXTENSION_INT_TYPE_ELEMENT, DOMUtil.XSD_INT, 0, -1); assertNull("'Indexed' attribute on 'intType' property is not null", intTypePropertyDef.isIndexed()); PrismPropertyDefinition integerTypePropertyDef = integerType.getDefinition(); PrismAsserts.assertDefinition(integerTypePropertyDef, EXTENSION_INTEGER_TYPE_ELEMENT, DOMUtil.XSD_INTEGER, 0, -1); assertNull("'Indexed' attribute on 'integerType' property is not null", integerTypePropertyDef.isIndexed()); PrismPropertyDefinition longTypePropertyDef = longType.getDefinition(); PrismAsserts.assertDefinition(longTypePropertyDef, EXTENSION_LONG_TYPE_ELEMENT, DOMUtil.XSD_LONG, 0, -1); assertNull("'Indexed' attribute on 'longType' property is not null", longTypePropertyDef.isIndexed()); PrismPropertyDefinition dateTypePropertyDef = dateType.getDefinition(); PrismAsserts.assertDefinition(dateTypePropertyDef, EXTENSION_DATE_TYPE_ELEMENT, DOMUtil.XSD_DATETIME, 0, -1); assertNull("'Indexed' attribute on 'longType' property is not null", dateTypePropertyDef.isIndexed()); PrismPropertyDefinition durationTypePropertyDef = durationType.getDefinition();
assertNotNull("No 'bar' definition in user extension", barPropDef); PrismAsserts.assertDefinition(barPropDef, USER_EXT_BAR_ELEMENT, DOMUtil.XSD_STRING, 1, 1); assertTrue("'bar' not indexed", barPropDef.isIndexed()); assertNull("'foobar' has non-null indexed flag", foobarPropDef.isIndexed()); assertFalse("'multi' not indexed", multiPropDef.isIndexed());
private void assertUserElisabethExtension(PrismObject<UserType> user) { PrismContainer<?> extension = user.getExtension(); assertContainerDefinition(extension, "extension", DOMUtil.XSD_ANY, 0, 1); PrismContainerValue<?> extensionValue = extension.getValue(); assertTrue("Extension parent", extensionValue.getParent() == extension); assertNull("Extension ID", extensionValue.getId()); // PrismProperty<String> stringType = extension.findProperty(EXTENSION_STRING_TYPE_ELEMENT); // PrismAsserts.assertPropertyValue(stringType, "BARbar", "FOObar"); // PrismPropertyDefinition stringTypePropertyDef = stringType.getDefinition(); // PrismAsserts.assertDefinition(stringTypePropertyDef, EXTENSION_STRING_TYPE_ELEMENT, DOMUtil.XSD_STRING, 0, -1); // assertNull("'Indexed' attribute on 'stringType' property is not null", stringTypePropertyDef.isIndexed()); PrismProperty<String> secondaryStringType = extension.findProperty(EXTENSION_SECONDARY_SECONDARY_STRING_TYPE_ELEMENT); PrismAsserts.assertPropertyValue(secondaryStringType, "string1"); PrismPropertyDefinition secondaryStringTypePropertyDef = secondaryStringType.getDefinition(); PrismAsserts.assertDefinition(secondaryStringTypePropertyDef, EXTENSION_SINGLE_STRING_TYPE_ELEMENT, DOMUtil.XSD_STRING, 0, -1); assertNull("'Indexed' attribute on 'secondaryStringType' property is not null", secondaryStringTypePropertyDef.isIndexed()); }