Coverage Report - edu.sampleu.travel.krad.controller.UITestController
 
Classes in this File Line Coverage Branch Coverage Complexity
UITestController
0%
0/56
0%
0/2
1.5
 
 1  
 /*
 2  
  * Copyright 2007 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 1.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/ecl1.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.util.type.KualiPercent;
 25  
 import org.kuali.rice.kns.util.GlobalVariables;
 26  
 import org.kuali.rice.kns.web.spring.controller.UifControllerBase;
 27  
 import org.kuali.rice.kns.web.spring.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  
         @Override
 49  
     protected UITestForm createInitialForm(HttpServletRequest request) {
 50  0
         return new UITestForm();
 51  
     }
 52  
 
 53  
         @Override
 54  
         @RequestMapping(params = "methodToCall=start")
 55  
         public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
 56  
                         HttpServletRequest request, HttpServletResponse response) {
 57  0
             UITestForm uiTestForm = (UITestForm) form;
 58  
                 
 59  
                 // populate model for testing
 60  0
                 TravelAccount travelAccount = new TravelAccount();
 61  0
                 travelAccount.setNumber("101");
 62  0
                 travelAccount.setName("Account 101");
 63  
 
 64  0
                 FiscalOfficer fiscalOfficer = new FiscalOfficer();
 65  0
                 fiscalOfficer.setId(new Long(1));
 66  
 
 67  0
                 List<TravelAccount> officerAccounts = new ArrayList<TravelAccount>();
 68  
 
 69  0
                 TravelAccount travelAccount2 = new TravelAccount();
 70  0
                 travelAccount2.setNumber("102");
 71  0
                 travelAccount2.setName("Account 102");
 72  0
                 travelAccount2.setSubAccount("34");
 73  0
                 travelAccount2.setSubAccountName("G34 So");
 74  0
                 travelAccount2.setSubsidizedPercent(new KualiPercent(45.0));
 75  0
                 officerAccounts.add(travelAccount2);
 76  
 
 77  0
                 TravelAccount travelAccount3 = new TravelAccount();
 78  0
                 travelAccount3.setNumber("103");
 79  0
                 travelAccount3.setName("Account 103");
 80  0
                 officerAccounts.add(travelAccount3);
 81  
 
 82  0
                 TravelAccount travelAccount4 = new TravelAccount();
 83  0
                 travelAccount4.setNumber("104");
 84  0
                 travelAccount4.setName("Account 104");
 85  0
                 travelAccount4.setSubAccount("i84n");
 86  0
                 travelAccount4.setSubAccountName("Supplies");
 87  0
                 travelAccount4.setSubsidizedPercent(new KualiPercent(10));
 88  0
                 officerAccounts.add(travelAccount4);
 89  
 
 90  0
                 fiscalOfficer.setAccounts(officerAccounts);
 91  0
                 travelAccount.setFiscalOfficer(fiscalOfficer);
 92  
                 
 93  
                 // build sub-collections
 94  0
                 travelAccount2.setFiscalOfficer(fiscalOfficer);
 95  0
                 travelAccount3.setFiscalOfficer(fiscalOfficer);
 96  0
                 travelAccount4.setFiscalOfficer(fiscalOfficer);
 97  
 
 98  0
                 uiTestForm.setTravelAccount1(travelAccount);
 99  0
                 uiTestForm.setTravelAccount2(travelAccount);
 100  0
                 uiTestForm.setTravelAccount3(travelAccount);
 101  0
                 uiTestForm.setTravelAccount4(travelAccount);
 102  
                 
 103  0
                 uiTestForm.setField5("a14");
 104  
                 
 105  0
                 uiTestForm.setField1("Field1");
 106  0
                 uiTestForm.setField2("Field2");
 107  
 
 108  0
                 return super.start(uiTestForm, result, request, response);
 109  
         }
 110  
 
 111  
         @RequestMapping(method = RequestMethod.POST, params = "methodToCall=save")
 112  
         public ModelAndView save(@ModelAttribute("KualiForm") UITestForm uiTestForm, BindingResult result,
 113  
                         HttpServletRequest request, HttpServletResponse response) {
 114  
                 //For testing server side errors:
 115  0
                 if(uiTestForm.getField2().equals("server_error")){
 116  0
                         GlobalVariables.getMessageMap().putError("field2", "serverTestError");
 117  0
                         GlobalVariables.getMessageMap().putError("field2", "serverTestError2");
 118  0
                         GlobalVariables.getMessageMap().putWarning("field2", "serverTestWarning");
 119  0
                         GlobalVariables.getMessageMap().putInfo("field2", "serverTestInfo");
 120  0
                         GlobalVariables.getMessageMap().putInfo("field3", "serverTestInfo");
 121  0
                         GlobalVariables.getMessageMap().putError("field13", "serverTestError");
 122  0
                         GlobalVariables.getMessageMap().putWarning("field4", "serverTestWarning");
 123  0
                         GlobalVariables.getMessageMap().putWarning("TEST_WARNING", "serverTestError3");
 124  0
                         GlobalVariables.getMessageMap().putError("TEST_ERROR", "serverTestError3");
 125  0
                         GlobalVariables.getMessageMap().putError("vField5", "serverTestError");
 126  0
                         GlobalVariables.getMessageMap().putError("vField6", "serverTestError");
 127  
                         //GlobalVariables.getMessageMap().clearErrorMessages();
 128  0
                         return getUIFModelAndView(uiTestForm, uiTestForm.getViewId(), uiTestForm.getPageId());
 129  
                 }
 130  
                 
 131  0
                 return getUIFModelAndView(uiTestForm, uiTestForm.getViewId(), "page2");
 132  
         }
 133  
         
 134  
         @RequestMapping(method = RequestMethod.POST, params = "methodToCall=close")
 135  
         public ModelAndView close(@ModelAttribute("KualiForm") UITestForm uiTestForm, BindingResult result,
 136  
                         HttpServletRequest request, HttpServletResponse response) {
 137  
 
 138  0
                 return getUIFModelAndView(uiTestForm, uiTestForm.getViewId(), "page1");
 139  
         }
 140  
 
 141  
 }