### Question:
WsImportPortlet extends Sw360Portlet { void setNewImportSource(TokenCredentials newCredentials, PortletSession session, JSONObject responseData) { String serverUrl = nullToEmpty(newCredentials.getServerUrl()); if (serverUrl.isEmpty()) { responseData.put(ProjectImportConstants.RESPONSE__STATUS, ProjectImportConstants.RESPONSE__DB_URL_NOT_SET); } else { putTokenCredentialsIntoSession(session, newCredentials); responseData.put(ProjectImportConstants.RESPONSE__STATUS, ProjectImportConstants.RESPONSE__DB_CHANGED); responseData.put(ProjectImportConstants.RESPONSE__DB_URL, serverUrl); } }  @Override void doView(RenderRequest request, RenderResponse response); @Override void serveResource(ResourceRequest request, ResourceResponse response); JSONObject handleRequestedAjaxAction(String requestedAction, ResourceRequest request);  }### Answer:
@Test public void testUpdateInputSourceWithoutUrl() throws Exception { TokenCredentials tokenCredentials = new TokenCredentials(); new WsImportPortlet().setNewImportSource( tokenCredentials, session, responseData); verify(responseData).put(ProjectImportConstants.RESPONSE__STATUS, ProjectImportConstants.RESPONSE__DB_URL_NOT_SET); }
@Test public void testUpdateInputSourceWithUrlUpdatesResponse() throws Exception { TokenCredentials tokenCredentials = new TokenCredentials(); tokenCredentials.setToken(token); tokenCredentials.setUserKey(userKey); tokenCredentials.setServerUrl(newURL); new WsImportPortlet().setNewImportSource( tokenCredentials, session, responseData); verify(responseData).put(ProjectImportConstants.RESPONSE__STATUS, ProjectImportConstants.RESPONSE__DB_CHANGED); verify(responseData).put(ProjectImportConstants.RESPONSE__DB_URL, newURL); }
@Test public void testUpdateInputSourceWithUrlUpdatesSession() throws Exception { TokenCredentials tokenCredentials = new TokenCredentials(); tokenCredentials.setToken(token); tokenCredentials.setUserKey(userKey); tokenCredentials.setServerUrl(newURL); new WsImportPortlet().setNewImportSource( tokenCredentials, session, responseData); verify(session).setAttribute(ProjectImportConstants.TOKEN, token); verify(session).setAttribute(ProjectImportConstants.USER_KEY, userKey); verify(session).setAttribute(ProjectImportConstants.SERVER_URL, newURL); }