protected void assertSyncToken(Task task, Object expectedValue, OperationResult result) throws ObjectNotFoundException, SchemaException { PrismProperty<Object> syncTokenProperty = task.getExtensionProperty(SchemaConstants.SYNC_TOKEN); if (expectedValue == null && syncTokenProperty == null) { return; } Object syncTokenPropertyValue = syncTokenProperty.getAnyRealValue(); if (!MiscUtil.equals(expectedValue, syncTokenPropertyValue)) { AssertJUnit.fail("Wrong sync token, expected: " + expectedValue + (expectedValue==null?"":(", "+expectedValue.getClass().getName())) + ", was: "+ syncTokenPropertyValue + (syncTokenPropertyValue==null?"":(", "+syncTokenPropertyValue.getClass().getName()))); } }
private SyncToken getSyncToken(PrismProperty tokenProperty) throws SchemaException { if (tokenProperty == null){ return null; } if (tokenProperty.getValues() == null) { return null; } if (tokenProperty.getValues().isEmpty()) { return null; } if (tokenProperty.getValues().size() > 1) { throw new SchemaException("Unexpected number of attributes in SyncToken. SyncToken is single-value attribute and can contain only one value."); } Object tokenValue = tokenProperty.getAnyRealValue(); if (tokenValue == null) { return null; } SyncToken syncToken = new SyncToken(tokenValue); return syncToken; }
public <T> T getResourceIcfConfigurationPropertyValue(ResourceType resource, String propertyLocalPart) throws SchemaException { if (propertyLocalPart == null) { return null; } PrismContainer<?> configurationProperties = getIcfConfigurationProperties(resource); if (configurationProperties == null) { return null; } for (PrismProperty<?> property : configurationProperties.getValue().getProperties()) { if (propertyLocalPart.equals(property.getElementName().getLocalPart())) { return (T) property.getAnyRealValue(); } } return null; }
/** * @return */ public boolean isStructuredProperty() { if (!isProperty()) { return false; } PrismProperty<?> property = (PrismProperty<?>) getAnyItem(); Object realValue = property.getAnyRealValue(); if (realValue != null) { return realValue instanceof Structured; } PropertyDelta<?> delta = (PropertyDelta<?>) getDelta(); realValue = delta.getAnyRealValue(); if (realValue != null) { return realValue instanceof Structured; } return false; }
@Test public void testFindExtensionBar() throws SchemaException, SAXException, IOException { final String TEST_NAME = "testFindExtensionBar"; System.out.println("===[ "+TEST_NAME+" ]==="); // GIVEN ItemPath path = ItemPath.create(UserType.F_EXTENSION, EXTENSION_BAR_ELEMENT); // WHEN PrismProperty<String> property = findUserProperty(path); // THEN assertEquals("Wrong property value (path="+path+")", "BAR", property.getAnyRealValue()); }
assertEquals("Real value was not changed", "Small black cube", displayNamePP.getAnyRealValue()); displayNamePP.getAnyValue().setValue("Green point"); assertEquals("Real value was not changed", "Green point", displayNamePP.getAnyRealValue());
@SuppressWarnings("rawtypes") private PrismProperty getTokenProperty(ResourceShadowDiscriminator shadowCoordinates, Task task, OperationResult result) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, ExpressionEvaluationException { PrismProperty tokenProperty = null; if (task.getExtension() != null) { tokenProperty = task.getExtensionProperty(SchemaConstants.SYNC_TOKEN); } if (tokenProperty != null && (tokenProperty.getAnyRealValue() == null)) { LOGGER.warn("Sync token exists, but it is empty (null value). Ignoring it."); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Empty sync token property:\n{}", tokenProperty.debugDump()); } tokenProperty = null; } // if the token is not specified in the task, get the latest token if (tokenProperty == null) { tokenProperty = shadowCache.fetchCurrentToken(shadowCoordinates, result); if (tokenProperty == null || tokenProperty.getValue() == null || tokenProperty.getValue().getValue() == null) { LOGGER.warn("Empty current sync token provided by {}", shadowCoordinates); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Empty current sync token property."); } return null; } } return tokenProperty; }
@Override public <T extends Objectable> EventResult postMarshall(PrismObject<T> object, Element objectElement, OperationResult objectResult) { System.out.println("Validating resorce:"); System.out.println(object.debugDump()); object.checkConsistence(); PrismContainer<?> extensionContainer = object.getExtension(); PrismProperty<Integer> menProp = extensionContainer.findProperty(new ItemName("http://myself.me/schemas/whatever","menOnChest")); assertNotNull("No men on a dead man chest!", menProp); assertEquals("Wrong number of men on a dead man chest", (Integer)15, menProp.getAnyRealValue()); PrismPropertyDefinition menPropDef = menProp.getDefinition(); assertNotNull("Men on a dead man chest NOT defined", menPropDef); assertEquals("Wrong type for men on a dead man chest definition", DOMUtil.XSD_INT, menPropDef.getTypeName()); assertTrue("Men on a dead man chest definition not dynamic", menPropDef.isDynamic()); return EventResult.cont(); }