{"id":15166,"date":"2014-08-04T16:37:17","date_gmt":"2014-08-04T11:07:17","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=15166"},"modified":"2016-12-19T14:54:46","modified_gmt":"2016-12-19T09:24:46","slug":"grails-unit-test-filters-with-the-injected-service","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/grails-unit-test-filters-with-the-injected-service\/","title":{"rendered":"Grails Unit Test Filters with the injected Service"},"content":{"rendered":"<p>Recently I was writing unit tests for a filter in my project, which makes use of a service. <\/p>\n<p>Normally mocking using &#8216;metaclass&#8217; and &#8216;demand&#8217; doesn&#8217;t work for services in filter, because filters don&#8217;t let mock the service methods like we do in other classes or controller.<\/p>\n<p>Suppose we have a filter like:<\/p>\n<p>[java]<br \/>\nclass SomeFilters {<\/p>\n<p>    SomeService someService<\/p>\n<p>    def filters = {<br \/>\n        all(controller: &#8216;*&#8217;, action: &#8216;*&#8217;) {<br \/>\n            before = {<br \/>\n                if (params.checkSomeValue) {<br \/>\n                    someService.serviceMethod(params.checkSomeValue)<br \/>\n                    redirect(controller: &#8216;some&#8217;, action: &#8216;index&#8217;)<br \/>\n                }<br \/>\n                return true<br \/>\n            }<br \/>\n        }<br \/>\n    }<br \/>\n}<br \/>\n[\/java]<\/p>\n<p>and a Controller and the service like:<br \/>\n[java]<br \/>\nclass SomeController {<\/p>\n<p>    def index() {<br \/>\n        render &quot;this is index&quot;<br \/>\n    }<br \/>\n}<br \/>\n[\/java]<\/p>\n<p>[java]<br \/>\nimport grails.transaction.Transactional<\/p>\n<p>@Transactional<br \/>\nclass SomeService {<\/p>\n<p>    def serviceMethod(String check) {<br \/>\n        println &quot;this is the Service Method &quot;+check<br \/>\n    }<br \/>\n}<br \/>\n[\/java]<\/p>\n<p>To test the above mentioned filter using Grails spock we need to first mock the service. We can mock the service like:<br \/>\n[java]<br \/>\nclass MockedSomeService extends SomeService {<br \/>\n    @Override<br \/>\n    def serviceMethod(String check) {<br \/>\n        println &quot;this is the Service Method &quot; + check<br \/>\n    }<br \/>\n}<br \/>\n[\/java]<\/p>\n<p>all we need to do is to create a class which will extend the service class.<br \/>\nNow the question arises, how&#8217;ll we inject this mocked service class for our test cases.<br \/>\nHere&#8217;s answer to this question.<br \/>\n[java]<br \/>\ndefineBeans {<br \/>\n            someService(MockedSomeService)<br \/>\n        }<br \/>\n[\/java]<\/p>\n<p>this &#8216;defineBeans&#8217; closure helps us to inject the service with the new definition specified by the mocked class. Here, our service &#8216;someService&#8217; will use &#8216;MockedSomeService&#8217; as its definition, i.e. overriding the original definition &#8216;SomeService&#8217;.<\/p>\n<p>What&#8217;s next? This is it, now we can write rest of the test case as we do for normal filters.<br \/>\n[java]<br \/>\n@Mock([SomeFilters, SomeService])<br \/>\n@TestFor(SomeController)<br \/>\nclass SomeFiltersSpec extends Specification {<\/p>\n<p>    void &quot;test the filter&quot;() {<br \/>\n        setup:<br \/>\n        defineBeans {<br \/>\n            someService(MockedSomeService)<br \/>\n        }<br \/>\n        \/\/mock other methods and variables here<\/p>\n<p>        when:<br \/>\n        params.checkSomeValue = &#8216;checkSomeValue&#8217;<br \/>\n        withFilters(controller: &quot;*&quot;, action: &quot;*&quot;) {<br \/>\n            controller.index()<br \/>\n        }<\/p>\n<p>        then:<br \/>\n        assert response.status == 302<br \/>\n        assert response.redirectedUrl == &quot;\/some\/index&quot;<br \/>\n    }<br \/>\n}<\/p>\n<p>class MockedSomeService extends SomeService {<br \/>\n    @Override<br \/>\n    def serviceMethod(String check) {<br \/>\n        println &quot;this is the Service Method &quot; + check<br \/>\n    }<br \/>\n}<br \/>\n[\/java]<\/p>\n<p>Dont forget to add the important annotations, i.e.,<br \/>\n[java]<br \/>\n@Mock([SomeFilters, SomeService])<br \/>\n@TestFor(SomeController)<br \/>\n[\/java]<\/p>\n<p>I hope you wont find it too difficult to test the filters with services.<\/p>\n<p>You can also find the demo here.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently I was writing unit tests for a filter in my project, which makes use of a service. Normally mocking using &#8216;metaclass&#8217; and &#8216;demand&#8217; doesn&#8217;t work for services in filter, because filters don&#8217;t let mock the service methods like we do in other classes or controller. Suppose we have a filter like: [java] class SomeFilters [&hellip;]<\/p>\n","protected":false},"author":115,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":6,"footnotes":""},"categories":[7],"tags":[1497],"class_list":["post-15166","post","type-post","status-publish","format-standard","hentry","category-grails","tag-injected-service"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"Recently I was writing unit tests for a filter in my project, which makes use of a service. Normally mocking using &#039;metaclass&#039; and &#039;demand&#039; doesn&#039;t work for services in filter, because filters don&#039;t let mock the service methods like we do in other classes or controller. Suppose we have a filter like: [java] class SomeFilters\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Neha Gupta\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/www.tothenew.com\/blog\/grails-unit-test-filters-with-the-injected-service\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"TO THE NEW BLOG\" \/>\n\t\t<meta property=\"og:type\" content=\"blog\" \/>\n\t\t<meta property=\"og:title\" content=\"Grails Unit Test Filters with the injected Service | TO THE NEW Blog\" \/>\n\t\t<meta property=\"og:description\" content=\"Recently I was writing unit tests for a filter in my project, which makes use of a service. Normally mocking using &#039;metaclass&#039; and &#039;demand&#039; doesn&#039;t work for services in filter, because filters don&#039;t let mock the service methods like we do in other classes or controller. Suppose we have a filter like: [java] class SomeFilters\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/www.tothenew.com\/blog\/grails-unit-test-filters-with-the-injected-service\/\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:site\" content=\"@tothenew\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Grails Unit Test Filters with the injected Service | TO THE NEW Blog\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Recently I was writing unit tests for a filter in my project, which makes use of a service. Normally mocking using &#039;metaclass&#039; and &#039;demand&#039; doesn&#039;t work for services in filter, because filters don&#039;t let mock the service methods like we do in other classes or controller. Suppose we have a filter like: [java] class SomeFilters\" \/>\n\t\t<meta name=\"twitter:image\" content=\"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/grails-unit-test-filters-with-the-injected-service\\\/#article\",\"name\":\"Grails Unit Test Filters with the injected Service | TO THE NEW Blog\",\"headline\":\"Grails Unit Test Filters with the injected Service\",\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/neha\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"},\"datePublished\":\"2014-08-04T16:37:17+05:30\",\"dateModified\":\"2016-12-19T14:54:46+05:30\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/grails-unit-test-filters-with-the-injected-service\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/grails-unit-test-filters-with-the-injected-service\\\/#webpage\"},\"articleSection\":\"Grails, Injected Service\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/grails-unit-test-filters-with-the-injected-service\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/grails\\\/#listItem\",\"name\":\"Grails\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/grails\\\/#listItem\",\"position\":2,\"name\":\"Grails\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/grails\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/grails-unit-test-filters-with-the-injected-service\\\/#listItem\",\"name\":\"Grails Unit Test Filters with the injected Service\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/grails-unit-test-filters-with-the-injected-service\\\/#listItem\",\"position\":3,\"name\":\"Grails Unit Test Filters with the injected Service\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/grails\\\/#listItem\",\"name\":\"Grails\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\",\"name\":\"TO THE NEW Blog\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/neha\\\/#author\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/neha\\\/\",\"name\":\"Neha Gupta\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/grails-unit-test-filters-with-the-injected-service\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a14fd5f9979fd5d8e3de87e89b59b2b233ac8e0851b1f5bd242c19c508895c65?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Neha Gupta\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/grails-unit-test-filters-with-the-injected-service\\\/#webpage\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/grails-unit-test-filters-with-the-injected-service\\\/\",\"name\":\"Grails Unit Test Filters with the injected Service | TO THE NEW Blog\",\"description\":\"Recently I was writing unit tests for a filter in my project, which makes use of a service. Normally mocking using 'metaclass' and 'demand' doesn't work for services in filter, because filters don't let mock the service methods like we do in other classes or controller. Suppose we have a filter like: [java] class SomeFilters\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/grails-unit-test-filters-with-the-injected-service\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/neha\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/neha\\\/#author\"},\"datePublished\":\"2014-08-04T16:37:17+05:30\",\"dateModified\":\"2016-12-19T14:54:46+05:30\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\",\"name\":\"TO THE NEW Blog\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Grails Unit Test Filters with the injected Service | TO THE NEW Blog","description":"Recently I was writing unit tests for a filter in my project, which makes use of a service. Normally mocking using 'metaclass' and 'demand' doesn't work for services in filter, because filters don't let mock the service methods like we do in other classes or controller. Suppose we have a filter like: [java] class SomeFilters","canonical_url":"https:\/\/www.tothenew.com\/blog\/grails-unit-test-filters-with-the-injected-service\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.tothenew.com\/blog\/grails-unit-test-filters-with-the-injected-service\/#article","name":"Grails Unit Test Filters with the injected Service | TO THE NEW Blog","headline":"Grails Unit Test Filters with the injected Service","author":{"@id":"https:\/\/www.tothenew.com\/blog\/author\/neha\/#author"},"publisher":{"@id":"https:\/\/www.tothenew.com\/blog\/#organization"},"datePublished":"2014-08-04T16:37:17+05:30","dateModified":"2016-12-19T14:54:46+05:30","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/www.tothenew.com\/blog\/grails-unit-test-filters-with-the-injected-service\/#webpage"},"isPartOf":{"@id":"https:\/\/www.tothenew.com\/blog\/grails-unit-test-filters-with-the-injected-service\/#webpage"},"articleSection":"Grails, Injected Service"},{"@type":"BreadcrumbList","@id":"https:\/\/www.tothenew.com\/blog\/grails-unit-test-filters-with-the-injected-service\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog#listItem","position":1,"name":"Home","item":"https:\/\/www.tothenew.com\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog\/category\/grails\/#listItem","name":"Grails"}},{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog\/category\/grails\/#listItem","position":2,"name":"Grails","item":"https:\/\/www.tothenew.com\/blog\/category\/grails\/","nextItem":{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog\/grails-unit-test-filters-with-the-injected-service\/#listItem","name":"Grails Unit Test Filters with the injected Service"},"previousItem":{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog\/grails-unit-test-filters-with-the-injected-service\/#listItem","position":3,"name":"Grails Unit Test Filters with the injected Service","previousItem":{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog\/category\/grails\/#listItem","name":"Grails"}}]},{"@type":"Organization","@id":"https:\/\/www.tothenew.com\/blog\/#organization","name":"TO THE NEW Blog","url":"https:\/\/www.tothenew.com\/blog\/"},{"@type":"Person","@id":"https:\/\/www.tothenew.com\/blog\/author\/neha\/#author","url":"https:\/\/www.tothenew.com\/blog\/author\/neha\/","name":"Neha Gupta","image":{"@type":"ImageObject","@id":"https:\/\/www.tothenew.com\/blog\/grails-unit-test-filters-with-the-injected-service\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/a14fd5f9979fd5d8e3de87e89b59b2b233ac8e0851b1f5bd242c19c508895c65?s=96&d=mm&r=g","width":96,"height":96,"caption":"Neha Gupta"}},{"@type":"WebPage","@id":"https:\/\/www.tothenew.com\/blog\/grails-unit-test-filters-with-the-injected-service\/#webpage","url":"https:\/\/www.tothenew.com\/blog\/grails-unit-test-filters-with-the-injected-service\/","name":"Grails Unit Test Filters with the injected Service | TO THE NEW Blog","description":"Recently I was writing unit tests for a filter in my project, which makes use of a service. Normally mocking using 'metaclass' and 'demand' doesn't work for services in filter, because filters don't let mock the service methods like we do in other classes or controller. Suppose we have a filter like: [java] class SomeFilters","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/www.tothenew.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/www.tothenew.com\/blog\/grails-unit-test-filters-with-the-injected-service\/#breadcrumblist"},"author":{"@id":"https:\/\/www.tothenew.com\/blog\/author\/neha\/#author"},"creator":{"@id":"https:\/\/www.tothenew.com\/blog\/author\/neha\/#author"},"datePublished":"2014-08-04T16:37:17+05:30","dateModified":"2016-12-19T14:54:46+05:30"},{"@type":"WebSite","@id":"https:\/\/www.tothenew.com\/blog\/#website","url":"https:\/\/www.tothenew.com\/blog\/","name":"TO THE NEW Blog","inLanguage":"en-US","publisher":{"@id":"https:\/\/www.tothenew.com\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"TO THE NEW BLOG","og:type":"blog","og:title":"Grails Unit Test Filters with the injected Service | TO THE NEW Blog","og:description":"Recently I was writing unit tests for a filter in my project, which makes use of a service. Normally mocking using 'metaclass' and 'demand' doesn't work for services in filter, because filters don't let mock the service methods like we do in other classes or controller. Suppose we have a filter like: [java] class SomeFilters","og:url":"https:\/\/www.tothenew.com\/blog\/grails-unit-test-filters-with-the-injected-service\/","og:image":"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","og:image:secure_url":"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","twitter:card":"summary","twitter:site":"@tothenew","twitter:title":"Grails Unit Test Filters with the injected Service | TO THE NEW Blog","twitter:description":"Recently I was writing unit tests for a filter in my project, which makes use of a service. Normally mocking using 'metaclass' and 'demand' doesn't work for services in filter, because filters don't let mock the service methods like we do in other classes or controller. Suppose we have a filter like: [java] class SomeFilters","twitter:image":"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png"},"aioseo_meta_data":{"post_id":"15166","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"created":"2021-04-29 17:10:46","updated":"2024-02-29 09:14:25","focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.tothenew.com\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.tothenew.com\/blog\/category\/grails\/\" title=\"Grails\">Grails<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tGrails Unit Test Filters with the injected Service\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/www.tothenew.com\/blog"},{"label":"Grails","link":"https:\/\/www.tothenew.com\/blog\/category\/grails\/"},{"label":"Grails Unit Test Filters with the injected Service","link":"https:\/\/www.tothenew.com\/blog\/grails-unit-test-filters-with-the-injected-service\/"}],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/15166","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/115"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=15166"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/15166\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=15166"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=15166"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=15166"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}