You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2013/12/06 15:51:45 UTC
[09/21] [OLINGO-77] Refactored java package names
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmSingleTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmSingleTest.java b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmSingleTest.java
deleted file mode 100644
index 33d703e..0000000
--- a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmSingleTest.java
+++ /dev/null
@@ -1,136 +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.core.edm.primitivetype;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-
-import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
-import org.junit.Test;
-
-public class EdmSingleTest extends PrimitiveTypeBaseTest {
-
- private final EdmPrimitiveType instance = EdmPrimitiveTypeKind.Single.getEdmPrimitiveTypeInstance();
-
- @Test
- public void compatibility() {
- assertTrue(instance.isCompatible(Uint7.getInstance()));
- assertTrue(instance.isCompatible(EdmPrimitiveTypeKind.Byte.getEdmPrimitiveTypeInstance()));
- assertTrue(instance.isCompatible(EdmPrimitiveTypeKind.SByte.getEdmPrimitiveTypeInstance()));
- assertTrue(instance.isCompatible(EdmPrimitiveTypeKind.Int16.getEdmPrimitiveTypeInstance()));
- assertTrue(instance.isCompatible(EdmPrimitiveTypeKind.Int32.getEdmPrimitiveTypeInstance()));
- assertTrue(instance.isCompatible(EdmPrimitiveTypeKind.Int64.getEdmPrimitiveTypeInstance()));
- }
-
- @Test
- public void toUriLiteral() throws Exception {
- assertEquals("127", instance.toUriLiteral("127"));
- }
-
- @Test
- public void fromUriLiteral() throws Exception {
- assertEquals("127", instance.fromUriLiteral("127"));
- }
-
- @Test
- public void valueToString() throws Exception {
- assertEquals("0", instance.valueToString(0, null, null, null, null, null));
- assertEquals("8", instance.valueToString((byte) 8, null, null, null, null, null));
- assertEquals("16", instance.valueToString((short) 16, null, null, null, null, null));
- assertEquals("32", instance.valueToString(Integer.valueOf(32), null, null, null, null, null));
- assertEquals("255", instance.valueToString(255L, null, null, null, null, null));
- assertEquals("0.00390625", instance.valueToString(1.0 / 256, null, null, null, null, null));
- assertEquals("4.2E-8", instance.valueToString(42e-9, null, null, null, null, null));
- assertEquals("INF", instance.valueToString(Double.POSITIVE_INFINITY, null, null, null, null, null));
- assertEquals("-INF", instance.valueToString(Double.NEGATIVE_INFINITY, null, null, null, null, null));
- assertEquals("NaN", instance.valueToString(Double.NaN, null, null, null, null, null));
- assertEquals("-0.125", instance.valueToString(-0.125f, null, null, null, null, null));
- assertEquals("INF", instance.valueToString(Float.POSITIVE_INFINITY, null, null, null, null, null));
- assertEquals("-INF", instance.valueToString(Float.NEGATIVE_INFINITY, null, null, null, null, null));
- assertEquals("NaN", instance.valueToString(Float.NaN, null, null, null, null, null));
- assertEquals("-123456.75", instance.valueToString(new BigDecimal("-123456.75"), null, null, null, null, null));
-
- expectContentErrorInValueToString(instance, 12345678L);
- expectContentErrorInValueToString(instance, new BigDecimal("123456789"));
- expectContentErrorInValueToString(instance, new BigDecimal(BigInteger.ONE, -39));
- expectContentErrorInValueToString(instance, 42e38);
- expectContentErrorInValueToString(instance, 12345.6789);
- expectContentErrorInValueToString(instance, 1E-50);
-
- expectTypeErrorInValueToString(instance, 'A');
- }
-
- @Test
- public void valueOfString() throws Exception {
- assertEquals(Float.valueOf(1.42F), instance.valueOfString("1.42", null, null, null, null, null, Float.class));
- assertEquals(Double.valueOf(-42.42), instance.valueOfString("-42.42", null, null, null, null, null, Double.class));
- assertEquals(Float.valueOf(42.0F), instance.valueOfString("42", null, null, null, null, null, Float.class));
- assertEquals(Float.valueOf(2.2E38F), instance.valueOfString("22E37", null, null, null, null, null, Float.class));
- assertEquals(Float.valueOf(1.23E-38F), instance.valueOfString("12.3E-39", null, null, null, null, null,
- Float.class));
- assertEquals(BigDecimal.TEN, instance.valueOfString("10", null, null, null, null, null, BigDecimal.class));
- assertEquals(Byte.valueOf((byte) 0), instance.valueOfString("0", null, null, null, null, null, Byte.class));
- assertEquals(Short.valueOf((short) 1), instance.valueOfString("1.00", null, null, null, null, null, Short.class));
- assertEquals(Integer.valueOf(42), instance.valueOfString("4.2E1", null, null, null, null, null, Integer.class));
- assertEquals(Long.valueOf(12345678), instance.valueOfString("12345.678E+03", null, null, null, null, null,
- Long.class));
-
- assertEquals(Float.valueOf(Float.NaN), instance.valueOfString("NaN", null, null, null, null, null, Float.class));
- assertEquals(Float.valueOf(Float.NEGATIVE_INFINITY), instance.valueOfString("-INF", null, null, null, null, null,
- Float.class));
- assertEquals(Float.valueOf(Float.POSITIVE_INFINITY), instance.valueOfString("INF", null, null, null, null, null,
- Float.class));
- assertEquals(Double.valueOf(Double.NaN), instance.valueOfString("NaN", null, null, null, null, null,
- Double.class));
- assertEquals(Double.valueOf(Double.NEGATIVE_INFINITY), instance.valueOfString("-INF", null, null, null, null, null,
- Double.class));
-
- expectContentErrorInValueOfString(instance, "0.");
- expectContentErrorInValueOfString(instance, ".0");
- expectContentErrorInValueOfString(instance, "1E-50");
- expectContentErrorInValueOfString(instance, "12345.6789");
- expectContentErrorInValueOfString(instance, "42E42");
- expectContentErrorInValueOfString(instance, "42.42.42");
- expectContentErrorInValueOfString(instance, "42.42.42");
- expectContentErrorInValueOfString(instance, "42D");
- expectContentErrorInValueOfString(instance, "0x42P4");
-
- expectUnconvertibleErrorInValueOfString(instance, "INF", BigDecimal.class);
- expectUnconvertibleErrorInValueOfString(instance, "NaN", BigDecimal.class);
- expectUnconvertibleErrorInValueOfString(instance, "-INF", Integer.class);
- expectUnconvertibleErrorInValueOfString(instance, "NaN", Integer.class);
- expectUnconvertibleErrorInValueOfString(instance, "5E-1", Byte.class);
- expectUnconvertibleErrorInValueOfString(instance, "5E-1", Short.class);
- expectUnconvertibleErrorInValueOfString(instance, "5E-1", Integer.class);
- expectUnconvertibleErrorInValueOfString(instance, "5E-1", Long.class);
- expectUnconvertibleErrorInValueOfString(instance, "-129", Byte.class);
- expectUnconvertibleErrorInValueOfString(instance, "128", Byte.class);
- expectUnconvertibleErrorInValueOfString(instance, "-32769", Short.class);
- expectUnconvertibleErrorInValueOfString(instance, "32768", Short.class);
- expectUnconvertibleErrorInValueOfString(instance, "-2147483.65E3", Integer.class);
- expectUnconvertibleErrorInValueOfString(instance, "2147483.65E3", Integer.class);
- expectUnconvertibleErrorInValueOfString(instance, "-1E19", Long.class);
- expectUnconvertibleErrorInValueOfString(instance, "1E19", Long.class);
-
- expectTypeErrorInValueOfString(instance, "1.42");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmStringTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmStringTest.java b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmStringTest.java
deleted file mode 100644
index aea314f..0000000
--- a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmStringTest.java
+++ /dev/null
@@ -1,77 +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.core.edm.primitivetype;
-
-import static org.junit.Assert.assertEquals;
-
-import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
-import org.junit.Test;
-
-public class EdmStringTest extends PrimitiveTypeBaseTest {
-
- private final EdmPrimitiveType instance = EdmPrimitiveTypeKind.String.getEdmPrimitiveTypeInstance();
-
- @Test
- public void toUriLiteral() throws Exception {
- assertEquals("'StringValue'", instance.toUriLiteral("StringValue"));
- assertEquals("'String''Value'", instance.toUriLiteral("String'Value"));
- assertEquals("'String''''''Value'", instance.toUriLiteral("String'''Value"));
- }
-
- @Test
- public void fromUriLiteral() throws Exception {
- assertEquals("String''Value", instance.fromUriLiteral("'String''''Value'"));
-
- expectErrorInFromUriLiteral(instance, "");
- expectErrorInFromUriLiteral(instance, "'");
- expectErrorInFromUriLiteral(instance, "'\"");
- }
-
- @Test
- public void valueToString() throws Exception {
- assertEquals("text", instance.valueToString("text", null, null, null, null, null));
- assertEquals("a\nb", instance.valueToString("a\nb", null, null, null, null, null));
- assertEquals("true", instance.valueToString(true, null, null, null, null, null));
- assertEquals("a'b", instance.valueToString("a'b", null, null, null, null, null));
-
- assertEquals("text", instance.valueToString("text", null, null, null, null, true));
- assertEquals("text", instance.valueToString("text", null, 4, null, null, null));
- assertEquals("text", instance.valueToString("text", null, Integer.MAX_VALUE, null, null, null));
-
- expectFacetsErrorInValueToString(instance, "schräg", null, null, null, null, false);
- expectFacetsErrorInValueToString(instance, "text", null, 3, null, null, null);
- }
-
- @Test
- public void valueOfString() throws Exception {
- assertEquals("text", instance.valueOfString("text", null, null, null, null, null, String.class));
- assertEquals("a\nb", instance.valueOfString("a\nb", null, null, null, null, null, String.class));
- assertEquals("true", instance.valueOfString("true", null, null, null, null, null, String.class));
- assertEquals("'a''b'", instance.valueOfString("'a''b'", null, null, null, null, null, String.class));
-
- assertEquals("text", instance.valueOfString("text", null, null, null, null, true, String.class));
- assertEquals("text", instance.valueOfString("text", null, 4, null, null, null, String.class));
- assertEquals("text", instance.valueOfString("text", null, Integer.MAX_VALUE, null, null, null, String.class));
-
- expectFacetsErrorInValueOfString(instance, "schräg", null, null, null, null, false);
- expectFacetsErrorInValueOfString(instance, "text", null, 3, null, null, null);
-
- expectTypeErrorInValueOfString(instance, "text");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmTimeOfDayTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmTimeOfDayTest.java b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmTimeOfDayTest.java
deleted file mode 100644
index a98e0d7..0000000
--- a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmTimeOfDayTest.java
+++ /dev/null
@@ -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.commons.core.edm.primitivetype;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.Calendar;
-import java.util.TimeZone;
-
-import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
-import org.junit.Test;
-
-public class EdmTimeOfDayTest extends PrimitiveTypeBaseTest {
-
- private final EdmPrimitiveType instance = EdmPrimitiveTypeKind.TimeOfDay.getEdmPrimitiveTypeInstance();
-
- @Test
- public void toUriLiteral() throws Exception {
- assertEquals("11:12", instance.toUriLiteral("11:12"));
- assertEquals("11:12:13.012", instance.toUriLiteral("11:12:13.012"));
- }
-
- @Test
- public void fromUriLiteral() throws Exception {
- assertEquals("11:12", instance.fromUriLiteral("11:12"));
- assertEquals("11:12:13.012", instance.fromUriLiteral("11:12:13.012"));
- }
-
- @Test
- public void valueToString() throws Exception {
- Calendar dateTime = Calendar.getInstance();
- dateTime.clear();
- dateTime.setTimeZone(TimeZone.getTimeZone("GMT+11:30"));
- dateTime.set(1, 2, 3, 4, 5, 6);
- assertEquals("04:05:06", instance.valueToString(dateTime, null, null, null, null, null));
-
- dateTime.add(Calendar.MILLISECOND, 42);
- assertEquals("04:05:06.042", instance.valueToString(dateTime, null, null, 3, null, null));
- assertEquals("04:05:06.042", instance.valueToString(dateTime, null, null, 4, null, null));
-
- expectFacetsErrorInValueToString(instance, dateTime, null, null, null, null, null);
- expectFacetsErrorInValueToString(instance, dateTime, null, null, 2, null, null);
-
- expectTypeErrorInValueToString(instance, 0);
- }
-
- @Test
- public void valueOfString() throws Exception {
- Calendar dateTime = Calendar.getInstance();
- dateTime.clear();
- dateTime.setTimeZone(TimeZone.getTimeZone("GMT"));
-
- assertEquals(dateTime, instance.valueOfString("00:00", null, null, null, null, null, Calendar.class));
- assertEquals(dateTime, instance.valueOfString("00:00:00", null, null, null, null, null, Calendar.class));
- assertEquals(dateTime, instance.valueOfString("00:00:00.000000000000", null, null, null, null, null,
- Calendar.class));
-
- dateTime.set(Calendar.MILLISECOND, 999);
- assertEquals(dateTime, instance.valueOfString("00:00:00.999", null, null, 3, null, null, Calendar.class));
- assertEquals(dateTime, instance.valueOfString("00:00:00.999", null, null, 3, null, null, Calendar.class));
-
- expectFacetsErrorInValueOfString(instance, "11:12:13.123", null, null, null, null, null);
- expectFacetsErrorInValueOfString(instance, "11:12:13.123", null, null, 2, null, null);
-
- expectContentErrorInValueOfString(instance, "24:32:02");
- expectContentErrorInValueOfString(instance, "011:12:13");
- expectContentErrorInValueOfString(instance, "11:12:13:14");
- expectContentErrorInValueOfString(instance, "111213");
- expectContentErrorInValueOfString(instance, "1:2:3");
- expectContentErrorInValueOfString(instance, "11:12:13.0.1");
- expectContentErrorInValueOfString(instance, "11:12:13.");
- expectContentErrorInValueOfString(instance, "11:12:13.0000000000000");
-
- expectTypeErrorInValueOfString(instance, "11:12:13");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/PrimitiveTypeBaseTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/PrimitiveTypeBaseTest.java b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/PrimitiveTypeBaseTest.java
deleted file mode 100644
index bef72bb..0000000
--- a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/PrimitiveTypeBaseTest.java
+++ /dev/null
@@ -1,117 +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.core.edm.primitivetype;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-
-public abstract class PrimitiveTypeBaseTest {
-
- private void expectErrorInValueToString(final EdmPrimitiveType instance,
- final Object value, final Boolean isNullable, final Integer maxLength,
- final Integer precision, final Integer scale, final Boolean isUnicode,
- final String messageReferenceString) {
- try {
- instance.valueToString(value, isNullable, maxLength, precision, scale, isUnicode);
- fail("Expected exception not thrown");
- } catch (final EdmPrimitiveTypeException e) {
- assertNotNull(e.getLocalizedMessage());
- assertTrue(e.getLocalizedMessage().startsWith(messageReferenceString));
- }
- }
-
- private void expectErrorInValueToString(final EdmPrimitiveType instance, final Object value,
- final String messageReference) {
- expectErrorInValueToString(instance, value, null, null, null, null, null, messageReference);
- }
-
- protected void expectTypeErrorInValueToString(final EdmPrimitiveType instance, final Object value) {
- expectErrorInValueToString(instance, value, "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED");
- }
-
- protected void expectContentErrorInValueToString(final EdmPrimitiveType instance, final Object value) {
- expectErrorInValueToString(instance, value, "EdmPrimitiveTypeException.VALUE_ILLEGAL_CONTENT");
- }
-
- protected void expectFacetsErrorInValueToString(final EdmPrimitiveType instance, final Object value,
- final Boolean isNullable, final Integer maxLength, final Integer precision,
- final Integer scale, final Boolean isUnicode) {
- expectErrorInValueToString(instance, value, isNullable, maxLength, precision, scale, isUnicode,
- "EdmPrimitiveTypeException.VALUE_FACETS_NOT_MATCHED");
- }
-
- protected void expectNullErrorInValueToString(final EdmPrimitiveType instance) {
- expectErrorInValueToString(instance, null, false, null, null, null, null,
- "EdmPrimitiveTypeException.VALUE_NULL_NOT_ALLOWED");
- }
-
- private void expectErrorInValueOfString(final EdmPrimitiveType instance,
- final String value, final Boolean isNullable, final Integer maxLength, final Integer precision,
- final Integer scale, final Boolean isUnicode, final Class<?> returnType, final String messageReferenceString) {
- try {
- instance.valueOfString(value, isNullable, maxLength, precision, scale, isUnicode, returnType);
- fail("Expected exception not thrown");
- } catch (final EdmPrimitiveTypeException e) {
- assertNotNull(e.getLocalizedMessage());
- assertTrue(e.getLocalizedMessage().startsWith(messageReferenceString));
- }
- }
-
- protected void expectTypeErrorInValueOfString(final EdmPrimitiveType instance, final String value) {
- expectErrorInValueOfString(instance, value, null, null, null, null, null, Class.class,
- "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED");
- }
-
- protected void expectUnconvertibleErrorInValueOfString(final EdmPrimitiveType instance, final String value,
- final Class<?> type) {
- expectErrorInValueOfString(instance, value, null, null, null, null, null, type,
- "EdmPrimitiveTypeException.LITERAL_UNCONVERTIBLE_TO_VALUE_TYPE");
- }
-
- protected void expectContentErrorInValueOfString(final EdmPrimitiveType instance, final String value) {
- expectErrorInValueOfString(instance, value, null, null, null, null, null, instance.getDefaultType(),
- "EdmPrimitiveTypeException.LITERAL_ILLEGAL_CONTENT");
- }
-
- protected void expectFacetsErrorInValueOfString(final EdmPrimitiveType instance, final String value,
- final Boolean isNullable, final Integer maxLength, final Integer precision,
- final Integer scale, final Boolean isUnicode) {
- expectErrorInValueOfString(instance, value, isNullable, maxLength, precision, scale, isUnicode,
- instance.getDefaultType(), "EdmPrimitiveTypeException.LITERAL_FACETS_NOT_MATCHED");
- }
-
- protected void expectNullErrorInValueOfString(final EdmPrimitiveType instance) {
- expectErrorInValueOfString(instance, null, false, null, null, null, null, instance.getDefaultType(),
- "EdmPrimitiveTypeException.LITERAL_NULL_NOT_ALLOWED");
- }
-
- protected void expectErrorInFromUriLiteral(final EdmPrimitiveType instance, final String value) {
- try {
- instance.fromUriLiteral(value);
- fail("Expected exception not thrown");
- } catch (final EdmPrimitiveTypeException e) {
- assertNotNull(e.getLocalizedMessage());
- assertTrue(e.getLocalizedMessage().startsWith("EdmPrimitiveTypeException.LITERAL_ILLEGAL_CONTENT"));
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/UInt7Test.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/UInt7Test.java b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/UInt7Test.java
deleted file mode 100644
index 1099377..0000000
--- a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/UInt7Test.java
+++ /dev/null
@@ -1,33 +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.core.edm.primitivetype;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-
-public class UInt7Test extends PrimitiveTypeBaseTest {
-
- @Test
- public void compatibility() {
- assertTrue(Uint7.getInstance().isCompatible(Uint7.getInstance()));
- assertFalse(Uint7.getInstance().isCompatible(EdmPrimitiveTypeKind.String.getEdmPrimitiveTypeInstance()));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/provider/EdmComplexTypeImplTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/provider/EdmComplexTypeImplTest.java b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/provider/EdmComplexTypeImplTest.java
deleted file mode 100644
index 9ee0ff7..0000000
--- a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/provider/EdmComplexTypeImplTest.java
+++ /dev/null
@@ -1,127 +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.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.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.commons.api.edm.EdmComplexType;
-import org.apache.olingo.commons.api.edm.EdmElement;
-import org.apache.olingo.commons.api.edm.helper.FullQualifiedName;
-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.NavigationProperty;
-import org.apache.olingo.commons.api.edm.provider.Property;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind;
-import org.junit.Before;
-import org.junit.Test;
-
-public class EdmComplexTypeImplTest {
-
- private EdmComplexType baseType;
- private EdmComplexType type;
-
- @Before
- public void setupTypes() throws Exception {
- EdmProvider provider = mock(EdmProvider.class);
- EdmProviderImpl edm = new EdmProviderImpl(provider);
-
- FullQualifiedName baseName = new FullQualifiedName("namespace", "BaseTypeName");
- ComplexType baseComplexType = new ComplexType();
- List<Property> baseProperties = new ArrayList<Property>();
- baseProperties.add(new Property().setName("prop1").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()));
- List<NavigationProperty> baseNavigationProperties = new ArrayList<NavigationProperty>();
- baseNavigationProperties.add(new NavigationProperty().setName("nav1"));
- baseComplexType.setName("BaseTypeName").setAbstract(false).setOpenType(false).setProperties(baseProperties)
- .setNavigationProperties(baseNavigationProperties);
- when(provider.getComplexType(baseName)).thenReturn(baseComplexType);
-
- baseType = new EdmComplexTypeImpl(edm, baseName, baseComplexType);
-
- FullQualifiedName name = new FullQualifiedName("namespace", "typeName");
- ComplexType complexType = new ComplexType().setBaseType(baseName);
- List<Property> properties = new ArrayList<Property>();
- properties.add(new Property().setName("prop2").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()));
- List<NavigationProperty> navigationProperties = new ArrayList<NavigationProperty>();
- navigationProperties.add(new NavigationProperty().setName("nav2"));
- complexType.setName("BaseTypeName").setAbstract(false).setOpenType(false).setProperties(properties)
- .setNavigationProperties(navigationProperties);
- when(provider.getComplexType(name)).thenReturn(complexType);
-
- type = new EdmComplexTypeImpl(edm, name, complexType);
- }
-
- @Test
- public void getBaseType() {
- assertNull(baseType.getBaseType());
- assertNotNull(type.getBaseType());
- }
-
- @Test
- public void propertiesBehaviour() {
- List<String> propertyNames = baseType.getPropertyNames();
- assertEquals(1, propertyNames.size());
- assertEquals("prop1", baseType.getProperty("prop1").getName());
- }
-
- @Test
- public void propertiesBehaviourWithBaseType() {
- List<String> propertyNames = type.getPropertyNames();
- assertEquals(2, propertyNames.size());
- assertEquals("prop1", type.getProperty("prop1").getName());
- assertEquals("prop2", type.getProperty("prop2").getName());
- }
-
- @Test
- public void navigationPropertiesBehaviour() {
- List<String> navigationPropertyNames = baseType.getNavigationPropertyNames();
- assertEquals(1, navigationPropertyNames.size());
- assertEquals("nav1", baseType.getProperty("nav1").getName());
- }
-
- @Test
- public void navigationPropertiesBehaviourWithBaseType() {
- List<String> navigationPropertyNames = type.getNavigationPropertyNames();
- assertEquals(2, navigationPropertyNames.size());
- assertEquals("nav1", type.getProperty("nav1").getName());
- assertEquals("nav2", type.getProperty("nav2").getName());
- }
-
- @Test
- public void propertyCaching() {
- EdmElement property = type.getProperty("prop1");
- assertTrue(property == type.getProperty("prop1"));
-
- property = type.getProperty("prop2");
- assertTrue(property == type.getProperty("prop2"));
-
- property = type.getProperty("nav1");
- assertTrue(property == type.getProperty("nav1"));
-
- property = type.getProperty("nav2");
- assertTrue(property == type.getProperty("nav2"));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/provider/EdmEntityTypeImplTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/provider/EdmEntityTypeImplTest.java b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/provider/EdmEntityTypeImplTest.java
deleted file mode 100644
index afe8fb6..0000000
--- a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/provider/EdmEntityTypeImplTest.java
+++ /dev/null
@@ -1,241 +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.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.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.commons.api.edm.EdmComplexType;
-import org.apache.olingo.commons.api.edm.EdmElement;
-import org.apache.olingo.commons.api.edm.EdmEntityType;
-import org.apache.olingo.commons.api.edm.EdmKeyPropertyRef;
-import org.apache.olingo.commons.api.edm.EdmProperty;
-import org.apache.olingo.commons.api.edm.helper.FullQualifiedName;
-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.EntityType;
-import org.apache.olingo.commons.api.edm.provider.NavigationProperty;
-import org.apache.olingo.commons.api.edm.provider.Property;
-import org.apache.olingo.commons.api.edm.provider.PropertyRef;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind;
-import org.junit.Before;
-import org.junit.Test;
-
-public class EdmEntityTypeImplTest {
-
- private EdmEntityType baseType;
- private EdmEntityType typeWithBaseType;
- private EdmEntityType typeWithComplexKey;
-
- // TODO: test with abstract types and keys
- @Before
- public void setupTypes() throws Exception {
- EdmProvider provider = mock(EdmProvider.class);
- EdmProviderImpl edm = new EdmProviderImpl(provider);
-
- FullQualifiedName baseName = new FullQualifiedName("namespace", "BaseTypeName");
- EntityType baseType = new EntityType();
- baseType.setName(baseName.getName());
- List<Property> properties = new ArrayList<Property>();
- properties.add(new Property().setName("Id").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()));
- properties.add(new Property().setName("Name").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()));
- baseType.setProperties(properties);
- List<PropertyRef> key = new ArrayList<PropertyRef>();
- key.add(new PropertyRef().setPropertyName("Id"));
- baseType.setKey(key);
- List<NavigationProperty> navigationProperties = new ArrayList<NavigationProperty>();
- navigationProperties.add(new NavigationProperty().setName("nav1"));
- baseType.setNavigationProperties(navigationProperties);
- when(provider.getEntityType(baseName)).thenReturn(baseType);
-
- this.baseType = new EdmEntityTypeImpl(edm, baseName, baseType);
-
- FullQualifiedName typeName = new FullQualifiedName("namespace", "typeName");
- EntityType type = new EntityType();
- type.setName(typeName.getName());
- type.setBaseType(baseName);
- List<Property> typeProperties = new ArrayList<Property>();
- typeProperties.add(new Property().setName("address").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()));
- typeProperties.add(new Property().setName("email").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()));
- type.setProperties(typeProperties);
- List<NavigationProperty> typeNavigationProperties = new ArrayList<NavigationProperty>();
- typeNavigationProperties.add(new NavigationProperty().setName("nav2"));
- type.setNavigationProperties(typeNavigationProperties);
- when(provider.getEntityType(typeName)).thenReturn(type);
-
- typeWithBaseType = new EdmEntityTypeImpl(edm, typeName, type);
-
- FullQualifiedName typeWithComplexKeyName = new FullQualifiedName("namespace", "typeName");
- EntityType typeWithComplexKeyProvider = new EntityType();
- typeWithComplexKeyProvider.setName(typeWithComplexKeyName.getName());
- List<Property> typeWithComplexKeyProperties = new ArrayList<Property>();
- typeWithComplexKeyProperties.add(new Property().setName("Id").setType(
- EdmPrimitiveTypeKind.String.getFullQualifiedName()));
-
- List<Property> complexTypeProperties = new ArrayList<Property>();
- complexTypeProperties.add(new Property().setName("ComplexPropName").setType(
- EdmPrimitiveTypeKind.String.getFullQualifiedName()));
- FullQualifiedName complexTypeName = new FullQualifiedName("namespace", "complexTypeName");
- when(provider.getComplexType(complexTypeName)).thenReturn(
- new ComplexType().setName("complexTypeName").setProperties(complexTypeProperties));
-
- typeWithComplexKeyProperties.add(new Property().setName("Comp").setType(complexTypeName));
- typeWithComplexKeyProvider.setProperties(typeWithComplexKeyProperties);
- List<PropertyRef> keyForTypeWithComplexKey = new ArrayList<PropertyRef>();
- keyForTypeWithComplexKey.add(new PropertyRef().setPropertyName("Id"));
- keyForTypeWithComplexKey.add(new PropertyRef().setPropertyName("ComplexPropName").setAlias("alias").setPath(
- "Comp/ComplexPropName"));
- typeWithComplexKeyProvider.setKey(keyForTypeWithComplexKey);
- when(provider.getEntityType(typeWithComplexKeyName)).thenReturn(typeWithComplexKeyProvider);
-
- typeWithComplexKey = new EdmEntityTypeImpl(edm, typeWithComplexKeyName, typeWithComplexKeyProvider);
- }
-
- @Test
- public void complexKeyWithAlias() {
- List<String> keyPredicateNames = typeWithComplexKey.getKeyPredicateNames();
- assertEquals(2, keyPredicateNames.size());
- assertEquals("Id", keyPredicateNames.get(0));
- assertEquals("alias", keyPredicateNames.get(1));
-
- EdmKeyPropertyRef keyPropertyRef = typeWithComplexKey.getKeyPropertyRef("Id");
- assertNotNull(keyPropertyRef);
- assertEquals("Id", keyPropertyRef.getKeyPropertyName());
- assertNull(keyPropertyRef.getAlias());
- EdmProperty keyProperty = keyPropertyRef.getProperty();
- assertNotNull(keyProperty);
- assertEquals(typeWithComplexKey.getProperty("Id"), keyProperty);
-
- keyPropertyRef = typeWithComplexKey.getKeyPropertyRef("alias");
- assertNotNull(keyPropertyRef);
- assertEquals("ComplexPropName", keyPropertyRef.getKeyPropertyName());
- assertEquals("alias", keyPropertyRef.getAlias());
- assertEquals("Comp/ComplexPropName", keyPropertyRef.getPath());
-
- keyProperty = keyPropertyRef.getProperty();
- assertNotNull(keyProperty);
- EdmElement complexProperty = typeWithComplexKey.getProperty("Comp");
- EdmComplexType complexType = (EdmComplexType) complexProperty.getType();
- assertNotNull(complexType);
- assertEquals(complexType.getProperty("ComplexPropName"), keyProperty);
- }
-
- @Test
- public void keyBehaviour() {
- List<String> keyPredicateNames = baseType.getKeyPredicateNames();
- assertEquals(1, keyPredicateNames.size());
- assertEquals("Id", keyPredicateNames.get(0));
-
- EdmKeyPropertyRef keyPropertyRef = baseType.getKeyPropertyRef("Id");
- assertNotNull(keyPropertyRef);
- assertEquals("Id", keyPropertyRef.getKeyPropertyName());
- assertNull(keyPropertyRef.getAlias());
-
- EdmProperty keyProperty = keyPropertyRef.getProperty();
- assertNotNull(keyProperty);
- assertEquals(baseType.getProperty("Id"), keyProperty);
-
- List<EdmKeyPropertyRef> keyPropertyRefs = baseType.getKeyPropertyRefs();
- assertNotNull(keyPropertyRefs);
- assertEquals(1, keyPropertyRefs.size());
- assertEquals("Id", keyPropertyRefs.get(0).getKeyPropertyName());
- }
-
- @Test
- public void keyBehaviourWithBasetype() {
- List<String> keyPredicateNames = typeWithBaseType.getKeyPredicateNames();
- assertEquals(1, keyPredicateNames.size());
- assertEquals("Id", keyPredicateNames.get(0));
-
- EdmKeyPropertyRef keyPropertyRef = typeWithBaseType.getKeyPropertyRef("Id");
- assertNotNull(keyPropertyRef);
- assertEquals("Id", keyPropertyRef.getKeyPropertyName());
- assertNull(keyPropertyRef.getAlias());
-
- // Should we support this?
- // EdmPoperty keyProperty = keyPropertyRef.getProperty();
-
- List<EdmKeyPropertyRef> keyPropertyRefs = typeWithBaseType.getKeyPropertyRefs();
- assertNotNull(keyPropertyRefs);
- assertEquals(1, keyPropertyRefs.size());
- assertEquals("Id", keyPropertyRefs.get(0).getKeyPropertyName());
- }
-
- @Test
- public void getBaseType() {
- assertNull(baseType.getBaseType());
- assertNotNull(typeWithBaseType.getBaseType());
- }
-
- @Test
- public void propertiesBehaviour() {
- List<String> propertyNames = baseType.getPropertyNames();
- assertEquals(2, propertyNames.size());
- assertEquals("Id", baseType.getProperty("Id").getName());
- assertEquals("Name", baseType.getProperty("Name").getName());
- }
-
- @Test
- public void propertiesBehaviourWithBaseType() {
- List<String> propertyNames = typeWithBaseType.getPropertyNames();
- assertEquals(4, propertyNames.size());
- assertEquals("Id", typeWithBaseType.getProperty("Id").getName());
- assertEquals("Name", typeWithBaseType.getProperty("Name").getName());
- assertEquals("address", typeWithBaseType.getProperty("address").getName());
- assertEquals("email", typeWithBaseType.getProperty("email").getName());
- }
-
- @Test
- public void navigationPropertiesBehaviour() {
- List<String> navigationPropertyNames = baseType.getNavigationPropertyNames();
- assertEquals(1, navigationPropertyNames.size());
- assertEquals("nav1", baseType.getProperty("nav1").getName());
- }
-
- @Test
- public void navigationPropertiesBehaviourWithBaseType() {
- List<String> navigationPropertyNames = typeWithBaseType.getNavigationPropertyNames();
- assertEquals(2, navigationPropertyNames.size());
- assertEquals("nav1", typeWithBaseType.getProperty("nav1").getName());
- assertEquals("nav2", typeWithBaseType.getProperty("nav2").getName());
- }
-
- @Test
- public void propertyCaching() {
- EdmElement property = typeWithBaseType.getProperty("Id");
- assertTrue(property == typeWithBaseType.getProperty("Id"));
-
- property = typeWithBaseType.getProperty("address");
- assertTrue(property == typeWithBaseType.getProperty("address"));
-
- property = typeWithBaseType.getProperty("nav1");
- assertTrue(property == typeWithBaseType.getProperty("nav1"));
-
- property = typeWithBaseType.getProperty("nav2");
- assertTrue(property == typeWithBaseType.getProperty("nav2"));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/provider/EdmNamedImplTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/provider/EdmNamedImplTest.java b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/provider/EdmNamedImplTest.java
deleted file mode 100644
index b3e1176..0000000
--- a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/provider/EdmNamedImplTest.java
+++ /dev/null
@@ -1,41 +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.core.edm.provider;
-
-import static org.junit.Assert.assertEquals;
-
-import org.apache.olingo.commons.api.edm.EdmNamed;
-import org.junit.Test;
-
-public class EdmNamedImplTest {
-
- @Test
- public void getNameTest() {
- EdmNamed obj = new EdmNamedImplTester("Name");
- assertEquals("Name", obj.getName());
- }
-
- private class EdmNamedImplTester extends EdmNamedImpl {
-
- public EdmNamedImplTester(final String name) {
- super(null, name);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/provider/EdmPropertyImplTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/provider/EdmPropertyImplTest.java b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/provider/EdmPropertyImplTest.java
deleted file mode 100644
index 42e2cd1..0000000
--- a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/provider/EdmPropertyImplTest.java
+++ /dev/null
@@ -1,35 +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.core.edm.provider;
-
-import org.junit.Test;
-
-public class EdmPropertyImplTest {
-
- @Test
- public void getTypeReturnsSimpleType() {
-
- }
-
- @Test
- public void getTypeReturnsComplexType() {
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/provider/EdmProviderImplTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/provider/EdmProviderImplTest.java b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/provider/EdmProviderImplTest.java
deleted file mode 100644
index d1a1c8a..0000000
--- a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/provider/EdmProviderImplTest.java
+++ /dev/null
@@ -1,170 +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.core.edm.provider;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-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.edm.Edm;
-import org.apache.olingo.commons.api.edm.EdmAction;
-import org.apache.olingo.commons.api.edm.EdmComplexType;
-import org.apache.olingo.commons.api.edm.EdmEntityContainer;
-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.EdmTypeDefinition;
-import org.apache.olingo.commons.api.edm.helper.EntityContainerInfo;
-import org.apache.olingo.commons.api.edm.helper.FullQualifiedName;
-import org.apache.olingo.commons.api.edm.provider.Action;
-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.EntityType;
-import org.apache.olingo.commons.api.edm.provider.EnumType;
-import org.apache.olingo.commons.api.edm.provider.Function;
-import org.apache.olingo.commons.api.edm.provider.Parameter;
-import org.apache.olingo.commons.api.edm.provider.PropertyRef;
-import org.apache.olingo.commons.api.edm.provider.TypeDefinition;
-import org.junit.Before;
-import org.junit.Test;
-
-public class EdmProviderImplTest {
-
- private Edm edm;
- private final FullQualifiedName FQN = new FullQualifiedName("testNamespace", "testName");
- private final FullQualifiedName WRONG_FQN = new FullQualifiedName("wrong", "wrong");
-
- @Before
- public void setup() throws Exception {
- EdmProvider provider = mock(EdmProvider.class);
- EntityContainerInfo containerInfo = new EntityContainerInfo().setContainerName(FQN);
- when(provider.getEntityContainerInfo(FQN)).thenReturn(containerInfo);
- when(provider.getEntityContainerInfo(null)).thenReturn(containerInfo);
-
- EnumType enumType = new EnumType().setName(FQN.getName());
- when(provider.getEnumType(FQN)).thenReturn(enumType);
-
- TypeDefinition typeDefinition = new TypeDefinition().setName(FQN.getName());
- when(provider.getTypeDefinition(FQN)).thenReturn(typeDefinition);
-
- EntityType entityType = new EntityType().setName(FQN.getName()).setKey(new ArrayList<PropertyRef>());
- when(provider.getEntityType(FQN)).thenReturn(entityType);
-
- ComplexType complexType = new ComplexType().setName(FQN.getName());
- when(provider.getComplexType(FQN)).thenReturn(complexType);
-
- Action action = new Action().setName(FQN.getName());
- List<Action> actions = new ArrayList<Action>();
- actions.add(action);
- when(provider.getActions(FQN)).thenReturn(actions);
-
- Function function = new Function().setName(FQN.getName()).setParameters(new ArrayList<Parameter>());
- List<Function> functions = new ArrayList<Function>();
- functions.add(function);
- when(provider.getFunctions(FQN)).thenReturn(functions);
-
- edm = new EdmProviderImpl(provider);
- }
-
- @Test
- public void getEntityContainer() {
- EdmEntityContainer entityContainer = edm.getEntityContainer(FQN);
- assertNotNull(entityContainer);
- assertEquals(FQN.getNamespace(), entityContainer.getNamespace());
- assertEquals(FQN.getName(), entityContainer.getName());
-
- entityContainer = edm.getEntityContainer(null);
- assertNotNull(entityContainer);
- assertEquals(FQN.getNamespace(), entityContainer.getNamespace());
- assertEquals(FQN.getName(), entityContainer.getName());
-
- assertNull(edm.getEntityContainer(WRONG_FQN));
- }
-
- @Test
- public void getEnumType() {
- EdmEnumType enumType = edm.getEnumType(FQN);
- assertNotNull(enumType);
- assertEquals(FQN.getNamespace(), enumType.getNamespace());
- assertEquals(FQN.getName(), enumType.getName());
-
- assertNull(edm.getEnumType(WRONG_FQN));
- }
-
- @Test
- public void getTypeDefinition() {
- EdmTypeDefinition typeDefinition = edm.getTypeDefinition(FQN);
- assertNotNull(typeDefinition);
- assertEquals(FQN.getNamespace(), typeDefinition.getNamespace());
- assertEquals(FQN.getName(), typeDefinition.getName());
-
- assertNull(edm.getTypeDefinition(WRONG_FQN));
- }
-
- @Test
- public void getEntityType() {
- EdmEntityType entityType = edm.getEntityType(FQN);
- assertNotNull(entityType);
- assertEquals(FQN.getNamespace(), entityType.getNamespace());
- assertEquals(FQN.getName(), entityType.getName());
-
- assertNull(edm.getEntityType(WRONG_FQN));
- }
-
- @Test
- public void getComplexType() {
- EdmComplexType complexType = edm.getComplexType(FQN);
- assertNotNull(complexType);
- assertEquals(FQN.getNamespace(), complexType.getNamespace());
- assertEquals(FQN.getName(), complexType.getName());
-
- assertNull(edm.getComplexType(WRONG_FQN));
- }
-
- @Test
- public void getAction() {
- EdmAction action = edm.getAction(FQN, null, null);
- assertNotNull(action);
- assertEquals(FQN.getNamespace(), action.getNamespace());
- assertEquals(FQN.getName(), action.getName());
-
- assertNull(edm.getAction(WRONG_FQN, null, null));
- }
-
- @Test
- public void getFunction() {
- EdmFunction function = edm.getFunction(FQN, null, null, new ArrayList<String>());
- assertNotNull(function);
- assertEquals(FQN.getNamespace(), function.getNamespace());
- assertEquals(FQN.getName(), function.getName());
-
- assertNull(edm.getFunction(WRONG_FQN, null, null, new ArrayList<String>()));
- }
-
- @Test
- public void getServiceMetadata() {
- assertNotNull(edm.getServiceMetadata());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/provider/EdmTypeImplTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/provider/EdmTypeImplTest.java b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/provider/EdmTypeImplTest.java
deleted file mode 100644
index 9bcc265..0000000
--- a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/provider/EdmTypeImplTest.java
+++ /dev/null
@@ -1,44 +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.core.edm.provider;
-
-import static org.junit.Assert.assertEquals;
-
-import org.apache.olingo.commons.api.edm.EdmType;
-import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
-import org.apache.olingo.commons.api.edm.helper.FullQualifiedName;
-import org.junit.Test;
-
-public class EdmTypeImplTest {
-
- @Test
- public void getterTest() {
- EdmType type = new EdmTypeImplTester(new FullQualifiedName("namespace", "name"), EdmTypeKind.UNDEFINED);
- assertEquals("name", type.getName());
- assertEquals("namespace", type.getNamespace());
- assertEquals(EdmTypeKind.UNDEFINED, type.getKind());
- }
-
- private class EdmTypeImplTester extends EdmTypeImpl {
- public EdmTypeImplTester(final FullQualifiedName name, final EdmTypeKind kind) {
- super(null, name, kind);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/ActionMapKeyTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/ActionMapKeyTest.java b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/ActionMapKeyTest.java
new file mode 100644
index 0000000..02759c8
--- /dev/null
+++ b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/ActionMapKeyTest.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * 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.odata4.commons.core.edm;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotSame;
+
+import org.apache.olingo.odata4.commons.api.edm.helper.FullQualifiedName;
+import org.junit.Test;
+
+public class ActionMapKeyTest {
+
+ private final FullQualifiedName fqn = new FullQualifiedName("namespace", "name");
+ private final FullQualifiedName fqnType = new FullQualifiedName("namespace2", "name2");
+
+ @Test
+ public void testEqualsMethod() {
+ ActionMapKey key1 = new ActionMapKey(fqn, null, null);
+ ActionMapKey someKey = new ActionMapKey(fqn, null, null);
+ assertEquals(key1, someKey);
+
+ key1 = new ActionMapKey(fqn, null, new Boolean(true));
+ someKey = new ActionMapKey(fqn, null, true);
+ assertEquals(key1, someKey);
+
+ key1 = new ActionMapKey(fqn, fqnType, false);
+ someKey = new ActionMapKey(fqn, fqnType, false);
+ assertEquals(key1, someKey);
+
+ key1 = new ActionMapKey(fqn, fqnType, null);
+ someKey = new ActionMapKey(fqn, fqnType, null);
+ assertEquals(key1, someKey);
+
+ key1 = new ActionMapKey(fqn, fqnType, true);
+ someKey = new ActionMapKey(fqn, fqnType, null);
+ assertNotSame(key1, someKey);
+
+ key1 = new ActionMapKey(fqn, fqnType, true);
+ someKey = new ActionMapKey(fqn, fqnType, false);
+ assertNotSame(key1, someKey);
+
+ key1 = new ActionMapKey(fqn, null, true);
+ someKey = new ActionMapKey(fqn, fqnType, false);
+ assertNotSame(key1, someKey);
+
+ key1 = new ActionMapKey(fqn, null, true);
+ someKey = new ActionMapKey(fqn, null, false);
+ assertNotSame(key1, someKey);
+ }
+
+ @Test
+ public void testHashMethod() {
+ ActionMapKey key1 = new ActionMapKey(fqn, null, null);
+ ActionMapKey someKey = new ActionMapKey(fqn, null, null);
+ assertEquals(key1.hashCode(), someKey.hashCode());
+
+ key1 = new ActionMapKey(fqn, null, new Boolean(true));
+ someKey = new ActionMapKey(fqn, null, true);
+ assertEquals(key1.hashCode(), someKey.hashCode());
+
+ someKey = new ActionMapKey(fqn, fqnType, true);
+ assertNotSame(key1.hashCode(), someKey.hashCode());
+
+ someKey = new ActionMapKey(fqn, fqnType, false);
+ assertNotSame(key1.hashCode(), someKey.hashCode());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/EdmImplCachingTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/EdmImplCachingTest.java b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/EdmImplCachingTest.java
new file mode 100644
index 0000000..0d1fd88
--- /dev/null
+++ b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/EdmImplCachingTest.java
@@ -0,0 +1,361 @@
+/*******************************************************************************
+ * 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.odata4.commons.core.edm;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertNull;
+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.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.olingo.odata4.commons.api.edm.Edm;
+import org.apache.olingo.odata4.commons.api.edm.EdmAction;
+import org.apache.olingo.odata4.commons.api.edm.EdmComplexType;
+import org.apache.olingo.odata4.commons.api.edm.EdmEntityContainer;
+import org.apache.olingo.odata4.commons.api.edm.EdmEntityType;
+import org.apache.olingo.odata4.commons.api.edm.EdmEnumType;
+import org.apache.olingo.odata4.commons.api.edm.EdmFunction;
+import org.apache.olingo.odata4.commons.api.edm.EdmServiceMetadata;
+import org.apache.olingo.odata4.commons.api.edm.EdmTypeDefinition;
+import org.apache.olingo.odata4.commons.api.edm.helper.FullQualifiedName;
+import org.junit.Before;
+import org.junit.Test;
+
+public class EdmImplCachingTest {
+
+ private final FullQualifiedName NAME1 = new FullQualifiedName("testNamespace1", "testName1");
+ private final FullQualifiedName NAME2 = new FullQualifiedName("testNamespace2", "testName2");
+ private Edm edm;
+
+ // TODO: Test with alias
+
+ @Test
+ public void cacheEntityContainer() {
+ EdmEntityContainer entityContainer = edm.getEntityContainer(null);
+ assertNotNull(entityContainer);
+
+ EdmEntityContainer cachedContainer = edm.getEntityContainer(NAME1);
+ assertNotNull(entityContainer);
+
+ assertTrue(entityContainer == cachedContainer);
+ assertEquals(entityContainer, cachedContainer);
+
+ cachedContainer = edm.getEntityContainer(NAME1);
+ assertNotNull(cachedContainer);
+
+ assertTrue(entityContainer == cachedContainer);
+ assertEquals(entityContainer, cachedContainer);
+
+ EdmEntityContainer entityContainer2 = edm.getEntityContainer(NAME2);
+ assertNotNull(entityContainer2);
+
+ assertNotSame(entityContainer, entityContainer2);
+ }
+
+ @Test
+ public void cacheEnumType() {
+ EdmEnumType enumType = edm.getEnumType(NAME1);
+ assertNotNull(enumType);
+
+ EdmEnumType cachedType = edm.getEnumType(NAME1);
+ assertNotNull(cachedType);
+
+ assertTrue(enumType == cachedType);
+ assertEquals(enumType, cachedType);
+
+ EdmEnumType enumType2 = edm.getEnumType(NAME2);
+ assertNotNull(enumType2);
+
+ assertNotSame(enumType, enumType2);
+ }
+
+ @Test
+ public void cacheTypeDefinition() {
+ EdmTypeDefinition typeDefinition = edm.getTypeDefinition(NAME1);
+ assertNotNull(typeDefinition);
+
+ EdmTypeDefinition cachedDefinition = edm.getTypeDefinition(NAME1);
+ assertNotNull(cachedDefinition);
+
+ assertTrue(typeDefinition == cachedDefinition);
+ assertEquals(typeDefinition, cachedDefinition);
+
+ EdmTypeDefinition typeDefinition2 = edm.getTypeDefinition(NAME2);
+ assertNotNull(typeDefinition2);
+
+ assertNotSame(typeDefinition, typeDefinition2);
+ }
+
+ @Test
+ public void cacheEntityType() {
+ EdmEntityType entityType = edm.getEntityType(NAME1);
+ assertNotNull(entityType);
+
+ EdmEntityType cachedType = edm.getEntityType(NAME1);
+ assertNotNull(cachedType);
+
+ assertTrue(entityType == cachedType);
+ assertEquals(entityType, cachedType);
+
+ EdmEntityType entityType2 = edm.getEntityType(NAME2);
+ assertNotNull(entityType2);
+
+ assertNotSame(entityType, entityType2);
+ }
+
+ @Test
+ public void cacheComplexType() {
+ EdmComplexType complexType = edm.getComplexType(NAME1);
+ assertNotNull(complexType);
+
+ EdmComplexType cachedType = edm.getComplexType(NAME1);
+ assertNotNull(cachedType);
+
+ assertTrue(complexType == cachedType);
+ assertEquals(complexType, cachedType);
+
+ EdmComplexType complexType2 = edm.getComplexType(NAME2);
+ assertNotNull(complexType2);
+
+ assertNotSame(complexType, complexType2);
+ }
+
+ @Test
+ public void cacheActionSimple() {
+ EdmAction action = edm.getAction(NAME1, null, null);
+ assertNotNull(action);
+
+ EdmAction cachedAction = edm.getAction(NAME1, null, null);
+ assertNotNull(cachedAction);
+
+ assertTrue(action == cachedAction);
+ assertEquals(action, cachedAction);
+
+ EdmAction action2 = edm.getAction(NAME2, null, false);
+ assertNotNull(action2);
+ assertNotSame(action, action2);
+ }
+
+ @Test
+ public void cacheActionComlex() {
+ EdmAction action = edm.getAction(NAME1, null, null);
+ assertNotNull(action);
+
+ EdmAction cachedAction = edm.getAction(NAME1, null, true);
+ assertNull(cachedAction);
+
+ cachedAction = edm.getAction(NAME1, null, false);
+ assertNull(cachedAction);
+
+ cachedAction = edm.getAction(NAME1, NAME2, null);
+ assertNull(cachedAction);
+
+ cachedAction = edm.getAction(NAME1, NAME2, true);
+ assertNull(cachedAction);
+
+ cachedAction = edm.getAction(NAME1, NAME2, false);
+ assertNull(cachedAction);
+
+ cachedAction = edm.getAction(NAME1, NAME1, null);
+ assertNull(cachedAction);
+
+ cachedAction = edm.getAction(NAME1, NAME1, true);
+ assertNull(cachedAction);
+
+ cachedAction = edm.getAction(NAME1, NAME1, false);
+ assertNull(cachedAction);
+ }
+
+ @Test
+ public void cacheFunctionSimple() {
+ EdmFunction function = edm.getFunction(NAME1, null, null, null);
+ assertNotNull(function);
+
+ EdmFunction cachedfunction = edm.getFunction(NAME1, null, null, null);
+ assertNotNull(cachedfunction);
+
+ assertTrue(function == cachedfunction);
+ assertEquals(function, cachedfunction);
+
+ EdmFunction function2 = edm.getFunction(NAME2, null, false, null);
+ assertNotNull(function2);
+
+ assertNotSame(function, function2);
+ }
+
+ @Test
+ public void cacheFunctionComplex() {
+ EdmFunction function = edm.getFunction(NAME1, null, null, null);
+ assertNotNull(function);
+
+ EdmFunction cachedfunction = edm.getFunction(NAME1, null, false, null);
+ assertNull(cachedfunction);
+
+ cachedfunction = edm.getFunction(NAME1, null, true, null);
+ assertNull(cachedfunction);
+
+ cachedfunction = edm.getFunction(NAME1, null, new Boolean(true), null);
+ assertNull(cachedfunction);
+
+ cachedfunction = edm.getFunction(NAME1, NAME2, null, null);
+ assertNull(cachedfunction);
+
+ cachedfunction = edm.getFunction(NAME1, NAME2, true, null);
+ assertNull(cachedfunction);
+
+ cachedfunction = edm.getFunction(NAME1, NAME2, false, null);
+ assertNull(cachedfunction);
+
+ cachedfunction = edm.getFunction(NAME1, null, null, new ArrayList<String>());
+ assertNull(cachedfunction);
+ }
+
+ @Test
+ public void cacheFunctionComplexWithListContent() {
+
+ }
+
+ @Test
+ public void cacheServiceMetadata() {
+ EdmServiceMetadata serviceMetadata = edm.getServiceMetadata();
+ EdmServiceMetadata cachedMetadata = edm.getServiceMetadata();
+
+ assertTrue(serviceMetadata == cachedMetadata);
+ assertEquals(serviceMetadata, cachedMetadata);
+ }
+
+ @Before
+ public void setup() {
+ edm = new LocalEdm();
+ }
+
+ private class LocalEdm extends EdmImpl {
+ @Override
+ public EdmEntityContainer createEntityContainer(final FullQualifiedName fqn) {
+ if (NAME1.equals(fqn) || fqn == null) {
+ EdmEntityContainer container = mock(EdmEntityContainer.class);
+ when(container.getNamespace()).thenReturn(NAME1.getNamespace());
+ when(container.getName()).thenReturn(NAME1.getName());
+ return container;
+ } else if (NAME2.equals(fqn)) {
+ EdmEntityContainer container = mock(EdmEntityContainer.class);
+ when(container.getNamespace()).thenReturn(fqn.getNamespace());
+ when(container.getName()).thenReturn(fqn.getName());
+ return container;
+ }
+ return null;
+ }
+
+ @Override
+ public EdmEnumType createEnumType(final FullQualifiedName fqn) {
+ if (NAME1.equals(fqn) || NAME2.equals(fqn)) {
+ EdmEnumType enumType = mock(EdmEnumType.class);
+ when(enumType.getNamespace()).thenReturn(fqn.getNamespace());
+ when(enumType.getName()).thenReturn(fqn.getName());
+ return enumType;
+ }
+ return null;
+ }
+
+ @Override
+ public EdmTypeDefinition createTypeDefinition(final FullQualifiedName fqn) {
+ if (NAME1.equals(fqn) || NAME2.equals(fqn)) {
+ EdmTypeDefinition typeDefinition = mock(EdmTypeDefinition.class);
+ when(typeDefinition.getNamespace()).thenReturn(fqn.getNamespace());
+ when(typeDefinition.getName()).thenReturn(fqn.getName());
+ return typeDefinition;
+ }
+ return null;
+ }
+
+ @Override
+ public EdmEntityType createEntityType(final FullQualifiedName fqn) {
+ if (NAME1.equals(fqn) || NAME2.equals(fqn)) {
+ EdmEntityType entityType = mock(EdmEntityType.class);
+ when(entityType.getNamespace()).thenReturn(fqn.getNamespace());
+ when(entityType.getName()).thenReturn(fqn.getName());
+ return entityType;
+ }
+ return null;
+ }
+
+ @Override
+ public EdmComplexType createComplexType(final FullQualifiedName fqn) {
+ if (NAME1.equals(fqn) || NAME2.equals(fqn)) {
+ EdmComplexType complexType = mock(EdmComplexType.class);
+ when(complexType.getNamespace()).thenReturn(fqn.getNamespace());
+ when(complexType.getName()).thenReturn(fqn.getName());
+ return complexType;
+ }
+ return null;
+ }
+
+ @Override
+ public EdmAction createAction(final FullQualifiedName fqn, final FullQualifiedName bindingParameterTypeName,
+ final Boolean isBindingParameterCollection) {
+ if (NAME1.equals(fqn) && bindingParameterTypeName == null && isBindingParameterCollection == null) {
+ EdmAction action = mock(EdmAction.class);
+ when(action.getNamespace()).thenReturn(fqn.getNamespace());
+ when(action.getName()).thenReturn(fqn.getName());
+ return action;
+ } else if (NAME2.equals(fqn)) {
+ EdmAction action = mock(EdmAction.class);
+ when(action.getNamespace()).thenReturn(fqn.getNamespace());
+ when(action.getName()).thenReturn(fqn.getName());
+ return action;
+ }
+ return null;
+ }
+
+ @Override
+ public EdmFunction createFunction(final FullQualifiedName fqn, final FullQualifiedName bindingParameterTypeName,
+ final Boolean isBindingParameterCollection, final List<String> bindingParameterNames) {
+ if (NAME1.equals(fqn) && bindingParameterTypeName == null && isBindingParameterCollection == null
+ && bindingParameterNames == null) {
+ EdmFunction function = mock(EdmFunction.class);
+ when(function.getNamespace()).thenReturn(fqn.getNamespace());
+ when(function.getName()).thenReturn(fqn.getName());
+ return function;
+ } else if (NAME2.equals(fqn)) {
+ EdmFunction function = mock(EdmFunction.class);
+ when(function.getNamespace()).thenReturn(fqn.getNamespace());
+ when(function.getName()).thenReturn(fqn.getName());
+ return function;
+ }
+ return null;
+ }
+
+ @Override
+ public EdmServiceMetadata createServiceMetadata() {
+ return mock(EdmServiceMetadata.class);
+ }
+
+ @Override
+ protected Map<String, String> createAliasToNamespaceInfo() {
+ return new HashMap<String, String>();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/EdmImplCallCreateTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/EdmImplCallCreateTest.java b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/EdmImplCallCreateTest.java
new file mode 100644
index 0000000..05612ee
--- /dev/null
+++ b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/odata4/commons/core/edm/EdmImplCallCreateTest.java
@@ -0,0 +1,225 @@
+/*******************************************************************************
+ * 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.odata4.commons.core.edm;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.olingo.odata4.commons.api.edm.Edm;
+import org.apache.olingo.odata4.commons.api.edm.EdmAction;
+import org.apache.olingo.odata4.commons.api.edm.EdmComplexType;
+import org.apache.olingo.odata4.commons.api.edm.EdmEntityContainer;
+import org.apache.olingo.odata4.commons.api.edm.EdmEntityType;
+import org.apache.olingo.odata4.commons.api.edm.EdmEnumType;
+import org.apache.olingo.odata4.commons.api.edm.EdmFunction;
+import org.apache.olingo.odata4.commons.api.edm.EdmServiceMetadata;
+import org.apache.olingo.odata4.commons.api.edm.EdmTypeDefinition;
+import org.apache.olingo.odata4.commons.api.edm.helper.FullQualifiedName;
+import org.junit.Before;
+import org.junit.Test;
+
+public class EdmImplCallCreateTest {
+
+ private final FullQualifiedName FQN = new FullQualifiedName("testNamespace", "testName");
+ private final FullQualifiedName WRONG_FQN = new FullQualifiedName("wrong", "wrong");
+ private Edm edm;
+
+ @Test
+ public void callCreateEntityContainer() {
+ EdmEntityContainer entityContainer = edm.getEntityContainer(FQN);
+ assertNotNull(entityContainer);
+ assertEquals(FQN.getNamespace(), entityContainer.getNamespace());
+ assertEquals(FQN.getName(), entityContainer.getName());
+
+ entityContainer = edm.getEntityContainer(null);
+ assertNotNull(entityContainer);
+ assertEquals(FQN.getNamespace(), entityContainer.getNamespace());
+ assertEquals(FQN.getName(), entityContainer.getName());
+
+ assertNull(edm.getEntityContainer(WRONG_FQN));
+ }
+
+ @Test
+ public void callCreateEnumType() {
+ EdmEnumType enumType = edm.getEnumType(FQN);
+ assertNotNull(enumType);
+ assertEquals(FQN.getNamespace(), enumType.getNamespace());
+ assertEquals(FQN.getName(), enumType.getName());
+
+ assertNull(edm.getEnumType(WRONG_FQN));
+ }
+
+ @Test
+ public void callCreateTypeDefinition() {
+ EdmTypeDefinition typeDefinition = edm.getTypeDefinition(FQN);
+ assertNotNull(typeDefinition);
+ assertEquals(FQN.getNamespace(), typeDefinition.getNamespace());
+ assertEquals(FQN.getName(), typeDefinition.getName());
+
+ assertNull(edm.getTypeDefinition(WRONG_FQN));
+ }
+
+ @Test
+ public void callCreateEntityType() {
+ EdmEntityType entityType = edm.getEntityType(FQN);
+ assertNotNull(entityType);
+ assertEquals(FQN.getNamespace(), entityType.getNamespace());
+ assertEquals(FQN.getName(), entityType.getName());
+
+ assertNull(edm.getEntityType(WRONG_FQN));
+ }
+
+ @Test
+ public void callCreateComplexType() {
+ EdmComplexType complexType = edm.getComplexType(FQN);
+ assertNotNull(complexType);
+ assertEquals(FQN.getNamespace(), complexType.getNamespace());
+ assertEquals(FQN.getName(), complexType.getName());
+
+ assertNull(edm.getComplexType(WRONG_FQN));
+ }
+
+ @Test
+ public void callCreateAction() {
+ EdmAction action = edm.getAction(FQN, null, null);
+ assertNotNull(action);
+ assertEquals(FQN.getNamespace(), action.getNamespace());
+ assertEquals(FQN.getName(), action.getName());
+
+ assertNull(edm.getAction(WRONG_FQN, null, null));
+ }
+
+ @Test
+ public void callCreateFunction() {
+ EdmFunction function = edm.getFunction(FQN, null, null, null);
+ assertNotNull(function);
+ assertEquals(FQN.getNamespace(), function.getNamespace());
+ assertEquals(FQN.getName(), function.getName());
+
+ assertNull(edm.getFunction(WRONG_FQN, null, null, null));
+ }
+
+ @Test
+ public void callCreateServiceMetadata() {
+ assertNotNull(edm.getServiceMetadata());
+ }
+
+ @Before
+ public void setup() {
+ edm = new LocalEdm();
+ }
+
+ private class LocalEdm extends EdmImpl {
+ @Override
+ public EdmEntityContainer createEntityContainer(final FullQualifiedName fqn) {
+ if (fqn == null || FQN.getNamespace().equals(fqn.getNamespace()) && FQN.getName().equals(fqn.getName())) {
+ EdmEntityContainer container = mock(EdmEntityContainer.class);
+ when(container.getNamespace()).thenReturn(FQN.getNamespace());
+ when(container.getName()).thenReturn(FQN.getName());
+ return container;
+ }
+ return null;
+ }
+
+ @Override
+ public EdmEnumType createEnumType(final FullQualifiedName fqn) {
+ if (FQN.getNamespace().equals(fqn.getNamespace()) && FQN.getName().equals(fqn.getName())) {
+ EdmEnumType enumType = mock(EdmEnumType.class);
+ when(enumType.getNamespace()).thenReturn(fqn.getNamespace());
+ when(enumType.getName()).thenReturn(fqn.getName());
+ return enumType;
+ }
+ return null;
+ }
+
+ @Override
+ public EdmTypeDefinition createTypeDefinition(final FullQualifiedName fqn) {
+ if (FQN.getNamespace().equals(fqn.getNamespace()) && FQN.getName().equals(fqn.getName())) {
+ EdmTypeDefinition typeDefinition = mock(EdmTypeDefinition.class);
+ when(typeDefinition.getNamespace()).thenReturn(fqn.getNamespace());
+ when(typeDefinition.getName()).thenReturn(fqn.getName());
+ return typeDefinition;
+ }
+ return null;
+ }
+
+ @Override
+ public EdmEntityType createEntityType(final FullQualifiedName fqn) {
+ if (FQN.getNamespace().equals(fqn.getNamespace()) && FQN.getName().equals(fqn.getName())) {
+ EdmEntityType entityType = mock(EdmEntityType.class);
+ when(entityType.getNamespace()).thenReturn(fqn.getNamespace());
+ when(entityType.getName()).thenReturn(fqn.getName());
+ return entityType;
+ }
+ return null;
+ }
+
+ @Override
+ public EdmComplexType createComplexType(final FullQualifiedName fqn) {
+ if (FQN.getNamespace().equals(fqn.getNamespace()) && FQN.getName().equals(fqn.getName())) {
+ EdmComplexType complexType = mock(EdmComplexType.class);
+ when(complexType.getNamespace()).thenReturn(fqn.getNamespace());
+ when(complexType.getName()).thenReturn(fqn.getName());
+ return complexType;
+ }
+ return null;
+ }
+
+ @Override
+ public EdmAction createAction(final FullQualifiedName fqn, final FullQualifiedName bindingParameterTypeName,
+ final Boolean isBindingParameterCollection) {
+ if (FQN.getNamespace().equals(fqn.getNamespace()) && FQN.getName().equals(fqn.getName())) {
+ EdmAction action = mock(EdmAction.class);
+ when(action.getNamespace()).thenReturn(fqn.getNamespace());
+ when(action.getName()).thenReturn(fqn.getName());
+ return action;
+ }
+ return null;
+ }
+
+ @Override
+ public EdmFunction createFunction(final FullQualifiedName fqn, final FullQualifiedName bindingParameterTypeName,
+ final Boolean isBindingParameterCollection, final List<String> bindingParameterNames) {
+ if (FQN.getNamespace().equals(fqn.getNamespace()) && FQN.getName().equals(fqn.getName())) {
+ EdmFunction function = mock(EdmFunction.class);
+ when(function.getNamespace()).thenReturn(fqn.getNamespace());
+ when(function.getName()).thenReturn(fqn.getName());
+ return function;
+ }
+ return null;
+ }
+
+ @Override
+ public EdmServiceMetadata createServiceMetadata() {
+ return mock(EdmServiceMetadata.class);
+ }
+
+ @Override
+ protected Map<String, String> createAliasToNamespaceInfo() {
+ return new HashMap<String, String>();
+ }
+ }
+}