Skip to content

Commit

Permalink
Test to verify if minimum-length is processed by the template
Browse files Browse the repository at this point in the history
  • Loading branch information
VineetReynolds committed Mar 8, 2013
1 parent 99b7f77 commit 4945195
Showing 1 changed file with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,32 @@ public void testGenerateBasicStringPropertyWithMaxlength() throws Exception {
assertThat(formInputElement.attr("id"), equalTo("fullName"));
assertThat(formInputElement.attr("type"), equalTo("text"));
assertThat(formInputElement.attr("ng-model"), equalTo(StringUtils.camelCase("SampleEntity")+"."+"fullName"));
assertThat(formInputElement.attr("maxlength"), equalTo("100"));
assertThat(formInputElement.attr("ng-maxlength"), equalTo("100"));
}

@Test
public void testGenerateBasicStringPropertyWithMinlength() throws Exception {
Map<String, String> nameProperties = new HashMap<String, String>();
nameProperties.put("name", "fullName");
nameProperties.put("type", "java.lang.String");
nameProperties.put("minimum-length", "5");

Map<String, Object> root = new HashMap<String, Object>();
root.put("entityName", "SampleEntity");
root.put("property", nameProperties);
String output = freemarkerClient.processFTL(root, "views/includes/basicPropertyDetail.html.ftl");
Document html = Jsoup.parseBodyFragment(output);
assertThat(output.trim(), not(equalTo("")));

Elements container = html.select("div.control-group");
assertThat(container, notNullValue());
assertThat(container.attr("ng-class"), not(equalTo("")));

Elements formInputElement = html.select("div.control-group input");
assertThat(formInputElement.attr("id"), equalTo("fullName"));
assertThat(formInputElement.attr("type"), equalTo("text"));
assertThat(formInputElement.attr("ng-model"), equalTo(StringUtils.camelCase("SampleEntity")+"."+"fullName"));
assertThat(formInputElement.attr("ng-minlength"), equalTo("5"));
}

@Test
Expand Down

0 comments on commit 4945195

Please sign in to comment.