Skip to content

Commit

Permalink
Fix localizable object names in messages (MID-5916)
Browse files Browse the repository at this point in the history
Localizable object names that are part of localizable messages
(e.g. user and role names in 'Approving assignment of <role> to <user>')
are now translated correctly.

Also, simplified setting up tracing of test methods and moved
TestPolicyRules to automatic task/result management.
  • Loading branch information
mederly committed Dec 3, 2019
1 parent 19303f5 commit 5b9d6d6
Show file tree
Hide file tree
Showing 9 changed files with 301 additions and 111 deletions.
Expand Up @@ -20,6 +20,7 @@
import com.evolveum.prism.xml.ns._public.types_3.PolyStringTranslationArgumentType;
import com.evolveum.prism.xml.ns._public.types_3.PolyStringTranslationType;

import com.evolveum.prism.xml.ns._public.types_3.PolyStringType;
import org.apache.commons.lang.StringUtils;
import org.springframework.context.MessageSource;
import org.springframework.context.NoSuchMessageException;
Expand Down Expand Up @@ -188,6 +189,10 @@ private Object[] translateParams(Object[] params, Locale locale) {
} else if (param instanceof LocalizableMessage) {
LocalizableMessage msg = (LocalizableMessage) param;
param = translate(msg, locale);
} else if (param instanceof PolyString) {
param = translate((PolyString) param, locale, true);
} else if (param instanceof PolyStringType) {
param = translate(((PolyStringType) param).toPolyString(), locale, true);
} else if (param instanceof PolyStringTranslationType) {
param = translate((PolyStringTranslationType)param, locale);
} else if (param instanceof PolyStringTranslationArgumentType) {
Expand Down
Expand Up @@ -23,6 +23,7 @@
import com.evolveum.midpoint.prism.util.PrismAsserts;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.test.TestResource;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -129,6 +130,9 @@ public abstract class AbstractLensTest extends AbstractInternalModelIntegrationT
protected static final File ROLE_CORP_AUTH_FILE = new File(TEST_DIR, "role-corp-auth.xml");
protected static final String ROLE_CORP_AUTH_OID = "12345678-d34d-b33f-f00d-55555555aaaa";

protected static final TestResource USER_LOCALIZED = new TestResource(TEST_DIR, "user-localized.xml", "c46f4b09-2200-4977-88bc-da1f3ffd0b42");
protected static final TestResource ROLE_LOCALIZED = new TestResource(TEST_DIR, "role-localized.xml", "25294519-5e0e-44d4-bebc-ea549d850ed9");

protected static final File[] ROLE_CORP_FILES = {
ROLE_METAROLE_SOD_NOTIFICATION_FILE,
ROLE_CORP_AUTH_FILE,
Expand Down Expand Up @@ -190,7 +194,8 @@ protected List<EvaluatedPolicyRule> assertEvaluatedFocusPolicyRules(LensContext<
}

protected void assertTargetTriggers(LensContext<? extends FocusType> context, PolicyConstraintKindType selectedConstraintKind, int expectedCount) {
List<EvaluatedPolicyRuleTrigger> triggers = new ArrayList<>();
display("Asserting target triggers for selected constraint kind = " + selectedConstraintKind + ", expected count = " + expectedCount);
List<EvaluatedPolicyRuleTrigger<?>> triggers = new ArrayList<>();
forTriggeredTargetPolicyRule(context, null, trigger -> {
if (selectedConstraintKind != null && trigger.getConstraintKind() != selectedConstraintKind) {
return;
Expand Down

0 comments on commit 5b9d6d6

Please sign in to comment.