We are integrating into Auth0 API's and as a part this whole mess, we have a function that converts UserInfo (from Auth0 lib) to our own case class.
The signature of this function is:
private[services] def convertUserInfoToAuth0UserInfo(userInfo: UserInfo): Auth0UserInfo
I am trying to create a unit test for this function, and for the setup I need to create UserInfo object and populate it with data.
val profileMap = Map(
"email" -> "name@email.com",
"username" -> "username",
"organizationName" -> "organizationName",
"avatarUrl" -> "avatarUrl",
"domains" -> List("domain.com"),
"access_token" -> "access_token"
)
val userInfo = new UserInfo()
userInfo.setValue("key", profileMap.asJava)
val auth0UserInfo = service.convertUserInfoToAuth0UserInfo(userInfo)
auth0UserInfo.accessToken must beSome("access_token")
The issue is setValue
function is not accessible for whatever reason, even though the UserInfo class itself looks like this:
package com.auth0.json.auth;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.HashMap;
import java.util.Map;
/**
* Class that holds the Information related to a User's Access Token. Obtained after a call to {@link com.auth0.client.auth.AuthAPI#userInfo(String)},
* {@link com.auth0.client.auth.AuthAPI#signUp(String, String, String)} or {@link com.auth0.client.auth.AuthAPI#signUp(String, String, String, String)}.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class UserInfo {
private Map<String, Object> values;
UserInfo() {
values = new HashMap<>();
}
@JsonAnySetter
void setValue(String key, Object value) {
values.put(key, value);
}
/**
* Getter for the values contained in this object
*
* @return the values contained in the object.
*/
@JsonAnyGetter
public Map<String, Object> getValues() {
return values;
}
}
Unless I am missing something, setValues
is public.
Why can't I use it?