use of com.liferay.apio.architect.test.util.json.Conditions in project com-liferay-apio-architect by liferay.
the class JSONLDDocumentationMessageMapperTest method testJSONLDDocumentationMessageMapper.
@Test
public void testJSONLDDocumentationMessageMapper() {
HttpHeaders httpHeaders = Mockito.mock(HttpHeaders.class);
JsonObject jsonObject = MockDocumentationWriter.write(httpHeaders, _documentationMessageMapper);
Conditions.Builder builder = new Conditions.Builder();
Conditions conditions = builder.where("@context", IS_A_LINK_TO_HYDRA_PROFILE).where("@id", is(aJsonString(equalTo("http://api.example.com/doc/")))).where("@type", is(aJsonString(equalTo("ApiDocumentation")))).where("description", is(aJsonString(equalTo("Description")))).where("title", is(aJsonString(equalTo("Title")))).build();
assertThat(jsonObject, is(aJsonObjectWith(conditions)));
}
use of com.liferay.apio.architect.test.util.json.Conditions in project com-liferay-apio-architect by liferay.
the class PlainJSONTestUtil method isAJsonObjectWithTheSecondNested.
/**
* Returns a {@code Matcher} that checks if the field is a JSON object of
* the second nested model.
*
* @return the matcher
*/
public static Matcher<JsonElement> isAJsonObjectWithTheSecondNested(String id) {
Builder builder = new Builder();
Conditions conditions = builder.where("bidirectionalModel3", isALinkTo("localhost/p/first-inner-model/" + id)).where("linked3", is(isALinkTo("localhost/p/third-inner-model/fifth"))).where("nested3", aJsonObjectWhere("string1", is(aJsonString(equalTo("id 3"))))).where("number1", is(aJsonInt(equalTo(42)))).where("relatedCollection3", is(isALinkTo("localhost/p/model/" + id + "/models"))).where("string1", is(aJsonString(equalTo(id)))).build();
return is(aJsonObjectWith(conditions));
}
use of com.liferay.apio.architect.test.util.json.Conditions in project com-liferay-apio-architect by liferay.
the class IsJsonObjectStringMatcherTest method testInvalidJsonObjectWithMultiConditionUpdatesDescription.
@Test
public void testInvalidJsonObjectWithMultiConditionUpdatesDescription() {
Conditions conditions = _builder.where("apio", is(aJsonString(equalTo("Live long and prosper")))).where("geek", is(aJsonBoolean(true))).build();
Matcher<String> stringMatcher = aJsonObjectStringWith(conditions);
Description description = new StringDescription();
stringMatcher.describeMismatch("{}", description);
String expected = "was a JSON object {\n apio: was null\n geek: was null\n}";
assertThat(description.toString(), is(expected));
}
use of com.liferay.apio.architect.test.util.json.Conditions in project com-liferay-apio-architect by liferay.
the class IsJsonObjectStringMatcherTest method testIsJsonMatcherUpdatesDescription.
@Test
public void testIsJsonMatcherUpdatesDescription() {
Conditions conditions = _builder.build();
Matcher<String> stringMatcher = aJsonObjectStringWith(conditions);
Description description = new StringDescription();
stringMatcher.describeTo(description);
assertThat(description.toString(), is("a JSON object where {\n}"));
}
use of com.liferay.apio.architect.test.util.json.Conditions in project com-liferay-apio-architect by liferay.
the class IsJsonObjectStringMatcherTest method testInvalidJsonObjectUpdatesValidDescription.
@Test
public void testInvalidJsonObjectUpdatesValidDescription() {
Conditions conditions = _builder.build();
Matcher<String> stringMatcher = aJsonObjectStringWith(conditions);
Description description = new StringDescription();
stringMatcher.describeMismatch("{", description);
assertThat(description.toString(), is("was not a JSON object"));
}
Aggregations