{"id":354252,"date":"2024-05-20T22:44:47","date_gmt":"2024-05-20T22:44:47","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=354252"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=354252","title":{"rendered":"<span>\u0415\u0434\u0438\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0418\u043b\u0438 \u043a\u0430\u043a \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0421\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043f\u0440\u043e\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u044b\u0445 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432. \u041a\u043e\u0434\u043e\u0432\u0430\u044f \u0431\u0430\u0437\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043e\u0442\u043d\u043e\u0441\u044f\u0449\u0430\u044f\u0441\u044f \u043a \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u043c \u0442\u0435\u0441\u0442\u0430\u043c, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0439, \u043a\u0430\u043a \u0438 \u0437\u0430\u0442\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043d\u0430 \u0435\u0435 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435.<\/p>\n<p>\u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u043e\u043f\u0438\u0441\u0430\u043d \u043f\u043e\u0434\u0445\u043e\u0434, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0441 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432. \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f, \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0434\u0438\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0432\u044b\u0432\u043e\u0434 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c. \u0415\u0441\u043b\u0438 \u0432\u0430\u0441 \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b\u043e, \u043a\u0430\u043a \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c, \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u044e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e.<\/p>\n<p>\u0412\u0441\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0441 \u043a\u043e\u0434\u043e\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u043d\u0430 Java, \u043d\u043e \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432 \u0438 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a. \u042d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u044b\u043b\u0430 \u043f\u043e\u043d\u044f\u0442\u043d\u0430 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f\u043c \u0432\u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0441\u0442\u0435\u043a\u0430 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0439.<\/p>\n<p>\u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0441\u0442\u043e\u0438\u0442 \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c Java \u043d\u0435 \u043a\u0430\u043a \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u044f\u0437\u044b\u043a \u0441 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c\u0438 \u0432 \u043d\u0435\u043c \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u0430 \u043a\u0430\u043a \u043f\u0441\u0435\u0432\u0434\u043e-\u044f\u0437\u044b\u043a \u0441 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u043e\u043c, \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u043d\u044b\u043c \u043a Java. \u042d\u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 Java, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0438\u0437 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043c\u043e\u0433\u043b\u0438 \u0431\u044b\u0442\u044c \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u043e \u043f\u0440\u043e\u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0435\u0439, \u043d\u0435\u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0445 \u0441 Java.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0434\u0430, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u0449\u0435\u043f\u0440\u0438\u0437\u043d\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438 \u043f\u043e \u043f\u0440\u043e\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043c\u043e\u0433\u043b\u0438 \u0431\u044b\u0442\u044c \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u043e \u043f\u0440\u043e\u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u043f\u043e \u043c\u043d\u0435\u043d\u0438\u044e \u0430\u0432\u0442\u043e\u0440\u0430 \u043d\u0435 \u0432\u043b\u0438\u044f\u043b\u0438 \u043d\u0430 \u0441\u0443\u0442\u044c \u0438\u0437\u043b\u0430\u0433\u0430\u0435\u043c\u043e\u0433\u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430.<\/p>\n<h2>1. \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438<\/h2>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u0441\u0443\u0442\u0438 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u043c\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430, \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u043c\u043e\u0433\u0443\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u0435\u0441\u0442\u044b. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u0430\u043b\u0435\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u0430\u044f \u043e\u0431\u043b\u0430\u0441\u0442\u044c.<\/p>\n<p>\u041f\u0443\u0441\u0442\u044c \u0435\u0441\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u043c\u0430\u0433\u0430\u0437\u0438\u043d, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c \u0437\u0430\u043a\u0430\u0437\u044b \u0442\u043e\u0432\u0430\u0440\u043e\u0432. \u0418 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0430 \u0435\u0441\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<ul>\n<li>\n<p>user &#8212; \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439<\/p>\n<ul>\n<li>\n<p>id: UUID<\/p>\n<\/li>\n<li>\n<p>login: String<\/p>\n<\/li>\n<li>\n<p>password: String<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>product &#8212; \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043f\u0440\u043e\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0445 \u0442\u043e\u0432\u0430\u0440\u043e\u0432<\/p>\n<ul>\n<li>\n<p>id: UUID<\/p>\n<\/li>\n<li>\n<p>name: String<\/p>\n<\/li>\n<li>\n<p>price: Integer<\/p>\n<\/li>\n<li>\n<p>total: Integer<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>delivery_address &#8212; \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0430\u0434\u0440\u0435\u0441\u0430 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u0442\u043e\u0432\u0430\u0440\u043e\u0432<\/p>\n<ul>\n<li>\n<p>id: UUID<\/p>\n<\/li>\n<li>\n<p>country: String<\/p>\n<\/li>\n<li>\n<p>city: String<\/p>\n<\/li>\n<li>\n<p>street: String<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>order &#8212; \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0437\u0430\u043a\u0430\u0437\u043e\u0432<\/p>\n<ul>\n<li>\n<p>id: UUID<\/p>\n<\/li>\n<li>\n<p>user_id: UUID<\/p>\n<\/li>\n<li>\n<p>delivery_address_id: UUID<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>order_item &#8212; \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043f\u043e\u0437\u0438\u0446\u0438\u0439 \u0437\u0430\u043a\u0430\u0437\u0430<\/p>\n<ul>\n<li>\n<p>id: UUID<\/p>\n<\/li>\n<li>\n<p>order_id: UUID<\/p>\n<\/li>\n<li>\n<p>product_id: UUID<\/p>\n<\/li>\n<li>\n<p>total: Integer<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u0418 \u043f\u0443\u0441\u0442\u044c \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0430 \u0441\u0440\u0435\u0434\u0438 \u043f\u0440\u043e\u0447\u0438\u0445 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0434\u0432\u0430 REST-\u043c\u0435\u0442\u043e\u0434\u0430:<\/p>\n<ol>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0437\u0430\u043a\u0430\u0437<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0437\u0430\u043a\u0430\u0437\u0435 \u043f\u043e \u0435\u0433\u043e id<\/p>\n<\/li>\n<\/ol>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u044b \u043f\u043e\u0434\u0445\u043e\u0434\u044b \u043f\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0442\u0435\u0441\u0442\u043e\u0432 \u0434\u043b\u044f \u044d\u0442\u0438\u0445 \u0434\u0432\u0443\u0445 REST-\u043c\u0435\u0442\u043e\u0434\u043e\u0432.<\/p>\n<h2>2. \u0422\u0435\u0441\u0442\u044b \u0441 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445<\/h2>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b.<\/p>\n<p>\u041d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0441 \u043a\u043e\u0434\u043e\u043c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432. \u0420\u0430\u0437\u0434\u0435\u043b 2.1. \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c, \u043f\u0435\u0440\u0435\u0439\u0434\u044f \u0441\u0440\u0430\u0437\u0443 \u043a \u0440\u0430\u0437\u0434\u0435\u043b\u0443 2.2., \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e \u043c\u043d\u0435\u043d\u0438\u044e \u0430\u0432\u0442\u043e\u0440\u0430 \u0441\u0442\u0430\u0442\u044c\u0438 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u044b.<\/p>\n<h2>2.1. \u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432<\/h2>\n<pre><code class=\"java\">public class DbTestClient {     public void execute(String sql) {         \/\/\u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u043c\u0443\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e (insert, update \u0438\u043b\u0438 delete) \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 \u0421\u0423\u0411\u0414     }      public List&lt;Map&lt;String, Object>> select(String sql) {         \/\/\u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 select \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 \u0421\u0423\u0411\u0414         \/\/\u0437\u0430\u0442\u0435\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0441\u0442\u0440\u043e\u043a\u0438     } }<\/code><\/pre>\n<p>\u041b\u0438\u0441\u0442\u0438\u043d\u0433 2.1.1.<\/p>\n<p><strong>DbTestClient<\/strong> &#8212; \u043a\u043b\u0430\u0441\u0441, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043c\u0443\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432 \u0421\u0423\u0411\u0414 \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434 <em>execute<\/em>. \u0422\u0430\u043a\u0436\u0435 \u0434\u0430\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0411\u0414 \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 select \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434 <em>select<\/em>.<\/p>\n<pre><code class=\"java\">public class RestTestClient {     public RestResponse send(RestRequest request) {         \/\/\u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 REST \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u0430     } }<\/code><\/pre>\n<p>\u041b\u0438\u0441\u0442\u0438\u043d\u0433 2.1.2.<\/p>\n<pre><code class=\"java\">public class RestRequest {     private String url;     private String httpMethod;     private Map&lt;String, String> headers;     private String body; }<\/code><\/pre>\n<p>\u041b\u0438\u0441\u0442\u0438\u043d\u0433 2.1.3.<\/p>\n<pre><code class=\"java\">public class RestResponse {     private Map&lt;String, String> headers;     private String body;     private int statusCode; }<\/code><\/pre>\n<p>\u041b\u0438\u0441\u0442\u0438\u043d\u0433 2.1.4.<\/p>\n<p><strong>RestTestClient<\/strong> &#8212; \u043a\u043b\u0430\u0441\u0441, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c REST-\u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 REST-\u043e\u0442\u0432\u0435\u0442\u044b. REST-\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u043a\u043b\u0430\u0441\u0441\u043e\u043c <em>RestRequest<\/em>. REST-\u043e\u0442\u0432\u0435\u0442\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u043a\u043b\u0430\u0441\u0441\u043e\u043c <em>RestResponse<\/em>.<\/p>\n<pre><code class=\"java\">public class JsonUtils {     public static String getString(String json, String jsonPath) {         \/\/\u041f\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c\u0443 jsonPath \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435     }      public static int getInt(String json, String jsonPath) {         \/\/\u041f\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c\u0443 jsonPath \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435     } }<\/code><\/pre>\n<p>\u041b\u0438\u0441\u0442\u0438\u043d\u0433 2.1.5.<\/p>\n<p><strong>JsonUtils<\/strong> &#8212; \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0437 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 JSON \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u043f\u043e JSONPath.<\/p>\n<h2>2.2. \u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0442\u0435\u0441\u0442\u043e\u0432<\/h2>\n<p>\u041d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0442\u0435\u0441\u0442 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0437\u0430\u043a\u0430\u0437\u0430.<\/p>\n<pre><code class=\"java\">public class CreateOrderTest {     private DbTestClient dbTestClient;     private RestTestClient restTestClient;      public void createOrderTest() {         \/\/Given         \/\/ (1)         dbTestClient.execute(\"\"\"                 insert into product (id, name, price, total) values (                     '00000003-0000-0000-0000-000000000001',                     'Brush',                     100,                     1000                 ), (                     '00000003-0000-0000-0000-000000000002',                     'Canvas',                     1000,                     500                 )                 \"\"\");          dbTestClient.execute(\"\"\"                 insert into user (id, login, password) values (                     '00000004-0000-0000-0000-000000000001',                     'user',                     'qwerty'                 )                 \"\"\");         \/\/When         \/\/ (2)         var request = new RestRequest();         request.setUrl(\"http:\/\/user:qwerty@localhost:8080\/orders\");         request.setHttpMethod(\"POST\");         request.setBody(\"\"\"                 {                   \"id\": \"00000001-0000-0000-0000-000000000001\",                   \"items\": [                     {                       \"id\": \"00000002-0000-0000-0000-000000000001\",                       \"product_id\": \"00000003-0000-0000-0000-000000000001\",                       \"total\": \"5\"                     },                     {                       \"id\": \"00000002-0000-0000-0000-000000000002\",                       \"product_id\": \"00000003-0000-0000-0000-000000000002\",                       \"total\": \"10\"                     }                   ],                   \"delivery_address\": {                     \"id\": \"00000005-0000-0000-0000-000000000001\",                     \"country\": \"Russia\",                     \"city\": \"Saint-Petersburg\",                     \"street\": \"Palace Square, 2\"                   }                 }                 \"\"\");          var response = restTestClient.send(request);         \/\/Then         \/\/ (3)         assertEquals(201, response.getStatusCode());          var orders = dbTestClient.select(\"\"\"                 select * from order                 where id = '00000001-0000-0000-0000-000000000001'                 \"\"\");          assertEquals(1, orders.size());         var order = orders.get(0);          assertEquals(\"00000001-0000-0000-0000-000000000001\", order.get(\"id\"));         assertEquals(\"00000004-0000-0000-0000-000000000001\", order.get(\"user_id\"));         assertEquals(\"00000005-0000-0000-0000-000000000001\", order.get(\"delivery_address_id\"));          var deliveryAddresses = dbTestClient.select(\"\"\"                 select * from delivery_address                 where id = '00000005-0000-0000-0000-000000000001'                 \"\"\");          assertEquals(1, deliveryAddresses.size());         var deliveryAddress = deliveryAddresses.get(0);          assertEquals(\"00000005-0000-0000-0000-000000000001\", deliveryAddress.get(\"id\"));         assertEquals(\"Russia\", deliveryAddress.get(\"country\"));         assertEquals(\"Saint-Petersburg\", deliveryAddress.get(\"city\"));         assertEquals(\"Palace Square, 2\", deliveryAddress.get(\"street\"));          var items = dbTestClient.select(\"\"\"                 select * from order_item                 where order_id = '00000001-0000-0000-0000-000000000001'                 order by product_id                 \"\"\");          assertEquals(2, items.size());          var brushItem = items.get(0);         assertEquals(\"00000002-0000-0000-0000-000000000001\", brushItem.get(\"id\"));         assertEquals(\"00000001-0000-0000-0000-000000000001\", brushItem.get(\"order_id\"));         assertEquals(\"00000003-0000-0000-0000-000000000001\", brushItem.get(\"product_id\"));         assertEquals(5, brushItem.get(\"total\"));          var canvasItem = items.get(1);         assertEquals(\"00000002-0000-0000-0000-000000000002\", canvasItem.get(\"id\"));         assertEquals(\"00000001-0000-0000-0000-000000000001\", canvasItem.get(\"order_id\"));         assertEquals(\"00000003-0000-0000-0000-000000000002\", canvasItem.get(\"product_id\"));         assertEquals(10, canvasItem.get(\"total\"));         \/\/ (4)     } }<\/code><\/pre>\n<p>\u041b\u0438\u0441\u0442\u0438\u043d\u0433 2.2.1.<\/p>\n<p>\u0411\u043b\u043e\u043a \u043a\u043e\u0434\u0430 \u0438\u0437 <em>\u043b\u0438\u0441\u0442\u0438\u043d\u0433\u0430 2.2.1.<\/em> \u043c\u0435\u0436\u0434\u0443 \u043c\u0435\u0442\u043a\u0430\u043c\u0438 <code>(1)<\/code> \u0438 <code>(2)<\/code> \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 (\u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445) \u043a \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u043c\u0443 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044e <em>(Given)<\/em>. \u0417\u0430\u0442\u0435\u043c \u0431\u043b\u043e\u043a \u043a\u043e\u0434\u0430 \u043c\u0435\u0436\u0434\u0443 \u043c\u0435\u0442\u043a\u0430\u043c\u0438 <code>(2)<\/code> \u0438 <code>(3)<\/code> \u043f\u043e\u0434\u0433\u043e\u0442\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 REST-\u0437\u0430\u043f\u0440\u043e\u0441 <em>(When)<\/em>. \u0412 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u0432 \u0431\u043b\u043e\u043a\u0435 \u043a\u043e\u0434\u0430 \u043c\u0435\u0436\u0434\u0443 \u043c\u0435\u0442\u043a\u0430\u043c\u0438 <code>(3)<\/code> \u0438 <code>(4)<\/code> \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e REST-\u043e\u0442\u0432\u0435\u0442\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u044b (\u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445) \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 <em>(Then)<\/em>.<\/p>\n<p>\u041d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0442\u0435\u0441\u0442 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0437\u0430\u043a\u0430\u0437\u0430 \u043f\u043e id.<\/p>\n<pre><code class=\"java\">public class GetOrderTest {     private DbTestClient dbTestClient;     private RestTestClient restTestClient;      public void getOrderTest() {         \/\/Given         \/\/ (1)         dbTestClient.execute(\"\"\"                 insert into product (id, name, price, total) values (                     '00000003-0000-0000-0000-000000000001',                     'Brush',                     100,                     1000                 ), (                     '00000003-0000-0000-0000-000000000002',                     'Canvas',                     1000,                     500                 )                 \"\"\");          dbTestClient.execute(\"\"\"                 insert into user (id, login, password) values (                     '00000004-0000-0000-0000-000000000001',                     'user',                     'qwerty'                 )                 \"\"\");          dbTestClient.execute(\"\"\"                 insert into delivery_address (id, country, city, street) values (                     '00000005-0000-0000-0000-000000000001',                     'Russia',                     'Saint-Petersburg',                     'Palace Square, 2'                 )                 \"\"\");          dbTestClient.execute(\"\"\"                 insert into order (id, user_id, delivery_address_id) values (                     '00000001-0000-0000-0000-000000000001',                     '00000004-0000-0000-0000-000000000001',                     '00000005-0000-0000-0000-000000000001'                 )                 \"\"\");          dbTestClient.execute(\"\"\"                 insert into order_item (id, order_id, product_id, total) values (                     '00000002-0000-0000-0000-000000000001',                     '00000001-0000-0000-0000-000000000001',                     '00000003-0000-0000-0000-000000000001',                     5                 ), (                     '00000002-0000-0000-0000-000000000002',                     '00000001-0000-0000-0000-000000000001',                     '00000003-0000-0000-0000-000000000002',                     10                 )                 \"\"\");         \/\/When         \/\/ (2)         var request = new RestRequest();         request.setUrl(\"http:\/\/user:qwerty@localhost:8080\/orders\/00000001-0000-0000-0000-000000000001\");         request.setHttpMethod(\"GET\");          var response = restTestClient.send(request);         \/\/Then         \/\/ (3)         assertEquals(200, response.getStatusCode());         var body = response.getBody();          assertEquals(\"00000001-0000-0000-0000-000000000001\", JsonUtils.getString(body, \"$.id\"));         assertEquals(\"00000002-0000-0000-0000-000000000001\", JsonUtils.getString(body, \"$.items[0].id\"));         assertEquals(\"00000003-0000-0000-0000-000000000001\", JsonUtils.getString(body, \"$.items[0].product_id\"));         assertEquals(5, JsonUtils.getInt(body, \"$.items[0].total\"));         assertEquals(\"00000002-0000-0000-0000-000000000002\", JsonUtils.getString(body, \"$.items[1].id\"));         assertEquals(\"00000003-0000-0000-0000-000000000002\", JsonUtils.getString(body, \"$.items[1].product_id\"));         assertEquals(10, JsonUtils.getInt(body, \"$.items[1].total\"));         assertEquals(\"00000005-0000-0000-0000-000000000001\", JsonUtils.getString(body, \"$.delivery_address.id\"));         assertEquals(\"Russia\", JsonUtils.getString(body, \"$.delivery_address.country\"));         assertEquals(\"Saint-Petersburg\", JsonUtils.getString(body, \"$.delivery_address.city\"));         assertEquals(\"Palace Square, 2\", JsonUtils.getString(body, \"$.delivery_address.street\"));         \/\/ (4)     } }<\/code><\/pre>\n<p>\u041b\u0438\u0441\u0442\u0438\u043d\u0433 2.2.2.<\/p>\n<p><em>\u041b\u0438\u0441\u0442\u0438\u043d\u0433 2.2.2.<\/em> \u0438\u043c\u0435\u0435\u0442 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443. \u041c\u0435\u0436\u0434\u0443 \u043c\u0435\u0442\u043a\u0430\u043c\u0438 <code>(1)<\/code> \u0438 <code>(2)<\/code> \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043a \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u043c\u0443 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044e <em>(Given)<\/em>. \u041c\u0435\u0436\u0434\u0443 \u043c\u0435\u0442\u043a\u0430\u043c\u0438 <code>(2)<\/code> \u0438 <code>(3)<\/code> \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 REST-\u0437\u0430\u043f\u0440\u043e\u0441\u0430 <em>(When)<\/em>. \u041c\u0435\u0436\u0434\u0443 \u043c\u0435\u0442\u043a\u0430\u043c\u0438 <code>(3)<\/code> \u0438 <code>(4)<\/code> \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 REST-\u043e\u0442\u0432\u0435\u0442\u0430 <em>(Then)<\/em>.<\/p>\n<p>\u0427\u0442\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u044c\u043d\u044b\u043c \u0432 \u044d\u0442\u0438\u0445 \u0434\u0432\u0443\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0441 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u043c, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u043c \u0432 \u0431\u0443\u0434\u0443\u0449\u0438\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u0430\u0445? \u041f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u044c\u043d\u044b\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430 \u043a\u043e\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u0432\u043e\u0439 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<ol>\n<li>\n<p>\u0414\u043b\u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043a \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u043c\u0443 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044e \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e insert \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u0445 SQL.<\/p>\n<\/li>\n<li>\n<p>\u0414\u043b\u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 REST-\u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0432 JSON \u0444\u043e\u0440\u043c\u0430\u0442\u0435.<\/p>\n<\/li>\n<li>\n<p>\u0414\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f select \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 (\u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0438 \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432) \u044f\u0437\u044b\u043a\u0430 Java. \u041e\u043d\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u0441 assertEquals.<\/p>\n<\/li>\n<li>\n<p>\u0414\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 REST-\u043e\u0442\u0432\u0435\u0442\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 JSON \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e JSONPath \u0438 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f assertEquals \u0434\u043b\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u043b\u044f.<\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0437\u0434\u0435\u0441\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u044d\u0442\u0438\u0445 \u0442\u0435\u0441\u0442\u043e\u0432 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u043b\u0438\u0431\u043e \u0447\u0430\u0441\u0442\u0438.<\/p>\n<p>\u041d\u0438\u0436\u0435 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u044d\u0442\u0438\u0445 \u0434\u0432\u0443\u0445 \u0442\u0435\u0441\u0442\u043e\u0432:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/b9a\/aa8\/2b6\/b9aaa82b6abbb40fe5124b22fd4cd445.jpg\" width=\"522\" height=\"362\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b9a\/aa8\/2b6\/b9aaa82b6abbb40fe5124b22fd4cd445.jpg\" data-blurred=\"true\"\/><\/figure>\n<p>\u0420\u0438\u0441. 2.2.3.<\/p>\n<p>\u0420\u0430\u0437\u043d\u044b\u0435 \u0446\u0432\u0435\u0442\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0440\u0430\u0437\u043d\u044b\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u043c \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u0438\u043b\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<h2>3. \u0422\u0435\u0441\u0442\u044b \u0441 \u0435\u0434\u0438\u043d\u044b\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445<\/h2>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043a \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0442\u0435\u0441\u0442\u043e\u0432. \u041a\u0430\u043a \u0443\u0436\u0435, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0441\u0442\u0430\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043f\u043e\u0434\u0445\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0435\u0434\u0438\u043d\u043e\u0433\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0435 \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u044d\u0442\u043e\u0439 \u0446\u0435\u043b\u0438.<\/p>\n<h2>3.1. \u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432<\/h2>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0435\u0434\u0438\u043d\u043e\u0433\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d JSON \u0444\u043e\u0440\u043c\u0430\u0442. \u041d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e JSON. \u0413\u043b\u0430\u0432\u043d\u043e\u0435, \u0447\u0442\u043e\u0431\u044b \u0444\u043e\u0440\u043c\u0430\u0442 \u0431\u044b\u043b \u043e\u0434\u0438\u043d.<\/p>\n<pre><code class=\"java\">public class DbTestClient {     \/\/rows - \u0441\u0442\u0440\u043e\u043a\u0438 \u0434\u043b\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0432 JSON \u0444\u043e\u0440\u043c\u0430\u0442\u0435     public void insert(String tableName, String rows) {         \/\/\u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 rows \u0438\u0437 JSON \u0444\u043e\u0440\u043c\u0430\u0442\u0430 \u0432 insert \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432 sql \u0444\u043e\u0440\u043c\u0430\u0442\u0435         \/\/\u0437\u0430\u0442\u0435\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 insert \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u0421\u0423\u0411\u0414 \u0434\u043b\u044f \u0438\u0445 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f     }      public String select(String sql) {         \/\/\u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 select \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 \u0421\u0423\u0411\u0414         \/\/\u0437\u0430\u0442\u0435\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043e\u0442 \u0421\u0423\u0411\u0414 \u0432 JSON \u0444\u043e\u0440\u043c\u0430\u0442     } }<\/code><\/pre>\n<p>\u041b\u0438\u0441\u0442\u0438\u043d\u0433 3.1.1.<\/p>\n<p><strong>DbTestClient<\/strong> &#8212; \u043a\u043b\u0430\u0441\u0441, \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0441 \u0421\u0423\u0411\u0414. \u041d\u043e \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 \u0438\u0437 <em>\u041b\u0438\u0441\u0442\u0438\u043d\u0433\u0430 2.1.1.<\/em>:<\/p>\n<ul>\n<li>\n<p>\u043c\u0435\u0442\u043e\u0434 <em>insert<\/em> \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u0441\u0442\u0430\u0432\u043a\u0443 \u0438 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0445 \u0441\u0442\u0440\u043e\u043a \u0432 JSON \u0444\u043e\u0440\u043c\u0430\u0442\u0435;<\/p>\n<\/li>\n<li>\n<p>\u043c\u0435\u0442\u043e\u0434 <em>select<\/em> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f select \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 JSON \u0444\u043e\u0440\u043c\u0430\u0442\u0435.<\/p>\n<\/li>\n<\/ul>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0432 \u0442\u0435\u0441\u0442\u0430\u0445 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d <em>RestTestClient<\/em>. \u0414\u043b\u044f \u043d\u0435\u0433\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u043a\u043e\u0434\u0430, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d \u0438 \u0435\u0433\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u043d\u0438\u0447\u0435\u043c \u043d\u0435 \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u043e\u0442 \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u043e\u0432: 2.1.2., 2.1.3., 2.1.4. \u0414\u0430\u043d\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d\u0438 \u0443\u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441 JSON \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u043c.<\/p>\n<p>\u041d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 JsonAsserter.<\/p>\n<pre><code class=\"java\">public class JsonAsserter {     \/\/ expected - \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0432 JSON \u0444\u043e\u0440\u043c\u0430\u0442\u0435, \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430.     \/\/ actual - \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 JSON \u0444\u043e\u0440\u043c\u0430\u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u0441 expected.     public static void assertEquals(String expected, String actual) {         \/\/ \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 expected \u0438 actual \u0432 JSON \u0444\u043e\u0440\u043c\u0430\u0442\u0435     } }<\/code><\/pre>\n<p>\u041b\u0438\u0441\u0442\u0438\u043d\u0433 3.1.2.<\/p>\n<p><strong>JsonAsserter<\/strong> &#8212; \u043a\u043b\u0430\u0441\u0441, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u043d\u0430 \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u043e \u0434\u0432\u0435 \u0441\u0442\u0440\u043e\u043a\u0438, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 JSON \u0444\u043e\u0440\u043c\u0430\u0442\u0435. \u0412\u0430\u0436\u043d\u044b\u043c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043a \u043c\u0435\u0442\u043e\u0434\u0443 <em>JsonAsserter#assertEquals<\/em> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u043e\u0431\u0449\u0430\u0442\u044c \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSONPath, \u043f\u043e \u043a\u0430\u043a\u043e\u043c\u0443 \u043f\u0443\u0442\u0438 \u0432 JSON \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0440\u0430\u0441\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043f\u043e \u0434\u0430\u043d\u043d\u044b\u043c.<\/p>\n<h2>3.2. \u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0442\u0435\u0441\u0442\u043e\u0432<\/h2>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u043e\u043f\u0438\u0441\u0430\u043d \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0442\u0435\u0441\u0442\u043e\u0432. \u041d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043f\u0435\u0440\u0432\u044b\u0439 \u0448\u0430\u0433 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0442\u0435\u0441\u0442\u0430 \u0434\u043b\u044f REST-\u043c\u0435\u0442\u043e\u0434\u0430 \u043f\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u0437\u0430\u043a\u0430\u0437\u0430.<\/p>\n<pre><code class=\"java\">public class CreateOrderTest {     private DbTestClient dbTestClient;     private RestTestClient restTestClient;      public void createOrderTest() {         \/\/Given         \/\/ (1)         dbTestClient.insert(\"product\", \"\"\"                 [                     {                       \"id\": \"00000003-0000-0000-0000-000000000001\",                       \"name\": \"Brush\",                       \"price\": \"100\"                       \"total\": 1000                     },                     {                       \"id\": \"00000003-0000-0000-0000-000000000002\",                       \"name\": \"Canvas\",                       \"price\": \"1000\"                       \"total\": 500                     }                 ]                 \"\"\");          dbTestClient.insert(\"user\", \"\"\"                 [                     {                       \"id\": \"00000004-0000-0000-0000-000000000001\",                       \"login\": \"user\",                       \"password\": \"qwerty\"                     }                 ]                 \"\"\");         \/\/When         \/\/ (2)         var request = new RestRequest();         request.setUrl(\"http:\/\/user:qwerty@localhost:8080\/orders\");         request.setHttpMethod(\"POST\");         request.setBody(\"\"\"                 {                   \"id\": \"00000001-0000-0000-0000-000000000001\",                   \"items\": [                     {                       \"id\": \"00000002-0000-0000-0000-000000000001\",                       \"product_id\": \"00000003-0000-0000-0000-000000000001\",                       \"total\": \"5\"                     },                     {                       \"id\": \"00000002-0000-0000-0000-000000000002\",                       \"product_id\": \"00000003-0000-0000-0000-000000000002\",                       \"total\": \"10\"                     }                   ],                   \"delivery_address\": {                     \"id\": \"00000005-0000-0000-0000-000000000001\",                     \"country\": \"Russia\",                     \"city\": \"Saint-Petersburg\",                     \"street\": \"Palace Square, 2\"                   }                 }                 \"\"\");          var response = restTestClient.send(request);         \/\/Then         \/\/ (3)         assertEquals(201, response.getStatusCode());          var order = dbTestClient.select(\"\"\"                 select * from order                 where id = '00000001-0000-0000-0000-000000000001'                 \"\"\");         \/\/ (4)         System.out.println(\"Order:\\n\" + order);          var deliveryAddress = dbTestClient.select(\"\"\"                 select * from delivery_address                 where id = '00000005-0000-0000-0000-000000000001'                 \"\"\");         \/\/ (5)         System.out.println(\"Delivery address:\\n\" + deliveryAddress);          var items = dbTestClient.select(\"\"\"                 select * from order_item                 where order_id = '00000001-0000-0000-0000-000000000001'                 order by product_id                 \"\"\");         \/\/ (6)         System.out.println(\"Items:\\n\" + items);     } }<\/code><\/pre>\n<p>\u041b\u0438\u0441\u0442\u0438\u043d\u0433 3.2.1.<\/p>\n<p>\u0411\u043b\u043e\u043a \u043a\u043e\u0434\u0430 \u0438\u0437 <em>\u043b\u0438\u0441\u0442\u0438\u043d\u0433\u0430 3.2.1.<\/em> \u043c\u0435\u0436\u0434\u0443 \u043c\u0435\u0442\u043a\u0430\u043c\u0438 <code>(1)<\/code> \u0438 <code>(2)<\/code> \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043a \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u043c\u0443 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044e, \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044f \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 <em>(Given)<\/em>. \u0422\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 JSON \u0444\u043e\u0440\u043c\u0430\u0442\u0435. \u0417\u0430\u0442\u0435\u043c \u0431\u043b\u043e\u043a \u043a\u043e\u0434\u0430 \u043c\u0435\u0436\u0434\u0443 \u043c\u0435\u0442\u043a\u0430\u043c\u0438 <code>(2)<\/code> \u0438 <code>(3)<\/code> \u043f\u043e\u0434\u0433\u043e\u0442\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 REST-\u0437\u0430\u043f\u0440\u043e\u0441 <em>(When)<\/em>. \u0414\u043e \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043d\u0435 \u0431\u044b\u043b\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435\u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e. \u041d\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u043c\u0435\u0442\u043a\u0438 <code>(4)<\/code>, \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u043f\u0435\u0440\u0432\u0430\u044f \u043f\u043e\u043b\u0435\u0437\u043d\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0430\u044f \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0442\u0435\u0441\u0442\u043e\u0432.<\/p>\n<p>\u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f REST-\u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0432 \u0441\u0442\u0440\u043e\u043a\u0430\u0445 \u043a\u043e\u0434\u0430 \u043f\u043e\u0441\u043b\u0435 \u043c\u0435\u0442\u043e\u043a <code>(4)<\/code>, <code>(5)<\/code> \u0438 <code>(6)<\/code>.<\/p>\n<p>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0442\u0435\u0441\u0442\u0430 \u0435\u0449\u0435 \u043d\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0430. \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u044d\u0442\u0430\u043f\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a \u0442\u0435\u0441\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0432\u0435\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430.<\/p>\n<p>\u041d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0432\u044b\u0432\u043e\u0434 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0442\u0435\u0441\u0442\u0430.<\/p>\n<pre><code>Order: [     {       \"id\": \"00000001-0000-0000-0000-000000000001\",       \"user_id\": \"00000004-0000-0000-0000-000000000001\",       \"delivery_address_id\": \"00000005-0000-0000-0000-000000000001\"     } ] Delivery address: [     {       \"id\": \"00000005-0000-0000-0000-000000000001\",       \"country\": \"Russia\",       \"city\": \"Saint-Petersburg\",       \"street\": \"INVALID VALUE\"     } ] Items: [   {     \"id\": \"00000002-0000-0000-0000-000000000001\",     \"order_id\": \"00000001-0000-0000-0000-000000000001\",     \"product_id\": \"00000003-0000-0000-0000-000000000001\",     \"total\": \"5\"   },   {     \"id\": \"00000002-0000-0000-0000-000000000002\",     \"order_id\": \"00000001-0000-0000-0000-000000000001\",     \"product_id\": \"00000003-0000-0000-0000-000000000002\",     \"total\": \"10\"   } ]<\/code><\/pre>\n<p>\u0412\u044b\u0432\u043e\u0434 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 3.2.2.<\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u044d\u0442\u0430\u043f\u043e\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0432\u044b\u0432\u043e\u0434 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438. \u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0435 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u044b \u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u0442\u0435\u0441\u0442 \u0432 \u043c\u0435\u0442\u043e\u0434 <em>JsonAsserter.assertEquals(String, String)<\/em>, \u0432\u043d\u0435\u0441\u044f \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442, \u0435\u0441\u043b\u0438 \u043e\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043e\u0448\u0438\u0431\u043a\u0438. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432 \u0432\u044b\u0432\u043e\u0434\u0435 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043f\u043e\u043b\u044f street.<\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u044d\u0442\u0438\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043d\u0438\u0436\u0435.<\/p>\n<pre><code class=\"java\">public class CreateOrderTest {     private DbTestClient dbTestClient;     private RestTestClient restTestClient;      public void createOrderTest() {         \/\/Given         \/\/ (1)         \/\/...          \/\/When         \/\/ (2)         \/\/ ...         var response = restTestClient.send(request);         \/\/Then           \/\/ (3)         assertEquals(201, response.getStatusCode());          var order = dbTestClient.select(\"\"\"                 select * from order                 where id = '00000001-0000-0000-0000-000000000001'                 \"\"\");         System.out.println(\"Order:\\n\" + order);         \/\/ (4)         JsonAsserter.assertEquals(                 \"\"\"                         [                             {                               \"id\": \"00000001-0000-0000-0000-000000000001\",                               \"user_id\": \"00000004-0000-0000-0000-000000000001\",                               \"delivery_address_id\": \"00000005-0000-0000-0000-000000000001\"                             }                         ]                         \"\"\",                 order         );          var deliveryAddress = dbTestClient.select(\"\"\"                 select * from delivery_address                 where id = '00000005-0000-0000-0000-000000000001'                 \"\"\");         System.out.println(\"Delivery address:\\n\" + deliveryAddress);         \/\/ (5)         JsonAsserter.assertEquals(                 \"\"\"                         [                             {                               \"id\": \"00000005-0000-0000-0000-000000000001\",                               \"country\": \"Russia\",                               \"city\": \"Saint-Petersburg\",                               \"street\": \"Palace Square, 2\"                             }                         ]                         \"\"\",                 deliveryAddress         );          var items = dbTestClient.select(\"\"\"                 select * from order_item                 where order_id = '00000001-0000-0000-0000-000000000001'                 order by product_id                 \"\"\");         System.out.println(\"Items:\\n\" + items);         \/\/ (6)         JsonAsserter.assertEquals(                 \"\"\"                         [                           {                             \"id\": \"00000002-0000-0000-0000-000000000001\",                             \"order_id\": \"00000001-0000-0000-0000-000000000001\",                             \"product_id\": \"00000003-0000-0000-0000-000000000001\",                             \"total\": \"5\"                           },                           {                             \"id\": \"00000002-0000-0000-0000-000000000002\",                             \"order_id\": \"00000001-0000-0000-0000-000000000001\",                             \"product_id\": \"00000003-0000-0000-0000-000000000002\",                             \"total\": \"10\"                           }                         ]                         \"\"\",                 items         );     } }<\/code><\/pre>\n<p>\u041b\u0438\u0441\u0442\u0438\u043d\u0433 3.2.3.<\/p>\n<p>\u041a\u043e\u0434 \u043c\u0435\u0436\u0434\u0443 \u043c\u0435\u0442\u043a\u0430\u043c\u0438 <code>(1)<\/code> \u0438 <code>(3)<\/code> \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u043d \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0432 \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u043d\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435. \u0418\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c \u0432 \u0442\u0435\u0441\u0442\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e, \u0447\u0442\u043e \u0431\u044b\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u0432\u044b\u0437\u043e\u0432\u044b \u043c\u0435\u0442\u043e\u0434\u0430 <em>JsonAsserter.assertEquals(String, String)<\/em> \u0432 \u0441\u0442\u0440\u043e\u043a\u0430\u0445 \u043a\u043e\u0434\u0430 \u0441 \u043c\u0435\u0442\u043a\u0430\u043c\u0438 <code>(4)<\/code>, <code>(5)<\/code> \u0438 <code>(6)<\/code> <em>(Then)<\/em>. \u0418 \u0447\u0442\u043e \u0441\u0430\u043c\u043e\u0435 \u0432\u0430\u0436\u043d\u043e\u0435, \u044d\u0442\u043e\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0431\u044b\u043b \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d \u0438\u0437 \u0432\u044b\u0432\u043e\u0434\u0430 \u043a\u043e\u043d\u0441\u043e\u043b\u0438.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u044e\u0442\u0441\u044f, \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442\u0441\u044f, \u0432\u044b\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0442\u0441\u044f \u0432 \u0435\u0434\u0438\u043d\u043e\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0435, \u0442\u043e \u0447\u0430\u0441\u0442\u044c \u0442\u0435\u0441\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u043d\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u0430 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c. \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u0442\u0430 \u0447\u0430\u0441\u0442\u044c \u0442\u0435\u0441\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c <u>\u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0430<\/u> \u0432 \u0432\u044b\u0432\u043e\u0434\u0435 \u043a\u043e\u043d\u0441\u043e\u043b\u0438.<\/p>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0442\u0435\u0441\u0442\u043e\u0432 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u043e \u0438 \u0431\u0440\u043e\u043a\u0435\u0440\u043e\u0432 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \u043c\u043e\u043a\u043e\u0432\/\u0441\u0442\u0430\u0431\u043e\u0432 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u0445 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432. \u0422\u043e \u0435\u0441\u0442\u044c \u0434\u043b\u044f \u043b\u044e\u0431\u044b\u0445 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432, \u0435\u0441\u043b\u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u043c\u044b\u0435 \u0438\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0435\u0434\u0438\u043d\u043e\u043c\u0443 \u0444\u043e\u0440\u043c\u0430\u0442\u0443 (\u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 JSON).<\/p>\n<p>\u0412\u0430\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0437\u0430 \u0441\u0447\u0435\u0442 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0442\u0435\u0441\u0442\u0430, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0430\u044f \u0437\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0430, \u0442\u043e \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u0435\u0432\u0430\u0436\u043d\u044b\u043c, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u0430 \u0447\u0430\u0441\u0442\u044c \u0432\u0435\u043b\u0438\u043a\u0430. \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0440\u0443\u0434\u043e\u0437\u0430\u0442\u0440\u0430\u0442 \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u0432 \u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u041d\u0438\u0436\u0435 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u044d\u0442\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/47e\/183\/c92\/47e183c9266588ea16e36140168d2b28.jpg\" width=\"521\" height=\"361\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/47e\/183\/c92\/47e183c9266588ea16e36140168d2b28.jpg\" data-blurred=\"true\"\/><\/figure>\n<p>\u0420\u0438\u0441. 3.2.4.<\/p>\n<p>\u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u0430\u0436\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u0432\u044b\u0432\u043e\u0434 \u0438\u0437 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u043b\u0441\u044f \u0438 \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0441\u044f. \u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0442\u0435\u0441\u0442\u043e\u0432 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u0445\u043e\u0440\u043e\u0448\u0438\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432. \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0432\u044b\u0432\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0431\u0435\u0437\u0434\u0443\u043c\u043d\u043e \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u0435\u0441\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442 \u0434\u0435\u0444\u0435\u043a\u0442\u044b, \u0430 \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u044e\u0442 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u043e\u0432. \u0421\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u044d\u0442\u043e \u043d\u0435 \u0442\u043e, \u0447\u0442\u043e \u043e\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>\u0412\u044b\u0432\u043e\u0434 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438. \u041d\u043e \u0435\u0441\u043b\u0438 \u043e\u043d \u0445\u043e\u0442\u044f \u0431\u044b \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0435\u0440\u043d\u044b\u043c, \u0442\u043e \u043e\u043d \u0443\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u0435\u043d. \u0412\u0435\u0434\u044c \u0435\u0441\u043b\u0438 \u043e\u0448\u0438\u0431\u043a\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043e\u0434\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043f\u043e\u043b\u0435\u0439, \u0442\u043e \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0433\u043e\u0442\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0438 \u0432\u0435\u0440\u043d\u043e\u0439 \u0434\u0440\u0443\u0433\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043f\u043e\u043b\u0435\u0439 \u0443\u0436\u0435 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0430\u044e\u0442 \u0437\u0430\u0434\u0430\u0447\u0443 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u0430. \u0410 \u0435\u0441\u043b\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0435\u043d, \u0442\u043e \u043d\u0435\u0442 \u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0442\u0432\u0438\u0439 \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u0441\u0435 \u0432\u0440\u0443\u0447\u043d\u0443\u044e.<\/p>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u0440\u0438\u043d\u043e\u0441\u0438\u0442 \u043c\u0435\u043d\u044c\u0448\u0435 \u043f\u043e\u043b\u044c\u0437\u044b \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0435\u0433\u043e \u0441 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u043c \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0442\u0435\u0441\u0442\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435, \u043a\u043e\u0433\u0434\u0430 \u0442\u0435\u0441\u0442\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0434\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043a\u043e\u0434\u0430 (TDD). \u042d\u0442\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0437 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043d\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u043d\u0430 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u0430.<\/p>\n<p>\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u044b\u0432\u043e\u0434\u0430 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u043d\u0435 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435, \u0432 \u0447\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u043e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0435\u0434\u0438\u043d\u043e\u0433\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. \u041d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043e \u043f\u043e\u044d\u0442\u0430\u043f\u043d\u043e\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0442\u0435\u0441\u0442\u0430 \u0434\u043b\u044f REST-\u043c\u0435\u0442\u043e\u0434\u0430, \u043e\u0442\u043d\u043e\u0441\u044f\u0449\u0435\u0433\u043e\u0441\u044f \u043a \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0437\u0430\u043a\u0430\u0437\u0435.<\/p>\n<pre><code class=\"java\">public class GetOrderTest {     private DbTestClient dbTestClient;     private RestTestClient restTestClient;      public void getOrderTest() {         \/\/Given         \/\/ (1)         dbTestClient.insert(\"product\", \"\"\"                 [                     {                       \"id\": \"00000003-0000-0000-0000-000000000001\",                       \"name\": \"Brush\",                       \"price\": \"100\"                       \"total\": 1000                     },                     {                       \"id\": \"00000003-0000-0000-0000-000000000002\",                       \"name\": \"Canvas\",                       \"price\": \"1000\"                       \"total\": 500                     }                 ]                 \"\"\");         \/\/ (2)         dbTestClient.insert(\"user\", \"\"\"                 [                     {                       \"id\": \"00000004-0000-0000-0000-000000000001\",                       \"login\": \"user\",                       \"password\": \"qwerty\"                     }                 ]                 \"\"\");         \/\/ (3)         dbTestClient.insert(\"delivery_address\", \"\"\"                 [                     {                       \"id\": \"00000005-0000-0000-0000-000000000001\",                       \"country\": \"Russia\",                       \"city\": \"Saint-Petersburg\",                       \"street\": \"Palace Square, 2\"                     }                 ]                 \"\"\");         \/\/ (4)         dbTestClient.insert(\"order\", \"\"\"                 [                     {                       \"id\": \"00000001-0000-0000-0000-000000000001\",                       \"user_id\": \"00000004-0000-0000-0000-000000000001\",                       \"delivery_address_id\": \"00000005-0000-0000-0000-000000000001\"                     }                 ]                 \"\"\");         \/\/ (5)         dbTestClient.insert(\"order_item\", \"\"\"                 [                   {                     \"id\": \"00000002-0000-0000-0000-000000000001\",                     \"order_id\": \"00000001-0000-0000-0000-000000000001\",                     \"product_id\": \"00000003-0000-0000-0000-000000000001\",                     \"total\": \"5\"                   },                   {                     \"id\": \"00000002-0000-0000-0000-000000000002\",                     \"order_id\": \"00000001-0000-0000-0000-000000000001\",                     \"product_id\": \"00000003-0000-0000-0000-000000000002\",                     \"total\": \"10\"                   }                 ]                 \"\"\");          \/\/ ...     } }<\/code><\/pre>\n<p>\u041b\u0438\u0441\u0442\u0438\u043d\u0433 3.2.5.<\/p>\n<p>\u0412 \u0442\u0435\u0441\u0442\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u043c \u0440\u0430\u043d\u0435\u0435, \u043e\u0442\u043d\u043e\u0441\u044f\u0449\u0435\u043c\u0441\u044f \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u0437\u0430\u043a\u0430\u0437\u0430 (\u0441\u043c. \u041b\u0438\u0441\u0442\u0438\u043d\u0433 3.2.3), \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0437\u0430\u043a\u0430\u0437\u0430 \u0432 \u0441\u0442\u0440\u043e\u043a\u0430\u0445 \u043a\u043e\u0434\u0430 \u0441 \u043c\u0435\u0442\u043a\u0430\u043c\u0438 <code>(4)<\/code>, <code>(5)<\/code> \u0438 <code>(6)<\/code> <em>(Then)<\/em>. \u042d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0442 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u0430, \u043e\u0442\u043d\u043e\u0441\u044f\u0449\u0435\u0433\u043e\u0441\u044f \u043a \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044e \u0437\u0430\u043a\u0430\u0437\u0430. \u0422\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0440\u043e Json-\u044b \u043c\u0435\u0436\u0434\u0443 \u043c\u0435\u0442\u043a\u0430\u043c\u0438 <code>(1)<\/code> \u0438 <code>(2)<\/code> <em>(Given)<\/em> \u0438\u0437 \u041b\u0438\u0441\u0442\u0438\u043d\u0433\u0430 3.2.1. \u0418\u0445 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0430, \u043e\u0442\u043d\u043e\u0441\u044f\u0449\u0435\u0433\u043e\u0441\u044f \u043a \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044e \u0437\u0430\u043a\u0430\u0437\u0430.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c Json-\u044b \u0438\u0437 \u041b\u0438\u0441\u0442\u0438\u043d\u0433\u0430 3.2.5, \u0438\u0445 \u0432\u0441\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0442\u0435\u0441\u0442\u0430 (\u0441\u043c. \u041b\u0438\u0441\u0442\u0438\u043d\u0433 3.2.1 \u0438 \u041b\u0438\u0441\u0442\u0438\u043d\u0433 3.2.3). \u0421\u0442\u043e\u0438\u0442 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0435\u0434\u0438\u043d\u043e\u043c\u0443 \u0444\u043e\u0440\u043c\u0430\u0442\u0443 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p><em><u>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/u><\/em>. \u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0435 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432. \u0414\u043b\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438.<\/p>\n<p>\u041d\u0438\u0436\u0435 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u0442\u0430\u043f \u043f\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0442\u0435\u0441\u0442\u0430:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/2fc\/2d9\/ed9\/2fc2d9ed992adbb0b00f10ce99a67ffe.jpg\" width=\"521\" height=\"361\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2fc\/2d9\/ed9\/2fc2d9ed992adbb0b00f10ce99a67ffe.jpg\" data-blurred=\"true\"\/><\/figure>\n<p>\u0420\u0438\u0441. 3.2.6.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u044d\u0442\u0430\u043f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0442\u0435\u0441\u0442\u0430.<\/p>\n<pre><code class=\"java\">public class GetOrderTest {     private DbTestClient dbTestClient;     private RestTestClient restTestClient;      public void getOrderTest() {         \/\/Given          \/\/...          \/\/When         var request = new RestRequest();         request.setUrl(\"http:\/\/user:qwerty@localhost:8080\/orders\/00000001-0000-0000-0000-000000000001\");         request.setHttpMethod(\"GET\");          var response = restTestClient.send(request);         \/\/Then         assertEquals(200, response.getStatusCode());         \/\/ (6)         System.out.println(\"Response body:\\n\" + response.getBody());     } }<\/code><\/pre>\n<p>\u041b\u0438\u0441\u0442\u0438\u043d\u0433 3.2.7.<\/p>\n<p>\u0414\u043b\u044f \u0442\u0435\u0441\u0442\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0431\u043b\u043e\u043a \u043a\u043e\u0434\u0430 <em>(When)<\/em>, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0422\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u043f\u0435\u0440\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0431\u043b\u043e\u043a\u0430 \u043a\u043e\u0434\u0430, \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 REST-\u043e\u0442\u0432\u0435\u0442\u0430. \u041d\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0435 (expected) \u0442\u0435\u043b\u043e \u043e\u0442\u0432\u0435\u0442\u0430, \u0432 \u0441\u0442\u0440\u043e\u0447\u043a\u0435 \u043a\u043e\u0434\u0430 \u043f\u043e\u0441\u043b\u0435 \u043c\u0435\u0442\u043a\u0438 <code>(6)<\/code> \u0443\u043a\u0430\u0437\u0430\u043d \u0432\u044b\u0432\u043e\u0434 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c. \u0418 \u043f\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0438 \u0441 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u043c \u0442\u0435\u0441\u0442\u043e\u043c \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0442\u0435\u0441\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u044b\u0432\u043e\u0434 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c.<\/p>\n<p>\u041d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0432\u044b\u0432\u043e\u0434 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0442\u0435\u0441\u0442\u0430.<\/p>\n<pre><code>Response body: {   \"id\": \"00000001-0000-0000-0000-000000000001\",   \"items\": [     {       \"id\": \"00000002-0000-0000-0000-000000000001\",       \"product_id\": \"00000003-0000-0000-0000-000000000001\",       \"total\": \"5\"     },     {       \"id\": \"00000002-0000-0000-0000-000000000002\",       \"product_id\": \"00000003-0000-0000-0000-000000000002\",       \"total\": \"10\"     }   ],   \"delivery_address\": {     \"id\": \"00000005-0000-0000-0000-000000000001\",     \"country\": \"Russia\",     \"city\": \"INVALID VALUE\",     \"street\": \"Palace Square, 2\"   } }<\/code><\/pre>\n<p>\u0412\u044b\u0432\u043e\u0434 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 3.2.8.<\/p>\n<p>\u0412\u044b\u0432\u043e\u0434 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f, \u0430 \u0437\u0430\u0442\u0435\u043c \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u0442\u0435\u0441\u0442. \u041f\u043e\u0441\u043b\u0435 \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0432 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u0432\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u043f\u0440\u0430\u0432\u043a\u0438, \u0435\u0441\u043b\u0438 \u0432\u044b\u0432\u043e\u0434 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043b \u043e\u0448\u0438\u0431\u043a\u0438. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0435\u0441\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0430 \u0432 \u043f\u043e\u043b\u0435 city.<\/p>\n<p>\u041d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0442\u0435\u0441\u0442 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439.<\/p>\n<pre><code class=\"java\">public class GetOrderTest {     private DbTestClient dbTestClient;     private RestTestClient restTestClient;      public void getOrderTest() {         \/\/Given          \/\/...          \/\/When          \/\/...          \/\/Then         assertEquals(200, response.getStatusCode());         \/\/ (6)         System.out.println(\"Response body:\\n\" + response.getBody());         \/\/ (7)         JsonAsserter.assertEquals(                 \"\"\"                         {                           \"id\": \"00000001-0000-0000-0000-000000000001\",                           \"items\": [                             {                               \"id\": \"00000002-0000-0000-0000-000000000001\",                               \"product_id\": \"00000003-0000-0000-0000-000000000001\",                               \"total\": \"5\"                             },                             {                               \"id\": \"00000002-0000-0000-0000-000000000002\",                               \"product_id\": \"00000003-0000-0000-0000-000000000002\",                               \"total\": \"10\"                             }                           ],                           \"delivery_address\": {                             \"id\": \"00000005-0000-0000-0000-000000000001\",                             \"country\": \"Russia\",                             \"city\": \"Saint-Petersburg\",                             \"street\": \"Palace Square, 2\"                           }                         }                         \"\"\",                 response.getBody()         );     } }<\/code><\/pre>\n<p>\u041b\u0438\u0441\u0442\u0438\u043d\u0433 3.2.9.<\/p>\n<p>\u041d\u0438\u0436\u0435 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u0442\u0430\u043f \u043f\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0442\u0435\u0441\u0442\u0430:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/085\/dc4\/16d\/085dc416d3bb46e1df71f201c1ed7809.jpg\" width=\"521\" height=\"361\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/085\/dc4\/16d\/085dc416d3bb46e1df71f201c1ed7809.jpg\" data-blurred=\"true\"\/><\/figure>\n<p>\u0420\u0438\u0441. 3.2.10.<\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430 \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0431\u044b\u043b\u0438 \u043b\u0438\u0431\u043e \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0442\u0435\u0441\u0442\u0430, \u043b\u0438\u0431\u043e \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0438\u0437 \u0432\u044b\u0432\u043e\u0434\u0430 \u043a\u043e\u043d\u0441\u043e\u043b\u0438. \u0422\u0430\u043a\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043d\u0435\u043b\u044c\u0437\u044f \u0431\u044b\u043b\u043e \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u0438\u0437 \u0440\u0430\u0437\u0434\u0435\u043b\u0430 2. \u0438\u0437-\u0437\u0430 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430 \u043a\u043e\u0434\u0430.<\/p>\n<p>\u041d\u0438\u0436\u0435 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0432\u0441\u0435\u0433\u043e \u0442\u0435\u0441\u0442\u0430:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/3d1\/e6f\/375\/3d1e6f375d8d63acc34ae704c7343f26.jpg\" width=\"791\" height=\"361\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3d1\/e6f\/375\/3d1e6f375d8d63acc34ae704c7343f26.jpg\" data-blurred=\"true\"\/><\/figure>\n<p>\u0420\u0438\u0441. 3.2.11.<\/p>\n<h2>4. \u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u043e<\/h2>\n<p>\u041f\u0440\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u043e. \u041c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u044f \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u043e\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c. \u0412 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043e\u0431\u044b\u0447\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0442 \u043d\u0435 \u043d\u0430 \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u043e, \u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0442, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u0438\u043b\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0442, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0435 \u043f\u0443\u0441\u0442\u043e\u0435 (\u043d\u0435 null).<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430, \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0449\u0435\u0433\u043e \u0434\u0432\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043e\u0434\u043d\u043e\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0435, \u0432\u0430\u0436\u043d\u043e \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043d\u0435\u0441\u0442\u0440\u043e\u0433\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f. \u0427\u0442\u043e\u0431\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, c \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u043c (actual) \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043b\u0438\u0441\u044c \u043d\u0430 \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u043f\u043e\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0435\u0441\u0442\u044c \u0432 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u043c (expected) \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043d\u0430 \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u043e, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u0434\u0440\u0443\u0433\u0438\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u043c.<\/p>\n<p>\u041d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b \u043c\u0435\u0442\u043e\u0434\u0430 \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u0432\u044b\u0431\u043e\u0440\u044b \u0441\u0442\u0440\u043e\u0433\u043e \u0438 \u043d\u0435\u0441\u0442\u0440\u043e\u0433\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"java\">public class JsonAsserter {     \/\/ expected - \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0432 JSON \u0444\u043e\u0440\u043c\u0430\u0442\u0435, \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430.     \/\/ actual - \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 JSON \u0444\u043e\u0440\u043c\u0430\u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u0441 expected.     \/\/ isStrict - \u0444\u043b\u0430\u0433 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0439 \u0440\u0435\u0436\u0438\u043c \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f     public static void assertEquals(String expected, String actual, boolean isStrict) {         \/\/ \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 expected \u0438 actual \u0432 JSON \u0444\u043e\u0440\u043c\u0430\u0442\u0435     } }<\/code><\/pre>\n<p>\u0414\u043b\u044f java \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0433\u043e\u0442\u043e\u0432\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 JSON \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u0441\u043e \u0441\u0442\u0440\u043e\u0433\u0438\u043c \u0438 \u043d\u0435\u0441\u0442\u0440\u043e\u0433\u0438\u043c \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435\u043c. \u0421\u043c. JSONassert.<\/p>\n<h2>5. \u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041e\u0431\u0449\u0438\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0432\u044b\u0448\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u043e \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0432 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0447\u0430\u0441\u0442\u0438 \u0442\u0435\u0441\u0442\u0430, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0435\u0439 \u0437\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 <em>(Then)<\/em>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0432\u044b\u0432\u043e\u0434 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c.<\/p>\n<p>\u041d\u043e \u0442\u0430\u043a\u0436\u0435 \u0441\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u0434\u0432\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043f\u043e\u0434\u0445\u043e\u0434 \u0432 \u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0441 TDD, \u043a\u043e\u0433\u0434\u0430 \u0442\u0435\u0441\u0442\u044b \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0434\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043a\u043e\u0434\u043e\u0432\u043e\u0439 \u0431\u0430\u0437\u044b, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0433\u043b\u0430 \u0431\u044b \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0434\u043b\u044f \u0447\u0430\u0441\u0442\u0438 <em>(Then)<\/em>. \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u043f\u043e\u0434\u0445\u043e\u0434 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u0442 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0434\u0438\u0441\u0446\u0438\u043f\u043b\u0438\u043d\u044b. \u0423\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0432\u044b\u0432\u043e\u0434 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0431\u043b\u043e\u043a\u0430 <em>(Then)<\/em>.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 TDD, \u0430 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0433\u043e\u0442\u043e\u0432\u044b \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u044c\u0441\u044f \u043a \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430, \u0442\u043e, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u044b \u0438\u0437 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0441\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0432\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043b\u0438\u0431\u043e \u043d\u0430\u0439\u0442\u0438, \u043b\u0438\u0431\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442 \u0441 \u043a\u0430\u0436\u0434\u044b\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0435\u043c \u0438\u043b\u0438 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043e\u0434\u0438\u043d \u0435\u0434\u0438\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/759522\/\"> https:\/\/habr.com\/ru\/articles\/759522\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0421\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043f\u0440\u043e\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u044b\u0445 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432. \u041a\u043e\u0434\u043e\u0432\u0430\u044f \u0431\u0430\u0437\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043e\u0442\u043d\u043e\u0441\u044f\u0449\u0430\u044f\u0441\u044f \u043a \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u043c \u0442\u0435\u0441\u0442\u0430\u043c, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0439, \u043a\u0430\u043a \u0438 \u0437\u0430\u0442\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043d\u0430 \u0435\u0435 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435.<\/p>\n<p>\u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u043e\u043f\u0438\u0441\u0430\u043d \u043f\u043e\u0434\u0445\u043e\u0434, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0441 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432. \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f, \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0434\u0438\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0432\u044b\u0432\u043e\u0434 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c. \u0415\u0441\u043b\u0438 \u0432\u0430\u0441 \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b\u043e, \u043a\u0430\u043a \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c, \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u044e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e.<\/p>\n<p>\u0412\u0441\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0441 \u043a\u043e\u0434\u043e\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u043d\u0430 Java, \u043d\u043e \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432 \u0438 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a. \u042d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u044b\u043b\u0430 \u043f\u043e\u043d\u044f\u0442\u043d\u0430 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f\u043c \u0432\u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0441\u0442\u0435\u043a\u0430 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0439.<\/p>\n<p>\u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0441\u0442\u043e\u0438\u0442 \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c Java \u043d\u0435 \u043a\u0430\u043a \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u044f\u0437\u044b\u043a \u0441 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c\u0438 \u0432 \u043d\u0435\u043c \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u0430 \u043a\u0430\u043a \u043f\u0441\u0435\u0432\u0434\u043e-\u044f\u0437\u044b\u043a \u0441 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u043e\u043c, \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u043d\u044b\u043c \u043a Java. \u042d\u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 Java, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0438\u0437 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043c\u043e\u0433\u043b\u0438 \u0431\u044b\u0442\u044c \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u043e \u043f\u0440\u043e\u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0435\u0439, \u043d\u0435\u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0445 \u0441 Java.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0434\u0430, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u0449\u0435\u043f\u0440\u0438\u0437\u043d\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438 \u043f\u043e \u043f\u0440\u043e\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043c\u043e\u0433\u043b\u0438 \u0431\u044b\u0442\u044c \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u043e \u043f\u0440\u043e\u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u043f\u043e \u043c\u043d\u0435\u043d\u0438\u044e \u0430\u0432\u0442\u043e\u0440\u0430 \u043d\u0435 \u0432\u043b\u0438\u044f\u043b\u0438 \u043d\u0430 \u0441\u0443\u0442\u044c \u0438\u0437\u043b\u0430\u0433\u0430\u0435\u043c\u043e\u0433\u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430.<\/p>\n<h2>1. \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438<\/h2>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u0441\u0443\u0442\u0438 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u043c\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430, \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u043c\u043e\u0433\u0443\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u0435\u0441\u0442\u044b. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u0430\u043b\u0435\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u0430\u044f \u043e\u0431\u043b\u0430\u0441\u0442\u044c.<\/p>\n<p>\u041f\u0443\u0441\u0442\u044c \u0435\u0441\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u043c\u0430\u0433\u0430\u0437\u0438\u043d, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c \u0437\u0430\u043a\u0430\u0437\u044b \u0442\u043e\u0432\u0430\u0440\u043e\u0432. \u0418 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0430 \u0435\u0441\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<ul>\n<li>\n<p>user &#8212; \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439<\/p>\n<ul>\n<li>\n<p>id: UUID<\/p>\n<\/li>\n<li>\n<p>login: String<\/p>\n<\/li>\n<li>\n<p>password: String<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>product &#8212; \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043f\u0440\u043e\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0445 \u0442\u043e\u0432\u0430\u0440\u043e\u0432<\/p>\n<ul>\n<li>\n<p>id: UUID<\/p>\n<\/li>\n<li>\n<p>name: String<\/p>\n<\/li>\n<li>\n<p>price: Integer<\/p>\n<\/li>\n<li>\n<p>total: Integer<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>delivery_address &#8212; \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0430\u0434\u0440\u0435\u0441\u0430 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u0442\u043e\u0432\u0430\u0440\u043e\u0432<\/p>\n<ul>\n<li>\n<p>id: UUID<\/p>\n<\/li>\n<li>\n<p>country: String<\/p>\n<\/li>\n<li>\n<p>city: String<\/p>\n<\/li>\n<li>\n<p>street: String<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>order &#8212; \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0437\u0430\u043a\u0430\u0437\u043e\u0432<\/p>\n<ul>\n<li>\n<p>id: UUID<\/p>\n<\/li>\n<li>\n<p>user_id: UUID<\/p>\n<\/li>\n<li>\n<p>delivery_address_id: UUID<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>order_item &#8212; \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043f\u043e\u0437\u0438\u0446\u0438\u0439 \u0437\u0430\u043a\u0430\u0437\u0430<\/p>\n<ul>\n<li>\n<p>id: UUID<\/p>\n<\/li>\n<li>\n<p>order_id: UUID<\/p>\n<\/li>\n<li>\n<p>product_id: UUID<\/p>\n<\/li>\n<li>\n<p>total: Integer<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u0418 \u043f\u0443\u0441\u0442\u044c \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0430 \u0441\u0440\u0435\u0434\u0438 \u043f\u0440\u043e\u0447\u0438\u0445 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0434\u0432\u0430 REST-\u043c\u0435\u0442\u043e\u0434\u0430:<\/p>\n<ol>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0437\u0430\u043a\u0430\u0437<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0437\u0430\u043a\u0430\u0437\u0435 \u043f\u043e \u0435\u0433\u043e id<\/p>\n<\/li>\n<\/ol>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u044b \u043f\u043e\u0434\u0445\u043e\u0434\u044b \u043f\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0442\u0435\u0441\u0442\u043e\u0432 \u0434\u043b\u044f \u044d\u0442\u0438\u0445 \u0434\u0432\u0443\u0445 REST-\u043c\u0435\u0442\u043e\u0434\u043e\u0432.<\/p>\n<h2>2. \u0422\u0435\u0441\u0442\u044b \u0441 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445<\/h2>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b.<\/p>\n<p>\u041d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0441 \u043a\u043e\u0434\u043e\u043c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432. \u0420\u0430\u0437\u0434\u0435\u043b 2.1. \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c, \u043f\u0435\u0440\u0435\u0439\u0434\u044f \u0441\u0440\u0430\u0437\u0443 \u043a \u0440\u0430\u0437\u0434\u0435\u043b\u0443 2.2., \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e \u043c\u043d\u0435\u043d\u0438\u044e \u0430\u0432\u0442\u043e\u0440\u0430 \u0441\u0442\u0430\u0442\u044c\u0438 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u044b.<\/p>\n<h2>2.1. \u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432<\/h2>\n<pre><code class=\"java\">public class DbTestClient {     public void execute(String sql) {         \/\/\u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u043c\u0443\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e (insert, update \u0438\u043b\u0438 delete) \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 \u0421\u0423\u0411\u0414     }      public List&lt;Map&lt;String, Object>> select(String sql) {         \/\/\u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 select \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 \u0421\u0423\u0411\u0414         \/\/\u0437\u0430\u0442\u0435\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0441\u0442\u0440\u043e\u043a\u0438     } }<\/code><\/pre>\n<p>\u041b\u0438\u0441\u0442\u0438\u043d\u0433 2.1.1.<\/p>\n<p><strong>DbTestClient<\/strong> &#8212; \u043a\u043b\u0430\u0441\u0441, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043c\u0443\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432 \u0421\u0423\u0411\u0414 \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434 <em>execute<\/em>. \u0422\u0430\u043a\u0436\u0435 \u0434\u0430\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0411\u0414 \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 select \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434 <em>select<\/em>.<\/p>\n<pre><code class=\"java\">public class RestTestClient {     public RestResponse send(RestRequest request) {         \/\/\u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 REST \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u0430     } }<\/code><\/pre>\n<p>\u041b\u0438\u0441\u0442\u0438\u043d\u0433 2.1.2.<\/p>\n<pre><code class=\"java\">public class RestRequest {     private String url;     private String httpMethod;     private Map&lt;String, String> headers;     private String body; }<\/code><\/pre>\n<p>\u041b\u0438\u0441\u0442\u0438\u043d\u0433 2.1.3.<\/p>\n<pre><code class=\"java\">public class RestResponse {     private Map&lt;String, String> headers;     private String body;     private int statusCode; }<\/code><\/pre>\n<p>\u041b\u0438\u0441\u0442\u0438\u043d\u0433 2.1.4.<\/p>\n<p><strong>RestTestClient<\/strong> &#8212; \u043a\u043b\u0430\u0441\u0441, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c REST-\u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 REST-\u043e\u0442\u0432\u0435\u0442\u044b. REST-\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u043a\u043b\u0430\u0441\u0441\u043e\u043c <em>RestRequest<\/em>. REST-\u043e\u0442\u0432\u0435\u0442\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u043a\u043b\u0430\u0441\u0441\u043e\u043c <em>RestResponse<\/em>.<\/p>\n<pre><code class=\"java\">public class JsonUtils {     public static String getString(String json, String jsonPath) {         \/\/\u041f\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c\u0443 jsonPath \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435     }      public static int getInt(String json, String jsonPath) {         \/\/\u041f\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c\u0443 jsonPath \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435     } }<\/code><\/pre>\n<p>\u041b\u0438\u0441\u0442\u0438\u043d\u0433 2.1.5.<\/p>\n<p><strong>JsonUtils<\/strong> &#8212; \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0437 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 JSON \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u043f\u043e JSONPath.<\/p>\n<h2>2.2. \u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0442\u0435\u0441\u0442\u043e\u0432<\/h2>\n<p>\u041d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0442\u0435\u0441\u0442 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0437\u0430\u043a\u0430\u0437\u0430.<\/p>\n<pre><code class=\"java\">public class CreateOrderTest {     private DbTestClient dbTestClient;     private RestTestClient restTestClient;      public void createOrderTest() {         \/\/Given         \/\/ (1)         dbTestClient.execute(\"\"\"                 insert into product (id, name, price, total) values (                     '00000003-0000-0000-0000-000000000001',                     'Brush',                     100,                     1000                 ), (                     '00000003-0000-0000-0000-000000000002',                     'Canvas',                     1000,                     500                 )                 \"\"\");          dbTestClient.execute(\"\"\"                 insert into user (id, login, password) values (                     '00000004-0000-0000-0000-000000000001',                     'user',                     'qwerty'                 )                 \"\"\");         \/\/When         \/\/ (2)         var request = new RestRequest();         request.setUrl(\"http:\/\/user:qwerty@localhost:8080\/orders\");         request.setHttpMethod(\"POST\");         request.setBody(\"\"\"                 {                   \"id\": \"00000001-0000-0000-0000-000000000001\",                   \"items\": [                     {                       \"id\": \"00000002-0000-0000-0000-000000000001\",                       \"product_id\": \"00000003-0000-0000-0000-000000000001\",                       \"total\": \"5\"                     },                     {                       \"id\": \"00000002-0000-0000-0000-000000000002\",                       \"product_id\": \"00000003-0000-0000-0000-000000000002\",                       \"total\": \"10\"                     }                   ],                   \"delivery_address\": {                     \"id\": \"00000005-0000-0000-0000-000000000001\",                     \"country\": \"Russia\",                     \"city\": \"Saint-Petersburg\",                     \"street\": \"Palace Square, 2\"                   }                 }                 \"\"\");          var response = restTestClient.send(request);         \/\/Then         \/\/ (3)         assertEquals(201, response.getStatusCode());          var orders = dbTestClient.select(\"\"\"                 select * from order                 where id = '00000001-0000-0000-0000-000000000001'                 \"\"\");          assertEquals(1, orders.size());         var order = orders.get(0);          assertEquals(\"00000001-0000-0000-0000-000000000001\", order.get(\"id\"));         assertEquals(\"00000004-0000-0000-0000-000000000001\", order.get(\"user_id\"));         assertEquals(\"00000005-0000-0000-0000-000000000001\", order.get(\"delivery_address_id\"));          var deliveryAddresses = dbTestClient.select(\"\"\"                 select * from delivery_address                 where id = '00000005-0000-0000-0000-000000000001'                 \"\"\");          assertEquals(1, deliveryAddresses.size());         var deliveryAddress = deliveryAddresses.get(0);          assertEquals(\"00000005-0000-0000-0000-000000000001\", deliveryAddress.get(\"id\"));         assertEquals(\"Russia\", deliveryAddress.get(\"country\"));         assertEquals(\"Saint-Petersburg\", deliveryAddress.get(\"city\"));         assertEquals(\"Palace Square, 2\", deliveryAddress.get(\"street\"));          var items = dbTestClient.select(\"\"\"                 select * from order_item                 where order_id = '00000001-0000-0000-0000-000000000001'                 order by product_id                 \"\"\");          assertEquals(2, items.size());          var brushItem = items.get(0);         assertEquals(\"00000002-0000-0000-0000-000000000001\", brushItem.get(\"id\"));         assertEquals(\"00000001-0000-0000-0000-000000000001\", brushItem.get(\"order_id\"));         assertEquals(\"00000003-0000-0000-0000-000000000001\", brushItem.get(\"product_id\"));         assertEquals(5, brushItem.get(\"total\"));          var canvasItem = items.get(1);         assertEquals(\"00000002-0000-0000-0000-000000000002\", canvasItem.get(\"id\"));         assertEquals(\"00000001-0000-0000-0000-000000000001\", canvasItem.get(\"order_id\"));         assertEquals(\"00000003-0000-0000-0000-000000000002\", canvasItem.get(\"product_id\"));         assertEquals(10, canvasItem.get(\"total\"));         \/\/ (4)     } }<\/code><\/pre>\n<p>\u041b\u0438\u0441\u0442\u0438\u043d\u0433 2.2.1.<\/p>\n<p>\u0411\u043b\u043e\u043a \u043a\u043e\u0434\u0430 \u0438\u0437 <em>\u043b\u0438\u0441\u0442\u0438\u043d\u0433\u0430 2.2.1.<\/em> \u043c\u0435\u0436\u0434\u0443 \u043c\u0435\u0442\u043a\u0430\u043c\u0438 <code>(1)<\/code> \u0438 <code>(2)<\/code> \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 (\u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445) \u043a \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u043c\u0443 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044e <em>(Given)<\/em>. \u0417\u0430\u0442\u0435\u043c \u0431\u043b\u043e\u043a \u043a\u043e\u0434\u0430 \u043c\u0435\u0436\u0434\u0443 \u043c\u0435\u0442\u043a\u0430\u043c\u0438 <code>(2)<\/code> \u0438 <code>(3)<\/code> \u043f\u043e\u0434\u0433\u043e\u0442\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 REST-\u0437\u0430\u043f\u0440\u043e\u0441 <em>(When)<\/em>. \u0412 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u0432 \u0431\u043b\u043e\u043a\u0435 \u043a\u043e\u0434\u0430 \u043c\u0435\u0436\u0434\u0443 \u043c\u0435\u0442\u043a\u0430\u043c\u0438 <code>(3)<\/code> \u0438 <code>(4)<\/code> \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e REST-\u043e\u0442\u0432\u0435\u0442\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u044b (\u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445) \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 <em>(Then)<\/em>.<\/p>\n<p>\u041d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0442\u0435\u0441\u0442 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0437\u0430\u043a\u0430\u0437\u0430 \u043f\u043e id.<\/p>\n<pre><code class=\"java\">public class GetOrderTest {     private DbTestClient dbTestClient;     private RestTestClient restTestClient;      public void getOrderTest() {         \/\/Given         \/\/ (1)         dbTestClient.execute(\"\"\"                 insert into product (id, name, price, total) values (                     '00000003-0000-0000-0000-000000000001',                     'Brush',                     100,                     1000                 ), (                     '00000003-0000-0000-0000-000000000002',                     'Canvas',                     1000,                     500                 )                 \"\"\");          dbTestClient.execute(\"\"\"                 insert into user (id, login, password) values (                     '00000004-0000-0000-0000-000000000001',                     'user',                     'qwerty'                 )                 \"\"\");<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-354252","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/354252","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=354252"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/354252\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=354252"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=354252"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=354252"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}