use of com.fsck.k9.Preferences in project k-9 by k9mail.
the class AccountCreatorTest method setUp.
@Before
public void setUp() {
Preferences preferences = mock(Preferences.class);
Resources resources = mock(Resources.class);
accountCreator = new AccountCreator(preferences, resources);
}
use of com.fsck.k9.Preferences in project uPortal by Jasig.
the class PreferencesService method parsePreferences.
public Preferences parsePreferences(String preferencesToken) {
final Jws<Claims> claims = parseEncryptedToken(preferencesToken, Preferences.class);
final String username = claims.getBody().getSubject();
final Map<String, List<String>> preferencesMap = new HashMap<>();
for (Map.Entry<String, Object> y : claims.getBody().entrySet()) {
final String key = y.getKey();
if (JwtClaims.forName(key) != null) {
// Skip these; we handle these differently
continue;
}
if (y.getValue() instanceof List) {
@SuppressWarnings("unchecked") final List<String> values = (List<String>) y.getValue();
preferencesMap.put(key, values);
} else {
logger.warn("Unexpected claim '{}' was not a List; skipping", key);
}
}
Preferences rslt = new Preferences(preferencesToken, preferencesMap);
logger.debug("Produced the following Preferences for user '{}': {}", username, rslt);
return rslt;
}
use of com.fsck.k9.Preferences in project uPortal by Jasig.
the class ModelAttributeServiceTest method testPrepareMethodParameters.
@Test
public void testPrepareMethodParameters() {
final ModelAttributeService modelAttributeService = new ModelAttributeService();
final Class[] parameterClasses = new Class[] { HttpServletRequest.class, PortalRequest.class, Bearer.class };
final Method method;
try {
method = getClass().getMethod("soffitModelAttributeMethod", parameterClasses);
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
}
// Object Model
final HttpServletRequest req = Mockito.mock(HttpServletRequest.class);
final HttpServletResponse res = Mockito.mock(HttpServletResponse.class);
final PortalRequest portalRequest = Mockito.mock(PortalRequest.class);
final Bearer bearer = Mockito.mock(Bearer.class);
final Preferences preferences = Mockito.mock(Preferences.class);
final Definition definition = Mockito.mock(Definition.class);
final Object[] parameters = modelAttributeService.prepareMethodParameters(method, req, res, portalRequest, bearer, preferences, definition);
assertEquals("parameterClasses and parameters arrays must be the same length", parameterClasses.length, parameters.length);
for (int i = 0; i < parameters.length; i++) {
assertTrue("Mismatched parameter type", parameterClasses[i].isInstance(parameters[i]));
}
}
Aggregations