package com.housekeepingtool.test;

import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;

import com.awshousekeeping.dao.UserManagementDao;
import com.awshousekeeping.model.User;
import com.awshousekeeping.services.UserService;
import com.awshousekeeping.services.impl.UserServiceImpl;
import com.awshousekeeping.utils.BusinessException;

public class TestUserManagement {

	@Mock
	private UserManagementDao useDao;

	@InjectMocks
	private UserService userService = new UserServiceImpl();

	@Before
	public void init() {
		MockitoAnnotations.initMocks(this);
	}

	@Test
	public void testAddUser() throws BusinessException {

		when(useDao.addUser(Mockito.any(User.class))).thenReturn(true);
		Boolean result = userService.addUser(Mockito.any(User.class));
		assertEquals(result, true);

	}

	@Test
	public void testListAllUser() throws BusinessException {
		when(useDao.getAllUser()).thenReturn(getDummyListUser());

		List<User> ulist = userService.listAllUsers();
		assertEquals(ulist.size(), 1);
	}

	private User getDummyUser() {
		User u = new User();
		u.setCreatedBy("pavan");
		u.setUid(1);
		u.setCreateOn(new Date());
		u.setLastName("pawar");
		u.setPassword("abcd");
		u.setRole(1);
		u.setIsActive(1);
		u.setUpdatedBy("admin");
		return u;

	}

	private List<User> getDummyListUser() {
		List<User> ulist = new ArrayList<>();
		ulist.add(getDummyUser());
		return ulist;
	}
}

@@ -164,34 +164,138 @@
 til.
-Date;%0Aimport java.util.Lis
+Collections;%0Aimport java.util.Date;%0Aimport java.util.List;%0Aimport java.util.Scanner;%0Aimport java.util.Set;%0Aimport java.util.TreeSe
 t;%0A%0A
@@ -1764,11 +1764,596 @@
 list;%0A%09%7D
+%0A%0A%09void a()%0A%09%7B%0A%09%09Scanner in = new Scanner(System.in);%0A        long a = in.nextLong();%0A        long b = in.nextLong();%0A        long c = in.nextLong();%0A        long d = in.nextLong();%0A        long e = in.nextLong();%0A        long  max;%0A        long  min;%0A        long sum=a+b+c+d+e;%0A        List%3CLong%3E input =new ArrayList%3C%3E();%0A        input.add(a);%0A        input.add(b);%0A        input.add(c);%0A        input.add(d);%0A        input.add(e);%0A       %0A        %0A        Collections.sort(input);%0A        System.out.println((sum-input.get(0))+%22 %22+(sum-input.get(4)));%0A        %0A        %0A        %0A%09%7D
 %0A%7D%0A

Test case