private <T> void assertExpression(PrismProperty<T> prop, String evaluatorName) { System.out.println("Prop:"); System.out.println(prop.debugDump(1)); PrismPropertyValue<T> pval = prop.getValue(); ExpressionWrapper expressionWrapper = pval.getExpression(); assertNotNull("No expression wrapper in "+prop, expressionWrapper); Object expressionObj = expressionWrapper.getExpression(); assertNotNull("No expression in "+prop, expressionObj); System.out.println("- Expression: "+expressionObj); if (namespaces) { assertTrue("Wrong expression type ("+language+","+(namespaces?"ns":"no-ns") + ") : " +expressionObj.getClass(), expressionObj instanceof ExpressionType); ExpressionType expressionType = (ExpressionType)expressionObj; JAXBElement<?> evaluatorElement = expressionType.getExpressionEvaluator().iterator().next(); assertEquals("Wrong expression evaluator name", evaluatorName, evaluatorElement.getName().getLocalPart()); } }
@Test public void test100FetchEmptyChanges() throws Exception { final String TEST_NAME = "test100FetchEmptyChanges"; TestUtil.displayTestTitle(this, TEST_NAME); OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME); ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT); // WHEN PrismProperty<Integer> lastToken = cc.fetchCurrentToken(accountDefinition, null, result); assertNotNull("No last sync token", lastToken); System.out.println("Property:"); System.out.println(lastToken.debugDump()); PrismPropertyDefinition<Integer> lastTokenDef = lastToken.getDefinition(); assertNotNull("No last sync token definition", lastTokenDef); assertEquals("Last sync token definition has wrong type", DOMUtil.XSD_INT, lastTokenDef.getTypeName()); assertTrue("Last sync token definition is NOT dynamic", lastTokenDef.isDynamic()); // WHEN List<Change> changes = cc.fetchChanges(accountDefinition, lastToken, null, null, result); AssertJUnit.assertEquals(0, changes.size()); }
@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; }
LOGGER.trace("targetPropertyNew:\n{}\ndelta:\n{}", targetPropertyNew.debugDump(1), DebugUtil.debugDump(delta, 1));