test_class.declarator: resolver
test_class.modifier: private
test_class.original_string: private CompositeCredentialResolver resolver;
test_class.type: CompositeCredentialResolver
test_class.var_name: resolver
test_class.file: ki4so-web/src/test/java/com/github/ebnew/ki4so/web/action/CompositeCredentialResolverTest.java
test_class.identifier: CompositeCredentialResolverTest
test_case.body: @Test
  	public void testResolveCredential() {
  		
  		
  		//测试参数request是空的情况。
  		Assert.assertNull(resolver.resolveCredential(null));
  		
  		
  		MockHttpServletRequest request = new MockHttpServletRequest();
  		
  		//测试request不是空，内部两个解析器都是空的情况。
  		Assert.assertNull(resolver.resolveCredential(request));
  		
  		//模拟两个解析器对象。
  		CredentialResolver encryCredentialResolver = Mockito.mock(CredentialResolver.class);
  		CredentialResolver usernamePasswordCredentialResolver = Mockito.mock(CredentialResolver.class);
  		
  		//测试request不是空，加密解析器是空，原始密码解析器非空的情况。
  		resolver.setEncryCredentialResolver(encryCredentialResolver);
  		Assert.assertNull(resolver.resolveCredential(request));
  		
  		//测试request不是空，加密解析器不是空，原始密码解析器为空的情况。
  		resolver.setEncryCredentialResolver(null);
  		resolver.setUsernamePasswordCredentialResolver(usernamePasswordCredentialResolver);
  		Assert.assertNull(resolver.resolveCredential(request));
  		
  		//测试request不是空，加密解析器和原始密码解析器都不是空，但是解析器解析返回值是null的情况。
  		resolver.setEncryCredentialResolver(encryCredentialResolver);
  		resolver.setUsernamePasswordCredentialResolver(usernamePasswordCredentialResolver);
  		Assert.assertNull(resolver.resolveCredential(request));
  		
  		//测试request不是空，加密解析器和原始密码解析器都不是空，但是加密解析器解析返回值是不null的情况。
  		Credential credential = Mockito.mock(Credential.class);
  		Credential credential1 = Mockito.mock(Credential.class);
  		resolver.setEncryCredentialResolver(encryCredentialResolver);
  		resolver.setUsernamePasswordCredentialResolver(usernamePasswordCredentialResolver);
  		Mockito.when(encryCredentialResolver.resolveCredential(request)).thenReturn(credential);
  		Mockito.when(usernamePasswordCredentialResolver.resolveCredential(request)).thenReturn(credential1);
  		Credential result = resolver.resolveCredential(request);
  		Assert.assertNotNull(result);
  		Assert.assertEquals(result, credential);
  		
  		//测试request不是空，加密解析器和原始密码解析器都不是空，但是加密凭据解析器解析返回值是null,
  		//而原始凭据解析器返回不为null的情况。
  		credential = Mockito.mock(Credential.class);
  		credential1 = Mockito.mock(Credential.class);
  		resolver.setEncryCredentialResolver(encryCredentialResolver);
  		resolver.setUsernamePasswordCredentialResolver(usernamePasswordCredentialResolver);
  		Mockito.when(encryCredentialResolver.resolveCredential(request)).thenReturn(null);
  		Mockito.when(usernamePasswordCredentialResolver.resolveCredential(request)).thenReturn(credential1);
  		result = resolver.resolveCredential(request);
  		Assert.assertNotNull(result);
  		Assert.assertEquals(result, credential1);
  		
  	}
