-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ROASTER-51: Improved parameter naming algorithm
- Loading branch information
Showing
3 changed files
with
104 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
api/src/test/java/org/jboss/forge/roaster/model/util/MethodsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright 2015 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Eclipse Public License version 1.0, available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
|
||
package org.jboss.forge.roaster.model.util; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertThat; | ||
|
||
import java.awt.List; | ||
import java.util.Arrays; | ||
import java.util.Map; | ||
|
||
import org.hamcrest.CoreMatchers; | ||
import org.junit.Test; | ||
|
||
/** | ||
* | ||
* @author <a href="mailto:ggastald@redhat.com">George Gastaldi</a> | ||
*/ | ||
public class MethodsTest | ||
{ | ||
|
||
@Test | ||
public void testParamNameSingleUpperCase() | ||
{ | ||
assertEquals("facesContext", Methods.toParamName("FacesContext")); | ||
} | ||
|
||
@Test | ||
public void testParamNameMultipleUpperCase() | ||
{ | ||
assertEquals("uiComponent", Methods.toParamName("UIComponent")); | ||
} | ||
|
||
@Test | ||
public void testParamNameAllLowerCase() | ||
{ | ||
assertEquals("myclass", Methods.toParamName("myclass")); | ||
} | ||
|
||
@Test | ||
public void testParametersSameTypes() | ||
{ | ||
String[] paramNames = Methods.generateParameterNames(new Class[] { List.class, List.class }); | ||
assertThat(Arrays.asList(paramNames), CoreMatchers.hasItems("list", "list1")); | ||
} | ||
|
||
@Test | ||
public void testParametersDifferentTypes() | ||
{ | ||
String[] paramNames = Methods.generateParameterNames(new Class[] { Map.class, List.class }); | ||
assertThat(Arrays.asList(paramNames), CoreMatchers.hasItems("map", "list")); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters