use of com.liferay.apio.architect.test.util.json.Conditions.Builder in project com-liferay-apio-architect by liferay.
the class JSONLDTestUtil method isAJsonObjectWithTheFirstEmbedded.
/**
* Returns a {@code Matcher} that checks if the field is a JSON object of
* the first embedded model.
*
* @param member whether the {@code FirstEmbeddedModel} is added as a
* collection member
* @return the matcher
*/
public static Matcher<JsonElement> isAJsonObjectWithTheFirstEmbedded(boolean member) {
Builder builder = new Builder();
List<Matcher<? super JsonElement>> theContext = Arrays.asList(aJsonObjectWhere("linked", IS_A_TYPE_ID_JSON_OBJECT), aJsonObjectWhere("relatedCollection", IS_A_TYPE_ID_JSON_OBJECT));
Builder firstEmbeddedBuilder = builder.where("@context", is(aJsonArrayThat(contains(theContext)))).where("@id", isALinkTo("localhost/p/first-inner-model/first")).where("@type", containsTheTypes("Type")).where("binary", isALinkTo("localhost/b/first-inner-model/first/binary")).where("boolean", is(aJsonBoolean(true))).where("booleanList", isAJsonArrayContaining(true, false)).where("embedded", isAJsonObjectWithTheSecondEmbedded()).where("link", isALinkTo("www.liferay.com")).where("linked", isALinkTo("localhost/p/second-inner-model/second")).where("localizedString", is(aJsonString(equalTo("Translated")))).where("number", is(aJsonInt(equalTo(42)))).where("numberList", isAJsonArrayContaining(1, 2)).where("relatedCollection", isALinkTo("localhost/p/first-inner-model/first/models")).where("string", is(aJsonString(equalTo("A string")))).where("stringList", isAJsonArrayContaining("a", "b"));
if (member) {
return aJsonObjectWith(firstEmbeddedBuilder.build());
}
Matcher<? super JsonElement> anOperation = builder.where("@id", is(aJsonString(equalTo("_:delete-operation")))).where("@type", is(aJsonString(equalTo("Operation")))).where("method", is(aJsonString(equalTo("DELETE")))).build();
Conditions conditions = firstEmbeddedBuilder.where("operation", is(aJsonArrayThat(contains(anOperation)))).build();
return aJsonObjectWith(conditions);
}
use of com.liferay.apio.architect.test.util.json.Conditions.Builder 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.Builder 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.Builder 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.Builder 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);
}
Aggregations