001    /**
002     * Copyright 2004-2012 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.hr.time.assignment.service;
017    
018    import java.sql.Date;
019    import java.util.List;
020    
021    import org.apache.log4j.Logger;
022    import org.joda.time.DateTime;
023    import org.joda.time.DateTimeZone;
024    import org.junit.Assert;
025    import org.junit.Before;
026    import org.junit.Test;
027    import org.kuali.hr.test.KPMETestCase;
028    import org.kuali.hr.time.assignment.Assignment;
029    import org.kuali.hr.time.assignment.dao.AssignmentDao;
030    import org.kuali.hr.time.service.base.TkServiceLocator;
031    import org.kuali.hr.time.util.TKUtils;
032    
033    public class AssignmentServiceImplTest extends KPMETestCase {
034    
035            private static final Logger LOG = Logger.getLogger(AssignmentServiceImplTest.class);
036            AssignmentDao assignmentDao = null;
037            AssignmentService assignmentService = null;
038    
039            @Before
040            public void setUp() throws Exception {
041                    super.setUp();
042                    assignmentDao = TkServiceLocator.getAssignmentDao();
043                    assignmentService=TkServiceLocator.getAssignmentService();
044            }
045    
046            @Test
047            public void testGetAssignments() throws Exception {
048                    List<Assignment> assignments = assignmentService.getAssignments("admin", new Date((new DateTime(2010,8,5,1,0,0,0, TKUtils.getSystemDateTimeZone())).getMillis()));
049                    Assert.assertNotNull("Null assignment list", assignments);
050                    Assert.assertTrue("No assignments found", assignments.size() > 0);
051    
052                    for(Assignment assign : assignments){
053                            Assert.assertNotNull("Null job found", assign.getJob());
054                            Assert.assertTrue("Job number is same", assign.getJob().getJobNumber().compareTo(assign.getJobNumber())==0);
055                    }
056    
057            }
058    
059    }