use of com.liferay.apio.architect.form.Form in project com-liferay-apio-architect by liferay.
the class FormEndpointTest method testValidCreatorFormMethodReturnsSuccess.
@Test
public void testValidCreatorFormMethodReturnsSuccess() {
FormEndpoint formEndpoint = new FormEndpoint(__ -> Optional.of(_collectionRoutes()), __ -> Optional.empty(), (name, nestedName) -> Optional.empty());
Try<Form> creatorFormTry = formEndpoint.creatorForm("");
assertThat(creatorFormTry, is(aSuccessTry()));
Form form = creatorFormTry.getUnchecked();
assertThat(form.id, is("c/name"));
}
use of com.liferay.apio.architect.form.Form in project com-liferay-apio-architect by liferay.
the class FormConditionsTest method testInvokingMatchesUpdatedDescription.
@Test
public void testInvokingMatchesUpdatedDescription() {
Builder<Map<String, Object>> builder = new Builder<>();
FormConditions formConditions = builder.whereBoolean("boolean", isReturnedIn(__ -> null)).whereString("string", isReturnedIn(__ -> null)).build();
Description description = new StringDescription();
Form.Builder<Map<String, Object>> formBuilder = Form.Builder.empty();
Form<Map<String, Object>> form = formBuilder.title(__ -> "title").description(__ -> "description").constructor(HashMap::new).build();
boolean matchesElement = formConditions.matches(form);
formConditions.describeMismatch(form, description);
String expected = "was a Form...\n\t...that should have returned something that is " + "<true> instead of null\n\t...that should have returned " + "something that is \"String\" instead of null\n";
assertThat(matchesElement, is(false));
assertThat(description.toString(), is(expected));
}
use of com.liferay.apio.architect.form.Form in project com-liferay-apio-architect by liferay.
the class FormConditionsTest method testFormWithInvalidFieldsUpdatesDescription.
@Test
public void testFormWithInvalidFieldsUpdatesDescription() {
Form.Builder<Map<String, Object>> builder = Form.Builder.empty();
Form<Map<String, Object>> form = builder.title(__ -> "title").description(__ -> "description").constructor(HashMap::new).build();
Builder<Map<String, Object>> formConditionsBuilder = new Builder<>();
FormConditions<Map<String, Object>> formConditions = formConditionsBuilder.whereDouble("double", isReturnedIn(map -> null)).build();
Description description = new StringDescription();
formConditions.describeMismatch(form, description);
String expected = "was a Form...\n\t...that should have returned something that is " + "<21.2> instead of null\n";
assertThat(description.toString(), is(expected));
}
Aggregations