Skip to content

Commit 8d53897

Browse files
committed
- fix userfilter junit test
1 parent 9da660f commit 8d53897

3 files changed

Lines changed: 12 additions & 11 deletions

File tree

modules/apim-adapter/src/main/java/com/axway/apim/adapter/jackson/UserOrgName2IdConverter.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@ public User convert(User user) {
1717
// if(user.getRole().equals("oadmin")) {
1818
// orgName2Id.put(organization.getName(), organization.getId());
1919
// }
20-
for (Map.Entry<String,String> entry : orgs2Role.entrySet()){
21-
String orgId = entry.getKey();
22-
String role = entry.getValue();
23-
if(role.equals("oadmin") || role.equals("admin")){
24-
orgName2Id.put(orgs2Name.get(orgId), orgId);
20+
if(orgs2Role != null) {
21+
for (Map.Entry<String, String> entry : orgs2Role.entrySet()) {
22+
String orgId = entry.getKey();
23+
String role = entry.getValue();
24+
if (role.equals("oadmin") || role.equals("admin")) {
25+
orgName2Id.put(orgs2Name.get(orgId), orgId);
26+
}
2527
}
28+
user.setName2OrgId(orgName2Id);
2629
}
27-
user.setName2OrgId(orgName2Id);
2830
return user;
2931
}
3032
}

modules/apim-adapter/src/main/java/com/axway/apim/adapter/user/UserFilter.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
public class UserFilter implements CustomPropertiesFilter {
1717

18-
public static enum USER_TYPE {
18+
public enum USER_TYPE {
1919
internal,
2020
external
2121
}
@@ -36,7 +36,7 @@ public static enum USER_TYPE {
3636

3737
private List<String> customProperties;
3838

39-
private List<NameValuePair> filters = new ArrayList<NameValuePair>();
39+
private List<NameValuePair> filters = new ArrayList<>();
4040

4141
private UserFilter() { }
4242

@@ -170,7 +170,7 @@ public void setCustomProperties(List<String> customProperties) {
170170
public boolean equals(Object obj) {
171171
if (obj == null) return false;
172172
if (this == obj) return true;
173-
if(obj instanceof UserFilter == false) return false;
173+
if(!(obj instanceof UserFilter)) return false;
174174
UserFilter other = (UserFilter)obj;
175175
return (
176176
StringUtils.equals(other.getId(), this.getId()) &&
@@ -229,7 +229,6 @@ public static class Builder {
229229

230230
private List<String> customProperties;
231231

232-
List<NameValuePair> filters = new ArrayList<NameValuePair>();
233232

234233
public Builder() {
235234
super();

modules/apim-adapter/src/main/java/com/axway/apim/api/model/User.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
@JsonIgnoreProperties(ignoreUnknown = true)
1919
@JsonFilter("UserFilter")
20-
//@JsonDeserialize(converter = UserOrgName2IdConverter.class)
20+
@JsonDeserialize(converter = UserOrgName2IdConverter.class)
2121
public class User implements CustomPropertiesEntity {
2222
String id;
2323
@JsonDeserialize(using = OrganizationDeserializer.class)

0 commit comments

Comments
 (0)