001    /**
002     * Copyright 2004-2013 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;
017    
018    import java.math.BigDecimal;
019    import java.util.Calendar;
020    import java.util.Collection;
021    import java.util.HashMap;
022    import java.util.Map;
023    
024    import org.junit.Assert;
025    import org.junit.Test;
026    import org.kuali.hr.test.KPMETestCase;
027    import org.kuali.hr.time.test.HtmlUnitUtil;
028    import org.kuali.hr.time.test.TkTestConstants;
029    import org.kuali.rice.krad.service.KRADServiceLocator;
030    
031    import com.gargoylesoftware.htmlunit.html.HtmlPage;
032    
033    public class AssignmentAccountMaintTest extends KPMETestCase{
034            private static final String TEST_CODE="CD";
035            private static final String TEST_ID="1";
036            private static final String TEST_ASSIGN_ID="23";
037            private static String assignmentAccountId;
038            private BigDecimal TEST_PERCENT =  new BigDecimal(1);
039    
040            @Test
041            public void testAssignmentAccountMaint() throws Exception {
042                    HtmlPage assignmentAccountLookup = HtmlUnitUtil.gotoPageAndLogin(TkTestConstants.Urls.ASSIGNMENT_ACCOUNT_MAINT_URL);
043                    assignmentAccountLookup = HtmlUnitUtil.clickInputContainingText(assignmentAccountLookup, "search");
044                    Assert.assertTrue("Page contains test assignmentAccount", assignmentAccountLookup.asText().contains(TEST_ASSIGN_ID.toString()));
045                    HtmlPage maintPage = HtmlUnitUtil.clickAnchorContainingText(assignmentAccountLookup, "edit",assignmentAccountId.toString());
046                    Assert.assertTrue("Maintenance Page contains test assignmentAccount",maintPage.asText().contains(TEST_ASSIGN_ID.toString()));    
047            }
048    
049            @Override
050            public void setUp() throws Exception {
051                    super.setUp();
052                    AssignmentAccount assignmentAccount = new AssignmentAccount();
053                    assignmentAccount.setAccountNbr(TEST_ID);
054                    assignmentAccount.setActive(true);
055                    assignmentAccount.setTkAssignmentId(TEST_ASSIGN_ID);
056                    assignmentAccount.setFinCoaCd(TEST_CODE);
057                    assignmentAccount.setFinObjectCd(TEST_CODE);
058                    assignmentAccount.setFinSubObjCd(TEST_CODE);
059                    assignmentAccount.setPercent(TEST_PERCENT);
060                    KRADServiceLocator.getBusinessObjectService().save(assignmentAccount);
061                    assignmentAccountId = assignmentAccount.getTkAssignAcctId();
062            }
063    
064            @Override
065            public void tearDown() throws Exception {                               
066                    AssignmentAccount assignmentAccountObj = KRADServiceLocator.getBusinessObjectService().findBySinglePrimaryKey(AssignmentAccount.class, assignmentAccountId);             
067                    KRADServiceLocator.getBusinessObjectService().delete(assignmentAccountObj);
068                    super.tearDown();
069            }
070    
071    }
072    
073