SAP Spartacus OccEndpointsService单元测试的依赖注入-阿里云开发者社区

开发者社区> 开发者小助手-bz5> 正文

SAP Spartacus OccEndpointsService单元测试的依赖注入

简介: SAP Spartacus OccEndpointsService单元测试的依赖注入
+关注继续查看

OccEndpointsService的两个依赖:

OccConfig和可选的BaseSiteService:

image.png

image.png

end point数据结构:OccEndpoints

export interface OccEndpoints {

 /**

  * Client login (get authorization token)

  *

  * @member {string}

  */

 login?: string | OccEndpoint;

 /**

  * Client logout (revoke authorization token)

  *

  * @member {string}

  */

 revoke?: string | OccEndpoint;

 /**

  * Get product details for scope

  *

  * @member Object

  */

 product?: string | ProductOccEndpoint;

 /**

  * Get reviews for a product

  *

  * @member {string}

  */

 productReviews?: string | OccEndpoint;

 /**

  * Get a list of product references

  *

  * @member {string}

  */

 productReferences?: string | OccEndpoint;

 /**

  * Get a list of products and additional data

  *

  * @member {string}

  */

 productSearch?: string | OccEndpoint;

 /**

  * Get a list of available suggestions

  *

  * @member {string}

  */

 productSuggestions?: string | OccEndpoint;

 /**

  * Get CMS component details

  *

  * @member {string}

  */

 component?: string | OccEndpoint;

 /**

  * Get a list of CMS component details

  *

  * @member {string}

  */

 components?: string | OccEndpoint;

 /**

  * Get page data with list of cms content slots

  *

  * @member {string}

  */

 pages?: string | OccEndpoint;

 /**

  * Get page data with list of cms content slots

  *

  * @member {string}

  */

 page?: string | OccEndpoint;

 /**

  * Get all carts

  *

  * @member {string} [carts]

  */

 carts?: string | OccEndpoint;

 /**

  * Get a cart with a given identifier

  *

  * @member {string} [cart]

  */

 cart?: string | OccEndpoint;

 /**

  * Creates or restore a cart for a user

  *

  * @member {string} [createCart]

  */

 createCart?: string | OccEndpoint;

 /**

  * Deletes a cart with a given cart id

  *

  * @member {string} [deleteCart]

  */

 deleteCart?: string | OccEndpoint;

 /**

  * Adds a product to the cart

  *

  * @member {string} [addEntries]

  */

 addEntries?: string | OccEndpoint;

 /**

  * Update quantity and store the details of a cart entry

  *

  * @member {string} [updateEntries]

  */

 updateEntries?: string | OccEndpoint;

 /**

  * Deletes cart entry

  *

  * @member {string} [removeEntries]

  */

 removeEntries?: string | OccEndpoint;

 /**

  * Assign email to cart

  *

  * @member {string} [addEmail]

  */

 addEmail?: string | OccEndpoint;

 /**

  * Get a store location

  *

  * @member {string} [page]

  */

 store?: string | OccEndpoint;

 /**

  * Get a list of store locations

  *

  * @member {string} [page]

  */

 stores?: string | OccEndpoint;

 /**

  * Gets a store location count per country and regions

  *

  * @member {string} [page]

  */

 storescounts?: string | OccEndpoint;

 /**

  * Get a list of available languages

  *

  * @member {string}

  */

 languages?: string | OccEndpoint;

 /**

  * Get a list of available currencies

  *

  * @member {string}

  */

 currencies?: string | OccEndpoint;

 /**

  * Get a list of countries

  *

  * @member {string}

  */

 countries?: string | OccEndpoint;

 /**

  * Fetch the list of regions for the provided country

  *

  * @member {string}

  */

 regions?: string | OccEndpoint;

 /**

  * Titles used for user's personal info.

  *

  * @member {string}

  */

 titles?: string | OccEndpoint;

 /**

  * Get user details

  *

  * @member {string}

  */

 user?: string | OccEndpoint;

 /**

  * Register a new user.

  *

  * @member {string}

  */

 userRegister?: string | OccEndpoint;

 /**

  * Request an email to reset the password

  *

  * @member {string}

  */

 userForgotPassword?: string | OccEndpoint;

 /**

  * Reset the password once the email is recieved.

  *

  * @member {string}

  */

 userResetPassword?: string | OccEndpoint;

 /**

  * Update the user id with which the user authenticates.

  *

  * @member {string}

  */

 userUpdateLoginId?: string | OccEndpoint;

 /**

  * Update the user's password

  *

  * @member {string}

  */

 userUpdatePassword?: string | OccEndpoint;

