/**
 * This file is part of mycollab-services-community.
 *
 * mycollab-services-community is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * mycollab-services-community is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with mycollab-services-community.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.esofthead.mycollab.common.service;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;

import com.esofthead.mycollab.core.arguments.NumberSearchField;
import com.esofthead.mycollab.core.arguments.SearchRequest;
import com.esofthead.mycollab.module.user.domain.SimpleUser;
import com.esofthead.mycollab.module.user.domain.criteria.UserSearchCriteria;
import com.esofthead.mycollab.module.user.service.UserService;
import com.esofthead.mycollab.test.DataSet;
import com.esofthead.mycollab.test.MyCollabClassRunner;
import com.esofthead.mycollab.test.service.ServiceTest;

@RunWith(MyCollabClassRunner.class)
public class UserServiceTest extends ServiceTest {
	@Autowired
	protected UserService userService;

	@SuppressWarnings("rawtypes")
	@DataSet
	@Test
	public void testGetListUser() {
		UserSearchCriteria criteria = new UserSearchCriteria();
		criteria.setSaccountid(new NumberSearchField(1));
		List lstUser = userService
				.findPagableListByCriteria(new SearchRequest<UserSearchCriteria>(
						criteria, 0, Integer.MAX_VALUE));
		Assert.assertEquals(2, lstUser.size());
	}

	@DataSet
	@Test
	public void updateUserEmail() {
		SimpleUser user = userService.findUserByUserNameInAccount(
				"hainguyen@esofthead.com", 1);
		Assert.assertNotNull(user);

		user.setEmail("hannguyen@esofthead.com");
		userService.updateUserAccount(user, 1);

		SimpleUser anotherUser = userService.findUserByUserNameInAccount(
				"hannguyen@esofthead.com", 1);
		Assert.assertNotNull(anotherUser);
	}

	@SuppressWarnings({ "unchecked", "unused" })
	@DataSet
	@Test
	public void testGetLoginByDate() throws ParseException {
		SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
		Date date = fmt.parse("2014-02-19");
		UserSearchCriteria searchCriteria = new UserSearchCriteria();
		searchCriteria.setSaccountid(null);
		List<SimpleUser> lstSimpleUsers = userService
				.findPagableListByCriteria(new SearchRequest<UserSearchCriteria>(
						searchCriteria, 0, Integer.MAX_VALUE));
		Assert.assertEquals(2, lstSimpleUsers.size());
		Assert.assertEquals(2, userService.getTotalCount(searchCriteria));
	}

}

@@ -2460,16 +2460,19 @@
 );%0A%09%7D%0A%0A%09
+// 
 @Suppres
@@ -2509,16 +2509,19 @@
 ed%22 %7D)%0A%09
+// 
 @DataSet
@@ -2514,39 +2514,45 @@
 )%0A%09// @DataSet%0A%09
+// 
 @Test%0A%09
+// 
 public void test
@@ -2589,24 +2589,27 @@
 xception %7B%0A%09
+// 
 %09SimpleDateF
@@ -2657,16 +2657,19 @@
 -dd%22);%0A%09
+// 
 %09Date da
@@ -2699,16 +2699,19 @@
 -19%22);%0A%09
+// 
 %09UserSea
@@ -2766,16 +2766,19 @@
 ria();%0A%09
+// 
 %09searchC
@@ -2803,24 +2803,27 @@
 tid(null);%0A%09
+// 
 %09List%3CSimple
@@ -2850,32 +2850,35 @@
  = userService%0A%09
+// 
 %09%09%09.findPagableL
@@ -2927,24 +2927,27 @@
 Criteria%3E(%0A%09
+// 
 %09%09%09%09%09searchC
@@ -2972,32 +2972,35 @@
 r.MAX_VALUE));%0A%09
+// 
 %09Assert.assertEq
@@ -3028,24 +3028,27 @@
 s.size());%0A%09
+// 
 %09Assert.asse
@@ -3104,13 +3104,16 @@
 ria));%0A%09
+// 
 %7D%0A%0A%7D%0A

Fix unit tests