test_case.class_method_signature: CompositeCredentialResolverTest.testResolveCredential()
test_case.full_signature: @Test public void testResolveCredential()
test_case.identifier: testResolveCredential
test_case.invocations: assertNull resolveCredential assertNull resolveCredential mock mock setEncryCredentialResolver assertNull resolveCredential setEncryCredentialResolver setUsernamePasswordCredentialResolver assertNull resolveCredential setEncryCredentialResolver setUsernamePasswordCredentialResolver assertNull resolveCredential mock mock setEncryCredentialResolver setUsernamePasswordCredentialResolver thenReturn when resolveCredential thenReturn when resolveCredential resolveCredential assertNotNull assertEquals mock mock setEncryCredentialResolver setUsernamePasswordCredentialResolver thenReturn when resolveCredential thenReturn when resolveCredential resolveCredential assertNotNull assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testResolveCredential()
focal_class.declarator: encryCredentialResolver
focal_class.modifier: private
focal_class.original_string: private CredentialResolver encryCredentialResolver;
focal_class.type: CredentialResolver
focal_class.var_name: encryCredentialResolver
focal_class.declarator: usernamePasswordCredentialResolver
focal_class.modifier: private
focal_class.original_string: private CredentialResolver usernamePasswordCredentialResolver;
focal_class.type: CredentialResolver
focal_class.var_name: usernamePasswordCredentialResolver
focal_class.file: ki4so-web/src/main/java/com/github/ebnew/ki4so/web/action/CompositeCredentialResolver.java
focal_class.identifier: CompositeCredentialResolver
focal_class.interfaces: implements CredentialResolver
focal_class.class_method_signature: CompositeCredentialResolver.CompositeCredentialResolver()
focal_class.full_signature: public  CompositeCredentialResolver()
focal_class.identifier: CompositeCredentialResolver
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  CompositeCredentialResolver()
focal_class.class_method_signature: CompositeCredentialResolver.resolveCredential(HttpServletRequest request)
focal_class.full_signature: public Credential resolveCredential(HttpServletRequest request)
focal_class.identifier: resolveCredential
focal_class.modifiers: public
focal_class.parameters: (HttpServletRequest request)
focal_class.return: Credential
focal_class.signature: Credential resolveCredential(HttpServletRequest request)
focal_class.class_method_signature: CompositeCredentialResolver.setEncryCredentialResolver(
  			CredentialResolver encryCredentialResolver)
focal_class.full_signature: public void setEncryCredentialResolver(
  			CredentialResolver encryCredentialResolver)
focal_class.identifier: setEncryCredentialResolver
focal_class.modifiers: public
focal_class.parameters: (
  			CredentialResolver encryCredentialResolver)
focal_class.return: void
focal_class.signature: void setEncryCredentialResolver(
  			CredentialResolver encryCredentialResolver)
focal_class.class_method_signature: CompositeCredentialResolver.setUsernamePasswordCredentialResolver(
  			CredentialResolver usernamePasswordCredentialResolver)
focal_class.full_signature: public void setUsernamePasswordCredentialResolver(
  			CredentialResolver usernamePasswordCredentialResolver)
focal_class.identifier: setUsernamePasswordCredentialResolver
focal_class.modifiers: public
focal_class.parameters: (
  			CredentialResolver usernamePasswordCredentialResolver)
focal_class.return: void
focal_class.signature: void setUsernamePasswordCredentialResolver(
  			CredentialResolver usernamePasswordCredentialResolver)
focal_method.body: public Credential resolveCredential(HttpServletRequest request){
  		if(request==null){
  			return null;
  		}
  		
  		Credential credential = null;
  		if(encryCredentialResolver!=null){
  			//先解析加密后的凭据。
  			credential = encryCredentialResolver.resolveCredential(request);
  		}
  		//若返回空，则用原始凭据解析器解析。
  		if(credential==null){
  			if(usernamePasswordCredentialResolver!=null){
  				credential = usernamePasswordCredentialResolver.resolveCredential(request);
  			}
  		}
  		
  		//如果是抽象的参数凭据对象，则解析其它的参数。
  		if(credential instanceof AbstractParameter){
  			AbstractParameter abstractParameter = (AbstractParameter)credential;
  			//将所有的参数设置到参数列表中，方便以后处理使用。
  			abstractParameter.setParameters(WebUtils.getParametersStartingWith(request, null));
  			//如果参数列表中无service,则从session中获取。
  			if(abstractParameter.getParameterValue(WebConstants.SERVICE_PARAM_NAME)==null){
  				if(request.getSession().getAttribute(WebConstants.KI4SO_SERVICE_KEY_IN_SESSION)!=null){
  					abstractParameter.getParameters().put(WebConstants.SERVICE_PARAM_NAME, request.getSession().getAttribute(WebConstants.KI4SO_SERVICE_KEY_IN_SESSION));
  				}
  			}
  		}
  		return credential;
  	}
focal_method.class_method_signature: CompositeCredentialResolver.resolveCredential(HttpServletRequest request)
focal_method.full_signature: public Credential resolveCredential(HttpServletRequest request)
focal_method.identifier: resolveCredential
focal_method.invocations: resolveCredential resolveCredential setParameters getParametersStartingWith getParameterValue getAttribute getSession put getParameters getAttribute getSession
focal_method.modifiers: public
focal_method.parameters: (HttpServletRequest request)
focal_method.return: Credential
focal_method.signature: Credential resolveCredential(HttpServletRequest request)