[OLINGO-422] Minor code refactorings and fixes
This commit is contained in:
parent
a1d9f747b8
commit
588ae2a70c
|
@ -47,8 +47,7 @@ public final class ContextURLHelper {
|
||||||
public static String buildSelectList(final EdmEntityType entityType,
|
public static String buildSelectList(final EdmEntityType entityType,
|
||||||
final ExpandOption expand, final SelectOption select) throws ODataSerializerException {
|
final ExpandOption expand, final SelectOption select) throws ODataSerializerException {
|
||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
boolean isSelected = select != null && select.getSelectItems() != null && !select.getSelectItems().isEmpty();
|
if (ExpandSelectHelper.hasSelect(select)) {
|
||||||
if(isSelected) {
|
|
||||||
handleSelect(entityType, select, result);
|
handleSelect(entityType, select, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +57,7 @@ public final class ContextURLHelper {
|
||||||
return result.length() == 0 ? null : result.toString();
|
return result.length() == 0 ? null : result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handleSelect(EdmEntityType entityType, SelectOption select, StringBuilder result) {
|
private static void handleSelect(final EdmEntityType entityType, final SelectOption select, StringBuilder result) {
|
||||||
if (ExpandSelectHelper.isAll(select)) {
|
if (ExpandSelectHelper.isAll(select)) {
|
||||||
result.append('*');
|
result.append('*');
|
||||||
} else {
|
} else {
|
||||||
|
@ -98,7 +97,7 @@ public final class ContextURLHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handleExpand(EdmEntityType entityType, ExpandOption expand, StringBuilder result)
|
private static void handleExpand(final EdmEntityType entityType, final ExpandOption expand, StringBuilder result)
|
||||||
throws ODataSerializerException {
|
throws ODataSerializerException {
|
||||||
final Set<String> expandedPropertyNames = ExpandSelectHelper.getExpandedPropertyNames(expand.getExpandItems());
|
final Set<String> expandedPropertyNames = ExpandSelectHelper.getExpandedPropertyNames(expand.getExpandItems());
|
||||||
for (final String propertyName : entityType.getNavigationPropertyNames()) {
|
for (final String propertyName : entityType.getNavigationPropertyNames()) {
|
||||||
|
@ -109,10 +108,12 @@ public final class ContextURLHelper {
|
||||||
|| ExpandSelectHelper.hasSelect(expandItem.getSelectOption())) {
|
|| ExpandSelectHelper.hasSelect(expandItem.getSelectOption())) {
|
||||||
final String innerSelectList = buildSelectList(entityType.getNavigationProperty(propertyName).getType(),
|
final String innerSelectList = buildSelectList(entityType.getNavigationProperty(propertyName).getType(),
|
||||||
expandItem.getExpandOption(), expandItem.getSelectOption());
|
expandItem.getExpandOption(), expandItem.getSelectOption());
|
||||||
if (result.length() > 0) {
|
if (innerSelectList != null) {
|
||||||
result.append(',');
|
if (result.length() > 0) {
|
||||||
|
result.append(',');
|
||||||
|
}
|
||||||
|
result.append(Encoder.encode(propertyName)).append('(').append(innerSelectList).append(')');
|
||||||
}
|
}
|
||||||
result.append(Encoder.encode(propertyName)).append('(').append(innerSelectList).append(')');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,90 @@
|
||||||
|
/*
|
||||||
|
* 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.olingo.server.core.serializer;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.olingo.commons.api.edm.EdmElement;
|
||||||
|
import org.apache.olingo.commons.api.edm.EdmEntitySet;
|
||||||
|
import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
|
||||||
|
import org.apache.olingo.commons.api.edm.EdmProperty;
|
||||||
|
import org.apache.olingo.commons.api.edm.EdmStructuredType;
|
||||||
|
import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
|
||||||
|
import org.apache.olingo.server.api.uri.UriInfoResource;
|
||||||
|
import org.apache.olingo.server.api.uri.UriResource;
|
||||||
|
import org.apache.olingo.server.api.uri.UriResourceNavigation;
|
||||||
|
import org.apache.olingo.server.api.uri.UriResourceProperty;
|
||||||
|
import org.apache.olingo.server.api.uri.queryoption.ExpandItem;
|
||||||
|
import org.apache.olingo.server.api.uri.queryoption.ExpandOption;
|
||||||
|
import org.apache.olingo.server.api.uri.queryoption.SelectItem;
|
||||||
|
import org.apache.olingo.server.api.uri.queryoption.SelectOption;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
|
public final class ExpandSelectMock {
|
||||||
|
|
||||||
|
private static UriInfoResource mockResource(final EdmEntitySet edmEntitySet, final String... names) {
|
||||||
|
EdmStructuredType type = edmEntitySet.getEntityType();
|
||||||
|
List<UriResource> elements = new ArrayList<UriResource>();
|
||||||
|
for (final String name : Arrays.asList(names)) {
|
||||||
|
final EdmElement edmElement = type.getProperty(name);
|
||||||
|
if (edmElement.getType().getKind() == EdmTypeKind.ENTITY) {
|
||||||
|
UriResourceNavigation element = Mockito.mock(UriResourceNavigation.class);
|
||||||
|
Mockito.when(element.getProperty()).thenReturn((EdmNavigationProperty) edmElement);
|
||||||
|
elements.add(element);
|
||||||
|
} else {
|
||||||
|
final EdmProperty property = (EdmProperty) edmElement;
|
||||||
|
UriResourceProperty element = Mockito.mock(UriResourceProperty.class);
|
||||||
|
Mockito.when(element.getProperty()).thenReturn(property);
|
||||||
|
elements.add(element);
|
||||||
|
type = property.isPrimitive() ? null : (EdmStructuredType) property.getType();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
UriInfoResource resource = Mockito.mock(UriInfoResource.class);
|
||||||
|
Mockito.when(resource.getUriResourceParts()).thenReturn(elements);
|
||||||
|
return resource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SelectItem mockSelectItem(final EdmEntitySet edmEntitySet, final String... names) {
|
||||||
|
final UriInfoResource resource = mockResource(edmEntitySet, names);
|
||||||
|
SelectItem selectItem = Mockito.mock(SelectItem.class);
|
||||||
|
Mockito.when(selectItem.getResourcePath()).thenReturn(resource);
|
||||||
|
return selectItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SelectOption mockSelectOption(final List<SelectItem> selectItems) {
|
||||||
|
SelectOption select = Mockito.mock(SelectOption.class);
|
||||||
|
Mockito.when(select.getSelectItems()).thenReturn(selectItems);
|
||||||
|
return select;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ExpandItem mockExpandItem(final EdmEntitySet edmEntitySet, final String... names) {
|
||||||
|
final UriInfoResource resource = mockResource(edmEntitySet, names);
|
||||||
|
ExpandItem expandItem = Mockito.mock(ExpandItem.class);
|
||||||
|
Mockito.when(expandItem.getResourcePath()).thenReturn(resource);
|
||||||
|
return expandItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ExpandOption mockExpandOption(final List<ExpandItem> expandItems) {
|
||||||
|
ExpandOption expand = Mockito.mock(ExpandOption.class);
|
||||||
|
Mockito.when(expand.getExpandItems()).thenReturn(expandItems);
|
||||||
|
return expand;
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,9 +20,7 @@ package org.apache.olingo.server.core.serializer.json;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.olingo.commons.api.data.ContextURL;
|
import org.apache.olingo.commons.api.data.ContextURL;
|
||||||
|
@ -31,28 +29,20 @@ import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntitySet;
|
import org.apache.olingo.commons.api.data.EntitySet;
|
||||||
import org.apache.olingo.commons.api.data.ValueType;
|
import org.apache.olingo.commons.api.data.ValueType;
|
||||||
import org.apache.olingo.commons.api.edm.Edm;
|
import org.apache.olingo.commons.api.edm.Edm;
|
||||||
import org.apache.olingo.commons.api.edm.EdmElement;
|
|
||||||
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
|
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
|
||||||
import org.apache.olingo.commons.api.edm.EdmEntitySet;
|
import org.apache.olingo.commons.api.edm.EdmEntitySet;
|
||||||
import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
|
|
||||||
import org.apache.olingo.commons.api.edm.EdmProperty;
|
|
||||||
import org.apache.olingo.commons.api.edm.EdmStructuredType;
|
|
||||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||||
import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
|
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||||
import org.apache.olingo.server.api.OData;
|
import org.apache.olingo.server.api.OData;
|
||||||
import org.apache.olingo.server.api.serializer.ODataSerializer;
|
import org.apache.olingo.server.api.serializer.ODataSerializer;
|
||||||
import org.apache.olingo.server.api.serializer.ODataSerializerException;
|
import org.apache.olingo.server.api.serializer.ODataSerializerException;
|
||||||
import org.apache.olingo.server.api.serializer.ODataSerializerOptions;
|
import org.apache.olingo.server.api.serializer.ODataSerializerOptions;
|
||||||
import org.apache.olingo.server.api.uri.UriInfoResource;
|
|
||||||
import org.apache.olingo.server.api.uri.UriResource;
|
|
||||||
import org.apache.olingo.server.api.uri.UriResourceNavigation;
|
|
||||||
import org.apache.olingo.server.api.uri.UriResourceProperty;
|
|
||||||
import org.apache.olingo.server.api.uri.queryoption.CountOption;
|
import org.apache.olingo.server.api.uri.queryoption.CountOption;
|
||||||
import org.apache.olingo.server.api.uri.queryoption.ExpandItem;
|
import org.apache.olingo.server.api.uri.queryoption.ExpandItem;
|
||||||
import org.apache.olingo.server.api.uri.queryoption.ExpandOption;
|
import org.apache.olingo.server.api.uri.queryoption.ExpandOption;
|
||||||
import org.apache.olingo.server.api.uri.queryoption.SelectItem;
|
import org.apache.olingo.server.api.uri.queryoption.SelectItem;
|
||||||
import org.apache.olingo.server.api.uri.queryoption.SelectOption;
|
import org.apache.olingo.server.api.uri.queryoption.SelectOption;
|
||||||
|
import org.apache.olingo.server.core.serializer.ExpandSelectMock;
|
||||||
import org.apache.olingo.server.tecsvc.data.DataProvider;
|
import org.apache.olingo.server.tecsvc.data.DataProvider;
|
||||||
import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
|
import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
|
||||||
import org.hamcrest.CoreMatchers;
|
import org.hamcrest.CoreMatchers;
|
||||||
|
@ -347,9 +337,10 @@ public class ODataJsonSerializerTest {
|
||||||
public void select() throws Exception {
|
public void select() throws Exception {
|
||||||
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
|
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
|
||||||
final Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
|
final Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
|
||||||
final SelectItem selectItem1 = mockSelectItem(edmEntitySet, "PropertyDate");
|
final SelectItem selectItem1 = ExpandSelectMock.mockSelectItem(edmEntitySet, "PropertyDate");
|
||||||
final SelectItem selectItem2 = mockSelectItem(edmEntitySet, "PropertyBoolean");
|
final SelectItem selectItem2 = ExpandSelectMock.mockSelectItem(edmEntitySet, "PropertyBoolean");
|
||||||
final SelectOption select = mockSelectOption(Arrays.asList(selectItem1, selectItem2, selectItem2));
|
final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(
|
||||||
|
selectItem1, selectItem2, selectItem2));
|
||||||
InputStream result = serializer
|
InputStream result = serializer
|
||||||
.entity(edmEntitySet, entity,
|
.entity(edmEntitySet, entity,
|
||||||
ODataSerializerOptions.with()
|
ODataSerializerOptions.with()
|
||||||
|
@ -369,10 +360,10 @@ public class ODataJsonSerializerTest {
|
||||||
public void selectAll() throws Exception {
|
public void selectAll() throws Exception {
|
||||||
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESTwoPrim");
|
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESTwoPrim");
|
||||||
final Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
|
final Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
|
||||||
final SelectItem selectItem1 = mockSelectItem(edmEntitySet, "PropertyString");
|
final SelectItem selectItem1 = ExpandSelectMock.mockSelectItem(edmEntitySet, "PropertyString");
|
||||||
SelectItem selectItem2 = Mockito.mock(SelectItem.class);
|
SelectItem selectItem2 = Mockito.mock(SelectItem.class);
|
||||||
Mockito.when(selectItem2.isStar()).thenReturn(true);
|
Mockito.when(selectItem2.isStar()).thenReturn(true);
|
||||||
final SelectOption select = mockSelectOption(Arrays.asList(selectItem1, selectItem2));
|
final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(selectItem1, selectItem2));
|
||||||
InputStream result = serializer.entity(edmEntitySet, entity,
|
InputStream result = serializer.entity(edmEntitySet, entity,
|
||||||
ODataSerializerOptions.with()
|
ODataSerializerOptions.with()
|
||||||
.contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build())
|
.contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build())
|
||||||
|
@ -388,8 +379,8 @@ public class ODataJsonSerializerTest {
|
||||||
public void selectComplex() throws Exception {
|
public void selectComplex() throws Exception {
|
||||||
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESCompComp");
|
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESCompComp");
|
||||||
final EntitySet entitySet = data.readAll(edmEntitySet);
|
final EntitySet entitySet = data.readAll(edmEntitySet);
|
||||||
final SelectOption select = mockSelectOption(Arrays.asList(
|
final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(
|
||||||
mockSelectItem(edmEntitySet, "PropertyComp", "PropertyComp", "PropertyString")));
|
ExpandSelectMock.mockSelectItem(edmEntitySet, "PropertyComp", "PropertyComp", "PropertyString")));
|
||||||
InputStream result = serializer
|
InputStream result = serializer
|
||||||
.entitySet(edmEntitySet, entitySet,
|
.entitySet(edmEntitySet, entitySet,
|
||||||
ODataSerializerOptions.with()
|
ODataSerializerOptions.with()
|
||||||
|
@ -411,9 +402,9 @@ public class ODataJsonSerializerTest {
|
||||||
public void selectComplexTwice() throws Exception {
|
public void selectComplexTwice() throws Exception {
|
||||||
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESCompComp");
|
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESCompComp");
|
||||||
final EntitySet entitySet = data.readAll(edmEntitySet);
|
final EntitySet entitySet = data.readAll(edmEntitySet);
|
||||||
final SelectOption select = mockSelectOption(Arrays.asList(
|
final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(
|
||||||
mockSelectItem(edmEntitySet, "PropertyComp", "PropertyComp", "PropertyString"),
|
ExpandSelectMock.mockSelectItem(edmEntitySet, "PropertyComp", "PropertyComp", "PropertyString"),
|
||||||
mockSelectItem(edmEntitySet, "PropertyComp", "PropertyComp")));
|
ExpandSelectMock.mockSelectItem(edmEntitySet, "PropertyComp", "PropertyComp")));
|
||||||
final String resultString = IOUtils.toString(serializer
|
final String resultString = IOUtils.toString(serializer
|
||||||
.entitySet(edmEntitySet, entitySet,
|
.entitySet(edmEntitySet, entitySet,
|
||||||
ODataSerializerOptions.with()
|
ODataSerializerOptions.with()
|
||||||
|
@ -434,8 +425,8 @@ public class ODataJsonSerializerTest {
|
||||||
public void expand() throws Exception {
|
public void expand() throws Exception {
|
||||||
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESTwoPrim");
|
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESTwoPrim");
|
||||||
final Entity entity = data.readAll(edmEntitySet).getEntities().get(3);
|
final Entity entity = data.readAll(edmEntitySet).getEntities().get(3);
|
||||||
final ExpandOption expand = mockExpandOption(Arrays.asList(
|
final ExpandOption expand = ExpandSelectMock.mockExpandOption(Arrays.asList(
|
||||||
mockExpandItem(edmEntitySet, "NavPropertyETAllPrimOne")));
|
ExpandSelectMock.mockExpandItem(edmEntitySet, "NavPropertyETAllPrimOne")));
|
||||||
InputStream result = serializer.entity(edmEntitySet, entity,
|
InputStream result = serializer.entity(edmEntitySet, entity,
|
||||||
ODataSerializerOptions.with()
|
ODataSerializerOptions.with()
|
||||||
.contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build())
|
.contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build())
|
||||||
|
@ -468,11 +459,11 @@ public class ODataJsonSerializerTest {
|
||||||
public void expandSelect() throws Exception {
|
public void expandSelect() throws Exception {
|
||||||
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESTwoPrim");
|
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESTwoPrim");
|
||||||
final Entity entity = data.readAll(edmEntitySet).getEntities().get(3);
|
final Entity entity = data.readAll(edmEntitySet).getEntities().get(3);
|
||||||
final SelectOption select = mockSelectOption(Arrays.asList(
|
final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(
|
||||||
mockSelectItem(entityContainer.getEntitySet("ESAllPrim"), "PropertyDate")));
|
ExpandSelectMock.mockSelectItem(entityContainer.getEntitySet("ESAllPrim"), "PropertyDate")));
|
||||||
ExpandItem expandItem = mockExpandItem(edmEntitySet, "NavPropertyETAllPrimOne");
|
ExpandItem expandItem = ExpandSelectMock.mockExpandItem(edmEntitySet, "NavPropertyETAllPrimOne");
|
||||||
Mockito.when(expandItem.getSelectOption()).thenReturn(select);
|
Mockito.when(expandItem.getSelectOption()).thenReturn(select);
|
||||||
final ExpandOption expand = mockExpandOption(Arrays.asList(expandItem));
|
final ExpandOption expand = ExpandSelectMock.mockExpandOption(Arrays.asList(expandItem));
|
||||||
final String resultString = IOUtils.toString(serializer
|
final String resultString = IOUtils.toString(serializer
|
||||||
.entity(edmEntitySet, entity,
|
.entity(edmEntitySet, entity,
|
||||||
ODataSerializerOptions.with()
|
ODataSerializerOptions.with()
|
||||||
|
@ -492,11 +483,13 @@ public class ODataJsonSerializerTest {
|
||||||
public void expandAll() throws Exception {
|
public void expandAll() throws Exception {
|
||||||
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
|
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
|
||||||
final Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
|
final Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
|
||||||
final ExpandItem expandItem = mockExpandItem(edmEntitySet, "NavPropertyETTwoPrimOne");
|
final ExpandItem expandItem = ExpandSelectMock.mockExpandItem(edmEntitySet, "NavPropertyETTwoPrimOne");
|
||||||
ExpandItem expandItemAll = Mockito.mock(ExpandItem.class);
|
ExpandItem expandItemAll = Mockito.mock(ExpandItem.class);
|
||||||
Mockito.when(expandItemAll.isStar()).thenReturn(true);
|
Mockito.when(expandItemAll.isStar()).thenReturn(true);
|
||||||
final ExpandOption expand = mockExpandOption(Arrays.asList(expandItem, expandItem, expandItemAll));
|
final ExpandOption expand = ExpandSelectMock.mockExpandOption(Arrays.asList(
|
||||||
final SelectOption select = mockSelectOption(Arrays.asList(mockSelectItem(edmEntitySet, "PropertySByte")));
|
expandItem, expandItem, expandItemAll));
|
||||||
|
final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(
|
||||||
|
ExpandSelectMock.mockSelectItem(edmEntitySet, "PropertySByte")));
|
||||||
final String resultString = IOUtils.toString(serializer
|
final String resultString = IOUtils.toString(serializer
|
||||||
.entity(edmEntitySet, entity,
|
.entity(edmEntitySet, entity,
|
||||||
ODataSerializerOptions.with()
|
ODataSerializerOptions.with()
|
||||||
|
@ -520,8 +513,9 @@ public class ODataJsonSerializerTest {
|
||||||
final Entity entity = data.readAll(edmEntitySet).getEntities().get(1);
|
final Entity entity = data.readAll(edmEntitySet).getEntities().get(1);
|
||||||
ExpandItem expandItemAll = Mockito.mock(ExpandItem.class);
|
ExpandItem expandItemAll = Mockito.mock(ExpandItem.class);
|
||||||
Mockito.when(expandItemAll.isStar()).thenReturn(true);
|
Mockito.when(expandItemAll.isStar()).thenReturn(true);
|
||||||
final ExpandOption expand = mockExpandOption(Arrays.asList(expandItemAll));
|
final ExpandOption expand = ExpandSelectMock.mockExpandOption(Arrays.asList(expandItemAll));
|
||||||
final SelectOption select = mockSelectOption(Arrays.asList(mockSelectItem(edmEntitySet, "PropertyTimeOfDay")));
|
final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(
|
||||||
|
ExpandSelectMock.mockSelectItem(edmEntitySet, "PropertyTimeOfDay")));
|
||||||
final String resultString = IOUtils.toString(serializer
|
final String resultString = IOUtils.toString(serializer
|
||||||
.entity(edmEntitySet, entity,
|
.entity(edmEntitySet, entity,
|
||||||
ODataSerializerOptions.with()
|
ODataSerializerOptions.with()
|
||||||
|
@ -545,13 +539,13 @@ public class ODataJsonSerializerTest {
|
||||||
final Entity entity = data.readAll(edmEntitySet).getEntities().get(1);
|
final Entity entity = data.readAll(edmEntitySet).getEntities().get(1);
|
||||||
ExpandItem expandItemSecond = Mockito.mock(ExpandItem.class);
|
ExpandItem expandItemSecond = Mockito.mock(ExpandItem.class);
|
||||||
Mockito.when(expandItemSecond.isStar()).thenReturn(true);
|
Mockito.when(expandItemSecond.isStar()).thenReturn(true);
|
||||||
final ExpandOption expandInner = mockExpandOption(Arrays.asList(expandItemSecond));
|
final ExpandOption expandInner = ExpandSelectMock.mockExpandOption(Arrays.asList(expandItemSecond));
|
||||||
ExpandItem expandItemFirst = mockExpandItem(edmEntitySet, "NavPropertyETAllPrimMany");
|
ExpandItem expandItemFirst = ExpandSelectMock.mockExpandItem(edmEntitySet, "NavPropertyETAllPrimMany");
|
||||||
Mockito.when(expandItemFirst.getExpandOption()).thenReturn(expandInner);
|
Mockito.when(expandItemFirst.getExpandOption()).thenReturn(expandInner);
|
||||||
final SelectOption select = mockSelectOption(Arrays.asList(
|
final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(
|
||||||
mockSelectItem(innerEntitySet, "PropertyInt32")));
|
ExpandSelectMock.mockSelectItem(innerEntitySet, "PropertyInt32")));
|
||||||
Mockito.when(expandItemFirst.getSelectOption()).thenReturn(select);
|
Mockito.when(expandItemFirst.getSelectOption()).thenReturn(select);
|
||||||
final ExpandOption expand = mockExpandOption(Arrays.asList(expandItemFirst));
|
final ExpandOption expand = ExpandSelectMock.mockExpandOption(Arrays.asList(expandItemFirst));
|
||||||
final String resultString = IOUtils.toString(serializer
|
final String resultString = IOUtils.toString(serializer
|
||||||
.entity(edmEntitySet, entity,
|
.entity(edmEntitySet, entity,
|
||||||
ODataSerializerOptions.with()
|
ODataSerializerOptions.with()
|
||||||
|
@ -572,52 +566,4 @@ public class ODataJsonSerializerTest {
|
||||||
+ "{\"PropertyInt16\":32767,\"PropertyString\":\"Test String4\"}]}]}",
|
+ "{\"PropertyInt16\":32767,\"PropertyString\":\"Test String4\"}]}]}",
|
||||||
resultString);
|
resultString);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static UriInfoResource mockResource(final EdmEntitySet edmEntitySet, final String... names) {
|
|
||||||
EdmStructuredType type = edmEntitySet.getEntityType();
|
|
||||||
List<UriResource> elements = new ArrayList<UriResource>();
|
|
||||||
for (final String name : Arrays.asList(names)) {
|
|
||||||
final EdmElement edmElement = type.getProperty(name);
|
|
||||||
if (edmElement.getType().getKind() == EdmTypeKind.ENTITY) {
|
|
||||||
UriResourceNavigation element = Mockito.mock(UriResourceNavigation.class);
|
|
||||||
Mockito.when(element.getProperty()).thenReturn((EdmNavigationProperty) edmElement);
|
|
||||||
elements.add(element);
|
|
||||||
} else {
|
|
||||||
final EdmProperty property = (EdmProperty) edmElement;
|
|
||||||
UriResourceProperty element = Mockito.mock(UriResourceProperty.class);
|
|
||||||
Mockito.when(element.getProperty()).thenReturn(property);
|
|
||||||
elements.add(element);
|
|
||||||
type = property.isPrimitive() ? null : (EdmStructuredType) property.getType();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
UriInfoResource resource = Mockito.mock(UriInfoResource.class);
|
|
||||||
Mockito.when(resource.getUriResourceParts()).thenReturn(elements);
|
|
||||||
return resource;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SelectItem mockSelectItem(final EdmEntitySet edmEntitySet, final String... names) {
|
|
||||||
final UriInfoResource resource = mockResource(edmEntitySet, names);
|
|
||||||
SelectItem selectItem = Mockito.mock(SelectItem.class);
|
|
||||||
Mockito.when(selectItem.getResourcePath()).thenReturn(resource);
|
|
||||||
return selectItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SelectOption mockSelectOption(final List<SelectItem> selectItems) {
|
|
||||||
SelectOption select = Mockito.mock(SelectOption.class);
|
|
||||||
Mockito.when(select.getSelectItems()).thenReturn(selectItems);
|
|
||||||
return select;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ExpandItem mockExpandItem(final EdmEntitySet edmEntitySet, final String... names) {
|
|
||||||
final UriInfoResource resource = mockResource(edmEntitySet, names);
|
|
||||||
ExpandItem expandItem = Mockito.mock(ExpandItem.class);
|
|
||||||
Mockito.when(expandItem.getResourcePath()).thenReturn(resource);
|
|
||||||
return expandItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ExpandOption mockExpandOption(final List<ExpandItem> expandItems) {
|
|
||||||
ExpandOption expand = Mockito.mock(ExpandOption.class);
|
|
||||||
Mockito.when(expand.getExpandItems()).thenReturn(expandItems);
|
|
||||||
return expand;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ import org.apache.olingo.server.api.uri.queryoption.ExpandItem;
|
||||||
import org.apache.olingo.server.api.uri.queryoption.ExpandOption;
|
import org.apache.olingo.server.api.uri.queryoption.ExpandOption;
|
||||||
import org.apache.olingo.server.api.uri.queryoption.SelectItem;
|
import org.apache.olingo.server.api.uri.queryoption.SelectItem;
|
||||||
import org.apache.olingo.server.api.uri.queryoption.SelectOption;
|
import org.apache.olingo.server.api.uri.queryoption.SelectOption;
|
||||||
import org.apache.olingo.server.core.serializer.json.ODataJsonSerializerTest;
|
import org.apache.olingo.server.core.serializer.ExpandSelectMock;
|
||||||
import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
|
import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
@ -46,9 +46,9 @@ public class ContextURLHelperTest {
|
||||||
@Test
|
@Test
|
||||||
public void buildSelect() throws Exception {
|
public void buildSelect() throws Exception {
|
||||||
final EdmEntitySet entitySet = entityContainer.getEntitySet("ESAllPrim");
|
final EdmEntitySet entitySet = entityContainer.getEntitySet("ESAllPrim");
|
||||||
final SelectItem selectItem1 = ODataJsonSerializerTest.mockSelectItem(entitySet, "PropertyString");
|
final SelectItem selectItem1 = ExpandSelectMock.mockSelectItem(entitySet, "PropertyString");
|
||||||
final SelectItem selectItem2 = ODataJsonSerializerTest.mockSelectItem(entitySet, "PropertyInt16");
|
final SelectItem selectItem2 = ExpandSelectMock.mockSelectItem(entitySet, "PropertyInt16");
|
||||||
final SelectOption select = ODataJsonSerializerTest.mockSelectOption(Arrays.asList(
|
final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(
|
||||||
selectItem1, selectItem2, selectItem2));
|
selectItem1, selectItem2, selectItem2));
|
||||||
final ContextURL contextURL = ContextURL.with().entitySet(entitySet)
|
final ContextURL contextURL = ContextURL.with().entitySet(entitySet)
|
||||||
.selectList(ContextURLHelper.buildSelectList(entitySet.getEntityType(), null, select)).build();
|
.selectList(ContextURLHelper.buildSelectList(entitySet.getEntityType(), null, select)).build();
|
||||||
|
@ -59,10 +59,10 @@ public class ContextURLHelperTest {
|
||||||
@Test
|
@Test
|
||||||
public void buildSelectAll() throws Exception {
|
public void buildSelectAll() throws Exception {
|
||||||
final EdmEntitySet entitySet = entityContainer.getEntitySet("ESAllPrim");
|
final EdmEntitySet entitySet = entityContainer.getEntitySet("ESAllPrim");
|
||||||
final SelectItem selectItem1 = ODataJsonSerializerTest.mockSelectItem(entitySet, "PropertyGuid");
|
final SelectItem selectItem1 = ExpandSelectMock.mockSelectItem(entitySet, "PropertyGuid");
|
||||||
SelectItem selectItem2 = Mockito.mock(SelectItem.class);
|
SelectItem selectItem2 = Mockito.mock(SelectItem.class);
|
||||||
Mockito.when(selectItem2.isStar()).thenReturn(true);
|
Mockito.when(selectItem2.isStar()).thenReturn(true);
|
||||||
final SelectOption select = ODataJsonSerializerTest.mockSelectOption(Arrays.asList(selectItem1, selectItem2));
|
final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(selectItem1, selectItem2));
|
||||||
final ContextURL contextURL = ContextURL.with().entitySet(entitySet)
|
final ContextURL contextURL = ContextURL.with().entitySet(entitySet)
|
||||||
.selectList(ContextURLHelper.buildSelectList(entitySet.getEntityType(), null, select)).build();
|
.selectList(ContextURLHelper.buildSelectList(entitySet.getEntityType(), null, select)).build();
|
||||||
assertEquals("$metadata#ESAllPrim(*)", ContextURLBuilder.create(contextURL).toASCIIString());
|
assertEquals("$metadata#ESAllPrim(*)", ContextURLBuilder.create(contextURL).toASCIIString());
|
||||||
|
@ -71,14 +71,14 @@ public class ContextURLHelperTest {
|
||||||
@Test
|
@Test
|
||||||
public void buildSelectComplex() throws Exception {
|
public void buildSelectComplex() throws Exception {
|
||||||
final EdmEntitySet entitySet = entityContainer.getEntitySet("ESCompMixPrimCollComp");
|
final EdmEntitySet entitySet = entityContainer.getEntitySet("ESCompMixPrimCollComp");
|
||||||
final SelectOption select = ODataJsonSerializerTest.mockSelectOption(Arrays.asList(
|
final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(
|
||||||
ODataJsonSerializerTest.mockSelectItem(entitySet,
|
ExpandSelectMock.mockSelectItem(entitySet,
|
||||||
"PropertyMixedPrimCollComp", "PropertyComp", "PropertyString"),
|
"PropertyMixedPrimCollComp", "PropertyComp", "PropertyString"),
|
||||||
ODataJsonSerializerTest.mockSelectItem(entitySet,
|
ExpandSelectMock.mockSelectItem(entitySet,
|
||||||
"PropertyMixedPrimCollComp", "PropertyComp", "PropertyInt16"),
|
"PropertyMixedPrimCollComp", "PropertyComp", "PropertyInt16"),
|
||||||
ODataJsonSerializerTest.mockSelectItem(entitySet, "PropertyMixedPrimCollComp", "CollPropertyString"),
|
ExpandSelectMock.mockSelectItem(entitySet, "PropertyMixedPrimCollComp", "CollPropertyString"),
|
||||||
ODataJsonSerializerTest.mockSelectItem(entitySet, "PropertyMixedPrimCollComp", "CollPropertyComp"),
|
ExpandSelectMock.mockSelectItem(entitySet, "PropertyMixedPrimCollComp", "CollPropertyComp"),
|
||||||
ODataJsonSerializerTest.mockSelectItem(entitySet, "PropertyInt16")));
|
ExpandSelectMock.mockSelectItem(entitySet, "PropertyInt16")));
|
||||||
final ContextURL contextURL = ContextURL.with().entitySet(entitySet)
|
final ContextURL contextURL = ContextURL.with().entitySet(entitySet)
|
||||||
.selectList(ContextURLHelper.buildSelectList(entitySet.getEntityType(), null, select)).build();
|
.selectList(ContextURLHelper.buildSelectList(entitySet.getEntityType(), null, select)).build();
|
||||||
assertEquals("$metadata#ESCompMixPrimCollComp("
|
assertEquals("$metadata#ESCompMixPrimCollComp("
|
||||||
|
@ -95,7 +95,7 @@ public class ContextURLHelperTest {
|
||||||
final EdmEntitySet entitySet = entityContainer.getEntitySet("ESTwoPrim");
|
final EdmEntitySet entitySet = entityContainer.getEntitySet("ESTwoPrim");
|
||||||
ExpandItem expandItem = Mockito.mock(ExpandItem.class);
|
ExpandItem expandItem = Mockito.mock(ExpandItem.class);
|
||||||
Mockito.when(expandItem.isStar()).thenReturn(true);
|
Mockito.when(expandItem.isStar()).thenReturn(true);
|
||||||
final ExpandOption expand = ODataJsonSerializerTest.mockExpandOption(Arrays.asList(expandItem));
|
final ExpandOption expand = ExpandSelectMock.mockExpandOption(Arrays.asList(expandItem));
|
||||||
final ContextURL contextURL = ContextURL.with().entitySet(entitySet)
|
final ContextURL contextURL = ContextURL.with().entitySet(entitySet)
|
||||||
.selectList(ContextURLHelper.buildSelectList(entitySet.getEntityType(), expand, null)).build();
|
.selectList(ContextURLHelper.buildSelectList(entitySet.getEntityType(), expand, null)).build();
|
||||||
assertEquals("$metadata#ESTwoPrim", ContextURLBuilder.create(contextURL).toASCIIString());
|
assertEquals("$metadata#ESTwoPrim", ContextURLBuilder.create(contextURL).toASCIIString());
|
||||||
|
@ -104,8 +104,8 @@ public class ContextURLHelperTest {
|
||||||
@Test
|
@Test
|
||||||
public void buildExpandNoSelect() throws Exception {
|
public void buildExpandNoSelect() throws Exception {
|
||||||
final EdmEntitySet entitySet = entityContainer.getEntitySet("ESTwoPrim");
|
final EdmEntitySet entitySet = entityContainer.getEntitySet("ESTwoPrim");
|
||||||
final ExpandOption expand = ODataJsonSerializerTest.mockExpandOption(Arrays.asList(
|
final ExpandOption expand = ExpandSelectMock.mockExpandOption(Arrays.asList(
|
||||||
ODataJsonSerializerTest.mockExpandItem(entitySet, "NavPropertyETAllPrimOne")));
|
ExpandSelectMock.mockExpandItem(entitySet, "NavPropertyETAllPrimOne")));
|
||||||
final ContextURL contextURL = ContextURL.with().entitySet(entitySet)
|
final ContextURL contextURL = ContextURL.with().entitySet(entitySet)
|
||||||
.selectList(ContextURLHelper.buildSelectList(entitySet.getEntityType(), expand, null)).build();
|
.selectList(ContextURLHelper.buildSelectList(entitySet.getEntityType(), expand, null)).build();
|
||||||
assertEquals("$metadata#ESTwoPrim", ContextURLBuilder.create(contextURL).toASCIIString());
|
assertEquals("$metadata#ESTwoPrim", ContextURLBuilder.create(contextURL).toASCIIString());
|
||||||
|
@ -114,35 +114,63 @@ public class ContextURLHelperTest {
|
||||||
@Test
|
@Test
|
||||||
public void buildExpandSelect() throws Exception {
|
public void buildExpandSelect() throws Exception {
|
||||||
final EdmEntitySet entitySet = entityContainer.getEntitySet("ESTwoPrim");
|
final EdmEntitySet entitySet = entityContainer.getEntitySet("ESTwoPrim");
|
||||||
final ExpandItem expandItem1 = ODataJsonSerializerTest.mockExpandItem(entitySet, "NavPropertyETAllPrimOne");
|
final ExpandItem expandItem1 = ExpandSelectMock.mockExpandItem(entitySet, "NavPropertyETAllPrimOne");
|
||||||
final EdmEntitySet innerEntitySet = entityContainer.getEntitySet("ESAllPrim");
|
final EdmEntitySet innerEntitySet = entityContainer.getEntitySet("ESAllPrim");
|
||||||
ExpandItem expandItem2 = ODataJsonSerializerTest.mockExpandItem(entitySet, "NavPropertyETAllPrimMany");
|
ExpandItem expandItem2 = ExpandSelectMock.mockExpandItem(entitySet, "NavPropertyETAllPrimMany");
|
||||||
final SelectOption innerSelect = ODataJsonSerializerTest.mockSelectOption(Arrays.asList(
|
final SelectOption innerSelect = ExpandSelectMock.mockSelectOption(Arrays.asList(
|
||||||
ODataJsonSerializerTest.mockSelectItem(innerEntitySet, "PropertyInt32")));
|
ExpandSelectMock.mockSelectItem(innerEntitySet, "PropertyInt32")));
|
||||||
Mockito.when(expandItem2.getSelectOption()).thenReturn(innerSelect);
|
Mockito.when(expandItem2.getSelectOption()).thenReturn(innerSelect);
|
||||||
final ExpandOption expand = ODataJsonSerializerTest.mockExpandOption(Arrays.asList(
|
final ExpandOption expand = ExpandSelectMock.mockExpandOption(Arrays.asList(
|
||||||
expandItem1, expandItem2));
|
expandItem1, expandItem2));
|
||||||
final SelectItem selectItem = ODataJsonSerializerTest.mockSelectItem(entitySet, "PropertyString");
|
final SelectItem selectItem = ExpandSelectMock.mockSelectItem(entitySet, "PropertyString");
|
||||||
final SelectOption select = ODataJsonSerializerTest.mockSelectOption(Arrays.asList(selectItem));
|
final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(selectItem));
|
||||||
final ContextURL contextURL = ContextURL.with().entitySet(entitySet)
|
final ContextURL contextURL = ContextURL.with().entitySet(entitySet)
|
||||||
.selectList(ContextURLHelper.buildSelectList(entitySet.getEntityType(), expand, select)).build();
|
.selectList(ContextURLHelper.buildSelectList(entitySet.getEntityType(), expand, select)).build();
|
||||||
assertEquals("$metadata#ESTwoPrim(PropertyString,NavPropertyETAllPrimMany(PropertyInt32))",
|
assertEquals("$metadata#ESTwoPrim(PropertyString,NavPropertyETAllPrimMany(PropertyInt32))",
|
||||||
ContextURLBuilder.create(contextURL).toASCIIString());
|
ContextURLBuilder.create(contextURL).toASCIIString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void buildExpandTwoLevels() throws Exception {
|
||||||
|
final EdmEntitySet entitySet = entityContainer.getEntitySet("ESTwoPrim");
|
||||||
|
final EdmEntitySet innerEntitySet = entityContainer.getEntitySet("ESAllPrim");
|
||||||
|
final ExpandOption innerExpand = ExpandSelectMock.mockExpandOption(Arrays.asList(
|
||||||
|
ExpandSelectMock.mockExpandItem(innerEntitySet, "NavPropertyETTwoPrimOne")));
|
||||||
|
ExpandItem expandItem = ExpandSelectMock.mockExpandItem(entitySet, "NavPropertyETAllPrimOne");
|
||||||
|
Mockito.when(expandItem.getExpandOption()).thenReturn(innerExpand);
|
||||||
|
final ExpandOption expand = ExpandSelectMock.mockExpandOption(Arrays.asList(expandItem));
|
||||||
|
final ContextURL contextURL = ContextURL.with().entitySet(entitySet)
|
||||||
|
.selectList(ContextURLHelper.buildSelectList(entitySet.getEntityType(), expand, null)).build();
|
||||||
|
assertEquals("$metadata#ESTwoPrim", ContextURLBuilder.create(contextURL).toASCIIString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void buildExpandTwoLevelsInnerAll() throws Exception {
|
||||||
|
final EdmEntitySet entitySet = entityContainer.getEntitySet("ESTwoPrim");
|
||||||
|
ExpandItem expandItemInner = Mockito.mock(ExpandItem.class);
|
||||||
|
Mockito.when(expandItemInner.isStar()).thenReturn(true);
|
||||||
|
final ExpandOption innerExpand = ExpandSelectMock.mockExpandOption(Arrays.asList(expandItemInner));
|
||||||
|
ExpandItem expandItem = ExpandSelectMock.mockExpandItem(entitySet, "NavPropertyETAllPrimOne");
|
||||||
|
Mockito.when(expandItem.getExpandOption()).thenReturn(innerExpand);
|
||||||
|
final ExpandOption expand = ExpandSelectMock.mockExpandOption(Arrays.asList(expandItem));
|
||||||
|
final ContextURL contextURL = ContextURL.with().entitySet(entitySet)
|
||||||
|
.selectList(ContextURLHelper.buildSelectList(entitySet.getEntityType(), expand, null)).build();
|
||||||
|
assertEquals("$metadata#ESTwoPrim", ContextURLBuilder.create(contextURL).toASCIIString());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void buildExpandSelectTwoLevels() throws Exception {
|
public void buildExpandSelectTwoLevels() throws Exception {
|
||||||
final EdmEntitySet entitySet = entityContainer.getEntitySet("ESTwoPrim");
|
final EdmEntitySet entitySet = entityContainer.getEntitySet("ESTwoPrim");
|
||||||
final EdmEntitySet innerEntitySet = entityContainer.getEntitySet("ESAllPrim");
|
final EdmEntitySet innerEntitySet = entityContainer.getEntitySet("ESAllPrim");
|
||||||
ExpandItem expandItemInner = ODataJsonSerializerTest.mockExpandItem(innerEntitySet, "NavPropertyETTwoPrimOne");
|
ExpandItem expandItemInner = ExpandSelectMock.mockExpandItem(innerEntitySet, "NavPropertyETTwoPrimOne");
|
||||||
SelectItem innerSelectItem = Mockito.mock(SelectItem.class);
|
SelectItem innerSelectItem = Mockito.mock(SelectItem.class);
|
||||||
Mockito.when(innerSelectItem.isStar()).thenReturn(true);
|
Mockito.when(innerSelectItem.isStar()).thenReturn(true);
|
||||||
final SelectOption innerSelect = ODataJsonSerializerTest.mockSelectOption(Arrays.asList(innerSelectItem));
|
final SelectOption innerSelect = ExpandSelectMock.mockSelectOption(Arrays.asList(innerSelectItem));
|
||||||
Mockito.when(expandItemInner.getSelectOption()).thenReturn(innerSelect);
|
Mockito.when(expandItemInner.getSelectOption()).thenReturn(innerSelect);
|
||||||
final ExpandOption innerExpand = ODataJsonSerializerTest.mockExpandOption(Arrays.asList(expandItemInner));
|
final ExpandOption innerExpand = ExpandSelectMock.mockExpandOption(Arrays.asList(expandItemInner));
|
||||||
ExpandItem expandItem = ODataJsonSerializerTest.mockExpandItem(entitySet, "NavPropertyETAllPrimOne");
|
ExpandItem expandItem = ExpandSelectMock.mockExpandItem(entitySet, "NavPropertyETAllPrimOne");
|
||||||
Mockito.when(expandItem.getExpandOption()).thenReturn(innerExpand);
|
Mockito.when(expandItem.getExpandOption()).thenReturn(innerExpand);
|
||||||
final ExpandOption expand = ODataJsonSerializerTest.mockExpandOption(Arrays.asList(expandItem));
|
final ExpandOption expand = ExpandSelectMock.mockExpandOption(Arrays.asList(expandItem));
|
||||||
final ContextURL contextURL = ContextURL.with().entitySet(entitySet)
|
final ContextURL contextURL = ContextURL.with().entitySet(entitySet)
|
||||||
.selectList(ContextURLHelper.buildSelectList(entitySet.getEntityType(), expand, null)).build();
|
.selectList(ContextURLHelper.buildSelectList(entitySet.getEntityType(), expand, null)).build();
|
||||||
assertEquals("$metadata#ESTwoPrim(NavPropertyETAllPrimOne(NavPropertyETTwoPrimOne(*)))",
|
assertEquals("$metadata#ESTwoPrim(NavPropertyETAllPrimOne(NavPropertyETTwoPrimOne(*)))",
|
||||||
|
|
Loading…
Reference in New Issue