Compare commits
35 Commits
reproduce-
...
openSAP-we
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a1a7b1f2b | ||
|
|
a560e12106 | ||
|
|
3dccfc30f0 | ||
|
|
cc0be09341 | ||
|
|
175a183f27 | ||
|
|
a1d663a717 | ||
|
|
e75cc7a0a5 | ||
|
|
37ed881102 | ||
|
|
a3ab8cd51f | ||
|
|
6c1f06a06c | ||
|
|
e9a18c9938 | ||
|
|
eb5334cafc | ||
|
|
d54b16bd94 | ||
|
|
ba054305a6 | ||
|
|
e89fc1d9bb | ||
|
|
659fe52509 | ||
|
|
4ad21a47d6 | ||
|
|
7b5b2210ae | ||
|
|
c20c1609a7 | ||
|
|
ffc9fbd5f5 | ||
|
|
11957c93d8 | ||
|
|
2ca71b0f7d | ||
|
|
452b442246 | ||
|
|
bf21d0220c | ||
|
|
b65be0cb41 | ||
|
|
c3c778b2be | ||
|
|
c38c5d832c | ||
|
|
5929d22f98 | ||
|
|
4030173bbc | ||
|
|
74ce1a5fd1 | ||
|
|
cbb27132ec | ||
|
|
72a17ffcf7 | ||
|
|
0e2218a5f1 | ||
|
|
fa8a7861d5 | ||
|
|
ceb5487e75 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -13,3 +13,5 @@ target/
|
||||
connection.properties
|
||||
default-env.json
|
||||
packages/messageBox
|
||||
*.db
|
||||
|
||||
|
||||
20
.vscode/launch.json
vendored
20
.vscode/launch.json
vendored
@@ -9,8 +9,16 @@
|
||||
"request": "launch",
|
||||
"type": "node",
|
||||
"runtimeExecutable": "npx",
|
||||
"runtimeArgs": ["-n"],
|
||||
"args": ["--", "cds", "run", "--with-mocks", "--in-memory?"], // the leading "--" arg ensures it works with as well as without debugging
|
||||
"runtimeArgs": [
|
||||
"-n"
|
||||
],
|
||||
"args": [
|
||||
"--",
|
||||
"cds",
|
||||
"run",
|
||||
"--with-mocks",
|
||||
"--in-memory"
|
||||
], // the leading "--" arg ensures it works with as well as without debugging
|
||||
"cwd": "${workspaceFolder}/packages/${input:service}",
|
||||
"console": "integratedTerminal",
|
||||
"serverReadyAction": {
|
||||
@@ -18,7 +26,9 @@
|
||||
"uriFormat": "http://localhost:%s",
|
||||
"action": "openExternally"
|
||||
},
|
||||
"skipFiles": ["<node_internals>/**"]
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
]
|
||||
}
|
||||
],
|
||||
"inputs": [
|
||||
@@ -36,7 +46,7 @@
|
||||
"reviews-service",
|
||||
"user-service"
|
||||
],
|
||||
"default": "bookstore"
|
||||
"default": "bookshop"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
87
README.md
87
README.md
@@ -1,73 +1,52 @@
|
||||
# cloud-cap-samples
|
||||
# Welcome to SAP Cloud Application Programming model samples
|
||||
|
||||
This is a monorepository for sample projects on [SAP Cloud Application Programming Model](https://cap.cloud.sap).
|
||||
Find here the samples for the openSAP course [Building Applications with the SAP Cloud Application Programming Model](https://open.sap.com/courses/cp7).
|
||||
|
||||
## Description
|
||||
## Get Access to SAP Business Application Studio
|
||||
The recommended environment for the course is SAP Business Application Studio. Watch [unit 2 of week 1](https://open.sap.com/courses/cp7/items/51pzQUzbXHr2kdbOmVs6jI) for how to get access.
|
||||
|
||||
This repository provides a list of samples and reusable packages created based on SAP Cloud Application Programming Model.
|
||||
The SAP Cloud Application Programming Model enables you to quickly create business applications by allowing you to focus on your domain logic. It offers a consistent end-to-end programming model that includes languages, libraries and APIs tailored for full-stack development on SAP Cloud Platform.
|
||||
## Setup
|
||||
|
||||
The samples provided can be run in a local setup on SQLite Database.
|
||||
In SAP Business Application Studio, open a terminal.
|
||||
Then clone the repo with this specific branch:
|
||||
|
||||
|
||||
## Requirements
|
||||
* [Node.js](https://nodejs.org/en/) v8 or higher
|
||||
* [Git](https://git-scm.com)
|
||||
* [SQLite DB](https://www.sqlite.org/download.html) (Windows only; pre-installed on Mac/Linux)
|
||||
|
||||
#### Optional (if you want to import the code into an editor)
|
||||
* [VS Code](https://code.visualstudio.com)
|
||||
* [Add CDS extension to VS](https://cap.cloud.sap/docs/get-started/in-vscode#add-cds-editor)
|
||||
|
||||
## Download and Installation
|
||||
|
||||
#### Install `cds` development kit
|
||||
```sh
|
||||
# sets the registry for `@sap` packages
|
||||
npm set @sap:registry=https://npm.sap.com
|
||||
|
||||
npm install -g @sap/cds-dk
|
||||
cds #> test-run it
|
||||
git clone https://github.com/sap-samples/cloud-cap-samples projects/cloud-cap-samples -b openSAP-week2-unit4567
|
||||
cd projects/cloud-cap-samples
|
||||
```
|
||||
Got issues? Check out the [documentation](https://cap.cloud.sap/docs/get-started/).
|
||||
|
||||
#### Clone and build the application
|
||||
`git clone https://github.com/SAP-samples/cloud-cap-samples samples && cd samples && npm i`
|
||||
In the `cloud-cap-samples` folder run:
|
||||
```sh
|
||||
npm install
|
||||
```
|
||||
|
||||
#### Run the samples
|
||||
### Cloud Foundry Login
|
||||
This is required later in the demo. In Studio's terminal, execute:
|
||||
```sh
|
||||
cf login
|
||||
```
|
||||
As input, provide
|
||||
- The Cloud Foundry API endpoint, which is usally `https://api.cf.eu10.hana.ondemand.com`. It can be obtained from the Overview page of your Subaccount in Cloud Cockpit.
|
||||
- Your user's email address and password
|
||||
- The name of your trial organization and space
|
||||
|
||||
With that you're ready to run the samples, e.g. start the [_bookshop_](./packages/bookshop) sample as follows:
|
||||
## Run
|
||||
|
||||
`npm run bookshop`
|
||||
Now you're ready to run the samples, for example:
|
||||
```sh
|
||||
cd packages/bookshop
|
||||
cds watch
|
||||
```
|
||||
|
||||
## Test
|
||||
|
||||
For example, try these links in your browser:
|
||||
- <http://localhost:4004> to test with generic index page.
|
||||
- <http://localhost:4004/fiori.html> to test with Fiori sandbox.
|
||||
After that, watch out for the little popup in the lower right corner of SAP Business Application Studio that asks you to open the application in your browser.
|
||||
|
||||
|
||||
## Debug
|
||||
## Get Support
|
||||
|
||||
For example, in [VS Code](https://code.visualstudio.com) switch to _Debug_ view and launch one of the prepared _cds run_ launch configurations.
|
||||
Check out the cap docs at https://cap.cloud.sap. <br>
|
||||
In case you find a bug or need support, please [open an issue in here](https://github.com/SAP-samples/cloud-cap-samples/issues/new).
|
||||
|
||||
|
||||
## Limitations
|
||||
|
||||
None
|
||||
|
||||
## Known Issues
|
||||
|
||||
None
|
||||
|
||||
## How to obtain support
|
||||
|
||||
Check out the documentation on https://cap.cloud.sap. In case you find a bug, or you need additional support, please open an issue [here](https://github.com/SAP-samples/cloud-cap-samples/issues/new) in GitHub.
|
||||
|
||||
## To-Do (upcoming changes)
|
||||
|
||||
None
|
||||
|
||||
## License
|
||||
|
||||
Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under SAP Sample Code License Agreement, except as noted otherwise in the [LICENSE](/LICENSE) file.
|
||||
Copyright (c) 2020 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under SAP Sample Code License Agreement, except as noted otherwise in the [LICENSE](/LICENSE) file.
|
||||
|
||||
7481
package-lock.json
generated
Normal file
7481
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
16
package.json
16
package.json
@@ -9,20 +9,18 @@
|
||||
"install": "(npm -s run lerna) && lerna bootstrap --hoist",
|
||||
"lerna": "npx --no-install lerna -v > /dev/null || npm i lerna --no-save",
|
||||
"test": "jest",
|
||||
"bookshop-enhanced": "cds watch packages/bookshop-enhanced",
|
||||
"bookshop": "cds watch packages/bookshop",
|
||||
"bookstore": "cds watch packages/bookstore",
|
||||
"products-service": "cds watch packages/products-service",
|
||||
"reviews-service": "cds watch packages/reviews-service"
|
||||
"bookshop": "cds watch packages/bookshop"
|
||||
},
|
||||
"dependencies": {
|
||||
"@sap/cds": "latest",
|
||||
"express": "*"
|
||||
"@sap/cds": "^3",
|
||||
"express": "^4"
|
||||
},
|
||||
"--add-these-to-devDependencies-for-tests": {
|
||||
"devDependencies": {
|
||||
"@types/jest": "*",
|
||||
"sqlite3": "*",
|
||||
"jest": "*"
|
||||
"jest": "*",
|
||||
"supertest": "^4.0.2",
|
||||
"@sap/hdi-deploy": "3.7.0"
|
||||
},
|
||||
"license": "SAP SAMPLE CODE LICENSE"
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
using from '@sap/capire-bookshop/app';
|
||||
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
In this model we demonstrate how to add Genres to Books in
|
||||
as if it was an external extension. For example we use
|
||||
CDS Aspects' to extend the core domain model's Books entity
|
||||
as well as the AdminService.
|
||||
*/
|
||||
|
||||
namespace sap.capire.bookshop;
|
||||
using { sap.capire.reviews.ReviewsService as external } from '@sap/capire-reviews';
|
||||
using { sap.capire.bookshop.Books } from '@sap/capire-bookshop/db/schema';
|
||||
using { sap.common.CodeList } from '@sap/cds/common';
|
||||
|
||||
// Extending Books by Reviews and Genres
|
||||
extend Books with {
|
||||
reviews : Composition of many external.Reviews on reviews.subject = ID;
|
||||
rating : external.Reviews.rating;
|
||||
genre : Association to Genres;
|
||||
}
|
||||
|
||||
// Hierarchical Code List for Genres
|
||||
entity Genres : CodeList {
|
||||
key ID : Integer;
|
||||
children : Composition of many Genres on children.parent = $self;
|
||||
parent : Association to Genres;
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
{
|
||||
"name": "@sap/capire-bookshop-enhanced",
|
||||
"version": "1.0.0",
|
||||
"description": "A sample for extending a base application package, in this case bookshop, e.g. in context of verticalization or customization.",
|
||||
"repository": "https://github.com/SAP-samples/cloud-cap-samples.git",
|
||||
"license": "SAP SAMPLE CODE LICENSE",
|
||||
"dependencies": {
|
||||
"@sap/capire-bookshop": "^1.0.0",
|
||||
"@sap/capire-reviews": "^1.0.0",
|
||||
"@sap/cds": "latest",
|
||||
"express": "*"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "npx cds run"
|
||||
},
|
||||
"cds": {
|
||||
"requires": {
|
||||
"sap.capire.reviews.ReviewsService": {
|
||||
"kind": "odata",
|
||||
"model": "@sap/capire-reviews"
|
||||
},
|
||||
"messaging": {
|
||||
"kind": "file-based-messaging"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace sap.capire.bookshop;
|
||||
|
||||
using { AdminService } from '@sap/capire-bookshop/srv/admin-service';
|
||||
using { sap.capire.bookshop } from '../db/schema';
|
||||
|
||||
@impl:'srv/services'
|
||||
extend service AdminService with {
|
||||
entity Genres as projection on bookshop.Genres;
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
const cds = require ('@sap/cds')
|
||||
|
||||
module.exports = cds.service.impl (async()=>{
|
||||
|
||||
const ReviewsService = await cds.connect.to ('sap.capire.reviews.ReviewsService')
|
||||
const CatalogService = await cds.connect.to ('CatalogService')
|
||||
const db = await cds.connect.to ('db')
|
||||
// import model definitions from connected services to work with subsequently
|
||||
const { Books } = db.entities
|
||||
const { Reviews } = ReviewsService.entities
|
||||
|
||||
CatalogService.impl (srv => {
|
||||
// delegate requests to read reviews to ReviewsService
|
||||
srv.on ('READ', 'Books/reviews', (req) => {
|
||||
const [ subject ] = req.params
|
||||
const tx = ReviewsService.transaction (req)
|
||||
return tx.run (SELECT.from (Reviews) .where ({subject}))
|
||||
})
|
||||
})
|
||||
|
||||
// react on event messages from reviews service
|
||||
ReviewsService.on ('reviewed', (msg) => {
|
||||
console.debug ('> received:', msg.event, msg.data)
|
||||
const { subject, rating } = msg.data
|
||||
const tx = db // TODO: db.transaction (msg)
|
||||
return tx.run (UPDATE (Books, subject) .with ({rating}))
|
||||
// return tx.update (Books, subject) .with ({rating})
|
||||
})
|
||||
|
||||
})
|
||||
@@ -1,33 +0,0 @@
|
||||
#################################################
|
||||
#
|
||||
# Genres
|
||||
#
|
||||
|
||||
GET http://localhost:4004/admin/Genres?
|
||||
###
|
||||
|
||||
POST http://localhost:4004/admin/Genres?
|
||||
Content-Type: application/json
|
||||
|
||||
{ "ID":100, "name":"Some Sample Genres...", "children":[
|
||||
{ "ID":101, "name":"Cat", "children":[
|
||||
{ "ID":102, "name":"Kitty", "children":[
|
||||
{ "ID":103, "name":"Kitty Cat", "children":[
|
||||
{ "ID":104, "name":"Aristocat" } ]},
|
||||
{ "ID":105, "name":"Kitty Bat" } ]},
|
||||
{ "ID":106, "name":"Catwoman", "children":[
|
||||
{ "ID":107, "name":"Catalina" } ]} ]},
|
||||
{ "ID":108, "name":"Catweazle" }
|
||||
]}
|
||||
###
|
||||
|
||||
GET http://localhost:4004/admin/Genres(100)?
|
||||
# &$expand=children
|
||||
# &$expand=children($expand=children($expand=children($expand=children)))
|
||||
###
|
||||
|
||||
DELETE http://localhost:4004/admin/Genres(103)
|
||||
###
|
||||
|
||||
DELETE http://localhost:4004/admin/Genres(100)
|
||||
###
|
||||
@@ -1,32 +0,0 @@
|
||||
#################################################
|
||||
#
|
||||
# Reviews Service
|
||||
#
|
||||
|
||||
|
||||
### Use this one for ReviewsService running as a separate process
|
||||
# Note: use 5005 instead of 4004 in case of separate service
|
||||
POST http://localhost:5005/reviews/Reviews
|
||||
# POST http://localhost:4004/reviews/Reviews
|
||||
Content-Type: application/json;IEEE754Compatible=true
|
||||
|
||||
{"subject":"201", "rating":"5", "title":"boo"}
|
||||
|
||||
### Direct Request to ReviewsService
|
||||
# Note: use 5005 instead of 4004 in case of separate service
|
||||
GET http://localhost:5005/reviews/Reviews?
|
||||
# GET http://localhost:4004/reviews/Reviews?
|
||||
# &$filter=subject eq '201'
|
||||
|
||||
|
||||
### Request to CatalogService > delegated to ReviewsService
|
||||
GET http://localhost:4004/browse/Books(201)/reviews
|
||||
|
||||
### Alternative OData URL
|
||||
GET http://localhost:4004/browse/Books/201/reviews
|
||||
|
||||
###
|
||||
GET http://localhost:4004/browse/Books(201)?
|
||||
&$select=ID,title,rating
|
||||
# &$expand=reviews
|
||||
# Note: the latter only works in case of ReviewsService in same process
|
||||
31
packages/bookshop/.vscode/launch.json
vendored
Normal file
31
packages/bookshop/.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Run bookshop",
|
||||
"request": "launch",
|
||||
"type": "node",
|
||||
"cwd": "/home/user/projects/cloud-cap-samples/packages/bookshop",
|
||||
"runtimeExecutable": "npx",
|
||||
"runtimeArgs": [
|
||||
"-n"
|
||||
],
|
||||
"args": [
|
||||
"--",
|
||||
"cds",
|
||||
"run",
|
||||
"--in-memory?"
|
||||
],
|
||||
"console": "internalConsole",
|
||||
"internalConsoleOptions": "openOnSessionStart",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"env": {
|
||||
"run.config": "{\"handlerId\":\"cap_run_config_handler_id\",\"runnableId\":\"/home/user/projects/cloud-cap-samples/packages/bookshop\"}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -4,10 +4,15 @@
|
||||
"description": "A simple bookshop application, build in a self-contained all-in-one fashion, i.e. w/o reusing other packages.",
|
||||
"license": "SAP SAMPLE CODE LICENSE",
|
||||
"dependencies": {
|
||||
"@sap/cds": "latest",
|
||||
"express": "*"
|
||||
"@sap/cds": "^3",
|
||||
"express": "^4",
|
||||
"hdb": "^0.17.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jest": "*"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "npx cds run"
|
||||
"start": "npx cds run",
|
||||
"test": "jest"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,8 @@ service AdminService @(_requires:'authenticated-user') {
|
||||
|
||||
// Enable Fiori Draft for Orders
|
||||
annotate AdminService.Orders with @odata.draft.enabled;
|
||||
// annotate AdminService.Books with @odata.draft.enabled;
|
||||
|
||||
// Temporary workaround -> https://github.wdf.sap.corp/cap/issues/issues/3121
|
||||
// Temporary workaround -> cap/issues#3121
|
||||
extend service AdminService with {
|
||||
entity OrderItems as select from my.OrderItems;
|
||||
}
|
||||
|
||||
22
packages/bookshop/srv/admin-service.js
Normal file
22
packages/bookshop/srv/admin-service.js
Normal file
@@ -0,0 +1,22 @@
|
||||
const cds = require('@sap/cds')
|
||||
|
||||
/** Service implementation for AdminService */
|
||||
module.exports = cds.service.impl(srv => {
|
||||
const { OrderItems } = srv.entities ('sap.capire.bookshop')
|
||||
|
||||
srv.after (['READ','EDIT'], 'Orders', _calculateTotals)
|
||||
|
||||
// on-the-fly calculate the total Order price based on the OrderItems' netAmounts
|
||||
async function _calculateTotals (orders, req) {
|
||||
const ordersByID = Array.isArray(orders)
|
||||
? orders.reduce ((all,o) => { (all[o.ID] = o).total=0; return all },{})
|
||||
: { [orders.ID]: orders }
|
||||
return cds.transaction(req) .run (
|
||||
SELECT.from(OrderItems) .columns ('parent_ID', 'netAmount')
|
||||
.where ({ parent_ID: {in: Object.keys(ordersByID)} })
|
||||
) .then (items =>
|
||||
items.forEach (item => ordersByID [item.parent_ID] .total += item.netAmount)
|
||||
)
|
||||
}
|
||||
|
||||
})
|
||||
@@ -1,6 +1,7 @@
|
||||
using { sap.capire.bookshop as my } from '../db/schema';
|
||||
|
||||
@path:'/browse'
|
||||
// @impl: './cat-service.js'
|
||||
service CatalogService {
|
||||
|
||||
@readonly entity Books as SELECT from my.Books {*,
|
||||
|
||||
@@ -2,25 +2,27 @@ const cds = require('@sap/cds')
|
||||
const { Books } = cds.entities
|
||||
|
||||
/** Service implementation for CatalogService */
|
||||
module.exports = cds.service.impl(function() {
|
||||
this.after ('READ', 'Books', each => each.stock > 111 && _addDiscount2(each,11))
|
||||
this.before ('CREATE', 'Orders', _reduceStock)
|
||||
module.exports = cds.service.impl(srv => {
|
||||
srv.after ('READ', 'Books', each => each.stock > 111 && _addDiscount2(each,11))
|
||||
srv.before ('CREATE', 'Orders', _reduceStock)
|
||||
// srv.before ('*', (req) => { console.debug ('>>>', req.method, req.target.name) })
|
||||
})
|
||||
|
||||
/** Add some discount for overstocked books */
|
||||
function _addDiscount2 (each,discount) {
|
||||
each.title += ` -- ${discount}% discount!`
|
||||
}
|
||||
|
||||
/** Reduce stock of ordered books if available stock suffices */
|
||||
async function _reduceStock (req) {
|
||||
const { Items: OrderItems } = req.data
|
||||
return cds.transaction(req) .run (()=> OrderItems.map (order =>
|
||||
UPDATE (Books) .set ('stock -=', order.amount)
|
||||
.where ('ID =', order.book_ID) .and ('stock >=', order.amount)
|
||||
)) .then (all => all.forEach ((affectedRows,i) => {
|
||||
if (affectedRows === 0) req.error (409,
|
||||
`${OrderItems[i].amount} exceeds stock for book #${OrderItems[i].book_ID}`
|
||||
)
|
||||
const { Items: orderItems } = req.data
|
||||
|
||||
return cds.transaction(req) .run (()=> orderItems.map (item =>
|
||||
UPDATE (Books)
|
||||
.set ('stock -=', item.amount)
|
||||
.where ('ID =', item.book_ID) .and ('stock >=', item.amount)
|
||||
)).then (all => all.forEach ((affectedRows,i) => {
|
||||
if (affectedRows === 0) {
|
||||
req.error (409, `${orderItems[i].amount} exceeds stock for book #${orderItems[i].book_ID}`)
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
79
packages/bookshop/tests/bookshop.test.js
Normal file
79
packages/bookshop/tests/bookshop.test.js
Normal file
@@ -0,0 +1,79 @@
|
||||
|
||||
const cds = require('@sap/cds')
|
||||
|
||||
describe('Bookshop: OData Protocol Level Testing', () => {
|
||||
jest.setTimeout(20*1000)
|
||||
const app = require('express')()
|
||||
const request = require('supertest')(app)
|
||||
|
||||
beforeAll(async () => {
|
||||
await cds.deploy(__dirname + '/../srv/cat-service').to('sqlite::memory:')
|
||||
await cds.serve('CatalogService').from(__dirname + '/../srv/cat-service').in(app)
|
||||
})
|
||||
|
||||
it('Service $metadata document', async () => {
|
||||
const response = await request
|
||||
.get('/browse/$metadata')
|
||||
.expect('Content-Type', /^application\/xml/)
|
||||
.expect(200)
|
||||
|
||||
const expectedVersion = '<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx">'
|
||||
const expectedBooksEntitySet = '<EntitySet Name="Books" EntityType="CatalogService.Books">'
|
||||
expect(response.text.includes(expectedVersion)).toBeTruthy()
|
||||
expect(response.text.includes(expectedBooksEntitySet)).toBeTruthy()
|
||||
})
|
||||
|
||||
|
||||
it('Get with select, expand and localized', async () => {
|
||||
const response = await request
|
||||
.get('/browse/Books?$select=title,author&$expand=currency')
|
||||
.set('Accept-Language', 'de')
|
||||
.expect('Content-Type', /^application\/json/)
|
||||
.expect(200)
|
||||
|
||||
expect(response.body.value).toMatchObject([
|
||||
{
|
||||
ID: 201, title: "Sturmhöhe", author: "Emily Brontë",
|
||||
currency: { name: "Pfund", descr: "Britische Pfund", code: "GBP", symbol: "£" }
|
||||
},
|
||||
{
|
||||
ID: 207, title: "Jane Eyre", author: "Charlotte Brontë",
|
||||
currency: { name: "Pfund", descr: "Britische Pfund", code: "GBP", symbol: "£" }
|
||||
},
|
||||
{
|
||||
ID: 251, title: "The Raven", author: "Edgar Allen Poe",
|
||||
currency: { name: "US-Dollar", descr: "United States Dollar", code: "USD", symbol: "$" }
|
||||
},
|
||||
{
|
||||
ID: 252, title: "Eleonora", author: "Edgar Allen Poe",
|
||||
currency: { name: "US-Dollar", descr: "United States Dollar", code: "USD", symbol: "$" }
|
||||
},
|
||||
{
|
||||
ID: 271, title: "Catweazle", author: "Richard Carpenter",
|
||||
currency: { name: "Euro", descr: "European Euro", code: "EUR", symbol: "€" }
|
||||
}
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
describe('Bookshop: CDS Service Level Testing', () => {
|
||||
let srv, Books
|
||||
|
||||
beforeAll(async () => {
|
||||
srv = await cds.serve('CatalogService').from(__dirname + '/../srv/cat-service')
|
||||
Books = srv.entities.Books
|
||||
expect(Books).toBeDefined()
|
||||
})
|
||||
|
||||
it('GETs all books', async () => {
|
||||
const books = await srv.read(Books, b => { b.title })
|
||||
|
||||
expect(books).toMatchObject([
|
||||
{ title: 'Wuthering Heights' },
|
||||
{ title: 'Jane Eyre' },
|
||||
{ title: 'The Raven' },
|
||||
{ title: 'Eleonora' },
|
||||
{ title: 'Catweazle' }
|
||||
])
|
||||
})
|
||||
})
|
||||
@@ -1,5 +0,0 @@
|
||||
ID;firstname;lastname;dateOfBirth;placeOfBirth;dateOfDeath;placeOfDeath
|
||||
101;Emily;Brontë;1818-07-30;Thornton, Yorkshire;1848-12-19;Haworth, Yorkshire
|
||||
107;Charlotte;Brontë;1818-04-21;Thornton, Yorkshire;1855-03-31;Haworth, Yorkshire
|
||||
150;Edgar Allen;Poe;1809-01-19;Boston, Massachusetts;1849-10-07;Baltimore, Maryland
|
||||
170;Richard;Carpenter;1929-08-14;King’s Lynn, Norfolk;2012-02-26;Hertfordshire, England
|
||||
|
@@ -1,11 +0,0 @@
|
||||
ID;parent_ID;name
|
||||
1;;Poetry
|
||||
2;;Biography
|
||||
3;;Fantasy
|
||||
4;;Science Fiction
|
||||
5;;Romance
|
||||
6;;Mystery
|
||||
7;;Thriller
|
||||
8;;Dystopia
|
||||
9;;Tragedy
|
||||
10;;Novel
|
||||
|
@@ -1,6 +0,0 @@
|
||||
ID;title;descr;author_ID;stock;price;currency_code;category_ID
|
||||
201;Wuthering Heights;"Wuthering Heights, Emily Brontë's only novel, was published in 1847 under the pseudonym ""Ellis Bell"". It was written between October 1845 and June 1846. Wuthering Heights and Anne Brontë's Agnes Grey were accepted by publisher Thomas Newby before the success of their sister Charlotte's novel Jane Eyre. After Emily's death, Charlotte edited the manuscript of Wuthering Heights and arranged for the edited version to be published as a posthumous second edition in 1850.";101;12;11.11;GBP;9
|
||||
207;Jane Eyre;"Jane Eyre /ɛər/ (originally published as Jane Eyre: An Autobiography) is a novel by English writer Charlotte Brontë, published under the pen name ""Currer Bell"", on 16 October 1847, by Smith, Elder & Co. of London. The first American edition was published the following year by Harper & Brothers of New York. Primarily a bildungsroman, Jane Eyre follows the experiences of its eponymous heroine, including her growth to adulthood and her love for Mr. Rochester, the brooding master of Thornfield Hall. The novel revolutionised prose fiction in that the focus on Jane's moral and spiritual development is told through an intimate, first-person narrative, where actions and events are coloured by a psychological intensity. The book contains elements of social criticism, with a strong sense of Christian morality at its core and is considered by many to be ahead of its time because of Jane's individualistic character and how the novel approaches the topics of class, sexuality, religion and feminism.";107;11;12.34;GBP;10
|
||||
251;The Raven;"“The Raven"" is a narrative poem by American writer Edgar Allan Poe. First published in January 1845, the poem is often noted for its musicality, stylized language, and supernatural atmosphere. It tells of a talking raven's mysterious visit to a distraught lover, tracing the man's slow fall into madness. The lover, often identified as being a student, is lamenting the loss of his love, Lenore. Sitting on a bust of Pallas, the raven seems to further distress the protagonist with its constant repetition of the word ""Nevermore"". The poem makes use of folk, mythological, religious, and classical references.";150;333;13.13;USD;1
|
||||
252;Eleonora;"""Eleonora"" is a short story by Edgar Allan Poe, first published in 1842 in Philadelphia in the literary annual The Gift. It is often regarded as somewhat autobiographical and has a relatively ""happy"" ending.";150;555;14;USD;5
|
||||
271;Catweazle;Catweazle is a British fantasy television series, starring Geoffrey Bayldon in the title role, and created by Richard Carpenter for London Weekend Television. The first series, produced and directed by Quentin Lawrence, was screened in the UK on ITV in 1970. The second series, directed by David Reid and David Lane, was shown in 1971. Each series had thirteen episodes, most but not all written by Carpenter, who also published two books based on the scripts.;170;22;15;EUR;3
|
||||
|
unable to load file
|
@@ -1,4 +0,0 @@
|
||||
ID;locale;title;descr
|
||||
201;de;Sturmhöhe;Sturmhöhe (Originaltitel: Wuthering Heights) ist der einzige Roman der englischen Schriftstellerin Emily Brontë (1818–1848). Der 1847 unter dem Pseudonym Ellis Bell veröffentlichte Roman wurde vom viktorianischen Publikum weitgehend abgelehnt, heute gilt er als ein Klassiker der britischen Romanliteratur des 19. Jahrhunderts.
|
||||
207;de;Jane Eyre;Jane Eyre. Eine Autobiographie (Originaltitel: Jane Eyre. An Autobiography), erstmals erschienen im Jahr 1847 unter dem Pseudonym Currer Bell, ist der erste veröffentlichte Roman der britischen Autorin Charlotte Brontë und ein Klassiker der viktorianischen Romanliteratur des 19. Jahrhunderts. Der Roman erzählt in Form einer Ich-Erzählung die Lebensgeschichte von Jane Eyre (ausgesprochen /ˌdʒeɪn ˈɛə/), die nach einer schweren Kindheit eine Stelle als Gouvernante annimmt und sich in ihren Arbeitgeber verliebt, jedoch immer wieder um ihre Freiheit und Selbstbestimmung kämpfen muss. Als klein, dünn, blass, stets schlicht dunkel gekleidet und mit strengem Mittelscheitel beschrieben, gilt die Heldin des Romans Jane Eyre nicht zuletzt aufgrund der Kino- und Fernsehversionen der melodramatischen Romanvorlage als die bekannteste englische Gouvernante der Literaturgeschichte
|
||||
252;de;Eleonora;“Eleonora” ist eine Erzählung von Edgar Allan Poe. Sie wurde 1841 erstveröffentlicht. In ihr geht es um das Paradox der Treue in der Treulosigkeit.
|
||||
|
500 Internal Server Error
Gitea Version: 1.24.4 |