BAEL-2981: Updated tests

This commit is contained in:
isaolmez 2019-06-24 23:13:05 +03:00
parent ca3ef57f04
commit 2e2af71a58
4 changed files with 16 additions and 16 deletions

View File

@ -32,9 +32,9 @@ public class BasicUsageUnitTest {
public void whenParameterMapIsSupplied_thenDisplays() throws IOException {
Handlebars handlebars = new Handlebars();
Template template = handlebars.compileInline("Hi {{name}}!");
Map<String, String> parameterMap = new HashMap<>();
parameterMap.put("name", "Baeldung");
String templateString = template.apply(parameterMap);
assertThat(templateString).isEqualTo("Hi Baeldung!");
@ -44,9 +44,9 @@ public class BasicUsageUnitTest {
public void whenParameterObjectIsSupplied_ThenDisplays() throws IOException {
Handlebars handlebars = new Handlebars();
Template template = handlebars.compileInline("Hi {{name}}!");
Person person = new Person();
person.setName("Baeldung");
String templateString = template.apply(person);
assertThat(templateString).isEqualTo("Hi Baeldung!");
@ -56,10 +56,10 @@ public class BasicUsageUnitTest {
public void whenMultipleParametersAreSupplied_ThenDisplays() throws IOException {
Handlebars handlebars = new Handlebars();
Template template = handlebars.compileInline("Hi {{name}}! This is {{topic}}.");
Map<String, String> parameterMap = new HashMap<>();
parameterMap.put("name", "Baeldung");
parameterMap.put("topic", "Handlebars");
String templateString = template.apply(parameterMap);
assertThat(templateString).isEqualTo("Hi Baeldung! This is Handlebars.");
@ -69,8 +69,8 @@ public class BasicUsageUnitTest {
public void whenNoLoaderIsGiven_ThenSearchesClasspath() throws IOException {
Handlebars handlebars = new Handlebars();
Template template = handlebars.compile("greeting");
Person person = getPerson("Baeldung");
String templateString = template.apply(person);
assertThat(templateString).isEqualTo("Hi Baeldung!");
@ -81,8 +81,8 @@ public class BasicUsageUnitTest {
TemplateLoader loader = new ClassPathTemplateLoader("/handlebars", ".html");
Handlebars handlebars = new Handlebars(loader);
Template template = handlebars.compile("greeting");
Person person = getPerson("Baeldung");
String templateString = template.apply(person);
assertThat(templateString).isEqualTo("Hi Baeldung!");
@ -94,8 +94,8 @@ public class BasicUsageUnitTest {
TemplateLoader secondLoader = new ClassPathTemplateLoader("/templates", ".html");
Handlebars handlebars = new Handlebars().with(firstLoader, secondLoader);
Template template = handlebars.compile("greeting");
Person person = getPerson("Baeldung");
String templateString = template.apply(person);
assertThat(templateString).isEqualTo("Hi Baeldung!");

View File

@ -22,9 +22,9 @@ public class BuiltinHelperUnitTest {
public void whenUsedWith_ThenContextChanges() throws IOException {
Handlebars handlebars = new Handlebars(templateLoader);
Template template = handlebars.compile("with");
Person person = getPerson("Baeldung");
person.getAddress().setStreet("World");
String templateString = template.apply(person);
assertThat(templateString).isEqualTo("\n<h4>I live in World</h4>\n");
@ -34,9 +34,9 @@ public class BuiltinHelperUnitTest {
public void whenUsedWithMustacheStyle_ThenContextChanges() throws IOException {
Handlebars handlebars = new Handlebars(templateLoader);
Template template = handlebars.compile("with_mustache");
Person person = getPerson("Baeldung");
person.getAddress().setStreet("World");
String templateString = template.apply(person);
assertThat(templateString).isEqualTo("\n<h4>I live in World</h4>\n");
@ -46,12 +46,12 @@ public class BuiltinHelperUnitTest {
public void whenUsedEach_ThenIterates() throws IOException {
Handlebars handlebars = new Handlebars(templateLoader);
Template template = handlebars.compile("each");
Person person = getPerson("Baeldung");
Person friend1 = getPerson("Java");
Person friend2 = getPerson("Spring");
person.getFriends().add(friend1);
person.getFriends().add(friend2);
String templateString = template.apply(person);
assertThat(templateString).isEqualTo("\n<span>Java is my friend.</span>\n"
@ -62,12 +62,12 @@ public class BuiltinHelperUnitTest {
public void whenUsedEachMustacheStyle_ThenIterates() throws IOException {
Handlebars handlebars = new Handlebars(templateLoader);
Template template = handlebars.compile("each_mustache");
Person person = getPerson("Baeldung");
Person friend1 = getPerson("Java");
Person friend2 = getPerson("Spring");
person.getFriends().add(friend1);
person.getFriends().add(friend2);
String templateString = template.apply(person);
assertThat(templateString).isEqualTo("\n<span>Java is my friend.</span>\n"
@ -78,9 +78,9 @@ public class BuiltinHelperUnitTest {
public void whenUsedIf_ThenPutsCondition() throws IOException {
Handlebars handlebars = new Handlebars(templateLoader);
Template template = handlebars.compile("if");
Person person = getPerson("Baeldung");
person.setBusy(true);
String templateString = template.apply(person);
assertThat(templateString).isEqualTo("\n<h4>Baeldung is busy.</h4>\n");
@ -90,9 +90,9 @@ public class BuiltinHelperUnitTest {
public void whenUsedIfMustacheStyle_ThenPutsCondition() throws IOException {
Handlebars handlebars = new Handlebars(templateLoader);
Template template = handlebars.compile("if_mustache");
Person person = getPerson("Baeldung");
person.setBusy(true);
String templateString = template.apply(person);
assertThat(templateString).isEqualTo("\n<h4>Baeldung is busy.</h4>\n");

View File

@ -31,8 +31,8 @@ public class CustomHelperUnitTest {
}
});
Template template = handlebars.compile("person");
Person person = getPerson("Baeldung");
String templateString = template.apply(person);
assertThat(templateString).isEqualTo("Baeldung - busy");
@ -43,8 +43,8 @@ public class CustomHelperUnitTest {
Handlebars handlebars = new Handlebars(templateLoader);
handlebars.registerHelpers(new HelperSource());
Template template = handlebars.compile("person");
Person person = getPerson("Baeldung");
String templateString = template.apply(person);
assertThat(templateString).isEqualTo("Baeldung - busy");

View File

@ -22,9 +22,9 @@ public class ReusingTemplatesUnitTest {
public void whenOtherTemplateIsReferenced_ThenCanReuse() throws IOException {
Handlebars handlebars = new Handlebars(templateLoader);
Template template = handlebars.compile("page");
Person person = new Person();
person.setName("Baeldung");
String templateString = template.apply(person);
assertThat(templateString).isEqualTo("<h4>Hi Baeldung!</h4>\n<p>This is the page Baeldung</p>");
@ -34,9 +34,9 @@ public class ReusingTemplatesUnitTest {
public void whenBlockIsDefined_ThenCanOverrideWithPartial() throws IOException {
Handlebars handlebars = new Handlebars(templateLoader);
Template template = handlebars.compile("simplemessage");
Person person = new Person();
person.setName("Baeldung");
String templateString = template.apply(person);
assertThat(templateString).isEqualTo("\n<html>\n"