 /**

  * Payment details root endpoint.

  *

  * @member {string}

  */

 paymentDetailsAll?: string | OccEndpoint;

 /**

  * Endpoint for a specific payment method.

  *

  * @member {string}

  */

 paymentDetail?: string | OccEndpoint;

 /**

  * Endpoint for the list of one user's orders

  *

  * @member {string}

  */

 orderHistory?: string | OccEndpoint;

 /**

  * Endpoint for the details of one user's order

  *

  * @member {string}

  */

 orderDetail?: string | OccEndpoint;

 /**

  * Endpoint for anonymous consent templates

  *

  * @member {string}

  */

 anonymousConsentTemplates?: string | OccEndpoint;

 /**

  * Endpoint for consent templates

  *

  * @member {string}

  */

 consentTemplates?: string | OccEndpoint;

 /**

  * Endpoint for a user's consents

  *

  * @member {string}

  */

 consents?: string | OccEndpoint;

 /**

  * Endpoint for a user's specific previously given consent.

  *

  * @member {string}

  */

 consentDetail?: string | OccEndpoint;

 /**

  * Endpoint for a user's addresses

  *

  * @member {string}

  */

 addresses?: string | OccEndpoint;

 /**

  * Endpoint for a user's specific address

  *

  * @member {string}

  */

 addressDetail?: string | OccEndpoint;

 /**

  * Endpoint for address verification

  *

  * @member {string}

  */

 addressVerification?: string | OccEndpoint;

 /**

  * Endpoint for consignment tracking

  *

  * @member {string}

  */

 consignmentTracking?: string | OccEndpoint;

 /**

  * Endpoint for asm customer search

  *

  * @member {string}

  */

 asmCustomerSearch?: string | OccEndpoint;

 /**

  * Endpoint for cart voucher

  *

  * @member {string}

  */

 cartVoucher?: string | OccEndpoint;

 /**

  * Endpoint for coupons

  *

  * @member {string}

  */

 customerCoupons?: string | OccEndpoint;

 /**

  * Endpoint for claiming coupon

  *

  * @member {string}

  */

 claimCoupon?: string | OccEndpoint;

 /**

  * Endpoint for coupons

  *

  * @member {string}

  */

 couponNotification?: string | OccEndpoint;

 /**

  * Explicitly saves a cart

  *

  * @member {string}

  */

 saveCart?: string | OccEndpoint;

 /**

  * Endpoint for notification preference

  *

  * @member {string}

  */

 notificationPreference?: string | OccEndpoint;

 /**

  * Endpoint for product interests

  *

  * @member {string}

  */

 productInterests?: string | OccEndpoint;

 /**

  * Endpoint for getting product interests

  *

  * @member {string}

  */

 getProductInterests?: string | OccEndpoint;

 /**

  * Endpoint for cancel an order

  */

 cancelOrder?: string | OccEndpoint;

 /**

  * Endpoint for creating order return request

  */

 returnOrder?: string | OccEndpoint;

 /**

  * Endpoint for user's order return requests

  */

 orderReturns?: string | OccEndpoint;

 /**

  * Endpoint for order return request details

  */

 orderReturnDetail?: string | OccEndpoint;

 /**

  * Endpoint for cancelling return request

  */

 cancelReturn?: string | OccEndpoint;

 /**

  * Endpoint for set delivery address to cart

  */

 setDeliveryAddress?: string | OccEndpoint;

 /**

  * Endpoint for place order

  */

 placeOrder?: string | OccEndpoint;

 /**

  * Endpoint for userGroupOrderApprovalPermission

  *

  * @member {string}

  */

 budget?: string | OccEndpoint;

 /**

  * Endpoint for budgets list

  *

  * @member {string}

  */

 budgets?: string | OccEndpoint;

 /**

  * Endpoint for organizations

  *

  * @member {string}

  */

 orgUnits?: string | OccEndpoint;

 /**

  * Endpoint for organizations list

  *

  * @member {string}

  */

 orgUnitsAvailable?: string | OccEndpoint;

 /**

  * Endpoint for organization units tree

  *

  * @member {string}

  */

 orgUnitsTree?: string | OccEndpoint;

 /**

  * Endpoint for approval processes for organization units

  *

  * @member {string}

  */

 orgUnitsApprovalProcesses?: string | OccEndpoint;

 /**

  * Endpoint for organization

  *

  * @member {string}

  */

 orgUnit?: string | OccEndpoint;

 /**

  * Endpoint for orgUnitUsers:

  *

  * @member {string}

  */

 orgUnitUsers?: string | OccEndpoint;

