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