From 5a95029d70fb439ede503a53a86fb3b8ce4ffab7 Mon Sep 17 00:00:00 2001 From: Christian Amend Date: Thu, 22 Jan 2015 15:17:30 +0100 Subject: [PATCH] [OLINGO-530] Refactor Edm TechScenario Names again --- .../core/edm/provider/EdmSchemaImpl.java | 2 +- .../core/edm/provider/EdmSchemaImplTest.java | 41 ++++++++++--------- .../tecsvc/provider/ComplexTypeProvider.java | 8 ++-- .../tecsvc/provider/PropertyProvider.java | 12 +++--- .../tecsvc/provider/SchemaProvider.java | 2 +- .../json/ODataJsonDeserializerEntityTest.java | 4 +- .../serializer/xml/MetadataDocumentTest.java | 6 +++ .../core/uri/antlr/TestFullResourcePath.java | 30 +++++++------- .../resources/EntityETMixEnumDefCollComp.json | 4 +- 9 files changed, 60 insertions(+), 49 deletions(-) diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmSchemaImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmSchemaImpl.java index e350d96ea..b617db9a2 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmSchemaImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmSchemaImpl.java @@ -74,7 +74,7 @@ public class EdmSchemaImpl extends AbstractEdmSchema { final List providerTypeDefinitions = schema.getTypeDefinitions(); if (providerTypeDefinitions != null) { for (TypeDefinition def : providerTypeDefinitions) { - typeDefinitions.add(new EdmTypeDefinitionImpl(edm, new FullQualifiedName("namespace", def.getName()), def)); + typeDefinitions.add(new EdmTypeDefinitionImpl(edm, new FullQualifiedName(namespace, def.getName()), def)); } } return typeDefinitions; diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmSchemaImplTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmSchemaImplTest.java index 647a6348a..03007b38f 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmSchemaImplTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmSchemaImplTest.java @@ -94,7 +94,7 @@ public class EdmSchemaImplTest { @Test public void basicGetters() { - assertEquals("namespace", schema.getNamespace()); + assertEquals("org.namespace", schema.getNamespace()); assertEquals("alias", schema.getAlias()); } @@ -105,7 +105,7 @@ public class EdmSchemaImplTest { assertEquals(2, typeDefinitions.size()); for (EdmTypeDefinition def : typeDefinitions) { - assertTrue(def == edm.getTypeDefinition(new FullQualifiedName("namespace", def.getName()))); + assertTrue(def == edm.getTypeDefinition(new FullQualifiedName("org.namespace", def.getName()))); } } @@ -116,7 +116,7 @@ public class EdmSchemaImplTest { assertEquals(2, enumTypes.size()); for (EdmEnumType enumType : enumTypes) { - assertTrue(enumType == edm.getEnumType(new FullQualifiedName("namespace", enumType.getName()))); + assertTrue(enumType == edm.getEnumType(new FullQualifiedName("org.namespace", enumType.getName()))); } } @@ -127,7 +127,7 @@ public class EdmSchemaImplTest { assertEquals(2, entityTypes.size()); for (EdmEntityType entityType : entityTypes) { - assertTrue(entityType == edm.getEntityType(new FullQualifiedName("namespace", entityType.getName()))); + assertTrue(entityType == edm.getEntityType(new FullQualifiedName("org.namespace", entityType.getName()))); } } @@ -138,7 +138,7 @@ public class EdmSchemaImplTest { assertEquals(2, complexTypes.size()); for (EdmComplexType complexType : complexTypes) { - assertTrue(complexType == edm.getComplexType(new FullQualifiedName("namespace", complexType.getName()))); + assertTrue(complexType == edm.getComplexType(new FullQualifiedName("org.namespace", complexType.getName()))); } } @@ -149,7 +149,7 @@ public class EdmSchemaImplTest { assertEquals(2, actions.size()); for (EdmAction action : actions) { - assertTrue(action == edm.getUnboundAction(new FullQualifiedName("namespace", action.getName()))); + assertTrue(action == edm.getUnboundAction(new FullQualifiedName("org.namespace", action.getName()))); } } @@ -160,7 +160,7 @@ public class EdmSchemaImplTest { assertEquals(2, functions.size()); for (EdmFunction function : functions) { - FullQualifiedName functionName = new FullQualifiedName("namespace", function.getName()); + FullQualifiedName functionName = new FullQualifiedName("org.namespace", function.getName()); assertTrue(function == edm.getUnboundFunction(functionName, null)); } } @@ -204,6 +204,9 @@ public class EdmSchemaImplTest { private class LocalProvider extends EdmProvider { + private static final String ALIAS = "alias"; + private static final String NAMESPACE = "org.namespace"; + @Override public EnumType getEnumType(final FullQualifiedName enumTypeName) throws ODataException { throw new RuntimeException("Provider must not be called in the schema case"); @@ -277,36 +280,36 @@ public class EdmSchemaImplTest { @Override public List getSchemas() throws ODataException { Schema providerSchema = new Schema(); - providerSchema.setNamespace("namespace"); - providerSchema.setAlias("alias"); + providerSchema.setNamespace(NAMESPACE); + providerSchema.setAlias(ALIAS); EntityContainer container = new EntityContainer().setName("container"); List entitySets = new ArrayList(); entitySets.add(new EntitySet().setName("entitySetName") - .setType(new FullQualifiedName("namespace", "entityType1"))); + .setType(new FullQualifiedName(NAMESPACE, "entityType1"))); entitySets - .add(new EntitySet().setName("entitySetName2").setType(new FullQualifiedName("namespace", "entityType2"))); + .add(new EntitySet().setName("entitySetName2").setType(new FullQualifiedName(NAMESPACE, "entityType2"))); container.setEntitySets(entitySets); List singletons = new ArrayList(); singletons.add(new Singleton().setName("singletonName") - .setType(new FullQualifiedName("namespace", "entityType1"))); + .setType(new FullQualifiedName(NAMESPACE, "entityType1"))); singletons - .add(new Singleton().setName("singletonName2").setType(new FullQualifiedName("namespace", "entityType2"))); + .add(new Singleton().setName("singletonName2").setType(new FullQualifiedName(NAMESPACE, "entityType2"))); container.setSingletons(singletons); List actionImports = new ArrayList(); actionImports.add(new ActionImport().setName("actionImportName").setAction( - new FullQualifiedName("namespace", "action1"))); + new FullQualifiedName(NAMESPACE, "action1"))); actionImports.add(new ActionImport().setName("actionImportName2").setAction( - new FullQualifiedName("namespace", "action2"))); + new FullQualifiedName(NAMESPACE, "action2"))); container.setActionImports(actionImports); List functionImports = new ArrayList(); functionImports.add(new FunctionImport().setName("functionImportName").setFunction( - new FullQualifiedName("namespace", "function1"))); + new FullQualifiedName(NAMESPACE, "function1"))); functionImports.add(new FunctionImport().setName("functionImportName2").setFunction( - new FullQualifiedName("namespace", "function2"))); + new FullQualifiedName(NAMESPACE, "function2"))); container.setFunctionImports(functionImports); providerSchema.setEntityContainer(container); @@ -323,13 +326,13 @@ public class EdmSchemaImplTest { List entityTypes = new ArrayList(); entityTypes.add(new EntityType().setName("entityType1")); entityTypes.add(new EntityType().setName("entityType2") - .setBaseType(new FullQualifiedName("namespace", "entityType1"))); + .setBaseType(new FullQualifiedName(NAMESPACE, "entityType1"))); providerSchema.setEntityTypes(entityTypes); List complexTypes = new ArrayList(); complexTypes.add(new ComplexType().setName("complexType1")); complexTypes.add(new ComplexType().setName("complexType2").setBaseType( - new FullQualifiedName("namespace", "complexType1"))); + new FullQualifiedName(NAMESPACE, "complexType1"))); providerSchema.setComplexTypes(complexTypes); List actions = new ArrayList(); diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ComplexTypeProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ComplexTypeProvider.java index ac9332b65..3c23d794b 100644 --- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ComplexTypeProvider.java +++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ComplexTypeProvider.java @@ -49,8 +49,8 @@ public class ComplexTypeProvider { public static final FullQualifiedName nameCTTwoBasePrimCompNav = new FullQualifiedName(SchemaProvider.NAMESPACE, "CTTwoBasePrimCompNav"); public static final FullQualifiedName nameCTTwoPrim = new FullQualifiedName(SchemaProvider.NAMESPACE, "CTTwoPrim"); - public static final FullQualifiedName nameCTMixEnumDefColl = new FullQualifiedName(SchemaProvider.NAMESPACE, - "CTMixEnumDefColl"); + public static final FullQualifiedName nameCTMixEnumDef = new FullQualifiedName(SchemaProvider.NAMESPACE, + "CTMixEnumDef"); public ComplexType getComplexType(final FullQualifiedName complexTypeName) throws ODataException { @@ -163,9 +163,9 @@ public class ComplexTypeProvider { .setName("CTTwoBasePrimCompNav") .setBaseType(nameCTBasePrimCompNav); - } else if (complexTypeName.equals(nameCTMixEnumDefColl)) { + } else if (complexTypeName.equals(nameCTMixEnumDef)) { return new ComplexType() - .setName(nameCTMixEnumDefColl.getName()) + .setName(nameCTMixEnumDef.getName()) .setProperties(Arrays.asList( PropertyProvider.propertyEnumString_ENString, PropertyProvider.collPropertyEnumString_ENString, diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/PropertyProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/PropertyProvider.java index 66dcc9e75..72eb8d5de 100644 --- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/PropertyProvider.java +++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/PropertyProvider.java @@ -517,12 +517,12 @@ public class PropertyProvider { .setType(ComplexTypeProvider.nameCTMixPrimCollComp); public static final Property propertyComp_CTMixEnumTypeDefColl = new Property() - .setName("PropertyCompMixedEnumTypeDefColl") - .setType(ComplexTypeProvider.nameCTMixEnumDefColl); + .setName("PropertyCompMixedEnumDef") + .setType(ComplexTypeProvider.nameCTMixEnumDef); public static final Property propertyCompColl_CTMixEnumTypeDefColl = new Property() - .setName("CollPropertyCompMixedEnumDefColl") - .setType(ComplexTypeProvider.nameCTMixEnumDefColl) + .setName("CollPropertyCompMixedEnumDef") + .setType(ComplexTypeProvider.nameCTMixEnumDef) .setCollection(true); // Navigation Properties ------------------------------------------------------------------------------------------- @@ -600,10 +600,12 @@ public class PropertyProvider { // TypeDefinition Properties --------------------------------------------------------------------------------------- public static final Property propertyTypeDefinition_TDString = new Property() .setName("PropertyDefString") - .setType(TypeDefinitionProvider.nameTDString); + .setType(TypeDefinitionProvider.nameTDString) + .setMaxLength(15); public static final Property collPropertyTypeDefinition_TDString = new Property() .setName("CollPropertyDefString") .setType(TypeDefinitionProvider.nameTDString) + .setMaxLength(15) .setCollection(true); } diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/SchemaProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/SchemaProvider.java index 320c1a40b..27e6a683e 100644 --- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/SchemaProvider.java +++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/SchemaProvider.java @@ -97,7 +97,7 @@ public class SchemaProvider { complexType.add(prov.getComplexType(ComplexTypeProvider.nameCTBasePrimCompNav)); complexType.add(prov.getComplexType(ComplexTypeProvider.nameCTTwoBasePrimCompNav)); complexType.add(prov.getComplexType(ComplexTypeProvider.nameCTCompNav)); - complexType.add(prov.getComplexType(ComplexTypeProvider.nameCTMixEnumDefColl)); + complexType.add(prov.getComplexType(ComplexTypeProvider.nameCTMixEnumDef)); // TypeDefinitions List typeDefinitions = new ArrayList(); diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java index b07c30518..e0d05e1bc 100644 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java +++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java @@ -434,7 +434,7 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe assertNotNull(defProperty); assertEquals("string", defProperty.getValue()); - Property complexProperty = entity.getProperty("PropertyCompMixedEnumTypeDefColl"); + Property complexProperty = entity.getProperty("PropertyCompMixedEnumDef"); List value = (List) complexProperty.getValue(); assertEquals((short) 2, value.get(0).getValue()); } @@ -1099,7 +1099,7 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe public void eTMixEnumDefCollCompNavInvalidComplexEnumValueNull() throws Exception { String entityString = "{" + "\"PropertyEnumString\" : 2," - + "\"PropertyCompMixedEnumTypeDefColl\" : {" + + "\"PropertyCompMixedEnumDef\" : {" + "\"PropertyEnumString\" : null" + "}}"; diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java index 2ee632061..c438d00a9 100644 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java +++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java @@ -133,6 +133,12 @@ public class MetadataDocumentTest { assertThat(metadata, containsString("")); assertThat(metadata, containsString("")); + + // TypeDefCheck + assertThat(metadata, + containsString("")); + assertThat(metadata, containsString("")); } /** diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java index 3e308eb54..0b5cb2ac0 100644 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java +++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java @@ -4460,11 +4460,11 @@ public class TestFullResourcePath { .root().right().isEnum(EnumTypeProvider.nameENString, Arrays.asList("String1")); testFilter.runOnETMixEnumDefCollComp( - "PropertyCompMixedEnumTypeDefColl/PropertyEnumString has olingo.odata.test1.ENString'String2'") - .is("< has >>") + "PropertyCompMixedEnumDef/PropertyEnumString has olingo.odata.test1.ENString'String2'") + .is("< has >>") .isBinary(BinaryOperatorKind.HAS) .root().left().goPath() - .first().isComplex("PropertyCompMixedEnumTypeDefColl") + .first().isComplex("PropertyCompMixedEnumDef") .n().isComplex("PropertyEnumString").isType(EnumTypeProvider.nameENString) .isType(EnumTypeProvider.nameENString) .goUpFilterValidator() @@ -4472,14 +4472,14 @@ public class TestFullResourcePath { testFilter .runOnETMixEnumDefCollComp( - "PropertyCompMixedEnumTypeDefColl/PropertyEnumString has olingo.odata.test1.ENString'String2' eq true") - .is("<< has " + + "PropertyCompMixedEnumDef/PropertyEnumString has olingo.odata.test1.ENString'String2' eq true") + .is("<< has " + ">> eq >") .isBinary(BinaryOperatorKind.EQ) .root().left() .isBinary(BinaryOperatorKind.HAS) .root().left().left().goPath() - .first().isComplex("PropertyCompMixedEnumTypeDefColl") + .first().isComplex("PropertyCompMixedEnumDef") .n().isComplex("PropertyEnumString").isType(EnumTypeProvider.nameENString) .goUpFilterValidator() .root().left().right().isEnum(EnumTypeProvider.nameENString, Arrays.asList("String2")); @@ -4734,26 +4734,26 @@ public class TestFullResourcePath { .root().right().isEnum(EnumTypeProvider.nameENString, Arrays.asList("String2")); testFilter.runOnETMixEnumDefCollComp( - "PropertyCompMixedEnumTypeDefColl/PropertyEnumString eq olingo.odata.test1.ENString'String3'") - .is("< eq >>") + "PropertyCompMixedEnumDef/PropertyEnumString eq olingo.odata.test1.ENString'String3'") + .is("< eq >>") .isBinary(BinaryOperatorKind.EQ) .root().left().goPath() - .first().isComplex("PropertyCompMixedEnumTypeDefColl") + .first().isComplex("PropertyCompMixedEnumDef") .n().isComplex("PropertyEnumString").isType(EnumTypeProvider.nameENString).goUpFilterValidator() .root().right().isEnum(EnumTypeProvider.nameENString, Arrays.asList("String3")); testFilter .runOnETMixEnumDefCollComp( - "PropertyCompMixedEnumTypeDefColl/PropertyEnumString eq " + - "PropertyCompMixedEnumTypeDefColl/PropertyEnumString") - .is("< eq " + - ">") + "PropertyCompMixedEnumDef/PropertyEnumString eq " + + "PropertyCompMixedEnumDef/PropertyEnumString") + .is("< eq " + + ">") .isBinary(BinaryOperatorKind.EQ) .root().left().goPath() - .first().isComplex("PropertyCompMixedEnumTypeDefColl") + .first().isComplex("PropertyCompMixedEnumDef") .n().isComplex("PropertyEnumString").isType(EnumTypeProvider.nameENString).goUpFilterValidator() .root().right().goPath() - .first().isComplex("PropertyCompMixedEnumTypeDefColl") + .first().isComplex("PropertyCompMixedEnumDef") .n().isComplex("PropertyEnumString").isType(EnumTypeProvider.nameENString).goUpFilterValidator(); } diff --git a/lib/server-test/src/test/resources/EntityETMixEnumDefCollComp.json b/lib/server-test/src/test/resources/EntityETMixEnumDefCollComp.json index ea997afed..c56a80900 100644 --- a/lib/server-test/src/test/resources/EntityETMixEnumDefCollComp.json +++ b/lib/server-test/src/test/resources/EntityETMixEnumDefCollComp.json @@ -3,13 +3,13 @@ "PropertyDefString" : "string", "CollPropertyEnumString" : [1, 2], "CollPropertyDefString" : ["string1", "string2"], - "PropertyCompMixedEnumTypeDefColl" : { + "PropertyCompMixedEnumDef" : { "PropertyEnumString" : 2, "PropertyDefString" : "string", "CollPropertyEnumString" : [1, 2], "CollPropertyDefString" : ["string1", "string2"] }, - "CollPropertyCompMixedEnumDefColl" : [{ + "CollPropertyCompMixedEnumDef" : [{ "PropertyEnumString" : 2, "PropertyDefString" : "string", "CollPropertyEnumString" : [1, 2],