Coverage Report - edu.sampleu.travel.krad.controller.UITestController
 
Classes in this File Line Coverage Branch Coverage Complexity
UITestController
0%
0/64
0%
0/2
1.5
 
 1  
 /**
 2  
  * Copyright 2005-2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package edu.sampleu.travel.krad.controller;
 17  
 
 18  
 import java.util.ArrayList;
 19  
 import java.util.List;
 20  
 
 21  
 import javax.servlet.http.HttpServletRequest;
 22  
 import javax.servlet.http.HttpServletResponse;
 23  
 
 24  
 import org.kuali.rice.core.api.util.type.KualiPercent;
 25  
 import org.kuali.rice.krad.util.GlobalVariables;
 26  
 import org.kuali.rice.krad.web.controller.UifControllerBase;
 27  
 import org.kuali.rice.krad.web.form.UifFormBase;
 28  
 import org.springframework.stereotype.Controller;
 29  
 import org.springframework.validation.BindingResult;
 30  
 import org.springframework.web.bind.annotation.ModelAttribute;
 31  
 import org.springframework.web.bind.annotation.RequestMapping;
 32  
 import org.springframework.web.bind.annotation.RequestMethod;
 33  
 import org.springframework.web.servlet.ModelAndView;
 34  
 
 35  
 import edu.sampleu.travel.bo.FiscalOfficer;
 36  
 import edu.sampleu.travel.bo.TravelAccount;
 37  
 import edu.sampleu.travel.krad.form.UITestForm;
 38  
 
 39  
 /**
 40  
  * Controller for the Test UI Page
 41  
  * 
 42  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 43  
  */
 44  0
 @Controller
 45  
 @RequestMapping(value = "/uitest")
 46  0
 public class UITestController extends UifControllerBase {
 47  
 
 48  
     /**
 49  
      * @see org.kuali.rice.krad.web.controller.UifControllerBase#createInitialForm(javax.servlet.http.HttpServletRequest)
 50  
      */
 51  
     @Override
 52  
     protected UITestForm createInitialForm(HttpServletRequest request) {
 53  0
         return new UITestForm();
 54  
     }
 55  
 
 56  
         @Override
 57  
         @RequestMapping(params = "methodToCall=start")
 58  
         public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
 59  
                         HttpServletRequest request, HttpServletResponse response) {
 60  0
             UITestForm uiTestForm = (UITestForm) form;
 61  
                 
 62  
                 // populate model for testing
 63  0
                 TravelAccount travelAccount = new TravelAccount();
 64  0
                 travelAccount.setNumber("101");
 65  0
                 travelAccount.setName("Account 101");
 66  
 
 67  0
                 FiscalOfficer fiscalOfficer = new FiscalOfficer();
 68  0
                 fiscalOfficer.setId(new Long(1));
 69  0
                 FiscalOfficer fiscalOfficer2 = new FiscalOfficer();
 70  0
         fiscalOfficer.setId(new Long(1));
 71  0
         FiscalOfficer fiscalOfficer3 = new FiscalOfficer();
 72  0
         fiscalOfficer.setId(new Long(1));
 73  0
         FiscalOfficer fiscalOfficer4 = new FiscalOfficer();
 74  0
         fiscalOfficer.setId(new Long(1));
 75  
         
 76  
 
 77  0
                 List<TravelAccount> officerAccounts = new ArrayList<TravelAccount>();
 78  
 
 79  0
                 TravelAccount travelAccount2 = new TravelAccount();
 80  0
                 travelAccount2.setNumber("102");
 81  0
                 travelAccount2.setName("Account 102");
 82  0
                 travelAccount2.setSubAccount("34");
 83  0
                 travelAccount2.setSubAccountName("G34 So");
 84  0
                 travelAccount2.setSubsidizedPercent(new KualiPercent(45.0));
 85  0
                 officerAccounts.add(travelAccount2);
 86  
 
 87  0
                 TravelAccount travelAccount3 = new TravelAccount();
 88  0
                 travelAccount3.setNumber("103");
 89  0
                 travelAccount3.setName("Account 103");
 90  0
                 officerAccounts.add(travelAccount3);
 91  
 
 92  0
                 TravelAccount travelAccount4 = new TravelAccount();
 93  0
                 travelAccount4.setNumber("104");
 94  0
                 travelAccount4.setName("Account 104");
 95  0
                 travelAccount4.setSubAccount("i84n");
 96  0
                 travelAccount4.setSubAccountName("Supplies");
 97  0
                 travelAccount4.setSubsidizedPercent(new KualiPercent(10));
 98  0
                 officerAccounts.add(travelAccount4);
 99  
 
 100  0
                 fiscalOfficer.setAccounts(officerAccounts);
 101  0
                 travelAccount.setFiscalOfficer(fiscalOfficer);
 102  
                 
 103  
                 // build sub-collections
 104  0
                 travelAccount2.setFiscalOfficer(fiscalOfficer2);
 105  0
                 travelAccount3.setFiscalOfficer(fiscalOfficer3);
 106  0
                 travelAccount4.setFiscalOfficer(fiscalOfficer4);
 107  
 
 108  0
                 uiTestForm.setTravelAccount1(travelAccount);
 109  0
                 uiTestForm.setTravelAccount2(travelAccount2);
 110  0
                 uiTestForm.setTravelAccount3(travelAccount3);
 111  0
                 uiTestForm.setTravelAccount4(travelAccount4);
 112  
                 
 113  0
                 uiTestForm.setField5("a14");
 114  
                 
 115  0
                 uiTestForm.setField1("Field1");
 116  0
                 uiTestForm.setField2("Field2");
 117  
 
 118  0
         uiTestForm.setHidden1("Hidden1");
 119  0
         uiTestForm.setHidden2("Hidden2");
 120  
 
 121  0
                 return super.start(uiTestForm, result, request, response);
 122  
         }
 123  
 
 124  
         @RequestMapping(method = RequestMethod.POST, params = "methodToCall=save")
 125  
         public ModelAndView save(@ModelAttribute("KualiForm") UITestForm uiTestForm, BindingResult result,
 126  
                         HttpServletRequest request, HttpServletResponse response) {
 127  
                 //For testing server side errors:
 128  0
                 if(uiTestForm.getField2().equals("server_error")){
 129  0
                         GlobalVariables.getMessageMap().putError("field2", "serverTestError");
 130  0
                         GlobalVariables.getMessageMap().putError("field2", "serverTestError2");
 131  0
                         GlobalVariables.getMessageMap().putWarning("field2", "serverTestWarning");
 132  0
                         GlobalVariables.getMessageMap().putInfo("field2", "serverTestInfo");
 133  0
                         GlobalVariables.getMessageMap().putInfo("field3", "serverTestInfo");
 134  0
                         GlobalVariables.getMessageMap().putError("field13", "serverTestError");
 135  0
                         GlobalVariables.getMessageMap().putWarning("field4", "serverTestWarning");
 136  0
                         GlobalVariables.getMessageMap().putWarning("TEST_WARNING", "serverTestError3");
 137  0
                         GlobalVariables.getMessageMap().putError("TEST_ERROR", "serverTestError3");
 138  0
                         GlobalVariables.getMessageMap().putError("vField5", "serverTestError");
 139  0
                         GlobalVariables.getMessageMap().putError("vField6", "serverTestError");
 140  
                         //GlobalVariables.getMessageMap().clearErrorMessages();
 141  0
                         return getUIFModelAndView(uiTestForm, uiTestForm.getPageId());
 142  
                 }
 143  
                 
 144  0
                 return getUIFModelAndView(uiTestForm, "page1");
 145  
         }
 146  
         
 147  
         @RequestMapping(method = RequestMethod.POST, params = "methodToCall=close")
 148  
         public ModelAndView close(@ModelAttribute("KualiForm") UITestForm uiTestForm, BindingResult result,
 149  
                         HttpServletRequest request, HttpServletResponse response) {
 150  
 
 151  0
                 return getUIFModelAndView(uiTestForm, "page1");
 152  
         }
 153  
 
 154  
 }