This is an automated email from the ASF dual-hosted git repository.
ilgrosso pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/syncope.git
The following commit(s) were added to refs/heads/master by this push:
new 8ca124a [SYNCOPE-1554] Adding missing @JsonAnySetter
8ca124a is described below
commit 8ca124a5ab6b3e289eeed926066a365f33257648
Author: Francesco Chicchiriccò <[email protected]>
AuthorDate: Thu Apr 23 11:19:44 2020 +0200
[SYNCOPE-1554] Adding missing @JsonAnySetter
---
.../syncope/client/console/layout/AnyLayout.java | 6 +++
.../client/console/layout/AnyLayoutTest.java | 50 ++++++++++++++++++++++
.../core/provisioning/java/MappingManagerImpl.java | 2 +-
3 files changed, 57 insertions(+), 1 deletion(-)
diff --git
a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/layout/AnyLayout.java
b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/layout/AnyLayout.java
index 1978f78..b15138c 100644
---
a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/layout/AnyLayout.java
+++
b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/layout/AnyLayout.java
@@ -19,6 +19,7 @@
package org.apache.syncope.client.console.layout;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import java.util.HashMap;
@@ -67,4 +68,9 @@ public class AnyLayout implements Serializable {
public Map<String, AnyObjectFormLayoutInfo> getAnyObjects() {
return anyObjects;
}
+
+ @JsonAnySetter
+ public void setAnyObjects(final String anyType, final
AnyObjectFormLayoutInfo layoutInfo) {
+ anyObjects.put(anyType, layoutInfo);
+ }
}
diff --git
a/client/idrepo/console/src/test/java/org/apache/syncope/client/console/layout/AnyLayoutTest.java
b/client/idrepo/console/src/test/java/org/apache/syncope/client/console/layout/AnyLayoutTest.java
new file mode 100644
index 0000000..f13fe52
--- /dev/null
+++
b/client/idrepo/console/src/test/java/org/apache/syncope/client/console/layout/AnyLayoutTest.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.layout;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.util.Arrays;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.syncope.common.lib.types.AnyTypeKind;
+import org.junit.jupiter.api.Test;
+
+public class AnyLayoutTest {
+
+ private static final ObjectMapper MAPPER = new ObjectMapper();
+
+ @Test
+ public void issueSYNCOPE1554() throws JsonProcessingException {
+ AnyLayout defaultObj = new AnyLayout();
+ defaultObj.setUser(new UserFormLayoutInfo());
+ defaultObj.setGroup(new GroupFormLayoutInfo());
+ defaultObj.getAnyObjects().put("PRINTER", new
AnyObjectFormLayoutInfo());
+ String defaultObjJSON =
MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(defaultObj);
+
+ String defaultIfEmpty = AnyLayoutUtils.defaultIfEmpty(
+ StringUtils.EMPTY, Arrays.asList(AnyTypeKind.USER.name(),
AnyTypeKind.GROUP.name(), "PRINTER"));
+ assertEquals(defaultObjJSON, defaultIfEmpty);
+
+ AnyLayout deserialized = MAPPER.readValue(defaultIfEmpty,
AnyLayout.class);
+ assertNotNull(deserialized);
+ }
+}
diff --git
a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/MappingManagerImpl.java
b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/MappingManagerImpl.java
index 7e70f84..8502dcf 100644
---
a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/MappingManagerImpl.java
+++
b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/MappingManagerImpl.java
@@ -488,7 +488,7 @@ public class MappingManagerImpl implements MappingManager {
protected String getPasswordAttrValue(final Provision provision, final
Account account, final String defaultValue) {
String passwordAttrValue;
if (account instanceof LinkedAccount) {
- if (((LinkedAccount) account).getPassword() != null) {
+ if (account.getPassword() != null) {
passwordAttrValue = decodePassword(account);
} else {
passwordAttrValue = defaultValue;