View Javadoc

1   /**
2    * Copyright 2005-2013 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.util;
17  
18  import org.junit.Before;
19  import org.junit.Test;
20  import org.kuali.rice.krad.uif.component.Component;
21  import org.kuali.rice.krad.uif.field.InputField;
22  
23  import static junit.framework.Assert.assertEquals;
24  import static junit.framework.Assert.assertTrue;
25  
26  /**
27   * ComponentUtilsTest tests various ComponentUtils methods
28   *
29   * @author Kuali Rice Team (rice.collab@kuali.org)
30   */
31  public class ComponentUtilsTest {
32  
33      private String componentId;
34      private Component component;
35  
36      @Before
37      public void setup() {
38          component = new InputField();
39          componentId = "field1";
40          component.setId(componentId);
41          component.setBaseId(componentId);
42      }
43  
44      @Test
45      /**
46       * test that {@link ComponentUtils#updateIdWithSuffix} works ok
47       */
48      public void testUpdateIdWithSuffix() {
49          ComponentUtils.updateIdWithSuffix(component, null);
50          assertTrue(component.getId().equalsIgnoreCase(componentId));
51  
52          String suffix = "_field";
53          ComponentUtils.updateIdWithSuffix(component, suffix);
54          assertTrue(component.getId().equalsIgnoreCase(componentId + suffix));
55  
56      }
57  }