Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Dec 2, 2017
2 parents bbf6a8b + 19c23ef commit 2d7f36b
Show file tree
Hide file tree
Showing 6 changed files with 172 additions and 36 deletions.
Expand Up @@ -555,18 +555,19 @@ public IModel<String> getDataModel(IModel<SelectableBean<ObjectType>> rowModel)

protected String getTaskName(String operation, QueryScope scope, boolean managers) {
StringBuilder nameBuilder = new StringBuilder(operation);
nameBuilder.append(" ");
nameBuilder.append(".");
if (scope != null) {
nameBuilder.append(scope.name());
nameBuilder.append(" ");
nameBuilder.append(".");
}
if (managers) {
nameBuilder.append("managers: ");
nameBuilder.append("managers");
} else {
nameBuilder.append("members: ");
nameBuilder.append("members");
}
nameBuilder
.append(WebComponentUtil.getEffectiveName(getModelObject(), AbstractRoleType.F_DISPLAY_NAME));
// nameBuilder.append(".");
// nameBuilder
// .append(WebComponentUtil.getEffectiveName(getModelObject(), AbstractRoleType.F_DISPLAY_NAME));
return nameBuilder.toString();
}

Expand Down
Expand Up @@ -3863,4 +3863,15 @@ ExpressionValuePanel.addValueButtonDefaultTitle=Add shadow reference value
ExpressionValuePanel.addValueButtonTargetSearchTitle=Add association target search
ExpressionValuePanel.addLiteralValueButton=Add literal value
ConstructionType.attribute=Attribute
ConstructionType.association=Association
ConstructionType.association=Association
operation.Recompute.ALL.members=Recompute all members
operation.Recompute.SELECTED.members=Recompute selected members
operation.Recompute.ALL_DIRECT.members=Recompute all direct members
operation.Remove.ALL.members=Remove all members
operation.Remove.SELECTED.members=Remove selected members
operation.Remove.ALL_DIRECT.members=Remove all direct members
operation.Remove.ALL.managers=Remove all managers
operation.Remove.SELECTED.managers=Remove selected managers
operation.Remove.ALL_DIRECT.managers=Remove all direct managers
operation.Add.members=Add members
operation.Remove.members=Remove members
Expand Up @@ -3823,3 +3823,15 @@ ExpressionValuePanel.addValueButtonTargetSearchTitle=Add association target sear
ExpressionValuePanel.addLiteralValueButton=Add literal value
ConstructionType.attribute=Attribute
ConstructionType.association=Association
operation.Recompute.ALL.members=Recompute all members
operation.Recompute.SELECTED.members=Recompute selected members
operation.Recompute.ALL_DIRECT.members=Recompute all direct members
operation.Remove.ALL.members=Remove all members
operation.Remove.SELECTED.members=Remove selected members
operation.Remove.ALL_DIRECT.members=Remove all direct members
operation.Remove.ALL.managers=Remove all managers
operation.Remove.SELECTED.managers=Remove selected managers
operation.Remove.ALL_DIRECT.managers=Remove all direct managers
operation.Add.members=Add members
operation.Remove.members=Remove members