 /**

  * Endpoint for add orgUnitUserRoles (except approver):

  *

  * @member {string}

  */

 orgUnitUserRoles?: string | OccEndpoint;

 /**

  * Endpoint for remove orgUnitUserRole (except approver):

  *

  * @member {string}

  */

 orgUnitUserRole?: string | OccEndpoint;

 /**

  * Endpoint for add orgUnitApprovers:

  *

  * @member {string}

  */

 orgUnitApprovers?: string | OccEndpoint;

 /**

  * Endpoint for delete orgUnitApprover:

  *

  * @member {string}

  */

 orgUnitApprover?: string | OccEndpoint;

 /**

  * Endpoint for organizational unit addresses

  *

  * @member {string}

  */

 orgUnitsAddresses?: string | OccEndpoint;

 /**

  * Endpoint for organizational unit address

  *

  * @member {string}

  */

 orgUnitsAddress?: string | OccEndpoint;

 /**

  * Endpoint for organizational unit user groups list

  *

  * @member {string}

  */

 userGroups?: string | OccEndpoint;

 /**

  * Endpoint for organizational unit user group

  *

  * @member {string}

  */

 userGroup?: string | OccEndpoint;

 /**

  * Endpoint for costCenter list

  *

  * @member {string}

  */

 userGroupAvailableOrderApprovalPermissions?: string | OccEndpoint;

 /**

  * Endpoint for userGroupAvailableOrderApprovalPermissions list

  *

  * @member {string}

  */

 userGroupAvailableOrgCustomers?: string | OccEndpoint;

 /**

  * Endpoint for userGroupAvailableOrgCustomers list

  *

  * @member {string}

  */

 userGroupMembers?: string | OccEndpoint;

 /**

  * Endpoint for userGroupMembers list

  *

  * @member {string}

  */

 userGroupMember?: string | OccEndpoint;

 /**

  * Endpoint for userGroupMember

  *

  * @member {string}

  */

 userGroupOrderApprovalPermissions?: string | OccEndpoint;

 /**

  * Endpoint for userGroupOrderApprovalPermissions list

  *

  * @member {string}

  */

 userGroupOrderApprovalPermission?: string | OccEndpoint;

 /**

  * Endpoint for userGroupOrderApprovalPermission

  *

  * @member {string}

  */

 costCenters?: string | OccEndpoint;

 /**

  * Endpoint to schedule a replenishment order

  *

  * * @member {string}

  */

 scheduleReplenishmentOrder?: string | OccEndpoint;

 /**

  * * Endpoint for the list of one user's replenishment orders

  *

  * * @member {string}

  */

 replenishmentOrderHistory?: string | OccEndpoint;

 /* Endpoint to get a replenishment order details

  *

  * * @member {string}

  */

 replenishmentOrderDetails?: string | OccEndpoint;

 /**

  * Endpoint to get a replenishment order history for a replenishment

  *

  * * @member {string}

  */

 replenishmentOrderDetailsHistory?: string | OccEndpoint;

 /**

  * Endpoint to get a replenishment order history for a replenishment

  *

  * * @member {string}

  */

 cancelReplenishmentOrder?: string | OccEndpoint;

 /**

  * Endpoint for all costCenters

  *

  * @member {string}

  */

 costCentersAll?: string | OccEndpoint;

 /**

  * Endpoint for costCenter

  *

  * @member {string}

  */

 costCenter?: string | OccEndpoint;

 /**

  * Endpoint for budgets assigned to costCenter

  *

  * @member {string}

  */

 costCenterBudgets?: string | OccEndpoint;

 /**

  * Endpoint for budget assigned to costCenter

  *

  * @member {string}

  */

 costCenterBudget?: string | OccEndpoint;

 /**

  * Endpoint for permission list

  *

  * @member {string}

  */

 permissions?: string | OccEndpoint;

 /**

  * Endpoint for permission

  *

  * @member {string}

  */

 permission?: string | OccEndpoint;

 /**

  * Endpoint for order approval permission types

  *

  * @member {string}

  */

 orderApprovalPermissionTypes?: string | OccEndpoint;

 /**

  * Endpoint for organization customers

  *

  * @member {string}

  */

 b2bUsers?: string | OccEndpoint;

 /**

  * Endpoint for organization customer

  *

  * @member {string}

  */

 b2bUser?: string | OccEndpoint;

 /**

  * Endpoint for organization customer approvers

  *

  * @member {string}

  */

 b2bUserApprovers?: string | OccEndpoint;

 /**

  * Endpoint for organization customer approver

  *

  * @member {string}

  */

 b2bUserApprover?: string | OccEndpoint;

