[OLINGO-595] Make EdmProvider an Interface

This commit is contained in:
Christian Amend 2015-03-31 13:47:15 +02:00
parent 92e201b0a8
commit d94edf568c
9 changed files with 173 additions and 88 deletions

View File

@ -24,13 +24,13 @@ import java.util.Map;
import org.apache.olingo.commons.api.ODataException;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.provider.AbstractEdmProvider;
import org.apache.olingo.commons.api.edm.provider.Action;
import org.apache.olingo.commons.api.edm.provider.ActionImport;
import org.apache.olingo.commons.api.edm.provider.AliasInfo;
import org.apache.olingo.commons.api.edm.provider.Annotatable;
import org.apache.olingo.commons.api.edm.provider.Annotations;
import org.apache.olingo.commons.api.edm.provider.ComplexType;
import org.apache.olingo.commons.api.edm.provider.EdmProvider;
import org.apache.olingo.commons.api.edm.provider.EntityContainer;
import org.apache.olingo.commons.api.edm.provider.EntityContainerInfo;
import org.apache.olingo.commons.api.edm.provider.EntitySet;
@ -43,7 +43,7 @@ import org.apache.olingo.commons.api.edm.provider.Singleton;
import org.apache.olingo.commons.api.edm.provider.Term;
import org.apache.olingo.commons.api.edm.provider.TypeDefinition;
public class ClientEdmProvider extends EdmProvider {
public class ClientEdmProvider extends AbstractEdmProvider {
private final Map<String, Schema> xmlSchemas;

View File

@ -0,0 +1,116 @@
/*
* 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.provider;
import java.util.List;
import org.apache.olingo.commons.api.ODataException;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
public abstract class AbstractEdmProvider implements EdmProvider {
@Override
public EnumType getEnumType(final FullQualifiedName enumTypeName) throws ODataException {
return null;
}
@Override
public TypeDefinition getTypeDefinition(final FullQualifiedName typeDefinitionName) throws ODataException {
return null;
}
@Override
public EntityType getEntityType(final FullQualifiedName entityTypeName) throws ODataException {
return null;
}
@Override
public ComplexType getComplexType(final FullQualifiedName complexTypeName) throws ODataException {
return null;
}
@Override
public List<Action> getActions(final FullQualifiedName actionName) throws ODataException {
return null;
}
@Override
public List<Function> getFunctions(final FullQualifiedName functionName) throws ODataException {
return null;
}
@Override
public Term getTerm(final FullQualifiedName termName) throws ODataException {
return null;
}
@Override
public EntitySet getEntitySet(final FullQualifiedName entityContainer, final String entitySetName)
throws ODataException {
return null;
}
@Override
public Singleton getSingleton(final FullQualifiedName entityContainer, final String singletonName)
throws ODataException {
return null;
}
@Override
public ActionImport getActionImport(final FullQualifiedName entityContainer, final String actionImportName)
throws ODataException {
return null;
}
@Override
public FunctionImport getFunctionImport(final FullQualifiedName entityContainer, final String functionImportName)
throws ODataException {
return null;
}
@Override
public EntityContainerInfo getEntityContainerInfo(final FullQualifiedName entityContainerName) throws ODataException {
return null;
}
@Override
public List<AliasInfo> getAliasInfos() throws ODataException {
return null;
}
@Override
public List<Schema> getSchemas() throws ODataException {
return null;
}
@Override
public EntityContainer getEntityContainer() throws ODataException {
return null;
}
@Override
public Annotations getAnnotationsGroup(FullQualifiedName targetName) throws ODataException {
return null;
}
@Override
public Annotatable getAnnoatatable(FullQualifiedName annotatedName) throws ODataException {
return null;
}
}

View File

@ -23,7 +23,7 @@ import java.util.List;
import org.apache.olingo.commons.api.ODataException;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
public abstract class EdmProvider {
public interface EdmProvider {
/**
* This method should return an {@link EnumType} or <b>null</b> if nothing is found
@ -32,9 +32,7 @@ public abstract class EdmProvider {
* @return {@link EnumType} for given name
* @throws ODataException
*/
public EnumType getEnumType(final FullQualifiedName enumTypeName) throws ODataException {
return null;
}
public EnumType getEnumType(final FullQualifiedName enumTypeName) throws ODataException;
/**
* This method should return an {@link TypeDefinition} or <b>null</b> if nothing is found
@ -43,9 +41,7 @@ public abstract class EdmProvider {
* @return {@link TypeDefinition} for given name
* @throws ODataException
*/
public TypeDefinition getTypeDefinition(final FullQualifiedName typeDefinitionName) throws ODataException {
return null;
}
public TypeDefinition getTypeDefinition(final FullQualifiedName typeDefinitionName) throws ODataException;
/**
* This method should return an {@link EntityType} or <b>null</b> if nothing is found
@ -54,9 +50,7 @@ public abstract class EdmProvider {
* @return {@link EntityType} for the given name
* @throws ODataException
*/
public EntityType getEntityType(final FullQualifiedName entityTypeName) throws ODataException {
return null;
}
public EntityType getEntityType(final FullQualifiedName entityTypeName) throws ODataException;
/**
* This method should return a {@link ComplexType} or <b>null</b> if nothing is found.
@ -65,9 +59,7 @@ public abstract class EdmProvider {
* @return {@link ComplexType} for the given name
* @throws ODataException
*/
public ComplexType getComplexType(final FullQualifiedName complexTypeName) throws ODataException {
return null;
}
public ComplexType getComplexType(final FullQualifiedName complexTypeName) throws ODataException;
/**
* This method should return a list of all {@link Action} for the FullQualifiedname or <b>null</b> if nothing is found
@ -76,9 +68,7 @@ public abstract class EdmProvider {
* @return List of {@link Action} or null
* @throws ODataException
*/
public List<Action> getActions(final FullQualifiedName actionName) throws ODataException {
return null;
}
public List<Action> getActions(final FullQualifiedName actionName) throws ODataException;
/**
* This method should return a list of all {@link Function} for the FullQualifiedname or <b>null</b> if nothing is
@ -88,9 +78,7 @@ public abstract class EdmProvider {
* @return List of {@link Function} or null
* @throws ODataException
*/
public List<Function> getFunctions(final FullQualifiedName functionName) throws ODataException {
return null;
}
public List<Function> getFunctions(final FullQualifiedName functionName) throws ODataException;
/**
* This method should return a {@link Term} for the FullQualifiedName or <b>null</b> if nothing is found.
@ -98,9 +86,7 @@ public abstract class EdmProvider {
* @return {@link Term} or null
* @throws ODataException
*/
public Term getTerm(final FullQualifiedName termName) throws ODataException {
return null;
}
public Term getTerm(final FullQualifiedName termName) throws ODataException;
/**
* This method should return an {@link EntitySet} or <b>null</b> if nothing is found
@ -111,9 +97,7 @@ public abstract class EdmProvider {
* @throws ODataException
*/
public EntitySet getEntitySet(final FullQualifiedName entityContainer, final String entitySetName)
throws ODataException {
return null;
}
throws ODataException;
/**
* This method should return an {@link Singleton} or <b>null</b> if nothing is found
@ -124,9 +108,7 @@ public abstract class EdmProvider {
* @throws ODataException
*/
public Singleton getSingleton(final FullQualifiedName entityContainer, final String singletonName)
throws ODataException {
return null;
}
throws ODataException;
/**
* This method should return an {@link ActionImport} or <b>null</b> if nothing is found
@ -137,9 +119,7 @@ public abstract class EdmProvider {
* @throws ODataException
*/
public ActionImport getActionImport(final FullQualifiedName entityContainer, final String actionImportName)
throws ODataException {
return null;
}
throws ODataException;
/**
* This method should return a {@link FunctionImport} or <b>null</b> if nothing is found
@ -150,9 +130,7 @@ public abstract class EdmProvider {
* @throws ODataException
*/
public FunctionImport getFunctionImport(final FullQualifiedName entityContainer, final String functionImportName)
throws ODataException {
return null;
}
throws ODataException;
/**
* This method should return an {@link EntityContainerInfo} or <b>null</b> if nothing is found
@ -161,9 +139,7 @@ public abstract class EdmProvider {
* @return {@link EntityContainerInfo} for the given name
* @throws ODataException
*/
public EntityContainerInfo getEntityContainerInfo(final FullQualifiedName entityContainerName) throws ODataException {
return null;
}
public EntityContainerInfo getEntityContainerInfo(final FullQualifiedName entityContainerName) throws ODataException;
/**
* This method should return a list of all namespaces which have an alias
@ -171,9 +147,7 @@ public abstract class EdmProvider {
* @return List of alias info
* @throws ODataException
*/
public List<AliasInfo> getAliasInfos() throws ODataException {
return null;
}
public List<AliasInfo> getAliasInfos() throws ODataException;
/**
* This method should return a collection of all {@link Schema}
@ -181,31 +155,23 @@ public abstract class EdmProvider {
* @return List<{@link Schema}>
* @throws ODataException
*/
public List<Schema> getSchemas() throws ODataException {
return null;
}
public List<Schema> getSchemas() throws ODataException;
/**
* Returns the entity container of this edm
* @return {@link EntityContainer} of this edm
*/
public EntityContainer getEntityContainer() throws ODataException {
return null;
}
public EntityContainer getEntityContainer() throws ODataException;
/**
* @param targetName
* @return {@link Annotations} group for the given Target
*/
public Annotations getAnnotationsGroup(FullQualifiedName targetName) throws ODataException {
return null;
}
public Annotations getAnnotationsGroup(FullQualifiedName targetName) throws ODataException;
/**
* @param annotatedName
* @return Annotatble element by target name
*/
public Annotatable getAnnoatatable(FullQualifiedName annotatedName) throws ODataException {
return null;
}
public Annotatable getAnnoatatable(FullQualifiedName annotatedName) throws ODataException;
}

View File

@ -18,6 +18,17 @@
*/
package org.apache.olingo.server.core.edm.provider;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.List;
import org.apache.olingo.commons.api.ODataException;
import org.apache.olingo.commons.api.edm.EdmActionImport;
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
@ -26,6 +37,7 @@ import org.apache.olingo.commons.api.edm.EdmException;
import org.apache.olingo.commons.api.edm.EdmFunctionImport;
import org.apache.olingo.commons.api.edm.EdmSingleton;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.provider.AbstractEdmProvider;
import org.apache.olingo.commons.api.edm.provider.ActionImport;
import org.apache.olingo.commons.api.edm.provider.EdmProvider;
import org.apache.olingo.commons.api.edm.provider.EntityContainer;
@ -38,17 +50,6 @@ import org.apache.olingo.commons.core.edm.provider.EdmProviderImpl;
import org.junit.Before;
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.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class EdmEntityContainerImplTest {
EdmEntityContainer container;
@ -231,7 +232,7 @@ public class EdmEntityContainerImplTest {
assertNull(container.getEntitySet(null));
}
private class CustomProvider extends EdmProvider {
private class CustomProvider extends AbstractEdmProvider {
@Override
public EntitySet getEntitySet(final FullQualifiedName entityContainer, final String entitySetName)
throws ODataException {

View File

@ -18,6 +18,15 @@
*/
package org.apache.olingo.server.core.edm.provider;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.List;
import org.apache.olingo.commons.api.ODataException;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAction;
@ -34,6 +43,7 @@ import org.apache.olingo.commons.api.edm.EdmSchema;
import org.apache.olingo.commons.api.edm.EdmSingleton;
import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.provider.AbstractEdmProvider;
import org.apache.olingo.commons.api.edm.provider.Action;
import org.apache.olingo.commons.api.edm.provider.ActionImport;
import org.apache.olingo.commons.api.edm.provider.AliasInfo;
@ -54,15 +64,6 @@ import org.apache.olingo.commons.core.edm.provider.EdmProviderImpl;
import org.junit.Before;
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.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class EdmSchemaImplTest {
private EdmSchema schema;
@ -204,7 +205,7 @@ public class EdmSchemaImplTest {
assertTrue(container == edm.getEntityContainer(null));
}
private class LocalProvider extends EdmProvider {
private class LocalProvider extends AbstractEdmProvider {
private static final String ALIAS = "alias";
private static final String NAMESPACE = "org.namespace";

View File

@ -38,6 +38,7 @@ import org.apache.olingo.commons.api.edm.EdmComplexType;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.EdmSchema;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.provider.AbstractEdmProvider;
import org.apache.olingo.commons.api.edm.provider.Action;
import org.apache.olingo.commons.api.edm.provider.ActionImport;
import org.apache.olingo.commons.api.edm.provider.AliasInfo;
@ -262,7 +263,7 @@ public class MetadataDocumentXmlSerializerTest {
+ "</ComplexType>"));
}
private class LocalProvider extends EdmProvider {
private class LocalProvider extends AbstractEdmProvider {
private final static String nameSpace = "namespace";
private final FullQualifiedName nameETAbstract = new FullQualifiedName(nameSpace, "ETAbstract");

View File

@ -18,14 +18,17 @@
*/
package org.apache.olingo.server.tecsvc.provider;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.apache.olingo.commons.api.ODataException;
import org.apache.olingo.server.api.edmx.EdmxReference;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.provider.AbstractEdmProvider;
import org.apache.olingo.commons.api.edm.provider.Action;
import org.apache.olingo.commons.api.edm.provider.ActionImport;
import org.apache.olingo.commons.api.edm.provider.AliasInfo;
import org.apache.olingo.commons.api.edm.provider.ComplexType;
import org.apache.olingo.commons.api.edm.provider.EdmProvider;
import org.apache.olingo.commons.api.edm.provider.EntityContainer;
import org.apache.olingo.commons.api.edm.provider.EntityContainerInfo;
import org.apache.olingo.commons.api.edm.provider.EntitySet;
@ -37,12 +40,9 @@ import org.apache.olingo.commons.api.edm.provider.Schema;
import org.apache.olingo.commons.api.edm.provider.Singleton;
import org.apache.olingo.commons.api.edm.provider.Term;
import org.apache.olingo.commons.api.edm.provider.TypeDefinition;
import org.apache.olingo.server.api.edmx.EdmxReference;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class EdmTechProvider extends EdmProvider {
public class EdmTechProvider extends AbstractEdmProvider {
public static final String nameSpace = "olingo.odata.test1";

View File

@ -39,7 +39,7 @@ import org.apache.commons.io.IOUtils;
import org.apache.olingo.commons.api.ODataException;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import org.apache.olingo.commons.api.edm.provider.EdmProvider;
import org.apache.olingo.commons.api.edm.provider.AbstractEdmProvider;
import org.apache.olingo.commons.api.edm.provider.EntitySet;
import org.apache.olingo.commons.api.format.ContentType;
import org.apache.olingo.commons.api.format.ODataFormat;
@ -223,7 +223,7 @@ public class ODataHandlerTest {
public void uriParserExceptionResultsInRightResponseEdmCause() throws Exception {
final OData odata = OData.newInstance();
final ServiceMetadata serviceMetadata = odata.createServiceMetadata(
new EdmProvider() {
new AbstractEdmProvider() {
public EntitySet getEntitySet(final FullQualifiedName entityContainer, final String entitySetName)
throws ODataException {
throw new ODataException("msg");

View File

@ -25,8 +25,8 @@ import java.util.List;
import org.apache.olingo.commons.api.ODataException;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.provider.AbstractEdmProvider;
import org.apache.olingo.commons.api.edm.provider.ComplexType;
import org.apache.olingo.commons.api.edm.provider.EdmProvider;
import org.apache.olingo.commons.api.edm.provider.EntityContainer;
import org.apache.olingo.commons.api.edm.provider.EntityContainerInfo;
import org.apache.olingo.commons.api.edm.provider.EntitySet;
@ -37,7 +37,7 @@ import org.apache.olingo.commons.api.edm.provider.Property;
import org.apache.olingo.commons.api.edm.provider.PropertyRef;
import org.apache.olingo.commons.api.edm.provider.Schema;
public class CarsEdmProvider extends EdmProvider {
public class CarsEdmProvider extends AbstractEdmProvider {
// Service Namespace
public static final String NAMESPACE = "olingo.odata.sample";