// Path: src/main/java/com/lesstif/jira/issue/IssueType.java
// @Data
// @EqualsAndHashCode(callSuper = false)
// public class IssueType extends JsonPrettyString {
// 	// Default issue type
// 	public static final String ISSUE_TYPE_BUG = "Bug";
// 	public static final String ISSUE_TYPE_TASK = "Task";
// 	public static final String ISSUE_TYPE_IMPROVEMENT = "Improvement";
// 	public static final String ISSUE_TYPE_SUBTASK = "SubTask";
// 	public static final String ISSUE_TYPE_NEW_FEATURE = "New Feature";
// 	
// 	private String self;
// 	private String id;
// 	private String description;
// 	private String iconUrl;
// 	private String name;
// 	private Boolean subtask;
// 	private Integer avatarId;
// }
// 
// Path: src/main/java/com/lesstif/jira/project/Project.java
// @Data
// @EqualsAndHashCode(callSuper=false)
// @JsonIgnoreProperties({"assigneeType", "roles"
// })
// public class Project extends JsonPrettyString{
// 	private String expand;
// 	private String self;
// 	
// 	private String id;
// 	private String key;
// 	
// 	private String description;
// 	private String name;
// 	private String url;
// 
// 	@JsonSerialize(using = LocalDateSerializer.class)
// 	@JsonDeserialize(using = LocalDateDeserializer.class)
// 	private LocalDateTime startDate;
// 	
// 	private Lead lead;
// 	
// 	private AvatarUrl avatarUrls; 
// 	private ProjectCategory projectCategory;
// 	
// 	private List<Component> components;
// 	private List<IssueType> issueTypes;
// 	private List<Version> versions;
// 	
// 	private String projectTypeKey;
// 
// 	private boolean archived;
// }


import java.io.IOException;
import java.util.List;
import java.util.Optional;
import com.lesstif.jira.issue.IssueType;
import org.apache.commons.configuration.ConfigurationException;
import org.hamcrest.Matchers;
import org.hamcrest.text.IsEmptyString;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.lesstif.jira.project.Project;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
package com.lesstif.jira.services;




public class ProjectTest {

	private Logger logger = LoggerFactory.getLogger(getClass());
	
	@Test
	public void listProject() throws IOException, ConfigurationException {
		ProjectService prjService = new ProjectService();
		
		List<Project> projects = prjService.getProjectList();
		
		int i = 0;
		for (Project prj : projects) {
			logger.info(i++ + "th " + prj.toPrettyJsonString() );

			assertThat(prj.getId(), notNullValue());
			assertThat(prj.getName(), notNullValue());
			//assertThat(prj.getDescription(), not(emptyOrNullString()));

			List<IssueType> issueTypes = prj.getIssueTypes();
			if (issueTypes != null) {
				assertThat(issueTypes.size(), greaterThan(1));
			}
		}
	}	
	
	@Test
	public void getProject() throws IOException, ConfigurationException {
		String projectKey = "TEST";

		ProjectService prjService = new ProjectService();
		
		Project prj = prjService.getProjectDetail(projectKey);

		assertThat(prj.getId(), notNullValue());
		assertThat(prj.getName(), notNullValue());
		//assertThat(prj.getDescription(), not(emptyOrNullString()));
// Path: src/main/java/com/lesstif/jira/issue/IssueType.java
// @Data
// @EqualsAndHashCode(callSuper = false)
// public class IssueType extends JsonPrettyString {
// 	// Default issue type
// 	public static final String ISSUE_TYPE_BUG = "Bug";
// 	public static final String ISSUE_TYPE_TASK = "Task";
// 	public static final String ISSUE_TYPE_IMPROVEMENT = "Improvement";
// 	public static final String ISSUE_TYPE_SUBTASK = "SubTask";
// 	public static final String ISSUE_TYPE_NEW_FEATURE = "New Feature";
// 	
// 	private String self;
// 	private String id;
// 	private String description;
// 	private String iconUrl;
// 	private String name;
// 	private Boolean subtask;
// 	private Integer avatarId;
// }
// 
// Path: src/main/java/com/lesstif/jira/project/Project.java
// @Data
// @EqualsAndHashCode(callSuper=false)
// @JsonIgnoreProperties({"assigneeType", "roles"
// })
// public class Project extends JsonPrettyString{
// 	private String expand;
// 	private String self;
// 	
// 	private String id;
// 	private String key;
// 	
// 	private String description;
// 	private String name;
// 	private String url;
// 
// 	@JsonSerialize(using = LocalDateSerializer.class)
// 	@JsonDeserialize(using = LocalDateDeserializer.class)
// 	private LocalDateTime startDate;
// 	
// 	private Lead lead;
// 	
// 	private AvatarUrl avatarUrls; 
// 	private ProjectCategory projectCategory;
// 	
// 	private List<Component> components;
// 	private List<IssueType> issueTypes;
// 	private List<Version> versions;
// 	
// 	private String projectTypeKey;
// 
// 	private boolean archived;
// }


// Path: src/test/java/com/lesstif/jira/services/ProjectTest.java
import java.io.IOException;
import java.util.List;
import java.util.Optional;
import com.lesstif.jira.issue.IssueType;
import org.apache.commons.configuration.ConfigurationException;
import org.hamcrest.Matchers;
import org.hamcrest.text.IsEmptyString;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.lesstif.jira.project.Project;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;

package com.lesstif.jira.services;




public class ProjectTest {

	private Logger logger = LoggerFactory.getLogger(getClass());
	
	@Test
	public void listProject() throws IOException, ConfigurationException {
		ProjectService prjService = new ProjectService();
		
		List<Project> projects = prjService.getProjectList();
		
		int i = 0;
		for (Project prj : projects) {
			logger.info(i++ + "th " + prj.toPrettyJsonString() );

			assertThat(prj.getId(), notNullValue());
			assertThat(prj.getName(), notNullValue());
			//assertThat(prj.getDescription(), not(emptyOrNullString()));

			List<IssueType> issueTypes = prj.getIssueTypes();
			if (issueTypes != null) {
				assertThat(issueTypes.size(), greaterThan(1));
			}
		}
	}	
	
	@Test
	public void getProject() throws IOException, ConfigurationException {
		String projectKey = "TEST";

		ProjectService prjService = new ProjectService();
		
		Project prj = prjService.getProjectDetail(projectKey);

		assertThat(prj.getId(), notNullValue());
		assertThat(prj.getName(), notNullValue());
		//assertThat(prj.getDescription(), not(emptyOrNullString()));
		assertThat(prj.getKey(), is(projectKey));