use of com.liferay.apio.architect.test.util.json.Conditions in project com-liferay-apio-architect by liferay.
the class JSONLDTestUtil method isAJsonObjectWithTheSecondEmbedded.
/**
* Returns a {@code Matcher} that checks if the field is a JSON object of
* the second embedded model.
*
* @return the matcher
*/
public static Matcher<JsonElement> isAJsonObjectWithTheSecondEmbedded() {
List<Matcher<? super JsonElement>> theContext = Arrays.asList(aJsonObjectWhere("embedded", IS_A_TYPE_ID_JSON_OBJECT), aJsonObjectWhere("linked", IS_A_TYPE_ID_JSON_OBJECT), aJsonObjectWhere("relatedCollection", IS_A_TYPE_ID_JSON_OBJECT));
Conditions.Builder builder = new Conditions.Builder();
Conditions secondEmbeddedConditions = builder.where("@context", is(aJsonArrayThat(contains(theContext)))).where("@id", isALinkTo("localhost/p/second-inner-model/first")).where("@type", containsTheTypes("Type")).where("binary", isALinkTo("localhost/b/second-inner-model/first/binary")).where("boolean", is(aJsonBoolean(false))).where("booleanList", isAJsonArrayContaining(true)).where("embedded", isALinkTo("localhost/p/third-inner-model/first")).where("link", isALinkTo("community.liferay.com")).where("linked", isALinkTo("localhost/p/third-inner-model/second")).where("number", is(aJsonInt(equalTo(2017)))).where("numberList", isAJsonArrayContaining(1)).where("relatedCollection", isALinkTo("localhost/p/second-inner-model/first/models")).where("string", is(aJsonString(equalTo("A string")))).where("stringList", isAJsonArrayContaining("a")).build();
return is(aJsonObjectWith(secondEmbeddedConditions));
}
use of com.liferay.apio.architect.test.util.json.Conditions in project com-liferay-apio-architect by liferay.
the class JSONLDTestUtil method containsTheRootOperations.
/**
* Returns a {@code Matcher} that checks if the field contains the {@code
* RootModel} operations.
*
* @return the matcher
*/
public static Matcher<? extends JsonElement> containsTheRootOperations() {
Builder builder = new Builder();
Conditions firstOperationConditions = builder.where("@id", is(aJsonString(equalTo("_:delete-operation")))).where("@type", is(aJsonString(equalTo("Operation")))).where("method", is(aJsonString(equalTo("DELETE")))).build();
Conditions secondOperationConditions = builder.where("@id", is(aJsonString(equalTo("_:update-operation")))).where("@type", is(aJsonString(equalTo("Operation")))).where("expects", is(aJsonString(equalTo("localhost/f/u/r")))).where("method", is(aJsonString(equalTo("PUT")))).build();
List<Matcher<? super JsonElement>> theOperations = Arrays.asList(is(aJsonObjectWith(firstOperationConditions)), is(aJsonObjectWith(secondOperationConditions)));
return is(aJsonArrayThat(contains(theOperations)));
}
use of com.liferay.apio.architect.test.util.json.Conditions in project com-liferay-apio-architect by liferay.
the class JSONLDTestUtil method isAJsonObjectWithTheFirstNested.
/**
* Returns a {@code Matcher} that checks if the field is a JSON object of
* the first nested model.
*
* @return the matcher
*/
public static Matcher<JsonElement> isAJsonObjectWithTheFirstNested() {
Builder builder = new Builder();
Conditions conditions = builder.where("@type", containsTheTypes("Type 3")).where("number1", is(aJsonInt(equalTo(2017)))).where("string1", is(aJsonString(equalTo("id 1")))).where("string2", is(aJsonString(equalTo("string2")))).build();
return aJsonObjectWith(conditions);
}
use of com.liferay.apio.architect.test.util.json.Conditions in project com-liferay-apio-architect by liferay.
the class JSONLDTestUtil 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) {
List<Matcher<? super JsonElement>> theContext = Arrays.asList(aJsonObjectWhere("bidirectionalModel3", IS_A_TYPE_ID_JSON_OBJECT), aJsonObjectWhere("linked3", IS_A_TYPE_ID_JSON_OBJECT), aJsonObjectWhere("relatedCollection3", IS_A_TYPE_ID_JSON_OBJECT));
Builder builder = new Builder();
Conditions secondNestedConditions = builder.where("@context", is(aJsonArrayThat(contains(theContext)))).where("@type", containsTheTypes("Type 4")).where("bidirectionalModel3", isALinkTo("localhost/p/first-inner-model/" + id)).where("linked3", isALinkTo("localhost/p/third-inner-model/fifth")).where("nested3", isAJsonObjectWithTheThirdNested()).where("number1", is(aJsonInt(equalTo(42)))).where("relatedCollection3", isALinkTo("localhost/p/model/" + id + "/models")).where("string1", is(aJsonString(equalTo(id)))).build();
return aJsonObjectWith(secondNestedConditions);
}
use of com.liferay.apio.architect.test.util.json.Conditions in project com-liferay-apio-architect by liferay.
the class HALPageMessageMapperTest method testHALPageMessageMapper.
@Test
public void testHALPageMessageMapper() {
HttpHeaders httpHeaders = Mockito.mock(HttpHeaders.class);
JsonObject jsonObject = MockPageWriter.write(httpHeaders, _pageMessageMapper);
Conditions.Builder builder = new Conditions.Builder();
Conditions conditions = builder.where("_embedded", _isAJsonObjectWithTheEmbedded).where("_links", _isAJsonObjectWithTheLinks).where("count", is(aJsonInt(equalTo(3)))).where("total", is(aJsonInt(equalTo(9)))).build();
assertThat(jsonObject, is(aJsonObjectWith(conditions)));
}
Aggregations