RESTWorkItemHandler extends AbstractLogOrThrowWorkItemHandler implements Cacheable { protected String getContentTypeAndCharset(Map<String, Object> params) { String contentType = (String) params.get(PARAM_CONTENT_TYPE); String contentTypeCharset = (String) params.get(PARAM_CONTENT_TYPE_CHARSET); if(contentType == null || contentTypeCharset == null) { return contentType; } if(!contentType.contains("charset=")) { return contentType + ";charset=" + contentTypeCharset; } else { return contentType; } } RESTWorkItemHandler();  RESTWorkItemHandler(boolean doCacheClient);  RESTWorkItemHandler(boolean doCacheClient,
                               int totalPoolConnections,
                               int maxPoolConnectionsPerRoute);  RESTWorkItemHandler(String username,
                               String password);  RESTWorkItemHandler(String username,
                               String password,
                               boolean doCacheClient);  RESTWorkItemHandler(String username,
                               String password,
                               boolean doCacheClient,
                               int totalPoolConnections,
                               int maxPoolConnectionsPerRoute);  RESTWorkItemHandler(String username,
                               String password,
                               String authUrl);  RESTWorkItemHandler(String username,
                               String password,
                               String authUrl,
                               boolean doCacheClient);  RESTWorkItemHandler(String username,
                               String password,
                               String authUrl,
                               boolean doCacheClient,
                               int totalPoolConnections,
                               int maxPoolConnectionsPerRoute);  RESTWorkItemHandler(ClassLoader classLoader);  RESTWorkItemHandler(ClassLoader classLoader,
                               boolean doCacheClient);  RESTWorkItemHandler(ClassLoader classLoader,
                               boolean doCacheClient,
                               int totalPoolConnections,
                               int maxPoolConnectionsPerRoute);  RESTWorkItemHandler(String username,
                               String password,
                               ClassLoader classLoader);  RESTWorkItemHandler(String username,
                               String password,
                               ClassLoader classLoader,
                               boolean doCacheClient);  RESTWorkItemHandler(String username,
                               String password,
                               ClassLoader classLoader,
                               boolean doCacheClient,
                               int totalPoolConnections,
                               int maxPoolConnectionsPerRoute);  RESTWorkItemHandler(String username,
                               String password,
                               String authUrl,
                               ClassLoader classLoader);  RESTWorkItemHandler(String username,
                               String password,
                               String authUrl,
                               ClassLoader classLoader,
                               boolean doCacheClient);  RESTWorkItemHandler(String username,
                               String password,
                               String authUrl,
                               ClassLoader classLoader,
                               boolean doCacheClient,
                               int totalPoolConnections,
                               int maxPoolConnectionsPerRoute);  RESTWorkItemHandler(String handlingProcessId,
                               String handlingStrategy,
                               String username,
                               String password);  RESTWorkItemHandler(String handlingProcessId,
                               String handlingStrategy,
                               String username,
                               String password,
                               boolean doCacheClient);  RESTWorkItemHandler(String handlingProcessId,
                               String handlingStrategy,
                               String username,
                               String password,
                               boolean doCacheClient,
                               int totalPoolConnections,
                               int maxPoolConnectionsPerRoute);  RESTWorkItemHandler(ClassLoader classLoader, 
                               String handlingProcessId,
                               String handlingStrategy);  RESTWorkItemHandler(ClassLoader classLoader,
                               boolean doCacheClient, 
                               String handlingProcessId,
                               String handlingStrategy);  RESTWorkItemHandler(ClassLoader classLoader,
                               boolean doCacheClient,
                               int totalPoolConnections,
                               int maxPoolConnectionsPerRoute,
                               String handlingProcessId,
                               String handlingStrategy);  RESTWorkItemHandler(String username,
                               String password,
                               ClassLoader classLoader,
                               String handlingProcessId,
                               String handlingStrategy);  RESTWorkItemHandler(String username,
                               String password,
                               ClassLoader classLoader,
                               boolean doCacheClient,
                               String handlingProcessId,
                               String handlingStrategy);  RESTWorkItemHandler(String username,
                               String password,
                               ClassLoader classLoader,
                               boolean doCacheClient,
                               int totalPoolConnections,
                               int maxPoolConnectionsPerRoute,
                               String handlingProcessId,
                               String handlingStrategy); String getAuthUrl(); boolean getDoCacheClient(); void executeWorkItem(WorkItem workItem,
                                WorkItemManager manager); void abortWorkItem(WorkItem workItem,
                              WorkItemManager manager); @Override void close(); static final String PARAM_AUTH_TYPE; static final String PARAM_CONNECT_TIMEOUT; static final String PARAM_READ_TIMEOUT; static final String PARAM_CONTENT_TYPE; static final String PARAM_CONTENT_TYPE_CHARSET; static final String PARAM_HEADERS; static final String PARAM_CONTENT; static final String PARAM_CONTENT_DATA; static final String PARAM_USERNAME; static final String PARAM_PASSWORD; static final String PARAM_AUTHURL; static final String PARAM_RESULT; static final String PARAM_STATUS; static final String PARAM_STATUS_MSG; }
@Test public void testGetContentTypeAndCharset() { RESTWorkItemHandler handler = new RESTWorkItemHandler(); Map<String, Object> params = new java.util.HashMap<>(); params.put(PARAM_CONTENT_TYPE, "application/xml"); params.put(PARAM_CONTENT_TYPE_CHARSET, "UTF-8"); assertEquals("application/xml;charset=UTF-8", handler.getContentTypeAndCharset(params) ); params.put(PARAM_CONTENT_TYPE, "application/xml;charset=UTF-8"); params.put(PARAM_CONTENT_TYPE_CHARSET, "SOME_WROMG_CHARSET"); assertEquals("application/xml;charset=UTF-8", handler.getContentTypeAndCharset(params) ); params.remove(PARAM_CONTENT_TYPE_CHARSET); assertEquals("application/xml;charset=UTF-8", handler.getContentTypeAndCharset(params) ); params.remove(PARAM_CONTENT_TYPE); assertNull(handler.getContentTypeAndCharset(params)); }