Expand Up @@ -19,6 +19,8 @@
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.util.LocalizableMessage;
import com.evolveum.midpoint.util.exception.SystemException;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import org.apache.commons.lang.StringUtils;
import org.springframework.context.MessageSource;
import org.springframework.context.NoSuchMessageException;
Expand All @@ -38,6 +40,8 @@
*/
public class LocalizationServiceImpl implements LocalizationService {

private static final Trace LOG = TraceManager.getTrace(LocalizationServiceImpl.class);

private List<MessageSource> sources = new ArrayList<>();

public void init() {
Expand Down Expand Up @@ -73,7 +77,10 @@ public String translate(String key, Object[] params, Locale locale, String defau
try {
String value = source.getMessage(key, translated, locale);
if (StringUtils.isNotEmpty(value)) {
//System.out.println("LSI: resolved [" + key + "] into [" + value + "]");
if (LOG.isTraceEnabled()) {
LOG.trace("Resolved key {} to value {} using message source {}", new Object[]{key, value, source});
}

return value;
}
} catch (NoSuchMessageException ex) {
Expand Down Expand Up @@ -105,6 +112,7 @@ public String translate(LocalizableMessage msg, Locale locale) {
private ResourceBundleMessageSource buildSource(String basename, ClassLoader classLoader) {
ResourceBundleMessageSource source = new ResourceBundleMessageSource();
source.setDefaultEncoding(StandardCharsets.UTF_8.name());
source.setFallbackToSystemLocale(false);
source.setBasename(basename);

if (classLoader == null) {
Expand Down
Expand Up @@ -2528,8 +2528,8 @@ public void test191ModifyUserJackModifyAssignment() throws Exception {
}

@Test
public void test195ModifyUserJack() throws Exception {
final String TEST_NAME = "test195ModifyUserJack";
public void test192ModifyUserJack() throws Exception {
final String TEST_NAME = "test192ModifyUserJack";
displayTestTitle(TEST_NAME);

// GIVEN
Expand All @@ -2544,15 +2544,14 @@ public void test195ModifyUserJack() throws Exception {

// THEN
displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess("executeChanges result", result);
assertSuccess(result);
// Strong mappings
assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1);

PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User after change execution", userJack);
assertUserJack(userJack, "Magnificent Captain Jack Sparrow");
accountJackOid = getSingleLinkOid(userJack);
PrismObject<UserType> userAfter = getUser(USER_JACK_OID);
display("User after", userAfter);
assertUserJack(userAfter, "Magnificent Captain Jack Sparrow");
accountJackOid = getSingleLinkOid(userAfter);

// Check shadow
PrismObject<ShadowType> accountShadow = repositoryService.getObject(ShadowType.class, accountJackOid, null, result);
Expand All @@ -2565,7 +2564,7 @@ public void test195ModifyUserJack() throws Exception {
// Check account in dummy resource
assertDefaultDummyAccount("jack", "Magnificent Captain Jack Sparrow", true);

assertDummyScriptsModify(userJack);
assertDummyScriptsModify(userAfter);

// Check audit
display("Audit", dummyAuditService);
Expand Down Expand Up @@ -2601,8 +2600,8 @@ public void test195ModifyUserJack() throws Exception {
}

@Test
public void test196ModifyUserJackLocationEmpty() throws Exception {
final String TEST_NAME = "test196ModifyUserJackLocationEmpty";
public void test193ModifyUserJackLocationEmpty() throws Exception {
final String TEST_NAME = "test193ModifyUserJackLocationEmpty";
displayTestTitle(TEST_NAME);

// GIVEN
Expand All @@ -2611,18 +2610,17 @@ public void test196ModifyUserJackLocationEmpty() throws Exception {
preTestCleanup(AssignmentPolicyEnforcementType.FULL);

// WHEN
modifyUserReplace(USER_JACK_OID, UserType.F_LOCALITY, task, result);
modifyUserReplace(USER_JACK_OID, UserType.F_LOCALITY, task, result /* no value */);

// THEN
result.computeStatus();
TestUtil.assertSuccess("executeChanges result", result);
assertSuccess(result);
// Strong mappings
assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1);

PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User after change execution", userJack);
assertUserJack(userJack, "Magnificent Captain Jack Sparrow", "Jack", "Sparrow", null);
accountJackOid = getSingleLinkOid(userJack);
PrismObject<UserType> userAfter = getUser(USER_JACK_OID);
display("User after", userAfter);
assertUserJack(userAfter, "Magnificent Captain Jack Sparrow", "Jack", "Sparrow", null);
accountJackOid = getSingleLinkOid(userAfter);

// Check shadow
PrismObject<ShadowType> accountShadow = repositoryService.getObject(ShadowType.class, accountJackOid, null, result);
Expand All @@ -2636,7 +2634,7 @@ public void test196ModifyUserJackLocationEmpty() throws Exception {
// Check account in dummy resource
assertDefaultDummyAccount("jack", "Magnificent Captain Jack Sparrow", true);

assertDummyScriptsModify(userJack);
assertDummyScriptsModify(userAfter);

// Check audit
display("Audit", dummyAuditService);
Expand All @@ -2645,6 +2643,9 @@ public void test196ModifyUserJackLocationEmpty() throws Exception {
dummyAuditService.assertAnyRequestDeltas();
dummyAuditService.assertExecutionDeltas(2);
dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class);
dummyAuditService.assertPropertyReplace(ChangeType.MODIFY, UserType.class, UserType.F_LOCALITY /* no values */);
// MID-4020
dummyAuditService.assertOldValue(ChangeType.MODIFY, UserType.class, UserType.F_LOCALITY, createPolyString(USER_JACK_LOCALITY));
dummyAuditService.assertHasDelta(ChangeType.MODIFY, ShadowType.class);
dummyAuditService.assertTarget(USER_JACK_OID);
dummyAuditService.assertExecutionSuccess();
Expand All @@ -2665,8 +2666,8 @@ public void test196ModifyUserJackLocationEmpty() throws Exception {
}

@Test
public void test197ModifyUserJackLocationNull() throws Exception {
final String TEST_NAME = "test197ModifyUserJackLocationNull";
public void test194ModifyUserJackLocationNull() throws Exception {
final String TEST_NAME = "test194ModifyUserJackLocationNull";
displayTestTitle(TEST_NAME);

// GIVEN
Expand Down Expand Up @@ -2697,6 +2698,73 @@ public void test197ModifyUserJackLocationNull() throws Exception {
assertCounterIncrement(InternalCounters.SCRIPT_COMPILE_COUNT, 0);
assertSteadyResources();
}

@Test
public void test195ModifyUserJackLocationSea() throws Exception {
final String TEST_NAME = "test195ModifyUserJackLocationSea";
displayTestTitle(TEST_NAME);

// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
preTestCleanup(AssignmentPolicyEnforcementType.FULL);

// WHEN
displayWhen(TEST_NAME);
modifyUserReplace(USER_JACK_OID, UserType.F_LOCALITY, task, result, createPolyString("sea"));

// THEN
displayThen(TEST_NAME);
assertSuccess(result);
// Strong mappings
assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1);

PrismObject<UserType> userAfter = getUser(USER_JACK_OID);
display("User after", userAfter);
assertUserJack(userAfter, "Magnificent Captain Jack Sparrow", USER_JACK_GIVEN_NAME, USER_JACK_FAMILY_NAME, "sea");
accountJackOid = getSingleLinkOid(userAfter);

// Check shadow
PrismObject<ShadowType> accountShadow = repositoryService.getObject(ShadowType.class, accountJackOid, null, result);
assertDummyAccountShadowRepo(accountShadow, accountJackOid, "jack");

// Check account
PrismObject<ShadowType> accountModel = modelService.getObject(ShadowType.class, accountJackOid, null, task, result);
assertDummyAccountShadowModel(accountModel, accountJackOid, "jack", "Magnificent Captain Jack Sparrow");

// Check account in dummy resource
assertDefaultDummyAccount("jack", "Magnificent Captain Jack Sparrow", true);

assertDummyScriptsModify(userAfter);

// Check audit
display("Audit", dummyAuditService);
dummyAuditService.assertRecords(2);
dummyAuditService.assertSimpleRecordSanity();
dummyAuditService.assertAnyRequestDeltas();
dummyAuditService.assertExecutionDeltas(2);
dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class);
dummyAuditService.assertHasDelta(ChangeType.MODIFY, ShadowType.class);
dummyAuditService.assertPropertyReplace(ChangeType.MODIFY, UserType.class, UserType.F_LOCALITY, createPolyString("sea"));
// MID-4020
dummyAuditService.assertOldValue(ChangeType.MODIFY, UserType.class, UserType.F_LOCALITY /* no values */);
dummyAuditService.assertTarget(USER_JACK_OID);
dummyAuditService.assertExecutionSuccess();

// Check notifications
notificationManager.setDisabled(true);
checkDummyTransportMessages(NOTIFIER_ACCOUNT_PASSWORD_NAME, 0);
checkDummyTransportMessages("userPasswordNotifier", 0);
checkDummyTransportMessages("simpleAccountNotifier-SUCCESS", 1);
checkDummyTransportMessages("simpleAccountNotifier-FAILURE", 0);
checkDummyTransportMessages("simpleAccountNotifier-ADD-SUCCESS", 0);
checkDummyTransportMessages("simpleAccountNotifier-DELETE-SUCCESS", 0);
checkDummyTransportMessages("simpleUserNotifier", 1);
checkDummyTransportMessages("simpleUserNotifier-ADD", 0);

assertCounterIncrement(InternalCounters.SCRIPT_COMPILE_COUNT, 0);
assertSteadyResources();
}

@Test
public void test198ModifyUserJackRaw() throws Exception {
Expand All @@ -2721,7 +2789,7 @@ public void test198ModifyUserJackRaw() throws Exception {

PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User after change execution", userJack);
assertUserJack(userJack, "Marvelous Captain Jack Sparrow", "Jack", "Sparrow", null);
assertUserJack(userJack, "Marvelous Captain Jack Sparrow", "Jack", "Sparrow", "sea");
accountJackOid = getSingleLinkOid(userJack);

// Check shadow
Expand Down
Expand Up @@ -344,17 +344,46 @@ public void assertTarget(String expectedOid) {
assertTarget(expectedOid, AuditEventStage.REQUEST);
assertTarget(expectedOid, AuditEventStage.EXECUTION);
}

public <O extends ObjectType,T> void assertPropertyReplace(ChangeType expectedChangeType, Class<O> expectedClass, QName attrName, T... expectedValues) {
assertPropertyReplace(null, 0, expectedChangeType, expectedClass, new ItemPath(attrName), expectedValues);
}

public <O extends ObjectType,T> void assertPropertyReplace(ChangeType expectedChangeType, Class<O> expectedClass, ItemPath propPath, T... expectedValues) {
assertPropertyReplace(null, 0, expectedChangeType, expectedClass, propPath, expectedValues);
}

public <O extends ObjectType,T> void assertOldValue(ChangeType expectedChangeType, Class<O> expectedClass, QName attrName, T expectedValue) {
assertOldValue(null, 0, expectedChangeType, expectedClass, new ItemPath(attrName), expectedValue);
public <O extends ObjectType,T> void assertPropertyReplace(int index, ChangeType expectedChangeType, Class<O> expectedClass, ItemPath propPath, T... expectedValues) {
assertPropertyReplace(null, index, expectedChangeType, expectedClass, propPath, 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);
}

public <O extends ObjectType,T> void assertOldValue(ChangeType expectedChangeType, Class<O> expectedClass, QName attrName, T... expectedValues) {
assertOldValue(null, 0, expectedChangeType, expectedClass, new ItemPath(attrName), expectedValues);
}

public <O extends ObjectType,T> void assertOldValue(ChangeType expectedChangeType, Class<O> expectedClass, ItemPath propPath, T expectedValue) {
assertOldValue(null, 0, expectedChangeType, expectedClass, propPath, expectedValue);
public <O extends ObjectType,T> void assertOldValue(ChangeType expectedChangeType, Class<O> expectedClass, ItemPath propPath, T... expectedValues) {
assertOldValue(null, 0, expectedChangeType, expectedClass, propPath, expectedValues);
}

public <O extends ObjectType,T> void assertOldValue(int index, ChangeType expectedChangeType, Class<O> expectedClass, ItemPath propPath, T expectedValue) {
assertOldValue(null, index, expectedChangeType, expectedClass, propPath, expectedValue);
public <O extends ObjectType,T> void assertOldValue(int index, ChangeType expectedChangeType, Class<O> expectedClass, ItemPath propPath, T... expectedValues) {
assertOldValue(null, index, expectedChangeType, expectedClass, propPath, expectedValues);
}

public <O extends ObjectType,T> void assertOldValue(String message, int index, ChangeType expectedChangeType, Class<O> expectedClass, ItemPath propPath, T... expectedValues) {
Expand All @@ -363,6 +392,13 @@ public <O extends ObjectType,T> void assertOldValue(String message, int index, C
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);
}
Expand Down

0 comments on commit 2d7f36b

Please sign in to comment.