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