@JsonCreator ContentQueryJson( @JsonProperty("queryExpr") final String queryExprString, // @JsonProperty("from") final Integer from, // @JsonProperty("size") final Integer size, // @JsonProperty("contentTypeNames") final List<String> contentTypeNameString, @JsonProperty("expand") final String expand, @JsonProperty("aggregationQueries") final List<AggregationQueryJson> aggregationQueries, // @JsonProperty("queryFilters") final List<FilterJson> queryFilters) { final ContentQuery.Builder builder = ContentQuery.newContentQuery() .from(from) .size(size) .queryExpr(QueryParser.parse(queryExprString)) .addContentTypeNames(ContentTypeNames.from(contentTypeNameString)); if (aggregationQueries != null) { for (final AggregationQueryJson aggregationQueryJson : aggregationQueries) { builder.aggregationQuery(aggregationQueryJson.getAggregationQuery()); } } if (queryFilters != null) { for (final FilterJson queryFilterJson : queryFilters) { builder.queryFilter(queryFilterJson.getFilter()); } } this.contentQuery = builder.build(); this.expand = expand != null ? expand : "none"; }
@Test public void testTo() throws Exception { final String xml = readFromFile("relationship-type.xml"); final RelationshipType.Builder builder = RelationshipType.newRelationshipType(); XmlSerializers.relationshipType().parse(xml).to(builder); builder.name("mymodule-1.0.0:myreltype"); final RelationshipType relationshipType = builder.build(); assertEquals("mymodule-1.0.0:myreltype", relationshipType.getName().toString()); assertEquals("description", relationshipType.getDescription()); assertEquals("likes", relationshipType.getFromSemantic()); assertEquals("liked by", relationshipType.getToSemantic()); assertEquals( ContentTypeNames.from("mymodule-1.0.0:animal", "mymodule-1.0.0:person"), relationshipType.getAllowedFromTypes()); assertEquals( ContentTypeNames.from("mymodule-1.0.0:vehicle"), relationshipType.getAllowedToTypes()); }