private static <T> void assertSet(String inMessage, String setName, MatchingRule<T> matchingRule, Collection<PrismPropertyValue<T>> actualPValues, T[] expectedValues) throws SchemaException { assertValues(setName + " set in " + inMessage, matchingRule, actualPValues, expectedValues); }
private static <T> void assertSet(String inMessage, String setName, Collection<PrismPropertyValue<T>> actualPValues, T[] expectedValues) { assertValues(setName + " set in " + inMessage, actualPValues, expectedValues); }
public static <T> void assertValues(String message, Collection<PrismPropertyValue<T>> actualPValues, T... expectedValues) { try { assertValues(message, null, actualPValues, expectedValues); } catch (SchemaException e) { // null matching rule, cannot happen throw new RuntimeException(e.getMessage(), e); } }
public <O extends ObjectType,T> void assertOldValue(String message, int index, ChangeType expectedChangeType, Class<O> expectedClass, ItemPath propPath, T... expectedValues) { ObjectDeltaOperation<O> deltaOp = getExecutionDelta(index, expectedChangeType, expectedClass); assert deltaOp != null : (message==null?"":message+": ")+"Delta for "+expectedClass+" of type "+expectedChangeType+" was not found in audit trail"; PropertyDelta<Object> propDelta = deltaOp.getObjectDelta().findPropertyDelta(propPath); assert propDelta != null : "No property delta for "+propPath+" in Delta for "+expectedClass+" of type "+expectedChangeType; Collection<PrismPropertyValue<Object>> estimatedOldValues = propDelta.getEstimatedOldValues(); if (expectedValues == null || expectedValues.length == 0) { if (estimatedOldValues == null || estimatedOldValues.isEmpty()) { return; } else { assert false : (message==null?"":message+": ") + "Empty old values in property delta for "+propPath+" in Delta for "+expectedClass+" of type "+expectedChangeType + ", expected " + Arrays.toString(expectedValues); } } assert estimatedOldValues != null && !estimatedOldValues.isEmpty() : "No old values in property delta for "+propPath+" in Delta for "+expectedClass+" of type "+expectedChangeType; PrismAsserts.assertValues((message==null?"":message+": ") +"Wrong old values in property delta for "+propPath+" in Delta for "+expectedClass+" of type "+expectedChangeType, estimatedOldValues, expectedValues); }
public <O extends ObjectType,T> void assertPropertyReplace(String message, int index, ChangeType expectedChangeType, Class<O> expectedClass, ItemPath propPath, T... expectedValues) { ObjectDeltaOperation<O> deltaOp = getExecutionDelta(index, expectedChangeType, expectedClass); assert deltaOp != null : (message==null?"":message+": ")+"Delta for "+expectedClass+" of type "+expectedChangeType+" was not found in audit trail"; PropertyDelta<Object> propDelta = deltaOp.getObjectDelta().findPropertyDelta(propPath); assert propDelta != null : "No property delta for "+propPath+" in Delta for "+expectedClass+" of type "+expectedChangeType; Collection<PrismPropertyValue<Object>> valuesToReplace = propDelta.getValuesToReplace(); assert valuesToReplace != null : "No values to replace in property delta for "+propPath+" in Delta for "+expectedClass+" of type "+expectedChangeType; if (expectedValues == null || expectedValues.length == 0) { if (valuesToReplace.isEmpty()) { return; } else { assert false : (message==null?"":message+": ") + "Empty values to replace in property delta for "+propPath+" in Delta for "+expectedClass+" of type "+expectedChangeType + ", expected " + Arrays.toString(expectedValues); } } PrismAsserts.assertValues((message==null?"":message+": ") +"Wrong values to replace in property delta for "+propPath+" in Delta for "+expectedClass+" of type "+expectedChangeType, valuesToReplace, expectedValues); }
@Test public void test152EvaluateExpressionEmployeeTypeDefaultsCaptain() throws Exception { final String TEST_NAME = "test152EvaluateExpressionEmployeeTypeDefaultsCaptain"; TestUtil.displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestFilterExpression.class.getName() + "." + TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); ObjectFilter filter = evaluateExpressionAssertFilter("expression-employeeType-filter-defaults.xml", "CAPTAIN", EqualFilter.class, task, result); EqualFilter equalFilter = (EqualFilter) filter; PrismAsserts.assertValues("Wrong values in filter", equalFilter.getValues(), "CAPTAIN"); executeFilter(filter, 1, task, result); }
@Test public void testItemDeltaReplaceOldValue() throws Exception { System.out.println("===[ testItemDeltaReplaceOldValue ]===="); // GIVEN PrismObjectDefinition<UserType> userDef = getUserDefinition(); PropertyDelta<String> deltaBefore = getPrismContext().deltaFactory().property().createReplaceEmptyDelta(userDef, UserType.F_COST_CENTER); deltaBefore.setRealValuesToReplace("foo"); deltaBefore.addEstimatedOldValue(getPrismContext().itemFactory().createPropertyValue("BAR")); // WHEN Collection<ItemDeltaType> itemDeltaTypes = DeltaConvertor.toItemDeltaTypes(deltaBefore); // THEN System.out.println("Serialized"); System.out.println(itemDeltaTypes); // WHEN ItemDelta<?,?> deltaAfter = DeltaConvertor.createItemDelta(itemDeltaTypes.iterator().next(), userDef); // THEN System.out.println("Parsed"); System.out.println(deltaAfter.debugDump()); assertEquals("Deltas do not match", deltaBefore, deltaAfter); PropertyDelta<String> propDeltaAfter = (PropertyDelta<String>)deltaAfter; PrismAsserts.assertValues("Wrong old value", propDeltaAfter.getEstimatedOldValues(), "BAR"); }