Coverage Report - edu.sampleu.travel.krad.controller.UITestController
 
Classes in this File Line Coverage Branch Coverage Complexity
UITestController
0%
0/53
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.springframework.stereotype.Controller;
 28  
 import org.springframework.validation.BindingResult;
 29  
 import org.springframework.web.bind.annotation.ModelAttribute;
 30  
 import org.springframework.web.bind.annotation.RequestMapping;
 31  
 import org.springframework.web.bind.annotation.RequestMethod;
 32  
 import org.springframework.web.servlet.ModelAndView;
 33  
 
 34  
 import edu.sampleu.travel.bo.FiscalOfficer;
 35  
 import edu.sampleu.travel.bo.TravelAccount;
 36  
 import edu.sampleu.travel.krad.form.UITestForm;
 37  
 
 38  
 /**
 39  
  * Controller for the Test UI Page
 40  
  * 
 41  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 42  
  */
 43  0
 @Controller
 44  
 @RequestMapping(value = "/uitest")
 45  0
 public class UITestController extends UifControllerBase {
 46  
 
 47  
         @Override
 48  
     protected UITestForm createInitialForm(HttpServletRequest request) {
 49  0
         return new UITestForm();
 50  
     }
 51  
 
 52  
         @RequestMapping(params = "methodToCall=start")
 53  
         public ModelAndView start(@ModelAttribute("KualiForm") UITestForm uiTestForm, BindingResult result,
 54  
                         HttpServletRequest request, HttpServletResponse response) {
 55  
                 
 56  
                 // populate model for testing
 57  0
                 TravelAccount travelAccount = new TravelAccount();
 58  0
                 travelAccount.setNumber("101");
 59  0
                 travelAccount.setName("Account 101");
 60  
 
 61  0
                 FiscalOfficer fiscalOfficer = new FiscalOfficer();
 62  0
                 fiscalOfficer.setId(new Long(1));
 63  
 
 64  0
                 List<TravelAccount> officerAccounts = new ArrayList<TravelAccount>();
 65  
 
 66  0
                 TravelAccount travelAccount2 = new TravelAccount();
 67  0
                 travelAccount2.setNumber("102");
 68  0
                 travelAccount2.setName("Account 102");
 69  0
                 travelAccount2.setSubAccount("34");
 70  0
                 travelAccount2.setSubAccountName("G34 So");
 71  0
                 travelAccount2.setSubsidizedPercent(new KualiPercent(45.0));
 72  0
                 officerAccounts.add(travelAccount2);
 73  
 
 74  0
                 TravelAccount travelAccount3 = new TravelAccount();
 75  0
                 travelAccount3.setNumber("103");
 76  0
                 travelAccount3.setName("Account 103");
 77  0
                 officerAccounts.add(travelAccount3);
 78  
 
 79  0
                 TravelAccount travelAccount4 = new TravelAccount();
 80  0
                 travelAccount4.setNumber("104");
 81  0
                 travelAccount4.setName("Account 104");
 82  0
                 travelAccount4.setSubAccount("i84n");
 83  0
                 travelAccount4.setSubAccountName("Supplies");
 84  0
                 travelAccount4.setSubsidizedPercent(new KualiPercent(10));
 85  0
                 officerAccounts.add(travelAccount4);
 86  
 
 87  0
                 fiscalOfficer.setAccounts(officerAccounts);
 88  0
                 travelAccount.setFiscalOfficer(fiscalOfficer);
 89  
                 
 90  
                 // build sub-collections
 91  0
                 travelAccount2.setFiscalOfficer(fiscalOfficer);
 92  0
                 travelAccount3.setFiscalOfficer(fiscalOfficer);
 93  0
                 travelAccount4.setFiscalOfficer(fiscalOfficer);
 94  
 
 95  0
                 uiTestForm.setTravelAccount1(travelAccount);
 96  0
                 uiTestForm.setTravelAccount2(travelAccount);
 97  0
                 uiTestForm.setTravelAccount3(travelAccount);
 98  0
                 uiTestForm.setTravelAccount4(travelAccount);
 99  
                 
 100  0
                 uiTestForm.setField5("a14");
 101  
 
 102  0
                 return getUIFModelAndView(uiTestForm, uiTestForm.getViewId(), "page1");
 103  
         }
 104  
 
 105  
         @RequestMapping(method = RequestMethod.POST, params = "methodToCall=save")
 106  
         public ModelAndView save(@ModelAttribute("KualiForm") UITestForm uiTestForm, BindingResult result,
 107  
                         HttpServletRequest request, HttpServletResponse response) {
 108  
                 //For testing server side errors:
 109  0
                 if(uiTestForm.getField2().equals("server_error")){
 110  0
                         GlobalVariables.getMessageMap().putError("field2", "serverTestError");
 111  0
                         GlobalVariables.getMessageMap().putError("field2", "serverTestError2");
 112  0
                         GlobalVariables.getMessageMap().putWarning("field2", "serverTestWarning");
 113  0
                         GlobalVariables.getMessageMap().putInfo("field2", "serverTestInfo");
 114  0
                         GlobalVariables.getMessageMap().putInfo("field3", "serverTestInfo");
 115  0
                         GlobalVariables.getMessageMap().putError("field13", "serverTestError");
 116  0
                         GlobalVariables.getMessageMap().putWarning("field4", "serverTestWarning");
 117  0
                         GlobalVariables.getMessageMap().putWarning("TEST_WARNING", "serverTestError3");
 118  0
                         GlobalVariables.getMessageMap().putError("TEST_ERROR", "serverTestError3");
 119  0
                         GlobalVariables.getMessageMap().putError("vField5", "serverTestError");
 120  0
                         GlobalVariables.getMessageMap().putError("vField6", "serverTestError");
 121  
                         //GlobalVariables.getMessageMap().clearErrorMessages();
 122  0
                         return getUIFModelAndView(uiTestForm, uiTestForm.getViewId(), uiTestForm.getPageId());
 123  
                 }
 124  0
                 return getUIFModelAndView(uiTestForm, uiTestForm.getViewId(), "page2");
 125  
         }
 126  
         
 127  
         @RequestMapping(method = RequestMethod.POST, params = "methodToCall=close")
 128  
         public ModelAndView close(@ModelAttribute("KualiForm") UITestForm uiTestForm, BindingResult result,
 129  
                         HttpServletRequest request, HttpServletResponse response) {
 130  
 
 131  0
                 return getUIFModelAndView(uiTestForm, uiTestForm.getViewId(), "page1");
 132  
         }
 133  
 
 134  
 }