You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2017/01/26 17:46:25 UTC
cxf git commit: [CXF-7213] Fixing FiqlParser issue to do with
resolving the collections inside an object,
patch from Hector Kikuchi Martins applied
Repository: cxf
Updated Branches:
refs/heads/master eadbdb1a2 -> 42f1c3035
[CXF-7213] Fixing FiqlParser issue to do with resolving the collections inside an object, patch from Hector Kikuchi Martins applied
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/42f1c303
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/42f1c303
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/42f1c303
Branch: refs/heads/master
Commit: 42f1c303547c0e6dd5ddc722be4b8f7d71d78c6b
Parents: eadbdb1
Author: Sergey Beryozkin <sb...@gmail.com>
Authored: Thu Jan 26 17:46:09 2017 +0000
Committer: Sergey Beryozkin <sb...@gmail.com>
Committed: Thu Jan 26 17:46:09 2017 +0000
----------------------------------------------------------------------
.../search/AbstractSearchConditionParser.java | 10 +-
.../ext/search/fiql/FiqlCollectionsTest.java | 97 ++++++++++++++++++++
2 files changed, 105 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/42f1c303/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/AbstractSearchConditionParser.java
----------------------------------------------------------------------
diff --git a/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/AbstractSearchConditionParser.java b/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/AbstractSearchConditionParser.java
index 8dfdd80..b28cbdc 100644
--- a/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/AbstractSearchConditionParser.java
+++ b/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/AbstractSearchConditionParser.java
@@ -42,6 +42,7 @@ import org.apache.cxf.jaxrs.utils.InjectionUtils;
import org.apache.cxf.jaxrs.utils.JAXRSUtils;
import org.apache.cxf.message.Message;
import org.apache.cxf.message.MessageUtils;
+import org.apache.olingo.odata2.api.servicedocument.Collection;
public abstract class AbstractSearchConditionParser<T> implements SearchConditionParser<T> {
@@ -210,8 +211,13 @@ public abstract class AbstractSearchConditionParser<T> implements SearchConditio
nextObject = actualReturnType.newInstance();
}
Method setterM = actualType.getMethod("set" + nextPart, new Class[]{returnType});
- Object valueObjectValue = lastTry || !returnCollection
- ? nextObject : getCollectionSingleton(valueType, nextObject);
+ Object valueObjectValue = null;
+ if (lastTry || !returnCollection) {
+ valueObjectValue = nextObject;
+ } else {
+ Class<?> collCls = Collection.class.isAssignableFrom(valueType) ? valueType : returnType;
+ valueObjectValue = getCollectionSingleton(collCls, nextObject);
+ }
setterM.invoke(valueObject, new Object[]{valueObjectValue});
if (lastTry) {
http://git-wip-us.apache.org/repos/asf/cxf/blob/42f1c303/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlCollectionsTest.java
----------------------------------------------------------------------
diff --git a/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlCollectionsTest.java b/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlCollectionsTest.java
new file mode 100644
index 0000000..c690af3
--- /dev/null
+++ b/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlCollectionsTest.java
@@ -0,0 +1,97 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.jaxrs.ext.search.fiql;
+
+import java.util.Set;
+
+import org.apache.cxf.jaxrs.ext.search.SearchCondition;
+import org.apache.cxf.jaxrs.ext.search.SearchParseException;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class FiqlCollectionsTest extends Assert {
+ @Test
+ public void testWithCollectionAfterFirstLevelOnCollection() throws SearchParseException {
+ FiqlParser<Place> placeParser = new FiqlParser<Place>(Place.class);
+ SearchCondition<Place> placeCondition = placeParser
+ .parse("specs.features.description==description");
+ Place place = placeCondition.getCondition();
+ assertNotNull(place);
+ }
+
+ @Test
+ public void testWithCollectionAfterFirstLevelOnSingleObject() throws SearchParseException {
+ FiqlParser<Room> roomParser = new FiqlParser<Room>(Room.class);
+ SearchCondition<Room> roomCondition = roomParser
+ .parse("furniture.spec.features.description==description");
+ Room room = roomCondition.getCondition();
+ assertNotNull(room);
+ }
+
+ public static class Room {
+ Set<Furniture> furniture;
+ public Set<Furniture> getFurniture() {
+ return furniture;
+ }
+ public void setFurniture(Set<Furniture> furniture) {
+ this.furniture = furniture;
+ }
+ }
+
+ public static class Place {
+ Set<Spec> specs;
+ public Set<Spec> getSpecs() {
+ return specs;
+ }
+ public void setSpecs(Set<Spec> specs) {
+ this.specs = specs;
+ }
+ }
+
+ public static class Furniture {
+ Spec spec;
+ public Spec getSpec() {
+ return spec;
+ }
+ public void setSpec(Spec spec) {
+ this.spec = spec;
+ }
+ }
+
+ public static class Spec {
+ Set<Feature> features;
+ public Set<Feature> getFeatures() {
+ return features;
+ }
+ public void setFeatures(Set<Feature> features) {
+ this.features = features;
+ }
+ }
+
+ public static class Feature {
+ String description;
+ public String getDescription() {
+ return description;
+ }
+ public void setDescription(String description) {
+ this.description = description;
+ }
+ }
+}