odata 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +0 -13
- data/CHANGELOG.md +4 -0
- data/lib/odata.rb +2 -2
- data/lib/odata/entity.rb +64 -47
- data/lib/odata/entity_set.rb +17 -20
- data/lib/odata/properties/boolean.rb +5 -0
- data/lib/odata/properties/integer.rb +16 -24
- data/lib/odata/property.rb +22 -0
- data/lib/odata/query.rb +105 -41
- data/lib/odata/query/criteria.rb +54 -48
- data/lib/odata/service.rb +2 -2
- data/lib/odata/version.rb +1 -1
- data/odata.gemspec +1 -2
- data/spec/fixtures/vcr_cassettes/entity_set_specs.yml +952 -0
- data/spec/fixtures/vcr_cassettes/entity_set_specs/bad_entry.yml +220 -0
- data/spec/fixtures/vcr_cassettes/entity_set_specs/existing_entry.yml +313 -0
- data/spec/fixtures/vcr_cassettes/entity_set_specs/new_entry.yml +226 -0
- data/spec/fixtures/vcr_cassettes/entity_specs.yml +164 -0
- data/spec/fixtures/vcr_cassettes/query_specs.yml +164 -0
- data/spec/fixtures/vcr_cassettes/service_registry_specs.yml +164 -0
- data/spec/fixtures/vcr_cassettes/service_specs.yml +164 -0
- data/spec/odata/entity_set_spec.rb +22 -40
- data/spec/odata/entity_spec.rb +5 -5
- data/spec/odata/query/criteria_spec.rb +57 -24
- data/spec/odata/query_spec.rb +79 -40
- data/spec/odata/service_registry_spec.rb +1 -1
- data/spec/odata/service_spec.rb +1 -7
- data/spec/spec_helper.rb +9 -46
- metadata +21 -19
@@ -0,0 +1,164 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://services.odata.org/OData/OData.svc/$metadata
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Typhoeus - https://github.com/typhoeus/typhoeus
|
12
|
+
response:
|
13
|
+
status:
|
14
|
+
code: 200
|
15
|
+
message: OK
|
16
|
+
headers:
|
17
|
+
Cache-Control:
|
18
|
+
- no-cache
|
19
|
+
Content-Length:
|
20
|
+
- '10034'
|
21
|
+
Content-Type:
|
22
|
+
- application/xml;charset=utf-8
|
23
|
+
Server:
|
24
|
+
- Microsoft-IIS/8.0
|
25
|
+
X-Content-Type-Options:
|
26
|
+
- nosniff
|
27
|
+
DataServiceVersion:
|
28
|
+
- 3.0;
|
29
|
+
X-AspNet-Version:
|
30
|
+
- 4.0.30319
|
31
|
+
X-Powered-By:
|
32
|
+
- ASP.NET
|
33
|
+
Access-Control-Allow-Origin:
|
34
|
+
- "*"
|
35
|
+
Access-Control-Allow-Methods:
|
36
|
+
- GET
|
37
|
+
Access-Control-Allow-Headers:
|
38
|
+
- Accept, Origin, Content-Type, MaxDataServiceVersion
|
39
|
+
Access-Control-Expose-Headers:
|
40
|
+
- DataServiceVersion
|
41
|
+
Set-Cookie:
|
42
|
+
- ARRAffinity=a9aad020fb0149d28d0efdb1e8bab24ad3481a904c8fb94abced8813c01ee265;Path=/;Domain=services.odata.org
|
43
|
+
Date:
|
44
|
+
- Sat, 19 Jul 2014 02:59:51 GMT
|
45
|
+
body:
|
46
|
+
encoding: UTF-8
|
47
|
+
string: <?xml version="1.0" encoding="utf-8"?><edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx"><edmx:DataServices
|
48
|
+
m:DataServiceVersion="3.0" m:MaxDataServiceVersion="3.0" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><Schema
|
49
|
+
Namespace="ODataDemo" xmlns="http://schemas.microsoft.com/ado/2009/11/edm"><EntityType
|
50
|
+
Name="Product"><Key><PropertyRef Name="ID" /></Key><Property Name="ID" Type="Edm.Int32"
|
51
|
+
Nullable="false" /><Property Name="Name" Type="Edm.String" m:FC_TargetPath="SyndicationTitle"
|
52
|
+
m:FC_ContentKind="text" m:FC_KeepInContent="false" /><Property Name="Description"
|
53
|
+
Type="Edm.String" m:FC_TargetPath="SyndicationSummary" m:FC_ContentKind="text"
|
54
|
+
m:FC_KeepInContent="false" /><Property Name="ReleaseDate" Type="Edm.DateTime"
|
55
|
+
Nullable="false" /><Property Name="DiscontinuedDate" Type="Edm.DateTime" /><Property
|
56
|
+
Name="Rating" Type="Edm.Int16" Nullable="false" /><Property Name="Price" Type="Edm.Double"
|
57
|
+
Nullable="false" /><NavigationProperty Name="Categories" Relationship="ODataDemo.Product_Categories_Category_Products"
|
58
|
+
ToRole="Category_Products" FromRole="Product_Categories" /><NavigationProperty
|
59
|
+
Name="Supplier" Relationship="ODataDemo.Product_Supplier_Supplier_Products"
|
60
|
+
ToRole="Supplier_Products" FromRole="Product_Supplier" /><NavigationProperty
|
61
|
+
Name="ProductDetail" Relationship="ODataDemo.Product_ProductDetail_ProductDetail_Product"
|
62
|
+
ToRole="ProductDetail_Product" FromRole="Product_ProductDetail" /></EntityType><EntityType
|
63
|
+
Name="FeaturedProduct" BaseType="ODataDemo.Product"><NavigationProperty Name="Advertisement"
|
64
|
+
Relationship="ODataDemo.FeaturedProduct_Advertisement_Advertisement_FeaturedProduct"
|
65
|
+
ToRole="Advertisement_FeaturedProduct" FromRole="FeaturedProduct_Advertisement"
|
66
|
+
/></EntityType><EntityType Name="ProductDetail"><Key><PropertyRef Name="ProductID"
|
67
|
+
/></Key><Property Name="ProductID" Type="Edm.Int32" Nullable="false" /><Property
|
68
|
+
Name="Details" Type="Edm.String" /><NavigationProperty Name="Product" Relationship="ODataDemo.Product_ProductDetail_ProductDetail_Product"
|
69
|
+
ToRole="Product_ProductDetail" FromRole="ProductDetail_Product" /></EntityType><EntityType
|
70
|
+
Name="Category" OpenType="true"><Key><PropertyRef Name="ID" /></Key><Property
|
71
|
+
Name="ID" Type="Edm.Int32" Nullable="false" /><Property Name="Name" Type="Edm.String"
|
72
|
+
m:FC_TargetPath="SyndicationTitle" m:FC_ContentKind="text" m:FC_KeepInContent="true"
|
73
|
+
/><NavigationProperty Name="Products" Relationship="ODataDemo.Product_Categories_Category_Products"
|
74
|
+
ToRole="Product_Categories" FromRole="Category_Products" /></EntityType><EntityType
|
75
|
+
Name="Supplier"><Key><PropertyRef Name="ID" /></Key><Property Name="ID" Type="Edm.Int32"
|
76
|
+
Nullable="false" /><Property Name="Name" Type="Edm.String" m:FC_TargetPath="SyndicationTitle"
|
77
|
+
m:FC_ContentKind="text" m:FC_KeepInContent="true" /><Property Name="Address"
|
78
|
+
Type="ODataDemo.Address" /><Property Name="Location" Type="Edm.GeographyPoint"
|
79
|
+
SRID="Variable" /><Property Name="Concurrency" Type="Edm.Int32" ConcurrencyMode="Fixed"
|
80
|
+
Nullable="false" /><NavigationProperty Name="Products" Relationship="ODataDemo.Product_Supplier_Supplier_Products"
|
81
|
+
ToRole="Product_Supplier" FromRole="Supplier_Products" /></EntityType><ComplexType
|
82
|
+
Name="Address"><Property Name="Street" Type="Edm.String" /><Property Name="City"
|
83
|
+
Type="Edm.String" /><Property Name="State" Type="Edm.String" /><Property Name="ZipCode"
|
84
|
+
Type="Edm.String" /><Property Name="Country" Type="Edm.String" /></ComplexType><EntityType
|
85
|
+
Name="Person"><Key><PropertyRef Name="ID" /></Key><Property Name="ID" Type="Edm.Int32"
|
86
|
+
Nullable="false" /><Property Name="Name" Type="Edm.String" /><NavigationProperty
|
87
|
+
Name="PersonDetail" Relationship="ODataDemo.Person_PersonDetail_PersonDetail_Person"
|
88
|
+
ToRole="PersonDetail_Person" FromRole="Person_PersonDetail" /></EntityType><EntityType
|
89
|
+
Name="Customer" BaseType="ODataDemo.Person"><Property Name="TotalExpense"
|
90
|
+
Type="Edm.Decimal" Nullable="false" /></EntityType><EntityType Name="Employee"
|
91
|
+
BaseType="ODataDemo.Person"><Property Name="EmployeeID" Type="Edm.Int64" Nullable="false"
|
92
|
+
/><Property Name="HireDate" Type="Edm.DateTime" Nullable="false" /><Property
|
93
|
+
Name="Salary" Type="Edm.Single" Nullable="false" /></EntityType><EntityType
|
94
|
+
Name="PersonDetail"><Key><PropertyRef Name="PersonID" /></Key><Property Name="PersonID"
|
95
|
+
Type="Edm.Int32" Nullable="false" /><Property Name="Age" Type="Edm.Byte" Nullable="false"
|
96
|
+
/><Property Name="Gender" Type="Edm.Boolean" Nullable="false" /><Property
|
97
|
+
Name="Phone" Type="Edm.String" /><Property Name="Address" Type="ODataDemo.Address"
|
98
|
+
/><Property Name="Photo" Type="Edm.Stream" Nullable="false" /><NavigationProperty
|
99
|
+
Name="Person" Relationship="ODataDemo.Person_PersonDetail_PersonDetail_Person"
|
100
|
+
ToRole="Person_PersonDetail" FromRole="PersonDetail_Person" /></EntityType><EntityType
|
101
|
+
Name="Advertisement" m:HasStream="true"><Key><PropertyRef Name="ID" /></Key><Property
|
102
|
+
Name="ID" Type="Edm.Guid" Nullable="false" /><Property Name="Name" Type="Edm.String"
|
103
|
+
/><Property Name="AirDate" Type="Edm.DateTime" Nullable="false" /><NavigationProperty
|
104
|
+
Name="FeaturedProduct" Relationship="ODataDemo.FeaturedProduct_Advertisement_Advertisement_FeaturedProduct"
|
105
|
+
ToRole="FeaturedProduct_Advertisement" FromRole="Advertisement_FeaturedProduct"
|
106
|
+
/></EntityType><Association Name="Product_Categories_Category_Products"><End
|
107
|
+
Type="ODataDemo.Category" Role="Category_Products" Multiplicity="*" /><End
|
108
|
+
Type="ODataDemo.Product" Role="Product_Categories" Multiplicity="*" /></Association><Association
|
109
|
+
Name="Product_Supplier_Supplier_Products"><End Type="ODataDemo.Supplier" Role="Supplier_Products"
|
110
|
+
Multiplicity="0..1" /><End Type="ODataDemo.Product" Role="Product_Supplier"
|
111
|
+
Multiplicity="*" /></Association><Association Name="Product_ProductDetail_ProductDetail_Product"><End
|
112
|
+
Type="ODataDemo.ProductDetail" Role="ProductDetail_Product" Multiplicity="0..1"
|
113
|
+
/><End Type="ODataDemo.Product" Role="Product_ProductDetail" Multiplicity="0..1"
|
114
|
+
/></Association><Association Name="FeaturedProduct_Advertisement_Advertisement_FeaturedProduct"><End
|
115
|
+
Type="ODataDemo.Advertisement" Role="Advertisement_FeaturedProduct" Multiplicity="0..1"
|
116
|
+
/><End Type="ODataDemo.FeaturedProduct" Role="FeaturedProduct_Advertisement"
|
117
|
+
Multiplicity="0..1" /></Association><Association Name="Person_PersonDetail_PersonDetail_Person"><End
|
118
|
+
Type="ODataDemo.PersonDetail" Role="PersonDetail_Person" Multiplicity="0..1"
|
119
|
+
/><End Type="ODataDemo.Person" Role="Person_PersonDetail" Multiplicity="0..1"
|
120
|
+
/></Association><EntityContainer Name="DemoService" m:IsDefaultEntityContainer="true"><EntitySet
|
121
|
+
Name="Products" EntityType="ODataDemo.Product" /><EntitySet Name="ProductDetails"
|
122
|
+
EntityType="ODataDemo.ProductDetail" /><EntitySet Name="Categories" EntityType="ODataDemo.Category"
|
123
|
+
/><EntitySet Name="Suppliers" EntityType="ODataDemo.Supplier" /><EntitySet
|
124
|
+
Name="Persons" EntityType="ODataDemo.Person" /><EntitySet Name="PersonDetails"
|
125
|
+
EntityType="ODataDemo.PersonDetail" /><EntitySet Name="Advertisements" EntityType="ODataDemo.Advertisement"
|
126
|
+
/><FunctionImport Name="GetProductsByRating" ReturnType="Collection(ODataDemo.Product)"
|
127
|
+
EntitySet="Products" m:HttpMethod="GET"><Parameter Name="rating" Type="Edm.Int16"
|
128
|
+
Nullable="false" /></FunctionImport><AssociationSet Name="Products_Advertisement_Advertisements"
|
129
|
+
Association="ODataDemo.FeaturedProduct_Advertisement_Advertisement_FeaturedProduct"><End
|
130
|
+
Role="FeaturedProduct_Advertisement" EntitySet="Products" /><End Role="Advertisement_FeaturedProduct"
|
131
|
+
EntitySet="Advertisements" /></AssociationSet><AssociationSet Name="Products_Categories_Categories"
|
132
|
+
Association="ODataDemo.Product_Categories_Category_Products"><End Role="Product_Categories"
|
133
|
+
EntitySet="Products" /><End Role="Category_Products" EntitySet="Categories"
|
134
|
+
/></AssociationSet><AssociationSet Name="Products_Supplier_Suppliers" Association="ODataDemo.Product_Supplier_Supplier_Products"><End
|
135
|
+
Role="Product_Supplier" EntitySet="Products" /><End Role="Supplier_Products"
|
136
|
+
EntitySet="Suppliers" /></AssociationSet><AssociationSet Name="Products_ProductDetail_ProductDetails"
|
137
|
+
Association="ODataDemo.Product_ProductDetail_ProductDetail_Product"><End Role="Product_ProductDetail"
|
138
|
+
EntitySet="Products" /><End Role="ProductDetail_Product" EntitySet="ProductDetails"
|
139
|
+
/></AssociationSet><AssociationSet Name="Persons_PersonDetail_PersonDetails"
|
140
|
+
Association="ODataDemo.Person_PersonDetail_PersonDetail_Person"><End Role="Person_PersonDetail"
|
141
|
+
EntitySet="Persons" /><End Role="PersonDetail_Person" EntitySet="PersonDetails"
|
142
|
+
/></AssociationSet></EntityContainer><Annotations Target="ODataDemo.DemoService"><ValueAnnotation
|
143
|
+
Term="Org.OData.Display.V1.Description" String="This is a sample OData service
|
144
|
+
with vocabularies" /></Annotations><Annotations Target="ODataDemo.Product"><ValueAnnotation
|
145
|
+
Term="Org.OData.Display.V1.Description" String="All Products available in
|
146
|
+
the online store" /></Annotations><Annotations Target="ODataDemo.Product/Name"><ValueAnnotation
|
147
|
+
Term="Org.OData.Display.V1.DisplayName" String="Product Name" /></Annotations><Annotations
|
148
|
+
Target="ODataDemo.DemoService/Suppliers"><ValueAnnotation Term="Org.OData.Publication.V1.PublisherName"
|
149
|
+
String="Microsoft Corp." /><ValueAnnotation Term="Org.OData.Publication.V1.PublisherId"
|
150
|
+
String="MSFT" /><ValueAnnotation Term="Org.OData.Publication.V1.Keywords"
|
151
|
+
String="Inventory, Supplier, Advertisers, Sales, Finance" /><ValueAnnotation
|
152
|
+
Term="Org.OData.Publication.V1.AttributionUrl" String="http://www.odata.org/"
|
153
|
+
/><ValueAnnotation Term="Org.OData.Publication.V1.AttributionDescription"
|
154
|
+
String="All rights reserved" /><ValueAnnotation Term="Org.OData.Publication.V1.DocumentationUrl
|
155
|
+
" String="http://www.odata.org/" /><ValueAnnotation Term="Org.OData.Publication.V1.TermsOfUseUrl"
|
156
|
+
String="All rights reserved" /><ValueAnnotation Term="Org.OData.Publication.V1.PrivacyPolicyUrl"
|
157
|
+
String="http://www.odata.org/" /><ValueAnnotation Term="Org.OData.Publication.V1.LastModified"
|
158
|
+
String="4/2/2013" /><ValueAnnotation Term="Org.OData.Publication.V1.ImageUrl
|
159
|
+
" String="http://www.odata.org/" /></Annotations></Schema></edmx:DataServices></edmx:Edmx>
|
160
|
+
http_version: '1.1'
|
161
|
+
adapter_metadata:
|
162
|
+
effective_url: http://services.odata.org/OData/OData.svc/$metadata
|
163
|
+
recorded_at: Sat, 19 Jul 2014 02:59:52 GMT
|
164
|
+
recorded_with: VCR 2.9.2
|
@@ -0,0 +1,164 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://services.odata.org/OData/OData.svc/$metadata
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Typhoeus - https://github.com/typhoeus/typhoeus
|
12
|
+
response:
|
13
|
+
status:
|
14
|
+
code: 200
|
15
|
+
message: OK
|
16
|
+
headers:
|
17
|
+
Cache-Control:
|
18
|
+
- no-cache
|
19
|
+
Content-Length:
|
20
|
+
- '10034'
|
21
|
+
Content-Type:
|
22
|
+
- application/xml;charset=utf-8
|
23
|
+
Server:
|
24
|
+
- Microsoft-IIS/8.0
|
25
|
+
X-Content-Type-Options:
|
26
|
+
- nosniff
|
27
|
+
DataServiceVersion:
|
28
|
+
- 3.0;
|
29
|
+
X-AspNet-Version:
|
30
|
+
- 4.0.30319
|
31
|
+
X-Powered-By:
|
32
|
+
- ASP.NET
|
33
|
+
Access-Control-Allow-Origin:
|
34
|
+
- "*"
|
35
|
+
Access-Control-Allow-Methods:
|
36
|
+
- GET
|
37
|
+
Access-Control-Allow-Headers:
|
38
|
+
- Accept, Origin, Content-Type, MaxDataServiceVersion
|
39
|
+
Access-Control-Expose-Headers:
|
40
|
+
- DataServiceVersion
|
41
|
+
Set-Cookie:
|
42
|
+
- ARRAffinity=a9aad020fb0149d28d0efdb1e8bab24ad3481a904c8fb94abced8813c01ee265;Path=/;Domain=services.odata.org
|
43
|
+
Date:
|
44
|
+
- Sat, 19 Jul 2014 02:59:53 GMT
|
45
|
+
body:
|
46
|
+
encoding: UTF-8
|
47
|
+
string: <?xml version="1.0" encoding="utf-8"?><edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx"><edmx:DataServices
|
48
|
+
m:DataServiceVersion="3.0" m:MaxDataServiceVersion="3.0" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><Schema
|
49
|
+
Namespace="ODataDemo" xmlns="http://schemas.microsoft.com/ado/2009/11/edm"><EntityType
|
50
|
+
Name="Product"><Key><PropertyRef Name="ID" /></Key><Property Name="ID" Type="Edm.Int32"
|
51
|
+
Nullable="false" /><Property Name="Name" Type="Edm.String" m:FC_TargetPath="SyndicationTitle"
|
52
|
+
m:FC_ContentKind="text" m:FC_KeepInContent="false" /><Property Name="Description"
|
53
|
+
Type="Edm.String" m:FC_TargetPath="SyndicationSummary" m:FC_ContentKind="text"
|
54
|
+
m:FC_KeepInContent="false" /><Property Name="ReleaseDate" Type="Edm.DateTime"
|
55
|
+
Nullable="false" /><Property Name="DiscontinuedDate" Type="Edm.DateTime" /><Property
|
56
|
+
Name="Rating" Type="Edm.Int16" Nullable="false" /><Property Name="Price" Type="Edm.Double"
|
57
|
+
Nullable="false" /><NavigationProperty Name="Categories" Relationship="ODataDemo.Product_Categories_Category_Products"
|
58
|
+
ToRole="Category_Products" FromRole="Product_Categories" /><NavigationProperty
|
59
|
+
Name="Supplier" Relationship="ODataDemo.Product_Supplier_Supplier_Products"
|
60
|
+
ToRole="Supplier_Products" FromRole="Product_Supplier" /><NavigationProperty
|
61
|
+
Name="ProductDetail" Relationship="ODataDemo.Product_ProductDetail_ProductDetail_Product"
|
62
|
+
ToRole="ProductDetail_Product" FromRole="Product_ProductDetail" /></EntityType><EntityType
|
63
|
+
Name="FeaturedProduct" BaseType="ODataDemo.Product"><NavigationProperty Name="Advertisement"
|
64
|
+
Relationship="ODataDemo.FeaturedProduct_Advertisement_Advertisement_FeaturedProduct"
|
65
|
+
ToRole="Advertisement_FeaturedProduct" FromRole="FeaturedProduct_Advertisement"
|
66
|
+
/></EntityType><EntityType Name="ProductDetail"><Key><PropertyRef Name="ProductID"
|
67
|
+
/></Key><Property Name="ProductID" Type="Edm.Int32" Nullable="false" /><Property
|
68
|
+
Name="Details" Type="Edm.String" /><NavigationProperty Name="Product" Relationship="ODataDemo.Product_ProductDetail_ProductDetail_Product"
|
69
|
+
ToRole="Product_ProductDetail" FromRole="ProductDetail_Product" /></EntityType><EntityType
|
70
|
+
Name="Category" OpenType="true"><Key><PropertyRef Name="ID" /></Key><Property
|
71
|
+
Name="ID" Type="Edm.Int32" Nullable="false" /><Property Name="Name" Type="Edm.String"
|
72
|
+
m:FC_TargetPath="SyndicationTitle" m:FC_ContentKind="text" m:FC_KeepInContent="true"
|
73
|
+
/><NavigationProperty Name="Products" Relationship="ODataDemo.Product_Categories_Category_Products"
|
74
|
+
ToRole="Product_Categories" FromRole="Category_Products" /></EntityType><EntityType
|
75
|
+
Name="Supplier"><Key><PropertyRef Name="ID" /></Key><Property Name="ID" Type="Edm.Int32"
|
76
|
+
Nullable="false" /><Property Name="Name" Type="Edm.String" m:FC_TargetPath="SyndicationTitle"
|
77
|
+
m:FC_ContentKind="text" m:FC_KeepInContent="true" /><Property Name="Address"
|
78
|
+
Type="ODataDemo.Address" /><Property Name="Location" Type="Edm.GeographyPoint"
|
79
|
+
SRID="Variable" /><Property Name="Concurrency" Type="Edm.Int32" ConcurrencyMode="Fixed"
|
80
|
+
Nullable="false" /><NavigationProperty Name="Products" Relationship="ODataDemo.Product_Supplier_Supplier_Products"
|
81
|
+
ToRole="Product_Supplier" FromRole="Supplier_Products" /></EntityType><ComplexType
|
82
|
+
Name="Address"><Property Name="Street" Type="Edm.String" /><Property Name="City"
|
83
|
+
Type="Edm.String" /><Property Name="State" Type="Edm.String" /><Property Name="ZipCode"
|
84
|
+
Type="Edm.String" /><Property Name="Country" Type="Edm.String" /></ComplexType><EntityType
|
85
|
+
Name="Person"><Key><PropertyRef Name="ID" /></Key><Property Name="ID" Type="Edm.Int32"
|
86
|
+
Nullable="false" /><Property Name="Name" Type="Edm.String" /><NavigationProperty
|
87
|
+
Name="PersonDetail" Relationship="ODataDemo.Person_PersonDetail_PersonDetail_Person"
|
88
|
+
ToRole="PersonDetail_Person" FromRole="Person_PersonDetail" /></EntityType><EntityType
|
89
|
+
Name="Customer" BaseType="ODataDemo.Person"><Property Name="TotalExpense"
|
90
|
+
Type="Edm.Decimal" Nullable="false" /></EntityType><EntityType Name="Employee"
|
91
|
+
BaseType="ODataDemo.Person"><Property Name="EmployeeID" Type="Edm.Int64" Nullable="false"
|
92
|
+
/><Property Name="HireDate" Type="Edm.DateTime" Nullable="false" /><Property
|
93
|
+
Name="Salary" Type="Edm.Single" Nullable="false" /></EntityType><EntityType
|
94
|
+
Name="PersonDetail"><Key><PropertyRef Name="PersonID" /></Key><Property Name="PersonID"
|
95
|
+
Type="Edm.Int32" Nullable="false" /><Property Name="Age" Type="Edm.Byte" Nullable="false"
|
96
|
+
/><Property Name="Gender" Type="Edm.Boolean" Nullable="false" /><Property
|
97
|
+
Name="Phone" Type="Edm.String" /><Property Name="Address" Type="ODataDemo.Address"
|
98
|
+
/><Property Name="Photo" Type="Edm.Stream" Nullable="false" /><NavigationProperty
|
99
|
+
Name="Person" Relationship="ODataDemo.Person_PersonDetail_PersonDetail_Person"
|
100
|
+
ToRole="Person_PersonDetail" FromRole="PersonDetail_Person" /></EntityType><EntityType
|
101
|
+
Name="Advertisement" m:HasStream="true"><Key><PropertyRef Name="ID" /></Key><Property
|
102
|
+
Name="ID" Type="Edm.Guid" Nullable="false" /><Property Name="Name" Type="Edm.String"
|
103
|
+
/><Property Name="AirDate" Type="Edm.DateTime" Nullable="false" /><NavigationProperty
|
104
|
+
Name="FeaturedProduct" Relationship="ODataDemo.FeaturedProduct_Advertisement_Advertisement_FeaturedProduct"
|
105
|
+
ToRole="FeaturedProduct_Advertisement" FromRole="Advertisement_FeaturedProduct"
|
106
|
+
/></EntityType><Association Name="Product_Categories_Category_Products"><End
|
107
|
+
Type="ODataDemo.Category" Role="Category_Products" Multiplicity="*" /><End
|
108
|
+
Type="ODataDemo.Product" Role="Product_Categories" Multiplicity="*" /></Association><Association
|
109
|
+
Name="Product_Supplier_Supplier_Products"><End Type="ODataDemo.Supplier" Role="Supplier_Products"
|
110
|
+
Multiplicity="0..1" /><End Type="ODataDemo.Product" Role="Product_Supplier"
|
111
|
+
Multiplicity="*" /></Association><Association Name="Product_ProductDetail_ProductDetail_Product"><End
|
112
|
+
Type="ODataDemo.ProductDetail" Role="ProductDetail_Product" Multiplicity="0..1"
|
113
|
+
/><End Type="ODataDemo.Product" Role="Product_ProductDetail" Multiplicity="0..1"
|
114
|
+
/></Association><Association Name="FeaturedProduct_Advertisement_Advertisement_FeaturedProduct"><End
|
115
|
+
Type="ODataDemo.Advertisement" Role="Advertisement_FeaturedProduct" Multiplicity="0..1"
|
116
|
+
/><End Type="ODataDemo.FeaturedProduct" Role="FeaturedProduct_Advertisement"
|
117
|
+
Multiplicity="0..1" /></Association><Association Name="Person_PersonDetail_PersonDetail_Person"><End
|
118
|
+
Type="ODataDemo.PersonDetail" Role="PersonDetail_Person" Multiplicity="0..1"
|
119
|
+
/><End Type="ODataDemo.Person" Role="Person_PersonDetail" Multiplicity="0..1"
|
120
|
+
/></Association><EntityContainer Name="DemoService" m:IsDefaultEntityContainer="true"><EntitySet
|
121
|
+
Name="Products" EntityType="ODataDemo.Product" /><EntitySet Name="ProductDetails"
|
122
|
+
EntityType="ODataDemo.ProductDetail" /><EntitySet Name="Categories" EntityType="ODataDemo.Category"
|
123
|
+
/><EntitySet Name="Suppliers" EntityType="ODataDemo.Supplier" /><EntitySet
|
124
|
+
Name="Persons" EntityType="ODataDemo.Person" /><EntitySet Name="PersonDetails"
|
125
|
+
EntityType="ODataDemo.PersonDetail" /><EntitySet Name="Advertisements" EntityType="ODataDemo.Advertisement"
|
126
|
+
/><FunctionImport Name="GetProductsByRating" ReturnType="Collection(ODataDemo.Product)"
|
127
|
+
EntitySet="Products" m:HttpMethod="GET"><Parameter Name="rating" Type="Edm.Int16"
|
128
|
+
Nullable="false" /></FunctionImport><AssociationSet Name="Products_Advertisement_Advertisements"
|
129
|
+
Association="ODataDemo.FeaturedProduct_Advertisement_Advertisement_FeaturedProduct"><End
|
130
|
+
Role="FeaturedProduct_Advertisement" EntitySet="Products" /><End Role="Advertisement_FeaturedProduct"
|
131
|
+
EntitySet="Advertisements" /></AssociationSet><AssociationSet Name="Products_Categories_Categories"
|
132
|
+
Association="ODataDemo.Product_Categories_Category_Products"><End Role="Product_Categories"
|
133
|
+
EntitySet="Products" /><End Role="Category_Products" EntitySet="Categories"
|
134
|
+
/></AssociationSet><AssociationSet Name="Products_Supplier_Suppliers" Association="ODataDemo.Product_Supplier_Supplier_Products"><End
|
135
|
+
Role="Product_Supplier" EntitySet="Products" /><End Role="Supplier_Products"
|
136
|
+
EntitySet="Suppliers" /></AssociationSet><AssociationSet Name="Products_ProductDetail_ProductDetails"
|
137
|
+
Association="ODataDemo.Product_ProductDetail_ProductDetail_Product"><End Role="Product_ProductDetail"
|
138
|
+
EntitySet="Products" /><End Role="ProductDetail_Product" EntitySet="ProductDetails"
|
139
|
+
/></AssociationSet><AssociationSet Name="Persons_PersonDetail_PersonDetails"
|
140
|
+
Association="ODataDemo.Person_PersonDetail_PersonDetail_Person"><End Role="Person_PersonDetail"
|
141
|
+
EntitySet="Persons" /><End Role="PersonDetail_Person" EntitySet="PersonDetails"
|
142
|
+
/></AssociationSet></EntityContainer><Annotations Target="ODataDemo.DemoService"><ValueAnnotation
|
143
|
+
Term="Org.OData.Display.V1.Description" String="This is a sample OData service
|
144
|
+
with vocabularies" /></Annotations><Annotations Target="ODataDemo.Product"><ValueAnnotation
|
145
|
+
Term="Org.OData.Display.V1.Description" String="All Products available in
|
146
|
+
the online store" /></Annotations><Annotations Target="ODataDemo.Product/Name"><ValueAnnotation
|
147
|
+
Term="Org.OData.Display.V1.DisplayName" String="Product Name" /></Annotations><Annotations
|
148
|
+
Target="ODataDemo.DemoService/Suppliers"><ValueAnnotation Term="Org.OData.Publication.V1.PublisherName"
|
149
|
+
String="Microsoft Corp." /><ValueAnnotation Term="Org.OData.Publication.V1.PublisherId"
|
150
|
+
String="MSFT" /><ValueAnnotation Term="Org.OData.Publication.V1.Keywords"
|
151
|
+
String="Inventory, Supplier, Advertisers, Sales, Finance" /><ValueAnnotation
|
152
|
+
Term="Org.OData.Publication.V1.AttributionUrl" String="http://www.odata.org/"
|
153
|
+
/><ValueAnnotation Term="Org.OData.Publication.V1.AttributionDescription"
|
154
|
+
String="All rights reserved" /><ValueAnnotation Term="Org.OData.Publication.V1.DocumentationUrl
|
155
|
+
" String="http://www.odata.org/" /><ValueAnnotation Term="Org.OData.Publication.V1.TermsOfUseUrl"
|
156
|
+
String="All rights reserved" /><ValueAnnotation Term="Org.OData.Publication.V1.PrivacyPolicyUrl"
|
157
|
+
String="http://www.odata.org/" /><ValueAnnotation Term="Org.OData.Publication.V1.LastModified"
|
158
|
+
String="4/2/2013" /><ValueAnnotation Term="Org.OData.Publication.V1.ImageUrl
|
159
|
+
" String="http://www.odata.org/" /></Annotations></Schema></edmx:DataServices></edmx:Edmx>
|
160
|
+
http_version: '1.1'
|
161
|
+
adapter_metadata:
|
162
|
+
effective_url: http://services.odata.org/OData/OData.svc/$metadata
|
163
|
+
recorded_at: Sat, 19 Jul 2014 02:59:53 GMT
|
164
|
+
recorded_with: VCR 2.9.2
|
@@ -1,22 +1,21 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe OData::EntitySet do
|
3
|
+
describe OData::EntitySet, vcr: {cassette_name: 'entity_set_specs'} do
|
4
|
+
before(:example) do
|
5
|
+
OData::Service.open('http://services.odata.org/OData/OData.svc')
|
6
|
+
end
|
7
|
+
|
4
8
|
let(:subject) { OData::EntitySet.new(options) }
|
5
9
|
let(:options) { {
|
6
10
|
container: 'DemoService', namespace: 'ODataDemo', name: 'Products',
|
7
11
|
type: 'Product'
|
8
12
|
} }
|
9
13
|
|
10
|
-
before(:example) do
|
11
|
-
OData::Service.open('http://services.odata.org/OData/OData.svc')
|
12
|
-
end
|
13
|
-
|
14
14
|
it { expect(subject).to respond_to(:name) }
|
15
15
|
it { expect(subject).to respond_to(:type) }
|
16
16
|
it { expect(subject).to respond_to(:container) }
|
17
17
|
it { expect(subject).to respond_to(:namespace) }
|
18
18
|
it { expect(subject).to respond_to(:new_entity) }
|
19
|
-
it { expect(subject).to respond_to(:filter) }
|
20
19
|
it { expect(subject).to respond_to(:[]) }
|
21
20
|
it { expect(subject).to respond_to(:<<) }
|
22
21
|
|
@@ -39,11 +38,16 @@ describe OData::EntitySet do
|
|
39
38
|
}.call.shuffle.first).to be_a(OData::Entity) }
|
40
39
|
end
|
41
40
|
|
41
|
+
it { expect(subject).to respond_to(:count) }
|
42
42
|
describe '#count' do
|
43
|
-
it { expect(subject).to respond_to(:count) }
|
44
43
|
it { expect(subject.count).to eq(11) }
|
45
44
|
end
|
46
45
|
|
46
|
+
it { expect(subject).to respond_to(:query) }
|
47
|
+
describe '#query' do
|
48
|
+
it { expect(subject.query).to be_a(OData::Query) }
|
49
|
+
end
|
50
|
+
|
47
51
|
describe '#new_entity' do
|
48
52
|
let(:new_entity) { subject.new_entity(properties) }
|
49
53
|
let(:release_date) { DateTime.new(2014,7,5) }
|
@@ -65,21 +69,6 @@ describe OData::EntitySet do
|
|
65
69
|
it { expect(new_entity['Price']).to eq(3.5) }
|
66
70
|
end
|
67
71
|
|
68
|
-
describe '#filter' do
|
69
|
-
let(:one_entity) { "Name eq 'Bread'" }
|
70
|
-
let(:many_entities) { 'Rating eq 3' }
|
71
|
-
|
72
|
-
it { expect(subject.filter(one_entity)).to be_a(Array) }
|
73
|
-
it { expect(subject.filter(one_entity).first).to be_a(OData::Entity) }
|
74
|
-
|
75
|
-
it { expect(subject.filter(many_entities)).to be_a(Array) }
|
76
|
-
it do
|
77
|
-
subject.filter(one_entity).each do |entity|
|
78
|
-
expect(entity).to be_a(OData::Entity)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
72
|
describe '#[]' do
|
84
73
|
let(:existing_entity) { subject[0] }
|
85
74
|
let(:nonexistant_entity) { subject[99] }
|
@@ -103,28 +92,21 @@ describe OData::EntitySet do
|
|
103
92
|
Price: 3.5
|
104
93
|
} }
|
105
94
|
|
106
|
-
|
107
|
-
|
108
|
-
to_return(status: 200, body: File.open('spec/fixtures/sample_service/product_0.xml'))
|
109
|
-
|
110
|
-
expect {subject << existing_entity}.to_not raise_error
|
95
|
+
describe 'with an existing entity', vcr: {cassette_name: 'entity_set_specs/existing_entry'} do
|
96
|
+
it { expect {subject << existing_entity}.to_not raise_error }
|
111
97
|
end
|
112
98
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
expect(new_entity['ID']).to eq(9999)
|
99
|
+
describe 'with a new entity', vcr: {cassette_name: 'entity_set_specs/new_entry'} do
|
100
|
+
it do
|
101
|
+
expect(new_entity['ID']).to be_nil
|
102
|
+
expect {subject << new_entity}.to_not raise_error
|
103
|
+
expect(new_entity['ID']).to_not be_nil
|
104
|
+
expect(new_entity['ID']).to eq(9999)
|
105
|
+
end
|
121
106
|
end
|
122
107
|
|
123
|
-
|
124
|
-
|
125
|
-
to_return(status: 400, body: nil)
|
126
|
-
|
127
|
-
expect {subject << bad_entity}.to raise_error(StandardError, 'Something went wrong committing your entity')
|
108
|
+
describe 'with a bad entity', vcr: {cassette_name: 'entity_set_specs/bad_entry'} do
|
109
|
+
it { expect {subject << bad_entity}.to raise_error(StandardError, 'Something went wrong committing your entity') }
|
128
110
|
end
|
129
111
|
end
|
130
112
|
end
|
data/spec/odata/entity_spec.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe OData::Entity do
|
3
|
+
describe OData::Entity, vcr: {cassette_name: 'entity_specs'} do
|
4
|
+
before(:example) do
|
5
|
+
OData::Service.open('http://services.odata.org/OData/OData.svc')
|
6
|
+
end
|
7
|
+
|
4
8
|
let(:subject) { OData::Entity.new(options) }
|
5
9
|
let(:options) { {
|
6
10
|
type: 'ODataDemo.Product',
|
@@ -21,10 +25,6 @@ describe OData::Entity do
|
|
21
25
|
document.xpath('//entry').first
|
22
26
|
}
|
23
27
|
|
24
|
-
before(:example) do
|
25
|
-
OData::Service.open('http://services.odata.org/OData/OData.svc')
|
26
|
-
end
|
27
|
-
|
28
28
|
it { expect(OData::Entity).to respond_to(:from_xml) }
|
29
29
|
it { expect(subject).to be_a(OData::Entity) }
|
30
30
|
|