View Javadoc

1   /*
2    * Copyright 2006-2012 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  
17  package org.kuali.rice.krad.uif.widget;
18  
19  import org.junit.Test;
20  import org.kuali.rice.kim.api.identity.Person;
21  import org.kuali.rice.krad.service.KRADServiceLocator;
22  import org.kuali.rice.krad.test.document.BOContainingPerson;
23  import org.kuali.rice.krad.uif.element.Action;
24  import org.kuali.rice.krad.uif.element.Link;
25  import org.kuali.rice.krad.util.KRADConstants;
26  import org.kuali.test.KRADTestCase;
27  
28  import java.util.HashMap;
29  import java.util.Map;
30  
31  import static org.junit.Assert.assertEquals;
32  import static org.junit.Assert.assertNotNull;
33  
34  /**
35   * Tests for {@link Inquiry}
36   */
37  public class InquiryTest extends KRADTestCase{
38      @Test
39      /**
40       * tests that the inquiry link for a related class is built ok
41       */
42      public void testBuildInquiryUrl_relatedClass() {
43          Inquiry inquiry = new Inquiry();
44          inquiry.setParentReadOnly(true);
45          inquiry.setInquiryLink(new Link());
46          inquiry.setDirectInquiryAction(new Action());
47          String baseInquiryUrl = KRADServiceLocator.getKualiConfigurationService().getPropertyValueAsString(
48                  KRADConstants.APPLICATION_URL_KEY);
49          inquiry.setBaseInquiryUrl(baseInquiryUrl);
50          Map<String, String> params = new HashMap<String, String>();
51          params.put("principalId", "principalId");
52          BOContainingPerson dataObject = new BOContainingPerson();
53          dataObject.setPrincipalId("en");
54          inquiry.buildInquiryLink(dataObject, "principalId", Person.class, params);
55  
56          assertNotNull("InquiryLink should not be null", inquiry.getInquiryLink());
57          assertNotNull("InquiryLink's href should not be null", inquiry.getInquiryLink().getHref());
58          String expectedHref = baseInquiryUrl +
59                  "/kr-krad/inquiry?principalId=en&methodToCall=start&dataObjectClassName=org.kuali.rice.kim.impl.identity.PersonImpl";
60          assertEquals("InquiryLink's href is not the expected value", expectedHref, inquiry.getInquiryLink().getHref());
61      }
62  }