[OLINGO-1004] Moved some Metadata Tests
Signed-off-by: Michael Bolz <michael.bolz@sap.com>
This commit is contained in:
parent
b380f97b74
commit
b1db030cb8
|
@ -24,8 +24,6 @@ import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.edm.Edm;
|
import org.apache.olingo.commons.api.edm.Edm;
|
||||||
import org.apache.olingo.commons.api.edm.EdmAnnotation;
|
import org.apache.olingo.commons.api.edm.EdmAnnotation;
|
||||||
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
|
|
||||||
import org.apache.olingo.commons.api.edm.EdmEntitySet;
|
|
||||||
import org.apache.olingo.commons.api.edm.EdmEnumType;
|
import org.apache.olingo.commons.api.edm.EdmEnumType;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||||
import org.apache.olingo.commons.api.edm.EdmSchema;
|
import org.apache.olingo.commons.api.edm.EdmSchema;
|
||||||
|
@ -38,44 +36,12 @@ import org.junit.Test;
|
||||||
|
|
||||||
public class MetadataTestITCase extends AbstractTestITCase {
|
public class MetadataTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
|
||||||
public void include() {
|
|
||||||
final Edm edm = client.getRetrieveRequestFactory().getMetadataRequest(testNorthwindRootURL).execute().getBody();
|
|
||||||
assertNotNull(edm);
|
|
||||||
|
|
||||||
final EdmEntityContainer container = edm.getEntityContainer(
|
|
||||||
new FullQualifiedName("ODataWebExperimental.Northwind.Model", "NorthwindEntities"));
|
|
||||||
assertNotNull(container);
|
|
||||||
|
|
||||||
final EdmEntitySet categories = container.getEntitySet("Categories");
|
|
||||||
assertNotNull(categories);
|
|
||||||
assertEquals("NorthwindModel", categories.getEntityType().getNamespace());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void vocabularies() {
|
public void vocabularies() {
|
||||||
final Edm edm = client.getRetrieveRequestFactory().
|
final Edm edm = client.getRetrieveRequestFactory().
|
||||||
getMetadataRequest(testVocabulariesServiceRootURL).execute().getBody();
|
getMetadataRequest(testVocabulariesServiceRootURL).execute().getBody();
|
||||||
assertNotNull(edm);
|
assertNotNull(edm);
|
||||||
|
|
||||||
// 1. core
|
|
||||||
final EdmSchema core = edm.getSchema("Org.OData.Core.V1");
|
|
||||||
assertNotNull(core);
|
|
||||||
final EdmSchema coreAlias = edm.getSchema("Core");
|
|
||||||
assertEquals(core, coreAlias);
|
|
||||||
|
|
||||||
final EdmTerm descriptionTerm = edm.getTerm(new FullQualifiedName("Core", "Description"));
|
|
||||||
assertNotNull(descriptionTerm);
|
|
||||||
assertEquals(descriptionTerm.getFullQualifiedName(),
|
|
||||||
edm.getTerm(new FullQualifiedName("Org.OData.Core.V1", "Description")).getFullQualifiedName());
|
|
||||||
|
|
||||||
final EdmAnnotation description = core.getAnnotation(descriptionTerm, null);
|
|
||||||
assertNotNull(description);
|
|
||||||
// assertEquals("Core terms needed to write vocabularies",
|
|
||||||
// description.getExpression().asConstant().getValue().asPrimitive().getName());
|
|
||||||
assertEquals("Core terms needed to write vocabularies",
|
|
||||||
description.getExpression().asConstant().getValueAsString());
|
|
||||||
|
|
||||||
final EdmTerm isLanguageDependent = edm.getTerm(new FullQualifiedName("Core", "IsLanguageDependent"));
|
final EdmTerm isLanguageDependent = edm.getTerm(new FullQualifiedName("Core", "IsLanguageDependent"));
|
||||||
assertNotNull(isLanguageDependent);
|
assertNotNull(isLanguageDependent);
|
||||||
assertTrue(isLanguageDependent.getAppliesTo().contains(TargetType.Property));
|
assertTrue(isLanguageDependent.getAppliesTo().contains(TargetType.Property));
|
||||||
|
@ -83,7 +49,6 @@ public class MetadataTestITCase extends AbstractTestITCase {
|
||||||
assertEquals(edm.getTypeDefinition(new FullQualifiedName("Core", "Tag")), isLanguageDependent.getType());
|
assertEquals(edm.getTypeDefinition(new FullQualifiedName("Core", "Tag")), isLanguageDependent.getType());
|
||||||
assertEquals(EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Boolean),
|
assertEquals(EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Boolean),
|
||||||
((EdmTypeDefinition) isLanguageDependent.getType()).getUnderlyingType());
|
((EdmTypeDefinition) isLanguageDependent.getType()).getUnderlyingType());
|
||||||
assertNotNull(isLanguageDependent.getAnnotation(descriptionTerm, null));
|
|
||||||
|
|
||||||
final EdmTerm permissions = edm.getTerm(new FullQualifiedName("Core", "Permissions"));
|
final EdmTerm permissions = edm.getTerm(new FullQualifiedName("Core", "Permissions"));
|
||||||
assertNotNull(permissions);
|
assertNotNull(permissions);
|
||||||
|
|
|
@ -69,6 +69,8 @@ import org.apache.olingo.client.api.domain.ClientObjectFactory;
|
||||||
import org.apache.olingo.client.api.domain.ClientPrimitiveValue;
|
import org.apache.olingo.client.api.domain.ClientPrimitiveValue;
|
||||||
import org.apache.olingo.client.api.domain.ClientProperty;
|
import org.apache.olingo.client.api.domain.ClientProperty;
|
||||||
import org.apache.olingo.client.api.domain.ClientServiceDocument;
|
import org.apache.olingo.client.api.domain.ClientServiceDocument;
|
||||||
|
import org.apache.olingo.client.api.domain.ClientSingleton;
|
||||||
|
import org.apache.olingo.client.api.domain.ClientValuable;
|
||||||
import org.apache.olingo.client.api.domain.ClientValue;
|
import org.apache.olingo.client.api.domain.ClientValue;
|
||||||
import org.apache.olingo.client.api.edm.xml.Reference;
|
import org.apache.olingo.client.api.edm.xml.Reference;
|
||||||
import org.apache.olingo.client.api.edm.xml.XMLMetadata;
|
import org.apache.olingo.client.api.edm.xml.XMLMetadata;
|
||||||
|
@ -77,13 +79,16 @@ import org.apache.olingo.client.core.uri.URIUtils;
|
||||||
import org.apache.olingo.commons.api.edm.Edm;
|
import org.apache.olingo.commons.api.edm.Edm;
|
||||||
import org.apache.olingo.commons.api.edm.EdmActionImport;
|
import org.apache.olingo.commons.api.edm.EdmActionImport;
|
||||||
import org.apache.olingo.commons.api.edm.EdmAnnotation;
|
import org.apache.olingo.commons.api.edm.EdmAnnotation;
|
||||||
|
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
|
||||||
import org.apache.olingo.commons.api.edm.EdmEntitySet;
|
import org.apache.olingo.commons.api.edm.EdmEntitySet;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||||
|
import org.apache.olingo.commons.api.edm.EdmTerm;
|
||||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||||
import org.apache.olingo.commons.api.ex.ODataError;
|
import org.apache.olingo.commons.api.ex.ODataError;
|
||||||
import org.apache.olingo.commons.api.format.ContentType;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.http.HttpHeader;
|
import org.apache.olingo.commons.api.http.HttpHeader;
|
||||||
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -129,15 +134,23 @@ public class BasicITCase extends AbstractParamTecSvcITCase {
|
||||||
public void readMetadata() {
|
public void readMetadata() {
|
||||||
EdmMetadataRequest request = getClient().getRetrieveRequestFactory().getMetadataRequest(SERVICE_URI);
|
EdmMetadataRequest request = getClient().getRetrieveRequestFactory().getMetadataRequest(SERVICE_URI);
|
||||||
assertNotNull(request);
|
assertNotNull(request);
|
||||||
setCookieHeader(request);
|
setCookieHeader(request);
|
||||||
|
|
||||||
ODataRetrieveResponse<Edm> response = request.execute();
|
ODataRetrieveResponse<Edm> response = request.execute();
|
||||||
saveCookieHeader(response);
|
saveCookieHeader(response);
|
||||||
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
|
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
|
||||||
|
|
||||||
Edm edm = response.getBody();
|
Edm edm = response.getBody();
|
||||||
|
|
||||||
assertNotNull(edm);
|
assertNotNull(edm);
|
||||||
|
|
||||||
|
final EdmEntityContainer container = edm.getEntityContainer(
|
||||||
|
new FullQualifiedName("olingo.odata.test1", "Container"));
|
||||||
|
assertNotNull(container);
|
||||||
|
|
||||||
|
final EdmEntitySet esAllPrim = container.getEntitySet("ESAllPrim");
|
||||||
|
assertNotNull(esAllPrim);
|
||||||
|
assertEquals("olingo.odata.test1", esAllPrim.getEntityType().getNamespace());
|
||||||
|
|
||||||
assertEquals(2, edm.getSchemas().size());
|
assertEquals(2, edm.getSchemas().size());
|
||||||
assertEquals(SERVICE_NAMESPACE, edm.getSchema(SERVICE_NAMESPACE).getNamespace());
|
assertEquals(SERVICE_NAMESPACE, edm.getSchema(SERVICE_NAMESPACE).getNamespace());
|
||||||
assertEquals("Namespace1_Alias", edm.getSchema(SERVICE_NAMESPACE).getAlias());
|
assertEquals("Namespace1_Alias", edm.getSchema(SERVICE_NAMESPACE).getAlias());
|
||||||
|
@ -145,6 +158,25 @@ public class BasicITCase extends AbstractParamTecSvcITCase {
|
||||||
assertEquals("Core", edm.getSchema("Org.OData.Core.V1").getAlias());
|
assertEquals("Core", edm.getSchema("Org.OData.Core.V1").getAlias());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void readMetadataWithTerm() {
|
||||||
|
EdmMetadataRequest request = getClient().getRetrieveRequestFactory().getMetadataRequest(SERVICE_URI);
|
||||||
|
assertNotNull(request);
|
||||||
|
setCookieHeader(request);
|
||||||
|
|
||||||
|
ODataRetrieveResponse<Edm> response = request.execute();
|
||||||
|
saveCookieHeader(response);
|
||||||
|
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
|
||||||
|
|
||||||
|
Edm edm = response.getBody();
|
||||||
|
assertNotNull(edm);
|
||||||
|
|
||||||
|
final EdmTerm descriptionTerm = edm.getTerm(new FullQualifiedName("Core", "Description"));
|
||||||
|
assertNotNull(descriptionTerm);
|
||||||
|
assertEquals(descriptionTerm.getFullQualifiedName(),
|
||||||
|
edm.getTerm(new FullQualifiedName("Org.OData.Core.V1", "Description")).getFullQualifiedName());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void readMetadataWithAnnotations() {
|
public void readMetadataWithAnnotations() {
|
||||||
EdmMetadataRequest request = getClient().getRetrieveRequestFactory().getMetadataRequest(SERVICE_URI);
|
EdmMetadataRequest request = getClient().getRetrieveRequestFactory().getMetadataRequest(SERVICE_URI);
|
||||||
|
@ -167,6 +199,9 @@ public class BasicITCase extends AbstractParamTecSvcITCase {
|
||||||
entitySet.getAnnotation(edm.getTerm(new FullQualifiedName("Org.OData.Core.V1", "Description")), null);
|
entitySet.getAnnotation(edm.getTerm(new FullQualifiedName("Org.OData.Core.V1", "Description")), null);
|
||||||
assertNotNull(annotation);
|
assertNotNull(annotation);
|
||||||
|
|
||||||
|
assertEquals("Contains entities with all primitive types",
|
||||||
|
annotation.getExpression().asConstant().getValueAsString());
|
||||||
|
|
||||||
EdmActionImport actionImport = edm.getEntityContainer().getActionImport("AIRTString");
|
EdmActionImport actionImport = edm.getEntityContainer().getActionImport("AIRTString");
|
||||||
annotations = actionImport.getAnnotations();
|
annotations = actionImport.getAnnotations();
|
||||||
assertNotNull(annotations);
|
assertNotNull(annotations);
|
||||||
|
@ -299,7 +334,7 @@ public class BasicITCase extends AbstractParamTecSvcITCase {
|
||||||
assertThat(error.getMessage(), containsString("key"));
|
assertThat(error.getMessage(), containsString("key"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void readEntity() throws Exception {
|
public void readEntity() throws Exception {
|
||||||
ODataEntityRequest<ClientEntity> request = getClient().getRetrieveRequestFactory()
|
ODataEntityRequest<ClientEntity> request = getClient().getRetrieveRequestFactory()
|
||||||
|
|
Loading…
Reference in New Issue