[OLINGO-456] Removed deprecated classes
This commit is contained in:
parent
188574f5c3
commit
87f0f06a39
|
@ -1,92 +0,0 @@
|
|||
/*
|
||||
* 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.client.core.edm;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.apache.olingo.client.api.edm.xml.EntityContainer;
|
||||
import org.apache.olingo.client.api.edm.xml.EntitySet;
|
||||
import org.apache.olingo.client.api.edm.xml.Schema;
|
||||
import org.apache.olingo.client.core.edm.v3.EdmMetadataImpl;
|
||||
import org.apache.olingo.commons.api.edm.EdmActionImportInfo;
|
||||
import org.apache.olingo.commons.api.edm.EdmEntitySetInfo;
|
||||
import org.apache.olingo.commons.api.edm.EdmFunctionImportInfo;
|
||||
import org.apache.olingo.commons.api.edm.EdmMetadata;
|
||||
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
|
||||
import org.apache.olingo.commons.core.edm.EdmEntitySetInfoImpl;
|
||||
|
||||
public abstract class AbstractEdmMetadataImpl implements EdmMetadata {
|
||||
|
||||
protected final List<? extends Schema> xmlSchemas;
|
||||
|
||||
private List<EdmEntitySetInfo> entitySetInfos;
|
||||
|
||||
protected List<EdmFunctionImportInfo> functionImportInfos;
|
||||
|
||||
protected List<EdmActionImportInfo> actionImportInfos;
|
||||
|
||||
public static EdmMetadata getInstance(final ODataServiceVersion version, final List<Schema> xmlSchemas) {
|
||||
|
||||
return version.compareTo(ODataServiceVersion.V40) < 0
|
||||
? new EdmMetadataImpl(xmlSchemas)
|
||||
: new org.apache.olingo.client.core.edm.v4.EdmMetadataImpl(xmlSchemas);
|
||||
}
|
||||
|
||||
public AbstractEdmMetadataImpl(final List<? extends Schema> xmlSchemas) {
|
||||
this.xmlSchemas = xmlSchemas;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EdmEntitySetInfo> getEntitySetInfos() {
|
||||
synchronized (this) {
|
||||
if (entitySetInfos == null) {
|
||||
entitySetInfos = new ArrayList<EdmEntitySetInfo>();
|
||||
for (Schema schema : xmlSchemas) {
|
||||
for (EntityContainer entityContainer : schema.getEntityContainers()) {
|
||||
for (EntitySet entitySet : entityContainer.getEntitySets()) {
|
||||
entitySetInfos.add(new EdmEntitySetInfoImpl(entityContainer.getName(), entitySet.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return entitySetInfos;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
return EqualsBuilder.reflectionEquals(this, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return HashCodeBuilder.reflectionHashCode(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
|
||||
}
|
||||
}
|
|
@ -96,7 +96,7 @@ public class EdmAnnotationImpl implements EdmAnnotation {
|
|||
EdmAnnotationExpression _expression = null;
|
||||
|
||||
if (exp.isConstant()) {
|
||||
_expression = new EdmConstantAnnotationExpressionImpl(edm, exp.asConstant());
|
||||
_expression = new EdmConstantAnnotationExpressionImpl(exp.asConstant());
|
||||
} else if (annotation.getExpression().isDynamic()) {
|
||||
_expression = getDynamicExpression(exp.asDynamic());
|
||||
}
|
||||
|
|
|
@ -58,7 +58,6 @@ import org.apache.olingo.commons.api.edm.EdmEntityType;
|
|||
import org.apache.olingo.commons.api.edm.EdmEnumType;
|
||||
import org.apache.olingo.commons.api.edm.EdmFunction;
|
||||
import org.apache.olingo.commons.api.edm.EdmSchema;
|
||||
import org.apache.olingo.commons.api.edm.EdmMetadata;
|
||||
import org.apache.olingo.commons.api.edm.EdmTerm;
|
||||
import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
|
@ -74,8 +73,6 @@ public class EdmClientImpl extends AbstractEdm {
|
|||
|
||||
private final Map<String, Schema> xmlSchemaByNamespace;
|
||||
|
||||
private final EdmMetadata serviceMetadata;
|
||||
|
||||
public EdmClientImpl(final ODataServiceVersion version, final Map<String, Schema> xmlSchemas) {
|
||||
this.version = version;
|
||||
|
||||
|
@ -87,13 +84,6 @@ public class EdmClientImpl extends AbstractEdm {
|
|||
this.xmlSchemas.add(schema);
|
||||
}
|
||||
}
|
||||
|
||||
this.serviceMetadata = AbstractEdmMetadataImpl.getInstance(version, this.xmlSchemas);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EdmMetadata createServiceMetadata() {
|
||||
return serviceMetadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,97 +0,0 @@
|
|||
/*
|
||||
* 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.client.core.edm.v3;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.olingo.client.api.edm.xml.CommonFunctionImport;
|
||||
import org.apache.olingo.client.api.edm.xml.EntityContainer;
|
||||
import org.apache.olingo.client.api.edm.xml.Schema;
|
||||
import org.apache.olingo.client.api.edm.xml.v3.FunctionImport;
|
||||
import org.apache.olingo.client.api.v3.UnsupportedInV3Exception;
|
||||
import org.apache.olingo.client.core.edm.AbstractEdmMetadataImpl;
|
||||
import org.apache.olingo.commons.api.edm.EdmActionImportInfo;
|
||||
import org.apache.olingo.commons.api.edm.EdmFunctionImportInfo;
|
||||
import org.apache.olingo.commons.api.edm.EdmSingletonInfo;
|
||||
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
|
||||
import org.apache.olingo.commons.core.edm.EdmActionImportInfoImpl;
|
||||
import org.apache.olingo.commons.core.edm.EdmFunctionImportInfoImpl;
|
||||
|
||||
public class EdmMetadataImpl extends AbstractEdmMetadataImpl {
|
||||
|
||||
private static final ODataServiceVersion SERVICE_VERSION = ODataServiceVersion.V30;
|
||||
|
||||
public EdmMetadataImpl(final List<? extends Schema> xmlSchemas) {
|
||||
super(xmlSchemas);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataServiceVersion getDataServiceVersion() {
|
||||
return SERVICE_VERSION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EdmSingletonInfo> getSingletonInfos() {
|
||||
throw new UnsupportedInV3Exception();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EdmFunctionImportInfo> getFunctionImportInfos() {
|
||||
synchronized (this) {
|
||||
if (functionImportInfos == null) {
|
||||
functionImportInfos = new ArrayList<EdmFunctionImportInfo>();
|
||||
for (Schema schema : xmlSchemas) {
|
||||
for (EntityContainer entityContainer : schema.getEntityContainers()) {
|
||||
for (CommonFunctionImport functionImport : entityContainer.getFunctionImports()) {
|
||||
final FunctionImport _funFunctionImport = (FunctionImport) functionImport;
|
||||
if (FunctionImportUtils.canProxyFunction(_funFunctionImport)) {
|
||||
functionImportInfos.add(
|
||||
new EdmFunctionImportInfoImpl(entityContainer.getName(), functionImport.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return functionImportInfos;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EdmActionImportInfo> getActionImportInfos() {
|
||||
synchronized (this) {
|
||||
if (actionImportInfos == null) {
|
||||
actionImportInfos = new ArrayList<EdmActionImportInfo>();
|
||||
for (Schema schema : xmlSchemas) {
|
||||
for (EntityContainer entityContainer : schema.getEntityContainers()) {
|
||||
for (CommonFunctionImport functionImport : entityContainer.getFunctionImports()) {
|
||||
final FunctionImport _funFunctionImport = (FunctionImport) functionImport;
|
||||
if (!FunctionImportUtils.canProxyFunction(_funFunctionImport)) {
|
||||
actionImportInfos.add(
|
||||
new EdmActionImportInfoImpl(entityContainer.getName(), functionImport.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return actionImportInfos;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,103 +0,0 @@
|
|||
/*
|
||||
* 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.client.core.edm.v4;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.olingo.client.api.edm.xml.CommonFunctionImport;
|
||||
import org.apache.olingo.client.api.edm.xml.Schema;
|
||||
import org.apache.olingo.client.api.edm.xml.v4.ActionImport;
|
||||
import org.apache.olingo.client.api.edm.xml.v4.EntityContainer;
|
||||
import org.apache.olingo.client.api.edm.xml.v4.Singleton;
|
||||
import org.apache.olingo.client.core.edm.AbstractEdmMetadataImpl;
|
||||
import org.apache.olingo.commons.api.edm.EdmActionImportInfo;
|
||||
import org.apache.olingo.commons.api.edm.EdmFunctionImportInfo;
|
||||
import org.apache.olingo.commons.api.edm.EdmSingletonInfo;
|
||||
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
|
||||
import org.apache.olingo.commons.core.edm.EdmActionImportInfoImpl;
|
||||
import org.apache.olingo.commons.core.edm.EdmFunctionImportInfoImpl;
|
||||
import org.apache.olingo.commons.core.edm.EdmSingletonInfoImpl;
|
||||
|
||||
public class EdmMetadataImpl extends AbstractEdmMetadataImpl {
|
||||
|
||||
private static final ODataServiceVersion SERVICE_VERSION = ODataServiceVersion.V40;
|
||||
|
||||
private List<EdmSingletonInfo> singletonInfos;
|
||||
|
||||
public EdmMetadataImpl(final List<Schema> xmlSchemas) {
|
||||
super(xmlSchemas);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataServiceVersion getDataServiceVersion() {
|
||||
return SERVICE_VERSION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EdmSingletonInfo> getSingletonInfos() {
|
||||
synchronized (this) {
|
||||
if (singletonInfos == null) {
|
||||
singletonInfos = new ArrayList<EdmSingletonInfo>();
|
||||
for (Schema schema : xmlSchemas) {
|
||||
final EntityContainer entityContainer = (EntityContainer) schema.getDefaultEntityContainer();
|
||||
for (Singleton singleton : entityContainer.getSingletons()) {
|
||||
singletonInfos.add(new EdmSingletonInfoImpl(entityContainer.getName(), singleton.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return singletonInfos;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EdmFunctionImportInfo> getFunctionImportInfos() {
|
||||
synchronized (this) {
|
||||
if (functionImportInfos == null) {
|
||||
functionImportInfos = new ArrayList<EdmFunctionImportInfo>();
|
||||
for (Schema schema : xmlSchemas) {
|
||||
final EntityContainer entityContainer = (EntityContainer) schema.getDefaultEntityContainer();
|
||||
|
||||
for (CommonFunctionImport functionImport : entityContainer.getFunctionImports()) {
|
||||
functionImportInfos.add(
|
||||
new EdmFunctionImportInfoImpl(entityContainer.getName(), functionImport.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return functionImportInfos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EdmActionImportInfo> getActionImportInfos() {
|
||||
synchronized (this) {
|
||||
if (actionImportInfos == null) {
|
||||
actionImportInfos = new ArrayList<EdmActionImportInfo>();
|
||||
for (Schema schema : xmlSchemas) {
|
||||
final EntityContainer entityContainer = (EntityContainer) schema.getDefaultEntityContainer();
|
||||
for (ActionImport actionImport : entityContainer.getActionImports()) {
|
||||
actionImportInfos.add(new EdmActionImportInfoImpl(entityContainer.getName(), actionImport.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return actionImportInfos;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -26,12 +26,12 @@ import org.apache.olingo.client.api.edm.xml.v4.annotation.ConstantAnnotationExpr
|
|||
import org.apache.olingo.commons.api.Constants;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataEnumValue;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataValue;
|
||||
import org.apache.olingo.commons.api.edm.Edm;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||
import org.apache.olingo.commons.api.edm.annotation.EdmConstantAnnotationExpression;
|
||||
import org.apache.olingo.commons.api.edm.annotation.EdmDynamicAnnotationExpression;
|
||||
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
|
||||
import org.apache.olingo.commons.core.domain.v4.ODataCollectionValueImpl;
|
||||
import org.apache.olingo.commons.core.domain.v4.ODataEnumValueImpl;
|
||||
import org.apache.olingo.commons.core.domain.v4.ODataPrimitiveValueImpl;
|
||||
|
@ -41,7 +41,7 @@ public class EdmConstantAnnotationExpressionImpl implements EdmConstantAnnotatio
|
|||
|
||||
private final ODataValue value;
|
||||
|
||||
public EdmConstantAnnotationExpressionImpl(final Edm edm, final ConstantAnnotationExpression constExprConstruct) {
|
||||
public EdmConstantAnnotationExpressionImpl(final ConstantAnnotationExpression constExprConstruct) {
|
||||
if (constExprConstruct.getType() == ConstantAnnotationExpression.Type.EnumMember) {
|
||||
final List<ODataEnumValue> enumValues = new ArrayList<ODataEnumValue>();
|
||||
String enumTypeName = null;
|
||||
|
@ -97,7 +97,7 @@ public class EdmConstantAnnotationExpressionImpl implements EdmConstantAnnotatio
|
|||
kind = EdmPrimitiveTypeKind.String;
|
||||
}
|
||||
final ODataPrimitiveValueImpl.BuilderImpl primitiveValueBuilder =
|
||||
new ODataPrimitiveValueImpl.BuilderImpl(edm.getServiceMetadata().getDataServiceVersion());
|
||||
new ODataPrimitiveValueImpl.BuilderImpl(ODataServiceVersion.V40);
|
||||
primitiveValueBuilder.setType(kind);
|
||||
try {
|
||||
final EdmPrimitiveType primitiveType = EdmPrimitiveTypeFactory.getInstance(kind);
|
||||
|
|
|
@ -23,13 +23,9 @@ import org.apache.olingo.client.api.edm.xml.EntityType;
|
|||
import org.apache.olingo.client.api.edm.xml.Schema;
|
||||
import org.apache.olingo.client.api.edm.xml.XMLMetadata;
|
||||
import org.apache.olingo.client.api.edm.xml.v3.FunctionImport;
|
||||
import org.apache.olingo.commons.api.http.HttpMethod;
|
||||
import org.apache.olingo.client.api.v3.ODataClient;
|
||||
import org.apache.olingo.client.core.AbstractTest;
|
||||
import org.apache.olingo.commons.api.edm.Edm;
|
||||
import org.apache.olingo.commons.api.edm.EdmAction;
|
||||
import org.apache.olingo.commons.api.edm.EdmActionImport;
|
||||
import org.apache.olingo.commons.api.edm.EdmActionImportInfo;
|
||||
import org.apache.olingo.commons.api.edm.EdmBindingTarget;
|
||||
import org.apache.olingo.commons.api.edm.EdmComplexType;
|
||||
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
|
||||
|
@ -37,11 +33,14 @@ import org.apache.olingo.commons.api.edm.EdmEntitySet;
|
|||
import org.apache.olingo.commons.api.edm.EdmEntityType;
|
||||
import org.apache.olingo.commons.api.edm.EdmFunction;
|
||||
import org.apache.olingo.commons.api.edm.EdmFunctionImport;
|
||||
import org.apache.olingo.commons.api.edm.EdmFunctionImportInfo;
|
||||
import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||
import org.apache.olingo.commons.api.edm.EdmReturnType;
|
||||
import org.apache.olingo.commons.api.edm.EdmSchema;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.commons.api.http.HttpMethod;
|
||||
import org.apache.olingo.client.api.v3.ODataClient;
|
||||
import org.apache.olingo.client.core.AbstractTest;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
|
||||
import org.junit.Test;
|
||||
|
@ -260,10 +259,11 @@ public class MetadataTest extends AbstractTest {
|
|||
final Edm metadata = getClient().getReader().
|
||||
readMetadata(getClass().getResourceAsStream("metadata.xml"));
|
||||
assertNotNull(metadata);
|
||||
final EdmSchema schema = metadata.getSchemas().get(0);
|
||||
|
||||
final Set<String> actionImports = new HashSet<String>();
|
||||
for (EdmActionImportInfo info : metadata.getServiceMetadata().getActionImportInfos()) {
|
||||
actionImports.add(info.getActionImportName());
|
||||
for (EdmAction info : schema.getActions()) {
|
||||
actionImports.add(info.getName());
|
||||
}
|
||||
final Set<String> expectedAI = new HashSet<String>(Arrays.asList(new String[] {
|
||||
"ResetDataSource",
|
||||
|
@ -274,8 +274,8 @@ public class MetadataTest extends AbstractTest {
|
|||
"ResetComputerDetailsSpecifications"}));
|
||||
assertEquals(expectedAI, actionImports);
|
||||
final Set<String> functionImports = new HashSet<String>();
|
||||
for (EdmFunctionImportInfo info : metadata.getServiceMetadata().getFunctionImportInfos()) {
|
||||
functionImports.add(info.getFunctionImportName());
|
||||
for (EdmFunction info : schema.getFunctions()) {
|
||||
functionImports.add(info.getName());
|
||||
}
|
||||
final Set<String> expectedFI = new HashSet<String>(Arrays.asList(new String[] {
|
||||
"GetPrimitiveString",
|
||||
|
|
|
@ -55,7 +55,6 @@ import org.apache.olingo.commons.api.edm.EdmEntityType;
|
|||
import org.apache.olingo.commons.api.edm.EdmEnumType;
|
||||
import org.apache.olingo.commons.api.edm.EdmFunction;
|
||||
import org.apache.olingo.commons.api.edm.EdmFunctionImport;
|
||||
import org.apache.olingo.commons.api.edm.EdmFunctionImportInfo;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||
import org.apache.olingo.commons.api.edm.EdmSchema;
|
||||
import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
|
||||
|
@ -68,6 +67,8 @@ import org.apache.olingo.commons.core.edm.primitivetype.EdmInt32;
|
|||
import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MetadataTest extends AbstractTest {
|
||||
|
||||
@Override
|
||||
|
@ -240,24 +241,29 @@ public class MetadataTest extends AbstractTest {
|
|||
final Edm edm = getClient().getReader().readMetadata(getClass().getResourceAsStream("fromdoc1-metadata.xml"));
|
||||
assertNotNull(edm);
|
||||
|
||||
final EdmFunctionImportInfo fiInfo = edm.getServiceMetadata().getFunctionImportInfos().get(0);
|
||||
final EdmEntityContainer demoService = edm.getEntityContainer(
|
||||
new FullQualifiedName(metadata.getSchema(0).getNamespace(), fiInfo.getEntityContainerName()));
|
||||
assertNotNull(demoService);
|
||||
final EdmFunctionImport fi = demoService.getFunctionImport(fiInfo.getFunctionImportName());
|
||||
assertNotNull(fi);
|
||||
assertEquals(demoService.getEntitySet("Products"), fi.getReturnedEntitySet());
|
||||
List<EdmSchema> schemaList = edm.getSchemas();
|
||||
assertNotNull(schemaList);
|
||||
assertEquals(1, schemaList.size());
|
||||
EdmSchema schema = schemaList.get(0);
|
||||
|
||||
final EdmFunction function = edm.getUnboundFunction(
|
||||
new FullQualifiedName(metadata.getSchema(0).getNamespace(), "ProductsByRating"), null);
|
||||
assertNotNull(function);
|
||||
assertEquals(function.getName(), fi.getUnboundFunction(null).getName());
|
||||
assertEquals(function.getNamespace(), fi.getUnboundFunction(null).getNamespace());
|
||||
assertEquals(function.getParameterNames(), fi.getUnboundFunction(null).getParameterNames());
|
||||
assertEquals(function.getReturnType().getType().getName(),
|
||||
fi.getUnboundFunction(null).getReturnType().getType().getName());
|
||||
assertEquals(function.getReturnType().getType().getNamespace(),
|
||||
fi.getUnboundFunction(null).getReturnType().getType().getNamespace());
|
||||
EdmEntityContainer demoService = schema.getEntityContainer();
|
||||
assertNotNull(demoService);
|
||||
for (EdmFunction function : schema.getFunctions()) {
|
||||
final EdmFunctionImport fi = demoService.getFunctionImport(function.getName());
|
||||
assertNotNull(fi);
|
||||
assertEquals(demoService.getEntitySet("Products"), fi.getReturnedEntitySet());
|
||||
|
||||
final EdmFunction edmFunction = edm.getUnboundFunction(
|
||||
new FullQualifiedName(metadata.getSchema(0).getNamespace(), "ProductsByRating"), null);
|
||||
assertNotNull(edmFunction);
|
||||
assertEquals(edmFunction.getName(), fi.getUnboundFunction(null).getName());
|
||||
assertEquals(edmFunction.getNamespace(), fi.getUnboundFunction(null).getNamespace());
|
||||
assertEquals(edmFunction.getParameterNames(), fi.getUnboundFunction(null).getParameterNames());
|
||||
assertEquals(edmFunction.getReturnType().getType().getName(),
|
||||
fi.getUnboundFunction(null).getReturnType().getType().getName());
|
||||
assertEquals(edmFunction.getReturnType().getType().getNamespace(),
|
||||
fi.getUnboundFunction(null).getReturnType().getType().getNamespace());
|
||||
}
|
||||
|
||||
final EdmTypeDefinition weight = edm.getTypeDefinition(new FullQualifiedName("ODataDemo", "Weight"));
|
||||
assertNotNull(weight);
|
||||
|
|
|
@ -172,13 +172,4 @@ public interface Edm {
|
|||
* @return {@link EdmAnnotation}
|
||||
*/
|
||||
EdmAnnotation getAnnotation(FullQualifiedName annotatableName, EdmTerm term);
|
||||
|
||||
/**
|
||||
* Get service metadata.
|
||||
* <br/>
|
||||
* See {@link EdmMetadata} for more information.
|
||||
*
|
||||
* @return {@link EdmMetadata}
|
||||
*/
|
||||
EdmMetadata getServiceMetadata();
|
||||
}
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
/*
|
||||
* 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.commons.api.edm;
|
||||
|
||||
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This interface gives an info list of all
|
||||
* entity sets, singletons, and function imports inside the EntityDataModel.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface EdmMetadata {
|
||||
|
||||
/**
|
||||
* @return a list of {@link EdmEntitySetInfo} objects inside the data model
|
||||
*/
|
||||
List<EdmEntitySetInfo> getEntitySetInfos();
|
||||
|
||||
/**
|
||||
* @return a list of {@link EdmSingletonInfo} objects inside the data model
|
||||
*/
|
||||
List<EdmSingletonInfo> getSingletonInfos();
|
||||
|
||||
/**
|
||||
* @return a list of {@link EdmActionImportInfo} objects inside the data model
|
||||
*/
|
||||
List<EdmActionImportInfo> getActionImportInfos();
|
||||
|
||||
/**
|
||||
* @return a list of {@link EdmFunctionImportInfo} objects inside the data model
|
||||
*/
|
||||
List<EdmFunctionImportInfo> getFunctionImportInfos();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
ODataServiceVersion getDataServiceVersion();
|
||||
}
|
|
@ -28,7 +28,6 @@ import org.apache.olingo.commons.api.edm.EdmEntityType;
|
|||
import org.apache.olingo.commons.api.edm.EdmEnumType;
|
||||
import org.apache.olingo.commons.api.edm.EdmFunction;
|
||||
import org.apache.olingo.commons.api.edm.EdmSchema;
|
||||
import org.apache.olingo.commons.api.edm.EdmMetadata;
|
||||
import org.apache.olingo.commons.api.edm.EdmTerm;
|
||||
import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
|
@ -76,8 +75,6 @@ public abstract class AbstractEdm implements Edm {
|
|||
private final Map<FullQualifiedName, List<EdmAnnotation>> annotations =
|
||||
new HashMap<FullQualifiedName, List<EdmAnnotation>>();
|
||||
|
||||
private EdmMetadata serviceMetadata;
|
||||
|
||||
private Map<String, String> aliasToNamespaceInfo;
|
||||
|
||||
@Override
|
||||
|
@ -402,14 +399,6 @@ public abstract class AbstractEdm implements Edm {
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EdmMetadata getServiceMetadata() {
|
||||
if (serviceMetadata == null) {
|
||||
serviceMetadata = createServiceMetadata();
|
||||
}
|
||||
return serviceMetadata;
|
||||
}
|
||||
|
||||
private FullQualifiedName resolvePossibleAlias(final FullQualifiedName namespaceOrAliasFQN) {
|
||||
if (aliasToNamespaceInfo == null) {
|
||||
aliasToNamespaceInfo = createAliasToNamespaceInfo();
|
||||
|
@ -455,8 +444,6 @@ public abstract class AbstractEdm implements Edm {
|
|||
FullQualifiedName bindingParameterTypeName, Boolean isBindingParameterCollection,
|
||||
List<String> parameterNames);
|
||||
|
||||
protected abstract EdmMetadata createServiceMetadata();
|
||||
|
||||
protected abstract EdmTerm createTerm(FullQualifiedName termName);
|
||||
|
||||
protected abstract EdmAnnotations createAnnotationGroup(FullQualifiedName targetName);
|
||||
|
|
|
@ -29,7 +29,6 @@ import org.apache.olingo.commons.api.edm.EdmEntityType;
|
|||
import org.apache.olingo.commons.api.edm.EdmEnumType;
|
||||
import org.apache.olingo.commons.api.edm.EdmFunction;
|
||||
import org.apache.olingo.commons.api.edm.EdmSchema;
|
||||
import org.apache.olingo.commons.api.edm.EdmMetadata;
|
||||
import org.apache.olingo.commons.api.edm.EdmTerm;
|
||||
import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
|
@ -249,15 +248,6 @@ public class EdmImplCachingTest {
|
|||
assertNotSame(function, function2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cacheServiceMetadata() {
|
||||
EdmMetadata serviceMetadata = edm.getServiceMetadata();
|
||||
EdmMetadata cachedMetadata = edm.getServiceMetadata();
|
||||
|
||||
assertTrue(serviceMetadata == cachedMetadata);
|
||||
assertEquals(serviceMetadata, cachedMetadata);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
edm = new LocalEdm();
|
||||
|
@ -360,11 +350,6 @@ public class EdmImplCachingTest {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EdmMetadata createServiceMetadata() {
|
||||
return mock(EdmMetadata.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, String> createAliasToNamespaceInfo() {
|
||||
return new HashMap<String, String>();
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.apache.olingo.commons.api.edm.EdmEntityType;
|
|||
import org.apache.olingo.commons.api.edm.EdmEnumType;
|
||||
import org.apache.olingo.commons.api.edm.EdmFunction;
|
||||
import org.apache.olingo.commons.api.edm.EdmSchema;
|
||||
import org.apache.olingo.commons.api.edm.EdmMetadata;
|
||||
import org.apache.olingo.commons.api.edm.EdmTerm;
|
||||
import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
|
@ -151,11 +150,6 @@ public class EdmImplCallCreateTest {
|
|||
assertNull(edm.getUnboundFunction(WRONG_FQN, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void callCreateServiceMetadata() {
|
||||
assertNotNull(edm.getServiceMetadata());
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
edm = new LocalEdm();
|
||||
|
@ -243,11 +237,6 @@ public class EdmImplCallCreateTest {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EdmMetadata createServiceMetadata() {
|
||||
return mock(EdmMetadata.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, String> createAliasToNamespaceInfo() {
|
||||
return new HashMap<String, String>();
|
||||
|
|
|
@ -1,173 +0,0 @@
|
|||
/*
|
||||
* 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.edm.provider;
|
||||
|
||||
import org.apache.olingo.commons.api.ODataException;
|
||||
import org.apache.olingo.commons.api.edm.*;
|
||||
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
|
||||
import org.apache.olingo.commons.core.edm.EdmActionImportInfoImpl;
|
||||
import org.apache.olingo.commons.core.edm.EdmEntitySetInfoImpl;
|
||||
import org.apache.olingo.commons.core.edm.EdmFunctionImportInfoImpl;
|
||||
import org.apache.olingo.commons.core.edm.EdmSingletonInfoImpl;
|
||||
import org.apache.olingo.server.api.edm.provider.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class EdmMetadataImpl implements EdmMetadata {
|
||||
|
||||
private EdmProvider provider;
|
||||
|
||||
private List<Schema> schemas;
|
||||
|
||||
private List<EdmEntitySetInfo> entitySetInfos;
|
||||
|
||||
private List<EdmSingletonInfo> singletonInfos;
|
||||
|
||||
private List<EdmActionImportInfo> actionImportInfos;
|
||||
|
||||
private List<EdmFunctionImportInfo> functionImportInfos;
|
||||
|
||||
public EdmMetadataImpl(final EdmProvider provider) {
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EdmEntitySetInfo> getEntitySetInfos() {
|
||||
if (entitySetInfos == null) {
|
||||
try {
|
||||
entitySetInfos = new ArrayList<EdmEntitySetInfo>();
|
||||
if (schemas == null) {
|
||||
schemas = provider.getSchemas();
|
||||
if (schemas == null) {
|
||||
throw new EdmException("Provider doe not define any schemas.");
|
||||
}
|
||||
}
|
||||
for (Schema schema : schemas) {
|
||||
final EntityContainer entityContainer = schema.getEntityContainer();
|
||||
if (entityContainer != null) {
|
||||
final List<EntitySet> entitySets = entityContainer.getEntitySets();
|
||||
if (entitySets != null) {
|
||||
for (EntitySet set : entitySets) {
|
||||
entitySetInfos.add(new EdmEntitySetInfoImpl(entityContainer.getName(), set.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (ODataException e) {
|
||||
throw new EdmException(e);
|
||||
}
|
||||
}
|
||||
return entitySetInfos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EdmSingletonInfo> getSingletonInfos() {
|
||||
if (singletonInfos == null) {
|
||||
try {
|
||||
singletonInfos = new ArrayList<EdmSingletonInfo>();
|
||||
if (schemas == null) {
|
||||
schemas = provider.getSchemas();
|
||||
if (schemas == null) {
|
||||
throw new EdmException("Provider doe not define any schemas.");
|
||||
}
|
||||
}
|
||||
for (Schema schema : schemas) {
|
||||
final EntityContainer entityContainer = schema.getEntityContainer();
|
||||
if (entityContainer != null) {
|
||||
final List<Singleton> singletons = entityContainer.getSingletons();
|
||||
if (singletons != null) {
|
||||
for (Singleton singleton : singletons) {
|
||||
singletonInfos.add(new EdmSingletonInfoImpl(entityContainer.getName(), singleton.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (ODataException e) {
|
||||
throw new EdmException(e);
|
||||
}
|
||||
}
|
||||
return singletonInfos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EdmActionImportInfo> getActionImportInfos() {
|
||||
if (actionImportInfos == null) {
|
||||
try {
|
||||
actionImportInfos = new ArrayList<EdmActionImportInfo>();
|
||||
if (schemas == null) {
|
||||
schemas = provider.getSchemas();
|
||||
if (schemas == null) {
|
||||
throw new EdmException("Provider doe not define any schemas.");
|
||||
}
|
||||
}
|
||||
for (Schema schema : schemas) {
|
||||
final EntityContainer entityContainer = schema.getEntityContainer();
|
||||
if (entityContainer != null) {
|
||||
final List<ActionImport> actionImports = entityContainer.getActionImports();
|
||||
if (actionImports != null) {
|
||||
for (ActionImport actionImport : actionImports) {
|
||||
actionImportInfos.add(new EdmActionImportInfoImpl(entityContainer.getName(), actionImport.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (ODataException e) {
|
||||
throw new EdmException(e);
|
||||
}
|
||||
}
|
||||
return actionImportInfos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EdmFunctionImportInfo> getFunctionImportInfos() {
|
||||
if (functionImportInfos == null) {
|
||||
try {
|
||||
functionImportInfos = new ArrayList<EdmFunctionImportInfo>();
|
||||
if (schemas == null) {
|
||||
schemas = provider.getSchemas();
|
||||
if (schemas == null) {
|
||||
throw new EdmException("Provider doe not define any schemas.");
|
||||
}
|
||||
}
|
||||
for (Schema schema : schemas) {
|
||||
final EntityContainer entityContainer = schema.getEntityContainer();
|
||||
if (entityContainer != null) {
|
||||
final List<FunctionImport> functionImports = entityContainer.getFunctionImports();
|
||||
if (functionImports != null) {
|
||||
for (FunctionImport functionImport : functionImports) {
|
||||
functionImportInfos.add(
|
||||
new EdmFunctionImportInfoImpl(entityContainer.getName(), functionImport.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (ODataException e) {
|
||||
throw new EdmException(e);
|
||||
}
|
||||
}
|
||||
return functionImportInfos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataServiceVersion getDataServiceVersion() {
|
||||
return ODataServiceVersion.V40;
|
||||
}
|
||||
|
||||
}
|
|
@ -29,7 +29,6 @@ import org.apache.olingo.commons.api.edm.EdmEnumType;
|
|||
import org.apache.olingo.commons.api.edm.EdmException;
|
||||
import org.apache.olingo.commons.api.edm.EdmFunction;
|
||||
import org.apache.olingo.commons.api.edm.EdmSchema;
|
||||
import org.apache.olingo.commons.api.edm.EdmMetadata;
|
||||
import org.apache.olingo.commons.api.edm.EdmTerm;
|
||||
import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
|
@ -209,11 +208,6 @@ public class EdmProviderImpl extends AbstractEdm {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EdmMetadata createServiceMetadata() {
|
||||
return new EdmMetadataImpl(provider);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, String> createAliasToNamespaceInfo() {
|
||||
final Map<String, String> aliasToNamespaceInfos = new HashMap<String, String>();
|
||||
|
|
|
@ -1,182 +0,0 @@
|
|||
/*
|
||||
* 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.edm.provider;
|
||||
|
||||
import org.apache.olingo.commons.api.ODataException;
|
||||
import org.apache.olingo.commons.api.edm.EdmEntitySetInfo;
|
||||
import org.apache.olingo.commons.api.edm.EdmException;
|
||||
import org.apache.olingo.commons.api.edm.EdmFunctionImportInfo;
|
||||
import org.apache.olingo.commons.api.edm.EdmMetadata;
|
||||
import org.apache.olingo.commons.api.edm.EdmSingletonInfo;
|
||||
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
|
||||
import org.apache.olingo.server.api.edm.provider.EdmProvider;
|
||||
import org.apache.olingo.server.api.edm.provider.EntityContainer;
|
||||
import org.apache.olingo.server.api.edm.provider.EntitySet;
|
||||
import org.apache.olingo.server.api.edm.provider.FunctionImport;
|
||||
import org.apache.olingo.server.api.edm.provider.Schema;
|
||||
import org.apache.olingo.server.api.edm.provider.Singleton;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class EdmMetadataImplTest {
|
||||
|
||||
@Test
|
||||
public void allGettersMustDeliver() {
|
||||
EdmMetadata serviceMetadata = new EdmMetadataImpl(new CustomProvider(true));
|
||||
List<EdmEntitySetInfo> entitySetInfos = serviceMetadata.getEntitySetInfos();
|
||||
assertNotNull(entitySetInfos);
|
||||
assertEquals(2, entitySetInfos.size());
|
||||
|
||||
List<EdmSingletonInfo> singletonInfos = serviceMetadata.getSingletonInfos();
|
||||
assertNotNull(singletonInfos);
|
||||
assertEquals(2, singletonInfos.size());
|
||||
|
||||
List<EdmFunctionImportInfo> functionImportInfos = serviceMetadata.getFunctionImportInfos();
|
||||
assertNotNull(functionImportInfos);
|
||||
assertEquals(2, functionImportInfos.size());
|
||||
|
||||
// Cache test
|
||||
assertTrue(entitySetInfos == serviceMetadata.getEntitySetInfos());
|
||||
assertTrue(singletonInfos == serviceMetadata.getSingletonInfos());
|
||||
assertTrue(functionImportInfos == serviceMetadata.getFunctionImportInfos());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initialProvider() {
|
||||
EdmProvider provider = new EdmProvider() {};
|
||||
EdmMetadata serviceMetadata = new EdmMetadataImpl(provider);
|
||||
assertEquals(ODataServiceVersion.V40, serviceMetadata.getDataServiceVersion());
|
||||
}
|
||||
|
||||
@Test(expected = EdmException.class)
|
||||
public void initialProviderEntitySetInfo() {
|
||||
EdmProvider provider = new EdmProvider() {};
|
||||
EdmMetadata serviceMetadata = new EdmMetadataImpl(provider);
|
||||
serviceMetadata.getEntitySetInfos();
|
||||
}
|
||||
|
||||
@Test(expected = EdmException.class)
|
||||
public void initialProviderSingletonInfo() {
|
||||
EdmProvider provider = new EdmProvider() {};
|
||||
EdmMetadata serviceMetadata = new EdmMetadataImpl(provider);
|
||||
serviceMetadata.getSingletonInfos();
|
||||
}
|
||||
|
||||
@Test(expected = EdmException.class)
|
||||
public void initialProviderFunctionImportInfo() {
|
||||
EdmProvider provider = new EdmProvider() {};
|
||||
EdmMetadata serviceMetadata = new EdmMetadataImpl(provider);
|
||||
serviceMetadata.getFunctionImportInfos();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void emptySchemaMustNotResultInException() {
|
||||
EdmMetadata serviceMetadata = new EdmMetadataImpl(new CustomProvider(false));
|
||||
assertNotNull(serviceMetadata.getEntitySetInfos());
|
||||
assertEquals(0, serviceMetadata.getEntitySetInfos().size());
|
||||
|
||||
assertNotNull(serviceMetadata.getSingletonInfos());
|
||||
assertEquals(0, serviceMetadata.getSingletonInfos().size());
|
||||
|
||||
assertNotNull(serviceMetadata.getFunctionImportInfos());
|
||||
assertEquals(0, serviceMetadata.getFunctionImportInfos().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void oDataExceptionsGetCaughtAndTransformed() {
|
||||
EdmProvider provider = new EdmProvider() {
|
||||
@Override
|
||||
public List<Schema> getSchemas() throws ODataException {
|
||||
throw new ODataException("msg");
|
||||
}
|
||||
};
|
||||
|
||||
EdmMetadata serviceMetadata = new EdmMetadataImpl(provider);
|
||||
callGetEntitySetInfosAndExpectException(serviceMetadata);
|
||||
callGetSingletonInfosAndExpectException(serviceMetadata);
|
||||
callGetFunctionImportInfosAndExpectException(serviceMetadata);
|
||||
}
|
||||
|
||||
private void callGetFunctionImportInfosAndExpectException(final EdmMetadata svc) {
|
||||
try {
|
||||
svc.getFunctionImportInfos();
|
||||
} catch (EdmException e) {
|
||||
assertEquals("org.apache.olingo.commons.api.ODataException: msg", e.getMessage());
|
||||
return;
|
||||
}
|
||||
fail("Expected EdmException was not thrown");
|
||||
|
||||
}
|
||||
|
||||
private void callGetSingletonInfosAndExpectException(final EdmMetadata svc) {
|
||||
try {
|
||||
svc.getSingletonInfos();
|
||||
} catch (EdmException e) {
|
||||
assertEquals("org.apache.olingo.commons.api.ODataException: msg", e.getMessage());
|
||||
return;
|
||||
}
|
||||
fail("Expected EdmException was not thrown");
|
||||
}
|
||||
|
||||
private void callGetEntitySetInfosAndExpectException(final EdmMetadata svc) {
|
||||
try {
|
||||
svc.getEntitySetInfos();
|
||||
} catch (EdmException e) {
|
||||
assertEquals("org.apache.olingo.commons.api.ODataException: msg", e.getMessage());
|
||||
return;
|
||||
}
|
||||
fail("Expected EdmException was not thrown");
|
||||
}
|
||||
|
||||
private class CustomProvider extends EdmProvider {
|
||||
private List<Schema> schemas;
|
||||
|
||||
public CustomProvider(final boolean fillSchema) {
|
||||
schemas = new ArrayList<Schema>();
|
||||
if (fillSchema) {
|
||||
List<EntitySet> entitySets = new ArrayList<EntitySet>();
|
||||
entitySets.add(new EntitySet().setName("1"));
|
||||
entitySets.add(new EntitySet().setName("2"));
|
||||
List<Singleton> singletons = new ArrayList<Singleton>();
|
||||
singletons.add(new Singleton().setName("1"));
|
||||
singletons.add(new Singleton().setName("2"));
|
||||
List<FunctionImport> functionImports = new ArrayList<FunctionImport>();
|
||||
functionImports.add(new FunctionImport().setName("1"));
|
||||
functionImports.add(new FunctionImport().setName("2"));
|
||||
EntityContainer entityContainer =
|
||||
new EntityContainer().setName("cont").setEntitySets(entitySets).setSingletons(singletons)
|
||||
.setFunctionImports(functionImports);
|
||||
Schema schema = new Schema().setEntityContainer(entityContainer);
|
||||
schemas.add(schema);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Schema> getSchemas() throws ODataException {
|
||||
return schemas;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -98,7 +98,6 @@ public class EdmProviderImplTest {
|
|||
localEdm.getEntityType(FQN);
|
||||
localEdm.getEnumType(FQN);
|
||||
localEdm.getTypeDefinition(FQN);
|
||||
localEdm.getServiceMetadata();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -222,10 +221,4 @@ public class EdmProviderImplTest {
|
|||
|
||||
assertNull(edm.getComplexType(WRONG_FQN));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getServiceMetadata() {
|
||||
assertNotNull(edm.getServiceMetadata());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue