package test.com.leanwo.activiti.rest.base;

import static org.junit.Assert.*;

import java.util.List;

import org.junit.Test;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.web.client.RestTemplate;

import com.leanwo.activiti.dto.base.UserTaskDto;

import test.com.leanwo.common.RestResourceTest;

public class WorkflowResourceTest extends RestResourceTest{

	@Test
	public void listUserTask() {
		String url = getApiUrl("workflowResource/listUserTask");
		RestTemplate restTemplate = getRestTemplate();
		
		HttpHeaders headers = getHttpHeaders();
		String deploymentId = "533a7821-d639-11e7-9760-005056c00001";
		HttpEntity<String> requestEntity = new HttpEntity<String>(deploymentId, headers);

		ResponseEntity<List<UserTaskDto>> response = restTemplate.exchange(url, HttpMethod.POST, requestEntity, new ParameterizedTypeReference<List<UserTaskDto>>() {}, "JackTest");
		((SimpleClientHttpRequestFactory)restTemplate.getRequestFactory()).setReadTimeout(1000*30);
		((SimpleClientHttpRequestFactory)restTemplate.getRequestFactory()).setConnectTimeout(1000*30);
		List<UserTaskDto> list = response.getBody();
		assertTrue(list.size() > 0);
	}

}