 /**

  * Endpoint for organization customer user groups

  *

  * @member {string}

  */

 b2bUserUserGroups?: string | OccEndpoint;

 /**

  * Endpoint for organization customer user group

  *

  * @member {string}

  */

 b2bUserUserGroup?: string | OccEndpoint;

 /**

  * Endpoint for organization customer permissions

  *

  * @member {string}

  */

 b2bUserPermissions?: string | OccEndpoint;

 /**

  * Endpoint for organization customer permission

  *

  * @member {string}

  */

 b2bUserPermission?: string | OccEndpoint;

 /**

  * Endpoint for order approvals

  *

  * @member {string}

  */

 orderApprovals?: string | OccEndpoint;

 /**

  * Endpoint for order approval

  *

  * @member {string}

  */

 orderApproval?: string | OccEndpoint;

 /**

  * Endpoint for order approval decision

  *

  * @member {string}

  */

 orderApprovalDecision?: string | OccEndpoint;

}

在单元测试里对OccConfig进行mock:

 beforeEach(() => {

   mockOccConfig = {

     backend: {

       occ: {

         baseUrl: 'test-baseUrl',

         prefix: '/test-occPrefix',

         endpoints: {

           login: '/authorizationserver/oauth/token',

           product: {

             default: 'configured-endpoint1/${test}?fields=abc',

             test: 'configured-endpoint1/${test}?fields=test',

           },

         },

       },

     },

     context: {

       baseSite: ['/test-baseSite'],

     },

   };

   TestBed.configureTestingModule({

     providers: [{ provide: OccConfig, useValue: mockOccConfig }],

   });

   service = TestBed.inject(OccEndpointsService);

 });


版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
阿里云服务器怎么设置密码?怎么停机?怎么重启服务器?
如果在创建实例时没有设置密码,或者密码丢失,您可以在控制台上重新设置实例的登录密码。本文仅描述如何在 ECS 管理控制台上修改实例登录密码。
9202 0
Spark RDD详解 —— RDD特性、lineage、缓存、checkpoint、依赖关系
RDD(Resilient Distributed Datasets)弹性的分布式数据集,又称Spark core,它代表一个只读的、不可变、可分区,里面的元素可分布式并行计算的数据集。
897 0
阿里云服务器如何登录?阿里云服务器的三种登录方法
购买阿里云ECS云服务器后如何登录?场景不同,大概有三种登录方式:
2902 0
使用-MM生成include指令和依赖生成(make include directive and dependency generation with -MM)
I want a build rule to be triggered by an include directive if the target of the include is out of date or doesn't exist.
913 0
Package.json中dependencies依赖包中^符号和~符号前缀的区别
刚git了webpack的包发现package.json里面dependencies依赖包的版本号前面的符号有两种,一种是~,一种是^,如下图标记: 然后搜了下在stackoverflow上找到一个比较好的答案所以在此mark下 ~,^的区别是 ~的意思是匹配最近的小版本 比如~1.
803 0
Redisson官方文档 - 15. 项目依赖列表
Redisson采用了常见的若干项目作为依赖,比如Netty、Jackson等等。
2419 0
SAP Spartacus 定义在app.module.ts里的providers依赖注入元数据何时得到处理
我基于 SAP Spartacus library创建了一个自定义的Storefront实现。在其app.module.ts里,我采用自定义的MyCurrentProductService,去替换 SAP Spartacus 标准的CurrentProductService 实现:
4 0
阿里云服务器端口号设置
阿里云服务器初级使用者可能面临的问题之一. 使用tomcat或者其他服务器软件设置端口号后,比如 一些不是默认的, mysql的 3306, mssql的1433,有时候打不开网页, 原因是没有在ecs安全组去设置这个端口号. 解决: 点击ecs下网络和安全下的安全组 在弹出的安全组中,如果没有就新建安全组,然后点击配置规则 最后如上图点击添加...或快速创建.   have fun!  将编程看作是一门艺术,而不单单是个技术。
10762 0
使用Angular依赖注入自定义SAP Spartacus的ProductAdapter
使用Angular依赖注入自定义SAP Spartacus的ProductAdapter
9 0
Silverlight:Dependency Property(依赖属性)学习笔记
1.定义依赖属性:           #region Text        public static readonly DependencyProperty TextProperty = DependencyProperty.
707 0
2497
文章
0
问答
来源圈子
更多
+ 订阅
文章排行榜
最热
最新
相关电子书
更多
《2021云上架构与运维峰会演讲合集》
立即下载
《零基础CSS入门教程》
立即下载
《零基础HTML入门教程》
立即下载